83Plus:Hooks:9B90

From WikiTI
Revision as of 14:42, 2 June 2005 by JasonM (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Synopsis

Name: Window Hook

Hook Pointer Block Address: 9B90

Hook Enable BCALL: 4FB1

Hook Disable BCALL: 4FB4

Hook Call BCALL: 9012

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.

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: Execute this code (just paste this right into your routine):
or 1 \ ld a, (ix) \ ret
  • A = 01h: Execute this code (same as above):
or 1 \ ld a, (ix + 3) \ ret
  • A = 02h: Execute this code (ditto):
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.)
  • 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. (So say you type something into Xmin, you must set OP1 to the value of Xmin here.)
  • 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 (not one of the start/end entries.)
  • 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 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. 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               ; Lets identify the first item by a value of 0
    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.

Credits and Contributions

  • Kirk Meyer: For Graph3, which uses this hook and provided a working example of the hook.