emailler/client/carts/nb65_skeleton.s
jonnosan 5218deb352 added mozilla public license
git-svn-id: http://svn.code.sf.net/p/netboot65/code@207 93682198-c243-4bdb-bd91-e943c89aac3b
2009-10-22 10:49:08 +00:00

174 lines
3.5 KiB
ArmAsm

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