EXT_APP equ 1 ;This definition is required of all apps cseg ;This linker directive is required of all apps. nolist include "ti83plus.inc" include "extraequ.inc" list globals on ;This is the application header definition area required for all apps. db 080h,0Fh ;Field: Program length db 00h,00h,00h,00h ;Length=0 (N/A for unsigned apps) db 080h,012h ;Field: Program type db 001h,004h ;Type= Shareware, TI-83Plus db 080h,021h ;Field: App ID db 01h ;Id = 1 db 080h,031h ;Field: App Build db 01h ;Build = 1 db 080h,048h ;Field: App Name db "Convertr" db 080h,081h ;Field: App Pages db 01h ;App Pages = 1 db 080h,090h ;No default splash screen db 03h,026h ,09h,04h, 04h,06fh,01bh,80h ;Field: Date stamp- 5/12/1999 db 02h,0dh,040h ;Dummy encrypted TI date stamp signature db 0a1h ,06bh ,099h ,0f6h ,059h ,0bch ,067h db 0f5h ,085h ,09ch ,09h ,06ch ,0fh ,0b4h ,03h ,09bh ,0c9h db 03h ,032h ,02ch ,0e0h ,03h ,020h ,0e3h ,02ch ,0f4h ,02dh db 073h ,0b4h ,027h ,0c4h ,0a0h ,072h ,054h ,0b9h ,0eah ,07ch db 03bh ,0aah ,016h ,0f6h ,077h ,083h ,07ah ,0eeh ,01ah ,0d4h db 042h ,04ch ,06bh ,08bh ,013h ,01fh ,0bbh ,093h ,08bh ,0fch db 019h ,01ch ,03ch ,0ech ,04dh ,0e5h ,075h db 80h,7Fh ;Field: Program Image length db 0,0,0,0 ;Length=0, N/A db 0,0,0,0 ;Reserved db 0,0,0,0 ;Reserved db 0,0,0,0 ;Reserved db 0,0,0,0 ;Reserved ;End of header data t23 equ asm_Flag1 ;?? negativeOK equ 0 ;?? negativeSet equ 1 ;?? horiz equ asm_Flag2 ;check if horizontal mode horizSet equ 0 TempSP EQU appBackUpScreen UType equ appBackUpScreen+5 ;toggles which unit to convert Unit_Type equ appBackUpScreen+6 ;toggles the type of unit eg. Mass, Pressure, etc. UCx equ appBackUpScreen+3 ;X value of the first line of the window UCy equ appBackUpScreen+4 ;Y "" "" "" UCpenY equ appBackUpScreen+7 ;where to display the result of the conversion (x coordinate) StartApp: bit grfSplit, (IY+sGrFlags) ;Checks if in HORIZ mode CALL z,SetFlag2 set grfSplitOverride, (IY+sGrFlags) set plotLoc, (IY+plotFlags) B_CALL SetNorm_Vals ;Execute your app here! MainMenu: ;This is the menu that you execute the Unit Converter from/ ;blah, blah, blah... jp Converter ;Jumps to converter. Suprised? jp Quit Converter: ;The CONVERTER ld a,1 ld (UType),a ld (Unit_Type),a Unit: B_CALL ClrScrnFull B_CALL ClrLCDFull ld a,6 ld (curRow),a XOR a ld (promptCol),a ld (promptRow),a ld (curCol),a set textInverse, (IY+textflags) set fracDrawLFont,(IY+fontFlags) XOR a ld (curRow),a ld (curCol),a ld a,(Unit_Type) cp 0 CALL z,UC3 cp 1 jp z,Col1 cp 2 jp z,Col2 cp 3 jp z,Col3 cp 4 jp z,Col4 ld a,1 ld (Unit_Type),a jp Col1 UC3: LD a,4 ld (Unit_Type),a ret Col1: ld a,6 ld (curRow),a ld a,0 ld (curCol),a ld hl,Cpressure CALL Disp XOR a ld (curRow),a ld (curCol),a ld a,(UType) cp 0 call z,UCl cp 1 jp z,Cin2mb cp 2 jp z,Cmb2in cp 3 jp z,Cmb2pascal cp 4 jp z,Cpascal2mb cp 5 jp z,Cmb2atm cp 6 jp z,Catm2mb ld a,1 ld (UType),a jp Cin2mb UCl: ld a,6 ld (UType),a ret Cin2mb: ld hl, Si2mb Call Disp ld hl,inmb B_CALL PushReal B_CALL OP1ToOP4 res textInverse, (IY+textflags) ld a,1 ld (curRow),a ld a,0 ld (curCol),a ld hl,Value CALL Disp B_CALL OP1ToOP6 ld hl,Value2 jp Cend Cmb2in: ld hl,Mb2in Call Disp ld hl,mbin B_CALL PushReal B_CALL OP1ToOP4 res textInverse, (IY+textflags) ld a,1 ld (curRow),a ld a,0 ld (curCol),a ld hl,Value2 CALL Disp B_CALL OP1ToOP6 ld hl,Value jp Cend Cmb2pascal: ld hl,mb2pascal Call Disp ld hl,mp B_CALL PushReal B_CALL OP1ToOP4 res textInverse, (IY+textflags) ld a,1 ld (curRow),a ld a,0 ld (curCol),a ld hl,Value2 CALL Disp B_CALL OP1ToOP6 ld hl,Value3 jp Cend Cpascal2mb: ld hl,pascal2mb Call Disp ld hl,pm B_CALL PushReal B_CALL OP1ToOP4 res textInverse, (IY+textflags) ld a,1 ld (curRow),a ld a,0 ld (curCol),a ld hl,Value3 CALL Disp B_CALL OP1ToOP6 ld hl,Value2 jp Cend Cmb2atm: ld hl,mb2atm Call Disp ld hl,ma B_CALL PushReal B_CALL OP1ToOP4 res textInverse, (IY+textflags) ld a,1 ld (curRow),a ld a,0 ld (curCol),a ld hl,Value2 CALL Disp B_CALL OP1ToOP6 ld hl,Value4 jp Cend Catm2mb: ld hl,atm2mb Call Disp ld hl,am B_CALL PushReal B_CALL OP1ToOP4 res textInverse, (IY+textflags) ld a,1 ld (curRow),a ld a,0 ld (curCol),a ld hl,Value4 CALL Disp B_CALL OP1ToOP6 ld hl,Value2 jp Cend Col2: ld a,6 ld (curRow),a ld a,0 ld (curCol),a ld hl,Cmass CALL Disp XOR a ld (curRow),a ld (curCol),a ld a,(UType) cp 0 call z,UC2 cp 1 jp z,Cg2lb cp 2 jp z,Clb2g ld a,1 ld (UType),a jp Cg2lb UC2: ld a,2 ld (UType),a ret Cg2lb: ld hl,g2lb Call Disp ld hl,gp B_CALL PushReal B_CALL OP1ToOP4 res textInverse, (IY+textflags) ld a,1 ld (curRow),a ld a,0 ld (curCol),a ld hl,Value5 CALL Disp B_CALL OP1ToOP6 ld hl,Value6 jp Cend Clb2g: ld hl,bl2g Call Disp ld hl,pg B_CALL PushReal B_CALL OP1ToOP4 res textInverse, (IY+textflags) ld a,1 ld (curRow),a ld a,0 ld (curCol),a ld hl,Value6 CALL Disp B_CALL OP1ToOP6 ld hl,Value5 jp Cend Col3: ld a,6 ld (curRow),a ld a,0 ld (curCol),a ld hl,Cenergy CALL Disp XOR a ld (curRow),a ld (curCol),a ld a,(UType) cp 0 CALL z,UC4 cp 1 jp z,Ce2j cp 2 jp z,Ce2cal cp 3 jp z,Cj2cal cp 4 jp z,Cj2erg cp 5 jp z,Ccal2j cp 6 jp z,Ccal2erg ld a,1 ld (UType),a jp Ce2j UC4: ld a,6 ld (UType),a ret Ce2j: ld hl,erg2j Call Disp ld hl,ej B_CALL PushReal B_CALL OP1ToOP4 res textInverse, (IY+textflags) ld a,1 ld (curRow),a ld a,0 ld (curCol),a ld hl,Cerg CALL Disp B_CALL OP1ToOP6 ld hl,Cj jp Cend Ce2cal: ld hl,e2cal Call Disp ld hl,ec B_CALL PushReal B_CALL OP1ToOP4 res textInverse, (IY+textflags) ld a,1 ld (curRow),a ld a,0 ld (curCol),a ld hl,Cerg CALL Disp B_CALL OP1ToOP6 ld hl,Ccal jp Cend Cj2cal: ld hl,j2cal Call Disp ld hl,jc B_CALL PushReal B_CALL OP1ToOP4 res textInverse, (IY+textflags) ld a,1 ld (curRow),a ld a,0 ld (curCol),a ld hl,Cj CALL Disp B_CALL OP1ToOP6 ld hl,Ccal jp Cend Cj2erg: ld hl,j2erg Call Disp ld hl,je B_CALL PushReal B_CALL OP1ToOP4 res textInverse, (IY+textflags) ld a,1 ld (curRow),a ld a,0 ld (curCol),a ld hl,Cj CALL Disp B_CALL OP1ToOP6 ld hl,Cerg jp Cend Ccal2j: ld hl,cal2j Call Disp ld hl,cj B_CALL PushReal B_CALL OP1ToOP4 res textInverse, (IY+textflags) ld a,1 ld (curRow),a ld a,0 ld (curCol),a ld hl,Ccal CALL Disp B_CALL OP1ToOP6 ld hl,Cj jp Cend Ccal2erg: ld hl,cal2erg Call Disp ld hl,ce B_CALL PushReal B_CALL OP1ToOP4 res textInverse, (IY+textflags) ld a,1 ld (curRow),a ld a,0 ld (curCol),a ld hl,Ccal CALL Disp B_CALL OP1ToOP6 ld hl,Cerg jp Cend Col4: ld a,6 ld (curRow),a ld a,0 ld (curCol),a ld hl,Cpower CALL Disp XOR a ld (curRow),a ld (curCol),a ld a,(UType) cp 0 CALL z,UC4 cp 1 jp z,Cw2cm cp 2 jp z,Cw2hp cp 3 jp z,Ccm2w cp 4 jp z,Ccm2hp cp 5 jp z,Chp2w cp 6 jp z,Chp2cm ld a,1 ld (UType),a jp Cw2cm Cw2cm: ld hl,w2cm Call Disp ld hl,wc B_CALL PushReal B_CALL OP1ToOP4 res textInverse, (IY+textflags) ld a,1 ld (curRow),a ld a,0 ld (curCol),a ld hl,Cw CALL Disp B_CALL OP1ToOP6 ld hl,Ccm jp Cend Cw2hp: ld hl,w2hp Call Disp ld hl,wh B_CALL PushReal B_CALL OP1ToOP4 res textInverse, (IY+textflags) ld a,1 ld (curRow),a ld a,0 ld (curCol),a ld hl,Cw CALL Disp B_CALL OP1ToOP6 ld hl,Chp jp Cend Ccm2w: ld hl,cm2w Call Disp ld hl,cw B_CALL PushReal B_CALL OP1ToOP4 res textInverse, (IY+textflags) ld a,1 ld (curRow),a ld a,0 ld (curCol),a ld hl,Ccm CALL Disp B_CALL OP1ToOP6 ld hl,Cw jp Cend Ccm2hp: ld hl,cm2hp Call Disp ld hl,ch B_CALL PushReal B_CALL OP1ToOP4 res textInverse, (IY+textflags) ld a,1 ld (curRow),a ld a,0 ld (curCol),a ld hl,Ccm CALL Disp B_CALL OP1ToOP6 ld hl,Chp jp Cend Chp2w: ld hl,hp2w Call Disp ld hl,hw B_CALL PushReal B_CALL OP1ToOP4 res textInverse, (IY+textflags) ld a,1 ld (curRow),a ld a,0 ld (curCol),a ld hl,Chp CALL Disp B_CALL OP1ToOP6 ld hl,Cw jp Cend Chp2cm: ld hl,hp2cm Call Disp ld hl,hc B_CALL PushReal B_CALL OP1ToOP4 res textInverse, (IY+textflags) ld a,1 ld (curRow),a ld a,0 ld (curCol),a ld hl,Chp CALL Disp B_CALL OP1ToOP6 ld hl,Ccm jp Cend Cend: ld a,24 ld (penRow),a XOR a ld (penCol),a call DispS res fracDrawLFont,(IY+fontFlags) ld a,(penCol) ld (UCpenY),a Init: ld a,(curCol) ld (UCx),a ld a,(curRow) ld (UCy),a ld hl,plotSScreen B_CALL SaveDisp call GetMathInput ;Get some input! CALL UnitMult CALL gmcxQuitStuff jp gmcxMQuit CreateEntry: ;Create the temp prog used for input call LookupEntry ret nc ld hl,0 B_CALL CreateProg ret DeleteEntry: ;Delete the temp prog call LookupEntry ret c B_CALL DelVar ret LookupEntry: ;Lookup temp prog in symbol table ld hl,EntryName rst 20h B_CALL ChkFindSym ret SetupInputStuff: ;General input set-up stuff that needs ; to be run whether we're continuing ; the input or not. set appAllowContext,(iy+APIFlg) ;To allow Yequ and Graph keys B_CALL CursorOn B_CALL HomeUp ld a,(UCy) ld (curRow),a ld a,(UCx) ld (curCol),a B_CALL CursorOn ld hl,gmMonVectors ;Our custom vectors! res appMenus, (IY+appFlags) set appLockMenus, (IY+appFlags) B_CALL AppInit ld a,(UCx) ld (winLeftEdge),a ld a,(UCy) ld (winTop),a ld (curRow),a inc a ld (winBtm),a xor a ld (curCol),a ld hl,OP6 Call Disp ret GetMathInput: call SetupInputStuff call CreateEntry set cmdVirgin,(iy+cmdFlags) ;Edit buffer is empty call LookupEntry B_CALL SetEmptyEditPtr ;Setup edit buffer ld (TempSP),sp ;Save for later call gmcxRedisp ;To get the softkey menu B_CALL Mon ContinueMathInput: call SetupInputStuff call SetupEditProg ;Not empty...needs to be done differently ld (TempSP),sp B_CALL DispEOW ;Restore old stuff to screen B_CALL IsEditEmpty ;Don't want to display a faulty char jp z,SkipInitCurUnder ld hl,(editTail) ld a,(hl) ld (curUnder),a ;Initialize under the cursor ld (textShadow),a SkipInitCurUnder: call gmcxRedisp ;Display softkey menu stuff B_CALL Mon SetupEditProg: call LookupEntry B_CALL EditProg ;Insert RAM, setup iMathPtrs set editOpen,(iy+editFlags) ;Editor is running ld hl,(iMathPtr1) inc hl inc hl ld (editTop),hl ;Top of edit session push hl ld hl,(iMathPtr2) ld (editCursor),hl push hl ex de,hl ld hl,(iMathPtr3) B_CALL CpHLDE jp nc,SetupEditProgSwapSkip ex de,hl SetupEditProgSwapSkip: ld (editBtm),hl ld (editTail),hl pop hl pop de or a sbc hl,de ret z ld c,l ld b,h ld hl,(editCursor) dec hl ld de,(editTail) dec de lddr inc hl ld (editCursor),hl inc de ld (editTail),de ret gmMonVectors: dw gmcxMain dw gmcxPPutAway dw gmcxPutAway dw gmcxRedisp dw gmcxErrorEP dw gmcxSizeWind db 0Eh ;Process menus + auto scroll + textsave gmcxSizeWind: ;We're not allowing Rcl in this example ;The window size wont change ret gmcxErrorEP: ;Not dealing with error goto either. ret gmcxRedisp: ld hl,plotSScreen ld b,63 B_CALL RestoreDisp gmcxRedispLoop: ;Restore the screen from textShadow ld hl,SoftKeyText call SoftKey ;Display softkey menu ret gmcxPutAway: B_CALL CloseEditEqu ;Close the equation B_CALL ReloadAppEntryVecs xor a ld (iy+textFlags),a call DeleteEntry bit monAbandon,(iy+monFlags) ;Is calc turning off? jp nz,gmcxPutAwayOff B_JUMP JForceCmdNoChar gmcxPutAwayOff: B_JUMP PutAway gmcxPPutAway: ret gmcxMain: ld hl,winBtm ld (hl),3 ;So the menu can't be overwritten push hl call gmcxDoMain ld hl,plotSScreen B_CALL SaveDisp pop hl ld (hl),8 ;Need a full screen for catalog ld a,1 ld (winTop),a ret gmcxLoopQuit: ld hl,1 B_CALL DeallocFPS call gmcxQuitStuff ld sp,(TempSP) ld hl,EntryName rst 20h bit grfSplit, (IY+sGrFlags) CALL z,SetFlag2 set grfSplitOverride, (IY+sGrFlags) set plotLoc, (IY+plotFlags) B_CALL SetNorm_Vals jp Quit Cinc: ld hl,1 B_CALL DeallocFPS CALL gmcxQuitStuff B_CALL ReleaseBuffer ld sp,(TempSP) ld hl,EntryName rst 20h bit grfSplit, (IY+sGrFlags) CALL z,SetFlag2 set grfSplitOverride, (IY+sGrFlags) set plotLoc, (IY+plotFlags) B_CALL SetNorm_Vals call DeleteEntry ld a,(Unit_Type) inc a ld (Unit_Type),a jp Unit Cinc2: ld hl,1 B_CALL DeallocFPS CALL gmcxQuitStuff B_CALL ReleaseBuffer ld sp,(TempSP) ld hl,EntryName rst 20h bit grfSplit, (IY+sGrFlags) CALL z,SetFlag2 set grfSplitOverride, (IY+sGrFlags) set plotLoc, (IY+plotFlags) B_CALL SetNorm_Vals call DeleteEntry ld a,(UType) inc a ld (UType),a jp Unit DispModeStuff: ld a,21 ld (penCol),a ld (penRow),a ld hl,ModeFloat CALL DispS ld a,21 ld (penCol),a ld a,27 ld (penRow),a ld hl,ModeDeg CALL DispS ld a,53 ld (penCol),a ld hl,ModeRad CALL DispS ret DR1: ld a,'F' B_CALL VPutMap ld a,(penCol) sub 4 ld (penCol),a ld a,b cp 21 ret z ld a,'0' B_CALL VPutMap ld a,(penCol) sub 4 ld (penCol),a ld a,b cp 26 ret z ld a,'1' B_CALL VPutMap ld a,(penCol) sub 4 ld (penCol),a ld a,b cp 31 ret z ld a,'2' B_CALL VPutMap ld a,(penCol) sub 4 ld (penCol),a ld a,b cp 36 ret z ld a,'3' B_CALL VPutMap ld a,(penCol) sub 4 ld (penCol),a ld a,b cp 41 ret z ld a,'4' B_CALL VPutMap ld a,(penCol) sub 4 ld (penCol),a ld a,b cp 46 ret z ld a,'5' B_CALL VPutMap ld a,(penCol) sub 4 ld (penCol),a ld a,b cp 51 ret z ld a,'6' B_CALL VPutMap ld a,(penCol) sub 4 ld (penCol),a ld a,b cp 56 ret z ld a,'7' B_CALL VPutMap ld a,(penCol) sub 4 ld (penCol),a ld a,b cp 61 ret z ld a,'8' B_CALL VPutMap ld a,(penCol) sub 4 ld (penCol),a ld a,b cp 66 ret z ld a,'9' B_CALL VPutMap ld a,(penCol) sub 4 ld (penCol),a ret DR2: push BC ld hl,ModeRad CALL DispS pop BC ld a,b ld (penCol),a ld a,b cp 53 ret z push BC ld hl,ModeDeg CALL DispS pop BC ld a,b ld (penCol),a ret ML1: ld d,b ret MLoop2: ld e,b ret SetDeg: ld e,53 ret ModeMenu: ld hl,plotSScreen B_CALL SaveDisp ld l,19 ld h,20 ld e,75 ld d,34 B_CALL ClearRect ld l,19 ld h,20 ld e,75 ld d,34 B_CALL DrawRectBorder CALL DispModeStuff B_CALL RunIndicOff ld c,21 ld a,(fmtDigits) ld b,26 cp 0 jp z,SetMode ld b,31 cp 1 jp z,SetMode ld b,36 cp 2 jp z,SetMode ld b,41 cp 3 jp z,SetMode ld b,46 cp 4 jp z,SetMode ld b,51 cp 5 jp z,SetMode ld b,56 cp 6 jp z,SetMode ld b,61 cp 7 jp z,SetMode ld b,66 cp 8 jp z,SetMode ld b,71 cp 9 jp z,SetMode ld b,21 SetMode: ld e,21 bit trigDeg, (IY+trigFlags) call z,SetDeg ld d,21 ModeLoop: push HL push DE push BC ld a,c cp 21 ld a,c cp 27 set textinverse, (IY+textFlags) ld a,c cp 21 jp z,Loop2 ld a,21 ld (penRow),a ld a,d ld b,a ld (penCol),a CALL DR1 jp Loop3 Loop2: ld a,27 ld (penRow),a ld a,e ld b,a ld (penCol),a CALL DR2 Loop3: pop BC ld a,c ld (penRow),a ld a,b ld (penCol),a ld a,c cp 21 call z,DR1 cp 27 call z,DR2 push BC B_CALL GetKey res textinverse, (IY+textFlags) push AF CALL DispModeStuff pop AF pop BC pop DE pop HL cp kLeft jp z,ModeLeft cp kRight jp z,ModeRight cp kDown jp z,ModeDown cp kEnter jp z,ModeEnter cp kUp jp z,ModeUp cp kGraph jp z,gmcxLoopQuit cp kYequ jp z,gmcxMQuit cp kClear jp z,ReturnMode cp kQuit jp z,gmcxMQuit jp ModeLoop ModeDown: ld a,c cp 27 jp z,ModeLoop CALL DoMode ld d,b ld b,e ld c,27 ld a,c ld (penCol),a jp ModeLoop ModeEnter: ld a,c cp 27 call z,DoMode2 ld a,c cp 27 jp z,ReturnMode CALL DoMode ld d,b ld b,e ld c,27 ld a,c ld (penCol),a jp ModeLoop DoMode: ld a,0 ld (fmtDigits),a ld a,b cp 26 ret z ld a,1 ld (fmtDigits),a ld a,b cp 31 ret z ld a,2 ld (fmtDigits),a ld a,b cp 36 ret z ld a,3 ld (fmtDigits),a ld a,b cp 41 ret z ld a,4 ld (fmtDigits),a ld a,b cp 46 ret z ld a,5 ld (fmtDigits),a ld a,b cp 51 ret z ld a,6 ld (fmtDigits),a ld a,b cp 56 ret z ld a,7 ld (fmtDigits),a ld a,b cp 61 ret z ld a,8 ld (fmtDigits),a ld a,b cp 66 ret z ld a,9 ld (fmtDigits),a ld a,b cp 71 ret z ld a,255 ld (fmtDigits),a ret DoMode2: set trigDeg, (IY+trigFlags) ld a,b cp 21 ret z res trigDeg, (IY+trigFlags) ret ModeUp: ld a,c cp 21 jp z,ModeLoop CALL DoMode2 ld e,b ld b,d ld c,21 ld a,c ld (penCol),a jp ModeLoop ModeLeft: ld a,c cp 27 jp z,ML2 ld a,b cp 21 jp z,MallL sub 5 ld b,a jp ModeLoop ML2: ld a,b CP 21 jp z,MallL2 jp MzeroL MzeroL: ld b,21 jp ModeLoop MallL: ld b,71 jp ModeLoop MallL2: ld b,53 jp ModeLoop ModeRight: ld a,c cp 27 jp z,MR2 ld a,b cp 71 jp z,MzeroL add a,5 ld b,a jp ModeLoop MR2: ld a,b CP 53 jp z,MzeroL jp MallL2 ReturnMode: ld l,19 ld h,20 ld e,75 ld d,34 B_CALL ClearRect B_CALL Disp ld b,63 call gmcxRedisp ret gmcxClear: B_CALL ClrWindow ld hl,1 B_CALL DeallocFPS CALL gmcxQuitStuff B_CALL ReleaseBuffer ld sp,(TempSP) ld hl,EntryName rst 20h bit grfSplit, (IY+sGrFlags) CALL z,SetFlag2 set grfSplitOverride, (IY+sGrFlags) set plotLoc, (IY+plotFlags) B_CALL SetNorm_Vals call DeleteEntry jp Unit gmcxDoMain: cp kMode jp z,ModeMenu cp kWindow jp z,Cinc cp kTrace jp z,Cinc2 cp kMatrixEd call z,gmcxRedisp cp kStatEd call z,gmcxRedisp cp kPrgmEd call z,gmcxRedisp cp kPrgmCr call z,gmcxRedisp cp kZFactEd call z,gmcxRedisp cp kSolveRoot call z,gmcxRedisp cp kZoom call z,gmcxRedisp cp kZFit call z,gmcxRedisp cp kZIn call z,gmcxRedisp cp kZOut call z,gmcxRedisp cp kZPrev call z,gmcxRedisp cp kBox call z,gmcxRedisp cp kDecml call z,gmcxRedisp cp kSetZm call z,gmcxRedisp cp kSquar call z,gmcxRedisp cp kStd call z,gmcxRedisp cp kTrig call z,gmcxRedisp cp kUsrZm call z,gmcxRedisp cp kZSto call z,gmcxRedisp cp kZInt call z,gmcxRedisp cp kZStat call z,gmcxRedisp cp kEval call z,gmcxRedisp cp kInters call z,gmcxRedisp cp kDYDX call z,gmcxRedisp cp kFnIntg call z,gmcxRedisp cp kRootG call z,gmcxRedisp cp kDYDT call z,gmcxRedisp cp kDXDT call z,gmcxRedisp cp kDRDo call z,gmcxRedisp cp KGFMin call z,gmcxRedisp cp KGFMax call z,gmcxRedisp cp kStatP call z,gmcxRedisp cp kChkRAM call z,gmcxRedisp cp kDelMem call z,gmcxRedisp cp kResetMem call z,gmcxRedisp cp kMem call z,gmcxRedisp cp kResetMem call z,gmcxRedisp cp kResetDef call z,gmcxRedisp cp kGraph jp z,gmcxLoopQuit cp kYequ jp z,gmcxMQuit cp kQuit jp z,gmcxMQuit cp kEnter jp z,gmcxMEnter cp kClear jp z,gmcxClear cp kLeft jp nz,gmcxMNotLeft B_CALL CursorLeft ret gmcxMNotLeft: cp kRight jp z,gmcxMRight cp kUp jp z,gmcxMUp cp kDown jp nz,gmcxMNotDown B_CALL CursorDown ret gmcxMNotDown: cp kBOL ;Beginning of Line jp z,gmcxMBOL cp kEOL ;End of Line jp z,gmcxMEOL cp kIns ;Insert jp z,gmcxMIns cp kDel jp z,gmcxMDel cp kClear jp z,gmcxMClear cp kTrace+1 ret c B_CALL InsDisp ;Display and update buffer XOR a ret gmcxMRight: res textInsMode,(iy+textFlags) B_CALL BufRight ;Update edit pointers jp z,gmcxMRightDone ;Already at the end of buffer? res textScrolled,(iy+textFlags) B_CALL PutTokString bit textScrolled,(iy+textFlags) jp z,gmcxMRightDone ;If no scroll, we don't have to ld hl,(curRow) ; worry about redisplaying the push hl ; text afterwards ld hl,(editBtm) ld de,(editTail) B_CALL DispForward pop hl ld (curRow),hl gmcxMRightDone: ret gmcxMClear: ;Clear screen bit cmdVirgin,(iy+cmdFlags) ret nz B_CALL IsEditEmpty jp nz,gmcxMClear2 B_CALL ClrWindow call gmcxMBOL set cmdVirgin,(iy+cmdFlags) B_CALL CanAlphIns gmcxMClear2: B_CALL DispHead B_CALL EraseEOW B_CALL BufClear set cmdVirgin,(iy+cmdFlags) B_CALL CanAlphIns ret gmcxMDel: res textInsMode,(iy+textFlags) B_CALL BufDelete ;Delete token from buffer B_CALL IsEditEmpty jp nz,gmcxMDelNotEmpty set cmdVirgin,(iy+cmdFlags) gmcxMDelNotEmpty: B_CALL DispEOW ;Redisplay the rest of the toks ret gmcxMIns: ld a,(flags+textFlags) xor 10h ;Toggle Insert flag ld (flags+textFlags),a ret gmcxMBOL: ;Beginning of line res textScrolled,(iy+textFlags) gmcxMBOLLoop: B_CALL IsAtTop ;Have we reached the beginning? ret z ;If so, we're done B_CALL CursorLeft jp gmcxMBOLLoop gmcxMEOL: ;End of line res textScrolled,(iy+textFlags) gmcxMEOLLoop: B_CALL IsAtBtm ret z call gmcxMRight jp gmcxMEOLLoop gmcxMUp: xor a push af res textScrolled,(iy+textFlags) ld de,(editTop) ld bc,(curRow) inc b gmcxMUpLoop: B_CALL CursorLeft ld hl,(editCursor) ld a,(curRow) cp c ;Still on same row? jp nz,gmcxMUpAtNextLine ;if not, proceed with A<>0 bit textScrolled,(iy+textFlags) jp nz,gmcxMUpAtNextLine ;If we scrolled, then we got to next line pop af ;Restore A=0 push af gmcxMUpAtNextLine: or a ;If A=0, we shouldn't check the col yet jp z,gmcxMUpCont ld a,(curCol) cp b ;Have we gotten back to the right column? jp c,gmcxMUpDone ;If so, we're done push de push hl B_CALL GetPrevTok pop hl ld (editCursor),hl pop de gmcxMUpCont: B_CALL CpHLDE ;Gotten to beginning of buffer yet? xo jp nz,gmcxMUpLoop ;If not, we can keep going! gmcxMUpDone: pop af or a B_CALL CpHLDE ret nz ld hl,0 ld (penCol),hl ld hl,8 ld (penRow),hl set fracDrawLFont, (IY+fontFlags) ld hl,OP6 CALL DispS res fracDrawLFont, (IY+fontFlags) ret gmcxMQuit: ld hl,1 B_CALL DeallocFPS CALL gmcxQuitStuff B_CALL ReleaseBuffer ld sp,(TempSP) ld hl,EntryName rst 20h bit grfSplit, (IY+sGrFlags) CALL z,SetFlag2 set grfSplitOverride, (IY+sGrFlags) set plotLoc, (IY+plotFlags) B_CALL SetNorm_Vals jp MainMenu gmcxMEnter: gmcxMEval: ;Parse edit buffer, and restore it call gmcxQuitStuff ld sp,(TempSP) ld hl,EntryName rst 20h AppOnErr ParseError B_CALL ParseInp ;Parse it! AppOffErr ld a,(OP1) and 1Fh ;Check if answer is a real jp nz,TypeError ld a,8 B_CALL FormReal ;Convert real to ASCII ld hl,SoftKeyText2 call SoftKey EvalLoop: ret UnitMult: B_CALL PopRealO2 B_CALL FPMult set fracDrawLFont,(IY+fontFlags) ld a,24 ld (penRow),a ld a,(UCpenY) ld (penCol),a ld a,7 B_CALL DispOP1A B_CALL OP1ToOP5 res fracDrawLFont,(IY+fontFlags) ld a,57 ld (penRow),a ld a,39 ld (penCol),a ld hl,SstoY CALL DispS ld a,57 ld (penRow),a ld a,20 ld (penCol),a ld hl,SstoX CALL DispS XOR a ld (curUnder),a ld (editCursor),a B_CALL RunIndicOff ConvLoop: B_CALL GetKey cp 0 jp z,ConvLoop cp kGraph jp z,Quit cp kQuit jp z,MainMenu cp kyequ jp z,MainMenu cp kWindow jp z,CstoX cp kZoom jp z,CstoY push AF cp kTrace CALL z,gmcxQuitStuff pop AF cp kTrace jp z,Unit jp ConvLoop CstoX: ld a,57 ld (penRow),a ld a,20 ld (pencol),a ld hl,SstoX set textInverse, (IY+textflags) call DispS res textInverse, (IY+textflags) B_CALL OP5ToOP1 B_CALL StoX XOR a jp ConvLoop CstoY: ld a,57 ld (penRow),a ld a,39 ld (pencol),a ld hl,SstoY set textInverse, (IY+textflags) call DispS res textInverse, (IY+textflags) B_CALL OP5ToOP1 B_CALL StoY XOR a jp ConvLoop ;===================== ;UTILITY ROUTINES ;===================== ParseError: ld hl,ParseErrorTXT jp ErrorCont TypeError: jp GetMathInput ErrorCont: push hl XOR a ld (curCol),a ld a,5 ld (curRow),a pop hl call PutSApp B_CALL GetKey XOR a ld (curCol),a ld a,5 ld (curRow),a ld hl,IntroText CALL Disp jp ContinueMathInput ParseErrorTXT: db "Syntax error ",0 gmcxQuitStuff: B_CALL CanAlphIns ;Turn off Alpha and Ins indicators B_CALL DispTail ;Display rest of the stuff after cursor B_CALL CloseEditEqu ;Close the edit buffer B_CALL ReloadAppEntryVecs ;Reload default system vectors ld a,9 ;Reset window to proper size ld (winBtm),a ld a,1 ld (winLeft),a ld (winLeftEdge),a ld (winTop),a ret EntryName: db ProgObj,026h,"tmp",0 SoftKeyText2: db "MAIN",0 db 0,0 db "BACK",0 db "QUIT",0 SoftKeyText: db "MAIN",0 db "TYPE",0 db 0 db "UNIT",0 db "QUIT",0 SoftKey: ;Input ; hl -> key text ;Ouput ; soft keys are displayed to screen push hl ld bc,0007h ld de,95*256+7 ld h,1 B_CALL ILine ld b,19 ld d,b ld e,0 B_CALL ILine ld b,38 ld d,b B_CALL ILine ld b,57 ld d,b B_CALL ILine ld b,76 ld d,b B_CALL ILine ld b,0 ld d,b B_CALL ILine ld b,95 ld d,b B_CALL ILine pop hl ld a,57 ld (penRow),a ld a,3 SoftKeyLoop: ;loop to display text inside boxes ld (penCol),a push af call VPutSApp pop af add a,19 cp 98 jp nz,SoftKeyLoop ret VPutSApp: ;Same as VPutS, but can be used with pointer in app ld a,(hl) inc hl or a ret z push hl B_CALL VPutMap pop hl jp VPutSApp Disp: ld de, OP1 B_CALL StrCopy ld hl, OP1 B_CALL PutS ret PutSApp: ;Same as PutS, but can be used with pointer in app ld a,(hl) inc hl or a ret z B_CALL PutC jp PutSApp Quit: ;the QUIT routine call DeleteEntry B_CALL ClrLCDFull set plotDisp, (IY+plotflags) set graphDraw, (iy+graphFlags) res grfSplitOverride, (IY+sGrFlags) set bufferOnly, (IY+plotflag3) res plotLoc, (IY+plotFlags) b_call ReloadAppEntryVecs res grfSplit, (IY+sGrFlags) B_CALL SetNorm_Vals ;Reset to horizontal mode doesn't work right. Just force full screen for now... B_JUMP JForceCmdNoChar DispS: ld de,OP1 B_CALL StrCopy ld hl,OP1 B_CALL VPutS ret SetFlag2: set horizSet, (IY+horiz) ret ModeFloat: .asciz "F 0 1 2 3 4 5 6 7 8 9" ModeDeg: .asciz "Degree" ModeRad: .asciz "Radian" Spressure: .asciz "Pressure" SstoX: .asciz " Sto X " SstoY: .asciz " Sto Y " Sblank: db 006h,006h,006h,006h,006h,006h,006h,006h,006h,006h,006h,006h,006h,006h,006h,006h,006h,006h,006h,006h,006h,006h,006h," ",00h IntroText: .asciz " " Cpressure: db " Pressure ",000h Cmass: db " Mass ",000h Cenergy: db " Energy ",000h Cpower: db " Power ",000h Value: db "in=",0 Value2: db "mb=",0 Value3: db "Pa=",0 Value4: db "atm=",0 Value5: db "g=",0 Value6: db "lb=",0 Cerg: db "erg=",0 Cj: db "j=",0 Ccal: db "Cal=",0 Cw: db "W=",0 Ccm: db "Cal/Min=",0 Chp: db "hp=",0 ;Pressure Si2mb: .asciz " Mercury to mb " inmb: db 00h,81h,33h,86h,50h,00h,00h,00h,00h Mb2in: .asciz " mb to Mercury " mbin: db 00h,7Eh,29h,53h,00h,00h,00h,00h,00h mb2pascal: .asciz " mb to Pascal " pm: db 00h,7Eh,10h,00h,00h,00h,00h,00h,00h pascal2mb: .asciz " Pascal to mb " mp: db 00h,81h,10h,00h,00h,00h,00h,00h,00h mb2atm: .asciz "mb to Atmosphere" ma: db 00h,7Ch,98h,69h,23h,26h,66h,66h,67h atm2mb: .asciz "Atmosphere to mb" am: db 00h,83h,10h,13h,25h,00h,00h,00h,00h ;Power w2cm: .asciz "Watts to Cal/Min" wc: db 00h,81h,14h,33h,53h,00h,00h,00h,00h w2hp: .asciz " Watts to hp " wh: db 00h,7Dh,13h,40h,44h,82h,60h,00h,00h cm2w: .asciz "Cal/Min to Watts" cw: db 00h,7Eh,69h,73h,00h,00h,00h,00h,00h cm2hp: .asciz " Cal/Min to hp " ch: db 00h,7Ah,93h,47h,18h,49h,87h,00h,00h hp2w: .asciz " hp to Watts " hw: db 00h,82h,74h,60h,00h,00h,00h,00h,00h hp2cm: .asciz " hp to Cal/Min " hc: db 00h,84h,10h,69h,84h,08h,15h,00h,00h ;Mass g2lb: .asciz "g to U.S. Pounds" gp: db 00h,7Dh,22h,01h,00h,00h,00h,00h,00h bl2g: .asciz "U.S. Pounds to g" pg: db 00h,82h,45h,45h,45h,45h,45h,45h,45h ;Energy erg2j: .asciz " Erg to Joules " ej: db 00h,79h,10h,00h,00h,00h,00h,00h,00h e2cal: .asciz "Erg to Calories " ec: db 00h,78h,23h,88h,00h,00h,00h,00h,00h j2cal: .asciz "Joule to Calorie" jc: db 00h,7Fh,23h,90h,00h,00h,00h,00h,00h j2erg: .asciz " Joules to Erg " je: db 00h,87h,10h,00h,00h,00h,00h,00h,00h cal2j: .asciz "Calorie to Joule" cj: db 00h,80h,41h,86h,00h,00h,00h,00h,00h cal2erg: .asciz "Calories to Erg " ce: db 00h,87h,41h,86h,00h,00h,00h,00h,00h a1: db 00h,7Fh,10h,00h,00h,00h,00h,00h,00h a2: db 00h,7Eh,10h,00h,00h,00h,00h,00h,00h a3: db 00h,7Dh,10h,00h,10h,00h,00h,00h,00h a4: db 00h,7Ch,10h,00h,00h,00h,00h,00h,00h a5: db 00h,7Bh,10h,00h,00h,00h,00h,00h,00h a6: db 00h,7Ah,10h,00h,00h,00h,00h,00h,00h a7: db 00h,79h,10h,00h,00h,00h,00h,00h,00h a8: db 00h,78h,10h,00h,00h,00h,00h,00h,00h a9: db 00h,77h,10h,00h,00h,00h,00h,00h,00h a10: db 00h,76h,10h,00h,00h,00h,00h,00h,00h a11: db 00h,75h,10h,00h,00h,00h,00h,00h,00h a12: db 00h,74h,10h,00h,00h,00h,00h,00h,00h a13: db 00h,73h,10h,00h,00h,00h,00h,00h,00h