Prev: F846 Up: Map Next: F8AE
F87E: Initialise the character buffers for characters 0xDE-0xE6
Used by the routine at F8AE. Initialises the animatory states, locations and command list addresses for characters 0xDE-0xE6 for the next game mode.
Input
A Game mode (0-4)
F87E LD C,A Point HL at the last byte in the set of initialisation parameters for the current game mode for character 0xDE (see DE20)
F87F ADD A,A
F880 ADD A,C
F881 ADD A,A
F882 ADD A,$25
F884 LD L,A
F885 LD H,$DE
F887 LD D,H Point DE at byte 0x1F of the character's buffer
F888 LD E,$1F
F88A LD A,(HL) Pick up the last byte in the set of initialisation parameters (the MSB of a command list address, or 1 if we're dealing with Sam)
F88B AND A Is there a command list address (or 1) here?
F88C JR Z,$F8A7 Jump if not
F88E XOR A Prepare A for filling parts of the character's buffer with zeroes
F88F PUSH HL Save the pointer to the initialisation parameters
F890 LD BC,$0702 B=7, C=2
F893 LD (DE),A Fill bytes 0x19-0x1F of the character's buffer with zeroes
F894 DEC E
F895 DJNZ $F893
F897 LDDR Copy the command list address (or message number and 1 if dealing with Sam) into bytes 0x17 and 0x18 of the character's buffer
F899 LD BC,$1204 B=18, C=4
F89C LD (DE),A Fill bytes 0x05-0x16 of the character's buffer with zeroes
F89D DEC E
F89E DJNZ $F89C
F8A0 LDD Copy the z-coordinate (or y-coordinate of the topmost row of the play area on screen if dealing with Sam) into byte 0x04 of the character's buffer
F8A2 LD (DE),A Reset all flags in byte 0x03 of the character's buffer
F8A3 DEC E Point DE at byte 0x02 of the character's buffer
F8A4 LDDR Copy the x- and y-coordinates and animatory state (or, if dealing with Sam, the x-coordinate of the leftmost column of the play area on screen, 32 or 34, and 0) into bytes 0x00-0x02 of the character's buffer
F8A6 POP HL Restore the pointer to the initialisation parameters to HL
F8A7 INC H Next character
F8A8 LD A,H Have we initialised all the character buffers yet?
F8A9 CP $E7
F8AB JR NZ,$F887 Jump back if not
F8AD RET
Prev: F846 Up: Map Next: F8AE