Prev: F22A Up: Map Next: F26C
F23B: Stir the random numbers
Used by the routines at deal_places, menu_loop and play.
Called once a pass of the play loop (play), of the menu's loop (menu_loop) and from deal_places. The two random bytes of random_a are stirred with a byte read from a pointer that walks through memory (kept big-endian after them), and with the player's controls as they were last read (controls_now). Bits 4 and 6 of the pointer's high byte are cleared and it never reaches the top 20K, so the bytes come from the ROM and the game's own code.
random F23B LD IX,random_a Step the pointer on, kept within the ROM and the code
F23F LD H,(IX+$02)
F242 LD L,(IX+$03)
F245 INC HL
F246 LD A,H
F247 AND $AF
F249 LD (IX+$02),A
F24C LD (IX+$03),L
F24F LD B,(HL) The byte there
F250 LD A,(controls_now) First random byte: add the byte, the controls and 5
F253 ADD A,B
F254 ADD A,$05
F256 ADD A,(IX+$00)
F259 LD (IX+$00),A
F25C LD A,B Second: add the byte's complement, the controls and 9
F25D CPL
F25E LD B,A
F25F LD A,(controls_now)
F262 ADD A,$09
F264 ADD A,B
F265 ADD A,(IX+$01)
F268 LD (IX+$01),A
F26B RET
Prev: F22A Up: Map Next: F26C