Prev: 37147 Up: Map Next: 37472
37333: Process keyboard / joystick input on a menu
Used by the routines at 26673, 31153, 31370, 31636, 32655, 33663, 34914, 35141, 35293 and 38725.
Output
A ASCII code of letter shortcut that has been selected on menu
37333 LD A,(37084) Check whether to draw hand cursor on menu...
37336 CP 105 ...and if not...
37338 RET NZ ...return
37339 LD A,(23493) Load x-coordinate of current window's top-left corner into A
37342 INC A Increase by one character...
37343 LD (23490),A ...and store for later use
37346 LD A,(23489) Load starting y-coordinate of hand cursor into A...
37349 LD B,A and copy into B
37350 LD A,(23494) Load y-coordinate of current window's top-left corner into A...
37353 ADD A,B ...add to B...
37354 ADD A,A ...and multiply by 8 to get y-coordinate of top of hand cursor in pixels...
37355 ADD A,A ...
37356 ADD A,A ...
37357 LD (23491),A Then store for later use
37360 LD A,(23496) Load y-coordinate of current window's bottom edge into A...
37363 ADD A,A ...multiply by eight...
37364 ADD A,A ...
37365 ADD A,A ...
37366 ADD A,7 ...then add 7 to get y-coordinate of absolute bottom of window in pixels
37368 LD (23492),A ...and store for later
37371 LD A,(23494) Load y-coordinate of current window's top-left corner into A...
37374 LD B,A ...and copy into B
37375 LD A,(23496) Load y-coordinate of current window's bottom-right corner into A...
37378 SUB B ...subtract B...
37379 DEC A ...then subtract one to get height of window, not including frame
37380 LD B,A Copy this into B
37381 LD A,(23489) Load A with initial y-coordinate of hand cursor relative to current window...
37384 SUB B ...subtract B...
37385 NEG ...and negate to give vertical distance available to hand cursor to move
37387 ADD A,A Multiply this by eight to convert from chars to pixels...
37388 ADD A,A ...
37389 ADD A,A ...
37390 LD (23471),A ...and store at 23471
37393 CALL 37571 Apply FLASH attribute to menu letter shortcut next to hand menu cursor
This entry point is used by the routines at 37497 and 37523.
37396 XOR A Set A to zero
37397 LD (23560),A Clear last pressed key (LAST K system variable)
37400 HALT Wait for interrupt / reset
37401 CALL 37876 Capture keyboard input, or jump to joystick reading routine
37404 BIT 2,A If "up" pressed then...
37406 JP NZ,37497 ...jump to routine to move hand cursor up and update flashing menu shortcut
37409 BIT 3,A If "down" pressed then...
37411 JP NZ,37523 ...jump to routine to move hand cursor down and update flashing menu shortcut
37414 BIT 4,A If "fire" pressed then...
37416 JP NZ,37552 ...jump to routine to load A with ASCII code of shortcut for selected item in menu
37419 LD A,(23560) Load A with last pressed key (LAST K system variable)...
37422 OR A ...and if this is zero (i.e. no key pressed)...
37423 JR Z,37396 ...loop back to 37396
37425 LD (37457),A Store pressed key further on in this routine
37428 LD A,(23491) Load A with y-coordinate of top of hand cursor (pixels)...
37431 CALL 30123 ...and divide by eight to get top of cursor in characters
37434 INC A Add one to this
37435 LD B,A Copy into B
37436 LD A,(23493) Load A with x-coordinate of left edge of current window (characters)
37439 LD C,A Copy into C
37440 LD A,(23492) Load A with y-coordinate of bottom of window (including frame) (pixels)
37443 CALL 30123 Divide by eight to get coordinate in characters...
37446 INC A ...and add one
37447 EX AF,AF' Switch A register
37448 PUSH BC Store B and C
37449 CALL 36551 Move virtual bitmap cursor to display file address for coordinates (C,B)
37452 CALL 37613 Load character in display file address stored at 36488 into A (i.e. letter shortcut for command at current y-coordinate)
37455 POP BC Restore coordinates to BC
The operand of the instruction at 37456 represents the index of the key that was pressed. This is modified by the instruction at 37425.
37456 CP 0 If last-pressed key matches this letter shortcut...
37458 JR Z,37468 ...then jump to end of routine
37460 INC B ...else increase y-coordinate by one (i.e. move onto next row of menu)
37461 EX AF,AF' Switch A register...
37462 CP B ...and if current y-coordinate is less than this (i.e. we haven't yet reached the last command in this window)...
37463 JR NZ,37447 ...then loop back to 37447 for next row of text in window
37465 JP 37396 Repeat process for next key-press
37468 CALL 37472 Wait for keyboard to be released
37471 RET Return
Prev: 37147 Up: Map Next: 37472