Prev: F820 Up: Map Next: F846
F82A: Control a cat
Used by the command list at FE92. Makes the cat run up and down for ever.
Input
H 0xDA (Cat)
F82A LD L,$01 Point HL at byte 0x01 of the cat's buffer
F82C LD A,(HL) A=cat's initial x-coordinate
F82D LD L,$03 Set bit 7 of byte 0x03 of the cat's buffer (cats always run)
F82F LD (HL),$80
F831 LD L,$0A The cat's initial x-coordinate will be its walkabout origin; store it in byte 0x0A of the cat's buffer
F833 LD (HL),A
The following loop controls the cat from now on.
F834 CALL $F17F Get a random number between 0 and 15 in A
F837 AND $0F
F839 LD L,$0A Add the x-coordinate of the cat's walkabout origin to get the next walkabout destination x-coordinate
F83B ADD A,(HL)
F83C INC L Store this in byte 0x0B of the cat's buffer
F83D LD (HL),A
F83E LD BC,$F846 Copy the address of the interruptible subcommand routine at F846 into bytes 0x0E and 0x0F of the cat's buffer, and change the address of the primary command routine to F844 (below)
F841 CALL $F79A
F844 JR $F834
Prev: F820 Up: Map Next: F846