mirror of
https://github.com/bobbimanners/emailler.git
synced 2025-01-11 10:29:56 +00:00
added some useful print functions to NB65 API
git-svn-id: http://svn.code.sf.net/p/netboot65/code@85 93682198-c243-4bdb-bd91-e943c89aac3b
This commit is contained in:
parent
c4d3e822ff
commit
5b5469cb13
@ -6,7 +6,7 @@ MEMORY {
|
||||
IP65ZP: start = $5f, size = $10, type = rw, define = yes;
|
||||
HEADER: start = $8000, size = $16, file = %O;
|
||||
ROM: start = $8016, size = $1F00, define = yes, file = %O;
|
||||
RAM: start = $C000, size = $1000, define = yes;
|
||||
RAM: start = $C080, size = $0f80, define = yes;
|
||||
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,8 @@ INCFILES=\
|
||||
../inc/commonprint.i\
|
||||
../inc/net.i\
|
||||
../inc/menu.i\
|
||||
|
||||
../inc/nb65_constants.i\
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
|
||||
|
@ -10,9 +10,21 @@
|
||||
;
|
||||
|
||||
|
||||
.macro print_failed
|
||||
ldax #failed_msg
|
||||
jsr print
|
||||
jsr print_cr
|
||||
.endmacro
|
||||
|
||||
.macro print_ok
|
||||
ldax #ok_msg
|
||||
jsr print
|
||||
jsr print_cr
|
||||
.endmacro
|
||||
|
||||
|
||||
.include "../inc/nb65_constants.i"
|
||||
.include "../inc/common.i"
|
||||
.include "../inc/commonprint.i"
|
||||
.include "../inc/menu.i"
|
||||
.include "../inc/c64keycodes.i"
|
||||
|
||||
@ -23,7 +35,16 @@
|
||||
.import timer_vbl_handler
|
||||
.import nb65_dispatcher
|
||||
.import ip65_process
|
||||
|
||||
|
||||
.import print_hex
|
||||
.import print_ip_config
|
||||
.import dhcp_msg
|
||||
.import ok_msg
|
||||
.import failed_msg
|
||||
.import init_msg
|
||||
.import print_a
|
||||
.import print_cr
|
||||
.import print
|
||||
.import copymem
|
||||
.importzp copy_src
|
||||
.importzp copy_dest
|
||||
@ -43,11 +64,7 @@ jmp_to_downloaded_prg:
|
||||
|
||||
.bss
|
||||
|
||||
nb65_param_buffer: .res $10
|
||||
|
||||
|
||||
|
||||
|
||||
nb65_param_buffer: .res $20
|
||||
|
||||
|
||||
.segment "CARTRIDGE_HEADER"
|
||||
@ -124,7 +141,10 @@ init:
|
||||
|
||||
print_ok
|
||||
|
||||
print_dhcp_init
|
||||
ldax #dhcp_msg
|
||||
jsr print
|
||||
ldax #init_msg
|
||||
jsr print
|
||||
|
||||
ldy #NB65_INIT_DHCP
|
||||
jsr NB65_DISPATCH_VECTOR
|
||||
@ -283,8 +303,9 @@ download: ;AX should point at filename to download
|
||||
|
||||
cfg_get_configuration_ptr:
|
||||
ldy #NB65_GET_IP_CONFIG_PTR
|
||||
ldax #nb65_param_buffer
|
||||
jmp NB65_DISPATCH_VECTOR
|
||||
|
||||
|
||||
.rodata
|
||||
|
||||
startup_msg:
|
||||
|
@ -1,5 +1,13 @@
|
||||
.include "../inc/nb65_constants.i"
|
||||
|
||||
.export print_hex
|
||||
.export print_ip_config
|
||||
.export dhcp_msg
|
||||
.export ok_msg
|
||||
.export failed_msg
|
||||
.export init_msg
|
||||
.export print
|
||||
|
||||
.zeropage
|
||||
pptr: .res 2
|
||||
.bss
|
||||
@ -43,6 +51,29 @@ temp_bcd: .res 2
|
||||
print_ip_config:
|
||||
|
||||
|
||||
ldax #mac_address_msg
|
||||
jsr print
|
||||
jsr cfg_get_configuration_ptr ;ax=base config, carry flag clear
|
||||
;first 6 bytes of cfg_get_configuration_ptr is MAC address
|
||||
stax pptr
|
||||
ldy #0
|
||||
@one_mac_digit:
|
||||
tya ;just to set the Z flag
|
||||
pha
|
||||
beq @dont_print_colon
|
||||
lda #':'
|
||||
jsr print_a
|
||||
@dont_print_colon:
|
||||
pla
|
||||
tay
|
||||
lda (pptr),y
|
||||
jsr print_hex
|
||||
iny
|
||||
cpy #06
|
||||
bne @one_mac_digit
|
||||
|
||||
jsr print_cr
|
||||
|
||||
ldax #ip_address_msg
|
||||
jsr print
|
||||
jsr cfg_get_configuration_ptr ;ax=base config, carry flag clear
|
||||
@ -214,6 +245,9 @@ print_hex:
|
||||
hexdigits:
|
||||
.byte "0123456789ABCDEF"
|
||||
|
||||
mac_address_msg:
|
||||
.byte "MAC ADDRESS: ", 0
|
||||
|
||||
ip_address_msg:
|
||||
.byte "IP ADDRESS: ", 0
|
||||
|
||||
|
@ -35,6 +35,12 @@ NB65_DNS_HOSTNAME_IP= $00 ;4 byte IP address (filled in
|
||||
NB65_UDP_LISTENER_PORT = $00 ;2 byte port number
|
||||
NB65_UDP_LISTENER_CALLBACK = $02 ;2 byte address of routine to call when UDP packet arrives for specified port
|
||||
|
||||
;offsets in UDP packet parameter structure
|
||||
NB65_REMOTE_IP = $00 ;4 byte IP address of remote machine (src of inbound packets, dest of outbound packets)
|
||||
NB65_REMOTE_PORT = $04 ;2 byte port number of remote machine (src of inbound packets, dest of outbound packets)
|
||||
NB65_LOCAL_PORT = $06 ;2 byte port number of local machine (src of outbound packets, dest of inbound packets)
|
||||
NB65_PAYLOAD_LENGTH = $08 ;2 byte length of payload of packet (after all ethernet,IP,UDP headers)
|
||||
NB65_PAYLOAD_POINTER =$0A ;2 byte pointer to payload of packet (after all headers)
|
||||
|
||||
;function numbers
|
||||
;to make a function call:
|
||||
@ -43,9 +49,8 @@ NB65_UDP_LISTENER_CALLBACK = $02 ;2 byte address of routin
|
||||
; then JSR NB65_DISPATCH_VECTOR
|
||||
; on return, carry flag is set if there is an error, or clear otherwise
|
||||
; some functions return results in AX directly, others will update the parameter buffer they were called with.
|
||||
NB65_GET_API_VERSION =$00 ;no inputs, outputs X=major version number, A=minor version number
|
||||
NB65_GET_DRIVER_NAME =$01 ;no inputs, outputs AX=pointer to asciiz driver name
|
||||
NB65_GET_IP_CONFIG_PTR =$02 ;no inputs, outputs AX=pointer to IP configuration structure (which can be modified)
|
||||
NB65_GET_IP_CONFIG_PTR =$02 ;AX=pointer to buffer where IP configuration structure written, outputs AX=points to same buffer, which has now been written to
|
||||
NB65_INIT_IP =$03 ;no inputs or outputs - also sets IRQ chain to call NB65_VBL_VECTOR at @ 60hz
|
||||
NB65_INIT_DHCP =$04 ;no inputs or outputs (NB65_INIT_IP should be called first
|
||||
NB65_TFTP_DIRECTORY_LISTING =$05 ;inputs: AX points to a TFTP parameter structure, outputs: none
|
||||
@ -54,8 +59,15 @@ NB65_TFTP_DOWNLOAD =$06 ;inputs: AX points to a TFTP parameter struct
|
||||
NB65_DNS_RESOLVE_HOSTNAME =$07 ;inputs: AX points to a DNS parameter structure, outputs: DNS param structure updated with
|
||||
;NB65_DNS_HOSTNAME_IP updated with IP address corresponding to hostname.
|
||||
NB65_UDP_ADD_LISTENER =$08 ;inputs: AX points to a UDP listener parameter structure, outputs: none
|
||||
NB65_GET_INPUT_PACKET_PTR =$09 ;inputs: none, outputs: AX contains address of start of IP packet
|
||||
NB65_GET_INPUT_PACKET_INFO =$09 ;inputs: AX points to a UDP packet parameter structure, outputs: UDP packet structure filled in
|
||||
NB65_UNHOOK_VBL_IRQ =$0A ;inputs: none, outputs: none (removes call to NB65_VBL_VECTOR on IRQ chain)
|
||||
|
||||
NB65_PRINT_ASCIIZ =$80 ;inputs: AX= pointer to null terminated string to be printed to screen, outputs: none
|
||||
NB65_PRINT_HEX_DIGIT =$81 ;inputs: A = hex digit to be printed (to screen)
|
||||
NB65_PRINT_DOTTED_QUAD =$82 ;inputs: AX= pointer to 4 bytes that will be displayed as a decimal dotted quad (e.g. 192.168.1.1)
|
||||
NB65_PRINT_IP_CONFIG =$83 ;no inputs, no outputs, prints (to screen) current IP configuration
|
||||
|
||||
|
||||
NB65_GET_LAST_ERROR =$FF ;no inputs, outputs A = error code (from last function that set the global error value, not necessarily the
|
||||
;last function that was called)
|
||||
|
||||
|
@ -3,10 +3,9 @@
|
||||
;this whole file could (and should) be greatly optimised by making it all table driven, but since this file is probably only going to be used in a bankswitched ROM where
|
||||
;space is not at such a premium, I'll go with the gross hack for now.
|
||||
|
||||
|
||||
.include "../inc/nb65_constants.i"
|
||||
.include "../inc/common.i"
|
||||
|
||||
.include "../inc/commonprint.i"
|
||||
.export nb65_dispatcher
|
||||
|
||||
.import ip65_init
|
||||
@ -26,6 +25,12 @@
|
||||
.import udp_callback
|
||||
.import udp_add_listener
|
||||
.import ip_inp
|
||||
|
||||
.import copymem
|
||||
.import cfg_mac
|
||||
.importzp copy_src
|
||||
.importzp copy_dest
|
||||
|
||||
.zeropage
|
||||
nb65_params: .res 2
|
||||
|
||||
@ -78,13 +83,8 @@ set_tftp_params:
|
||||
|
||||
nb65_dispatcher:
|
||||
stax nb65_params
|
||||
cpy #NB65_GET_API_VERSION
|
||||
bne :+
|
||||
ldax #NB65_API_VERSION
|
||||
clc
|
||||
rts
|
||||
:
|
||||
|
||||
|
||||
|
||||
cpy #NB65_GET_DRIVER_NAME
|
||||
bne :+
|
||||
ldax #cs_driver_name
|
||||
@ -94,7 +94,14 @@ nb65_dispatcher:
|
||||
|
||||
cpy #NB65_GET_IP_CONFIG_PTR
|
||||
bne :+
|
||||
jmp cfg_get_configuration_ptr
|
||||
stax copy_dest
|
||||
ldax #cfg_mac
|
||||
stax copy_src
|
||||
ldax #NB65_CFG_DHCP_SERVER+4 ;bytes to copy
|
||||
jsr copymem
|
||||
clc
|
||||
ldax nb65_params
|
||||
rts
|
||||
:
|
||||
|
||||
cpy #NB65_INIT_IP
|
||||
@ -186,19 +193,13 @@ irq_handler_installed:
|
||||
:
|
||||
|
||||
|
||||
cpy #NB65_GET_INPUT_PACKET_PTR
|
||||
cpy #NB65_GET_INPUT_PACKET_INFO
|
||||
bne :+
|
||||
ldax #ip_inp
|
||||
fixme:
|
||||
clc
|
||||
rts
|
||||
:
|
||||
|
||||
cpy #NB65_GET_LAST_ERROR
|
||||
bne :+
|
||||
lda ip65_error
|
||||
clc
|
||||
rts
|
||||
:
|
||||
|
||||
cpy #NB65_UNHOOK_VBL_IRQ
|
||||
bne :+
|
||||
@ -210,6 +211,44 @@ irq_handler_installed:
|
||||
rts
|
||||
:
|
||||
|
||||
cpy #NB65_PRINT_ASCIIZ
|
||||
bne :+
|
||||
jsr print
|
||||
clc
|
||||
rts
|
||||
:
|
||||
|
||||
cpy #NB65_PRINT_HEX_DIGIT
|
||||
bne :+
|
||||
jsr print_hex
|
||||
clc
|
||||
rts
|
||||
:
|
||||
|
||||
cpy #NB65_PRINT_DOTTED_QUAD
|
||||
bne :+
|
||||
jsr print_dotted_quad
|
||||
clc
|
||||
rts
|
||||
:
|
||||
|
||||
cpy #NB65_PRINT_IP_CONFIG
|
||||
bne :+
|
||||
jsr print_ip_config
|
||||
clc
|
||||
rts
|
||||
:
|
||||
|
||||
|
||||
|
||||
cpy #NB65_GET_LAST_ERROR
|
||||
bne :+
|
||||
lda ip65_error
|
||||
clc
|
||||
rts
|
||||
:
|
||||
|
||||
|
||||
;default function handler
|
||||
lda #NB65_ERROR_FUNCTION_NOT_SUPPORTED
|
||||
sta ip65_error
|
||||
|
@ -1,9 +1,28 @@
|
||||
;test the "NETBOOT65 Cartridge API"
|
||||
.include "../inc/nb65_constants.i"
|
||||
.include "../inc/common.i"
|
||||
.include "../inc/commonprint.i"
|
||||
|
||||
|
||||
.import get_key
|
||||
|
||||
; load A/X macro
|
||||
.macro ldax arg
|
||||
.if (.match (.left (1, arg), #)) ; immediate mode
|
||||
lda #<(.right (.tcount (arg)-1, arg))
|
||||
ldx #>(.right (.tcount (arg)-1, arg))
|
||||
.else ; assume absolute or zero page
|
||||
lda arg
|
||||
ldx 1+(arg)
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
; store A/X macro
|
||||
.macro stax arg
|
||||
sta arg
|
||||
stx 1+(arg)
|
||||
.endmacro
|
||||
|
||||
|
||||
print_a = $ffd2
|
||||
|
||||
.bss
|
||||
nb65_param_buffer: .res $10
|
||||
|
||||
@ -14,6 +33,27 @@
|
||||
|
||||
.word basicstub ; load address
|
||||
|
||||
.macro print_failed
|
||||
ldax #failed_msg
|
||||
ldy #NB65_PRINT_ASCIIZ
|
||||
jsr NB65_DISPATCH_VECTOR
|
||||
print_cr
|
||||
.endmacro
|
||||
|
||||
|
||||
.macro print_ok
|
||||
ldax #ok_msg
|
||||
ldy #NB65_PRINT_ASCIIZ
|
||||
jsr NB65_DISPATCH_VECTOR
|
||||
print_cr
|
||||
.endmacro
|
||||
|
||||
.macro print_cr
|
||||
lda #13
|
||||
jsr print_a
|
||||
.endmacro
|
||||
|
||||
|
||||
basicstub:
|
||||
.word @nextline
|
||||
.word 2003
|
||||
@ -31,8 +71,9 @@ init:
|
||||
lda #$01
|
||||
sta $de00 ;turns on RR cartridge (since it will have been banked out when exiting to BASIC)
|
||||
|
||||
jsr print_cr
|
||||
jsr print_ip_config
|
||||
print_cr
|
||||
ldy #NB65_PRINT_IP_CONFIG
|
||||
jsr NB65_DISPATCH_VECTOR
|
||||
|
||||
ldy #NB65_INIT_IP
|
||||
jsr NB65_DISPATCH_VECTOR
|
||||
@ -51,9 +92,11 @@ init:
|
||||
jmp bad_boot
|
||||
:
|
||||
|
||||
jsr print_ip_config
|
||||
ldy #NB65_PRINT_IP_CONFIG
|
||||
jsr NB65_DISPATCH_VECTOR
|
||||
|
||||
|
||||
jmp callback_test
|
||||
;jmp callback_test
|
||||
|
||||
ldax #hostname_1
|
||||
jsr do_dns_query
|
||||
@ -92,7 +135,9 @@ callback_test:
|
||||
:
|
||||
|
||||
ldax #listening
|
||||
jsr print
|
||||
ldy #NB65_PRINT_ASCIIZ
|
||||
jsr NB65_DISPATCH_VECTOR
|
||||
|
||||
@loop_forever:
|
||||
jsr NB65_PERIODIC_PROCESSING_VECTOR
|
||||
jmp @loop_forever
|
||||
@ -101,8 +146,9 @@ callback_test:
|
||||
|
||||
udp_callback:
|
||||
ldax #recv_from
|
||||
jsr print
|
||||
ldy #NB65_GET_INPUT_PACKET_PTR
|
||||
ldy #NB65_PRINT_ASCIIZ
|
||||
jsr NB65_DISPATCH_VECTOR
|
||||
ldy #NB65_GET_INPUT_PACKET_INFO
|
||||
jsr NB65_DISPATCH_VECTOR
|
||||
stax buffer_ptr
|
||||
|
||||
@ -112,51 +158,60 @@ udp_callback:
|
||||
do_dns_query: ;AX points at the hostname on entry
|
||||
stax nb65_param_buffer+NB65_DNS_HOSTNAME
|
||||
|
||||
jsr print
|
||||
|
||||
ldy #NB65_PRINT_ASCIIZ
|
||||
jsr NB65_DISPATCH_VECTOR
|
||||
|
||||
pha
|
||||
jsr print
|
||||
lda #' '
|
||||
jsr print_a
|
||||
lda #':'
|
||||
jsr print_a
|
||||
lda #' '
|
||||
jsr print_a
|
||||
pla
|
||||
ldax #nb65_param_buffer
|
||||
ldy #NB65_DNS_RESOLVE_HOSTNAME
|
||||
jsr NB65_DISPATCH_VECTOR
|
||||
bcc :+
|
||||
ldax #dns_lookup_failed_msg
|
||||
jsr print
|
||||
jsr print_cr
|
||||
ldy #NB65_PRINT_ASCIIZ
|
||||
jsr NB65_DISPATCH_VECTOR
|
||||
print_cr
|
||||
jmp print_errorcode
|
||||
:
|
||||
ldax #nb65_param_buffer+NB65_DNS_HOSTNAME_IP
|
||||
jsr print_dotted_quad
|
||||
jsr print_cr
|
||||
ldy #NB65_PRINT_DOTTED_QUAD
|
||||
jsr NB65_DISPATCH_VECTOR
|
||||
print_cr
|
||||
rts
|
||||
|
||||
bad_boot:
|
||||
ldax #press_a_key_to_continue
|
||||
jsr print
|
||||
ldy #NB65_PRINT_ASCIIZ
|
||||
jsr NB65_DISPATCH_VECTOR
|
||||
jsr get_key
|
||||
jmp $fe66 ;do a wam start
|
||||
|
||||
|
||||
print_errorcode:
|
||||
ldax #error_code
|
||||
jsr print
|
||||
ldy #NB65_PRINT_ASCIIZ
|
||||
jsr NB65_DISPATCH_VECTOR
|
||||
ldy #NB65_GET_LAST_ERROR
|
||||
jsr NB65_DISPATCH_VECTOR
|
||||
jsr print_hex
|
||||
jmp print_cr
|
||||
ldy #NB65_PRINT_HEX_DIGIT
|
||||
jsr NB65_DISPATCH_VECTOR
|
||||
print_cr
|
||||
rts
|
||||
|
||||
cfg_get_configuration_ptr:
|
||||
ldy #NB65_GET_IP_CONFIG_PTR
|
||||
jmp NB65_DISPATCH_VECTOR
|
||||
|
||||
;use C64 Kernel ROM function to read a key
|
||||
;inputs: none
|
||||
;outputs: A contains ASCII value of key just pressed
|
||||
get_key:
|
||||
jsr $ffe4
|
||||
cmp #0
|
||||
beq get_key
|
||||
rts
|
||||
|
||||
.rodata
|
||||
|
||||
buffer1: .res 256
|
||||
@ -191,3 +246,12 @@ error_code:
|
||||
.asciiz "ERROR CODE: "
|
||||
press_a_key_to_continue:
|
||||
.byte "PRESS A KEY TO CONTINUE",13,0
|
||||
|
||||
failed_msg:
|
||||
.byte "FAILED", 0
|
||||
|
||||
ok_msg:
|
||||
.byte "OK", 0
|
||||
|
||||
dns_lookup_failed_msg:
|
||||
.byte "DNS LOOKUP FAILED", 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user