2009-01-22 01:27:03 +00:00
|
|
|
;#############
|
|
|
|
;
|
|
|
|
; This will boot a C64 with RR-NET from the network
|
|
|
|
; requires
|
|
|
|
; 1) a DHCP server, and
|
|
|
|
; 2) a TFTP server that responds to requests on the broadcast address (255.255.255.255) and that will serve a file called 'BOOTC64.PRG'.
|
2009-03-26 03:17:47 +00:00
|
|
|
; the prg file can be either BASIC or M/L, and up to 22K in length.
|
2009-01-22 01:27:03 +00:00
|
|
|
;
|
|
|
|
; jonno@jamtronix.com - January 2009
|
|
|
|
;
|
|
|
|
|
|
|
|
.include "../inc/common.i"
|
|
|
|
.include "../inc/commonprint.i"
|
|
|
|
.include "../inc/net.i"
|
2009-03-08 10:18:59 +00:00
|
|
|
.include "../inc/menu.i"
|
2009-03-26 03:17:47 +00:00
|
|
|
.include "../inc/c64keycodes.i"
|
2009-03-08 10:18:59 +00:00
|
|
|
.import cls
|
|
|
|
.import get_key
|
|
|
|
.import beep
|
2009-03-26 00:43:35 +00:00
|
|
|
.import exit_to_basic
|
2009-01-22 01:27:03 +00:00
|
|
|
|
|
|
|
.importzp tftp_filename
|
|
|
|
.import tftp_load_address
|
2009-03-08 10:18:59 +00:00
|
|
|
.import tftp_ip
|
2009-01-22 01:27:03 +00:00
|
|
|
.import tftp_download
|
2009-03-08 10:18:59 +00:00
|
|
|
.import tftp_directory_listing
|
2009-03-27 13:19:05 +00:00
|
|
|
.import tftp_set_download_callback
|
|
|
|
|
2009-01-22 01:27:03 +00:00
|
|
|
.import copymem
|
|
|
|
.importzp copy_src
|
|
|
|
.importzp copy_dest
|
|
|
|
|
|
|
|
.import __DATA_LOAD__
|
|
|
|
.import __DATA_RUN__
|
|
|
|
.import __DATA_SIZE__
|
|
|
|
|
2009-03-27 13:19:05 +00:00
|
|
|
|
|
|
|
.export jmp_ip65_init
|
|
|
|
.export jmp_dhcp_init
|
|
|
|
.export jmp_tftp_download
|
|
|
|
.export jmp_tftp_directory_listing
|
|
|
|
.export jmp_tftp_set_download_callback
|
|
|
|
|
2009-01-22 01:27:03 +00:00
|
|
|
.bss
|
|
|
|
|
2009-01-22 02:53:18 +00:00
|
|
|
;temp_bin: .res 1
|
|
|
|
;temp_bcd: .res 2
|
2009-01-22 01:27:03 +00:00
|
|
|
|
|
|
|
bin_file_jmp: .res 3
|
2009-03-08 10:18:59 +00:00
|
|
|
tftp_dir_buffer: .res 2000
|
|
|
|
|
2009-01-22 01:27:03 +00:00
|
|
|
|
|
|
|
.segment "CARTRIDGE_HEADER"
|
|
|
|
.word init ;cold start vector
|
|
|
|
.word init ;warm start vector
|
|
|
|
.byte $C3,$C2,$CD,$38,$30 ; "CBM80"
|
|
|
|
|
2009-03-27 13:19:05 +00:00
|
|
|
.segment "JUMP_TABLE"
|
|
|
|
|
|
|
|
jmp_ip65_init:
|
|
|
|
jmp ip65_init
|
|
|
|
|
|
|
|
jmp_dhcp_init:
|
|
|
|
jmp dhcp_init
|
|
|
|
|
|
|
|
jmp_tftp_directory_listing:
|
|
|
|
jmp tftp_directory_listing
|
2009-01-22 01:27:03 +00:00
|
|
|
|
2009-03-27 13:19:05 +00:00
|
|
|
jmp_tftp_download:
|
|
|
|
jmp tftp_download
|
|
|
|
|
|
|
|
jmp_tftp_set_download_callback:
|
|
|
|
jmp tftp_set_download_callback
|
|
|
|
|
|
|
|
filler:
|
|
|
|
.res 17
|
|
|
|
.code
|
2009-01-22 01:27:03 +00:00
|
|
|
|
|
|
|
init:
|
|
|
|
|
|
|
|
;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
|
|
|
|
jsr $e453 ;set BASIC vectors
|
|
|
|
jsr $e3bf ;initialize zero page
|
|
|
|
|
2009-03-27 13:19:05 +00:00
|
|
|
|
|
|
|
;relocate our r/w data
|
2009-01-22 01:27:03 +00:00
|
|
|
ldax #__DATA_LOAD__
|
|
|
|
stax copy_src
|
|
|
|
ldax #__DATA_RUN__
|
|
|
|
stax copy_dest
|
|
|
|
ldax #__DATA_SIZE__
|
|
|
|
jsr copymem
|
|
|
|
|
2009-03-27 13:19:05 +00:00
|
|
|
|
|
|
|
ldax #startup_msg
|
|
|
|
jsr print
|
|
|
|
|
|
|
|
@get_key:
|
|
|
|
jsr get_key
|
|
|
|
cmp #KEYCODE_F1
|
|
|
|
beq @tftp_boot
|
|
|
|
cmp #KEYCODE_F3
|
|
|
|
|
|
|
|
beq @exit_to_basic
|
|
|
|
|
|
|
|
jmp @get_key
|
|
|
|
|
|
|
|
@exit_to_basic:
|
|
|
|
jmp $fe66 ;do a wam start
|
2009-01-22 01:27:03 +00:00
|
|
|
|
2009-03-27 13:19:05 +00:00
|
|
|
@tftp_boot:
|
2009-01-22 01:27:03 +00:00
|
|
|
|
|
|
|
init_ip_via_dhcp
|
2009-03-08 10:18:59 +00:00
|
|
|
bcc :+
|
|
|
|
jmp bad_boot
|
|
|
|
:
|
2009-01-22 01:27:03 +00:00
|
|
|
jsr print_ip_config
|
|
|
|
|
2009-03-08 10:18:59 +00:00
|
|
|
ldx #3
|
2009-01-22 01:27:03 +00:00
|
|
|
:
|
|
|
|
lda cfg_tftp_server,x
|
|
|
|
sta tftp_ip,x
|
|
|
|
dex
|
|
|
|
bpl :-
|
|
|
|
|
2009-03-26 03:32:04 +00:00
|
|
|
ldax #press_a_key_to_continue
|
|
|
|
jsr print
|
|
|
|
jsr get_key
|
|
|
|
|
2009-03-08 10:18:59 +00:00
|
|
|
|
|
|
|
ldax #tftp_dir_buffer
|
|
|
|
stax tftp_load_address
|
|
|
|
|
|
|
|
ldax #getting_dir_listing_msg
|
|
|
|
jsr print
|
|
|
|
|
|
|
|
ldax #tftp_dir_filemask
|
|
|
|
stax tftp_filename
|
|
|
|
jsr print
|
|
|
|
jsr print_cr
|
|
|
|
|
|
|
|
jsr tftp_directory_listing
|
|
|
|
bcs @dir_failed
|
|
|
|
|
2009-03-26 03:17:47 +00:00
|
|
|
lda tftp_dir_buffer ;get the first byte that was downloaded
|
|
|
|
bne :+
|
|
|
|
jmp @no_files_on_server
|
|
|
|
:
|
2009-01-22 01:27:03 +00:00
|
|
|
ldax #$0000 ;load address will be first 2 bytes of file we dowload (LO/HI order)
|
|
|
|
stax tftp_load_address
|
|
|
|
|
2009-03-26 03:32:04 +00:00
|
|
|
;switch to lower case charset
|
|
|
|
lda #23
|
|
|
|
sta $d018
|
2009-03-08 10:18:59 +00:00
|
|
|
ldax #tftp_dir_buffer
|
2009-03-26 03:32:04 +00:00
|
|
|
|
2009-03-08 10:18:59 +00:00
|
|
|
jsr select_option_from_menu
|
|
|
|
stax tftp_filename
|
|
|
|
|
|
|
|
|
2009-01-22 01:27:03 +00:00
|
|
|
ldax #downloading_msg
|
|
|
|
jsr print
|
|
|
|
|
2009-03-08 10:18:59 +00:00
|
|
|
|
|
|
|
ldax tftp_filename
|
2009-01-22 01:27:03 +00:00
|
|
|
jsr download
|
|
|
|
bcc @file_downloaded_ok
|
2009-03-26 01:00:12 +00:00
|
|
|
|
2009-03-08 10:18:59 +00:00
|
|
|
@dir_failed:
|
2009-03-26 01:00:12 +00:00
|
|
|
ldax #tftp_dir_listing_fail_msg
|
|
|
|
jsr print
|
|
|
|
|
|
|
|
ldax #$0000 ;load address will be first 2 bytes of file we download (LO/HI order)
|
|
|
|
stax tftp_load_address
|
|
|
|
|
|
|
|
ldax #downloading_msg
|
|
|
|
jsr print
|
|
|
|
|
|
|
|
ldax #tftp_file
|
|
|
|
jsr download
|
|
|
|
|
|
|
|
bcc @file_downloaded_ok
|
2009-01-22 01:27:03 +00:00
|
|
|
jmp bad_boot
|
|
|
|
|
2009-03-26 03:17:47 +00:00
|
|
|
@no_files_on_server:
|
|
|
|
ldax #no_files_on_server
|
|
|
|
jsr print
|
|
|
|
|
|
|
|
jmp bad_boot
|
|
|
|
|
2009-01-22 01:27:03 +00:00
|
|
|
@file_downloaded_ok:
|
|
|
|
;check whether the file we just downloaded was a BASIC prg
|
|
|
|
lda tftp_load_address
|
|
|
|
cmp #01
|
|
|
|
bne @not_a_basic_file
|
|
|
|
lda tftp_load_address+1
|
|
|
|
cmp #$08
|
|
|
|
bne @not_a_basic_file
|
|
|
|
|
|
|
|
jsr $e453 ;set BASIC vectors
|
|
|
|
jsr $e3bf ;initialize BASIC
|
|
|
|
jsr $a86e
|
|
|
|
jsr $a533 ; re-bind BASIC lines
|
|
|
|
ldx $22 ;load end-of-BASIC pointer (lo byte)
|
|
|
|
ldy $23 ;load end-of-BASIC pointer (hi byte)
|
|
|
|
stx $2d ;save end-of-BASIC pointer (lo byte)
|
|
|
|
sty $2e ;save end-of-BASIC pointer (hi byte)
|
|
|
|
jsr $a659 ; CLR (reset variables)
|
|
|
|
jmp $a7ae ; jump to BASIC interpreter loop
|
|
|
|
|
|
|
|
@not_a_basic_file:
|
|
|
|
lda #$4C ;opcode for JMP
|
|
|
|
sta bin_file_jmp
|
|
|
|
ldax tftp_load_address
|
|
|
|
stax bin_file_jmp+1
|
|
|
|
jsr bin_file_jmp
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
bad_boot:
|
2009-03-26 00:43:35 +00:00
|
|
|
ldax #press_a_key_to_continue
|
|
|
|
jsr print
|
|
|
|
jsr get_key
|
|
|
|
jmp $fe66 ;do a wam start
|
2009-01-22 01:27:03 +00:00
|
|
|
|
|
|
|
download:
|
|
|
|
stax tftp_filename
|
|
|
|
jsr print
|
|
|
|
jsr print_cr
|
|
|
|
|
|
|
|
jsr tftp_download
|
|
|
|
bcc :+
|
|
|
|
|
|
|
|
ldax #tftp_download_fail_msg
|
|
|
|
jsr print
|
|
|
|
sec
|
|
|
|
rts
|
|
|
|
|
|
|
|
:
|
|
|
|
ldax #tftp_download_ok_msg
|
|
|
|
jsr print
|
|
|
|
clc
|
|
|
|
rts
|
|
|
|
|
|
|
|
.rodata
|
|
|
|
|
2009-03-27 13:19:05 +00:00
|
|
|
startup_msg:
|
|
|
|
.byte "NETBOOT65 - C64 NETWORK BOOT CLIENT V0.2",13
|
|
|
|
.byte "F1=TFTP BOOT, F3=BASIC",13
|
|
|
|
.byte 0
|
2009-01-22 01:27:03 +00:00
|
|
|
|
|
|
|
downloading_msg: .asciiz "DOWNLOADING "
|
|
|
|
|
2009-03-08 10:18:59 +00:00
|
|
|
getting_dir_listing_msg: .asciiz "FETCHING TFTP DIRECTORY FOR "
|
|
|
|
|
|
|
|
tftp_dir_listing_fail_msg:
|
2009-03-26 01:00:12 +00:00
|
|
|
.byte "DIR LISTING FAILED",13,0
|
2009-01-22 01:27:03 +00:00
|
|
|
|
|
|
|
tftp_download_fail_msg:
|
|
|
|
.byte "DOWNLOAD FAILED", 13, 0
|
|
|
|
|
|
|
|
tftp_download_ok_msg:
|
|
|
|
.byte "DOWNLOAD OK", 13, 0
|
|
|
|
|
2009-03-08 10:18:59 +00:00
|
|
|
tftp_dir_filemask:
|
|
|
|
.asciiz "*.PRG"
|
2009-03-26 00:43:35 +00:00
|
|
|
|
2009-03-26 01:00:12 +00:00
|
|
|
tftp_file:
|
|
|
|
.asciiz "BOOTC64.PRG"
|
|
|
|
|
2009-03-26 03:17:47 +00:00
|
|
|
no_files_on_server:
|
|
|
|
.byte "TFTP SERVER HAS NO MATCHING FILES",13,0
|
|
|
|
|
2009-03-26 00:43:35 +00:00
|
|
|
press_a_key_to_continue:
|
|
|
|
.byte "PRESS A KEY TO CONTINUE",13,0
|