mirror of
https://github.com/bobbimanners/emailler.git
synced 2025-04-06 14:39:54 +00:00
Removed several files that seem to rather belong to NETBOO65.
This commit is contained in:
parent
d3638c92e4
commit
7ce0ff2023
@ -29,13 +29,13 @@ a2lancegs.lib: a2print.o lan91c96.o a2timer.o a2kernal.o a2input.o a2charconv.o
|
||||
a2uther.lib: a2print.o uthernet.o a2timer.o a2kernal.o a2input.o a2charconv.o cs8900a.o a2_zero_page.o
|
||||
ar65 a $@ $^
|
||||
|
||||
c64rrnet.lib: c64print.o rr-net.o c64timer.o c64kernal.o c64inputs.o cbm_disk_access.o petscii_charconv.o c64_vt100.o cs8900a.o generic_zero_page.o
|
||||
c64rrnet.lib: c64print.o rr-net.o c64timer.o c64kernal.o c64inputs.o petscii_charconv.o cs8900a.o generic_zero_page.o
|
||||
ar65 a $@ $^
|
||||
|
||||
c64wiznet.lib: w5100.o c64print.o c64timer.o c64kernal.o c64inputs.o cbm_disk_access.o petscii_charconv.o c64_vt100.o generic_zero_page.o
|
||||
c64wiznet.lib: w5100.o c64print.o c64timer.o c64kernal.o c64inputs.o petscii_charconv.o generic_zero_page.o
|
||||
ar65 a $@ $^
|
||||
|
||||
vic20rrnet.lib: vic20print.o vic20-rr-net.o vic20timer.o vic20input.o cbm_disk_access.o petscii_charconv.o cs8900a.o generic_zero_page.o
|
||||
vic20rrnet.lib: vic20print.o vic20-rr-net.o vic20timer.o vic20input.o petscii_charconv.o cs8900a.o generic_zero_page.o
|
||||
ar65 a $@ $^
|
||||
|
||||
clean:
|
||||
|
2124
drivers/c64_vt100.s
2124
drivers/c64_vt100.s
File diff suppressed because it is too large
Load Diff
@ -1,642 +0,0 @@
|
||||
;C64 disk access routines
|
||||
;
|
||||
|
||||
|
||||
.ifndef KPR_API_VERSION_NUMBER
|
||||
.define EQU =
|
||||
.include "../inc/kipper_constants.i"
|
||||
.endif
|
||||
|
||||
.include "../inc/common.i"
|
||||
.export io_device_no
|
||||
.export io_sector_no
|
||||
.export io_track_no
|
||||
.export io_read_sector
|
||||
.export io_write_sector
|
||||
.export io_read_catalogue
|
||||
.export io_read_catalogue_ex
|
||||
.export io_read_file
|
||||
.export io_read_file_with_callback
|
||||
.export io_filename
|
||||
.export io_filesize
|
||||
.export io_load_address
|
||||
.export io_callback
|
||||
.export io_error_buffer
|
||||
|
||||
.importzp copy_src
|
||||
.import ip65_error
|
||||
.import output_buffer
|
||||
.importzp copy_dest
|
||||
|
||||
|
||||
io_error_buffer=error_buffer
|
||||
;reuse the copy_src zero page location
|
||||
buffer_ptr = copy_src
|
||||
|
||||
;######### KERNEL functions
|
||||
CHKIN = $ffc6
|
||||
CHKOUT = $ffc9
|
||||
CHRIN = $ffcf
|
||||
CHROUT = $ffd2
|
||||
CLRCHN = $ffcc
|
||||
CLALL = $FFE7
|
||||
CLOSE = $ffc3
|
||||
OPEN = $ffc0
|
||||
READST = $ffb7
|
||||
SETNAM = $ffbd
|
||||
SETLFS = $ffba
|
||||
|
||||
.segment "SELF_MODIFIED_CODE"
|
||||
|
||||
io_track_no: .res 2
|
||||
io_sector_no: .res 1
|
||||
io_device_no: .byte 0
|
||||
io_filename: .res 2
|
||||
io_filesize: .res 2 ;although a file on disk can be >64K, io_filesize is only used when loading into RAM hence file must be <64K
|
||||
io_load_address: .res 2
|
||||
error_buffer = output_buffer + 256
|
||||
command_buffer = error_buffer+128
|
||||
sector_buffer_address: .res 2
|
||||
buffer_counter: .res 1
|
||||
extended_catalogue_flag: .res 1
|
||||
|
||||
|
||||
drive_id: .byte 08 ;default to drive 8
|
||||
|
||||
jmp_to_callback:
|
||||
jmp $ffff
|
||||
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+1
|
||||
:
|
||||
rts
|
||||
|
||||
|
||||
.code
|
||||
|
||||
;routine to read a file
|
||||
; 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
|
||||
; AX - address of buffer to read file into (set to $0000 to treat first 2 bytes as load address)
|
||||
; outputs:
|
||||
; on errror, carry flag is set
|
||||
; otherwise, io_filesize will be set to size of file and io_load_address will be set to actual load address used.
|
||||
;
|
||||
io_read_file:
|
||||
stax io_load_address
|
||||
sta sector_buffer_address
|
||||
stx sector_buffer_address+1 ;this also sets the Z flag
|
||||
bne @sector_buffer_address_set
|
||||
;if we get here, X was $00 so we need to use first 2 bytes of file as load address
|
||||
ldax #output_buffer
|
||||
stax sector_buffer_address
|
||||
|
||||
@sector_buffer_address_set:
|
||||
ldax #read_file_callback
|
||||
stax io_callback
|
||||
lda #0
|
||||
sta io_filesize
|
||||
sta io_filesize+1
|
||||
ldax sector_buffer_address
|
||||
jsr io_read_file_with_callback
|
||||
rts
|
||||
|
||||
read_file_callback:
|
||||
sty io_filesize ;only 1 (the last) sector can ever be !=$100 bytes
|
||||
bne @not_full_sector
|
||||
inc io_filesize+1
|
||||
inc sector_buffer_address +1
|
||||
@not_full_sector:
|
||||
lda io_load_address+1 ;is the high byte of the address $00?
|
||||
bne @done
|
||||
ldax output_buffer ;if we get here we must have used downloaded into the static output buffer, so the
|
||||
;first 2 bytes there are the real load address
|
||||
stax copy_dest ;now copy the rest of the sector
|
||||
stax sector_buffer_address
|
||||
stax io_load_address
|
||||
dey
|
||||
dey
|
||||
@copy_one_byte:
|
||||
dey
|
||||
lda output_buffer+2,y
|
||||
sta (copy_dest),y
|
||||
inc sector_buffer_address
|
||||
bne :+
|
||||
inc sector_buffer_address+1
|
||||
:
|
||||
tya
|
||||
bne @copy_one_byte
|
||||
|
||||
@done:
|
||||
rts
|
||||
|
||||
;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
|
||||
|
||||
io_read_file_with_callback:
|
||||
|
||||
stax sector_buffer_address
|
||||
jsr CLALL
|
||||
jsr parse_filename
|
||||
|
||||
jsr SETNAM
|
||||
|
||||
jsr set_drive_id
|
||||
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 #KPR_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:
|
||||
jmp close_filenumber_2
|
||||
@device_error:
|
||||
lda #KPR_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 catalogue disk (with filename, filetype, filesize)
|
||||
; 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.
|
||||
; otherwise, buffer will be filled with asciiz filenames,followed by 1 byte filetype, followed by 2 byte file length (in 256 byte sectors)
|
||||
; there is an extra zero at the end of the last file.
|
||||
io_read_catalogue_ex:
|
||||
stax tmp_buffer_ptr
|
||||
lda #1
|
||||
bne extended_catalogue_flag_set
|
||||
|
||||
;routine to catalogue disk (filenames only)
|
||||
; 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.
|
||||
; otherwise, buffer will be filled with asciiz filenames (and an extra zero at the end of the last filename)
|
||||
io_read_catalogue:
|
||||
stax tmp_buffer_ptr
|
||||
lda #0
|
||||
extended_catalogue_flag_set:
|
||||
sta extended_catalogue_flag
|
||||
;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
|
||||
|
||||
@get_next_char:
|
||||
lda output_buffer+5,y ;file name
|
||||
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 extended_catalogue_flag ;do we need to include the 'extended' data?
|
||||
beq @skip_to_next_file
|
||||
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
|
||||
|
||||
set_drive_id:
|
||||
lda io_device_no
|
||||
beq @drive_id_set
|
||||
clc
|
||||
adc #07 ;so 01->08, 02->09 etc
|
||||
sta drive_id
|
||||
@drive_id_set:
|
||||
rts
|
||||
|
||||
;routine to write a sector
|
||||
;cribbed from http://codebase64.org/doku.php?id=base:writing_a_sector_to_disk (credited to "Graham")
|
||||
;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 written
|
||||
; io_track_no - set to track number to be written (only lo byte is used)
|
||||
; AX - address of buffer to to write to sector
|
||||
; outputs:; on errror, carry flag is set.
|
||||
io_write_sector:
|
||||
stax sector_buffer_address
|
||||
jsr set_drive_id
|
||||
jsr CLALL
|
||||
lda #$32 ;"2"
|
||||
jsr make_user_command
|
||||
lda #1
|
||||
ldx #<cname
|
||||
ldy #>cname
|
||||
jsr SETNAM
|
||||
lda #02
|
||||
ldx drive_id
|
||||
ldy #02
|
||||
jsr SETLFS
|
||||
jsr OPEN
|
||||
bcs @error
|
||||
|
||||
lda #7
|
||||
ldx #<bpname
|
||||
ldy #>bpname
|
||||
jsr SETNAM
|
||||
lda #15
|
||||
ldx drive_id
|
||||
ldy #15
|
||||
jsr SETLFS
|
||||
jsr OPEN
|
||||
bcs @error
|
||||
|
||||
jsr check_error_channel
|
||||
lda #$30
|
||||
cmp error_buffer
|
||||
bne @error
|
||||
|
||||
ldx #$02 ; filenumber 2
|
||||
jsr CHKOUT ; file 2 now used as output
|
||||
|
||||
ldax sector_buffer_address
|
||||
stax buffer_ptr
|
||||
ldy #0
|
||||
:
|
||||
lda (buffer_ptr),y ;get next byte in sector
|
||||
jsr CHROUT ;write it out
|
||||
iny
|
||||
bne :-
|
||||
|
||||
ldx #$0F ; filenumber 15
|
||||
jsr CHKOUT ; file 15 now used as output
|
||||
|
||||
ldy #$00
|
||||
:
|
||||
lda command_buffer,y
|
||||
beq :+
|
||||
jsr CHROUT ;write byte to command channel
|
||||
iny
|
||||
bne :-
|
||||
:
|
||||
|
||||
lda #$0d ; carriage return, required to start command
|
||||
jsr CHROUT ;write it out
|
||||
jsr check_error_channel
|
||||
lda #$30
|
||||
cmp error_buffer
|
||||
bne @error
|
||||
|
||||
@close:
|
||||
jsr close_filenumbers_2_and_15
|
||||
jsr CLRCHN
|
||||
clc
|
||||
rts
|
||||
|
||||
@error:
|
||||
lda #KPR_ERROR_DEVICE_FAILURE
|
||||
sta ip65_error
|
||||
jsr @close
|
||||
sec
|
||||
rts
|
||||
|
||||
|
||||
close_filenumbers_2_and_15:
|
||||
lda #15 ; filenumber 15
|
||||
jsr CLOSE
|
||||
close_filenumber_2:
|
||||
lda #$02 ; filenumber 2
|
||||
jsr CLOSE
|
||||
ldx #$00 ; filenumber 0 = keyboard
|
||||
jsr CHKIN ;(keyboard now input device again)
|
||||
clc
|
||||
rts
|
||||
|
||||
;routine to read a sector (credited to "Graham")
|
||||
;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
|
||||
; io_track_no - set to track number to be read (only lo byte is used)
|
||||
; AX - address of buffer to read sector into
|
||||
; outputs:
|
||||
; on errror, carry flag is set. otherwise buffer will be filled with 256 bytes
|
||||
|
||||
io_read_sector:
|
||||
|
||||
stax sector_buffer_address
|
||||
jsr set_drive_id
|
||||
jsr CLALL
|
||||
lda #$31 ;"1"
|
||||
jsr make_user_command
|
||||
lda #1
|
||||
ldx #<cname
|
||||
ldy #>cname
|
||||
jsr SETNAM
|
||||
lda #02
|
||||
ldx drive_id
|
||||
ldy #02
|
||||
jsr SETLFS
|
||||
jsr OPEN
|
||||
bcs @error
|
||||
ldx #<command_buffer
|
||||
ldy #>command_buffer
|
||||
lda #12
|
||||
jsr SETNAM
|
||||
lda #15
|
||||
ldx $BA ;use whatever was last device #
|
||||
ldy #15
|
||||
jsr SETLFS
|
||||
jsr OPEN
|
||||
bcs @error
|
||||
|
||||
jsr check_error_channel
|
||||
lda #$30
|
||||
cmp error_buffer
|
||||
bne @error
|
||||
|
||||
ldx #$02 ; filenumber 2
|
||||
jsr CHKIN ;(file 2 now used as input)
|
||||
|
||||
lda sector_buffer_address
|
||||
sta buffer_ptr
|
||||
lda sector_buffer_address+1
|
||||
sta buffer_ptr+1
|
||||
ldy #$00
|
||||
@loop:
|
||||
jsr CHRIN ;(get a byte from file)
|
||||
sta (buffer_ptr),Y ; write byte to memory
|
||||
iny
|
||||
bne @loop ; next byte, end when 256 bytes are read
|
||||
@close:
|
||||
jmp close_filenumbers_2_and_15
|
||||
@error:
|
||||
lda #KPR_ERROR_DEVICE_FAILURE
|
||||
sta ip65_error
|
||||
jsr @close
|
||||
sec
|
||||
rts
|
||||
|
||||
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)
|
||||
BNE @eof ; either EOF or read error
|
||||
JSR CHRIN ;(get a byte from file)
|
||||
sta error_buffer,y
|
||||
iny
|
||||
|
||||
JMP @loop ; next byte
|
||||
|
||||
@eof:
|
||||
lda #0
|
||||
sta error_buffer,y
|
||||
LDX #$00 ; filenumber 0 = keyboard
|
||||
JSR CHKIN ;(keyboard now input device again)
|
||||
rts
|
||||
|
||||
make_user_command:
|
||||
;fill command buffer with "U <x>" command, where "x" is passed in via A
|
||||
;i.e. A=1 makes command to read in track & sector
|
||||
;A=2 makes command to write track & sector
|
||||
;returns length of command in Y
|
||||
|
||||
pha
|
||||
ldy #0
|
||||
lda #85 ;"U"
|
||||
sta command_buffer,y
|
||||
iny
|
||||
pla
|
||||
sta command_buffer,y
|
||||
iny
|
||||
lda #$20 ;" "
|
||||
sta command_buffer,y
|
||||
iny
|
||||
lda #$32 ;"2" - file number
|
||||
sta command_buffer,y
|
||||
iny
|
||||
lda #$20 ;" "
|
||||
sta command_buffer,y
|
||||
iny
|
||||
lda #$30 ;"0" - drive number
|
||||
sta command_buffer,y
|
||||
iny
|
||||
lda #$20 ;" "
|
||||
sta command_buffer,y
|
||||
iny
|
||||
lda io_track_no
|
||||
jsr byte_to_ascii
|
||||
pha
|
||||
txa
|
||||
sta command_buffer,y
|
||||
pla
|
||||
iny
|
||||
sta command_buffer,y
|
||||
iny
|
||||
lda #$20 ;" "
|
||||
sta command_buffer,y
|
||||
iny
|
||||
lda io_sector_no
|
||||
jsr byte_to_ascii
|
||||
pha
|
||||
txa
|
||||
sta command_buffer,y
|
||||
pla
|
||||
iny
|
||||
sta command_buffer,y
|
||||
iny
|
||||
|
||||
lda #0
|
||||
sta command_buffer,y ;make it ASCIIZ so we can print it
|
||||
|
||||
rts
|
||||
|
||||
byte_to_ascii:
|
||||
cmp #30
|
||||
bmi @not_30
|
||||
ldx #$33
|
||||
clc
|
||||
adc #18
|
||||
rts
|
||||
@not_30:
|
||||
cmp #20
|
||||
bmi @not_20
|
||||
ldx #$32
|
||||
clc
|
||||
adc #28
|
||||
rts
|
||||
@not_20:
|
||||
cmp #10
|
||||
bmi @not_10
|
||||
ldx #$31
|
||||
clc
|
||||
adc #38
|
||||
rts
|
||||
@not_10:
|
||||
ldx #$30
|
||||
clc
|
||||
adc #48
|
||||
rts
|
||||
|
||||
.rodata
|
||||
cname: .byte '#'
|
||||
bpname: .byte "B-P 2 0"
|
||||
|
||||
|
||||
;-- LICENSE FOR c64_disk_access.s --
|
||||
; 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/
|
||||
;
|
||||
; 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.
|
||||
;
|
||||
; The Original Code is ip65.
|
||||
;
|
||||
; The Initial Developer of the Original Code is Jonno Downes,
|
||||
; jonno@jamtronix.com.
|
||||
; Portions created by the Initial Developer are Copyright (C) 2009
|
||||
; Jonno Downes. All Rights Reserved.
|
||||
; -- LICENSE END --
|
@ -31,7 +31,6 @@ ETHOBJS=\
|
||||
parser.o \
|
||||
string_utils.o \
|
||||
telnet.o \
|
||||
xmodem.o \
|
||||
url.o \
|
||||
arithmetic.o\
|
||||
ip.o \
|
||||
|
599
ip65/xmodem.s
599
ip65/xmodem.s
@ -1,599 +0,0 @@
|
||||
; XMODEM file transfer
|
||||
|
||||
.include "../inc/common.i"
|
||||
.ifndef KPR_API_VERSION_NUMBER
|
||||
.define EQU =
|
||||
.include "../inc/kipper_constants.i"
|
||||
.endif
|
||||
|
||||
|
||||
XMODEM_BLOCK_SIZE=$80 ;how many bytes (excluding header & checksum) in each block?
|
||||
XMODEM_TIMEOUT_SECONDS=5
|
||||
XMODEM_MAX_ERRORS=10
|
||||
SOH = $01
|
||||
EOT = $04
|
||||
ACK = $06
|
||||
NAK = $15
|
||||
CAN = $18
|
||||
PAD = $1A ;padding added to end of file
|
||||
|
||||
.export xmodem_receive
|
||||
.export xmodem_send
|
||||
|
||||
.export xmodem_iac_escape ;are IAC bytes ($FF) escaped?
|
||||
|
||||
.import ip65_process
|
||||
.import ip65_error
|
||||
.import tcp_callback
|
||||
.import copymem
|
||||
.importzp copy_src
|
||||
.importzp copy_dest
|
||||
.import tcp_send
|
||||
.import tcp_send_data_len
|
||||
.import tcp_inbound_data_ptr
|
||||
.import tcp_inbound_data_length
|
||||
.import check_for_abort_key
|
||||
.import print_a
|
||||
.import print_cr
|
||||
.import print_ascii_as_native
|
||||
.import print_hex
|
||||
.import timer_seconds
|
||||
|
||||
.segment "SELF_MODIFIED_CODE"
|
||||
got_byte:
|
||||
jmp $ffff
|
||||
|
||||
get_byte:
|
||||
jmp $ffff
|
||||
|
||||
next_char:
|
||||
lda buffer_length
|
||||
bne @not_eof
|
||||
lda buffer_length+1
|
||||
bne @not_eof
|
||||
sec
|
||||
rts
|
||||
@not_eof:
|
||||
next_char_ptr=*+1
|
||||
lda $ffff
|
||||
pha
|
||||
inc next_char_ptr
|
||||
bne :+
|
||||
inc next_char_ptr+1
|
||||
:
|
||||
sec
|
||||
lda buffer_length
|
||||
sbc #1
|
||||
sta buffer_length
|
||||
lda buffer_length+1
|
||||
sbc #0
|
||||
sta buffer_length+1
|
||||
pla
|
||||
clc
|
||||
rts
|
||||
|
||||
|
||||
emit_a:
|
||||
;put a byte to the output buffer
|
||||
;if the byte is $FF, and xmodem_iac_escape is not zero, it is doubled
|
||||
jsr @real_emit_a
|
||||
cmp #$ff
|
||||
bne exit_emit_a
|
||||
ldx xmodem_iac_escape
|
||||
beq exit_emit_a
|
||||
@real_emit_a:
|
||||
emit_a_ptr=*+1
|
||||
sta $ffff
|
||||
inc emit_a_ptr
|
||||
bne :+
|
||||
inc emit_a_ptr+1
|
||||
:
|
||||
inc xmodem_block_buffer_length
|
||||
bne :+
|
||||
inc xmodem_block_buffer_length+1
|
||||
:
|
||||
exit_emit_a:
|
||||
rts
|
||||
|
||||
.bss
|
||||
|
||||
original_tcp_callback: .res 2
|
||||
getc_timeout_end: .res 1
|
||||
getc_timeout_seconds: .res 1
|
||||
buffer_length: .res 2
|
||||
|
||||
.code
|
||||
|
||||
;send a file via XMODEM (checksum mode only, not CRC)
|
||||
;assumes that a tcp connection has already been set up, and that the other end is waiting to start receiving
|
||||
;inputs: AX points to routine to call once for each byte in file to send (e.g. save to disk, print to screen, whatever) - byte will be in A, carry flag set means EOF
|
||||
; xmodem_iac_escape should be set to non-zero if the remote end escapes $FF bytes (i.e. if it is a real telnet server)
|
||||
;outputs: none
|
||||
xmodem_send:
|
||||
stax get_byte+1
|
||||
jsr xmodem_transfer_setup
|
||||
lda #0
|
||||
sta at_eof
|
||||
|
||||
@send_block:
|
||||
ldax #sending
|
||||
jsr print_ascii_as_native
|
||||
|
||||
ldax #block_number_msg
|
||||
jsr print_ascii_as_native
|
||||
lda expected_block_number
|
||||
jsr print_hex
|
||||
jsr print_cr
|
||||
|
||||
|
||||
@wait_for_ack_or_nak:
|
||||
lda #XMODEM_TIMEOUT_SECONDS
|
||||
jsr getc
|
||||
bcs @synch_error
|
||||
cmp #ACK
|
||||
beq @got_ack
|
||||
cmp #NAK
|
||||
beq @got_nak
|
||||
|
||||
@synch_error:
|
||||
pha
|
||||
lda user_abort
|
||||
beq @no_user_abort
|
||||
pla
|
||||
jmp xmodem_transfer_exit
|
||||
@no_user_abort:
|
||||
|
||||
|
||||
;flush the input buffer
|
||||
lda #0
|
||||
sta buffer_length
|
||||
lda buffer_length+1
|
||||
|
||||
lda #'('
|
||||
jsr print_a
|
||||
pla
|
||||
jsr print_hex
|
||||
lda #')'
|
||||
jsr print_a
|
||||
|
||||
inc error_number
|
||||
ldax #sync_error_msg
|
||||
jsr print_ascii_as_native
|
||||
ldax #error_count_msg
|
||||
jsr print_ascii_as_native
|
||||
lda error_number
|
||||
jsr print_hex
|
||||
jsr print_cr
|
||||
lda error_number
|
||||
cmp #XMODEM_MAX_ERRORS
|
||||
bcc @wait_for_ack_or_nak
|
||||
lda #KPR_ERROR_TOO_MANY_ERRORS
|
||||
sta ip65_error
|
||||
|
||||
|
||||
jmp xmodem_transfer_exit
|
||||
|
||||
@got_ack:
|
||||
inc expected_block_number
|
||||
lda at_eof
|
||||
bne @send_eot
|
||||
@got_nak:
|
||||
lda #0
|
||||
sta checksum
|
||||
sta xmodem_block_buffer_length
|
||||
sta xmodem_block_buffer_length+1
|
||||
ldax #xmodem_block_buffer
|
||||
stax emit_a_ptr
|
||||
|
||||
lda #SOH
|
||||
jsr emit_a
|
||||
lda expected_block_number
|
||||
jsr emit_a
|
||||
eor #$ff
|
||||
jsr emit_a
|
||||
lda #$80
|
||||
sta block_ptr
|
||||
@copy_one_byte:
|
||||
lda at_eof
|
||||
bne @add_pad_byte
|
||||
|
||||
jsr get_byte
|
||||
bcc @got_byte
|
||||
;sec indicates EOF
|
||||
lda block_ptr
|
||||
cmp #$80 ;have we sent any data at all?
|
||||
bne @add_pad_byte
|
||||
|
||||
@send_eot:
|
||||
;if we get here, we should send an EOT, then read an ACK
|
||||
ldax #1
|
||||
stax tcp_send_data_len
|
||||
ldax #eot_packet
|
||||
jsr tcp_send
|
||||
|
||||
lda #XMODEM_TIMEOUT_SECONDS
|
||||
jsr getc ;should be an ACK coming back, doesn't really matter if we don't see it though
|
||||
|
||||
jmp xmodem_transfer_exit
|
||||
|
||||
@add_pad_byte:
|
||||
lda #PAD
|
||||
@got_byte:
|
||||
pha
|
||||
clc
|
||||
adc checksum
|
||||
sta checksum
|
||||
pla
|
||||
jsr emit_a
|
||||
dec block_ptr
|
||||
bne @copy_one_byte
|
||||
lda checksum
|
||||
jsr emit_a
|
||||
|
||||
ldax xmodem_block_buffer_length
|
||||
stax tcp_send_data_len
|
||||
ldax #xmodem_block_buffer
|
||||
jsr tcp_send
|
||||
bcc @send_ok
|
||||
ldax #send_error
|
||||
jsr print_ascii_as_native
|
||||
lda ip65_error
|
||||
jsr print_hex
|
||||
jsr print_cr
|
||||
@send_ok:
|
||||
jmp @send_block
|
||||
|
||||
rts
|
||||
|
||||
|
||||
|
||||
xmodem_transfer_setup:
|
||||
lda #0
|
||||
sta buffer_length
|
||||
sta buffer_length+1
|
||||
sta error_number
|
||||
sta user_abort
|
||||
lda #1
|
||||
sta expected_block_number
|
||||
|
||||
|
||||
ldax tcp_callback
|
||||
stax original_tcp_callback
|
||||
ldax #xmodem_tcp_callback
|
||||
stax tcp_callback
|
||||
rts
|
||||
|
||||
|
||||
;recieve a file via XMODEM (checksum mode only, not CRC)
|
||||
;assumes that a tcp connection has already been set up, and that the other end is waiting to start sending
|
||||
;inputs: AX points to routine to call once for each byte in downloaded file (e.g. save to disk, print to screen, whatever) - byte will be in A
|
||||
; xmodem_iac_escape should be set to non-zero if the remote end escapes $FF bytes (i.e. if it is a real telnet server)
|
||||
;outputs: none
|
||||
xmodem_receive:
|
||||
|
||||
stax got_byte+1
|
||||
jsr xmodem_transfer_setup
|
||||
jsr send_nak
|
||||
|
||||
|
||||
@next_block:
|
||||
lda #0
|
||||
sta block_ptr
|
||||
sta checksum
|
||||
ldax #expecting
|
||||
jsr print_ascii_as_native
|
||||
|
||||
ldax #block_number_msg
|
||||
jsr print_ascii_as_native
|
||||
lda expected_block_number
|
||||
jsr print_hex
|
||||
jsr print_cr
|
||||
|
||||
@wait_for_block_start:
|
||||
lda #XMODEM_TIMEOUT_SECONDS
|
||||
jsr getc
|
||||
bcc @got_block_start
|
||||
lda user_abort
|
||||
beq @no_user_abort
|
||||
sec
|
||||
jmp xmodem_transfer_exit
|
||||
@no_user_abort:
|
||||
jsr send_nak
|
||||
inc error_number
|
||||
ldax #timeout_msg
|
||||
jsr print_ascii_as_native
|
||||
ldax #error_count_msg
|
||||
jsr print_ascii_as_native
|
||||
lda error_number
|
||||
jsr print_hex
|
||||
jsr print_cr
|
||||
lda error_number
|
||||
cmp #XMODEM_MAX_ERRORS
|
||||
bcc @wait_for_block_start
|
||||
lda #KPR_ERROR_TOO_MANY_ERRORS
|
||||
sta ip65_error
|
||||
jmp xmodem_transfer_exit
|
||||
@got_block_start:
|
||||
cmp #EOT
|
||||
bne :+
|
||||
ldax #got_eot
|
||||
jsr print_ascii_as_native
|
||||
|
||||
jsr send_ack
|
||||
clc
|
||||
jmp xmodem_transfer_exit
|
||||
:
|
||||
|
||||
cmp #$81 ;jamming signal BBS seems to use $81 not $01 as SOH
|
||||
beq @got_soh
|
||||
cmp #SOH
|
||||
beq @got_soh
|
||||
lda #'!' ;we got an unexpected character
|
||||
jsr print_a
|
||||
jsr print_hex
|
||||
;we need to clear the input buffer
|
||||
@clear_input_buffer:
|
||||
lda #'!' ;we got an unexpected character
|
||||
jsr print_a
|
||||
lda #1
|
||||
jsr getc
|
||||
bcc @clear_input_buffer
|
||||
|
||||
|
||||
jmp @wait_for_block_start
|
||||
@got_soh:
|
||||
;now get block number
|
||||
lda #XMODEM_TIMEOUT_SECONDS
|
||||
jsr getc
|
||||
bcc :+
|
||||
jsr send_nak
|
||||
lda #'.'
|
||||
jmp print_a
|
||||
jmp @wait_for_block_start
|
||||
:
|
||||
sta actual_block_number
|
||||
|
||||
;now get block number check
|
||||
lda #XMODEM_TIMEOUT_SECONDS
|
||||
jsr getc
|
||||
bcc :+
|
||||
lda #'.'
|
||||
jmp print_a
|
||||
jsr send_nak
|
||||
jmp @wait_for_block_start
|
||||
:
|
||||
adc actual_block_number
|
||||
cmp #$ff
|
||||
beq :+
|
||||
lda #'?'
|
||||
jsr print_a
|
||||
jmp @wait_for_block_start
|
||||
:
|
||||
ldax #receiving
|
||||
jsr print_ascii_as_native
|
||||
|
||||
ldax #block_number_msg
|
||||
jsr print_ascii_as_native
|
||||
lda actual_block_number
|
||||
jsr print_hex
|
||||
jsr print_cr
|
||||
|
||||
@next_byte:
|
||||
lda #XMODEM_TIMEOUT_SECONDS
|
||||
jsr getc
|
||||
bcc :+
|
||||
jmp xmodem_transfer_exit
|
||||
:
|
||||
ldx block_ptr
|
||||
sta xmodem_block_buffer,x
|
||||
adc checksum
|
||||
sta checksum
|
||||
|
||||
inc block_ptr
|
||||
lda block_ptr
|
||||
bpl @next_byte
|
||||
|
||||
ldax #checksum_msg
|
||||
jsr print_ascii_as_native
|
||||
|
||||
lda checksum
|
||||
jsr print_hex
|
||||
|
||||
lda #'/'
|
||||
jsr print_a
|
||||
|
||||
lda #XMODEM_TIMEOUT_SECONDS
|
||||
jsr getc
|
||||
bcs xmodem_transfer_exit
|
||||
sta received_checksum
|
||||
jsr print_hex
|
||||
jsr print_cr
|
||||
|
||||
lda received_checksum
|
||||
cmp checksum
|
||||
beq @checksum_ok
|
||||
;checksum error :-(
|
||||
inc error_number
|
||||
ldax #checksum_error_msg
|
||||
jsr print_ascii_as_native
|
||||
ldax #error_count_msg
|
||||
jsr print_ascii_as_native
|
||||
lda error_number
|
||||
jsr print_hex
|
||||
jsr print_cr
|
||||
lda error_number
|
||||
cmp #XMODEM_MAX_ERRORS
|
||||
bcs :+
|
||||
jmp @wait_for_block_start
|
||||
:
|
||||
lda #KPR_ERROR_TOO_MANY_ERRORS
|
||||
sta ip65_error
|
||||
jmp xmodem_transfer_exit
|
||||
|
||||
jsr send_nak
|
||||
jmp @next_block
|
||||
|
||||
@checksum_ok:
|
||||
lda expected_block_number
|
||||
cmp actual_block_number
|
||||
bne @skip_block_output
|
||||
|
||||
lda #0
|
||||
sta block_ptr
|
||||
|
||||
@output_byte:
|
||||
ldx block_ptr
|
||||
lda xmodem_block_buffer,x
|
||||
jsr got_byte
|
||||
inc block_ptr
|
||||
lda block_ptr
|
||||
bpl @output_byte
|
||||
|
||||
inc expected_block_number
|
||||
|
||||
@skip_block_output:
|
||||
jsr send_ack
|
||||
jmp @next_block
|
||||
|
||||
clc
|
||||
|
||||
xmodem_transfer_exit:
|
||||
ldax original_tcp_callback
|
||||
stax tcp_callback
|
||||
|
||||
rts
|
||||
|
||||
xmodem_tcp_callback:
|
||||
lda tcp_inbound_data_length+1
|
||||
cmp #$ff
|
||||
bne @not_eof
|
||||
rts
|
||||
@not_eof:
|
||||
|
||||
ldax tcp_inbound_data_ptr
|
||||
stax copy_src
|
||||
ldax #xmodem_stream_buffer
|
||||
stax copy_dest
|
||||
stax next_char_ptr
|
||||
|
||||
ldax tcp_inbound_data_length
|
||||
stax buffer_length
|
||||
jsr copymem
|
||||
rts
|
||||
|
||||
send_nak:
|
||||
ldax #1
|
||||
stax tcp_send_data_len
|
||||
ldax #nak_packet
|
||||
jmp tcp_send
|
||||
|
||||
send_ack:
|
||||
ldax #1
|
||||
stax tcp_send_data_len
|
||||
ldax #ack_packet
|
||||
jmp tcp_send
|
||||
|
||||
|
||||
getc:
|
||||
jsr @real_getc
|
||||
bcc :+ ;of we got an error, then bail
|
||||
rts
|
||||
:
|
||||
cmp #$ff
|
||||
beq @got_ff
|
||||
clc
|
||||
rts
|
||||
@got_ff:
|
||||
lda xmodem_iac_escape
|
||||
bne @real_getc ;need to skip over the $FF and go read another byte
|
||||
lda #$ff
|
||||
clc
|
||||
rts
|
||||
|
||||
@real_getc:
|
||||
sta getc_timeout_seconds
|
||||
|
||||
clc
|
||||
jsr timer_seconds ;time of day clock: seconds (in BCD)
|
||||
sed
|
||||
adc getc_timeout_seconds
|
||||
cmp #$60
|
||||
bcc @timeout_set
|
||||
sec
|
||||
sbc #$60
|
||||
@timeout_set:
|
||||
cld
|
||||
sta getc_timeout_end
|
||||
|
||||
@poll_loop:
|
||||
jsr next_char
|
||||
bcs @no_char
|
||||
rts ;done!
|
||||
@no_char:
|
||||
jsr check_for_abort_key
|
||||
bcc @no_abort
|
||||
lda #KPR_ERROR_ABORTED_BY_USER
|
||||
sta ip65_error
|
||||
inc user_abort
|
||||
rts
|
||||
@no_abort:
|
||||
jsr ip65_process
|
||||
jsr timer_seconds ;time of day clock: seconds
|
||||
cmp getc_timeout_end
|
||||
bne @poll_loop
|
||||
lda #00
|
||||
sec
|
||||
rts
|
||||
|
||||
|
||||
|
||||
.rodata
|
||||
ack_packet: .byte ACK
|
||||
nak_packet: .byte NAK
|
||||
eot_packet: .byte EOT
|
||||
|
||||
block_number_msg: .byte " block $",0
|
||||
expecting: .byte "expecting",0
|
||||
receiving: .byte "receiving",0
|
||||
sending: .byte "sending",0
|
||||
got_eot: .byte "end of transmission",10,0
|
||||
|
||||
bad_block_number: .byte "bad block number",0
|
||||
checksum_msg: .byte "checksum $",0
|
||||
checksum_error_msg : .byte "checksum",0
|
||||
timeout_msg: .byte "timeout error",0
|
||||
sync_error_msg: .byte "sync",0
|
||||
error_count_msg: .byte " error - error count $",0
|
||||
send_error: .byte " send error - $",0
|
||||
|
||||
.segment "APP_SCRATCH"
|
||||
xmodem_stream_buffer: .res 1600
|
||||
xmodem_block_buffer: .res 300
|
||||
xmodem_block_buffer_length: .res 2
|
||||
expected_block_number: .res 1
|
||||
actual_block_number: .res 1
|
||||
checksum: .res 1
|
||||
received_checksum: .res 1
|
||||
block_ptr: .res 1
|
||||
error_number: .res 1
|
||||
user_abort: .res 1
|
||||
xmodem_iac_escape: .res 1
|
||||
at_eof: .res 1
|
||||
;-- LICENSE FOR xmodem.s --
|
||||
; 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/
|
||||
;
|
||||
; 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.
|
||||
;
|
||||
; The Original Code is ip65.
|
||||
;
|
||||
; The Initial Developer of the Original Code is Jonno Downes,
|
||||
; jonno@jamtronix.com.
|
||||
; Portions created by the Initial Developer are Copyright (C) 2009
|
||||
; Jonno Downes. All Rights Reserved.
|
||||
; -- LICENSE END --
|
@ -23,9 +23,7 @@ all: prg bin
|
||||
prg: \
|
||||
ip65 \
|
||||
drivers \
|
||||
cartapi.prg \
|
||||
cifs_tcp.prg \
|
||||
diskio.prg \
|
||||
dns.prg \
|
||||
dottedquad.prg \
|
||||
getc.prg \
|
||||
@ -38,9 +36,7 @@ prg: \
|
||||
tcp_tcp.prg \
|
||||
tftp.prg \
|
||||
vic20.prg \
|
||||
vt100.prg \
|
||||
wiznet.prg \
|
||||
xmodem_tcp.prg
|
||||
wiznet.prg
|
||||
|
||||
bin: \
|
||||
ip65 \
|
||||
|
441
test/cartapi.s
441
test/cartapi.s
@ -1,441 +0,0 @@
|
||||
;test the "Kipper Kartridge API"
|
||||
.ifndef KPR_API_VERSION_NUMBER
|
||||
.define EQU =
|
||||
.include "../inc/kipper_constants.i"
|
||||
.endif
|
||||
|
||||
.include "../ip65/copymem.s"
|
||||
|
||||
; load A/X macro
|
||||
.macro ldax arg
|
||||
.if (.match (.left (1, arg), #)) ; immediate mode
|
||||
lda #<(.right (.tcount (arg)-1, arg))
|
||||
ldx #>(.right (.tcount (arg)-1, arg))
|
||||
.else ; assume absolute or zero page
|
||||
lda arg
|
||||
ldx 1+(arg)
|
||||
.endif
|
||||
.endmacro
|
||||
|
||||
; store A/X macro
|
||||
.macro stax arg
|
||||
sta arg
|
||||
stx 1+(arg)
|
||||
.endmacro
|
||||
|
||||
print_a = $ffd2
|
||||
|
||||
.macro cout arg
|
||||
lda arg
|
||||
jsr print_a
|
||||
.endmacro
|
||||
|
||||
.zeropage
|
||||
temp_ptr: .res 2
|
||||
|
||||
.bss
|
||||
kipper_param_buffer: .res $20
|
||||
block_number: .res $0
|
||||
|
||||
.segment "STARTUP" ;this is what gets put at the start of the file on the C64
|
||||
|
||||
.word basicstub ; load address
|
||||
|
||||
.macro print arg
|
||||
ldax arg
|
||||
ldy #KPR_PRINT_ASCIIZ
|
||||
jsr KPR_DISPATCH_VECTOR
|
||||
.endmacro
|
||||
|
||||
.macro print_cr
|
||||
lda #13
|
||||
jsr print_a
|
||||
.endmacro
|
||||
|
||||
.macro call arg
|
||||
ldy arg
|
||||
jsr KPR_DISPATCH_VECTOR
|
||||
.endmacro
|
||||
|
||||
basicstub:
|
||||
.word @nextline
|
||||
.word 2003
|
||||
.byte $9e
|
||||
.byte <(((init / 1000) .mod 10) + $30)
|
||||
.byte <(((init / 100 ) .mod 10) + $30)
|
||||
.byte <(((init / 10 ) .mod 10) + $30)
|
||||
.byte <(((init ) .mod 10) + $30)
|
||||
.byte 0
|
||||
@nextline:
|
||||
.word 0
|
||||
|
||||
|
||||
;look for KIPPER signature at location pointed at by AX
|
||||
look_for_signature:
|
||||
stax temp_ptr
|
||||
ldy #5
|
||||
@check_one_byte:
|
||||
lda (temp_ptr),y
|
||||
cmp kipper_signature,y
|
||||
bne @bad_match
|
||||
dey
|
||||
bpl@check_one_byte
|
||||
clc
|
||||
rts
|
||||
@bad_match:
|
||||
sec
|
||||
rts
|
||||
|
||||
init:
|
||||
|
||||
|
||||
ldax #KPR_CART_SIGNATURE ;where signature should be in cartridge
|
||||
jsr look_for_signature
|
||||
bcc @found_kipper_signature
|
||||
jmp kipper_signature_not_found
|
||||
|
||||
@found_kipper_signature:
|
||||
|
||||
print #initializing
|
||||
|
||||
ldy #KPR_INITIALIZE
|
||||
jsr KPR_DISPATCH_VECTOR
|
||||
bcc :+
|
||||
print #failed
|
||||
jsr print_errorcode
|
||||
jmp bad_boot
|
||||
:
|
||||
|
||||
print #ok
|
||||
print_cr
|
||||
|
||||
call #KPR_PRINT_IP_CONFIG
|
||||
|
||||
;DNS resolution test
|
||||
|
||||
ldax #test_hostname
|
||||
stax kipper_param_buffer+KPR_DNS_HOSTNAME
|
||||
|
||||
call #KPR_PRINT_ASCIIZ
|
||||
|
||||
cout #' '
|
||||
cout #':'
|
||||
cout #' '
|
||||
|
||||
ldax #kipper_param_buffer
|
||||
call #KPR_DNS_RESOLVE
|
||||
bcc :+
|
||||
print #dns_lookup_failed_msg
|
||||
print_cr
|
||||
jmp print_errorcode
|
||||
:
|
||||
ldax #kipper_param_buffer+KPR_DNS_HOSTNAME_IP
|
||||
call #KPR_PRINT_DOTTED_QUAD
|
||||
print_cr
|
||||
|
||||
ldax #64
|
||||
call #KPR_UDP_REMOVE_LISTENER ;should generate an error since there is no listener on port 64
|
||||
jsr print_errorcode
|
||||
|
||||
|
||||
;tftp send test
|
||||
lda #0
|
||||
sta block_number
|
||||
ldax #test_file
|
||||
stax kipper_param_buffer+KPR_TFTP_FILENAME
|
||||
ldax #tftp_upload_callback
|
||||
stax kipper_param_buffer+KPR_TFTP_POINTER
|
||||
ldax #kipper_param_buffer
|
||||
call #KPR_TFTP_CALLBACK_UPLOAD
|
||||
bcc :+
|
||||
jmp print_errorcode
|
||||
:
|
||||
|
||||
|
||||
@download_test:
|
||||
;tftp download callback test
|
||||
lda #0
|
||||
sta block_number
|
||||
ldax #test_file
|
||||
stax kipper_param_buffer+KPR_TFTP_FILENAME
|
||||
ldax #tftp_download_callback
|
||||
stax kipper_param_buffer+KPR_TFTP_POINTER
|
||||
ldax #kipper_param_buffer
|
||||
call #KPR_TFTP_CALLBACK_DOWNLOAD
|
||||
bcc :+
|
||||
jmp print_errorcode
|
||||
:
|
||||
lda #'$'
|
||||
jsr print_a
|
||||
lda kipper_param_buffer+KPR_TFTP_FILESIZE+1
|
||||
jsr print_hex
|
||||
lda kipper_param_buffer+KPR_TFTP_FILESIZE
|
||||
jsr print_hex
|
||||
print #bytes_download
|
||||
print_cr
|
||||
|
||||
;udp callback test
|
||||
|
||||
ldax #64 ;listen on port 64
|
||||
stax kipper_param_buffer+KPR_UDP_LISTENER_PORT
|
||||
ldax #udp_callback
|
||||
stax kipper_param_buffer+KPR_UDP_LISTENER_CALLBACK
|
||||
ldax #kipper_param_buffer
|
||||
call #KPR_UDP_ADD_LISTENER
|
||||
bcc :+
|
||||
print #failed
|
||||
jsr print_errorcode
|
||||
jmp bad_boot
|
||||
:
|
||||
|
||||
print #listening
|
||||
|
||||
|
||||
@loop_forever:
|
||||
jsr KPR_PERIODIC_PROCESSING_VECTOR
|
||||
jmp @loop_forever
|
||||
|
||||
|
||||
tftp_upload_callback:
|
||||
stax copy_dest
|
||||
inc block_number
|
||||
print #sending
|
||||
print #block_no
|
||||
lda block_number
|
||||
jsr print_hex
|
||||
print_cr
|
||||
|
||||
lda block_number
|
||||
asl
|
||||
cmp #$10
|
||||
beq @last_block
|
||||
clc
|
||||
adc #$a0
|
||||
tax
|
||||
lda #0
|
||||
stax copy_src
|
||||
ldax #$200
|
||||
jsr copymem
|
||||
ldax #$200
|
||||
rts
|
||||
@last_block:
|
||||
ldax #0
|
||||
rts
|
||||
|
||||
tftp_download_callback:
|
||||
inc block_number
|
||||
print #received
|
||||
print #block_no
|
||||
lda block_number
|
||||
jsr print_hex
|
||||
print_cr
|
||||
rts
|
||||
|
||||
udp_callback:
|
||||
|
||||
ldax #kipper_param_buffer
|
||||
call #KPR_GET_INPUT_PACKET_INFO
|
||||
|
||||
print #port
|
||||
|
||||
lda kipper_param_buffer+KPR_LOCAL_PORT+1
|
||||
call #KPR_PRINT_HEX
|
||||
|
||||
lda kipper_param_buffer+KPR_LOCAL_PORT
|
||||
call #KPR_PRINT_HEX
|
||||
|
||||
print_cr
|
||||
|
||||
print #received
|
||||
print #from
|
||||
|
||||
ldax #kipper_param_buffer+KPR_REMOTE_IP
|
||||
call #KPR_PRINT_DOTTED_QUAD
|
||||
|
||||
cout #' '
|
||||
|
||||
print #port
|
||||
|
||||
lda kipper_param_buffer+KPR_REMOTE_PORT+1
|
||||
call #KPR_PRINT_HEX
|
||||
lda kipper_param_buffer+KPR_REMOTE_PORT
|
||||
call #KPR_PRINT_HEX
|
||||
|
||||
print_cr
|
||||
|
||||
print #length
|
||||
|
||||
lda kipper_param_buffer+KPR_PAYLOAD_LENGTH+1
|
||||
call #KPR_PRINT_HEX
|
||||
lda kipper_param_buffer+KPR_PAYLOAD_LENGTH
|
||||
call #KPR_PRINT_HEX
|
||||
print_cr
|
||||
print #data
|
||||
|
||||
ldax kipper_param_buffer+KPR_PAYLOAD_POINTER
|
||||
|
||||
stax temp_ptr
|
||||
ldx kipper_param_buffer+KPR_PAYLOAD_LENGTH ;assumes length is < 255
|
||||
ldy #0
|
||||
:
|
||||
lda (temp_ptr),y
|
||||
jsr print_a
|
||||
iny
|
||||
dex
|
||||
bpl :-
|
||||
|
||||
print_cr
|
||||
|
||||
;make and send reply
|
||||
ldax #reply_message
|
||||
stax kipper_param_buffer+KPR_PAYLOAD_POINTER
|
||||
|
||||
ldax #reply_message_length
|
||||
stax kipper_param_buffer+KPR_PAYLOAD_LENGTH
|
||||
|
||||
ldax #kipper_param_buffer
|
||||
call #KPR_SEND_UDP_PACKET
|
||||
bcc :+
|
||||
jmp print_errorcode
|
||||
:
|
||||
print #reply_sent
|
||||
rts
|
||||
|
||||
bad_boot:
|
||||
print #press_a_key_to_continue
|
||||
restart:
|
||||
jsr get_key
|
||||
jmp $fce2 ;do a cold start
|
||||
|
||||
|
||||
print_errorcode:
|
||||
print #error_code
|
||||
call #KPR_GET_LAST_ERROR
|
||||
call #KPR_PRINT_HEX
|
||||
print_cr
|
||||
rts
|
||||
|
||||
kipper_signature_not_found:
|
||||
|
||||
ldy #0
|
||||
:
|
||||
lda kipper_signature_not_found_message,y
|
||||
beq restart
|
||||
jsr print_a
|
||||
iny
|
||||
jmp :-
|
||||
|
||||
|
||||
;use C64 Kernel ROM function to read a key
|
||||
;inputs: none
|
||||
;outputs: A contains ASCII value of key just pressed
|
||||
get_key:
|
||||
jsr $ffe4
|
||||
cmp #0
|
||||
beq get_key
|
||||
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
|
||||
|
||||
.rodata
|
||||
hexdigits:
|
||||
.byte "0123456789ABCDEF"
|
||||
|
||||
test_hostname:
|
||||
.byte "RETROHACKERS.COM",0 ;this should be an A record
|
||||
|
||||
received:
|
||||
.asciiz "RECEIVED "
|
||||
sending:
|
||||
.asciiz "SENDING "
|
||||
from:
|
||||
.asciiz " FROM: "
|
||||
|
||||
listening:
|
||||
.byte "LISTENING ON UDP PORT 64",13,0
|
||||
|
||||
|
||||
reply_sent:
|
||||
.byte "REPLY SENT.",13,0
|
||||
|
||||
|
||||
initializing:
|
||||
.byte "INITIALIZING ",0
|
||||
|
||||
port:
|
||||
.byte "PORT: $",0
|
||||
|
||||
length:
|
||||
.byte "LENGTH: $",0
|
||||
|
||||
data:
|
||||
.byte "DATA: ",0
|
||||
|
||||
block_no:
|
||||
.byte "BLOCK: $",0
|
||||
|
||||
error_code:
|
||||
.asciiz "ERROR CODE: $"
|
||||
press_a_key_to_continue:
|
||||
.byte "PRESS A KEY TO CONTINUE",13,0
|
||||
|
||||
failed:
|
||||
.byte "FAILED ", 0
|
||||
|
||||
ok:
|
||||
.byte "OK ", 0
|
||||
|
||||
kipper_signature_not_found_message:
|
||||
.byte "NO KIPPER API FOUND",13,"PRESS ANY KEY TO RESET", 0
|
||||
|
||||
dns_lookup_failed_msg:
|
||||
.byte "DNS LOOKUP FAILED", 0
|
||||
|
||||
bytes_download: .byte "BYTES DOWNLOADED",13,0
|
||||
|
||||
reply_message:
|
||||
.byte "PONG!"
|
||||
reply_message_end:
|
||||
reply_message_length=reply_message_end-reply_message
|
||||
|
||||
test_file:
|
||||
.byte "TESTFILE.BIN",0
|
||||
|
||||
kipper_signature:
|
||||
.byte "KIPPER" ; API signature
|
||||
|
||||
|
||||
;-- LICENSE FOR test_cart_api.s --
|
||||
; 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/
|
||||
;
|
||||
; 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.
|
||||
;
|
||||
; The Original Code is ip65.
|
||||
;
|
||||
; The Initial Developer of the Original Code is Jonno Downes,
|
||||
; jonno@jamtronix.com.
|
||||
; Portions created by the Initial Developer are Copyright (C) 2009
|
||||
; Jonno Downes. All Rights Reserved.
|
||||
; -- LICENSE END --
|
471
test/diskio.s
471
test/diskio.s
@ -1,471 +0,0 @@
|
||||
|
||||
.ifndef KIPPER_API_VERSION_NUMBER
|
||||
.define EQU =
|
||||
.include "../inc/kipper_constants.i"
|
||||
.endif
|
||||
|
||||
.include "../inc/common.i"
|
||||
.include "../inc/commonprint.i"
|
||||
.import print_a
|
||||
.import cfg_get_configuration_ptr
|
||||
.import io_device_no
|
||||
.import io_sector_no
|
||||
.import io_track_no
|
||||
.import io_read_sector
|
||||
.import io_write_sector
|
||||
.import io_read_file_with_callback
|
||||
.import io_read_file
|
||||
.import io_filename
|
||||
.import io_filesize
|
||||
.import io_load_address
|
||||
.import io_callback
|
||||
.import get_key
|
||||
.import ip65_error
|
||||
.import io_read_catalogue_ex
|
||||
|
||||
.macro cout arg
|
||||
lda arg
|
||||
jsr print_a
|
||||
.endmacro
|
||||
|
||||
|
||||
|
||||
.bss
|
||||
sector_buffer: .res 256
|
||||
output_buffer: .res 520
|
||||
.export output_buffer
|
||||
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
|
||||
|
||||
basicstub:
|
||||
.word @nextline
|
||||
.word 2003
|
||||
.byte $9e
|
||||
.byte <(((init / 1000) .mod 10) + $30)
|
||||
.byte <(((init / 100 ) .mod 10) + $30)
|
||||
.byte <(((init / 10 ) .mod 10) + $30)
|
||||
.byte <(((init ) .mod 10) + $30)
|
||||
.byte 0
|
||||
@nextline:
|
||||
.word 0
|
||||
|
||||
init:
|
||||
|
||||
;switch to lower case charset
|
||||
lda #23
|
||||
sta $d018
|
||||
|
||||
;test we can read catalogue the hard way
|
||||
ldax #loading
|
||||
jsr print
|
||||
ldax #dir_fname
|
||||
stax io_filename
|
||||
jsr print
|
||||
|
||||
|
||||
jsr print_cr
|
||||
lda #01
|
||||
sta io_device_no
|
||||
|
||||
ldax #readfile_callback
|
||||
stax io_callback
|
||||
ldax #$3000
|
||||
jsr io_read_file
|
||||
bcc :+
|
||||
jsr print_error_code
|
||||
rts
|
||||
:
|
||||
|
||||
|
||||
|
||||
;test we can write sector to default desk
|
||||
|
||||
ldx #$00
|
||||
@fill_sector_loop:
|
||||
txa
|
||||
sta sector_buffer,x
|
||||
inx
|
||||
bne @fill_sector_loop
|
||||
|
||||
lda #$01
|
||||
sta io_track_no
|
||||
lda #$01
|
||||
sta io_sector_no
|
||||
ldax #write_sector
|
||||
jsr print
|
||||
lda io_sector_no
|
||||
jsr print_hex
|
||||
jsr print_cr
|
||||
ldax #sector_buffer
|
||||
jsr io_write_sector
|
||||
|
||||
bcc :+
|
||||
jsr print_error_code
|
||||
rts
|
||||
:
|
||||
|
||||
|
||||
|
||||
inc io_sector_no
|
||||
ldax #write_sector
|
||||
jsr print
|
||||
lda io_sector_no
|
||||
jsr print_hex
|
||||
jsr print_cr
|
||||
ldax #sector_buffer
|
||||
jsr io_write_sector
|
||||
|
||||
bcc :+
|
||||
jsr print_error_code
|
||||
rts
|
||||
:
|
||||
|
||||
inc io_sector_no
|
||||
ldax #write_sector
|
||||
jsr print
|
||||
lda io_sector_no
|
||||
jsr print_hex
|
||||
jsr print_cr
|
||||
ldax #sector_buffer
|
||||
jsr io_write_sector
|
||||
|
||||
bcc :+
|
||||
jsr print_error_code
|
||||
rts
|
||||
:
|
||||
|
||||
|
||||
|
||||
;test we can read a sector from default desk
|
||||
ldax #read_sector
|
||||
jsr print
|
||||
|
||||
lda #$01
|
||||
sta io_track_no
|
||||
lda #$03
|
||||
sta io_sector_no
|
||||
ldax #sector_buffer
|
||||
jsr io_read_sector
|
||||
bcc :+
|
||||
jsr print_error_code
|
||||
rts
|
||||
:
|
||||
|
||||
jsr dump_sector
|
||||
|
||||
;test we can read the catalogue
|
||||
ldax #read_catalogue
|
||||
jsr print
|
||||
|
||||
lda #01
|
||||
sta io_device_no
|
||||
|
||||
ldax #directory_buffer
|
||||
jsr io_read_catalogue_ex
|
||||
|
||||
bcc @no_error_on_catalogue
|
||||
jsr print_error_code
|
||||
rts
|
||||
@no_error_on_catalogue:
|
||||
ldax #directory_buffer
|
||||
jsr print_catalogue
|
||||
|
||||
;test we can read without callbacks to fixed buffer
|
||||
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 #$3000
|
||||
jsr io_read_file
|
||||
bcc :+
|
||||
jsr print_error_code
|
||||
rts
|
||||
:
|
||||
|
||||
ldax io_filesize
|
||||
jsr print_integer
|
||||
ldax #bytes_to
|
||||
jsr print
|
||||
lda io_load_address+1
|
||||
jsr print_hex
|
||||
lda io_load_address
|
||||
jsr print_hex
|
||||
jsr print_cr
|
||||
|
||||
|
||||
;test we can read without callbacks to address in file
|
||||
ldax #loading
|
||||
jsr print
|
||||
ldax #fname2
|
||||
stax io_filename
|
||||
jsr print
|
||||
|
||||
|
||||
jsr print_cr
|
||||
lda #01
|
||||
sta io_device_no
|
||||
|
||||
ldax #readfile_callback
|
||||
stax io_callback
|
||||
ldax #$0000
|
||||
jsr io_read_file
|
||||
bcc :+
|
||||
jsr print_error_code
|
||||
rts
|
||||
:
|
||||
|
||||
ldax io_filesize
|
||||
jsr print_integer
|
||||
ldax #bytes_to
|
||||
jsr print
|
||||
lda io_load_address+1
|
||||
jsr print_hex
|
||||
lda io_load_address
|
||||
jsr print_hex
|
||||
jsr print_cr
|
||||
|
||||
jsr wait_for_keypress
|
||||
|
||||
;test we can read via callbacks
|
||||
|
||||
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 :+
|
||||
jsr print_error_code
|
||||
:
|
||||
|
||||
|
||||
|
||||
rts
|
||||
|
||||
|
||||
@error:
|
||||
jsr print_cr
|
||||
lda ip65_error
|
||||
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+1
|
||||
:
|
||||
pha
|
||||
pla ;reload A so flags are set correctly
|
||||
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
|
||||
|
||||
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
|
||||
sta current_byte_in_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 #':'
|
||||
jsr print_a
|
||||
lda #' '
|
||||
jsr print_a
|
||||
|
||||
lda #0
|
||||
sta current_byte_in_row
|
||||
|
||||
;first the hex values
|
||||
@dump_byte:
|
||||
ldy current_byte_in_sector
|
||||
lda sector_buffer,y
|
||||
jsr print_hex
|
||||
lda #' '
|
||||
jsr print_a
|
||||
inc current_byte_in_sector
|
||||
inc current_byte_in_row
|
||||
lda current_byte_in_row
|
||||
cmp #08
|
||||
bne @dump_byte
|
||||
|
||||
;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
|
||||
inc current_byte_in_sector
|
||||
beq @last_byte
|
||||
dec current_byte_in_row
|
||||
bne @print_byte
|
||||
jsr print_cr
|
||||
jmp @one_row
|
||||
@last_byte:
|
||||
jsr print_cr
|
||||
jsr wait_for_keypress
|
||||
rts
|
||||
|
||||
|
||||
|
||||
write_sector:
|
||||
.byte "WRITING SECTOR",0
|
||||
|
||||
read_sector:
|
||||
.byte "READING SECTOR",13,0
|
||||
|
||||
|
||||
dir_fname: .byte "$",0
|
||||
|
||||
read_catalogue:
|
||||
.byte "READING CATALOGUE",13,0
|
||||
fname:
|
||||
.byte "TEST_DISK_IO.PRG",0
|
||||
|
||||
fname2:
|
||||
.byte "SCREEN.PRG",0
|
||||
|
||||
loading: .byte "LOADING ",0
|
||||
.rodata
|
||||
|
||||
filetype:
|
||||
.byte "TYPE: $",0
|
||||
|
||||
sectors:
|
||||
.byte " SECTORS: $",0
|
||||
error:
|
||||
.byte "ERROR - $", 0
|
||||
|
||||
failed:
|
||||
.byte "FAILED ", 0
|
||||
|
||||
ok:
|
||||
.byte "OK ", 0
|
||||
|
||||
bytes:
|
||||
.byte " BYTES.", 0
|
||||
|
||||
bytes_to:
|
||||
.byte " BYTES TO $", 0
|
||||
|
||||
|
||||
|
||||
|
||||
;-- LICENSE FOR test_disk_io.s --
|
||||
; 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/
|
||||
;
|
||||
; 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.
|
||||
;
|
||||
; The Original Code is ip65.
|
||||
;
|
||||
; The Initial Developer of the Original Code is Jonno Downes,
|
||||
; jonno@jamtronix.com.
|
||||
; Portions created by the Initial Developer are Copyright (C) 2009
|
||||
; Jonno Downes. All Rights Reserved.
|
||||
; -- LICENSE END --
|
105
test/vt100.s
105
test/vt100.s
@ -1,105 +0,0 @@
|
||||
|
||||
.ifndef KIPPER_API_VERSION_NUMBER
|
||||
.define EQU =
|
||||
.include "../inc/kipper_constants.i"
|
||||
.endif
|
||||
|
||||
.include "../inc/common.i"
|
||||
.include "../inc/commonprint.i"
|
||||
.import print_a
|
||||
.import cfg_get_configuration_ptr
|
||||
|
||||
.import get_key
|
||||
.import timer_init
|
||||
.import beep
|
||||
.segment "STARTUP" ;this is what gets put at the start of the file on the C64
|
||||
|
||||
.word basicstub ; load address
|
||||
|
||||
.import vt100_init_terminal
|
||||
.import vt100_process_inbound_char
|
||||
|
||||
basicstub:
|
||||
.word @nextline
|
||||
.word 2003
|
||||
.byte $9e
|
||||
.byte <(((init / 1000) .mod 10) + $30)
|
||||
.byte <(((init / 100 ) .mod 10) + $30)
|
||||
.byte <(((init / 10 ) .mod 10) + $30)
|
||||
.byte <(((init ) .mod 10) + $30)
|
||||
.byte 0
|
||||
@nextline:
|
||||
.word 0
|
||||
|
||||
.code
|
||||
init:
|
||||
|
||||
jsr timer_init
|
||||
jsr vt100_init_terminal
|
||||
ldax #string1
|
||||
jsr emit_string
|
||||
|
||||
rts
|
||||
|
||||
|
||||
emit_string:
|
||||
stax next_byte+1
|
||||
:
|
||||
jsr next_byte
|
||||
|
||||
beq @done
|
||||
jsr vt100_process_inbound_char
|
||||
jmp :-
|
||||
@done:
|
||||
rts
|
||||
|
||||
next_byte:
|
||||
lda $ffff
|
||||
inc next_byte+1
|
||||
bne :+
|
||||
inc next_byte+2
|
||||
:
|
||||
cmp #0
|
||||
rts
|
||||
|
||||
|
||||
.rodata
|
||||
|
||||
string1:
|
||||
.byte $1b,"[H" ;HOME
|
||||
.byte "hello world",13,10
|
||||
.byte $1b,"[1m" ;BOLD
|
||||
.byte "hello bold",13,10
|
||||
.byte $1b,"[7m" ;reverse
|
||||
.byte "hello reverse bold",13,10
|
||||
.byte $1b,"7" ;save cursor position & attributes
|
||||
.byte $1b,"[m" ;normal
|
||||
.byte "hello normal",13,10
|
||||
.byte 07
|
||||
.byte "that was a beep!",13,10
|
||||
.byte $1b,"8" ;restor cursor position & attributes
|
||||
.byte $1b,"[20;1H"; ;move to row 20, pos 1
|
||||
.byte "ABCDEFGhijklmnopqRsTuVwXyZ01234567890"
|
||||
.byte $1b,"[20;10f"; ;move to row 20, pos 1
|
||||
.byte $1b,"[1K"
|
||||
|
||||
.byte 0
|
||||
|
||||
;-- LICENSE FOR test_vt00.s --
|
||||
; 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/
|
||||
;
|
||||
; 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.
|
||||
;
|
||||
; The Original Code is ip65.
|
||||
;
|
||||
; The Initial Developer of the Original Code is Jonno Downes,
|
||||
; jonno@jamtronix.com.
|
||||
; Portions created by the Initial Developer are Copyright (C) 2009
|
||||
; Jonno Downes. All Rights Reserved.
|
||||
; -- LICENSE END --
|
326
test/xmodem.s
326
test/xmodem.s
@ -1,326 +0,0 @@
|
||||
.include "../inc/common.i"
|
||||
.include "../inc/commonprint.i"
|
||||
.include "../inc/net.i"
|
||||
|
||||
.import parse_dotted_quad
|
||||
.import dotted_quad_value
|
||||
|
||||
.import tcp_listen
|
||||
.import tcp_callback
|
||||
.import ip65_error
|
||||
.import get_key_ip65
|
||||
|
||||
.import tcp_connect
|
||||
.import tcp_connect_ip
|
||||
|
||||
.import tcp_inbound_data_ptr
|
||||
.import tcp_inbound_data_length
|
||||
|
||||
.import xmodem_send
|
||||
.import xmodem_receive
|
||||
.import xmodem_iac_escape
|
||||
|
||||
.import tcp_send
|
||||
.import tcp_send_data_len
|
||||
.import tcp_send_string
|
||||
.import tcp_close
|
||||
.import __CODE_LOAD__
|
||||
.import __CODE_SIZE__
|
||||
.import __RODATA_SIZE__
|
||||
.import __DATA_SIZE__
|
||||
|
||||
|
||||
.segment "STARTUP" ;this is what gets put at the start of the file on the C64
|
||||
|
||||
.word basicstub ; load address
|
||||
|
||||
basicstub:
|
||||
.word @nextline
|
||||
.word 2003
|
||||
.byte $9e
|
||||
.byte <(((init / 1000) .mod 10) + $30)
|
||||
.byte <(((init / 100 ) .mod 10) + $30)
|
||||
.byte <(((init / 10 ) .mod 10) + $30)
|
||||
.byte <(((init ) .mod 10) + $30)
|
||||
.byte 0
|
||||
@nextline:
|
||||
.word 0
|
||||
|
||||
.segment "EXEHDR" ;this is what gets put an the start of the file on the Apple 2
|
||||
.addr __CODE_LOAD__-$11 ; Start address
|
||||
.word __CODE_SIZE__+__RODATA_SIZE__+__DATA_SIZE__+4 ; Size
|
||||
jmp init
|
||||
|
||||
.bss
|
||||
packet_count: .res 1
|
||||
.code
|
||||
|
||||
init:
|
||||
|
||||
|
||||
lda #14
|
||||
jsr print_a ;switch to lower case
|
||||
|
||||
|
||||
lda #1
|
||||
; lda #0
|
||||
sta xmodem_iac_escape
|
||||
lda #0
|
||||
sta $dc08 ;set deciseconds - starts TOD going
|
||||
jsr print_cr
|
||||
init_ip_via_dhcp
|
||||
jsr print_ip_config
|
||||
|
||||
ldax #starting
|
||||
jsr print_ascii_as_native
|
||||
jsr print_cr
|
||||
|
||||
|
||||
;connect to port 1000 - xmodem server
|
||||
|
||||
ldax #tcp_callback_routine
|
||||
stax tcp_callback
|
||||
ldax tcp_dest_ip
|
||||
stax tcp_connect_ip
|
||||
ldax tcp_dest_ip+2
|
||||
stax tcp_connect_ip+2
|
||||
|
||||
lda #0
|
||||
sta packet_count
|
||||
ldax #1000
|
||||
jsr tcp_connect
|
||||
|
||||
bcc :+
|
||||
jmp check_for_error
|
||||
:
|
||||
|
||||
ldax #first_message
|
||||
jsr tcp_send_string
|
||||
:
|
||||
jsr ip65_process
|
||||
lda packet_count
|
||||
beq :-
|
||||
|
||||
ldax #connected
|
||||
jsr print_ascii_as_native
|
||||
jsr download_file
|
||||
jsr check_for_error
|
||||
jsr upload_file
|
||||
jsr check_for_error
|
||||
jsr tcp_close
|
||||
rts
|
||||
|
||||
upload_file:
|
||||
ldax #uploading
|
||||
jsr print_ascii_as_native
|
||||
|
||||
ldax #start_upload
|
||||
jsr tcp_send_string
|
||||
bcc :+
|
||||
@error:
|
||||
jsr check_for_error
|
||||
:
|
||||
|
||||
jsr open_upload_file
|
||||
bcc :+
|
||||
jmp check_for_error
|
||||
:
|
||||
ldax #read_byte
|
||||
jsr xmodem_send
|
||||
jsr close_file
|
||||
|
||||
rts
|
||||
|
||||
read_byte:
|
||||
lda eof
|
||||
beq @not_eof
|
||||
sec
|
||||
rts
|
||||
@not_eof:
|
||||
ldx #$02 ; filenumber 2 = output file
|
||||
jsr $FFC6 ; call CHKIN (file 2 now used as input)
|
||||
|
||||
jsr $FFCF ; call CHRIN (get a byte from file)
|
||||
pha
|
||||
|
||||
jsr $FFB7 ; call READST (read status byte)
|
||||
|
||||
beq :+ ; either EOF or read error
|
||||
inc eof
|
||||
:
|
||||
ldx #$00 ; filenumber 0 = console
|
||||
jsr $FFC6 ; call CHKIN (console now used as input)
|
||||
|
||||
pla
|
||||
clc
|
||||
rts
|
||||
|
||||
eof: .byte $0
|
||||
|
||||
|
||||
download_file:
|
||||
ldax #downloading
|
||||
jsr print_ascii_as_native
|
||||
|
||||
ldax #start_download
|
||||
jsr tcp_send_string
|
||||
bcc :+
|
||||
@error:
|
||||
jsr check_for_error
|
||||
:
|
||||
|
||||
jsr open_download_file
|
||||
bcc :+
|
||||
jmp check_for_error
|
||||
:
|
||||
ldax #write_byte
|
||||
jsr xmodem_receive
|
||||
jsr close_file
|
||||
|
||||
|
||||
rts
|
||||
|
||||
|
||||
tcp_callback_routine:
|
||||
|
||||
inc packet_count
|
||||
rts
|
||||
|
||||
|
||||
|
||||
|
||||
check_for_error:
|
||||
lda ip65_error
|
||||
beq @exit
|
||||
ldax #error_code
|
||||
jsr print
|
||||
lda ip65_error
|
||||
jsr print_hex
|
||||
jsr print_cr
|
||||
lda #0
|
||||
sta ip65_error
|
||||
@exit:
|
||||
rts
|
||||
|
||||
|
||||
|
||||
@error:
|
||||
ldax #failed_msg
|
||||
jsr print
|
||||
jsr print_cr
|
||||
rts
|
||||
|
||||
|
||||
open_upload_file:
|
||||
lda #upload_filename_end-upload_filename
|
||||
ldx #<upload_filename
|
||||
ldy #>upload_filename
|
||||
jmp open_file
|
||||
|
||||
open_download_file:
|
||||
lda #download_filename_end-download_filename
|
||||
ldx #<download_filename
|
||||
ldy #>download_filename
|
||||
|
||||
open_file:
|
||||
jsr $FFBD ; call SETNAM
|
||||
lda #$02 ; file number 2
|
||||
ldx $BA ; last used device number
|
||||
bne @skip
|
||||
.import cfg_default_drive
|
||||
ldx cfg_default_drive
|
||||
@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
|
||||
|
||||
rts
|
||||
@error:
|
||||
sta ip65_error
|
||||
jsr close_file
|
||||
sec
|
||||
rts
|
||||
|
||||
write_byte:
|
||||
pha
|
||||
ldx #$02 ; filenumber 2 = output file
|
||||
jsr $FFC9 ; call CHKOUT
|
||||
pla
|
||||
jsr $ffd2 ;write byte
|
||||
JSR $FFB7 ; call READST (read status byte)
|
||||
bne @error
|
||||
ldx #$00 ; filenumber 0 = console
|
||||
jsr $FFC9 ; call CHKOUT
|
||||
rts
|
||||
@error:
|
||||
lda #KPR_ERROR_FILE_ACCESS_FAILURE
|
||||
sta ip65_error
|
||||
jsr close_file
|
||||
sec
|
||||
rts
|
||||
|
||||
|
||||
close_file:
|
||||
|
||||
lda #$02 ; filenumber 2
|
||||
jsr $FFC3 ; call CLOSE
|
||||
rts
|
||||
|
||||
|
||||
.bss
|
||||
temp_ax: .res 2
|
||||
|
||||
.rodata
|
||||
|
||||
starting:
|
||||
.byte "saving to "
|
||||
download_filename: .byte "@0:XMODEM.TMP,P,W" ; @0: means 'overwrite if existing', ',P,W' is required to make this an output file
|
||||
download_filename_end:
|
||||
.byte 0
|
||||
first_message:
|
||||
.byte "yo!",0
|
||||
|
||||
upload_filename: .byte "XMODEM.TMP"
|
||||
upload_filename_end:
|
||||
.byte 0
|
||||
|
||||
start_download:
|
||||
.byte "B",0 ;B=Binary, i.e. trigger IAC escape, R=receive text, i.e. no IAC escape
|
||||
.data
|
||||
|
||||
start_upload:
|
||||
.byte "S",0 ;S send via normal checksum mode (not CRC)
|
||||
.data
|
||||
|
||||
uploading: .byte "uploading",10,0
|
||||
downloading: .byte "downloading",10,0
|
||||
connected: .byte "connected",10,0
|
||||
tcp_dest_ip:
|
||||
.byte 10,5,1,102
|
||||
; .byte 192,168,160,1
|
||||
|
||||
|
||||
|
||||
|
||||
;-- LICENSE FOR test_xmodem.s --
|
||||
; 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/
|
||||
;
|
||||
; 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.
|
||||
;
|
||||
; The Original Code is ip65.
|
||||
;
|
||||
; The Initial Developer of the Original Code is Jonno Downes,
|
||||
; jonno@jamtronix.com.
|
||||
; Portions created by the Initial Developer are Copyright (C) 2009
|
||||
; Jonno Downes. All Rights Reserved.
|
||||
; -- LICENSE END --
|
Loading…
x
Reference in New Issue
Block a user