diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1377554 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.swp diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..decca2a --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,53 @@ +# Contributing +Before you fork and change anything, please read this file! + +## Conventions +This project *may* contain some conventions not found in other simalar projects. The main code styles and locations of use are listed below. + +### Universal +* Indents +Indents are inportant to keep code readable. The superior indent character is space, so. You should indent when: + * Pushing to stack (unindent when poping) + * ex instruction (only when the ex is temporary and reversed) + * Loops +* Routines + * Routines should have the following header: + ```asm + ;;name + ;;Discription + ;;Inputs: + ;; HL: purpose + ;;Outputs: + ;; HL: ... + ``` + * Inputs/Outputs only if needed. + * Labels + * Name of routine must be lowercase + * Name of routine must have prefix of file name + * If there are lables in a routine: + * label must be name of routine + Suffix (capitalized): + `fileroutineSuffix` + * Keep to `jr` in routines (unless impossible) + * All routines MUST ret at the end (no jp) + * Routines MUST preserve all registers (except outputs) + * A routine's instructions should be lowercase + +### FSHa.asm +* All instructions/registers/directives are UPPERCASE (strings are fine) +* High level view + * Only ld, calls, jmps (no routines/macros) +* Keep it readable + +### Command Files +* Name of file is UPPERCASE +* Inctructions are lowercase +* The layout of the file must be as follows: + ```asm + cmd: .db "", 0 + cmdo: .db $ + cmdu: .db "", 0 + cmdf: + + jp Fin + ``` +* Registers CAN be destroyed during execution of command's code diff --git a/FSHa.asm b/FSHa.asm index de19a71..fcbc9dc 100644 --- a/FSHa.asm +++ b/FSHa.asm @@ -1,5 +1,6 @@ -#include "includes/ti84pce.inc" -#include "includes/define.inc" +#include "includes/static/ti84pce.inc" +#include "includes/static/define.inc" +#include "includes/macros/macros.inc" .assume ADL=1 .org userMem-2 @@ -12,9 +13,14 @@ Setup: CALL _homeup CALL _ClrLCDFull + CALL drawstatusbar + CALL fshvarreset + CALL printmotd + Input: + ;; TODO: Update status bar sometimes LD A, $00 CALL commandfill @@ -25,6 +31,9 @@ Input: LD DE, FshCmdInptSize CALL inputstr + LD HL, FshCmd + CALL fshparsecommand + CALL _NewLine Decode: @@ -45,28 +54,24 @@ Err: Cleanup: SET graphdraw,(IY+graphflags) CALL _ClrLCDFull + CALL _ClrTxtShdw + CALL _homeup + call _DrawStatusBar Exit: RES donePrgm,(iy+doneFlags) RET -PS1: .DB "FSH> ",0 +#include "includes/Text.inc" FshFlags: .DB %00000000 ; 0: Debug Flag ; 1: Error Flag ; 2: Program Flag -#include "includes/Math.asm" -#include "includes/Byte.asm" -#include "includes/Char.asm" -#include "includes/Cursor.asm" -#include "includes/Print.asm" +#include "includes/lib/std/std.inc" +#include "includes/lib/fsh/fsh.inc" +#include "includes/man-db.asm" #include "includes/Command.asm" -#include "includes/Err.asm" -#include "includes/String.asm" -#include "includes/FshVar.asm" - -#include "includes/Input.asm" .end diff --git a/README.md b/README.md new file mode 100644 index 0000000..e0dc041 --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +# Fsh SHell +Fsh SHell is a compact command-line interface for TI-84 Plus CE calculators. + +## Installing +* Windows + 1. Download and install a linking program. is ti's prepritory software. + 2. Plug in calculator and launch ti connect ce + 3. Drag and drop `bin\FSHa.8xp` to calculator + 4. Done! +* Linux + 1. Install TiLP + 2. Plug in Calculator and launch TiLP + 3. Send over `bin/FSHa.8xp` + +## Running +For most people all that is required is to press 2nd+0 and select the Asm( option. Then, press Prgm and select FSHA. you should now have the following: `Asm(PrgmFSHA` Press Enter + +For TIOS 5.3+ + Press Prgm and select FSHA. you should now have the following: `PrgmFSHA` Press Enter + +## Building From Source +* Linux + 1. Clone, make, and install spasm-ng + 2. Run the `build` script + ``` + ./build + ``` + +## Contributing +Please see `CONTRIBUTING.md` + +## Bug Reports +If you find an Issue or Bug, please let me know by making an Issue on Gitlab: +Please include: +1. What went wrong. +2. What you were doing when the issue occurred. +3. Possible cause/fixes? (optional) + +Thank you! diff --git a/bin/FSHa.8xp b/bin/FSHa.8xp index 6557199..ad25169 100644 Binary files a/bin/FSHa.8xp and b/bin/FSHa.8xp differ diff --git a/build b/build index a6d8082..a02a46b 100755 --- a/build +++ b/build @@ -1,3 +1,3 @@ #!/bin/bash date -spasm -ET "FSHa.asm" "bin/FSHa.8xp" +spasm -ETA "FSHa.asm" "bin/FSHa.8xp" diff --git a/includes/Byte.asm b/includes/Byte.asm deleted file mode 100644 index d5f3347..0000000 --- a/includes/Byte.asm +++ /dev/null @@ -1,31 +0,0 @@ -;; bytecmp [Bytes] -;; Determines if two bytes are equal. -;; Inputs: -;; HL: Byte pointer -;; DE: Byte pointer -;; Outputs: -;; Z: Set if equal, reset if not equal -bytecmp: - push hl - push de - ld a, (de) - or a - cp (hl) - pop de - pop hl - ret - -;; bytecpy [Bytes] -;; Copies a byte. -;; Inputs: -;; HL: Byte pointer -;; DE: Destination -bytecpy: - push de - push hl - ex de, hl - ld a, (de) - ld (hl), a - pop hl - pop de - ret diff --git a/includes/Command.asm b/includes/Command.asm index 244c7b9..025cc86 100644 --- a/includes/Command.asm +++ b/includes/Command.asm @@ -7,43 +7,22 @@ ;; Sets (DE) with command op code commanddecode: call fshcmddecode + ;Extention Point + ret ;;commandroute ;;Routes all commamds. ;;Inputs: ;; HL: Op code mem loc -;;Outputs: -;; Jp to loc for cmd func -;; ult go to Fin commandroute: call fshcmdroute + ;Extention Point - ld hl, FshCmdErrCode - ld (hl), $01 + ld hl, ErrCmdNotFoundo + ld de, FshCmdErrCode + call bytecpy + call ErrSet jp Err -; commandfill -;; fills command mem with byte a -commandfill: - push hl - push bc - push de - ld b, 0 - ld de, 0 - ld c, a - ld hl, FshCmd -commandfillLoop: - ld (hl), c - inc hl - inc b - inc de - ld a, b - cp FshCmdSize - jr c, commandfillLoop - pop de - pop bc - pop hl - ret - -#include "includes/FshCmd.asm" +#include "includes/FshCommands/FshCommand.asm" diff --git a/includes/FshCmd.asm b/includes/FshCmd.asm deleted file mode 100644 index fc004d7..0000000 --- a/includes/FshCmd.asm +++ /dev/null @@ -1,114 +0,0 @@ -;;fshcmddecode -;;Decodes all commands. -;;Inputs: -;; HL: Cmd String mem loc -;; DE: Op code mem loc -;;Output: -;; Sets (DE) with command op code -fshcmddecode: - push hl - push de - ld de, fshcmdEXIT - call strcmp - ld hl, fshcmdEXITo - pop de - call z, bytecpy - pop hl - - push hl - push de - ld de, fshcmdSET - call strcmp - ld hl, fshcmdSETo - pop de - call z, bytecpy - pop hl - - push hl - push de - ld de, fshcmdCOPY - call strcmp - ld hl, fshcmdCOPYo - pop de - call z, bytecpy - pop hl - - push hl - push de - ld de, fshcmdMOVE - call strcmp - ld hl, fshcmdMOVEo - pop de - call z, bytecpy - pop hl - - push hl - push de - ld de, fshcmdCLS - call strcmp - ld hl, fshcmdCLSo - pop de - call z, bytecpy - pop hl - - push hl - push de - ld de, fshcmdVARS - call strcmp - ld hl, fshcmdVARSo - pop de - call z, bytecpy - pop hl - - push hl - push de - ld de, fshcmdSLEEP - call strcmp - ld hl, fshcmdSLEEPo - pop de - call z, bytecpy - pop hl - - ret - -;;fshcmdroute -;;Routes FshCommamds. -;;Inputs: -;; HL: Op code mem loc -;;Outputs: -;; Jp to loc for cmd func -fshcmdroute: - pop bc ;pop the ret loc from stack into bc - - ld de, fshcmdEXITo - call bytecmp - jp z, fshcmdEXITf - - ld de, fshcmdSETo - call bytecmp - jp z, fshcmdSETf - - ld de, fshcmdCOPYo - call bytecmp - jp z, fshcmdCOPYf - - ld de, fshcmdMOVEo - call bytecmp - jp z, fshcmdMOVEf - - ld de, fshcmdCLSo - call bytecmp - jp z, fshcmdCLSf - - ld de, fshcmdVARSo - call bytecmp - jp z, fshcmdVARSf - - ld de, fshcmdSLEEPo - call bytecmp - jp z, fshcmdSLEEPf - - push bc ;put ret location back on stack - ret - -#include "includes/FshCommands/FshCommands.inc" diff --git a/includes/FshCommands/CLS.asm b/includes/FshCommands/CLS.asm index ae870de..3005bbc 100644 --- a/includes/FshCommands/CLS.asm +++ b/includes/FshCommands/CLS.asm @@ -1,9 +1,10 @@ fshcmdCLS: .db "CLS", 0 fshcmdCLSo: .db $10 -fshcmdCLSu: .db "Clears the screen", 0 +fshcmdCLSm: .db "Clears the screen", 0 +fshcmdCLSu: .db "CLS", 0 fshcmdCLSf: - CALL _ClrLCDFull - XOR A - LD (CurRow), A - LD (CurCol), A - JP Fin + call _ClrLCDFull + xor a + ld (CurRow), a + ld (CurCol), a + jp Fin diff --git a/includes/FshCommands/COPY.asm b/includes/FshCommands/COPY.asm index 88162b3..d64fdf2 100644 --- a/includes/FshCommands/COPY.asm +++ b/includes/FshCommands/COPY.asm @@ -1,17 +1,17 @@ fshcmdCOPY: .db "COPY", 0 fshcmdCOPYo: .db $02 -fshcmdCOPYu: .db "Copys a value in FSH memory to another addess", 0 +fshcmdCOPYm: .db "Copys a value in FSH memory to another addess", 0 +fshcmdCOPYu: .db "COPY ", 0 fshcmdCOPYf: fshcmdCOPYfArg0: - ld hl, FshCmdArg0 - ld de, 0 - ld e, (hl) - inc hl - ld d, (hl) - ex de, hl - ld de, 0 - call cpHLDE + ld hl, FshCmdArgFlags + bit 1, (hl) jr nz, fshcmdCOPYfArg1 + bit 0, (hl) + jr z, fshcmdCOPYfArg0Get + ld hl, ErrUsageo + call ErrSet + call ErrCatch fshcmdCOPYfArg0Get: ld hl, fshcmdCOPYfDSource call printprompt @@ -23,25 +23,24 @@ fshcmdCOPYfArg0Get: ld (hl), a call _NewLine fshcmdCOPYfArg1: - ld hl, FshCmdArg1 - ld de, 0 - ld e, (hl) - inc hl - ld d, (hl) - ex de, hl - ld de, 0 - call cpHLDE + ld hl, FshCmdArgFlags + bit 3, (hl) jr nz, fshcmdCOPYfExe + bit 2, (hl) + jr z, fshcmdCOPYfArg1Get + ld hl, ErrUsageo + call ErrSet + call ErrCatch fshcmdCOPYfArg1Get: - ld hl, fshcmdCOPYfDDestination + ld hl, fshcmdCOPYfDSource call printprompt ld hl, fshcmdCOPYfInputBuffer ld de, 3 call inputnumstr call strtob - ex de, hl ld hl, FshCmdArg1 ld (hl), a + call _NewLine fshcmdCOPYfExe: ld hl, FshCmdArg0 ld de, 0 @@ -53,8 +52,8 @@ fshcmdCOPYfExe: ld e, (hl) pop hl call fshvarcpy - call _NewLine - jp ErrCatch + call ErrCatch + jp Fin fshcmdCOPYfInputBuffer: .db $00, $00, $00, $00 fshcmdCOPYfDSource: .db "Source= ", 0 diff --git a/includes/FshCommands/EXIT.asm b/includes/FshCommands/EXIT.asm index 9818e7c..6df801c 100644 --- a/includes/FshCommands/EXIT.asm +++ b/includes/FshCommands/EXIT.asm @@ -1,4 +1,5 @@ fshcmdEXIT: .db "EXIT", 0 fshcmdEXITo: .db $FF -fshcmdEXITu: .db "Exits Fsh", 0 +fshcmdEXITm: .db "Exits Fsh", 0 +fshcmdEXITu: .db "EXIT", 0 fshcmdEXITf: JP Cleanup diff --git a/includes/FshCommands/FshCommand.asm b/includes/FshCommands/FshCommand.asm new file mode 100644 index 0000000..a86d7f1 --- /dev/null +++ b/includes/FshCommands/FshCommand.asm @@ -0,0 +1,63 @@ +fshcmddecode: + decodecmdopt(fshcmdEXIT, fshcmdEXITo) + decodecmdopt(fshcmdSET, fshcmdSETo) + decodecmdopt(fshcmdCOPY, fshcmdCOPYo) + decodecmdopt(fshcmdMOVE, fshcmdMOVEo) + decodecmdopt(fshcmdCLS, fshcmdCLSo) + decodecmdopt(fshcmdVAR, fshcmdVARo) + decodecmdopt(fshcmdVARS, fshcmdVARSo) + decodecmdopt(fshcmdSLEEP, fshcmdSLEEPo) + decodecmdopt(fshcmdINFO, fshcmdINFOo) + decodecmdopt(fshcmdHELP, fshcmdHELPo) + decodecmdopt(fshcmdMAN, fshcmdMANo) + ret + +fshcmdroute: + pop bc ;pop the ret loc from stack into bc + routeoptjp(fshcmdEXITo, fshcmdEXITf) + routeoptjp(fshcmdSETo, fshcmdSETf) + routeoptjp(fshcmdCOPYo, fshcmdCOPYf) + routeoptjp(fshcmdMOVEo, fshcmdMOVEf) + routeoptjp(fshcmdCLSo, fshcmdCLSf) + routeoptjp(fshcmdVARo, fshcmdVARf) + routeoptjp(fshcmdVARSo, fshcmdVARSf) + routeoptjp(fshcmdSLEEPo, fshcmdSLEEPf) + routeoptjp(fshcmdINFOo, fshcmdINFOf) + routeoptjp(fshcmdHELPo, fshcmdHELPf) + routeoptjp(fshcmdMANo, fshcmdMANf) + push bc ;put ret location back on stack + ret + +fshcmdmanroute: + pop bc + routestrjp(fshcmdEXIT, fshCmdEXITm) + routestrjp(fshcmdSET, fshCmdSETm) + routestrjp(fshcmdCOPY, fshCmdCOPYm) + routestrjp(fshcmdMOVE, fshCmdMOVEm) + routestrjp(fshcmdCLS, fshCmdCLSm) + routestrjp(fshcmdVAR, fshCmdVARm) + routestrjp(fshcmdVARS, fshCmdVARSm) + routestrjp(fshcmdSLEEP, fshCmdSLEEPm) + routestrjp(fshcmdINFO, fshCmdINFOm) + routestrjp(fshcmdHELP, fshCmdHELPm) + routestrjp(fshcmdMAN, fshCmdMANm) + push bc + ret + +fshcmdmanrouteu: + pop bc + routeustrjp(fshcmdEXIT, fshCmdEXITu) + routeustrjp(fshcmdSET, fshCmdSETu) + routeustrjp(fshcmdCOPY, fshCmdCOPYu) + routeustrjp(fshcmdMOVE, fshCmdMOVEu) + routeustrjp(fshcmdCLS, fshCmdCLSu) + routeustrjp(fshcmdVAR, fshCmdVARu) + routeustrjp(fshcmdVARS, fshCmdVARSu) + routeustrjp(fshcmdSLEEP, fshCmdSLEEPu) + routeustrjp(fshcmdINFO, fshCmdINFOu) + routeustrjp(fshcmdHELP, fshCmdHELPu) + routeustrjp(fshcmdMAN, fshCmdMANu) + push bc + ret + +#include "includes/FshCommands/FshCommands.inc" diff --git a/includes/FshCommands/FshCommands.inc b/includes/FshCommands/FshCommands.inc index 8460529..c1ac7ae 100644 --- a/includes/FshCommands/FshCommands.inc +++ b/includes/FshCommands/FshCommands.inc @@ -3,5 +3,9 @@ #include "includes/FshCommands/COPY.asm" #include "includes/FshCommands/MOVE.asm" #include "includes/FshCommands/CLS.asm" +#include "includes/FshCommands/VAR.asm" #include "includes/FshCommands/VARS.asm" #include "includes/FshCommands/SLEEP.asm" +#include "includes/FshCommands/INFO.asm" +#include "includes/FshCommands/HELP.asm" +#include "includes/FshCommands/MAN.asm" diff --git a/includes/FshCommands/HELP.asm b/includes/FshCommands/HELP.asm new file mode 100644 index 0000000..49af614 --- /dev/null +++ b/includes/FshCommands/HELP.asm @@ -0,0 +1,64 @@ +fshcmdHELP: .db "HELP", 0 +fshcmdHELPo: .db $21 +fshcmdHELPm: .db "Displays all commands", 0 +fshcmdHELPu: .db "HELP", 0 +fshcmdHELPf: + ld hl, FshCmdArgFlags + bit 0, (hl) + jr z, fshcmdHELPfExe + ld hl, ErrUsageo + call ErrSet + call ErrCatch +fshcmdHELPfExe: + ld hl, fshcmdHELPfLine1 + call _PutS + call _NewLine + +#macro fshcmdHELPmRow1(cmdXs) + xor a + ld (curCol), a + ld hl, cmdXs + call _PutS + call _NewLine +#endmacro +#macro fshcmdHELPmRow2(cmdXs, cmdYs) + xor a + ld (curCol), a + ld hl, cmdXs + call _PutS + ld a, 9 + ld (curcol), a + ld hl, cmdYs + call _PutS + call _NewLine +#endmacro +#macro fshcmdHELPmRow3(cmdXs, cmdYs, cmdZs) + xor a + ld (curCol), a + ld hl, cmdXs + call _PutS + ld a, 9 + ld (curcol), a + ld hl, cmdYs + call _PutS + ld a, 19 + ld (curcol), a + ld hl, cmdZs + call _PutS + call _NewLine +#endmacro + + fshcmdHELPmRow3(fshcmdEXIT, fshcmdSET, fshcmdCOPY) + fshcmdHELPmRow3(fshcmdMOVE, fshcmdCLS, fshcmdVAR) + fshcmdHELPmRow3(fshcmdVARS, fshcmdSLEEP, fshcmdINFO) + fshcmdHELPmRow2(fshcmdHELP, fshcmdMAN) + ; Extention Point + + call _NewLine + ld hl, fshcmdHELPfLine2 + call _PutS + call _NewLine + jp Fin + +fshcmdHELPfLine1: .db "Available Commands:", 0 +fshcmdHELPfLine2: .db "Type 'MAN' and command for more info", 0 diff --git a/includes/FshCommands/INFO.asm b/includes/FshCommands/INFO.asm new file mode 100644 index 0000000..24ec38d --- /dev/null +++ b/includes/FshCommands/INFO.asm @@ -0,0 +1,42 @@ +fshcmdINFO: .db "INFO", 0 +fshcmdINFOo: .db $20 +fshcmdINFOm: .db "Displays Syetem Information and Stats", 0 +fshcmdINFOu: .db "INFO", 0 +fshcmdINFOf: + ld hl, FshCmdArgFlags + bit 0, (hl) + jr z, fshcmdINFOfExe + ld hl, ErrUsageo + call ErrSet + call ErrCatch +fshcmdINFOfExe: + call _ClrLCDFull + xor a + ld (CurRow), a + ld (CurCol), a + + call printfshnamelong + call _NewLine + + ld hl, FshBy + call _PutS + call _NewLine + + ld hl, FshSite + call _PutS + call _NewLine + + call _NewLine + ld hl, fshcmdINFOfSPS1 + call _PutS + ld a, $27 + call _PutC + ld hl, PS1 + call _PutS + ld a, $27 + call _PutC + call _NewLine + + jp Fin + +fshcmdINFOfSPS1: .db "PS1", $CE, $CE, $CE, ":", 0 diff --git a/includes/FshCommands/MAN.asm b/includes/FshCommands/MAN.asm new file mode 100644 index 0000000..78b6e8f --- /dev/null +++ b/includes/FshCommands/MAN.asm @@ -0,0 +1,62 @@ +fshcmdMAN: .db "MAN", 0 +fshcmdMANo: .db $22 +fshcmdMANm: .db "Displays MAN text for command", 0 +fshcmdMANu: .db "MAN ", 0 +fshcmdMANf: +fshcmdMANfCheckArgs: + ld hl, FshCmdArgFlags + bit 0, (hl) + jr z, fshcmdMANfArg0Get + bit 1, (hl) + jr z, fshcmdMANfExe + ld hl, ErrUsageo + call ErrSet + call ErrCatch +fshcmdMANfArg0Get: + ld hl, fshcmdMANfPrompt + call printprompt + + ld hl, FshCmdArg0 + ld de, FshCmdCmdSize + call inputstr + call _NewLine + +fshcmdMANfExe: + ld hl, FshCmdArg0 + ld de, FshCmd + call strcpy + + ld hl, fshcmdMANfPrefix + call _PutS + + ld hl, FshCmd + call _PutS + call _NewLine + call _NewLine + + ld hl, FshCmd + call manroute + ld de, $00 + call cpHLDE + jp z, Err + + call _PutS + call _NewLine + call _NewLine + + ld hl, fshcmdMANfUsage + call _PutS + + ld hl, FshCmd + call manrouteu + ld de, $00 + call cpHLDE + jp z, Err + call _PutS + call _NewLine + + jp Fin + +fshcmdMANfPrefix: .db "MAN-DB", $DF, ' ', 0 +fshcmdMANfUsage: .db "Usage: ",0 +fshcmdMANfPrompt: .db "Command= ", 0 diff --git a/includes/FshCommands/MOVE.asm b/includes/FshCommands/MOVE.asm index 30c5fca..f6024f1 100644 --- a/includes/FshCommands/MOVE.asm +++ b/includes/FshCommands/MOVE.asm @@ -1,17 +1,17 @@ fshcmdMOVE: .db "MOVE", 0 fshcmdMOVEo: .db $03 -fshcmdMOVEu: .db "Move a value in FSH memory to another addess", 0 +fshcmdMOVEm: .db "Move a value in FSH memory to another addess", 0 +fshcmdMOVEu: .db "MOVE ", 0 fshcmdMOVEf: fshcmdMOVEfArg0: - ld hl, FshCmdArg0 - ld de, 0 - ld e, (hl) - inc hl - ld d, (hl) - ex de, hl - ld de, 0 - call cpHLDE + ld hl, FshCmdArgFlags + bit 1, (hl) jr nz, fshcmdMOVEfArg1 + bit 0, (hl) + jr z, fshcmdMOVEfArg0Get + ld hl, ErrUsageo + call ErrSet + call ErrCatch fshcmdMOVEfArg0Get: ld hl, fshcmdMOVEfDSource call printprompt @@ -23,15 +23,14 @@ fshcmdMOVEfArg0Get: ld (hl), a call _NewLine fshcmdMOVEfArg1: - ld hl, FshCmdArg1 - ld de, 0 - ld e, (hl) - inc hl - ld d, (hl) - ex de, hl - ld de, 0 - call cpHLDE + ld hl, FshCmdArgFlags + bit 3, (hl) jr nz, fshcmdMOVEfExe + bit 2, (hl) + jr z, fshcmdMOVEfArg1Get + ld hl, ErrUsageo + call ErrSet + call ErrCatch fshcmdMOVEfArg1Get: ld hl, fshcmdMOVEfDDestination call printprompt @@ -39,9 +38,9 @@ fshcmdMOVEfArg1Get: ld de, 3 call inputnumstr call strtob - ex de, hl ld hl, FshCmdArg1 ld (hl), a + call _NewLine fshcmdMOVEfExe: ld hl, FshCmdArg0 ld de, 0 @@ -56,8 +55,8 @@ fshcmdMOVEfExe: ex de, hl ld hl, 0 call fshvarset - call _NewLine - jp ErrCatch + call ErrCatch + jp Fin fshcmdMOVEfInputBuffer: .db $00, $00, $00, $00 fshcmdMOVEfDSource: .db "Source= ", 0 diff --git a/includes/FshCommands/SET.asm b/includes/FshCommands/SET.asm index 893fb68..535475f 100644 --- a/includes/FshCommands/SET.asm +++ b/includes/FshCommands/SET.asm @@ -1,37 +1,39 @@ fshcmdSET: .db "SET", 0 fshcmdSETo: .db $01 -fshcmdSETu: .db "Sets a value in FSH memory", 0 +fshcmdSETm: .db "Sets a value in FSH memory", 0 +fshcmdSETu: .db "SET ", 0 fshcmdSETf: fshcmdSETfArg0: - ld hl, FshCmdArg0 - ld de, 0 - ld e, (hl) - inc hl - ld d, (hl) - ex de, hl - ld de, 0 - call cpHLDE + ld hl, FshCmdArgFlags + bit 1, (hl) jr nz, fshcmdSETfArg1 + bit 0, (hl) + jr z, fshcmdSETfArg0Get + ld hl, ErrUsageo + call ErrSet + call ErrCatch fshcmdSETfArg0Get: ld hl, fshcmdSETfDIndex call printprompt ld hl, fshcmdSETfInputBuffer ld de, 3 call inputnumstr - call strtob - ld hl, FshCmdArg0 - ld (hl), a + call strtow + ld de, FshCmdArg0 + ex de, hl + ld (hl), e + inc hl + ld (hl), d call _NewLine fshcmdSETfArg1: - ld hl, FshCmdArg1 - ld de, 0 - ld e, (hl) - inc hl - ld d, (hl) - ex de, hl - ld de, 0 - call cpHLDE + ld hl, FshCmdArgFlags + bit 3, (hl) jr nz, fshcmdSETfExe + bit 2, (hl) + jr z, fshcmdSETfArg1Get + ld hl, ErrUsageo + call ErrSet + call ErrCatch fshcmdSETfArg1Get: ld hl, fshcmdSETfDValue call printprompt @@ -41,23 +43,26 @@ fshcmdSETfArg1Get: call strtow ex de, hl ld hl, FshCmdArg1 - ld (hl), d - inc hl ld (hl), e + inc hl + ld (hl), d + call _NewLine fshcmdSETfExe: ld hl, FshCmdArg0 ld de, 0 ld e, (hl) + inc hl + ld d, (hl) push de ld hl, FshCmdArg1 - ld d, (hl) - inc hl ld e, (hl) + inc hl + ld d, (hl) ex de, hl pop de call fshvarset - call _NewLine - jp ErrCatch + call ErrCatch + jp Fin fshcmdSETfInputBuffer: .db $00, $00, $00, $00, $00, $00 fshcmdSETfDIndex: .db "Destination= ", 0 diff --git a/includes/FshCommands/SLEEP.asm b/includes/FshCommands/SLEEP.asm index 074d6eb..e414cb0 100644 --- a/includes/FshCommands/SLEEP.asm +++ b/includes/FshCommands/SLEEP.asm @@ -1,6 +1,7 @@ fshcmdSLEEP: .db "SLEEP", 0 fshcmdSLEEPo: .db $16 -fshcmdSLEEPu: .db "Puts the calculator into sleep mode (APD)", 0 +fshcmdSLEEPm: .db "Puts the calculator into sleep mode (APD)", 0 +fshcmdSLEEPu: .db "SLEEP", 0 fshcmdSLEEPf: di call _EnableAPD diff --git a/includes/FshCommands/VAR.asm b/includes/FshCommands/VAR.asm new file mode 100644 index 0000000..e03e87a --- /dev/null +++ b/includes/FshCommands/VAR.asm @@ -0,0 +1,41 @@ +fshcmdVAR: .db "VAR", 0 +fshcmdVARo: .db $11 +fshcmdVARm: .db "Displays a value from FSH memory", 0 +fshcmdVARu: .db "VAR ", 0 +fshcmdVARf: +fshcmdVARfArg0: + ld hl, FshCmdArgFlags + bit 1, (hl) + jr nz, fshcmdVARfExe + bit 0, (hl) + jr z, fshcmdVARfArg0Get + ld hl, ErrUsageo + call ErrSet + call ErrCatch +fshcmdVARfArg0Get: + ld hl, fshcmdVARfDIndex + call printprompt + ld hl, fshcmdVARfInputBuffer + ld de, 3 + call inputnumstr + call strtow + ld de, FshCmdArg0 + ex de, hl + ld (hl), e + inc hl + ld (hl), d + call _NewLine +fshcmdVARfExe: + ld hl, FshCmdArg0 + ld de, 0 + ld e, (hl) + inc hl + ld d, (hl) + call fshvarget + call ErrCatch + call _DispHL_s + call _NewLine + jp Fin + +fshcmdVARfInputBuffer: .db $00, $00, $00, $00 +fshcmdVARfDIndex: .db "Index= ", 0 diff --git a/includes/FshCommands/VARS.asm b/includes/FshCommands/VARS.asm index 2792fe0..3ffa1a1 100644 --- a/includes/FshCommands/VARS.asm +++ b/includes/FshCommands/VARS.asm @@ -1,7 +1,15 @@ fshcmdVARS: .db "VARS", 0 fshcmdVARSo: .db $12 -fshcmdVARSu: .db "Displays all Fsh Vars", 0 +fshcmdVARSm: .db "Displays all Fsh Vars", 0 +fshcmdVARSu: .db "VARS", 0 fshcmdVARSf: + ld hl, FshCmdArgFlags + bit 0, (hl) + jr z, fshcmdVARSfExe + ld hl, ErrUsageo + call ErrSet + call ErrCatch +fshcmdVARSfExe: ld b, 0 ld c, 0 ld de, 0 diff --git a/includes/Math.asm b/includes/Math.asm deleted file mode 100644 index a43a0e0..0000000 --- a/includes/Math.asm +++ /dev/null @@ -1,107 +0,0 @@ -;; cpHLDE [Maths] -;; Compares HL to DE. -;; Output: -;; Same as z80 CP instruction. -cpHLDE: - or a - sbc hl, de - add hl,de - ret -;; cpHLBC [Maths] -;; Compares HL to BC. -;; Output: -;; Same as z80 CP instruction. -cpHLBC: - or a - sbc hl, bc - add hl,bc - ret -;; cpBCDE [Maths] -;; Compares DE to BC. -;; Output: -;; Same as z80 CP instruction. -cpBCDE: - push hl - ld h, b - ld l, c - or a - sbc hl, de - pop hl - ret - -;; mulAbyB -;; Multiplys AxB -;; Inputs: -;; A: Multiplier -;; B: Multiplicand -;; Outputs: -;; A: Product of A and B. -mulAbyB: - push bc - ld c, a -mulAbyBLoop: - add a, c - djnz mulAbyBLoop - sub c - pop bc - ret - -;; mulAbyHL -;; Multiplys AxHL -;; Inputs: -;; A: Multiplier -;; HL: Multiplicand -;; Outputs: -;; HL: Product of A and HL. -mulAbyHL: - push bc - push de - ld de, 0 - ex de, hl - cp 0 - jr z, mulAbyHLEnd - ld b, a -mulAbyHLLoop: - add hl, de - djnz mulAbyHLLoop -mulAbyHLEnd: - pop de - pop bc - ret - - -;; mul32By8 [Maths] -;; Performs an unsigned multiplication of DEHL and A. -;; Outputs: -;; DEHL: product of DEHL and A -mul32By8: - push bc \ push ix - ld ixl, 8 - push de - push hl - ld hl, 0 - ld d, h - ld e, l -mul32by8loop: - add hl, hl - rl e - rl d - rla - jr nc, mul32by8noAdd - pop bc - add hl, bc - ex (sp), hl - push hl - adc hl, de - pop de - ex de, hl - ex (sp), hl - push bc -mul32by8noAdd: - dec ixl - jr nz, mul32by8loop - pop bc - pop bc - pop ix \ pop bc - ret - diff --git a/includes/Text.inc b/includes/Text.inc new file mode 100644 index 0000000..49b6678 --- /dev/null +++ b/includes/Text.inc @@ -0,0 +1,13 @@ +;STRINGS ------------------------- +FshName: .db "Fsh SHell", 0 +FshBy: .db "By pixiys", 0 +FshSite: .db "stephenltoth.com/fsh-shell", 0 +PS1: .db "FSH> ", 0 +FshVVars: .db "64w", 0 +FshVMajor: .db "0", 0 +FshVMinor: .db "1", 0 +FshVPatch: .db "0", 0 +FshVBuild: .db "205", 0 +FshVSeparator: .db ".", 0 +FshMotd2nd: .db "Press 2nd for numbers", 0 +FshMotdHelp: .db "Type 'HELP' for help", 0 diff --git a/includes/define.inc b/includes/define.inc deleted file mode 100644 index 64ce319..0000000 --- a/includes/define.inc +++ /dev/null @@ -1,26 +0,0 @@ -.nolist - -; Included for Assembler Compatibility -;------------------------------------ -#define equ .equ -#define EQU .equ -#define end .end -#define END .end - -#define FshVarsSize 128 ;256 bytes | 64 words -#define FshCmdSize 24 ;17 bytes | 8 chars | 1 null, 4 words (args) | 1 byte (err code) | 6 unused -#define FshCmdInptSize 8 ;8 bytes | 8 chars -#define FshPrgmSize 1024 ;1024 bytes | max size - -RamVars equ 0D0EA1Fh ;saveSScreen | 21945 bytes -FshVars equ RamVars -FshCmd equ FshVars + FshVarsSize -FshPrgm equ FshCmd + FshCmdSize - -FshCmdNull equ FshCmd + FshCmdInptSize -FshCmdOP equ FshCmdNull + 1 -FshCmdArg0 equ FshCmdOP + 1 -FshCmdArg1 equ FshCmdOP + 3 -FshCmdArg2 equ FshCmdOP + 5 -FshCmdArg3 equ FshCmdOP + 7 -FshCmdErrCode equ FshCmdArg3 + 1 diff --git a/includes/lib/fsh/Command.asm b/includes/lib/fsh/Command.asm new file mode 100644 index 0000000..999b17b --- /dev/null +++ b/includes/lib/fsh/Command.asm @@ -0,0 +1,24 @@ +;;commandfill +;;Fills command mem with byte a +;;Inputs: +;; A: byte +commandfill: + push hl + push bc + push de + ld b, 0 + ld de, 0 + ld c, a + ld hl, FshCmd +commandfillLoop: + ld (hl), c + inc hl + inc b + inc de + ld a, b + cp FshCmdSize + jr c, commandfillLoop + pop de + pop bc + pop hl + ret diff --git a/includes/lib/fsh/Draw.asm b/includes/lib/fsh/Draw.asm new file mode 100644 index 0000000..d28ef16 --- /dev/null +++ b/includes/lib/fsh/Draw.asm @@ -0,0 +1,30 @@ +;;drawstatusbar +;;draws the FSH status bar +drawstatusbar: + ;rgbto565(84, 84, 84) + ld hl, $52AA + ld a, 0 + ld bc, 30 + call drawbar + ;rgbto565(0, 159, 209) + ld hl, $04FA + ;ld hl, %1111100000000000 + drawrectfilledM(0, 0, 2, 30) + call _DrawBatteryIndicator + ;draw name + set fracDrawLFont, (iy + fontFlags) + ld a, 6 + ld (penRow), a + ld a, 7 + ld (penCol), a + ld hl, $52AA + ld (drawBGcolor), hl + ld hl, $ffff + ld (drawFGcolor), hl + ld hl, FshName + call _VPutS + ld hl, $ffff + ld (drawBGcolor), hl + ld hl, $0000 + ld (drawFGcolor), hl + ret diff --git a/includes/Err.asm b/includes/lib/fsh/Err.asm similarity index 58% rename from includes/Err.asm rename to includes/lib/fsh/Err.asm index d2bdb26..765b2fb 100644 --- a/includes/Err.asm +++ b/includes/lib/fsh/Err.asm @@ -1,34 +1,47 @@ ;;ErrCatch ;;Checks err bit and jp to err route ErrCatch: - ld hl, FshFlags - bit 1, (hl) - jp nz, ErrRoute - jp Fin + pop bc + push hl + ld hl, FshFlags + bit 1, (hl) + pop hl + jp nz, ErrRoute + push bc + ret ;;ErrRoute ;;Routes err codes. ErrRoute: + ld hl, FshFlags res 1, (hl) ld hl, FshCmdErrCode - - ld de, ErrCmdNotFoundo - call bytecmp + + ld de, ErrCmdNotFoundo + call bytecmp jp z, ErrCmdNotFoundf ld de, ErrOutOfBoundso call bytecmp jp z, ErrOutOfBoundsf + ld de, ErrArgso + call bytecmp + jp z, ErrArgsf + + ld de, ErrUsageo + call bytecmp + jp z, ErrUsagef + jp ErrDefault ;;ErrSet ;;Sets all things relating to Err codes -;; Inputs: -;; HL: Err____o +;;Inputs: +;; HL: Err_____o ErrSet: push hl ld a, (hl) @@ -39,10 +52,14 @@ ErrSet: pop hl ret -;;ERR FUNCS +;;ERR FUNCS------------------- ErrCmdNotFoundo: .db $01 ErrCmdNotFoundf: + ld hl, FshCmd + ld a, (hl) + cp $00 + jp z, Fin ld hl, ErrCmdNotFoundt call _PutS ld hl, FshCmd @@ -59,6 +76,25 @@ ErrOutOfBoundsf: jp Fin ErrOutOfBoundst: .db "error: Out Of Bounds", 0 +ErrArgso: .db $03 +ErrArgsf: + ld hl, ErrArgst + call _PutS + call _NewLine + jp Fin +ErrArgst: .db "error: Invalid Arguments", 0 + +ErrUsageo: .db $04 +ErrUsagef: + ld hl, ErrUsaget + call _PutS + ld hl, FshCmd + call manrouteu + call _PutS + call _NewLine + jp Fin +ErrUsaget: .db "error: Usage: ", 0 + ErrDefault: ld hl, ErrDefaultt call _PutS diff --git a/includes/FshVar.asm b/includes/lib/fsh/FshVar.asm similarity index 78% rename from includes/FshVar.asm rename to includes/lib/fsh/FshVar.asm index 42669d5..ec8dc3e 100644 --- a/includes/FshVar.asm +++ b/includes/lib/fsh/FshVar.asm @@ -1,15 +1,14 @@ -;;; fshvarset [Bytes] -;; Sets a Word in FshVars. -;; Inputs: -;; HL: 16b -;; DE: Destination Word Relitive to FshVars +;;fshvarset +;;Sets a Word in FshVars. +;;Inputs: +;; HL: 16b +;; DE: Destination Word Relitive to FshVars fshvarset: push bc ld bc, FshVarsSize / 2 - 1 call cpBCDE pop bc jr c, fshvarsetOOBException - push bc push de push hl @@ -24,7 +23,6 @@ fshvarset: pop de pop bc ret - fshvarsetOOBException: push hl ld hl, ErrOutOfBoundso @@ -32,19 +30,18 @@ fshvarsetOOBException: pop hl ret -;;; fshvarget [Words] -;; Gets a Word in FshVars. -;; Inputs: -;; DE: Destination Word Relitive to FshVars -;; Outputs: -;; HL: Word in (DE) +;;fshvarget +;;Gets a Word in FshVars. +;;Inputs: +;; DE: Destination Word Relitive to FshVars +;;Outputs: +;; HL: Word in (DE) fshvarget: push bc ld bc, FshVarsSize / 2 - 1 call cpBCDE pop bc jr c, fshvargetOOBException - push bc push de ld hl, 0 @@ -59,19 +56,17 @@ fshvarget: pop de pop bc ret - fshvargetOOBException: push hl ld hl, ErrOutOfBoundso call ErrSet pop hl ret - -; fshvarcpy [Bytes] -;; Copies a word. -;; Inputs: -;; HL: Byte pointer -;; DE: Destination +;;fshvarcpy +;;Copies a word. +;;Inputs: +;; HL: Byte pointer +;; DE: Destination fshvarcpy: push bc ld bc, FshVarsSize / 2 - 1 @@ -83,7 +78,6 @@ fshvarcpy: call cpHLBC pop bc jr nc, fshvarcpyOOBException - push de push hl ld bc, FshVarsSize / 2 @@ -112,8 +106,8 @@ fshvarcpyOOBException: pop hl ret -; fshvarreset -;; fills fshvars with word +;;fshvarreset +;;Fills fshvars with $00 fshvarreset: push hl push bc diff --git a/includes/lib/fsh/Parse.asm b/includes/lib/fsh/Parse.asm new file mode 100644 index 0000000..951f374 --- /dev/null +++ b/includes/lib/fsh/Parse.asm @@ -0,0 +1,187 @@ +;;fshparsecommand +;;Inputs: +;; HL: FshCmd +;;b = buf row +;;c = char in row +;de = scratch +fshparsecommand: + push hl + push bc + push de + push hl + push hl + ld hl, fshparsecommandCmd + ld b, 45 + ld a, $00 + call memset + pop hl + + ld bc, 0 + ld de, 0 +fshparsecommandLoop: + ld a, (hl) +fshparsecommandCheckSpace: + cp ' ' ;end of word + jr nz, fshparsecommandCheckEnd + ld a, $00 + call fshparsecommandCopyChar + ld c, 0 + inc b + inc hl + jr fshparsecommandLoop + +fshparsecommandCheckEnd: + cp $00 ;end of string + jr z, fshparsecommandCheckArgStatus + +fshparsecommandLoopEnd: + call fshparsecommandCopyChar + inc hl + inc c + + ld a, c + cp FshCmdCmdSize + jr nz, fshparsecommandLoop + ;inc hl + ld c, 0 + inc b + ld a, b + cp 5 + jr nz, fshparsecommandLoop +; ld bc, 0 + +fshparsecommandCheckArgStatus: + xor a + ld hl, FshCmdArgFlags + ld (hl), a +fshparsecommandCheckArg0: + ld hl, fshparsecommandArg0 + ld a, (hl) + cp $00 + jr z, fshparsecommandCheckArg1 + ld hl, FshCmdArgFlags + set 0, (hl) + ld a, (hl) + ld hl, fshparsecommandArg0 + ld a, (hl) + sub '0' + cp '9' - '0' + 1 + jr nc, fshparsecommandCheckArg1 + call strtow + ld de, fshparsecommandArg0 + ex de, hl + ld (hl), e + inc hl + ld (hl), d + inc (hl) + ld (hl), $00 + ld hl, FshCmdArgFlags + set 1, (hl) +fshparsecommandCheckArg1: + ld hl, fshparsecommandArg1 + ld a, (hl) + cp $00 + jr z, fshparsecommandCheckArg2 + ld hl, FshCmdArgFlags + set 2, (hl) + ld hl, fshparsecommandArg1 + ld a, (hl) + sub '0' + cp '9' - '0' + 1 + jr nc, fshparsecommandCheckArg2 + call strtow + ld de, fshparsecommandArg1 + ex de, hl + ld (hl), e + inc hl + ld (hl), d + inc hl + ld (hl), $00 + ld hl, FshCmdArgFlags + set 3, (hl) +fshparsecommandCheckArg2: + ld hl, fshparsecommandArg2 + ld a, (hl) + cp $00 + jr z, fshparsecommandCheckArg3 + ld hl, FshCmdArgFlags + set 4, (hl) + ld hl, fshparsecommandArg2 + ld a, (hl) + sub '0' + cp '9' - '0' + 1 + jr nc, fshparsecommandCheckArg3 + call strtow + ld de, fshparsecommandArg2 + ex de, hl + ld (hl), e + inc hl + ld (hl), d + inc hl + ld (hl), $00 + ld hl, FshCmdArgFlags + set 5, (hl) +fshparsecommandCheckArg3: + ld hl, fshparsecommandArg3 + ld a, (hl) + cp $00 + jr z, fshparsecommandCopyBack + ld hl, FshCmdArgFlags + set 6, (hl) + ld hl, fshparsecommandArg3 + ld a, (hl) + sub '0' + cp '9' - '0' + 1 + jr nc, fshparsecommandCopyBack + call strtow + ld de, fshparsecommandArg3 + ex de, hl + ld (hl), e + inc hl + ld (hl), d + inc hl + ld (hl), $00 + ld hl, FshCmdArgFlags + set 7, (hl) +fshparsecommandCopyBack: + pop hl + push bc + ex de, hl + ld hl, fshparsecommandCmd + ld bc, 45 + ldir + pop bc + + pop de + pop bc + pop hl + ret + +fshparsecommandCmd: .db $00, $00, $00, $00, $00, $00, $00, $00, $00 +fshparsecommandArg0: .db $00, $00, $00, $00, $00, $00, $00, $00, $00 +fshparsecommandArg1: .db $00, $00, $00, $00, $00, $00, $00, $00, $00 +fshparsecommandArg2: .db $00, $00, $00, $00, $00, $00, $00, $00, $00 +fshparsecommandArg3: .db $00, $00, $00, $00, $00, $00, $00, $00, $00 +fshparsecommandOverB: .db $00, $00, $00, $00, $00, $00 + +fshparsecommandCopyChar: + ;Copy + push hl + push bc + ld hl, 0 + ld h, b + ld l, 9 + ld b, c + ld de, fshparsecommandCmd + call array2d + pop bc + pop hl + ;push hl + ; ld hl, fshparsecommandCmd+45+1 + ; call cpHLDE + ;pop hl + ;pop de + ;ret c + ;push de + ld (de), a ;ld buffer + ret diff --git a/includes/lib/fsh/Print.asm b/includes/lib/fsh/Print.asm new file mode 100644 index 0000000..a74034c --- /dev/null +++ b/includes/lib/fsh/Print.asm @@ -0,0 +1,44 @@ +;;printfshnamelong +;;prints Name + Varsv + Version to screen +printfshnamelong: + push hl + ld hl, FshName + call _PutS + ld a, ' ' + call _PutC + ld hl, FshVVars + call _PutS + ld a, ' ' + call _PutC + ld a, 'v' + call _PutC + ld hl, FshVMajor + call _PutS + ld hl, FshVSeparator + call _PutS + ld hl, FshVMinor + call _PutS + ld hl, FshVSeparator + call _PutS + ld hl, FshVPatch + call _PutS + ld a, ' ' + call _PutC + ld hl, FshVBuild + call _PutS + pop hl + ret + +;;printmotd +;;prints the motd to screen +printmotd: + call printfshnamelong + call _NewLine + call _NewLine + ld hl, FshMotd2nd + call _PutS + call _NewLine + ld hl, FshMotdHelp + call _PutS + call _NewLine + ret diff --git a/includes/lib/fsh/fsh.inc b/includes/lib/fsh/fsh.inc new file mode 100644 index 0000000..10acee1 --- /dev/null +++ b/includes/lib/fsh/fsh.inc @@ -0,0 +1,6 @@ +#include "includes/lib/fsh/Command.asm" +#include "includes/lib/fsh/Parse.asm" +#include "includes/lib/fsh/FshVar.asm" +#include "includes/lib/fsh/Err.asm" +#include "includes/lib/fsh/Print.asm" +#include "includes/lib/fsh/Draw.asm" diff --git a/includes/lib/std/Array.asm b/includes/lib/std/Array.asm new file mode 100644 index 0000000..c1aa52a --- /dev/null +++ b/includes/lib/std/Array.asm @@ -0,0 +1,19 @@ +;;array2d +;;gets the address of 2d array +;;Inputs: +;; H: y +;; L: x width +;; B: x +;; DE: Array start +;;Outputs: +;; DE: Array loc address +array2d: + push hl + mlt hl + add hl, de + ld de, 0 + ld e, b + add hl, de + ex de, hl + pop hl + ret diff --git a/includes/lib/std/Byte.asm b/includes/lib/std/Byte.asm new file mode 100644 index 0000000..2b9b790 --- /dev/null +++ b/includes/lib/std/Byte.asm @@ -0,0 +1,31 @@ +;;bytecmp +;;Determines if two bytes are equal. +;;Inputs: +;; HL: Byte pointer +;; DE: Byte pointer +;;Outputs: +;; Z: Set if equal, reset if not equal +bytecmp: + push hl + push de + ld a, (de) + or a + cp (hl) + pop de + pop hl + ret + +;;bytecpy +;; Copies a byte. +;;Inputs: +;; HL: Byte pointer +;; DE: Destination +bytecpy: + push de + push hl + ex de, hl + ld a, (de) + ld (hl), a + pop hl + pop de + ret diff --git a/includes/Char.asm b/includes/lib/std/Char.asm similarity index 62% rename from includes/Char.asm rename to includes/lib/std/Char.asm index 1e0a350..910e202 100644 --- a/includes/Char.asm +++ b/includes/lib/std/Char.asm @@ -1,12 +1,12 @@ #include "includes/tables/CSC.asm" -; chartoascii -;; Converts a char to "ascii" +;;chartoascii +;;Converts a char to "ascii" ;;Inputs: ;; A: char code (csc) ;;Outputs: ;; A: ascii char chartoascii: - push hl ; Convert scan code into character + push hl ld hl, 0 ld h, 0 ld l, a @@ -15,14 +15,15 @@ chartoascii: ld a, (hl) pop hl ret -; charnumtoascii -;; Converts a char to "ascii" + +;;Charnumtoascii +;;Converts a char to "ascii" ;;Inputs: ;; A: char code (csc) ;;Outputs: ;; A: ascii char charnumtoascii: - push hl ; Convert scan code into character + push hl ld hl, 0 ld h, 0 ld l, a @@ -31,14 +32,15 @@ charnumtoascii: ld a, (hl) pop hl ret -; charnumsymtoascii -;; Converts a char to "ascii" + +;;charnumsymtoascii +;;Converts a char to "ascii" ;;Inputs: ;; A: char code (csc) ;;Outputs: ;; A: ascii char charnumsymtoascii: - push hl ; Convert scan code into character + push hl ld hl, 0 ld h, 0 ld l, a diff --git a/includes/Cursor.asm b/includes/lib/std/Cursor.asm similarity index 95% rename from includes/Cursor.asm rename to includes/lib/std/Cursor.asm index 6915b98..ed26b30 100644 --- a/includes/Cursor.asm +++ b/includes/lib/std/Cursor.asm @@ -1,4 +1,3 @@ -;TODO ;;cursorcharunderreset ;;Sets curUnder to 0 cursorcurunderreset: diff --git a/includes/lib/std/Draw.asm b/includes/lib/std/Draw.asm new file mode 100644 index 0000000..6354655 --- /dev/null +++ b/includes/lib/std/Draw.asm @@ -0,0 +1,125 @@ +;;drawpixel +;;Sets a pixel to specified color (565) +;;Inputs: +;; HL: color +;; DE: vRam location +drawpixel: + push hl + push de + ex de, hl + ld (hl), e + inc hl + ld (hl), d + pop de + pop hl + ret + +;;drawpixelxy +;;Sets a pixel to specified color +;;Inputs: +;; HL: color +;; DE: x +;; A: y +drawpixelxy + push de + push hl + ex de, hl + add hl, hl + push hl + ld hl, 640 + call mulAbyHL + ex de, hl + pop hl + add hl, de + ld de, vRam + add hl, de + ex de, hl + pop hl + call drawpixel + pop de + ret + +;;drawrow +;;Draws a row on lcd +;;Inputs: +;; A: y +;; HL: color +drawrow: + push hl + push bc + push hl + ld hl, lcdHeight * 2 + call mulAbyHL + ld de, vRam + add hl, de + ex de, hl + pop hl + ld bc, lcdWidth +drawrowLoop: + call drawpixel + inc de + inc de + dec bc + push hl + ld hl, 0 + call cpHLBC + pop hl + jr nz, drawrowLoop + pop bc + pop hl + ret + +;;drawbar +;;Loops drawing row +;;Inputs: +;; A: y +;; [B]C: height +;; HL: color +drawbar: + push bc +drawbarLoop: + call drawrow + dec bc + inc a + push hl + ld hl, 0 + call cpHLBC + pop hl + jr nz, drawbarLoop + pop bc + ret + +;;drawrectfilled +;;Draws a rectangle from coordinates (Slow) +;;Inputs: +;; DE: x +;; C: y +;; HL: width +;; A: height +;; IXH+IXL: color +drawrectfilled: + add hl, de + add a, c + ld b, a +drawrectfilledLoopY: + push de +drawrectfilledLoopX: + push hl + push bc + ex de, hl + ld d, ixh + ld e, ixl + ex de, hl + ld a, c + call drawpixelxy + pop bc + pop hl + inc de + call cpHLDE + jr nz, drawrectfilledLoopX + pop de + inc c + ld a, b + cp c + jr nz, drawrectfilledLoopY + ret diff --git a/includes/Input.asm b/includes/lib/std/Input.asm similarity index 72% rename from includes/Input.asm rename to includes/lib/std/Input.asm index 18ea571..495bd37 100644 --- a/includes/Input.asm +++ b/includes/lib/std/Input.asm @@ -12,9 +12,8 @@ inputgetkey: jr z, inputgetkey ret - -;;inputstr [Input, String] -;; +;;inputstr +;;Inputs string of length [Buffer Size] and puts it in (Destination) ;;Inputs: ;; HL: Destination ;; D[E]: Buffer Size @@ -29,12 +28,16 @@ inputstr: ld hl, CurCol ld de, inputstrCurColBuf call bytecpy + ld hl, CurRow + ld de, inputstrCurRowBuf + call bytecpy pop de pop hl + res Shift2nd, (IY + ShiftFlags) call _CursorOn - xor a + xor a ld b, a inputstrKeyInput: call cursorcurunderreset @@ -67,12 +70,25 @@ inputstrKeyInput: call z, chartoascii call nz, charnumsymtoascii + cp $FF + jr z, inputstrKeyInput + + res textScrolled, (iy+textFlags) + call _PutC ld (hl), a inc hl inc b - + + bit textScrolled, (iy+textFlags) + jr z, inputstrKeyInput + push hl + ld hl, inputstrCurRowBuf + ld a, (hl) + dec a + ld (hl), a + pop hl jr inputstrKeyInput inputstrKey2nd: push hl @@ -92,7 +108,6 @@ inputstrKeyDel: push hl ld hl, CurCol - ld a, (hl) dec (hl) pop hl @@ -108,16 +123,14 @@ inputstrKeyClear: cp 0 jp z, inputstrKeyInput - push hl - ld hl, CurRow - ld c, (hl) - pop hl - push hl push de ld hl, inputstrCurColBuf ld de, CurCol call bytecpy + ld hl, inputstrCurRowBuf + ld de, CurRow + call bytecpy pop de pop hl @@ -126,17 +139,18 @@ inputstrKeyClear: inputstrKeyClearLoop: call _PutC djnz inputstrKeyClearLoop + ld b, 0 - push hl - push de + push de + push hl ld hl, inputstrCurColBuf ld de, CurCol call bytecpy - pop de - pop hl - - ld hl, CurRow - ld (hl), c + ld hl, inputstrCurRowBuf + ld de, CurRow + call bytecpy + pop hl + pop de pop hl push hl jp inputstrKeyInput @@ -148,15 +162,17 @@ inputstrKeyEnter: call _PutMap pop hl pop de + res Shift2nd, (IY + ShiftFlags) ret inputstrFlags: .db %00000000 ; 0: num Flag inputstrSizeBuf: .dw $0000 inputstrCurColBuf: .db $00 +inputstrCurRowBuf: .db $00 -;;inputcharstr [Input, String] -;; +;;inputcharstr +;;Inputs string of (only letters) of length [Buffer Size] and puts it in (Destination) ;;Inputs: ;; HL: Destination ;; D[E]: Buffer Size @@ -165,11 +181,14 @@ inputstrCurColBuf: .db $00 inputcharstr: push de push hl - ld (inputcharstrSizeBuf), de + ld (inputstrSizeBuf), de push hl push de ld hl, CurCol - ld de, inputcharstrCurColBuf + ld de, inputstrCurColBuf + call bytecpy + ld hl, CurRow + ld de, inputstrCurRowBuf call bytecpy pop de pop hl @@ -178,7 +197,6 @@ inputcharstr: xor a ld b, a - inputcharstrKeyInput: call cursorcurunderreset call inputgetkey @@ -206,14 +224,26 @@ inputcharstrKeyInput: call chartoascii + cp $FF + jr z, inputcharstrKeyInput + + res textScrolled, (iy+textFlags) + call _PutC ld (hl), a inc hl inc b - - jr inputcharstrKeyInput - + + bit textScrolled, (iy+textFlags) + jr z, inputcharstrKeyInput + push hl + ld hl, inputcharstrCurRowBuf + ld a, (hl) + dec a + ld (hl), a + pop hl + jr inputcharstrKeyInput inputcharstrKeyDel: ld a, b cp 0 @@ -224,7 +254,6 @@ inputcharstrKeyDel: push hl ld hl, CurCol - ld a, (hl) dec (hl) pop hl @@ -250,6 +279,9 @@ inputcharstrKeyClear: ld hl, inputcharstrCurColBuf ld de, CurCol call bytecpy + ld hl, inputcharstrCurRowBuf + ld de, CurRow + call bytecpy pop de pop hl @@ -267,8 +299,16 @@ inputcharstrKeyClearLoop: pop de pop hl - ld hl, CurRow - ld (hl), c + push de + push hl + ld hl, inputcharstrCurColBuf + ld de, CurCol + call bytecpy + ld hl, inputcharstrCurRowBuf + ld de, CurRow + call bytecpy + pop hl + pop de pop hl push hl jp inputcharstrKeyInput @@ -284,9 +324,10 @@ inputcharstrKeyEnter: inputcharstrSizeBuf: .dw $0000 inputcharstrCurColBuf: .db $00 +inputcharstrCurRowBuf: .db $00 -;;inputnumstr [Input, String] -;; +;;inputnumstr +;;Inputs string of (only numbers) of length [Buffer Size] and puts it in (Destination) ;;Inputs: ;; HL: Destination ;; D[E]: Buffer Size @@ -301,6 +342,9 @@ inputnumstr: ld hl, CurCol ld de, inputnumstrCurColBuf call bytecpy + ld hl, CurRow + ld de, inputnumstrCurRowBuf + call bytecpy pop de pop hl @@ -338,15 +382,24 @@ inputnumstrKeyInput: cp $FF jr z, inputnumstrKeyInput + res textScrolled, (iy+textFlags) + call _PutC ld (hl), a inc hl inc b - jr inputnumstrKeyInput - -inputnumstrKeyDel: + bit textScrolled, (iy+textFlags) + jr z, inputnumstrKeyInput + push hl + ld hl, inputnumstrCurRowBuf + ld a, (hl) + dec a + ld (hl), a + pop hl + jr inputnumstrKeyInput +inputnumstrkeydel: ld a, b cp 0 jp z, inputnumstrKeyInput @@ -355,9 +408,8 @@ inputnumstrKeyDel: call _PutMap push hl - ld hl, CurCol - ld a, (hl) - dec (hl) + ld hl, CurCol + dec (hl) pop hl ld a, ' ' @@ -382,6 +434,9 @@ inputnumstrKeyClear: ld hl, inputnumstrCurColBuf ld de, CurCol call bytecpy + ld hl, inputnumstrCurRowBuf + ld de, CurRow + call bytecpy pop de pop hl @@ -391,16 +446,16 @@ inputnumstrKeyClearLoop: call _PutC djnz inputnumstrKeyClearLoop - push hl - push de - ld hl, inputnumstrCurColBuf + push de + push hl + ld hl, inputnumstrCurColBuf ld de, CurCol call bytecpy - pop de - pop hl - - ld hl, CurRow - ld (hl), c + ld hl, inputnumstrCurRowBuf + ld de, CurRow + call bytecpy + pop hl + pop de pop hl push hl jp inputnumstrKeyInput @@ -416,3 +471,4 @@ inputnumstrKeyEnter: inputnumstrSizeBuf: .dw $0000 inputnumstrCurColBuf: .db $00 +inputnumstrCurRowBuf: .db $00 diff --git a/includes/lib/std/Math.asm b/includes/lib/std/Math.asm new file mode 100644 index 0000000..030e3f6 --- /dev/null +++ b/includes/lib/std/Math.asm @@ -0,0 +1,109 @@ +;;cpHLDE +;;Compares HL to DE. +;;Output: +;; Same as z80 CP instruction. +cpHLDE: + or a + sbc hl, de + add hl,de + ret + +;;cpHLBC +;;Compares HL to BC. +;;Output: +;; Same as z80 CP instruction. +cpHLBC: + or a + sbc hl, bc + add hl,bc + ret + +;;cpBCDE +;;Compares DE to BC. +;;Output: +;; Same as z80 CP instruction. +cpBCDE: + push hl + ld h, b + ld l, c + or a + sbc hl, de + pop hl + ret + +;;mulAbyB +;;Multiplys AxB +;;Inputs: +;; A: Multiplier +;; B: Multiplicand +;;Outputs: +;; A: Product of A and B. +mulAbyB: + push bc + ld c, a +mulAbyBLoop: + add a, c + djnz mulAbyBLoop + sub c + pop bc + ret + +;;mulAbyHL +;;Multiplys AxHL +;;Inputs: +;; A: Multiplier +;; HL: Multiplicand +;;Outputs: +;; HL: Product of A and HL. +mulAbyHL: + push bc + push de + ld de, 0 + ex de, hl + cp 0 + jr z, mulAbyHLEnd + ld b, a +mulAbyHLLoop: + add hl, de + djnz mulAbyHLLoop +mulAbyHLEnd: + pop de + pop bc + ret + + +;;mul32By8 +;;Performs an unsigned multiplication of DEHL and A. +;;Outputs: +;; DEHL: product of DEHL and A +mul32By8: + push bc \ push ix + ld ixl, 8 + push de + push hl + ld hl, 0 + ld d, h + ld e, l +mul32by8loop: + add hl, hl + rl e + rl d + rla + jr nc, mul32by8noAdd + pop bc + add hl, bc + ex (sp), hl + push hl + adc hl, de + pop de + ex de, hl + ex (sp), hl + push bc +mul32by8noAdd: + dec ixl + jr nz, mul32by8loop + pop bc + pop bc + pop ix \ pop bc + ret + diff --git a/includes/lib/std/Mem.asm b/includes/lib/std/Mem.asm new file mode 100644 index 0000000..8cf7244 --- /dev/null +++ b/includes/lib/std/Mem.asm @@ -0,0 +1,16 @@ +;;memset +;;Fills B amount of bytes from hl with a +;;Inputs: +;; HL: start +;; B: how many bytes +;; A: Byte +memset: + push hl + push bc +memsetLoop: + ld (hl), a + inc hl + djnz memsetLoop + pop bc + pop hl + ret diff --git a/includes/Print.asm b/includes/lib/std/Print.asm similarity index 100% rename from includes/Print.asm rename to includes/lib/std/Print.asm diff --git a/includes/String.asm b/includes/lib/std/String.asm similarity index 54% rename from includes/String.asm rename to includes/lib/std/String.asm index 94ccc87..e23a99f 100644 --- a/includes/String.asm +++ b/includes/lib/std/String.asm @@ -1,81 +1,60 @@ -;; strlen [Strings] -;; Determines the length of a zero delimited string. -;; Inputs: -;; HL: String pointer -;; Outputs: -;; BC: String length +;;strlen +;;Determines the length of a zero delimited string. +;;Inputs: +;; HL: String pointer +;;Outputs: +;; BC: String length strlen: - push af - push hl - xor a - ld b, a - ld c, a - cpir - ; bc = -bc - xor a \ sub c \ ld c, a \ sbc a, a \ sub b \ ld b, a - dec bc - pop hl - pop af - ret + push af + push hl + xor a + ld b, a + ld c, a + cpir + ; bc = -bc + xor a \ sub c \ ld c, a \ sbc a, a \ sub b \ ld b, a + dec bc + pop hl + pop af + ret -;; strcmp [Strings] -;; Determines if two strings are equal, and checks alphabetical sort order. -;; Inputs: -;; HL: String pointer -;; DE: String pointer -;; Outputs: -;; Z: Set if equal, reset if not equal -;; C: Set if string HL is alphabetically earlier than string DE +;;strcmp +;;Determines if two strings are equal, and checks alphabetical sort order. +;;Inputs: +;; HL: String pointer +;; DE: String pointer +;;Outputs: +;; Z: Set if equal, reset if not equal +;; C: Set if string HL is alphabetically earlier than string DE strcmp: - push hl - push de + push hl + push de strcmpLoop: - ld a, (de) - or a - jr z, strCmpEnd - cp (hl) - jr nz, strcmpExit - inc hl - inc de - jr strcmpLoop + ld a, (de) + or a + jr z, strCmpEnd + cp (hl) + jr nz, strcmpExit + inc hl + inc de + jr strcmpLoop strcmpEnd: - ld a, (hl) - or a + ld a, (hl) + or a strcmpExit: - ccf - pop de - pop hl - ret - -;; strcmp_sort [Strings] -;; Compares strings at ((HL)) and ((DE)). That is, calls [[indirect16HLDE]], -;; then calls [[strcmp]]. -;; Inputs: -;; HL: Pointer to string pointer -;; DE: Pointer to string pointer -;; Outputs: -;; Z: Set if equal, reset if not equal -;; C: Set if string (HL) is alphabetically earlier than string (DE) -;; Notes: -;; This routine is useful as the callback for the [[callbackSort]] routine. -;; It allows sorting a list of pointers to strings in alphabetical order. -;strcmp_sort: -; push hl -; push de -; call indirect16HLDE -; call strcmp -; pop de -; pop hl -; ret - -;; strcpy [Strings] -;; Copies a string. -;; Inputs: -;; HL: String pointer -;; DE: Destination -;; Notes: -;; This will trample into undefined territory if you try to copy a string into some -;; allocated memory it won't fit in. + ccf + pop de + pop hl + ret + +;;strcpy +;;Copies a string. +;;Inputs: +;; HL: String pointer +;; DE: Destination +;;Notes: +;; This will trample into undefined territory if you try to copy a string into some +;;allocated memory it won't fit in. strcpy: push de push hl @@ -90,34 +69,34 @@ _: pop hl pop de ret -;; strchr [Strings] -;; Returns a pointer on the first occurence of a character in a string. -;; Inputs: -;; HL: Haystack -;; B: Needle -;; Outputs: -;; HL: Pointer to first occurence of character -;; Z: Set if character found -;; A: Destroyed +;;strchr +;;Returns a pointer on the first occurence of a character in a string. +;;Inputs: +;; HL: Haystack +;; B: Needle +;;Outputs: +;; HL: Pointer to first occurence of character +;; Z: Set if character found +;; A: Destroyed strchr: strchrLoop: - ld a, (hl) - or a - jr z, strchrNoCharFound - cp b - ret z - inc hl - jr strchrLoop + ld a, (hl) + or a + jr z, strchrNoCharFound + cp b + ret z + inc hl + jr strchrLoop strchrNoCharFound: - inc a - ret + inc a + ret -;; strtob -;; Converts a string to a byte -;; Inputs: -;; HL: string pointer -;; Outputs: -;; A: byte +;;strtob +;;Converts a string to a byte +;;Inputs: +;; HL: string pointer +;;Outputs: +;; A: byte strtob: push bc push de @@ -176,12 +155,12 @@ strtobExit: pop bc ret -;; strtow -;; Converts a string to a byte -;; Inputs: -;; HL: string pointer -;; Outputs: -;; HL: byte +;;strtow +;;Converts a string to a byte +;;Inputs: +;; HL: string pointer +;;Outputs: +;; HL: byte strtow: push bc push de @@ -211,6 +190,7 @@ strtowNumWhileLoop: inc c jr strtowNumWhileLoop strtowConvert: + ld bc, 0 dec hl ld a, (hl) sub '0' @@ -278,12 +258,12 @@ strtowExit: pop bc ret -;; toLower [Strings] -;; Converts every alpha character of a string to lowercase. -;; Inputs: -;; HL: Pointer to string -;; Notes: -;; This modifies the string in-place. +;;toLower [Strings] +;;Converts every alpha character of a string to lowercase. +;;Inputs: +;; HL: Pointer to string +;;Notes: +;; This modifies the string in-place. ;toLower: ; push af \ push hl ; ld a, (hl) @@ -302,12 +282,12 @@ strtowExit: ; pop hl \ pop af ; ret -;; toUpper [Strings] -;; Converts every alpha character of a string to uppercase. -;; Inputs: -;; HL: Pointer to string -;; Notes: -;; This modifies the string in-place. +;;toUpper [Strings] +;;Converts every alpha character of a string to uppercase. +;;Inputs: +;; HL: Pointer to string +;;Notes: +;; This modifies the string in-place. ;toUpper: ; push af \ push hl ; ld a, (hl) diff --git a/includes/Word.asm b/includes/lib/std/Word.asm similarity index 57% rename from includes/Word.asm rename to includes/lib/std/Word.asm index 1d9b796..5168a3b 100644 --- a/includes/Word.asm +++ b/includes/lib/std/Word.asm @@ -1,8 +1,8 @@ -;; wordcpy [Words] -;; Copies a word. -;; Inputs: -;; HL: word pointer -;; DE: Destination +;;wordcpy [Words] +;;Copies a word. +;;Inputs: +;; HL: word pointer +;; DE: Destination wordcpy: push de push hl diff --git a/includes/lib/std/std.inc b/includes/lib/std/std.inc new file mode 100644 index 0000000..0e4e778 --- /dev/null +++ b/includes/lib/std/std.inc @@ -0,0 +1,12 @@ +#include "includes/lib/std/Math.asm" +#include "includes/lib/std/Byte.asm" +#include "includes/lib/std/Mem.asm" +#include "includes/lib/std/Char.asm" +#include "includes/lib/std/Cursor.asm" +#include "includes/lib/std/Print.asm" +#include "includes/lib/std/Draw.asm" +#include "includes/lib/std/Array.asm" + +#include "includes/lib/std/String.asm" + +#include "includes/lib/std/Input.asm" diff --git a/includes/macros/command.asm b/includes/macros/command.asm new file mode 100644 index 0000000..4486998 --- /dev/null +++ b/includes/macros/command.asm @@ -0,0 +1,21 @@ +;;decodecmdopt +;;compares cmdXs to command input and conditionally sets opt to optcode +;;Inputs: +;; HL: cmd string input +;; DE: op code mem location +#macro decodecmdopt(cmdXs, cmdXo) + push hl + push de + ld de, cmdXs + call strcmp + ld hl, cmdXo + pop de + call z, bytecpy + pop hl +#endmacro + +#macro routeoptjp(cmdXo, cmdXf) + ld de, cmdXo + call bytecmp + jp z, cmdXf +#endmacro diff --git a/includes/macros/draw.asm b/includes/macros/draw.asm new file mode 100644 index 0000000..664a4a7 --- /dev/null +++ b/includes/macros/draw.asm @@ -0,0 +1,33 @@ +#macro drawpixelxyM(x, y) + ld de, x + ld a, y + call drawpixelxy +#endmacro + +#macro drawlineM(x1, y1, x2, y2) +;TODO +#endmacro + +#macro drawrowM(y) + ld a, y + call drawrow +#endmacro + +#macro drawbarM(y, height) + ld a, y + ld bc, height + call drawbar +#endmacro + +#macro drawrectfilledM(x, y, width, height) + ex de, hl + ld ixl, e + ld ixh, d + ex de, hl + ld hl, width + ld de, x + ld bc, 0 + ld c, y + ld a, height + call drawrectfilled +#endmacro diff --git a/includes/macros/macros.inc b/includes/macros/macros.inc new file mode 100644 index 0000000..9cac28f --- /dev/null +++ b/includes/macros/macros.inc @@ -0,0 +1,4 @@ +#include "includes/macros/misc.asm" +#include "includes/macros/pixel.asm" +#include "includes/macros/draw.asm" +#include "includes/macros/command.asm" diff --git a/includes/macros/misc.asm b/includes/macros/misc.asm new file mode 100644 index 0000000..ba398d7 --- /dev/null +++ b/includes/macros/misc.asm @@ -0,0 +1,9 @@ +;;rgbto565 +;;turns an rgb input into the 656 format that the lcd uses +;;Inputs: +;; r,g,b +;;Outputs: +;; HL: color +#macro rgbto565(red, green, blue) + ld hl, ((red / 255 * 31) << 11) | ((green / 255 * 63) << 5) | ((blue / 255 * 31)) +#endmacro diff --git a/includes/macros/pixel.asm b/includes/macros/pixel.asm new file mode 100644 index 0000000..0b60bb5 --- /dev/null +++ b/includes/macros/pixel.asm @@ -0,0 +1,10 @@ +;;pixel +;;Gets vRam location of coordinates +;;Inputs: +;; x: x axis +;; y: y axis +;;Outputs: +;; DE: vRam location +#macro pixel(x, y) + ld de, vRam + (y * 320 * 2) + (x * 2) +#endmacro diff --git a/includes/man-db.asm b/includes/man-db.asm new file mode 100644 index 0000000..77d348d --- /dev/null +++ b/includes/man-db.asm @@ -0,0 +1,52 @@ +;;TODO: move module specific macros to diffrent file +;;manroute +;;routes command string to discription +;;Inputs: +;; HL: Command String +;;Outputs: +;; HL: Command Discription String +manroute: + push de +#macro routestrjp(cmdXs, cmdXm) + ld de, cmdXs + call strcmp + ld de, cmdXm + jp z, manrouteReturn +#endmacro + + call fshcmdmanroute + ;Extention Point + + ld hl, FshCmdErrCode + ld (hl), $01 + ld de, $00 +manrouteReturn: + ex de, hl + pop de + ret + +;;manrouteu +;;routes command string to usage +;;Inputs: +;; HL: Command String +;;Outputs: +;; HL: Command Usage String +manrouteu: + push de +#macro routeustrjp(cmdXs, cmdXu) + ld de, cmdXs + call strcmp + ld de, cmdXu + jp z, manrouteuReturn +#endmacro + + call fshcmdmanrouteu + ;Extention Point + + ld hl, FshCmdErrCode + ld (hl), $01 + ld de, $00 +manrouteuReturn: + ex de, hl + pop de + ret diff --git a/includes/static/define.inc b/includes/static/define.inc new file mode 100644 index 0000000..021531b --- /dev/null +++ b/includes/static/define.inc @@ -0,0 +1,28 @@ +.nolist + +; Included for Assembler Compatibility +;------------------------------------ +#define equ .equ +#define EQU .equ +#define end .end +#define END .end + +#define FshVarsSize 128 ;256 bytes | 64 words +#define FshCmdSize 64 ;64 bytes | 44 chars , 5 qwords (CMD + args) , + 4 0's| 1 byte null | 2 byte optcode | 1 byte arg flags |1 byte (err code) | 6 unused +#define FshCmdInptSize 44 +#define FshCmdCmdSize 8 +#define FshPrgmSize 1024 + +RamVars equ 0D0EA1Fh ;saveSScreen | 21945 bytes +FshVars equ RamVars +FshCmd equ FshVars + FshVarsSize +FshPrgm equ FshCmd + FshCmdSize + +FshCmdNull equ FshCmd + FshCmdInptSize +FshCmdOP equ FshCmdNull + 1 +FshCmdArg0 equ FshCmd + 9 +FshCmdArg1 equ FshCmdArg0 + 9 +FshCmdArg2 equ FshCmdArg1 + 9 +FshCmdArg3 equ FshCmdArg2 + 9 +FshCmdArgFlags equ FshCmdArg3 + 10 +FshCmdErrCode equ FshCmdArgFlags + 1 diff --git a/includes/ti84pce.inc b/includes/static/ti84pce.inc similarity index 99% rename from includes/ti84pce.inc rename to includes/static/ti84pce.inc index 100235a..e150bc3 100644 --- a/includes/ti84pce.inc +++ b/includes/static/ti84pce.inc @@ -481,7 +481,7 @@ _ClrLCDFull equ 0020808h _ClrLCD equ 002080Ch _ClrScrnFull equ 0020810h _ClrScrn equ 0020814h -_ClrTxtShd equ 0020818h +_ClrTxtShdw equ 0020818h _ClrWindow equ 002081Ch _EraseEOL equ 0020820h _EraseEOW equ 0020824h diff --git a/includes/tables/CSC.asm b/includes/tables/CSC.asm index a39b69b..0f7d420 100644 --- a/includes/tables/CSC.asm +++ b/includes/tables/CSC.asm @@ -1,9 +1,9 @@ charMapCSC: - .DB 0, "WRMH", 0, 0 - .DB Lquestion, Ltheta, "VQLG", 0, 0 - .DB ":ZUPKFC", 0 - .DB " YTOJEB",0 - .DB 0, "XSNIDA" + .DB "\"WRMH", $FF, $FF + .DB Lquestion, Ltheta, "VQLG", $FF, $FF + .DB ":ZUPKFC", $FF + .DB " YTOJEB", $FF + .DB $FF, "XSNIDA" numsymMapCSC .DB "+-*/^", $FF, $FF diff --git a/screenshots/help.png b/screenshots/help.png new file mode 100644 index 0000000..a92bd39 Binary files /dev/null and b/screenshots/help.png differ diff --git a/screenshots/man_set.png b/screenshots/man_set.png new file mode 100644 index 0000000..96e0294 Binary files /dev/null and b/screenshots/man_set.png differ diff --git a/screenshots/motd.png b/screenshots/motd.png new file mode 100644 index 0000000..376c200 Binary files /dev/null and b/screenshots/motd.png differ diff --git a/screenshots/vars.png b/screenshots/vars.png new file mode 100644 index 0000000..30df370 Binary files /dev/null and b/screenshots/vars.png differ