diff --git a/client/basic/Makefile b/client/basic/Makefile index 1fd8224..6e6ddab 100644 --- a/client/basic/Makefile +++ b/client/basic/Makefile @@ -17,8 +17,10 @@ IP65LIB=../ip65/ip65_tcp.lib C64PROGLIB=../drivers/c64prog.lib -all: kipperbas.d64 bails.d64 +all: ip65 kipperbas.d64 bails.d64 +ip65: + make -C ../ip65 all %.o: %.s $(INCFILES) $(AS) $(AFLAGS) $< diff --git a/client/basic/bails.d64 b/client/basic/bails.d64 index a3e391c..5996533 100644 Binary files a/client/basic/bails.d64 and b/client/basic/bails.d64 differ diff --git a/client/basic/kipperbas.d64 b/client/basic/kipperbas.d64 index c173026..96de627 100644 Binary files a/client/basic/kipperbas.d64 and b/client/basic/kipperbas.d64 differ diff --git a/client/basic/kipperbas.s b/client/basic/kipperbas.s index c2d9c3b..d6334df 100644 --- a/client/basic/kipperbas.s +++ b/client/basic/kipperbas.s @@ -25,7 +25,7 @@ IERROR = $0300 ICRUNCH = $0304 ;Crunch ASCII into token IQPLOP = $0306 ;List IGONE = $0308 ;Execute next BASIC token - +IEVAL = $30A ; evaluate expression CHRGET = $73 CHRGOT = $79 CHROUT = $FFD2 @@ -171,14 +171,14 @@ FS=$8000-main_start ldax #welcome_banner jsr print - ldx #5 ;Copy CURRENT vectors + ldx #7 ;Copy CURRENT vectors @copy_old_vectors_loop: lda ICRUNCH,x sta oldcrunch,x dex bpl @copy_old_vectors_loop - ldx #5 ;Copy CURRENT vectors + ldx #7 ;Copy CURRENT vectors install_new_vectors_loop: lda vectors,x sta ICRUNCH,x @@ -592,8 +592,11 @@ print: extract_string: + jsr FRMEVL + jsr FRESTR ;if not string, will create type mismatch error + sta param_length tay lda #0 @@ -827,7 +830,10 @@ ping_keyword: lda $cb ;current key pressed cmp #$3F ;RUN/STOP? beq @done + lda ping_counter + beq @ping_loop dec ping_counter + cmp #1 bne @ping_loop @done: jsr print_cr @@ -1087,12 +1093,15 @@ make_tcp_connection: rts netcat_keyword: + lda $CC + sta cursor_state + lda #$0 + sta $CC ;enable blinking cursor ldax #netcat_callback stax tcp_callback jsr make_tcp_connection - bcc :+ - rts - : + bcs @exit + ;is there an optional parameter? ldx #0 jsr get_optional_byte @@ -1113,8 +1122,12 @@ netcat_keyword: jsr ip65_process lda connection_state bne @not_disconnected +@disconnected: ldax #disconnected jsr print +@exit: + lda cursor_state + sta $CC rts @not_disconnected: @@ -1131,11 +1144,8 @@ netcat_keyword: beq @runstop jsr ip65_process lda connection_state - bne :+ - ldax #disconnected - jsr print - rts -: + beq @disconnected + jsr $f142 ;not officially documented - where F13E (GETIN) falls through to if device # is 0 (KEYBD) beq @read_line @@ -1180,6 +1190,7 @@ netcat_keyword: jmp @read_line @input_done: + jsr reset_cursor lda #$0d jsr $ffd2 ;print a newline ldy string_length @@ -1208,6 +1219,9 @@ netcat_keyword: @runstop: lda #0 sta $cb ;overwrite "current key pressed" else it's seen by the tcp stack and the close aborts + lda cursor_state + sta $CC + jmp tcp_close @not_runstop: jsr $ffe4 ;getkey - 0 means no input @@ -1227,12 +1241,24 @@ netcat_keyword: jmp @main_polling_loop @error_on_send: + lda cursor_state + sta $CC ldax #transmission jmp print_error - +reset_cursor: + lda $cf ;0 means last cursor blink set char to be reversed + beq @done + lda $ce ;original value of cursor char + ldx $287 ;original colour + ldy #$0 ;blink phase + sty $cf + jsr $ea13 ;restore char & colour +@done: + rts netcat_callback: + jsr reset_cursor lda tcp_inbound_data_length+1 cmp #$ff bne @not_eof @@ -1430,14 +1456,42 @@ tcpblat_keyword: lda #KPR_ERROR_FILE_ACCESS_FAILURE jmp @store_error +evaluate: + lda $00 + sta $0D ;set string flag to not string + jsr CHRGET + cmp #$E3 ; PING keyword + bne @done + jsr CHRGET ;take PING command off stack + + ldax #icmp_echo_ip + jsr get_ip_parameter + lda #$00 + sta $0D ;set string flag to not string + + bcs @error + jsr icmp_ping + bcc @no_error +@error: + lda #$ff + tax +@no_error: + tay + txa + jmp $b395 ;signed 16 bit number to floating point + rts + +@done: + jsr CHRGOT + jmp $AE8D ;inside original EVAL routine .rodata vectors: .word crunch .word list .word execute - + .word evaluate ; Keyword list ; Keywords are stored as normal text, ; followed by the token number. @@ -1553,7 +1607,7 @@ jmp_crunch: .byte $4C ;JMP oldcrunch: .res 2 ;Old CRUNCH vector oldlist: .res 2 oldexec: .res 2 - +oldeval: .res 2 emit_a: current_output_ptr=emit_a+1 sta $ffff @@ -1565,7 +1619,6 @@ current_output_ptr=emit_a+1 rts - .bss netcat_mode: .res 1 bytes_read: .res 2 @@ -1584,4 +1637,4 @@ file_opened: .res 1 connection_state: .res 1 netcat_timeout: .res 1 buffer_length: .res 2 - +cursor_state: .res 1 diff --git a/client/basic/welcome_banner.txt b/client/basic/welcome_banner.txt index 550a052..1182c50 100644 --- a/client/basic/welcome_banner.txt +++ b/client/basic/welcome_banner.txt @@ -1 +1 @@ -**** KIPPER BASIC 1.0 **** +**** KIPPER BASIC 1.1 **** diff --git a/client/inc/version.i b/client/inc/version.i index dab8cfc..681cfc0 100644 --- a/client/inc/version.i +++ b/client/inc/version.i @@ -1 +1 @@ -.byte "1.0.31" +.byte "1.0.35" diff --git a/client/v1541/v1541.cfg b/client/v1541/v1541.cfg index 0697bf8..82ad2d8 100644 --- a/client/v1541/v1541.cfg +++ b/client/v1541/v1541.cfg @@ -2,7 +2,7 @@ MEMORY { IP65ZP: start = $A3, size = $12, type = rw; STARTRAM: start = $07FF, size = $4000, file = %O; - UNDERBASIC: start = $A000, size = $2000, define = yes, file = %O; + UNDERBASIC: start = $9000, size = $3000, define = yes, file = %O; HIRAM: start = $C000, size = $01000; } @@ -12,6 +12,7 @@ MEMORY { IP65ZP: load = IP65ZP, type = zp; ZEROPAGE: load = IP65ZP, type = zp; STARTUP: load = STARTRAM, type = rw; + TCP_VARS: load = UNDERBASIC, type = bss; CODE: load = STARTRAM, run=UNDERBASIC, type = ro,define = yes; RODATA: load = STARTRAM, run=UNDERBASIC, type = ro,define = yes; DATA: load = STARTRAM, run=UNDERBASIC, type = rw, define = yes; @@ -19,6 +20,5 @@ MEMORY { CODESTUB: load STARTRAM, run= HIRAM, type = rw, define = yes; BSS: load = HIRAM, type = bss; - TCP_VARS: load = UNDERBASIC, type = bss; } diff --git a/client/v1541/v1541.prg b/client/v1541/v1541.prg index a9256f5..89823a4 100644 Binary files a/client/v1541/v1541.prg and b/client/v1541/v1541.prg differ diff --git a/client/v1541/v1541.s b/client/v1541/v1541.s index 6b4b3bb..b65eb4f 100644 --- a/client/v1541/v1541.s +++ b/client/v1541/v1541.s @@ -81,6 +81,9 @@ basicstub: .word 0 relocate: + ldax #$9000 + stax $37; MEMSIZ + jsr $A65E ;do a CLR ;relocate everything ldax #__CODE_LOAD__ @@ -101,7 +104,7 @@ relocate: @installed_msg: .byte "V1541 INSTALLED",0 @already_installed_msg: .byte "V1541 ALREADY INSTALLED",0 @not_installed: - + ldax #__DATA_LOAD__ stax copy_src @@ -217,14 +220,13 @@ ldax #irq_handler sei stax CINV -; jsr install_wedge - @done: jsr swap_basic_in lda #0 sta $dc08 ;make sure TOD clock is started cli - rts + + rts __copymem: sta end @@ -273,69 +275,14 @@ __print: @done_print: rts -install_wedge: - ldax #wedge_start - stax copy_src - sec - lda MEMSIZ - sbc #wedge_length - sta MEMSIZ+1 - sta copy_dest+1 - sta IERROR+1 - ldax #wedge_length - jsr __copymem - jmp $a644 ;NEW - -wedge_start: - - - ;new error handler - cpx #$0b ; is it a SYNTAX ERROR? - beq @syntax_error; yes, jump to command test -@exit: - jmp $e38b ;nope, normal error handler - -@syntax_error: - - jsr CHRGOT ;read current character in buffer again - bcc @exit - cmp #$b1 ;is current character a > token? - bne @exit ;nope, normal error handler -@got_it: - ldy #0 - lda #'>' - sta (TXTPTR),y ;replace token with > symbol again -@scan_command: - lda (TXTPTR),y ; - beq @end_of_command - cmp #':' - beq @end_of_command - iny - bne @scan_command -@end_of_command: - sty FNLEN ;file name length - lda TXTPTR ;start of filename - sta FNADDR - lda TXTPTR+1 ;start of filename - sta FNADDR+1 - lda #$2 - sta $BA ;current device number - ;jmp (ILOAD) - jsr load_handler - jmp $A474 ;READY prompt - - -wedge_length=*-wedge_start .code load_dev_2: ldy #$00 + sty receive_type ;0 = display to screen, 1 = load to memory + sty buffer_length + sty buffer_length+1 lda (FNADDR),y cmp #'!' beq @do_disks @@ -343,8 +290,26 @@ load_dev_2: beq @do_command cmp #'#' beq @do_insert - + cmp #'=' + beq @do_find + cmp #'/' + bne @not_cf + lda FNLEN + cmp #1 + bne @do_cf + ldax #cmd_cf_root + jmp @send_string_receive_response +@not_cf: + cmp #'%' + beq @do_name + cmp #'$' + beq @do_cat + inc receive_type + ldax #cmd_load + jmp @copy_prefix + @done: + clc jmp swap_basic_in @@ -356,7 +321,6 @@ load_dev_2: dey bne @copy_cmd - ldy FNLEN lda #$0D sta cmd_buffer-1,y @@ -364,29 +328,57 @@ load_dev_2: sta cmd_buffer,y @send_command_buffer: ldax #cmd_buffer - jmp @send_string_show_list - + jmp @send_string_receive_response + +@do_name: + ldax #cmd_name + jmp @send_string_receive_response + +@do_find: + ldax #cmd_find + jmp @copy_prefix + +@do_cat: + ldax #cmd_cat + jmp @send_string_receive_response + + @do_disks: - ldax #@cmd_dsks -@send_string_show_list: + ldax #cmd_dsks +@send_string_receive_response: jsr tcp_send_string bcs @error - jsr show_list + lda receive_type + bne @load_file + jsr show_list jmp @done +@load_file: + jsr receive_file + jmp @done + +@do_cf: + ldax #cmd_cf + jmp @copy_prefix -@cmd_dsks: .byte "DISKS 22",$0d,$0 @do_insert: - - ldx #0 -@copy_insert: - lda @cmd_insert,x - beq @end_insert - sta cmd_buffer,x - inx - bne @copy_insert -@end_insert: + ldax #cmd_insert +@copy_prefix: + stax copy_src + ldy #0 +@copy_prefix_loop: + lda (copy_src),y + beq @end_copy_prefix + sta cmd_buffer,y + iny + bne @copy_prefix_loop +@end_copy_prefix: + tya + tax ldy #1 + lda receive_type + beq :+ + dey ;if this is a LOAD command, don't skip the first byte : lda (FNADDR),y sta cmd_buffer,x @@ -402,22 +394,18 @@ load_dev_2: sta cmd_buffer+1,x jmp @send_command_buffer -@cmd_insert: .byte "INSERT ",0 - - @error: + ldax #SERVER_PORT + jsr tcp_connect + ldax #transmission_error jsr print - lda ip65_error - jsr print_hex - lda tcp_state - jsr print_hex - + jmp @done -show_list: - +show_list: + @loop: lda $91 ; look for STOP key cmp #$7F @@ -427,6 +415,7 @@ show_list: bcc @got_data rts @got_data: + cmp #$03 ;ETX byte (indicating end of page)? beq @get_user_input cmp #$04 ;EOT byte (indicating end of list)? @@ -436,6 +425,7 @@ show_list: ;End of page, so ask for user input @get_user_input: + jsr get_key cmp #'S' @@ -552,28 +542,9 @@ next_char: sta buffer_length+1 pla clc + rts -print_hex: - pha - pha - lsr - lsr - lsr - lsr - tax - lda hexdigits,x - jsr print_a - pla - and #$0F - tax - lda hexdigits,x - jsr print_a - pla - rts -hexdigits: -.byte "0123456789ABCDEF" - tcp_irq_handler: inc keep_alive_counter @@ -585,8 +556,98 @@ tcp_irq_handler: @done: rts - +receive_file: + lda #0 + sta byte_count +@loop: + lda $91 ; look for STOP key + cmp #$7F + beq @done + lda #2 ;wait for max 2 seconds + jsr getc + bcc @got_data +@done: + rts +@got_data: + ldy byte_count + sta file_length,y + inc byte_count + lda byte_count + cmp #4 + bne @loop + ;is the first 4 bytes "500 " +; + lda file_length+1 + cmp #'0' ;if 2nd char was '0' this might be an ASCII error message + bne @real_file_transmission + lda file_location + cmp #$01 + beq @real_file_transmission + ;this was probably an ASCII error message + + lda #0 + sta byte_count +: + ldy byte_count + lda file_length,y + jsr print_a + inc byte_count + lda byte_count + cmp #4 + bne :- + jmp show_list +@real_file_transmission: + ldax file_location + stax copy_dest + + lda file_length + sec + sbc #2 + sta file_length + + lda file_length+1 + sbc #0 + sta file_length+1 + +@rx_loop: + lda file_length+1 + bne @not_done + lda file_length + bne @not_done + ;file now fully in RAM, time for housekeeping + sta $297 ;RS-232 status = 0 (no error) + sta $90 ;status = 0 (no error) + ldy copy_dest+1 ;high byte of end of loaded program + ldx copy_dest ;lo byte of end of loaded program + inx + bne :+ + iny ;if X rolled over, bump y +: + rts ;done! + +@not_done: + lda #2 ;wait for max 2 seconds + jsr getc + bcs @rx_error + ldy #0 + sta (copy_dest),y + inc copy_dest + bne :+ + inc copy_dest+1 +: + lda file_length + bne :+ + dec file_length+1 + lda #'.' + jsr print_a +: + dec file_length + jmp @rx_loop + +@rx_error: + ldax #receive_error + jmp print .segment "CODESTUB" @@ -605,6 +666,8 @@ swap_basic_in: sta underneath_basic rts +underneath_basic: .res 1 + load_handler: ldx $BA ; Current Device Number cpx #$02 @@ -617,7 +680,8 @@ old_load_vector: jmp load_dev_2 irq_handler: - lda underneath_basic + + lda underneath_basic bne @done jsr swap_basic_out jsr tcp_irq_handler @@ -627,22 +691,39 @@ irq_handler: old_irq_vector: .word $ffff -underneath_basic: .res 1 + +.data +cmd_dsks: .byte "DISKS 22",$0d,$0 +cmd_insert: .byte "INSERT ",0 +cmd_cat: .byte "$",$0d,$00 +cmd_find: .byte "FIND ",$00 +cmd_name: .byte "NAME",$0d,$00 +cmd_cf: .byte "CF ",0 +cmd_load: .byte "LOAD ",0 +cmd_cf_root: .byte "CF /",$0d,0 + +transmission_error: .byte "TRANSMIT ERROR",13,0 +receive_error: .byte "RECEIVE ERROR",13,0 .segment "TCP_VARS" -csip_stream_buffer: .res 1400 +csip_stream_buffer: .res 1500 cmd_buffer: .res 100 +.bss + user_abort: .res 1 getc_timeout_end: .res 1 getc_timeout_seconds: .res 1 buffer_length: .res 2 keep_alive_counter: .res 1 - +file_length: .res 2 +file_location: .res 2 +rx_length: .res 2 +receive_type: .res 1 +byte_count: .res 1 .data continue_cmd: .byte $0D,0 stop_cmd: .byte "S",0 -transmission_error: .byte "TRANSMISSION ERROR",13,0 ;-- LICENSE FOR v1541.s -- ; The contents of this file are subject to the Mozilla Public License diff --git a/dist/version_number.txt b/dist/version_number.txt index a8c6b78..fff1fac 100644 --- a/dist/version_number.txt +++ b/dist/version_number.txt @@ -1 +1 @@ -1.0.31 \ No newline at end of file +1.0.35 \ No newline at end of file diff --git a/doc/CHANGES.txt b/doc/CHANGES.txt index f0787c1..810dfc4 100644 --- a/doc/CHANGES.txt +++ b/doc/CHANGES.txt @@ -1,5 +1,5 @@ - v1.0.33 +v1.0.33 - FIX: gracefully close the TCP connection when a telnet connection is aborted by user keystroke - FIX: telnet client was reprocessing last received packet after an error (including user abort) - FIX: was not signalling an error when a RST or FIN was sent back to tcp_connect