Prev: 04C0 Up: Map Next: 06A6
0640: display_menu: Display the main menu and wait for enter key to be pressed.
Used by the routines at init_variables, handle_keypress and hold_page.
display_menu 0640 PUSH BC Preserve registers.
0641 PUSH DE
0642 PUSH HL
0643 CALL clear_page_buffer Clear page display buffer.
0646 LD HL,(page_display_buffer_pointer) Load address of page display buffer and add 8 to move to start of page header.
0649 LD BC,$0008
064C ADD HL,BC
064D EX DE,HL
064E LD HL,menu_data Copy 24 characters to buffer from menu_data.
0651 LD BC,$0018
0654 LDIR
0656 LD HL,(page_display_buffer_pointer) Load address of page display buffer and add 40 to move to start of row 1.
0659 LD BC,$0028
065C ADD HL,BC
065D EX DE,HL
065E LD HL,$04DD Set HL to address of the first row of menu data.
display_menu_0 0661 PUSH DE
display_menu_1 0662 LD A,(HL) Load next character from input data.
0663 CP $1B If $1B (escape) jump to display_menu_2.
0665 JR Z,display_menu_2
0667 CP $10 If $10 jump to display_menu_3.
0669 JR Z,display_menu_3
066B LD (DE),A Else store character in output buffer.
066C INC DE Increment pointers and loop for next character.
066D INC HL
066E JR display_menu_1
display_menu_2 0670 POP DE End of row data - get start of row back off stack.
0671 EX DE,HL
0672 LD BC,$0028 Add 40 to get address of next row.
0675 ADD HL,BC
0676 EX DE,HL
0677 INC HL Move on to next character of menu data and loop.
0678 JR display_menu_0
display_menu_3 067A POP DE End of menu data - balance the stack.
067B CALL decode_page Render menu page data to screen.
display_menu_4 067E CALL get_keypress Get a keypress.
0681 CP $5A If key code is 'Z', call address in print_pointer via display_menu_6, then loop back and wait for another keypress.
0683 JR NZ,display_menu_5
0685 LD HL,(print_pointer)
0688 CALL display_menu_6
068B JR display_menu_4
display_menu_5 068D CP $45 Else if key code is 'E', jump to address in exit_pointer.
068F JR NZ,display_menu_7
0691 LD HL,(exit_pointer)
display_menu_6 0694 JP (HL)
display_menu_7 0695 CP $0D Else if key code is not 'enter', loop back and wait for another keypress.
0697 JR NZ,display_menu_4
0699 CALL clear_page_buffer Clear page display buffer and screen.
069C CALL copy_page_data Load recieved page data back into page display buffer render it.
069F CALL decode_page
06A2 POP HL Restore registers and return.
06A3 POP DE
06A4 POP BC
06A5 RET
Prev: 04C0 Up: Map Next: 06A6