83Plus:Hooks:9B90
Synopsis
Name: Window Hook
Hook Pointer Block Address: 9B90
Hook Enable BCALL: 4FB1
Hook Disable BCALL: 4FB4
Hook Call BCALL: Unknown
Hook Active Flag: 2, (iy + 35h)
This hook is triggered when various events occur on the Window screen (where you adjust the Xmin, Xmax, etc. values). It is also called for the finance solver and TblSet interfaces.
This hook is based around a special table which is documented in the comments section below. It might help to read that section first. It should be noted that returning with zero set will let the normal flow of code happen.
Using the Hook
Events are determined by the accumulator, as usual.
- A = 04h: The WINDOW title is about to be displayed. Returning with zero reset will cancel this drawing; you can draw your own title.
- A = 00h: The OS wants to know the value at IX. This is done because your table might be on another page than the os code that wants to read. Thus if you haven't changed the table(IX) or if you use your own table that is stored in ram, return with zero set. If you use your own table stored in flash, you have to return the value at IX in A and return with zero reset. You can use the following code to do that:
or 1 \ ld a, (ix+0) \ ret
- A = 01h: The same as above only the OS wants the value at IX+3. This would give the following code when using your own table in flash:
or 1 \ ld a, (ix + 3) \ ret
- A = 02h: The same as above only the OS wants the value at IX-3. This would give the following code when using your own table in flash:
or 1 \ ld a, (ix - 3) \ ret
- A = 03h: Draw the table item pointed by IX. curRow and curCol are already setup for outputting the prompt (the Xmin=-style thing.) After showing this prompt, B_CALL SetNumWindow. Then, output the number (see message 9 below.) and return with zero reset. If you don't use your own flash stored table, don't do any of the above and just return with zero set.
- A = 05h: We are about to edit an entry. HL is a pointer to the table entry corresponding to the entry to edit. You need to set OP1 to the value in the editing field and return with zero reset. (So say you type something into Xmin, you must set OP1 to the value of Xmin here.) If you return with zero set, the os will try to read the value at HL and use it to recall the system token specified by it. (This will only work correctly if you use a table stored in ram or the default os table.)
- A = 06h: We are done editing an entry. HL points to the table entry that we are done editing, and the value is in OP1. You probably want to save this value.
- A = 07h: The hook needs the address of the first real entry in the table returned in HL (not one of the start/end entries.) See the comments section for details.
- A = 09h: We are going to display one of the numbers. HL is pointing to the appropriate table entry. You probably want to copy the number into OP1 and execute the following code (see the docs for 83Plus:BCALLs:4990:FormEReal and WPutSEOL for more info):
ld a, 15h B_CALL FormEReal ld hl, OP3 B_CALL WPutSEOL
- A = 0Ah: A key was pressed, the keycode is in B. You can modify this as needed.
Comments
The table is the most important part of the hook, which tells what you want the table to look like. Each record in the table is three bytes. The first byte is simply a value which you can use to identify the entry. It can be a memory offset (one byte only), token identifier, keypress equate, or any other one byte value. If you use a table stored in ram and let the os handle events 05h,06h and 09h (by returning with zero set), it will interpret it as a token identifier to be displayed or stored. However, it has one special value, 0FFh, which means this record indicates either the start or end of the table. The second and third bytes are simply the pointer to the string to be displayed, null terminated as usual.
Here's an example table:
db 0FFh ; Dummy Entry signifying start of table dw 0 ; Doesn't matter on string pointer TableStart: db 0 ; Identifier dw EntryString1 ; Pointer to string ; Simply using this assemble trick is perfect db 1 ; Same as above dw EntryString2 ; Same as above db 0FFh ; Dummy Entry signifying end of table ; No need for string pointer, the OS never checks EntryString1: db "Var=", 0 EntryString2: db "Var2=", 0
When you pass the table pointer in message 7, pass "TableStart" as indicated above, as that is the first entry to be displayed.
NOTE: If you read the documentation above precisely you will see that the os never directly reads the table. Thus if you're feeling adventurous, you don't have to use this table at all.
Credits and Contributions
- Kirk Meyer: For Graph3, which uses this hook and provided a working example of the hook.