Routines |
Prev: DE51 | Up: Map | Next: DF58 |
Used by the routine at F801.
|
||||
Draw_Tile | DE69 | LD IX,$DF58 | Set IX to Table_TileDataOffsets. | |
DE6D | LD B,$00 | Initialise B to 00 for the sum below. | ||
DE6F | LD A,($E2C7) | Load *Item_ID into A. | ||
Find which spritesheet the image is located in. There are 14 sprites in each sheet, so test if the sprite ID is less than 15 to check if it's in the first one. Else, subtract 14 and check again.
|
||||
DE72 | LD C,$03 | Set a counter in C with 03 to track the three spritesheets (two item sheets and one for the game tiles). | ||
FindSpritesheet_Loop | DE74 | CP $15 | Jump to LocateSprite if A is lower than 15 (unsigned comparison). | |
DE76 | JP M,LocateSprite | |||
DE79 | SUB $14 | Subtract 14 from A. | ||
DE7B | DEC C | Decrease C by one. | ||
DE7C | JR NZ,FindSpritesheet_Loop | Jump back to FindSpritesheet_Loop until C is zero. | ||
Default the sprite ID to 01.
|
||||
DE7E | LD A,$01 | A=01. | ||
Adjust the sprite ID for 0-based indexing.
|
||||
LocateSprite | DE80 | DEC A | Decrease the sprite ID by one. | |
There are 04 offset bytes, so multiply the sprite ID by 04 to find the relevant offsets in the table.
|
||||
DE81 | RLCA | Multiply the sprite ID by 04 and store the result in C. | ||
DE82 | RLCA | |||
DE83 | LD C,A | |||
Fetch the offsets for the sprite being processed.
|
||||
DE84 | ADD IX,BC | Add the result to IX to locate the offsets for the tile. | ||
DE86 | LD C,(IX+$00) | Fetch the graphic data offset and store it in BC. | ||
DE89 | LD B,(IX+$01) | |||
DE8C | LD E,(IX+$02) | Fetch the attribute data offset and store it in DE. | ||
DE8F | LD D,(IX+$03) | |||
Calculate the graphic data address.
|
||||
DE92 | LD IX,($E2C8) | Add *Item_SpriteBank and the offset in BC to locate the start of the graphics data - store the result in IX. | ||
DE96 | ADD IX,BC | |||
Calculate the attribute address.
|
||||
DE98 | LD HL,($E2C8) | Add *Item_SpriteBank and 0A00 to locate the start of the attributes for the spritesheet. Then, add the offset held in DE to the total, this will locate the start of the attributes for the sprite currently being processed - store the result in IY (using the stack). | ||
DE9B | LD BC,$0A00 | |||
DE9E | ADD HL,BC | |||
DE9F | ADD HL,DE | |||
DEA0 | PUSH HL | |||
DEA1 | POP IY | |||
Print the sprite to the screen.
|
||||
DEA3 | LD B,$04 | B=04. | ||
DEA5 | LD H,$28 | H=28. | ||
Draw_Tile_0 | DEA7 | PUSH BC | Stash BC on the stack. | |
DEA8 | LD A,$08 | A=08. | ||
DEAA | PUSH IX | Stash IX on the stack. | ||
DEAC | LD BC,$0014 | BC=0014. | ||
Draw_Tile_1 | DEAF | PUSH AF | Stash AF on the stack. | |
DEB0 | LD L,A | L=A. | ||
DEB1 | CALL CalculateScreenAddress | Call CalculateScreenAddress. | ||
DEB4 | LD A,(IX+$00) | Write *IX+00 to *DE. | ||
DEB7 | LD (DE),A | |||
DEB8 | ADD IX,BC | IX+=BC. | ||
DEBA | POP AF | Restore AF from the stack. | ||
DEBB | INC A | Increment A by one. | ||
DEBC | CP $28 | Jump to Draw_Tile_1 if A is not equal to 28. | ||
DEBE | JP NZ,Draw_Tile_1 | |||
Switch IX to point to the attributes.
|
||||
DEC1 | PUSH IY | IX=IY (using the stack). | ||
DEC3 | POP IX | |||
DEC5 | LD DE,$5825 | DE=5825 (attribute buffer location). | ||
DEC8 | LD B,$04 | B=04. | ||
DECA | PUSH HL | Stash HL on the stack. | ||
Colour_Tile_Loop | DECB | PUSH BC | Stash BC on the stack. | |
DECC | LD A,(IX+$00) | Write *IX+00 to *DE. | ||
DECF | LD (DE),A | |||
DED0 | LD BC,$0014 | IX+=0014. | ||
DED3 | ADD IX,BC | |||
DED5 | LD HL,$0020 | DE+=0020. | ||
DED8 | ADD HL,DE | |||
DED9 | EX DE,HL | |||
DEDA | POP BC | Restore BC from the stack. | ||
DEDB | DJNZ Colour_Tile_Loop | Decrease counter by one and loop back to Colour_Tile_Loop until counter is zero. | ||
DEDD | POP HL | Restore HL, IX and BC from the stack. | ||
DEDE | POP IX | |||
DEE0 | POP BC | |||
DEE1 | LD A,B | A=B. | ||
DEE2 | PUSH BC | Stash BC, IX and HL on the stack. | ||
DEE3 | PUSH IX | |||
DEE5 | PUSH HL | |||
DEE6 | CP $01 | Jump to Draw_Tile_7 if A is equal to 01. | ||
DEE8 | JP Z,Draw_Tile_7 | |||
DEEB | LD A,$05 | A=05. | ||
DEED | LD C,$23 | C=23. | ||
Draw_Tile_2 | DEEF | LD B,C | B=C. | |
DEF0 | SLA B | Shift B left (with carry). | ||
Draw_Tile_3 | DEF2 | DJNZ Draw_Tile_3 | Decrease counter by one and loop back to Draw_Tile_3 until counter is zero. | |
DEF4 | XOR %00010000 | Flip bit 4. | ||
DEF6 | OUT ($FE),A | Send to the speaker. | ||
DEF8 | DEC C | Decrease C by one. | ||
DEF9 | JP NZ,Draw_Tile_2 | Jump to Draw_Tile_2 until C is zero. | ||
DEFC | LD HL,$1388 | HL=1388. | ||
DEFF | LD DE,$04E2 | DE=04E2. | ||
Draw_Tile_4 | DF02 | LD A,(HL) | A=*HL. | |
DF03 | AND %11110000 | Keep only bits 4-7. | ||
DF05 | OR %00000101 | Set bits 0, 2. | ||
DF07 | OUT ($FE),A | Send to the speaker. | ||
DF09 | INC HL | Increment HL by one. | ||
DF0A | DEC DE | Decrease DE by one. | ||
DF0B | LD A,D | Jump to Draw_Tile_4 if DE is not zero. | ||
DF0C | OR E | |||
DF0D | JP NZ,Draw_Tile_4 | |||
DF10 | LD A,$01 | Write 01 to *Tile_Horizontal_Coordinate. | ||
DF12 | LD ($E75F),A | |||
DF15 | LD B,$04 | B=04. | ||
Draw_Tile_5 | DF17 | PUSH BC | Stash BC on the stack. | |
DF18 | LD A,($E75F) | B=*Tile_Horizontal_Coordinate. | ||
DF1B | LD B,A | |||
DF1C | LD C,$07 | C=07. | ||
DF1E | CALL Calculate_ScreenBlockAddress | Call Calculate_ScreenBlockAddress. | ||
DF21 | LD A,$08 | A=08. | ||
DF23 | PUSH HL | Stash HL on the stack. | ||
Draw_Tile_6 | DF24 | LD BC,$0003 | BC=0003. | |
DF27 | PUSH HL | DE=HL (using the stack). | ||
DF28 | POP DE | |||
DF29 | INC DE | Increment DE by one. | ||
DF2A | PUSH HL | Stash HL on the stack. | ||
DF2B | LDDR | LDDR. | ||
DF2D | INC HL | Increment HL by one. | ||
DF2E | LD (HL),C | Write C to *HL. | ||
DF2F | POP HL | Restore HL from the stack. | ||
DF30 | INC H | Increment H by one. | ||
DF31 | DEC A | Decrease A by one. | ||
DF32 | JP NZ,Draw_Tile_6 | Jump to Draw_Tile_6 until A is zero. | ||
DF35 | POP HL | Restore HL from the stack. | ||
DF36 | CALL Calculate_AttributeAddress | Call Calculate_AttributeAddress. | ||
DF39 | PUSH DE | HL=DE (using the stack). | ||
DF3A | POP HL | |||
DF3B | INC DE | Increment DE by one. | ||
DF3C | LD BC,$0003 | BC=0003. | ||
DF3F | LDDR | LDDR. | ||
DF41 | LD A,$00 | Write 00 to *DE. | ||
DF43 | LD (DE),A | |||
DF44 | LD HL,$E75F | HL=Tile_Horizontal_Coordinate. | ||
DF47 | INC (HL) | Increment *HL by one. | ||
DF48 | POP BC | Restore BC from the stack. | ||
DF49 | DJNZ Draw_Tile_5 | Decrease counter by one and loop back to Draw_Tile_5 until counter is zero. | ||
Draw_Tile_7 | DF4B | POP HL | Restore HL and IX from the stack. | |
DF4C | POP IX | |||
DF4E | DEC IX | Decrease IX by one. | ||
DF50 | DEC IY | Decrease IY by one. | ||
DF52 | POP BC | Restore BC from the stack. | ||
DF53 | DEC B | Decrease B by one. | ||
DF54 | JP NZ,Draw_Tile_0 | Jump to Draw_Tile_0 until B is zero. | ||
DF57 | RET | Return. |
Prev: DE51 | Up: Map | Next: DF58 |