From 7387bed442fd19f980c29d9f36c4bcbd397cecd3 Mon Sep 17 00:00:00 2001 From: jonnosan Date: Tue, 14 Apr 2009 11:03:36 +0000 Subject: [PATCH] git-svn-id: http://svn.code.sf.net/p/netboot65/code@102 93682198-c243-4bdb-bd91-e943c89aac3b --- client/nb65_api/Makefile | 63 +++++ client/nb65_api/bootmenu.s | 145 +++++++++++ client/nb65_api/fix_cart.rb | 26 ++ client/nb65_api/hello | Bin 0 -> 256 bytes client/nb65_api/rrnetboot.s | 491 ++++++++++++++++++++++++++++++++++++ client/nb65_api/utherboot.s | 297 ++++++++++++++++++++++ 6 files changed, 1022 insertions(+) create mode 100644 client/nb65_api/Makefile create mode 100644 client/nb65_api/bootmenu.s create mode 100644 client/nb65_api/fix_cart.rb create mode 100644 client/nb65_api/hello create mode 100644 client/nb65_api/rrnetboot.s create mode 100644 client/nb65_api/utherboot.s diff --git a/client/nb65_api/Makefile b/client/nb65_api/Makefile new file mode 100644 index 0000000..c267a8f --- /dev/null +++ b/client/nb65_api/Makefile @@ -0,0 +1,63 @@ +AS=ca65 +LD=ld65 +CFLAGS=-Oirs -t $(TARGET) +AFLAGS= + +INCFILES=\ + ../inc/common.i\ + ../inc/commonprint.i\ + ../inc/net.i\ + ../inc/menu.i\ + ../inc/nb65_constants.i\ + + +IP65LIB=../ip65/ip65.lib + +C64PROGLIB=../drivers/c64prog.lib +C64NB65LIB=../drivers/c64nb65.lib +APPLE2PROGLIB=../drivers/apple2prog.lib + +BOOTA2.PG2=../../server/boot/BOOTA2.PG2 + +all: \ + rrnetboot.bin \ + utherboot.dsk \ + 64nicboot.bin \ + $(BOOTA2.PG2) \ + +rrnetboot.o: rrnetboot.s $(INCFILES) + $(AS) -DBANKSWITCH_SUPPORT=2 $(AFLAGS) $< + +64nicboot.o: rrnetboot.s $(INCFILES) + $(AS) -DBANKSWITCH_SUPPORT=1 $(AFLAGS) -o 64nicboot.o $< + +%.o: %.s $(INCFILES) + $(AS) $(AFLAGS) $< + +rrnetboot.bin: rrnetboot.o $(IP65LIB) $(C64NB65LIB) $(INCFILES) ../cfg/rrbin.cfg + $(LD) -m rrnetboot.map -vm -C ../cfg/rrbin.cfg -o rrnetboot.bin $< $(IP65LIB) $(C64NB65LIB) + ruby fix_cart.rb rrnetboot.bin 8193 + +64nicboot.bin: 64nicboot.o $(IP65LIB) $(C64NB65LIB) $(INCFILES) ../cfg/rrbin.cfg + $(LD) -C ../cfg/rrbin.cfg -o 64nicboot.bin $< $(IP65LIB) $(C64NB65LIB) + ruby fix_cart.rb 64nicboot.bin 8192 + +utherboot.pg2: utherboot.o $(IP65LIB) $(APPLE2PROGLIB) $(INCFILES) ../cfg/a2language_card.cfg + $(LD) -m utherboot.map -C ../cfg/a2language_card.cfg -o utherboot.pg2 $< $(IP65LIB) $(APPLE2PROGLIB) + +utherboot.dsk: utherboot.pg2 + ripxplore.rb --init AppleDos utherboot.dsk -a utherboot.pg2 -t AppleBinary + ripxplore.rb utherboot.dsk -a hello -t Applesoft + +$(BOOTA2.PG2): bootmenu.o $(IP65LIB) $(APPLE2PROGLIB) $(INCFILES) ../cfg/a2language_card.cfg + $(LD) -m bootmenu.map -C ../cfg/a2language_card.cfg -o $(BOOTA2.PG2) $< $(IP65LIB) $(APPLE2PROGLIB) + +clean: + rm -f *.o + rm -f rrnetboot.bin rrnetboot.map + rm -f 64nicboot.bin 64nicboot.map + rm -f utherboot.pg2 utherboot.map utherboot.dsk + rm -f $(BOOTA2.PG2) + +distclean: clean + rm -f *~ diff --git a/client/nb65_api/bootmenu.s b/client/nb65_api/bootmenu.s new file mode 100644 index 0000000..a54c934 --- /dev/null +++ b/client/nb65_api/bootmenu.s @@ -0,0 +1,145 @@ +;############# +; +; This program looks for a TNDP server on the network, presents a catalog of volumes on that server, and allows a volume to be attached +; +; jonno@jamtronix.com - January 2009 +; + + .include "../inc/common.i" + .include "../inc/commonprint.i" + .include "../inc/net.i" + .import cls + + .import exit_to_basic + + .import copymem + .importzp copy_src + .importzp copy_dest + + .import __STARTUP_LOAD__ + .import __STARTUP_SIZE__ + .import __BSS_LOAD__ + .import __DATA_LOAD__ + .import __DATA_RUN__ + .import __DATA_SIZE__ + .import __RODATA_LOAD__ + .import __RODATA_RUN__ + .import __RODATA_SIZE__ + .import __CODE_LOAD__ + .import __CODE_RUN__ + .import __CODE_SIZE__ + +.segment "PAGE3" + +disable_language_card: .res 3 +bin_file_jmp: .res 3 + +; ------------------------------------------------------------------------ + + .segment "EXEHDR" + + .addr __STARTUP_LOAD__ ; Start address + .word __STARTUP_SIZE__+__CODE_SIZE__+__RODATA_SIZE__+__DATA_SIZE__+4 ; Size + +; ------------------------------------------------------------------------ + + +.segment "STARTUP" + + + lda $c089 ;enable language : card read ROM, write RAM, BANK 1 + + ;copy the monitor rom on to the language card + ldax #$f800 + stax copy_src + stax copy_dest + ldax #$0800 + jsr startup_copymem + + + lda $c08b ;enable language : card read RAM, write RAM, BANK 1 + lda $c08b ;this soft switch needs to be read twice + + + ;relocate the CODE segment + ldax #__CODE_LOAD__ + stax copy_src + ldax #__CODE_RUN__ + stax copy_dest + ldax #__CODE_SIZE__ + jsr startup_copymem + + + ;relocate the RODATA segment + ldax #__RODATA_LOAD__ + stax copy_src + ldax #__RODATA_RUN__ + stax copy_dest + ldax #__RODATA_SIZE__ + jsr startup_copymem + + ;relocate the DATA segment + ldax #__DATA_LOAD__ + stax copy_src + ldax #__DATA_RUN__ + stax copy_dest + ldax #__DATA_SIZE__ + jsr startup_copymem + + jmp init + +; copy memory +; set copy_src and copy_dest, length in A/X + + +end: .res 1 + +startup_copymem: + sta end + ldy #0 + + cpx #0 + beq @tail + +: lda (copy_src),y + sta (copy_dest),y + iny + bne :- + inc copy_src+1 ;next page + inc copy_dest+1 ;next page + dex + bne :- + +@tail: + lda end + beq @done + +: lda (copy_src),y + sta (copy_dest),y + iny + cpy end + bne :- + +@done: + rts + +.code + + +init: + + jsr cls + + ldax #startup_msg + jsr print + jsr print_cr + + jmp exit_to_basic + + .rodata +startup_msg: .byte "NETBOOT65 FOR APPLE 2 V0.1",13 +.byte "SEE README.TXT FOR MORE INFO (INCLUDING",13 +.byte "HOW TO RUN SOMETHING MORE INTERESTING)",13 +.byte 0 + + diff --git a/client/nb65_api/fix_cart.rb b/client/nb65_api/fix_cart.rb new file mode 100644 index 0000000..2aca81d --- /dev/null +++ b/client/nb65_api/fix_cart.rb @@ -0,0 +1,26 @@ +# +# Vice will treat a cartridge bin file that is of an even length as if the first 2 bytes in the file are a load address to be skipped over +# so we want to make sure the bin file is an odd length - specifically 8193 bytes +# + + +PAD_BYTE=0xff.chr +filename=ARGV[0] + +if filename.nil? then + puts "no filename specified" + exit +end + +if ARGV[1].nil? then + puts "no padding length specified" + exit +end +file_length=ARGV[1].to_i + +infile=File.open(filename,"rb").read +puts "fixing length of #{filename} from #{infile.length} to #{file_length} bytes" +outfile=File.open(filename,"wb") +outfile<