!FrameNum = $1510 !TempDir = $02 !TilePointerTemp = $05 ;\16 bit !SizePointerTemp = $07 ;| !XOffPointerTemp = $09 ;| !YOffPointerTemp = $0B ;/ !TileSizeTemp = $0D !TilesNumTemp = $0E !MiscTemp = $0F TileMap: Standing: db $6A,$6B,$6C,$67,$68,$69,$64,$65,$66,$FF ;Standing Walking1: db $10,$12,$01,$02,$03,$FF ;Walking1 Walking2: db $04,$06,$24,$25,$26,$FF ;Walking2 Walking3: db $08,$0A,$29,$2A,$2B,$FF ;Walking3 Walking4: db $0C,$0E,$2D,$2E,$2F,$FF ;Walking4 Slashing1: db $30,$32,$50,$52,$FF ;Slashing1 Slashing2: db $34,$36,$54,$55,$56,$57,$FF ;Slashing2 Slashing3: db $38,$3A,$58,$59,$5A,$5B,$FF ;Slashing3 Dieing: db $3C,$3E,$5D,$5C,$5F,$6F,$FF ;Dieing TileNumbers: db $08,$04,$04,$04,$04,$03,$05,$05,$05 TilesSizes: StandingS: db $00,$00,$00,$00,$00,$00,$00,$00,$00 Walking1S: db $02,$02,$00,$00,$00 Walking2S: db $02,$02,$00,$00,$00 Walking3S: db $02,$02,$00,$00,$00 Walking4S: db $02,$02,$00,$00,$00 Slashing1S: db $02,$02,$02,$02 Slashing2S: db $02,$02,$00,$00,$00,$00 Slashing3S: db $02,$02,$00,$00,$00,$00 DieingS: db $02,$02,$02,$00,$00,$00 XOffsets: StandingX: db $F8,$00,$08,$F8,$00,$08,$F8,$00,$08 Walking1X: db $F0,$00,$00,$08,$0F Walking2X: db $F0,$00,$F8,$00,$08 Walking3X: db $F0,$00,$F8,$00,$08, Walking4X: db $F0,$00,$F8,$00,$08 Slashing1X: db $F0,$00,$F0,$00 Slashing2X: db $F0,$00,$F0,$F8,$00,$08 Slashing3X: db $F0,$00,$F0,$F8,$00,$08 DieingX: db $F0,$00,$F8,$F0,$08,$08 YOffsets: StandingY: db $08,$08,$08,$00,$00,$00,$F8,$F8,$F8 Walking1Y: db $00,$00,$F8,$F8,$F8 Walking2Y: db $F8,$F8,$08,$08,$08 Walking3Y: db $F8,$F8,$08,$08,$08 Walking4Y: db $F8,$F8,$08,$08,$08 Slashing1Y: db $F8,$F8,$08,$08 Slashing2Y: db $F8,$F8,$08,$08,$08,$08 Slashing3Y: db $F8,$F8,$08,$08,$08,$08 DieingY: db $F8,$F8,$08,$08,$08,$0F SUB_GFX: JSR GET_DRAW_INFO ; after: Y = index to sprite OAM ($300) ; $00 = sprite x position relative to screen boarder ; $01 = sprite y position relative to screen boarder LDA $157C,x ; $02 = sprite direction STA !TempDir STZ !TilesNumTemp PHX ;Sprite Index JSR GetPointers LDX #$00 PHY ;OAM Index TXY LDA (!SizePointerTemp),y PLY ;OAM Index STA !TileSizeTemp TileLoop: PHY ;OAM Index TXY LDA (!TilePointerTemp),y CMP #$FF BNE NotEndIt JMP EndIt NotEndIt: PLY ;OAM Index LDA !TempDir BEQ left PHY ;OAM Index TXY LDA $00 CLC ADC (!XOffPointerTemp),y PLY ;OAM Index BRA storeX left: PHY ;OAM Index TXY LDA $00 SEC SBC (!XOffPointerTemp),y PLY ;OAM Index storeX: STA $0300,y LDA $01 PHY ;OAM Index TXY CLC ADC (!YOffPointerTemp),y PLY ;OAM Index STA $0301,y PHY ;OAM Index TXY LDA (!TilePointerTemp),y PLY ;OAM Index STA $0302,y STX !MiscTemp PLX ;Sprite Index LDA $15F6,x PHX ;Sprite Index LDX !MiscTemp PHX ;Tile Index LDX !TempDir BNE NotFlip ORA #$40 NotFlip: ORA $64 ; add in tile priority of level STA $0303,y ; store tile properties PHY ;OAM Index LDY $15E9 LDX !FrameNum,y LDA TileNumbers,x CMP !TilesNumTemp BEQ Cont PLY ;OAM Index PLX ;Tile Index PHY ;OAM Index TXY INY LDA (!SizePointerTemp),y CMP !TileSizeTemp BEQ NotDif PLY ;OAM Index PHX ;Tile Index PHY ;OAM Index JMP DrawTiles NotDif: PLY PHX PHY Cont: PLY ;OAM Index PLX INC !TilesNumTemp ContinueLoop: INY INY INY INY INX BRA TileLoop DrawTiles: LDY !TileSizeTemp ; #$02 means the tiles are 16x16 LDA !TilesNumTemp ; This means we drew two tiles PHX ;Tile Index JSL $01B7B3 PLX ;TileIndex STZ !TilesNumTemp TXY INY LDA (!SizePointerTemp),y STA !TileSizeTemp JSR GetPointers PLY ;OAM Index PLX BRA ContinueLoop EndIt: LDY !TileSizeTemp ; #$02 means the tiles are 16x16 LDA !TilesNumTemp ; This means we drew two tiles JSL $01B7B3 PLY ;OAM Index PLX ;Sprite Index RTS GetPointers: PHX PHY PHA LDX $15E9 LDA !FrameNum,x ASL A TAX REP #$20 LDA TilePointers,x STA !TilePointerTemp LDA SizePointers,x STA !SizePointerTemp LDA XOffPointers,x STA !XOffPointerTemp LDA YOffPointers,x STA !YOffPointerTemp SEP #$20 PLA PLY PLX RTS TilePointers: dw Standing dw Walking1 dw Walking2 dw Walking3 dw Walking4 dw Slashing1 dw Slashing2 dw Slashing3 dw Dieing SizePointers: dw StandingS dw Walking1S dw Walking2S dw Walking3S dw Walking4S dw Slashing1S dw Slashing2S dw Slashing3S dw DieingS XOffPointers: dw StandingX dw Walking1X dw Walking2X dw Walking3X dw Walking4X dw Slashing1X dw Slashing2X dw Slashing3X dw DieingX YOffPointers: dw StandingY dw Walking1Y dw Walking2Y dw Walking3Y dw Walking4Y dw Slashing1Y dw Slashing2Y dw Slashing3Y dw DieingY