mirror of
https://github.com/romychs/ESPKit.git
synced 2025-04-18 01:52:41 +03:00
circular buffer first impl
This commit is contained in:
parent
07f504579d
commit
2d74d03448
32
sources/DSS/.vscode/tasks.json
vendored
32
sources/DSS/.vscode/tasks.json
vendored
@ -25,7 +25,7 @@
|
||||
},
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
"isDefault": false
|
||||
}
|
||||
},
|
||||
|
||||
@ -56,7 +56,35 @@
|
||||
"isDefault": true
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
"label": "make ISA-TEST (sjasmplus)",
|
||||
"type": "shell",
|
||||
"command": "sjasmplus",
|
||||
"args": [
|
||||
"--sld=isa-test.sld",
|
||||
"--sym=isa-test.labels",
|
||||
"--raw=isa-test.exe",
|
||||
"--fullpath",
|
||||
"isa-test.asm"
|
||||
],
|
||||
"problemMatcher": {
|
||||
"owner": "sjasmplus",
|
||||
"fileLocation": "autoDetect",
|
||||
"pattern": {
|
||||
"regexp": "^(.*)\\((\\d+)\\):\\s+(warning|error):\\s+(.*)$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"severity": 3,
|
||||
"message": 4
|
||||
}
|
||||
},
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": false
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"label": "start mame",
|
||||
"type": "shell",
|
||||
|
189
sources/DSS/buffer.asm
Normal file
189
sources/DSS/buffer.asm
Normal file
@ -0,0 +1,189 @@
|
||||
; ======================================================
|
||||
; Circular buffer implementation
|
||||
; By Roman Boykov. Copyright (c) 2024
|
||||
; https://github.com/romychs
|
||||
; ======================================================
|
||||
|
||||
MODULE BUFFER
|
||||
|
||||
SIZE_MASK EQU 0x1FFF
|
||||
|
||||
; ------------------------------------------------------
|
||||
; Init circular buffer before use
|
||||
; Reset pointers and allocate memory
|
||||
; ------------------------------------------------------
|
||||
INIT
|
||||
; reset buffer pointers
|
||||
LD HL,0x0000
|
||||
LD (PTR_SET), HL
|
||||
LD (PTR_GET), HL
|
||||
|
||||
DI
|
||||
IN A,(PAGE_1)
|
||||
LD (SAVE_P1), A
|
||||
|
||||
; request one 16k page
|
||||
LD B,1
|
||||
DSS_EXEC DSS_GETMEM
|
||||
JR C,MAL_ERROR
|
||||
; save handler
|
||||
LD (MEMHND),A
|
||||
; map allocated mem to p1
|
||||
LD HL,PAGE1_ADDR
|
||||
LD B,0
|
||||
LD A,(MEMHND)
|
||||
DSS_EXEC DSS_SETMEM
|
||||
JR C,MAL_ERROR
|
||||
;LD (SAVE_P1),A
|
||||
RET
|
||||
|
||||
MAL_ERROR
|
||||
LD DE,MSG_MAL_VAL
|
||||
LD C, A
|
||||
CALL UTIL.HEXB
|
||||
|
||||
MSG_MAL
|
||||
DB "Memory allocation error: 0x"
|
||||
MSG_MAL_VAL
|
||||
DB "xx",0
|
||||
|
||||
; ------------------------------------------------------
|
||||
; Deallocate memory, allocated by INIT. Call this before
|
||||
; exit to DSS
|
||||
; ------------------------------------------------------
|
||||
FREE
|
||||
; free allocated memory
|
||||
LD A,(MEMHND)
|
||||
CP 0xFF
|
||||
JR Z, NO_MA
|
||||
DSS_EXEC DSS_FREEMEM
|
||||
NO_MA
|
||||
; restore page
|
||||
LD A,(SAVE_P1)
|
||||
CP 0xFF
|
||||
JR Z, NO_PA
|
||||
OUT (PAGE_1),A
|
||||
NO_PA
|
||||
RET
|
||||
|
||||
; ------------------------------------------------------
|
||||
; PUT Data to buffer
|
||||
; Inp: C - byte to place
|
||||
; Out: CF=1 if no space
|
||||
; ------------------------------------------------------
|
||||
PUT
|
||||
PUSH HL,DE
|
||||
LD HL,(PTR_HEAD_P)
|
||||
LD DE,(PTR_TAIL)
|
||||
LD A,L
|
||||
CP E
|
||||
JP NZ, P_NOTF
|
||||
LD A, H
|
||||
CP D
|
||||
JP NZ, P_NOTF
|
||||
SCF
|
||||
JR P_RET
|
||||
P_NOTF
|
||||
; put value to buffer
|
||||
OR D,0x40 ; p1
|
||||
LD (DE),C
|
||||
; increment and wrap tail ptr
|
||||
INC DE
|
||||
LD A, D
|
||||
AND 0x1F
|
||||
LD D, A
|
||||
LD (PTR_TAIL), DE
|
||||
P_RET
|
||||
POP DE,HL
|
||||
RET
|
||||
|
||||
; ------------------------------------------------------
|
||||
; GET Data from buffer
|
||||
; Out: CF=1 if empty
|
||||
; else A - byte from buffer
|
||||
; ------------------------------------------------------
|
||||
GET
|
||||
PUSH HL,DE
|
||||
LD HL,(PTR_HEAD)
|
||||
LD DE,(PTR_TAIL)
|
||||
LD A,L
|
||||
CP E
|
||||
JP NZ, G_NOTE
|
||||
LD A, H
|
||||
CP D
|
||||
JP NZ, G_NOTE
|
||||
SCF
|
||||
JR G_RET
|
||||
G_NOTE
|
||||
; store previous head ptr
|
||||
LD (PTR_HEAD_P), HL
|
||||
; get value
|
||||
LD A,H
|
||||
OR 0x40
|
||||
LD H,A
|
||||
LD C, (HL)
|
||||
; inc and wrap head ptr
|
||||
INC HL
|
||||
LD A, H
|
||||
AND 0x1F
|
||||
LD H, A
|
||||
LD (PTR_HEAD), HL
|
||||
G_RET
|
||||
POP DE,HL
|
||||
RET
|
||||
|
||||
; ------------------------------------------------------
|
||||
; Check buffer is full
|
||||
; Out: CF=1 if full
|
||||
; ------------------------------------------------------
|
||||
IS_FULL
|
||||
PUSH HL,DE
|
||||
LD HL,(PTR_HEAD_P)
|
||||
LD DE,(PTR_TAIL)
|
||||
SBC HL,DE
|
||||
JP NZ, ISF_NOTF
|
||||
SCF
|
||||
JR ISF_RET
|
||||
ISF_NOTF
|
||||
AND A
|
||||
ISF_RET
|
||||
POP DE,HL
|
||||
RET
|
||||
|
||||
; ------------------------------------------------------
|
||||
; Check buffer is empty
|
||||
; Out: CF=1 if empty
|
||||
; ------------------------------------------------------
|
||||
IS_EMPTY
|
||||
PUSH HL,DE
|
||||
LD HL,(PTR_HEAD)
|
||||
LD DE,(PTR_TAIL)
|
||||
SBC HL,DE
|
||||
JR NZ, ISF_NOTF
|
||||
SCF
|
||||
JR ISF_RET
|
||||
|
||||
; buffer set position
|
||||
PTR_TAIL
|
||||
DW 0x0000
|
||||
|
||||
; buffer get position
|
||||
PTR_HEAD
|
||||
DW 0x0000
|
||||
|
||||
; buffer previous head position
|
||||
PTR_HEAD_P
|
||||
DW 0x0000
|
||||
|
||||
; habler for allocated memory
|
||||
MEMHND
|
||||
DB 0xFF
|
||||
|
||||
; storage for old mem page
|
||||
SAVE_P1
|
||||
DB 0xFF
|
||||
|
||||
ORG 0x5000
|
||||
RX_BUFFER
|
||||
|
||||
ENDMODULE
|
@ -21,7 +21,10 @@ DSS_MKDIR EQU 0x1B
|
||||
DSS_CHDIR EQU 0x1D
|
||||
DSS_CURDIR EQU 0x1E
|
||||
DSS_SCANKEY EQU 0x31
|
||||
DSS_ECHOKEY EQU 0x32
|
||||
DSS_ECHOKEY EQU 0x32
|
||||
DSS_SETMEM EQU 0x38
|
||||
DSS_GETMEM EQU 0x3D
|
||||
DSS_FREEMEM EQU 0x3E
|
||||
DSS_EXIT EQU 0x41
|
||||
DSS_WAITKEY EQU 0x48
|
||||
DSS_SETVMOD EQU 0x50
|
||||
@ -50,3 +53,5 @@ KB_ALT EQU 0x10
|
||||
KB_CTRL EQU 0x20
|
||||
KB_R_SHIFT EQU 0x40
|
||||
KB_L_SHIFT EQU 0x80
|
||||
|
||||
|
||||
|
135
sources/DSS/isa-test.asm
Normal file
135
sources/DSS/isa-test.asm
Normal file
@ -0,0 +1,135 @@
|
||||
; ======================================================
|
||||
; ISA-Test to test ISA-Bus
|
||||
; For Sprinter computer DSS
|
||||
; By Roman Boykov. Copyright (c) 2024
|
||||
; https://github.com/romychs
|
||||
; License: BSD 3-Clause
|
||||
; ======================================================
|
||||
|
||||
; Set to 1 to turn debug ON with DeZog VSCode plugin
|
||||
; Set to 0 to compile .EXE
|
||||
DEBUG EQU 0
|
||||
|
||||
; Set to 1 to output TRACE messages
|
||||
TRACE EQU 1
|
||||
|
||||
; Version of EXE file, 1 for DSS 1.70+
|
||||
EXE_VERSION EQU 0
|
||||
|
||||
; Timeout to wait ESP response
|
||||
DEFAULT_TIMEOUT EQU 2000
|
||||
|
||||
SLDOPT COMMENT WPMEM, LOGPOINT, ASSERTION
|
||||
|
||||
DEVICE NOSLOT64K
|
||||
|
||||
INCLUDE "macro.inc"
|
||||
INCLUDE "dss.inc"
|
||||
INCLUDE "sprinter.inc"
|
||||
|
||||
MODULE MAIN
|
||||
|
||||
ORG 0x8080
|
||||
; ------------------------------------------------------
|
||||
EXE_HEADER
|
||||
DB "EXE"
|
||||
DB EXE_VERSION ; EXE Version
|
||||
DW 0x0080 ; Code offset
|
||||
DW 0
|
||||
DW 0 ; Primary loader size
|
||||
DW 0 ; Reserved
|
||||
DW 0
|
||||
DW 0
|
||||
DW START ; Loading Address
|
||||
DW START ; Entry Point
|
||||
DW STACK_TOP ; Stack address
|
||||
DS 106, 0 ; Reserved
|
||||
|
||||
ORG 0x8100
|
||||
@STACK_TOP
|
||||
|
||||
; ------------------------------------------------------
|
||||
START
|
||||
|
||||
IF DEBUG == 1
|
||||
; LD IX,CMD_LINE1
|
||||
LD SP, STACK_TOP
|
||||
JP MAIN_LOOP
|
||||
ENDIF
|
||||
|
||||
|
||||
PRINTLN MSG_START
|
||||
|
||||
|
||||
XOR A
|
||||
LD (ISA.ISA_SLOT),A
|
||||
|
||||
CALL ISA.ISA_OPEN
|
||||
|
||||
; --------- IOW/IOR/A0-A7/D0-D7 --------------
|
||||
; LD D,0
|
||||
; L_DATA
|
||||
; LD HL, PORT_UART_A
|
||||
; LD B,0x08
|
||||
; L_PORT
|
||||
; LD (HL), D
|
||||
; LD E,(HL)
|
||||
; INC HL
|
||||
; DJNZ L_PORT
|
||||
; INC D
|
||||
|
||||
CALL ISA.ISA_OPEN
|
||||
LD HL, PORT_UART_A
|
||||
LD D,0x55
|
||||
L_AGAIN
|
||||
.1000 LD (HL), D
|
||||
.1000 LD D,(HL)
|
||||
JP L_AGAIN
|
||||
|
||||
; --------- RESET & AEN --------------
|
||||
; LD BC, PORT_ISA
|
||||
; LD A,ISA_RST | ISA_AEN ; RESET=1 AEN=1
|
||||
; OUT (C), A
|
||||
; CALL UTIL.DELAY_100uS
|
||||
; XOR A
|
||||
; OUT (C), A ; RESET=0 AEN=0
|
||||
|
||||
;JR L_DATA
|
||||
|
||||
; XOR A
|
||||
; LD (Q_POS),A
|
||||
|
||||
MAIN_LOOP
|
||||
|
||||
|
||||
; ------------------------------------------------------
|
||||
; Do Some
|
||||
; ------------------------------------------------------
|
||||
|
||||
OK_EXIT
|
||||
LD B,0
|
||||
JP WCOMMON.EXIT
|
||||
|
||||
|
||||
; ------------------------------------------------------
|
||||
; Custom messages
|
||||
; ------------------------------------------------------
|
||||
|
||||
MSG_START
|
||||
DB "ISA test for ISA-BUS by Sprinter Team. v1.0.b1, ", __DATE__, "\r\n", 0
|
||||
|
||||
MSG_EXIT
|
||||
DB "Bue!",0
|
||||
|
||||
; ------------------------------------------------------
|
||||
; Custom commands
|
||||
; ------------------------------------------------------
|
||||
|
||||
ENDMODULE
|
||||
|
||||
INCLUDE "wcommon.asm"
|
||||
INCLUDE "util.asm"
|
||||
INCLUDE "isa.asm"
|
||||
INCLUDE "esplib.asm"
|
||||
|
||||
END MAIN.START
|
@ -48,7 +48,7 @@ ISA_OPEN
|
||||
LD BC, PORT_SYSTEM
|
||||
LD A, 0x11
|
||||
OUT (C), A
|
||||
ISA_SLOT+* LD A,0x01
|
||||
ISA_SLOT+* LD A,0x00
|
||||
SLA A
|
||||
OR A, 0xD4 ; D4 - ISA1, D6 - ISA2
|
||||
LD BC, PAGE3
|
||||
|
@ -37,3 +37,13 @@
|
||||
POP DE,BC
|
||||
ENDIF
|
||||
ENDM
|
||||
|
||||
; Execute specified DSS function
|
||||
MACRO DSS_EXEC func
|
||||
IF func>255
|
||||
LD BC,func
|
||||
ELSE
|
||||
LD C,func
|
||||
ENDIF
|
||||
RST DSS
|
||||
ENDM
|
@ -193,6 +193,7 @@ MSG_SLOT_NO
|
||||
|
||||
MSG_COMM_ERROR
|
||||
DB "Error communication with Sprinter-WiFi #"
|
||||
|
||||
COMM_ERROR_NO
|
||||
DB "n!",0
|
||||
|
||||
|
@ -84,37 +84,17 @@ START
|
||||
|
||||
CALL WIFI.UART_EMPTY_RS
|
||||
|
||||
; XOR A
|
||||
; LD (Q_POS),A
|
||||
|
||||
MAIN_LOOP
|
||||
; handle key pressed
|
||||
LD C,DSS_SCANKEY
|
||||
RST DSS
|
||||
JP Z,HANDLE_RECEIVE ; if no key pressed
|
||||
|
||||
; Check for Alt+x
|
||||
; IF TRACE
|
||||
; LD D,A
|
||||
; LD A,B
|
||||
; AND KB_ALT
|
||||
; JP Z, NO_QUIT
|
||||
; LD C,D
|
||||
; PUSH BC,DE,HL
|
||||
; LD DE, MSG_ALT_KEY
|
||||
; CALL UTIL.HEXB
|
||||
; PRINTLN MSG_ALT
|
||||
; POP HL,DE,BC
|
||||
|
||||
; ELSE
|
||||
LD A,D
|
||||
;AND 0xDF
|
||||
CP 0xAB
|
||||
JR NZ, NO_QUIT
|
||||
LD A,B
|
||||
AND KB_ALT
|
||||
JP NZ, OK_EXIT
|
||||
;ENDIF
|
||||
|
||||
NO_QUIT
|
||||
|
||||
@ -167,9 +147,11 @@ HANDLE_RECEIVE
|
||||
CALL PUT_A_CHAR
|
||||
JP CHECK_FOR_END
|
||||
|
||||
; check for printable symbol, and print
|
||||
CHK_1F
|
||||
CP 0x20
|
||||
CALL P, PUT_A_CHAR
|
||||
|
||||
; reset error counter if received symbol withoud error
|
||||
XOR A
|
||||
LD (RX_ERR),A
|
||||
@ -178,8 +160,6 @@ CHECK_FOR_END
|
||||
; LD A,(Q_POS)
|
||||
; CP 5
|
||||
; JP Z, OK_EXIT
|
||||
|
||||
|
||||
JP MAIN_LOOP
|
||||
|
||||
RX_WARN
|
||||
@ -211,7 +191,6 @@ PUT_A_CHAR
|
||||
POP DE,BC
|
||||
RET
|
||||
|
||||
|
||||
; ------------------------------------------------------
|
||||
; Do Some
|
||||
; ------------------------------------------------------
|
||||
@ -226,27 +205,27 @@ OK_EXIT
|
||||
; ------------------------------------------------------
|
||||
|
||||
MSG_START
|
||||
DB "Terminal for Sprinter-WiFi by Sprinter Team. v1.0 beta2, ", __DATE__, "\r\n", 0
|
||||
DB "Terminal for Sprinter-WiFi by Sprinter Team. v1.0 beta3, ", __DATE__, "\r\n"Z
|
||||
MSG_HLP
|
||||
DB"\r\nEnter ESP AT command or Alt+x to close terminal.",0
|
||||
DB"\r\nEnter ESP AT command or Alt+x to close terminal."Z
|
||||
MSG_EXIT
|
||||
|
||||
MSG_TX_ERROR
|
||||
DB "Transmitter not ready",0
|
||||
DB "Transmitter not ready"Z
|
||||
|
||||
MSG_RX_ERROR
|
||||
DB "Receiver error LSR: 0x"
|
||||
MSG_LSR_VALUE
|
||||
DB "xx",0
|
||||
DB "xx"Z
|
||||
|
||||
MSG_MANY_RX_ERROR
|
||||
DB "Too many receiver errors!",0
|
||||
DB "Too many receiver errors!"Z
|
||||
|
||||
|
||||
MSG_ALT
|
||||
DB "Pressed ALT+"
|
||||
MSG_ALT_KEY
|
||||
DB "xx",0
|
||||
DB "xx"Z
|
||||
|
||||
; TX_DATA
|
||||
; DB " ",0
|
||||
@ -254,13 +233,13 @@ MSG_ALT_KEY
|
||||
; Custom commands
|
||||
; ------------------------------------------------------
|
||||
CMD_QUIT
|
||||
DB "QUIT\r",0
|
||||
DB "QUIT\r"Z
|
||||
|
||||
RX_ERR
|
||||
DB 0
|
||||
|
||||
IF DEBUG == 1
|
||||
CMD_TEST1 DB "ATE0\r\n",0
|
||||
CMD_TEST1 DB "ATE0\r\n"Z
|
||||
BUFF_TEST1 DS RS_BUFF_SIZE,0
|
||||
ENDIF
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user