Prev: 74BA Up: Map Next: 7574
74C1: Print Token
Used by the routines at 70F3, PrintMsg, 7340, 742D, Action_Look, 9EC7, A0C8, DisplayExits and ActionCapture.
Input
DE e.g. $56D1 token?
PrintToken 74C1 LD A,D A=D
74C2 AND %00001111 Keep only bits 0-3.
74C4 OR E Combine with E.
74C5 RET Z Return the result is zero.
74C6 PUSH HL Store HL, BC and DE on the stack for later.
74C7 PUSH BC
74C8 PUSH DE
74C9 LD C,D
74CA LD A,D
74CB AND $0F
74CD LD D,A
74CE LD HL,$6000 HL=$6000+DE
74D1 ADD HL,DE
74D2 LD DE,$74A6 DE=output buffer.
74D5 PUSH HL Store HL on the stack.
74D6 LD B,$00 Intialise B to $00 to count the number of letters.
PrintToken_Loop 74D8 LD A,(HL) Fetch the next character from HL.
74D9 AND $1F Keep only bits 0-4.
74DB JR Z,PrintToken_ Jump to PrintToken_ if this is zero.
74DD INC B Increase B by one.
74DE ADD A,$60 Add $60 to A to convert to ASCII.
74E0 LD (DE),A Store the result in the output buffer.
74E1 INC DE Increase the output buffer pointer by one.
74E2 BIT 7,(HL) Check if this is the last character in the word.
74E4 INC HL Increase the character pointer reference by one.
74E5 JR Z,PrintToken_Loop If this is not the last character in the word, loop back to PrintToken_Loop to continue processing.
Check minimum length.
74E7 LD A,B A=the number of characters.
74E8 CP $02 If the number of characters is only $02 then jump back to PrintToken_Loop to continue processing.
74EA JR Z,PrintToken_Loop
74EC CP $03 If it is not $03, then jump to PrintToken_.
74EE JR NZ,PrintToken_
74F0 DEC HL Else, fetch the first character again and check if it is the last character in the word.
74F1 DEC HL
74F2 LD A,(HL)
74F3 INC HL
74F4 INC HL
74F5 BIT 7,A
74F7 JR NZ,PrintToken_Loop If it is not, loop back to PrintToken_Loop to continue processing.
PrintToken_ 74F9 POP HL Restore HL off the stack.
74FA LD A,C
74FB AND $F0
74FD CP $50
74FF JR Z,PrintToken_____
7501 CP $40
7503 JR Z,PrintToken___
7505 CP $10
7507 LD A,($B6E8)
750A JR Z,PrintToken__
750C LD A,($B6EA)
PrintToken__ 750F AND A
7510 JR Z,PrintToken_____
PrintToken___ 7512 INC HL
7513 BIT 7,(HL)
7515 JR Z,PrintToken_____
7517 INC HL
7518 LD A,(HL)
7519 AND $E0 E0?
751B RRCA
751C RRCA
751D RRCA
751E LD L,A
751F LD H,$00
7521 LD BC,$B71F
7524 ADD HL,BC
7525 LD B,$04
PrintToken____ 7527 LD A,(HL)
7528 AND A
7529 JR Z,PrintToken_____
752B INC HL
752C LD (DE),A
752D INC DE
752E DJNZ PrintToken____
PrintToken_____ 7530 LD HL,$74A6
7533 EX DE,HL
7534 AND A
7535 SBC HL,DE
7537 LD B,L
7538 LD A,($B701)
753B AND A
753C PUSH AF
753D JR NZ,PrintToken______
753F LD A,($86A0)
7542 AND A
PrintToken______ 7543 LD A,$20
7545 CALL NZ,$858B
7548 POP AF
7549 LD A,($85B3)
754C JR NZ,PrintToken_______
754E LD A,($869B)
PrintToken_______ 7551 LD HL,$B704
7554 CP B
7555 JR NC,PrintToken________
7557 LD A,(HL)
7558 CALL $8583
755B LD (HL),A
PrintToken________ 755C POP DE
755D LD A,D
755E AND $F0
7560 CP $70
7562 LD A,$01
7564 JR NZ,PrintToken_Print
7566 LD (HL),A
PrintToken_Print 7567 LD HL,$74A6 HL=output buffer.
PrintToken_Print_Loop 756A LD A,(HL) Fetch the next character from the output buffer.
756B CALL $858B Call 858B.
756E INC HL Increase the output buffer pointer by one.
756F DJNZ PrintToken_Print_Loop Decrease counter by one and loop back to PrintToken_Print_Loop until counter is zero.
7571 POP BC Restore BC and HL off the stack.
7572 POP HL
7573 RET Return.
Prev: 74BA Up: Map Next: 7574