From b2d1f1875f19ee5b1272a50b433a021a5435afc1 Mon Sep 17 00:00:00 2001 From: jonnosan Date: Sat, 10 Jan 2009 10:18:51 +0000 Subject: [PATCH] add credits for IP65 files, clean up Makefiles git-svn-id: http://svn.code.sf.net/p/netboot65/code@2 93682198-c243-4bdb-bd91-e943c89aac3b --- cfg/a2bin.cfg | 15 +- cfg/a2language_card.cfg | 20 +++ cfg/c64prg.cfg | 14 +- clients/Makefile | 4 +- drivers/Makefile | 4 +- drivers/a2kernal.s | 5 + drivers/c64kernal.s | 5 + ip65/Makefile | 3 +- ip65/arp.s | 3 +- ip65/config.s | 2 + ip65/copymem.s | 2 + ip65/cs8900a.i | 2 + ip65/cs8900a.s | 2 + ip65/debug.s | 2 + ip65/eth.s | 2 + ip65/icmp.s | 2 + ip65/ip.s | 2 + ip65/ip65.s | 2 + ip65/printf.s | 2 + ip65/tcp.s | 272 --------------------------------- ip65/timer.s | 2 + ip65/udp.s | 2 + test/Makefile | 44 +++--- test/testarp.s | 196 ------------------------ test/testarpcache.s | 205 ------------------------- test/testcksum.s | 147 ------------------ test/testdns.s | 36 +++-- test/testeth.s | 220 -------------------------- test/testping.s | 256 ------------------------------- test/testsend.s | 331 ---------------------------------------- test/testtcpsend.s | 158 ------------------- test/testtimer.s | 108 ------------- test/testudp.s | 189 ----------------------- test/testudpsend.s | 174 --------------------- 34 files changed, 118 insertions(+), 2315 deletions(-) create mode 100644 cfg/a2language_card.cfg create mode 100644 drivers/a2kernal.s create mode 100644 drivers/c64kernal.s delete mode 100644 ip65/tcp.s delete mode 100644 test/testarp.s delete mode 100644 test/testarpcache.s delete mode 100644 test/testcksum.s delete mode 100644 test/testeth.s delete mode 100644 test/testping.s delete mode 100644 test/testsend.s delete mode 100644 test/testtcpsend.s delete mode 100644 test/testtimer.s delete mode 100644 test/testudp.s delete mode 100644 test/testudpsend.s diff --git a/cfg/a2bin.cfg b/cfg/a2bin.cfg index ff2950f..68fbc04 100644 --- a/cfg/a2bin.cfg +++ b/cfg/a2bin.cfg @@ -2,17 +2,16 @@ MEMORY { ZP: start = $00, size = $08, type = rw, define = yes; IP65ZP: start = $0f, size = $10, type = rw, define = yes; - HEADER: start = $0000, size = $4, file = %O; - RAM: start = $800, size = $8000, file = %O; - LANGUAGE_CARD: start= $D000, size=$2800, type=rw, define=yes; + HEADER: start = $0000, size = $10, file = %O; + RAM: start = $800, size = $8000, file = %O; } SEGMENTS { - EXEHDR: load = HEADER, type = ro; + EXEHDR: load = HEADER, type = ro; STARTUP: load = RAM,run=RAM, type = ro, define = yes; - CODE: load = RAM, run=LANGUAGE_CARD, type = ro, define = yes; - RODATA: load = RAM, run=LANGUAGE_CARD, type = ro , define = yes; - DATA: load = RAM, run=LANGUAGE_CARD, type = rw , define = yes; - BSS: load=LANGUAGE_CARD, type = bss, define = yes; + CODE: load = RAM, run=RAM, type = ro, define = yes; + RODATA: load = RAM, run=RAM, type = ro , define = yes; + DATA: load = RAM, run=RAM, type = rw , define = yes; + BSS: load=RAM, type = bss, define = yes; ZEROPAGE: load = ZP, type = zp; IP65ZP: load = IP65ZP, type = zp; } diff --git a/cfg/a2language_card.cfg b/cfg/a2language_card.cfg new file mode 100644 index 0000000..ff2950f --- /dev/null +++ b/cfg/a2language_card.cfg @@ -0,0 +1,20 @@ + +MEMORY { + ZP: start = $00, size = $08, type = rw, define = yes; + IP65ZP: start = $0f, size = $10, type = rw, define = yes; + HEADER: start = $0000, size = $4, file = %O; + RAM: start = $800, size = $8000, file = %O; + LANGUAGE_CARD: start= $D000, size=$2800, type=rw, define=yes; +} +SEGMENTS { + EXEHDR: load = HEADER, type = ro; + STARTUP: load = RAM,run=RAM, type = ro, define = yes; + CODE: load = RAM, run=LANGUAGE_CARD, type = ro, define = yes; + RODATA: load = RAM, run=LANGUAGE_CARD, type = ro , define = yes; + DATA: load = RAM, run=LANGUAGE_CARD, type = rw , define = yes; + BSS: load=LANGUAGE_CARD, type = bss, define = yes; + ZEROPAGE: load = ZP, type = zp; + IP65ZP: load = IP65ZP, type = zp; +} + + diff --git a/cfg/c64prg.cfg b/cfg/c64prg.cfg index 0513377..8ec783d 100644 --- a/cfg/c64prg.cfg +++ b/cfg/c64prg.cfg @@ -1,14 +1,16 @@ MEMORY { ZP: start = $02, size = $1A, type = rw, define = yes; IP65ZP: start = $5f, size = $10, type = rw, define = yes; - RAM: start = $07FF, size = $c801, define = yes, file = %O; + RAM: start = $07FF, size = $c801, define = yes, file = %O; + DISCARD: start = $77FF, size = $10, define = yes; } SEGMENTS { - STARTUP: load = RAM, type = ro; - CODE: load = RAM, type = ro; - DATA: load = RAM, type = rw; - RODATA: load = RAM, type = ro; + STARTUP: load = RAM, type = ro ,define = yes; + CODE: load = RAM, type = ro,define = yes; + DATA: load = RAM, type = rw,define = yes; + RODATA: load = RAM, type = ro,define = yes; BSS: load = RAM, type = bss; ZEROPAGE: load = ZP, type = zp; - IP65ZP: load = IP65ZP, type = zp; + IP65ZP: load = IP65ZP, type = zp; + EXEHDR: load = DISCARD, type = ro; } diff --git a/clients/Makefile b/clients/Makefile index e138151..d70cc5c 100644 --- a/clients/Makefile +++ b/clients/Makefile @@ -28,8 +28,8 @@ rrnetboot.bin: rrnetboot.o $(IP65LIB) $(C64NETLIB) $(INCFILES) ../cfg/rrbin.cfg $(LD) -m rrnetboot.map -C ../cfg/rrbin.cfg -o rrnetboot.bin $(AFLAGS) $< $(IP65LIB) $(C64NETLIB) ruby fix_cart.rb rrnetboot.bin -utherboot.bin: utherboot.o $(IP65LIB) $(APPLE2NETLIB) $(INCFILES) ../cfg/a2bin.cfg - $(LD) -m utherboot.map -C ../cfg/a2bin.cfg -o utherboot.bin $(AFLAGS) $< $(IP65LIB) $(APPLE2NETLIB) +utherboot.bin: utherboot.o $(IP65LIB) $(APPLE2NETLIB) $(INCFILES) ../cfg/a2language_card.cfg + $(LD) -m utherboot.map -C ../cfg/a2language_card.cfg -o utherboot.bin $(AFLAGS) $< $(IP65LIB) $(APPLE2NETLIB) utherboot.dsk: utherboot.bin dsktool.rb --init dos33 utherboot.dsk -a utherboot.bin -t B diff --git a/drivers/Makefile b/drivers/Makefile index 02807f5..7bb4d5e 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -17,10 +17,10 @@ DRIVERS=\ all: $(DRIVERS) -apple2net.lib: a2print.o uthernet.o a2timer.o +apple2net.lib: a2print.o uthernet.o a2timer.o a2kernal.o ar65 a apple2net.lib $^ -c64net.lib: c64print.o rr-net.o c64timer.o +c64net.lib: c64print.o rr-net.o c64timer.o c64kernal.o ar65 a c64net.lib $^ clean: diff --git a/drivers/a2kernal.s b/drivers/a2kernal.s new file mode 100644 index 0000000..cb3941d --- /dev/null +++ b/drivers/a2kernal.s @@ -0,0 +1,5 @@ +.export exit_to_basic + +.code +exit_to_basic: + jmp $3d0 \ No newline at end of file diff --git a/drivers/c64kernal.s b/drivers/c64kernal.s new file mode 100644 index 0000000..1c712a1 --- /dev/null +++ b/drivers/c64kernal.s @@ -0,0 +1,5 @@ +.export exit_to_basic + +.code +exit_to_basic: + jmp $a7ae ; jump to BASIC interpreter loop diff --git a/ip65/Makefile b/ip65/Makefile index 198f277..54966e2 100644 --- a/ip65/Makefile +++ b/ip65/Makefile @@ -25,8 +25,7 @@ ETHOBJS= \ debug.o \ dhcp.o \ dns.o \ - tftp.o \ - tcp.o \ + tftp.o \ all: ip65.lib diff --git a/ip65/arp.s b/ip65/arp.s index 2c00aca..95e9427 100644 --- a/ip65/arp.s +++ b/ip65/arp.s @@ -1,5 +1,6 @@ ; ARP address resolution - + +;originally from Per Olofsson's IP65 library - http://www.paradroid.net/ip65 .include "../inc/common.i" diff --git a/ip65/config.s b/ip65/config.s index d8adb13..758f0aa 100644 --- a/ip65/config.s +++ b/ip65/config.s @@ -1,3 +1,5 @@ +;originally from Per Olofsson's IP65 library - http://www.paradroid.net/ip65 + ; Configuration diff --git a/ip65/copymem.s b/ip65/copymem.s index c042a00..1f968c6 100644 --- a/ip65/copymem.s +++ b/ip65/copymem.s @@ -1,3 +1,5 @@ +;originally from Per Olofsson's IP65 library - http://www.paradroid.net/ip65 + ; copy memory diff --git a/ip65/cs8900a.i b/ip65/cs8900a.i index d53b4bb..0486960 100644 --- a/ip65/cs8900a.i +++ b/ip65/cs8900a.i @@ -1,3 +1,5 @@ +;originally from Per Olofsson's IP65 library - http://www.paradroid.net/ip65 + pp_rx_ctl = $0104 pp_line_ctl = $0112 pp_self_ctl = $0114 diff --git a/ip65/cs8900a.s b/ip65/cs8900a.s index e7e90fa..f7d5e6b 100644 --- a/ip65/cs8900a.s +++ b/ip65/cs8900a.s @@ -1,3 +1,5 @@ +;originally from Per Olofsson's IP65 library - http://www.paradroid.net/ip65 + ; Ethernet driver for CS8900A ; ; Based on Doc Bacardi's tftp source diff --git a/ip65/debug.s b/ip65/debug.s index 0d8bfea..30efaa8 100644 --- a/ip65/debug.s +++ b/ip65/debug.s @@ -1,3 +1,5 @@ +;originally from Per Olofsson's IP65 library - http://www.paradroid.net/ip65 + .include "../inc/common.i" .include "../inc/printf.i" diff --git a/ip65/eth.s b/ip65/eth.s index b88de45..61ad8de 100644 --- a/ip65/eth.s +++ b/ip65/eth.s @@ -1,3 +1,5 @@ +;originally from Per Olofsson's IP65 library - http://www.paradroid.net/ip65 + ; Common ethernet driver code diff --git a/ip65/icmp.s b/ip65/icmp.s index 2abaf50..2e1b432 100644 --- a/ip65/icmp.s +++ b/ip65/icmp.s @@ -1,3 +1,5 @@ +;originally from Per Olofsson's IP65 library - http://www.paradroid.net/ip65 + .include "../inc/common.i" .export icmp_init diff --git a/ip65/ip.s b/ip65/ip.s index 7ee162a..5a09dfb 100644 --- a/ip65/ip.s +++ b/ip65/ip.s @@ -1,3 +1,5 @@ +;originally from Per Olofsson's IP65 library - http://www.paradroid.net/ip65 + .include "../inc/common.i" ;.import dbg_dump_ip_header diff --git a/ip65/ip65.s b/ip65/ip65.s index 5d2a51e..9289f42 100644 --- a/ip65/ip65.s +++ b/ip65/ip65.s @@ -1,3 +1,5 @@ +;originally from Per Olofsson's IP65 library - http://www.paradroid.net/ip65 + ; ip65 main routines .include "../inc/common.i" diff --git a/ip65/printf.s b/ip65/printf.s index 11196e0..01d9609 100644 --- a/ip65/printf.s +++ b/ip65/printf.s @@ -1,3 +1,5 @@ +;originally from Per Olofsson's IP65 library - http://www.paradroid.net/ip65 + .include "../inc/common.i" .export console_printf diff --git a/ip65/tcp.s b/ip65/tcp.s deleted file mode 100644 index a40472d..0000000 --- a/ip65/tcp.s +++ /dev/null @@ -1,272 +0,0 @@ -;######################## -; minimal tcp implementation -; written by jonno@jamtronix.com 2009 -;######################## - -.include "../inc/common.i" - - MAX_TCP_RETRY=10 - - .export tcp_init - .export tcp_process - .export tcp_connect -; .export tcp_close - .export tcp_send - - .export tcp_callback - - .export tcp_inp - .export tcp_outp - - .exportzp tcp_src_port - .exportzp tcp_dest_port -; .exportzp tcp_len - .exportzp tcp_cksum - .exportzp tcp_data - - .export tcp_send_dest - .export tcp_send_src_port - .export tcp_send_dest_port - .export tcp_send_len - - - .import ip65_process - .import timer_read - .import ip_calc_cksum - .import ip_send - .import ip_create_packet - .import ip_inp - .import ip_outp - .importzp ip_cksum_ptr - .importzp ip_header_cksum - .importzp ip_src - .importzp ip_dest - .importzp ip_data - .importzp ip_proto - .importzp ip_proto_tcp - .importzp ip_id - .importzp ip_len - - .import copymem - .importzp copy_src - .importzp copy_dest - - .import cfg_ip - - - .bss - -; arguments for tcp_connect -tcp_callback: .res 2 -tcp_send_dest: .res 4 -tcp_send_src_port: .res 2 -tcp_send_dest_port: .res 2 - -;data on current connection -tcp_current_seq_number: .res 4 -tcp_last_ack_number: .res 4 -tcp_expected_ack_number: .res 4 -tcp_flags_value: .res 1 - -; arguments for tcp_send -tcp_send_len: .res 2 - -; tcp packet offsets -tcp_inp = ip_inp + ip_data -tcp_outp = ip_outp + ip_data -tcp_src_port = 0 -tcp_dest_port = 2 -tcp_sequence_number=4 -tcp_ack_number=8 -tcp_flags=12 -tcp_window_size=14 -tcp_cksum = 16 -tcp_urgent_pointer = 18 -tcp_data=20 - - -tcp_state: .res 1 -tcp_state_listen=1 -tcp_state_syn_sent=2 -tcp_state_syn_received=3 -tcp_state_established=4 -tcp_state_fin_wait_1=5 -tcp_state_fin_wait_2=6 -tcp_state_close_wait=7 -tcp_state_closing=8 -tcp_state_last_ack=9 -tcp_state_time_wait=10 -tcp_state_closed=11 - -tcp_message_sent_count: .res 1 -tcp_loop_count: .res 1 -tcp_timer: .res 1 - -; virtual header -tcp_vh = tcp_outp - 12 -tcp_vh_src = 0 -tcp_vh_dest = 4 -tcp_vh_zero = 8 -tcp_vh_proto = 9 -tcp_vh_len = 10 - - .code - -; initialize tcp -tcp_init: - ;nothing to do here yet -rts - - -; process incoming tcp packet -tcp_process: - rts - - -;connect to a remote server -; but first: -; -; set destination address -; set source port -; set destination port -; set callback address - -tcp_connect: - ldax #0 - stax tcp_send_len - sta tcp_message_sent_count - lda #$02 ;SYN - sta tcp_flags_value - lda #tcp_state_syn_sent - sta tcp_state - - jsr tcp_send - -@tcp_polling_loop: - lda tcp_message_sent_count - adc #1 - sta tcp_loop_count ;we wait a bit longer between each resend -@outer_delay_loop: - jsr timer_read - stx tcp_timer ;we only care about the high byte - -@inner_delay_loop: - jsr ip65_process - lda tcp_state - cmp #tcp_state_syn_sent - clc - bne @done - jsr timer_read - cpx tcp_timer ;this will tick over after about 1/4 of a second - beq @inner_delay_loop - - dec tcp_loop_count - bne @outer_delay_loop - - jsr tcp_send - inc tcp_message_sent_count - lda tcp_message_sent_count - cmp #MAX_TCP_RETRY-1 - bpl @too_many_retries - jmp @tcp_polling_loop - -@too_many_retries: - sec -@done: - rts - - -; send tcp packet to currently open connection -; -; but first: -; -; set length - -tcp_send: - stax copy_src ; copy data to output buffer - ldax #tcp_outp + tcp_data - stax copy_dest - ldax tcp_send_len - jsr copymem - - - lda tcp_flags_value - sta ip_outp +tcp_flags - - ldx #3 ; copy virtual header addresses -: lda tcp_send_dest,x - sta tcp_vh + tcp_vh_dest,x ; set virtual header destination - - lda cfg_ip,x - sta tcp_vh + tcp_vh_src,x ; set virtual header source - dex - bpl :- - - lda tcp_send_src_port ; copy source port - sta tcp_outp + tcp_src_port + 1 - lda tcp_send_src_port + 1 - sta tcp_outp + tcp_src_port - - lda tcp_send_dest_port ; copy destination port - sta tcp_outp + tcp_dest_port + 1 - lda tcp_send_dest_port + 1 - sta tcp_outp + tcp_dest_port - - lda #ip_proto_tcp - sta tcp_vh + tcp_vh_proto - - lda #0 ; clear checksum - sta tcp_outp + tcp_cksum - sta tcp_outp + tcp_cksum + 1 - sta tcp_vh + tcp_vh_zero ; clear virtual header zero byte - - ldax #tcp_vh ; checksum pointer to virtual header - stax ip_cksum_ptr - - lda tcp_send_len ; copy length + 20 - clc - adc #20 - sta tcp_vh + tcp_vh_len + 1 ; lsb for virtual header - tay - lda tcp_send_len + 1 - adc #0 - sta tcp_vh + tcp_vh_len ; msb for virtual header - - tax ; length to A/X - tya - - clc ; add 12 bytes for virtual header - adc #12 - bcc :+ - inx -: - jsr ip_calc_cksum ; calculate checksum - stax tcp_outp + tcp_cksum - - ldx #3 ; copy addresses -: lda tcp_send_dest,x - sta ip_outp + ip_dest,x ; set ip destination address - dex - bpl :- - - - jsr ip_create_packet ; create ip packet template - - - lda tcp_outp + tcp_send_len + 1 ; ip len = tcp data len + 20 byte tcp header len + 20 byte ip header len - ldx tcp_outp + tcp_send_len - clc - adc #40 - bcc :+ - inx -: sta ip_outp + ip_len + 1 ; set length - stx ip_outp + ip_len - - ldax #$1234 ; set ID - stax ip_outp + ip_id - - lda #ip_proto_tcp ; set protocol - sta ip_outp + ip_proto - - - jmp ip_send ; send packet, sec on error diff --git a/ip65/timer.s b/ip65/timer.s index 2d1b8f3..fc1b199 100644 --- a/ip65/timer.s +++ b/ip65/timer.s @@ -1,3 +1,5 @@ +;originally from Per Olofsson's IP65 library - http://www.paradroid.net/ip65 + ; timer routines ; ; the timer should be a 16-bit counter that's incremented by about diff --git a/ip65/udp.s b/ip65/udp.s index cd3d6fb..a79be49 100644 --- a/ip65/udp.s +++ b/ip65/udp.s @@ -1,3 +1,5 @@ +;originally from Per Olofsson's IP65 library - http://www.paradroid.net/ip65 + .include "../inc/common.i" ;.import dbg_dump_udp_header diff --git a/test/Makefile b/test/Makefile index 33c755d..d641b7f 100644 --- a/test/Makefile +++ b/test/Makefile @@ -7,6 +7,7 @@ AFLAGS= IP65LIB=../ip65/ip65.lib C64NETLIB=../drivers/c64net.lib +APPLE2NETLIB=../drivers/apple2net.lib INCFILES=\ ../inc/common.i\ @@ -19,35 +20,26 @@ INCFILES=\ %.o: %.s $(AS) $(AFLAGS) $< -%.prg: %.o $(IP65LIB) $(C64NETLIB) $(INCFILES) +%.bin: %.o $(IP65LIB) $(APPLE2NETLIB) $(INCFILES) ../cfg/a2bin.cfg + $(LD) -m $*.map -C ../cfg/a2bin.cfg -o $*.bin $(AFLAGS) $< $(IP65LIB) $(APPLE2NETLIB) + +%.prg: %.o $(IP65LIB) $(C64NETLIB) $(INCFILES) ../cfg/c64prg.cfg $(LD) -m $*.map -C ../cfg/c64prg.cfg -o $*.prg $(AFLAGS) $< $(IP65LIB) $(C64NETLIB) - -all: \ - testeth.prg \ - testarp.prg \ - testarpcache.prg \ - testping.prg \ - testcksum.prg \ - testsend.prg \ - testtimer.prg \ - testudp.prg \ - testudpsend.prg \ - testdns.prg \ - testtcpsend.prg \ - + +ip65test.dsk: testdns.bin + dsktool.rb --init dos33 ip65test.dsk -a testdns.bin -t B + + +all: \ + ip65test.dsk \ + testdns.bin \ + testdns.prg \ + + clean: rm -f *.o - rm -f testeth.prg testeth.map - rm -f testarp.prg testarp.map - rm -f testarpcache.prg testarpcache.map - rm -f testping.prg testping.map - rm -f testsend.prg testsend.map - rm -f testcksum.prg testcksum.map - rm -f testtimer.prg testtimer.map - rm -f testudp.prg testudp.map - rm -f testudpsend.prg testudpsend.map - rm -f testdns.prg testdns.map - rm -f testtcpsend.prg testtcpsend.map + rm -f testdns.prg testdns.map testdns.bin + rm -f ip65test.dsk distclean: clean rm -f *~ diff --git a/test/testarp.s b/test/testarp.s deleted file mode 100644 index 181478f..0000000 --- a/test/testarp.s +++ /dev/null @@ -1,196 +0,0 @@ -.include "../inc/common.i" -.include "../inc/petscii.i" - - - .import eth_init - .import eth_init - .import eth_rx - .import eth_tx - .import eth_inp - .import eth_inp_len - - .import arp_init - .import arp_lookup - .import arp_process - - - .zeropage - -printptr: .res 2 -pptr: .res 2 - - - .bss - -pbtemp: .res 1 - - - .segment "STARTUP" - - .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 - - - .code - -init: - jsr eth_init ; initialize ethernet driver - ldx #0 - bcc :+ - - ldax #failmsg - jmp print - -: ldax #startmsg - jsr print - - jsr arp_init ; initialize arp - -@waitpacket: - jsr eth_rx - bcs @waitpacket - - lda eth_inp + 12 - cmp #8 - bne @waitpacket - - lda eth_inp + 13 - cmp #6 ; arp - bne @waitpacket - - ldax #arpmsg - jsr print - ldax eth_inp_len - jsr printint - ldax #bytesmsg - jsr print - - jsr arp_process ; process arp packet - - ldax #eth_inp - stax pptr - - ldy #petscii_ltred ; dest addr - lda #6 - jsr printbytes - - ldy #petscii_ltgreen ; src addr - lda #6 - jsr printbytes - - ldy #petscii_ltgray ; type - lda #2 - jsr printbytes - - lda #13 - jsr $ffd2 - -@arp: - ldy #petscii_yellow ; hw, proto, hwlen, protolen, op - lda #8 - jsr printbytes - lda #13 - jsr $ffd2 - - ldy #petscii_cyan - lda #10 - jsr printbytes - lda #13 - jsr $ffd2 - - ldy #petscii_white - lda #10 - jsr printbytes - lda #13 - jsr $ffd2 - -@done: - lda #petscii_ltblue - jsr $ffd2 - lda #13 - jsr $ffd2 - - jmp @waitpacket - - -printbytes: - sta pbtemp - tya - jsr $ffd2 - ldy #0 -: lda (pptr),y - jsr printhex - iny - cpy pbtemp - bne :- - - lda pbtemp - clc - adc pptr - sta pptr - bcc :+ - inc pptr+1 -: rts - - -print: - sta printptr - stx printptr + 1 - ldy #0 -: lda (printptr),y - beq :+ - jsr $ffd2 - iny - bne :- -: rts - - -printint: - pha - txa - jsr printhex - pla -printhex: - pha - lsr - lsr - lsr - lsr - tax - lda hexdigit,x - jsr $ffd2 - pla - and #$0f - tax - lda hexdigit,x - jsr $ffd2 - rts - - - .data - -hexdigit: - .byte "0123456789ABCDEF" - -startmsg: - .byte 14, "rr-nET INITIALIZED", 13, 0 - -failmsg: - .byte 14, "rr-nET INIT FAILED", 13, 0 - -arpmsg: - .byte "arp PACKET RECEIVED: ",0 - -bytesmsg: - .byte " BYTES", 13, 0 diff --git a/test/testarpcache.s b/test/testarpcache.s deleted file mode 100644 index 1112554..0000000 --- a/test/testarpcache.s +++ /dev/null @@ -1,205 +0,0 @@ -.include "../inc/common.i" -.include "../inc/petscii.i" - - - .import ip65_init - .import ip65_process - - .import ip65_ctr - .import ip65_ctr_arp - .import ip65_ctr_ip - - .import arp_cache - - - .zeropage - -printptr: .res 2 -pptr: .res 2 - - - .bss - -pbtemp: .res 1 -cnt: .res 1 - - - .segment "STARTUP" - - .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 - - - .code - -init: - lda #0 - sta $d021 - - jsr ip65_init - ldx #0 - bcc :+ - - ldax #failmsg - jmp print - -: ldax #startmsg - jsr print - -main: - lda ip65_ctr_arp - pha - lda ip65_ctr_ip - pha - jsr ip65_process - pla - cmp ip65_ctr_arp - beq :+ - jsr printarp -: pla - cmp ip65_ctr_ip - beq :+ - jsr printip -: jmp main - - -printarp: - ldax #arp_cache - stax pptr - - lda #petscii_home - jsr $ffd2 - lda #petscii_down - jsr $ffd2 - - lda #8 - sta cnt - -@print: - ldy #petscii_ltgray - lda #6 - jsr printbytes - - lda #' ' - jsr $ffd2 - - ldy #petscii_gray - lda #4 - jsr printbytes - - lda #13 - jsr $ffd2 - - dec cnt - bne @print - - rts - - -printip: - lda #petscii_home - jsr $ffd2 - ldx #10 - lda #petscii_down -: jsr $ffd2 - dex - bne :- - - lda #petscii_white - jsr $ffd2 - - lda ip65_ctr_ip - jsr printhex - - ldax ippktmsg - jsr print - - rts - - -printbytes: - sta pbtemp - tya - jsr $ffd2 - ldy #0 -: lda (pptr),y - jsr printhex - lda #' ' - jsr $ffd2 - iny - cpy pbtemp - bne :- - - lda pbtemp - clc - adc pptr - sta pptr - bcc :+ - inc pptr+1 -: rts - - -print: - sta printptr - stx printptr + 1 - ldy #0 -: lda (printptr),y - beq :+ - jsr $ffd2 - iny - bne :- -: rts - - -printint: - pha - txa - jsr printhex - pla -printhex: - pha - lsr - lsr - lsr - lsr - tax - lda hexdigit,x - jsr $ffd2 - pla - and #$0f - tax - lda hexdigit,x - jsr $ffd2 - rts - - - .data - -hexdigit: - .byte "0123456789ABCDEF" - -startmsg: - .byte petscii_clear, petscii_lower, "arp CACHE:", 13, 0 - -failmsg: - .byte petscii_lower, "rr-nET INIT FAILED", 13, 0 - -ippktmsg: - .byte petscii_ltgray, " ip PACKETS RECEIVED",0 - -bytesmsg: - .byte " BYTES", 13, 0 - -pingdest: - .byte 130, 241, 53, 61 diff --git a/test/testcksum.s b/test/testcksum.s deleted file mode 100644 index 5f94256..0000000 --- a/test/testcksum.s +++ /dev/null @@ -1,147 +0,0 @@ -.include "../inc/common.i" -.include "../inc/petscii.i" - - - .import ip_calc_cksum - .importzp ip_cksum_ptr - - - .segment "STARTUP" - - .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 - - - .code - -init: - jsr printpacket - -calccksum: - ldax #0 - stax ip_outp + ip_header_cksum ; null any garbage checksum - - ldax #ip_outp - stax ip_cksum_ptr - ldax #20 - jsr ip_calc_cksum - stax ip_outp + ip_header_cksum - -icmp_outp = ip_outp + 20 -icmp_cksum = 2 - - ldax #0 - stax icmp_outp + icmp_cksum - ldax #icmp_outp - stax ip_cksum_ptr - ldax #40 - jsr ip_calc_cksum - stax icmp_outp + icmp_cksum - - jsr printpacket - - rts - - -printpacket: - ldx #0 -: lda ip_outp,x - jsr printhex - txa - and #7 - tay - lda sep,y - jsr $ffd2 - inx - cpx #60 - bne :- - lda #13 - jsr $ffd2 - jsr $ffd2 - rts - - -printint: - pha - txa - jsr printhex - pla -printhex: - pha - lsr - lsr - lsr - lsr - tay - lda hexdigit,y - jsr $ffd2 - pla - and #$0f - tay - lda hexdigit,y - jsr $ffd2 - rts - - - .data - -hexdigit: - .byte "0123456789ABCDEF" - -ip_header_cksum = 10 -ip_data = 20 - -yip_outp: - .byte $45, $00, $00, $3c, $65, $f7, $40, $00 - .byte $f3, $01, $a9, $21, $82, $f1, $35, $0c - .byte $c0, $a8, $00, $02, $00, $00, $36, $5c - .byte $04, $00, $1b, $00, $61, $62, $63, $64 - .byte $65, $66, $67, $68, $69, $6a, $6b, $6c - .byte $6d, $6e, $6f, $70, $71, $72, $73, $74 - .byte $75, $76, $77, $61, $62, $63, $64, $65 - .byte $66, $67, $68, $69 - -sep: - .byte 32, 32, 32, 32, 32, 32, 32, 13 - -xip_outp: - .byte $45, $00, $00, $3c, $bf, $c9, $00, $00 - .byte $80, $01, $02, $50, $c0, $a8, $00, $02 - .byte $82, $f1, $35, $0c, $08, $00, $2e, $5c - .byte $04, $00, $1b, $00, $61, $62, $63, $64 - .byte $65, $66, $67, $68, $69, $6a, $6b, $6c - .byte $6d, $6e, $6f, $70, $71, $72, $73, $74 - .byte $75, $76, $77, $61, $62, $63, $64, $65 - .byte $66, $67, $68, $69 - -ip_outp: - .byte $45, $00, $00, $3c, $f4, $4d, $00, $00 - .byte $80, $01, $c4, $e0, $c0, $a8, $00, $40 - .byte $c0, $a8, $00, $02, $00, $00, $03, $5b - .byte $04, $00, $4e, $00, $61, $62, $63, $64 - .byte $65, $66, $67, $68, $69, $6a, $6b, $6c - .byte $6d, $6e, $6f, $70, $71, $72, $73, $74 - .byte $75, $76, $77, $61, $62, $63, $64, $65 - .byte $66, $67, $68, $69 - -zip_outp: - .byte $45, $00, $00, $40, $12, $34, $40, $00 - .byte $40, $01, $b7, $b6, $82, $f1, $35, $b3 - .byte $82, $f1, $35, $3d, $08, $00, $af, $ed - .byte $12, $34, $00, $97, $20, $21, $22, $23 - .byte $24, $25, $26, $27, $28, $29, $2a, $2b - .byte $2c, $2d, $2e, $2f, $30, $31, $32, $33 - .byte $34, $35, $36, $37, $38, $39, $3a, $3b - .byte $3c, $3d, $3e, $3f, $20, $21, $22, $23 - .byte $2d, $c9, $7f, $c1 diff --git a/test/testdns.s b/test/testdns.s index 92c5579..979d739 100644 --- a/test/testdns.s +++ b/test/testdns.s @@ -1,19 +1,25 @@ .include "../inc/common.i" .include "../inc/commonprint.i" .include "../inc/net.i" + + .import exit_to_basic .import dns_set_hostname .import dns_resolve .import dns_ip .import dns_status - + .import __CODE_LOAD__ + .import __CODE_SIZE__ + .import __RODATA_SIZE__ + .import __DATA_SIZE__ + .bss temp_bin: .res 1 temp_bcd: .res 2 - .segment "STARTUP" + .segment "STARTUP" ;this is what gets put at the start of the file on the C64 .word basicstub ; load address @@ -29,14 +35,19 @@ basicstub: @nextline: .word 0 - - .code +.segment "EXEHDR" ;this is what gets put an the start of the file on the Apple 2 + .addr __CODE_LOAD__-$11 ; Start address + .word __CODE_SIZE__+__RODATA_SIZE__+__DATA_SIZE__+4 ; Size + jmp init + +.code init: - jsr print_ip_config + jsr print_cr + jsr print_ip_config - init_ip_via_dhcp + init_ip_via_dhcp ; jsr overwrite_with_hardcoded_dns_server jsr print_ip_config @@ -59,17 +70,18 @@ init: ldax #hostname_6 jsr do_dns_query - rts + jmp exit_to_basic + do_dns_query: pha jsr print lda #' ' - jsr $ffd2 + jsr print_a lda #':' - jsr $ffd2 + jsr print_a lda #' ' - jsr $ffd2 + jsr print_a pla jsr dns_set_hostname jsr dns_resolve @@ -87,8 +99,7 @@ do_dns_query: lda dns_status+1 jsr print_hex jsr print_cr - - rts + rts overwrite_with_hardcoded_dns_server: ldx #3 @@ -104,6 +115,7 @@ overwrite_with_hardcoded_dns_server: .rodata +buffer1: .res 256 hostname_1: .byte "SLASHDOT.ORG",0 ;this should be an A record diff --git a/test/testeth.s b/test/testeth.s deleted file mode 100644 index ab64c24..0000000 --- a/test/testeth.s +++ /dev/null @@ -1,220 +0,0 @@ -.include "../inc/common.i" -.include "../inc/petscii.i" - - - .import eth_init - .import eth_init - .import eth_rx - .import eth_tx - .import eth_inp - .import eth_inp_len - - - .zeropage - -printptr: .res 2 -pptr: .res 2 - - - .bss - -pbtemp: .res 1 - - - .segment "STARTUP" - - .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 - - - .code - -init: - jsr eth_init - ldx #0 - bcc :+ - - ldax #failmsg - jmp print - -: ldax #startmsg - jsr print - -@waitpacket: - jsr eth_rx - bcs @waitpacket - -; lda eth_inp + 12 -; cmp #8 -; bne @waitpacket - - ldax #packetmsg - jsr print - ldax eth_inp_len - jsr printint - ldax #bytesmsg - jsr print - - ldax #eth_inp - stax pptr - - lda #petscii_ltred ; dest addr - jsr $ffd2 - lda #6 - jsr printbytes - lda #6 - jsr addpptr - - lda #petscii_ltgreen ; src addr - jsr $ffd2 - lda #6 - jsr printbytes - lda #6 - jsr addpptr - - lda #petscii_ltgray ; type - jsr $ffd2 - lda #2 - jsr printbytes - - lda #13 - jsr $ffd2 - - ldy #0 - lda (pptr),y - cmp #$08 - bne @done - - iny - lda (pptr),y - beq @ip - cmp #6 - beq @arp - bne @done - -@ip: - lda #2 - jsr addpptr - - lda #petscii_white - jsr $ffd2 - lda #10 - jsr printbytes - lda #10 - jsr addpptr - lda #13 - jsr $ffd2 - - lda #10 - jsr printbytes - lda #10 - jsr addpptr - lda #13 - jsr $ffd2 - - jmp @done - -@arp: - lda #2 - jsr addpptr - - lda #petscii_yellow - jsr $ffd2 - lda #8 - jsr printbytes - lda #13 - jsr $ffd2 - -@done: - lda #petscii_ltblue - jsr $ffd2 - lda #13 - jsr $ffd2 - - jmp @waitpacket - - -addpptr: - clc - adc pptr - sta pptr - bcc :+ - inc pptr+1 -: rts - - -printbytes: - sta pbtemp - ldy #0 -: lda (pptr),y - jsr printhex - iny - cpy pbtemp - bne :- - rts - - -print: - sta printptr - stx printptr + 1 - ldy #0 -: lda (printptr),y - beq :+ - jsr $ffd2 - iny - bne :- -: rts - - -printint: - pha - txa - jsr printhex - pla -printhex: - pha - lsr - lsr - lsr - lsr - tax - lda hexdigit,x - jsr $ffd2 - pla - and #$0f - tax - lda hexdigit,x - jsr $ffd2 - rts - - - .data - -hexdigit: - .byte "0123456789ABCDEF" - -macaddr: - .byte $0c, $64, "PO", $74, $04 - -startmsg: - .byte 14, "rr-nET INITIALIZED", 13, 0 - -failmsg: - .byte 14, "rr-nET INIT FAILED", 13, 0 - -packetmsg: - .byte "PACKET RECEIVED: ",0 - -bytesmsg: - .byte " BYTES", 13, 0 diff --git a/test/testping.s b/test/testping.s deleted file mode 100644 index ce73799..0000000 --- a/test/testping.s +++ /dev/null @@ -1,256 +0,0 @@ -.include "../inc/common.i" -.include "../inc/petscii.i" - - - .import eth_init - .import eth_init - .import eth_rx - .import eth_tx - .import eth_inp - .import eth_inp_len - - .import arp_init - .import arp_lookup - .import arp_process - - .import ip_init - .import ip_process - - - .zeropage - -printptr: .res 2 -pptr: .res 2 - - - .bss - -pbtemp: .res 1 - - - .segment "STARTUP" - - .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 - - - .code - -init: - lda #0 - sta $d021 - - jsr eth_init ; initialize ethernet driver - ldx #0 - bcc :+ - - ldax #failmsg - jmp print - -: ldax #startmsg - jsr print - - jsr arp_init ; initialize arp - - jsr ip_init ; initialize ip and icmp - -@waitpacket: - jsr eth_rx - bcs @waitpacket - - lda eth_inp + 12 - cmp #8 - bne @waitpacket - - lda eth_inp + 13 - beq @ip ; ip - cmp #6 ; arp - bne @waitpacket - -@arp: - jsr arp_process ; process arp packet - - jmp @waitpacket - - ldax #arpmsg - jsr print - ldax eth_inp_len - jsr printint - ldax #bytesmsg - jsr print - - - ldax #eth_inp - stax pptr - - ldy #petscii_ltred ; dest addr - lda #6 - jsr printbytes - - ldy #petscii_ltgreen ; src addr - lda #6 - jsr printbytes - - ldy #petscii_ltgray ; type - lda #2 - jsr printbytes - - lda #13 - jsr $ffd2 - - ldy #petscii_yellow ; hw, proto, hwlen, protolen, op - lda #8 - jsr printbytes - lda #13 - jsr $ffd2 - - ldy #petscii_cyan - lda #10 - jsr printbytes - lda #13 - jsr $ffd2 - - ldy #petscii_white - lda #10 - jsr printbytes - lda #13 - jsr $ffd2 - - lda #petscii_ltblue - jsr $ffd2 - -@wp: - jmp @waitpacket - -@ip: - lda ip_inp + ip_proto - cmp #1 - bne @wp - - ldax #ipmsg - jsr print - ldax eth_inp_len - jsr printint - ldax #bytesmsg - jsr print - - lda #petscii_white - jsr $ffd2 - lda ip_inp + ip_proto - jsr printhex - - ldax #ip_inp + ip_src - stax pptr - ldy #petscii_ltgreen - lda #4 - jsr printbytes - - ldax #ip_inp + ip_dest - stax pptr - ldy #petscii_ltred - lda #4 - jsr printbytes - - lda #petscii_ltblue - jsr $ffd2 - lda #13 - jsr $ffd2 -; jsr $ffd2 - - jsr ip_process ; handle packet - - jmp @waitpacket -; ip packets start at ethernet packet + 14 -ip_inp = eth_inp + 14 - -; ip packet offsets -ip_proto = 9 -ip_src = 12 -ip_dest = 16 - - - -printbytes: - sta pbtemp - tya - jsr $ffd2 - ldy #0 -: lda (pptr),y - jsr printhex - iny - cpy pbtemp - bne :- - - lda pbtemp - clc - adc pptr - sta pptr - bcc :+ - inc pptr+1 -: rts - - -print: - sta printptr - stx printptr + 1 - ldy #0 -: lda (printptr),y - beq :+ - jsr $ffd2 - iny - bne :- -: rts - - -printint: - pha - txa - jsr printhex - pla -printhex: - pha - lsr - lsr - lsr - lsr - tax - lda hexdigit,x - jsr $ffd2 - pla - and #$0f - tax - lda hexdigit,x - jsr $ffd2 - rts - - - .data - -hexdigit: - .byte "0123456789ABCDEF" - -startmsg: - .byte 14, "rr-nET INITIALIZED", 13, 0 - -failmsg: - .byte 14, "rr-nET INIT FAILED", 13, 0 - -arpmsg: - .byte "arp PACKET RECEIVED: ", 0 - -ipmsg: - .byte "ip PACKET RECEIVED: ",0 - -bytesmsg: - .byte " BYTES", 13, 0 diff --git a/test/testsend.s b/test/testsend.s deleted file mode 100644 index 10b0374..0000000 --- a/test/testsend.s +++ /dev/null @@ -1,331 +0,0 @@ -.include "../inc/common.i" -.include "../inc/petscii.i" - - - .import eth_init - .import eth_init - .import eth_rx - .import eth_tx - .import eth_inp - .import eth_inp_len - - .import arp_init - .import arp_lookup - .import arp_process - - .import ip_init - .import ip_process - .import ip_create_packet - .import ip_send - - .import ip_calc_cksum - .import ip_inp - .import ip_outp - .importzp ip_cksum_ptr - .importzp ip_header_cksum - .importzp ip_src - .importzp ip_dest - .importzp ip_data - .importzp ip_len - .importzp ip_id - .importzp ip_proto - - .import icmp_inp - .import icmp_outp - .importzp icmp_type - .importzp icmp_code - .importzp icmp_cksum - .importzp icmp_data - - - .zeropage - -printptr: .res 2 -pptr: .res 2 - - - .bss - -pbtemp: .res 1 -cnt: .res 2 - - - .segment "STARTUP" - - .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 - - - .code - -init: - lda #0 - sta $d021 - - jsr eth_init ; initialize ethernet driver - ldx #0 - bcc :+ - - ldax #failmsg - jmp print - -: ldax #startmsg - jsr print - - jsr arp_init ; initialize arp - - jsr ip_init ; initialize ip and icmp - -@waitpacket: -; call ip_create_packet -; set length -; set ID -; set protocol -; set destination address - ; send ping - jsr ip_create_packet ; create packet template - lda #0 - sta ip_outp + ip_len ; set length - lda #64 - sta ip_outp + ip_len + 1 - lda #$12 - sta ip_outp + ip_id ; set id - lda #$34 - sta ip_outp + ip_id + 1 - lda #$01 - sta ip_outp + ip_proto ; set protocol - ldx #3 -: lda pingdest,x ; set destination - sta ip_outp + ip_dest,x - dex - bpl :- - inc cnt ; increment ping counter - bne :+ - inc cnt + 1 -: - lda #8 - sta icmp_outp + icmp_type - lda #0 - sta icmp_outp + icmp_code - sta icmp_outp + icmp_cksum - sta icmp_outp + icmp_cksum + 1 - lda #$12 - sta icmp_outp + icmp_data - lda #$34 - sta icmp_outp + icmp_data + 1 - lda cnt + 1 - sta icmp_outp + icmp_data + 2 - lda cnt - sta icmp_outp + icmp_data + 3 - ldx #35 -: txa - ora #$20 - sta icmp_outp + icmp_data + 4,x - dex - bpl :- - - ldax #icmp_outp - stax ip_cksum_ptr - ldax #44 - jsr ip_calc_cksum - stax icmp_outp + icmp_cksum - - jsr ip_send - bcc @wait - inc $d020 -@wait: - jsr eth_rx - bcs @wait - - lda eth_inp + 12 - cmp #8 - beq :+ - jmp @waitpacket -: - lda eth_inp + 13 - beq @ip ; ip - cmp #6 ; arp - beq @arp - jmp @waitpacket - -@arp: - ldax #arpmsg - jsr print - ldax eth_inp_len - jsr printint - ldax #bytesmsg - jsr print - - jsr arp_process ; process arp packet - - jmp @dontprint - - ldax #eth_inp - stax pptr - - ldy #petscii_ltred ; dest addr - lda #6 - jsr printbytes - - ldy #petscii_ltgreen ; src addr - lda #6 - jsr printbytes - - ldy #petscii_ltgray ; type - lda #2 - jsr printbytes - - lda #13 - jsr $ffd2 - - ldy #petscii_yellow ; hw, proto, hwlen, protolen, op - lda #8 - jsr printbytes - lda #13 - jsr $ffd2 - - ldy #petscii_cyan - lda #10 - jsr printbytes - lda #13 - jsr $ffd2 - - ldy #petscii_white - lda #10 - jsr printbytes - lda #13 - jsr $ffd2 -@dontprint: - lda #petscii_ltblue - jsr $ffd2 - -@wp: - jmp @waitpacket - -@ip: - lda ip_inp + ip_proto - cmp #1 - bne @wp - - ldax #ipmsg - jsr print - ldax eth_inp_len - jsr printint - ldax #bytesmsg - jsr print - - lda #petscii_white - jsr $ffd2 - lda ip_inp + ip_proto - jsr printhex - - ldax #ip_inp + ip_src - stax pptr - ldy #petscii_ltgreen - lda #4 - jsr printbytes - - ldax #ip_inp + ip_dest - stax pptr - ldy #petscii_ltred - lda #4 - jsr printbytes - - lda #petscii_ltblue - jsr $ffd2 - lda #13 - jsr $ffd2 -; jsr $ffd2 - - jsr ip_process ; handle packet - - jmp @waitpacket - - -printbytes: - sta pbtemp - tya - jsr $ffd2 - ldy #0 -: lda (pptr),y - jsr printhex - iny - cpy pbtemp - bne :- - - lda pbtemp - clc - adc pptr - sta pptr - bcc :+ - inc pptr+1 -: rts - - -print: - sta printptr - stx printptr + 1 - ldy #0 -: lda (printptr),y - beq :+ - jsr $ffd2 - iny - bne :- -: rts - - -printint: - pha - txa - jsr printhex - pla -printhex: - pha - lsr - lsr - lsr - lsr - tax - lda hexdigit,x - jsr $ffd2 - pla - and #$0f - tax - lda hexdigit,x - jsr $ffd2 - rts - - - .data - -hexdigit: - .byte "0123456789ABCDEF" - -startmsg: - .byte 14, "rr-nET INITIALIZED", 13, 0 - -failmsg: - .byte 14, "rr-nET INIT FAILED", 13, 0 - -arpmsg: - .byte "arp PACKET RECEIVED: ",0 - -ipmsg: - .byte "ip PACKET RECEIVED: ",0 - -bytesmsg: - .byte " BYTES", 13, 0 - -pingdest: - .byte 192, 168, 0, 2 diff --git a/test/testtcpsend.s b/test/testtcpsend.s deleted file mode 100644 index 7556ac5..0000000 --- a/test/testtcpsend.s +++ /dev/null @@ -1,158 +0,0 @@ -.include "../inc/common.i" - - .import dbgout16 - - - .import ip65_init - .import ip65_process - - .import tcp_connect - .import tcp_callback - .import tcp_send - .import tcp_close - - .import dhcp_init - .import tcp_inp - .import tcp_outp - - .importzp tcp_data - .importzp tcp_len - .importzp tcp_src_port - .importzp tcp_dest_port - - .import tcp_send_dest - .import tcp_send_src_port - .import tcp_send_dest_port - .import tcp_send_len - - .importzp ip_src - .import ip_inp - - - .zeropage - -pptr: .res 2 - - - .bss - -cnt: .res 1 -replyaddr: .res 4 -replyport: .res 2 -idle = 1 -recv = 2 -resend = 3 - - - .segment "STARTUP" - - .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 - - - .code - -init: - jsr ip65_init - bcc :+ - - ldax #failmsg - jmp print -: - jsr dhcp_init - - bcc :+ - - ldax #failmsg - jmp print - -: -ldax #startmsg - jsr print - - jsr ip65_process - - -send: - ldx #3 -: lda serverip,x ; set destination - sta tcp_send_dest,x - dex - bpl :- - - ldax #3172 ; set source port - stax tcp_send_src_port - - ldax #3172 ; set dest port - stax tcp_send_dest_port - -; ldax #tcp_in -; stax tcp_callback - - jsr tcp_connect -@fixme: - jmp @fixme - - - bcc :+ - ldax #tcpfailmsg - jsr print - rts -: - - ldax #tcpsendend - tcpsendmsg ; set length - stax tcp_send_len - - ldax #tcpsendmsg - jsr tcp_send - - - -rts - - -udp_in: - - rts - - -print: - sta pptr - stx pptr + 1 - ldy #0 -: lda (pptr),y - beq :+ - jsr $ffd2 - iny - bne :- -: rts - - - .rodata - -startmsg: - .byte "INITIATING TCP CONNECTION", 13, 0 - -failmsg: - .byte "RR-NET INIT FAILED", 13, 0 - -tcpfailmsg: - .byte "TCP CONNECT FAILED", 13, 0 - -tcpsendmsg: - .byte "Hello, world!", 13, 10 -tcpsendend: - -serverip: - .byte 10, 5, 1, 1 diff --git a/test/testtimer.s b/test/testtimer.s deleted file mode 100644 index 3416540..0000000 --- a/test/testtimer.s +++ /dev/null @@ -1,108 +0,0 @@ -.include "../inc/common.i" -.include "../inc/petscii.i" - - - .import timer_init - .import timer_read - .import timer_timeout - - - .zeropage - -printptr: .res 2 - - - .bss - -time: .res 2 - - - .segment "STARTUP" - - .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 - - - .code - -init: - jsr timer_init - - lda #petscii_clear - jsr $ffd2 - -@print: - lda #petscii_home - jsr $ffd2 - - jsr timer_read - jsr printint - - lda $c6 - beq @print - - dec $c6 - jsr timer_read - clc - adc #<1000 - sta time - txa - adc #>1000 - sta time + 1 - -: ldax time - jsr timer_timeout - bcs :- - bcc @print - - -print: - sta printptr - stx printptr + 1 - ldy #0 -: lda (printptr),y - beq :+ - jsr $ffd2 - iny - bne :- -: rts - - -printint: - pha - txa - jsr printhex - pla -printhex: - pha - lsr - lsr - lsr - lsr - tax - lda hexdigit,x - jsr $ffd2 - pla - and #$0f - tax - lda hexdigit,x - jsr $ffd2 - rts - - - .data - -hexdigit: - .byte "0123456789ABCDEF" - diff --git a/test/testudp.s b/test/testudp.s deleted file mode 100644 index 90e5db0..0000000 --- a/test/testudp.s +++ /dev/null @@ -1,189 +0,0 @@ -.include "../inc/common.i" -.include "../inc/petscii.i" - - - .import ip65_init - .import ip65_process - - .import ip65_ctr - .import ip65_ctr_arp - .import ip65_ctr_ip - - .import udp_add_listener - .import udp_callback - .import udp_send - - .import udp_inp - .import udp_outp - - .importzp udp_data - .importzp udp_len - .importzp udp_src_port - - .import udp_send_dest - .import udp_send_src_port - .import udp_send_dest_port - .import udp_send_len - - .importzp ip_src - .import ip_inp - - - .zeropage - -pptr: .res 2 - - - .bss - -cnt: .res 1 -replyaddr: .res 4 -replyport: .res 2 -state: .res 1 -idle = 1 -recv = 2 -resend = 3 - - - .segment "STARTUP" - - .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 - - - .code - -init: - jsr ip65_init - bcc :+ - - ldax #failmsg - jmp print - -: ldax #startmsg - jsr print - - lda #idle - sta state - - ldax #udp_in - stax udp_callback - ldax #3172 - jsr udp_add_listener - bcc main - - ldax #udpfailmsg - jsr print - rts - -main: - jsr ip65_process - - lda state - cmp #idle - beq main - cmp #resend - beq @resend - - ldx #3 ; set destination address -: lda replyaddr,x - sta udp_send_dest,x - dex - bpl :- - - ldax #3172 ; set source port - stax udp_send_src_port - - ldax replyport ; set destination port - stax udp_send_dest_port - - ldax #udpsendend - udpsendmsg ; set length - stax udp_send_len - -@resend: - ldax #udpsendmsg ; send datagram - jsr udp_send - bcs :+ - lda #idle - .byte $2c -: lda #resend - sta state - jmp main - - -udp_in: - lda state - cmp #idle - bne @skip - - lda udp_inp + udp_src_port + 1 - sta replyport - lda udp_inp + udp_src_port - sta replyport + 1 - - ldx #3 -: lda ip_inp + ip_src,x - sta replyaddr,x - dex - bpl :- - - lda udp_inp + udp_len + 1 - sec - sbc #8 - sta cnt - ldax #udp_inp + udp_data - stax pptr - ldy #0 -@print: - lda (pptr),y - cmp #10 - bne :+ - lda #13 -: jsr $ffd2 - iny - cpy cnt - bne @print - - lda #recv - sta state -@skip: - rts - - -print: - sta pptr - stx pptr + 1 - ldy #0 -: lda (pptr),y - beq :+ - jsr $ffd2 - iny - bne :- -: rts - - - .data - -startmsg: - .byte petscii_clear, petscii_lower, "LISTENING FOR udp PACKETS ON 3172", 13, 0 - -failmsg: - .byte petscii_lower, "rr-nET INIT FAILED", 13, 0 - -udpfailmsg: - .byte "udp LISTEN FAILED", 13, 0 - -udpsendmsg: - .byte "Message received", 13, 10, 0 -udpsendend: diff --git a/test/testudpsend.s b/test/testudpsend.s deleted file mode 100644 index 2a0fda4..0000000 --- a/test/testudpsend.s +++ /dev/null @@ -1,174 +0,0 @@ -.include "../inc/common.i" -.include "../inc/petscii.i" - - .import dbgout16 - - - .import ip65_init - .import ip65_process - - .import udp_add_listener - .import udp_callback - .import udp_send - - .import udp_inp - .import udp_outp - - .importzp udp_data - .importzp udp_len - .importzp udp_src_port - .importzp udp_dest_port - - .import udp_send_dest - .import udp_send_src_port - .import udp_send_dest_port - .import udp_send_len - - .importzp ip_src - .import ip_inp - - - .zeropage - -pptr: .res 2 - - - .bss - -cnt: .res 1 -replyaddr: .res 4 -replyport: .res 2 -idle = 1 -recv = 2 -resend = 3 - - - .segment "STARTUP" - - .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 - - - .code - -init: - jsr ip65_init - bcc :+ - - ldax #failmsg - jmp print - -: ldax #startmsg - jsr print - - ldax #udp_in - stax udp_callback - ldax #3172 - jsr udp_add_listener - bcc main - - ldax #udpfailmsg - jsr print - rts - -main: - jsr ip65_process - - ;lda $c6 - ;beq main - ;dec $c6 - -send: - ldx #3 -: lda serverip,x ; set destination - sta udp_send_dest,x - dex - bpl :- - - ldax #3172 ; set source port - stax udp_send_src_port - - ldax #3172 ; set dest port - stax udp_send_dest_port - - ldax #udpsendend - udpsendmsg ; set length - stax udp_send_len - - ldax #udpsendmsg - jsr udp_send - - jmp main - - -udp_in: - lda udp_inp + udp_src_port + 1 - sta replyport - lda udp_inp + udp_src_port - sta replyport + 1 - - ldx #3 -: lda ip_inp + ip_src,x - sta replyaddr,x - dex - bpl :- - - lda udp_inp + udp_len + 1 - sec - sbc #8 - sta cnt - ldax #udp_inp + udp_data - stax pptr - ldy #0 -@print: - lda (pptr),y - cmp #10 - bne :+ - lda #13 -: jsr $ffd2 - iny - cpy cnt - bne @print - - rts - - -print: - sta pptr - stx pptr + 1 - ldy #0 -: lda (pptr),y - beq :+ - jsr $ffd2 - iny - bne :- -: rts - - - .rodata - -startmsg: - .byte petscii_clear, petscii_lower, "LISTENING FOR REPLIES ON PORT 3172", 13, 0 - -failmsg: - .byte petscii_lower, "rr-nET INIT FAILED", 13, 0 - -udpfailmsg: - .byte "udp LISTEN FAILED", 13, 0 - -udpsendmsg: - .byte "Hello, world!", 13, 10 -udpsendend: - -serverip: - .byte 192, 168, 0, 2