GetTrapAddress
#include <OSUtils.h> Operating System Utilities
short trapNum ; trap number of system routine. See TrapWords. returns address of the trap handler
GetTrapAddress returns the address of a system routine - an element of the trap dispatch table. This can be used to intercept or patch ROM routines. Use
more information).
trapNum identifies the ROM routine whose address you want.
Returns: a 32-bit value; the address of the system routine that corresponds to trapNum.
Notes: GetTrapAddress can help you to speed up your program. Also, if you know what you're doing, its possible to intercept OS or Toolbox calls and
perform pre- or post- processing, or even replace the function altogether.
Note: If a ROM routine has already been patched, you should NOT do any post- processing. And in any case, you must preserve the registers and
maintain the stack. Check the return value of GetTrapAddress against the global variable ROMBase to see if the trap has already been re directed to a
RAM address (lower in memory than ROM).
If you call a ROM or OS routine directly instead of using a trap or glue, you
lose one level of register saves. Be aware that registers A2-A6 and D3-D7
will be p reserved, but all others may be modified.
The trap dispatcher changed between the 64K and 128K ROMs. Before
value of trapNum must be correct for that version of the ROM.