Prev: 59258 Up: Map Next: 59369
59291: Handler: Change Characters
Used by the routine at GameLoop.
Handler_ChangeCharacters 59291 LD A,247 Read from the keyboard;
Port Number Bit
0 1 2 3 4
247 1 2 3 4 5
59293 IN A,(254)
59295 OR %11100000 Set bits 5-7.
59297 XOR %11111111 Return if no keys have been pressed.
59299 RET Z
Fetch room ID for the current character.
59300 LD B,(IY+15) B=*IY+15.
59303 PUSH IY Stash the character pointer in IY on the stack.
Loop through the port bits and correlate them with the base character reference in IY.
This associates each character with a keypress.
Key Character
1 Wally
2 Wilma
3 Tom
4 Dick
5 Harry
59305 LD IY,48231 IY=FrameId_Wally.
ChangeCharacters_WhichCharacter_Loop 59309 RRCA Rotate A right once.
59310 JR C,ChangeCharacters_CheckRoom If this key has been pressed, jump to ChangeCharacters_CheckRoom.
The character data is "interlaced" hence we can increment to point to the next character in the sequence.
59312 INC IY Increment IY by one.
59314 JR ChangeCharacters_WhichCharacter_Loop Jump to ChangeCharacters_WhichCharacter_Loop.
Check if the current character is in the same room as the selected character.
ChangeCharacters_CheckRoom 59316 LD A,(IY+15) A=*IY+15.
59319 CP B If this is the same room, jump to ChangeCharacters_Process.
59320 JR Z,ChangeCharacters_Process
If the character is elsewhere, print where they are to the screen.
59322 CALL Handler_DisplayCharacterLocation Call Handler_DisplayCharacterLocation.
Restore the current character pointer to IY and return.
ChangeCharacters_Return 59325 POP IY Restore the character pointer in IY from the stack.
59327 RET Return.
The chosen character is in the same room as the current character, so begin to action the request.
ChangeCharacters_Process 59328 CALL Character_Active Call Character_Active.
59331 JR Z,ChangeCharacters_Return If the selected character is the current character, jump to ChangeCharacters_Return.
59333 LD (45213),IY Write IY to *CurrentCharacter.
59337 POP IY Restore IY from the stack.
59339 LD A,B A=B.
59340 CALL 44137 Call 44137.
59343 LD A,(HL) A=*HL.
59344 LD (IY+105),A Write A to IY+105.
59347 INC HL Increment HL by one.
59348 LD A,(HL) A=*HL.
59349 LD (IY+100),A Write A to IY+100.
59352 INC HL Increment HL by one.
59353 LD A,(HL) A=*HL.
59354 LD (IY+115),A Write A to IY+115.
59357 LD (IY+110),5 Write 5 to IY+110.
59361 LD IY,(45213) IY=*CurrentCharacter.
Update the banner to show the updated character name.
59365 CALL PrintBanner Call PrintBanner.
59368 RET Return.
Prev: 59258 Up: Map Next: 59369