Prev: 00427 Up: Map Next: 00543
00461: Find Variable
Used by the routines at HandleInterrupt, ParseSpeechString and TestKeysVariable.
Walk the BASIC variable area looking for the name code in A.
Input
A Name code
Output
HL Pointer to the variable
F Z flag set if the name was found
FindVariable 00461 LD B,A Keep the name code in B.
00462 LD A,(23611) Fetch *FLAGS.
00465 RLA Jump to FindVariable_Miss if bit 7 is not set.
00466 JR NC,FindVariable_Miss
00468 LD A,(23734) Fetch *CHINFO.
00471 CP 244 Jump to FindVariable_Start if it is 244.
00473 JR Z,FindVariable_Start
00475 OR A Jump to FindVariable_Miss if it is not 0.
00476 JR NZ,FindVariable_Miss
Walk *VARS for the requested name.
FindVariable_Start 00478 LD HL,(23627) Start at *VARS.
FindVariable_Loop 00481 LD A,(HL) Return if this is the requested variable.
00482 CP B
00483 RET Z
00484 CP 128 Jump to FindVariable_Miss if this is the end of *VARS.
00486 JR Z,FindVariable_Miss
00488 AND %11100000 Keep only bits 5-7 (the variable type).
00490 CP 96 Jump to FindVariable_SkipNumeric if the type is 96.
00492 JR Z,FindVariable_SkipNumeric
00494 CP 160 Jump to FindVariable_SkipName if the type is 160.
00496 JR Z,FindVariable_SkipName
00498 CP 224 Jump to FindVariable_SkipArray if the type is 224.
00500 JR Z,FindVariable_SkipArray
00502 CP 192 Jump to FindVariable_SkipWord if the type is 192.
00504 JR Z,FindVariable_SkipWord
00506 CP 128 Jump to FindVariable_SkipWord if the type is 128.
00508 JR Z,FindVariable_SkipWord
00510 CP 64 Return if the type is not a simple numeric.
00512 RET NZ
FindVariable_SkipWord 00513 INC HL Skip the following length word and jump to FindVariable_Loop.
00514 LD E,(HL)
00515 INC HL
00516 LD D,(HL)
00517 INC HL
00518 ADD HL,DE
00519 JR FindVariable_Loop
FindVariable_Miss 00521 LD A,128 Clear the Z flag.
00523 AND A
00524 RET Return.
FindVariable_SkipArray 00525 LD DE,13 Skip the array header.
00528 ADD HL,DE
FindVariable_SkipNumeric 00529 LD DE,6 Skip the numeric value and jump to FindVariable_Loop.
00532 ADD HL,DE
00533 JR FindVariable_Loop
FindVariable_SkipName 00535 INC HL Move to the next letter of the long name.
00536 LD A,(HL) Jump to FindVariable_SkipName if the name has not ended.
00537 SLA A
00539 JR NC,FindVariable_SkipName
00541 JR FindVariable_SkipNumeric Jump to FindVariable_SkipNumeric.
Prev: 00427 Up: Map Next: 00543