Prev: 59281 Up: Map Next: 59466
59313: Refresh Slot Table
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 59313 LD A,(61341) Fetch *Slot_Count.
59316 LD B,A Copy the slot count to B.
59317 LD IX,23296 Point IX at Slot_Table.
59321 LD DE,(61317) Fetch *Slot_Subtract.
59325 EXX Set the slot stride to 6 in DE'.
59326 LD DE,6
59329 EXX
Move every slot.
Refresh_Slot_Table_0 59330 LD L,(IX+3) Subtract *Slot_Subtract from the second word of this slot.
59333 LD H,(IX+4)
59336 AND A
59337 SBC HL,DE
59339 LD (IX+3),L
59342 LD (IX+4),H
59345 EXX Advance to the next slot, and loop back to Refresh_Slot_Table_0 until all slots are processed.
59346 ADD IX,DE
59348 EXX
59349 DJNZ Refresh_Slot_Table_0
Fill new slots from the write index.
59351 LD IX,23296 Point IX at Slot_Table.
59355 LD A,(61344) Point IX at slot *Write_Index.
59358 ADD A,A
59359 LD E,A
59360 ADD A,A
59361 ADD A,E
59362 LD E,A
59363 LD D,0
59365 ADD IX,DE
59367 LD A,(61343) Fetch *New_Slot_Count.
59370 LD B,A Copy the new slot count to B.
59371 EX AF,AF' Stash the new slot count in AF'.
Fill one slot.
Refresh_Slot_Table_1 59372 LD (IX+0),1 Set the occupied flag.
59376 LD A,63 Call Random_Number and clamp the maximum value to 63.
59378 CALL Random_Number
59381 LD L,A Multiply the random value by 44.
59382 LD H,0
59384 ADD HL,HL
59385 ADD HL,HL
59386 PUSH HL
59387 ADD HL,HL
59388 PUSH HL
59389 ADD HL,HL
59390 ADD HL,HL
59391 POP DE
59392 ADD HL,DE
59393 POP DE
59394 ADD HL,DE
59395 PUSH HL Stash the first word on the stack.
59396 LD A,63 Call Random_Number and clamp the maximum value to 63.
59398 CALL Random_Number
59401 POP HL Restore the first word from the stack.
59402 RR A Jump to Refresh_Slot_Table_2 if bit 0 of the random value is reset.
59404 JR NC,Refresh_Slot_Table_2
59406 LD A,L Negate the first word.
59407 CPL
59408 LD L,A
59409 LD A,H
59410 CPL
59411 LD H,A
59412 INC HL
Refresh_Slot_Table_2 59413 LD (IX+1),L Write the first word to the slot.
59416 LD (IX+2),H
59419 LD (IX+3),128 Write 3712 to the second word.
59423 LD (IX+4),14
59427 LD A,12 Call Random_Number and clamp the maximum value to 12.
59429 CALL Random_Number
59432 SRA A Halve the random value.
59434 INC A Increment the random value by one.
59435 LD (IX+5),A Write the attribute to the slot.
59438 EXX Advance to the next slot, and loop back to Refresh_Slot_Table_1 until all new slots are filled.
59439 ADD IX,DE
59441 EXX
59442 DJNZ Refresh_Slot_Table_1
Advance the write index, and wrap it.
59444 EX AF,AF' Copy the new slot count from AF' to C.
59445 LD C,A
59446 CP 1 Compare the new slot count with 1.
59448 LD E,18 Set the wrap limit to 18.
59450 JR Z,Refresh_Slot_Table_3 Jump to Refresh_Slot_Table_3 if the new slot count is 1.
59452 LD E,37 Set the wrap limit to 37.
Refresh_Slot_Table_3 59454 LD A,(61344) Fetch *Write_Index.
59457 ADD A,C Add the new slot count.
59458 CP E Jump to Refresh_Slot_Table_4 if the write index is less than the wrap limit.
59459 JR C,Refresh_Slot_Table_4
59461 XOR A Clear the write index.
Refresh_Slot_Table_4 59462 LD (61344),A Write the write index to *Write_Index.
59465 RET Return.
Prev: 59281 Up: Map Next: 59466