diff --git a/Makefile b/Makefile deleted file mode 100644 index 47b521b..0000000 --- a/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -.PHONY: client clean dist distclean - -all: client dist dist-ip65 - -client: - make -C client all - -clean: - make -C client clean - rm -rf dist/netboot65 - rm -rf dist/ip65 - rm -f dist/*.zip - -dist: - rm -rf dist/netboot65 - ruby dist/make_dist.rb - -dist-ip65: - rm -rf dist/ip65 - ruby dist/make_dist_ip65.rb - -distclean: - make -C client distclean - rm -f *~ diff --git a/client/cfg/a2bin.cfg b/cfg/a2bin.cfg similarity index 97% rename from client/cfg/a2bin.cfg rename to cfg/a2bin.cfg index c792f94..775830c 100644 --- a/client/cfg/a2bin.cfg +++ b/cfg/a2bin.cfg @@ -1,25 +1,25 @@ - -MEMORY { - ZP: start = $00, size = $08, type = rw, define = yes; #zero size as we hand allocate all ZP locations - IP65ZP: start = $E0, size = $0, type = rw, define = yes; #zero size as we hand allocate all ZP locations - HEADER: start = $0000, size = $10, file = %O; - RAM: start = $800, size = $8000, file = %O, define=yes; - PAGE3: start = $2C0, size = 272; -} -SEGMENTS { - EXEHDR: load = HEADER, type = ro; - STARTUP: load = RAM,run=RAM, type = ro, define = yes, optional=yes; - CODE: load = RAM, run=RAM, type = ro, define = yes; - RODATA: load = RAM, run=RAM, type = ro , define = yes; - IP65_DEFAULTS: load = RAM, run=RAM, type = ro , define = yes; - DATA: load = RAM, run=RAM, type = rw , define = yes; - PAGE3: load = RAM,run=PAGE3, type = rw, define = yes, optional=yes; - HTTP_VARS: load = RAM, run=RAM, type = rw, optional=yes; - TCP_VARS: load = RAM, type = bss, optional=yes; - APP_SCRATCH: load = RAM, type = bss , optional=yes; - BSS: load=RAM, type = bss, define = yes; - ZEROPAGE: load = ZP, type = zp , optional=yes; - IP65ZP: load = IP65ZP, type = zp,optional=yes; -} - - + +MEMORY { + ZP: start = $00, size = $08, type = rw, define = yes; #zero size as we hand allocate all ZP locations + IP65ZP: start = $E0, size = $0, type = rw, define = yes; #zero size as we hand allocate all ZP locations + HEADER: start = $0000, size = $10, file = %O; + RAM: start = $800, size = $8000, file = %O, define=yes; + PAGE3: start = $2C0, size = 272; +} +SEGMENTS { + EXEHDR: load = HEADER, type = ro; + STARTUP: load = RAM,run=RAM, type = ro, define = yes, optional=yes; + CODE: load = RAM, run=RAM, type = ro, define = yes; + RODATA: load = RAM, run=RAM, type = ro , define = yes; + IP65_DEFAULTS: load = RAM, run=RAM, type = ro , define = yes; + DATA: load = RAM, run=RAM, type = rw , define = yes; + PAGE3: load = RAM,run=PAGE3, type = rw, define = yes, optional=yes; + HTTP_VARS: load = RAM, run=RAM, type = rw, optional=yes; + TCP_VARS: load = RAM, type = bss, optional=yes; + APP_SCRATCH: load = RAM, type = bss , optional=yes; + BSS: load=RAM, type = bss, define = yes; + ZEROPAGE: load = ZP, type = zp , optional=yes; + IP65ZP: load = IP65ZP, type = zp,optional=yes; +} + + diff --git a/client/cfg/c64prg.cfg b/cfg/c64prg.cfg similarity index 98% rename from client/cfg/c64prg.cfg rename to cfg/c64prg.cfg index 2ed6dd2..7a5e6cd 100644 --- a/client/cfg/c64prg.cfg +++ b/cfg/c64prg.cfg @@ -1,29 +1,29 @@ MEMORY { ZP: start = $02, size = $1A, type = rw ; IP65ZP: start = $5f, size = $10, type = rw; - RAM: start = $07FF, size = $77ab, file = %O; - RAM3000: start = $3000, size = $4800, type=rw; - RAM4000: start = $4000, size = $3800, type=rw; - RAM6000: start = $6000, size = $1800, type=rw; + RAM: start = $07FF, size = $77ab, file = %O; + RAM3000: start = $3000, size = $4800, type=rw; + RAM4000: start = $4000, size = $3800, type=rw; + RAM6000: start = $6000, size = $1800, type=rw; DISCARD: start = $77FF, size = $10; } SEGMENTS { STARTUP: load = RAM, type = ro ,define = yes, optional=yes; CODE: load = RAM, type = ro,define = yes; - DATA: load = RAM, type = rw,define = yes; - SELF_MODIFIED_CODE: load = RAM, type = rw,define = yes, optional=yes; + DATA: load = RAM, type = rw,define = 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; - IP65_DEFAULTS: load = RAM, type = rw,define = yes, optional=yes; - BSS: load = RAM, type = bss, optional=yes; - SAFE_BSS: load = RAM3000, type = bss, optional=yes; - BSS4K: load = RAM4000, type = bss, optional=yes; - DATA6K: load = RAM, run = RAM6000, type = rw, define = yes, optional=yes; + RODATA: load = RAM, type = ro,define = yes, optional=yes; + IP65_DEFAULTS: load = RAM, type = rw,define = yes, optional=yes; + BSS: load = RAM, type = bss, optional=yes; + SAFE_BSS: load = RAM3000, type = bss, optional=yes; + BSS4K: load = RAM4000, type = bss, optional=yes; + DATA6K: load = RAM, run = RAM6000, type = rw, define = yes, optional=yes; APP_SCRATCH: load = RAM, type = bss, optional=yes; ZEROPAGE: load = ZP, type = zp, optional=yes; - IP65ZP: load = IP65ZP, type = zp, optional=yes; - EXEHDR: load = DISCARD, type = ro, optional=yes; - TCP_VARS: load = RAM, type = bss, optional=yes; - HTTP_VARS: load = RAM, type = bss, optional=yes; + IP65ZP: load = IP65ZP, type = zp, optional=yes; + EXEHDR: load = DISCARD, type = ro, optional=yes; + TCP_VARS: load = RAM, type = bss, optional=yes; + HTTP_VARS: load = RAM, type = bss, optional=yes; } diff --git a/client/cfg/vic20prg.cfg b/cfg/vic20prg.cfg similarity index 97% rename from client/cfg/vic20prg.cfg rename to cfg/vic20prg.cfg index 7c6c198..98d6b90 100644 --- a/client/cfg/vic20prg.cfg +++ b/cfg/vic20prg.cfg @@ -1,23 +1,23 @@ -#assumes a fully expanded VIC 20 -MEMORY { - ZP: start = $02, size = $1A, type = rw ; - IP65ZP: start = $5f, size = $10, type = rw; - RAM: start = $11FF, size = $6e00, file = %O; -} -SEGMENTS { - STARTUP: load = RAM, type = ro ,define = yes, optional=yes; - CODE: load = RAM, type = ro,define = yes; - DATA: load = RAM, type = rw,define = 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; - IP65_DEFAULTS: load = RAM, type = rw,define = yes, optional=yes; - BSS: load = RAM, type = bss, optional=yes; -# SAFE_BSS: load = RAM3000, 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; - -} +#assumes a fully expanded VIC 20 +MEMORY { + ZP: start = $02, size = $1A, type = rw ; + IP65ZP: start = $5f, size = $10, type = rw; + RAM: start = $11FF, size = $6e00, file = %O; +} +SEGMENTS { + STARTUP: load = RAM, type = ro ,define = yes, optional=yes; + CODE: load = RAM, type = ro,define = yes; + DATA: load = RAM, type = rw,define = 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; + IP65_DEFAULTS: load = RAM, type = rw,define = yes, optional=yes; + BSS: load = RAM, type = bss, optional=yes; +# SAFE_BSS: load = RAM3000, 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/Makefile b/client/Makefile deleted file mode 100644 index 544281c..0000000 --- a/client/Makefile +++ /dev/null @@ -1,61 +0,0 @@ - -.PHONY: ip65 drivers test clean distclean kipperterm2 examples carts basic wiznet a2 - - -all: ip65 drivers test carts examples basic kipperterm2 wiznet a2 - -ip65: - make -C ip65 all - -drivers: - make -C drivers all - -examples: - make -C examples all - -a2: - make -C a2 all - -test: - make -C test TARGET=$(TARGET) all - - -kipperterm2: - make -C kipperterm2 all - - -carts: - make -C carts all - -basic: - make -C basic all - -wiznet: - make -C wiznet all - - -clean: - make -C ip65 clean - - make -C drivers clean - make -C test clean - make -C carts clean - - make -C kipperterm2 clean - - make -C basic clean - - -distclean: - make -C ip65 distclean - - make -C drivers clean - make -C test distclean - - make -C carts distclean - - make -C kipperterm2 distclean - - make -C basic distclean - - rm -f *~ diff --git a/client/a2/Makefile b/client/a2/Makefile deleted file mode 100644 index 62ad876..0000000 --- a/client/a2/Makefile +++ /dev/null @@ -1,54 +0,0 @@ -CC=cl65 -AS=ca65 -LD=ld65 -CFLAGS=-Oirs -t $(TARGET) -AFLAGS= - - - -IP65LIB=../ip65/ip65.lib -IP65TCPLIB=../ip65/ip65_tcp.lib -A2UTHERLIB=../drivers/a2uther.lib - -INCFILES=\ - ../inc/common.i\ - ../inc/commonprint.i\ - ../inc/net.i\ - -all: \ - ip65 \ - drivers \ - amper.dsk \ - - -ip65: - make -C ../ip65 all - -drivers: - make -C ../drivers all - -%.o: %.s - $(AS) $(AFLAGS) $< - -#tokenize_asoft comes from http://www.deater.net/weave/vmwprod/apple/dos33fs.html -%.bas: %.applesoft - tokenize_asoft < $*.applesoft > $*.bas - -%.pg2: %.o $(IP65LIB) $(A2UTHERLIB) $(INCFILES) ../cfg/a2bin.cfg - $(LD) -vm --mapfile $*.map -C ../cfg/a2bin.cfg -o $*.pg2 $(AFLAGS) $< $(IP65TCPLIB) $(A2UTHERLIB) - -amper.dsk: autoexec.bas amper.pg2 hello.bas - ripxplore.rb amper.dsk --init AppleDos - ripxplore.rb amper.dsk -a amper.pg2 -t AppleBinary - cp hello.bas hello - ripxplore.rb amper.dsk -a hello -t Applesoft - rm hello - ripxplore.rb amper.dsk -a autoexec.bas -t Applesoft - -clean: - rm -f *.o *.pg2 *.map *.lst - rm -f ip65test.dsk - rm -f amper.dsk - -distclean: clean - rm -f *~ diff --git a/client/a2/amper.s b/client/a2/amper.s deleted file mode 100644 index c0b9863..0000000 --- a/client/a2/amper.s +++ /dev/null @@ -1,646 +0,0 @@ - .include "../inc/common.i" - .include "../inc/commonprint.i" - .include "../inc/a2const.i" - .include "../inc/net.i" - - .import exit_to_basic - .import cfg_get_configuration_ptr - .import dns_ip - .import dns_resolve - .import dns_set_hostname - .import icmp_ping - .import icmp_echo_ip - - - .import copymem - .importzp copy_src - - .importzp copy_dest - .importzp buffer_ptr - .importzp scratch_ptr - - .import http_parse_request - .import http_get_value - .import http_variables_buffer - - .import tcp_inbound_data_ptr - .import tcp_inbound_data_length - .import tcp_send_data_len - .import tcp_send - .import check_for_abort_key - .import tcp_connect_remote_port - .import tcp_remote_ip - .import tcp_listen - .import tcp_callback - .import tcp_close - - .import __CODE_LOAD__ - .import __CODE_SIZE__ - .import __RODATA_SIZE__ - .import __DATA_SIZE__ - .import __IP65_DEFAULTS_SIZE__ - .import __BSS_RUN__ - .import __BSS_SIZE__ - - END_OF_BSS = __BSS_RUN__+__BSS_SIZE__ - -.segment "EXEHDR" ;this is what gets put an the start of the file on the Apple 2 - .addr __CODE_LOAD__-$03 ; Start address - .word __CODE_SIZE__+__RODATA_SIZE__+__DATA_SIZE__+__IP65_DEFAULTS_SIZE__+4 ; file size - jmp init -.code - -init: - jsr ip65_init - bcc @init_ok - ldax #@no_nic - jsr print - - jmp exit_to_basic -@no_nic: - .byte "NO NIC - UNINSTALLING",0 -@install_msg: - .byte " FOUND",13,"APPLESOFT.NET USING $801-$" - - .byte 0 -@init_ok: - ;print the banner - ldax #eth_driver_name - jsr print_ascii_as_native - ldax #@install_msg - jsr print - print_hex_double #END_OF_BSS - jsr print_cr - - ;take over the ampersand vector - ldax AMPERSAND_VECTOR+1 - stax old_amper_handler - ldax #amper_handler - stax AMPERSAND_VECTOR+1 - - lda #$FF - sta CURLIN+1 ;put into 'immediate' mode - ldax #END_OF_BSS+1 - stax TXTTAB - lda #0 - sta END_OF_BSS ;if the byte before the start of the BASIC is not zero, we - ;get a weird 'SYNTAX ERROR IN LINE' because - ;STXTPT (called by RUN) sets TXTPTR (address of next BASIC token) to be TXTTAB-1 - ;if this byte is zero, then NEWSTT tries to execute that byte - jsr SCRTCH ;reset BASIC now we have updated the start address - lday #chain_cmd - jsr STROUT - jmp exit_to_basic - -print_error: - jsr print - ldax #error - jsr print - lda ip65_error - jsr print_hex - jsr print_cr - sec - rts -amper_handler: - ;see if & is followed by one of our keywords - - ldx #0 - ldy #0 - lda keyword_table - -@check_one_handler: - cmp #$FF ;end of table? - beq exit_to_old_handler - cmp (TXTPTR),y ;char in line - beq @this_char_ok -@skip_to_next_handler_loop: - inx - lda keyword_table,x - bne @skip_to_next_handler_loop - inx ;skip first part of handler address - inx ;skip next part of handler address - ldy #$FF -@this_char_ok: - iny - inx - lda keyword_table,x ;get cmd char - bne @check_one_handler - ;if we get here, we have matched a keyword, and X points to the zero terminating the keyword, Y is length of keyword - lda keyword_table+2,x ;get high byte of handler address - pha - lda keyword_table+1,x ;get low byte of handler address - pha - jmp ADDON ;fix-up TXTPTR - on return control will transfer to address we just pushed - -exit_to_old_handler: - jmp $ffff -old_amper_handler=exit_to_old_handler+1 - - get_optional_byte: - jsr CHRGOT - beq @no_param ;leave X as it was - jmp COMBYTE -@no_param: - rts - -extract_string: - jsr FRMEVL - jsr FRESTR ;if not string, will create type mismatch error - sta param_length - tay - lda #0 - sta transfer_buffer,y - dey -@loop: - lda (INDEX),y - sta transfer_buffer,y - dey - bpl @loop - rts - -get_ip_parameter: - stax buffer_ptr - jsr extract_string - ldax #transfer_buffer - - jsr dns_set_hostname - - bcs @error - jsr dns_resolve - bcc @ok -@error: - ldax #address_resolution - jmp print_error - -@ok: - ldax #dns_ip - ldx #4 -@copy_dns_ip: - lda dns_ip,y - sta (buffer_ptr),y - iny - dex - bne @copy_dns_ip - rts - -ipcfg_handler: - jmp print_ip_config - -ping_handler: - ldax #icmp_echo_ip - jsr get_ip_parameter - bcc @no_error - rts -@no_error: - ;is there an optional parameter? - ldx #3 - jsr get_optional_byte - stx ping_counter - - ldax #pinging - jsr print - ldax #dns_ip - jsr print_dotted_quad - jsr print_cr - -@ping_loop: - jsr icmp_ping - bcs @error - lda #'.' -@print_and_loop: - jsr print_a - lda $c000 ;key pressed - sta $c010 ;clear keyboard - cmp #$9B ;escape - beq @done - dec ping_counter - bne @ping_loop -@done: - jmp print_cr -@error: - lda #'!' - jmp @print_and_loop - - -dhcp_handler: - jsr dhcp_init - bcc @init_ok - jsr ip65_init ;if DHCP failed, then reinit the IP stack (which will reset IP address etc that DHCP messed with to default values) - -@init_failed: - ldax #dhcp - jmp print_error -@init_ok: - rts - -myip_handler: - ldax #cfg_ip - jmp get_ip_parameter - -dns_handler: - ldax #cfg_dns - jmp get_ip_parameter - -gateway_handler: - ldax #cfg_gateway - jmp get_ip_parameter - -netmask_handler: - ldax #cfg_netmask - jmp get_ip_parameter - - -skip_comma_get_integer: - jsr CHKCOM - get_integer: - jsr CHRGOT - jsr LINGET - ldax LINNUM - rts - - -httpd_handler: - jsr flush_handler ;clean out the last connection - jsr get_integer - stax httpd_port_number - tsx - stx top_of_stack - ldax #__http_variables_buffer - stax http_variables_buffer - - ldax #listening - jsr print - ldax #cfg_ip - jsr print_dotted_quad - lda #':' - jsr print_a - ldax httpd_port_number - jsr print_integer - jsr print_cr - -@listen: - jsr tcp_close - ldax httpd_io_buffer - stax tcp_buffer_ptr - - ldax #http_callback - stax tcp_callback - ldax httpd_port_number - - jsr tcp_listen - bcc @connect_ok - jmp END4 - -@connect_ok: - ldax #connection_from - jsr print - ldax #tcp_remote_ip - jsr print_dotted_quad - lda #':' - jsr print_a - ldax tcp_connect_remote_port - - jsr print_integer - jsr print_cr - lda #0 - sta connection_closed - sta found_eol - sta polling_counter - -@main_polling_loop: - jsr ip65_process - jsr ISCNTC ;check for ^C, if so print error message, warm start BASIC - - lda found_eol - bne @got_eol - lda #75 - jsr $fca8 ;wait for about 15ms - this gives a total timeout of ~4seconds - inc polling_counter - bne @main_polling_loop - jmp @listen - -@got_eol: - - jsr reset_output_buffer - - ldy #$FF -: - iny - lda status_ok,y - sta status_code_buffer,y - bne :- - - ldy #$FF -: - iny - lda text_html,y - sta content_type_buffer,y - bne :- - - sta sent_header - - ldax httpd_io_buffer - jmp got_http_request - -http_callback: - lda tcp_inbound_data_length+1 - cmp #$ff - bne @not_eof - inc connection_closed -@done: - rts -@not_eof: - lda found_eol - bne @done - -;copy this chunk to our input buffer - ldax tcp_buffer_ptr - stax copy_dest - ldax tcp_inbound_data_ptr - stax copy_src - ldax tcp_inbound_data_length - jsr copymem - -;increment the pointer into the input buffer - clc - lda tcp_buffer_ptr - adc tcp_inbound_data_length - sta tcp_buffer_ptr - sta copy_src - lda tcp_buffer_ptr+1 - adc tcp_inbound_data_length+1 - sta tcp_buffer_ptr+1 - sta copy_src+1 - -;put a null byte at the end (assumes we have set copy_src already) - lda #0 - tay - sta (copy_src),y - -;look for CR or LF in input - sta found_eol - ldax httpd_io_buffer - stax get_next_byte+1 - -@look_for_eol: - jsr get_next_byte - cmp #$0a - beq @found_eol - cmp #$0d - bne @not_eol -@found_eol: - inc found_eol - rts -@not_eol: - cmp #0 - bne @look_for_eol - rts - -send_buffer: - ldax output_buffer_length - stax tcp_send_data_len - ldax httpd_io_buffer - jsr tcp_send - -reset_output_buffer: - ldax httpd_io_buffer - sta xmit_a_ptr+1 - stx xmit_a_ptr+2 - lda #0 - sta output_buffer_length - sta output_buffer_length+1 - rts - - -emit_string: - stax scratch_ptr - ldy #0 -@next_byte: - lda (scratch_ptr),y - beq @done - jsr xmit_a - iny - bne @next_byte -@done: - rts - -got_http_request: - - jsr http_parse_request - - ldax #path - jsr print - lda #$02 - jsr http_get_value - stax scratch_ptr - jsr print - jsr print_cr - - ldy #0 -@find_null: - lda (scratch_ptr),y - beq @found_null - iny - bne @find_null -@found_null: - sty param_length - - lda #'P' - sta VARNAM - lda #'A'+$80 - sta VARNAM+1 - - jsr GETVAR ;find the variable of this name (or else make a blank one) - lda param_length - jsr GETSPA ;create space in the string table of appropriate length - ldy #$00 ;set up string variable pointer - sta (VARPNT),Y ;string length - iny - lda FRESPC ;lo byte of area just reserved - sta (VARPNT),Y - iny - lda FRESPC+1 ;hi byte of area just reserved - sta (VARPNT),Y - - ldx scratch_ptr - ldy scratch_ptr+1 - lda param_length - jsr MOVSTR - - ;now restore stack to how it was when &HTTPD was called, and return to BASIC - ldx top_of_stack - txs - rts - - -bang_handler: - jsr extract_string - lda sent_header - bne :+ - jsr send_header -: - ldy #0 - sty string_ptr -@loop: - lda transfer_buffer,y - jsr xmit_a - inc string_ptr - ldy string_ptr - cpy param_length - bne @loop - rts - -send_header: - inc sent_header - ldax #http_version - jsr emit_string - ldax #status_code_buffer - jsr emit_string - ldax #crlf - jsr emit_string - ldax #content_type - jsr emit_string - ldax #content_type_buffer - jsr emit_string - ldax #end_of_header - jsr emit_string - -flush_handler: - lda output_buffer_length - bne :+ - ldx output_buffer_length+1 - bne :+ - rts -: - jmp send_buffer - -.rodata -keyword_table: -.byte "IPCFG",0 -.word ipcfg_handler-1 -.byte "DHCP",0 -.word dhcp_handler-1 -.byte "PING",0 -.word ping_handler-1 -.byte "MYIP",0 -.word myip_handler-1 -.byte "DNS",0 -.word dns_handler-1 -.byte "G",$c5,"EWAY",0 ;$C5 is token for 'AT' -.word gateway_handler-1 -.byte "NETMASK",0 -.word netmask_handler-1 -.byte "HTTPD",0 -.word httpd_handler-1 -.byte "!",0 -.word bang_handler-1 -.byte "FLUSH",0 -.word flush_handler-1 - -.byte $ff - -keyword_table_size=*-keyword_table -.if keyword_table_size>255 - .error "KEYWORD TABLE TOO BIG!" -.endif - -CR=$0D -LF=$0A - -dhcp: -.byte "DHCP",0 -address_resolution: -.byte "ADDRESS RESOLUTION",0 -error: -.byte " ERROR $",0 -pinging: -.byte "PINGING ",0 - -path: - .byte "PATH: ",0 -http_version: - .byte "HTTP/1.0 ",0 - -status_ok: - .byte "200 OK",0 -status_error: - .byte "500 " -system_error: - .byte "SYSTEM ERROR",0 -content_type: - .byte "Content-Type: ",0 -text_html: - .byte "text/html",0 - -end_of_header: - .byte CR,LF - .byte "Connection: Close",CR,LF - .byte "Server: AppleSoft.NET/0.2",CR,LF -crlf: - .byte CR,LF,0 - -connection_from: .byte "CONNECTION FROM ",0 -chain_cmd: - -.byte 13,4,"RUN AUTOEXEC.BAS",13,0 - -listening: -.byte"LISTENING ON ",0 - - - -.data - - -httpd_io_buffer: .word __httpd_io_buffer -httpd_port_number: .word 80 - - -get_next_byte: - lda $ffff - inc get_next_byte+1 - bne @skip - inc get_next_byte+2 -@skip: - rts - - -xmit_a: - -xmit_a_ptr: - sta $ffff - inc xmit_a_ptr+1 - bne :+ - inc xmit_a_ptr+2 -: - inc output_buffer_length - bne :+ - inc output_buffer_length+1 - lda output_buffer_length+1 - cmp #2 - bne :+ - stx temp_x - jsr send_buffer - ldx temp_x -: - rts - -.bss - -param_length: .res 1 -ping_counter: .res 1 -handler_address: .res 2 -temp_x: .res 1 -output_buffer_length: .res 2 -sent_header: .res 1 -content_type_buffer: .res 128 -status_code_buffer: .res 128 -found_eol: .byte 0 -connection_closed: .byte 0 -tcp_buffer_ptr: .res 2 -top_of_stack: .res 1 -polling_counter: .res 1 -string_ptr: .res 1 -transfer_buffer: .res 256 -__http_variables_buffer: .res 256; temp buffer for storing variables -__httpd_io_buffer: .res 1024 ;temp buffer for storing inbound requests. diff --git a/client/a2/autoexec.applesoft b/client/a2/autoexec.applesoft deleted file mode 100644 index f3cc47e..0000000 --- a/client/a2/autoexec.applesoft +++ /dev/null @@ -1,17 +0,0 @@ -10 PRINT "HELLO FROM BASIC" -20 &MYIP"1.2.3.4" -21 &NETMASK"255.0.255.0" -22 &GATEWAY"7.6.5.4" -23 &DNS"8.8.7.6" -25 &IPCFG -30 &DHCP -40 &IPCFG -50 &PING "192.168.10.2" -60 &PING "192.168.10.2" , 5 -70 PA$="DUMMY" -100 &HTTPD 8080 -1000 PRINT "HELLO FOO!" -1005 PRINT PA$ -1010 &!"HOWDY DOODY DOO!" -1020 &FLUSH -1030 GOTO 100 \ No newline at end of file diff --git a/client/a2/autoexec.bas b/client/a2/autoexec.bas deleted file mode 100644 index 068853e..0000000 Binary files a/client/a2/autoexec.bas and /dev/null differ diff --git a/client/a2/autoexec.s b/client/a2/autoexec.s deleted file mode 100644 index c572f73..0000000 --- a/client/a2/autoexec.s +++ /dev/null @@ -1,24 +0,0 @@ - .include "../inc/common.i" - .include "../inc/a2const.i" - .import exit_to_basic - - - .import __CODE_LOAD__ - .import __CODE_SIZE__ - .import __RODATA_SIZE__ - .import __DATA_SIZE__ - -.segment "EXEHDR" ;this is what gets put an the start of the file on the Apple 2 - .addr __CODE_LOAD__-$03 ; Start address - .word __CODE_SIZE__+__RODATA_SIZE__+__DATA_SIZE__+4 ; file size - jmp init - -.code - -init: - lday #chain_cmd - jsr STROUT - - jmp exit_to_basic - chain_cmd: - .byte 13,4,"CATALOG",13,0 \ No newline at end of file diff --git a/client/a2/hello.applesoft b/client/a2/hello.applesoft deleted file mode 100644 index 1df0a3a..0000000 --- a/client/a2/hello.applesoft +++ /dev/null @@ -1 +0,0 @@ -10 PRINT CHR$(4);"BRUN AMPER.PG2" diff --git a/client/a2/ip65test.dsk.original b/client/a2/ip65test.dsk.original deleted file mode 100644 index d490f5c..0000000 Binary files a/client/a2/ip65test.dsk.original and /dev/null differ diff --git a/client/a2/make b/client/a2/make deleted file mode 100644 index 925025d..0000000 Binary files a/client/a2/make and /dev/null differ diff --git a/client/basic/BoB.htm b/client/basic/BoB.htm deleted file mode 100644 index ef84c8c..0000000 --- a/client/basic/BoB.htm +++ /dev/null @@ -1,189 +0,0 @@ -

BASIC ON BAILS

-

COMMAND SUMMARY

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CommandDescrptionParametersExample
IPCFGDisplay the current IP stack configurationnone
  • IPCFG
  • MACSet the last 3 bytes of the MAC address. Top 3 bytes will always be "00:80:10".
    This command - also resets the whole IP stack, so new IP address will need to be assigned (via MYIP or DHCP) after calling MAC
    3 byte string
  • MAC "FOO" - MAC will become 00:80:10:46:4F:4F (in PETSCII, $46 is 'F' and $4F is 'O')
  • DHCPUse DHCP to assign IP address, netmask, default gateway and DNS server none
  • DHCP
  • MYIPAssign a new IP address
  • IP address (string)
  • MYIP"10.1.1.2"
  • NETMASKAssign a new netmask
  • netmask (string)
  • NETMASK"255.255.255.0"
  • GATEWAYAssign a new default gateway (router to send non-local traffic to)
  • gateway IP address (string)
  • GATEWAY"10.1.1.1"
  • DNSSpecify the DNS server to be used for resolving hostnames
  • DNS server IP address (string)
  • DNS"10.1.1.1"
  • PINGSends a number of ICMP echo requests to the specified host. For each packet sent, if a response is received a "." is displayed, if an error occurs (including a timeout) then a "!" is displayed.
  • hostname or IP ddress (string)
  • [optional] number of PING request to be sent (1..255) - default is 3
  • PING"JAMTRONIX.COM"
  • PING"10.1.1.1",10
  • HTTPDstart listening on a TCP port for inbound HTTP requests. When a HTTP request is received, go to the specified -default line number, unless the request happens to be for a path that has previously been HOOKed
  • port number (1..65535)
  • line number (1..65535)
  • HTTPD80,100 - will listen on port 80 and GOTO line 100 when a HTTP request is received
  • HOOKsociate the 'path' part of a URL with a BASIC line number to jump to when a request for the specified path is received
  • path (string) - must start with "/"
  • line number (1..65535)
  • HOOK"/HELLO",200 - line 200 will be executed if request for "/HELLO" is received
  • TYPEchange the HTTP Content Type field in the HTTP header -from the default "text/html" to whatever is specified. Be careful with -case - the remote end will be expecting ASCII not PETSCII! For this to be effective, it must -be set BEFORE any data is output with the ! or XSEND keywords
  • mime type (string)
  • TYPE"application/octet-stream"
  • STATUSchange the HTTP status line from default -"200 OK". Be careful you include the 3 digit code (as an ASCII string) -then a space then a free form status description (ASCII NOT PETSCII). -To be effective, it must be set BEFORE any data is output with the ! or XSEND keywords
  • HTTP status line (string)
  • STATUS"404 File Not Found"
  • !Send specified string expression. If no -HTTP header has been sent yet, one will be sent now. -
  • string to output
  • !"<H1>HELLO WORLD</H1>"
  • XSENDSend a file from the default drive. If the file does -not exist, then an error message will be sent to the remote browser. If no HTTP header has -been sent yet, one will be sent first.
  • filename (string)
  • XSEND"FAVICON.ICO"
  • YIELDfinish processing the current request, go back and wait for -another HTTP request.
  • none
  • YIELD
  • -

    Magic Variables

    -The following BASIC variables are set by BASIC ON BAILS whenever a HTTP request is being handled. -

    PA$

    -Set to the "path" part of the HTTP request. -

    Query String Variables

    -For each variable in the query string part of the HTTP request,the value is -decoded and stuck into a BASIC string variable. -
    -
    -Only the first letter of the query string variable is significant, -i.e. query strings N, NA, NAME, all would map to N$. -
    -
    -If there are multiple query string variables that all start with the -same letter, the LAST such variable in the query string is the one -that would be effective -.e.g if BASIC ON BAILS is processing a HTTP request with a query string /FOO?N=1&NA=2?NAME=3 then -in the BASIC handler, N$ would be "3", and NA$ and NAME$ would be -empty (BASIC only treats first 2 chars as significant anyway, so NA$ -is same as NAME$) -
    -

    STARTUP

    -If you try and load BASIC ON BAILS twice (or some other BASIC extender before BASIC ON BAILS) you will get an 'insufficient memory' error. -
    -
    - -After BASIC ON BAILS has been installed, it will attempt to load (and run) a file (from whatever device BASIC ON BAILS was loaded from itself) called "INDEX.BAS". -If this file does not exist, then BASIC ON BAILS will exit with 'FILE NOT FOUND ERROR IN 10". This error can be ignored - you can load any file you want from then, or type -in a new one, or even use the commands in interactive mode. -
    -
    -

    ERROR HANDLING

    -Before HTTPD is called, BASIC errors are treated normally, i.e. on a SYNTAX ERROR or TYPE MISMATCH error, an error will be displayed on the screen, and -program execution will stop. But once you have fired up HTTPD, any BASIC errors are displayed on the -screen AND passed back to the browser as a HTTP error, and are non-fatal i.e. the HTTPD loop will keep running. You can exit HTTPD by -pressing RUN/STOP though. -

    EXAMPLE

    -
    -
    -5 MAC CHR$(192)+CHR$(29)+CHR$(85)
    -10 DHCP
    -20 HOOK"/HELLO",1000 
    -25 FA$="/"+CHR$(102)+CHR$(97)+CHR$(118)+CHR$(105)+CHR$(99)+CHR$(111)
    -27 FA$=FA$+CHR$(110)+CHR$(46)+CHR$(105)+CHR$(99)+CHR$(111)
    -30 HOOKFA$,2000
    -40 HTTPD80,100
    -
    -100 !"<H1>HELLO</H1>"
    -110 !"<FORM ACTION=/HELLO>"
    -120 !"WHAT'S YOUR NAME?"
    -130 !"<INPUT TYPE=TEXT NAME=N>"
    -140 !"</FORM>"
    -200 YIELD
    -
    -1000!"HELLO "+N$+", I'M A C64 RUNNING BASIC ON BAILS."
    -1010 FOR I=1 TO 10
    -1020 !"<BR>"
    -1030 !STR$(I)
    -1040 NEXT I
    -1100 YIELD
    -
    -2000 TYPE"IMAGE/X-ICON"
    -2010 XSEND"FAVICON.ICO"
    -2020 YIELD
    -
    -
    -
    - - diff --git a/client/basic/KB.htm b/client/basic/KB.htm deleted file mode 100644 index bfba08f..0000000 --- a/client/basic/KB.htm +++ /dev/null @@ -1,193 +0,0 @@ -

    KIPPER BASIC

    -

    COMMAND SUMMARY

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    CommandDescrptionParametersExample
    IPCFGDisplay the current IP stack configurationnone
  • IPCFG
  • MACSet the last 3 bytes of the MAC address. Top 3 bytes will always be "00:80:10".
    This command - also resets the whole IP stack, so new IP address will need to be assigned (via MYIP or DHCP) after calling MAC
    3 byte string
  • MAC "FOO" - MAC will become 00:80:10:46:4F:4F (in PETSCII, $46 is 'F' and $4F is 'O')
  • DHCPUse DHCP to assign IP address, netmask, default gateway and DNS server none
  • DHCP
  • MYIPAssign a new IP address
  • IP address (string)
  • MYIP"10.1.1.2"
  • NETMASKAssign a new netmask
  • netmask (string)
  • NETMASK"255.255.255.0"
  • GATEWAYAssign a new default gateway (router to send non-local traffic to)
  • gateway IP address (string)
  • GATEWAY"10.1.1.1"
  • DNSSpecify the DNS server to be used for resolving hostnames
  • DNS server IP address (string)
  • DNS"10.1.1.1"
  • TFTPSpecify the TFTP server that will be accessed by TFPUT and TFGET.
  • TFTP server IP address or hostname (string)
  • TFTP"10.1.1.5"
  • TFTP"JAMTRONIX.COM"
  • PINGSends a number of ICMP echo requests to the specified host. For each packet sent, if a response is received a "." is displayed, if an error occurs (including a timeout) then a "!" is displayed.
  • hostname or IP ddress (string)
  • [optional] number of PING request to be sent (1..255) - default is 3
  • PING"JAMTRONIX.COM"
  • PING"10.1.1.1",10
  • NETCATOpen a TCP connection to a remote server. Any data received on the connection will be displayed on screen, any keypress will be sent to the remote server. To exit, hit RUN/STOP.

    The optional mode paramater determines whether the connection should be in PETSCII 'char at a time' mode, where every keypress is sent 'as is' to the remote site, or ASCII 'line mode', which allows a line to be edited and is sent (with a CR/LF at the end) only when the RETURN key is pressed. In this mode, data is converted between the PETSCII character set and standard ASCII - you will need to shift to the "lower case" char set for this to display properly. -

    The PETSCII mode is appropriate for connecting to e.g. a PETSCII BBS. The ASCII mode is appropriate for connecting to a server running a "network ASCII" derived protocol, e.g. SMTP or HTTP. - ' - -
  • hostname or IP ddress (string)
  • port number (1..65535)
  • [optional] mode:
    • 0=PETSCII (default)
    • 1=ASCII
  • NETCAT"JAMTRONIX.COM",6464
  • NETCAT"10.1.1.1",25,1
  • TFPUTUpload a file to a TFTP server. By default, TFPUT will use the broadcast address (255.255.255.255), meaning -any TFTP server on the LAN will respond. To send a file to a specific TFTP server (including one not on the local network), specify the -destination TFTP server with the "TFTP" command prior to calling TFPUT. The filename specified will be looked for on whichever drive was last accessed.
  • filename (string)
  • TFPUT"KIPPERBAS.PRG"
  • TFGETDownload a file from a TFTP server. By default, TFPUT will use the broadcast address (255.255.255.255), meaning -any TFTP server on the LAN will respond. To download a file from a specific TFTP server (including one not on the local network), specify the -destination TFTP server with the "TFTP" command prior to calling TFGET. The file will be written (as a PRG file) to whichever drive was last accessed.
  • filename (string)
  • TFGET"KIPPERBAS.PRG"
  • TCPCONNECTOpen a TCP connection to a remote server.
  • hostname or IP address (string)
  • port number (1..65535)
  • TCPCONNECT"JAMTRONIX.COM",70
  • TCPCONNECT"10.1.1.1",80
  • TCPLISTENWait for an inbound TCP connection from a remote client. This is a blocking command, i.e. the BASIC program will not continue executing until either an inbound connection is made, or the program is terminated by pressing RUN/STOP
  • port number (1..65535)
  • TCPLISTEN 80
  • POLLCheck for network traffic. If data has arrived on a previously opened TCP connection, that data (up to a maximum of 255 bytes) will be set into string variable IN$.If no data has arrived since the last POLL, then IN$ will be an empty string. Integer variables CO% and ER% -are also set to indicate current connection state and error conditions (if any). - - -nonePOLL
    TCPSENDSend a string (up to 255 bytes) over a previously opened connection.Integer variables CO% and ER% are set to indicate current connection state and any error condition which may occur during the sending of the file. NB - in the current implementation of Kipper BASIC, it is possible for data to arrive during a call to TCPSEND, which may not be passed through to the BASIC program.
  • data (string)
  • TCPSEND"HELLO "+"WORLD"
  • TCPBLATSend a file (of any length) over a previously opened connection. The file will be looked for on the current 'default' device, i.e. which ever drive was last accessed. Integer variables CO% and ER% ae aset to indicate current connection state and any error condition which may occur during the sending of the file. NB - in the current implementation of Kipper BASIC, it is possible for data to arrive during a call to TCPSEND, which may not be passed through to the BASIC program.
  • filename (string)
  • TCPBLAT"GOPHERMAP.TXT"
  • UDPSENDSend a string (up to 255 bytes) over UDP . There is no need to connect first -
  • destination hostname or IP address (string) -
  • destination port number (1..65535) -
  • local port number (1..65535) -
  • data (string) -
  • UDPSEND"JAMTRONIX.COM",7,6464,"echo test"
  • - -

    Magic Variables

    -The following BASIC variables are set by the TCP commands and POLL. -

    CO%

    -
  • CO%=1 means there is a current TCP connection
  • -
  • CO%=0 means there is no current TCP connection (either one has never been opened, or else it has been closed) - -

    ER%

    -ER% is set to indicate any error occuring inside the ip65 TCP/IP stack that Kipper BASIC is built on top of. -Possible values: - - - - - - - - - - - - - - - - - - - -
    ERROR CODE
    HEX / DEC
    DESCRIPTION
    $80 / 128PORT IN USE
    $81 / 129TIMEOUT ON RECEIVE
    $82 / 130TRANSMIT FAILED
    $83 / 131TRANSMISSION REJECTED BY PEER
    $84 / 132INPUT TOO LARGE
    $85 / 133DEVICE FAILURE
    $86 / 134ABORTED BY USER
    $87 / 135LISTENER NOT AVAILABLE
    $88 / 136NO SUCH LISTENER
    $89 / 137CONNECTION RESET BY PEER
    $8A / 138CONNECTION CLOSED
    $8B / 139TOO MANY ERRORS
    $90 / 140FILE ACCESS FAILURE
    $A0 / 160MALFORMED URL
    $A1 / 161DNS LOOKUP FAILED
    $FE / 254OPTION NOT SUPPORTED
    $FF / 255FUNCTION NOT SUPPORTED
    - -

    STARTUP

    -If you try and load Kipper BASIC twice (or some other BASIC extender before Kipper BASIC) you will get an 'insufficient memory' error. -
    -
    - -After Kipper BASIC has been installed, it will attempt to load (and run) a file (from whatever device Kipper BASIC was loaded from) called "AUTOEXEC.BAS". -If this file does not exist, then Kipper BASIC will exit with 'FILE NOT FOUND ERROR IN 10". This error can be ignored - you can load any file you want from then, or type -in a new one, or even use the commands in interactive mode. -
    -
    -For example, try: -
    -DHCP:NETCAT"JAMTRONIX.COM",6464
    -
    - - diff --git a/client/basic/Makefile b/client/basic/Makefile deleted file mode 100644 index c2d6d83..0000000 --- a/client/basic/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -AS=ca65 -LD=ld65 -CFLAGS=-Oirs -t $(TARGET) -AFLAGS= - -INCFILES=\ - ../inc/common.i\ - ../inc/commonprint.i\ - ../inc/net.i\ - ../inc/menu.i\ - ../inc/kipper_constants.i\ - ../inc/version.i\ - -IP65LIB=../ip65/ip65_tcp.lib -C64RRNETLIB=../drivers/c64rrnet.lib -VIC20RRNETLIB=../drivers/vic20rrnet.lib - -all: ip65 kipperbas.d64 bails.d64 kipperbasv20.prg - -ip65: - make -C ../ip65 all - -%.o: %.s $(INCFILES) timestamp.rb - ruby timestamp.rb > timestamp.i - $(AS) $(AFLAGS) $< - -%.prg: %.o $(IP65LIB) $(C64RRNETLIB) $(INCFILES) ../cfg/kipperbas.cfg - $(LD) -m $*.map -vm -C ../cfg/kipperbas.cfg -o $*.prg $(AFLAGS) $< $(IP65LIB) $(C64RRNETLIB) - -kipperbasv20.prg: kipperbasv20.o $(IP65LIB) $(VIC20RRNETLIB) $(INCFILES) ../cfg/kipperbasv20.cfg - $(LD) -m kipperbasv20.map -vm -C ../cfg/kipperbasv20.cfg -o kipperbasv20.prg $(AFLAGS) $< $(IP65LIB) $(VIC20RRNETLIB) - - -bails.d64: bails.prg - c1541 -format bails,bb d64 $@ -attach $@ -write bails.prg - -kipperbas.d64: kipperbas.prg - c1541 -format kipperbas,kb d64 $@ -attach $@ -write kipperbas.prg - -clean: - rm -f *.o *.bin *.map *.prg - -distclean: clean - rm -f *~ diff --git a/client/basic/addresses.txt b/client/basic/addresses.txt deleted file mode 100644 index b65da5a..0000000 --- a/client/basic/addresses.txt +++ /dev/null @@ -1,14 +0,0 @@ -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/bails.d64 b/client/basic/bails.d64 deleted file mode 100644 index f55ff16..0000000 Binary files a/client/basic/bails.d64 and /dev/null differ diff --git a/client/basic/bails.s b/client/basic/bails.s deleted file mode 100644 index 6a9ecf3..0000000 --- a/client/basic/bails.s +++ /dev/null @@ -1,1725 +0,0 @@ - -.include "../inc/common.i" -;.ifndef KPR_API_VERSION_NUMBER -; .define EQU = -; .include "../inc/kipper_constants.i" -;.endif - - -HTTPD_TIMEOUT_SECONDS=5 ;what's the maximum time we let 1 connection be open for? - -;DEBUG=1 - -VARTAB = $2D ;BASIC variable table storage -ARYTAB = $2F ;BASIC array table storage -FREETOP = $33 ;bottom of string text storage area -MEMSIZ = $37 ;highest address used by BASIC -VARNAM = $45 ;current BASIC variable name -VARPNT = $47 ; pointer to current BASIC variable value - -SETNAM = $FFBD -SETLFS = $FFBA -LOAD = $FFD5 -OPEN = $FFC0 -CHKIN = $FFC6 -READST = $FFB7 ; read status byte -CHRIN = $FFCF ; get a byte from file -CLOSE = $FFC3 -MEMTOP = $FE25 -TXTPTR = $7A ;BASIC text pointer -IERROR = $0300 -ICRUNCH = $0304 ;Crunch ASCII into token -IQPLOP = $0306 ;List -IGONE = $0308 ;Execute next BASIC token - -CHRGET = $73 -CHRGOT = $79 -CHROUT = $FFD2 -GETBYT = $B79E ;BASIC routine -GETPAR = $B7EB ;Get a 16,8 pair of numbers -CHKCOM = $AEFD -NEW = $A642 -CLR = $A65E -NEWSTT = $A7AE -GETVAR = $B0E7 ;find or create a variable -FRMEVL = $AD9E ;evaluate expression -FRESTR = $B6A3 ;free temporary string -FRMNUM = $AD8A ;get a number -GETADR = $B7F7 ;convert number to 16 bit integer -INLIN = $A560 ; read a line from keyboard - -VALTYP=$0D ;00=number, $FF=string - -LINNUM = $14 ;Number returned by GETPAR - -crunched_line = $0200 ;Input buffer - -.import copymem -.importzp copy_src -.importzp copy_dest -.import dhcp_init -.import ip65_init -.import cfg_get_configuration_ptr -.import ip65_process -.import ip65_error -.import cfg_ip -.import cfg_dns -.import cfg_gateway -.import cfg_netmask -.import icmp_ping -.import icmp_echo_ip -.import dns_set_hostname -.import dns_resolve -.import dns_ip - -.import print_a -.import print_cr -.import dhcp_server -.import cfg_mac -.import cfg_mac_default -.import eth_driver_name -.import get_key_if_available -.import timer_read -.import native_to_ascii -.import ascii_to_native - -.import http_parse_request -.import http_get_value -.import http_variables_buffer - -.import tcp_inbound_data_ptr -.import tcp_inbound_data_length -.import tcp_send_data_len -.import tcp_send -.import check_for_abort_key -.import tcp_connect_remote_port -.import tcp_remote_ip -.import tcp_listen -.import tcp_callback -.import tcp_close - -temp_ptr =copy_src - - -.zeropage -temp: .res 2 -temp2: .res 2 -pptr=temp -.segment "STARTUP" ;this is what gets put at the start of the file on the C64 -.word basicstub ; load address -basicstub: - .word @nextline - .word 10 ;line number - .byte $9e ;SYS - .byte <(((relocate / 1000) .mod 10) + $30) - .byte <(((relocate / 100 ) .mod 10) + $30) - .byte <(((relocate / 10 ) .mod 10) + $30) - .byte <(((relocate ) .mod 10) + $30) - .byte ":" - .byte "D" - .byte $b2 ;= - .byte $c2 ;PEEK - .byte "(186):" - .byte $93 ;LOAD - .byte $22,"INDEX.BAS",$22,",D" - .byte 0 -@nextline: - .word 0 -relocate: - lda MEMSIZ+1 - cmp #$A0 ;standard end of memory - beq ok_to_install - - ldy #0 -@loop: - lda not_installing,y - beq @done - jsr $ffd2 - iny - bne @loop -@done: - rts -not_installing: - .byte "INSUFFICIENT FREE MEMORY",0 -ok_to_install: - - ldax #end_of_loader - stax copy_src - ldax #main_start - stax copy_dest - stax MEMSIZ -FS=$8000-main_start - ldax #FS - -;copy memory - sta end - ldy #0 - - cpx #0 - beq @tail - -: lda (copy_src),y - sta (copy_dest),y - iny - bne :- - inc copy_src+1 ;next page - inc copy_dest+1 ;next page - dex - bne :- - -@tail: - lda end - beq @done - -: lda (copy_src),y - sta (copy_dest),y - iny - cpy end - bne :- - -@done: - ldax #welcome_banner - jsr print - - ldx #5 ;Copy CURRENT vectors -@copy_old_vectors_loop: - lda ICRUNCH,x - sta oldcrunch,x - dex - bpl @copy_old_vectors_loop - - ldx #5 ;Copy CURRENT vectors -install_new_vectors_loop: - lda vectors,x - sta ICRUNCH,x - dex - bpl install_new_vectors_loop - -;copy error handlers: - ldax IERROR - stax olderror - ldax #error_handler - stax IERROR - - ;BASIC keywords installed, now bring up the ip65 stack - - jsr ip65_init - bcc @init_ok - ldax #@no_nic - jsr print -@reboot: - jsr $e453 ;reset vectors - jsr $e3bf ;init BASIC - jsr $a644 ;NEW - jmp $e39d -@no_nic: - .byte "NO RR-NET FOUND - UNINSTALLING",0 - -@init_ok: - -; jsr $A644 ;do a "NEW" -; jmp $A474 ;"READY" prompt - rts ;so BASIC will LOAD & RUN INDEX.BAS - -welcome_banner: -.byte "### BASIC ON BAILS ###",13 -.byte 0 -end: .res 1 -end_of_loader: - -.segment "MAINSTART" -main_start: - -safe_getvar: ;if GETVAR doesn't find the desired variable name in the VARTABLE, a routine at $B11D will create it - ;however that routine checks if the low byte of the return address of the caller is $2A. if it is, - ;it assumes the caller is the routine at $AF28 which just wants to get the variable value, and - ;returns a pointer to a dummy 'zero' pointer. - ;so if user code that is calling GETVAR happens to be compiled to an address $xx28, it will - ;trigger this check, and not create a new variable, which (from painful experience) will create - ;a really nasty condition to debug! - ;so vector to GETVAR via here, so the return address seen by $B11D is here, and never $xx28 - jsr GETVAR - rts -.code - - -; CRUNCH -- If this is one of our keywords, then tokenize it -; -crunch: - jsr jmp_crunch ;First crunch line normally - ldy #05 ;Offset for KERNAL - ;Y will contain line length+5 -@loop: - sty temp - jsr isword ;Are we at a keyword? - bcs @gotcha -@next: - jsr nextchar - bne @loop ;Null byte marks end - sta crunched_line-3,Y ;00 line number - lda #$FF ;'tis what A should be - rts ;Buh-bye - -; Insert token and crunch line -@gotcha: - ldx temp ;If so, A contains opcode - sta crunched_line-5,X -@move: - inx - lda crunched_line-5,Y - sta crunched_line-5,X ;Move text backwards - beq @next - iny - bpl @move - - -; ISWORD -- Checks to see if word is -; in table. If a word is found, then -; C is set, Y is one past the last char -; and A contains opcode. Otherwise, -; carry is clear. -; -; On entry, TEMP must contain current -; character position. -; -isword: - ldx #00 -@loop: - ldy temp -@loop2: - lda keywords,x - beq @notmine - cmp #$E0 - bcs @done ;Tokens are >=$E0 - cmp crunched_line-5,Y - bne @next - iny ;Success! Go to next char - inx - bne @loop2 -@next: - inx - lda keywords,x ;Find next keyword - cmp #$E0 - bcc @next - inx - bne @loop ;And check again -@notmine: - clc -@done: - rts - - -; NEXTCHAR finds the next char -; in the buffer, skipping -; spaces and quotes. On -; entry, TEMP contains the -; position of the last spot -; read. On exit, Y contains -; the index to the next char, -; A contains that char, and Z is set if at end of line. - -nextchar: - ldy temp -@loop: - iny - lda crunched_line-5,Y - beq @done - cmp #$8F ;REM - bne @cont - lda #00 -@skip: - sta temp2 ;Find matching character -@loop2: - iny - lda crunched_line-5,Y - beq @done - cmp temp2 - bne @loop2 ;Skip to end of line - beq @loop -@cont: - cmp #$20 ;space - beq @loop - cmp #$22 ;quote - beq @skip -@done: - rts - - -; -; LIST -- patches the LIST routine -; to list our new tokens correctly. -; - -list: - cmp #$E0 - bcc @notmine ;Not my token - cmp #HITOKEN - bcs @notmine - bit $0F ;Check for quote mode - bmi @notmine - sec - sbc #$DF ;Find the corresponding text - tax - sty $49 - ldy #00 -@loop: - dex - beq @done -@loop2: - iny - lda keywords,y - cmp #$E0 - bcc @loop2 - iny - bne @loop -@done: - lda keywords,y - cmp #$91 ;is it "ON"? - bne @not_on - lda #'O' - jsr CHROUT - lda #'N' - bne @skip - -@not_on: - cmp #$9B ;is it "LIST"? - - bne @not_list - lda #'L' - jsr CHROUT - lda #'I' - jsr CHROUT - lda #'S' - jsr CHROUT - lda #'T' - bne @skip -@not_list: - lda keywords,y - bmi @out ;is it >=$80? -@skip: - jsr CHROUT - iny - bne @done -@out: - cmp #$E0 ;It might be BASIC token - bcs @cont - ldy $49 -@notmine: - and #$FF - jmp (oldlist) -@cont: - ldy $49 - jmp $A700 ;Normal exit - - - -; -; EXECUTE -- if this is one of our new -; tokens, then execute it. -execute: - jsr CHRGET -execute_a: - php - cmp #':' ;is it a colon? - beq execute;if so, skip over and go to next token - cmp #$8B ;is it 'IF'? - bne @not_if - lda #$E0 ;our dummy IF token -@not_if: - cmp #$E0 - bcc @notmine - cmp #HITOKEN - bcs @notmine - plp - jsr @disp - jmp NEWSTT -@disp: - eor #$E0 - asl ;multiply by 2 - tax - lda token_routines+1,x - pha - lda token_routines,x - pha - jmp CHRGET ;exit to routine (via RTS) -@notmine: - plp - cmp #0 ;reset flags - jmp $A7E7 - -;the standard BASIC IF routine calls the BASIC EXECUTE routine directly, -;without going through the vector. That means an extended keyword following THEN -;will lead to a syntax error. So we have to reimpliment IF here -;this is taken from TransBASIC - The Transactor, vol 5, Issue 04 (March 1985) page 34 -if_keyword: - jsr FRMEVL ;evaluate expression - jsr CHRGOT - cmp #$89 ;is next token GOTO? - beq @ok - lda #$A7 ;is next token THEN - jsr $AEFF ;will generate SYNTAX ERROR if not -@ok: - jsr CHRGOT - ldx $61 ;result of expression : 0 means false - bne @expression_was_true - jmp $A93B ;go to REM implementation - skips rest of line -@expression_was_true: - bcs @not_numeric;CHRGOT clears carry flag if current char is a number - jmp $A8A0 ;do a GOTO -@not_numeric: - pla - pla ;pop the return address off the stack - jsr CHRGOT - jmp execute_a ;execute current token - - - -;emit the 4 bytes pointed at by AX as dotted decimals -emit_dotted_quad: - sta pptr - stx pptr + 1 - ldy #0 - lda (pptr),y - jsr emit_decimal - lda #'.' - jsr emit_a - - ldy #1 - lda (pptr),y - jsr emit_decimal - lda #'.' - jsr emit_a - - ldy #2 - lda (pptr),y - jsr emit_decimal - lda #'.' - jsr emit_a - - ldy #3 - lda (pptr),y - jsr emit_decimal - - rts - -emit_decimal: ;emit byte in A as a decimal number - pha - sta temp_bin ;save - sed ; Switch to decimal mode - lda #0 ; Ensure the result is clear - sta temp_bcd - sta temp_bcd+1 - ldx #8 ; The number of source bits - : - asl temp_bin+0 ; Shift out one bit - lda temp_bcd+0 ; And add into result - adc temp_bcd+0 - sta temp_bcd+0 - lda temp_bcd+1 ; propagating any carry - adc temp_bcd+1 - sta temp_bcd+1 - dex ; And repeat for next bit - bne :- - - cld ;back to binary - - pla ;get back the original passed in number - bmi @emit_hundreds ; if N is set, the number is >=128 so emit all 3 digits - cmp #10 - bmi @emit_units - cmp #100 - bmi @emit_tens -@emit_hundreds: - lda temp_bcd+1 ;get the most significant digit - and #$0f - clc - adc #'0' - jsr emit_a - -@emit_tens: - lda temp_bcd - lsr - lsr - lsr - lsr - clc - adc #'0' - jsr emit_a -@emit_units: - lda temp_bcd - and #$0f - clc - adc #'0' - jsr emit_a - - rts - -print: - sta pptr - stx pptr + 1 - -@print_loop: - ldy #0 - lda (pptr),y - beq @done_print - jsr print_a - inc pptr - bne @print_loop - inc pptr+1 - bne @print_loop ;if we ever get to $ffff, we've probably gone far enough ;-) -@done_print: - rts - - -extract_string: - jsr FRMEVL - jsr FRESTR ;if not string, will create type mismatch error - sta param_length - tay - lda #0 - sta transfer_buffer,y - dey -@loop: - lda ($22),y - sta transfer_buffer,y - dey - bpl @loop - jmp FRESTR ;free up the temp string created by FRMEVL - -;get a string value from BASIC command, turn into a 32 bit IP address,save it in the 4 bytes pointed at by AX -get_ip_parameter: - stax temp2 - jsr extract_string - ldax #transfer_buffer - jsr dns_set_hostname - - bcs @error - jsr dns_resolve - bcc @ok -@error: - ldax #address_resolution - jmp print_error - -@ok: - ldax #dns_ip - ldx #4 -@copy_dns_ip: - lda dns_ip,y - sta (temp2),y - iny - dex - bne @copy_dns_ip - rts - - -reset_string: - ldy #string_buffer - sty current_output_ptr+1 - rts - -print_dotted_quad: - jsr reset_string - jsr emit_dotted_quad -make_null_terminated_and_print: - lda #0 - jsr emit_a - ldax #string_buffer - jmp print - -print_integer: -sta $63 -stx $62 -jmp $bdd1 ;BASIC routine - -print_decimal: - jsr reset_string - jsr emit_decimal - jmp make_null_terminated_and_print - -print_mac: - jsr reset_string - jsr emit_mac - jmp make_null_terminated_and_print - -;print 6 bytes printed at by AX as a MAC address -emit_mac: - stax pptr - ldy #0 -@one_mac_digit: - tya ;just to set the Z flag - pha - beq @dont_print_colon - lda #':' - jsr emit_a -@dont_print_colon: - pla - tay - lda (pptr),y - jsr emit_hex - iny - cpy #06 - bne @one_mac_digit - rts - -emit_hex: - pha - pha - lsr - lsr - lsr - lsr - tax - lda hexdigits,x - jsr emit_a - pla - and #$0F - tax - lda hexdigits,x - jsr emit_a - pla - rts - -print_hex: - jsr reset_string - jsr emit_hex - jmp make_null_terminated_and_print - -print_error: - jsr print - ldax #error - jsr print - lda ip65_error - jsr print_hex - jsr print_cr - sec - rts - -get_optional_byte: - jsr CHRGOT - beq @no_param ;leave X as it was - jsr CHKCOM ;make sure next char is a comma (and skip it) - jsr CHRGOT - beq @eol - jsr GETBYT -@no_param: - rts -@eol: - jmp $AF08 ;SYNTAX ERROR - -ipcfg_keyword: - - ldax #interface_type - jsr print - - ldax #eth_driver_name - jsr print - jsr print_cr - - ldax #mac_address_msg - jsr print - ldax #cfg_mac - jsr print_mac - jsr print_cr - - ldax #ip_address_msg - jsr print - ldax #cfg_ip - jsr print_dotted_quad - jsr print_cr - - ldax #netmask_msg - jsr print - ldax #cfg_netmask - jsr print_dotted_quad - jsr print_cr - - ldax #gateway_msg - jsr print - ldax #cfg_gateway - jsr print_dotted_quad - jsr print_cr - - ldax #dns_server_msg - jsr print - ldax #cfg_dns - jsr print_dotted_quad - jsr print_cr - - - ldax #dhcp_server_msg - jsr print - ldax #dhcp_server - jsr print_dotted_quad - jsr print_cr - rts - - -dhcp_keyword: - jsr dhcp_init - bcc @init_ok - jsr ip65_init ;if DHCP failed, then reinit the IP stack (which will reset IP address etc that DHCP messed with to default values) - -@init_failed: - ldax #dhcp - jmp print_error -@init_ok: - rts - -ping_keyword: - ldax #icmp_echo_ip - jsr get_ip_parameter - bcc @no_error - rts -@no_error: - - ;is there an optional parameter? - ldx #3 - jsr get_optional_byte - stx ping_counter - - ldax #pinging - jsr print - ldax #dns_ip - jsr print_dotted_quad - jsr print_cr - -@ping_loop: - jsr icmp_ping - bcs @error - lda #'.' -@print_and_loop: - jsr print_a - lda $cb ;current key pressed - cmp #$3F ;RUN/STOP? - beq @done - dec ping_counter - bne @ping_loop -@done: - jmp print_cr -@error: - lda #'!' - jmp @print_and_loop - - -myip_keyword: - ldax #cfg_ip - jmp get_ip_parameter - -dns_keyword: - ldax #cfg_dns - jmp get_ip_parameter - -gateway_keyword: - ldax #cfg_gateway - jmp get_ip_parameter - -netmask_keyword: - ldax #cfg_netmask - jmp get_ip_parameter - -mac_keyword: - jsr extract_string - ldy #2 -: - lda transfer_buffer,y - sta cfg_mac_default+3,y - dey - bpl:- - jsr ip65_init - rts - - -skip_comma_get_integer: - jsr CHRGOT - jsr CHKCOM ;make sure next char is a comma (and skip it) -get_integer: - jsr CHRGOT - beq @eol - jsr FRMNUM - jsr GETADR - ldax LINNUM -@no_param: - rts -@eol: - jmp $AF08 ;SYNTAX ERROR - - -hook_keyword: - jsr extract_string - ldax #transfer_buffer - jsr skip_comma_get_integer - stax handler_address - jsr find_hook - bcc @existing_entry - - lda hooks - cmp #MAX_HOOKS - bmi @got_space - ldx #$10 ;OUT OF MEMORY - jmp $A437 ;print error -@got_space: - clc - lda #0 - adc hooks - adc hooks - adc hooks - adc hooks - adc hooks - adc hooks - tay - inc hooks - @existing_entry: - ;y now points to free slot in hook table - lda transfer_buffer - sta hook_table,y - lda transfer_buffer+1 - sta hook_table+1,y - lda param_length - sta hook_table+2,y - lda hash - sta hook_table+3,y - lda handler_address - sta hook_table+4,y - lda handler_address+1 - sta hook_table+5,y - rts - - -goto: - sta $14 - sta $39 - stx $15 - stx $3a - - jmp $a8a3 ;GOTO keyword - - -find_hook: - jsr calc_hash - ldy #0 - ldx hooks - beq @done -@compare_one_entry: - lda transfer_buffer - cmp hook_table,y - bne @nope - lda transfer_buffer+1 - cmp hook_table+1,y - bne @nope - lda param_length - cmp hook_table+2,y - bne @nope - lda hash - cmp hook_table+3,y - bne @nope -;found it! - clc - rts -@nope: - dex - beq @done - iny - iny - iny - iny - iny - iny - - bne @compare_one_entry -@done: - sec - rts - -calc_hash: - clc - lda #0 - ldy param_length - beq @done -@loop: - adc transfer_buffer,y - dey - bne @loop -@done: - sta hash - rts - - -yield_keyword: - jsr flush_keyword - jsr tcp_close - .ifdef DEBUG - dec $d020 - .endif - jmp httpd_start - - -bang_keyword: - jsr extract_string - lda sent_header - bne :+ - jsr send_header -: - ldy #0 - sty string_ptr -@loop: - lda transfer_buffer,y - jsr xmit_a - inc string_ptr - ldy string_ptr - cpy param_length - bne @loop - rts - - - -got_http_request: - jsr http_parse_request - ldax #path - jsr print - lda #$02 - jsr http_get_value - stax copy_src - jsr print - jsr print_cr - ldy #0 -@copy_path: - lda (copy_src),y - beq @done - sta transfer_buffer,y - iny - bne @copy_path -@done: - sty string_length - lda #0 - sta transfer_buffer,y - sty param_length - sty tmp_length - clc - lda #'P' - sta VARNAM - lda #'A'+$80 - jmp @set_var_value -@copy_vars: - iny - lda (copy_src),y - beq @last_var - tax ;var name - iny - clc - tya - adc copy_src - sta copy_src - bcc :+ - inc copy_src+1 -: - ldy #0 -: - lda (copy_src),y - beq @end_of_var - iny - bne :- -@end_of_var: - sty tmp_length - clc - stx VARNAM - lda #$80 -@set_var_value: - sta VARNAM+1 - jsr safe_getvar - ldy #0 - lda tmp_length - sta (VARPNT),y - iny - lda copy_src - sta (VARPNT),y - iny - lda copy_src+1 - sta (VARPNT),y - ldy tmp_length - jmp @copy_vars - - - @last_var: - - jsr find_hook - bcc @got_hook - ldax default_line_number - jmp goto - @got_hook: - lda hook_table+4,y - ldx hook_table+5,y - jmp goto - - -;start a HTTP server -;this routine will stay in an endless loop that is broken only if user press the ABORT key (runstop on a c64) -;inputs: -; none -;outputs: -; none -httpd_start: - ldx top_of_stack - txs - ldax #listening - jsr print - ldax #cfg_ip - jsr print_dotted_quad - lda #':' - jsr print_a - ldax httpd_port_number - jsr print_integer - jsr print_cr - lda #0 - sta $dc08 ;make sure TOD clock is started - -@listen: - jsr tcp_close - ldax httpd_io_buffer - stax tcp_buffer_ptr - ldax #http_callback - stax tcp_callback - ldax httpd_port_number - - jsr tcp_listen - bcs @abort_key_pressed - -@connect_ok: -.ifdef DEBUG - inc $d020 -.endif - ldax #connection_from - jsr print - ldax #tcp_remote_ip - jsr print_dotted_quad - lda #':' - jsr print_a - ldax tcp_connect_remote_port - - jsr print_integer - jsr print_cr - lda #0 - sta connection_closed - sta found_eol - clc - lda $dc09 ;time of day clock: seconds (in BCD) - sed - adc #HTTPD_TIMEOUT_SECONDS - cmp #$60 - bcc @timeout_set - sec - sbc #$60 -@timeout_set: - cld - sta connection_timeout_seconds - -@main_polling_loop: - jsr ip65_process - jsr check_for_abort_key - bcc @no_abort -@abort_key_pressed: - lda #0 - sta error_handling_mode - ldx #$1E ;break - jmp $e38b ;print error message, warm start BASIC - -@no_abort: - lda found_eol - bne @got_eol - - lda $dc09 ;time of day clock: seconds - - cmp connection_timeout_seconds - beq @connection_timed_out - lda connection_closed - beq @main_polling_loop -@connection_timed_out: -.ifdef DEBUG - dec $d020 -.endif - jmp @listen - -@got_eol: - - jsr reset_output_buffer - - ldy #$FF -: - iny - lda status_ok,y - sta status_code_buffer,y - bne :- - - ldy #$FF -: - iny - lda text_html,y - sta content_type_buffer,y - bne :- - - sta sent_header - - ldax httpd_io_buffer - jmp got_http_request - -http_callback: - lda tcp_inbound_data_length+1 - cmp #$ff - bne @not_eof - inc connection_closed -@done: - rts -@not_eof: - lda found_eol - bne @done - -;copy this chunk to our input buffer - ldax tcp_buffer_ptr - stax copy_dest - ldax tcp_inbound_data_ptr - stax copy_src - ldax tcp_inbound_data_length - jsr copymem - -;increment the pointer into the input buffer - clc - lda tcp_buffer_ptr - adc tcp_inbound_data_length - sta tcp_buffer_ptr - sta temp_ptr - lda tcp_buffer_ptr+1 - adc tcp_inbound_data_length+1 - sta tcp_buffer_ptr+1 - sta temp_ptr+1 - -;put a null byte at the end (assumes we have set temp_ptr already) - lda #0 - tay - sta (temp_ptr),y - -;look for CR or LF in input - sta found_eol - ldax httpd_io_buffer - stax get_next_byte+1 - -@look_for_eol: - jsr get_next_byte - cmp #$0a - beq @found_eol - cmp #$0d - bne @not_eol -@found_eol: - inc found_eol - rts -@not_eol: - cmp #0 - bne @look_for_eol - rts - - - -reset_output_buffer: - ldax httpd_io_buffer - sta xmit_a_ptr+1 - stx xmit_a_ptr+2 - lda #0 - sta output_buffer_length - sta output_buffer_length+1 - rts - - -send_buffer: - ldax output_buffer_length - stax tcp_send_data_len - ldax httpd_io_buffer - jsr tcp_send - jmp reset_output_buffer - - -emit_string: - stax temp_ptr - ldy #0 -@next_byte: - lda (temp_ptr),y - beq @done - jsr xmit_a - iny - bne @next_byte -@done: - rts - - - -httpd_keyword: - jsr get_integer - stax httpd_port_number - jsr skip_comma_get_integer - stax default_line_number - inc error_handling_mode - tsx - stx top_of_stack - jmp httpd_start - -status_keyword: - jsr extract_string - ldy #$FF -@loop: - iny - lda transfer_buffer,y - sta status_code_buffer,y - bne @loop - rts - - -type_keyword: - jsr extract_string - ldy #$FF -@loop: - iny - lda transfer_buffer,y - sta content_type_buffer,y - bne @loop - rts - -send_header: - inc sent_header - ldax #http_version - jsr emit_string - ldax #status_code_buffer - jsr emit_string - ldax #crlf - jsr emit_string - ldax #content_type - jsr emit_string - ldax #content_type_buffer - jsr emit_string - ldax #end_of_header - jmp emit_string - - -flush_keyword: - - lda output_buffer_length - bne :+ - ldx output_buffer_length+1 - bne :+ - rts -: - jmp send_buffer - - -xsend_keyword: - - jsr extract_string - - ldx #transfer_buffer - lda param_length - 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 - -@loop: - jsr CHRIN - sta tmp_a - jsr READST - bne @eof ; either EOF or read error - lda sent_header - bne :+ - jsr send_header -: - lda tmp_a - jsr xmit_a - jmp @loop -@eof: - and #$40 ; end of file? - beq @error - lda tmp_a - jsr xmit_a - -@close_handles: - lda #$02 ; filenumber 2 - jsr CLOSE - ldx #$00 ; filenumber 0 = keyboard - jsr CHKIN ;keyboard now input device again - rts - - - @error: - - lda #$00 ; no filename - tax - tay - jsr SETNAM - lda #$0f ;file number 15 - ldx $ba ;drive number - ldy #$0f ; secondary address 15 (error channel) - jsr SETLFS - jsr OPEN - LDX #$0F ; filenumber 15 - JSR CHKIN ;(file 15 now used as input) - LDY #$00 -@error_loop: - JSR READST ;(read status byte) - BNE @error_eof ; either EOF or read error - JSR CHRIN ;(get a byte from file) - sta error_buffer,y - iny - - JMP @error_loop ; next byte -@error_eof: - lda #0 - sta error_buffer,y - LDX #$00 ; filenumber 0 = keyboard - JSR CHKIN ;(keyboard now input device again) - - - jsr @close_handles - jmp create_error - -create_error: - lda sent_header - bne @header_sent - ldy #$FF -: - iny - lda status_error,y - sta status_code_buffer,y - bne :- - jsr send_header - -@header_sent: - ldax #error_start - jsr emit_string - ldax #system_error - jsr print - lda $3a ;current line number - ldx $39 - sta $62 - stx $63 - ldx #$90 ;exponent to 16 - sec - jsr $bc49 ;pad out flp acc - jsr $bddf ;convert to string - jsr $b487 ;move string descriptor into flp acc - jsr $b6a6 ;get text pointer into $22/$23 - tay - lda #0 - sta ($22),y - lda $22 - ldx $23 - jsr emit_string - jsr emit_br - ldax #line_number - jsr print - lda $22 - ldx $23 - jsr print - jsr print_cr - ldax #error_buffer - jsr emit_string - ldax #error_buffer - jsr print - jmp yield_keyword - -emit_br: - ldax #br - jmp emit_string - -error_handler: - ldy error_handling_mode - bne @send_error_to_browser - jmp (olderror) -@send_error_to_browser: - txa - asl a - tax - lda $a326,x ; fetch address from table of error messages - sta $22 - lda $a327,x ; fetch address from table of error messages - sta $23 - ldy #0 -@one_char: - lda ($22),y - pha - and #$7f - sta error_buffer,y - iny - pla - bpl @one_char - lda #0 - sta error_buffer,y - jmp create_error - -.rodata -vectors: - .word crunch - .word list - .word execute - -hexdigits: -.byte "0123456789ABCDEF" - -CR=$0D -LF=$0A - -error_start: -.byte "

    SYSTEM ERROR


    " -line_number: -.byte " LINE NUMBER: ",0 -br: -.byte "
    ",CR,LF,0 - -listening: -.byte"LISTENING ON ",0 - -pinging: -.byte"PINGING ",0 -interface_type: -.byte "INTERFACE : ",0 - -mac_address_msg: -.byte "MAC ADDRESS : ", 0 - -ip_address_msg: -.byte "IP ADDRESS : ", 0 - -netmask_msg: -.byte "NETMASK : ", 0 - -gateway_msg: -.byte "GATEWAY : ", 0 - -dns_server_msg: -.byte "DNS SERVER : ", 0 - -dhcp_server_msg: -.byte "DHCP SERVER : ", 0 - - -address_resolution: -.byte "ADDRESS RESOLUTION",0 - -tftp: -.byte "TFTP",0 -dhcp: -.byte "DHCP",0 - -connect: -.byte "CONNECT",0 - -error: -.byte " ERROR $",0 - -disconnected: -.byte 13,"DIS" -connected_msg: -.byte "CONNECTED",13,0 - -loaded: - .byte " LOADED",13,0 -skipped: - .byte " SKIPPED",13,0 - -path: - .byte "PATH: ",0 - -http_version: - .byte "HTTP/1.0 ",0 - -status_ok: - .byte "200 OK",0 -status_error: - .byte "500 " -system_error: - .byte "SYSTEM ERROR",0 -content_type: - .byte "Content-Type: ",0 -text_html: - .byte "text/html",0 - -end_of_header: - .byte CR,LF - .byte "Connection: Close",CR,LF - .byte "Server: BoB_httpd/0.c64",CR,LF -crlf: - .byte CR,LF,0 - -connection_from: .byte "CONNECTION FROM ",0 - - -; Keyword list -; Keywords are stored as normal text, -; followed by the token number. -; All tokens are >$80, -; so they easily mark the end of the keyword -keywords: - .byte "IF",$E0 ;our dummy 'IF' entry takes $E0 - .byte "IPCFG",$E1 - .byte "DHCP",$E2 - .byte "PING",$E3 - .byte "MYIP",$E4 - .byte "NETMASK",$E5 - .byte "GATEWAY",$E6 - .byte "DNS",$E7 - .byte "HOOK",$E8 - .byte "YIELD",$E9 - .byte "XS",$80,$EA ;BASIC will replace 'END' with $80 - .byte "!",$EB - .byte "HTTPD",$EC - .byte "TYPE",$ED - .byte "STATUS",$EE - .byte "FLUSH",$EF - .byte "MAC",$F0 - .byte $00 ;end of list -HITOKEN=$F1 - -; -; Table of token locations-1 -; -token_routines: -E0: .word if_keyword-1 -E1: .word ipcfg_keyword-1 -E2: .word dhcp_keyword-1 -E3: .word ping_keyword-1 -E4: .word myip_keyword-1 -E5: .word netmask_keyword-1 -E6: .word gateway_keyword-1 -E7: .word dns_keyword-1 -E8: .word hook_keyword-1 -E9: .word yield_keyword-1 -EA: .word xsend_keyword-1 -EB: .word bang_keyword-1 -EC: .word httpd_keyword-1 -ED: .word type_keyword-1 -EE: .word status_keyword-1 -EF: .word flush_keyword-1 -F0: .word mac_keyword-1 - -.segment "SELF_MODIFIED_CODE" - - -jmp_crunch: .byte $4C ;JMP -oldcrunch: .res 2 ;Old CRUNCH vector -oldlist: .res 2 -oldexec: .res 2 -olderror: .res 2 - -emit_a: -current_output_ptr=emit_a+1 - sta $ffff - inc string_length - inc current_output_ptr - bne :+ - inc current_output_ptr+1 -: - rts - -MAX_HOOKS=40 - -hook_table: -.res MAX_HOOKS*6 -;format is: -; $00/$01 first 2 chars of hook name -; $02 length of name -; $03 hash of name -; $04/$05 line number that hook handler starts at - -hooks: .byte 0 -error_handling_mode: .byte 0 - -.bss -string_length: .res 1 -param_length: .res 1 -tmp_length: .res 1 -temp_bin: .res 1 -temp_bcd: .res 2 -ping_counter: .res 1 -http_buffer: .res 256 -string_buffer: .res 128 -content_type_buffer: .res 128 -status_code_buffer: .res 128 -transfer_buffer: .res 256 -handler_address: .res 2 -hash: .res 1 -string_ptr: .res 1 -default_line_number: .res 2 -found_eol: .byte 0 -connection_closed: .byte 0 -output_buffer_length: .res 2 -connection_timeout_seconds: .byte 0 -tcp_buffer_ptr: .res 2 -buffer_size: .res 1 -temp_x: .res 1 -sent_header: .res 1 -tmp_a: .res 1 -error_buffer: .res 80 -top_of_stack: .res 1 -.segment "TCP_VARS" - -__httpd_io_buffer: .res 1024 ;temp buffer for storing inbound requests. - -.segment "HTTP_VARS" - -httpd_io_buffer: .word __httpd_io_buffer -httpd_port_number: .word 80 - - -get_next_byte: - lda $ffff - inc get_next_byte+1 - bne @skip - inc get_next_byte+2 -@skip: - rts - - -xmit_a: - -xmit_a_ptr: - sta $ffff - inc xmit_a_ptr+1 - bne :+ - inc xmit_a_ptr+2 -: - inc output_buffer_length - bne :+ - inc output_buffer_length+1 - lda output_buffer_length+1 - cmp #2 - bne :+ - stx temp_x - jsr send_buffer - ldx temp_x -: - rts - - -;-- LICENSE FOR bails.s -- -; The contents of this file are subject to the Mozilla Public License -; Version 1.1 (the "License"); you may not use this file except in -; compliance with the License. You may obtain a copy of the License at -; http://www.mozilla.org/MPL/ -; -; Software distributed under the License is distributed on an "AS IS" -; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -; License for the specific language governing rights and limitations -; under the License. -; -; The Original Code is netboot65. -; -; The Initial Developer of the Original Code is Jonno Downes, -; jonno@jamtronix.com. -; Portions created by the Initial Developer are Copyright (C) 2009,2010 -; Jonno Downes. All Rights Reserved. -; -- LICENSE END -- diff --git a/client/basic/favicon.ico b/client/basic/favicon.ico deleted file mode 100644 index acec6de..0000000 Binary files a/client/basic/favicon.ico and /dev/null differ diff --git a/client/basic/gophermap.txt b/client/basic/gophermap.txt deleted file mode 100644 index 45e52c0..0000000 --- a/client/basic/gophermap.txt +++ /dev/null @@ -1,2 +0,0 @@ -1FLOODGAP GOPHER / GOPHER.FLOODGAP.COM 70 -1Interesting telnet destinations /ADDRESSES.TXT 10.5.1.9 70 diff --git a/client/basic/index.bas.txt b/client/basic/index.bas.txt deleted file mode 100644 index 0e96ba7..0000000 --- a/client/basic/index.bas.txt +++ /dev/null @@ -1,25 +0,0 @@ - -5 mac chr$(192)+chr$(29)+chr$(85) -10 dhcp -20 hook"/hello",1000 -25 fa$="/"+chr$(102)+chr$(97)+chr$(118)+chr$(105)+chr$(99)+chr$(111) -27 fa$=fa$+chr$(110)+chr$(46)+chr$(105)+chr$(99)+chr$(111) -30 hookfa$,2000 -40 httpd80,100 -100 !"

    hello

    " -110 !"
    " -120 !"what's your name?" -130 !"" -140 !"
    " -200 yield - -1000!"hello "+n$+", i'm a c64 running basic on bails." -1010 for i=1 to 10 -1020 !"
    " -1030 !str$(i) -1040 next i -1100 yield - -2000 type"IMAGE/X-ICON" -2010 xsend"favicon.ico" -2020 yield diff --git a/client/basic/kipperbas.d64 b/client/basic/kipperbas.d64 deleted file mode 100644 index 459d8e0..0000000 Binary files a/client/basic/kipperbas.d64 and /dev/null differ diff --git a/client/basic/kipperbas.s b/client/basic/kipperbas.s deleted file mode 100644 index 8ee2a5f..0000000 --- a/client/basic/kipperbas.s +++ /dev/null @@ -1,1739 +0,0 @@ - -.include "../inc/common.i" -.ifndef KPR_API_VERSION_NUMBER - .define EQU = - .include "../inc/kipper_constants.i" -.endif - -VARTAB = $2D ;BASIC variable table storage -ARYTAB = $2F ;BASIC array table storage -FREETOP = $33 ;bottom of string text storage area -MEMSIZ = $37 ;highest address used by BASIC -VARNAM = $45 ;current BASIC variable name -VARPNT = $47 ; pointer to current BASIC variable value - -SETNAM = $FFBD -SETLFS = $FFBA -OPEN = $FFC0 -CHKIN = $FFC6 -READST = $FFB7 ; read status byte -CHRIN = $FFCF ; get a byte from file -CLOSE = $FFC3 -MEMTOP = $FE25 -TXTPTR = $7A ;BASIC text pointer -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 -GETBYT = $B79E ;BASIC routine -GETPAR = $B7EB ;Get a 16,8 pair of numbers -CHKCOM = $AEFD -NEW = $A642 -CLR = $A65E -NEWSTT = $A7AE -GETVAR = $B0E7 ;find or create a variable -FRMEVL = $AD9E ;evaluate expression -FRESTR = $B6A3 ;free temporary string -FRMNUM = $AD8A ;get a number -GETADR = $B7F7 ;convert number to 16 bit integer -INLIN = $A560 ; read a line from keyboard - -VALTYP=$0D ;00=number, $FF=string - -LINNUM = $14 ;Number returned by GETPAR - -crunched_line = $0200 ;Input buffer - -.import copymem -.importzp copy_src -.importzp copy_dest -.import dhcp_init -.import ip65_init -.import cfg_get_configuration_ptr -.import tcp_listen -.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 -.import ip65_error -.import cfg_ip -.import cfg_dns -.import cfg_gateway -.import cfg_netmask -.import cfg_tftp_server -.import icmp_ping -.import icmp_echo_ip -.import print_a -.import print_cr -.import dhcp_server -.import cfg_mac -.import cfg_mac_default -.import eth_driver_name -.importzp tftp_filename -.import tftp_ip -.import tftp_download -.import tftp_set_callback_vector -.import tftp_data_block_length -.import tftp_upload -.import get_key_if_available -.import tcp_send_keep_alive -.import timer_read -.import native_to_ascii -.import ascii_to_native -.import udp_send_dest -.import udp_send_dest_port -.import udp_send_src_port -.import udp_send_len -.import udp_send -.import udp_add_listener -.import udp_remove_listener -.import udp_callback -.zeropage -temp: .res 2 -temp2: .res 2 -pptr=temp -.segment "STARTUP" ;this is what gets put at the start of the file on the C64 -.word basicstub ; load address -basicstub: - .word @nextline - .word 10 ;line number - .byte $9e ;SYS - .byte <(((relocate / 1000) .mod 10) + $30) - .byte <(((relocate / 100 ) .mod 10) + $30) - .byte <(((relocate / 10 ) .mod 10) + $30) - .byte <(((relocate ) .mod 10) + $30) - .byte ":" - .byte "D" - .byte $b2 ;= - .byte $c2 ;PEEK - .byte "(186):" - .byte $93 ;LOAD - .byte $22,"AUTOEXEC.BAS",$22,",D" - .byte 0 -@nextline: - .word 0 -relocate: - lda MEMSIZ+1 - cmp #$A0 ;standard end of memory - beq ok_to_install - - ldy #0 -@loop: - lda not_installing,y - beq @done - jsr $ffd2 - iny - bne @loop -@done: - rts -not_installing: - .byte "INSUFFICIENT FREE MEMORY",13,0 -ok_to_install: - ldax #end_of_loader - stax copy_src - ldax #main_start - stax copy_dest - stax MEMSIZ -FS=$8000-main_start - ldax #FS - -;copy memory - sta end - ldy #0 - - cpx #0 - beq @tail - -: lda (copy_src),y - sta (copy_dest),y - iny - bne :- - inc copy_src+1 ;next page - inc copy_dest+1 ;next page - dex - bne :- - -@tail: - lda end - beq @done - -: lda (copy_src),y - sta (copy_dest),y - iny - cpy end - bne :- - -@done: - ldax #welcome_banner - jsr print - - ldx #7 ;Copy CURRENT vectors -@copy_old_vectors_loop: - lda ICRUNCH,x - sta oldcrunch,x - dex - bpl @copy_old_vectors_loop - - ldx #7 ;Copy CURRENT vectors -install_new_vectors_loop: - lda vectors,x - sta ICRUNCH,x - dex - bpl install_new_vectors_loop - - ;BASIC keywords installed, now bring up the ip65 stack - - jsr ip65_init - bcc @init_ok - ldax #@no_nic - jsr print -@reboot: - jsr $e453 ;reset vectors - jsr $e3bf ;init BASIC - jsr $a644 ;NEW - jmp $e39d -@no_nic: - .byte "NO RR-NET FOUND - UNINSTALLING",0 - -@init_ok: - - lda #0 - sta ip65_error - sta connection_state - jsr set_error -@exit: - ; jsr $A644 ;do a "NEW" - ; jmp $A474 ;"READY" prompt - rts - -welcome_banner: -.byte " *** KIPPER BASIC 1.22" -.include "timestamp.i" -.byte " ***" - -.byte 13,0 -end: .res 1 -end_of_loader: - -.segment "MAINSTART" -main_start: - -safe_getvar: ;if GETVAR doesn't find the desired variable name in the VARTABLE, a routine at $B11D will create it - ;however that routine checks if the low byte of the return address of the caller is $2A. if it is, - ;it assumes the caller is the routine at $AF28 which just wants to get the variable value, and - ;returns a pointer to a dummy 'zero' pointer. - ;so if user code that is calling GETVAR happens to be compiled to an address $xx28, it will - ;trigger this check, and not create a new variable, which (from painful experience) will create - ;a really nasty condition to debug! - ;so vector to GETVAR via here, so the return address seen by $B11D is here, and never $xx28 - jsr GETVAR - rts -.code - - -; CRUNCH -- If this is one of our keywords, then tokenize it -; -crunch: - jsr jmp_crunch ;First crunch line normally - ldy #05 ;Offset for KERNAL - ;Y will contain line length+5 -@loop: - sty temp - jsr isword ;Are we at a keyword? - bcs @gotcha -@next: - jsr nextchar - bne @loop ;Null byte marks end - sta crunched_line-3,Y ;00 line number - lda #$FF ;'tis what A should be - rts ;Buh-bye - -; Insert token and crunch line -@gotcha: - ldx temp ;If so, A contains opcode - sta crunched_line-5,X -@move: - inx - lda crunched_line-5,Y - sta crunched_line-5,X ;Move text backwards - beq @next - iny - bpl @move - - -; ISWORD -- Checks to see if word is -; in table. If a word is found, then -; C is set, Y is one past the last char -; and A contains opcode. Otherwise, -; carry is clear. -; -; On entry, TEMP must contain current -; character position. -; -isword: - ldx #00 -@loop: - ldy temp -@loop2: - lda keywords,x - beq @notmine - cmp #$E0 - bcs @done ;Tokens are >=$E0 - cmp crunched_line-5,Y - bne @next - iny ;Success! Go to next char - inx - bne @loop2 -@next: - inx - lda keywords,x ;Find next keyword - cmp #$E0 - bcc @next - inx - bne @loop ;And check again -@notmine: - clc -@done: - rts - - -; NEXTCHAR finds the next char -; in the buffer, skipping -; spaces and quotes. On -; entry, TEMP contains the -; position of the last spot -; read. On exit, Y contains -; the index to the next char, -; A contains that char, and Z is set if at end of line. - -nextchar: - ldy temp -@loop: - iny - lda crunched_line-5,Y - beq @done - cmp #$8F ;REM - bne @cont - lda #00 -@skip: - sta temp2 ;Find matching character -@loop2: - iny - lda crunched_line-5,Y - beq @done - cmp temp2 - bne @loop2 ;Skip to end of line - beq @loop -@cont: - cmp #$20 ;space - beq @loop - cmp #$22 ;quote - beq @skip -@done: - rts - - -; -; LIST -- patches the LIST routine -; to list our new tokens correctly. -; - -list: - cmp #$E0 - bcc @notmine ;Not my token - cmp #HITOKEN - bcs @notmine - bit $0F ;Check for quote mode - bmi @notmine - sec - sbc #$DF ;Find the corresponding text - tax - sty $49 - ldy #00 -@loop: - dex - beq @done -@loop2: - iny - lda keywords,y - cmp #$E0 - bcc @loop2 - iny - bne @loop -@done: - lda keywords,y - cmp #$91 ;is it "ON"? - bne @not_on - lda #'O' - jsr CHROUT - lda #'N' - bne @skip - -@not_on: - cmp #$9B ;is it "LIST"? - - bne @not_list - lda #'L' - jsr CHROUT - lda #'I' - jsr CHROUT - lda #'S' - jsr CHROUT - lda #'T' - bne @skip -@not_list: - lda keywords,y - bmi @out ;is it >=$80? -@skip: - jsr CHROUT - iny - bne @done -@out: - cmp #$E0 ;It might be BASIC token - bcs @cont - ldy $49 -@notmine: - and #$FF - jmp (oldlist) -@cont: - ldy $49 - jmp $A700 ;Normal exit - - - -; -; EXECUTE -- if this is one of our new -; tokens, then execute it. -execute: - jsr CHRGET -execute_a: - php - cmp #':' ;is it a colon? - beq execute;if so, skip over and go to next token - cmp #$8B ;is it 'IF'? - bne @not_if - lda #$E0 ;our dummy IF token -@not_if: - cmp #$E0 - bcc @notmine - cmp #HITOKEN - bcs @notmine - plp - jsr @disp - jmp NEWSTT -@disp: - eor #$E0 - asl ;multiply by 2 - tax - lda token_routines+1,x - pha - lda token_routines,x - pha - jmp CHRGET ;exit to routine (via RTS) -@notmine: - plp - cmp #0 ;reset flags - jmp $A7E7 - -;the standard BASIC IF routine calls the BASIC EXECUTE routine directly, -;without going through the vector. That means an extended keyword following THEN -;will lead to a syntax error. So we have to reimpliment IF here -;this is taken from TransBASIC - The Transactor, vol 5, Issue 04 (March 1985) page 34 -if_keyword: - jsr FRMEVL ;evaluate expression - jsr CHRGOT - cmp #$89 ;is next token GOTO? - beq @ok - lda #$A7 ;is next token THEN - jsr $AEFF ;will generate SYNTAX ERROR if not -@ok: - jsr CHRGOT - ldx $61 ;result of expression : 0 means false - bne @expression_was_true - jmp $A93B ;go to REM implementation - skips rest of line -@expression_was_true: - bcs @not_numeric;CHRGOT clears carry flag if current char is a number - jmp $A8A0 ;do a GOTO -@not_numeric: - pla - pla ;pop the return address off the stack - jsr CHRGOT - jmp execute_a ;execute current token - - - -find_var: - sta VARNAM - stx VARNAM+1 - jsr safe_getvar - ldy #0 - rts - -set_connection_state: - lda #'C'+$80 - ldx #'O'+$80 - jsr find_var - tya - sta (VARPNT),y - iny - lda connection_state - sta (VARPNT),y - -set_error: - lda #'E'+$80 - ldx #'R'+$80 - sta VARNAM+1 - jsr find_var - lda #0 - sta (VARPNT),y - iny - lda ip65_error - sta (VARPNT),y - - rts - - -;emit the 4 bytes pointed at by AX as dotted decimals -emit_dotted_quad: - sta pptr - stx pptr + 1 - ldy #0 - lda (pptr),y - jsr emit_decimal - lda #'.' - jsr emit_a - - ldy #1 - lda (pptr),y - jsr emit_decimal - lda #'.' - jsr emit_a - - ldy #2 - lda (pptr),y - jsr emit_decimal - lda #'.' - jsr emit_a - - ldy #3 - lda (pptr),y - jsr emit_decimal - - rts - -emit_decimal: ;emit byte in A as a decimal number - pha - sta temp_bin ;save - sed ; Switch to decimal mode - lda #0 ; Ensure the result is clear - sta temp_bcd - sta temp_bcd+1 - ldx #8 ; The number of source bits - : - asl temp_bin+0 ; Shift out one bit - lda temp_bcd+0 ; And add into result - adc temp_bcd+0 - sta temp_bcd+0 - lda temp_bcd+1 ; propagating any carry - adc temp_bcd+1 - sta temp_bcd+1 - dex ; And repeat for next bit - bne :- - - cld ;back to binary - - pla ;get back the original passed in number - bmi @emit_hundreds ; if N is set, the number is >=128 so emit all 3 digits - cmp #10 - bmi @emit_units - cmp #100 - bmi @emit_tens -@emit_hundreds: - lda temp_bcd+1 ;get the most significant digit - and #$0f - clc - adc #'0' - jsr emit_a - -@emit_tens: - lda temp_bcd - lsr - lsr - lsr - lsr - clc - adc #'0' - jsr emit_a -@emit_units: - lda temp_bcd - and #$0f - clc - adc #'0' - jsr emit_a - - rts - -print: - sta pptr - stx pptr + 1 - -@print_loop: - ldy #0 - lda (pptr),y - beq @done_print - jsr print_a - inc pptr - bne @print_loop - inc pptr+1 - bne @print_loop ;if we ever get to $ffff, we've probably gone far enough ;-) -@done_print: - rts - - -extract_string: - - jsr FRMEVL - - jsr FRESTR ;if not string, will create type mismatch error - - sta param_length - tay - lda #0 - sta transfer_buffer,y - dey -@loop: - lda ($22),y - sta transfer_buffer,y - dey - bpl @loop - jmp FRESTR ;free up the temp string created by FRMEVL - -;get a string value from BASIC command, turn into a 32 bit IP address,save it in the 4 bytes pointed at by AX -get_ip_parameter: - stax temp2 - jsr extract_string - ldax #transfer_buffer - jsr dns_set_hostname - - bcs @error - jsr dns_resolve - bcc @ok -@error: - ldax #address_resolution - jmp print_error - -@ok: - ldax #dns_ip - ldx #4 -@copy_dns_ip: - lda dns_ip,y - sta (temp2),y - iny - dex - bne @copy_dns_ip - rts - - -reset_string: - ldy #string_buffer - sty current_output_ptr+1 - rts - -print_dotted_quad: - jsr reset_string - jsr emit_dotted_quad -make_null_terminated_and_print: - lda #0 - jsr emit_a - ldax #string_buffer - jmp print - -print_mac: - jsr reset_string - jsr emit_mac - jmp make_null_terminated_and_print - -;print 6 bytes printed at by AX as a MAC address -emit_mac: - stax pptr - ldy #0 -@one_mac_digit: - tya ;just to set the Z flag - pha - beq @dont_print_colon - lda #':' - jsr emit_a -@dont_print_colon: - pla - tay - lda (pptr),y - jsr emit_hex - iny - cpy #06 - bne @one_mac_digit - rts - -emit_hex: - pha - pha - lsr - lsr - lsr - lsr - tax - lda hexdigits,x - jsr emit_a - pla - and #$0F - tax - lda hexdigits,x - jsr emit_a - pla - rts - -print_hex: - jsr reset_string - jsr emit_hex - jmp make_null_terminated_and_print - -print_error: - jsr print - ldax #error - jsr print - lda ip65_error - jsr print_hex - jsr print_cr - jsr set_error - sec - rts - -get_optional_byte: - jsr CHRGOT - beq @no_param ;leave X as it was - jsr CHKCOM ;make sure next char is a comma (and skip it) - jsr CHRGOT - beq @eol - jsr GETBYT -@no_param: - rts -@eol: - jmp $AF08 ;SYNTAX ERROR - -ipcfg_keyword: - - ldax #interface_type - jsr print - - ldax #eth_driver_name - jsr print - jsr print_cr - - ldax #mac_address_msg - jsr print - ldax #cfg_mac - jsr print_mac - jsr print_cr - - ldax #ip_address_msg - jsr print - ldax #cfg_ip - jsr print_dotted_quad - jsr print_cr - - ldax #netmask_msg - jsr print - ldax #cfg_netmask - jsr print_dotted_quad - jsr print_cr - - ldax #gateway_msg - jsr print - ldax #cfg_gateway - jsr print_dotted_quad - jsr print_cr - - ldax #dns_server_msg - jsr print - ldax #cfg_dns - jsr print_dotted_quad - jsr print_cr - - - ldax #dhcp_server_msg - jsr print - ldax #dhcp_server - jsr print_dotted_quad - jsr print_cr - - ldax #tftp_server_msg - jsr print - ldax #cfg_tftp_server - jsr print_dotted_quad - jsr print_cr - -clear_error: - lda #0 - sta ip65_error - jmp set_error - -dhcp_keyword: - jsr dhcp_init - bcc @init_ok - jsr ip65_init ;if DHCP failed, then reinit the IP stack (which will reset IP address etc that DHCP messed with to default values) - -@init_failed: - jsr set_error - ldax #dhcp - jmp print_error -@init_ok: - jmp clear_error - rts - -mac_keyword: - jsr extract_string - ldy #2 -: - lda transfer_buffer,y - sta cfg_mac_default+3,y - dey - bpl:- - jsr ip65_init - rts - -ping_keyword: - ldax #icmp_echo_ip - jsr get_ip_parameter - bcc @no_error - rts -@no_error: - - ;is there an optional parameter? - ldx #3 - jsr get_optional_byte - stx ping_counter - - ldax #pinging - jsr print - ldax #dns_ip - jsr print_dotted_quad - jsr print_cr - -@ping_loop: - jsr icmp_ping - bcs @error - lda #'.' -@print_and_loop: - jsr print_a - 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 - jmp set_error -@error: - lda #'!' - jmp @print_and_loop - - -myip_keyword: - ldax #cfg_ip - jmp get_ip_parameter - -dns_keyword: - ldax #cfg_dns - jmp get_ip_parameter - -gateway_keyword: - ldax #cfg_gateway - jmp get_ip_parameter - -netmask_keyword: - ldax #cfg_netmask - jmp get_ip_parameter - -tftp_keyword: - ldax #cfg_tftp_server - jmp get_ip_parameter - - -tf_param_setup: - jsr print - jsr extract_string - ldax #transfer_buffer - stax tftp_filename - jsr print - lda #' ' - jsr print_a - lda #'(' - jsr print_a - ldax #cfg_tftp_server - jsr print_dotted_quad - lda #')' - jsr print_a - - jsr print_cr - - ldx #$03 -: - lda cfg_tftp_server,x - sta tftp_ip,x - dex - bpl :- - rts - -tfget_keyword: - ldax #get_msg - jsr tf_param_setup - ldax #tftp_download_callback - jsr tftp_set_callback_vector - lda #0 - sta file_opened -;make file output name - lda #'@' - sta string_buffer - lda #':' - sta string_buffer+1 - ldy #$FF -@loop: - iny - lda transfer_buffer,y - sta string_buffer+2,y - bne @loop - iny - iny - lda #',' - sta string_buffer,y - iny - lda #'P' - sta string_buffer,y - iny - lda #',' - sta string_buffer,y - iny - lda #'W' - sta string_buffer,y - iny - sta string_length - - jsr tftp_download -after_tftp_xfer: - bcc @no_error - ldax #tftp -@error_set: - jsr print_error -@no_error: - jsr close_file - jmp set_error - -close_file: - lda #$02 ; filenumber 2 - jsr $FFC3 ; call CLOSE - rts - -open_file: - ;A,X,Y set up ready for a call to SETNAM for file #2 - jsr $FFBD ; call SETNAM - lda #$02 ; file number 2 - ldx $BA ; last used drive - - ldy #$02 ; secondary address 2 - jsr $FFBA ; call SETLFS - - jmp $FFC0 ; call OPEN - - -tftp_download_callback: - - ;buffer pointed at by AX now contains "tftp_data_block_length" bytes - stax temp - - lda #'.' - jsr print_a - lda file_opened - bne @already_opened - lda string_length - ldx #string_buffer - jsr open_file - -@already_opened: - - ldx #$02 ; filenumber 2 = output file - jsr $FFC9 ; call CHKOUT - -@copy_one_byte: - lda tftp_data_block_length - bne @not_done - lda tftp_data_block_length+1 - beq @done - -@not_done: - ldy #2 ;we want to skip the first 2 bytes in the buffer - lda (temp),y - jsr $ffd2 ;write byte - inc temp - bne :+ - inc temp+1 -: - lda tftp_data_block_length - dec tftp_data_block_length - cmp #0 - bne @copy_one_byte - dec tftp_data_block_length+1 - jmp @copy_one_byte -@done: - - ldx #$00 ; filenumber 0 = console - jmp $FFC9 ; call CHKOUT - - -tfput_keyword: - ldax #put_msg - jsr tf_param_setup - - lda param_length - ldx #transfer_buffer - jsr open_file - bcs @error - lda $90 ;get ST - beq @ok -@error: - - ldx #4 ;"FILE NOT FOUND" error - jmp $A437 ;error -@ok: - ldax #tftp_upload_callback - jsr tftp_set_callback_vector - jsr tftp_upload - jmp after_tftp_xfer - - -tftp_upload_callback: - stax copy_dest - lda #'.' - jsr print_a - lda #0 - sta bytes_read - sta bytes_read+1 - - ldx #$02 ; filenumber 2 = output file - jsr $FFC6 ; call CHKIN (file 2 now used as input) -@loop: - jsr $FFCF ; call CHRIN (get a byte from file) - ldy #0 - sta (copy_dest),y - inc copy_dest - bne :+ - inc copy_dest+1 -: - inc bytes_read - bne :+ - inc bytes_read+1 -: - lda bytes_read+1 - cmp #2 - beq @done - jsr $FFB7 ; call READST (read status byte) - beq @loop ; nonzero mean either EOF or read error - -@done: - ldx #$00 ; filenumber 0 = console - jsr $FFC6 ; call CHKIN (console now used as input) - ldax bytes_read - rts - -skip_comma_get_integer: - jsr CHRGOT - jsr CHKCOM ;make sure next char is a comma (and skip it) -get_integer: - jsr CHRGOT - beq @eol - jsr FRMNUM - jsr GETADR - ldax LINNUM -@no_param: - rts -@eol: - jmp $AF08 ;SYNTAX ERROR - - -make_tcp_connection: - lda #0 - sta connection_state - jsr set_connection_state - ldax #tcp_connect_ip - jsr get_ip_parameter - bcc @no_error - rts -@no_error: - jsr skip_comma_get_integer - jsr tcp_connect - bcc :+ -@connect_error: - ldax #connect - jmp print_error -: - ldax #connected_msg - jsr print - lda #1 - sta connection_state - lda #0 - sta ip65_error - jsr set_connection_state - clc - 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 - bcs @exit - - ;is there an optional parameter? - ldx #0 - jsr get_optional_byte - stx netcat_mode -@main_polling_loop: - - jsr timer_read - txa - adc #$20 ;32 x 1/4 = ~ 8seconds - sta netcat_timeout -@wait_for_keypress: - jsr timer_read - cpx netcat_timeout - bne @no_timeout - jsr tcp_send_keep_alive - jmp @main_polling_loop -@no_timeout: - jsr ip65_process - lda connection_state - bne @not_disconnected -@disconnected: - ldax #disconnected - jsr print -@exit: - lda cursor_state - sta $CC - rts -@not_disconnected: - - lda netcat_mode - beq @not_line_mode - - lda #$00 - sta string_length - -;process inbound ip packets while waiting for a keypress -@read_line: - lda $cb ;current key pressed - cmp #$3F ;RUN/STOP? - beq @runstop - jsr ip65_process - lda connection_state - beq @disconnected - - jsr $f142 ;not officially documented - where F13E (GETIN) falls through to if device # is 0 (KEYBD) - - beq @read_line - - cmp #$14 ;Delete - beq @delete - - cmp #$0d ;Return - beq @input_done - - ;End reached? - ldy string_length - cpy #$FF - beq @read_line - - jsr $ffd2 ;Print it - jsr native_to_ascii - sta transfer_buffer,y ;Add it to string - - inc string_length - - ;Not yet. - jmp @read_line - - -@delete: - ;First, check if we're at the beginning. - lda string_length - bne @delete_ok - jmp @read_line - - ;At least one character entered. -@delete_ok: - ;Move pointer back. - dec string_length - - ;Print the delete char - lda #$14 - jsr $ffd2 - - ;Wait for next char - jmp @read_line - -@input_done: - jsr reset_cursor - lda #$0d - jsr $ffd2 ;print a newline - ldy string_length - lda #$0d - sta transfer_buffer,y - iny - lda #$0a - sta transfer_buffer,y - iny - sty tcp_send_data_len - jmp @send_buffer -@not_line_mode: - - ;is there anything in the input buffer? - lda $c6 ;NDX - chars in keyboard buffer - bne :+ - jmp @wait_for_keypress -: - lda #0 - sta tcp_send_data_len - sta tcp_send_data_len+1 -@get_next_char: - lda $cb ;current key pressed - cmp #$3F ;RUN/STOP? - bne @not_runstop -@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 - tax - beq @no_more_input - txa - - ldy tcp_send_data_len - sta transfer_buffer,y - inc tcp_send_data_len - jmp @get_next_char -@no_more_input: -@send_buffer: - ldax #transfer_buffer - jsr tcp_send - bcs @error_on_send - 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 - lda #0 - sta connection_state - rts -@not_eof: - - ldax tcp_inbound_data_ptr - stax temp2 - lda tcp_inbound_data_length - sta buffer_length - lda tcp_inbound_data_length+1 - sta buffer_length+1 - -@next_byte: - lda $cb ;current key pressed - cmp #$3F ;RUN/STOP? - beq @finished - - ldy #0 - lda (temp2),y - ldx netcat_mode - beq @no_transform - jsr ascii_to_native -@no_transform: - jsr print_a - inc temp2 - bne :+ - inc temp2+1 -: - lda buffer_length+1 - beq @last_page - lda buffer_length - bne @not_end_of_page - dec buffer_length+1 -@not_end_of_page: - dec buffer_length - jmp @next_byte -@last_page: - dec buffer_length - beq @finished - - jmp @next_byte - -@finished: - - rts - - -tcpconnect_keyword: - ldax #tcpconnect_callback - stax tcp_callback - jmp make_tcp_connection - -tcpconnect_callback: - - 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 - cpx #$ff - bne @not_end_packet - -@end_packet: - lda #0 - sta connection_state - rts -@not_end_packet: - - stax inbound_data_length -set_packet_vars: - - jsr copymem - ldx inbound_data_length+1 - beq @short_packet - lda #$ff -@short_packet: - lda inbound_data_length -set_input_string: - pha - lda #'I' - ldx #'N'+$80 - jsr find_var - ldy #0 - pla - pha - sta (VARPNT),y - iny - lda #transfer_buffer - sta (VARPNT),y - pla - beq :+ - ldx #0 - jsr copymem -: - - lda #'I'+$80 - ldx #'P'+$80 - jsr find_var - lda #transfer_buffer - sta (VARPNT),y - - lda #'I'+$80 - ldx #'L'+$80 - jsr find_var - lda inbound_data_length+1 - sta (VARPNT),y - iny - lda inbound_data_length - sta (VARPNT),y - - rts - -poll_keyword: - lda #0 - sta tcp_inbound_data_length - sta tcp_inbound_data_length+1 - jsr set_input_string - jsr set_connection_state - jsr ip65_process - lda ip65_error - beq @no_error - jmp set_error -@no_error: - jmp set_connection_state - -tcplisten_keyword: - lda #0 - sta connection_state - sta ip65_error - ldax #tcpconnect_callback - stax tcp_callback - jsr get_integer - jsr tcp_listen - bcs :+ - inc connection_state -: - jmp set_connection_state - -tcpsend_keyword: - jsr extract_string - ldy param_length - sty tcp_send_data_len - ldy #0 - sty tcp_send_data_len+1 - ldax #transfer_buffer - jsr tcp_send - jmp set_connection_state - -tcpclose_keyword: - lda #0 - sta connection_state - jsr tcp_close - jmp set_connection_state - -tcpblat_keyword: - - jsr extract_string - - ldx #transfer_buffer - lda param_length - 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 - 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: - lda #$02 ; filenumber 2 - jsr CLOSE - ldx #$00 ; filenumber 0 = keyboard - jsr CHKIN ;keyboard now input device again - jmp set_error - -@error: - lda #KPR_ERROR_DEVICE_FAILURE - jmp @store_error -@readerror: - lda #KPR_ERROR_FILE_ACCESS_FAILURE - jmp @store_error - -;send udp packet - -udpsend_keyword: - ldax #udp_send_dest - jsr get_ip_parameter - bcc @no_error - rts -@no_error: - jsr skip_comma_get_integer - stax udp_send_dest_port - - jsr skip_comma_get_integer - stax udp_send_src_port - jsr CHRGOT - jsr CHKCOM ;make sure next char is a comma (and skip it) - jsr extract_string - inc $d020 - - ldy param_length - sty udp_send_len - ldy #0 - sty udp_send_len+1 - ldax #transfer_buffer - jsr udp_send - - lda #0 - sta ip65_error - clc - rts - -udplisten_keyword: - ldax #udp_handler - stax udp_callback - jsr get_integer ;port number - stax port - jsr udp_remove_listener - ldax port - jsr udp_add_listener - bcc @ok - ldax #too_many_listeners - jmp print_error -@ok: - rts - -udp_handler: - inc $d020 - rts -evaluate: - - lda #$00 - sta $0D ;set string flag to not stringe - 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. -; All tokens are >$80, -; so they easily mark the end of the keyword -hexdigits: -.byte "0123456789ABCDEF" - -pinging: -.byte"PINGING ",0 -interface_type: -.byte "INTERFACE : ",0 - -mac_address_msg: -.byte "MAC ADDRESS : ", 0 - -ip_address_msg: -.byte "IP ADDRESS : ", 0 - -netmask_msg: -.byte "NETMASK : ", 0 - -gateway_msg: -.byte "GATEWAY : ", 0 - -dns_server_msg: -.byte "DNS SERVER : ", 0 - -dhcp_server_msg: -.byte "DHCP SERVER : ", 0 - -tftp_server_msg: -.byte "TFTP SERVER : ", 0 - -too_many_listeners: -.byte "TOO MANY LISTENERS",0 -address_resolution: -.byte "ADDRESS RESOLUTION",0 - -get_msg: -.byte "GETTING ",0 -put_msg: -.byte "PUTTING ",0 - -tftp: -.byte "TFTP",0 -dhcp: -.byte "DHCP",0 - -connect: -.byte "CONNECT",0 - -transmission: -.byte "TRANSMISSION",0 - -error: -.byte " ERROR $",0 - -disconnected: -.byte 13,"DIS" -connected_msg: -.byte "CONNECTED",13,0 - -keywords: - .byte "IF",$E0 ;our dummy 'IF' entry takes $E0 - .byte "IPCFG",$E1 - .byte "DHCP",$E2 - .byte "PING",$E3 - .byte "MYIP",$E4 - .byte "NETMASK",$E5 - .byte "GATEWAY",$E6 - .byte "DNS",$E7 - .byte "TFTP",$E8 - .byte "TF",$A1,$E9 ;TFGET - BASIC will replace GET with A1 - .byte "TFPUT",$EA - .byte "NETCAT",$EB - .byte "TCPC",$91,"NECT",$EC ; TCPCONNECT - BASIC will replace ON with $91 - .byte "POLL",$ED - .byte "TCP",$9B,"EN",$EE ;TCPLISTEN - BASIC will replace LIST with $9b - .byte "TCPS",$80,$EF ;TCPSEND - BASIC will replace END with $80 - .byte "TCP",$A0,$F0 ;TCPLOSE - BASIC will replace CLOSE with $A0 - .byte "TCPBLAT",$F1 - .byte "MAC",$F2 - .byte "UDPS",$80,$F3 ;UDPSEND - BASIC will replace END with $80 - .byte "UDP",$9B,"EN",$F4 ;UDPLISTEN - BASIC will replace LIST with $9b - .byte $00 ;end of list -HITOKEN=$F5 - -; -; Table of token locations-1 -; -token_routines: -E0: .word if_keyword-1 -E1: .word ipcfg_keyword-1 -E2: .word dhcp_keyword-1 -E3: .word ping_keyword-1 -E4: .word myip_keyword-1 -E5: .word netmask_keyword-1 -E6: .word gateway_keyword-1 -E7: .word dns_keyword-1 -E8: .word tftp_keyword-1 -E9: .word tfget_keyword-1 -EA: .word tfput_keyword-1 -EB: .word netcat_keyword-1 -EC: .word tcpconnect_keyword-1 -ED: .word poll_keyword-1 -EE: .word tcplisten_keyword-1 -EF: .word tcpsend_keyword-1 -FO: .word tcpclose_keyword-1 -F1: .word tcpblat_keyword-1 -F2: .word mac_keyword-1 -F3: .word udpsend_keyword-1 -F4: .word udplisten_keyword-1 - -.segment "SELF_MODIFIED_CODE" - - -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 - inc string_length - inc current_output_ptr - bne :+ - inc current_output_ptr+1 -: - rts - - -.bss -netcat_mode: .res 1 -bytes_read: .res 2 -string_length: .res 1 -param_length: .res 1 -ip_string: .res 15 -netmask_string: .res 15 -dns_string: .res 15 -gateway_string: .res 15 - temp_bin: .res 1 -temp_bcd: .res 2 -ping_counter: .res 1 -string_buffer: .res 128 -transfer_buffer: .res 1500 -file_opened: .res 1 -connection_state: .res 1 -netcat_timeout: .res 1 -buffer_length: .res 2 -cursor_state: .res 1 -port: .res 2 -inbound_data_length: .res 2 \ No newline at end of file diff --git a/client/basic/kipperbasv20.s b/client/basic/kipperbasv20.s deleted file mode 100644 index 8e4f0ee..0000000 --- a/client/basic/kipperbasv20.s +++ /dev/null @@ -1,1658 +0,0 @@ - -.ifndef SCREEN_WIDTH - SCREEN_WIDTH = 22 -.endif - -.include "../inc/common.i" -.ifndef KPR_API_VERSION_NUMBER - .define EQU = - .include "../inc/kipper_constants.i" -.endif - -VARTAB = $2D ;BASIC variable table storage -ARYTAB = $2F ;BASIC array table storage -FREETOP = $33 ;bottom of string text storage area -MEMSIZ = $37 ;highest address used by BASIC -VARNAM = $45 ;current BASIC variable name -VARPNT = $47 ; pointer to current BASIC variable value - -SETNAM = $FFBD -SETLFS = $FFBA -OPEN = $FFC0 -CHKIN = $FFC6 -READST = $FFB7 ; read status byte -CHRIN = $FFCF ; get a byte from file -CLOSE = $FFC3 -MEMTOP = $FE25 -TXTPTR = $7A ;BASIC text pointer -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 -GETBYT = $D79E ;BASIC routine -GETPAR = $D7EB ;Get a 16,8 pair of numbers -CHKCOM = $CEFD -NEW = $C642 -CLR = $C65E -NEWSTT = $C7AE -GETVAR = $D0E7 ;find or create a variable -FRMEVL = $CD9E ;evaluate expression -FRESTR = $D6A3 ;free temporary string -FRMNUM = $CD8A ;get a number -GETADR = $D7F7 ;convert number to 16 bit integer -INLIN = $C560 ; read a line from keyboard - -VALTYP=$0D ;00=number, $FF=string - -LINNUM = $14 ;Number returned by GETPAR - -crunched_line = $0200 ;Input buffer - -.import copymem -.importzp copy_src -.importzp copy_dest -.import dhcp_init -.import ip65_init -.import cfg_get_configuration_ptr -.import tcp_listen -.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 -.import ip65_error -.import cfg_ip -.import cfg_dns -.import cfg_gateway -.import cfg_netmask -.import cfg_tftp_server -.import icmp_ping -.import icmp_echo_ip -.import print_a -.import print_cr -.import dhcp_server -.import cfg_mac -.import cfg_mac_default -.import eth_driver_name -.importzp tftp_filename -.import tftp_ip -.import tftp_download -.import tftp_set_callback_vector -.import tftp_data_block_length -.import tftp_upload -.import get_key_if_available -.import tcp_send_keep_alive -.import timer_read -.import native_to_ascii -.import ascii_to_native -.zeropage -temp: .res 2 -temp2: .res 2 -pptr=temp -.segment "STARTUP" ;this is what gets put at the start of the file on the Vic 20 -.word basicstub ; load address -basicstub: - .word @nextline - .word 10 ;line number - .byte $9e ;SYS - .byte <(((relocate / 1000) .mod 10) + $30) - .byte <(((relocate / 100 ) .mod 10) + $30) - .byte <(((relocate / 10 ) .mod 10) + $30) - .byte <(((relocate ) .mod 10) + $30) -; .byte ":" -; .byte "D" -; .byte $b2 ;= -; .byte $c2 ;PEEK -; .byte "(186):" -; .byte $93 ;LOAD -; .byte $22,"AUTOEXEC.BAS",$22,",D" - .byte 0 -@nextline: - .word 0 -relocate: - lda MEMSIZ+1 - cmp #$80 ;standard end of memory - beq ok_to_install - ldy #0 -@loop: - lda not_installing,y - beq @done - jsr $ffd2 - iny - bne @loop -@done: - rts -not_installing: - .byte "INSUFFICIENT FREE MEMORY",13,0 -ok_to_install: - - ldax #end_of_loader - stax copy_src - ldax #main_start - stax copy_dest - stax MEMSIZ - FS= $3FC9 ;how much data to relocate? - ldax #FS - -;copy memory - sta end - ldy #0 - - cpx #0 - beq @tail - -: lda (copy_src),y - sta (copy_dest),y - iny - bne :- - inc copy_src+1 ;next page - inc copy_dest+1 ;next page - dex - bne :- - -@tail: - lda end - beq @done - -: lda (copy_src),y - sta (copy_dest),y - iny - cpy end - bne :- - -@done: - ldax #welcome_banner - - jsr print - - - ldx #7 ;Copy CURRENT vectors -@copy_old_vectors_loop: - lda ICRUNCH,x - sta oldcrunch,x - dex - bpl @copy_old_vectors_loop - - ldx #7 ;Copy CURRENT vectors -install_new_vectors_loop: - lda vectors,x - sta ICRUNCH,x - dex - bpl install_new_vectors_loop - - ;BASIC keywords installed, now bring up the ip65 stack - - jsr ip65_init - bcc @init_ok - bcs @init_ok ;FIXME - ldax #@no_nic - jsr print -@reboot: - - ldax #$8000 - stax MEMSIZ - - jsr $e45b ;reset vectors - - jsr $c642 ;NEW - jsr $c65e ;CLR - jsr $e3a4 ;init RAM - jmp $e467 ;BASIC warm start - -@no_nic: - .byte "NO RR-NET FOUND!",13,0 - -@init_ok: - - lda #0 - sta ip65_error - sta connection_state - jsr set_error - -@exit: - - ; jsr $C644 ;do a "NEW" - ; jmp $C474 ;"READY" prompt - jmp $e467 ;BASIC warm start - rts - -welcome_banner: -.byte "** KIPPER BASIC 1.1 **" -.byte 0 -end: .res 1 -end_of_loader: - -.segment "MAINSTART" -main_start: - -safe_getvar: ;if GETVAR doesn't find the desired variable name in the VARTABLE, a routine at $D11D will create it - ;however that routine checks if the low byte of the return address of the caller is $2A. if it is, - ;it assumes the caller is the routine at $CF28 which just wants to get the variable value, and - ;returns a pointer to a dummy 'zero' pointer. - ;so if user code that is calling GETVAR happens to be compiled to an address $xx28, it will - ;trigger this check, and not create a new variable, which (from painful experience) will create - ;a really nasty condition to debug! - ;so vector to GETVAR via here, so the return address seen by $D11D is here, and never $xx28 - jsr GETVAR - rts -.code - - -; CRUNCH -- If this is one of our keywords, then tokenize it -; -crunch: - jsr jmp_crunch ;First crunch line normally - ldy #05 ;Offset for KERNAL - ;Y will contain line length+5 -@loop: - sty temp - jsr isword ;Are we at a keyword? - bcs @gotcha -@next: - jsr nextchar - bne @loop ;Null byte marks end - sta crunched_line-3,Y ;00 line number - lda #$FF ;'tis what A should be - rts ;Buh-bye - -; Insert token and crunch line -@gotcha: - ldx temp ;If so, A contains opcode - sta crunched_line-5,X -@move: - inx - lda crunched_line-5,Y - sta crunched_line-5,X ;Move text backwards - beq @next - iny - bpl @move - - -; ISWORD -- Checks to see if word is -; in table. If a word is found, then -; C is set, Y is one past the last char -; and A contains opcode. Otherwise, -; carry is clear. -; -; On entry, TEMP must contain current -; character position. -; -isword: - ldx #00 -@loop: - ldy temp -@loop2: - lda keywords,x - beq @notmine - cmp #$E0 - bcs @done ;Tokens are >=$E0 - cmp crunched_line-5,Y - bne @next - iny ;Success! Go to next char - inx - bne @loop2 -@next: - inx - lda keywords,x ;Find next keyword - cmp #$E0 - bcc @next - inx - bne @loop ;And check again -@notmine: - clc -@done: - rts - - -; NEXTCHAR finds the next char -; in the buffer, skipping -; spaces and quotes. On -; entry, TEMP contains the -; position of the last spot -; read. On exit, Y contains -; the index to the next char, -; A contains that char, and Z is set if at end of line. - -nextchar: - ldy temp -@loop: - iny - lda crunched_line-5,Y - beq @done - cmp #$8F ;REM - bne @cont - lda #00 -@skip: - sta temp2 ;Find matching character -@loop2: - iny - lda crunched_line-5,Y - beq @done - cmp temp2 - bne @loop2 ;Skip to end of line - beq @loop -@cont: - cmp #$20 ;space - beq @loop - cmp #$22 ;quote - beq @skip -@done: - rts - - -; -; LIST -- patches the LIST routine -; to list our new tokens correctly. -; - -list: - cmp #$E0 - bcc @notmine ;Not my token - cmp #HITOKEN - bcs @notmine - bit $0F ;Check for quote mode - bmi @notmine - sec - sbc #$DF ;Find the corresponding text - tax - sty $49 - ldy #00 -@loop: - dex - beq @done -@loop2: - iny - lda keywords,y - cmp #$E0 - bcc @loop2 - iny - bne @loop -@done: - lda keywords,y - cmp #$91 ;is it "ON"? - bne @not_on - lda #'O' - jsr CHROUT - lda #'N' - bne @skip - -@not_on: - cmp #$9B ;is it "LIST"? - - bne @not_list - lda #'L' - jsr CHROUT - lda #'I' - jsr CHROUT - lda #'S' - jsr CHROUT - lda #'T' - bne @skip -@not_list: - lda keywords,y - bmi @out ;is it >=$80? -@skip: - jsr CHROUT - iny - bne @done -@out: - cmp #$E0 ;It might be BASIC token - bcs @cont - ldy $49 -@notmine: - and #$FF - jmp (oldlist) -@cont: - ldy $49 - jmp $C700 ;Normal exit - - - -; -; EXECUTE -- if this is one of our new -; tokens, then execute it. -execute: - jsr CHRGET -execute_a: - php - cmp #':' ;is it a colon? - beq execute;if so, skip over and go to next token - cmp #$8B ;is it 'IF'? - bne @not_if - lda #$E0 ;our dummy IF token -@not_if: - cmp #$E0 - bcc @notmine - cmp #HITOKEN - bcs @notmine - plp - jsr @disp - jmp NEWSTT -@disp: - eor #$E0 - asl ;multiply by 2 - tax - lda token_routines+1,x - pha - lda token_routines,x - pha - jmp CHRGET ;exit to routine (via RTS) -@notmine: - plp - cmp #0 ;reset flags - jmp $C7E7 - -;the standard BASIC IF routine calls the BASIC EXECUTE routine directly, -;without going through the vector. That means an extended keyword following THEN -;will lead to a syntax error. So we have to reimpliment IF here -;this is taken from TransBASIC - The Transactor, vol 5, Issue 04 (March 1985) page 34 -if_keyword: - jsr FRMEVL ;evaluate expression - jsr CHRGOT - cmp #$89 ;is next token GOTO? - beq @ok - lda #$A7 ;is next token THEN - jsr $CEFF ;will generate SYNTAX ERROR if not -@ok: - jsr CHRGOT - ldx $61 ;result of expression : 0 means false - bne @expression_was_true - jmp $C93B ;go to REM implementation - skips rest of line -@expression_was_true: - bcs @not_numeric;CHRGOT clears carry flag if current char is a number - jmp $C8A0 ;do a GOTO -@not_numeric: - pla - pla ;pop the return address off the stack - jsr CHRGOT - jmp execute_a ;execute current token - - - -find_var: - sta VARNAM - stx VARNAM+1 - jsr safe_getvar - ldy #0 - rts - -set_connection_state: - lda #'C'+$80 - ldx #'O'+$80 - jsr find_var - tya - sta (VARPNT),y - iny - lda connection_state - sta (VARPNT),y - -set_error: - lda #'E'+$80 - ldx #'R'+$80 - sta VARNAM+1 - jsr find_var - lda #0 - sta (VARPNT),y - iny - lda ip65_error - sta (VARPNT),y - - rts - - -;emit the 4 bytes pointed at by AX as dotted decimals -emit_dotted_quad: - sta pptr - stx pptr + 1 - ldy #0 - lda (pptr),y - jsr emit_decimal - lda #'.' - jsr emit_a - - ldy #1 - lda (pptr),y - jsr emit_decimal - lda #'.' - jsr emit_a - - ldy #2 - lda (pptr),y - jsr emit_decimal - lda #'.' - jsr emit_a - - ldy #3 - lda (pptr),y - jsr emit_decimal - - rts - -emit_decimal: ;emit byte in A as a decimal number - pha - sta temp_bin ;save - sed ; Switch to decimal mode - lda #0 ; Ensure the result is clear - sta temp_bcd - sta temp_bcd+1 - ldx #8 ; The number of source bits - : - asl temp_bin+0 ; Shift out one bit - lda temp_bcd+0 ; And add into result - adc temp_bcd+0 - sta temp_bcd+0 - lda temp_bcd+1 ; propagating any carry - adc temp_bcd+1 - sta temp_bcd+1 - dex ; And repeat for next bit - bne :- - - cld ;back to binary - - pla ;get back the original passed in number - bmi @emit_hundreds ; if N is set, the number is >=128 so emit all 3 digits - cmp #10 - bmi @emit_units - cmp #100 - bmi @emit_tens -@emit_hundreds: - lda temp_bcd+1 ;get the most significant digit - and #$0f - clc - adc #'0' - jsr emit_a - -@emit_tens: - lda temp_bcd - lsr - lsr - lsr - lsr - clc - adc #'0' - jsr emit_a -@emit_units: - lda temp_bcd - and #$0f - clc - adc #'0' - jsr emit_a - - rts - -print: - sta pptr - stx pptr + 1 - -@print_loop: - ldy #0 - lda (pptr),y - beq @done_print - jsr print_a - inc pptr - bne @print_loop - inc pptr+1 - bne @print_loop ;if we ever get to $ffff, we've probably gone far enough ;-) -@done_print: - rts - - -extract_string: - - jsr FRMEVL - - jsr FRESTR ;if not string, will create type mismatch error - - sta param_length - tay - lda #0 - sta transfer_buffer,y - dey -@loop: - lda ($22),y - sta transfer_buffer,y - dey - bpl @loop - jmp FRESTR ;free up the temp string created by FRMEVL - -;get a string value from BASIC command, turn into a 32 bit IP address,save it in the 4 bytes pointed at by AX -get_ip_parameter: - stax temp2 - jsr extract_string - ldax #transfer_buffer - jsr dns_set_hostname - - bcs @error - jsr dns_resolve - bcc @ok -@error: - ldax #address_resolution - jmp print_error - -@ok: - ldax #dns_ip - ldx #4 -@copy_dns_ip: - lda dns_ip,y - sta (temp2),y - iny - dex - bne @copy_dns_ip - rts - - -reset_string: - ldy #string_buffer - sty current_output_ptr+1 - rts - -print_dotted_quad: - jsr reset_string - jsr emit_dotted_quad -make_null_terminated_and_print: - lda #0 - jsr emit_a - ldax #string_buffer - jmp print - -print_mac: - jsr reset_string - jsr emit_mac - jmp make_null_terminated_and_print - -;print 6 bytes printed at by AX as a MAC address -emit_mac: - stax pptr - ldy #0 -@one_mac_digit: - tya ;just to set the Z flag - pha - beq @dont_print_colon - lda #':' - jsr emit_a -@dont_print_colon: - pla - tay - lda (pptr),y - jsr emit_hex - iny - cpy #06 - bne @one_mac_digit - rts - -emit_hex: - pha - pha - lsr - lsr - lsr - lsr - tax - lda hexdigits,x - jsr emit_a - pla - and #$0F - tax - lda hexdigits,x - jsr emit_a - pla - rts - -print_hex: - jsr reset_string - jsr emit_hex - jmp make_null_terminated_and_print - -print_error: - jsr print - ldax #error - jsr print - lda ip65_error - jsr print_hex - jsr print_cr - jsr set_error - sec - rts - -get_optional_byte: - jsr CHRGOT - beq @no_param ;leave X as it was - jsr CHKCOM ;make sure next char is a comma (and skip it) - jsr CHRGOT - beq @eol - jsr GETBYT -@no_param: - rts -@eol: - jmp $CF08 ;SYNTAX ERROR - -ipcfg_keyword: - - ldax #interface_type - jsr print - - ldax #eth_driver_name - jsr print - jsr print_cr - - ldax #mac_address_msg - jsr print - ldax #cfg_mac - jsr print_mac - jsr print_cr - - ldax #ip_address_msg - jsr print - ldax #cfg_ip - jsr print_dotted_quad - jsr print_cr - - ldax #netmask_msg - jsr print - ldax #cfg_netmask - jsr print_dotted_quad - jsr print_cr - - ldax #gateway_msg - jsr print - ldax #cfg_gateway - jsr print_dotted_quad - jsr print_cr - - ldax #dns_server_msg - jsr print - ldax #cfg_dns - jsr print_dotted_quad - jsr print_cr - - - ldax #dhcp_server_msg - jsr print - ldax #dhcp_server - jsr print_dotted_quad - jsr print_cr - - ldax #tftp_server_msg - jsr print - ldax #cfg_tftp_server - jsr print_dotted_quad - jsr print_cr - -clear_error: - lda #0 - sta ip65_error - jmp set_error - -dhcp_keyword: - jsr dhcp_init - bcc @init_ok - jsr ip65_init ;if DHCP failed, then reinit the IP stack (which will reset IP address etc that DHCP messed with to default values) - -@init_failed: - jsr set_error - ldax #dhcp - jmp print_error -@init_ok: - jmp clear_error - rts - -mac_keyword: - jsr extract_string - ldy #2 -: - lda transfer_buffer,y - sta cfg_mac_default+3,y - dey - bpl:- - jsr ip65_init - rts - -ping_keyword: - ldax #icmp_echo_ip - jsr get_ip_parameter - bcc @no_error - rts -@no_error: - - ;is there an optional parameter? - ldx #3 - jsr get_optional_byte - stx ping_counter - - ldax #pinging - jsr print - ldax #dns_ip - jsr print_dotted_quad - jsr print_cr - -@ping_loop: - - jsr icmp_ping - bcs @error - lda #'.' -@print_and_loop: - jsr print_a - lda $cb ;current key pressed - cmp #$18 ;RUN/STOP? - beq @done - lda ping_counter - beq @ping_loop - dec ping_counter - cmp #1 - bne @ping_loop -@done: - jsr print_cr - jmp set_error -@error: - lda #'!' - jmp @print_and_loop - - -myip_keyword: - ldax #cfg_ip - jmp get_ip_parameter - -dns_keyword: - ldax #cfg_dns - jmp get_ip_parameter - -gateway_keyword: - ldax #cfg_gateway - jmp get_ip_parameter - -netmask_keyword: - ldax #cfg_netmask - jmp get_ip_parameter - -tftp_keyword: - ldax #cfg_tftp_server - jmp get_ip_parameter - - -tf_param_setup: - jsr print - jsr extract_string - ldax #transfer_buffer - stax tftp_filename - jsr print - lda #' ' - jsr print_a - lda #'(' - jsr print_a - ldax #cfg_tftp_server - jsr print_dotted_quad - lda #')' - jsr print_a - - jsr print_cr - - ldx #$03 -: - lda cfg_tftp_server,x - sta tftp_ip,x - dex - bpl :- - rts - -tfget_keyword: - ldax #get_msg - jsr tf_param_setup - ldax #tftp_download_callback - jsr tftp_set_callback_vector - lda #0 - sta file_opened -;make file output name - lda #'@' - sta string_buffer - lda #':' - sta string_buffer+1 - ldy #$FF -@loop: - iny - lda transfer_buffer,y - sta string_buffer+2,y - bne @loop - iny - iny - lda #',' - sta string_buffer,y - iny - lda #'P' - sta string_buffer,y - iny - lda #',' - sta string_buffer,y - iny - lda #'W' - sta string_buffer,y - iny - sta string_length - - jsr tftp_download -after_tftp_xfer: - bcc @no_error - ldax #tftp -@error_set: - jsr print_error -@no_error: - jsr close_file - jmp set_error - -close_file: - lda #$02 ; filenumber 2 - jsr $FFC3 ; call CLOSE - rts - -open_file: - ;A,X,Y set up ready for a call to SETNAM for file #2 - jsr $FFBD ; call SETNAM - lda #$02 ; file number 2 - ldx $BA ; last used drive - - ldy #$02 ; secondary address 2 - jsr $FFBA ; call SETLFS - - jmp $FFC0 ; call OPEN - - -tftp_download_callback: - - ;buffer pointed at by AX now contains "tftp_data_block_length" bytes - stax temp - - lda #'.' - jsr print_a - lda file_opened - bne @already_opened - lda string_length - ldx #string_buffer - jsr open_file - -@already_opened: - - ldx #$02 ; filenumber 2 = output file - jsr $FFC9 ; call CHKOUT - -@copy_one_byte: - lda tftp_data_block_length - bne @not_done - lda tftp_data_block_length+1 - beq @done - -@not_done: - ldy #2 ;we want to skip the first 2 bytes in the buffer - lda (temp),y - jsr $ffd2 ;write byte - inc temp - bne :+ - inc temp+1 -: - lda tftp_data_block_length - dec tftp_data_block_length - cmp #0 - bne @copy_one_byte - dec tftp_data_block_length+1 - jmp @copy_one_byte -@done: - - ldx #$00 ; filenumber 0 = console - jmp $FFC9 ; call CHKOUT - - -tfput_keyword: - ldax #put_msg - jsr tf_param_setup - - lda param_length - ldx #transfer_buffer - jsr open_file - bcs @error - lda $90 ;get ST - beq @ok -@error: - - ldx #4 ;"FILE NOT FOUND" error - jmp $C437 ;error -@ok: - ldax #tftp_upload_callback - jsr tftp_set_callback_vector - jsr tftp_upload - jmp after_tftp_xfer - - -tftp_upload_callback: - stax copy_dest - lda #'.' - jsr print_a - lda #0 - sta bytes_read - sta bytes_read+1 - - ldx #$02 ; filenumber 2 = output file - jsr $FFC6 ; call CHKIN (file 2 now used as input) -@loop: - jsr $FFCF ; call CHRIN (get a byte from file) - ldy #0 - sta (copy_dest),y - inc copy_dest - bne :+ - inc copy_dest+1 -: - inc bytes_read - bne :+ - inc bytes_read+1 -: - lda bytes_read+1 - cmp #2 - beq @done - jsr $FFB7 ; call READST (read status byte) - beq @loop ; nonzero mean either EOF or read error - -@done: - ldx #$00 ; filenumber 0 = console - jsr $FFC6 ; call CHKIN (console now used as input) - ldax bytes_read - rts - -skip_comma_get_integer: - jsr CHRGOT - jsr CHKCOM ;make sure next char is a comma (and skip it) -get_integer: - jsr CHRGOT - beq @eol - jsr FRMNUM - jsr GETADR - ldax LINNUM -@no_param: - rts -@eol: - jmp $CF08 ;SYNTAX ERROR - - -make_tcp_connection: - lda #0 - sta connection_state - jsr set_connection_state - ldax #tcp_connect_ip - jsr get_ip_parameter - bcc @no_error - rts -@no_error: - jsr skip_comma_get_integer - jsr tcp_connect - bcc :+ -@connect_error: - ldax #connect - jmp print_error -: - ldax #connected_msg - jsr print - lda #1 - sta connection_state - lda #0 - sta ip65_error - jsr set_connection_state - clc - 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 - bcs @exit - - ;is there an optional parameter? - ldx #0 - jsr get_optional_byte - stx netcat_mode -@main_polling_loop: - - jsr timer_read - txa - adc #$20 ;32 x 1/4 = ~ 8seconds - sta netcat_timeout -@wait_for_keypress: - jsr timer_read - cpx netcat_timeout - bne @no_timeout - jsr tcp_send_keep_alive - jmp @main_polling_loop -@no_timeout: - jsr ip65_process - lda connection_state - bne @not_disconnected -@disconnected: - ldax #disconnected - jsr print -@exit: - lda cursor_state - sta $CC - rts -@not_disconnected: - - lda netcat_mode - beq @not_line_mode - - lda #$00 - sta string_length - -;process inbound ip packets while waiting for a keypress -@read_line: - lda $cb ;current key pressed - cmp #$18 ;RUN/STOP? - beq @runstop - jsr ip65_process - lda connection_state - beq @disconnected - - jsr $f142 ;not officially documented - where F13E (GETIN) falls through to if device # is 0 (KEYBD) - - beq @read_line - - cmp #$14 ;Delete - beq @delete - - cmp #$0d ;Return - beq @input_done - - ;End reached? - ldy string_length - cpy #$FF - beq @read_line - - jsr $ffd2 ;Print it - jsr native_to_ascii - sta transfer_buffer,y ;Add it to string - - inc string_length - - ;Not yet. - jmp @read_line - - -@delete: - ;First, check if we're at the beginning. - lda string_length - bne @delete_ok - jmp @read_line - - ;At least one character entered. -@delete_ok: - ;Move pointer back. - dec string_length - - ;Print the delete char - lda #$14 - jsr $ffd2 - - ;Wait for next char - jmp @read_line - -@input_done: - jsr reset_cursor - lda #$0d - jsr $ffd2 ;print a newline - ldy string_length - lda #$0d - sta transfer_buffer,y - iny - lda #$0a - sta transfer_buffer,y - iny - sty tcp_send_data_len - jmp @send_buffer -@not_line_mode: - - ;is there anything in the input buffer? - lda $c6 ;NDX - chars in keyboard buffer - bne :+ - jmp @wait_for_keypress -: - lda #0 - sta tcp_send_data_len - sta tcp_send_data_len+1 -@get_next_char: - lda $cb ;current key pressed - cmp #$18 ;RUN/STOP? - bne @not_runstop -@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 - tax - beq @no_more_input - txa - - ldy tcp_send_data_len - sta transfer_buffer,y - inc tcp_send_data_len - jmp @get_next_char -@no_more_input: -@send_buffer: - ldax #transfer_buffer - jsr tcp_send - bcs @error_on_send - 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 - lda #0 - sta connection_state - rts -@not_eof: - - ldax tcp_inbound_data_ptr - stax temp2 - lda tcp_inbound_data_length - sta buffer_length - lda tcp_inbound_data_length+1 - sta buffer_length+1 - -@next_byte: - lda $cb ;current key pressed - cmp #$18 ;RUN/STOP? - beq @finished - - ldy #0 - lda (temp2),y - ldx netcat_mode - beq @no_transform - jsr ascii_to_native -@no_transform: - jsr print_a - inc temp2 - bne :+ - inc temp2+1 -: - lda buffer_length+1 - beq @last_page - lda buffer_length - bne @not_end_of_page - dec buffer_length+1 -@not_end_of_page: - dec buffer_length - jmp @next_byte -@last_page: - dec buffer_length - beq @finished - - jmp @next_byte - -@finished: - - rts - - -tcpconnect_keyword: - ldax #tcpconnect_callback - stax tcp_callback - jmp make_tcp_connection - -tcpconnect_callback: - - 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 - lda #0 - sta connection_state - rts -@not_end_packet: - lda #$ff -@short_packet: - -set_input_string: - pha - lda #'I' - ldx #'N'+$80 - jsr find_var - ldy #0 - pla - pha - sta (VARPNT),y - iny - lda #transfer_buffer - sta (VARPNT),y - pla - beq :+ - ldx #0 - jsr copymem -: - rts - -poll_keyword: - lda #0 - jsr set_input_string - jsr set_connection_state - jsr ip65_process - lda ip65_error - beq @no_error - jmp set_error -@no_error: - jmp set_connection_state - -tcplisten_keyword: - lda #0 - sta connection_state - sta ip65_error - ldax #tcpconnect_callback - stax tcp_callback - jsr get_integer - jsr tcp_listen - bcs :+ - inc connection_state -: - jmp set_connection_state - -tcpsend_keyword: - jsr extract_string - ldy param_length - sty tcp_send_data_len - ldy #0 - sty tcp_send_data_len+1 - ldax #transfer_buffer - jsr tcp_send - jmp set_connection_state - -tcpclose_keyword: - lda #0 - sta connection_state - jsr tcp_close - jmp set_connection_state - -tcpblat_keyword: - - jsr extract_string - - ldx #transfer_buffer - lda param_length - 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: - lda #$02 ; filenumber 2 - jsr CLOSE - ldx #$00 ; filenumber 0 = keyboard - jsr CHKIN ;keyboard now input device again - jmp set_error - -@error: - lda #KPR_ERROR_DEVICE_FAILURE - jmp @store_error -@readerror: - 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 $D395 ;signed 16 bit number to floating point - rts - -@done: - jsr CHRGOT - jmp $CE8D ;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. -; All tokens are >$80, -; so they easily mark the end of the keyword -hexdigits: -.byte "0123456789ABCDEF" - -pinging: -.byte"PINGING ",0 -interface_type: -.byte $12,"INTERFACE",$92,13,0 - -mac_address_msg: -.byte $12,"MAC ADDRESS",$92,13,0 - -ip_address_msg: -.byte $12,"IP ADDRESS",$92,13,0 - -netmask_msg: -.byte $12,"NETMASK",$92,13,0 - -gateway_msg: -.byte $12,"GATEWAY",$92,13,0 - -dns_server_msg: -.byte $12,"DNS SERVER",$92,13,0 - -dhcp_server_msg: -.byte $12,"DHCP SERVER",$92,13,0 - -tftp_server_msg: -.byte $12,"TFTP SERVER",$92,13,0 - -address_resolution: -.byte "ADDRESS RESOLUTION",0 - -get_msg: -.byte "GETTING ",0 -put_msg: -.byte "PUTTING ",0 - -tftp: -.byte "TFTP",0 -dhcp: -.byte "DHCP",0 - -connect: -.byte "CONNECT",0 - -transmission: -.byte "TRANSMISSION",0 - -error: -.byte " ERROR $",0 - -disconnected: -.byte 13,"DIS" -connected_msg: -.byte "CONNECTED",13,0 - -keywords: - .byte "IF",$E0 ;our dummy 'IF' entry takes $E0 - .byte "IPCFG",$E1 - .byte "DHCP",$E2 - .byte "PING",$E3 - .byte "MYIP",$E4 - .byte "NETMASK",$E5 - .byte "GATEWAY",$E6 - .byte "DNS",$E7 - .byte "TFTP",$E8 - .byte "TF",$A1,$E9 ;TFGET - BASIC will replace GET with A1 - .byte "TFPUT",$EA - .byte "NETCAT",$EB - .byte "TCPC",$91,"NECT",$EC ; TCPCONNECT - BASIC will replace ON with $91 - .byte "POLL",$ED - .byte "TCP",$9B,"EN",$EE ;TCPLISTEN - BASIC will replace LIST with $9b - .byte "TCPS",$80,$EF ;TCPSEND - BASIC will replace END with $80 - .byte "TCP",$A0,$F0 ;TCPLOSE - BASIC will replace CLOSE with $A0 - .byte "TCPBLAT",$F1 - .byte "MAC",$F2 - .byte $00 ;end of list -HITOKEN=$F3 - -; -; Table of token locations-1 -; -token_routines: -E0: .word if_keyword-1 -E1: .word ipcfg_keyword-1 -E2: .word dhcp_keyword-1 -E3: .word ping_keyword-1 -E4: .word myip_keyword-1 -E5: .word netmask_keyword-1 -E6: .word gateway_keyword-1 -E7: .word dns_keyword-1 -E8: .word tftp_keyword-1 -E9: .word tfget_keyword-1 -EA: .word tfput_keyword-1 -EB: .word netcat_keyword-1 -EC: .word tcpconnect_keyword-1 -ED: .word poll_keyword-1 -EE: .word tcplisten_keyword-1 -EF: .word tcpsend_keyword-1 -FO: .word tcpclose_keyword-1 -F1: .word tcpblat_keyword-1 -F2: .word mac_keyword-1 - -.segment "SELF_MODIFIED_CODE" - - -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 - inc string_length - inc current_output_ptr - bne :+ - inc current_output_ptr+1 -: - rts - - -.bss -netcat_mode: .res 1 -bytes_read: .res 2 -string_length: .res 1 -param_length: .res 1 -ip_string: .res 15 -netmask_string: .res 15 -dns_string: .res 15 -gateway_string: .res 15 - temp_bin: .res 1 -temp_bcd: .res 2 -ping_counter: .res 1 -string_buffer: .res 128 -transfer_buffer: .res 256 -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/timestamp.rb b/client/basic/timestamp.rb deleted file mode 100644 index a061cf9..0000000 --- a/client/basic/timestamp.rb +++ /dev/null @@ -1 +0,0 @@ -puts Time.now.strftime(".byte \" (%Y-%m-%d)\"") \ No newline at end of file diff --git a/client/basic/welcome_banner.txt b/client/basic/welcome_banner.txt deleted file mode 100644 index 1182c50..0000000 --- a/client/basic/welcome_banner.txt +++ /dev/null @@ -1 +0,0 @@ -**** KIPPER BASIC 1.1 **** diff --git a/client/carts/Makefile b/client/carts/Makefile deleted file mode 100644 index 3c012cf..0000000 --- a/client/carts/Makefile +++ /dev/null @@ -1,145 +0,0 @@ -AS=ca65 -LD=ld65 -CFLAGS=-Oirs -t $(TARGET) -AFLAGS= - -INCFILES=\ - ../inc/common.i\ - ../inc/commonprint.i\ - ../inc/net.i\ - ../inc/menu.i\ - ../inc/kipper_constants.i\ - ../inc/version.i\ - -IP65LIB=../ip65/ip65.lib -IP65TCPLIB=../ip65/ip65_tcp.lib -C64RRNETLIB=../drivers/c64rrnet.lib -C64WIZNETLIB=../drivers/c64wiznet.lib -IP65WIZNETLIB=../ip65/ip65_wiznet.lib - -all: ip65 drivers\ - kkwiz.bin \ - kkwiz.prg \ - bobcart.bin \ - kipperkart.bin \ - kipperkart_rr.bin \ - netboot.bin \ - kipperterm.bin \ - kipperkart.prg \ - kipperterm.prg \ - kipperterm_rr.bin \ - kippergo.bin \ - kipperkart.prg \ - kippergo.prg \ - kippergo_rr.bin \ - kkwiz_rr.bin \ - telnetd.prg \ - kipperdisk.d64 \ - -kipperkart.o: kipperkart.s $(INCFILES) ../inc/ping.i ../inc/disk_transfer.i ../inc/sidplay.i ../inc/config_menu.i - $(AS) $(AFLAGS) -o $@ $< - -kipperterm.o: kipperterm.s $(INCFILES) ../inc/telnet.i ../inc/config_menu.i - $(AS) $(AFLAGS) -o $@ $< - -kippergo.o: kippergo.s $(INCFILES) ../inc/gopher.i ../inc/telnet.i ../inc/config_menu.i - $(AS) $(AFLAGS) -o $@ $< - -%.o: %.s $(INCFILES) - ruby timestamp.rb > timestamp.i - $(AS) $(AFLAGS) $< - -kipperkart.prg: kipperkart.bin c64_cart_ram_header.prg - cat c64_cart_ram_header.prg kipperkart.bin > kipperkart.prg - - -kkwiz.prg: kkwiz.bin c64_cart_ram_header.prg - cat c64_cart_ram_header.prg kkwiz.bin > kkwiz.prg - -kipperterm.prg: kipperterm.bin c64_cart_ram_header.prg - cat c64_cart_ram_header.prg kipperterm.bin > kipperterm.prg - -kippergo.prg: kippergo.bin c64_cart_ram_header.prg - cat c64_cart_ram_header.prg kippergo.bin > kippergo.prg - -%.prg: %.o $(IP65LIB) $(C64RRNETLIB) $(INCFILES) ../cfg/c64prg.cfg - $(LD) -m $*.map -vm -C ../cfg/c64prg.cfg -o $*.prg $(AFLAGS) $< $(IP65LIB) $(C64RRNETLIB) - - -netboot.bin: netboot.o $(IP65LIB) $(C64RRNETLIB) $(INCFILES) ../cfg/c64_8kcart.cfg - $(LD) -m netboot.map -vm -C ../cfg/c64_8kcart.cfg -o $@ $< $(IP65LIB) $(C64RRNETLIB) - ruby fix_cart.rb $@ 8192 - -kipperkart.bin: kipperkart.o $(IP65TCPLIB) $(C64RRNETLIB) $(INCFILES) ../cfg/c64_16kcart.cfg - $(LD) -m kipperkart.map -vm -C ../cfg/c64_16kcart.cfg -o $@ $< $(IP65TCPLIB) $(C64RRNETLIB) - ruby fix_cart.rb $@ 16384 - ruby set_ip_config.rb $@ mac auto - ruby dupe_cart.rb kipperkart.bin kipperkart_29c040.bin 32 - -kipperterm.bin: kipperterm.o $(IP65TCPLIB) $(C64RRNETLIB) $(INCFILES) ../cfg/c64_16kcart.cfg - $(LD) -m kipperterm.map -vm -C ../cfg/c64_16kcart.cfg -o $@ $< $(IP65TCPLIB) $(C64RRNETLIB) - ruby fix_cart.rb $@ 16384 - ruby dupe_cart.rb kipperterm.bin kipperterm_29c040.bin 32 - -kipperterm_rr.bin: kipperterm.bin - cp crt8040.obj rrnet_header.bin - cat rrnet_header.bin kipperterm.bin > kipperterm_rr.bin - ruby fix_cart.rb $@ 32768 - - -kippergo.bin: kippergo.o $(IP65TCPLIB) $(C64RRNETLIB) $(INCFILES) ../cfg/c64_16kcart.cfg - $(LD) -m kippergo.map -vm -C ../cfg/c64_16kcart.cfg -o $@ $< $(IP65TCPLIB) $(C64RRNETLIB) - ruby fix_cart.rb $@ 16384 - ruby dupe_cart.rb kippergo.bin kippergo_29c040.bin 32 - -kippergo_rr.bin: kippergo.bin - cp crt8040.obj rrnet_header.bin - cat rrnet_header.bin kippergo.bin > kippergo_rr.bin - ruby fix_cart.rb $@ 32768 - -kipperkart_rr.bin: kipperkart.bin - cp crt8040.obj rrnet_header.bin - cat rrnet_header.bin kipperkart.bin > kipperkart_rr.bin - ruby fix_cart.rb $@ 32768 - -kipperdisk.d64: kipperkart.prg kipperterm.prg kipperkart.prg kippergo.prg - c1541 -format kipperdisk,kd d64 $@ -attach $@ -write kipperkart.prg -write kipperterm.prg -write kippergo.prg - cp $@ ../../server/boot/ - -bobcart.bin: bobcart.o $(IP65TCPLIB) $(C64RRNETLIB) $(INCFILES) ../cfg/c64_8kcart.cfg - $(LD) -m bobcart.map -vm -C ../cfg/c64_8kcart.cfg -o $@ $< $(IP65TCPLIB) $(C64RRNETLIB) - ruby fix_cart.rb $@ 8192 - -kkwiz.bin: kipperkart.o $(IP65WIZNETLIB) $(C64WIZNETLIB) $(INCFILES) ../cfg/c64_16kcart.cfg - $(LD) -m kkwiz.map -vm -C ../cfg/c64_16kcart.cfg -o $@ $< $(IP65WIZNETLIB) $(C64WIZNETLIB) - ruby fix_cart.rb $@ 16384 -# ruby set_ip_config.rb $@ mac auto - -kkwiz_rr.bin: kkwiz.bin - cp crt8040.obj rrnet_header.bin - cat rrnet_header.bin kkwiz.bin > kkwiz_rr.bin - ruby fix_cart.rb $@ 32768 - cp kkwiz_rr.bin ../wiznet/ - -telnetd.bin: telnetd.o $(IP65TCPLIB) $(C64RRNETLIB) $(INCFILES) ../cfg/c64_8kcart.cfg - $(LD) -m telnetd.map -vm -C ../cfg/c64_8kcart.cfg -o $@ $< $(IP65TCPLIB) $(C64RRNETLIB) - ruby ../carts/fix_cart.rb $@ 8192 - -telnetd.prg: telnetd.bin cartheader.prg - cat cartheader.prg telnetd.bin > $@ - -d64_upload.d64: d64_upload.prg - cp d64_upload.prg ../../server/boot/ - c1541 -format d64upload,kd d64 $@ -attach $@ -write d64_upload.prg - -clean: - rm -f *.o *.bin *.map *.prg *.pg2 *.dsk *.d64 - -distclean: clean - rm -f *~ - -ip65: - make -C ../ip65 all - -drivers: - make -C ../drivers all diff --git a/client/carts/bobcart.s b/client/carts/bobcart.s deleted file mode 100644 index dabd5f4..0000000 --- a/client/carts/bobcart.s +++ /dev/null @@ -1,1671 +0,0 @@ - -.include "../inc/common.i" -;.ifndef KPR_API_VERSION_NUMBER -; .define EQU = -; .include "../inc/kipper_constants.i" -;.endif - - -HTTPD_TIMEOUT_SECONDS=5 ;what's the maximum time we let 1 connection be open for? - -;DEBUG=1 - -VARTAB = $2D ;BASIC variable table storage -ARYTAB = $2F ;BASIC array table storage -FREETOP = $33 ;bottom of string text storage area -MEMSIZ = $37 ;highest address used by BASIC -VARNAM = $45 ;current BASIC variable name -VARPNT = $47 ; pointer to current BASIC variable value - -SETNAM = $FFBD -SETLFS = $FFBA -LOAD = $FFD5 -OPEN = $FFC0 -CHKIN = $FFC6 -READST = $FFB7 ; read status byte -CHRIN = $FFCF ; get a byte from file -CLOSE = $FFC3 -MEMTOP = $FE25 -TXTPTR = $7A ;BASIC text pointer -IERROR = $0300 -ICRUNCH = $0304 ;Crunch ASCII into token -IQPLOP = $0306 ;List -IGONE = $0308 ;Execute next BASIC token - -CHRGET = $73 -CHRGOT = $79 -CHROUT = $FFD2 -GETBYT = $B79E ;BASIC routine -GETPAR = $B7EB ;Get a 16,8 pair of numbers -CHKCOM = $AEFD -NEW = $A642 -CLR = $A65E -NEWSTT = $A7AE -GETVAR = $B0E7 ;find or create a variable -FRMEVL = $AD9E ;evaluate expression -FRESTR = $B6A3 ;free temporary string -FRMNUM = $AD8A ;get a number -GETADR = $B7F7 ;convert number to 16 bit integer -INLIN = $A560 ; read a line from keyboard - -VALTYP=$0D ;00=number, $FF=string - -LINNUM = $14 ;Number returned by GETPAR - -crunched_line = $0200 ;Input buffer - -.import copymem -.importzp copy_src -.importzp copy_dest -.import ip65_init -.import cfg_get_configuration_ptr -.import ip65_process -.import ip65_error -.import cfg_ip -.import cfg_dns -.import cfg_gateway -.import cfg_netmask -.import icmp_ping -.import icmp_echo_ip -.import dotted_quad_value -.import parse_dotted_quad - -.import print_a -.import print_cr -.import cfg_mac -.import eth_driver_name -.import get_key_if_available -.import timer_read -.import native_to_ascii -.import ascii_to_native -.import eth_init - -.import http_parse_request -.import http_get_value -.import http_variables_buffer - -.import tcp_inbound_data_ptr -.import tcp_inbound_data_length -.import tcp_send_data_len -.import tcp_send -.import check_for_abort_key -.import tcp_connect_remote_port -.import tcp_remote_ip -.import tcp_listen -.import tcp_callback -.import tcp_close - -.import __DATA_LOAD__ -.import __DATA_RUN__ -.import __DATA_SIZE__ -.import __SELF_MODIFIED_CODE_LOAD__ -.import __SELF_MODIFIED_CODE_RUN__ -.import __SELF_MODIFIED_CODE_SIZE__ - -temp_ptr =copy_src -temp=copy_src -temp2=copy_dest - -;.zeropage -;temp: .res 2 -;temp2: .res 2 -pptr=temp_ptr -.segment "CARTRIDGE_HEADER" -.word init ;cold start vector -.word $FE47 ;warm start vector -.byte $C3,$C2,$CD,$38,$30 ; "CBM80" -.byte "KIPBOB" -.byte $0,$0,$0 ;reserved for future use -.byte $0,$0,$0 ;reserved for future use -.byte $0,$0,$0 ;reserved for future use - -.code - -init: -;first let the kernal do a normal startup - sei - jsr $fda3 ;initialize CIA I/O - jsr $fd50 ;RAM test, set pointers - jsr $fd15 ;set vectors for KERNAL - jsr $ff5B ;init. VIC - cli ;KERNAL init. finished - - -;we need to set up BASIC as well - jsr $e453 ;set BASIC vectors - jsr $e3bf ;initialize zero page - - - -;make some room for extra RAM - - ldax #$5800 - stax MEMSIZ - - stax http_variables_buffer - - ldax #welcome_banner - jsr print - lda #$90 ;'rest of banner - ldy #$E4 - -;print rest of startup banner - JSR $E42D - -;relocate our r/w data - ldax #__DATA_LOAD__ - stax copy_src - ldax #__DATA_RUN__ - stax copy_dest - ldax #__DATA_SIZE__ - jsr copymem - - ldax #__SELF_MODIFIED_CODE_LOAD__ - stax copy_src - ldax #__SELF_MODIFIED_CODE_RUN__ - stax copy_dest - ldax #__SELF_MODIFIED_CODE_SIZE__ - jsr copymem - - - ldx #5 ;Copy CURRENT vectors -@copy_old_vectors_loop: - lda ICRUNCH,x - sta oldcrunch,x - dex - bpl @copy_old_vectors_loop - - ldx #5 ;Copy CURRENT vectors -install_new_vectors_loop: - lda vectors,x - sta ICRUNCH,x - dex - bpl install_new_vectors_loop - -;copy error handlers: - ldax IERROR - stax olderror - ldax #error_handler - stax IERROR - - ;BASIC keywords installed, now bring up the ip65 stack - - jsr ip65_init - bcc @init_ok - ldax #@no_nic - jsr print -@reboot: - jsr $e453 ;reset vectors - jsr $e3bf ;init BASIC - jsr $a644 ;NEW - jmp $e39d -@no_nic: - .byte 13,"RR-NET NOT FOUND",13,0 - -@init_ok: - - jsr $A644 ;do a "NEW" - jmp $A474 ;"READY" prompt -; rts ;so BASIC will LOAD & RUN INDEX.BAS - -welcome_banner: -.byte $93,$0d," **** C64 BASIC ON BAILS" -.byte 0 - - -safe_getvar: ;if GETVAR doesn't find the desired variable name in the VARTABLE, a routine at $B11D will create it - ;however that routine checks if the low byte of the return address of the caller is $2A. if it is, - ;it assumes the caller is the routine at $AF28 which just wants to get the variable value, and - ;returns a pointer to a dummy 'zero' pointer. - ;so if user code that is calling GETVAR happens to be compiled to an address $xx28, it will - ;trigger this check, and not create a new variable, which (from painful experience) will create - ;a really nasty condition to debug! - ;so vector to GETVAR via here, so the return address seen by $B11D is here, and never $xx28 - jsr GETVAR - rts -.code - - -; CRUNCH -- If this is one of our keywords, then tokenize it -; -crunch: - jsr jmp_crunch ;First crunch line normally - ldy #05 ;Offset for KERNAL - ;Y will contain line length+5 -@loop: - sty temp - jsr isword ;Are we at a keyword? - bcs @gotcha -@next: - jsr nextchar - bne @loop ;Null byte marks end - sta crunched_line-3,Y ;00 line number - lda #$FF ;'tis what A should be - rts ;Buh-bye - -; Insert token and crunch line -@gotcha: - ldx temp ;If so, A contains opcode - sta crunched_line-5,X -@move: - inx - lda crunched_line-5,Y - sta crunched_line-5,X ;Move text backwards - beq @next - iny - bpl @move - - -; ISWORD -- Checks to see if word is -; in table. If a word is found, then -; C is set, Y is one past the last char -; and A contains opcode. Otherwise, -; carry is clear. -; -; On entry, TEMP must contain current -; character position. -; -isword: - ldx #00 -@loop: - ldy temp -@loop2: - lda keywords,x - beq @notmine - cmp #$E0 - bcs @done ;Tokens are >=$E0 - cmp crunched_line-5,Y - bne @next - iny ;Success! Go to next char - inx - bne @loop2 -@next: - inx - lda keywords,x ;Find next keyword - cmp #$E0 - bcc @next - inx - bne @loop ;And check again -@notmine: - clc -@done: - rts - - -; NEXTCHAR finds the next char -; in the buffer, skipping -; spaces and quotes. On -; entry, TEMP contains the -; position of the last spot -; read. On exit, Y contains -; the index to the next char, -; A contains that char, and Z is set if at end of line. - -nextchar: - ldy temp -@loop: - iny - lda crunched_line-5,Y - beq @done - cmp #$8F ;REM - bne @cont - lda #00 -@skip: - sta temp2 ;Find matching character -@loop2: - iny - lda crunched_line-5,Y - beq @done - cmp temp2 - bne @loop2 ;Skip to end of line - beq @loop -@cont: - cmp #$20 ;space - beq @loop - cmp #$22 ;quote - beq @skip -@done: - rts - - -; -; LIST -- patches the LIST routine -; to list our new tokens correctly. -; - -list: - cmp #$E0 - bcc @notmine ;Not my token - cmp #HITOKEN - bcs @notmine - bit $0F ;Check for quote mode - bmi @notmine - sec - sbc #$DF ;Find the corresponding text - tax - sty $49 - ldy #00 -@loop: - dex - beq @done -@loop2: - iny - lda keywords,y - cmp #$E0 - bcc @loop2 - iny - bne @loop -@done: - lda keywords,y - cmp #$91 ;is it "ON"? - bne @not_on - lda #'O' - jsr CHROUT - lda #'N' - bne @skip - -@not_on: - cmp #$9B ;is it "LIST"? - - bne @not_list - lda #'L' - jsr CHROUT - lda #'I' - jsr CHROUT - lda #'S' - jsr CHROUT - lda #'T' - bne @skip -@not_list: - lda keywords,y - bmi @out ;is it >=$80? -@skip: - jsr CHROUT - iny - bne @done -@out: - cmp #$E0 ;It might be BASIC token - bcs @cont - ldy $49 -@notmine: - and #$FF - jmp (oldlist) -@cont: - ldy $49 - jmp $A700 ;Normal exit - - - -; -; EXECUTE -- if this is one of our new -; tokens, then execute it. -execute: - jsr CHRGET -execute_a: - php - cmp #':' ;is it a colon? - beq execute;if so, skip over and go to next token - cmp #$8B ;is it 'IF'? - bne @not_if - lda #$E0 ;our dummy IF token -@not_if: - cmp #$E0 - bcc @notmine - cmp #HITOKEN - bcs @notmine - plp - jsr @disp - jmp NEWSTT -@disp: - eor #$E0 - asl ;multiply by 2 - tax - lda token_routines+1,x - pha - lda token_routines,x - pha - jmp CHRGET ;exit to routine (via RTS) -@notmine: - plp - cmp #0 ;reset flags - jmp $A7E7 - -;the standard BASIC IF routine calls the BASIC EXECUTE routine directly, -;without going through the vector. That means an extended keyword following THEN -;will lead to a syntax error. So we have to reimpliment IF here -;this is taken from TransBASIC - The Transactor, vol 5, Issue 04 (March 1985) page 34 -if_keyword: - jsr FRMEVL ;evaluate expression - jsr CHRGOT - cmp #$89 ;is next token GOTO? - beq @ok - lda #$A7 ;is next token THEN - jsr $AEFF ;will generate SYNTAX ERROR if not -@ok: - jsr CHRGOT - ldx $61 ;result of expression : 0 means false - bne @expression_was_true - jmp $A93B ;go to REM implementation - skips rest of line -@expression_was_true: - bcs @not_numeric;CHRGOT clears carry flag if current char is a number - jmp $A8A0 ;do a GOTO -@not_numeric: - pla - pla ;pop the return address off the stack - jsr CHRGOT - jmp execute_a ;execute current token - - - -;emit the 4 bytes pointed at by AX as dotted decimals -emit_dotted_quad: - sta pptr - stx pptr + 1 - ldy #0 - lda (pptr),y - jsr emit_decimal - lda #'.' - jsr emit_a - - ldy #1 - lda (pptr),y - jsr emit_decimal - lda #'.' - jsr emit_a - - ldy #2 - lda (pptr),y - jsr emit_decimal - lda #'.' - jsr emit_a - - ldy #3 - lda (pptr),y - jsr emit_decimal - - rts - -emit_decimal: ;emit byte in A as a decimal number - pha - sta temp_bin ;save - sed ; Switch to decimal mode - lda #0 ; Ensure the result is clear - sta temp_bcd - sta temp_bcd+1 - ldx #8 ; The number of source bits - : - asl temp_bin+0 ; Shift out one bit - lda temp_bcd+0 ; And add into result - adc temp_bcd+0 - sta temp_bcd+0 - lda temp_bcd+1 ; propagating any carry - adc temp_bcd+1 - sta temp_bcd+1 - dex ; And repeat for next bit - bne :- - - cld ;back to binary - - pla ;get back the original passed in number - bmi @emit_hundreds ; if N is set, the number is >=128 so emit all 3 digits - cmp #10 - bmi @emit_units - cmp #100 - bmi @emit_tens -@emit_hundreds: - lda temp_bcd+1 ;get the most significant digit - and #$0f - clc - adc #'0' - jsr emit_a - -@emit_tens: - lda temp_bcd - lsr - lsr - lsr - lsr - clc - adc #'0' - jsr emit_a -@emit_units: - lda temp_bcd - and #$0f - clc - adc #'0' - jsr emit_a - - rts - -print: - sta pptr - stx pptr + 1 - -@print_loop: - ldy #0 - lda (pptr),y - beq @done_print - jsr print_a - inc pptr - bne @print_loop - inc pptr+1 - bne @print_loop ;if we ever get to $ffff, we've probably gone far enough ;-) -@done_print: - rts - - -extract_string: - jsr FRMEVL - jsr FRESTR ;if not string, will create type mismatch error - sta param_length - tay - lda #0 - sta transfer_buffer,y - dey -@loop: - lda ($22),y - sta transfer_buffer,y - dey - bpl @loop - jmp FRESTR ;free up the temp string created by FRMEVL - -;get a string value from BASIC command, turn into a 32 bit IP address,save it in the 4 bytes pointed at by AX -get_ip_parameter: - stax temp2 - jsr extract_string - ldax #transfer_buffer - jsr parse_dotted_quad - - bcc @ok -@error: - ldax #address_resolution - jmp print_error - -@ok: - ldax #dotted_quad_value - ldx #4 -@copy_dotted_quad_value: - lda dotted_quad_value,y - sta (temp2),y - iny - dex - bne @copy_dotted_quad_value - rts - - -reset_string: - ldy #string_buffer - sty current_output_ptr+1 - rts - -print_dotted_quad: - jsr reset_string - jsr emit_dotted_quad -make_null_terminated_and_print: - lda #0 - jsr emit_a - ldax #string_buffer - jmp print - -print_integer: -sta $63 -stx $62 -jmp $bdd1 ;BASIC routine - -print_decimal: - jsr reset_string - jsr emit_decimal - jmp make_null_terminated_and_print - -print_mac: - jsr reset_string - jsr emit_mac - jmp make_null_terminated_and_print - -;print 6 bytes printed at by AX as a MAC address -emit_mac: - stax pptr - ldy #0 -@one_mac_digit: - tya ;just to set the Z flag - pha - beq @dont_print_colon - lda #':' - jsr emit_a -@dont_print_colon: - pla - tay - lda (pptr),y - jsr emit_hex - iny - cpy #06 - bne @one_mac_digit - rts - -emit_hex: - pha - pha - lsr - lsr - lsr - lsr - tax - lda hexdigits,x - jsr emit_a - pla - and #$0F - tax - lda hexdigits,x - jsr emit_a - pla - rts - -print_hex: - jsr reset_string - jsr emit_hex - jmp make_null_terminated_and_print - -print_error: - jsr print - ldax #error - jsr print - lda ip65_error - jsr print_hex - jsr print_cr - sec - rts - -get_optional_byte: - jsr CHRGOT - beq @no_param ;leave X as it was - jsr CHKCOM ;make sure next char is a comma (and skip it) - jsr CHRGOT - beq @eol - jsr GETBYT -@no_param: - rts -@eol: - jmp $AF08 ;SYNTAX ERROR - -ipcfg_keyword: - - ldax #interface_type - jsr print - - ldax #eth_driver_name - jsr print - jsr print_cr - - ldax #mac_address_msg - jsr print - ldax #cfg_mac - jsr print_mac - jsr print_cr - - ldax #ip_address_msg - jsr print - ldax #cfg_ip - jsr print_dotted_quad - jsr print_cr - - ldax #netmask_msg - jsr print - ldax #cfg_netmask - jsr print_dotted_quad - jsr print_cr - - ldax #gateway_msg - jsr print - ldax #cfg_gateway - jsr print_dotted_quad - jsr print_cr - - - - rts - - - -ping_keyword: - ldax #icmp_echo_ip - jsr get_ip_parameter - bcc @no_error - rts -@no_error: - - ;is there an optional parameter? - ldx #3 - jsr get_optional_byte - stx ping_counter - - ldax #pinging - jsr print - ldax #icmp_echo_ip - jsr print_dotted_quad - jsr print_cr - -@ping_loop: - jsr icmp_ping - bcs @error - lda #'.' -@print_and_loop: - jsr print_a - lda $cb ;current key pressed - cmp #$3F ;RUN/STOP? - beq @done - dec ping_counter - bne @ping_loop -@done: - jmp print_cr -@error: - jsr print_error - lda #'!' - jmp @print_and_loop - - -myip_keyword: - ldax #cfg_ip - jmp get_ip_parameter - -gateway_keyword: - ldax #cfg_gateway - jmp get_ip_parameter - -netmask_keyword: - ldax #cfg_netmask - jmp get_ip_parameter - -mac_keyword: - jsr extract_string - ldy #2 -: - lda transfer_buffer,y - sta cfg_mac+3,y - dey - bpl:- - jsr eth_init - rts - - -skip_comma_get_integer: - jsr CHRGOT - jsr CHKCOM ;make sure next char is a comma (and skip it) -get_integer: - jsr CHRGOT - beq @eol - jsr FRMNUM - jsr GETADR - ldax LINNUM -@no_param: - rts -@eol: - jmp $AF08 ;SYNTAX ERROR - - -hook_keyword: - jsr extract_string - ldax #transfer_buffer - jsr skip_comma_get_integer - stax handler_address - jsr find_hook - bcc @existing_entry - - lda hooks - cmp #MAX_HOOKS - bmi @got_space - ldx #$10 ;OUT OF MEMORY - jmp $A437 ;print error -@got_space: - clc - lda #0 - adc hooks - adc hooks - adc hooks - adc hooks - adc hooks - adc hooks - tay - inc hooks - @existing_entry: - ;y now points to free slot in hook table - lda transfer_buffer - sta hook_table,y - lda transfer_buffer+1 - sta hook_table+1,y - lda param_length - sta hook_table+2,y - lda hash - sta hook_table+3,y - lda handler_address - sta hook_table+4,y - lda handler_address+1 - sta hook_table+5,y - rts - - -goto: - sta $14 - sta $39 - stx $15 - stx $3a - - jmp $a8a3 ;GOTO keyword - - -find_hook: - jsr calc_hash - ldy #0 - ldx hooks - beq @done -@compare_one_entry: - lda transfer_buffer - cmp hook_table,y - bne @nope - lda transfer_buffer+1 - cmp hook_table+1,y - bne @nope - lda param_length - cmp hook_table+2,y - bne @nope - lda hash - cmp hook_table+3,y - bne @nope -;found it! - clc - rts -@nope: - dex - beq @done - iny - iny - iny - iny - iny - iny - - bne @compare_one_entry -@done: - sec - rts - -calc_hash: - clc - lda #0 - ldy param_length - beq @done -@loop: - adc transfer_buffer,y - dey - bne @loop -@done: - sta hash - rts - - -yield_keyword: - jsr flush_keyword - jsr tcp_close - .ifdef DEBUG - dec $d020 - .endif - jmp httpd_start - -gosub: - -bang_keyword: - jsr extract_string - lda sent_header - bne :+ - jsr send_header -: - ldy #0 - sty string_ptr -@loop: - lda transfer_buffer,y - jsr xmit_a - inc string_ptr - ldy string_ptr - cpy param_length - bne @loop - rts - - - -got_http_request: - jsr http_parse_request - ldax #path - jsr print - lda #$02 - jsr http_get_value - stax copy_src - jsr print - jsr print_cr - ldy #0 -@copy_path: - lda (copy_src),y - beq @done - sta transfer_buffer,y - iny - bne @copy_path -@done: - sty string_length - lda #0 - sta transfer_buffer,y - sty param_length - sty tmp_length - clc - lda #'P' - sta VARNAM - lda #'A'+$80 - jmp @set_var_value -@copy_vars: - iny - lda (copy_src),y - beq @last_var - tax ;var name - iny - clc - tya - adc copy_src - sta copy_src - bcc :+ - inc copy_src+1 -: - ldy #0 -: - lda (copy_src),y - beq @end_of_var - iny - bne :- -@end_of_var: - sty tmp_length - clc - stx VARNAM - lda #$80 -@set_var_value: - sta VARNAM+1 - jsr safe_getvar - ldy #0 - lda tmp_length - sta (VARPNT),y - iny - lda copy_src - sta (VARPNT),y - iny - lda copy_src+1 - sta (VARPNT),y - ldy tmp_length - jmp @copy_vars - - - @last_var: - - jsr find_hook - bcc @got_hook - ldax default_line_number - jmp goto - @got_hook: - lda hook_table+4,y - ldx hook_table+5,y - jmp goto - - -;start a HTTP server -;this routine will stay in an endless loop that is broken only if user press the ABORT key (runstop on a c64) -;inputs: -; none -;outputs: -; none -httpd_start: - ldx top_of_stack - txs - ldax #listening - jsr print - ldax #cfg_ip - jsr print_dotted_quad - lda #':' - jsr print_a - ldax httpd_port_number - jsr print_integer - jsr print_cr - lda #0 - sta $dc08 ;make sure TOD clock is started - -@listen: - jsr tcp_close - ldax httpd_io_buffer - stax tcp_buffer_ptr - ldax #http_callback - stax tcp_callback - ldax httpd_port_number - - jsr tcp_listen - bcs @abort_key_pressed - -@connect_ok: -.ifdef DEBUG - inc $d020 -.endif - ldax #connection_from - jsr print - ldax #tcp_remote_ip - jsr print_dotted_quad - lda #':' - jsr print_a - ldax tcp_connect_remote_port - - jsr print_integer - jsr print_cr - lda #0 - sta connection_closed - sta found_eol - clc - lda $dc09 ;time of day clock: seconds (in BCD) - sed - adc #HTTPD_TIMEOUT_SECONDS - cmp #$60 - bcc @timeout_set - sec - sbc #$60 -@timeout_set: - cld - sta connection_timeout_seconds - -@main_polling_loop: - jsr ip65_process - jsr check_for_abort_key - bcc @no_abort -@abort_key_pressed: - lda #0 - sta error_handling_mode - ldx #$1E ;break - jmp $e38b ;print error message, warm start BASIC - -@no_abort: - lda found_eol - bne @got_eol - - lda $dc09 ;time of day clock: seconds - - cmp connection_timeout_seconds - beq @connection_timed_out - lda connection_closed - beq @main_polling_loop -@connection_timed_out: -.ifdef DEBUG - dec $d020 -.endif - jmp @listen - -@got_eol: - - jsr reset_output_buffer - - ldy #$FF -: - iny - lda status_ok,y - sta status_code_buffer,y - bne :- - - ldy #$FF -: - iny - lda text_html,y - sta content_type_buffer,y - bne :- - - sta sent_header - - ldax httpd_io_buffer - jmp got_http_request - -http_callback: - lda tcp_inbound_data_length+1 - cmp #$ff - bne @not_eof - inc connection_closed -@done: - rts -@not_eof: - lda found_eol - bne @done - -;copy this chunk to our input buffer - ldax tcp_buffer_ptr - stax copy_dest - ldax tcp_inbound_data_ptr - stax copy_src - ldax tcp_inbound_data_length - jsr copymem - -;increment the pointer into the input buffer - clc - lda tcp_buffer_ptr - adc tcp_inbound_data_length - sta tcp_buffer_ptr - sta temp_ptr - lda tcp_buffer_ptr+1 - adc tcp_inbound_data_length+1 - sta tcp_buffer_ptr+1 - sta temp_ptr+1 - -;put a null byte at the end (assumes we have set temp_ptr already) - lda #0 - tay - sta (temp_ptr),y - -;look for CR or LF in input - sta found_eol - ldax httpd_io_buffer - stax get_next_byte+1 - -@look_for_eol: - jsr get_next_byte - cmp #$0a - beq @found_eol - cmp #$0d - bne @not_eol -@found_eol: - - inc found_eol - rts -@not_eol: - cmp #0 - bne @look_for_eol - rts - - - -reset_output_buffer: - ldax httpd_io_buffer - sta xmit_a_ptr+1 - stx xmit_a_ptr+2 - lda #0 - sta output_buffer_length - sta output_buffer_length+1 - rts - - -send_buffer: - ldax output_buffer_length - stax tcp_send_data_len - ldax httpd_io_buffer - jsr tcp_send - jmp reset_output_buffer - - -emit_string: - stax temp_ptr - ldy #0 -@next_byte: - lda (temp_ptr),y - beq @done - jsr xmit_a - iny - bne @next_byte -@done: - rts - - - -httpd_keyword: - jsr get_integer - stax httpd_port_number - jsr skip_comma_get_integer - stax default_line_number - inc error_handling_mode - tsx - stx top_of_stack - jmp httpd_start - -status_keyword: - jsr extract_string - ldy #$FF -@loop: - iny - lda transfer_buffer,y - sta status_code_buffer,y - bne @loop - rts - - -type_keyword: - jsr extract_string - ldy #$FF -@loop: - iny - lda transfer_buffer,y - sta content_type_buffer,y - bne @loop - rts - -send_header: - inc sent_header - ldax #http_version - jsr emit_string - ldax #status_code_buffer - jsr emit_string - ldax #crlf - jsr emit_string - ldax #content_type - jsr emit_string - ldax #content_type_buffer - jsr emit_string - ldax #end_of_header - jmp emit_string - - -flush_keyword: - - lda output_buffer_length - bne :+ - ldx output_buffer_length+1 - bne :+ - rts -: - jmp send_buffer - - -xsend_keyword: - - jsr extract_string - - ldx #transfer_buffer - lda param_length - 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 - -@loop: - jsr CHRIN - sta tmp_a - jsr READST - bne @eof ; either EOF or read error - lda sent_header - bne :+ - jsr send_header -: - lda tmp_a - jsr xmit_a - jmp @loop -@eof: - and #$40 ; end of file? - beq @error - lda tmp_a - jsr xmit_a - -@close_handles: - lda #$02 ; filenumber 2 - jsr CLOSE - ldx #$00 ; filenumber 0 = keyboard - jsr CHKIN ;keyboard now input device again - rts - - - @error: - - lda #$00 ; no filename - tax - tay - jsr SETNAM - lda #$0f ;file number 15 - ldx $ba ;drive number - ldy #$0f ; secondary address 15 (error channel) - jsr SETLFS - jsr OPEN - LDX #$0F ; filenumber 15 - JSR CHKIN ;(file 15 now used as input) - LDY #$00 -@error_loop: - JSR READST ;(read status byte) - BNE @error_eof ; either EOF or read error - JSR CHRIN ;(get a byte from file) - sta error_buffer,y - iny - - JMP @error_loop ; next byte -@error_eof: - lda #0 - sta error_buffer,y - LDX #$00 ; filenumber 0 = keyboard - JSR CHKIN ;(keyboard now input device again) - - - jsr @close_handles - jmp create_error - -create_error: - lda sent_header - bne @header_sent - ldy #$FF -: - iny - lda status_error,y - sta status_code_buffer,y - bne :- - jsr send_header - -@header_sent: - ldax #error_start - jsr emit_string - ldax #system_error - jsr print - lda $3a ;current line number - ldx $39 - sta $62 - stx $63 - ldx #$90 ;exponent to 16 - sec - jsr $bc49 ;pad out flp acc - jsr $bddf ;convert to string - jsr $b487 ;move string descriptor into flp acc - jsr $b6a6 ;get text pointer into $22/$23 - tay - lda #0 - sta ($22),y - lda $22 - ldx $23 - jsr emit_string - jsr emit_br - ldax #line_number - jsr print - lda $22 - ldx $23 - jsr print - jsr print_cr - ldax #error_buffer - jsr emit_string - ldax #error_buffer - jsr print - jmp yield_keyword - -emit_br: - ldax #br - jmp emit_string - -error_handler: - ldy error_handling_mode - bne @send_error_to_browser - jmp (olderror) -@send_error_to_browser: - txa - asl a - tax - lda $a326,x ; fetch address from table of error messages - sta $22 - lda $a327,x ; fetch address from table of error messages - sta $23 - ldy #0 -@one_char: - lda ($22),y - pha - and #$7f - sta error_buffer,y - iny - pla - bpl @one_char - lda #0 - sta error_buffer,y - jmp create_error - -.rodata -vectors: - .word crunch - .word list - .word execute - -hexdigits: -.byte "0123456789ABCDEF" - -CR=$0D -LF=$0A - -error_start: -.byte "

    SYSTEM ERROR


    " -line_number: -.byte " LINE NUMBER: ",0 -br: -.byte "
    ",CR,LF,0 - -listening: -.byte"LISTENING ON ",0 - -pinging: -.byte"PINGING ",0 -interface_type: -.byte "INTERFACE : ",0 - -mac_address_msg: -.byte "MAC ADDRESS : ", 0 - -ip_address_msg: -.byte "IP ADDRESS : ", 0 - -netmask_msg: -.byte "NETMASK : ", 0 - -gateway_msg: -.byte "GATEWAY : ", 0 - - -address_resolution: -.byte "ADDRESS RESOLUTION",0 - - -connect: -.byte "CONNECT",0 - -error: -.byte " ERROR $",0 - -disconnected: -.byte 13,"DIS" -connected_msg: -.byte "CONNECTED",13,0 - - -path: - .byte "PATH: ",0 - -http_version: - .byte "HTTP/1.0 ",0 - -status_ok: - .byte "200 OK",0 -status_error: - .byte "500 " -system_error: - .byte "SYSTEM ERROR",0 -content_type: - .byte "Content-Type: ",0 -text_html: - .byte "text/html",0 - -end_of_header: - .byte CR,LF - .byte "Connection: Close",CR,LF - .byte "Server: BoB_httpd/0.c64",CR,LF -crlf: - .byte CR,LF,0 - -connection_from: .byte "CONNECTION FROM ",0 - - -; Keyword list -; Keywords are stored as normal text, -; followed by the token number. -; All tokens are >$80, -; so they easily mark the end of the keyword -keywords: - .byte "IF",$E0 ;our dummy 'IF' entry takes $E0 - .byte "IPCFG",$E1 - .byte "DHCP",$E2 ;DUMMY! - .byte "PING",$E3 - .byte "MYIP",$E4 - .byte "NETMASK",$E5 - .byte "GATEWAY",$E6 - .byte "DNS",$E7 ;DUMMY! - .byte "HOOK",$E8 - .byte "YIELD",$E9 - .byte "XS",$80,$EA ;BASIC will replace 'END' with $80 - .byte "!",$EB - .byte "HTTPD",$EC - .byte "TYPE",$ED - .byte "STATUS",$EE - .byte "FLUSH",$EF - .byte "MAC",$F0 - .byte $00 ;end of list -HITOKEN=$F1 - -; -; Table of token locations-1 -; -token_routines: -E0: .word if_keyword-1 -E1: .word ipcfg_keyword-1 -E2: .word ipcfg_keyword-1 ;dummy -E3: .word ping_keyword-1 -E4: .word myip_keyword-1 -E5: .word netmask_keyword-1 -E6: .word gateway_keyword-1 -E7: .word ipcfg_keyword-1 ;dummy -E8: .word hook_keyword-1 -E9: .word yield_keyword-1 -EA: .word xsend_keyword-1 -EB: .word bang_keyword-1 -EC: .word httpd_keyword-1 -ED: .word type_keyword-1 -EE: .word status_keyword-1 -EF: .word flush_keyword-1 -F0: .word mac_keyword-1 - -.segment "SELF_MODIFIED_CODE" - - -jmp_crunch: .byte $4C ;JMP -oldcrunch: .res 2 ;Old CRUNCH vector -oldlist: .res 2 -oldexec: .res 2 -olderror: .res 2 - -emit_a: -current_output_ptr=emit_a+1 - sta $ffff - inc string_length - inc current_output_ptr - bne :+ - inc current_output_ptr+1 -: - rts - -MAX_HOOKS=10 - -hook_table: -.res MAX_HOOKS*6 -;format is: -; $00/$01 first 2 chars of hook name -; $02 length of name -; $03 hash of name -; $04/$05 line number that hook handler starts at - -hooks: .byte 0 -error_handling_mode: .byte 0 -connection_timeout_seconds: .byte 0 -found_eol: .byte 0 -connection_closed: .byte 0 - -httpd_io_buffer: .word __httpd_io_buffer -httpd_port_number: .word 80 - - -get_next_byte: - lda $ffff - inc get_next_byte+1 - bne @skip - inc get_next_byte+2 -@skip: - rts - - -xmit_a: - -xmit_a_ptr: - sta $ffff - inc xmit_a_ptr+1 - bne :+ - inc xmit_a_ptr+2 -: - inc output_buffer_length - bne :+ - inc output_buffer_length+1 - lda output_buffer_length+1 - cmp #2 - bne :+ - stx temp_x - jsr send_buffer - ldx temp_x -: - rts - -.bss -string_length: .res 1 -param_length: .res 1 -tmp_length: .res 1 -temp_bin: .res 1 -temp_bcd: .res 2 -ping_counter: .res 1 -http_buffer: .res 256 -string_buffer: .res 128 -transfer_buffer: .res 256 -handler_address: .res 2 -hash: .res 1 -string_ptr: .res 1 -default_line_number: .res 2 -output_buffer_length: .res 2 -tcp_buffer_ptr: .res 2 -buffer_size: .res 1 -temp_x: .res 1 -sent_header: .res 1 -tmp_a: .res 1 -error_buffer: .res 80 -top_of_stack: .res 1 -.segment "TCP_VARS" - -__httpd_io_buffer: .res 1024 ;temp buffer for storing inbound requests. -content_type_buffer: .res 128 -status_code_buffer: .res 128 - - - - -;-- LICENSE FOR bails.s -- -; The contents of this file are subject to the Mozilla Public License -; Version 1.1 (the "License"); you may not use this file except in -; compliance with the License. You may obtain a copy of the License at -; http://www.mozilla.org/MPL/ -; -; Software distributed under the License is distributed on an "AS IS" -; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -; License for the specific language governing rights and limitations -; under the License. -; -; The Original Code is netboot65. -; -; The Initial Developer of the Original Code is Jonno Downes, -; jonno@jamtronix.com. -; Portions created by the Initial Developer are Copyright (C) 2009,2010 -; Jonno Downes. All Rights Reserved. -; -- LICENSE END -- diff --git a/client/carts/bootmenu.s b/client/carts/bootmenu.s deleted file mode 100644 index d63d48b..0000000 --- a/client/carts/bootmenu.s +++ /dev/null @@ -1,164 +0,0 @@ -;############# -; -; This program looks for a TNDP server on the network, presents a catalog of volumes on that server, and allows a volume to be attached -; -; jonno@jamtronix.com - January 2009 -; - - .include "../inc/common.i" - .include "../inc/commonprint.i" - .include "../inc/net.i" - .import cls - - .import exit_to_basic - - .import copymem - .importzp copy_src - .importzp copy_dest - - .import __STARTUP_LOAD__ - .import __STARTUP_SIZE__ - .import __BSS_LOAD__ - .import __DATA_LOAD__ - .import __DATA_RUN__ - .import __DATA_SIZE__ - .import __RODATA_LOAD__ - .import __RODATA_RUN__ - .import __RODATA_SIZE__ - .import __CODE_LOAD__ - .import __CODE_RUN__ - .import __CODE_SIZE__ - -.segment "PAGE3" - -disable_language_card: .res 3 -bin_file_jmp: .res 3 - -; ------------------------------------------------------------------------ - - .segment "EXEHDR" - - .addr __STARTUP_LOAD__ ; Start address - .word __STARTUP_SIZE__+__CODE_SIZE__+__RODATA_SIZE__+__DATA_SIZE__+4 ; Size - -; ------------------------------------------------------------------------ - - -.segment "STARTUP" - - - lda $c089 ;enable language : card read ROM, write RAM, BANK 1 - - ;copy the monitor rom on to the language card - ldax #$f800 - stax copy_src - stax copy_dest - ldax #$0800 - jsr startup_copymem - - - lda $c08b ;enable language : card read RAM, write RAM, BANK 1 - lda $c08b ;this soft switch needs to be read twice - - - ;relocate the CODE segment - ldax #__CODE_LOAD__ - stax copy_src - ldax #__CODE_RUN__ - stax copy_dest - ldax #__CODE_SIZE__ - jsr startup_copymem - - - ;relocate the RODATA segment - ldax #__RODATA_LOAD__ - stax copy_src - ldax #__RODATA_RUN__ - stax copy_dest - ldax #__RODATA_SIZE__ - jsr startup_copymem - - ;relocate the DATA segment - ldax #__DATA_LOAD__ - stax copy_src - ldax #__DATA_RUN__ - stax copy_dest - ldax #__DATA_SIZE__ - jsr startup_copymem - - jmp init - -; copy memory -; set copy_src and copy_dest, length in A/X - - -end: .res 1 - -startup_copymem: - sta end - ldy #0 - - cpx #0 - beq @tail - -: lda (copy_src),y - sta (copy_dest),y - iny - bne :- - inc copy_src+1 ;next page - inc copy_dest+1 ;next page - dex - bne :- - -@tail: - lda end - beq @done - -: lda (copy_src),y - sta (copy_dest),y - iny - cpy end - bne :- - -@done: - rts - -.code - - -init: - - jsr cls - - ldax #startup_msg - jsr print - jsr print_cr - - jmp exit_to_basic - - .rodata -startup_msg: .byte "NETBOOT65 FOR APPLE 2 V0.1",13 -.byte "SEE README.TXT FOR MORE INFO (INCLUDING",13 -.byte "HOW TO RUN SOMETHING MORE INTERESTING)",13 -.byte 0 - - - -;-- LICENSE FOR bootmenu.s -- -; The contents of this file are subject to the Mozilla Public License -; Version 1.1 (the "License"); you may not use this file except in -; compliance with the License. You may obtain a copy of the License at -; http://www.mozilla.org/MPL/ -; -; Software distributed under the License is distributed on an "AS IS" -; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -; License for the specific language governing rights and limitations -; under the License. -; -; The Original Code is netboot65. -; -; The Initial Developer of the Original Code is Jonno Downes, -; jonno@jamtronix.com. -; Portions created by the Initial Developer are Copyright (C) 2009 -; Jonno Downes. All Rights Reserved. -; -- LICENSE END -- diff --git a/client/carts/c64_cart_ram_header.s b/client/carts/c64_cart_ram_header.s deleted file mode 100644 index a598645..0000000 --- a/client/carts/c64_cart_ram_header.s +++ /dev/null @@ -1,117 +0,0 @@ -.segment "IP65ZP" : zeropage - -; pointers for copying -copy_src: .res 2 ; source pointer -copy_dest: .res 2 ; destination pointer -end: .res 1 - -.segment "STARTUP" ;this is what gets put at the start of the file on the C64 - - .word basicstub ; load address -.include "../inc/common.i" - -basicstub: - .word @nextline - .word 2003 - .byte $9e - .byte <(((init / 1000) .mod 10) + $30) - .byte <(((init / 100 ) .mod 10) + $30) - .byte <(((init / 10 ) .mod 10) + $30) - .byte <(((init ) .mod 10) + $30) - .byte 0 -@nextline: - .word 0 - -init: - - ;clear screen - lda #147 ; 'CLR/HOME' - jsr $ffd2 - ;turn off BASIC - lda $01 - and #$FE ;mask out bit 0 - sta $01 - - ;now relocate the cart - - ldax #cart_data - stax copy_src - ldax #$8000 - stax copy_dest - ldax #$4000 - jsr copymem - - - ;if this is a KIPPERKART, then set default drive to - ;be whatever we just booted from - - lda $8009 - cmp #'K' - bne @drive_done - lda $8009 - cmp #'K' - bne @drive_done - lda $8036 ;location in cart config of default drive - cmp #08 - bne @drive_done - lda $ba - sta $8036 -@drive_done: - jmp ($8002) ;warm start vector - -;copy memory -;inputs: -; copy_src is address of buffer to copy from -; copy_dest is address of buffer to copy to -; AX = number of bytes to copy -;outputs: none -copymem: - sta end - ldy #0 - - cpx #0 - beq @tail - -: lda (copy_src),y - sta (copy_dest),y - iny - bne :- - inc copy_src+1 ;next page - inc copy_dest+1 ;next page - dex - bne :- - -@tail: - lda end - beq @done - -: lda (copy_src),y - sta (copy_dest),y - iny - cpy end - bne :- - -@done: - rts - -;this is where the cart data will be appended to: - cart_data: - -;-- LICENSE FOR c64_cart_ram_header.s -- -; The contents of this file are subject to the Mozilla Public License -; Version 1.1 (the "License"); you may not use this file except in -; compliance with the License. You may obtain a copy of the License at -; http://www.mozilla.org/MPL/ -; -; Software distributed under the License is distributed on an "AS IS" -; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -; License for the specific language governing rights and limitations -; under the License. -; -; The Original Code is netboot65. -; -; The Initial Developer of the Original Code is Jonno Downes, -; jonno@jamtronix.com. -; Portions created by the Initial Developer are Copyright (C) 2009 -; Jonno Downes. All Rights Reserved. -; -- LICENSE END -- diff --git a/client/carts/cartheader.s b/client/carts/cartheader.s deleted file mode 100644 index f49c65c..0000000 --- a/client/carts/cartheader.s +++ /dev/null @@ -1,54 +0,0 @@ - -.include "../inc/common.i" - -.import copymem -.importzp copy_src -.importzp copy_dest - -.segment "STARTUP" ;this is what gets put at the start of the file on the C64 - -.word basicstub ; load address - -basicstub: - .word @nextline - .word 2003 - .byte $9e - .byte <(((init / 1000) .mod 10) + $30) - .byte <(((init / 100 ) .mod 10) + $30) - .byte <(((init / 10 ) .mod 10) + $30) - .byte <(((init ) .mod 10) + $30) - .byte 0 -@nextline: - .word 0 - -init: - -;copy BASIC to RAM - ldax #$A000 - stax copy_src - stax copy_dest - ldax #$2000 - jsr copymem - -;copy cart data from end of file to $8000 (RAM) - ldax #cart_data - stax copy_src - ldax #$8000 - stax copy_dest - ldax #$2000 - jsr copymem - -;swap out the cartridge (also swaps out BASIC) - - lda $01 - and #$fe ;reset bit 0 - sta $01 - -;execute the cartridge from RAM - jmp ($8002) - - -.bss - -cart_data: ;this should point to where the cart data gets appended. - .res $2000 \ No newline at end of file diff --git a/client/carts/crt8040.obj b/client/carts/crt8040.obj deleted file mode 100644 index b5ab5c1..0000000 Binary files a/client/carts/crt8040.obj and /dev/null differ diff --git a/client/carts/crt8040.src b/client/carts/crt8040.src deleted file mode 100644 index f7f31bb..0000000 --- a/client/carts/crt8040.src +++ /dev/null @@ -1,107 +0,0 @@ -;taken from DocBacardi's CRT8040 tool - http://freenet-homepage.de/LittleDreamLand/CRT8040.html - -#segdef "zp", $57-$72 -#segdef "bank0", $8000-$9f10, force, fillup -#segdef "common", $df10-$e000, force, fillup - -#outfile @, $00, "bank0", "common" - -;-------------------------------------- -; init the startadr of all segments - - .segment "zp" - * = $57 - - .segment "bank0" - * = $8000 - - .segment "common" - * = $df10 - -;-------------------------------------- -; init the rr registers and copy -; bank 3 to ram - - .segment "bank0" - - .DW Bank0_Reset ;Reset vector - .DW $fe5e ;NMI vector is not used here, points to system - .PET "CBM80" ;Reset Magic - -Bank0_Reset: - lda #%01000111 ;Standard Memory Map, No Freeze, No Banking in $DF00 (+ allow access to accessory connector - Jonno 2009-08-20) - sta $de01 - - ldx #kickStack_len-1 -copyKickStack: - lda kickStack_org,x - sta kickStack,x - dex - bpl copyKickStack - jmp kickStack - -kickStack_org: - .pseudopc $0900 -kickStack: - - ldx #$1f - ldy #0 -copyCrt: - lda #%00101011 ; switch to bank 1 - sta $de00 -delay0: - nop - iny - bne delay0 -copyPage0: -smod0: - lda $e000,y - sta $0400,y - iny - bne copyPage0 - lda #%00110011 ; switch to bank 2 - sta $de00 -delay1: - nop - iny - bne delay1 -copyPage1: - lda $0400,y -smod1: - sta $8000,y - iny - bne copyPage1 - inc smod0+2 - inc smod1+2 - inc $d020 - dex - bpl copyCrt - - lda #%00110001 ; switch to 8040 - sta $de00 -delay2: - nop - iny - bne delay2 - - - ; during the copy process occured some irqs, clear them - lda $dc0d - lda $dd0d - asl $d019 - - ; set registers - ; NV-BDIZC - lda #%00110111 - pha - lda #$c3 - ldx #$00 - plp - - jmp ($8000) - -kickStack_len = *-kickStack - .realpc - -;-------------------------------------- - diff --git a/client/carts/d64_upload.s b/client/carts/d64_upload.s deleted file mode 100644 index bdd296c..0000000 --- a/client/carts/d64_upload.s +++ /dev/null @@ -1,562 +0,0 @@ -;use the NB65 API to send a d64 disk via TFTP -; -; - -.ifndef NB65_API_VERSION_NUMBER - .define EQU = - .include "../inc/nb65_constants.i" -.endif - -.include "../ip65/copymem.s" -.include "../inc/common.i" - -.import print_a -.import get_key -.import get_filtered_input -.import filter_dns -.macro cout arg - lda arg - jsr print_a -.endmacro - -;######### KERNEL functions -CHKIN = $ffc6 -CHKOUT = $ffc9 -CHRIN = $ffcf -CHROUT = $ffd2 -CLALL = $FFE7 -CLOSE = $ffc3 -OPEN = $ffc0 -READST = $ffb7 -SETNAM = $ffbd -SETLFS = $ffba - -.bss - current_byte: .res 1 - track: .res 1 - sector: .res 1 - sectors_in_track: .res 1 - error_buffer: .res 128 - - command_buffer: .res 128 - sector_buffer: .res 256 - nb65_param_buffer: .res $20 -sector_buffer_address: .res 2 - - .zeropage - temp_ptr: .res 2 - -.segment "STARTUP" ;this is what gets put at the start of the file on the C64 - -.word basicstub ; load address - -.macro print arg - ldax arg - ldy #NB65_PRINT_ASCIIZ - jsr NB65_DISPATCH_VECTOR -.endmacro - -.macro print_cr - lda #13 - jsr print_a -.endmacro - -.macro call arg - ldy arg - jsr NB65_DISPATCH_VECTOR -.endmacro - -basicstub: - .word @nextline - .word 2003 - .byte $9e - .byte <(((init / 1000) .mod 10) + $30) - .byte <(((init / 100 ) .mod 10) + $30) - .byte <(((init / 10 ) .mod 10) + $30) - .byte <(((init ) .mod 10) + $30) - .byte 0 -@nextline: - .word 0 - - -;look for NB65 signature at location pointed at by AX -look_for_signature: - stax temp_ptr - ldy #3 -@check_one_byte: - lda (temp_ptr),y - cmp nb65_signature,y - bne @bad_match - dey - bpl@check_one_byte - clc - rts -@bad_match: - sec - rts -init: - - print #signon_message - - ldax #NB65_CART_SIGNATURE ;where signature should be in cartridge - jsr look_for_signature - bcc @found_nb65_signature - - ldax #NB65_RAM_STUB_SIGNATURE ;where signature should be in RAM - jsr look_for_signature - bcc :+ - jmp nb65_signature_not_found -: - jsr NB65_RAM_STUB_ACTIVATE ;we need to turn on NB65 cartridge - -@found_nb65_signature: - - print #initializing - print #nb65_signature - ldy #NB65_INITIALIZE - jsr NB65_DISPATCH_VECTOR - bcc :+ - print #failed - jsr print_nb65_errorcode - jmp bad_boot -: - print #ok - print_cr - -; ######################## -; main program goes here: -; - - jsr CLALL - - -; ldx #18 -; stx track -; ldx #1 -; stx sector -; ldx #21 -; stx sectors_in_track -; ldax #sector_buffer -; jsr send_next_block -; rts - - -@send_1_image: - lda #$93 ;cls - jsr print_a - print #signon_message - jsr reset_counters_to_first_sector - print #enter_filename - ldax #filter_dns ;this is pretty close to being a filter for legal chars in file names as well - jsr get_filtered_input - bcs @no_filename_entered - stax nb65_param_buffer+NB65_TFTP_FILENAME - print #position_cursor_for_track_display - ldax #send_next_block - stax nb65_param_buffer+NB65_TFTP_POINTER - ldax #nb65_param_buffer - call #NB65_TFTP_CALLBACK_UPLOAD - bcc :+ - print_cr - print #failed - jmp print_nb65_errorcode -: - lda #15 ; filenumber 15 - command channel - jsr CLOSE - print_cr - print #ok - print #press_a_key_to_continue - jsr get_key - jmp @send_1_image ;done! so go again -@no_filename_entered: - rts - - -send_next_block: -;tftp upload callback routine -;AX will point to address to fill - stax sector_buffer_address - lda track - cmp #36 - beq @past_last_track - print #position_cursor_for_track_display - jsr print_current_sector - jsr read_sector - lda #$30 - cmp error_buffer - bne @was_an_error -@after_error_check: - jsr move_to_next_sector - bcc @not_last_sector - ldax #$100 - rts -@not_last_sector: - -; jsr dump_sector ;DEBUG - - inc sector_buffer_address+1 - jsr read_sector - jsr move_to_next_sector - ldax #$200 - -; jsr dump_sector ;DEBUG - - rts -@past_last_track: - ldax #$0000 - rts - -@was_an_error: - print #position_cursor_for_error_display - print #drive_error - print_cr - jsr print_current_sector - print #error_buffer - jmp @after_error_check - -print_current_sector: - print #track_no - lda track - jsr byte_to_ascii - pha - txa - jsr print_a - pla - jsr print_a - print #sector_no - lda sector - jsr byte_to_ascii - pha - txa - jsr print_a - pla - jsr print_a - print_cr - rts - - - -dump_sector: -;hex dump sector - lda #0 - sta current_byte -@dump_byte: - ldy current_byte - lda sector_buffer,y - call #NB65_PRINT_HEX - inc current_byte - bne @dump_byte -rts - -read_sector: -;routine to read a sector cribbed from http://codebase64.org/doku.php?id=base:reading_a_sector_from_disk -; - requires track and sector values be set first -; sector will be written to address whos value is stored in sector_data -; open the channel file - - jsr make_read_sector_command - - lda #1 - ldx #cname - jsr SETNAM - lda #02 - ldx #08 - ldy #02 - jsr SETLFS - jsr OPEN - bcs @error - ldx #command_buffer - lda #12 - jsr SETNAM - lda #15 - ldx $BA ;use whatever was last device # - ldy #15 - jsr SETLFS - jsr OPEN - bcs @error - - - jsr check_error_channel - lda #$30 - cmp error_buffer - beq @was_not_an_error - print #error_buffer - - @was_not_an_error: - ldx #$02 ; filenumber 2 - jsr CHKIN ;(file 2 now used as input) - - lda sector_buffer_address - sta temp_ptr - lda sector_buffer_address+1 - sta temp_ptr+1 - ldy #$00 -@loop: - jsr CHRIN ;(get a byte from file) - sta (temp_ptr),Y ; write byte to memory - iny - bne @loop ; next byte, end when 256 bytes are read -@close: - lda #15 ; filenumber 15 - jsr CLOSE - lda #$02 ; filenumber 2 - jsr CLOSE - ldx #$00 ; filenumber 0 = keyboard - jsr CHKIN ;(keyboard now input device again) - rts -@error: - pha - print #error_opening_channel - pla - call #NB65_PRINT_HEX - jmp @close - -check_error_channel: - LDX #$0F ; filenumber 15 - JSR CHKIN ;(file 15 now used as input) - LDY #$00 -@loop: - JSR READST ;(read status byte) - BNE @eof ; either EOF or read error - JSR CHRIN ;(get a byte from file) - sta error_buffer,y - iny - JMP @loop ; next byte - -@eof: - lda #0 - sta error_buffer,y - LDX #$00 ; filenumber 0 = keyboard - JSR CHKIN ;(keyboard now input device again) - RTS - -bad_boot: - print #press_a_key_to_continue -restart: - jsr get_key - jmp $fce2 ;do a cold start - - -print_a_as_errorcode: - pha - lda #' ' - jsr print_a - print #error_code - pla - call #NB65_PRINT_HEX - rts - -print_nb65_errorcode: - print #error_code - call #NB65_GET_LAST_ERROR - call #NB65_PRINT_HEX - print_cr - rts - -nb65_signature_not_found: - - ldy #0 -: - lda nb65_signature_not_found_message,y - beq restart - jsr print_a - iny - jmp :- - - - -make_read_sector_command: -;fill command buffer with command to read in track & sector -;returns length of command in Y - - ldy #0 - lda #85 ;"U" - sta command_buffer,y - iny - lda #$31 ;"1" - sta command_buffer,y - iny - lda #$20 ;" " - sta command_buffer,y - iny - lda #$32 ;"2" - file number - sta command_buffer,y - iny - lda #$20 ;" " - sta command_buffer,y - iny - lda #$30 ;"0" - drive number - sta command_buffer,y - iny - lda #$20 ;" " - sta command_buffer,y - iny - lda track - jsr byte_to_ascii - pha - txa - sta command_buffer,y - pla - iny - sta command_buffer,y - iny - lda #$20 ;" " - sta command_buffer,y - iny - lda sector - jsr byte_to_ascii - pha - txa - sta command_buffer,y - pla - iny - sta command_buffer,y - iny - - lda #0 - sta command_buffer,y ;make it ASCIIZ so we can print it - - rts - -byte_to_ascii: - cmp #30 - bmi @not_30 - ldx #$33 - clc - adc #18 - rts -@not_30: - cmp #20 - bmi @not_20 - ldx #$32 - clc - adc #28 - rts -@not_20: - cmp #10 - bmi @not_10 - ldx #$31 - clc - adc #38 - rts -@not_10: - ldx #$30 - clc - adc #48 - rts - - -reset_counters_to_first_sector: - ldx #1 - stx track - dex - stx sector - ldx #21 - stx sectors_in_track - rts - -move_to_next_sector: - inc sector - lda sector - cmp sectors_in_track - beq @move_to_next_track - rts -@move_to_next_track: - lda #0 - sta sector - inc track - lda track - cmp #18 - bne @not_track_18 - lda #19 - sta sectors_in_track - clc - rts -@not_track_18: - cmp #25 - bne @not_track_25 - lda #18 - sta sectors_in_track - clc - rts -@not_track_25: - cmp #31 - bne @not_track_31 - lda #17 - sta sectors_in_track - clc - rts -@not_track_31: - lda track - cmp #36 ;carry will be set if hit track 36 - rts - - -.rodata - -error_code: - .byte "ERROR CODE: $",0 -press_a_key_to_continue: - .byte "PRESS A KEY TO CONTINUE",13,0 - -failed: - .byte "FAILED ", 0 - -ok: - .byte "OK ", 0 - -initializing: - .byte "INITIALIZING ",0 -track_no: - .byte "TRACK ",0 - - -sector_no: - .byte " SECTOR ",0 - -signon_message: - .byte "D64 UPLOADER V0.1",13,0 - -enter_filename: -.byte "SEND AS: ",0 - -drive_error: - .byte "DRIVE ACCESS ERROR - ",0 - nb65_signature_not_found_message: - .byte "NO NB65 API FOUND",13,"PRESS ANY KEY TO RESET", 0 - error_opening_channel: - .byte "ERROR OPENING CHANNEL $",0 - -disk_access: -.byte 13,13,13,13,13,"SENDING TO CHANNEL $",0 - -nb65_signature: - .byte $4E,$42,$36,$35 ; "NB65" - API signature - .byte ' ',0 ; so we can use this as a string -position_cursor_for_track_display: -; .byte $13,13,13,13,13,13,13,13,13,13,13," SENDING ",0 -.byte $13,13,13,"SENDING ",0 -position_cursor_for_error_display: - .byte $13,13,13,13,"LAST ",0 - -cname: .byte '#' -;-- LICENSE FOR d64_upload.s -- -; The contents of this file are subject to the Mozilla Public License -; Version 1.1 (the "License"); you may not use this file except in -; compliance with the License. You may obtain a copy of the License at -; http://www.mozilla.org/MPL/ -; -; Software distributed under the License is distributed on an "AS IS" -; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -; License for the specific language governing rights and limitations -; under the License. -; -; The Original Code is netboot65. -; -; The Initial Developer of the Original Code is Jonno Downes, -; jonno@jamtronix.com. -; Portions created by the Initial Developer are Copyright (C) 2009 -; Jonno Downes. All Rights Reserved. -; -- LICENSE END -- diff --git a/client/carts/dupe_cart.rb b/client/carts/dupe_cart.rb deleted file mode 100644 index a686ece..0000000 --- a/client/carts/dupe_cart.rb +++ /dev/null @@ -1,33 +0,0 @@ -infilename=ARGV[0] -outfilename=ARGV[1] -duplication=ARGV[2].to_i - -if duplication.nil? then - puts "usage: dupe_cart.rb [input filename] [output filename] [number of duplications]" - exit -end - - -infile=File.open(infilename,"rb").read -puts "copying #{infilename} to #{outfilename} #{duplication} times" -outfile=File.open(outfilename,"wb") -duplication.times {outfile<temp_filename_start - - -open_file: - ;A,X,Y set up ready for a call to SETNAM for file #2 - jsr $FFBD ; call SETNAM - lda #$02 ; file number 2 -.import cfg_default_drive - ldx cfg_default_drive - - ldy #$02 ; secondary address 2 - jsr $FFBA ; call SETLFS - - jsr $FFC0 ; call OPEN - bcs @error ; if carry set, the file could not be opened - rts -@error: - sta ip65_error - jsr close_file - sec - rts - -write_byte: - pha - ldx #$02 ; filenumber 2 = output file - jsr $FFC9 ; call CHKOUT - pla - jsr $ffd2 ;write byte - JSR $FFB7 ; call READST (read status byte) - bne @error - ldx #$00 ; filenumber 0 = console - jsr $FFC9 ; call CHKOUT - rts -@error: - lda #KPR_ERROR_FILE_ACCESS_FAILURE - sta ip65_error - jsr close_file - sec - rts - - -close_file: - - lda #$02 ; filenumber 2 - jsr $FFC3 ; call CLOSE - rts - - -rename_file: -;AX points at new filename - stax copy_src - ldx #0 - ldy #0 - ;first the "RENAME0:" - -: - lda rename_cmd,y - sta command_buffer,x - inx - iny - cmp #':' - bne :- - - ;now the new filename - ldy #0 -: - lda (copy_src),y - beq @end_of_new_filename - sta command_buffer,x - inx - iny - bne :- -@end_of_new_filename: - - ;now the "=" - lda #'=' - sta command_buffer,x - inx - - ;now the old filename - ldy #0 -: - lda temp_filename,y - cmp #',' - beq @end_of_old_filename - sta command_buffer,x - inx - iny - bne :- -@end_of_old_filename: - txa ;filename length - ldx #command_buffer - - jsr $FFBD ; call SETNAM - lda #$0F ; filenumber 15 - ldx cfg_default_drive - ldy #$0F ; secondary address 15 - jsr $FFBA ; call SETLFS - jsr $FFC0 ; call OPEN - lda #$0F ; filenumber 15 - jsr $FFC3 ; call CLOSE - rts - -rename_cmd: - .byte "RENAME0:" - -exit_telnet: -exit_gopher: - jsr setup_screen - jmp main_menu -.rodata - -menu_header_msg: -.byte $13,10,"KipperTerm V" -.include "../inc/version.i" -.byte 10,0 -main_menu_msg: -.byte 10,"Main Menu",10,10 -.byte "F1: Telnet ",10 -.byte "F7: Config F8: Credits",10,10 - -.byte 0 - - -telnet_menu_msg: -.byte 10,10,10 -.byte "F1: D/L File (XMODEM)",10 -.byte "F3: U/L File (XMODEM)",10 -.byte "F5: Send ASCII char",10 -.byte "F7: Return",10,10 -.byte 0 - -telnet_header: .byte "telnet",10,0 - -opening_file: -.byte 10,"opening file",10,0 -transfer_complete: -.byte "transfer complete.",10,0 -prompt_for_filename: .byte "save file as?",10,0 -current: -.byte "current ",0 - -enter_ascii: -.byte 10,"ASCII value (0..255)? ",0 - -byte_sent: -.byte 10,"byte sent.",0 - -new: -.byte"new ",0 - -resolving: - .byte "resolving ",0 - -no_files: - .byte "no files",10,0 - -dir_listing_fail_msg: - .byte "directory listing failed",10,0 - -temp_filename_start: .byte "@" -temp_filename: -.byte "0:XMODEM.TMP,P,W" ; @0: means 'overwrite if existing', ',P,W' is required to make this an output file -temp_filename_end: -.byte 0 - -credits: -.byte 10,"License: Mozilla Public License v1.1",10 -.byte 10 -.byte 10,"Contributors:",10 -.byte 10,"Jonno Downes" -.byte 10,"Glenn Holmer" -.byte 10,"Per Olofsson" -.byte 10,"Lars Stollenwerk" -.byte 10,10 -.byte 0 - -.segment "APP_SCRATCH" - -temp_font: .res 1 -temp_border: .res 1 -temp_text_back: .res 1 -temp_text_fore: .res 1 -temp_page_zero_vars: .res $28 -temp_screen_chars: .res $400 -temp_colour_ram: .res $400 -command_buffer: .res $80 -eof: .res 1 -ascii_packet: .res 1 - -;-- LICENSE FOR kipperterm.s -- -; The contents of this file are subject to the Mozilla Public License -; Version 1.1 (the "License"); you may not use this file except in -; compliance with the License. You may obtain a copy of the License at -; http://www.mozilla.org/MPL/ -; -; Software distributed under the License is distributed on an "AS IS" -; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -; License for the specific language governing rights and limitations -; under the License. -; -; The Original Code is KipperTerm. -; -; The Initial Developer of the Original Code is Jonno Downes, -; jonno@jamtronix.com. -; Portions created by the Initial Developer are Copyright (C) 2009 -; Jonno Downes. All Rights Reserved. -; -- LICENSE END -- diff --git a/client/carts/nb65_skeleton.s b/client/carts/nb65_skeleton.s deleted file mode 100644 index 84ba806..0000000 --- a/client/carts/nb65_skeleton.s +++ /dev/null @@ -1,173 +0,0 @@ -;use the NB65 API to send a d64 disk via TFTP - -.ifndef NB65_API_VERSION_NUMBER - .define EQU = - .include "../inc/nb65_constants.i" -.endif - -.include "../ip65/copymem.s" -.include "../inc/common.i" - -.import print_a -.import get_key -.macro cout arg - lda arg - jsr print_a -.endmacro - - .zeropage - temp_ptr: .res 2 - - .bss - nb65_param_buffer: .res $20 - block_number: .res $0 - -.segment "STARTUP" ;this is what gets put at the start of the file on the C64 - -.word basicstub ; load address - -.macro print arg - ldax arg - ldy #NB65_PRINT_ASCIIZ - jsr NB65_DISPATCH_VECTOR -.endmacro - -.macro print_cr - lda #13 - jsr print_a -.endmacro - -.macro call arg - ldy arg - jsr NB65_DISPATCH_VECTOR -.endmacro - -basicstub: - .word @nextline - .word 2003 - .byte $9e - .byte <(((init / 1000) .mod 10) + $30) - .byte <(((init / 100 ) .mod 10) + $30) - .byte <(((init / 10 ) .mod 10) + $30) - .byte <(((init ) .mod 10) + $30) - .byte 0 -@nextline: - .word 0 - - -;look for NB65 signature at location pointed at by AX -look_for_signature: - stax temp_ptr - ldy #3 -@check_one_byte: - lda (temp_ptr),y - cmp nb65_signature,y - bne @bad_match - dey - bpl@check_one_byte - clc - rts -@bad_match: - sec - rts -init: - - print #signon_message - - ldax #NB65_CART_SIGNATURE ;where signature should be in cartridge - jsr look_for_signature - bcc @found_nb65_signature - - ldax #NB65_RAM_STUB_SIGNATURE ;where signature should be in RAM - jsr look_for_signature - bcc :+ - jmp nb65_signature_not_found -: - jsr NB65_RAM_STUB_ACTIVATE ;we need to turn on NB65 cartridge - -@found_nb65_signature: - - print #initializing - print #nb65_signature - ldy #NB65_INITIALIZE - jsr NB65_DISPATCH_VECTOR - bcc :+ - print #failed - jsr print_errorcode - jmp bad_boot -: - print #ok - print_cr - -; ######################## -; main program goes here: -; - rts - -bad_boot: - print #press_a_key_to_continue -restart: - jsr get_key - jmp $fce2 ;do a cold start - - -print_errorcode: - print #error_code - call #NB65_GET_LAST_ERROR - call #NB65_PRINT_HEX - print_cr - rts - -nb65_signature_not_found: - - ldy #0 -: - lda nb65_signature_not_found_message,y - beq restart - jsr print_a - iny - jmp :- - -.rodata - -error_code: - .asciiz "ERROR CODE: $" -press_a_key_to_continue: - .byte "PRESS A KEY TO CONTINUE",13,0 - -failed: - .byte "FAILED ", 0 - -ok: - .byte "OK ", 0 - -initializing: - .byte "INITIALIZING ",0 - -signon_message: - .byte "NB65 UNNAMED TOOL V0.1",13,0 - - nb65_signature_not_found_message: - .byte "NO NB65 API FOUND",13,"PRESS ANY KEY TO RESET", 0 - -nb65_signature: - .byte $4E,$42,$36,$35 ; "NB65" - API signature - .byte ' ',0 ; so we can use this as a string -;-- LICENSE FOR nb65_skeleton.s -- -; The contents of this file are subject to the Mozilla Public License -; Version 1.1 (the "License"); you may not use this file except in -; compliance with the License. You may obtain a copy of the License at -; http://www.mozilla.org/MPL/ -; -; Software distributed under the License is distributed on an "AS IS" -; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -; License for the specific language governing rights and limitations -; under the License. -; -; The Original Code is netboot65. -; -; The Initial Developer of the Original Code is Jonno Downes, -; jonno@jamtronix.com. -; Portions created by the Initial Developer are Copyright (C) 2009 -; Jonno Downes. All Rights Reserved. -; -- LICENSE END -- diff --git a/client/carts/netboot.s b/client/carts/netboot.s deleted file mode 100644 index 9e88135..0000000 --- a/client/carts/netboot.s +++ /dev/null @@ -1,392 +0,0 @@ -; ############# -; -; This will boot a C64 with an RR-NET compatible cs8900a from the network -; requires -; 1) a DHCP server, and -; 2) a TFTP server that responds to requests on the broadcast address (255.255.255.255) and that will serve a file called 'BOOTC64.PRG'. -; -; jonno@jamtronix.com - January 2009 -; - - - .include "../inc/common.i" - .include "../inc/commonprint.i" - .include "../inc/c64keycodes.i" - .include "../inc/menu.i" - - .import ip65_init - .import dhcp_init - .import tftp_ip - .importzp tftp_filename - .import tftp_load_address - .import tftp_download - - .import cls - .import beep - .import exit_to_basic - .import timer_vbl_handler - .import get_key_ip65 - .import cfg_ip - .import cfg_netmask - .import cfg_gateway - .import cfg_dns - .import cfg_tftp_server - .import cfg_get_configuration_ptr - - - .import copymem - .importzp copy_src - .importzp copy_dest - .import get_filtered_input - .import __DATA_LOAD__ - .import __DATA_RUN__ - .import __DATA_SIZE__ - .import __SELF_MODIFIED_CODE_LOAD__ - .import __SELF_MODIFIED_CODE_RUN__ - .import __SELF_MODIFIED_CODE_SIZE__ - - - directory_buffer = $6020 - .bss -tmp_load_address: .res 2 - - .data -exit_cart: - - lda #$02 - sta $de00 ;turns off RR cartridge by modifying GROUND and EXROM -call_downloaded_prg: - jsr $0000 ;overwritten when we load a file - jmp init - -get_value_of_axy: ;some more self-modifying code - lda $ffff,y - rts - - -.segment "CARTRIDGE_HEADER" -.word init ;cold start vector -.word $FE47 ;warm start vector -.byte $C3,$C2,$CD,$38,$30 ; "CBM80" -.byte $0,$0,$0 ;reserved for future use -.byte $0,$0,$0 ;reserved for future use -.byte $0,$0,$0 ;reserved for future use -.byte $0,$0,$0 ;reserved for future use -.byte $0,$0,$0 ;reserved for future use - -.code - - - -init: - - - ;first let the kernal do a normal startup - sei - jsr $fda3 ;initialize CIA I/O - jsr $fd50 ;RAM test, set pointers - jsr $fd15 ;set vectors for KERNAL - jsr $ff5B ;init. VIC - cli ;KERNAL init. finished - - -;we need to set up BASIC as well - jsr $e453 ;set BASIC vectors - jsr $e3bf ;initialize zero page - - - ;set some funky colours - LDA #$05 ;green - STA $D020 ;border - LDA #$00 ;black - STA $D021 ;background - - lda #$05 ;petscii for white text - - - jsr print_a - - -;relocate our r/w data - ldax #__DATA_LOAD__ - stax copy_src - ldax #__DATA_RUN__ - stax copy_dest - ldax #__DATA_SIZE__ - jsr copymem - ldax #__SELF_MODIFIED_CODE_LOAD__ - stax copy_src - ldax #__SELF_MODIFIED_CODE_RUN__ - stax copy_dest - ldax #__SELF_MODIFIED_CODE_SIZE__ - jsr copymem - - - ldax #netboot_msg - jsr print_ascii_as_native - - print_driver_init - - - jsr ip65_init - - - - bcs @init_failed - jsr dhcp_init - bcc init_ok - jsr ip65_init ;if DHCP failed, then reinit the IP stack (which will reset IP address etc that DHCP messed with to cartridge default values) - bcc init_ok -@init_failed: - - print_failed - jsr print_errorcode - jsr wait_for_keypress - jmp exit_to_basic - - -init_ok: - - - - ldx #$03 -: - lda cfg_tftp_server,x - sta tftp_ip,x - dex - bpl :- - - jsr print_cr - jsr print_ip_config -tftp_boot: - - ldax #tftp_dir_filemask - jsr get_tftp_directory_listing - bcs return_to_main - -@boot_filename_set: - ;AX now points to filename - jsr download - bcc file_downloaded_ok -tftp_boot_failed: - jsr wait_for_keypress -return_to_main: - jmp tftp_boot - -file_downloaded_ok: -ldax tftp_load_address - -boot_into_file: - stax tmp_load_address ;use the param buffer as a temp holding place for the load address - ;get ready to bank out - - jsr $ffe7 ; make sure all files have been closed. - - ;check whether the file we just downloaded was a BASIC prg - lda tmp_load_address - cmp #01 - bne @not_a_basic_file - - lda tmp_load_address+1 - cmp #$08 - bne @not_a_basic_file - - - jsr $e453 ;set BASIC vectors - jsr $e3bf ;initialize BASIC - jsr $a86e - jsr $a533 ; re-bind BASIC lines - ldx $22 ;load end-of-BASIC pointer (lo byte) - ldy $23 ;load end-of-BASIC pointer (hi byte) - stx $2d ;save end-of-BASIC pointer (lo byte) - sty $2e ;save end-of-BASIC pointer (hi byte) - jsr $a659 ; CLR (reset variables) - ldax #$a7ae ; jump to BASIC interpreter loop - jmp exit_cart_via_ax - -@not_a_basic_file: - ldax tmp_load_address -exit_cart_via_ax: - sta call_downloaded_prg+1 - stx call_downloaded_prg+2 - jmp exit_cart - -get_tftp_directory_listing: - stax tftp_filename - - ldax #directory_buffer - stax tftp_load_address - - ldax #getting_dir_listing_msg - jsr print_ascii_as_native - - jsr tftp_download - - bcs @dir_failed - - lda directory_buffer ;get the first byte that was downloaded - bne :+ - jmp @no_files_on_server -: - - ;switch to lower case charset - lda #23 - sta $d018 - -@loop_till_filename_entered: - ldax #directory_buffer - ldy #1 ;filenames will be ASCII - jsr select_option_from_menu - bcs @loop_till_filename_entered -@tftp_filename_set: - stax copy_dest - stax get_value_of_axy+1 - ldy #0 - jsr get_value_of_axy ;A now == first char in string we just downloaded - cmp #'$' - bne @not_directory_name - ;it's a directory name, so we need to append the file mask to end of it - ;this will fail if the file path is more than 255 characters long -@look_for_trailing_zero: - iny - inc copy_dest - bne :+ - inc copy_dest+1 -: - jsr get_value_of_axy ;A now == next char in string we just downloaded - bne @look_for_trailing_zero - -; got trailing zero - ldax #tftp_dir_filemask+1 ;skip the leading '$' - stax copy_src - ldax #$07 - jsr copymem - ldax get_value_of_axy+1 - jmp get_tftp_directory_listing - -@not_directory_name: - ldax get_value_of_axy+1 - clc - rts - - -@dir_failed: - ldax #dir_listing_fail_msg - jsr print_ascii_as_native - jsr print_errorcode - jsr print_cr - - ldax #tftp_file - jmp @tftp_filename_set - -@no_files_on_server: - ldax #no_files - jsr print_ascii_as_native - - jmp tftp_boot_failed - - - -bad_boot: - jsr wait_for_keypress - jmp $fe66 ;do a wam start - -download: ;AX should point at filename to download - stax tftp_filename - - ldax #$0000 ;load address will be first 2 bytes of file we download (LO/HI order) - stax tftp_load_address - - ldax #downloading_msg - jsr print_ascii_as_native - ldax tftp_filename - jsr print_ascii_as_native - jsr print_cr - - jsr tftp_download - - bcc :+ - - ldax #tftp_download_fail_msg - jsr print_ascii_as_native - jsr print_errorcode - sec - rts - -: - ldax #tftp_download_ok_msg - jsr print_ascii_as_native - clc - rts - -wait_for_keypress: - ldax #press_a_key_to_continue - jsr print_ascii_as_native -@loop: - jsr $ffe4 - beq @loop - rts - -get_key: -@loop: - jsr $ffe4 - beq @loop - rts - - -.rodata - -netboot_msg: -.byte 14,10,"NETBOOT - V" -.include "../inc/version.i" -.byte 10,0 -downloading_msg: .byte "down" -loading_msg: .asciiz "loading " - -getting_dir_listing_msg: .byte "fetching directory",10,0 - -dir_listing_fail_msg: - .byte "dir failed",10,0 - -tftp_download_fail_msg: - .byte "download failed", 10, 0 - -tftp_download_ok_msg: - .byte "down" -load_ok_msg: - .byte "load OK", 10, 0 - - - -tftp_dir_filemask: - .asciiz "$/*.prg" - -tftp_file: - .asciiz "BOOTC64.PRG" - -no_files: - .byte "No files",10,0 - - -;we need a 'dummy' segment here - some drivers use this segment (e.g. wiznet), some don't (e.g. rr-net) -;if we don't declare this, we get an 'undefined segment' error when linking to a driver that doesn't use it. -.segment "SELF_MODIFIED_CODE" - -;-- LICENSE FOR netboot.s -- -; The contents of this file are subject to the Mozilla Public License -; Version 1.1 (the "License"); you may not use this file except in -; compliance with the License. You may obtain a copy of the License at -; http://www.mozilla.org/MPL/ -; -; Software distributed under the License is distributed on an "AS IS" -; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -; License for the specific language governing rights and limitations -; under the License. -; -; The Original Code is netboot65. -; -; The Initial Developer of the Original Code is Jonno Downes, -; jonno@jamtronix.com. -; Portions created by the Initial Developer are Copyright (C) 2009 -; Jonno Downes. All Rights Reserved. -; -- LICENSE END -- diff --git a/client/carts/set_ip_config.rb b/client/carts/set_ip_config.rb deleted file mode 100644 index 6ba2649..0000000 --- a/client/carts/set_ip_config.rb +++ /dev/null @@ -1,128 +0,0 @@ -#cartridge offsets: -# $18=MAC address (6 bytes) -# $1E=IP address (4 bytes) -# $22=netmask (4 bytes) -# $26=gateway (4 bytes) -# $2A=DNS (4 bytes) -# $2E= DHCP server (4 bytes) (not changeable) -# $32=TFTP server (4 bytes) -# $36=drive (1 byte) - -@cartridge_offsets={ -#symobol => offset, length - :mac=>[0x18,6], - :ip=>[0x1e,4], - :netmask=>[0x22,4], - :gateway=>[0x26,4], - :dns=>[0x2a,4], - :tftp=>[0x32,4], - :drive=>[0x36,1] - } - - @progname=File.basename($0) - def show_options - puts "valid options are: #{@cartridge_offsets.keys.join(", ")}" - puts "mac auto will automagically generate a pseudorandom MAC" -end - def usage - puts "#{@progname}