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

From WikiTI
Jump to: navigation, search
 
Line 1: Line 1:
'''Note:''' Do not take the information on this template page as actual documentation!
+
== Synopsis ==
 +
'''Name:''' Parser Hook
  
The Hooks are named by their hook pointer block address (the four bytes consisting of page, address, and an extra byte), in hexadecimal. An example is [[83Plus:Hooks:9B84]].
+
'''Hook Pointer Block Address:''' [[83Plus:RAM:9BAC|9BAC]]
  
----
+
'''Hook Enable BCALL:''' [[83Plus:BCALLs:5026|5026]]
  
== Synopsis ==
+
'''Hook Disable BCALL:''' [[83Plus:BCALLs:5029|5029]]
'''Name:''' ImAHook
+
  
'''Hook Pointer Block Address:''' [[83Plus:RAM:8562|8562]]
+
'''Hook Call BCALL:''' ''(none known)''
  
'''Hook Enable BCALL:''' [[83Plus:BCALLs:1234|1234]]
+
'''Hook Active Flag:''' [[83Plus:Flags:36#Bit_1|1, (iy + 36h)]]
  
'''Hook Disable BCALL:''' [[83Plus:BCALLs:5678|5678]]
+
This hook allows you to change the behavior of the TI-BASIC parser and functions.
  
'''Hook Call BCALL:''' [[83Plus:BCALLs:9012|9012]]
+
== Using the Hook ==
 +
These different values, passed in A, determine what the hook should do.
 +
* 0: The calculator is about to parse a variable.
 +
** OP1 = name of variable to be parsed.
 +
** Return Z if the variable should be parsed normally.
 +
* 1-3: A BASIC function has been encountered.  The various types are described below.
 +
** BC identifies the particular function within the class.  For many 1-byte tokens, B is the token itself; for many others, B is the OP-number given in ti83plus.inc (although some of these are incorrect.)
 +
** Return Z to run the standard function.
  
'''Hook Active Flag:''' 6, (iy + 23h)
+
=== Class 1 Functions ===
  
This hook allows you to change the values that [[83Plus:BCALLs:4972|GetKey]] returns.
+
Class 1 tokens all take some positive number of arguments (zero arguments is a syntax error.)  These are separated by commas, or in the case of binary operators, by the operator itself. All of the arguments are evaluated before the function is.
  
== Using the Hook ==
+
The arguments are placed on the FPS in "reverse" order.  That is to say, the earliest argument read is deepest in the stack. The final argument is in OP1.  The total number of arguments is passed in HL.
These different values, passed in a, determines what the hook should do.
+
 
* 1: The calculator just turned on. There seem to be no other values passed to the hook.
+
Any of the following data types may be used (except where prohibited by syntax rules): Real, List, Matrix, Equation, String, Complex, Complex List.  Real numbers are stored on the stack as floating-point. Complex numbers are stored as two consecutive stack entries or in OP1 and OP2 (see the SDK documentation for Push/Pop OP1/3/5.)  Other data types are stored as variable names.
* 2: The calculator is computing 1+1.
+
 
** b: 1
+
A hook may do any of the following:
** c: 1
+
* Leave all arguments as is, and return Z.
** Change b and/or c to affect the output of the problem (which will still look like 1+1 to the user).
+
* Modify arguments, or add or remove them while updating HL appropriately, and return Z.
* 3: Preparing to turn off due to 2nd+OFF.
+
* Remove all arguments from the FPS, place the result of your computation in OP1, and return NZ.
** Zero flag: Clear to abort the power off.
+
* Remove all arguments from the FPS, reset [[83Plus:Flags:7#Bit0|numOP1,(iy+ParsFlag2)]], and return NZ. (This is generally preferable if you are not returning a useful value, as it will preserve Ans.)
 +
 
 +
=== Class 2 Functions ===
 +
 
 +
These include most "programming" commands.  No arguments are parsed.
 +
 
 +
You may, if you are prepared to face the consequences, attempt to read the arguments yourself. The undocumented B_CALL [[83Plus:BCALLs:4B73|IncFetch]] can be useful in doing so.
 +
 
 +
If you return Z, the parser will run the function normally.  If you return NZ, the parser will continue execution from where you left off.
 +
 
 +
=== Class 3 Functions ===
 +
 
 +
If very little is known about class 2, less is known about class 3.  Tenatively, it looks like the class 2 functions that you would expect to be class 1 have class 3 secondary callbacks.
  
== Comments ==
+
It looks like the parameters are stored in OP1 and the FPS as in class 1, but there is the rather significant problem that the number of arguments is not in HL.  If it's stored somewhere else, I don't know about it, though I haven't looked very hard.
This hook doesn't exist. This is a demonstration only.
+
  
 
== Credits and Contributions ==
 
== Credits and Contributions ==
* '''/dev/hda1:''' My favorite hard drive partition.
+
* '''Brandon Sterner:''' Analysis, and the Symbolic source code.
 +
* '''Michael Vincent:''' The Omnicalc source code.

Revision as of 00:04, 28 March 2005

Synopsis

Name: Parser Hook

Hook Pointer Block Address: 9BAC

Hook Enable BCALL: 5026

Hook Disable BCALL: 5029

Hook Call BCALL: (none known)

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

This hook allows you to change the behavior of the TI-BASIC parser and functions.

Using the Hook

These different values, passed in A, determine what the hook should do.

  • 0: The calculator is about to parse a variable.
    • OP1 = name of variable to be parsed.
    • Return Z if the variable should be parsed normally.
  • 1-3: A BASIC function has been encountered. The various types are described below.
    • BC identifies the particular function within the class. For many 1-byte tokens, B is the token itself; for many others, B is the OP-number given in ti83plus.inc (although some of these are incorrect.)
    • Return Z to run the standard function.

Class 1 Functions

Class 1 tokens all take some positive number of arguments (zero arguments is a syntax error.) These are separated by commas, or in the case of binary operators, by the operator itself. All of the arguments are evaluated before the function is.

The arguments are placed on the FPS in "reverse" order. That is to say, the earliest argument read is deepest in the stack. The final argument is in OP1. The total number of arguments is passed in HL.

Any of the following data types may be used (except where prohibited by syntax rules): Real, List, Matrix, Equation, String, Complex, Complex List. Real numbers are stored on the stack as floating-point. Complex numbers are stored as two consecutive stack entries or in OP1 and OP2 (see the SDK documentation for Push/Pop OP1/3/5.) Other data types are stored as variable names.

A hook may do any of the following:

  • Leave all arguments as is, and return Z.
  • Modify arguments, or add or remove them while updating HL appropriately, and return Z.
  • Remove all arguments from the FPS, place the result of your computation in OP1, and return NZ.
  • Remove all arguments from the FPS, reset numOP1,(iy+ParsFlag2), and return NZ. (This is generally preferable if you are not returning a useful value, as it will preserve Ans.)

Class 2 Functions

These include most "programming" commands. No arguments are parsed.

You may, if you are prepared to face the consequences, attempt to read the arguments yourself. The undocumented B_CALL IncFetch can be useful in doing so.

If you return Z, the parser will run the function normally. If you return NZ, the parser will continue execution from where you left off.

Class 3 Functions

If very little is known about class 2, less is known about class 3. Tenatively, it looks like the class 2 functions that you would expect to be class 1 have class 3 secondary callbacks.

It looks like the parameters are stored in OP1 and the FPS as in class 1, but there is the rather significant problem that the number of arguments is not in HL. If it's stored somewhere else, I don't know about it, though I haven't looked very hard.

Credits and Contributions

  • Brandon Sterner: Analysis, and the Symbolic source code.
  • Michael Vincent: The Omnicalc source code.