added so many new things
making a release
new commands
new interface!
This commit is contained in:
Stephen Toth 2018-07-07 10:08:04 -04:00
parent de6092bb9e
commit c127c5eb81
57 changed files with 1540 additions and 611 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.swp

53
CONTRIBUTING.md Normal file
View File

@ -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
<nameofmodule>cmd<COMMAND>: .db "<COMMAND>", 0
<nameofmodule>cmd<COMMAND>o: .db $<optcode>
<nameofmodule>cmd<COMMAND>u: .db "<Discription>", 0
<nameofmodule>cmd<COMMAND>f:
<Command code to execute>
jp Fin
```
* Registers CAN be destroyed during execution of command's code

View File

@ -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

39
README.md Normal file
View File

@ -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. <https://education.ti.com/ticonnectce> 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 <kbd>2nd</kbd>+<kbd>0</kbd> and select the Asm( option. Then, press <kbd>Prgm</kbd> and select FSHA. you should now have the following: `Asm(PrgmFSHA` Press <kbd>Enter</kbd>
For TIOS 5.3+
Press <kbd>Prgm</kbd> and select FSHA. you should now have the following: `PrgmFSHA` Press <kbd>Enter</kbd>
## Building From Source
* Linux
1. Clone, make, and install spasm-ng <https://github.com/alberthdev/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: <https://gitlab.com/stephentoth/fsh-shell>
Please include:
1. What went wrong.
2. What you were doing when the issue occurred.
3. Possible cause/fixes? (optional)
Thank you!

Binary file not shown.

2
build
View File

@ -1,3 +1,3 @@
#!/bin/bash
date
spasm -ET "FSHa.asm" "bin/FSHa.8xp"
spasm -ETA "FSHa.asm" "bin/FSHa.8xp"

View File

@ -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

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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 <source address> <destination address>", 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

View File

@ -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

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,62 @@
fshcmdMAN: .db "MAN", 0
fshcmdMANo: .db $22
fshcmdMANm: .db "Displays MAN text for command", 0
fshcmdMANu: .db "MAN <command>", 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

View File

@ -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 <source address> <destination address>", 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

View File

@ -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 <destination address> <value>", 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

View File

@ -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

View File

@ -0,0 +1,41 @@
fshcmdVAR: .db "VAR", 0
fshcmdVARo: .db $11
fshcmdVARm: .db "Displays a value from FSH memory", 0
fshcmdVARu: .db "VAR <source address>", 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

View File

@ -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

View File

@ -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

13
includes/Text.inc Normal file
View File

@ -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

View File

@ -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

View File

@ -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

30
includes/lib/fsh/Draw.asm Normal file
View File

@ -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

View File

@ -1,14 +1,19 @@
;;ErrCatch
;;Checks err bit and jp to err route
ErrCatch:
pop bc
push hl
ld hl, FshFlags
bit 1, (hl)
pop hl
jp nz, ErrRoute
jp Fin
push bc
ret
;;ErrRoute
;;Routes err codes.
ErrRoute:
ld hl, FshFlags
res 1, (hl)
@ -22,13 +27,21 @@ ErrRoute:
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

View File

@ -1,6 +1,6 @@
;;; fshvarset [Bytes]
;; Sets a Word in FshVars.
;; Inputs:
;;fshvarset
;;Sets a Word in FshVars.
;;Inputs:
;; HL: 16b
;; DE: Destination Word Relitive to FshVars
fshvarset:
@ -9,7 +9,6 @@ fshvarset:
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,11 +30,11 @@ fshvarsetOOBException:
pop hl
ret
;;; fshvarget [Words]
;; Gets a Word in FshVars.
;; Inputs:
;;fshvarget
;;Gets a Word in FshVars.
;;Inputs:
;; DE: Destination Word Relitive to FshVars
;; Outputs:
;;Outputs:
;; HL: Word in (DE)
fshvarget:
push bc
@ -44,7 +42,6 @@ fshvarget:
call cpBCDE
pop bc
jr c, fshvargetOOBException
push bc
push de
ld hl, 0
@ -59,17 +56,15 @@ fshvarget:
pop de
pop bc
ret
fshvargetOOBException:
push hl
ld hl, ErrOutOfBoundso
call ErrSet
pop hl
ret
; fshvarcpy [Bytes]
;; Copies a word.
;; Inputs:
;;fshvarcpy
;;Copies a word.
;;Inputs:
;; HL: Byte pointer
;; DE: Destination
fshvarcpy:
@ -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

187
includes/lib/fsh/Parse.asm Normal file
View File

@ -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

View File

@ -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

6
includes/lib/fsh/fsh.inc Normal file
View File

@ -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"

View File

@ -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

31
includes/lib/std/Byte.asm Normal file
View File

@ -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

View File

@ -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

View File

@ -1,4 +1,3 @@
;TODO
;;cursorcharunderreset
;;Sets curUnder to 0
cursorcurunderreset:

125
includes/lib/std/Draw.asm Normal file
View File

@ -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

View File

@ -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,9 +28,13 @@ 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
@ -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 hl
ld hl, inputstrCurColBuf
ld de, CurCol
call bytecpy
pop de
ld hl, inputstrCurRowBuf
ld de, CurRow
call bytecpy
pop hl
ld hl, CurRow
ld (hl), c
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
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
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:
inputnumstrkeydel:
ld a, b
cp 0
jp z, inputnumstrKeyInput
@ -356,7 +409,6 @@ inputnumstrKeyDel:
push hl
ld hl, CurCol
ld a, (hl)
dec (hl)
pop hl
@ -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
push hl
ld hl, inputnumstrCurColBuf
ld de, CurCol
call bytecpy
pop de
ld hl, inputnumstrCurRowBuf
ld de, CurRow
call bytecpy
pop hl
ld hl, CurRow
ld (hl), c
pop de
pop hl
push hl
jp inputnumstrKeyInput
@ -416,3 +471,4 @@ inputnumstrKeyEnter:
inputnumstrSizeBuf: .dw $0000
inputnumstrCurColBuf: .db $00
inputnumstrCurRowBuf: .db $00

109
includes/lib/std/Math.asm Normal file
View File

@ -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

16
includes/lib/std/Mem.asm Normal file
View File

@ -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

View File

@ -1,8 +1,8 @@
;; strlen [Strings]
;; Determines the length of a zero delimited string.
;; Inputs:
;;strlen
;;Determines the length of a zero delimited string.
;;Inputs:
;; HL: String pointer
;; Outputs:
;;Outputs:
;; BC: String length
strlen:
push af
@ -18,12 +18,12 @@ strlen:
pop af
ret
;; strcmp [Strings]
;; Determines if two strings are equal, and checks alphabetical sort order.
;; Inputs:
;;strcmp
;;Determines if two strings are equal, and checks alphabetical sort order.
;;Inputs:
;; HL: String pointer
;; DE: String pointer
;; Outputs:
;;Outputs:
;; Z: Set if equal, reset if not equal
;; C: Set if string HL is alphabetically earlier than string DE
strcmp:
@ -47,35 +47,14 @@ strcmpExit:
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:
;;strcpy
;;Copies a string.
;;Inputs:
;; HL: String pointer
;; DE: Destination
;; Notes:
;;Notes:
;; This will trample into undefined territory if you try to copy a string into some
;; allocated memory it won't fit in.
;;allocated memory it won't fit in.
strcpy:
push de
push hl
@ -90,12 +69,12 @@ _: pop hl
pop de
ret
;; strchr [Strings]
;; Returns a pointer on the first occurence of a character in a string.
;; Inputs:
;;strchr
;;Returns a pointer on the first occurence of a character in a string.
;;Inputs:
;; HL: Haystack
;; B: Needle
;; Outputs:
;;Outputs:
;; HL: Pointer to first occurence of character
;; Z: Set if character found
;; A: Destroyed
@ -112,11 +91,11 @@ strchrNoCharFound:
inc a
ret
;; strtob
;; Converts a string to a byte
;; Inputs:
;;strtob
;;Converts a string to a byte
;;Inputs:
;; HL: string pointer
;; Outputs:
;;Outputs:
;; A: byte
strtob:
push bc
@ -176,11 +155,11 @@ strtobExit:
pop bc
ret
;; strtow
;; Converts a string to a byte
;; Inputs:
;;strtow
;;Converts a string to a byte
;;Inputs:
;; HL: string pointer
;; Outputs:
;;Outputs:
;; HL: byte
strtow:
push bc
@ -211,6 +190,7 @@ strtowNumWhileLoop:
inc c
jr strtowNumWhileLoop
strtowConvert:
ld bc, 0
dec hl
ld a, (hl)
sub '0'
@ -278,11 +258,11 @@ strtowExit:
pop bc
ret
;; toLower [Strings]
;; Converts every alpha character of a string to lowercase.
;; Inputs:
;;toLower [Strings]
;;Converts every alpha character of a string to lowercase.
;;Inputs:
;; HL: Pointer to string
;; Notes:
;;Notes:
;; This modifies the string in-place.
;toLower:
; push af \ push hl
@ -302,11 +282,11 @@ strtowExit:
; pop hl \ pop af
; ret
;; toUpper [Strings]
;; Converts every alpha character of a string to uppercase.
;; Inputs:
;;toUpper [Strings]
;;Converts every alpha character of a string to uppercase.
;;Inputs:
;; HL: Pointer to string
;; Notes:
;;Notes:
;; This modifies the string in-place.
;toUpper:
; push af \ push hl

View File

@ -1,6 +1,6 @@
;; wordcpy [Words]
;; Copies a word.
;; Inputs:
;;wordcpy [Words]
;;Copies a word.
;;Inputs:
;; HL: word pointer
;; DE: Destination
wordcpy:

12
includes/lib/std/std.inc Normal file
View File

@ -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"

View File

@ -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

33
includes/macros/draw.asm Normal file
View File

@ -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

View File

@ -0,0 +1,4 @@
#include "includes/macros/misc.asm"
#include "includes/macros/pixel.asm"
#include "includes/macros/draw.asm"
#include "includes/macros/command.asm"

9
includes/macros/misc.asm Normal file
View File

@ -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

10
includes/macros/pixel.asm Normal file
View File

@ -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

52
includes/man-db.asm Normal file
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

BIN
screenshots/help.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
screenshots/man_set.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
screenshots/motd.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
screenshots/vars.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB