Prev: 29882 Up: Map Next: 30068
29889: Print Token
Used by the routines at 28915, PrintMsg, 29504, 29741, Action_Look, 40647, 41160, DisplayExits and ActionCapture.
Input
DE e.g. $56D1 token?
PrintToken 29889 LD A,D A=D
29890 AND %00001111 Keep only bits 0-3.
29892 OR E Combine with E.
29893 RET Z Return the result is zero.
29894 PUSH HL Store HL, BC and DE on the stack for later.
29895 PUSH BC
29896 PUSH DE
29897 LD C,D
29898 LD A,D
29899 AND 15
29901 LD D,A
29902 LD HL,24576 HL=$6000+DE
29905 ADD HL,DE
29906 LD DE,29862 DE=output buffer.
29909 PUSH HL Store HL on the stack.
29910 LD B,0 Intialise B to $00 to count the number of letters.
PrintToken_Loop 29912 LD A,(HL) Fetch the next character from HL.
29913 AND 31 Keep only bits 0-4.
29915 JR Z,PrintToken_ Jump to PrintToken_ if this is zero.
29917 INC B Increase B by one.
29918 ADD A,96 Add $60 to A to convert to ASCII.
29920 LD (DE),A Store the result in the output buffer.
29921 INC DE Increase the output buffer pointer by one.
29922 BIT 7,(HL) Check if this is the last character in the word.
29924 INC HL Increase the character pointer reference by one.
29925 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.
29927 LD A,B A=the number of characters.
29928 CP 2 If the number of characters is only $02 then jump back to PrintToken_Loop to continue processing.
29930 JR Z,PrintToken_Loop
29932 CP 3 If it is not $03, then jump to PrintToken_.
29934 JR NZ,PrintToken_
29936 DEC HL Else, fetch the first character again and check if it is the last character in the word.
29937 DEC HL
29938 LD A,(HL)
29939 INC HL
29940 INC HL
29941 BIT 7,A
29943 JR NZ,PrintToken_Loop If it is not, loop back to PrintToken_Loop to continue processing.
PrintToken_ 29945 POP HL Restore HL off the stack.
29946 LD A,C
29947 AND 240
29949 CP 80
29951 JR Z,PrintToken_____
29953 CP 64
29955 JR Z,PrintToken___
29957 CP 16
29959 LD A,(46824)
29962 JR Z,PrintToken__
29964 LD A,(46826)
PrintToken__ 29967 AND A
29968 JR Z,PrintToken_____
PrintToken___ 29970 INC HL
29971 BIT 7,(HL)
29973 JR Z,PrintToken_____
29975 INC HL
29976 LD A,(HL)
29977 AND 224 E0?
29979 RRCA
29980 RRCA
29981 RRCA
29982 LD L,A
29983 LD H,0
29985 LD BC,46879
29988 ADD HL,BC
29989 LD B,4
PrintToken____ 29991 LD A,(HL)
29992 AND A
29993 JR Z,PrintToken_____
29995 INC HL
29996 LD (DE),A
29997 INC DE
29998 DJNZ PrintToken____
PrintToken_____ 30000 LD HL,29862
30003 EX DE,HL
30004 AND A
30005 SBC HL,DE
30007 LD B,L
30008 LD A,(46849)
30011 AND A
30012 PUSH AF
30013 JR NZ,PrintToken______
30015 LD A,(34464)
30018 AND A
PrintToken______ 30019 LD A,32
30021 CALL NZ,34187
30024 POP AF
30025 LD A,(34227)
30028 JR NZ,PrintToken_______
30030 LD A,(34459)
PrintToken_______ 30033 LD HL,46852
30036 CP B
30037 JR NC,PrintToken________
30039 LD A,(HL)
30040 CALL 34179
30043 LD (HL),A
PrintToken________ 30044 POP DE
30045 LD A,D
30046 AND 240
30048 CP 112
30050 LD A,1
30052 JR NZ,PrintToken_Print
30054 LD (HL),A
PrintToken_Print 30055 LD HL,29862 HL=output buffer.
PrintToken_Print_Loop 30058 LD A,(HL) Fetch the next character from the output buffer.
30059 CALL 34187 Call 34187.
30062 INC HL Increase the output buffer pointer by one.
30063 DJNZ PrintToken_Print_Loop Decrease counter by one and loop back to PrintToken_Print_Loop until counter is zero.
30065 POP BC Restore BC and HL off the stack.
30066 POP HL
30067 RET Return.
Prev: 29882 Up: Map Next: 30068