diff --git a/client/inc/nb65_constants.i b/client/inc/nb65_constants.i index 9a66ffd..7d4f1ee 100644 --- a/client/inc/nb65_constants.i +++ b/client/inc/nb65_constants.i @@ -2,9 +2,17 @@ NB65_API_VERSION=$0001 -NB65_DISPATCH_VECTOR = $800d -NB65_PERIODIC_PROCESSING_VECTOR =$8010 -NB65_VBL_VECTOR =$8013 +NB65_DISPATCH_VECTOR = $800d +NB65_PERIODIC_PROCESSING_VECTOR = $8010 +NB65_VBL_VECTOR = $8013 + +;offsets in IP packet of various interesting bits: +NB65_IP_SRC = 12 ;offset of "source address" field in an IP packet header +NB65_IP_DEST = 16 ;offset of "destination address" field in an IP packet header +NB65_UDP_SRC_PORT = 20 ;offset of udp source port field in ip packet +NB65_UDP_DEST_PORT = 22 ;offset of udp source port field in ip packet +NB65_UDP_DATA_LENGTH = 24 ;offset of length field in udp packet +NB65_UDP_DATA = 28 ;offset of data in udp packet ;offsets in NB65 configuration structure NB65_CFG_MAC = $00 ;6 byte MAC address @@ -46,7 +54,8 @@ 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_UNHOOK_VBL_IRQ =$0A ;inputs: none, outputs: none (removes call to NB65_VBL_VECTOR on IRQ chain) 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) diff --git a/client/ip65/function_dispatcher.s b/client/ip65/function_dispatcher.s index 3605eca..e8bb143 100644 --- a/client/ip65/function_dispatcher.s +++ b/client/ip65/function_dispatcher.s @@ -23,6 +23,9 @@ .import dns_ip .import dns_resolve .import dns_set_hostname +.import udp_callback +.import udp_add_listener +.import ip_inp .zeropage nb65_params: .res 2 @@ -177,10 +180,19 @@ irq_handler_installed: lda (nb65_params),y tax dey + lda (nb65_params),y + jmp udp_add_listener : + cpy #NB65_GET_INPUT_PACKET_PTR + bne :+ + ldax #ip_inp + clc + rts +: + cpy #NB65_GET_LAST_ERROR bne :+ lda ip65_error @@ -188,6 +200,16 @@ irq_handler_installed: rts : + cpy #NB65_UNHOOK_VBL_IRQ + bne :+ + ldax jmp_old_irq+1 + sei ;don't want any interrupts while we fiddle with the vector + stax $314 ;previous IRQ handler + cli + clc + rts +: + ;default function handler lda #NB65_ERROR_FUNCTION_NOT_SUPPORTED sta ip65_error