create a RAM stub (at $C000) that user apps can use to detect presence of a banked out NB65 cart, and a routine to request banking the cart back in

git-svn-id: http://svn.code.sf.net/p/netboot65/code@91 93682198-c243-4bdb-bd91-e943c89aac3b
This commit is contained in:
jonnosan 2009-04-08 10:24:45 +00:00
parent 49510e86b0
commit ae8a98f8a1
3 changed files with 71 additions and 8 deletions

View File

@ -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

View File

@ -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:

View File

@ -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