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

This commit is contained in:
jonnosan 2009-08-09 11:22:52 +00:00
parent 79a6bcb04f
commit cef3c75c59
3 changed files with 196 additions and 17 deletions

View File

@ -12,6 +12,7 @@
.export io_sector_no
.export io_track_no
.export io_read_sector
.export io_read_catalogue
.export io_read_file_with_callback
.export io_filename
@ -55,6 +56,16 @@ jmp_to_callback:
io_callback=jmp_to_callback+1
write_byte_to_buffer:
tmp_buffer_ptr=write_byte_to_buffer+1
sta $ffff
inc tmp_buffer_ptr
bne :+
inc tmp_buffer_ptr
:
rts
.code
;routine to read a file with a callback after each 256 byte sector
@ -91,8 +102,6 @@ io_read_file_with_callback:
jsr open_error_channel
@no_error_opening_error_channel:
jsr check_error_channel
lda #$30
cmp error_buffer
@ -120,7 +129,7 @@ io_read_file_with_callback:
sta (buffer_ptr),y
inc buffer_counter
bne @get_next_byte
ldy #$00;= 256 bytes
jsr jmp_to_callback
jmp @get_next_sector
@ -138,7 +147,7 @@ io_read_file_with_callback:
@close:
lda #$02 ; filenumber 2
jsr CLOSE
ldx #$00
ldx #$00 ;keyboard now used as input
jsr CHKIN
clc
rts
@ -167,6 +176,82 @@ parse_filename:
ldy buffer_ptr+1
rts
;routine to catalogue disk
; 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))
; AX - address of buffer to read catalogue into
; outputs:
; on errror, carry flag is set.
io_read_catalogue:
stax tmp_buffer_ptr
;get the BAM
lda #$12
sta io_track_no
lda #00
sta io_sector_no
ldax #output_buffer
jsr io_read_sector
bcs @end_catalogue
@get_next_catalogue_sector:
clc
lda output_buffer
beq @end_catalogue
sta io_track_no
lda output_buffer+1
sta io_sector_no
ldax #output_buffer
jsr io_read_sector
bcs @end_catalogue
ldy #0
@read_one_file:
tya
pha
lda output_buffer+2,y ;file type
and #$7f
beq @skip_to_next_file
; bpl @skip_to_next_file
@get_next_char:
lda output_buffer+5,y ;file type
beq @end_of_filename
cmp #$a0
beq @end_of_filename
jsr write_byte_to_buffer
iny
jmp @get_next_char
@end_of_filename:
lda #0
jsr write_byte_to_buffer
pla
pha
tay ;get Y back to start of this file entry
lda output_buffer+2,y ;file type
jsr write_byte_to_buffer
lda output_buffer+30,y ;lo byte of file length in sectors
jsr write_byte_to_buffer
lda output_buffer+31,y ;hi byte of file length in sectors
jsr write_byte_to_buffer
@skip_to_next_file:
pla
clc
adc #$20
tay
bne @read_one_file
jmp @get_next_catalogue_sector
@end_catalogue:
lda #0
jsr write_byte_to_buffer
jsr write_byte_to_buffer
rts
;routine to read a sector
;cribbed from http://codebase64.org/doku.php?id=base:reading_a_sector_from_disk
;inputs:

View File

@ -20,20 +20,20 @@ allowed_ptr=copy_src ;reuse zero page
;inputs: none
;outputs: A contains ASCII value of key just pressed
get_key:
jsr $ffe4
jsr get_key_if_available
beq get_key
rts
;use C64 Kernel ROM function to read a key
;inputs: none
;outputs: A contains ASCII value of key just pressed (0 if no key pressed)
get_key_if_available=$ffe4
get_key_if_available=$f142 ;not officially documented - where F13E (GETIN) falls through to if device # is 0 (KEYBD)
;process inbound ip packets while waiting for a keypress
get_key_ip65:
jsr ip65_process
jsr $ffe4
jsr get_key_if_available
beq get_key_ip65
rts
@ -48,7 +48,7 @@ check_for_abort_key:
cmp #$3F
bne @not_abort
@flush_loop:
jsr $ffe4
jsr get_key_if_available
bne @flush_loop
lda $cb ;current key pressed
cmp #$3F

View File

@ -17,6 +17,7 @@
.import io_callback
.import get_key
.import ip65_error
.import io_read_catalogue
.macro cout arg
lda arg
@ -33,6 +34,8 @@ current_byte_in_row: .res 1
current_byte_in_sector: .res 1
start_of_current_row: .res 1
directory_buffer: .res 4096
.segment "STARTUP" ;this is what gets put at the start of the file on the C64
.word basicstub ; load address
@ -51,6 +54,30 @@ basicstub:
init:
ldax #read_catalogue
jsr print
; ldax #dummy_catalogue
; jsr print_catalogue
; rts
lda #01
sta io_device_no
ldax #directory_buffer
jsr io_read_catalogue
bcc @no_error_on_catalogue
jsr print_error_code
rts
@no_error_on_catalogue:
ldax #directory_buffer
jsr print_catalogue
rts
ldax #loading
jsr print
ldax #fname
@ -119,6 +146,51 @@ init:
jsr print_hex
rts
;print catalogue pointed at by AX
print_catalogue:
stax tmp_buffer_ptr
@print_one_filename:
jsr read_byte_from_buffer
beq @catalogue_done
@print_one_char:
jsr print_a
jsr read_byte_from_buffer
beq @end_of_filename
jmp @print_one_char
@end_of_filename:
jsr print_cr
ldax #filetype
jsr print
jsr read_byte_from_buffer
jsr print_hex
ldax #sectors
jsr print
jsr read_byte_from_buffer
pha
jsr read_byte_from_buffer
jsr print_hex
pla
jsr print_hex
jsr print_cr
jmp @print_one_filename
@catalogue_done:
rts
read_byte_from_buffer:
tmp_buffer_ptr=read_byte_from_buffer+1
lda $ffff
inc tmp_buffer_ptr
bne :+
inc tmp_buffer_ptr
:
pha
pla ;reload A so flags are set correctly
rts
readfile_callback:
tya
jsr print_hex
@ -136,6 +208,14 @@ print_error_code:
jsr print_cr
rts
wait_for_keypress:
lda #0
sta $c6 ;set the keyboard buffer to be empty
ldax #press_a_key_to_continue
jsr print
jsr get_key
rts
dump_sector:
;hex dump sector
lda #0
@ -143,7 +223,13 @@ dump_sector:
sta start_of_current_row
@one_row:
lda #$80
cmp current_byte_in_sector
bne @dont_wait_for_key
jsr wait_for_keypress
@dont_wait_for_key:
lda current_byte_in_sector
sta start_of_current_row
jsr print_hex
lda #':'
@ -187,14 +273,18 @@ dump_sector:
bne @print_byte
jsr print_cr
jmp @one_row
@last_byte:
@last_byte:
jsr print_cr
jsr wait_for_keypress
rts
fname: .byte "$"
fname_end:
.byte 0
read_catalogue:
.byte "READING CATALOGUE",13,0
fname:
.byte "TEST_DISK_IO.PRG",0
loading: .byte "LOADING ",0
.rodata
@ -202,6 +292,11 @@ loading: .byte "LOADING ",0
press_a_key_to_continue:
.byte "PRESS A KEY TO CONTINUE",13,0
filetype:
.byte "TYPE: $",0
sectors:
.byte " SECTORS: $",0
error:
.byte "ERROR - $", 0
@ -214,8 +309,7 @@ ok:
bytes:
.byte "BYTES.",13, 0
dirname:
.byte "$" ; filename used to access directory
dirname_end:
cname: .byte '#'
dummy_catalogue:
.byte"FILE 1",0,$81,$34,$12
.byte "FILE 2",0,$82,$f0,$0d
.byte 0