Oh don't refer to that tutorial ever again, it was written when I sucked at ASM 

dcb "INIT" JSR SUB_HORZ_POS TYA STA $157C,x RTL dcb "MAIN" PHB ;\ PHK ; | Change the data bank to the one our code is running from. PLB ; | This is a good practice. JSR SpriteCode ; | Jump to the sprite's function. PLB ; | Restore old data bank. RTL ;/ And return. ;=================================== ;Sprite Function ;=================================== RETURN: RTS SpriteCode: JSR Graphics LDA $14C8,x ;\ CMP #$08 ; | If sprite dead, BNE RETURN ;/ Return. LDA $9D ;\ BNE RETURN ;/ If locked, return. ;sprites coding below LDA $94 STA $E4,x LDA $95 STA $14E0,x LDA $96 SEC SBC #$10 STA $D8,x LDA $97 STA $14D4,x ;sprites coding above JSR SUB_OFF_SCREEN_X0 ; Handle offscreen. RTS ;=================================== ;Graphics Code ;=================================== PROPERTIES: dcb $80,$00 TILEMAP: dcb $00,$02 YDISP: dcb $10,$00 Graphics: JSR GET_DRAW_INFO ; Before actually coding the graphics, we need a routine that will get the current sprite's value ; into the OAM. ; The OAM being a place where the tile data for the current sprite will be stored. LDA $157C,x STA $02 ; Store direction to $02 for use with property routine later. PHX ;\ Push the sprite index, since we're using it for a loop. LDX #$01 ;/ X = number of times to loop through. Since we only draw one MORE tile, loop one more time. Loop: LDA $00 ;\ STA $0300,y ;/ Draw the X position of the sprite LDA $01 ;\ SEC ; | Y displacement is added for the Y position, so one tile is higher than the other. SBC YDISP,x ; | Otherwise, both tiles would have been drawn to the same position! STA $0301,y ; | If X is 00, i.e. first tile, then load the first value from the table and apply that ;/ as the displacement. For the second tile, F0 is added to make it higher than the first. LDA TILEMAP,x ; X still contains index for the tile to draw. If it's the first tile, draw first tile in STA $0302,y ; the table. If X = 01, i.e. second tile, draw second tile in the table. PHX ; Push number of times to go through loop (01), because we're using it for a table here. LDX $02 ;\ LDA PROPERTIES,x ; | Set properties based on direction. ORA $64 STA $0303,y ;/ PLX ; Pull number of times to go through loop. INY ;\ INY ; | The OAM is 8x8, but our sprite is 16x16 .. INY ; | So increment it 4 times. INY ;/ DEX ; After drawing this tile, decrease number of tiles to go through loop. If the second tile ; is drawn, then loop again to draw the first tile. BPL Loop ; Loop until X becomes negative (FF). PLX ; Pull back the sprite index! We pushed it at the beginning of the routine. LDY #$02 ; Y ends with the tile size .. 02 means it's 16x16 LDA #$01 ; A -> number of tiles drawn - 1. ; I drew 2 tiles, so 2-1 = 1. A = 01. JSL $01B7B3 ; Call the routine that draws the sprite. RTS ; Never forget this!
LDA #(number of cloud tile, which i am too lazy to look up at the moment) ;\ STA $0302,y ;/ Tile to draw. This is currently tile 24. ; NOTE: The tile is the upper-left tile of the 16x16 tile you want to draw LDA #$06 ORA $64 STA $0303,y ; Write the YXPPCCCT property byte of the sprite ; See this part of the tutorial again for more info INY ;\ INY ; | The OAM is 8x8, but our sprite is 16x16 .. INY ; | So increment it 4 times. INY ;/ LDY #$02 ; Y ends with the tile size .. 02 means it's 16x16 LDA #$00 ; A -> number of tiles drawn - 1. ; I drew only 1 tile so I put in 1-1 = 00. JSL $01B7B3 ; Call the routine that draws the sprite. RTS ; Never forget this!
SBC $1A ; | mark sprite invalid if far enough off screen
TILEMAP dcb $60,$60,$64,$8A,$60,$60,$AC,$AC,$AC,$CE
TILEMAP dcb $60,$60,$64,$8A,$60,$60,$AC,$AC,$AC,$CE