2013-12-27 13:57:56 +00:00
; this is some very quick and dirty glue to make the most useful IP65 functions available via a single entry point.
; this allows user applications to be developed that don't link ip65 in directly, rather they use an instance of ip65 that is preloaded (or in a cartridge/ROM)
; 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.
2013-12-13 21:24:03 +00:00
.ifndef KPR_API_VERSION_NUMBER
2013-12-27 13:57:56 +00:00
.define EQU =
2013-12-13 21:24:03 +00:00
.include " . . / inc/ k i p p e r _ c o n s t a n t s . i "
.endif
2013-12-27 13:57:56 +00:00
2013-12-13 21:24:03 +00:00
.include " . . / inc/ c o m m o n . i "
.include " . . / inc/ c o m m o n p r i n t . i "
.export kipper_dispatcher
.import ip65_init
.import dhcp_init
.import cfg_get_configuration_ptr
.import tftp_load_address
.importzp tftp_filename
.import tftp_ip
.import ip65_error
.import tftp_clear_callbacks
.import tftp_download
.import tftp_upload
.import tftp_set_callback_vector
.import tftp_filesize
.import dns_ip
.import dns_resolve
.import dns_set_hostname
.import udp_callback
.import udp_add_listener
.import udp_remove_listener
.import ip_inp
.import udp_inp
.import udp_send
.import udp_send_src
.import udp_send_src_port
.import udp_send_dest
.import udp_send_dest_port
.import udp_send_len
.import copymem
.import cfg_mac
.import cfg_tftp_server
.importzp copy_src
.importzp copy_dest
2013-12-27 13:57:56 +00:00
; reuse the copy_src zero page location
2013-12-13 21:24:03 +00:00
kipper_ p a r a m s = c o p y _ s r c
buffer_ p t r = c o p y _ d e s t
2013-12-27 13:57:56 +00:00
.data
2013-12-13 21:24:03 +00:00
ip_configured_flag :
.byte 0
2013-12-27 13:57:56 +00:00
.code
2013-12-13 21:24:03 +00:00
set_tftp_params :
2013-12-27 13:57:56 +00:00
ldx #$ 03
: lda c f g _ t f t p _ s e r v e r ,x
2013-12-13 21:24:03 +00:00
sta t f t p _ i p ,x
dex
bpl : -
ldy #K P R _ T F T P _ F I L E N A M E
lda ( k i p p e r _ p a r a m s ) ,y
sta t f t p _ f i l e n a m e
iny
lda ( k i p p e r _ p a r a m s ) ,y
sta t f t p _ f i l e n a m e + 1
ldy #K P R _ T F T P _ P O I N T E R
lda ( k i p p e r _ p a r a m s ) ,y
sta t f t p _ l o a d _ a d d r e s s
iny
lda ( k i p p e r _ p a r a m s ) ,y
sta t f t p _ l o a d _ a d d r e s s + 1
2013-12-27 13:57:56 +00:00
2013-12-13 21:24:03 +00:00
jsr t f t p _ c l e a r _ c a l l b a c k s
rts
set_tftp_callback_vector :
ldy #K P R _ T F T P _ P O I N T E R + 1
lda ( k i p p e r _ p a r a m s ) ,y
tax
dey
2013-12-27 13:57:56 +00:00
lda ( k i p p e r _ p a r a m s ) ,y
2013-12-13 21:24:03 +00:00
jmp t f t p _ s e t _ c a l l b a c k _ v e c t o r
2013-12-27 13:57:56 +00:00
2013-12-13 21:24:03 +00:00
kipper_dispatcher :
stax k i p p e r _ p a r a m s
cpy #K P R _ I N I T I A L I Z E
bne : +
lda i p _ c o n f i g u r e d _ f l a g
bne i p _ c o n f i g u r e d
jsr i p65 _ i n i t
bcs i n i t _ f a i l e d
jsr d h c p _ i n i t
bcc d h c p _ o k
2013-12-27 13:57:56 +00:00
jsr i p65 _ i n i t ; if DHCP failed, then reinit the IP stack (which will reset IP address etc that DHCP messed with to cartridge default values)
dhcp_ok :
2013-12-13 21:24:03 +00:00
lda #1
sta i p _ c o n f i g u r e d _ f l a g
clc
2013-12-27 13:57:56 +00:00
init_failed :
2013-12-13 21:24:03 +00:00
rts
2013-12-27 13:57:56 +00:00
2013-12-13 21:24:03 +00:00
ip_configured :
clc
rts
2013-12-27 13:57:56 +00:00
: cpy #K P R _ G E T _ I P _ C O N F I G
2013-12-13 21:24:03 +00:00
bne : +
2013-12-27 13:57:56 +00:00
ldax #c f g _ m a c
2013-12-13 21:24:03 +00:00
clc
rts
2013-12-27 13:57:56 +00:00
: cpy #K P R _ D N S _ R E S O L V E
bne : +
2013-12-13 21:24:03 +00:00
phax
ldy #K P R _ D N S _ H O S T N A M E + 1
lda ( k i p p e r _ p a r a m s ) ,y
tax
dey
lda ( k i p p e r _ p a r a m s ) ,y
2013-12-27 13:57:56 +00:00
jsr d n s _ s e t _ h o s t n a m e
2013-12-13 21:24:03 +00:00
bcs @dns_error
jsr d n s _ r e s o l v e
bcs @dns_error
2013-12-27 13:57:56 +00:00
ldy #K P R _ D N S _ H O S T N A M E _ I P
2013-12-13 21:24:03 +00:00
plax
stax k i p p e r _ p a r a m s
ldx #4
@copy_dns_ip:
lda d n s _ i p ,y
sta ( k i p p e r _ p a r a m s ) ,y
iny
2013-12-27 13:57:56 +00:00
dex
2013-12-13 21:24:03 +00:00
bne @copy_dns_ip
rts
@dns_error:
plax
rts
2013-12-27 13:57:56 +00:00
: cpy #K P R _ U D P _ A D D _ L I S T E N E R
bne : +
2013-12-13 21:24:03 +00:00
ldy #K P R _ U D P _ L I S T E N E R _ C A L L B A C K
lda ( k i p p e r _ p a r a m s ) ,y
sta u d p _ c a l l b a c k
iny
lda ( k i p p e r _ p a r a m s ) ,y
sta u d p _ c a l l b a c k + 1
ldy #K P R _ U D P _ L I S T E N E R _ P O R T + 1
lda ( k i p p e r _ p a r a m s ) ,y
tax
dey
lda ( k i p p e r _ p a r a m s ) ,y
2013-12-27 13:57:56 +00:00
jmp u d p _ a d d _ l i s t e n e r
: cpy #K P R _ G E T _ I N P U T _ P A C K E T _ I N F O
2013-12-13 21:24:03 +00:00
bne : +
ldy #3
2013-12-27 13:57:56 +00:00
@copy_src_ip:
lda i p _ i n p + 1 2 ,y ; src IP
2013-12-13 21:24:03 +00:00
sta ( k i p p e r _ p a r a m s ) ,y
dey
bpl @copy_src_ip
2013-12-27 13:57:56 +00:00
2013-12-13 21:24:03 +00:00
ldy #K P R _ R E M O T E _ P O R T
2013-12-27 13:57:56 +00:00
lda u d p _ i n p + 1 ; src port (lo byte)
2013-12-13 21:24:03 +00:00
sta ( k i p p e r _ p a r a m s ) ,y
iny
2013-12-27 13:57:56 +00:00
lda u d p _ i n p + 0 ; src port (high byte)
2013-12-13 21:24:03 +00:00
sta ( k i p p e r _ p a r a m s ) ,y
iny
2013-12-27 13:57:56 +00:00
lda u d p _ i n p + 3 ; dest port (lo byte)
2013-12-13 21:24:03 +00:00
sta ( k i p p e r _ p a r a m s ) ,y
iny
2013-12-27 13:57:56 +00:00
lda u d p _ i n p + 2 ; dest port (high byte)
2013-12-13 21:24:03 +00:00
sta ( k i p p e r _ p a r a m s ) ,y
iny
sec
2013-12-27 13:57:56 +00:00
lda u d p _ i n p + 5 ; payload length (lo byte)
sbc #8 ; to remove length of header
2013-12-13 21:24:03 +00:00
sta ( k i p p e r _ p a r a m s ) ,y
iny
2013-12-27 13:57:56 +00:00
lda u d p _ i n p + 4 ; payload length (hi byte)
sbc #0 ; in case there was a carry from the lo byte
2013-12-13 21:24:03 +00:00
sta ( k i p p e r _ p a r a m s ) ,y
2013-12-27 13:57:56 +00:00
2013-12-13 21:24:03 +00:00
iny
2013-12-27 13:57:56 +00:00
lda #< ( u d p _ i n p + 8 ) ; payload ptr (lo byte)
2013-12-13 21:24:03 +00:00
sta ( k i p p e r _ p a r a m s ) ,y
iny
2013-12-27 13:57:56 +00:00
lda #> ( u d p _ i n p + 8 ) ; payload ptr (hi byte)
2013-12-13 21:24:03 +00:00
sta ( k i p p e r _ p a r a m s ) ,y
.import tcp_inbound_data_ptr
.import tcp_inbound_data_length
2013-12-27 13:57:56 +00:00
lda i p _ i n p + 9 ; proto number
cmp #6 ; TCP
2013-12-13 21:24:03 +00:00
bne @not_tcp
ldy #K P R _ P A Y L O A D _ L E N G T H
lda t c p _ i n b o u n d _ d a t a _ l e n g t h
sta ( k i p p e r _ p a r a m s ) ,y
iny
lda t c p _ i n b o u n d _ d a t a _ l e n g t h + 1
sta ( k i p p e r _ p a r a m s ) ,y
2013-12-27 13:57:56 +00:00
2013-12-13 21:24:03 +00:00
ldy #K P R _ P A Y L O A D _ P O I N T E R
lda t c p _ i n b o u n d _ d a t a _ p t r
sta ( k i p p e r _ p a r a m s ) ,y
iny
lda t c p _ i n b o u n d _ d a t a _ p t r + 1
sta ( k i p p e r _ p a r a m s ) ,y
@not_tcp:
clc
rts
2013-12-27 13:57:56 +00:00
: cpy #K P R _ S E N D _ U D P _ P A C K E T
2013-12-13 21:24:03 +00:00
bne : +
ldy #3
2013-12-27 13:57:56 +00:00
@copy_dest_ip:
2013-12-13 21:24:03 +00:00
lda ( k i p p e r _ p a r a m s ) ,y
sta u d p _ s e n d _ d e s t ,y
dey
bpl @copy_dest_ip
2013-12-27 13:57:56 +00:00
ldy #K P R _ R E M O T E _ P O R T
2013-12-13 21:24:03 +00:00
lda ( k i p p e r _ p a r a m s ) ,y
sta u d p _ s e n d _ d e s t _ p o r t
iny
lda ( k i p p e r _ p a r a m s ) ,y
sta u d p _ s e n d _ d e s t _ p o r t + 1
iny
lda ( k i p p e r _ p a r a m s ) ,y
sta u d p _ s e n d _ s r c _ p o r t
iny
lda ( k i p p e r _ p a r a m s ) ,y
sta u d p _ s e n d _ s r c _ p o r t + 1
iny
lda ( k i p p e r _ p a r a m s ) ,y
sta u d p _ s e n d _ l e n
iny
lda ( k i p p e r _ p a r a m s ) ,y
sta u d p _ s e n d _ l e n + 1
iny
2013-12-27 13:57:56 +00:00
; AX should point at data to send
2013-12-13 21:24:03 +00:00
lda ( k i p p e r _ p a r a m s ) ,y
pha
iny
2013-12-27 13:57:56 +00:00
lda ( k i p p e r _ p a r a m s ) ,y
2013-12-13 21:24:03 +00:00
tax
pla
jmp u d p _ s e n d
2013-12-27 13:57:56 +00:00
: cpy #K P R _ U D P _ R E M O V E _ L I S T E N E R
2013-12-13 21:24:03 +00:00
bne : +
jmp u d p _ r e m o v e _ l i s t e n e r
2013-12-27 13:57:56 +00:00
: cpy #K P R _ D E A C T I V A T E
; nothing to do now we don't use IRQ
2013-12-13 21:24:03 +00:00
bne : +
clc
rts
2013-12-27 13:57:56 +00:00
: cpy #K P R _ T F T P _ S E T _ S E R V E R
2013-12-13 21:24:03 +00:00
bne : +
ldy #3
2013-12-27 13:57:56 +00:00
@copy_tftp_server_ip:
2013-12-13 21:24:03 +00:00
lda ( k i p p e r _ p a r a m s ) ,y
sta c f g _ t f t p _ s e r v e r ,y
dey
bpl @copy_tftp_server_ip
clc
rts
2013-12-27 13:57:56 +00:00
: cpy #K P R _ T F T P _ D O W N L O A D
2013-12-13 21:24:03 +00:00
bne : +
phax
jsr s e t _ t f t p _ p a r a m s
jsr t f t p _ d o w n l o a d
2013-12-27 13:57:56 +00:00
@after_tftp_call: ; write the current load address back to the param buffer (so if $0000 was passed in, the caller can find out the actual value used)
2013-12-13 21:24:03 +00:00
plax
bcs @tftp_error
stax k i p p e r _ p a r a m s
ldy #K P R _ T F T P _ P O I N T E R
lda t f t p _ l o a d _ a d d r e s s
2013-12-27 13:57:56 +00:00
sta ( k i p p e r _ p a r a m s ) ,y
2013-12-13 21:24:03 +00:00
iny
lda t f t p _ l o a d _ a d d r e s s + 1
sta ( k i p p e r _ p a r a m s ) ,y
ldy #K P R _ T F T P _ F I L E S I Z E
lda t f t p _ f i l e s i z e
2013-12-27 13:57:56 +00:00
sta ( k i p p e r _ p a r a m s ) ,y
2013-12-13 21:24:03 +00:00
iny
lda t f t p _ f i l e s i z e + 1
sta ( k i p p e r _ p a r a m s ) ,y
clc
2013-12-27 13:57:56 +00:00
@tftp_error:
2013-12-13 21:24:03 +00:00
rts
2013-12-27 13:57:56 +00:00
: cpy #K P R _ T F T P _ C A L L B A C K _ D O W N L O A D
2013-12-13 21:24:03 +00:00
bne : +
phax
jsr s e t _ t f t p _ p a r a m s
jsr s e t _ t f t p _ c a l l b a c k _ v e c t o r
jsr t f t p _ d o w n l o a d
jmp @after_tftp_call
2013-12-27 13:57:56 +00:00
: cpy #K P R _ T F T P _ U P L O A D
2013-12-13 21:24:03 +00:00
bne : +
phax
jsr s e t _ t f t p _ p a r a m s
ldy #K P R _ T F T P _ P O I N T E R
lda ( k i p p e r _ p a r a m s ) ,y
sta t f t p _ f i l e s i z e
iny
2013-12-27 13:57:56 +00:00
lda ( k i p p e r _ p a r a m s ) ,y
2013-12-13 21:24:03 +00:00
sta t f t p _ f i l e s i z e + 1
2013-12-27 13:57:56 +00:00
2013-12-13 21:24:03 +00:00
jsr t f t p _ d o w n l o a d
jmp @after_tftp_call
2013-12-27 13:57:56 +00:00
: cpy #K P R _ T F T P _ C A L L B A C K _ U P L O A D
2013-12-13 21:24:03 +00:00
bne : +
jsr s e t _ t f t p _ p a r a m s
jsr s e t _ t f t p _ c a l l b a c k _ v e c t o r
jmp t f t p _ u p l o a d
2013-12-27 13:57:56 +00:00
: cpy #K P R _ P R I N T _ A S C I I Z
2013-12-13 21:24:03 +00:00
bne : +
jsr p r i n t
clc
rts
2013-12-27 13:57:56 +00:00
: cpy #K P R _ P R I N T _ H E X
2013-12-13 21:24:03 +00:00
bne : +
jsr p r i n t _ h e x
clc
rts
2013-12-27 13:57:56 +00:00
: cpy #K P R _ P R I N T _ D O T T E D _ Q U A D
2013-12-13 21:24:03 +00:00
bne : +
jsr p r i n t _ d o t t e d _ q u a d
clc
rts
2013-12-27 13:57:56 +00:00
: cpy #K P R _ P R I N T _ I P _ C O N F I G
2013-12-13 21:24:03 +00:00
bne : +
jsr p r i n t _ i p _ c o n f i g
clc
rts
2013-12-27 13:57:56 +00:00
: cpy #K P R _ P R I N T _ I N T E G E R
2013-12-13 21:24:03 +00:00
bne : +
jsr p r i n t _ i n t e g e r
clc
rts
:
2013-12-27 13:57:56 +00:00
.segment " TCP_ V A R S "
port_number : .res 2
nonzero_octets : .res 1
.code
2013-12-13 21:24:03 +00:00
cpy #K P R _ D O W N L O A D _ R E S O U R C E
2013-12-27 13:57:56 +00:00
bne : +
2013-12-13 21:24:03 +00:00
.import url_download
.import url_download_buffer
.import url_download_buffer_length
ldy #K P R _ U R L _ D O W N L O A D _ B U F F E R
lda ( k i p p e r _ p a r a m s ) ,y
sta u r l _ d o w n l o a d _ b u f f e r
iny
lda ( k i p p e r _ p a r a m s ) ,y
sta u r l _ d o w n l o a d _ b u f f e r + 1
ldy #K P R _ U R L _ D O W N L O A D _ B U F F E R _ L E N G T H
lda ( k i p p e r _ p a r a m s ) ,y
sta u r l _ d o w n l o a d _ b u f f e r _ l e n g t h
iny
lda ( k i p p e r _ p a r a m s ) ,y
sta u r l _ d o w n l o a d _ b u f f e r _ l e n g t h + 1
2013-12-27 13:57:56 +00:00
2013-12-13 21:24:03 +00:00
ldy #K P R _ U R L + 1
lda ( k i p p e r _ p a r a m s ) ,y
tax
dey
lda ( k i p p e r _ p a r a m s ) ,y
jmp u r l _ d o w n l o a d
2013-12-27 13:57:56 +00:00
: cpy #K P R _ F I L E _ L O A D
bne : +
2013-12-13 21:24:03 +00:00
2013-12-27 13:57:56 +00:00
.import io_device_no
2013-12-13 21:24:03 +00:00
.import io_read_file
.import io_filename
.import io_filesize
.import io_load_address
2013-12-27 13:57:56 +00:00
2013-12-13 21:24:03 +00:00
phax
ldy #K P R _ F I L E _ A C C E S S _ F I L E N A M E
lda ( k i p p e r _ p a r a m s ) ,y
sta i o _ f i l e n a m e
iny
lda ( k i p p e r _ p a r a m s ) ,y
sta i o _ f i l e n a m e + 1
ldy #K P R _ F I L E _ A C C E S S _ D E V I C E
lda ( k i p p e r _ p a r a m s ) ,y
sta i o _ d e v i c e _ n o
ldy #K P R _ F I L E _ A C C E S S _ P O I N T E R + 1
lda ( k i p p e r _ p a r a m s ) ,y
tax
dey
lda ( k i p p e r _ p a r a m s ) ,y
jsr i o _ r e a d _ f i l e
plax
bcc @read_file_ok
rts
2013-12-27 13:57:56 +00:00
@read_file_ok:
2013-12-13 21:24:03 +00:00
stax k i p p e r _ p a r a m s
ldy #K P R _ F I L E _ A C C E S S _ P O I N T E R
lda i o _ l o a d _ a d d r e s s
sta ( k i p p e r _ p a r a m s ) ,y
iny
lda i o _ l o a d _ a d d r e s s + 1
sta ( k i p p e r _ p a r a m s ) ,y
ldy #K P R _ F I L E _ A C C E S S _ F I L E S I Z E
lda i o _ f i l e s i z e
sta ( k i p p e r _ p a r a m s ) ,y
iny
lda i o _ f i l e s i z e + 1
sta ( k i p p e r _ p a r a m s ) ,y
rts
2013-12-27 13:57:56 +00:00
: cpy #K P R _ H T T P D _ S T A R T
bne : +
.import httpd_start
2013-12-13 21:24:03 +00:00
jmp h t t p d _ s t a r t
2014-04-13 16:48:11 +00:00
: cpy #K P R _ H T T P D _ G E T _ V A R _ V A L U E
2013-12-27 13:57:56 +00:00
bne : +
2013-12-13 21:24:03 +00:00
2013-12-27 13:57:56 +00:00
.import http_get_value
jmp h t t p _ g e t _ v a l u e
: cpy #K P R _ P I N G _ H O S T
2013-12-13 21:24:03 +00:00
2013-12-27 13:57:56 +00:00
.import icmp_echo_ip
.import icmp_ping
2013-12-13 21:24:03 +00:00
2013-12-27 13:57:56 +00:00
bne : +
2013-12-13 21:24:03 +00:00
ldy #3
@copy_ping_ip_loop:
lda ( k i p p e r _ p a r a m s ) ,y
sta i c m p _ e c h o _ i p ,y
dey
bpl @copy_ping_ip_loop
2013-12-27 13:57:56 +00:00
jmp i c m p _ p i n g
: cpy #K P R _ T C P _ C O N N E C T
bne : +
.import tcp_connect
.import tcp_callback
.import tcp_connect_ip
.import tcp_listen
2013-12-13 21:24:03 +00:00
ldy #3
lda #0
sta n o n z e r o _ o c t e t s
2013-12-27 13:57:56 +00:00
@copy_dest_ip:
2013-12-13 21:24:03 +00:00
lda ( k i p p e r _ p a r a m s ) ,y
beq @octet_was_zero
inc n o n z e r o _ o c t e t s
2013-12-27 13:57:56 +00:00
@octet_was_zero:
2013-12-13 21:24:03 +00:00
sta t c p _ c o n n e c t _ i p ,y
dey
bpl @copy_dest_ip
2013-12-27 13:57:56 +00:00
2013-12-13 21:24:03 +00:00
ldy #K P R _ T C P _ C A L L B A C K
lda ( k i p p e r _ p a r a m s ) ,y
sta t c p _ c a l l b a c k
iny
lda ( k i p p e r _ p a r a m s ) ,y
sta t c p _ c a l l b a c k + 1
2013-12-27 13:57:56 +00:00
2013-12-13 21:24:03 +00:00
ldy #K P R _ T C P _ P O R T + 1
lda ( k i p p e r _ p a r a m s ) ,y
tax
dey
lda ( k i p p e r _ p a r a m s ) ,y
ldy n o n z e r o _ o c t e t s
bne @outbound_tcp_connection
jmp t c p _ l i s t e n
2013-12-27 13:57:56 +00:00
@outbound_tcp_connection:
2013-12-13 21:24:03 +00:00
jmp t c p _ c o n n e c t
2013-12-27 13:57:56 +00:00
.import tcp_send
.import tcp_send_data_len
2013-12-13 21:24:03 +00:00
2013-12-27 13:57:56 +00:00
: cpy #K P R _ S E N D _ T C P _ P A C K E T
2013-12-13 21:24:03 +00:00
bne : +
ldy #K P R _ T C P _ P A Y L O A D _ L E N G T H
lda ( k i p p e r _ p a r a m s ) ,y
sta t c p _ s e n d _ d a t a _ l e n
iny
lda ( k i p p e r _ p a r a m s ) ,y
sta t c p _ s e n d _ d a t a _ l e n + 1
ldy #K P R _ T C P _ P A Y L O A D _ P O I N T E R + 1
lda ( k i p p e r _ p a r a m s ) ,y
tax
dey
lda ( k i p p e r _ p a r a m s ) ,y
jmp t c p _ s e n d
.import tcp_close
2013-12-27 13:57:56 +00:00
: cpy #K P R _ T C P _ C L O S E _ C O N N E C T I O N
2013-12-13 21:24:03 +00:00
bne : +
jmp t c p _ c l o s e
.import filter_dns
.import get_filtered_input
.import filter_number
2013-12-27 13:57:56 +00:00
: cpy #K P R _ I N P U T _ S T R I N G
2013-12-13 21:24:03 +00:00
bne : +
2013-12-27 13:57:56 +00:00
ldy #40 ; max chars
2013-12-13 21:24:03 +00:00
ldax #$ 0000
jmp g e t _ f i l t e r e d _ i n p u t
2013-12-27 13:57:56 +00:00
: cpy #K P R _ I N P U T _ H O S T N A M E
2013-12-13 21:24:03 +00:00
bne : +
2013-12-27 13:57:56 +00:00
ldy #40 ; max chars
2013-12-13 21:24:03 +00:00
ldax #f i l t e r _ d n s
jmp g e t _ f i l t e r e d _ i n p u t
:
cpy #K P R _ I N P U T _ P O R T _ N U M B E R
bne : +
2013-12-27 13:57:56 +00:00
ldy #5 ; max chars
2013-12-13 21:24:03 +00:00
ldax #f i l t e r _ n u m b e r
2013-12-27 13:57:56 +00:00
jsr g e t _ f i l t e r e d _ i n p u t
2013-12-13 21:24:03 +00:00
bcs @no_port_entered
2013-12-27 13:57:56 +00:00
; AX now points a string containing port number
.import parse_integer
2013-12-13 21:24:03 +00:00
jmp p a r s e _ i n t e g e r
2013-12-27 13:57:56 +00:00
2013-12-13 21:24:03 +00:00
@no_port_entered:
rts
2013-12-27 13:57:56 +00:00
: cpy #K P R _ B L O C K _ C O P Y
2013-12-13 21:24:03 +00:00
bne : +
2013-12-27 13:57:56 +00:00
; this is where we pay the price for trying to save a few 'zero page' pointers
; by reusing the 'copy_src' and 'copy_dest' addresses!
2013-12-13 21:24:03 +00:00
.segment " TCP_ V A R S "
2013-12-27 13:57:56 +00:00
tmp_copy_src : .res 2
tmp_copy_dest : .res 2
tmp_copy_length : .res 2
2013-12-13 21:24:03 +00:00
.code
2013-12-27 13:57:56 +00:00
2013-12-13 21:24:03 +00:00
ldy #K P R _ B L O C K _ S R C
lda ( k i p p e r _ p a r a m s ) ,y
sta t m p _ c o p y _ s r c
2013-12-27 13:57:56 +00:00
iny
2013-12-13 21:24:03 +00:00
lda ( k i p p e r _ p a r a m s ) ,y
sta t m p _ c o p y _ s r c + 1
2013-12-27 13:57:56 +00:00
2013-12-13 21:24:03 +00:00
ldy #K P R _ B L O C K _ D E S T
lda ( k i p p e r _ p a r a m s ) ,y
sta t m p _ c o p y _ d e s t
2013-12-27 13:57:56 +00:00
iny
2013-12-13 21:24:03 +00:00
lda ( k i p p e r _ p a r a m s ) ,y
sta t m p _ c o p y _ d e s t + 1
ldy #K P R _ B L O C K _ S I Z E
lda ( k i p p e r _ p a r a m s ) ,y
sta t m p _ c o p y _ l e n g t h
2013-12-27 13:57:56 +00:00
iny
2013-12-13 21:24:03 +00:00
lda ( k i p p e r _ p a r a m s ) ,y
sta t m p _ c o p y _ l e n g t h + 1
ldax t m p _ c o p y _ s r c
2013-12-27 13:57:56 +00:00
stax c o p y _ s r c
2013-12-13 21:24:03 +00:00
ldax t m p _ c o p y _ d e s t
2013-12-27 13:57:56 +00:00
stax c o p y _ d e s t
2013-12-13 21:24:03 +00:00
ldax t m p _ c o p y _ l e n g t h
jmp c o p y m e m
2013-12-27 13:57:56 +00:00
: cpy #K P R _ P A R S E R _ I N I T
2013-12-13 21:24:03 +00:00
bne : +
2013-12-27 13:57:56 +00:00
.import parser_init
2013-12-13 21:24:03 +00:00
2013-12-27 13:57:56 +00:00
jmp p a r s e r _ i n i t
: cpy #K P R _ P A R S E R _ S K I P _ N E X T
bne : +
2013-12-13 21:24:03 +00:00
2013-12-27 13:57:56 +00:00
.import parser_skip_next
2013-12-13 21:24:03 +00:00
2013-12-27 13:57:56 +00:00
jmp p a r s e r _ s k i p _ n e x t
: cpy #K P R _ G E T _ L A S T _ E R R O R
2013-12-13 21:24:03 +00:00
bne : +
lda i p65 _ e r r o r
clc
rts
2013-12-27 13:57:56 +00:00
: ; default function handler
2013-12-13 21:24:03 +00:00
lda #K P R _ E R R O R _ F U N C T I O N _ N O T _ S U P P O R T E D
sta i p65 _ e r r o r
2013-12-27 13:57:56 +00:00
sec ; carry flag set = error
2013-12-13 21:24:03 +00:00
rts
2013-12-27 13:57:56 +00:00
; -- LICENSE FOR function_dispatcher.s --
2013-12-13 21:24:03 +00:00
; 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/
2013-12-27 13:57:56 +00:00
;
2013-12-13 21:24:03 +00:00
; 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.
2013-12-27 13:57:56 +00:00
;
2013-12-13 21:24:03 +00:00
; The Original Code is ip65.
2013-12-27 13:57:56 +00:00
;
2013-12-13 21:24:03 +00:00
; The Initial Developer of the Original Code is Jonno Downes,
; jonno@jamtronix.com.
; Portions created by the Initial Developer are Copyright (C) 2009
2013-12-27 13:57:56 +00:00
; Jonno Downes. All Rights Reserved.
2013-12-13 21:24:03 +00:00
; -- LICENSE END --