Executing Menus

z80 » Menus

One pain of making branched programs is menus for the user to select where to go next by clicking a Function key (F1, F2, F3, F4, and F5). You have to make a routine to draw the menu, make a routine to display the text in the menu slots, and yet another routine to control the input of keys and jump to different parts of the program accordingly. This can be over 100 bytes for this all. Thanks to Dux Gregis and other pioneers of the TI86 ROM routines, we have gained much knowledge of internal TI86 routines that can do tasks like displaying a menu and controlling keypresses for us. There are two routines that we are going to study that have to do with setting up a menu structure and implementing the menu. The two calls are:

_ASAPloadmenu	=$49c8
_funcDisp	=$49e8

The whole idea of executing a menu is easy: load hl with the address of the menu data, call _ASAPloadmenu, and call _funcDisp. You can actually just jump to _funcDisp if you don't want to come back. You can lock the cursor so that the TI86 will not accept the [2nd] or [ALPHA] input. Either set curLock,(iy+curFlags) or set 4,(iy+$0c) will lock the key input so that no keypress modifiers ([2nd] or [ALPHA]) will be accepted.

Here is an example of running a menu located at $f200 on RAM page 0.

menu_to_run	=$f200		;address of menu
	ld hl,menu_to_run	;hl holds menu location
	call _ASAPloadmenu	;set it up in memory
	jp _funcDisp		;execute it and return to ti-os

Your last thing to do is to jump (or call _funcDisp / ret) to _funcDisp. If You just call it and then execute code after, your menu will not be able to get keypresses. By jumping to _funcDisp, you display the menu and exit to TI-OS which can then use the menu.


More from z80 » Menus
Creating Menus // Executing Menus // ROM Menus