Routines |
Prev: EF98 | Up: Map | Next: F10E |
Used by the routine at RunHandlers.
|
||||
This isn't so much a counter; it's more an address offset to select each buildings data in turn.
|
||||
Handler_Buildings | EFE0 | XOR A | A=00 (building data offset). | |
Handler_Buildings_Loop | EFE1 | PUSH AF | Stash the building data offset on the stack. | |
EFE2 | LD D,$00 | Create an offset using DE. | ||
EFE4 | LD E,A | |||
EFE5 | LD HL,$D39F | IX=Table_Buildings+building data offset. | ||
EFE8 | ADD HL,DE | |||
EFE9 | PUSH HL | |||
EFEA | POP IX | |||
EFEC | LD A,(IX+$00) | A=building state (*IX+00). | ||
EFEF | CP $02 | Jump to Handler_BuildingCrumbling if A is equal to 02 (crumbling). | ||
EFF1 | JR Z,Handler_BuildingCrumbling | |||
EFF3 | CP $03 | Jump to Handler_BuildingCollapsing if A is equal to 03. | ||
EFF5 | JP Z,Handler_BuildingCollapsing | |||
EFF8 | CP $04 | Jump to Handler_BuildingRubble if A is equal to 04 | ||
EFFA | JP Z,Handler_BuildingRubble | |||
Handler_Buildings_Next | EFFD | POP AF | Restore the building data offset from the stack. | |
EFFE | ADD A,$0E | Move onto the next set of building data (offset+0E). | ||
Have we accounted for all the buildings?
|
||||
F000 | CP $54 | Jump to Handler_Buildings_Loop until A is equal to 54. | ||
F002 | JR NZ,Handler_Buildings_Loop | |||
F004 | RET | Return. | ||
Handle the building crumbling.
|
||||
Handler_BuildingCrumbling | F005 | DEC (IX+$0D) | Decrease *IX+0D by one. | |
F008 | JP NZ,Sounds_BuildingCrumbling | Jump to Sounds_BuildingCrumbling until *IX+0D is zero. | ||
F00B | LD (IX+$0D),$02 | Write 02 to *IX+0D. | ||
F00F | DEC (IX+$0A) | Decrease "crumbling countdown" (*IX+0A) by one. | ||
F012 | JR NZ,Animate_Crumbling | Jump to Animate_Crumbling until "crumbling countdown" (*IX+0A) is zero. | ||
F014 | LD (IX+$00),$03 | Write "collapsing" (03) to building state (*IX+00). | ||
F018 | LD A,(IX+$05) | A=*IX+05. | ||
F01B | INC A | Increment A by one. | ||
F01C | LD (IX+$0B),A | Write A to "collapsing countdown" (*IX+0B). | ||
F01F | LD C,$07 | C=07. | ||
F021 | LD A,(IX+$07) | A=*IX+07. | ||
F024 | RRCA | Rotate A right one position, setting the carry flag if bit 0 was set. | ||
F025 | JR NC,Handler_Buildings_0 | Jump to Handler_Buildings_0 if the carry flag is not set. | ||
F027 | LD C,$38 | C=38. | ||
Handler_Buildings_0 | F029 | LD E,(IX+$01) | E=*IX+01. | |
F02C | LD B,(IX+$06) | B=Building width (*IX+06). | ||
F02F | LD HL,$D31F | HL=D31F+DE. | ||
F032 | ADD HL,DE | |||
Handler_Buildings_1 | F033 | LD A,(HL) | A=*HL. | |
F034 | AND C | Merge the bits from C. | ||
F035 | LD (HL),A | Write A to *HL. | ||
F036 | INC HL | Increment HL by one. | ||
F037 | DJNZ Handler_Buildings_1 | Decrease counter by one and loop back to Handler_Buildings_1 until counter is zero. | ||
F039 | JP Handler_BuildingRubble | Jump to Handler_BuildingRubble. | ||
Animate_Crumbling | F03C | LD L,(IX+$0A) | L=Crumbling countdown (*IX+0A). | |
F03F | CALL Handler_Buildings_10 | Call Handler_Buildings_10. | ||
F042 | LD E,L | E=L. | ||
F043 | LD B,(IX+$06) | B=Building width (*IX+06). | ||
F046 | LD C,$FF | C=FF. | ||
Handler_Buildings_2 | F048 | LD A,(HL) | A=*HL. | |
F049 | OR %10000000 | Set bit 7. | ||
F04B | LD (HL),A | Write A to *HL. | ||
F04C | LD A,C | A=C. | ||
F04D | LD (DE),A | Write A to *DE. | ||
F04E | INC HL | Increment HL by one. | ||
F04F | INC DE | Increment DE by one. | ||
F050 | DJNZ Handler_Buildings_2 | Decrease counter by one and loop back to Handler_Buildings_2 until counter is zero. | ||
Plays a single building "crumbling" sound, the handler looping will keep it going until it's fallen and done.
|
||||
Sounds_BuildingCrumbling | F052 | LD A,$09 | Write melody ID 09 to *MelodyID. | |
F054 | LD ($FF8D),A | |||
F057 | JP Handler_BuildingRubble | Jump to Handler_BuildingRubble. | ||
Handler_BuildingCollapsing | F05A | DEC (IX+$0D) | Decrease *IX+0D by one. | |
F05D | JR NZ,Handler_BuildingRubble | Jump to Handler_BuildingRubble until *IX+0D is zero. | ||
Plays a single building "collapsing" sound, the handler looping will keep it going until it's fallen and done.
|
||||
F05F | LD A,$08 | Write melody ID 08 to *MelodyID. | ||
F061 | LD ($FF8D),A | |||
F064 | LD (IX+$0D),$02 | Write 02 to *IX+0D. | ||
F068 | DEC (IX+$0B) | Decrease "collapsing countdown" (*IX+0B) by one. | ||
F06B | JR NZ,Handler_Buildings_3 | Jump to Handler_Buildings_3 until "collapsing countdown" (*IX+0B) is zero. | ||
F06D | LD (IX+$00),$04 | Write "rubble" (04) to building state (*IX+00). | ||
F071 | JR Handler_BuildingRubble | Jump to Handler_BuildingRubble. | ||
Handler_Buildings_3 | F073 | LD L,(IX+$05) | L=*IX+05. | |
F076 | DEC L | Decrease L by one. | ||
F077 | CALL Handler_Buildings_10 | Call Handler_Buildings_10. | ||
F07A | ADD A,$20 | A+=20. | ||
F07C | LD E,A | E=A. | ||
F07D | LD B,(IX+$0B) | B=Collapsing countdown (*IX+0B). | ||
Handler_Buildings_4 | F080 | PUSH BC | Stash BC, HL and DE (twice) on the stack. | |
F081 | PUSH HL | |||
F082 | PUSH DE | |||
F083 | PUSH DE | |||
F084 | LD D,H | D=H. | ||
F085 | LD E,L | E=L. | ||
F086 | LD BC,$0020 | HL+=0020. | ||
F089 | ADD HL,BC | |||
F08A | LD B,(IX+$06) | B=Building width (*IX+06). | ||
Handler_Buildings_5 | F08D | LD A,(DE) | A=*DE. | |
F08E | LD (HL),A | Write A to *HL. | ||
F08F | INC E | Increment E by one. | ||
F090 | INC L | Increment L by one. | ||
F091 | DJNZ Handler_Buildings_5 | Decrease counter by one and loop back to Handler_Buildings_5 until counter is zero. | ||
F093 | POP HL | Restore HL from the stack. | ||
F094 | LD B,(IX+$06) | B=Building width (*IX+06). | ||
F097 | LD C,$FF | Write FF to *HL. | ||
Handler_Buildings_6 | F099 | LD (HL),C | ||
F09A | INC HL | Increment HL by one. | ||
F09B | DJNZ Handler_Buildings_6 | Decrease counter by one and loop back to Handler_Buildings_6 until counter is zero. | ||
F09D | LD BC,$0020 | BC=0020. | ||
F0A0 | POP HL | Restore HL from the stack. | ||
F0A1 | AND A | Set flags. | ||
F0A2 | SBC HL,BC | HL-=BC. | ||
F0A4 | EX DE,HL | Exchange the DE register with the shadow HL register. | ||
F0A5 | POP HL | Restore HL from the stack. | ||
F0A6 | SBC HL,BC | HL-=BC. | ||
F0A8 | POP BC | Restore BC from the stack. | ||
F0A9 | DJNZ Handler_Buildings_4 | Decrease counter by one and loop back to Handler_Buildings_4 until counter is zero. | ||
Self-modifying code.
|
||||
Handler_BuildingRubble | F0AB | XOR A | Write 00 to *Handler_Buildings_8. | |
F0AC | LD ($F0DD),A | |||
F0AF | DEC (IX+$0C) | Decrease *IX+0C by one. | ||
F0B2 | JR NZ,Handler_Buildings_7 | Jump to Handler_Buildings_7 until *IX+0C is zero. | ||
The whole animation is finished so set the state to "gone" and decrease the active buildings count.
|
||||
F0B4 | LD (IX+$00),$05 | Write "gone" (05) to building state (*IX+00). | ||
F0B8 | LD A,($D3F3) | Decrease *BuildingsRemainingCount by one. | ||
F0BB | DEC A | |||
F0BC | LD ($D3F3),A | |||
Self-modifying code.
|
||||
F0BF | LD A,$AF | Write AF (XOR A) to *Handler_Buildings_8. | ||
F0C1 | LD ($F0DD),A | |||
Handler_Buildings_7 | F0C4 | LD L,(IX+$05) | L=*IX+05. | |
F0C7 | DEC L | Decrease L by one. | ||
F0C8 | CALL Handler_Buildings_10 | Call Handler_Buildings_10. | ||
F0CB | ADD A,$20 | A+=20. | ||
F0CD | LD L,A | L=A. | ||
F0CE | LD E,A | E=A. | ||
F0CF | LD B,(IX+$06) | B=Building width (*IX+06). | ||
F0D2 | EX DE,HL | Exchange the DE register with the shadow HL register. | ||
F0D3 | LD A,(IX+$0C) | A=*IX+0C. | ||
F0D6 | AND %00000001 | Keep only bit 0. | ||
F0D8 | ADD A,A | A*=08. | ||
F0D9 | ADD A,A | |||
F0DA | ADD A,A | |||
F0DB | ADD A,$44 | A+=44. | ||
Handler_Buildings_8 | F0DD | NOP | No operation OR A=00 depending on the above. | |
F0DE | LD (HL),$FF | Write FF to *HL. | ||
F0E0 | LD (DE),A | Write A to *DE. | ||
F0E1 | INC L | Increment L by one. | ||
F0E2 | INC E | Increment E by one. | ||
F0E3 | INC A | Increment A by one. | ||
F0E4 | CP $4D | Jump to Handler_Buildings_9 if A is not equal to 4D. | ||
F0E6 | JR NZ,Handler_Buildings_9 | |||
F0E8 | LD A,$44 | A=44. | ||
Handler_Buildings_9 | F0EA | DJNZ Handler_Buildings_8 | Decrease counter by one and loop back to Handler_Buildings_8 until counter is zero. | |
F0EC | JP Handler_Buildings_Next | Jump to Handler_Buildings_Next. | ||
Handler_Buildings_10 | F0EF | LD H,$00 | H=00. | |
F0F1 | DEC L | Decrease L by one. | ||
F0F2 | ADD HL,HL | HL*=20. | ||
F0F3 | ADD HL,HL | |||
F0F4 | ADD HL,HL | |||
F0F5 | ADD HL,HL | |||
F0F6 | ADD HL,HL | |||
F0F7 | LD E,(IX+$03) | E=*IX+03. | ||
F0FA | LD D,(IX+$04) | D=*IX+04. | ||
F0FD | ADD HL,DE | HL+=DE. | ||
F0FE | LD A,(IX+$07) | A=*IX+07. | ||
F101 | LD B,A | B=5F+(B*03). | ||
F102 | ADD A,A | |||
F103 | ADD A,B | |||
F104 | ADD A,$5F | |||
F106 | LD B,A | |||
F107 | LD A,H | D=68+H-B | ||
F108 | SUB B | |||
F109 | ADD A,$68 | |||
F10B | LD D,A | |||
F10C | LD A,L | A=L. | ||
F10D | RET | Return. |
Prev: EF98 | Up: Map | Next: F10E |