mirror of
https://github.com/bobbimanners/emailler.git
synced 2024-11-19 12:30:51 +00:00
git-svn-id: http://svn.code.sf.net/p/netboot65/code@188 93682198-c243-4bdb-bd91-e943c89aac3b
This commit is contained in:
parent
ef67996a73
commit
a22aec2890
@ -1,5 +1,6 @@
|
|||||||
CC=cl65
|
CC=cl65
|
||||||
AS=ca65
|
AS=ca65
|
||||||
|
DA=dasm
|
||||||
LD=ld65
|
LD=ld65
|
||||||
CFLAGS=-Oirs -t $(TARGET)
|
CFLAGS=-Oirs -t $(TARGET)
|
||||||
AFLAGS=
|
AFLAGS=
|
||||||
@ -13,7 +14,7 @@ INCFILES=\
|
|||||||
../inc/commonprint.i\
|
../inc/commonprint.i\
|
||||||
../inc/net.i\
|
../inc/net.i\
|
||||||
|
|
||||||
all: upnatom.prg upnatom.d64
|
all: upnatom.prg upnatom.d64 httpd.d64
|
||||||
|
|
||||||
%.o: %.s
|
%.o: %.s
|
||||||
$(AS) $(AFLAGS) $<
|
$(AS) $(AFLAGS) $<
|
||||||
@ -33,6 +34,13 @@ upnatom.d64: upnatom.prg url.cfg
|
|||||||
ripxplore.rb --init CbmDos upnatom.d64 -a autoexec.prg
|
ripxplore.rb --init CbmDos upnatom.d64 -a autoexec.prg
|
||||||
ripxplore.rb upnatom.d64 -a url.cfg -t C64Seq
|
ripxplore.rb upnatom.d64 -a url.cfg -t C64Seq
|
||||||
|
|
||||||
|
httpd.prg: httpd.asm
|
||||||
|
$(DA) httpd.asm -ohttpd.prg
|
||||||
|
|
||||||
|
httpd.d64: httpd.prg url.cfg
|
||||||
|
cp httpd.prg autoexec.prg
|
||||||
|
ripxplore.rb --init CbmDos httpd.d64 -a autoexec.prg
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o *.pg2 *.prg *.map upnatom.d64
|
rm -f *.o *.pg2 *.prg *.map upnatom.d64
|
||||||
|
|
||||||
|
@ -42,6 +42,10 @@
|
|||||||
endm
|
endm
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protocol_http equ $00
|
||||||
|
protocol_gopher equ $01
|
||||||
|
|
||||||
;some routines & zero page variables
|
;some routines & zero page variables
|
||||||
print_a equ $ffd2
|
print_a equ $ffd2
|
||||||
temp_ptr equ $FB ; scratch space in page zero
|
temp_ptr equ $FB ; scratch space in page zero
|
||||||
@ -50,7 +54,9 @@ temp_ptr equ $FB ; scratch space in page zero
|
|||||||
;start of code
|
;start of code
|
||||||
;NO BASIC stub! needs to be direct booted via TFTP
|
;NO BASIC stub! needs to be direct booted via TFTP
|
||||||
org $1000
|
org $1000
|
||||||
|
|
||||||
|
jsr init_tod
|
||||||
|
|
||||||
ldaxi #NB65_CART_SIGNATURE ;where signature should be in cartridge (if cart is banked in)
|
ldaxi #NB65_CART_SIGNATURE ;where signature should be in cartridge (if cart is banked in)
|
||||||
jsr look_for_signature
|
jsr look_for_signature
|
||||||
bcc found_nb65_signature
|
bcc found_nb65_signature
|
||||||
@ -88,6 +94,7 @@ found_nb65_signature
|
|||||||
;print out the current configuration
|
;print out the current configuration
|
||||||
nb65call #NB65_PRINT_IP_CONFIG
|
nb65call #NB65_PRINT_IP_CONFIG
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
listen_on_port_80
|
listen_on_port_80
|
||||||
|
|
||||||
@ -113,27 +120,92 @@ listen_on_port_80
|
|||||||
lda #0
|
lda #0
|
||||||
sta connection_closed
|
sta connection_closed
|
||||||
sta found_eol
|
sta found_eol
|
||||||
|
clc
|
||||||
|
lda $dc09 ;time of day clock: seconds (in BCD)
|
||||||
|
sed
|
||||||
|
adc #$30
|
||||||
|
cmp #$60
|
||||||
|
bcc .timeout_set
|
||||||
|
sec
|
||||||
|
sbc #$60
|
||||||
|
.timeout_set:
|
||||||
|
cld
|
||||||
|
sta connection_timeout_seconds
|
||||||
|
|
||||||
.main_polling_loop
|
.main_polling_loop
|
||||||
jsr NB65_PERIODIC_PROCESSING_VECTOR
|
jsr NB65_PERIODIC_PROCESSING_VECTOR
|
||||||
|
|
||||||
lda found_eol
|
lda found_eol
|
||||||
beq .no_eol_yet
|
bne .got_eol
|
||||||
nb65call #NB65_PRINT_HEX
|
|
||||||
lda #"!"
|
lda $dc09 ;time of day clock: seconds
|
||||||
jsr print_a
|
|
||||||
ldaxi #html_length
|
cmp connection_timeout_seconds
|
||||||
|
beq .connection_timed_out
|
||||||
|
; nb65call #NB65_PRINT_HEX
|
||||||
|
lda connection_closed
|
||||||
|
beq .main_polling_loop
|
||||||
|
jmp listen_on_port_80
|
||||||
|
|
||||||
|
.connection_timed_out:
|
||||||
|
print #timeout
|
||||||
|
jmp listen_on_port_80
|
||||||
|
.got_eol:
|
||||||
|
;if we have a CR, we have got enough of a request to know if it's a HTTP or gopher request
|
||||||
|
lda #"G"
|
||||||
|
cmp scratch_buffer
|
||||||
|
bne .gopher
|
||||||
|
lda #"E"
|
||||||
|
cmp scratch_buffer+1
|
||||||
|
bne .gopher
|
||||||
|
lda #"T"
|
||||||
|
cmp scratch_buffer+2
|
||||||
|
bne .gopher
|
||||||
|
lda #" "
|
||||||
|
cmp scratch_buffer+3
|
||||||
|
bne .gopher
|
||||||
|
lda #protocol_http
|
||||||
|
sta protocol
|
||||||
|
print #http
|
||||||
|
ldx #4
|
||||||
|
jmp .copy_selector
|
||||||
|
.gopher
|
||||||
|
jsr print_a
|
||||||
|
lda #protocol_gopher
|
||||||
|
sta protocol
|
||||||
|
print #gopher
|
||||||
|
ldx #0
|
||||||
|
.copy_selector:
|
||||||
|
lda scratch_buffer,x
|
||||||
|
cmp #"/"
|
||||||
|
bne .copy_one_char
|
||||||
|
inx
|
||||||
|
.copy_one_char
|
||||||
|
lda scratch_buffer,x
|
||||||
|
cmp #$20
|
||||||
|
bcc .last_char_in_selector
|
||||||
|
sta selector,y
|
||||||
|
inx
|
||||||
|
iny
|
||||||
|
bne .copy_one_char
|
||||||
|
|
||||||
|
.last_char_in_selector
|
||||||
|
lda #0
|
||||||
|
sta selector,y
|
||||||
|
|
||||||
|
print #selector
|
||||||
|
|
||||||
|
; ldaxi #html_length
|
||||||
stax nb65_param_buffer+NB65_TCP_PAYLOAD_LENGTH
|
stax nb65_param_buffer+NB65_TCP_PAYLOAD_LENGTH
|
||||||
ldaxi #html
|
; ldaxi #html
|
||||||
stax nb65_param_buffer+NB65_TCP_PAYLOAD_POINTER
|
stax nb65_param_buffer+NB65_TCP_PAYLOAD_POINTER
|
||||||
ldaxi #nb65_param_buffer
|
ldaxi #nb65_param_buffer
|
||||||
nb65call #NB65_SEND_TCP_PACKET
|
nb65call #NB65_SEND_TCP_PACKET
|
||||||
|
|
||||||
nb65call #NB65_TCP_CLOSE_CONNECTION
|
nb65call #NB65_TCP_CLOSE_CONNECTION
|
||||||
|
.start_new_connection
|
||||||
jmp listen_on_port_80
|
jmp listen_on_port_80
|
||||||
.no_eol_yet
|
|
||||||
lda connection_closed
|
|
||||||
beq .main_polling_loop
|
|
||||||
jmp listen_on_port_80
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -178,6 +250,58 @@ reset_after_keypress
|
|||||||
jmp $fce2 ;do a cold start
|
jmp $fce2 ;do a cold start
|
||||||
|
|
||||||
|
|
||||||
|
;init the Time-Of-Day clock - cribbed from http://codebase64.org/doku.php?id=base:initialize_tod_clock_on_all_platforms
|
||||||
|
init_tod:
|
||||||
|
sei
|
||||||
|
lda #0
|
||||||
|
sta $d011 ;Turn off display to disable badlines
|
||||||
|
sta $dc0e ;Set TOD Clock Frequency to 60Hz
|
||||||
|
sta $dc0f ;Enable Set-TOD-Clock
|
||||||
|
sta $dc0b ;Set TOD-Clock to 0 (hours)
|
||||||
|
sta $dc0a ;- (minutes)
|
||||||
|
sta $dc09 ;- (seconds)
|
||||||
|
sta $dc08 ;- (deciseconds)
|
||||||
|
|
||||||
|
lda $dc08 ;
|
||||||
|
.wait_raster
|
||||||
|
cmp $dc08 ;Sync raster to TOD Clock Frequency
|
||||||
|
beq .wait_raster
|
||||||
|
|
||||||
|
ldx #0 ;Prep X and Y for 16 bit
|
||||||
|
ldy #0 ; counter operation
|
||||||
|
lda $dc08 ;Read deciseconds
|
||||||
|
.loop1
|
||||||
|
inx ;2 -+
|
||||||
|
bne .loop2 ;2/3 | Do 16 bit count up on
|
||||||
|
iny ;2 | X(lo) and Y(hi) regs in a
|
||||||
|
jmp .loop3 ;3 | fixed cycle manner
|
||||||
|
.loop2
|
||||||
|
nop ;2 |
|
||||||
|
nop ;2 -+
|
||||||
|
.loop3
|
||||||
|
cmp $dc08 ;4 - Did 1 decisecond pass?
|
||||||
|
beq .loop1 ;3 - If not, loop-di-doop
|
||||||
|
;Each loop = 16 cycles
|
||||||
|
;If less than 118230 cycles passed, TOD is
|
||||||
|
;clocked at 60Hz. If 118230 or more cycles
|
||||||
|
;passed, TOD is clocked at 50Hz.
|
||||||
|
;It might be a good idea to account for a bit
|
||||||
|
;of slack and since every loop is 16 cycles,
|
||||||
|
;28*256 loops = 114688 cycles, which seems to be
|
||||||
|
;acceptable. That means we need to check for
|
||||||
|
;a Y value of 28.
|
||||||
|
|
||||||
|
cpy #28 ;Did 114688 cycles or less go by?
|
||||||
|
bcc .hertz_correct ;- Then we already have correct 60Hz $dc0e value
|
||||||
|
lda #$80 ;Otherwise, we need to set it to 50Hz
|
||||||
|
sta $dc0e
|
||||||
|
.hertz_correct
|
||||||
|
lda #$1b ;Enable the display again
|
||||||
|
sta $d011
|
||||||
|
cli
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
print_errorcode
|
print_errorcode
|
||||||
print #error_code
|
print #error_code
|
||||||
nb65call #NB65_GET_LAST_ERROR
|
nb65call #NB65_GET_LAST_ERROR
|
||||||
@ -200,7 +324,6 @@ http_callback
|
|||||||
|
|
||||||
lda #"*"
|
lda #"*"
|
||||||
jsr print_a
|
jsr print_a
|
||||||
|
|
||||||
ldax nb65_param_buffer+NB65_PAYLOAD_POINTER
|
ldax nb65_param_buffer+NB65_PAYLOAD_POINTER
|
||||||
stax tcp_inbound_data_ptr
|
stax tcp_inbound_data_ptr
|
||||||
ldax nb65_param_buffer+NB65_PAYLOAD_LENGTH
|
ldax nb65_param_buffer+NB65_PAYLOAD_LENGTH
|
||||||
@ -233,7 +356,7 @@ http_callback
|
|||||||
tay
|
tay
|
||||||
sta (temp_ptr),y
|
sta (temp_ptr),y
|
||||||
|
|
||||||
;look for EOL ($0D) in input
|
;look for CR or LF in input
|
||||||
sta found_eol
|
sta found_eol
|
||||||
ldaxi #scratch_buffer
|
ldaxi #scratch_buffer
|
||||||
stax get_next_byte+1
|
stax get_next_byte+1
|
||||||
@ -241,7 +364,7 @@ http_callback
|
|||||||
.look_for_eol
|
.look_for_eol
|
||||||
jsr get_next_byte
|
jsr get_next_byte
|
||||||
cmp #$0a
|
cmp #$0a
|
||||||
bne .found_eol
|
beq .found_eol
|
||||||
cmp #$0d
|
cmp #$0d
|
||||||
bne .not_eol
|
bne .not_eol
|
||||||
.found_eol
|
.found_eol
|
||||||
@ -267,12 +390,11 @@ mode dc.b " MODE",13,0
|
|||||||
disconnected dc.b 13,"CONNECTION CLOSED",13,0
|
disconnected dc.b 13,"CONNECTION CLOSED",13,0
|
||||||
failed dc.b "FAILED ", 0
|
failed dc.b "FAILED ", 0
|
||||||
ok dc.b "OK ", 0
|
ok dc.b "OK ", 0
|
||||||
|
timeout dc.b 13,"CONNECTION TIMEOUT ",13, 0
|
||||||
|
|
||||||
transmission_error dc.b "ERROR WHILE SENDING ",0
|
transmission_error dc.b "ERROR WHILE SENDING ",0
|
||||||
|
http: dc.b "HTTP: ",0
|
||||||
html dc.b "<H1>c64 test page</h1><form method=post>foo:<input type=text name=foo><br>bar:<textarea name=bar></textarea><br><INPUT type=submit value=send>"
|
gopher: dc.b "GOPHER: ",0
|
||||||
html_end
|
|
||||||
html_length equ html_end-html
|
|
||||||
|
|
||||||
;self modifying code
|
;self modifying code
|
||||||
get_next_byte
|
get_next_byte
|
||||||
lda $ffff
|
lda $ffff
|
||||||
@ -284,12 +406,16 @@ get_next_byte
|
|||||||
|
|
||||||
|
|
||||||
;variables
|
;variables
|
||||||
|
protocol ds.b 1
|
||||||
connection_closed ds.b 1
|
connection_closed ds.b 1
|
||||||
|
connection_timeout_seconds ds.b 1
|
||||||
found_eol ds.b 1
|
found_eol ds.b 1
|
||||||
nb65_param_buffer DS.B $20
|
nb65_param_buffer DS.B $20
|
||||||
tcp_buffer_ptr ds.b 2
|
tcp_buffer_ptr ds.b 2
|
||||||
scan_ptr ds.b 2
|
scan_ptr ds.b 2
|
||||||
tcp_inbound_data_ptr ds.b 2
|
tcp_inbound_data_ptr ds.b 2
|
||||||
tcp_inbound_data_length ds.b 2
|
tcp_inbound_data_length ds.b 2
|
||||||
scratch_buffer: DS.B $1000
|
selector: ds.b $100
|
||||||
|
scratch_buffer: ds.b $1000
|
||||||
|
index_html_buffer: ds.b $1000
|
||||||
|
gopher_map_buffer: ds.b $1000
|
||||||
|
@ -55,7 +55,10 @@
|
|||||||
.import eth_outp_len
|
.import eth_outp_len
|
||||||
.import timer_read
|
.import timer_read
|
||||||
.import timer_timeout
|
.import timer_timeout
|
||||||
|
|
||||||
|
.data
|
||||||
|
icmp_cbtmp: jmp $0000 ; temporary vector - address filled in later
|
||||||
|
|
||||||
|
|
||||||
.bss
|
.bss
|
||||||
|
|
||||||
@ -65,7 +68,6 @@ icmp_callback: .res 2
|
|||||||
|
|
||||||
; icmp callbacks
|
; icmp callbacks
|
||||||
icmp_cbmax = 2
|
icmp_cbmax = 2
|
||||||
icmp_cbtmp: .res 3 ; temporary vector
|
|
||||||
icmp_cbveclo: .res icmp_cbmax ; table of listener vectors (lsb)
|
icmp_cbveclo: .res icmp_cbmax ; table of listener vectors (lsb)
|
||||||
icmp_cbvechi: .res icmp_cbmax ; table of listener vectors (msb)
|
icmp_cbvechi: .res icmp_cbmax ; table of listener vectors (msb)
|
||||||
icmp_cbtype: .res icmp_cbmax ; table of listener types
|
icmp_cbtype: .res icmp_cbmax ; table of listener types
|
||||||
@ -118,8 +120,6 @@ ping_state: .res 1
|
|||||||
icmp_init:
|
icmp_init:
|
||||||
lda #0
|
lda #0
|
||||||
sta icmp_cbcount
|
sta icmp_cbcount
|
||||||
lda #$4c ; jmp addr
|
|
||||||
sta icmp_cbtmp
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
;process incoming icmp packet
|
;process incoming icmp packet
|
||||||
|
@ -53,6 +53,9 @@
|
|||||||
.importzp copy_dest
|
.importzp copy_dest
|
||||||
|
|
||||||
.import cfg_ip
|
.import cfg_ip
|
||||||
|
|
||||||
|
.data
|
||||||
|
udp_cbtmp: jmp $ffff ; temporary vector - gets filled in later
|
||||||
|
|
||||||
|
|
||||||
.bss
|
.bss
|
||||||
@ -68,7 +71,6 @@ udp_send_len: .res 2 ;set to length of data to be sent in udp packet (excluding
|
|||||||
|
|
||||||
; udp listener callbacks
|
; udp listener callbacks
|
||||||
udp_cbmax = 4
|
udp_cbmax = 4
|
||||||
udp_cbtmp: .res 3 ; temporary vector
|
|
||||||
udp_cbveclo: .res udp_cbmax ; table of listener vectors (lsb)
|
udp_cbveclo: .res udp_cbmax ; table of listener vectors (lsb)
|
||||||
udp_cbvechi: .res udp_cbmax ; table of listener vectors (msb)
|
udp_cbvechi: .res udp_cbmax ; table of listener vectors (msb)
|
||||||
udp_cbportlo: .res udp_cbmax ; table of ports (lsb)
|
udp_cbportlo: .res udp_cbmax ; table of ports (lsb)
|
||||||
@ -105,8 +107,6 @@ port: .res 2
|
|||||||
udp_init:
|
udp_init:
|
||||||
lda #0
|
lda #0
|
||||||
sta udp_cbcount
|
sta udp_cbcount
|
||||||
lda #$4c ; jmp addr
|
|
||||||
sta udp_cbtmp
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user