diff --git a/client/wiznet/Makefile b/client/wiznet/Makefile index 943c05d..ca00765 100644 --- a/client/wiznet/Makefile +++ b/client/wiznet/Makefile @@ -93,5 +93,5 @@ bootc64.prg: # cp wizbobcart.prg ../../server/boot/bootc64.prg # cp telnetd.prg ../../server/boot/bootc64.prg # cp wizboot2.prg ../../server/boot/bootc64.prg -# cp wiztest.prg ../../server/boot/bootc64.prg - cp wizflash.prg ../../server/boot/bootc64.prg \ No newline at end of file + cp wiztest.prg ../../server/boot/bootc64.prg +# cp wizflash.prg ../../server/boot/bootc64.prg \ No newline at end of file diff --git a/client/wiznet/wizboot.s b/client/wiznet/wizboot.s index e16c358..7a71a90 100644 --- a/client/wiznet/wizboot.s +++ b/client/wiznet/wizboot.s @@ -63,8 +63,7 @@ call_downloaded_prg: .word cold_init ;cold start vector .word warm_init ;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 "KIPWBT" .byte $0,$0,$0 ;reserved for future use .byte $0,$0,$0 ;reserved for future use .byte $0,$0,$0 ;reserved for future use diff --git a/client/wiznet/wizflashheader.s b/client/wiznet/wizflashheader.s index 446afc2..a5a7025 100644 --- a/client/wiznet/wizflashheader.s +++ b/client/wiznet/wizflashheader.s @@ -8,7 +8,7 @@ print_a = $ffd2 cart_data_ptr: .res 2 eeprom_ptr: .res 2 pptr: .res 2 - +checksum_ptr: .res 2 .segment "STARTUP" ;this is what gets put at the start of the file on the C64 .word basicstub ; load address @@ -31,6 +31,54 @@ init: jsr print cli + ;check if our data is a KIPPER image (with MAC at offset 0x18) + lda cart_data+9 + cmp #'K' + bne @not_kipper + lda cart_data+10 + cmp #'I' + bne @not_kipper + lda cart_data+11 + cmp #'P' + bne @not_kipper +@loop: + ldax #found_kip + jsr print + lda cart_data+$18 + sta cart_data+$1FF8 + lda cart_data+$19 + sta cart_data+$1FF9 + lda cart_data+$1A + sta cart_data+$1FFA + lda cart_data+$1B + sta cart_data+$1FFB + lda cart_data+$1C + sta cart_data+$1FFC + lda cart_data+$1D + sta cart_data+$1FFD + + lda #0 ;flag byte defaults to 0 + sta cart_data+$1FFE + + ldax #cart_data+$1FF8 + stax checksum_ptr + + clc + ldy #0 + tya +@checksum_loop: + asl + adc (checksum_ptr),y + iny + cpy #7 ;6 byte MAC address plus 1 byte flag + bne @checksum_loop + + sta cart_data+$1FFF + jsr print_hex + jsr print_cr +@not_kipper: + + ldax #$8000 stax eeprom_ptr @@ -58,7 +106,7 @@ init: ldy #0 @reset_1_byte: - lda #$55 + lda #0 sta (eeprom_ptr),y iny cpy #64 @@ -77,6 +125,44 @@ init: cmp #$A0 bne @reset_64_bytes +;now validate the reset + lda #$0 + sta validation_counter + lda old_d011 + sta $d011 + + ldax #validating_reset + jsr print + +@reset_validation_loop: + ldax #$8000 + stax eeprom_ptr + ldy #0 +@reset_compare_loop: + lda (eeprom_ptr),y + bne @reset_validation_error + iny + bne @reset_compare_loop + lda #'.' + jsr print_a + + inc eeprom_ptr+1 + lda eeprom_ptr+1 + cmp #$A0 + bne @reset_compare_loop + beq @reset_ok + @reset_validation_error: + jmp @validation_error + +@reset_ok: + ldax #OK + jsr print + + + lda $d011 + and #$ef ;turn off bit 4 + sta $d011 + ldax #cart_data stax cart_data_ptr @@ -252,13 +338,15 @@ poll_till_stable: ldax eeprom_ptr stax @offset_1+1 stax @offset_2+1 + ldx #$03 @poll_loop: @offset_1: lda $8000 ;address will get overwritten @offset_2: cmp $8000 ;address will get overwritten bne poll_till_stable - + dex + bne @poll_loop @done: rts @@ -317,9 +405,14 @@ validating: .byte 13,"CHECKING EEPROM DATA ",13,0 validation_error: .byte 13,"VALIDATION ERROR : $",0 offset: .byte " OFFSET : $",0 - +OK: .byte 13,"OK",13,0 +validating_reset: .byte "VALIDATING EEPROM RESET",13,0 rd: .byte "RD :",0 wr: .byte "WR :",0 +found_kip: +.byte 13," KIP HEADER FOUND - RELOCATING MAC",13 +.byte " CHECKSUM : $" +.byte 0 .bss cart_data: ;this should point to where the cart data gets appended. .res $2000 diff --git a/client/wiznet/wiztest.s b/client/wiznet/wiztest.s index 82d93b2..f4c69df 100644 --- a/client/wiznet/wiztest.s +++ b/client/wiznet/wiztest.s @@ -16,9 +16,10 @@ TEST_LOOPS=$FF TX_BUFFER_START_PAGE=$40 -TIMER_POSITION_ROW=5 +TIMER_POSITION_ROW=6 TIMER_POSITION_COL=15 TIMER_POSITION=$400+TIMER_POSITION_ROW*40+TIMER_POSITION_COL +LAST_PROMPT_POSITION=$400+15*40+9 ; load A/X macro .macro ldax arg @@ -58,7 +59,6 @@ basicstub: .word 0 init: - ;set funky colours lda #$06 ; @@ -66,36 +66,12 @@ init: lda #$00 ;dark blue sta $D021 ;background - - ldax #banner jsr print lda #0 sta clockport_mode lda $de01 - and #$fe ;turn off clockport - sta $de01 - - lda #$80 ;reset - sta WIZNET_MODE_REG - lda WIZNET_MODE_REG - bne @try_clockport - ;writing a byte to the MODE register with bit 7 set should reset. - ;after a reset, mode register is zero - ;therefore, if there is a real W5100 at the specified address, - ;we should be able to write a $80 and read back a $00 - - lda #$13 ;set indirect mode, with autoinc, no auto PING - sta WIZNET_MODE_REG - lda WIZNET_MODE_REG - cmp #$13 - beq @w5100_found - -@try_clockport: - inc clockport_mode - ;now try with clockport on - lda $de01 ora #1 ;turn on clockport sta $de01 @@ -117,18 +93,18 @@ init: jsr print_hex jsr print_cr - jmp $e37b +; jmp $e37b + jmp @after_mac @reset_ok: - lda #$13 ;set indirect mode, with autoinc, no auto PING + lda #$11 ;set indirect mode, with no autoinc, no auto PING sta WIZNET_MODE_REG lda WIZNET_MODE_REG - cmp #$13 + cmp #$11 bne @error ;make sure if we write to mode register without bit 7 set, ;the value persists. - @w5100_found: ldax #w5100_found @@ -137,16 +113,53 @@ init: jsr print_hex lda #