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

This commit is contained in:
jonnosan 2009-08-09 06:25:36 +00:00
parent 520b1769e9
commit b1673c8145
12 changed files with 319 additions and 199 deletions

View File

@ -13,6 +13,10 @@
.export io_track_no
.export io_read_sector
.export io_read_file_with_callback
.export io_filename
.export io_callback
.importzp copy_src
.import ip65_error
.import output_buffer
@ -38,29 +42,133 @@ SETLFS = $ffba
io_track_no: .res 2
io_sector_no: .res 1
io_device_no: .res 1
io_filename: .res 2
error_buffer = output_buffer + 256
command_buffer = error_buffer+128
sector_buffer_address: .res 2
buffer_counter: .res 1
.data
drive_id: .byte 08 ;default to drive 8
jmp_to_callback:
jmp $ffff
io_callback=jmp_to_callback+1
.code
; init
; jsr CLALL
;close
; lda #15 ; filenumber 15 - command channel
; jsr CLOSE
;routine to read a file with a callback after each 256 byte sector
; inputs:
; io_device_number - specifies drive to use ($00 = same as last time, $01 = first disk (i.e. #8), $02 = 2nd disk (drive #9))
; io_filename - specifies filename to open
; io_callback - address of routine to be called after each sector is read
; AX - address of buffer to read sector into
; outputs:
; on errror, carry flag is set
;jsr read_sector
; lda #$30
io_read_file_with_callback:
stax sector_buffer_address
jsr parse_filename
jsr SETNAM
lda io_device_no
beq @drive_id_set
clc
adc #07 ;so 01->08, 02->09 etc
sta drive_id
@drive_id_set:
lda #$02 ; file number 2
ldx drive_id
ldy #02 ; secondary address 2
jsr SETLFS
jsr OPEN
bcs @device_error ; if carry set, the device could not be addressed
;we should now check for file access errors
jsr open_error_channel
@no_error_opening_error_channel:
jsr check_error_channel
lda #$30
cmp error_buffer
beq @was_not_an_error
@readerror:
lda #NB65_ERROR_FILE_ACCESS_FAILURE
sta ip65_error
sec
rts
@was_not_an_error:
@get_next_sector:
ldx #$02 ;file number 2
jsr CHKIN ;file 2 now used as input
ldax sector_buffer_address
stax buffer_ptr
lda #$00
sta buffer_counter
@get_next_byte:
jsr READST
bne @eof
jsr CHRIN
ldy buffer_counter
sta (buffer_ptr),y
inc buffer_counter
bne @get_next_byte
ldy #$00;= 256 bytes
jsr jmp_to_callback
jmp @get_next_sector
@eof:
and #$40 ; end of file?
beq @readerror
;we have part loaded a sector
ldy buffer_counter
beq @empty_sector
jsr jmp_to_callback
@empty_sector:
@close:
lda #$02 ; filenumber 2
jsr CLOSE
ldx #$00
jsr CHKIN
clc
rts
@device_error:
lda #NB65_ERROR_DEVICE_FAILURE
sta ip65_error
ldx #$00
jsr CHKIN
sec
rts
;io_filename is null-terminated.
;this routines sets up up A,X,Y as needed by kernal routines i.e. XY=pointer to name, A = length of name
parse_filename:
ldax io_filename
stax buffer_ptr
ldy #$ff
@next_byte:
iny
lda (buffer_ptr),y
bne @next_byte
tya
ldx buffer_ptr
ldy buffer_ptr+1
rts
;routine to read a sector
;cribbed from http://codebase64.org/doku.php?id=base:reading_a_sector
;cribbed from http://codebase64.org/doku.php?id=base:reading_a_sector_from_disk
;inputs:
; io_device_number set to specify drive to use ($00 = same as last time, $01 = first disk (i.e. #8), $02 = 2nd disk (drive #9))
; io_sector_no - set to sector number to be read
@ -77,8 +185,8 @@ io_read_sector:
clc
adc #07 ;so 01->08, 02->09 etc
sta drive_id
jsr make_read_sector_command
@drive_id_set:
jsr make_read_sector_command
lda #1
ldx #<cname
ldy #>cname
@ -136,16 +244,32 @@ io_read_sector:
sta ip65_error
jmp @close
check_error_channel:
open_error_channel:
lda #$00 ; no filename
tax
tay
jsr SETNAM
lda #$0f ;file number 15
ldx drive_id
ldy #$0f ; secondary address 15 (error channel)
jsr SETLFS
jsr OPEN
rts
check_error_channel:
LDX #$0F ; filenumber 15
JSR CHKIN ;(file 15 now used as input)
LDY #$00
@loop:
JSR READST ;(read status byte)
JSR READST ;(read status byte)
BNE @eof ; either EOF or read error
JSR CHRIN ;(get a byte from file)
sta error_buffer,y
iny
JMP @loop ; next byte
@eof:

View File

@ -524,17 +524,17 @@ load_resource_into_buffer:
sta telnet_line_mode
sta telnet_use_native_charset
;if the username = '/native', then connect in native mode
;if the username = '/n', then connect in native mode
lda resource_selector_length
cmp #7
cmp #2
bne @not_native
lda resource_selector
cmp #'/'
bne @not_native
lda resource_selector+1
cmp #'n'
bne @not_native
lda resource_selector+2
cmp #'a'
bne @not_native
inc telnet_use_native_charset
@not_native:
jsr telnet_connect

View File

@ -122,5 +122,6 @@ NB65_ERROR_LISTENER_NOT_AVAILABLE EQU $87
NB65_ERROR_NO_SUCH_LISTENER EQU $88
NB65_ERROR_CONNECTION_RESET_BY_PEER EQU $89
NB65_ERROR_CONNECTION_CLOSED EQU $8A
NB65_ERROR_FILE_ACCESS_FAILURE EQU $90
NB65_ERROR_OPTION_NOT_SUPPORTED EQU $FE
NB65_ERROR_FUNCTION_NOT_SUPPORTED EQU $FF

View File

@ -425,6 +425,7 @@ tftp_in:
stax output_buffer
jsr copymem
ldax #output_buffer
jsr tftp_callback_vector
jsr send_ack

View File

@ -569,11 +569,10 @@ net_apps_menu:
jmp telnet_main_entry
@not_telnet:
cmp #KEYCODE_F3
bne @not_gopher
bne @not_gopher_floodgap_com
jsr cls
lda #14
jsr print_a ;switch to lower case
; jsr prompt_for_gopher_resource ;only returns if no server was entered.
ldax #gopher_initial_location
sta resource_pointer_lo
@ -582,6 +581,15 @@ net_apps_menu:
jsr select_resource_from_current_directory
jmp exit_gopher
@not_gopher_floodgap_com:
cmp #KEYCODE_F5
bne @not_gopher
jsr cls
lda #14
jsr print_a ;switch to lower case
jsr prompt_for_gopher_resource ;only returns if no server was entered.
jmp exit_gopher
@not_gopher:
cmp #KEYCODE_F7
bne @not_main
@ -650,6 +658,8 @@ exit_telnet:
exit_gopher:
lda #142
jsr print_a ;switch to upper case
lda #$05 ;petscii for white text
jsr print_a
jmp main_menu
.endif
.rodata
@ -683,11 +693,12 @@ config_menu_msg:
.if (BANKSWITCH_SUPPORT=$03)
net_apps_menu_msg:
.byte 13," NET APPS",13,13
.byte "F1: TELNET F3: GOPHER",13
.byte "F5: F7: MAIN MENU",13,13
.byte "F1: TELNET F3: GOPHER.FLOODGAP.COM",13
.byte "F5: GOPHER F7: MAIN MENU",13,13
.byte 0
cant_boot_basic: .byte "BASIC FILE EXECUTION NOT SUPPORTED",13,0
cant_boot_basic:
.byte "BASIC FILE EXECUTION NOT SUPPORTED",13,0
gopher_initial_location:
.byte "1gopher.floodgap.com",$09,"/",$09,"gopher.floodgap.com",$09,"70",$0D,$0A,0

View File

@ -1 +1 @@
.byte "0.9.17"
.byte "0.9.20"

View File

@ -12,6 +12,10 @@
.import io_sector_no
.import io_track_no
.import io_read_sector
.import io_read_file_with_callback
.import io_filename
.import io_callback
.import get_key
.import ip65_error
.macro cout arg
@ -25,8 +29,10 @@
sector_buffer: .res 256
output_buffer: .res 520
.export output_buffer
current_byte: .res 1
current_byte_in_row: .res 1
current_byte_in_sector: .res 1
start_of_current_row: .res 1
.segment "STARTUP" ;this is what gets put at the start of the file on the C64
.word basicstub ; load address
@ -45,10 +51,28 @@ basicstub:
init:
; jsr dump_dir
jsr dump_file
ldax #loading
jsr print
ldax #fname
stax io_filename
jsr print
jsr print_cr
lda #01
sta io_device_no
ldax #readfile_callback
stax io_callback
ldax #sector_buffer
jsr io_read_file_with_callback
bcc @no_error_on_file_read
jsr print_error_code
@no_error_on_file_read:
rts
lda #01
sta io_track_no
lda #01
@ -71,9 +95,22 @@ init:
jsr io_read_sector
bcs @error
jsr dump_sector ;DEBUG
; jsr dump_sector ;DEBUG
lda #$12
sta io_track_no
lda #01
sta io_sector_no
lda #01
sta io_device_no
ldax #sector_buffer
jsr io_read_sector
bcs @error
jsr dump_sector ;DEBUG
rts
@error:
@ -82,182 +119,103 @@ init:
jsr print_hex
rts
readfile_callback:
tya
jsr print_hex
ldax #bytes
jsr print
jsr dump_sector
rts
print_error_code:
jsr print_cr
ldax #error
jsr print
lda ip65_error
jsr print_hex
jsr print_cr
rts
dump_sector:
;hex dump sector
lda #0
sta current_byte
sta current_byte_in_sector
sta start_of_current_row
@one_row:
lda current_byte_in_sector
sta start_of_current_row
jsr print_hex
lda #':'
jsr print_a
lda #' '
jsr print_a
lda #0
sta current_byte_in_row
;first the hex values
@dump_byte:
ldy current_byte
ldy current_byte_in_sector
lda sector_buffer,y
jsr print_hex
lda sector_buffer,y
lda #' '
jsr print_a
inc current_byte
inc current_byte_in_sector
inc current_byte_in_row
lda current_byte_in_row
cmp #08
bne @dump_byte
rts
dump_dir:
LDA #dirname_end-dirname
LDX #<dirname
LDY #>dirname
JSR $FFBD ; call SETNAM
LDA #$02 ; filenumber 2
LDX $BA
BNE @skip
LDX #$08 ; default to device number 8
@skip:
LDY #$00 ; secondary address 0 (required for dir reading!)
JSR $FFBA ; call SETLFS
JSR $FFC0 ; call OPEN (open the directory)
BCS @error ; quit if OPEN failed
LDX #$02 ; filenumber 2
JSR $FFC6 ; call CHKIN
LDY #$04 ; skip 4 bytes on the first dir line
BNE @skip2
@next:
LDY #$02 ; skip 2 bytes on all other lines
@skip2:
JSR getbyte ; get a byte from dir and ignore it
DEY
BNE @skip2
JSR getbyte ; get low byte of basic line number
TAY
JSR getbyte ; get high byte of basic line number
PHA
TYA ; transfer Y to X without changing Akku
TAX
PLA
JSR $BDCD ; print basic line number
JSR getbyte
JSR getbyte
LDA #'#' ; print a space first
@char:
JSR $FFD2 ; call CHROUT (print character)
JSR getbyte
BNE @char ; continue until end of line
LDA #$0D
JSR $FFD2 ; print RETURN
JSR $FFE1 ; RUN/STOP pressed?
BNE @next ; no RUN/STOP -> continue
@error:
; Akkumulator contains BASIC error code
; most likely error:
; A = $05 (DEVICE NOT PRESENT)
exit:
LDA #$02 ; filenumber 2
JSR $FFC3 ; call CLOSE
LDX #$00
JSR $FFC9 ; call CHKIN (keyboard now input device again)
RTS
getbyte:
JSR $FFB7 ; call READST (read status byte)
BNE @end ; read error or end of file
JMP $FFCF ; call CHRIN (read byte from directory)
@end:
PLA ; don't return to dir reading loop
PLA
JMP exit
dump_file:
LDA #fname_end-fname
LDX #<fname
LDY #>fname
JSR $FFBD ; call SETNAM
LDA #$02 ; file number 2
LDX $BA ; last used device number
BNE @skip
LDX #$08 ; default to device 8
@skip:
LDY #$02 ; secondary address 2
JSR $FFBA ; call SETLFS
JSR $FFC0 ; call OPEN
BCS @error ; if carry set, the file could not be opened
; check drive error channel here to test for
; FILE NOT FOUND error etc.
LDX #$02 ; filenumber 2
JSR $FFC6 ; call CHKIN (file 2 now used as input)
@loop:
JSR $FFB7 ; call READST (read status byte)
BNE @eof ; either EOF or read error
JSR $FFCF ; call CHRIN (get a byte from file)
JSR $FFD2 ; call CHROUT (print character)
JMP @loop ; next byte
@eof:
AND #$40 ; end of file?
BEQ @readerror
@close:
LDA #$02 ; filenumber 2
JSR $FFC3 ; call CLOSE
LDX #$00 ; filenumber 0 = keyboard
JSR $FFC6 ; call CHKIN (keyboard now input device again)
RTS
@error:
; Akkumulator contains BASIC error code
; most likely errors:
; A = $05 (DEVICE NOT PRESENT)
pha
ldax #error_code
jsr print
pla
jsr print_hex
JMP @close ; even if OPEN failed, the file has to be closed
@readerror:
; for further information, the drive error channel has to be read
jsr print_error
JMP @close
print_error:
LDX #$0F ; filenumber 15
JSR $FFC6 ; call CHKIN (file 15 now used as input)
@loop:
JSR $FFB7 ; call READST (read status byte)
BNE @end ; read error or end of file
JMP $FFCF ; call CHRIN (read byte from directory)
;now the ascii values
lda start_of_current_row
sta current_byte_in_sector
@print_byte:
ldy current_byte_in_sector
lda sector_buffer,y
cmp #32
bmi @not_printable
cmp #94
bmi @printable
@not_printable:
lda #'.'
@printable:
jsr print_a
JMP @loop ; next byte
@end:
.byte $92
inc current_byte_in_sector
beq @last_byte
dec current_byte_in_row
bne @print_byte
jsr print_cr
jmp @one_row
@last_byte:
rts
fname: .byte "tcp.s"
fname: .byte "$"
fname_end:
.byte 0
loading: .byte "LOADING ",0
.rodata
press_a_key_to_continue:
.byte "PRESS A KEY TO CONTINUE",13,0
error:
.byte "ERROR - $", 0
failed:
.byte "FAILED ", 0
ok:
.byte "OK ", 0
bytes:
.byte "BYTES.",13, 0
dirname:
.byte "$" ; filename used to access directory
dirname_end:
cname: .byte '#'
cname: .byte '#'

View File

@ -6,11 +6,10 @@ AFLAGS=
INCFILES=\
../inc/common.i\
../inc/commonprint.i\
../inc/simpleprint.i\
../inc/net.i\
../inc/menu.i\
../inc/nb65_constants.i\
nb65_version.i\
../nb65/nb65_version.i\
IP65LIB=../ip65/ip65.lib
@ -19,17 +18,26 @@ APPLE2PROGLIB=../drivers/apple2prog.lib
%.o: %.s $(INCFILES) $(APPLE2PROGLIB)
$(AS) $(AFLAGS) $<
all: applewin.exe
all: utherboot.dsk
c700_rom.bin: c700_rom.o ../cfg/a2rom.cfg
$(LD) -C ../cfg/a2rom.cfg -o $@ c700_rom.o $(APPLE2PROGLIB)
#c700_rom.bin: c700_rom.o ../cfg/a2rom.cfg
# $(LD) -C ../cfg/a2rom.cfg -o $@ c700_rom.o $(APPLE2PROGLIB)
#
#bankswitch_eeprom.bin: bankswitch_eeprom.o ../cfg/a2rom.cfg
# $(LD) -C ../cfg/a2rom.cfg -o $@ bankswitch_eeprom.o $(APPLE2PROGLIB)
#
#applewin.exe: c700_rom.bin bankswitch_eeprom.bin patch_applewin.rb
# ruby patch_applewin.rb
bankswitch_eeprom.bin: bankswitch_eeprom.o ../cfg/a2rom.cfg
$(LD) -C ../cfg/a2rom.cfg -o $@ bankswitch_eeprom.o $(APPLE2PROGLIB)
utherboot.pg2: utherboot.o $(IP65LIB) $(APPLE2PROGLIB) $(INCFILES) ../cfg/a2language_card.cfg
$(LD) -m utherboot.map -C ../cfg/a2language_card.cfg -o $@ $< $(IP65LIB) $(APPLE2PROGLIB)
utherboot.dsk: utherboot.pg2
ripxplore.rb --init AppleDos utherboot.dsk -a utherboot.pg2 -t AppleBinary
ripxplore.rb utherboot.dsk -a hello -t Applesoft
applewin.exe: c700_rom.bin bankswitch_eeprom.bin patch_applewin.rb
ruby patch_applewin.rb
clean:
rm -f *.o *.bin *.map *.prg *.pg2 *.dsk *.d64

View File

@ -21,6 +21,7 @@
.import tftp_load_address
.import tftp_ip
.import tftp_download
.import tftp_clear_callbacks
.import copymem
.importzp copy_src
@ -171,24 +172,30 @@ init:
jsr print_ip_config
ldx #3
lda #$FF
:
lda cfg_tftp_server,x
; lda cfg_tftp_server,x
sta tftp_ip,x
dex
bpl :-
jsr tftp_clear_callbacks
ldax #tftp_dir_buffer
stax tftp_load_address
ldax #getting_dir_listing_msg
jsr print
ldax #tftp_dir_filemask
stax tftp_filename
jsr print
jsr print_cr
jsr tftp_download
bcs @dir_failed
@ -309,5 +316,6 @@ tftp_download_ok_msg:
.asciiz "DOWNLOAD OK"
startup_msg: .byte "UTHERNET NETWORK BOOT CLIENT V"
.include "nb65_version.i"
.include "..\nb65\nb65_version.i"
.byte 0

7
dist/make_dist.rb vendored
View File

@ -18,18 +18,19 @@ version_string=File.open(VERSION_FILE).read
end
[
#["client/nb65/utherboot.dsk","a2/"],
["client/nb65/utherboot.dsk","a2/"],
["client/nb65/set_ip_config.rb","bin/"],
#["client/nb65/nb65_rrnet.bin","c64/"],
["client/nb65/nb65_c64_ram.prg","c64/"],
["client/nb65/nb65_std_cart.bin","c64/"],
\["client/nb65/nb65_tcp_cart.bin","c64/"],
["client/nb65/d64_upload.prg","boot/"],
["server/lib/tftp_server.rb","lib"],
["server/lib/file_list.rb","lib"],
["server/bin/tftp_only_server.rb","bin/tftp_server.rb"],
#["server/bin/import_ags_games.rb","bin"],
["server/bin/import_ags_games.rb","bin"],
#["server/boot/BOOTA2.PG2","boot"],
#["doc/README.Apple2.html","a2"],
["doc/README.Apple2.html","a2"],
["doc/README.C64.html","c64"],
["doc/netboot65.html","doc/index.html"],
#["doc/README.Apple2.html","doc"],

View File

@ -1 +1 @@
0.9.17
0.9.20

View File

@ -87,6 +87,13 @@ IP65 is a TCP/IP stack for 6502 based computers.
<table>
<tr>
<th>Applications</th>
<td class="partial" colspan="3" >Telnet</td>
<td class="partial" colspan="3">Gopher</td>
</tr>
<tr>
<th>Services</th>
<td class="partial" colspan="2" rowspan="2">TCP</td>
@ -153,6 +160,7 @@ IP65 is a TCP/IP stack for 6502 based computers.
<pre>
Release Maintainer Changes
------- ---------- -------
2009-08-02 Jonno Downes More TCP functionality, includes telnet
2009-07-12 Jonno Downes Initial TCP implementation (use -DTCP to include)
2009-03-21 Jonno Downes Added technical reference documentation
2009-03-15 Jonno Downes Added DHCP, DNS & TFTP