Except for one nasty certificate-related page 0 call, system.asm should be fully
cleaned up now.
coorMon:
res g_style_active, (iy+sGrFlags)
call j_CursorOff
call j_COORDISP
Mon: call j_RunIndicOff
call j_CursorOn
res displayCoords, (iy+newDispF)
bit sendFinalPacketOnMon, (iy+linkFlags2)
jr z, Mon_NoPacketSend
di
res sendFinalPacketOnMon, (iy+linkFlags2)
ld hl, Mon_ResetIndicOnly
call pushErrorHandleR
set indicOnly, (iy+indicFlags)
ld a, (mcxCurApp)
cp kError
jr nz, {+}
ld a, (errNo)
call j_SendSkipExitPacket
jr Mon_LinkEnd
+: call j_SendAck
Mon_LinkEnd:
call popErrorHandleR
Mon_ResetIndicOnly:
res indicOnly, (iy+indicFlags)
ei
Mon_NoPacketSend:
xor a
ld (kbdKey), a
ld (keyExtend), a
call j_getkey
monForceKey:
res recallingPrgmName, (iy+rclFlag2)
res recallingListName, (iy+rclFlag3)
ld (kbdKey), a
bit allowCursor, (iy+plotFlags)
jr z, {+}
res curAble, (iy+curFlags)
bit curOn, (iy+curFlags)
call z, j_BLINKGCUR
ld a, (kbdKey)
jr {++}
+: call j_CursorOff
++: call j_RunIndicOn
or a
jr nz, {++}
;ON was pressed; now what?
bit appWantIntrpt, (iy+appFlags)
jr nz, {+}
res onInterrupt, (iy+onFlags)
jr jpCoorMon
+: ;Return kEnter instead
ld a, kEnter
jp sendKPress
++: cp kVarx
jr nz, monNotVarKey
ld a, kTheta
call IsFunctionMode
jr nz, {+}
ld a, kCapT
call IsParametricMode
jr nz, {+}
ld a, kCapX
call IsFuncMode
jr nz, {+}
ld a, kRecn
ld (keyExtend), a
ld a, kExtendEcho
+: ld (kbdKey), a
monNotVarKey:
res appIgnoreKey, (iy+APIFlg)
res sendKeyStraightTocxMain, (iy+APIFlg)
bit rawKeyHookActive, (iy+hookflags2)
jr z, {+}
call j_call_rawkey_hook
bit appIgnoreKey, (iy+APIFlg)
jr nz, jpCoorMon
bit sendKeyStraightTocxMain, (iy+APIFlg)
jr z, {+}
push af
jp Mon_CallcxMain
+: cp kOff
jr z, {+}
call j_PULLDOWNCHK
jr c, jpCoorMon
call j_clrTR
jr c, jpCoorMon
call IsExternalApp
+: jr z, sendKPress
cp kDoug
jr z, sendKPress
cp kListflag
jr z, sendKPress
jr Mon_Continue
-: pop hl
pop bc
djnz {+}
jpCoorMon:
jp coorMon
SendProgToEditTocxMain:
ld b, 8
ld hl, progToEdit-1
+: inc hl
ld a, (hl)
or a
jr z, jpCoorMon
push bc
push hl
ld d, 0
ld e, a
call j_TokToKey
call cxMain
res onInterrupt, (iy+onFlags)
jr {-}
Mon_Continue:
cp EchoStart
jp c, Mon_HandleNonEchoKey
cp kExtendEcho
jr z, sendKPress
cp kExtendEcho2
jr z, sendKPress
cp kExtendEcho3
jr nz, _isOtherKey
ld a, (keyExtend)
or a
jr z, {+}
cp 0Dh
jr c, _isValid3Key
cp 8Ch
jr c, Mon_HandleOurselves
cp 0A6h
jr nc, Mon_HandleOurselves
_isValid3Key:
ld a, kExtendEcho3
jr sendKPress
+: ld a, (kbdKey)
_isOtherKey:
cp 0EFh
jr nz, {+}
ld a, 0A6h
jr setKeyExtend
+: cp 0F9h
jr c, {+}
sub 14h
jr setKeyExtend
+: cp 0F3h
jr c, sendKPress
sub 7Ch
setKeyExtend:
ld (keyExtend), a
ld a, kExtendEcho
sendKPress:
cp echoStart2
jr nz, {+}
ld a, kExtendEcho2
jr setKeyExtend
+: cp echoStart1+1
jr nz, {+}
ld a, 0FDh
jr setKeyExtend
sendKPress_NamedVar:
+: cp kDoug
push af
jr nz, {+}
set recallingPrgmName, (iy+rclFlag2)
ld a, kExec
jr Mon_CallcxMain
+: pop af
cp kListflag
push af
jr nz, Mon_CallcxMain
set recallingListName, (iy+rclFlag3)
ld a, kListName
Mon_CallcxMain:
call cxMain
res onInterrupt, (iy+onFlags)
pop af
jp z, SendProgToEditTocxMain
Mon_HandleOurselves:
bit enableQueue, (iy+rclFlag)
jr z, Mon_Restart
ld de, (rclQueue)
ld hl, (editCursor)
bit useRclQueueEnd, (iy+hookflags1)
jr z, {+}
ld hl, (rclQueueEnd)
ex de, hl
+: call CpHLDE
jr nc, Mon_DisableQueueRestart
ld a, (hl)
call isPtrHLA2ByteTok
ld d, 0
ld e, a
jr nz, {+}
ld d, a
inc hl
ld e, (hl)
+: bit useRclQueueEnd, (iy+hookflags1)
jr z, {+}
inc hl
ld (rclQueue), hl
+: call j_TokToKey
jpSendKPress:
jr sendKPress
Mon_DisableQueueRestart:
res enableQueue, (iy+rclFlag)
ld hl, flags+textFlags
ld a, (promptIns)
res textInsMode, (hl)
or (hl)
ld (hl), a
Mon_Restart:
res useRclQueueEnd, (iy+hookflags1)
jp Mon
Mon_HandleNonEchoKey:
cp kApp
jr c, jpSendKPress
cp echoStart1
jr c, Mon_SwitchToStandardContext
cp kEval
jr nc, Mon_SwitchToGraphContextThenPressKey
bit prgmEdit, (iy+prgmFlags)
jr nz, jpSendKPress
cp echoStart2
jr c, Mon_SwitchToGraphContextThenPressKey
cp kPen
jr z, Mon_SwitchToGraphContextThenPressKey
cp echoStart2
jr z, jpSendKPress
ld b, a
ld a, (mcxCurApp)
cp kGraph
ld a, b
jr nz, jpSendKPress
Mon_SwitchToGraphContextThenPressKey:
ld b, a
ld a, kGraph
jr {+}
push af
Mon_SwitchToStandardContext:
ld b, a
cp kNewApps
jr nz, {+}
ld a, (keyExtend)
add a, b
cp echoStart1+1
jr nc, JForceCmdNoChar
ld b, a
+: ld c, a
ld a, (mcxCurApp)
cp kPrgmInput
jr nz, {+}
ld a, b
cp appStart
jr z, JForceCmdNoChar
ld a, kPrgmInput
jr {++}
+: cp kError
ld a, c
jr nz, {++}
cp appStart
jr nz, Mon_Restart
++: call newContext0
ld a, b
jp sendKPress_NamedVar
JForceCmdNoChar:
xor a
JForceCmd:
ld b, a
ld sp, (onSP)
res cmdExec, (iy+cmdFlags)
call SetFastSpeed
ld a, appStart
call newContext0
ld a, b
cp kExec
jr nz, {+}
ld a, kDoug
-: jp sendKPress
+: cp kListName
jr nz, {-}
ld a, kListflag
jr {-}
sysErrHandler:
ld sp, (onSP)
ld a, kError
call newContext
jp Mon
#ifndef DEVIATE_FROM_ORIGINAL_FILE
;We don't need this, I don't think.
ret
#endif
newContext:
ld c, a
sub a
ld (kbdKey), a
ld b, a
in a, (6)
push af
ld a, c
call newContext0
pop af
OutPort6:
out (6), a
ret
newContext0:
res appRetKeyOff, (iy+APIFlg)
ld hl, mcxCurApp
cp (hl)
jr nz, newContext_Start
cp kGraph
jr nz, {+}
;If you try to start the graph context again, just put it away
push bc
call j_GRPUTAWAY
pop bc
ret
+: ;We're allowed to re-start the homescreen context again
cp appStart
jr z, newContext_Start
ld b, kApp
ret
newContext_Start:
push bc
push af
pop af
cp kInputDone
jr nz, {+}
ld a, appStart
push af
xor a
jr newContext_Init
+: push af
sub appStart
jr nz, newContext_Init
res cmdExec, (iy+cmdFlags)
newContext_Init:
call j_InitContextA
pop af
push hl
push af
res curLock, (iy+curFlags)
call cxPPutAway2
pop af
push af
ld b, a
ld a, (mcxCurApp)
cp kPrgmCr
ld a, b
jr z, _notProgramEditor
bit prgmEdit, (iy+prgmFlags)
jr z, _notProgramEditor
cp kFormat
jr z, _skipPutAway
cp kMode
jr z, _skipPutAway
cp kTblSet
jr z, _skipPutAway
_notProgramEditor:
;In program editor context, or
;NOT in program editor, or
;NOT in FORMAT, MODE, or TBL SET contexts
call j_RefreshSplitGraphTableFlags
cp kError
jr z, _skipPutAway
call call_cxPutAway
call IsExternalApp
call z, SetFastSpeed
_skipPutAway:
ld a, (mcxCurApp)
pop bc
push af
push bc
cp kError
jr nz, {+}
call j_POPCX
call cxPutAway_NoPartial
call IsExternalApp
call z, SetFastSpeed
+: ld hl, mcxMain
ld de, mcxPrev
ld bc, 14
ldir
ld a, (appFlagsAddr)
ld (de), a
pop af
push af
cp kTable
jr nz, {+}
call j_SetVertSplitRedisplayFlags
jr newContext_Finish
+: cp kGraph
call z, j_SetVertSplitRedisplayFlags
jr z, {+}
set NEED_BUFCPY, (iy+VERTFLAG2)
set NEED_RETABLE, (iy+VERTFLAG2)
jr newContext_Finish
+: call ResetSplitOverride
call CheckSplitFlag
jr z, newContext_Finish
ld a, (mcxCurApp)
call j_CompareContext
jr nz, newContext_Finish
ld a, appStart
ld (mcxCurApp), a
ld hl, j_InitHomescreenContext
ld a, (iy+shiftFlags)
push af
ld a, appstart
call CallAppChangeRoutineHL
call cxPutAway
pop af
ld (iy+shiftFlags), a
newContext_Finish:
pop af
pop bc
cp kPrgmEd
jr nz, _notPrgmEd
push af
ld a, b
cp kError
jr z, {+}
set promptEdit, (iy+promptFlags)
+: pop af
_notPrgmEd:
pop hl
ld (mcxCurApp), a
pop af
CallAppChangeRoutineHL:
bit appChangeHookActive, (iy+hookflags4)
call nz, j_call_appchange_hook
push af
set monAppInit, (iy+monFlags)
call jpHL
res monAppInit, (iy+monFlags)
pop bc
ret
ldHLind_AWord:
add a, a
ld e, a
ld d, 0
add hl, de
jp ldHLind
cxPutAway:
call cxPPutAway2
cxPutAway_NoPartial:
call call_cxPutAway
ResetPromptEditFlag:
res promptEdit, (iy+promptFlags)
ret
cxPPutAway2:
bit nocxPutAway, (iy+contextFlags)
ret nz
push hl
ld hl, (mcxPPutAway)
call CallCxRoutineHL
jr {+}
call_cxPutAway:
bit nocxPutAway, (iy+contextFlags)
ret nz
push hl
ld hl, (mcxPutAway)
call CallCxRoutineHL
call zero_basic_prog
+: pop hl
jp CancelAlpha
cxRedisp:
ld hl, (mcxRedisp)
jr CallCxRoutineHL
cxSizeWind:
bit monAppInit, (iy+monFlags)
push af
ld a, (menuActive)
ld b, a
ld hl, (mcxSizeWind)
call CallCxRoutineHL
pop af
ret
cxErrEP:
ld hl, (mcxErrorEP)
CallCxRoutineHL:
in a, (6)
push af
ld a, (mcxPage)
call OutPort6
call jpHL
pop af
call OutPort6
ret
cxMain: push hl
ld hl, (mcxMain)
push af
ld a, (mcxPage)
call OutPort6
pop af
call jpHL
pop hl
ret
jpHL: jp (hl)
call_cxPrevRedisp:
ld a, (cxPrevPage)
call OutPort6
ld hl, (cxPrevRedisp)
jr jpHL
monErrHand:
ld hl, monErrHand
call pushErrorHandleR
ld a, kError
call newContext0
jp Mon
#ifndef DEVIATE_FROM_ORIGINAL_FILE
;I don't think this is used *anywhere*.
push hl
ld hl, 100
jr AppInitEnoughMemHL
#endif
AppInitEnoughMem50:
push hl
ld hl, 50
AppInitEnoughMemHL:
call EnoughMem
jp c, ErrMemory_NoGoTo
pop hl
AppInit:
ld de, mcxMain
ld bc, 12
ldir
ld a, (hl)
ld (appFlagsAddr), a
in a, (6)
ld (mcxPage), a
ret
IsExternalApp:
ld b, a
ld a, (mcxCurApp)
cp kExtApps
ld a, b
ret
handleONKeyPress:
;Switch to slow speed
in a, (2)
and 80h
jr z, {+}
in a, (20h)
ld e, a
xor a
out (20h), a
+: ld b, 0
debounceRestart:
ld hl, 1016h
debounceLoop:
in a, (4)
and 8
cp b
ld b, a
jr nz, debounceRestart
dec hl
ld a, l
or h
jr nz, debounceLoop
cp b
jr z, ONKeyBeingPressed
;ON key is being released
in a, (7)
ld b, a
in a, (2)
and 80h
jr z, {+}
;Restore previous speed
ld a, e
out (20h), a
ld a, b
cp 81h
jr isRAMUnhooked
+: ld a, b
and 4Fh
cp 41h
isRAMUnhooked:
jp nz, RAMUnhookedWaitForPowerOn
bit onRunning, (iy+onFlags)
ret nz
;ON key being released and we're just off, so just return from the interrupt handler
pop hl
sub a
push af
ld a, 8
out (3), a
pop af
out (3), a
ld a, 11h
jp noSecondHardwareTimer
ONKeyBeingPressed:
;Restore previous speed
in a, (2)
and 80h
jr z, HandlePowerOnRequest
ld a, e
out (20h), a
.module HandlePowerOnRequest
HandlePowerOnRequest:
ld a, 76h
out (4), a
in a, (2)
and 80h
jr z, {+}
in a, (7)
cp 81h
jr _isRAMUnhooked
+: in a, (7)
and 4Fh
cp 41h
_isRAMUnhooked:
jp nz, HookRAMAndPowerOn
bit shift2nd, (iy+shiftFlags)
jp z, HandleONPressed
;2nd is being pressed, so we might be turning off
bit enableKeyEcho, (iy+hookflags1)
jr nz, {+}
bit appRetKeyOff, (iy+APIFlg)
jr z, PowerOff
+: set kOffPressed, (iy+APIFlg)
ret
.endmodule
.module PowerOff
PowerOff:
ld a, 8
push af
ld a, 8
out (3), a
pop af
out (3), a
call TurnOffLCD
bit resetOnPowerOn, (iy+selfTestFlag)
jr z, {+}
;If above flag is set and APD is disabled, skip RAM checksum generation (forcing a reset)
bit apdAble, (iy+apdFlags)
jr z, _skipRAMChecksum
+: call SetFastSpeed
call PreviousContext_CloseAnyOpenMenu
call j_hideCursor
set monAbandon, (iy+monFlags)
ld hl, lcdFlag
set powerLcdForGC, (hl)
call forcecmd
ld hl, lcdFlag
res powerLcdForGC, (hl)
res monAbandon, (iy+monFlags)
bit alt_Off, (iy+hookflags1)
call nz, j_ExecuteOFFSCRPT
_DoShutDown:
call j_SetupDBusMem
ld a, 8
out (3), a
call TurnOffLCD
ld hl, flags+onFlags
bit onClearScrn, (hl)
res onClearScrn, (hl)
call nz, j_ClrScrn
call calculateRAMChecksum
ld (RAMChecksum), hl
_skipRAMChecksum:
res bPLinkOn, (iy+hookflags1)
res enableKeyEcho, (iy+hookflags1)
ld a, 36h
out (4), a
ld a, 11h
out (3), a
res shift2nd, (iy+shiftFlags)
res onRunning, (iy+onFlags)
ex af, af'
exx
ei
-: halt
jr {-}
.endmodule
HandleONPressed:
res checkNoBatteriesNextTime, (iy+batteryFlags2)
call ApdSetup
bit onRunning, (iy+onFlags)
jr nz, SetOnInterruptFlag
HandleONPressed_WasOff:
set onRunning, (iy+onFlags)
ld hl, flags+apdFlags
bit APDWarmStart, (hl)
res APDWarmStart, (hl)
jr nz, restoreToPoweredOn
res indicInUse, (iy+indicFlags)
bit resetOnPowerOn, (iy+selfTestFlag)
jr z, {+}
bit 2, (hl)
jp z, resetRam
+: ld sp, (onSP)
call j_resetStacks
xor a
ld (MenuCurrent), a
call refreshSystemRAM
call PowerOn
call j_SetExecutionPermissionsAndDeleteOldApps
bit cmdExec, (iy+cmdFlags)
call nz, j_SetupLastEntryEditResetFlags
ei
jp Mon
restoreToPoweredOn:
bit alt_On, (iy+hookflags1)
call nz, j_ExecuteONSCRPT
ld a, 8
push af
ld a, 8
out (3), a
pop af
out (3), a
call j_RstrOScreen
pop de
pop de
pop de
set APDRunning, (hl)
call PowerOn
ex af, af'
exx
ei
reti
SetOnInterruptFlag:
set onInterrupt, (iy+onFlags)
ret
HookRAMAndPowerOn:
ld a, 76h
out (4), a
ld a, 0C0h
out (0), a
in a, (2)
and 80h
ld a, 41h
jr z, {+}
ld a, 1
out (20h), a
xor a
out (0Fh), a
ld a, 81h
+: out (7), a
xor a
push af
ld a, 8
out (3), a
pop af
out (3), a
ld iy, flags
call NZIf83Plus
call z, j_ResetIOPorts
ld hl, (RAMChecksum)
ld de, 0A55Ah
call CpHLDE
jp z, doFunkyTurnOnFromA55AChecksum
call NZIf83Plus
jr z, {+}
;The loading of B here is to see if the boot code sets it to 1.
;This indicates a change in LCD hardware and requires a different contrast setting.
ld b, 0
B_CALL(_getHardwareVersion)
bit 0, b
ld a, 1Fh
jr z, {++}
ld a, 1Ch
jr {++}
+: ld a, 17h
++: ld (contrast), a
call calculateRAMChecksum
ld de, (RAMChecksum)
call CpHLDE
jr nz, resetRam
dec de
ld (RAMChecksum), de
call j_SetExecutionPermissions
call PreviousContext_CloseAnyOpenMenu
ld a, 0Bh
out (3), a
res apdWarmStart, (iy+apdFlags)
call forcecmd
jp HandleONPressed_WasOff
resetRam:
di
ld hl, 8000h
ld de, 8001h
ld bc, 7FFFh
ld (hl), 0
ldir
ld hl, 0109h
ld (localLanguage), hl
;#ifdef DEVIATE_FROM_ORIGINAL_FILE
; call NZIfColorModel
; jr z, {+}
; set 0, (iy+asm_Flag3)
;+:
;#endif
resetRam_AfterMemClear:
ld a, 0C0h
out (0), a
ld sp, 0FFF7h
call j_SetupHomescreen_RecreateSystemVars
ld hl, monErrHand
call pushErrorHandleR
ld (onSP), sp
call j_DisplayCalcModelAndOSVersion
jp j_DisplayRAMCleared
page0_9F8:
di
ld a, 0C0h
out (0), a
ld sp, 0FFF7h
ld hl, 8000h
ld de, 8001h
ld bc, 7FFFh
ld (hl), 0
ldir
ld hl, 0109h
ld (localLanguage), hl
call j_SetupHomescreen_RecreateSystemVars
ld hl, monErrHand
call pushErrorHandleR
ld (onSP), sp
call j_DisplayCalcModelAndOSVersion
jp j_DisplayMemCleared
GetKey_ClearScrn_MonForceKey:
call GetCSC
set onClearScrn, (iy+onFlags)
call j_getkey
call j_ClrScrn
res onClearScrn, (iy+onFlags)
jp monForceKey
calculateRAMChecksum:
push ix
ld ix, userMem
ld bc, 60DBh
ld hl, 11h
ld d, h
-: ld e, (ix+0)
inc ix
add hl, de
dec bc
ld a, c
or b
jr nz, {-}
ld e, d
ex de, hl
sbc hl, de
pop ix
ret
forcecmd:
call CanAlphIns
res textInverse, (iy+textFlags)
call j_Disp
res cmdExec, (iy+cmdFlags)
ld a, appStart
jp newContext0
bootCalc:
call SetSlowSpeed
ld a, 77h
out (4), a
ld b, 0
ld sp, 0FDFAh
-: djnz $
ld ix, 1
add ix, sp
ld sp, ix
jr nc, {-}
ld sp, 0FFC5h
in a, (2)
and 80h
jr z, {+}
ld a, 1
out (20h), a
+: ld a, 77h
out (4), a
im 1
ld a, 0C0h
out (0), a
RAMUnhookedWaitForPowerOn:
ld a, 37h
out (4), a
sub a
push af
ld a, 8
out (3), a
pop af
out (3), a
ld a, 11h
out (3), a
ei
halt
lcd_busy:
push af
-: in a, (2)
and 2
jr z, {-}
pop af
ret
TurnOffLCD:
ld a, 2
OutLCDCommand:
push af
loop: in a, (2)
and 2
jr z, loop
pop af
out (10h), a
ret
smallDelay:
push af
inc hl
dec hl
pop af
ret
slowDelay:
ld a, 0FFh
slowDelayA:
push af
call forceSlowSpeed
pop af
delayLoop:
call smallDelay
dec a
jr nz, delayLoop
call restorePreviousSpeed
ret
PowerOn:
ld a, 0Bh
out (3), a
call j_LCD_DRIVERON
call Chk_Batt_Low_2
ret nz
call refreshSystemRAM
in a, (2)
bit 0, a
jp z, PowerOff._skipRAMChecksum
PowerOn_SkipLCDAndBatteryCheck:
call j_ClearScreen_SetupAPDFromPowerOn
call forcecmd
jp j_DisplayLowBattRecommendChange
Chk_Batt_Low_2:
call refreshSystemRAM
Chk_Batt_Low:
ld a, 76h
out (4), a
ld a, 0F6h
out (4), a
ld b, 5
longerDelay:
call slowDelay
djnz longerDelay
set battGoodTemp, (iy+timerFlags)
in a, (2)
bit 0, a
jr nz, {+}
res battGoodTemp, (iy+timerFlags)
+: ld a, 76h
out (4), a
ld a, 0Ah
call slowDelayA
ld a, 76h
out (4), a
bit battGoodTemp, (iy+timerFlags)
ret
.module RefreshSystemRAM
refreshSystemRAM:
ld bc, 2710h
ld hl, ramStart
-: ld a, (hl)
ld (hl), a
dec bc
ld a, b
or c
jr nz, {-}
ret
.endmodule
doFunkyTurnOnFromA55AChecksum:
ld hl, 0
ld (RAMChecksum), hl
ld sp, (onSP)
ld iy, flags
call Page0Call_3EE5 ;TODO: Uh...come back to this one.
call PreviousContext_CloseAnyOpenMenu
call forcecmd
res apdWarmStart, (iy+apdFlags)
bit cmdExec, (iy+cmdFlags)
call nz, j_SetupLastEntryEditResetFlags
ld a, 0Bh
out (3), a
call j_LCD_DRIVERON
set onRunning, (iy+onFlags)
call Chk_Batt_Low_2
call z, PowerOn_SkipLCDAndBatteryCheck
bit alt_On, (iy+hookflags1)
call nz, j_ExecuteONSCRPT
ei
jp Mon
PreviousContext_CloseAnyOpenMenu:
call IsInMenu
jr z, PreviousContext
xor a
ld (MenuCurrent), a
call j_rstrpartial
PreviousContext:
call j_PrevContext
ret
IsInMenu:
ld b, a
ld a, (MenuCurrent)
or a
ld a, b
ret
SetSlowSpeed:
call NZIf83Plus
ret nz
jr {+}
forceSlowSpeed:
call NZIf83Plus
ret nz
in a, (20h)
ld (oldSESpeed), a
+: push af
xor a
out (20h), a
pop af
ret
restorePreviousSpeed:
call NZIf83Plus
ret nz
ld a, (oldSESpeed)
and 1
out (20h), a
ret
SetExSpeed:
or a
SetSpeed_NZForFast:
jr z, SetSlowSpeed
SetFastSpeed:
push af
call NZIf83Plus
jr nz, {+}
ld a, 1
out (20h), a
+: pop af
ret
RestoreCPUSpeed_SE:
pop af
push hl
ld hl, hookNestCount
dec (hl)
pop hl
call NZIf83Plus
jr nz, {+}
and 1
out (20h), a
+: pop af
pop af
pop af
ret