Changeset 55

Show
Ignore:
Timestamp:
10/11/09 23:33:32 (2 years ago)
Author:
brandonlw
Message:

We now have a basic menu system and the beginnings of an oncalc hex editor
I also was forced to duplicate PutMap? instead of using the boot code hack, since it doesn't support inverse text
Progress...

Location:
trunk
Files:
2 added
10 modified

Legend:

Unmodified
Added
Removed
  • trunk/OS2.zws

    r49 r55  
    4949SOURCE = page00\jumptable.asm 
    5050SOURCE = page01\01base.asm 
     51SOURCE = page01\font.asm 
     52SOURCE = page01\strings.asm 
    5153SOURCE = page02\02base.asm 
    5254SOURCE = page03\03base.asm 
  • trunk/includes/os2.inc

    r49 r55  
    2727;====================================================================== 
    2828_GetCSC                     EQU 4018h 
     29_JForceCmdNoChar            EQU 4027h 
     30_JForceCmd                  EQU 402Ah 
    2931_AppInit                    EQU 404Bh 
    3032_PutS                       EQU 450Ah 
     
    3638_CursorOn                   EQU 45C4h 
    3739_showCursor                 EQU 45C7h 
     40_KeyToString                EQU 45CAh 
    3841_keyscnlnk                  EQU 4A1Ah 
    3942_GetKey                     EQU 4972h 
     
    7780kbdKey                      EQU    8444h 
    7881kbdGetKy                    EQU    8445h 
    79 ; 
     82keyExtend                   EQU    8446h 
    8083contrast                    EQU    8447h 
    8184apdSubTimer                 EQU    8448h 
     
    8891; 
    8992curXRow                     EQU    8451h 
     93; 
     94lFont_record                EQU    845Ah 
    9095; 
    9196indicMem                    EQU    846Eh 
     
    118123textShadow                  EQU    8508h 
    119124; 
     125textShadCur                 EQU    8588h 
     126textShadTop                 EQU    858Ah 
     127textShadAlph                EQU    858Bh 
     128textShadIns                 EQU    858Ch 
    120129cxMain                      EQU    858Dh 
    121130cxPPutAway                  EQU    858Fh 
     
    132141; 
    133142menuCurrent                 EQU    85DEh 
     143selectedSubMenu             EQU    85DFh 
     144selectedMenuItem            EQU    85E0h 
     145numHeaders                  EQU    85E1h 
     146numItemsForThisHeader       EQU    85E2h 
     147; 
     148curFlagsBackup              EQU    85E4h 
    134149; 
    135150ioFlag                      EQU    8670h 
     
    218233pagedBuf                    EQU    983Ah ;16 bytes 
    219234; 
     235topMenuRow                  EQU    984Ah 
     236; 
    220237appBackUpScreen             EQU    9872h 
    221238; 
     
    235252; 
    236253nestedHookLevels            EQU    9CAEh ;not sure this is of any use 
     254; 
     255keyForStr                   EQU    9D76h 
     256keyForStrRam                EQU    9D77h 
    237257; 
    238258userMem                     EQU    9D95h 
     
    294314batteryCheckFlags           EQU    0Fh 
    295315turnOffIfLowBatteriesFound  EQU    7      ;1=if low batteries detected, shut the calculator off 
     316 
     317menuFlags                   EQU    11h 
     318useCustomDisplay            EQU    5      ;1=use custom display of menu items instead of key codes -> strings 
    296319 
    297320indicFlags                  EQU    12h 
     
    434457speedPort            EQU    20h 
    435458modelPort            EQU    21h 
     459 
     460;====================================================================== 
     461; Menu Equates 
     462;====================================================================== 
     463mConfirmation           equ 01h 
     464mApps                   equ 02h 
     465mProgramHome            equ 03h 
     466mPrgm_Run               equ 00h 
     467mPrgm_Edit              equ 01h 
     468mPrgm_New               equ 02h 
     469mZoom                   equ 04h 
     470mZoom_Zoom              equ 00h 
     471mZoom_Memory            equ 01h 
     472mDraw                   equ 05h 
     473mDraw_Draw              equ 00h 
     474mDraw_Points            equ 01h 
     475mDraw_Store             equ 02h 
     476mStatPlots              equ 06h 
     477mStat                   equ 07h 
     478mStat_Edit              equ 00h 
     479mStat_Calc              equ 01h 
     480mStat_Tests             equ 02h 
     481mMath                   equ 08h 
     482mMath_Math              equ 00h 
     483mMath_Number            equ 01h 
     484mMath_Complex           equ 02h 
     485mMath_Prob              equ 03h 
     486mTest                   equ 09h 
     487mTest_Test              equ 00h 
     488mTest_Logic             equ 01h 
     489mVars                   equ 0Ah 
     490mVars_Vars              equ 00h 
     491mVars_YVars             equ 01h 
     492mMemory                 equ 0Ch 
     493mMatrix                 equ 0Dh 
     494mMatrix_Name            equ 00h 
     495mMatrix_Math            equ 01h 
     496mMatrix_Edit            equ 02h 
     497mDistr                  equ 0Eh 
     498mDistr_Distr            equ 00h 
     499mDistr_Draw             equ 01h 
     500mAngle                  equ 0Fh 
     501mList                   equ 10h 
     502mList_Names             equ 00h 
     503mList_Ops               equ 01h 
     504mList_Math              equ 02h 
     505mCalculate              equ 11h 
     506mVarsWin                equ 14h 
     507mVarsWin_XY             equ 00h 
     508mVarsWin_TTh            equ 01h 
     509mVarsWin_UVW            equ 02h 
     510mVarsZoom               equ 15h 
     511mVarsZoom_ZXY           equ 00h 
     512mVarsZoom_ZT            equ 01h 
     513mVarsZoom_UVW           equ 02h 
     514mVarsGDB                equ 16h 
     515mVarsPics               equ 17h 
     516mVarsStrings            equ 18h 
     517mVarsStat               equ 19h 
     518mVarsStat_XY            equ 00h 
     519mVarsStat_Sigma         equ 01h 
     520mVarsStat_EQ            equ 02h 
     521mVarsStat_Test          equ 03h 
     522mVarsStat_Pts           equ 04h 
     523mVarsTable              equ 1Ah 
     524mVarsYEqu               equ 1Bh 
     525mVarsParametric         equ 1Ch 
     526mVarsPolar              equ 1Dh 
     527mVarsFnOnOff            equ 1Eh 
     528mMemReset               equ 1Fh 
     529mMemReset_RAM           equ 00h 
     530mMemReset_ROM           equ 01h 
     531mMemReset_All           equ 02h 
     532mMemMgmtDel             equ 20h 
     533mMemResetDefaults       equ 21h 
     534mMemResetRAMAll         equ 23h 
     535mMemResetROMVars        equ 24h 
     536mMemResetROMApps        equ 25h 
     537mMemResetROMAll         equ 26h 
     538mMemResetAll            equ 27h 
     539mGroup                  equ 28h 
     540mGroup_New              equ 00h 
     541mGroup_Ungroup          equ 01h 
     542mGroupVars              equ 29h 
     543mProgramEdit            equ 2Ah 
     544mPrgmEd_Ctrl            equ 00h 
     545mPrgmEd_IO              equ 01h 
     546mPrgmEd_Exec            equ 02h 
     547mPrgmZoom               equ 2Bh 
     548mPrgmZoom_Zoom          equ 00h 
     549mPrgmZoom_Mem           equ 01h 
     550mPrgmDraw               equ 2Ch 
     551mPrgmDraw_Draw          equ 00h 
     552mPrgmDraw_Pt            equ 01h 
     553mPrgmDraw_Store         equ 02h 
     554mPrgmStatPlot           equ 2Dh 
     555mPrgmSP_Plots           equ 00h 
     556mPrgmSP_Type            equ 01h 
     557mPrgmSP_Mark            equ 02h 
     558mPrgmStat               equ 2Eh 
     559mPrgmStat_Edit          equ 00h 
     560mPrgmStat_Calc          equ 01h 
     561mPrgmStat_Tests         equ 02h 
     562mPrgmMath               equ 2Fh 
     563mPrgmMath_Math          equ 00h 
     564mPrgmMath_Num           equ 01h 
     565mPrgmMath_Cplx          equ 02h 
     566mPrgmMath_Prob          equ 03h 
     567mLink                   equ 30h 
     568mLink_Send              equ 00h 
     569mLink_Recieve           equ 01h 
     570mLinkTrasmit            equ 31h 
     571mLinkXmit_Xmit          equ 01h 
     572mGarbageCollect         equ 3Fh 
     573mSelectGroupVars        equ 40h 
     574mSelGrpVars_Sel         equ 00h 
     575mSelGrpVars_Grp         equ 01h 
     576mDuplicateName          equ 42h 
     577mCatalog                equ 45h 
     578mFinance                equ 22h 
     579mFinance_Calc           equ 00h 
     580mFinance_Vars           equ 01h 
    436581 
    437582;====================================================================== 
     
    12031348;====================================================================== 
    12041349; 
    1205 kExtendEcho2    EQU       0FCh 
     1350kExtendEcho2         EQU           0FCh 
     1351k2Tools              EQU           4 
    12061352; 
    12071353;======================================================================; 
  • trunk/page00/boot.asm

    r49 r55  
    44 include "includes\os2.inc" 
    55 
    6  PUBLIC LdHLInd,BCALLRoutine,CheckForBootLoader,OS2Marker,AppInit 
     6 PUBLIC LdHLInd,BCALLRoutine,CheckForBootLoader,OS2Marker,AppInit,JForceCmdNoChar,JForceCmd 
    77 EXTERN PutS,PutC,ifastcopy,CallUSBActivityHook,CheckLowBatteriesTurnOff,SaveOScreen 
    88 EXTERN RunLinkActivityHook,HandleLinkKeyActivity,ResetStacks,_LCD_DRIVERON 
    99 EXTERN _APP_PUSH_ERRORH,_APP_POP_ERRORH,FindSym,PushRealO1,Mov9ToOP1,FPAdd,OP1ToOP2,LCDDelay 
    1010 EXTERN Placeholder005Fh,Placeholder0006h,Placeholder004Eh,Placeholder0003h,Placeholder0035h 
    11  EXTERN outputPage,NZIf83Plus,_ZERO_PORT_3,_OUT_PORT_3,AnimateRunIndicator,PowerOff 
     11 EXTERN outputPage,NZIf83Plus,_ZERO_PORT_3,_OUT_PORT_3,AnimateRunIndicator,PowerOff,clrTR 
    1212 EXTERN DispHexA,DispHexHL,IPutC,ReadKeyboardKey,ReadKeypad,ClrLCDFull,InitHomescreenContext 
    1313 EXTERN curBlink,resetAPDTimer,UpdateAPD,BCALL,BJUMP,CopyRAMToFlashPage,cphlde,CalculateOSChecksum 
     
    1515 EXTERN _HandleUSBACablePluggedIn,_HandleUSBACableUnplugged,_HandleUSBBCablePluggedIn,_HandleUSBBCableUnplugged 
    1616 EXTERN GetHexA,GetHexHL,CursorOff,RunIndicOn,SetFastSpeed,CanAlph,homescreenContextVectors,SetContrast,_PULLDOWNCHK 
     17 EXTERN savepartialWin 
    1718 
    1819;0000h: 
     
    494495       ld hl,0800h 
    495496       ld (winTop),hl 
     497       set appTextSave,(iy+appFlags) 
    496498       B_CALL ClrScrnFull 
    497499       ld hl,userMem 
     
    516518       call APP_PUSH_ERRORH 
    517519       ld (onSP),sp 
     520       ld a,lcdTurnOn 
     521       out (LCDinstPort),a 
     522       set onRunning,(iy+onFlags) 
     523       res indicOnly,(iy+indicFlags) 
     524       set indicRun,(iy+indicFlags) 
     525       set curAble,(iy+curFlags) 
     526       set apdAble,(iy+apdFlags) 
     527       set apdRunning,(iy+apdFlags) 
     528       xor a 
     529       ld (menuCurrent),a 
     530       ld a,appStart 
     531       call _newContext0 
     532       call ResetStacks 
     533       ld hl,0205h 
     534       ld (curRow),hl 
     535       res appTextSave,(iy+appFlags) 
     536       ld hl,sRAMCleared 
     537       call PutS 
     538       set appTextSave,(iy+appFlags) 
     539       call savepartialWin 
     540       ld hl,0 
     541       ld (curRow),hl 
     542       B_CALL GetKey 
     543       push af 
     544       B_CALL ClrLCDFull 
     545       pop af 
     546       jr _monForceKey 
    518547$$:    ;Screw up the RAM checksum so it's no longer valid 
     548       ld de,(RAMChecksum) 
    519549       dec de 
    520550       ld (RAMChecksum),de 
     
    540570       call ResetStacks 
    541571       set appTextSave,(iy+appFlags) 
     572       call savepartialWin 
    542573RestartMon: 
    543574_Mon:  xor a 
    544575       ld (kbdKey),a 
    545        ld (8446h),a 
     576       ld (keyExtend),a 
    546577       B_CALL GetKey 
    547578_monForceKey: 
    548579       ld (kbdKey),a 
     580       cp kQuit 
     581       jr z,doContextSwitch 
     582       push af 
    549583       call CursorOff 
    550584       call RunIndicOn 
     585       pop af 
    551586       call _PULLDOWNCHK 
     587       jr c,RestartMon 
     588       call clrTR 
    552589       jr c,RestartMon 
    553590       call CallcxMain 
    554591       jr _Mon 
     592doContextSwitch: 
     593       call _newContext0 
     594       jr RestartMon 
     595JForceCmdNoChar: 
     596       xor a 
     597JForceCmd: 
     598       ld sp,(onSP) 
     599       ld a,appStart 
     600       call _newContext0 
     601       jr _Mon 
     602sRAMCleared: 
     603       DB "RAM cleared",0 
     604 
    555605CallcxMain: 
    556606       push hl 
  • trunk/page00/display.asm

    r49 r55  
    55 PUBLIC _LCD_COMMAND,SetXAutoIncrementMode,SetYAutoIncrementMode,IPutSB,PutMap,ClrScrnFull,ClrTxtShd 
    66 PUBLIC saveTR,restoreTR,showCursor,CursorOff,CursorOn,hideCursor,RunIndicOn,IPutC,_LCD_DRIVERON 
    7  EXTERN IsAtEditTail,IsAtBtm,LCDDelay,ATimes16,NZIf83Plus 
     7 PUBLIC RestoreTextShadow,rstrpartialWin,savepartialWin,PutPS 
     8 EXTERN IsAtEditTail,IsAtBtm,LCDDelay,ATimes16,NZIf83Plus,_GetCharacterBitmap 
    89 
    910 include "includes\os2.inc" 
     11 
     12PutPS: 
     13       ld b,(hl) 
     14$$:    inc hl 
     15       ld a,(hl) 
     16       call PutC 
     17       djnz $B 
     18       ret 
     19 
     20RestoreTextShadow: 
     21       ld hl,0 
     22       ld (curRow),hl 
     23       ld hl,textShadow 
     24       ld b,127 
     25$$:    ld a,(hl) 
     26       inc hl 
     27       call IPutC 
     28       djnz $B 
     29       ld a,(hl) 
     30       call PutMap 
     31rstrpartialWin: 
     32       ld hl,(textShadCur) 
     33       ld (curRow),hl 
     34       ld a,(textShadAlph) 
     35       ld (flags+shiftFlags),a 
     36       ld a,(textShadIns) 
     37       and 0EFh 
     38       ld hl,flags+textFlags 
     39       or (hl) 
     40       ld (hl),a 
     41       ret 
     42savepartialWin: 
     43       ld hl,(curRow) 
     44       ld (textShadCur),hl 
     45       ld a,(winTop) 
     46       ld (textShadTop),a 
     47       ld a,(flags+shiftFlags) 
     48       ld (textShadAlph),a 
     49       ld a,(flags+textFlags) 
     50       and 10h 
     51       ld (textShadIns),a 
     52       ret 
    1053 
    1154_LCD_DRIVERON: 
     
    83126       jr endTR 
    84127 
    85 PutMap: 
    86        push hl 
    87        ld hl,(curRow) 
    88        push hl 
    89        call PutC 
    90        pop hl 
    91        ld (curRow),hl 
    92        pop hl 
    93        ret 
    94  
    95128restoreTR: 
    96129       bit indicInUse,(iy+indicFlags) 
     
    255288 
    256289EraseEOL: 
    257        ld hl,(curRow) 
     290       push af 
     291       push bc 
     292       push de 
    258293       push hl 
    259294       ld a,(curCol) 
     295       push af 
     296       sub 16 
     297       jr nc,EraseEOL_1 
     298       neg 
    260299       ld b,a 
    261        ld a,16 
    262        sub b 
    263        ld b,a 
    264 $$:    ld a,' ' 
    265        push bc 
    266        call PutC 
    267        pop bc 
     300       ld a,' ' 
     301       dec b 
     302       jr z,EraseEOL_2 
     303$$:    call PutC 
    268304       djnz $B 
    269        pop hl 
    270        ld (curRow),hl 
    271        ret 
    272  
    273 ;TODO: get this using a built-in font table instead of this boot code hack 
     305EraseEOL_2: 
     306       call PutMap 
     307;       ei 
     308EraseEOL_1: 
     309       pop af 
     310       ld (curCol),a 
     311       pop hl 
     312       pop de 
     313       pop bc 
     314       pop af 
     315       ret 
     316 
     317newLine: 
     318       push af 
     319       ld a,(curRow) 
     320       inc a 
     321       ld (curRow),a 
     322       xor a 
     323       ld (curCol),a 
     324       pop af 
     325       ret 
     326 
    274327PutC: 
     328       push af 
     329       push hl 
     330       cp 0D6h 
     331       jr nz,$F 
     332       call EraseEOL 
     333       call newLine 
     334       ld a,(winBtm) 
     335       ld l,a 
     336       ld a,(curRow) 
     337       cp l 
     338       jr nc,PutC_Done 
     339       ld a,3Ah 
     340$$:    call PutMap 
     341       res 0,(iy+8) 
     342       ld hl,curCol 
     343       inc (hl) 
     344       ld a,(hl) 
     345       cp 16 
     346       call nc,newLine 
     347PutC_Done: 
     348       pop hl 
     349       pop af 
     350       ret 
     351 
     352PutMap: 
    275353       push af 
    276354       push bc 
     
    282360       call GetTextShadowOffset 
    283361       ld (hl),a 
    284 $$:    ld b,a 
     362$$:    or a 
     363       jr z,$F 
     364       cp 0F5h 
     365       jr c,PutMap_1 
     366$$:    ld a,0D0h 
     367PutMap_1: 
     368       ld l,a 
     369       ld h,0 
     370       add hl,hl 
     371       add hl,hl 
     372       add hl,hl 
     373       call _GetCharacterBitmap 
     374       push hl 
     375       pop ix 
     376       ld a,(curRow) 
     377       add a,a 
     378       add a,a 
     379       add a,a 
     380       add a,80h 
     381       ld (curXRow),a 
     382       ld a,(curCol) 
     383       and 1Fh 
     384       add a,20h 
     385       ld b,a 
     386       xor a 
     387       call LCDDelay 
     388       out (LCDinstPort),a 
     389       ld a,(curXRow) 
     390       call SetLCDRow 
     391       call SetXAutoIncrementMode 
     392       ld a,b 
     393       call LCDDelay 
     394       out (LCDinstPort),a 
     395       ld b,8 
     396PutMap_Loop1: 
     397       xor a 
     398       dec b 
     399       jr z,$F 
     400       ld a,(ix+0) 
     401       inc ix 
     402$$:    inc b 
     403       sla a 
     404       bit textInverse,(iy+textFlags) 
     405       jr z,PutMap_3 
     406       xor 3Eh 
     407PutMap_4:push af 
     408       ld a,(curCol) 
     409       and 1Fh 
     410       jr z,PutMap_2 
     411       add a,1Fh 
     412       call LCDDelay 
     413       out (LCDinstPort),a 
     414       call SetLCDRow_1 
     415       or 1 
     416       bit 0,(iy+8) 
     417       jr z,$F 
     418       and 3Eh 
     419$$:    call LCDDelay 
     420       out (LCDdataPort),a 
     421       ld a,(curCol) 
     422       and 1Fh 
     423       add a,20h 
     424       call LCDDelay 
     425       out (LCDinstPort),a 
     426       call SetLCDRow_2 
     427PutMap_2: 
     428       pop af 
     429       jr PutMap_5 
     430PutMap_3: 
     431       bit 0,(iy+8) 
     432       jr nz,PutMap_4 
     433PutMap_5: 
     434       call LCDDelay 
     435       out (LCDdataPort),a 
     436       djnz PutMap_Loop1 
     437       ld a,1 
     438       call LCDDelay 
     439       out (LCDinstPort),a 
     440       COMMENT ~ 
     441       ld b,a 
    285442       in a,(6) 
    286443       push af 
     
    318475       ld a,b 
    319476       out (6),a 
     477       ~ 
    320478       pop ix 
    321479       pop hl 
    322480       pop de 
    323481       pop bc 
     482       pop af 
     483       ret 
     484SetLCDRow_1: 
     485       call LCDDelay 
     486       in a,(LCDdataPort) 
     487       call LCDDelay 
     488       in a,(LCDdataPort) 
     489SetLCDRow_2: 
     490       push af 
     491       ld a,(curXRow) 
     492       add a,8 
     493       sub b 
     494       call SetLCDRow 
     495       call SetXAutoIncrementMode 
    324496       pop af 
    325497       ret 
  • trunk/page00/home.asm

    r48 r55  
    55 
    66 PUBLIC homescreenContextVectors,InitHomescreenContext 
    7  EXTERN DispHexA,DispHexHL,GetHexA,GetHexHL,AppInit 
     7 EXTERN DispHexA,DispHexHL,GetHexA,GetHexHL,AppInit,RestoreTextShadow 
    88 
    99InitHomescreenContext: 
     
    2222       ld hl,homescreenContextVectors 
    2323       call AppInit 
    24        B_CALL ClrLCDFull 
     24       call RestoreTextShadow 
     25       set appTextSave,(iy+appFlags) 
     26       set curAble,(iy+curFlags) 
     27       set curOn,(iy+curFlags) 
     28       ld hl,menuCurrent 
     29       ld (hl),0 
    2530       ret 
    2631 
  • trunk/page00/intmisc.asm

    r47 r55  
    4040       dec (hl) 
    4141       ret nz 
    42        ld a,lcdTurnOff 
    43        out (LCDinstPort),a 
    4442       call SaveOScreen 
    4543       res apdRunning,(iy+apdFlags) 
  • trunk/page00/jumptable.asm

    r32 r55  
    44 include "includes\os2.inc" 
    55 
    6  PUBLIC _OutputProtectedPort,Page0Call 
     6 PUBLIC _OutputProtectedPort,Page0Call,_GetCharacterBitmap 
    77 PUBLIC _HandleUSBACablePluggedIn,_HandleUSBBCablePluggedIn,_HandleUSBACableUnplugged,_HandleUSBBCableUnplugged 
    88 PUBLIC _HandleUSBInterruptInitialize,_HandleDefaultUSBInterrupt,_ReadUSBInterruptData 
    9  EXTERN OutputProtectedPort 
     9 EXTERN OutputProtectedPort,GetCharacterBitmap 
    1010 EXTERN HandleUSBACablePluggedIn,HandleUSBBCablePluggedIn,HandleUSBACableUnplugged,HandleUSBBCableUnplugged 
    1111 EXTERN HandleUSBInterruptInitialize,HandleDefaultUSBInterrupt,ReadUSBInterruptData 
     
    6060       DW OutputProtectedPort 
    6161       DB 7Ch 
     62_GetCharacterBitmap: 
     63       call Page0Call 
     64       DW GetCharacterBitmap 
     65       DB 01h 
    6266_HandleUSBACablePluggedIn: 
    6367       call Page0Call 
  • trunk/page00/mathcore.asm

    r53 r55  
    44 include "includes\os2.inc" 
    55 
    6  PUBLIC OP1ToOP4,OP1ToOP2,MovToOP1,EquToOP1,MovFrOP1 
     6 PUBLIC OP1ToOP4,OP1ToOP2,MovToOP1,EquToOP1,MovFrOP1,Mov8B 
    77 
    88OP1ToOP4: 
  • trunk/page00/menu.asm

    r48 r55  
    44 include "includes\os2.inc" 
    55 
    6  PUBLIC _PULLDOWNCHK 
     6 PUBLIC _PULLDOWNCHK,clrTR 
     7 EXTERN savepartialWin,rstrpartialWin,RestoreTextShadow,PutS,LdHLInd,PutPS,EraseEOL,PutC 
    78 
    89_PULLDOWNCHK: 
    910;Key code is in A. Check to see if it's a menu key and back out if not, otherwise handle it. 
    1011;Return carry flag set if you want the system monitor to restart, otherwise the current cxMain handler will get called for this key. 
    11        or a 
    12        ret 
     12;In other words return carry flag set if you're handling this keypress. 
     13       cp kInputDone 
     14       jr nz,$F 
     15skipKey: 
     16       or a 
     17       ret 
     18$$:    call IsSystemMenuKey 
     19       jr c,HandleSystemMenuKey 
     20       call IsInCatalogMenu 
     21       jr z,skipKey 
     22       call IsInMenu 
     23       jr nz,HandleMenuOpenKey 
     24MenuCatCommon: 
     25       cp appStart 
     26       jr c,skipKey 
     27;       cp echoStart1 
     28;       call c,RestoreOldContext 
     29       cp kQuit 
     30       jr z,skipKey 
     31       or a 
     32       ret 
     33HandleSystemMenuKey: 
     34;       call IsInMenu 
     35;       jr nz,keyHandled 
     36       ld c,(iy+menuFlags) 
     37       res useCustomDisplay,(iy+menuFlags) 
     38       cp kExtendEcho 
     39       jr nz,$F 
     40       ld b,a 
     41       ld a,(keyExtend) 
     42       cp k2Tools 
     43       ld a,b 
     44       jr z,SetupMenuCustom 
     45       jr skipKey 
     46$$:    cp kAppsMenu 
     47       jr z,SetupMenu 
     48skipSystemKey: 
     49       ld (iy+menuFlags),c 
     50       or a 
     51       ret 
     52       xor a 
     53SetupMenuCustom: 
     54       set useCustomDisplay,(iy+menuFlags) 
     55SetupMenu: 
     56       push af 
     57       ld a,(flags+curFlags) 
     58       ld (curFlagsBackup),a 
     59       res appTextSave,(iy+appFlags) 
     60       res curAble,(iy+curFlags) 
     61       res curOn,(iy+curFlags) 
     62       ld a,(menuCurrent) 
     63       or a 
     64       call z,savepartialWin 
     65       pop af 
     66       cp kExtendEcho 
     67       jr nz,$F 
     68       ld a,(keyExtend) 
     69       jr hsmk1 
     70$$:    sub 2Ah ;menuStart-1 
     71hsmk1: ld (menuCurrent),a 
     72       ld hl,0 
     73       ld (menuCurrent+1),hl 
     74       B_CALL ClrLCDFull 
     75       ld hl,0 
     76       ld (curRow),hl 
     77       call GetMenuPointer 
     78       ld a,(hl) 
     79       ld (numHeaders),a 
     80       ld a,(menuCurrent+1) 
     81       ld b,a 
     82       inc b 
     83$$:    inc hl 
     84       djnz $B 
     85       ld a,(hl) 
     86       ld (numItemsForThisHeader),a 
     87       xor a 
     88       ld (menuCurrent+2),a 
     89       call DisplayMenu 
     90keyHandled: 
     91       scf 
     92       ret 
     93HandleMenuOpenKey: 
     94       cp kLeft 
     95       jr nz,notLeft 
     96       call DisplayMenu 
     97       jr keyHandled 
     98notLeft: 
     99       cp kRight 
     100       jr nz,notRight 
     101       call DisplayMenu 
     102       jr keyHandled 
     103notRight: 
     104       cp kUp 
     105       jr nz,notUp 
     106       call DisplayMenu 
     107       jr keyHandled 
     108notUp: cp kDown 
     109       jr nz,notDown 
     110       call DisplayMenu 
     111       jr keyHandled 
     112notDown: 
     113       cp kEnter 
     114       jr nz,notEnter 
     115       ld a,(menuCurrent+2) 
     116       push af 
     117       call GetCurrentMenuPointer 
     118       pop bc 
     119       ld a,b 
     120       inc hl 
     121       or a 
     122       jr z,$F 
     123enterLoop: 
     124       inc hl 
     125       inc hl 
     126       djnz enterLoop 
     127$$:    bit useCustomDisplay,(iy+menuFlags) 
     128       jr z,$F 
     129       ld d,(hl) 
     130       dec hl 
     131       ld e,(hl) 
     132       ex de,hl 
     133       ld c,(hl) 
     134       ld b,0 
     135       add hl,bc 
     136       inc hl 
     137       push hl 
     138       set appTextSave,(iy+appFlags) 
     139       ld hl,menuCurrent 
     140       ld (hl),0 
     141       pop hl 
     142       jp (hl) 
     143$$:    ld b,(hl) 
     144       dec hl 
     145       ld a,(hl) 
     146       ld (keyExtend),a 
     147       or a 
     148       ld a,b 
     149       jr z,$F 
     150       ld a,(keyExtend) 
     151       ld c,a 
     152       ld a,b 
     153       ld (keyExtend),a 
     154       ld a,c 
     155       cp 83h 
     156       jr nz,$F 
     157       ld a,kExtendEcho 
     158       jr HandleSystemMenuKey 
     159$$:    push af 
     160       call RestoreTextShadow 
     161       ld a,(curFlagsBackup) 
     162       ld (flags+curFlags),a 
     163       set appTextSave,(iy+appFlags) 
     164       ld hl,menuCurrent 
     165       ld (hl),0 
     166       pop af 
     167       or a 
     168       ret 
     169notEnter: 
     170       cp kClear 
     171       jr nz,keyHandled 
     172       call RestoreTextShadow 
     173       ld a,(curFlagsBackup) 
     174       ld (flags+curFlags),a 
     175       set appTextSave,(iy+appFlags) 
     176       ld hl,menuCurrent 
     177       ld (hl),0 
     178       jr keyHandled 
     179IsSystemMenuKey: 
     180;HACK: until we get all the menus between menuStart and menuEnd implemented, we have to hard-code 
     181;  which menu keys we support, which for now is just APPS. 
     182       cp kAppsMenu 
     183       scf 
     184       ret z 
     185       or a 
     186       ret 
     187       cp menuEnd+1 
     188       ret nc 
     189       cp menuStart 
     190       ccf 
     191       ret 
     192DisplayMenu: 
     193       ld a,(menuCurrent+2) 
     194       ld c,a 
     195       push bc 
     196       ld a,1 
     197       ld (topMenuRow),a 
     198       B_CALL ClrLCDFull 
     199       ld hl,0 
     200       ld (curRow),hl 
     201       call EraseEOL 
     202       call DisplayMenuHeader 
     203       call GetCurrentMenuPointer 
     204       pop bc 
     205       ld a,(numItemsForThisHeader) 
     206       or a 
     207       jr z,noItems 
     208       ld a,c 
     209       sla a 
     210       ld e,a 
     211       ld d,0 
     212       add hl,de 
     213       call DispMenuChoices 
     214       ld a,(topMenuRow) 
     215       jr $F 
     216noItems: 
     217       ld a,1 
     218$$:    ld (curRow),a 
     219       ret 
     220DispMenuChoices: 
     221       ld a,(topMenuRow) 
     222DispMenuChoicesLoop: 
     223       ld (curRow),a 
     224       call DisplayCurMenuNumColonArrow 
     225       ld d,(hl) 
     226       inc hl 
     227       ld e,(hl) 
     228       inc hl 
     229       push hl 
     230       push bc 
     231       call DisplayMenuItem 
     232       pop bc 
     233       pop hl 
     234       inc c 
     235       ld a,(numItemsForThisHeader) 
     236       cp c 
     237       ret z 
     238       ret c 
     239       ld a,(curRow) 
     240       cp 7 
     241       ret z 
     242       inc a 
     243       jr DispMenuChoicesLoop 
     244DisplayMenuItem: 
     245       bit useCustomDisplay,(iy+menuFlags) 
     246       jr z,$F 
     247       ld h,e 
     248       ld l,d 
     249       jr dmiDisplay 
     250$$:    B_CALL KeyToString 
     251dmiDisplay: 
     252       call PutPS 
     253       ld a,(curCol) 
     254       cp 15 
     255       call c,EraseEOL 
     256       ret 
     257DisplayCurMenuNumColonArrow: 
     258       xor a 
     259       ld (curCol),a 
     260       ld a,(menuCurrent+2) 
     261       cp c 
     262       jr nz,$F 
     263DisplayMenuNumColonArow: 
     264       set textInverse,(iy+textFlags) 
     265$$:    ld b,'1' 
     266       ld a,c 
     267       ld e,a 
     268       cp 9 
     269       jr c,dispLessThan9 
     270       jr nz,dispHigherThan10 
     271       ld a,'0' 
     272       jr displayMenuIndexChar 
     273dispSpace: 
     274       ld a,' ' 
     275       jr displayMenuIndexChar 
     276dispTheta: 
     277       ld a,5Bh 
     278       jr displayMenuIndexChar 
     279dispHigherThan10: 
     280       ld a,(menuCurrent) 
     281       cp 3 
     282       jr z,dispSpace 
     283       cp 28h 
     284       jr z,dispSpace 
     285       cp 2 
     286       jr z,dispSpace 
     287       cp 16 
     288       jr nz,$F 
     289       ld a,(menuCurrent+1) 
     290       or a 
     291       jr z,dispSpace 
     292       jr notProgEdit 
     293$$:    cp 2Ah 
     294       jr nz,notProgEdit 
     295       ld a,(menuCurrent+1) 
     296       cp 2 
     297       jr z,dispSpace 
     298notProgEdit: 
     299       ld a,e 
     300       ld b,'7' 
     301       cp 36 
     302       jr z,dispTheta 
     303       jr nc,dispSpace 
     304dispLessThan9: 
     305       add a,b 
     306displayMenuIndexChar: 
     307       call PutC 
     308       push bc 
     309       ld a,(topMenuRow) 
     310       ld b,a 
     311       ld a,(curRow) 
     312       cp b 
     313       pop bc 
     314       jr nz,$F 
     315       ld a,e 
     316       or a 
     317       jr z,dispColon 
     318       ld a,1Eh 
     319       jr dispArrowColon 
     320$$:    cp 7 
     321       jr nz,dispColon 
     322       ld a,(numItemsForThisHeader) 
     323       dec a 
     324       cp e 
     325       ld a,1Fh 
     326       jr z,dispColon 
     327       jr nc,dispArrowColon 
     328dispColon: 
     329       ld a,':' 
     330dispArrowColon: 
     331       call PutC 
     332       res textInverse,(iy+textFlags) 
     333       ret 
     334GetCurrentMenuPointer: 
     335       call GetMenuPointer 
     336       ld a,(menuCurrent+1) 
     337       or a 
     338       ld b,a 
     339       ld a,(hl) 
     340       ld c,a 
     341       jr z,$F 
     342       push hl 
     343gcmpLoop: 
     344       inc hl 
     345       add a,(hl) 
     346       djnz gcmpLoop 
     347       pop hl 
     348$$:    sla a 
     349       sub c 
     350       add a,(hl) 
     351       inc hl 
     352       ld e,a 
     353       ld d,0 
     354       add hl,de 
     355       ret 
     356DisplayMenuHeader: 
     357       call GetMenuPointer 
     358       ld a,(hl) 
     359       ld b,a 
     360       inc hl 
     361       inc hl 
     362       ld a,(hl) 
     363       ;A is the string index for the header 
     364       set textInverse,(iy+textFlags) 
     365       call GetBuiltInString 
     366       call PutPS 
     367       res textInverse,(iy+textFlags) 
     368       ret 
     369GetMenuPointer: 
     370       ld a,(menuCurrent) 
     371       ld h,0 
     372       ld l,a 
     373       add hl,hl 
     374       ld de,menuTables-2 
     375       add hl,de 
     376       jr LdHLInd 
     377GetBuiltInString: 
     378       ld h,0 
     379       ld l,a 
     380       add hl,hl 
     381       ld de,ptrStrings-2 
     382       add hl,de 
     383       jr LdHLInd 
     384menuTables: 
     385       DW 0000h 
     386       DW mntApps 
     387       DW mntPrograms 
     388       DW mntTools 
     389;Each table has the following: 
     390;      DB bNumberOfHeaders 
     391;      DB bNumberOfChoices1 
     392;      DB bHeaderStringIndex 
     393;      DB keyExtend1,keyCode1 
     394;Custom menu entries also hvae: 
     395;      DW wJumpAddress 
     396mntPrograms: 
     397mntApps: 
     398       DB 1 
     399       DB 1 
     400       DB 01h 
     401       DB 83h,k2Tools 
     402mntTools: 
     403       DB 1 
     404       DB 1 
     405       DB 02h 
     406       DW HexEditor 
     407ptrStrings: 
     408       DW sApplications 
     409       DW sTools 
     410sApplications: 
     411       DB sTools-$F 
     412$$:    DB "APPLICATIONS" 
     413sTools: 
     414       DB sEnd-$F 
     415$$:    DB "TOOLS" 
     416sEnd: 
    13417 
     418HexEditor: 
     419       DB $F-HexEditor-1 
     420       DB "Hex Editor" 
     421$$:    res curAble,(iy+curFlags) 
     422       res curOn,(iy+curFlags) 
     423       res appTextSave,(iy+appFlags) 
     424       B_CALL ClrLCDFull 
     425       ld hl,0 
     426       ld (curRow),hl 
     427       ld hl,sWelcome 
     428       call PutS 
     429       B_CALL GetKey 
     430       B_JUMP JForceCmdNoChar 
     431sWelcome: 
     432       DB "Welcome to the  " 
     433       DB "hex editor!",0 
     434    
     435clrTR: 
     436       cp kCatalog 
     437       jr z,clrTRCatalogPressed 
     438       call IsInCatalogMenu 
     439       jr z,DoCatalogKeyPress 
     440       jr MenuCatCommon 
     441clrTRCatalogPressed: 
     442DoCatalogKeyPress: 
     443       scf 
     444       ret 
     445IsInCatalogMenu: 
     446       ld b,a 
     447       ld a,(menuCurrent) 
     448       cp mCatalog 
     449       ld a,b 
     450       ret 
     451IsInMenu: 
     452       ld b,a 
     453       ld a,(menuCurrent) 
     454       or a 
     455       ld a,b 
     456       ret 
     457 
  • trunk/page1D/1Dbase.asm

    r47 r55  
    44 PUBLIC _JErrorNo,_UnlockFlash,_GetKey 
    55 EXTERN JErrorNo,UnlockFlash,GetKey,keyscnlnk,Rec1stByteNC,RecAByteIO,MemClear,ClrTxtShd 
    6  EXTERN ClrLCDFull,PutS,GetCSC,CursorOff,CursorOn,hideCursor,showCursor,ClrScrnFull 
     6 EXTERN ClrLCDFull,PutS,GetCSC,CursorOff,CursorOn,hideCursor,showCursor,ClrScrnFull,KeyToString 
     7 EXTERN JForceCmdNoChar,JForceCmd 
    78 
    89;4000h: 
     
    4748       DW 0000h 
    4849       DB 00h 
    49 ;_JForceCmdNoChar       equ 4027h 
    50        DW 0000h 
    51        DB 00h 
    52 ;_JForceCmd             equ 402Ah ; 
    53        DW 0000h 
     50_JForceCmdNoChar: 
     51       DW JForceCmdNoChar 
     52       DB 00h 
     53_JForceCmd: 
     54       DW JForceCmd 
    5455       DB 00h 
    5556;_sysErrHandler         equ 402Dh ;loads error context? sp=(onSP) 
     
    14911492       DW showCursor 
    14921493       DB 00h 
    1493 ;_KeyToString           equ 45CAh 
    1494        DW 0000h 
    1495        DB 00h 
     1494_KeyToString: 
     1495       DW KeyToString 
     1496       DB 01h 
    14961497;_PULLDOWNCHK           equ 45CDh ;something wrong here 
    14971498       DW 0000h