![]() |
Routines |
| Prev: E791 | Up: Map | Next: E84A |
|
Used by the routine at Dispatch_Phase_One.
Subtracts *Slot_Subtract from each slot, then fills *New_Slot_Count new slots from *Write_Index using Random_Number.
|
||||
| Refresh_Slot_Table | E7B1 | LD A,($EF9D) | Fetch *Slot_Count. | |
| E7B4 | LD B,A | Copy the slot count to B. | ||
| E7B5 | LD IX,$5B00 | Point IX at Slot_Table. | ||
| E7B9 | LD DE,($EF85) | Fetch *Slot_Subtract. | ||
| E7BD | EXX | Set the slot stride to 06 in DE'. | ||
| E7BE | LD DE,$0006 | |||
| E7C1 | EXX | |||
|
Move every slot.
|
||||
| Refresh_Slot_Table_0 | E7C2 | LD L,(IX+$03) | Subtract *Slot_Subtract from the second word of this slot. | |
| E7C5 | LD H,(IX+$04) | |||
| E7C8 | AND A | |||
| E7C9 | SBC HL,DE | |||
| E7CB | LD (IX+$03),L | |||
| E7CE | LD (IX+$04),H | |||
| E7D1 | EXX | Advance to the next slot, and loop back to Refresh_Slot_Table_0 until all slots are processed. | ||
| E7D2 | ADD IX,DE | |||
| E7D4 | EXX | |||
| E7D5 | DJNZ Refresh_Slot_Table_0 | |||
|
Fill new slots from the write index.
|
||||
| E7D7 | LD IX,$5B00 | Point IX at Slot_Table. | ||
| E7DB | LD A,($EFA0) | Point IX at slot *Write_Index. | ||
| E7DE | ADD A,A | |||
| E7DF | LD E,A | |||
| E7E0 | ADD A,A | |||
| E7E1 | ADD A,E | |||
| E7E2 | LD E,A | |||
| E7E3 | LD D,$00 | |||
| E7E5 | ADD IX,DE | |||
| E7E7 | LD A,($EF9F) | Fetch *New_Slot_Count. | ||
| E7EA | LD B,A | Copy the new slot count to B. | ||
| E7EB | EX AF,AF' | Stash the new slot count in AF'. | ||
|
Fill one slot.
|
||||
| Refresh_Slot_Table_1 | E7EC | LD (IX+$00),$01 | Set the occupied flag. | |
| E7F0 | LD A,$3F | Call Random_Number and clamp the maximum value to 3F. | ||
| E7F2 | CALL Random_Number | |||
| E7F5 | LD L,A | Multiply the random value by 2C. | ||
| E7F6 | LD H,$00 | |||
| E7F8 | ADD HL,HL | |||
| E7F9 | ADD HL,HL | |||
| E7FA | PUSH HL | |||
| E7FB | ADD HL,HL | |||
| E7FC | PUSH HL | |||
| E7FD | ADD HL,HL | |||
| E7FE | ADD HL,HL | |||
| E7FF | POP DE | |||
| E800 | ADD HL,DE | |||
| E801 | POP DE | |||
| E802 | ADD HL,DE | |||
| E803 | PUSH HL | Stash the first word on the stack. | ||
| E804 | LD A,$3F | Call Random_Number and clamp the maximum value to 3F. | ||
| E806 | CALL Random_Number | |||
| E809 | POP HL | Restore the first word from the stack. | ||
| E80A | RR A | Jump to Refresh_Slot_Table_2 if bit 0 of the random value is reset. | ||
| E80C | JR NC,Refresh_Slot_Table_2 | |||
| E80E | LD A,L | Negate the first word. | ||
| E80F | CPL | |||
| E810 | LD L,A | |||
| E811 | LD A,H | |||
| E812 | CPL | |||
| E813 | LD H,A | |||
| E814 | INC HL | |||
| Refresh_Slot_Table_2 | E815 | LD (IX+$01),L | Write the first word to the slot. | |
| E818 | LD (IX+$02),H | |||
| E81B | LD (IX+$03),$80 | Write 0E80 to the second word. | ||
| E81F | LD (IX+$04),$0E | |||
| E823 | LD A,$0C | Call Random_Number and clamp the maximum value to 0C. | ||
| E825 | CALL Random_Number | |||
| E828 | SRA A | Halve the random value. | ||
| E82A | INC A | Increment the random value by one. | ||
| E82B | LD (IX+$05),A | Write the attribute to the slot. | ||
| E82E | EXX | Advance to the next slot, and loop back to Refresh_Slot_Table_1 until all new slots are filled. | ||
| E82F | ADD IX,DE | |||
| E831 | EXX | |||
| E832 | DJNZ Refresh_Slot_Table_1 | |||
|
Advance the write index, and wrap it.
|
||||
| E834 | EX AF,AF' | Copy the new slot count from AF' to C. | ||
| E835 | LD C,A | |||
| E836 | CP $01 | Compare the new slot count with 01. | ||
| E838 | LD E,$12 | Set the wrap limit to 12. | ||
| E83A | JR Z,Refresh_Slot_Table_3 | Jump to Refresh_Slot_Table_3 if the new slot count is 01. | ||
| E83C | LD E,$25 | Set the wrap limit to 25. | ||
| Refresh_Slot_Table_3 | E83E | LD A,($EFA0) | Fetch *Write_Index. | |
| E841 | ADD A,C | Add the new slot count. | ||
| E842 | CP E | Jump to Refresh_Slot_Table_4 if the write index is less than the wrap limit. | ||
| E843 | JR C,Refresh_Slot_Table_4 | |||
| E845 | XOR A | Clear the write index. | ||
| Refresh_Slot_Table_4 | E846 | LD ($EFA0),A | Write the write index to *Write_Index. | |
| E849 | RET | Return. | ||
| Prev: E791 | Up: Map | Next: E84A |