diff --git a/Tester/dss.inc b/Tester/dss.inc new file mode 100644 index 0000000..14f4569 --- /dev/null +++ b/Tester/dss.inc @@ -0,0 +1,74 @@ +; ====================================================== +; Defines for DSS Estex for Sprinter computer +; By Roman Boykov. Copyright (c) 2024 +; https://github.com/romychs +; ====================================================== + + IFNDEF _DSS_INC + DEFINE _DSS_INC + +; DSS RST Entry +DSS EQU 0x10 + +; DSS Functions +DSS_CURDISK EQU 0x02 +DSS_CREATE_FILE EQU 0x0B +DSS_OPEN_FILE EQU 0x11 +DSS_CLOSE_FILE EQU 0x12 +DSS_READ_FILE EQU 0x13 +DSS_WRITE EQU 0x14 +DSS_MOVE_FP_CP EQU 0x0115 +DSS_FIND_FIRST EQU 0x0119 +DSS_FIND_NEXT EQU 0x011A +DSS_MKDIR EQU 0x1B +DSS_CHDIR EQU 0x1D +DSS_CURDIR EQU 0x1E +DSS_SCANKEY EQU 0x31 +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 +DSS_GETVMOD EQU 0x51 +DSS_CLEAR EQU 0x56 +DSS_PUTCHAR EQU 0x5B +DSS_PCHARS EQU 0x5C + + +DSS_VMOD_T40 EQU 0x02 ; text 40x32, 16 colors +DSS_VMOD_T80 EQU 0x03 ; text 80x32, 16 colors +DSS_VMOD_G320 EQU 0x81 ; graphics 320x256, 256 colors +DSS_VMOD_G640 EQU 0x82 ; graphics 640x256, 16 colors + + +; DSS Error codes +E_FILE_EXISTS EQU 7 +E_FILE_NOT_FOUND EQU 3 + +; Keyboard Shift key status bits +KB_R_ALT EQU 0x01 +KB_R_CTRL EQU 0x02 +KB_L_ALT EQU 0x04 +KB_L_CTRL EQU 0x08 +KB_ALT EQU 0x10 +KB_CTRL EQU 0x20 +KB_R_SHIFT EQU 0x40 +KB_L_SHIFT EQU 0x80 + + +; File attributes +FA_READONLY EQU 0x01 +FA_HIDDEN EQU 0x02 +FA_SYSTEM EQU 0x04 +FA_LABEL EQU 0x08 +FA_DIRECTORY EQU 0x10 +FA_ARCHIVE EQU 0x20 + +; File Access mode +FM_READ_WRITE EQU 0x00 +FM_READ EQU 0x01 +FM_WRITE EQU 0x02 + + ENDIF diff --git a/Tester/ftlib.asm b/Tester/ftlib.asm new file mode 100644 index 0000000..bdb3077 --- /dev/null +++ b/Tester/ftlib.asm @@ -0,0 +1,72 @@ +; ====================================================== +; Library for Sprinter-FT ISA Card +; By Roman Boykov. Copyright (c) 2025 +; https://github.com/romychs +; License: BSD 3-Clause +; ====================================================== + + IFNDEF _FT_LIB + DEFINE _FT_LIB + + + INCLUDE "isa.asm" + INCLUDE "util.asm" + + +FT_CTRL EQU 0x77 +FT_DATA EQU 0x57 + +PORT_FT_CTRL EQU ISA_BASE_A + FT_CTRL ; Memory address to read Strinter-FT Control port +PORT_FT_DATA EQU ISA_BASE_A + FT_DATA ; Memory address to read Strinter-FT Data port + + MODULE FT + +; ------------------------------------------------------ +; Reset ESP module +; ------------------------------------------------------ + +FT_RESET + PUSH AF,HL + + CALL ISA.ISA_OPEN + +; TODO: FT Init code here + + CALL ISA.ISA_CLOSE + + ; wait 2s for ESP firmware boot + LD HL,2000 + CALL UTIL.DELAY + + POP HL,AF + RET + +; ------------------------------------------------------ +; Check ISA slots for Sprinter-FT card +; Out: CF if no card found +; (ISA.ISA_SLOT) = slot no 0 - ISA1, 1-ISA2 +; ------------------------------------------------------ +FT_FIND + PUSH BC, HL + + XOR A + LD B,2 + LD (ISA.ISA_SLOT),A + +.FT_CHK_SLOT: + CALL ISA.ISA_OPEN + LD A, (PORT_FT_CTRL) + CALL ISA.ISA_CLOSE + CP 0xFC + JR Z, .FT_FOUND + LD HL, ISA.ISA_SLOT + INC (HL) + DJNZ .FT_CHK_SLOT + SCF +.FT_FOUND + POP HL, BC + RET + + ENDMODULE + + ENDIF diff --git a/Tester/ftt.asm b/Tester/ftt.asm new file mode 100644 index 0000000..ecb339a --- /dev/null +++ b/Tester/ftt.asm @@ -0,0 +1,122 @@ +; ====================================================== +; FT-Test to test Sprinter-FT +; FT812 Video card for Sprinter computer +; By Roman Boykov. Copyright (c) 2025 +; 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 0 + +; 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 + + IFDEF DEBUG + ; LD IX,CMD_LINE1 + LD SP, STACK_TOP + ; JP MAIN_LOOP + ENDIF + +// CALL @WCOMMON.INIT_VMODE + + PRINTLN MSG_START + + CALL ISA.ISA_RESET ; Reset ISA Devices + +; ------------------------------------------------------ +; Do Some +; ------------------------------------------------------ + +MAIN_LOOP + + ; Find FT + CALL FT.FT_FIND + LD HL, MSG_NO_FT + JR C, MSG_FNF_OUT + ; FT is Found + LD A, (ISA.ISA_SLOT) + INC A + LD L, A + LD H, 0 + LD DE, MSG_SLOT_NO + CALL UTIL.FAST_UTOA + LD HL, MSG_IS_FT + ; Out message about FT slot +MSG_FNF_OUT + PRINTLN_HL + + +OK_EXIT + LD B,0 + DSS_EXEC DSS_EXIT + +; ------------------------------------------------------ +; Custom messages +; ------------------------------------------------------ + +MSG_START + DB "FTTest for Sprinter-FT by Sprinter Team. v1.0.b1, ", __DATE__, "\r\n", 0 + +MSG_NO_FT + DB "Sprinter-FT not found!",0 + + +MSG_IS_FT + DB "Sprinter-FT found at ISA" +MSG_SLOT_NO + DB 0,0,0 + +;MSG_EXIT +; DB "Bye!",0 + +; ------------------------------------------------------ +; Custom commands +; ------------------------------------------------------ + + ENDMODULE + + INCLUDE "ftlib.asm" + INCLUDE "util.asm" + INCLUDE "isa.asm" + + END MAIN.START diff --git a/Tester/ftt.exe b/Tester/ftt.exe new file mode 100644 index 0000000..5a77455 Binary files /dev/null and b/Tester/ftt.exe differ diff --git a/Tester/isa.asm b/Tester/isa.asm new file mode 100644 index 0000000..f17ebc5 --- /dev/null +++ b/Tester/isa.asm @@ -0,0 +1,94 @@ +; ====================================================== +; ISA Library for Sprinter computer +; By Roman Boykov. Copyright (c) 2024 +; https://github.com/romychs +; License: BSD 3-Clause +; ====================================================== + + IFNDEF _ISA + DEFINE _ISA + + INCLUDE "sprinter.inc" + INCLUDE "util.asm" + +PORT_ISA EQU 0x9FBD +PORT_SYSTEM EQU 0x1FFD + +ISA_BASE_A EQU 0xC000 ; Базовый адрес портов ISA в памяти + +; --- PORT_ISA bits +ISA_A14 EQU 0x01 +ISA_A15 EQU 0x02 +ISA_A16 EQU 0x04 +ISA_A17 EQU 0x08 +ISA_A18 EQU 0x10 +ISA_A19 EQU 0x20 +ISA_AEN EQU 0x40 +ISA_RST EQU 0x80 +NOP_FOR_DELAY EQU 5 + + MODULE ISA + +; ------------------------------------------------------ +; Reset ISA device +; ------------------------------------------------------ +ISA_RESET + PUSH AF, BC + LD BC, PORT_ISA + LD A, ISA_RST | ISA_AEN ; RESET=1 AEN=1 + OUT (C), A + DUP NOP_FOR_DELAY + NOP + EDUP + ;CALL @UTIL.DELAY_100uS + XOR A + OUT (C), A ; RESET=0 AEN=0 + ;CALL @UTIL.DELAY_100uS + POP BC, AF + RET + +; ------------------------------------------------------ +; Open access to ISA ports as memory +; Inp: A = 0 - ISA slot 0, 1 - ISA SLOT 1 +; ------------------------------------------------------ +ISA_OPEN + PUSH AF,BC + LD BC, PAGE3 + IN A,(C) + LD (SAVE_MMU3), A + LD BC, PORT_SYSTEM + LD A, 0x11 + OUT (C), A +ISA_SLOT EQU $+1 + LD A, 0x00 + SLA A + OR A, 0xD4 ; D4 - ISA1, D6 - ISA2 + LD BC, PAGE3 + OUT (C), A + LD BC, PORT_ISA + XOR A + OUT (C), A + POP BC,AF + RET + + +; ------------------------------------------------------ +; Close access to ISA ports +; ------------------------------------------------------ +ISA_CLOSE + PUSH AF,BC + LD A,0x01 + LD BC,PORT_SYSTEM + OUT (C),A + LD BC,PAGE3 + LD A,(SAVE_MMU3) + OUT (C),A + POP BC,AF + RET + +; To save memory page 3 +SAVE_MMU3 DB 0 + + ENDMODULE + + ENDIF \ No newline at end of file diff --git a/Tester/macro.inc b/Tester/macro.inc new file mode 100644 index 0000000..e8055e9 --- /dev/null +++ b/Tester/macro.inc @@ -0,0 +1,70 @@ +; ====================================================== +; Macros for Sprinter-WiFi utilities +; By Roman Boykov. Copyright (c) 2024 +; https://github.com/romychs +; License: BSD 3-Clause +; ====================================================== + + IFNDEF _MACRO + DEFINE _MACRO + + ; Transmit data|command via UART and check response + MACRO SEND_CMD data + LD HL, data + CALL @WIFI.UART_TX_CMD + CALL CHECK_ERROR + ENDM + + ; Print data forn HL - pointer to ASCIIZ string to screen + MACRO PRINT_HL + LD C,DSS_PCHARS + RST DSS + ENDM + + ; Print data forn HL - pointer to ASCIIZ string to screen, and + MACRO PRINTLN_HL + PRINT_HL + LD HL, UTIL.LINE_END + PRINT_HL + ENDM + + ; Print data ASCIIZ string to screen + MACRO PRINT data + LD HL,data + PRINT_HL + ENDM + + ; Print data ASCIIZ string to screen and + MACRO PRINTLN data + LD HL,data + PRINTLN_HL + ENDM + + ; Print data ASCIIZ string to screen if TRACE enabled + MACRO TRACELN data + IFDEF TRACE + PUSH BC,DE + PRINTLN data + 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 + + ; If current work mode is upload, go to label + MACRO IF_UPLOAD_GO lbl + LD A,(WORK_MODE) + ;CP WM_UPLOAD + DEC A + JR Z,lbl + ENDM + + ENDIF \ No newline at end of file diff --git a/Tester/sprinter.inc b/Tester/sprinter.inc new file mode 100644 index 0000000..ee24514 --- /dev/null +++ b/Tester/sprinter.inc @@ -0,0 +1,37 @@ +; ====================================================== +; Defines for Sprinter computer hardware +; By Roman Boykov. Copyright (c) 2024 +; https://github.com/romychs +; ====================================================== + + IFNDEF _SPRINTER + DEFINE _SPRINTER + +; Memory pages +PAGE0_ADDR EQU 0x0000 +PAGE1_ADDR EQU 0x4000 +PAGE2_ADDR EQU 0x8000 +PAGE3_ADDR EQU 0xC000 + +; Sprinter ports to switch mem pages +PAGE0 EQU 0x82 +PAGE1 EQU 0xA2 +PAGE2 EQU 0xC2 +PAGE3 EQU 0xE2 + +; CTC Control register ports +CTC_CH0 EQU 0x10 +CTC_CH1 EQU 0x11 +CTC_CH2 EQU 0x12 +CTC_CH3 EQU 0x13 + +CTC_CR_VEC EQU 0x01 ; 1 - Vector, 0 - Control +CTC_CR_SWR EQU 0x02 ; 1 - Software Reset, 0 - Continued operation +CTC_CR_TCF EQU 0x04 ; 1 - TYime const follows +CTC_CR_TTR EQU 0x08 ; 1 - Time trigger +CTC_CT_TRE EQU 0x10 ; 1 - Trigger Edge +CTC_CT_PRE EQU 0x20 ; 1 - 256 Prescaler, 0 - 16 +CTC_CT_CTR EQU 0x40 ; 0 - Timer, 1 - Counter +CTC_CT_EI EQU 0x80 ; Interrupt 1 - enable, 0 - disable + + ENDIF \ No newline at end of file diff --git a/Tester/util.asm b/Tester/util.asm new file mode 100644 index 0000000..37cfba0 --- /dev/null +++ b/Tester/util.asm @@ -0,0 +1,405 @@ +; ====================================================== +; Utility code for Sprinter-WiFi utilities +; By Roman Boykov. Copyright (c) 2024 +; https://github.com/romychs +; License: BSD 3-Clause +; ====================================================== + + IFNDEF _UTIL + DEFINE _UTIL + + MODULE UTIL + +MAX_BUFF_SIZE EQU 2048 + +; ------------------------------------------------------ +; Small delay +; Inp: HL - number of cycles, if HL=0, then 2000 +; ------------------------------------------------------ +DELAY + PUSH AF,BC,HL + + LD A,H + OR L + JR NZ,.DELAY_NXT + LD HL,20 + +.DELAY_NXT + CALL .DELAY_1MS_INT + DEC HL + LD A,H + OR L + JP NZ,.DELAY_NXT + + POP HL,BC,AF + RET + +.DELAY_1MS_INT + LD BC,400 +.SBD_NXT + DEC BC + LD A, B + OR C + JR NZ, .SBD_NXT + RET + +; ------------------------------------------------------ +; Delay for about 1ms +; ------------------------------------------------------ +DELAY_1MS + PUSH BC + CALL DELAY.DELAY_1MS_INT + POP BC + RET + +; ------------------------------------------------------ +; Delay for about 100us +; ------------------------------------------------------ +DELAY_100uS + PUSH BC + LD BC,40 + CALL DELAY.SBD_NXT + POP BC + RET + +; ------------------------------------------------------ +; Calc length of zero ended string +; Inp: HL - pointer to string; +; Out: BC - length of string +; ------------------------------------------------------ + ;;IFUSED STRLEN +STRLEN + PUSH DE, HL, HL + LD BC, MAX_BUFF_SIZE + XOR A + CPIR + POP DE + SBC HL, DE ; length of zero ended string + LD BC, HL + LD A, B + OR C + JR Z, .STRL_NCOR + DEC BC +.STRL_NCOR + POP HL, DE + RET + ;ENDIF + +; ------------------------------------------------------ +; Compare strings +; Inp: HL, DE - pointers to asciiz strings to compare; +; Out: CF=0 - equal, CF=1 - not equal +; ------------------------------------------------------ + ;;IFUSED STRCMP +STRCMP + PUSH DE,HL +.STC_NEXT + LD A, (DE) + CP (HL) + JR NZ,.STC_NE + AND A + JR Z,.STC_EQ + INC DE + INC HL + JR .STC_NEXT +.STC_NE + SCF +.STC_EQ + POP HL,DE + RET + ;;ENDIF + + + +; ------------------------------------------------------ +; Compare first BC chars for two zero-ended strings +; Inp: HL, DE - pointers to strings to compare; +; BC - Number of chars to compare; +; Out: ZF=0 - not equal, ZF=1 - equal +; ------------------------------------------------------ + ;IFUSED STRNCMP +STRNCMP + PUSH HL,DE,BC +.STRN_NXT + LD A,(DE) + SUB (HL) + JR NZ,.STRN_NE + LD A,(DE) + OR A + JR Z,.STRN_NE + INC DE + INC HL + DEC BC + LD A,B + OR C + JP NZ,.STRN_NXT +.STRN_NE + POP BC,DE,HL + RET + ;ENDIF + +; ------------------------------------------------------ +; Checks whether a string (HL) starts with the strinf (DE) +; Inp: DE - points to start string; +; HL - points to string; +; Out: ZF=0 - not equal, ZF=1 - equal +; ------------------------------------------------------ + ;;IFUSED STARTSWITH +STARTSWITH + PUSH HL,DE +.STRW_NXT + LD A,(DE) + OR A + JR Z,.STRW_END + LD A,(DE) + CP (HL) + JR NZ,.STRW_END + INC HL + INC DE + JR .STRW_NXT +.STRW_END + POP DE,HL + RET + ;;ENDIF + + +; ------------------------------------------------------ +; Skip spaces at start of zero ended string +; Inp: HL - pointer to string; +; Out: HL - points to first non space symbol +; ------------------------------------------------------ + ;;IFUSED LTRIM +LTRIM + LD A, (HL) + OR A + RET Z + CP 0x21 + RET P + INC HL + JR LTRIM + ;;ENDIF + +; ------------------------------------------------------ +; Convert string to number +; Inp: DE - ptr to zero ended string; +; Out: HL - Result +; ------------------------------------------------------ + ;;IFUSED ATOU +ATOU + PUSH BC + LD HL,0x0000 +.ATOU_L1 + LD A,(DE) + AND A + JR Z, .ATOU_LE + SUB 0x30 + CP 10 + JR NC, .ATOU_LE + INC DE + LD B,H + LD C,L + ADD HL,HL + ADD HL,HL + ADD HL,BC + ADD HL,HL + ADD A,L + LD L,A + JR NC,.ATOU_L1 + INC H + JP .ATOU_L1 +.ATOU_LE + POP BC + RET + ;;ENDIF + +; ------------------------------------------------------ +; Convert 16 bit unsigned number to string +; Inp: HL - number; +; DE - ptr to buffer; +; Out: DE -> asciiz string representing a number +; ------------------------------------------------------ + ;;IFUSED UTOA +UTOA: + PUSH BC, HL + XOR A + PUSH AF ; END MARKER A=0, Z +.UTOA_L1 + CALL DIV_10 + ADD '0' + PUSH AF ; DIGIT: A>0, NZ + LD A,H + OR L + JR NZ,.UTOA_L1 +.UTOA_L2 + POP AF + LD (DE),A + INC DE + JR NZ,.UTOA_L2 + POP HL, BC + RET + +; ------------------------------------------------------ +; Division by 10 +; Inp: HL - number; +; Out: HL - quotient; +; A - remainder; +; ------------------------------------------------------ +DIV_10: + PUSH BC + LD BC,0x0D0A + XOR A + ADD HL,HL + RLA + ADD HL,HL + RLA + ADD HL,HL + RLA +.DDL1 + ADD HL,HL + RLA + CP C + JR C,.DDL2 + SUB C + INC L +.DDL2 + DJNZ .DDL1 + POP BC + RET + ;;ENDIF +; ------------------------------------------------------ +; FAST_UTOA +; Inp: HL - number; +; DE - Buffer; +; CF is set to write leading zeroes; +; Out: DE - address of destination string +; ------------------------------------------------------ + ;;IFUSED FAST_UTOA +FAST_UTOA + LD BC,0+256 + PUSH BC + LD BC,-10+256 + PUSH BC + INC H + DEC H + JR Z, .EIGHT_BIT + + LD C,0xFF & (-100+256) + PUSH BC + + LD BC,-1000+256 + PUSH BC + + LD BC,-10000 + + JR C,.LEADING_ZEROES + +.NO_LEADING_ZEROES + + CALL .DIVIDE + CP '0' + JR NZ,.WRITE + + POP BC + DJNZ .NO_LEADING_ZEROES + + JR .WRITE1S + +.LEADING_ZEROES + CALL .DIVIDE + +.WRITE + LD (DE),A + INC DE + + POP BC + DJNZ .LEADING_ZEROES + +.WRITE1S + LD A,L + ADD A,'0' + + LD (DE),A + INC DE + RET + +.DIVIDE + LD A,'0'-1 + +.DIVLOOP + INC A + ADD HL,BC + JR C, .DIVLOOP + + SBC HL,BC + RET + +.EIGHT_BIT + LD BC,-100 + JR NC, .NO_LEADING_ZEROES + + ; write two leading zeroes to output string + LD A,'0' + LD (DE),A + INC DE + LD (DE),A + INC DE + + JR .LEADING_ZEROES + ;;ENDIF + +; ------------------------------------------------------ +; Find char in string +; Inp: HL - ptr to zero endeds string; +; A - char to find; +; Outp: CF=0, HL points to char if found; +; CF=1 - Not found +; ------------------------------------------------------ + ;;IFUSED STRCHR +STRCHR + PUSH BC +.STCH_NEXT + LD C,A + LD A,(HL) + AND A + JR Z, .STCH_N_FOUND + CP C + JR Z, .STCH_FOUND + INC HL + JR .STCH_NEXT +.STCH_N_FOUND + SCF +.STCH_FOUND + POP BC + RET + ;;ENDIF + +; ------------------------------------------------------ +; Convert Byte to hex +; Inp: C +; Out: (DE) +; ------------------------------------------------------ +HEXB + LD A,C + RRA + RRA + RRA + RRA + CALL .CONV_NIBLE + LD A,C + +.CONV_NIBLE + AND 0x0f + ADD A,0x90 + DAA + ADC A,0x40 + DAA + LD (DE), A + INC DE + RET + +LINE_END + DB "\r\n",0 + + ENDMODULE + + ENDIF \ No newline at end of file