hgskiing_fully_ldirs_run.skool  Routines 
Prev: 28182  Up: Map  Next: 28480 
28234: READ_KEYBOARD Keyboard detection routine. Also does other things BEFORE looking at the keyboard. Uses documented QZIP keys. Also allows Interface 2 1234 and 6789 keys to be used instead (undocumented). And allows S key to pause, any bottom row key resumes (also undocumented). Also checks H and G keys – if both are pressed, restarts the game by setting 24249 Uses variable at 24248 and DEMO_OR_GAME_MODE variable at 24249 INPUT: no parameters OUTPUT: B = ONE and only ONE of 0 (UP), 1 (RIGHT), 2 (DOWN), 3 (LEFT) on RETurn Game variables changed: 24262 – these probably all relate to the location of Horace 24261 24260 24220 24249 DEMO_OR_GAME_MODE CALLS: 28077 Call DO_SOME_ATTRIBUTE_WORK Game variables read but not changed 24248 only BITs 210 used ?


28234  LD BC,1271  B = 4, C = 247 – C used for keyboard check later  
28237  LD DE,24248  Check 24248  
28240  LD A,(DE)  A = (24248)  
28241  AND A  Test if any bits are set, result in A  
28242  JR Z,28335  If 24248 is zero, A AND A is 0, then jump to 28335 (CHECK_PAUSE_ACTIVATE)  
28244  BIT 0,A  24248 is not zero, at least one bit was set in 24248, so check BIT 0  
28246  JR NZ,28256  If BIT 0 of 24248 is 1, jump to 28256  
28248  CP 2  BIT 0 is zero, so check if BIT 1 is set (only BIT 1)  
28250  JR Z,28297  If 24248 = 2 (10 binary), then jump to 28297  
28252  LD B,0  If A (24248)!= 2 set B = 0  
28254  JR 28299  Jump to 28299  
28256  CP 5  BIT 0 of 24248 is 1 if we are here, is A = 5?  
28258  JR Z,28285  If A (24248) = 5 BIN 00000101 then jump to 28285  
28260  LD HL,24262  HL = 24262  
28263  LD A,(HL)  A = (HL)  
28264  AND A  A AND A  
28265  JR NZ,28269  If A AND A is nonzero (any of the bits set), jump to 28269  
28267  LD (HL),20  24262 is 0, so set 24262 = 20  
28269  DEC (HL)  (HL)–  
28270  LD A,(24261)  A = (24261)  
28273  JR NZ,28279  If (24261) is nonzero, go to 28279  
28275  XOR 3  A is 0, so 00 XOR 11 is 11 (3 decimal)  
28277  OR 1  A = 3 (11 binary), so 11 OR 01 is 11  
28279  LD B,A  B = A = 3 (11)  
28280  LD (24261),A  Set 24261 = A = 3 or nonzero original value of 24261 from 28270  
28283  JR 28299  Jump to 28299  
28285  CALL 28077  A was 5 from 28258, so now DO_SOME_ATTRIBUTE_WORK  
28288  AND 3  Only want bits 10 of A, discard the rest  
28290  BIT 0,A  Test only BIT 0  
28292  JR Z,28318  Jump to READ_KEYBOARD if BIT 0 of A is ZERO  
28294  LD B,A  If BIT 0 of A is 1, set B = A  
28295  JR 28299  Jump to 28299  
28297  LD B,2  24248 = A = 2, jump here from 28250  
28299  LD HL,24260  24248 != 2, B already set to 0  
28302  DEC (HL)  24260–  
28303  JR NZ,28318  If A != 0, jump to 28318  
28305  LD (HL),90  
28307  LD A,(DE)  A = 24248 (again)  
28308  INC A  A = A + 1  
28309  CP 5  Subtract 5 from A to compare  
28311  LD (DE),A  24248 = A + 1  
28312  JR C,28318  If A > 5 then jump to 28318  
28314  XOR A  A <= 5, so set A = 0  
28315  LD (24220),A  Set 24220 = 0  
28318  XOR A  READ_KEYBOARD A !=0 if came from 28303, so set A = 0  
28319  IN A,(254)  
28321  AND 31  Use only 5 rightmost bits  
28323  CP 31  If all 5 43210 bits are 1 then no key pressed  
28325  RET Z  If no key pressed then return  
28326  XOR A  A = 0  
28327  LD (24220),A  Set 24220 to be zero  
28330  INC A  A = 1  
28331  LD (24249),A  Set DEMO_OR_GAME_MODE to be 1 (GAME)  
28334  RET  And return (GAME must have started?)  
28335  LD A,253  CHECK_PAUSE_ACTIVATE 24248 was zero, so jumped here  
28337  IN A,(254)  Read keyboard A – G halfrow  
28339  AND 2  Use only S key (BIT 1)  
28341  JR NZ,28363  If S key is pressed, BIT 1 is zero, so AND 2 is nonzero, so go to 28363  
28343  LD A,127  S_KEY_PRESSED Bottom right halfrow B to SPACE  
28345  IN A,(254)  
28347  AND 31  Discard bits 765 as meaningless. Use only bits 43210  
28349  CP 31  If all bits 43210 are 1 = 31, and no key pressed.  
28351  JR NZ,28363  If zero, all bits 1. Otherwise at least one key was pressed, so jump to CHECK_H_KEY  
28353  LD A,254  Bottom left halfrow CAPS SHIFT to V  
28355  IN A,(254)  
28357  AND 31  Discard bits 765 as meaningless  
28359  CP 31  If all bits 43210 are 1, no key pressed  
28361  JR Z,28343  LOOP_PAUSE If no key pressed, jump back to S_KEY_PRESSED – 28343 – no bottom row key pressed  
28363  LD A,191  CHECK_H_KEY This is H to ENTER halfrow  
28365  IN A,(254)  
28367  AND 16  Check only bit 4 which is H key  
28369  JR NZ,28383  If H is pressed, bit 4 is ZERO, AND 16 is ZERO – jump to CHECK_MOVEMENT_KEYS  
28371  LD A,253  CHECK_G_KEY H key has been pressed  
28373  IN A,(254)  Read keyboard A – G halfrow  
28375  AND 16  Check only bit 4 which is G key  
28377  JR NZ,28383  If G is pressed, bit 4 is ZERO, AND 16 is ZERO – jump to CHECK_MOVEMENT_KEYS  
28379  INC A  A is zero if 28377 did not jump, so set A = 1  
28380  LD (24249),A  DEMO_OR_GAME_MODE set to GAME Mode = 1 which starts a new game  
28383  LD DE,57327  CHECK_MOVEMENT_KEYS D = 223, E = 239  
28386  LD A,D  CHECK_RIGHT_KEYS Y to P halfrow of keyboard  
28387  IN A,(254)  
28389  BIT 0,A  Check P key  
28391  JR Z,28407  If BIT 0 is ZERO, P was pressed, then jump to 28407  
28393  LD A,E  Top right halfrow 6 to 0  
28394  IN A,(254)  
28396  BIT 3,A  Check 7 key  
28398  JR Z,28407  If BIT 3 is ZERO, 7 was pressed, then jump to 28407  
28400  LD A,C  C = 247  
28401  IN A,(254)  Read from top right halfrow 1 to 5 keys  
28403  BIT 1,A  Check 2 key (BIT 1)  
28405  JR NZ,28409  If 2 key was pressed, BIT 1 is ZERO, jump to 28409  
28407  LD B,1  GO_RIGHT_KEY_PRESSED One of the “Go right” keys was pressed (P,7,2) – set B = 1  
28409  LD A,C  CHECK_LEFT_KEYS C = 247 from first LD BC at 28234  
28410  IN A,(254)  Read from top right halfrow 1 to 5 keys  
28412  BIT 0,A  BIT 0 is 1 key  
28414  JR Z,28430  If 1 key is pressed, BIT 0 is 0, jump to GO_LEFT_KEY_PRESSED  
28416  LD A,D  D = 223 from 28383 which is executed in all cases  
28417  IN A,(254)  223 represents Y to P keys  
28419  BIT 2,A  BIT 2 is the I key  
28421  JR Z,28430  Bit 2 will be 0 if I key is pressed, so jump to GO_LEFT_KEY_PRESSED  
28423  LD A,E  E = 239 from 28383  
28424  IN A,(254)  239 represents 6 to 0 keys  
28426  BIT 4,A  BIT 4 is the innermost (leftmost) key, which is 6 key  
28428  JR NZ,28432  If it is pressed, it will be zero, so do not jump and enter GO_LEFT_KEY_PRESSED  
28430  LD B,3  GO_LEFT_KEY_PRESSED – set B = 3  
28432  LD A,E  CHECK_UP_KEYS E = 239 from 28383  
28433  IN A,(254)  Checking 6 to 0 half row of keys  
28435  BIT 1,A  BIT 1 is 9 key  
28437  JR Z,28454  If 9 key is pressed, BIT 1 will be zero, so jump to UP_KEY_PRESSED  
28439  LD A,251  Checking 1 to 5 half row of keys  
28441  IN A,(254)  
28443  BIT 0,A  BIT 0 is outermost key which is Q  
28445  JR Z,28454  If Q key is pressed, BIT 0 will be zero, so jump to UP_KEY_PRESSED  
28447  LD A,C  C = 247 from first LD BC at 28234  
28448  IN A,(254)  Checking 1 to 5 half row of keys  
28450  BIT 3,A  BIT 3 is 4 key  
28452  JR NZ,28456  If it is pressed, it will be zero, so do not jump and execute next line  
28454  LD B,0  UP_KEY_PRESSED  
28456  LD A,C  CHECK_DOWN_KEYS C = 247 from first LD BC at 28234  
28457  IN A,(254)  Checking 1 to 5 half row of keys  
28459  BIT 2,A  BIT 2 is 3 key  
28461  JR Z,28477  If 3 key is pressed, BIT 2 will be zero, so jump to DOWN_KEY_PRESSED  
28463  LD A,254  CAPS SHIFT to V halfrow of keys  
28465  IN A,(254)  
28467  BIT 1,A  Check BIT 1 which is Z key  
28469  JR Z,28477  If Z is pressed, A will be 0, so jump to DOWN_KEY_PRESSED  
28471  LD A,E  E = 239 from 28383  
28472  IN A,(254)  Check 6 to 0 keys  
28474  BIT 2,A  BIT 2 is 8 key  
28476  RET NZ  If BIT is NOT zero, then return without signalling down key.  
28477  LD B,2  DOWN_KEY_PRESSED  
28479  RET  B = ONE and only ONE of 0 (UP), 1 (RIGHT), 2 (DOWN), 3 (LEFT) on RETurn  
END READ_KEYBOARD

Prev: 28182  Up: Map  Next: 28480 