diff --git a/client/clients/rrnetboot.s b/client/clients/rrnetboot.s index b8e61fe..5a342db 100644 --- a/client/clients/rrnetboot.s +++ b/client/clients/rrnetboot.s @@ -71,7 +71,7 @@ nb65_param_buffer: .res $20 .word init ;cold start vector .word $FE47 ;warm start vector .byte $C3,$C2,$CD,$38,$30 ; "CBM80" -.byte "NB65" ;netboot 65 signature +.byte $4E,$42,$36,$35 ; "NB65" - API signature jmp nb65_dispatcher ; NB65_DISPATCH_VECTOR : entry point for NB65 functions jmp ip65_process ;NB65_PERIODIC_PROCESSING_VECTOR : routine to be periodically called to check for arrival of ethernet packects jmp timer_vbl_handler ;NB65_VBL_VECTOR : routine to be called during each vertical blank interrupt @@ -104,7 +104,16 @@ init: ldax #__DATA_SIZE__ jsr copymem +;copy the RAM stub to RAM + ldax #nb65_ram_stub + stax copy_src + ldax #NB65_RAM_STUB_SIGNATURE + stax copy_dest + ldax #nb65_ram_stub_length + jsr copymem + + ldax #startup_msg jsr print @@ -340,3 +349,11 @@ no_files_on_server: press_a_key_to_continue: .byte "PRESS A KEY TO CONTINUE",13,0 + +nb65_ram_stub: ; this gets copied to $C000 so programs can bank in the cartridge +.byte $4E,$42,$36,$35 ; "NB65" - API signature + lda #$01 + sta $de00 ;turns on RR cartridge (since it will have been banked out when exiting to BASIC) + rts +nb65_ram_stub_end: +nb65_ram_stub_length=nb65_ram_stub_end-nb65_ram_stub \ No newline at end of file diff --git a/client/inc/nb65_constants.i b/client/inc/nb65_constants.i index a76ef32..5b51f46 100644 --- a/client/inc/nb65_constants.i +++ b/client/inc/nb65_constants.i @@ -2,10 +2,13 @@ NB65_API_VERSION=$0001 + +NB65_CART_SIGNATURE = $8009 NB65_DISPATCH_VECTOR = $800d NB65_PERIODIC_PROCESSING_VECTOR = $8010 NB65_VBL_VECTOR = $8013 - +NB65_RAM_STUB_SIGNATURE = $C000 +NB65_RAM_STUB_ACTIVATE = $C004 ;function numbers ;to make a function call: diff --git a/client/test/test_cart_api.s b/client/test/test_cart_api.s index 57217d8..8a629bd 100644 --- a/client/test/test_cart_api.s +++ b/client/test/test_cart_api.s @@ -63,16 +63,41 @@ basicstub: @nextline: .word 0 + +look_for_signature: ;look for NB65 signature at location pointed at by AX + 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: - lda #$01 - sta $de00 ;turns on RR cartridge (since it will have been banked out when exiting to BASIC) - ldy #NB65_GET_DRIVER_NAME - jsr NB65_DISPATCH_VECTOR + 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 - ldy #NB65_PRINT_ASCIIZ - jsr NB65_DISPATCH_VECTOR +@found_nb65_signature: + call #NB65_GET_DRIVER_NAME + + + call #NB65_PRINT_ASCIIZ print #initializing @@ -216,6 +241,7 @@ udp_callback: bad_boot: print #press_a_key_to_continue +restart: jsr get_key jmp $fce2 ;do a cold start @@ -227,6 +253,17 @@ print_errorcode: print_cr rts +nb65_signature_not_found: + + ldy #0 +: + lda nb65_signature_not_found_message,y + beq restart + jsr print_a + iny + jmp :- + + ;use C64 Kernel ROM function to read a key ;inputs: none ;outputs: A contains ASCII value of key just pressed @@ -277,6 +314,9 @@ failed: ok: .byte "OK ", 0 + nb65_signature_not_found_message: + .byte "NO NB65 API FOUND",13,"PRESS ANY KEY TO RESET", 0 + dns_lookup_failed_msg: .byte "DNS LOOKUP FAILED", 0 @@ -284,3 +324,6 @@ reply_message: .byte "PONG!" reply_message_end: reply_message_length=reply_message_end-reply_message + +nb65_signature: + .byte $4E,$42,$36,$35 ; "NB65" - API signature \ No newline at end of file