Difference between revisions of "83Plus:Hooks:9BC0"

From WikiTI
Jump to: navigation, search
(added menu table example)
(Example)
 
(2 intermediate revisions by one other user not shown)
Line 23: Line 23:
 
* '''A = 00h:''' This is the second event, called after event 04h. This event allows you to provide your own menu table. B contains the menu ID. If you want to provide your own table, copy it to RAM, point HL to it, and return with the zero flag reset. It's called a second time, but with B being zero. The outputs appear to be the same, so handle it the same way.
 
* '''A = 00h:''' This is the second event, called after event 04h. This event allows you to provide your own menu table. B contains the menu ID. If you want to provide your own table, copy it to RAM, point HL to it, and return with the zero flag reset. It's called a second time, but with B being zero. The outputs appear to be the same, so handle it the same way.
 
* '''A = 02h:''' This event is called before the OS draws the menu header. C is the index of the header (zero based.) Returning with zero set will draw the header, returning with zero reset will cause it to not draw the header. It's also called after it's done drawing the headers, with C is the number of headers (basically, last index plus one). Return flag seems to be ignored.
 
* '''A = 02h:''' This event is called before the OS draws the menu header. C is the index of the header (zero based.) Returning with zero set will draw the header, returning with zero reset will cause it to not draw the header. It's also called after it's done drawing the headers, with C is the number of headers (basically, last index plus one). Return flag seems to be ignored.
* '''A = 01h:''' The OS is about to draw the text corresponding to a menu item. The number prefix has already been drawn. C contains the index of the item (zero indexed.) Returning with zero set will cause the OS to draw the string, returning with zero reset will cause it just to draw a blank line (but it does draw something!)
+
* '''A = 01h:''' The OS is about to draw the text corresponding to a menu item. The number prefix has already been drawn. C contains the index of the item (zero indexed.) Returning with zero set will cause the OS to draw the string, returning with zero reset will cause it just to draw a blank line (but it does draw something!). To draw another token, you will need DE to be an extended keycode. 
 
* '''A = 03h:''' The user selected an item from the menu that is about to cause a context switch. B contains the ID of the context the calculator might switch to. You can return with zero set to execute the app, or zero reset to cancel the execution. If you're switching to a flash app (B is cxextapps), then DE also points to the end of the name of the flash app in RAM. You can cancel the execution of a flash app (this could prove useful for a security app.)
 
* '''A = 03h:''' The user selected an item from the menu that is about to cause a context switch. B contains the ID of the context the calculator might switch to. You can return with zero set to execute the app, or zero reset to cancel the execution. If you're switching to a flash app (B is cxextapps), then DE also points to the end of the name of the flash app in RAM. You can cancel the execution of a flash app (this could prove useful for a security app.)
  
Line 35: Line 35:
 
db 0,kZOut ;these are 2-byte keypresses of each entry
 
db 0,kZOut ;these are 2-byte keypresses of each entry
 
db 0,kStd</nowiki>
 
db 0,kStd</nowiki>
 +
 +
Another example with more headers:
 +
<nowiki>ZoomMenu:
 +
db 2 ;how many headers?
 +
db 3 ;how many choices under 1st header?
 +
db 2 ;how many choices under 1st header?
 +
db 5Eh ;string table entry for "ZOOM"
 +
db 5Fh  ;just for fun
 +
db 0,kZIn ;first header
 +
db 0,kZOut ;these are 2-byte keypresses of each entry
 +
db 0,kStd
 +
db 0,kZIn ;second header
 +
db 0,kZOut ;these are 2-byte keypresses of each entry</nowiki>
  
 
== Credits and Contributions ==
 
== Credits and Contributions ==
 
* '''Kirk Meyer:''' For providing an example of this hook in graph3
 
* '''Kirk Meyer:''' For providing an example of this hook in graph3

Latest revision as of 09:31, 11 July 2016

Synopsis

Name: Menu Hook

Hook Pointer Block Address: 9BC0

Hook Enable BCALL: 5083

Hook Disable BCALL: 5086

Hook Call BCALL: (Unknown)

Hook Active Flag: 6, (iy + 36h)

The menu hook allows for modification of any of the system menus that are presented through the system monitor.

Using the Hook

This hook, like most, is called for several events, each identified by A. In general, it appears that returning with the zero flag set will cause the OS to execute its normal behavior.

I've ordered the events in the order that they are called by the OS.

  • A = 04h: This is the first event called. B contains the value of the menu about to be displayed. When this event is triggered, MenuCurrent currently contains the ID referring to the menu that was previously displayed (if you went from one menu directly to another), or 0 if previously there was no menu displayed (you were seeing the context itself.)
  • A = 00h: This is the second event, called after event 04h. This event allows you to provide your own menu table. B contains the menu ID. If you want to provide your own table, copy it to RAM, point HL to it, and return with the zero flag reset. It's called a second time, but with B being zero. The outputs appear to be the same, so handle it the same way.
  • A = 02h: This event is called before the OS draws the menu header. C is the index of the header (zero based.) Returning with zero set will draw the header, returning with zero reset will cause it to not draw the header. It's also called after it's done drawing the headers, with C is the number of headers (basically, last index plus one). Return flag seems to be ignored.
  • A = 01h: The OS is about to draw the text corresponding to a menu item. The number prefix has already been drawn. C contains the index of the item (zero indexed.) Returning with zero set will cause the OS to draw the string, returning with zero reset will cause it just to draw a blank line (but it does draw something!). To draw another token, you will need DE to be an extended keycode.
  • A = 03h: The user selected an item from the menu that is about to cause a context switch. B contains the ID of the context the calculator might switch to. You can return with zero set to execute the app, or zero reset to cancel the execution. If you're switching to a flash app (B is cxextapps), then DE also points to the end of the name of the flash app in RAM. You can cancel the execution of a flash app (this could prove useful for a security app.)

Example

This is an example of a menu table taken from graph3.

ZoomMenu:
	db 1		;how many headers?
	db 3 	;how many choices under 1st header?
	db 5Eh	;string table entry for "ZOOM"
	db 0,kZIn
	db 0,kZOut	;these are 2-byte keypresses of each entry
	db 0,kStd

Another example with more headers:

ZoomMenu:
	db 2		;how many headers?
	db 3 	;how many choices under 1st header?
	db 2 	;how many choices under 1st header?
	db 5Eh	;string table entry for "ZOOM"
	db 5Fh  ;just for fun
	db 0,kZIn	;first header
	db 0,kZOut	;these are 2-byte keypresses of each entry
	db 0,kStd
	db 0,kZIn	;second header
	db 0,kZOut	;these are 2-byte keypresses of each entry

Credits and Contributions

  • Kirk Meyer: For providing an example of this hook in graph3