Routines |
Prev: 61336 | Up: Map | Next: 61710 |
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 | 61408 | XOR A | A=0 (building data offset). | |
Handler_Buildings_Loop | 61409 | PUSH AF | Stash the building data offset on the stack. | |
61410 | LD D,0 | Create an offset using DE. | ||
61412 | LD E,A | |||
61413 | LD HL,54175 | IX=Table_Buildings+building data offset. | ||
61416 | ADD HL,DE | |||
61417 | PUSH HL | |||
61418 | POP IX | |||
61420 | LD A,(IX+0) | A=building state (*IX+0). | ||
61423 | CP 2 | Jump to Handler_BuildingCrumbling if A is equal to 2 (crumbling). | ||
61425 | JR Z,Handler_BuildingCrumbling | |||
61427 | CP 3 | Jump to Handler_BuildingCollapsing if A is equal to 3. | ||
61429 | JP Z,Handler_BuildingCollapsing | |||
61432 | CP 4 | Jump to Handler_BuildingRubble if A is equal to 4 | ||
61434 | JP Z,Handler_BuildingRubble | |||
Handler_Buildings_Next | 61437 | POP AF | Restore the building data offset from the stack. | |
61438 | ADD A,14 | Move onto the next set of building data (offset+14). | ||
Have we accounted for all the buildings?
|
||||
61440 | CP 84 | Jump to Handler_Buildings_Loop until A is equal to 84. | ||
61442 | JR NZ,Handler_Buildings_Loop | |||
61444 | RET | Return. | ||
Handle the building crumbling.
|
||||
Handler_BuildingCrumbling | 61445 | DEC (IX+13) | Decrease *IX+13 by one. | |
61448 | JP NZ,Sounds_BuildingCrumbling | Jump to Sounds_BuildingCrumbling until *IX+13 is zero. | ||
61451 | LD (IX+13),2 | Write 2 to *IX+13. | ||
61455 | DEC (IX+10) | Decrease "crumbling countdown" (*IX+10) by one. | ||
61458 | JR NZ,Animate_Crumbling | Jump to Animate_Crumbling until "crumbling countdown" (*IX+10) is zero. | ||
61460 | LD (IX+0),3 | Write "collapsing" (3) to building state (*IX+0). | ||
61464 | LD A,(IX+5) | A=*IX+5. | ||
61467 | INC A | Increment A by one. | ||
61468 | LD (IX+11),A | Write A to "collapsing countdown" (*IX+11). | ||
61471 | LD C,7 | C=7. | ||
61473 | LD A,(IX+7) | A=*IX+7. | ||
61476 | RRCA | Rotate A right one position, setting the carry flag if bit 0 was set. | ||
61477 | JR NC,Handler_Buildings_0 | Jump to Handler_Buildings_0 if the carry flag is not set. | ||
61479 | LD C,56 | C=56. | ||
Handler_Buildings_0 | 61481 | LD E,(IX+1) | E=*IX+1. | |
61484 | LD B,(IX+6) | B=Building width (*IX+6). | ||
61487 | LD HL,54047 | HL=54047+DE. | ||
61490 | ADD HL,DE | |||
Handler_Buildings_1 | 61491 | LD A,(HL) | A=*HL. | |
61492 | AND C | Merge the bits from C. | ||
61493 | LD (HL),A | Write A to *HL. | ||
61494 | INC HL | Increment HL by one. | ||
61495 | DJNZ Handler_Buildings_1 | Decrease counter by one and loop back to Handler_Buildings_1 until counter is zero. | ||
61497 | JP Handler_BuildingRubble | Jump to Handler_BuildingRubble. | ||
Animate_Crumbling | 61500 | LD L,(IX+10) | L=Crumbling countdown (*IX+10). | |
61503 | CALL Handler_Buildings_10 | Call Handler_Buildings_10. | ||
61506 | LD E,L | E=L. | ||
61507 | LD B,(IX+6) | B=Building width (*IX+6). | ||
61510 | LD C,255 | C=255. | ||
Handler_Buildings_2 | 61512 | LD A,(HL) | A=*HL. | |
61513 | OR %10000000 | Set bit 7. | ||
61515 | LD (HL),A | Write A to *HL. | ||
61516 | LD A,C | A=C. | ||
61517 | LD (DE),A | Write A to *DE. | ||
61518 | INC HL | Increment HL by one. | ||
61519 | INC DE | Increment DE by one. | ||
61520 | 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 | 61522 | LD A,9 | Write melody ID 9 to *MelodyID. | |
61524 | LD (65421),A | |||
61527 | JP Handler_BuildingRubble | Jump to Handler_BuildingRubble. | ||
Handler_BuildingCollapsing | 61530 | DEC (IX+13) | Decrease *IX+13 by one. | |
61533 | JR NZ,Handler_BuildingRubble | Jump to Handler_BuildingRubble until *IX+13 is zero. | ||
Plays a single building "collapsing" sound, the handler looping will keep it going until it's fallen and done.
|
||||
61535 | LD A,8 | Write melody ID 8 to *MelodyID. | ||
61537 | LD (65421),A | |||
61540 | LD (IX+13),2 | Write 2 to *IX+13. | ||
61544 | DEC (IX+11) | Decrease "collapsing countdown" (*IX+11) by one. | ||
61547 | JR NZ,Handler_Buildings_3 | Jump to Handler_Buildings_3 until "collapsing countdown" (*IX+11) is zero. | ||
61549 | LD (IX+0),4 | Write "rubble" (4) to building state (*IX+0). | ||
61553 | JR Handler_BuildingRubble | Jump to Handler_BuildingRubble. | ||
Handler_Buildings_3 | 61555 | LD L,(IX+5) | L=*IX+5. | |
61558 | DEC L | Decrease L by one. | ||
61559 | CALL Handler_Buildings_10 | Call Handler_Buildings_10. | ||
61562 | ADD A,32 | A+=32. | ||
61564 | LD E,A | E=A. | ||
61565 | LD B,(IX+11) | B=Collapsing countdown (*IX+11). | ||
Handler_Buildings_4 | 61568 | PUSH BC | Stash BC, HL and DE (twice) on the stack. | |
61569 | PUSH HL | |||
61570 | PUSH DE | |||
61571 | PUSH DE | |||
61572 | LD D,H | D=H. | ||
61573 | LD E,L | E=L. | ||
61574 | LD BC,32 | HL+=0032. | ||
61577 | ADD HL,BC | |||
61578 | LD B,(IX+6) | B=Building width (*IX+6). | ||
Handler_Buildings_5 | 61581 | LD A,(DE) | A=*DE. | |
61582 | LD (HL),A | Write A to *HL. | ||
61583 | INC E | Increment E by one. | ||
61584 | INC L | Increment L by one. | ||
61585 | DJNZ Handler_Buildings_5 | Decrease counter by one and loop back to Handler_Buildings_5 until counter is zero. | ||
61587 | POP HL | Restore HL from the stack. | ||
61588 | LD B,(IX+6) | B=Building width (*IX+6). | ||
61591 | LD C,255 | Write 255 to *HL. | ||
Handler_Buildings_6 | 61593 | LD (HL),C | ||
61594 | INC HL | Increment HL by one. | ||
61595 | DJNZ Handler_Buildings_6 | Decrease counter by one and loop back to Handler_Buildings_6 until counter is zero. | ||
61597 | LD BC,32 | BC=0032. | ||
61600 | POP HL | Restore HL from the stack. | ||
61601 | AND A | Set flags. | ||
61602 | SBC HL,BC | HL-=BC. | ||
61604 | EX DE,HL | Exchange the DE register with the shadow HL register. | ||
61605 | POP HL | Restore HL from the stack. | ||
61606 | SBC HL,BC | HL-=BC. | ||
61608 | POP BC | Restore BC from the stack. | ||
61609 | DJNZ Handler_Buildings_4 | Decrease counter by one and loop back to Handler_Buildings_4 until counter is zero. | ||
Self-modifying code.
|
||||
Handler_BuildingRubble | 61611 | XOR A | Write 0 to *Handler_Buildings_8. | |
61612 | LD (61661),A | |||
61615 | DEC (IX+12) | Decrease *IX+12 by one. | ||
61618 | JR NZ,Handler_Buildings_7 | Jump to Handler_Buildings_7 until *IX+12 is zero. | ||
The whole animation is finished so set the state to "gone" and decrease the active buildings count.
|
||||
61620 | LD (IX+0),5 | Write "gone" (5) to building state (*IX+0). | ||
61624 | LD A,(54259) | Decrease *BuildingsRemainingCount by one. | ||
61627 | DEC A | |||
61628 | LD (54259),A | |||
Self-modifying code.
|
||||
61631 | LD A,175 | Write 175 (XOR A) to *Handler_Buildings_8. | ||
61633 | LD (61661),A | |||
Handler_Buildings_7 | 61636 | LD L,(IX+5) | L=*IX+5. | |
61639 | DEC L | Decrease L by one. | ||
61640 | CALL Handler_Buildings_10 | Call Handler_Buildings_10. | ||
61643 | ADD A,32 | A+=32. | ||
61645 | LD L,A | L=A. | ||
61646 | LD E,A | E=A. | ||
61647 | LD B,(IX+6) | B=Building width (*IX+6). | ||
61650 | EX DE,HL | Exchange the DE register with the shadow HL register. | ||
61651 | LD A,(IX+12) | A=*IX+12. | ||
61654 | AND %00000001 | Keep only bit 0. | ||
61656 | ADD A,A | A*=8. | ||
61657 | ADD A,A | |||
61658 | ADD A,A | |||
61659 | ADD A,68 | A+=68. | ||
Handler_Buildings_8 | 61661 | NOP | No operation OR A=0 depending on the above. | |
61662 | LD (HL),255 | Write 255 to *HL. | ||
61664 | LD (DE),A | Write A to *DE. | ||
61665 | INC L | Increment L by one. | ||
61666 | INC E | Increment E by one. | ||
61667 | INC A | Increment A by one. | ||
61668 | CP 77 | Jump to Handler_Buildings_9 if A is not equal to 77. | ||
61670 | JR NZ,Handler_Buildings_9 | |||
61672 | LD A,68 | A=68. | ||
Handler_Buildings_9 | 61674 | DJNZ Handler_Buildings_8 | Decrease counter by one and loop back to Handler_Buildings_8 until counter is zero. | |
61676 | JP Handler_Buildings_Next | Jump to Handler_Buildings_Next. | ||
Handler_Buildings_10 | 61679 | LD H,0 | H=0. | |
61681 | DEC L | Decrease L by one. | ||
61682 | ADD HL,HL | HL*=32. | ||
61683 | ADD HL,HL | |||
61684 | ADD HL,HL | |||
61685 | ADD HL,HL | |||
61686 | ADD HL,HL | |||
61687 | LD E,(IX+3) | E=*IX+3. | ||
61690 | LD D,(IX+4) | D=*IX+4. | ||
61693 | ADD HL,DE | HL+=DE. | ||
61694 | LD A,(IX+7) | A=*IX+7. | ||
61697 | LD B,A | B=95+(B*3). | ||
61698 | ADD A,A | |||
61699 | ADD A,B | |||
61700 | ADD A,95 | |||
61702 | LD B,A | |||
61703 | LD A,H | D=104+H-B | ||
61704 | SUB B | |||
61705 | ADD A,104 | |||
61707 | LD D,A | |||
61708 | LD A,L | A=L. | ||
61709 | RET | Return. |
Prev: 61336 | Up: Map | Next: 61710 |