Initial commit
This commit is contained in:
commit
6f423f2f54
|
|
@ -0,0 +1,15 @@
|
|||
stages:
|
||||
- build
|
||||
|
||||
before_script:
|
||||
- apt-get update -qq && apt-get install -y -qq git build-essential libssl-dev zlib1g-dev libgmp-dev
|
||||
- git clone https://github.com/alberthdev/spasm-ng.git
|
||||
- pushd spasm-ng
|
||||
- make version
|
||||
- make
|
||||
- make install
|
||||
- popd
|
||||
|
||||
jobBuild:
|
||||
stage: build
|
||||
script: ./build
|
||||
Binary file not shown.
|
|
@ -0,0 +1,76 @@
|
|||
#include "includes/ti84pce.inc"
|
||||
#include "includes/define.inc"
|
||||
|
||||
.assume ADL=1
|
||||
.org userMem-2
|
||||
.DB tExtTok,tAsm84CeCmp
|
||||
|
||||
Setup:
|
||||
CALL _homeup ;Put up home
|
||||
CALL _ClrLCDFull ;Clear screen
|
||||
|
||||
LD HL, $FF
|
||||
CALL fshvarfill
|
||||
|
||||
|
||||
Input:
|
||||
XOR A
|
||||
LD (CurCol), A
|
||||
LD HL, PS1
|
||||
CALL _PutS
|
||||
|
||||
;TODO: reset CmdFsh mem
|
||||
LD HL, FshCmd
|
||||
LD DE, 0
|
||||
LD DE, FshCmdInptSize
|
||||
CALL inputstr
|
||||
|
||||
CALL _NewLine
|
||||
|
||||
Decode:
|
||||
LD HL, FshCmdOP ; resets to 0, TEMP
|
||||
LD A, $00
|
||||
LD (HL), A
|
||||
|
||||
LD HL, FshCmd
|
||||
LD DE, FshCmdOP
|
||||
CALL fshcmddecode
|
||||
|
||||
Route:
|
||||
LD HL, FshCmdOP
|
||||
JP fshcmdroute
|
||||
|
||||
Fin:
|
||||
JP Input
|
||||
|
||||
Err:
|
||||
;TODO: Err Handler
|
||||
JP ErrDefault
|
||||
|
||||
Cleanup:
|
||||
SET graphdraw,(IY+graphflags)
|
||||
CALL _ClrLCDFull
|
||||
|
||||
Exit:
|
||||
RES donePrgm,(iy+doneFlags)
|
||||
RET
|
||||
|
||||
PS1: .DB "FSH> ",0
|
||||
;TestStr: .DB "081",0
|
||||
FshFlags: .DB %00000000
|
||||
; 0: Debug Flag
|
||||
; 1: Error Flag
|
||||
; 2: Program Flag
|
||||
|
||||
|
||||
#include "includes/String.asm"
|
||||
#include "includes/Byte.asm"
|
||||
#include "includes/Math.asm"
|
||||
#include "includes/FshVar.asm"
|
||||
#include "includes/FshCmd.asm"
|
||||
#include "includes/Char.asm"
|
||||
#include "includes/Cursor.asm"
|
||||
#include "includes/Input.asm"
|
||||
#include "includes/bbuffer.asm"
|
||||
#include "includes/Err.asm"
|
||||
.end
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash -l
|
||||
#$ -S /bin/bash
|
||||
#$ -N $2
|
||||
date
|
||||
spasm -ET "FSHa.asm" "bin/FSHa.8xp"
|
||||
Binary file not shown.
|
|
@ -0,0 +1,34 @@
|
|||
;; bytecmp [Bytes]
|
||||
;; Determines if two bytes are equal.
|
||||
;; Inputs:
|
||||
;; HL: String pointer
|
||||
;; DE: String 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
|
||||
;; Notes:
|
||||
;; This will trample into undefined territory if you try to copy a string into some
|
||||
;; allocated memory it won't fit in.
|
||||
bytecpy:
|
||||
push de
|
||||
push hl
|
||||
ex de, hl
|
||||
ld a, (de)
|
||||
ld (hl), a
|
||||
pop hl
|
||||
pop de
|
||||
ret
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
#include "includes/tables/CSC.asm"
|
||||
; chartoascii
|
||||
;; Converts a char to "ascii"
|
||||
;;Inputs:
|
||||
;; A: char code (csc)
|
||||
;;Outputs:
|
||||
;; A: ascii char
|
||||
chartoascii:
|
||||
push hl ; Convert scan code into character
|
||||
ld hl, 0
|
||||
ld h, 0
|
||||
ld l, a
|
||||
ld de, charMapCSC
|
||||
add hl, de
|
||||
ld a, (hl)
|
||||
pop hl
|
||||
ret
|
||||
; charnumtoascii
|
||||
;; Converts a char to "ascii"
|
||||
;;Inputs:
|
||||
;; A: char code (csc)
|
||||
;;Outputs:
|
||||
;; A: ascii char
|
||||
charnumtoascii:
|
||||
push hl ; Convert scan code into character
|
||||
ld hl, 0
|
||||
ld h, 0
|
||||
ld l, a
|
||||
ld de, numMapCSC
|
||||
add hl, de
|
||||
ld a, (hl)
|
||||
pop hl
|
||||
ret
|
||||
; charnumsymtoascii
|
||||
;; Converts a char to "ascii"
|
||||
;;Inputs:
|
||||
;; A: char code (csc)
|
||||
;;Outputs:
|
||||
;; A: ascii char
|
||||
charnumsymtoascii:
|
||||
push hl ; Convert scan code into character
|
||||
ld hl, 0
|
||||
ld h, 0
|
||||
ld l, a
|
||||
ld de, numsymMapCSC
|
||||
add hl, de
|
||||
ld a, (hl)
|
||||
pop hl
|
||||
ret
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
;TODO
|
||||
;;cursorcharunderreset
|
||||
;;Sets curUnder to 0
|
||||
cursorcurunderreset:
|
||||
push hl
|
||||
ld hl, curUnder
|
||||
ld (hl), ' '
|
||||
pop hl
|
||||
ret
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
ErrDefault:
|
||||
ld hl, ErrDefaultT
|
||||
call _PutS
|
||||
jp Exit
|
||||
ErrDefaultT:
|
||||
.db "ERR: Default; Exit",0
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
;;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, fshcmdVARS
|
||||
call strcmp
|
||||
ld hl, fshcmdVARSo
|
||||
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
|
||||
|
||||
ret
|
||||
|
||||
;;fshcmdroute
|
||||
;;Routes all commamds.
|
||||
;;Inputs:
|
||||
;; HL: Op code mem loc
|
||||
;;Outputs:
|
||||
;; Jp to loc for cmd func
|
||||
;; ult go to Fin
|
||||
fshcmdroute:
|
||||
ld de, fshcmdEXITo
|
||||
call bytecmp
|
||||
jp z, fshcmdEXITf
|
||||
|
||||
ld de, fshcmdSETo
|
||||
call bytecmp
|
||||
jp z, fshcmdSETf
|
||||
|
||||
ld de, fshcmdVARSo
|
||||
call bytecmp
|
||||
jp z, fshcmdVARSf
|
||||
|
||||
ld de, fshcmdCLSo
|
||||
call bytecmp
|
||||
jp z, fshcmdCLSf
|
||||
|
||||
jp Fin
|
||||
|
||||
#include "includes/commands.inc"
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
;;; fshvarset [Bytes]
|
||||
;; Sets a Word in FshVars.
|
||||
;; Inputs:
|
||||
;; HL: 16b
|
||||
;; DE: Destination Word Relitive to FshVars
|
||||
fshvarset:
|
||||
push bc
|
||||
push de
|
||||
push hl
|
||||
ld bc, FshVars
|
||||
ex de, hl
|
||||
add hl, hl
|
||||
add hl, bc
|
||||
ld (hl), e
|
||||
inc hl
|
||||
ld (hl), d
|
||||
pop hl
|
||||
pop de
|
||||
pop bc
|
||||
ret
|
||||
|
||||
;;; fshvarget [Words]
|
||||
;; Gets a Word in FshVars.
|
||||
;; Inputs:
|
||||
;; DE: Destination Word Relitive to FshVars
|
||||
;; Outputs:
|
||||
;; HL: Word in (DE)
|
||||
fshvarget:
|
||||
push bc
|
||||
push de
|
||||
ld bc, FshVars
|
||||
ex de, hl
|
||||
add hl, hl
|
||||
add hl, bc
|
||||
ld e, (hl)
|
||||
inc hl
|
||||
ld d, (hl)
|
||||
ex de, hl
|
||||
pop de
|
||||
pop bc
|
||||
ret
|
||||
|
||||
; fshvarcpy [Bytes]
|
||||
;; Copies a word.
|
||||
;; Inputs:
|
||||
;; HL: Byte pointer
|
||||
;; DE: Destination
|
||||
fshvarcpy:
|
||||
push bc
|
||||
push de
|
||||
push hl
|
||||
ld bc, FshVars
|
||||
add hl, hl
|
||||
add hl, bc
|
||||
ex de, hl
|
||||
add hl, hl
|
||||
add hl, bc
|
||||
ld a, (de)
|
||||
ld (hl), a
|
||||
inc de
|
||||
inc hl
|
||||
ld a, (de)
|
||||
ld (hl), a
|
||||
pop hl
|
||||
pop de
|
||||
pop bc
|
||||
ret
|
||||
|
||||
; fshvarfill
|
||||
;; fills fshvars with word
|
||||
;; Inputs:
|
||||
;; HL: 16b
|
||||
fshvarfill:
|
||||
push hl
|
||||
push bc
|
||||
push de
|
||||
ld b, 0
|
||||
ld de, 0
|
||||
fshvarfillLoop:
|
||||
call fshvarset
|
||||
inc b
|
||||
inc de
|
||||
ld a, b
|
||||
cp FshVarsSize / 2
|
||||
jr c, fshvarfillLoop
|
||||
pop de
|
||||
pop bc
|
||||
pop hl
|
||||
ret
|
||||
|
|
@ -0,0 +1,418 @@
|
|||
;;inputgetkey
|
||||
;;Gets keycode
|
||||
;;Outputs:
|
||||
;; A: keycode
|
||||
;;Destroys:
|
||||
;; DE
|
||||
inputgetkey:
|
||||
ex de, hl
|
||||
call _GetCSC
|
||||
ex de, hl
|
||||
or a
|
||||
jr z, inputgetkey
|
||||
ret
|
||||
|
||||
|
||||
;;inputstr [Input, String]
|
||||
;;
|
||||
;;Inputs:
|
||||
;; HL: Destination
|
||||
;; D[E]: Buffer Size
|
||||
;;Ouptuts:
|
||||
;; (HL): String
|
||||
inputstr:
|
||||
push de
|
||||
push hl
|
||||
ld (inputstrSizeBuf), de
|
||||
push hl
|
||||
push de
|
||||
ld hl, CurCol
|
||||
ld de, inputstrCurColBuf
|
||||
call bytecpy
|
||||
pop de
|
||||
pop hl
|
||||
|
||||
call _CursorOn
|
||||
|
||||
xor a
|
||||
ld b, a
|
||||
inputstrKeyInput:
|
||||
call cursorcurunderreset
|
||||
call inputgetkey
|
||||
|
||||
cp sk2nd
|
||||
jp z, inputstrKey2nd
|
||||
cp skDel
|
||||
jp z, inputstrKeyDel
|
||||
cp skClear
|
||||
jp z, inputstrKeyClear
|
||||
cp skEnter
|
||||
jp z, inputstrKeyEnter
|
||||
|
||||
ld c, a
|
||||
ld a, b
|
||||
push de
|
||||
ld de, (inputstrSizeBuf)
|
||||
cp e
|
||||
pop de
|
||||
jr z, inputstrKeyInput
|
||||
ld a, c
|
||||
|
||||
sub skAdd
|
||||
jr c, inputstrKeyInput
|
||||
cp skMath - skAdd + 1
|
||||
jr nc, inputstrKeyInput
|
||||
|
||||
bit Shift2nd, (IY + ShiftFlags) ; TIOS BASED
|
||||
call z, chartoascii
|
||||
call nz, charnumsymtoascii
|
||||
|
||||
call _PutC
|
||||
|
||||
ld (hl), a
|
||||
inc hl
|
||||
inc b
|
||||
|
||||
jr inputstrKeyInput
|
||||
inputstrKey2nd:
|
||||
push hl
|
||||
ld hl, Flags + ShiftFlags
|
||||
ld a, (hl)
|
||||
xor 1 << Shift2nd ; Toggle state of Shift2nd flag
|
||||
ld (hl), a
|
||||
pop hl
|
||||
jp inputstrKeyInput
|
||||
inputstrKeyDel:
|
||||
ld a, b
|
||||
cp 0
|
||||
jp z, inputstrKeyInput
|
||||
|
||||
ld a, ' '
|
||||
call _PutMap
|
||||
|
||||
push hl
|
||||
ld hl, CurCol
|
||||
ld a, (hl)
|
||||
dec (hl)
|
||||
pop hl
|
||||
|
||||
ld a, ' '
|
||||
call _PutMap
|
||||
|
||||
dec hl
|
||||
dec b
|
||||
jp inputstrKeyInput
|
||||
|
||||
inputstrKeyClear:
|
||||
ld a, b
|
||||
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
|
||||
pop de
|
||||
pop hl
|
||||
|
||||
ld a, ' '
|
||||
inc b
|
||||
inputstrKeyClearLoop:
|
||||
call _PutC
|
||||
djnz inputstrKeyClearLoop
|
||||
|
||||
push hl
|
||||
push de
|
||||
ld hl, inputstrCurColBuf
|
||||
ld de, CurCol
|
||||
call bytecpy
|
||||
pop de
|
||||
pop hl
|
||||
|
||||
ld hl, CurRow
|
||||
ld (hl), c
|
||||
pop hl
|
||||
push hl
|
||||
jp inputstrKeyInput
|
||||
|
||||
inputstrKeyEnter:
|
||||
ld (hl), 0
|
||||
call _CursorOff
|
||||
ld a, ' '
|
||||
call _PutMap
|
||||
pop hl
|
||||
pop de
|
||||
ret
|
||||
|
||||
inputstrFlags: .db %00000000
|
||||
; 0: num Flag
|
||||
inputstrSizeBuf: .dw $0000
|
||||
inputstrCurColBuf: .db $00
|
||||
|
||||
;;inputcharstr [Input, String]
|
||||
;;
|
||||
;;Inputs:
|
||||
;; HL: Destination
|
||||
;; D[E]: Buffer Size
|
||||
;;Ouptuts:
|
||||
;; (HL): String
|
||||
inputcharstr:
|
||||
push de
|
||||
push hl
|
||||
ld (inputcharstrSizeBuf), de
|
||||
push hl
|
||||
push de
|
||||
ld hl, CurCol
|
||||
ld de, inputcharstrCurColBuf
|
||||
call bytecpy
|
||||
pop de
|
||||
pop hl
|
||||
|
||||
call _CursorOn
|
||||
|
||||
xor a
|
||||
ld b, a
|
||||
|
||||
inputcharstrKeyInput:
|
||||
call cursorcurunderreset
|
||||
call inputgetkey
|
||||
|
||||
cp skDel
|
||||
jp z, inputcharstrKeyDel
|
||||
cp skClear
|
||||
jp z, inputcharstrKeyClear
|
||||
cp skEnter
|
||||
jp z, inputcharstrKeyEnter
|
||||
|
||||
ld c, a
|
||||
ld a, b
|
||||
push de
|
||||
ld de, (inputcharstrSizeBuf)
|
||||
cp e
|
||||
pop de
|
||||
jr z, inputcharstrKeyInput
|
||||
ld a, c
|
||||
|
||||
sub skAdd
|
||||
jr c, inputcharstrKeyInput
|
||||
cp skMath - skAdd + 1
|
||||
jr nc, inputcharstrKeyInput
|
||||
|
||||
call chartoascii
|
||||
|
||||
call _PutC
|
||||
|
||||
ld (hl), a
|
||||
inc hl
|
||||
inc b
|
||||
|
||||
jr inputcharstrKeyInput
|
||||
|
||||
inputcharstrKeyDel:
|
||||
ld a, b
|
||||
cp 0
|
||||
jp z, inputcharstrKeyInput
|
||||
|
||||
ld a, ' '
|
||||
call _PutMap
|
||||
|
||||
push hl
|
||||
ld hl, CurCol
|
||||
ld a, (hl)
|
||||
dec (hl)
|
||||
pop hl
|
||||
|
||||
ld a, ' '
|
||||
call _PutMap
|
||||
|
||||
dec hl
|
||||
dec b
|
||||
jp inputcharstrKeyInput
|
||||
|
||||
inputcharstrKeyClear:
|
||||
ld a, b
|
||||
cp 0
|
||||
jp z, inputcharstrKeyInput
|
||||
|
||||
push hl
|
||||
ld hl, CurRow
|
||||
ld c, (hl)
|
||||
pop hl
|
||||
|
||||
push hl
|
||||
push de
|
||||
ld hl, inputcharstrCurColBuf
|
||||
ld de, CurCol
|
||||
call bytecpy
|
||||
pop de
|
||||
pop hl
|
||||
|
||||
ld a, ' '
|
||||
inc b
|
||||
inputcharstrKeyClearLoop:
|
||||
call _PutC
|
||||
djnz inputcharstrKeyClearLoop
|
||||
|
||||
push hl
|
||||
push de
|
||||
ld hl, inputcharstrCurColBuf
|
||||
ld de, CurCol
|
||||
call bytecpy
|
||||
pop de
|
||||
pop hl
|
||||
|
||||
ld hl, CurRow
|
||||
ld (hl), c
|
||||
pop hl
|
||||
push hl
|
||||
jp inputcharstrKeyInput
|
||||
|
||||
inputcharstrKeyEnter:
|
||||
ld (hl), 0
|
||||
call _CursorOff
|
||||
ld a, ' '
|
||||
call _PutMap
|
||||
pop hl
|
||||
pop de
|
||||
ret
|
||||
|
||||
inputcharstrSizeBuf: .dw $0000
|
||||
inputcharstrCurColBuf: .db $00
|
||||
|
||||
;;inputnumstr [Input, String]
|
||||
;;
|
||||
;;Inputs:
|
||||
;; HL: Destination
|
||||
;; D[E]: Buffer Size
|
||||
;;Ouptuts:
|
||||
;; (HL): String
|
||||
inputnumstr:
|
||||
push de
|
||||
push hl
|
||||
ld (inputnumstrSizeBuf), de
|
||||
push hl
|
||||
push de
|
||||
ld hl, CurCol
|
||||
ld de, inputnumstrCurColBuf
|
||||
call bytecpy
|
||||
pop de
|
||||
pop hl
|
||||
|
||||
call _CursorOn
|
||||
|
||||
xor a
|
||||
ld b, a
|
||||
|
||||
inputnumstrKeyInput:
|
||||
call cursorcurunderreset
|
||||
call inputgetkey
|
||||
|
||||
cp skDel
|
||||
jp z, inputnumstrKeyDel
|
||||
cp skClear
|
||||
jp z, inputnumstrKeyClear
|
||||
cp skEnter
|
||||
jp z, inputnumstrKeyEnter
|
||||
|
||||
ld c, a
|
||||
ld a, b
|
||||
push de
|
||||
ld de, (inputnumstrSizeBuf)
|
||||
cp e
|
||||
pop de
|
||||
jr z, inputnumstrKeyInput
|
||||
ld a, c
|
||||
|
||||
sub skAdd
|
||||
jr c, inputnumstrKeyInput
|
||||
cp skMath - skAdd + 1
|
||||
jr nc, inputnumstrKeyInput
|
||||
|
||||
call charnumtoascii
|
||||
cp $FF
|
||||
jr z, inputnumstrKeyInput
|
||||
|
||||
call _PutC
|
||||
|
||||
ld (hl), a
|
||||
inc hl
|
||||
inc b
|
||||
|
||||
jr inputnumstrKeyInput
|
||||
|
||||
inputnumstrKeyDel:
|
||||
ld a, b
|
||||
cp 0
|
||||
jp z, inputnumstrKeyInput
|
||||
|
||||
ld a, ' '
|
||||
call _PutMap
|
||||
|
||||
push hl
|
||||
ld hl, CurCol
|
||||
ld a, (hl)
|
||||
dec (hl)
|
||||
pop hl
|
||||
|
||||
ld a, ' '
|
||||
call _PutMap
|
||||
|
||||
dec hl
|
||||
dec b
|
||||
jp inputnumstrKeyInput
|
||||
|
||||
inputnumstrKeyClear:
|
||||
ld a, b
|
||||
cp 0
|
||||
jp z, inputnumstrKeyInput
|
||||
|
||||
push hl
|
||||
ld hl, CurRow
|
||||
ld c, (hl)
|
||||
pop hl
|
||||
|
||||
push hl
|
||||
push de
|
||||
ld hl, inputnumstrCurColBuf
|
||||
ld de, CurCol
|
||||
call bytecpy
|
||||
pop de
|
||||
pop hl
|
||||
|
||||
ld a, ' '
|
||||
inc b
|
||||
inputnumstrKeyClearLoop:
|
||||
call _PutC
|
||||
djnz inputnumstrKeyClearLoop
|
||||
|
||||
push hl
|
||||
push de
|
||||
ld hl, inputnumstrCurColBuf
|
||||
ld de, CurCol
|
||||
call bytecpy
|
||||
pop de
|
||||
pop hl
|
||||
|
||||
ld hl, CurRow
|
||||
ld (hl), c
|
||||
pop hl
|
||||
push hl
|
||||
jp inputnumstrKeyInput
|
||||
|
||||
inputnumstrKeyEnter:
|
||||
ld (hl), 0
|
||||
call _CursorOff
|
||||
ld a, ' '
|
||||
call _PutMap
|
||||
pop hl
|
||||
pop de
|
||||
ret
|
||||
|
||||
inputnumstrSizeBuf: .dw $0000
|
||||
inputnumstrCurColBuf: .db $00
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
;; 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
|
||||
|
||||
;; mul8By8 [Maths]
|
||||
;; Performs an unsigned multiplication of H and E
|
||||
;; Inputs:
|
||||
;; H: Multiplier
|
||||
;; E: Multiplicand
|
||||
;; Outputs:
|
||||
;; HL: Product of H and E.
|
||||
mul8By8:
|
||||
push de
|
||||
ld l, 0
|
||||
ld d, l
|
||||
|
||||
sla h
|
||||
jr nc, $ + 3
|
||||
ld l, e
|
||||
|
||||
add hl, hl
|
||||
jr nc, $ + 3
|
||||
add hl, de
|
||||
add hl, hl
|
||||
jr nc, $ + 3
|
||||
add hl, de
|
||||
add hl, hl
|
||||
jr nc, $ + 3
|
||||
add hl, de
|
||||
add hl, hl
|
||||
jr nc, $ + 3
|
||||
add hl, de
|
||||
add hl, hl
|
||||
jr nc, $ + 3
|
||||
add hl, de
|
||||
add hl, hl
|
||||
jr nc, $ + 3
|
||||
add hl, de
|
||||
add hl, hl
|
||||
jr nc, $ + 3
|
||||
add hl, hl
|
||||
jr nc, $ + 3
|
||||
add hl, de
|
||||
add hl, de
|
||||
|
||||
pop de
|
||||
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
|
||||
|
||||
|
|
@ -0,0 +1,224 @@
|
|||
;; strlen [Strings]
|
||||
;; 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
|
||||
|
||||
;; 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:
|
||||
push hl
|
||||
push de
|
||||
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
|
||||
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.
|
||||
strcpy:
|
||||
push de
|
||||
push hl
|
||||
ex de, hl
|
||||
_: ld a, (de)
|
||||
ld (hl), a
|
||||
or a
|
||||
jr z, _
|
||||
inc hl \ inc de
|
||||
jr -_
|
||||
_: 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:
|
||||
strchrLoop:
|
||||
ld a, (hl)
|
||||
or a
|
||||
jr z, strchrNoCharFound
|
||||
cp b
|
||||
ret z
|
||||
inc hl
|
||||
jr strchrLoop
|
||||
strchrNoCharFound:
|
||||
inc a
|
||||
ret
|
||||
|
||||
;; strtob
|
||||
;; Converts a string to a byte
|
||||
;; Inputs:
|
||||
;; HL: string pointer
|
||||
;; Outputs:
|
||||
;; A: byte
|
||||
strtob:
|
||||
push bc
|
||||
push de
|
||||
strtobNumFind:
|
||||
ld a, (hl)
|
||||
cp $00
|
||||
jp z, strtobEXIT
|
||||
ld c, 0
|
||||
sub '1'
|
||||
cp '9' + 1
|
||||
jr c, strtobNumWhile
|
||||
inc hl
|
||||
jr strtobNumFind
|
||||
strtobNumWhile:
|
||||
push hl
|
||||
strtobNumWhileLoop:
|
||||
ld a, c
|
||||
cp 3
|
||||
jp nc, strtobConvert
|
||||
ld a, (hl)
|
||||
sub '0' - 1
|
||||
jr c, strtobConvert
|
||||
cp '9' + 1
|
||||
jr nc, strtobConvert
|
||||
inc hl
|
||||
inc c
|
||||
jr strtobNumWhileLoop
|
||||
strtobConvert:
|
||||
dec hl
|
||||
ld a, (hl)
|
||||
sub '0'
|
||||
ld c, a
|
||||
dec hl
|
||||
pop de
|
||||
call cpHLDE
|
||||
jp c, strtobExit
|
||||
ld a, (hl)
|
||||
sub '0'
|
||||
ld b, 10
|
||||
call mulAbyB
|
||||
add a, c
|
||||
ld c, a
|
||||
dec hl
|
||||
call cpHLDE
|
||||
jp c, strtobExit
|
||||
ld a, (hl)
|
||||
sub '0'
|
||||
ld b, 100
|
||||
call mulAbyB
|
||||
add a, c
|
||||
ld c, a
|
||||
strtobExit:
|
||||
ld a, c
|
||||
pop de
|
||||
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:
|
||||
; push af \ push hl
|
||||
; ld a, (hl)
|
||||
; or a
|
||||
; jr z, toLowerExit
|
||||
; call isAlphaNum
|
||||
; jr nc, toLowerNotUpperAlpha
|
||||
; cp 'a'
|
||||
; jr nc, toLowerNotUpperAlpha
|
||||
; add a, 'a' - 'A'
|
||||
; ld (hl), a
|
||||
;toLowerNotUpperAlpha:
|
||||
; inc hl
|
||||
; jr toLower + 2
|
||||
;toLowerExit:
|
||||
; 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:
|
||||
; push af \ push hl
|
||||
; ld a, (hl)
|
||||
; or a
|
||||
; jr z, toUpperExit
|
||||
; call isAlphaNum
|
||||
; jr nc, toUpperNotLowerAlpha
|
||||
; cp 'a'
|
||||
; jr c, toUpperNotLowerAlpha
|
||||
; sub 'a' - 'A'
|
||||
; ld (hl), a
|
||||
;toUpperNotLowerAlpha:
|
||||
; inc hl
|
||||
; jr toUpper + 2
|
||||
;toUpperExit:
|
||||
; pop hl \ pop af
|
||||
; ret
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
;; THIS FILE HOLDS SMALL (byte) BUFFERS
|
||||
;; DONT TOUCH
|
||||
CurColBuf:
|
||||
.DB $00
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
#include "includes/commands/EXIT.asm"
|
||||
#include "includes/commands/SET.asm"
|
||||
#include "includes/commands/CLS.asm"
|
||||
#include "includes/commands/VARS.asm"
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
fshcmdCLS: .db "CLS", 0
|
||||
fshcmdCLSo: .db $10
|
||||
fshcmdCLSu: .db "Clears the screen", 0
|
||||
fshcmdCLSf:
|
||||
CALL _ClrLCDFull
|
||||
XOR A
|
||||
LD (CurRow), A
|
||||
LD (CurCol), A
|
||||
JP Fin
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
fshcmdEXIT: .db "EXIT", 0
|
||||
fshcmdEXITo: .db $FF
|
||||
fshcmdEXITu: .db "Exits Fsh", 0
|
||||
fshcmdEXITf: JP Cleanup
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
fshcmdSET: .db "SET", 0
|
||||
fshcmdSETo: .db $01
|
||||
fshcmdSETu: .db "Sets a value in FSH memory", 0
|
||||
fshcmdSETf:
|
||||
xor a
|
||||
ld (CurCol), a
|
||||
ld hl, fshcmdSETfDIndex
|
||||
call _PutS
|
||||
ld hl, fshcmdSETfInputBuffer
|
||||
ld de, 3
|
||||
call inputnumstr
|
||||
call strtob
|
||||
ld de, 0
|
||||
ld e, a
|
||||
push de
|
||||
call _NewLine
|
||||
xor a
|
||||
ld (CurCol), a
|
||||
ld hl, fshcmdSETfDValue
|
||||
call _PutS
|
||||
ld hl, fshcmdSETfInputBuffer
|
||||
ld de, 3
|
||||
call inputnumstr
|
||||
call strtob
|
||||
pop de
|
||||
ld hl, 0
|
||||
ld l, a
|
||||
call fshvarset
|
||||
call _NewLine
|
||||
jp Fin
|
||||
|
||||
fshcmdSETfInputBuffer: .db $00,$00,$00,$00
|
||||
fshcmdSETfDIndex: .db "Index= ", 0
|
||||
fshcmdSETfDValue: .db "Value= ", 0
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
fshcmdVARS: .db "VARS", 0
|
||||
fshcmdVARSo: .db $12
|
||||
fshcmdVARSu: .db "Displays all Fsh Vars", 0
|
||||
fshcmdVARSf:
|
||||
ld b, 0
|
||||
ld de, 0
|
||||
fshcmdVARSfLoop:
|
||||
call fshvarget
|
||||
ld a, h
|
||||
call _PutC
|
||||
ld a, l
|
||||
call _PutC
|
||||
ld a, '_'
|
||||
call _PutC
|
||||
inc b
|
||||
inc de
|
||||
ld a, b
|
||||
cp FshVarsSize / 2
|
||||
jr c, fshcmdVARSfLoop
|
||||
call _NewLine
|
||||
jp Fin
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
.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 16 ;16 bytes | 8 chars | 8 meta
|
||||
#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
|
||||
|
||||
FshCmdMeta equ FshCmd + FshCmdInptSize
|
||||
FshCmdOP equ FshCmdMeta + 1
|
||||
FshCmdArg1 equ FshCmdMeta + 2
|
||||
FshCmdArg2 equ FshCmdMeta + 3
|
||||
FshCmdArg3 equ FshCmdMeta + 4
|
||||
FshCmdArg4 equ FshCmdMeta + 5
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
charMapCSC:
|
||||
.DB 0, "WRMH", 0, 0
|
||||
.DB Lquestion, Ltheta, "VQLG", 0, 0
|
||||
.DB ":ZUPKFC", 0
|
||||
.DB " YTOJEB",0
|
||||
.DB 0, "XSNIDA"
|
||||
|
||||
numsymMapCSC
|
||||
.DB "+-*/^", $FF, $FF
|
||||
.DB "_369)", $C1, "]", $FF
|
||||
.DB ".258({};"
|
||||
.DB "0147, <>|", $FF
|
||||
.DB $05, "!@#%&"
|
||||
|
||||
numMapCSC
|
||||
.DB $FF, $FF, $FF, $FF, $FF, $FF, $FF
|
||||
.DB $FF, "369", $FF, $FF, $FF, $FF
|
||||
.DB $FF, "258", $FF, $FF, $FF, $FF
|
||||
.DB "0147", $FF, $FF, $FF, $FF, $FF, $FF
|
||||
.DB $FF, $FF, $FF, $FF, $FF, $FF
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
CharMapKey:
|
||||
.DB 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue