diff --git a/sources/DSS/.vscode/tasks.json b/sources/DSS/.vscode/tasks.json index 6b41c82..105b8cb 100644 --- a/sources/DSS/.vscode/tasks.json +++ b/sources/DSS/.vscode/tasks.json @@ -142,6 +142,36 @@ } }, + { + "label": "make CMDTEST (sjasmplus)", + "type": "shell", + "command": "sjasmplus", + "args": [ + "--sld=cmdtest.sld", + "--sym=cmdtest.labels", + "--raw=cmdtest.exe", + "--fullpath", + "cmdtest.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": true + } + }, + + + { "label": "start mame", "type": "shell", diff --git a/sources/DSS/cmdtest.asm b/sources/DSS/cmdtest.asm new file mode 100644 index 0000000..c2bfa3d --- /dev/null +++ b/sources/DSS/cmdtest.asm @@ -0,0 +1,66 @@ +DSS EQU 0x10 +DSS_PCHARS EQU 0x5C +DSS_EXIT EQU 0x41 +EXE_VERSION EQU 0x00 + + + ; Print data ASCIIZ string to screen and CR+LF + MACRO PRINTLN data + LD HL,data + LD C,DSS_PCHARS + RST DSS + LD C,DSS_PCHARS + LD HL, MSG_LINE_END + RST DSS + ENDM + + 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 + + PRINTLN MSG_CMDLINE + PUSH IX + POP HL + LD C,DSS_PCHARS + RST DSS + + PRINTLN MSG_CURPATH + PUSH IY + POP HL + LD C,DSS_PCHARS + RST DSS + + LD BC,DSS_EXIT + RST DSS + + +MSG_CMDLINE + DB "\r\nCommandline:"Z + +MSG_CURPATH + DB "\r\nCurrentPath:"Z + +MSG_LINE_END + DB "\r\n"Z + + ENDMODULE diff --git a/sources/DSS/dss.asm b/sources/DSS/dss.asm index e209dd9..d1ee95b 100644 --- a/sources/DSS/dss.asm +++ b/sources/DSS/dss.asm @@ -41,7 +41,7 @@ RST38: DSS_HANDLER - PUSH HL + //PUSH HL PUSH BC LD A, C CP DSS_CURDISK @@ -119,13 +119,13 @@ NXT_PCHAR NORM_EXIT AND A ; CF=0 POP BC - POP HL + //POP HL RET BAD_EXIT SCF POP BC - POP HL + //POP HL RET @@ -364,10 +364,10 @@ CMD_LINE_TFTP_D DB " tftp://tftp.server.ru:1024/file_in.asm c:\\tmp\\file_out.asm"Z CMD_LINE_TFTP_D1 - DB " tftp://tftp.server.ru:1024/file_in.asm local.asm"Z + DB " tftp://server.ru/file.src sss.dst"Z CMD_LINE_TFTP_U - DB " file_up.txt tftp://tftp.server.ru:9999/file_in.asm "Z + DB " file_from.asm tftp://server.ru:9999/file_to.asm"Z CMD_LINE_TFTP_U1 DB " file_up.txt"Z diff --git a/sources/DSS/dss_error.asm b/sources/DSS/dss_error.asm index 19b066d..c267ed9 100644 --- a/sources/DSS/dss_error.asm +++ b/sources/DSS/dss_error.asm @@ -13,6 +13,9 @@ CHECK RET NC PRINT + PUSH AF + PRINT GET_ERR_MSG.MSG_DSS_ERROR + POP AF CALL GET_ERR_MSG DSS_EXEC DSS_PCHARS LD HL, WCOMMON.LINE_END @@ -43,6 +46,9 @@ GET_ERR_MSG POP AF RET +.MSG_DSS_ERROR + DB " Error: "Z + .MSG_E01 DB "Invalid function"Z .MSG_E02 DB "Invalid drive number"Z .MSG_E03 DB "File not found"Z diff --git a/sources/DSS/esplib.asm b/sources/DSS/esplib.asm index 9b59974..71c34ed 100644 --- a/sources/DSS/esplib.asm +++ b/sources/DSS/esplib.asm @@ -503,9 +503,8 @@ MSG_ERROR DB "ERROR", 0 ; Received message for Failure MSG_FAIL DB "FAIL", 0 - IFUSED RS_BUFF ; Buffer to receive response from ESP -RS_BUFF DS RS_BUFF_SIZE, 0 - ENDIF +RS_BUFF + ;DS RS_BUFF_SIZE, 0 ENDMODULE \ No newline at end of file diff --git a/sources/DSS/macro.inc b/sources/DSS/macro.inc index b7372a4..e7f338e 100644 --- a/sources/DSS/macro.inc +++ b/sources/DSS/macro.inc @@ -15,21 +15,29 @@ CALL CHECK_ERROR ENDM - ; Print data ASCIIZ string to screen - MACRO PRINT data - LD HL,data + ; Print data forn HL - pointer to ASCIIZ string to screen + MACRO PRINT_HL LD C,DSS_PCHARS RST DSS ENDM - ; Print data ASCIIZ string to screen and CR+LF + ; Print data forn HL - pointer to ASCIIZ string to screen, and + MACRO PRINTLN_HL + PRINT_HL + LD HL, WCOMMON.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 - LD C,DSS_PCHARS - RST DSS - LD C,DSS_PCHARS - LD HL, WCOMMON.LINE_END - RST DSS + PRINTLN_HL ENDM ; Print data ASCIIZ string to screen if TRACE enabled @@ -51,5 +59,11 @@ RST DSS ENDM + ; If current work mode is upload, go to label + MACRO IF_UPLOAD_GO lbl + LD A,(WORK_MODE) + CP WM_UPLOAD + JR Z,lbl + ENDM ENDIF \ No newline at end of file diff --git a/sources/DSS/tftp.asm b/sources/DSS/tftp.asm new file mode 100644 index 0000000..0ccfa29 --- /dev/null +++ b/sources/DSS/tftp.asm @@ -0,0 +1,163 @@ +; ====================================================== +; TFTP-protocol support module for WTFTP app +; By Roman Boykov. Copyright (c) 2024 +; https://github.com/romychs +; License: BSD 3-Clause +; ====================================================== + + MODULE TFTP + +; ------------------------------------------------------ +; Operation codes 2b for tftp packet header +; ------------------------------------------------------ + +; Opcode Read Request +OP_RRQ EQU '01' +; Opcode Write Request +OP_WRQ EQU '02' +; Opcode Data packet +OP_DATA EQU '03' +; Opcode Acknowledge packet +OP_ACK EQU '04' +; Opcode Error packet +OP_ERROR EQU '05' + +; ------------------------------------------------------ +; Build packet for request file from TFTF-server +; Out: HL - pointer to buffer to send +; ------------------------------------------------------ +BUILD_RRQ_PACKET + PUSH DE + LD DE,OP_RRQ ; opcode + CALL .BUILD_RW_PACKET + POP HL,DE + RET + +; ------------------------------------------------------ +; Build packet for write file to TFTF-server +; ------------------------------------------------------ +!BUILD_WRQ_PACKET + PUSH DE + LD DE,OP_WRQ ; opcode + CALL .BUILD_RW_PACKET + POP HL,DE + RET + +; ------------------------------------------------------ +; Build packet for write file or receive form TFTF-server +; ------------------------------------------------------ +.BUILD_RW_PACKET + LD HL,TFTP_BUFF + PUSH HL + LD (HL), DE + INC HL + INC HL + LD DE,MAIN.REM_FILE + ; filename +.BRP_NXT_RF + LD A, (DE) + LD (HL), A + OR A + JR Z,.BRP_MOD + INC HL + INC DE + JR .BRP_NXT_RF + ; Mode 'octet'Z +.BRP_MOD + INC HL + LD DE,'ct' + LD (HL),DE + INC HL + LD DE,'et' + LD (HL),DE + INC HL + LD DE,'t' + LD (HL),DE + RET + +; ------------------------------------------------------ +; Check TFTP Error, out error message if '05' packet +; type received +; Out: CF set if Error +; A - packet type, second byte if no errors +; ------------------------------------------------------ +CHK_ERROR + LD HL,TFTP_BUFF + LD A, (HL) + CP '0' + JR NZ, .CKE_UNKNOWN + INC HL + LD A, (HL) + CP '5' + JR Z, .CKE_ERR + OR A + RET +.CKE_ERR + INC HL + LD DE,(HL) ; ErrorCode + LD A, D + OR E + ; check for 1..7 range for defined error codes + JR Z,.CKE_UNDEF_ERR + LD A,E + CP 8 + JP P,.CKE_UNDEF_ERR + ; defined error + ADD A + LD E,A + LD HL,.TFTPE_T + ADD HL,DE + LD A,(HL) + INC HL + LD H,(HL) + LD L,A + ; print error message, HL - pointer to message +.CKE_PRINT_ERR + PUSH HL + PRINT .MSG_TFTP_ERR ; Protocol error: ... + POP HL + PRINTLN_HL + JR .CKE_ERR_EXIT + + ; undefined error, message in datagram +.CKE_UNDEF_ERR + INC HL + INC HL + JR .CKE_PRINT_ERR + +.CKE_UNKNOWN + ; unknown packet type + PRINTLN .MSG_ERR_UPT +.CKE_ERR_EXIT + SCF + RET + +; ------------------------------------------------------ +; Defined TFTP Protocol Error messages +; ------------------------------------------------------ + +;MSG_TFTPE_0 DB "Not defined, see error message (if any)."Z +.MSG_TFTPE_1 DB "File not found."Z +.MSG_TFTPE_2 DB "Access violation."Z +.MSG_TFTPE_3 DB "Disk full or allocation exceeded."Z +.MSG_TFTPE_4 DB "Illegal TFTP operation."Z +.MSG_TFTPE_5 DB "Unknown transfer ID."Z +.MSG_TFTPE_6 DB "File already exists."Z +.MSG_TFTPE_7 DB "No such user."Z + +; Table with error messages offsets +.TFTPE_T + DW .MSG_TFTPE_1,.MSG_TFTPE_1,.MSG_TFTPE_2,.MSG_TFTPE_3 + DW .MSG_TFTPE_4,.MSG_TFTPE_5,.MSG_TFTPE_7,.MSG_TFTPE_7 + +.MSG_TFTP_ERR + DB "Protocol error: "Z + +.MSG_ERR_UPT + DB "Unknown TFTP packet received!"Z + +; Buffer for UDP datagram with TFTP payload +TFTP_BUFF + DS 516,0 + + ENDMODULE \ No newline at end of file diff --git a/sources/DSS/util.asm b/sources/DSS/util.asm index 0f81ca7..4e738d2 100644 --- a/sources/DSS/util.asm +++ b/sources/DSS/util.asm @@ -19,26 +19,26 @@ DELAY LD A,H OR L - JR NZ,DELAY_NXT + JR NZ,.DELAY_NXT LD HL,20 -DELAY_NXT - CALL DELAY_1MS_INT +.DELAY_NXT + CALL .DELAY_1MS_INT DEC HL LD A,H OR L - JP NZ,DELAY_NXT + JP NZ,.DELAY_NXT POP HL,BC,AF RET -DELAY_1MS_INT +.DELAY_1MS_INT LD BC,400 -SBD_NXT +.SBD_NXT DEC BC LD A, B OR C - JR NZ, SBD_NXT + JR NZ, .SBD_NXT RET ; ------------------------------------------------------ @@ -46,7 +46,7 @@ SBD_NXT ; ------------------------------------------------------ DELAY_1MS PUSH BC - CALL DELAY_1MS_INT + CALL DELAY.DELAY_1MS_INT POP BC RET @@ -56,14 +56,14 @@ DELAY_1MS DELAY_100uS PUSH BC LD BC,40 - CALL SBD_NXT + CALL DELAY.SBD_NXT POP BC RET ; ------------------------------------------------------ ; Calc length of zero ended string -; Inp: HL - pointer to string -; Out: BC - length of string +; Inp: HL - pointer to string +; Out: BC - length of string ; ------------------------------------------------------ IFUSED STRLEN STRLEN @@ -76,33 +76,33 @@ STRLEN LD BC,HL LD A, B OR C - JR Z, STRL_NCOR + JR Z, .STRL_NCOR DEC BC -STRL_NCOR +.STRL_NCOR POP HL,DE RET ENDIF ; ------------------------------------------------------ -; Compare zero-ended strings -; Inp: HL, DE - pointers to strings to compare -; Out: CF=0 - equal, CF=1 - not equal +; 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 +.STC_NEXT LD A, (DE) CP (HL) - JR NZ, STC_NE + JR NZ,.STC_NE AND A - JR Z, STC_EQ + JR Z,.STC_EQ INC DE INC HL - JR STC_NEXT -STC_NE + JR .STC_NEXT +.STC_NE SCF -STC_EQ +.STC_EQ POP HL,DE RET ENDIF @@ -161,6 +161,21 @@ STARTSWITH 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 @@ -171,13 +186,13 @@ STARTSWITH ATOU PUSH BC LD HL,0x0000 -ATOU_L1 +.ATOU_L1 LD A,(DE) AND A - JR Z, ATOU_LE + JR Z, .ATOU_LE SUB 0x30 CP 10 - JR NC, ATOU_LE + JR NC, .ATOU_LE INC DE LD B,H LD C,L @@ -187,36 +202,171 @@ ATOU_L1 ADD HL,HL ADD A,L LD L,A - JR NC,ATOU_L1 + JR NC,.ATOU_L1 INC H - JP ATOU_L1 -ATOU_LE + JP .ATOU_L1 +.ATOU_LE POP BC RET 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 +; Convert 16 bit unsigned number to string +; Inp: HL - number +; DE - ptr to buffer +; Out: DE -> asciiz string representing a number ; ------------------------------------------------------ - IFUSED STRCHR + 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 strinf +; ------------------------------------------------------ + 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 +.STCH_NEXT LD C,A LD A,(HL) AND A - JR Z, STCH_N_FOUND + JR Z, .STCH_N_FOUND CP C - JR Z, STCH_FOUND + JR Z, .STCH_FOUND INC HL JR STCH_NEXT -STCH_N_FOUND +.STCH_N_FOUND SCF -STCH_FOUND +.STCH_FOUND POP BC RET ENDIF @@ -233,9 +383,10 @@ HEXB RRA RRA RRA - CALL CONV_NIBLE + CALL .CONV_NIBLE LD A,C -CONV_NIBLE + +.CONV_NIBLE AND 0x0f ADD A,0x90 DAA @@ -296,8 +447,6 @@ ADD_BACK_SLASH LD (HL),0x0 RET - - ENDMODULE ENDIF \ No newline at end of file diff --git a/sources/DSS/utoa.asm b/sources/DSS/utoa.asm new file mode 100644 index 0000000..e5c7df2 --- /dev/null +++ b/sources/DSS/utoa.asm @@ -0,0 +1,81 @@ + +; ------------------------------------------------------ +; FAST_UTOA +; Inp: HL - number +; A - Radix 2,8,10,16 +; DE - Buffer +; CF is set to write leading zeroes +; Out: DE - address of strinf +; ------------------------------------------------------ +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 diff --git a/sources/DSS/wtftp.asm b/sources/DSS/wtftp.asm index e4ea32a..1be358a 100644 --- a/sources/DSS/wtftp.asm +++ b/sources/DSS/wtftp.asm @@ -8,14 +8,13 @@ ; Set to 1 to turn debug ON with DeZog VSCode plugin ; Set to 0 to compile .EXE - DEFINE DEBUG +; DEFINE DEBUG ; Set to 1 to output TRACE messages DEFINE TRACE WM_DOWNLOAD EQU 0 - WM_UPLOAD EQU 1 @@ -67,17 +66,29 @@ START LD SP, STACK_TOP ENDIF + PRINTLN MSG_START + CALL PARSE_CMD_LINE - CALL OPEN_LOCAL_FILE - CALL DISPLAY_MODE + CALL OPEN_LOCAL_FILE + + IF_UPLOAD_GO DO_UPLOAD + CALL @TFTP.BUILD_RRQ_PACKET + JP DONE + +DO_UPLOAD + CALL @TFTP.BUILD_WRQ_PACKET + +DONE CALL CLOSE_LOCAL_FILE - IFDEF DEBUG - JP MAIN_LOOP - ENDIF + ;IFDEF DEBUG + LD B,0 + DSS_EXEC DSS_EXIT + + ;ENDIF CALL ISA.ISA_RESET @@ -113,16 +124,17 @@ OK_EXIT ; IX - points to cmd line ; ------------------------------------------------------ PARSE_CMD_LINE - PUSH IX - POP HL - LD A,(HL) + PUSH IX + POP HL ; HL -> CMD Line + LD A,(HL) ; CMD Line length OR A JR Z, OUT_USAGE_MSG - CALL SKIP_SPACES + INC HL ; skip length byte + CALL @UTIL.LTRIM ; skip leading non-printable characters ; check first parameter for tftp url pattern - LD DE,TFTF_START + LD DE,TFTF_START ; check parameter to start from 'tftp://' CALL @UTIL.STARTSWITH JR NZ,.PLC_UPLOAD @@ -130,7 +142,7 @@ PARSE_CMD_LINE ; handle parameter URL CALL GET_SRV_PARAMS - CALL SKIP_SPACES + CALL @UTIL.LTRIM ; skip spaces between parameters ; handle lfn CALL GET_LFN @@ -143,7 +155,7 @@ PARSE_CMD_LINE LD (WORK_MODE),A CALL GET_LFN - CALL SKIP_SPACES + CALL @UTIL.LTRIM LD DE,TFTF_START CALL @UTIL.STARTSWITH @@ -308,6 +320,7 @@ COPY_LFN INC (IX+0) LD DE,REM_FILE + LD B,12 ; limit filename length nnnnnnnn.exe .CLFN_NXT LD A,(DE) LD (HL),A @@ -315,10 +328,7 @@ COPY_LFN RET Z INC HL INC DE - JR .CLFN_NXT - - - + DJNZ .CLFN_NXT ; ------------------------------------------------------ ; Open local file for upload or download @@ -331,8 +341,8 @@ OPEN_LOCAL_FILE OR A JR NZ,.OLF_SKP_CP - LD HL, WIFI.RS_BUFF - PUSH HL + LD HL, @TMP_BUFF + ;PUSH HL CALL UTIL.GET_CUR_DIR LD DE,LOC_FILE LD B,128 @@ -345,25 +355,41 @@ OPEN_LOCAL_FILE INC DE DJNZ .OLF_NXT .OLF_EFN - POP HL + LD HL, @TMP_BUFF + ;POP HL ; HL - points to file path name .OLF_SKP_CP - LD A, (WORK_MODE) - CP WM_UPLOAD - JR Z,.OLF_UPL + IF_UPLOAD_GO .OLF_UPL ; create new file for write - XOR A + PUSH HL, HL + PRINT MSG_LFN_CR + POP HL + CALL PRINT_FILENAME + POP HL + + XOR A + PUSH HL LD C,DSS_CREATE_FILE RST DSS + POP HL JR NC,.OLF_END CP 0x07 ; file exists? JP NZ,DSS_ERROR.PRINT ; print error and exit + PUSH HL + PRINTLN MSG_OF_EXISTS + POP HL LD A,FM_WRITE JR .OLF_FOW + ; open existing file for read .OLF_UPL + PUSH HL, HL + PRINT MSG_LFN_OP + POP HL + CALL PRINT_FILENAME + POP HL LD A,FM_READ .OLF_FOW LD C,DSS_OPEN_FILE @@ -376,11 +402,28 @@ OPEN_LOCAL_FILE RET +PRINT_FILENAME + DSS_EXEC DSS_PCHARS + PRINTLN WCOMMON.LINE_END + RET + + +MSG_OF_EXISTS + DB "Output file already exists!"Z + IFDEF TRACE +MSG_LFN_CR + DB "Create file: "Z +MSG_LFN_OP + DB "Open file: "Z MSG_LFN_OPEN - DB "Local file succes open/created."Z + DB "File successfully accessed."Z ENDIF + +; ------------------------------------------------------ +; Closes loacal file if it open +; ------------------------------------------------------ CLOSE_LOCAL_FILE LD A,(LOC_FH) OR A @@ -389,28 +432,13 @@ CLOSE_LOCAL_FILE CALL DSS_ERROR.CHECK RET -; ------------------------------------------------------ -; Skip spaces at start of zero ended string -; Inp: HL - pointer to string -; Out: HL - points to first non space symbol -; ------------------------------------------------------ -SKIP_SPACES - LD A, (HL) - OR A - RET Z - CP 0x21 - RET P - INC HL - JR SKIP_SPACES ; ------------------------------------------------------ ; Display current working mode ; ------------------------------------------------------ DISPLAY_MODE - LD A,(WORK_MODE) - CP A,WM_UPLOAD - JR .DM_UPLOAD + IF_UPLOAD_GO .DM_UPLOAD ; Download PRINT MSG_MODE_D PRINT REM_FILE @@ -429,20 +457,6 @@ DISPLAY_MODE PRINTLN REM_FILE RET -MSG_MODE_D - DB "Download file "Z -MSG_MODE_D_S - DB " from server "Z -MSG_MODE_D_T - DB " to file "Z - -MSG_MODE_U - DB "Upload file "Z -MSG_MODE_U_S - DB " to server "Z -MSG_MODE_U_T - DB " to file "Z - ; ------------------------------------------------------ ; Custom messages ; ------------------------------------------------------ @@ -454,8 +468,8 @@ MSG_ERR_CMD DB "Invalid command line parameters!\r\n"Z MSG_HLP - DB "\r\nUse: wtftp.exe tftp://server[:port]/filename filename - to download file from server;\r\n" - DB " wtftp.exe filename tftp://server[:port]/filename - to upload file to server.\r\n"Z + DB "\r\nUse:\r\n wtftp.exe tftp://server[:port]/filename filename - to download from server;\r\n" + DB " wtftp.exe filename tftp://server[:port]/filename - to upload to server.\r\n"Z MSG_TX_ERROR DB "Transmitter not ready"Z @@ -477,6 +491,24 @@ MSG_ERR_RFN MSG_ERR_LFN DB "Invalid local file name!"Z +MSG_MODE_D + DB "Download file "Z +MSG_MODE_D_S + DB " from server "Z +MSG_MODE_D_T + DB " to file "Z + +MSG_MODE_U + DB "Upload file "Z +MSG_MODE_U_S + DB " to server "Z +MSG_MODE_U_T + DB " to file "Z + +; ------------------------------------------------------ +; Variables +; ------------------------------------------------------ + ; Start of tftf URL TFTF_START DB "tftp://"Z @@ -489,12 +521,12 @@ WORK_MODE ; Name/IP of the tftp server SRV_NAME DS 128,0 - +CMDLINE ; UDP port of the tftp server SRV_PORT DB 69,0,0,0,0,0 ; udp port number 0..65535 -; Name of the source file +; Name of the remote file REM_FILE DS 128,0 @@ -506,28 +538,23 @@ LOC_FILE LOC_FH DW 0 -; Not null if local file name contains path +; Non zero, if local file name contains path HAVE_PATH DB 0 -; ------------------------------------------------------ -; Custom commands -; ------------------------------------------------------ -RX_ERR - DB 0 - -; IFDEF DEBUG -; CMD_TEST1 DB "ATE0\r\n"Z -; BUFF_TEST1 DS RS_BUFF_SIZE,0 -; ENDIF - ENDMODULE +; ------------------------------------------------------ +; Includes +; ------------------------------------------------------ INCLUDE "wcommon.asm" INCLUDE "dss_error.asm" ;INCLUDE "util.asm" INCLUDE "isa.asm" + INCLUDE "tftp.asm" INCLUDE "esplib.asm" +TMP_BUFF + END MAIN.START