git-svn-id: http://svn.code.sf.net/p/netboot65/code@287 93682198-c243-4bdb-bd91-e943c89aac3b

This commit is contained in:
jonnosan 2010-11-06 21:11:27 +00:00
parent 8faf470f47
commit b37e2a2e03
11 changed files with 274 additions and 138 deletions

View File

@ -17,8 +17,10 @@ IP65LIB=../ip65/ip65_tcp.lib
C64PROGLIB=../drivers/c64prog.lib C64PROGLIB=../drivers/c64prog.lib
all: kipperbas.d64 bails.d64 all: ip65 kipperbas.d64 bails.d64
ip65:
make -C ../ip65 all
%.o: %.s $(INCFILES) %.o: %.s $(INCFILES)
$(AS) $(AFLAGS) $< $(AS) $(AFLAGS) $<

Binary file not shown.

Binary file not shown.

View File

@ -25,7 +25,7 @@ IERROR = $0300
ICRUNCH = $0304 ;Crunch ASCII into token ICRUNCH = $0304 ;Crunch ASCII into token
IQPLOP = $0306 ;List IQPLOP = $0306 ;List
IGONE = $0308 ;Execute next BASIC token IGONE = $0308 ;Execute next BASIC token
IEVAL = $30A ; evaluate expression
CHRGET = $73 CHRGET = $73
CHRGOT = $79 CHRGOT = $79
CHROUT = $FFD2 CHROUT = $FFD2
@ -171,14 +171,14 @@ FS=$8000-main_start
ldax #welcome_banner ldax #welcome_banner
jsr print jsr print
ldx #5 ;Copy CURRENT vectors ldx #7 ;Copy CURRENT vectors
@copy_old_vectors_loop: @copy_old_vectors_loop:
lda ICRUNCH,x lda ICRUNCH,x
sta oldcrunch,x sta oldcrunch,x
dex dex
bpl @copy_old_vectors_loop bpl @copy_old_vectors_loop
ldx #5 ;Copy CURRENT vectors ldx #7 ;Copy CURRENT vectors
install_new_vectors_loop: install_new_vectors_loop:
lda vectors,x lda vectors,x
sta ICRUNCH,x sta ICRUNCH,x
@ -592,8 +592,11 @@ print:
extract_string: extract_string:
jsr FRMEVL jsr FRMEVL
jsr FRESTR ;if not string, will create type mismatch error jsr FRESTR ;if not string, will create type mismatch error
sta param_length sta param_length
tay tay
lda #0 lda #0
@ -827,7 +830,10 @@ ping_keyword:
lda $cb ;current key pressed lda $cb ;current key pressed
cmp #$3F ;RUN/STOP? cmp #$3F ;RUN/STOP?
beq @done beq @done
lda ping_counter
beq @ping_loop
dec ping_counter dec ping_counter
cmp #1
bne @ping_loop bne @ping_loop
@done: @done:
jsr print_cr jsr print_cr
@ -1087,12 +1093,15 @@ make_tcp_connection:
rts rts
netcat_keyword: netcat_keyword:
lda $CC
sta cursor_state
lda #$0
sta $CC ;enable blinking cursor
ldax #netcat_callback ldax #netcat_callback
stax tcp_callback stax tcp_callback
jsr make_tcp_connection jsr make_tcp_connection
bcc :+ bcs @exit
rts
:
;is there an optional parameter? ;is there an optional parameter?
ldx #0 ldx #0
jsr get_optional_byte jsr get_optional_byte
@ -1113,8 +1122,12 @@ netcat_keyword:
jsr ip65_process jsr ip65_process
lda connection_state lda connection_state
bne @not_disconnected bne @not_disconnected
@disconnected:
ldax #disconnected ldax #disconnected
jsr print jsr print
@exit:
lda cursor_state
sta $CC
rts rts
@not_disconnected: @not_disconnected:
@ -1131,11 +1144,8 @@ netcat_keyword:
beq @runstop beq @runstop
jsr ip65_process jsr ip65_process
lda connection_state lda connection_state
bne :+ beq @disconnected
ldax #disconnected
jsr print
rts
:
jsr $f142 ;not officially documented - where F13E (GETIN) falls through to if device # is 0 (KEYBD) jsr $f142 ;not officially documented - where F13E (GETIN) falls through to if device # is 0 (KEYBD)
beq @read_line beq @read_line
@ -1180,6 +1190,7 @@ netcat_keyword:
jmp @read_line jmp @read_line
@input_done: @input_done:
jsr reset_cursor
lda #$0d lda #$0d
jsr $ffd2 ;print a newline jsr $ffd2 ;print a newline
ldy string_length ldy string_length
@ -1208,6 +1219,9 @@ netcat_keyword:
@runstop: @runstop:
lda #0 lda #0
sta $cb ;overwrite "current key pressed" else it's seen by the tcp stack and the close aborts sta $cb ;overwrite "current key pressed" else it's seen by the tcp stack and the close aborts
lda cursor_state
sta $CC
jmp tcp_close jmp tcp_close
@not_runstop: @not_runstop:
jsr $ffe4 ;getkey - 0 means no input jsr $ffe4 ;getkey - 0 means no input
@ -1227,12 +1241,24 @@ netcat_keyword:
jmp @main_polling_loop jmp @main_polling_loop
@error_on_send: @error_on_send:
lda cursor_state
sta $CC
ldax #transmission ldax #transmission
jmp print_error jmp print_error
reset_cursor:
lda $cf ;0 means last cursor blink set char to be reversed
beq @done
lda $ce ;original value of cursor char
ldx $287 ;original colour
ldy #$0 ;blink phase
sty $cf
jsr $ea13 ;restore char & colour
@done:
rts
netcat_callback: netcat_callback:
jsr reset_cursor
lda tcp_inbound_data_length+1 lda tcp_inbound_data_length+1
cmp #$ff cmp #$ff
bne @not_eof bne @not_eof
@ -1430,14 +1456,42 @@ tcpblat_keyword:
lda #KPR_ERROR_FILE_ACCESS_FAILURE lda #KPR_ERROR_FILE_ACCESS_FAILURE
jmp @store_error jmp @store_error
evaluate:
lda $00
sta $0D ;set string flag to not string
jsr CHRGET
cmp #$E3 ; PING keyword
bne @done
jsr CHRGET ;take PING command off stack
ldax #icmp_echo_ip
jsr get_ip_parameter
lda #$00
sta $0D ;set string flag to not string
bcs @error
jsr icmp_ping
bcc @no_error
@error:
lda #$ff
tax
@no_error:
tay
txa
jmp $b395 ;signed 16 bit number to floating point
rts
@done:
jsr CHRGOT
jmp $AE8D ;inside original EVAL routine
.rodata .rodata
vectors: vectors:
.word crunch .word crunch
.word list .word list
.word execute .word execute
.word evaluate
; Keyword list ; Keyword list
; Keywords are stored as normal text, ; Keywords are stored as normal text,
; followed by the token number. ; followed by the token number.
@ -1553,7 +1607,7 @@ jmp_crunch: .byte $4C ;JMP
oldcrunch: .res 2 ;Old CRUNCH vector oldcrunch: .res 2 ;Old CRUNCH vector
oldlist: .res 2 oldlist: .res 2
oldexec: .res 2 oldexec: .res 2
oldeval: .res 2
emit_a: emit_a:
current_output_ptr=emit_a+1 current_output_ptr=emit_a+1
sta $ffff sta $ffff
@ -1565,7 +1619,6 @@ current_output_ptr=emit_a+1
rts rts
.bss .bss
netcat_mode: .res 1 netcat_mode: .res 1
bytes_read: .res 2 bytes_read: .res 2
@ -1584,4 +1637,4 @@ file_opened: .res 1
connection_state: .res 1 connection_state: .res 1
netcat_timeout: .res 1 netcat_timeout: .res 1
buffer_length: .res 2 buffer_length: .res 2
cursor_state: .res 1

View File

@ -1 +1 @@
**** KIPPER BASIC 1.0 **** **** KIPPER BASIC 1.1 ****

View File

@ -1 +1 @@
.byte "1.0.31" .byte "1.0.35"

View File

@ -2,7 +2,7 @@
MEMORY { MEMORY {
IP65ZP: start = $A3, size = $12, type = rw; IP65ZP: start = $A3, size = $12, type = rw;
STARTRAM: start = $07FF, size = $4000, file = %O; STARTRAM: start = $07FF, size = $4000, file = %O;
UNDERBASIC: start = $A000, size = $2000, define = yes, file = %O; UNDERBASIC: start = $9000, size = $3000, define = yes, file = %O;
HIRAM: start = $C000, size = $01000; HIRAM: start = $C000, size = $01000;
} }
@ -12,6 +12,7 @@ MEMORY {
IP65ZP: load = IP65ZP, type = zp; IP65ZP: load = IP65ZP, type = zp;
ZEROPAGE: load = IP65ZP, type = zp; ZEROPAGE: load = IP65ZP, type = zp;
STARTUP: load = STARTRAM, type = rw; STARTUP: load = STARTRAM, type = rw;
TCP_VARS: load = UNDERBASIC, type = bss;
CODE: load = STARTRAM, run=UNDERBASIC, type = ro,define = yes; CODE: load = STARTRAM, run=UNDERBASIC, type = ro,define = yes;
RODATA: load = STARTRAM, run=UNDERBASIC, type = ro,define = yes; RODATA: load = STARTRAM, run=UNDERBASIC, type = ro,define = yes;
DATA: load = STARTRAM, run=UNDERBASIC, type = rw, define = yes; DATA: load = STARTRAM, run=UNDERBASIC, type = rw, define = yes;
@ -19,6 +20,5 @@ MEMORY {
CODESTUB: load STARTRAM, run= HIRAM, type = rw, define = yes; CODESTUB: load STARTRAM, run= HIRAM, type = rw, define = yes;
BSS: load = HIRAM, type = bss; BSS: load = HIRAM, type = bss;
TCP_VARS: load = UNDERBASIC, type = bss;
} }

Binary file not shown.

View File

@ -81,6 +81,9 @@ basicstub:
.word 0 .word 0
relocate: relocate:
ldax #$9000
stax $37; MEMSIZ
jsr $A65E ;do a CLR
;relocate everything ;relocate everything
ldax #__CODE_LOAD__ ldax #__CODE_LOAD__
@ -101,7 +104,7 @@ relocate:
@installed_msg: .byte "V1541 INSTALLED",0 @installed_msg: .byte "V1541 INSTALLED",0
@already_installed_msg: .byte "V1541 ALREADY INSTALLED",0 @already_installed_msg: .byte "V1541 ALREADY INSTALLED",0
@not_installed: @not_installed:
ldax #__DATA_LOAD__ ldax #__DATA_LOAD__
stax copy_src stax copy_src
@ -217,14 +220,13 @@ ldax #irq_handler
sei sei
stax CINV stax CINV
; jsr install_wedge
@done: @done:
jsr swap_basic_in jsr swap_basic_in
lda #0 lda #0
sta $dc08 ;make sure TOD clock is started sta $dc08 ;make sure TOD clock is started
cli cli
rts
rts
__copymem: __copymem:
sta end sta end
@ -273,69 +275,14 @@ __print:
@done_print: @done_print:
rts rts
install_wedge:
ldax #wedge_start
stax copy_src
sec
lda MEMSIZ
sbc #<wedge_length
sta MEMSIZ
sta copy_dest
sta IERROR
lda MEMSIZ+1
sbc #>wedge_length
sta MEMSIZ+1
sta copy_dest+1
sta IERROR+1
ldax #wedge_length
jsr __copymem
jmp $a644 ;NEW
wedge_start:
;new error handler
cpx #$0b ; is it a SYNTAX ERROR?
beq @syntax_error; yes, jump to command test
@exit:
jmp $e38b ;nope, normal error handler
@syntax_error:
jsr CHRGOT ;read current character in buffer again
bcc @exit
cmp #$b1 ;is current character a > token?
bne @exit ;nope, normal error handler
@got_it:
ldy #0
lda #'>'
sta (TXTPTR),y ;replace token with > symbol again
@scan_command:
lda (TXTPTR),y ;
beq @end_of_command
cmp #':'
beq @end_of_command
iny
bne @scan_command
@end_of_command:
sty FNLEN ;file name length
lda TXTPTR ;start of filename
sta FNADDR
lda TXTPTR+1 ;start of filename
sta FNADDR+1
lda #$2
sta $BA ;current device number
;jmp (ILOAD)
jsr load_handler
jmp $A474 ;READY prompt
wedge_length=*-wedge_start
.code .code
load_dev_2: load_dev_2:
ldy #$00 ldy #$00
sty receive_type ;0 = display to screen, 1 = load to memory
sty buffer_length
sty buffer_length+1
lda (FNADDR),y lda (FNADDR),y
cmp #'!' cmp #'!'
beq @do_disks beq @do_disks
@ -343,8 +290,26 @@ load_dev_2:
beq @do_command beq @do_command
cmp #'#' cmp #'#'
beq @do_insert beq @do_insert
cmp #'='
beq @do_find
cmp #'/'
bne @not_cf
lda FNLEN
cmp #1
bne @do_cf
ldax #cmd_cf_root
jmp @send_string_receive_response
@not_cf:
cmp #'%'
beq @do_name
cmp #'$'
beq @do_cat
inc receive_type
ldax #cmd_load
jmp @copy_prefix
@done: @done:
clc clc
jmp swap_basic_in jmp swap_basic_in
@ -356,7 +321,6 @@ load_dev_2:
dey dey
bne @copy_cmd bne @copy_cmd
ldy FNLEN ldy FNLEN
lda #$0D lda #$0D
sta cmd_buffer-1,y sta cmd_buffer-1,y
@ -364,29 +328,57 @@ load_dev_2:
sta cmd_buffer,y sta cmd_buffer,y
@send_command_buffer: @send_command_buffer:
ldax #cmd_buffer ldax #cmd_buffer
jmp @send_string_show_list jmp @send_string_receive_response
@do_name:
ldax #cmd_name
jmp @send_string_receive_response
@do_find:
ldax #cmd_find
jmp @copy_prefix
@do_cat:
ldax #cmd_cat
jmp @send_string_receive_response
@do_disks: @do_disks:
ldax #@cmd_dsks ldax #cmd_dsks
@send_string_show_list: @send_string_receive_response:
jsr tcp_send_string jsr tcp_send_string
bcs @error bcs @error
jsr show_list lda receive_type
bne @load_file
jsr show_list
jmp @done jmp @done
@load_file:
jsr receive_file
jmp @done
@do_cf:
ldax #cmd_cf
jmp @copy_prefix
@cmd_dsks: .byte "DISKS 22",$0d,$0
@do_insert: @do_insert:
ldax #cmd_insert
ldx #0 @copy_prefix:
@copy_insert: stax copy_src
lda @cmd_insert,x ldy #0
beq @end_insert @copy_prefix_loop:
sta cmd_buffer,x lda (copy_src),y
inx beq @end_copy_prefix
bne @copy_insert sta cmd_buffer,y
@end_insert: iny
bne @copy_prefix_loop
@end_copy_prefix:
tya
tax
ldy #1 ldy #1
lda receive_type
beq :+
dey ;if this is a LOAD command, don't skip the first byte
: :
lda (FNADDR),y lda (FNADDR),y
sta cmd_buffer,x sta cmd_buffer,x
@ -402,22 +394,18 @@ load_dev_2:
sta cmd_buffer+1,x sta cmd_buffer+1,x
jmp @send_command_buffer jmp @send_command_buffer
@cmd_insert: .byte "INSERT ",0
@error: @error:
ldax #SERVER_PORT
jsr tcp_connect
ldax #transmission_error ldax #transmission_error
jsr print jsr print
lda ip65_error
jsr print_hex
lda tcp_state
jsr print_hex
jmp @done jmp @done
show_list: show_list:
@loop: @loop:
lda $91 ; look for STOP key lda $91 ; look for STOP key
cmp #$7F cmp #$7F
@ -427,6 +415,7 @@ show_list:
bcc @got_data bcc @got_data
rts rts
@got_data: @got_data:
cmp #$03 ;ETX byte (indicating end of page)? cmp #$03 ;ETX byte (indicating end of page)?
beq @get_user_input beq @get_user_input
cmp #$04 ;EOT byte (indicating end of list)? cmp #$04 ;EOT byte (indicating end of list)?
@ -436,6 +425,7 @@ show_list:
;End of page, so ask for user input ;End of page, so ask for user input
@get_user_input: @get_user_input:
jsr get_key jsr get_key
cmp #'S' cmp #'S'
@ -552,28 +542,9 @@ next_char:
sta buffer_length+1 sta buffer_length+1
pla pla
clc clc
rts rts
print_hex:
pha
pha
lsr
lsr
lsr
lsr
tax
lda hexdigits,x
jsr print_a
pla
and #$0F
tax
lda hexdigits,x
jsr print_a
pla
rts
hexdigits:
.byte "0123456789ABCDEF"
tcp_irq_handler: tcp_irq_handler:
inc keep_alive_counter inc keep_alive_counter
@ -585,8 +556,98 @@ tcp_irq_handler:
@done: @done:
rts rts
receive_file:
lda #0
sta byte_count
@loop:
lda $91 ; look for STOP key
cmp #$7F
beq @done
lda #2 ;wait for max 2 seconds
jsr getc
bcc @got_data
@done:
rts
@got_data:
ldy byte_count
sta file_length,y
inc byte_count
lda byte_count
cmp #4
bne @loop
;is the first 4 bytes "500 "
;
lda file_length+1
cmp #'0' ;if 2nd char was '0' this might be an ASCII error message
bne @real_file_transmission
lda file_location
cmp #$01
beq @real_file_transmission
;this was probably an ASCII error message
lda #0
sta byte_count
:
ldy byte_count
lda file_length,y
jsr print_a
inc byte_count
lda byte_count
cmp #4
bne :-
jmp show_list
@real_file_transmission:
ldax file_location
stax copy_dest
lda file_length
sec
sbc #2
sta file_length
lda file_length+1
sbc #0
sta file_length+1
@rx_loop:
lda file_length+1
bne @not_done
lda file_length
bne @not_done
;file now fully in RAM, time for housekeeping
sta $297 ;RS-232 status = 0 (no error)
sta $90 ;status = 0 (no error)
ldy copy_dest+1 ;high byte of end of loaded program
ldx copy_dest ;lo byte of end of loaded program
inx
bne :+
iny ;if X rolled over, bump y
:
rts ;done!
@not_done:
lda #2 ;wait for max 2 seconds
jsr getc
bcs @rx_error
ldy #0
sta (copy_dest),y
inc copy_dest
bne :+
inc copy_dest+1
:
lda file_length
bne :+
dec file_length+1
lda #'.'
jsr print_a
:
dec file_length
jmp @rx_loop
@rx_error:
ldax #receive_error
jmp print
.segment "CODESTUB" .segment "CODESTUB"
@ -605,6 +666,8 @@ swap_basic_in:
sta underneath_basic sta underneath_basic
rts rts
underneath_basic: .res 1
load_handler: load_handler:
ldx $BA ; Current Device Number ldx $BA ; Current Device Number
cpx #$02 cpx #$02
@ -617,7 +680,8 @@ old_load_vector:
jmp load_dev_2 jmp load_dev_2
irq_handler: irq_handler:
lda underneath_basic
lda underneath_basic
bne @done bne @done
jsr swap_basic_out jsr swap_basic_out
jsr tcp_irq_handler jsr tcp_irq_handler
@ -627,22 +691,39 @@ irq_handler:
old_irq_vector: old_irq_vector:
.word $ffff .word $ffff
underneath_basic: .res 1
.data
cmd_dsks: .byte "DISKS 22",$0d,$0
cmd_insert: .byte "INSERT ",0
cmd_cat: .byte "$",$0d,$00
cmd_find: .byte "FIND ",$00
cmd_name: .byte "NAME",$0d,$00
cmd_cf: .byte "CF ",0
cmd_load: .byte "LOAD ",0
cmd_cf_root: .byte "CF /",$0d,0
transmission_error: .byte "TRANSMIT ERROR",13,0
receive_error: .byte "RECEIVE ERROR",13,0
.segment "TCP_VARS" .segment "TCP_VARS"
csip_stream_buffer: .res 1400 csip_stream_buffer: .res 1500
cmd_buffer: .res 100 cmd_buffer: .res 100
.bss
user_abort: .res 1 user_abort: .res 1
getc_timeout_end: .res 1 getc_timeout_end: .res 1
getc_timeout_seconds: .res 1 getc_timeout_seconds: .res 1
buffer_length: .res 2 buffer_length: .res 2
keep_alive_counter: .res 1 keep_alive_counter: .res 1
file_length: .res 2
file_location: .res 2
rx_length: .res 2
receive_type: .res 1
byte_count: .res 1
.data .data
continue_cmd: .byte $0D,0 continue_cmd: .byte $0D,0
stop_cmd: .byte "S",0 stop_cmd: .byte "S",0
transmission_error: .byte "TRANSMISSION ERROR",13,0
;-- LICENSE FOR v1541.s -- ;-- LICENSE FOR v1541.s --
; The contents of this file are subject to the Mozilla Public License ; The contents of this file are subject to the Mozilla Public License

View File

@ -1 +1 @@
1.0.31 1.0.35

View File

@ -1,5 +1,5 @@
v1.0.33 v1.0.33
- FIX: gracefully close the TCP connection when a telnet connection is aborted by user keystroke - FIX: gracefully close the TCP connection when a telnet connection is aborted by user keystroke
- FIX: telnet client was reprocessing last received packet after an error (including user abort) - FIX: telnet client was reprocessing last received packet after an error (including user abort)
- FIX: was not signalling an error when a RST or FIN was sent back to tcp_connect - FIX: was not signalling an error when a RST or FIN was sent back to tcp_connect