|50h||MN$DISP||display a menu|
|Input||D register - Terminating bit-mask.
X register - Address of menu-list.
Displays a menu according to the specified menu-list at X, allowing the user to scroll through the menu using the arrow keys or by pressing the first letter of the item to be selected.
The menu-list consists of item names (with leading byte-count), each followed by the address of an associated subroutine, or by 0. The top level menu uses zero for items associated with OPL procedures (the LZ also uses 1 for Notepad files, 2 for data files).
The list is terminated by a name of length 0. The maximum name length is 16. The items are displayed (and numbered) in the same order as in the menu-list. The first item is displayed at the top left-hand corner (HOME position) of the LCD display. The display is filled from left to right until an item is too long to fit, in which case a new line is started.
On the Lz in 4-line mode, menus are aligned in three columns unless there are items longer than 6 characters in which case it switches to 2 columns.
The error 202 is returned when
In the terminating mask, the n'th bit set corresponds to allowing termination on pressing key value n+1. For instance, bit 0 set corresponds to allowing termination on pressing the ON/CLEAR key, which has value 1. Bit 12 should always be set to allow termination by pressing EXE.
MN$DISP exits when the user either
When the routine terminates, it returns in X the address of the subroutine corresponding to the item selected, unless this address is is 0. If it is 0 then the routine returns in X the address of the item's name in the menu-list. The B register is returned with the terminating key press, (or with EXE when terminating on pressing an item's initial letter). The A register is returned with 0 if the item had an associated subroutine address (non-zero), and otherwise A equals 1. UTW_S0 is returned with the number of the menu item, where 0 specifies the first item.
If the D register is passed as 0 then the routine will never exit as there will be no valid terminating character.
Also note that this routine puts the keyboard state into alpha shift.
On the LZ, the system variable MNB_CPTZ ($209C) is used to decide whether the menu should be capitalized or not when in 4-line mode. The default is 0, meaning that all menu's are capitalized. If it is 1, then all menu's are displayed exactly as they were stored.
An undocumented feature is that the menu routines use dpb_vsiz ($65) to hold the number of items in the menu and dpb_vlin ($64) to hold the currently selected one (0=first item etc).
Displays and gets the selection from a menu that has three items. Calls
the subroutine associated with the item if specified in the menu-list,
and otherwise runs the language procedure which has the name of the
MENU_LIST: ASCIC "FIRST" ; First item (item number 0) DB FIRST_SUBROUTINE ; Address of subroutine to be ; called on selecting FIRST ASCIC "SECOND" ; Second item (item number 1) DB 0 ; No associated subroutine ASCIC "THIRD" ; Third item (item number 2) DB THIRD_SUBROUTINE ; Address of subroutine to be ; called on selecting THIRD DB 0 ; Terminate the list DO_MENU: LDX MENU_LIST ; Point to the menu-list LDD #1002h ; Terminate on EXE or MODE ie. 2 ; or 13, so set bits 1 and 12 OS MN$DISP ; Call the service CMPB #K_EXE ; EXE pressed? BNE MODE ; No, so MODE was pressed TST A ; Was there a subroutine address? BNE NOSUB JMP 0,X ; Yes, so run the subroutine NOSUB: CLRB OS RM$RUNP ; No, so run language procedure ; (B=0 for not in the calculator) BCS ERROR ; Handle error RTS MODE: ; Here if MODE was pressed
|Errors||202 - menu error|