diff --git a/client/basic/Makefile b/client/basic/Makefile index e080ed4..2aa72b7 100644 --- a/client/basic/Makefile +++ b/client/basic/Makefile @@ -17,7 +17,7 @@ IP65LIB=../ip65/ip65_tcp.lib C64PROGLIB=../drivers/c64prog.lib -all: basml.d64 +all: gopherd.d64 %.o: %.s $(INCFILES) $(AS) $(AFLAGS) $< @@ -26,9 +26,11 @@ all: basml.d64 $(LD) -m $*.map -vm -C ../cfg/c64_mlstub.cfg -o $*.prg $(AFLAGS) $< $(IP65LIB) $(C64PROGLIB) -basml.d64: mlstub.prg - ripxplore.rb -r -e basml $@ -o basml.bas +gopherd.d64: mlstub.prg gophermap.txt addresses.txt + ripxplore.rb -r -e gopherd $@ -o gopherd.bas ripxplore.rb $@ -a mlstub.prg + ripxplore.rb $@ -a gophermap.txt -t C64Seq + ripxplore.rb $@ -a addresses.txt -t C64Seq clean: rm -f *.o *.bin *.map *.prg diff --git a/client/basic/addresses.txt b/client/basic/addresses.txt new file mode 100644 index 0000000..b65da5a --- /dev/null +++ b/client/basic/addresses.txt @@ -0,0 +1,14 @@ +1FLOODGAP GOPHER / GOPHER.FLOODGAP.COM 70 +8JAMTRONIX PETSCIIMATION /n JAMTRONIX.COM 6464 +8ANTIDOTE /n ANTIDOTE.HOPTO.ORG 23 +8EXCALIBUR'S STONE /n BBS.EXCALIBURSSTONE.COM 6400 +8JAMMING SIGNAL /n BBS.JAMMINGSIGNAL.COM 23 +8MAD WORLD /n MADWORLD.BOUNCEME.NET 23 +8REALMS OF MYSTERY /n BBS.PIPESUP.CA 6400 +8RIKTRONICS /n RKBBS.NET 23 +8WIZARD'S REALM /n WIZBBS.DYNDNS.ORG 23 +8COTTONWOOD BBS /n COTTONWOOD.SERVEBBS.COM 23 +8COTTONWOOD II /n COTTONWOOD.SERVEBBS.COM 6400 +8THE HIDDEN /n THE-HIDDEN.HOPTO.ORG 23 + +. \ No newline at end of file diff --git a/client/basic/basml.bas b/client/basic/basml.bas index 04efa7b..13b16ce 100644 Binary files a/client/basic/basml.bas and b/client/basic/basml.bas differ diff --git a/client/basic/basml.d64 b/client/basic/basml.d64 index 44aa2ed..9d70881 100644 Binary files a/client/basic/basml.d64 and b/client/basic/basml.d64 differ diff --git a/client/basic/gopherd b/client/basic/gopherd new file mode 100644 index 0000000..9c55cee Binary files /dev/null and b/client/basic/gopherd differ diff --git a/client/basic/gopherd.bas b/client/basic/gopherd.bas new file mode 100644 index 0000000..9c55cee Binary files /dev/null and b/client/basic/gopherd.bas differ diff --git a/client/basic/gopherd.d64 b/client/basic/gopherd.d64 new file mode 100644 index 0000000..cbc7e75 Binary files /dev/null and b/client/basic/gopherd.d64 differ diff --git a/client/basic/gophermap.txt b/client/basic/gophermap.txt new file mode 100644 index 0000000..45e52c0 --- /dev/null +++ b/client/basic/gophermap.txt @@ -0,0 +1,2 @@ +1FLOODGAP GOPHER / GOPHER.FLOODGAP.COM 70 +1Interesting telnet destinations /ADDRESSES.TXT 10.5.1.9 70 diff --git a/client/basic/mlstub.s b/client/basic/mlstub.s index c475915..59d0a89 100644 --- a/client/basic/mlstub.s +++ b/client/basic/mlstub.s @@ -7,7 +7,13 @@ ARYTAB=$2F ;BASIC array table storage FREETOP=$33 ;bottom of string text storage area MEMSIZ=$37 ;highest address used by BASIC CLEAR=$A65E ;clears BASIC variables - +SETNAM=$FFBD +SETLFS=$FFBA +OPEN=$FFC0 +CHKIN=$FFC6 +READST=$FFB7 ; read status byte +CHRIN=$FFCF ; get a byte from file +CLOSE=$FFC3 .import copymem .importzp copy_dest @@ -18,38 +24,35 @@ CLEAR=$A65E ;clears BASIC variables .import tcp_callback .import tcp_connect_ip .import tcp_send +.import tcp_connect +.import tcp_close .import tcp_send_data_len +.import tcp_inbound_data_ptr +.import tcp_inbound_data_length +.import dns_set_hostname +.import dns_resolve +.import dns_ip +.import ip65_process + .zeropage temp_buff: .res 2 .segment "STARTUP" ;this is what gets put at the start of the file on the C64 .word jump_table ; load address jump_table: - jmp init ; this should be at $4000 ie SYS 16384 - jmp listen_on_port ; this should be at $4003 ie SYS 16387 - jmp send_data ; this should be at $4006 ie SYS 16390 + jmp init ; $4000 (PTR) - vars io$,io%,er% should be created (in that order!) before calling + jmp listen_on_port ; $4003 (PTR+3) - io% is port to listen on + jmp send_data ; $4006 (PTR+6) - io$ is string to send + jmp check_for_data ; $4009 (PTR+9) - after return, io% 0 means no new data, 1 means io$ set to new data + jmp connect_to_server ; $400c (PTR+12) - io$ is remote server name or ip, io% is remote port + jmp send_file ; $400f (PTR+15) - io$ is name of file (on last accessed drive) to send over current channel + jmp close_connection ; $4002 (ptr+18) - no inputs needed .code init: - ;set up the transfer variables IO$,IO% and ER% - - ;first make room - clc - lda VARTAB - adc #basic_vartable_entries_length/7 - sta ARYTAB - lda VARTAB+1 - adc #0 - sta ARYTAB+1 - - ldax #basic_vartable_entries - stax copy_src - ldax VARTAB - stax copy_dest - ldax #basic_vartable_entries_length - jsr copymem + ;IO$,IO% and ER% should be first three variables created! lda #14 jsr print_a ;switch to lower case @@ -74,12 +77,15 @@ exit_to_basic: rts -listen_on_port: +setup_for_tcp: ldax #tcp_data_arrived stax tcp_callback lda #0 sta ip65_error - + rts +listen_on_port: + + jsr setup_for_tcp jsr get_io_var jsr tcp_listen bcs @error @@ -88,6 +94,9 @@ listen_on_port: ldax #tcp_connect_ip jsr print_dotted_quad jsr print_cr + lda #0 + sta ip65_error + @error: jmp set_error_var @@ -144,6 +153,17 @@ get_io_string_ptr: pla rts +get_io_string: ;we want to turn from a string prefixed by length to nul terminated + jsr get_io_string_ptr + stax copy_src + ldax #transfer_buffer + stax copy_dest + lda #0 + sta (copy_dest),y ;null terminate the string + tax + tya + jmp copymem + set_io_string: stax copy_src ldax #transfer_buffer @@ -156,6 +176,7 @@ set_io_string: iny bne @loop @done: +set_io_string_ptr: tya ;length of string copied ldy #2 ;length is 2nd byte of variable table entry sta (VARTAB),y @@ -167,31 +188,139 @@ set_io_string: sta (VARTAB),y rts - -tcp_data_arrived: +check_for_data: + lda #0 + sta ip65_error + jsr set_error_var + sta data_arrived_flag + jsr ip65_process + bcc @no_error + jsr set_error_var +@no_error: + lda data_arrived_flag + ldx #0 + jmp set_io_var + +tcp_data_arrived: + inc data_arrived_flag + ldax #transfer_buffer + stax copy_dest + ldax tcp_inbound_data_ptr + stax copy_src + lda tcp_inbound_data_length + ldx tcp_inbound_data_length+1 + beq @short_packet + cpx #$ff + bne @not_end_packet + inc data_arrived_flag + rts +@not_end_packet: + lda #$ff +@short_packet: + tay + pha + jsr set_io_string_ptr + pla + ldx #0 + jmp copymem rts +connect_to_server: + jsr get_io_string + ldax #transfer_buffer + jsr dns_set_hostname + bcs @error + jsr dns_resolve + bcs @error + ldx #4 +@copy_dns_ip: + lda dns_ip,y + sta tcp_connect_ip,y + iny + dex + bne @copy_dns_ip + jsr setup_for_tcp + jsr get_io_var + jsr tcp_connect + +@error: + jmp set_error_var + + +send_file: + jsr get_io_string_ptr ;AX ptr, Y is length + stax copy_src + tya + ldx copy_src + ldy copy_src+1 + jsr SETNAM + lda #$02 ; file number 2 + ldx $BA ; last used device number + bne @skip + ldx #$08 ; default to device 8 +@skip: + ldy #$02 ; secondary address 2 + jsr SETLFS + jsr OPEN + bcs @error ; if carry set, the file could not be opened + ldx #$02 ; filenumber 2 + jsr CHKIN + ldy #$00 +@loop: + jsr READST + bne @eof ; either EOF or read error + jsr CHRIN + sta transfer_buffer,y + iny + bne @loop + ldax #$100 + stax tcp_send_data_len + ldax #transfer_buffer + jsr tcp_send + bcs @error_stored + ldy #0 + jmp @loop +@eof: + and #$40 ; end of file? + beq @readerror + lda #$00 + sty tcp_send_data_len + sta tcp_send_data_len+1 + ldax #transfer_buffer + jsr tcp_send + bcs @error_stored + +@close: + lda #0 +@store_error: + sta ip65_error +@error_stored: + jsr set_error_var + lda #$02 ; filenumber 2 + jsr CLOSE + ldx #$00 ; filenumber 0 = keyboard + jsr CHKIN ;keyboard now input device again + rts +@error: + lda #KPR_ERROR_DEVICE_FAILURE + jmp @store_error +@readerror: + lda #KPR_ERROR_FILE_ACCESS_FAILURE + jmp @store_error + +close_connection: + jsr tcp_close + bcs @error + lda #0 + sta ip65_error +@error: + jmp set_error_var + .data +data_arrived_flag: .byte 0 -basic_vartable_entries: - .byte $49,$CF ; IO$ - .byte 0 ;length 0 - .word 0; pointer - .word 0 ;2 dummy bytes - .byte $C9,$CF ; IO% - .byte 0 ;initial value HI - .byte 0 ;initial value = LO - .byte 0,0,0 ;3 dummy bytes - - .byte $C5,$D2 ; ER% - .byte 0 ;initial value HI - .byte 0 ;initial value = LO - .byte 0,0,0 ;3 dummy bytes - -basic_vartable_entries_length=*-basic_vartable_entries connected: .byte "connected - ",0 .bss transfer_buffer: .res $100 - diff --git a/client/cfg/c64_mlstub.cfg b/client/cfg/c64_mlstub.cfg index 39c73c4..f7ae43f 100644 --- a/client/cfg/c64_mlstub.cfg +++ b/client/cfg/c64_mlstub.cfg @@ -12,7 +12,7 @@ MEMORY { STARTUP: load = MAINRAM, type = ro; IP65_DEFAULTS: load = MAINRAM, type = ro; CODE: load = MAINRAM, type = ro; - + SELF_MODIFIED_CODE: load = MAINRAM, type = rw; RODATA: load = MAINRAM, type = ro; DATA: load = MAINRAM, type = rw, define = yes; BSS: load = MAINRAM, type = bss; diff --git a/client/cfg/c64fullprg.cfg b/client/cfg/c64fullprg.cfg new file mode 100644 index 0000000..02d5aed --- /dev/null +++ b/client/cfg/c64fullprg.cfg @@ -0,0 +1,26 @@ +MEMORY { + ZP: start = $02, size = $1A, type = rw ; + IP65ZP: start = $5f, size = $10, type = rw; + RAM: start = $07FF, size = $c7ab, file = %O; +} +SEGMENTS { + STARTUP: load = RAM, type = ro ,define = yes, optional=yes; + SELF_MODIFIED_CODE: load = RAM, type = rw,define = yes, optional=yes; + VIC_DATA: load = RAM, type = rw,align = $800, optional=yes; + RODATA: load = RAM, type = ro,define = yes, optional=yes; + CARTRIDGE_HEADER: load = RAM, type = ro, optional=yes; + + IP65_DEFAULTS: load = RAM, type = rw,define = yes, optional=yes; + DATA: load = RAM, type = rw,define = yes; + FONT_TABLE: load=RAM, type=rw, optional=yes,start=$2000; + + CODE: load = RAM, type = ro,define = yes; + + BSS: load = RAM, type = bss, optional=yes; + APP_SCRATCH: load = RAM, type = bss, optional=yes; + ZEROPAGE: load = ZP, type = zp, optional=yes; + IP65ZP: load = IP65ZP, type = zp, optional=yes; + TCP_VARS: load = RAM, type = bss, optional=yes; + HTTP_VARS: load = RAM, type = bss, optional=yes; + +} diff --git a/client/ip65/tcp.s b/client/ip65/tcp.s index d9377fb..2406c7f 100644 --- a/client/ip65/tcp.s +++ b/client/ip65/tcp.s @@ -933,7 +933,6 @@ tcp_process: beq @syn jmp @not_syn @syn: - ;for the moment, inbound connections not accepted. so send a RST ;is this the port we are listening on? lda tcp_inp+tcp_dest_port+1 @@ -947,6 +946,9 @@ tcp_process: lda #tcp_cxn_state_listening cmp tcp_state beq @this_is_connection_we_are_waiting_for + ;is this the current connection? that would mean our ACK got lost, so resend + jsr check_current_connection + bcc @this_is_connection_we_are_waiting_for rts ;if we've currently got a connection open, then ignore any new requests ;the sender will timeout and resend the SYN, by which time we may be diff --git a/client/kipperterm2/Makefile b/client/kipperterm2/Makefile index 6024182..99238fe 100644 --- a/client/kipperterm2/Makefile +++ b/client/kipperterm2/Makefile @@ -32,6 +32,7 @@ kipperterm2.o: kipperterm2.s $(INCFILES) ../inc/telnet.i ../inc/config_menu.i .. kipperterm2.d64: kipperterm2.prg addresses.txt abe.bas ripxplore.rb --init CbmDos $@ -a kipperterm2.prg + ripxplore.rb $@ -a 80columns -t C64Prg ripxplore.rb $@ -a addresses.txt -t C64Seq ripxplore.rb $@ -a abe -t C64Prg cp kipperterm2.d64 ../../server/boot diff --git a/client/kipperterm2/kipperterm2.s b/client/kipperterm2/kipperterm2.s index ce0831e..a20f42b 100644 --- a/client/kipperterm2/kipperterm2.s +++ b/client/kipperterm2/kipperterm2.s @@ -16,7 +16,7 @@ KEY_NEW_SERVER=KEYCODE_F5 XMODEM_IN_TELNET = 1 - GOPHER_BUFFER_SIZE = 8000 + GOPHER_BUFFER_SIZE = 2000 .include "../inc/gopher.i" .include "../inc/telnet.i"