2009-09-22 10:08:58 +00:00
|
|
|
; #############
|
|
|
|
; KIPPER KART - A C64 TCP/IP stack as a 16KB cartridge
|
|
|
|
; jonno@jamtronix.com
|
|
|
|
|
|
|
|
.macro print_failed
|
|
|
|
ldax #failed_msg
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
jsr print_cr
|
|
|
|
.endmacro
|
|
|
|
|
|
|
|
.macro print_ok
|
|
|
|
ldax #ok_msg
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
jsr print_cr
|
|
|
|
.endmacro
|
|
|
|
|
|
|
|
.macro kippercall arg
|
|
|
|
ldy arg
|
|
|
|
jsr KPR_DISPATCH_VECTOR
|
|
|
|
.endmacro
|
|
|
|
|
|
|
|
.ifndef KPR_API_VERSION_NUMBER
|
|
|
|
.define EQU =
|
|
|
|
.include "../inc/kipper_constants.i"
|
|
|
|
.endif
|
|
|
|
.include "../inc/common.i"
|
|
|
|
.include "../inc/c64keycodes.i"
|
|
|
|
.include "../inc/menu.i"
|
|
|
|
|
|
|
|
.include "../inc/ping.i"
|
2009-09-27 10:32:03 +00:00
|
|
|
.include "../inc/sidplay.i"
|
|
|
|
|
|
|
|
.include "../inc/disk_transfer.i"
|
2009-09-22 10:08:58 +00:00
|
|
|
|
|
|
|
.import cls
|
|
|
|
.import beep
|
|
|
|
.import exit_to_basic
|
|
|
|
.import timer_vbl_handler
|
|
|
|
.import kipper_dispatcher
|
|
|
|
.import ip65_process
|
|
|
|
.import ip65_init
|
|
|
|
.import get_filtered_input
|
|
|
|
.import filter_text
|
|
|
|
.import filter_dns
|
|
|
|
.import filter_ip
|
|
|
|
.import arp_calculate_gateway_mask
|
|
|
|
.import parse_dotted_quad
|
|
|
|
.import dotted_quad_value
|
|
|
|
.import parse_integer
|
|
|
|
.import print_integer
|
|
|
|
.import get_key_ip65
|
|
|
|
.import cfg_ip
|
|
|
|
.import cfg_netmask
|
|
|
|
.import cfg_gateway
|
|
|
|
.import cfg_dns
|
|
|
|
.import cfg_tftp_server
|
|
|
|
|
|
|
|
.import print_ascii_as_native
|
|
|
|
.import print_dotted_quad
|
|
|
|
.import print_hex
|
|
|
|
.import print_errorcode
|
|
|
|
.import print_ip_config
|
|
|
|
.import ok_msg
|
|
|
|
.import failed_msg
|
|
|
|
.import init_msg
|
|
|
|
.import ip_address_msg
|
|
|
|
.import netmask_msg
|
|
|
|
.import gateway_msg
|
|
|
|
.import dns_server_msg
|
|
|
|
.import tftp_server_msg
|
|
|
|
.import press_a_key_to_continue
|
2009-11-13 12:39:41 +00:00
|
|
|
.import cfg_default_drive
|
2009-09-22 10:08:58 +00:00
|
|
|
.import print_a
|
|
|
|
.import print_cr
|
|
|
|
.import print
|
|
|
|
.import copymem
|
|
|
|
.importzp copy_src
|
|
|
|
.importzp copy_dest
|
|
|
|
.import get_filtered_input
|
|
|
|
.import __DATA_LOAD__
|
|
|
|
.import __DATA_RUN__
|
|
|
|
.import __DATA_SIZE__
|
|
|
|
.import __SELF_MODIFIED_CODE_LOAD__
|
|
|
|
.import __SELF_MODIFIED_CODE_RUN__
|
|
|
|
.import __SELF_MODIFIED_CODE_SIZE__
|
|
|
|
|
|
|
|
.import cfg_tftp_server
|
|
|
|
kipper_param_buffer = $6000
|
2009-10-05 03:01:58 +00:00
|
|
|
directory_buffer = $4020
|
2009-09-22 10:08:58 +00:00
|
|
|
|
2009-09-27 10:32:03 +00:00
|
|
|
|
|
|
|
.bss
|
|
|
|
temp_ptr: .res 2
|
|
|
|
.segment "SELF_MODIFIED_CODE"
|
2009-09-22 10:08:58 +00:00
|
|
|
|
|
|
|
call_downloaded_prg:
|
|
|
|
jsr $0000 ;overwritten when we load a file
|
2009-10-05 03:01:58 +00:00
|
|
|
jmp cold_init
|
2009-09-22 10:08:58 +00:00
|
|
|
|
|
|
|
get_value_of_axy: ;some more self-modifying code
|
|
|
|
lda $ffff,y
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
.segment "CARTRIDGE_HEADER"
|
2009-10-05 03:01:58 +00:00
|
|
|
.word cold_init ;cold start vector
|
|
|
|
.word warm_init ;warm start vector
|
2009-09-22 10:08:58 +00:00
|
|
|
.byte $C3,$C2,$CD,$38,$30 ; "CBM80"
|
|
|
|
.byte "KIPPER" ; API signature
|
|
|
|
jmp kipper_dispatcher ; KPR_DISPATCH_VECTOR : entry point for KIPPER functions
|
|
|
|
jmp ip65_process ;KPR_PERIODIC_PROCESSING_VECTOR : routine to be periodically called to check for arrival of ethernet packets
|
2009-10-05 03:01:58 +00:00
|
|
|
.byte $0,$0,$0 ;reserved for future use
|
2009-09-22 10:08:58 +00:00
|
|
|
.code
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-10-05 03:01:58 +00:00
|
|
|
cold_init:
|
2009-09-22 10:08:58 +00:00
|
|
|
|
2009-10-20 10:36:09 +00:00
|
|
|
jsr init_tod
|
|
|
|
|
2009-09-22 10:08:58 +00:00
|
|
|
;first let the kernal do a normal startup
|
|
|
|
sei
|
|
|
|
jsr $fda3 ;initialize CIA I/O
|
|
|
|
jsr $fd50 ;RAM test, set pointers
|
|
|
|
jsr $fd15 ;set vectors for KERNAL
|
|
|
|
jsr $ff5B ;init. VIC
|
|
|
|
cli ;KERNAL init. finished
|
2009-10-05 03:01:58 +00:00
|
|
|
|
2009-10-16 11:18:05 +00:00
|
|
|
|
2009-10-05 03:01:58 +00:00
|
|
|
warm_init:
|
2009-10-30 20:42:50 +00:00
|
|
|
|
|
|
|
lda #14
|
|
|
|
jsr print_a ;switch to lower case
|
|
|
|
|
2009-09-22 10:08:58 +00:00
|
|
|
;set some funky colours
|
|
|
|
|
|
|
|
LDA #$04 ;purple
|
|
|
|
|
|
|
|
STA $D020 ;border
|
|
|
|
LDA #$00 ;black
|
|
|
|
STA $D021 ;background
|
|
|
|
lda #$05 ;petscii for white text
|
|
|
|
jsr print_a
|
|
|
|
|
|
|
|
;relocate our r/w data
|
|
|
|
ldax #__DATA_LOAD__
|
|
|
|
stax copy_src
|
|
|
|
ldax #__DATA_RUN__
|
|
|
|
stax copy_dest
|
|
|
|
ldax #__DATA_SIZE__
|
|
|
|
jsr copymem
|
|
|
|
|
|
|
|
|
|
|
|
;relocate the self-modifying code (if necessary)
|
|
|
|
ldax #__SELF_MODIFIED_CODE_LOAD__
|
|
|
|
stax copy_src
|
|
|
|
ldax #__SELF_MODIFIED_CODE_RUN__
|
|
|
|
stax copy_dest
|
|
|
|
ldax #__SELF_MODIFIED_CODE_SIZE__
|
|
|
|
jsr copymem
|
2009-10-16 11:18:05 +00:00
|
|
|
|
2009-09-22 10:08:58 +00:00
|
|
|
ldax #netboot65_msg
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
ldax #init_msg+1
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
|
|
|
|
kippercall #KPR_INITIALIZE
|
|
|
|
bcc init_ok
|
|
|
|
print_failed
|
|
|
|
jsr print_errorcode
|
|
|
|
jsr wait_for_keypress
|
|
|
|
jmp exit_to_basic
|
|
|
|
|
|
|
|
print_main_menu:
|
2009-10-30 20:42:50 +00:00
|
|
|
|
2009-09-22 10:08:58 +00:00
|
|
|
jsr cls
|
|
|
|
ldax #netboot65_msg
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
ldax #main_menu_msg
|
2009-10-30 20:42:50 +00:00
|
|
|
jmp print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
|
|
|
|
init_ok:
|
|
|
|
|
|
|
|
;look for an 'autoexec' file
|
|
|
|
jsr print_cr
|
|
|
|
ldax #loading_msg
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
ldax #autoexec_filename
|
|
|
|
stax io_filename
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
jsr print_cr
|
|
|
|
ldax #$0000
|
|
|
|
jsr io_read_file
|
|
|
|
bcs main_menu
|
|
|
|
@file_read_ok:
|
|
|
|
ldax #load_ok_msg
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
ldax io_load_address
|
|
|
|
jmp boot_into_file
|
|
|
|
|
|
|
|
main_menu:
|
|
|
|
jsr print_main_menu
|
|
|
|
jsr print_ip_config
|
2009-11-13 11:53:57 +00:00
|
|
|
jsr print_default_drive
|
2009-09-22 10:08:58 +00:00
|
|
|
jsr print_cr
|
|
|
|
|
|
|
|
@get_key:
|
|
|
|
jsr get_key_ip65
|
2009-10-20 10:36:09 +00:00
|
|
|
|
|
|
|
|
2009-09-22 10:08:58 +00:00
|
|
|
cmp #KEYCODE_F1
|
2009-09-27 10:32:03 +00:00
|
|
|
bne @not_f1
|
2009-09-22 10:08:58 +00:00
|
|
|
jmp @tftp_boot
|
2009-09-27 10:32:03 +00:00
|
|
|
@not_f1:
|
2009-09-22 10:08:58 +00:00
|
|
|
cmp #KEYCODE_F2
|
2009-09-27 10:32:03 +00:00
|
|
|
bne @not_f2
|
2009-09-22 10:08:58 +00:00
|
|
|
jmp disk_boot
|
2009-09-27 10:32:03 +00:00
|
|
|
@not_f2:
|
2009-09-22 10:08:58 +00:00
|
|
|
|
|
|
|
cmp #KEYCODE_F3
|
2009-10-05 03:01:58 +00:00
|
|
|
bne @not_f3
|
|
|
|
jsr upload_d64
|
|
|
|
jmp main_menu
|
2009-09-22 10:08:58 +00:00
|
|
|
@not_f3:
|
|
|
|
cmp #KEYCODE_F4
|
2009-09-27 10:32:03 +00:00
|
|
|
bne @not_f4
|
2009-10-05 03:01:58 +00:00
|
|
|
jsr d64_download
|
|
|
|
jmp main_menu
|
2009-09-27 10:32:03 +00:00
|
|
|
@not_f4:
|
2009-09-22 10:08:58 +00:00
|
|
|
|
|
|
|
cmp #KEYCODE_F5
|
2009-09-27 10:32:03 +00:00
|
|
|
bne @not_f5
|
|
|
|
jmp netplay_sid
|
|
|
|
@not_f5:
|
|
|
|
|
|
|
|
cmp #KEYCODE_F6
|
|
|
|
bne @not_f6
|
|
|
|
jsr cls
|
|
|
|
ldax #ping_header
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-27 10:32:03 +00:00
|
|
|
jsr ping_loop
|
|
|
|
jmp exit_ping
|
|
|
|
|
|
|
|
@not_f6:
|
|
|
|
|
2009-09-22 10:08:58 +00:00
|
|
|
cmp #KEYCODE_F7
|
|
|
|
beq @change_config
|
2009-10-30 20:42:50 +00:00
|
|
|
|
2009-10-20 10:36:09 +00:00
|
|
|
|
2009-09-22 10:08:58 +00:00
|
|
|
jmp @get_key
|
|
|
|
|
|
|
|
@exit_to_prog:
|
|
|
|
ldax #$fe66 ;do a wam start
|
|
|
|
jmp call_downloaded_prg
|
|
|
|
|
|
|
|
|
|
|
|
@change_config:
|
|
|
|
jsr cls
|
2009-11-13 11:53:57 +00:00
|
|
|
@config_menu:
|
2009-09-22 10:08:58 +00:00
|
|
|
ldax #netboot65_msg
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
ldax #config_menu_msg
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
jsr print_ip_config
|
2009-11-13 11:53:57 +00:00
|
|
|
jsr print_default_drive
|
2009-09-22 10:08:58 +00:00
|
|
|
jsr print_cr
|
|
|
|
@get_key_config_menu:
|
|
|
|
jsr get_key_ip65
|
|
|
|
cmp #KEYCODE_ABORT
|
|
|
|
bne @not_abort
|
|
|
|
jmp main_menu
|
|
|
|
@not_abort:
|
|
|
|
cmp #KEYCODE_F1
|
|
|
|
bne @not_ip
|
|
|
|
ldax #new
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
ldax #ip_address_msg
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
jsr print_cr
|
|
|
|
ldax #filter_ip
|
|
|
|
ldy #20
|
|
|
|
jsr get_filtered_input
|
|
|
|
bcs @no_ip_address_entered
|
|
|
|
jsr parse_dotted_quad
|
|
|
|
bcc @no_ip_resolve_error
|
|
|
|
jmp @change_config
|
|
|
|
@no_ip_resolve_error:
|
|
|
|
ldax #dotted_quad_value
|
|
|
|
stax copy_src
|
|
|
|
ldax #cfg_ip
|
|
|
|
stax copy_dest
|
|
|
|
ldax #4
|
|
|
|
jsr copymem
|
|
|
|
@no_ip_address_entered:
|
|
|
|
jmp @change_config
|
|
|
|
|
|
|
|
@not_ip:
|
|
|
|
cmp #KEYCODE_F2
|
|
|
|
bne @not_netmask
|
|
|
|
ldax #new
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
ldax #netmask_msg
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
jsr print_cr
|
|
|
|
ldax #filter_ip
|
|
|
|
ldy #20
|
|
|
|
jsr get_filtered_input
|
|
|
|
bcs @no_netmask_entered
|
|
|
|
jsr parse_dotted_quad
|
|
|
|
bcc @no_netmask_resolve_error
|
|
|
|
jmp @change_config
|
|
|
|
@no_netmask_resolve_error:
|
|
|
|
ldax #dotted_quad_value
|
|
|
|
stax copy_src
|
|
|
|
ldax #cfg_netmask
|
|
|
|
stax copy_dest
|
|
|
|
ldax #4
|
|
|
|
jsr copymem
|
|
|
|
@no_netmask_entered:
|
|
|
|
jmp @change_config
|
|
|
|
|
|
|
|
@not_netmask:
|
|
|
|
cmp #KEYCODE_F3
|
|
|
|
bne @not_gateway
|
|
|
|
ldax #new
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
ldax #gateway_msg
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
jsr print_cr
|
|
|
|
ldax #filter_ip
|
|
|
|
ldy #20
|
|
|
|
jsr get_filtered_input
|
|
|
|
bcs @no_gateway_entered
|
|
|
|
jsr parse_dotted_quad
|
|
|
|
bcc @no_gateway_resolve_error
|
|
|
|
jmp @change_config
|
|
|
|
@no_gateway_resolve_error:
|
|
|
|
ldax #dotted_quad_value
|
|
|
|
stax copy_src
|
|
|
|
ldax #cfg_gateway
|
|
|
|
stax copy_dest
|
|
|
|
ldax #4
|
|
|
|
jsr copymem
|
|
|
|
jsr arp_calculate_gateway_mask ;we have modified our netmask, so we need to recalculate gw_test
|
|
|
|
@no_gateway_entered:
|
|
|
|
jmp @change_config
|
|
|
|
|
|
|
|
|
|
|
|
@not_gateway:
|
|
|
|
cmp #KEYCODE_F4
|
|
|
|
bne @not_dns_server
|
|
|
|
ldax #new
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
ldax #dns_server_msg
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
jsr print_cr
|
|
|
|
ldax #filter_ip
|
|
|
|
ldy #20
|
|
|
|
jsr get_filtered_input
|
|
|
|
bcs @no_dns_server_entered
|
|
|
|
jsr parse_dotted_quad
|
|
|
|
bcc @no_dns_resolve_error
|
|
|
|
jmp @change_config
|
|
|
|
@no_dns_resolve_error:
|
|
|
|
ldax #dotted_quad_value
|
|
|
|
stax copy_src
|
|
|
|
ldax #cfg_dns
|
|
|
|
stax copy_dest
|
|
|
|
ldax #4
|
|
|
|
jsr copymem
|
|
|
|
@no_dns_server_entered:
|
|
|
|
|
|
|
|
jmp @change_config
|
|
|
|
|
|
|
|
@not_dns_server:
|
|
|
|
cmp #KEYCODE_F5
|
|
|
|
bne @not_tftp_server
|
|
|
|
ldax #new
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
ldax #tftp_server_msg
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
jsr print_cr
|
|
|
|
ldax #filter_dns
|
|
|
|
ldy #40
|
|
|
|
jsr get_filtered_input
|
|
|
|
bcs @no_server_entered
|
|
|
|
stax kipper_param_buffer
|
|
|
|
jsr print_cr
|
|
|
|
ldax #resolving
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
ldax #kipper_param_buffer
|
|
|
|
kippercall #KPR_DNS_RESOLVE
|
|
|
|
bcs @resolve_error
|
|
|
|
ldax #kipper_param_buffer
|
|
|
|
stax copy_src
|
|
|
|
ldax #cfg_tftp_server
|
|
|
|
stax copy_dest
|
|
|
|
ldax #4
|
|
|
|
jsr copymem
|
|
|
|
@no_server_entered:
|
|
|
|
jmp @change_config
|
|
|
|
|
|
|
|
@not_tftp_server:
|
|
|
|
|
|
|
|
|
|
|
|
cmp #KEYCODE_F6
|
|
|
|
bne @not_reset
|
|
|
|
jsr ip65_init ;this will reset everything
|
|
|
|
jmp @change_config
|
|
|
|
@not_reset:
|
|
|
|
cmp #KEYCODE_F7
|
|
|
|
bne @not_main_menu
|
|
|
|
jmp main_menu
|
|
|
|
|
|
|
|
@not_main_menu:
|
2009-11-13 11:53:57 +00:00
|
|
|
|
|
|
|
cmp #'+'
|
|
|
|
bne @not_plus
|
2009-11-13 12:39:41 +00:00
|
|
|
inc cfg_default_drive
|
2009-11-13 11:53:57 +00:00
|
|
|
jmp @config_menu
|
|
|
|
@not_plus:
|
|
|
|
|
|
|
|
cmp #'-'
|
|
|
|
bne @not_minus
|
2009-11-13 12:39:41 +00:00
|
|
|
dec cfg_default_drive
|
2009-11-13 11:53:57 +00:00
|
|
|
jmp @config_menu
|
|
|
|
|
|
|
|
@not_minus:
|
|
|
|
|
2009-09-22 10:08:58 +00:00
|
|
|
jmp @get_key_config_menu
|
|
|
|
|
|
|
|
|
|
|
|
@resolve_error:
|
|
|
|
print_failed
|
|
|
|
jsr wait_for_keypress
|
|
|
|
jsr @change_config
|
|
|
|
|
|
|
|
@tftp_boot:
|
|
|
|
|
|
|
|
ldax #tftp_dir_filemask
|
|
|
|
jsr get_tftp_directory_listing
|
|
|
|
bcs return_to_main
|
|
|
|
|
|
|
|
@boot_filename_set:
|
|
|
|
;AX now points to filename
|
|
|
|
jsr download
|
|
|
|
bcc file_downloaded_ok
|
|
|
|
tftp_boot_failed:
|
|
|
|
jsr wait_for_keypress
|
|
|
|
return_to_main:
|
2009-09-27 10:32:03 +00:00
|
|
|
jmp error_handler
|
2009-09-22 10:08:58 +00:00
|
|
|
|
|
|
|
file_downloaded_ok:
|
|
|
|
ldax kipper_param_buffer+KPR_TFTP_POINTER
|
|
|
|
|
|
|
|
boot_into_file:
|
|
|
|
stax kipper_param_buffer ;use the param buffer as a temp holding place for the load address
|
|
|
|
;get ready to bank out
|
|
|
|
kippercall #KPR_DEACTIVATE
|
|
|
|
|
|
|
|
jsr $ffe7 ; make sure all files have been closed.
|
|
|
|
|
|
|
|
;check whether the file we just downloaded was a BASIC prg
|
|
|
|
lda kipper_param_buffer
|
|
|
|
cmp #01
|
|
|
|
bne @not_a_basic_file
|
|
|
|
|
|
|
|
lda kipper_param_buffer+1
|
|
|
|
cmp #$08
|
|
|
|
bne @not_a_basic_file
|
|
|
|
|
|
|
|
lda $805
|
|
|
|
cmp #$9e ;opcode for 'SYS'
|
|
|
|
bne @not_a_basic_stub
|
|
|
|
|
|
|
|
ldax #$806 ;should point to ascii string containing address that was to be SYSed
|
|
|
|
jsr parse_integer
|
|
|
|
jmp exit_cart_via_ax ;good luck!
|
|
|
|
@not_a_basic_stub:
|
|
|
|
ldax #cant_boot_basic
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
jsr wait_for_keypress
|
2009-10-05 03:01:58 +00:00
|
|
|
jmp warm_init
|
2009-09-22 10:08:58 +00:00
|
|
|
|
|
|
|
@not_a_basic_file:
|
|
|
|
ldax kipper_param_buffer
|
|
|
|
exit_cart_via_ax:
|
|
|
|
sta call_downloaded_prg+1
|
|
|
|
stx call_downloaded_prg+2
|
|
|
|
jmp call_downloaded_prg
|
|
|
|
|
|
|
|
get_tftp_directory_listing:
|
2009-09-27 10:32:03 +00:00
|
|
|
stax temp_ptr
|
|
|
|
@get_listing:
|
2009-09-22 10:08:58 +00:00
|
|
|
stax kipper_param_buffer+KPR_TFTP_FILENAME
|
|
|
|
|
|
|
|
ldax #directory_buffer
|
|
|
|
stax kipper_param_buffer+KPR_TFTP_POINTER
|
|
|
|
|
|
|
|
ldax #getting_dir_listing_msg
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
|
|
|
|
ldax #kipper_param_buffer
|
|
|
|
kippercall #KPR_TFTP_DOWNLOAD
|
|
|
|
|
|
|
|
bcs @dir_failed
|
|
|
|
|
|
|
|
lda directory_buffer ;get the first byte that was downloaded
|
|
|
|
bne :+
|
|
|
|
jmp @no_files_on_server
|
|
|
|
:
|
|
|
|
|
|
|
|
|
|
|
|
ldax #directory_buffer
|
2009-10-20 10:36:09 +00:00
|
|
|
ldy #1 ;filenames will be ASCII
|
2009-09-22 10:08:58 +00:00
|
|
|
jsr select_option_from_menu
|
|
|
|
bcc @tftp_filename_set
|
|
|
|
rts
|
|
|
|
@tftp_filename_set:
|
|
|
|
stax copy_dest
|
|
|
|
stax get_value_of_axy+1
|
|
|
|
ldy #0
|
|
|
|
jsr get_value_of_axy ;A now == first char in string we just downloaded
|
|
|
|
cmp #'$'
|
|
|
|
bne @not_directory_name
|
|
|
|
;it's a directory name, so we need to append the file mask to end of it
|
|
|
|
;this will fail if the file path is more than 255 characters long
|
|
|
|
@look_for_trailing_zero:
|
|
|
|
iny
|
|
|
|
inc copy_dest
|
|
|
|
bne :+
|
|
|
|
inc copy_dest+1
|
|
|
|
:
|
|
|
|
jsr get_value_of_axy ;A now == next char in string we just downloaded
|
|
|
|
bne @look_for_trailing_zero
|
|
|
|
|
|
|
|
; got trailing zero
|
2009-09-27 10:32:03 +00:00
|
|
|
ldax temp_ptr
|
|
|
|
clc
|
|
|
|
adc #1 ;skip the leading '$'
|
|
|
|
bcc :+
|
|
|
|
inx
|
|
|
|
:
|
2009-09-22 10:08:58 +00:00
|
|
|
stax copy_src
|
|
|
|
ldax #$07
|
|
|
|
jsr copymem
|
|
|
|
ldax get_value_of_axy+1
|
2009-09-27 10:32:03 +00:00
|
|
|
jmp @get_listing
|
2009-09-22 10:08:58 +00:00
|
|
|
|
|
|
|
@not_directory_name:
|
|
|
|
ldax get_value_of_axy+1
|
|
|
|
clc
|
|
|
|
rts
|
|
|
|
|
|
|
|
@dir_failed:
|
|
|
|
ldax #dir_listing_fail_msg
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-27 10:32:03 +00:00
|
|
|
sec
|
|
|
|
rts
|
|
|
|
|
2009-09-22 10:08:58 +00:00
|
|
|
@no_files_on_server:
|
|
|
|
ldax #no_files
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-27 10:32:03 +00:00
|
|
|
sec
|
|
|
|
rts
|
2009-09-22 10:08:58 +00:00
|
|
|
|
|
|
|
disk_boot:
|
|
|
|
.import io_read_catalogue
|
|
|
|
.import io_device_no
|
|
|
|
.import io_filename
|
|
|
|
.import io_read_file
|
|
|
|
.import io_load_address
|
|
|
|
|
2009-11-13 12:39:41 +00:00
|
|
|
lda cfg_default_drive
|
|
|
|
sec
|
|
|
|
sbc #7
|
|
|
|
sta io_device_no
|
2009-09-22 10:08:58 +00:00
|
|
|
ldax #directory_buffer
|
|
|
|
jsr io_read_catalogue
|
|
|
|
|
|
|
|
lda directory_buffer ;get the first byte that was downloaded
|
|
|
|
bne :+
|
|
|
|
jmp @no_files_on_disk
|
|
|
|
:
|
|
|
|
|
|
|
|
|
|
|
|
ldax #directory_buffer
|
2009-10-20 10:36:09 +00:00
|
|
|
ldy #0 ;filenames will NOT be ASCII
|
2009-09-22 10:08:58 +00:00
|
|
|
jsr select_option_from_menu
|
|
|
|
bcc @disk_filename_set
|
|
|
|
jmp main_menu
|
|
|
|
|
|
|
|
@dir_failed:
|
|
|
|
ldax #dir_listing_fail_msg
|
|
|
|
@print_error:
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
jsr print_errorcode
|
|
|
|
jsr print_cr
|
|
|
|
jmp @wait_keypress_then_return_to_main
|
|
|
|
|
|
|
|
@no_files_on_disk:
|
|
|
|
ldax #no_files
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
@wait_keypress_then_return_to_main:
|
|
|
|
jsr wait_for_keypress
|
|
|
|
jmp main_menu
|
|
|
|
|
|
|
|
@disk_filename_set:
|
|
|
|
stax io_filename
|
|
|
|
ldax #loading_msg
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
ldax io_filename
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
jsr print_cr
|
|
|
|
ldax #$0000
|
|
|
|
jsr io_read_file
|
|
|
|
bcc @file_read_ok
|
|
|
|
ldax #file_read_error
|
|
|
|
jmp @print_error
|
|
|
|
@file_read_ok:
|
|
|
|
ldax #load_ok_msg
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
ldax io_load_address
|
|
|
|
jmp boot_into_file
|
|
|
|
|
2009-09-27 10:32:03 +00:00
|
|
|
error_handler:
|
|
|
|
jsr print_errorcode
|
|
|
|
jsr print_cr
|
|
|
|
jsr wait_for_keypress
|
|
|
|
jmp main_menu
|
2009-09-22 10:08:58 +00:00
|
|
|
|
2009-09-27 10:32:03 +00:00
|
|
|
netplay_sid:
|
|
|
|
|
|
|
|
ldax #sid_filemask
|
2009-09-22 10:08:58 +00:00
|
|
|
jsr get_tftp_directory_listing
|
2009-09-27 10:32:03 +00:00
|
|
|
bcc @sid_filename_set
|
|
|
|
jmp error_handler
|
|
|
|
@sid_filename_set:
|
2009-09-22 10:08:58 +00:00
|
|
|
;AX now points to filename
|
2009-09-27 10:32:03 +00:00
|
|
|
stax kipper_param_buffer+KPR_TFTP_FILENAME
|
|
|
|
ldax #$1000 ;load address
|
|
|
|
stax kipper_param_buffer+KPR_TFTP_POINTER
|
|
|
|
jsr download2
|
2009-09-22 10:08:58 +00:00
|
|
|
|
2009-09-27 10:32:03 +00:00
|
|
|
|
|
|
|
bcc :+
|
|
|
|
jmp error_handler
|
|
|
|
:
|
2009-09-22 10:08:58 +00:00
|
|
|
|
|
|
|
jsr cls
|
2009-09-27 10:32:03 +00:00
|
|
|
ldax kipper_param_buffer+KPR_TFTP_FILESIZE
|
|
|
|
stax sidfile_length
|
|
|
|
ldax kipper_param_buffer+KPR_TFTP_POINTER
|
|
|
|
jsr load_sid
|
|
|
|
jsr play_sid
|
2009-09-22 10:08:58 +00:00
|
|
|
|
|
|
|
|
2009-09-27 10:32:03 +00:00
|
|
|
jmp main_menu
|
2009-09-22 10:08:58 +00:00
|
|
|
|
2009-09-27 10:32:03 +00:00
|
|
|
|
|
|
|
d64_download:
|
|
|
|
|
|
|
|
ldax #d64_filemask
|
|
|
|
jsr get_tftp_directory_listing
|
|
|
|
bcc @d64_filename_set
|
2009-09-22 10:08:58 +00:00
|
|
|
jmp main_menu
|
2009-09-27 10:32:03 +00:00
|
|
|
@d64_filename_set:
|
|
|
|
;AX now points to filename
|
|
|
|
jsr download_d64
|
|
|
|
jmp main_menu
|
|
|
|
|
2009-09-22 10:08:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bad_boot:
|
|
|
|
jsr wait_for_keypress
|
|
|
|
jmp $fe66 ;do a wam start
|
|
|
|
|
|
|
|
download: ;AX should point at filename to download
|
|
|
|
stax kipper_param_buffer+KPR_TFTP_FILENAME
|
|
|
|
ldax #$0000 ;load address will be first 2 bytes of file we download (LO/HI order)
|
|
|
|
stax kipper_param_buffer+KPR_TFTP_POINTER
|
|
|
|
|
2009-09-27 10:32:03 +00:00
|
|
|
download2:
|
2009-09-22 10:08:58 +00:00
|
|
|
ldax #downloading_msg
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
ldax kipper_param_buffer+KPR_TFTP_FILENAME
|
2009-09-27 10:32:03 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
jsr print_cr
|
|
|
|
|
|
|
|
ldax #kipper_param_buffer
|
|
|
|
kippercall #KPR_TFTP_DOWNLOAD
|
|
|
|
|
|
|
|
bcc :+
|
|
|
|
|
|
|
|
ldax #tftp_download_fail_msg
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
jsr print_errorcode
|
|
|
|
sec
|
|
|
|
rts
|
|
|
|
|
|
|
|
:
|
|
|
|
ldax #tftp_download_ok_msg
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
clc
|
|
|
|
rts
|
|
|
|
|
|
|
|
wait_for_keypress:
|
|
|
|
ldax #press_a_key_to_continue
|
2009-10-30 20:42:50 +00:00
|
|
|
jsr print_ascii_as_native
|
2009-09-22 10:08:58 +00:00
|
|
|
@loop:
|
|
|
|
jsr $ffe4
|
|
|
|
beq @loop
|
|
|
|
rts
|
|
|
|
|
|
|
|
get_key:
|
|
|
|
@loop:
|
|
|
|
jsr KPR_PERIODIC_PROCESSING_VECTOR
|
|
|
|
jsr $ffe4
|
|
|
|
beq @loop
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
cfg_get_configuration_ptr:
|
|
|
|
ldax #kipper_param_buffer
|
|
|
|
kippercall #KPR_GET_IP_CONFIG
|
|
|
|
rts
|
|
|
|
|
|
|
|
exit_ping:
|
|
|
|
lda #$05 ;petscii for white text
|
|
|
|
jsr print_a
|
2009-09-27 10:32:03 +00:00
|
|
|
jmp main_menu
|
2009-11-13 11:53:57 +00:00
|
|
|
|
|
|
|
print_default_drive:
|
|
|
|
ldax #default_drive
|
|
|
|
jsr print_ascii_as_native
|
2009-11-13 12:39:41 +00:00
|
|
|
lda cfg_default_drive
|
2009-11-13 11:53:57 +00:00
|
|
|
jsr print_hex
|
|
|
|
jmp print_cr
|
2009-10-16 11:18:05 +00:00
|
|
|
|
|
|
|
;init the Time-Of-Day clock - cribbed from http://codebase64.org/doku.php?id=base:initialize_tod_clock_on_all_platforms
|
|
|
|
init_tod:
|
|
|
|
sei
|
|
|
|
lda #0
|
|
|
|
sta $d011 ;Turn off display to disable badlines
|
|
|
|
sta $dc0e ;Set TOD Clock Frequency to 60Hz
|
|
|
|
sta $dc0f ;Enable Set-TOD-Clock
|
|
|
|
sta $dc0b ;Set TOD-Clock to 0 (hours)
|
|
|
|
sta $dc0a ;- (minutes)
|
|
|
|
sta $dc09 ;- (seconds)
|
|
|
|
sta $dc08 ;- (deciseconds)
|
|
|
|
|
|
|
|
lda $dc08 ;
|
|
|
|
@wait_raster:
|
|
|
|
cmp $dc08 ;Sync raster to TOD Clock Frequency
|
|
|
|
beq @wait_raster
|
|
|
|
|
|
|
|
ldx #0 ;Prep X and Y for 16 bit
|
|
|
|
ldy #0 ; counter operation
|
|
|
|
lda $dc08 ;Read deciseconds
|
|
|
|
@loop1:
|
|
|
|
inx ;2 -+
|
|
|
|
bne @loop2 ;2/3 | Do 16 bit count up on
|
|
|
|
iny ;2 | X(lo) and Y(hi) regs in a
|
|
|
|
jmp @loop3 ;3 | fixed cycle manner
|
|
|
|
@loop2:
|
|
|
|
nop ;2 |
|
|
|
|
nop ;2 -+
|
|
|
|
@loop3:
|
|
|
|
cmp $dc08 ;4 - Did 1 decisecond pass?
|
|
|
|
beq @loop1 ;3 - If not, loop-di-doop
|
|
|
|
;Each loop = 16 cycles
|
|
|
|
;If less than 118230 cycles passed, TOD is
|
|
|
|
;clocked at 60Hz. If 118230 or more cycles
|
|
|
|
;passed, TOD is clocked at 50Hz.
|
|
|
|
;It might be a good idea to account for a bit
|
|
|
|
;of slack and since every loop is 16 cycles,
|
|
|
|
;28*256 loops = 114688 cycles, which seems to be
|
|
|
|
;acceptable. That means we need to check for
|
|
|
|
;a Y value of 28.
|
|
|
|
|
|
|
|
cpy #28 ;Did 114688 cycles or less go by?
|
|
|
|
bcc @hertz_correct ;- Then we already have correct 60Hz $dc0e value
|
|
|
|
lda #$80 ;Otherwise, we need to set it to 50Hz
|
|
|
|
sta $dc0e
|
|
|
|
@hertz_correct:
|
|
|
|
lda #$1b ;Enable the display again
|
|
|
|
sta $d011
|
|
|
|
cli
|
|
|
|
rts
|
|
|
|
|
2009-09-22 10:08:58 +00:00
|
|
|
.rodata
|
|
|
|
|
|
|
|
netboot65_msg:
|
2009-11-13 11:53:57 +00:00
|
|
|
.byte $13,10,"KipperKart V"
|
2009-09-22 10:08:58 +00:00
|
|
|
.include "../inc/version.i"
|
2009-10-30 20:42:50 +00:00
|
|
|
.byte 10,0
|
2009-09-22 10:08:58 +00:00
|
|
|
main_menu_msg:
|
2009-10-30 20:42:50 +00:00
|
|
|
.byte 10,"Main Menu",10,10
|
|
|
|
.byte "F1: TFTP Boot F2: Disk Boot",10
|
|
|
|
.byte "F3: Upload D64 F4: Download D64",10
|
|
|
|
.byte "F5: SID Netplay F6: Ping",10
|
2009-11-13 11:53:57 +00:00
|
|
|
.byte "F7: Config",10,10
|
2009-09-22 10:08:58 +00:00
|
|
|
|
|
|
|
.byte 0
|
|
|
|
|
|
|
|
config_menu_msg:
|
2009-10-30 20:42:50 +00:00
|
|
|
.byte 10,"Configuration",10,10
|
|
|
|
.byte "F1: IP Address F2: Netmask",10
|
|
|
|
.byte "F3: Gateway F4: DNS Server",10
|
|
|
|
.byte "F5: TFTP Server F6: Reset To Default",10
|
2009-11-13 11:53:57 +00:00
|
|
|
.byte "F7: Main Menu +/- Drive #",10,10
|
2009-09-22 10:08:58 +00:00
|
|
|
.byte 0
|
|
|
|
|
|
|
|
cant_boot_basic:
|
2009-10-30 20:42:50 +00:00
|
|
|
.byte "BASIC file execution not supported",10,0
|
2009-09-22 10:08:58 +00:00
|
|
|
|
2009-10-30 20:42:50 +00:00
|
|
|
ping_header: .byte "ping",10,0
|
2009-09-22 10:08:58 +00:00
|
|
|
|
2009-10-30 20:42:50 +00:00
|
|
|
file_read_error: .asciiz "Error reading file"
|
2009-09-22 10:08:58 +00:00
|
|
|
autoexec_filename: .byte "AUTOEXEC.PRG",0
|
|
|
|
|
2009-10-30 20:42:50 +00:00
|
|
|
downloading_msg: .byte "down"
|
|
|
|
loading_msg: .asciiz "loading "
|
2009-09-22 10:08:58 +00:00
|
|
|
|
2009-10-30 20:42:50 +00:00
|
|
|
uploading_msg: .byte "uploading ",0
|
2009-10-05 03:01:58 +00:00
|
|
|
|
2009-10-30 20:42:50 +00:00
|
|
|
getting_dir_listing_msg: .byte "fetching directory",10,0
|
2009-09-22 10:08:58 +00:00
|
|
|
|
|
|
|
dir_listing_fail_msg:
|
2009-10-30 20:42:50 +00:00
|
|
|
.byte "directory listing failed",10,0
|
2009-09-22 10:08:58 +00:00
|
|
|
|
|
|
|
tftp_download_fail_msg:
|
2009-10-30 20:42:50 +00:00
|
|
|
.byte "download failed", 10, 0
|
2009-09-22 10:08:58 +00:00
|
|
|
|
2009-11-13 11:53:57 +00:00
|
|
|
default_drive:
|
|
|
|
.byte "Use Drive # : $",0
|
2009-09-22 10:08:58 +00:00
|
|
|
tftp_download_ok_msg:
|
2009-10-30 20:42:50 +00:00
|
|
|
.byte "down"
|
2009-09-22 10:08:58 +00:00
|
|
|
load_ok_msg:
|
2009-10-30 20:42:50 +00:00
|
|
|
.byte "load OK", 10, 0
|
2009-09-22 10:08:58 +00:00
|
|
|
|
|
|
|
current:
|
2009-10-30 20:42:50 +00:00
|
|
|
.byte "current ",0
|
2009-09-22 10:08:58 +00:00
|
|
|
|
|
|
|
new:
|
2009-10-30 20:42:50 +00:00
|
|
|
.byte"new ",0
|
2009-09-22 10:08:58 +00:00
|
|
|
|
|
|
|
tftp_dir_filemask:
|
|
|
|
.asciiz "$/*.prg"
|
|
|
|
|
|
|
|
d64_filemask:
|
|
|
|
.asciiz "$/*.d64"
|
|
|
|
|
2009-09-27 10:32:03 +00:00
|
|
|
sid_filemask:
|
|
|
|
.asciiz "$/*.sid"
|
2009-09-22 10:08:58 +00:00
|
|
|
|
|
|
|
no_files:
|
2009-10-30 20:42:50 +00:00
|
|
|
.byte "no files",10,0
|
2009-09-22 10:08:58 +00:00
|
|
|
|
|
|
|
resolving:
|
2009-10-30 20:42:50 +00:00
|
|
|
.byte "resolving ",0
|
|
|
|
|
|
|
|
remote_host: .byte "hostname (return to quit)",10,": ",0
|
2009-10-22 10:49:08 +00:00
|
|
|
|
|
|
|
;-- LICENSE FOR kipperkart.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 netboot65.
|
|
|
|
;
|
|
|
|
; 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 --
|