cpct_removeInterruptHandler.s | |
Functions | |
cpct_disableFirmware | Disables Amstrad CPC firmware, preventing it from being executed at every CPU interrupt. |
cpct_removeInterruptHandler | Sets nothing as interrupt handler (returns every time it is called). |
Disables Amstrad CPC firmware, preventing it from being executed at every CPU interrupt.
u16 cpct_disableFirmware ()
call cpct_disableFirmware_asm
<u16> | Pointer to present interrupt handler (normally, pointer to firmware ROM code). This value should be stored to restore it later, if required. |
This function is exactly the same as cpct_removeInterruptHandler, as firmware is executed as an interrupt handler, and disabling them is nothing more than removing it. For more details on how it works, see cpct_removeInterruptHandler
HL
16 bytes
Case | microSecs (us) | CPU Cycles -------------------------------------- Any | 22 | 88 --------------------------------------
This function was initially based on cpc_disableFirmware function from CPCRSLib by Raul Simarro.
Sets nothing as interrupt handler (returns every time it is called). It returns previous interrupt handler for restoration purposes.
u16 cpct_removeInterruptHandler ()
call cpct_removeInterruptHandler_asm
(u16, HL) | Previous interrupt code pointer located at 0x0039. |
This function sets Interrupt Mode to 1 (call 0x0038 every time a maskable interrupt happens) and then writes assembly instructions EI : RET at 0x0038. (0xC9FB --> 0xFB = EI, 0xC9 = RET). This makes the CPU directly return every time an interrupt creates a jump to 0x0038 (6 times per frame, 300 times per second).
This function retrieves previous interrupt handler before setting it. This previous interrupt handler is returned. You may store it as a 16-bits value and use it again to restore it later on if you wanted.
Modifying the interrupt vector, this function also disables firmware, as firmware will not be called again. Firmware routines are executed as a interrupt handler and the ROM entry point is stored at 0x0039 (a 16-bit address where the firmware code starts).
Before inserting 0xC9FB at 0x0038, the 2 bytes lying at 0x0039 are saved into DE. These 2 bytes are returned to the caller, to let them be stored and restored later on, if normal firmware operation (or previous interrupt handler) is required again. cpct_reenableFirmware may be used for this restoring operation.
HL
16 bytes
Case | microSecs (us) | CPU Cycles ------------------------------------- Any | 22 | 88 -------------------------------------