diff -r ba7bd14b7d7b -r 9ef17625274f source/page00/system.asm --- a/source/page00/system.asm Thu May 15 05:38:01 2014 -0400 +++ b/source/page00/system.asm Tue May 20 02:59:10 2014 -0400 @@ -304,7 +304,7 @@ ld a, c call newContext0 pop af -sub_630: +OutPort6: out (6), a ret @@ -330,59 +330,59 @@ push af pop af cp kInputDone - jr nz, page0_65B + jr nz, {+} ld a, appStart push af xor a - jr page0_664 -page0_65B: - push af -page0_65C: + jr newContext_Init ++: push af sub appStart - jr nz, page0_664 + jr nz, newContext_Init res cmdExec, (iy+cmdFlags) -page0_664: - call Page0Call_3F51 +newContext_Init: + call j_InitContextA pop af push hl push af res curLock, (iy+curFlags) - call cxPutAway2 + call cxPPutAway2 pop af push af ld b, a ld a, (mcxCurApp) cp kPrgmCr ld a, b - jr z, page0_68E + jr z, _notProgramEditor bit prgmEdit, (iy+prgmFlags) - jr z, page0_68E + jr z, _notProgramEditor cp kFormat - jr z, page0_69E + jr z, _skipPutAway cp kMode - jr z, page0_69E + jr z, _skipPutAway cp kTblSet - jr z, page0_69E -page0_68E: - call Page0Call_3F57 + 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, page0_69E - call cxPPutAway + jr z, _skipPutAway + call call_cxPutAway call IsExternalApp call z, SetFastSpeed -page0_69E: +_skipPutAway: ld a, (mcxCurApp) pop bc push af push bc cp kError - jr nz, page0_6B4 + jr nz, {+} call j_POPCX - call sub_73D + call cxPutAway_NoPartial call IsExternalApp call z, SetFastSpeed -page0_6B4: - ld hl, mcxMain ++: ld hl, mcxMain ld de, mcxPrev ld bc, 14 ldir @@ -390,57 +390,54 @@ ld (de), a pop af push af - cp 4Ah - jr nz, page0_6CE - call Page0Call_3F63 - jr page0_707 -page0_6CE: - cp kGraph - call z, Page0Call_3F63 - jr z, page0_6DF - set 6, (iy+1Dh) - set 7, (iy+1Dh) - jr page0_707 -page0_6DF: - call page0_17DB + 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, page0_707 + jr z, newContext_Finish ld a, (mcxCurApp) call j_CompareContext - jr nz, page0_707 + jr nz, newContext_Finish ld a, appStart ld (mcxCurApp), a - ld hl, Page0Call_3F6F - ld a, (iy+12h) + ld hl, j_InitHomescreenContext + ld a, (iy+shiftFlags) push af ld a, appstart - call sub_71D + call CallAppChangeRoutineHL call cxPutAway pop af - ld (iy+12h), a -page0_707: + ld (iy+shiftFlags), a +newContext_Finish: pop af pop bc - cp 46h ; 'F' - jr nz, page0_718 + cp kPrgmEd + jr nz, _notPrgmEd push af ld a, b cp kError - jr z, page0_717 + jr z, {+} set promptEdit, (iy+promptFlags) -page0_717: - pop af -page0_718: ++: pop af +_notPrgmEd: pop hl ld (mcxCurApp), a pop af -sub_71D: +CallAppChangeRoutineHL: bit appChangeHookActive, (iy+hookflags4) call nz, j_call_appchange_hook push af - set 5, (iy+1) + set monAppInit, (iy+monFlags) call jpHL - res 5, (iy+1) + res monAppInit, (iy+monFlags) pop bc ret @@ -452,98 +449,93 @@ jp ldHLind cxPutAway: - call cxPutAway2 -sub_73D: - call cxPPutAway -page0_740: + call cxPPutAway2 +cxPutAway_NoPartial: + call call_cxPutAway +ResetPromptEditFlag: res promptEdit, (iy+promptFlags) ret -cxPutAway2: +cxPPutAway2: bit nocxPutAway, (iy+contextFlags) ret nz push hl ld hl, (mcxPPutAway) -page0_74E: - call sub_77F - jr page0_762 - -cxPPutAway: + call CallCxRoutineHL + jr {+} +call_cxPutAway: bit nocxPutAway, (iy+contextFlags) ret nz push hl ld hl, (mcxPutAway) - call sub_77F + call CallCxRoutineHL call zero_basic_prog -page0_762: - pop hl -page0_763: ++: pop hl jp CancelAlpha cxRedisp: - ld hl, (unk_8593) - jr sub_77F + ld hl, (mcxRedisp) + jr CallCxRoutineHL cxSizeWind: - bit 5, (iy+1) + bit monAppInit, (iy+monFlags) push af ld a, (menuActive) ld b, a -page0_774: ld hl, (mcxSizeWind) -sub_777: - call sub_77F + call CallCxRoutineHL pop af ret cxErrEP: ld hl, (mcxErrorEP) -sub_77F: +CallCxRoutineHL: in a, (6) push af ld a, (mcxPage) - call sub_630 + call OutPort6 call jpHL pop af - call sub_630 + call OutPort6 ret -cxMain: - push hl +cxMain: push hl ld hl, (mcxMain) push af ld a, (mcxPage) - call sub_630 + call OutPort6 pop af call jpHL pop hl ret -jpHL: - jp (hl) +jpHL: jp (hl) -page0_7A2: - ld a, (unk_85A7) - call sub_630 - ld hl, (unk_85A1) +call_cxPrevRedisp: + ld a, (cxPrevPage) + call OutPort6 + ld hl, (cxPrevRedisp) jr jpHL monErrHand: ld hl, monErrHand call pushErrorHandleR - ld a, 52h ; 'R' + ld a, kError call newContext0 jp Mon - push hl - ld hl, 64h ; 'd' - jr page0_7C5 -page0_7C1: +#ifndef DEVIATE_FROM_ORIGINAL_FILE +;I don't think this is used *anywhere*. push hl - ld hl, 32h ; '2' -page0_7C5: + ld hl, 100 + jr AppInitEnoughMemHL +#endif +AppInitEnoughMem50: + push hl + ld hl, 50 +AppInitEnoughMemHL: call EnoughMem - jp c, Page0Call_24F9 + jp c, ErrMemory_NoGoTo pop hl AppInit: ld de, mcxMain @@ -681,8 +673,8 @@ out (3), a call TurnOffLCD ld hl, flags+onFlags - bit clrScrnOnPowerOff, (hl) - res clrScrnOnPowerOff, (hl) + bit onClearScrn, (hl) + res onClearScrn, (hl) call nz, j_ClrScrn call calculateRAMChecksum ld (RAMChecksum), hl @@ -706,32 +698,30 @@ res checkNoBatteriesNextTime, (iy+batteryFlags2) call ApdSetup bit onRunning, (iy+onFlags) - jr nz, page0_94D -page0_8F1: + jr nz, SetOnInterruptFlag +HandleONPressed_WasOff: set onRunning, (iy+onFlags) ld hl, flags+apdFlags - bit 4, (hl) - res 4, (hl) - jr nz, page0_92C + bit APDWarmStart, (hl) + res APDWarmStart, (hl) + jr nz, restoreToPoweredOn res indicInUse, (iy+indicFlags) bit resetOnPowerOn, (iy+selfTestFlag) - jr z, page0_90D + jr z, {+} bit 2, (hl) jp z, resetRam -page0_90D: - ld sp, (onSP) ++: ld sp, (onSP) call j_resetStacks xor a ld (MenuCurrent), a call refreshSystemRAM - call sub_ADA - call Page0Call_3E97 + call PowerOn + call j_SetExecutionPermissionsAndDeleteOldApps bit cmdExec, (iy+cmdFlags) - call nz, Page0Call_3E9D + call nz, j_SetupLastEntryEditResetFlags ei jp Mon - -page0_92C: +restoreToPoweredOn: bit alt_On, (iy+hookflags1) call nz, j_ExecuteONSCRPT ld a, 8 @@ -744,73 +734,70 @@ pop de pop de pop de - set 3, (hl) - call sub_ADA + set APDRunning, (hl) + call PowerOn ex af, af' exx ei reti - -page0_94D: +SetOnInterruptFlag: set onInterrupt, (iy+onFlags) ret HookRAMAndPowerOn: - ld a, 76h ; 'v' + ld a, 76h out (4), a - ld a, 0C0h ; '' + ld a, 0C0h out (0), a in a, (2) - and 80h ; '' - ld a, 41h ; 'A' - jr z, page0_96B + and 80h + ld a, 41h + jr z, {+} ld a, 1 out (20h), a xor a out (0Fh), a - ld a, 81h ; 'g -page0_96B: - out (7), a + ld a, 81h ++: out (7), a xor a push af ld a, 8 out (3), a pop af out (3), a - ld iy, 89F0h + ld iy, flags call NZIf83Plus - call z, Page0Call_3EAF + call z, j_ResetIOPorts ld hl, (RAMChecksum) ld de, 0A55Ah call CpHLDE jp z, doFunkyTurnOnFromA55AChecksum call NZIf83Plus - jr z, page0_9A0 + 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, page0_9A2 + jr z, {++} ld a, 1Ch - jr page0_9A2 - -page0_9A0: - ld a, 17h -page0_9A2: - ld (contrast), a + jr {++} ++: ld a, 17h +++: ld (contrast), a call calculateRAMChecksum ld de, (RAMChecksum) call CpHLDE jr nz, resetRam dec de ld (RAMChecksum), de - call Page0Call_3EB5 + call j_SetExecutionPermissions call PreviousContext_CloseAnyOpenMenu ld a, 0Bh out (3), a res apdWarmStart, (iy+apdFlags) call forcecmd - jp page0_8F1 + jp HandleONPressed_WasOff resetRam: di @@ -819,7 +806,7 @@ ld bc, 7FFFh ld (hl), 0 ldir - ld hl, 109h + ld hl, 0109h ld (localLanguage), hl ;#ifdef DEVIATE_FROM_ORIGINAL_FILE ; call NZIfColorModel @@ -828,7 +815,7 @@ ;+: ;#endif page0_9DE: - ld a, 0C0h ; '' + ld a, 0C0h out (0), a ld sp, 0FFF7h call Page0Call_3EBB @@ -857,12 +844,12 @@ call Page0Call_3EC1 jp Page0Call_3ECD -page0_A26: +GetKey_ClearScrn_MonForceKey: call GetCSC - set 2, (iy+9) + set onClearScrn, (iy+onFlags) call j_getkey call j_ClrScrn - res 2, (iy+9) + res onClearScrn, (iy+onFlags) jp monForceKey calculateRAMChecksum: @@ -890,12 +877,12 @@ res textInverse, (iy+textFlags) call j_Disp res cmdExec, (iy+cmdFlags) - ld a, 40h ; '@' + ld a, appStart jp newContext0 bootCalc: call SetSlowSpeed - ld a, 77h ; 'w' + ld a, 77h out (4), a ld b, 0 ld sp, 0FDFAh @@ -977,7 +964,7 @@ call restorePreviousSpeed ret -sub_ADA: +PowerOn: ld a, 0Bh out (3), a call j_LCD_DRIVERON @@ -987,11 +974,10 @@ in a, (2) bit 0, a jp z, PowerOff._skipRAMChecksum - sub_AEF: - call Page0Call_3ED9 + call j_ClearScreen_SetupAPDFromPowerOn call forcecmd - jp Page0Call_3EDF + jp j_DisplayLowBattRecommendChange Chk_Batt_Low_2: call refreshSystemRAM @@ -1041,7 +1027,7 @@ call forcecmd res apdWarmStart, (iy+apdFlags) bit cmdExec, (iy+cmdFlags) - call nz, Page0Call_3E9D + call nz, j_SetupLastEntryEditResetFlags ld a, 0Bh out (3), a call j_LCD_DRIVERON