From dc74ddbaf1dff6e236c72b27de6743d582a41d35 Mon Sep 17 00:00:00 2001 From: LGB Date: Mon, 22 Aug 2016 19:02:38 +0200 Subject: [PATCH 01/12] Dirty hack to load GEOS from C65 mode directly Basically it just "prefixes" the puc'ed binary with a C65 basic stub to set-up some C64-compatible settings in relation of memory and relocting stuff followed by transferring control to the old un-puc' stuff. In this way, GEOS65 can be loaded from C65 mode as well (no need for GO64 first). The result works in my Xemu/C65 emulator, however GEOS won't work, as it reads CIA-2 reg 0, maybe because of IEC serial bus. However that is not emulated, and a new disk driver is needed for F011 FDC in Commodore 65. There is *some* driver for that already, but it's not clear it's for Mega65 only or C65 too. Moreover, the current GEOS repository of mist64 does not allow to include custom disk driver other than 1541, at least I couldn't find it out, how to do so. --- .gitignore | 7 +++- Makefile | 29 +++++++++++++-- c65boot.s | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+), 5 deletions(-) create mode 100644 c65boot.s diff --git a/.gitignore b/.gitignore index c637b774..cd194e4a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,8 @@ *.bin *.prg *.d64 -desktop.cvt -kernal.map +*.d81 +/desktop.cvt +/kernal.map +/GEOS64.D64 +/GEOS64.D81 diff --git a/Makefile b/Makefile index bec9b043..52404d3d 100755 --- a/Makefile +++ b/Makefile @@ -63,24 +63,44 @@ ALL_BINS= \ koalapad.bin \ pcanalog.bin -all: geos.d64 +all: geos.d64 geos.d81 clean: - rm -f $(KERNAL_OBJECTS) drv/*.o input/*.o $(ALL_BINS) combined.prg compressed.prg geos.d64 + rm -f $(KERNAL_OBJECTS) drv/*.o input/*.o $(ALL_BINS) combined.prg compressed.prg geos.d64 geos.d81 compressed_c65.prg c65boot.o -geos.d64: compressed.prg +geos.d64: compressed.prg compressed_c65.prg if [ -e GEOS64.D64 ]; then \ cp GEOS64.D64 geos.d64; \ echo delete geos geoboot | c1541 geos.d64 >/dev/null; \ echo write compressed.prg geos | c1541 geos.d64 >/dev/null; \ + echo write compressed_c65.prg geos65 | c1541 geos.d64 >/dev/null; \ echo \*\*\* Created geos.d64 based on GEOS64.D64.; \ else \ echo format geos,00 d64 geos.d64 | c1541 >/dev/null; \ echo write compressed.prg geos | c1541 geos.d64 >/dev/null; \ + echo write compressed_c65.prg geos65 | c1541 geos.d64 >/dev/null; \ if [ -e desktop.cvt ]; then echo geoswrite desktop.cvt | c1541 geos.d64; fi >/dev/null; \ echo \*\*\* Created fresh geos.d64.; \ fi; +geos.d81: compressed.prg compressed_c65.prg + if [ -e GEOS64.D81 ]; then \ + cp GEOS64.D81 geos.d81; \ + echo delete geos geoboot | c1541 geos.d81 >/dev/null; \ + echo write compressed.prg geos | c1541 geos.d81 >/dev/null; \ + echo write compressed_c65.prg geos65 | c1541 geos.d81 >/dev/null; \ + echo \*\*\* Created geos.d81 based on GEOS64.D81.; \ + else \ + echo format geos,00 d81 geos.d81 | c1541 >/dev/null; \ + echo write compressed.prg geos | c1541 geos.d81 >/dev/null; \ + echo write compressed_c65.prg geos65 | c1541 geos.d81 >/dev/null; \ + if [ -e desktop.cvt ]; then echo geoswrite desktop.cvt | c1541 geos.d81; fi >/dev/null; \ + echo \*\*\* Created fresh geos.d81.; \ + fi; + +compressed_c65.prg: compressed.prg c65boot.o + $(LD) -t none c65boot.o -o $@ + compressed.prg: combined.prg pucrunch -f -c64 -x0x5000 $< $@ @@ -109,6 +129,9 @@ drv1571.bin: drv/drv1571.o drv/drv1571.cfg $(DEPS) drv1581.bin: drv/drv1581.o drv/drv1581.cfg $(DEPS) $(LD) -C drv/drv1581.cfg drv/drv1581.o -o $@ +drvf011.bin: drv/drvf011.o drv/drvf011.cfg $(DEPS) + $(LD) -C drv/drvf011.cfg drv/drvf011.o -o $@ + amigamse.bin: input/amigamse.o input/amigamse.cfg $(DEPS) $(LD) -C input/amigamse.cfg input/amigamse.o -o $@ diff --git a/c65boot.s b/c65boot.s new file mode 100644 index 00000000..1160cbf4 --- /dev/null +++ b/c65boot.s @@ -0,0 +1,105 @@ +; VERY ugly C65 GEOS "loader". +; +; (C)2016 LGB (Gabor Lenart) +; +; Basically it gets the pucrunch'ed (for C64) version of the GEOS build, with its BASIC stub, etc +; And copy to the address where it would be on C64, then execute it directly, bypassing the SYS stuff. +; Also it sets up an unmapped 4510 status, without VIC3 reg $30 ROM mapping and the desired CPU port value +; for some kind of faked "C64 compatibility", though, the CPU fast mode is kept turned on for some +; GEOS performance boost :) +; Note, that I was lazy to write proper linker cfg file and use segments, so it's an ugly .ORG stuff. +; Also, a more proper solution would be use a custom un-puprunch code in the loader without the ugly +; copy hack ... + + .ORG $1FFF ; C65 basic loader start stuff + + .WORD basic +basic: + .WORD basic_next + .WORD 2016 + .BYTE $FE, $02 ; BASIC token (double byte ...) for "BANK" + .BYTE " 0 : " + .BYTE $9E, " " ; SYS token + .BYTE (main/1000+48) + .BYTE (main/100 .MOD 10+48) + .BYTE (main/10 .MOD 10+48) + .BYTE (main .MOD 10+48) + .BYTE " : GEOS FOR C65" + .BYTE 0 +basic_next: + .WORD 0 + + +relocator_run_addr = $400 + + + +relocator_load_addr: + .ORG relocator_run_addr + ; Copy stuff to the usual basic start location + ; Yes, cool guys use DMAgic on C65. Though I am not a cool guy. Yet :) +relocator_start: +relocator_exec: + LDA geos_kernal,Y + STA $7FF,Y + INY + BNE relocator_exec + INC relocator_exec + 2 + INC relocator_exec + 5 + DEX + BPL relocator_exec + NOP ; aka. EOM ... (must be here!) + JMP 2061 ; the ugly hack: we simulate pucrunch's SYS 2061 here + + + .ORG relocator_load_addr + (* - relocator_run_addr) + + + +main: + LDA #0 + TAX + TAY + .BYTE $4B ; TAZ + .BYTE $5C ; MAP (it also inhibits interrupts till the next NOP ... errrr ... EOM), totally unmapped status + .BYTE $5B ; TAB, zero page is _zero_ page :) + INY + .BYTE $2B ; TYS, standard stack location + .BYTE $03 ; SEE, 8 bit stack + ; Just to be sure, enable newVic mode + LDA #$A5 + STA $D02F + LDA #$96 + STA $D02F + ; CPU port stuff, C64-alike config + LDA #$FF + STA 0 + LDA #$37 + STA 1 ; the "CPU port" + ; Various VIC register stuffs + LDA #64 + STA $D031 ; turn maybe used enhanched VIC3 capabilities OFF (other than FAST mode!) + LDA #0 + STA $D030 ; turn ROM mappings / etc OFF + STA $D019 ; disable VIC interrupts + STA $D01A + LDA #$15 + STA $D018 + ; *** Copy the relocator code + ; 128 bytes should be enough for everyone! + LDX #0 +copy_relocator: + LDA relocator_load_addr, X + STA relocator_run_addr, X + INX + BPL copy_relocator + ; Preparing to call the relocator code + LDY #0 + LDX #geos_kernal_pages + ; Call the relocator + JMP relocator_exec + + +geos_kernal: + .INCBIN "compressed.prg" +geos_kernal_pages = ((* - geos_kernal) >> 8) + 1 From eec1b9557ae94ddc450beb8dc14d495768bf1f26 Mon Sep 17 00:00:00 2001 From: LGB Date: Tue, 23 Aug 2016 01:54:58 +0200 Subject: [PATCH 02/12] Unfinisged work of better load for C65 --- Makefile | 22 ++- loader/boot.s | 89 +++++++++++ loader/c65.cfg | 13 ++ c65boot.s => loader/uglyboot.s | 0 loader/uncrunch.s | 278 +++++++++++++++++++++++++++++++++ 5 files changed, 394 insertions(+), 8 deletions(-) create mode 100644 loader/boot.s create mode 100644 loader/c65.cfg rename c65boot.s => loader/uglyboot.s (100%) create mode 100644 loader/uncrunch.s diff --git a/Makefile b/Makefile index 52404d3d..a30b1806 100755 --- a/Makefile +++ b/Makefile @@ -66,43 +66,49 @@ ALL_BINS= \ all: geos.d64 geos.d81 clean: - rm -f $(KERNAL_OBJECTS) drv/*.o input/*.o $(ALL_BINS) combined.prg compressed.prg geos.d64 geos.d81 compressed_c65.prg c65boot.o + rm -f $(KERNAL_OBJECTS) drv/*.o input/*.o $(ALL_BINS) combined.prg compressed.prg geos.d64 geos.d81 compressed_c65.prg compressed.bin loader/*.o compressed_c65m.prg -geos.d64: compressed.prg compressed_c65.prg +geos.d64: compressed.prg if [ -e GEOS64.D64 ]; then \ cp GEOS64.D64 geos.d64; \ echo delete geos geoboot | c1541 geos.d64 >/dev/null; \ echo write compressed.prg geos | c1541 geos.d64 >/dev/null; \ - echo write compressed_c65.prg geos65 | c1541 geos.d64 >/dev/null; \ echo \*\*\* Created geos.d64 based on GEOS64.D64.; \ else \ echo format geos,00 d64 geos.d64 | c1541 >/dev/null; \ echo write compressed.prg geos | c1541 geos.d64 >/dev/null; \ - echo write compressed_c65.prg geos65 | c1541 geos.d64 >/dev/null; \ if [ -e desktop.cvt ]; then echo geoswrite desktop.cvt | c1541 geos.d64; fi >/dev/null; \ echo \*\*\* Created fresh geos.d64.; \ fi; -geos.d81: compressed.prg compressed_c65.prg +geos.d81: compressed.prg compressed_c65.prg compressed_c65m.prg if [ -e GEOS64.D81 ]; then \ cp GEOS64.D81 geos.d81; \ echo delete geos geoboot | c1541 geos.d81 >/dev/null; \ echo write compressed.prg geos | c1541 geos.d81 >/dev/null; \ echo write compressed_c65.prg geos65 | c1541 geos.d81 >/dev/null; \ + echo write compressed_c65m.prg geos65m | c1541 geos.d81 >/dev/null; \ echo \*\*\* Created geos.d81 based on GEOS64.D81.; \ else \ echo format geos,00 d81 geos.d81 | c1541 >/dev/null; \ echo write compressed.prg geos | c1541 geos.d81 >/dev/null; \ echo write compressed_c65.prg geos65 | c1541 geos.d81 >/dev/null; \ + echo write compressed_c65m.prg geos65m | c1541 geos.d81 >/dev/null; \ if [ -e desktop.cvt ]; then echo geoswrite desktop.cvt | c1541 geos.d81; fi >/dev/null; \ echo \*\*\* Created fresh geos.d81.; \ fi; -compressed_c65.prg: compressed.prg c65boot.o - $(LD) -t none c65boot.o -o $@ +compressed_c65.prg: compressed.prg loader/uglyboot.o + $(LD) -t none loader/uglyboot.o -o $@ + +compressed_c65m.prg: compressed.bin loader/uncrunch.o loader/boot.o + $(LD) -C loader/c65.cfg loader/boot.o loader/uncrunch.o -o $@ compressed.prg: combined.prg - pucrunch -f -c64 -x0x5000 $< $@ + pucrunch +f -c64 -x0x5000 $< $@ + +compressed.bin: combined.prg + pucrunch -c0 -x0x5000 $< $@ combined.prg: $(ALL_BINS) printf "\x00\x50" > tmp.bin diff --git a/loader/boot.s b/loader/boot.s new file mode 100644 index 00000000..3318b1e1 --- /dev/null +++ b/loader/boot.s @@ -0,0 +1,89 @@ +; VERY ugly C65 GEOS "loader". +; +; (C)2016 LGB (Gabor Lenart) +; +; Basically it gets the pucrunch'ed (for C64) version of the GEOS build, with its BASIC stub, etc +; And copy to the address where it would be on C64, then execute it directly, bypassing the SYS stuff. +; Also it sets up an unmapped 4510 status, without VIC3 reg $30 ROM mapping and the desired CPU port value +; for some kind of faked "C64 compatibility", though, the CPU fast mode is kept turned on for some +; GEOS performance boost :) +; Note, that I was lazy to write proper linker cfg file and use segments, so it's an ugly .ORG stuff. +; Also, a more proper solution would be use a custom un-puprunch code in the loader without the ugly +; copy hack ... + + +.SEGMENT "LOADADDR" + .IMPORT __STUB_LOAD__ + .WORD __STUB_LOAD__ + + +.SEGMENT "STUB" +.SCOPE + .WORD next + .WORD 2016 + .BYTE $FE, $02 ; BASIC token (double byte ...) for "BANK" + .BYTE " 0 : " + .BYTE $9E, " " ; SYS token + .BYTE <(main/10000+48) + .BYTE <(main/1000 .MOD 10+48) + .BYTE <(main/100 .MOD 10+48) + .BYTE <(main/10 .MOD 10+48) + .BYTE <(main .MOD 10+48) + .BYTE " : GEOS FOR C65" + .BYTE 0 +next: .WORD 0 +.ENDSCOPE + + + +.CODE +.IMPORT uncruncher + + +.PROC main + LDA #0 + TAX + TAY + .BYTE $4B ; TAZ + .BYTE $5C ; MAP (it also inhibits interrupts till the next NOP ... errrr ... EOM), totally unmapped status + .BYTE $5B ; TAB, zero page is _zero_ page :) + INY + .BYTE $2B ; TYS, standard stack location + .BYTE $03 ; SEE, 8 bit stack + ; Just to be sure, enable newVic mode + LDA #$A5 + STA $D02F + LDA #$96 + STA $D02F + ; CPU port stuff, C64-alike config + LDA #$FF + STA 0 + LDA #$37 + STA 1 ; the "CPU port" + ; Various VIC register stuffs + LDA #64 + STA $D031 ; turn maybe used enhanched VIC3 capabilities OFF (other than FAST mode!) + LDA #0 + STA $D030 ; turn ROM mappings / etc OFF + STA $D019 ; disable VIC interrupts + STA $D01A + LDA #$15 + STA $D018 + ; *** Uncrunch + ; Call with X = HI of packed data, Y = LO of packed data + ; Returns exec address in X = HI and Y = LO + ; Carry will be set for error, cleared for OK + LDX #.HIBYTE(geos_kernal_compressed) + LDY #.LOBYTE(geos_kernal_compressed) + JSR uncruncher + BCS @unpack_error + NOP + JMP $5000 +@unpack_error: + INC 53281 + JMP @unpack_error +.ENDPROC + +.SEGMENT "PACKED" +geos_kernal_compressed: + .INCBIN "compressed.bin" diff --git a/loader/c65.cfg b/loader/c65.cfg new file mode 100644 index 00000000..2dc42fd1 --- /dev/null +++ b/loader/c65.cfg @@ -0,0 +1,13 @@ +FEATURES { + STARTADDRESS: default = $2001; +} +MEMORY { + LOADADDR: file = %O, start = %S - 2, size = 2; + STUFF: file = %O, start = %S, size = $A000; +} +SEGMENTS { + LOADADDR: load = LOADADDR; + STUB: load = STUFF, define = yes; + CODE: load = STUFF; + PACKED: load = STUFF; +} diff --git a/c65boot.s b/loader/uglyboot.s similarity index 100% rename from c65boot.s rename to loader/uglyboot.s diff --git a/loader/uncrunch.s b/loader/uncrunch.s new file mode 100644 index 00000000..87e291b4 --- /dev/null +++ b/loader/uncrunch.s @@ -0,0 +1,278 @@ +; Uncrunch code from pucrunch +; Somewhat reformatted to be able to be assembled with CA65 + +; Pucrunch (C)1997-2008 by Pasi 'Albert' Ojala, a1bert@iki.fi +; Pucrunch is now under LGPL: see the doc for details. + +; SHORTY+IRQLOAD 354 bytes +; no rle =~ -83 bytes -> 271 +; fixed params =~ -48 bytes -> 306 +; 223 bytes + +.CODE +.FEATURE labels_without_colons + +LZPOS = $9e ; 2 ZeroPage temporaries +bitstr = $fb ; 1 temporary (does not need to be ZP) + + ; Call with X = HI of packed data, Y = LO of packed data + ; Returns exec address in X = HI and Y = LO + ; Carry will be set for error, cleared for OK +.EXPORT uncruncher +.PROC uncruncher +SHORTY = 0 ;1 ; assume file is ok +.if (SHORTY = 0) + sei + lda #$35 + sta 1 +.endif + ; Setup read pointer + sty INPOS + stx INPOS+1 + +.if SHORTY + ldx #5 +@l222: jsr getbyt ; skip 'p', 'u', endAddr HI&LO, leave starting escape in A + dex + bne @l222 +.else + jsr getbyt ; 'p' + cmp #112 + beq @l9 + sec ; error + jmp eof2 +@l9: jsr getbyt ; 'u' + cmp #117 + beq @l8 + sec ; error + jmp eof2 +@l8: jsr getbyt ; skip endAddr + jsr getbyt + jsr getbyt +.endif + sta esc+1 ; starting escape + + jsr getbyt ; read startAddr + sta OUTPOS + jsr getbyt + sta OUTPOS+1 + jsr getbyt ; read # of escape bits + sta escB0+1 + sta escB1+1 + lda #8 + sec + sbc escB1+1 + sta noesc+1 ; 8-escBits + + jsr getbyt + sta mg+1 ; maxGamma + 1 + lda #9 + sec + sbc mg+1 ; 8 - maxGamma == (8 + 1) - (maxGamma + 1) + sta longrle+1 + jsr getbyt + sta mg1+1 ; (1< LZ77 + ;tya ; A = 0 + jsr get1bit ; X = 0 + lsr ; bit -> C, A = 0 + bcc lz77_2 ; A=0 -> LZPOS+1 + ;***FALL THRU*** + + ; e..e01 + jsr get1bit ; X = 0 + lsr ; bit -> C, A = 0 + bcc newesc ; e..e010 + ;***FALL THRU*** + + ; e..e011 +srle iny ; Y is 1 bigger than MSB loops + jsr getval ; Y is 1, get len, X = 0 + sta LZPOS ; xstore - Save length LSB +mg1 cmp #64 ; ** PARAMETER 63-64 -> C clear, 64-64 -> C set.. + bcc chrcode ; short RLE, get bytecode + +longrle ldx #2 ; ** PARAMETER 111111xxxxxx + jsr getbits ; get 3/2/1 more bits to get a full byte, X = 0 + sta LZPOS ; xstore - Save length LSB + + jsr getval ; length MSB, X = 0 + tay ; Y is 1 bigger than MSB loops + +chrcode jsr getval ; Byte Code, X = 0 + tax ; this is executed most of the time anyway + lda table-1,x ; Saves one jump if done here (loses one txa) + + cpx #16 ; 32 ; 31-32 -> C clear, 32-32 -> C set.. + bcc @l1 ; 1..31, we got the right byte from the table + + ; Ranks 32..64 (11111 xxxxx), get byte.. + txa ; get back the value (5 valid bits) + ldx #4 ;3 + jsr getbits ; get 3 more bits to get a full byte, X = 0 + +@l1: ldx LZPOS ; xstore - get length LSB + inx ; adjust for cpx#$ff;bne -> bne +dorle jsr putch + dex + bne dorle ; xstore 0..255 -> 1..256 + dey + bne dorle ; Y was 1 bigger than wanted originally +mainbeq beq main ; reverse condition -> jump always + + +lz77 jsr getval ; X = 0 +mg21 cmp #127 ; ** PARAMETER Clears carry (is maximum value) + bne noeof + ; EOF +eof +.if SHORTY = 0 + ; EOF + clc ; removed 'eof' label, duplication! +eof2 lda #$37 + sta 1 + cli +.endif +hi ldx #0 +lo ldy #0 + rts + + +noeof sbc #0 ; C is clear -> subtract 1 (1..126 -> 0..125) +elzpb ldx #0 ; ** PARAMETER (more bits to get) + jsr getchkf ; clears Carry, X = 0 + +lz77_2 sta LZPOS+1 ; offset MSB + jsr getbyte ; clears Carry, X = 0 + ; Note: Already eor:ed in the compressor.. + ;eor #255 ; offset LSB 2's complement -1 (i.e. -X = ~X+1) + adc OUTPOS ; -offset -1 + curpos (C is clear) + ldx LZPOS ; xstore = LZLEN (read before it's overwritten) + sta LZPOS + + lda OUTPOS+1 + sbc LZPOS+1 ; takes C into account + sta LZPOS+1 ; copy X+1 number of chars from LZPOS to OUTPOS + ;ldy #0 ; Y was 0 originally, we don't change it + + inx ; adjust for cpx#$ff;bne -> bne +lzloop lda (LZPOS),y ; using abs,y is 3 bytes longer, only 1 cycle/byte faster + jsr putch ; Note: must be copied forwards! + iny ; Y does not wrap because X=0..255 and Y initially 0 + dex + bne lzloop ; X loops, (256,1..255) + beq mainbeq ; jump through another beq (-1 byte, +3 cycles) + + +getnew pha ; 1 Byte/3 cycles + +INPOS = *+1 + lda $aaaa ; ** PARAMETER + inc INPOS + bne @l0 + inc INPOS+1 +@l0: sec + rol ; Shift out the next bit and + ; shift in C=1 (last bit marker) + sta bitstr ; bitstr initial value = $80 == empty + pla ; 1 Byte/4 cycles + rts + ; 25+12 = 37 + +; getval : Gets a 'static huffman coded' value +; ** Scratches X, returns the value in A ** +getval inx ; X <- 1 + txa ; set the top bit (value is 1..255) +gv0 asl bitstr + bne @l1 + jsr getnew +@l1: bcc getchk ; got 0-bit + inx +mg cpx #7 ; ** PARAMETER unary code maximum length + 1 + bne gv0 + beq getchk ; inverse condition -> jump always + ; getval: 18 bytes + ; 15 + 17*n + 6+15*n+12 + 36*n/8 = 33 + 32*n + 36*n/8 cycles + +; getbits: Gets X bits from the stream +; ** Scratches X, returns the value in A ** +getbyte ldx #7 +get1bit inx ;2 +getbits asl bitstr + bne @l1 + jsr getnew +@l1: rol ;2 +getchk dex ;2 more bits to get ? +getchkf bne getbits ;2/3 + clc ;2 return carry cleared + rts ;6+6 + + +OUTPOS = *+1 ; ZP +putch sta $aaaa ; ** parameter + inc OUTPOS ; ZP + bne @l0 + inc OUTPOS+1 ; ZP +@l0: rts + + + +table .BYTE 0,0,0,0,0,0,0 + .BYTE 0,0,0,0,0,0,0,0 + ;dc.b 0,0,0,0,0,0,0,0 + ;dc.b 0,0,0,0,0,0,0,0 + +.ENDPROC From 3f3335ef1c67a3c64699abcf99a2b3d2b072cacc Mon Sep 17 00:00:00 2001 From: LGB Date: Tue, 23 Aug 2016 23:34:26 +0200 Subject: [PATCH 03/12] Borrowed from the Mega65 project :) --- drv/drvf011.cfg | 7 + drv/drvf011.s | 1093 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1100 insertions(+) create mode 100644 drv/drvf011.cfg create mode 100644 drv/drvf011.s diff --git a/drv/drvf011.cfg b/drv/drvf011.cfg new file mode 100644 index 00000000..99edda9a --- /dev/null +++ b/drv/drvf011.cfg @@ -0,0 +1,7 @@ +MEMORY { + DISK_BASE: start = $9000, size = $0D80 file = %O; +} + +SEGMENTS { + drvf011: load = DISK_BASE, type = ro; +} diff --git a/drv/drvf011.s b/drv/drvf011.s new file mode 100644 index 00000000..ef13d61e --- /dev/null +++ b/drv/drvf011.s @@ -0,0 +1,1093 @@ + +;GEOS F1011 disk driver +;reassembled by Maciej 'YTM/Elysium' Witkowiak +;31.08-3.09.2001 +;ported 1581 to F011 for MEGA65 compatiblity +;05.08.2016 - 08.08.2016 + + ;*=DISK_BASE + +.include "const.inc" +.include "geossym.inc" +.include "geosmac.inc" +.include "kernal.inc" +.include "jumptab.inc" +.include "c64.inc" + +.segment "drvf011" + +DriveAddy = $0300 + +dir3Head = $9c80 + +_InitForIO: .word __InitForIO ;9000 +_DoneWithIO: .word __DoneWithIO ;9002 +_ExitTurbo: .word __ExitTurbo ;9004 +_PurgeTurbo: .word __PurgeTurbo ;9006 +_EnterTurbo: .word __EnterTurbo ;9008 +_ChangeDiskDevice: .word __ChangeDiskDevice ;900a +_NewDisk: .word __NewDisk ;900c +_ReadBlock: .word __ReadBlock ;900e +_WriteBlock: .word __WriteBlock ;9010 +_VerWriteBlock: .word __VerWriteBlock ;9012 +_OpenDisk: .word __OpenDisk ;9014 +_GetBlock: .word __GetBlock ;9016 +_PutBlock: .word __PutBlock ;9018 +_GetDirHead: .word __GetDirHead ;901a +_PutDirHead: .word __PutDirHead ;901c +_GetFreeDirBlk: .word __GetFreeDirBlk ;901e +_CalcBlksFree: .word __CalcBlksFree ;9020 +_FreeBlock: .word __FreeBlock ;9022 +_SetNextFree: .word __SetNextFree ;9024 +_FindBAMBit: .word __FindBAMBit ;9026 +_NxtBlkAlloc: .word __NxtBlkAlloc ;9028 +_BlkAlloc: .word __BlkAlloc ;902a +_ChkDkGEOS: .word __ChkDkGEOS ;902c +_SetGEOSDisk: .word __SetGEOSDisk ;902e + +Get1stDirEntry: JMP _Get1stDirEntry ;9030 +GetNxtDirEntry: JMP _GetNxtDirEntry ;9033 +GetBorder: JMP _GetBorder ;9036 +AddDirBlock: JMP _AddDirBlock ;9039 +ReadBuff: JMP _ReadBuff ;903c +WriteBuff: JMP _WriteBuff ;903f + JMP __I9042 ;9042 + JMP GetDOSError ;9045 +AllocateBlock: JMP _AllocateBlock ;9048 +ReadLink: JMP _ReadLink ;904b + +E904E: .byte $03 ;904e + +; ============================================================================== + +uname: .byte "U? 2 0 ", NULL +utands: .byte "00 00", NULL + .byte $0d +uname_end: + +bpname: .byte "B-P 2 0", NULL +bpname_end: + +cmdname: .byte " ", NULL +cmdnameLength: .byte 0 + +; ============================================================================== + +__GetDirHead: + JSR SetDirHead_1 ;904f + JSR __GetBlock + BNE GDH_0 + JSR SetDirHead_2 + JSR __GetBlock + BNE GDH_0 + JSR SetDirHead_3 + BNE __GetBlock +GDH_0: + RTS ;9064 + +_ReadBuff: + LoadW r4, diskBlkBuf ;9065 + +__GetBlock: + JSR InitForIO + JSR ReadBlock + JSR DoneWithIO + + TXA + RTS + +__PutDirHead: ;907d + JSR SetDirHead_1 + JSR __PutBlock + BNE PDH_0 + JSR SetDirHead_2 + JSR __PutBlock + BNE PDH_0 + JSR SetDirHead_3 + BNE __PutBlock +PDH_0: + RTS ;9092 + +_WriteBuff: + LoadW r4, diskBlkBuf ;9093 +__PutBlock: + JSR InitForIO + JSR WriteBlock + bnex PutBlk0 + JSR VerWriteBlock + +PutBlk0: + JSR DoneWithIO ;90ac + + TXA + RTS + +SetDirHead_1: + LDX #>curDirHead ;90b1 + LDY #dir2Head ;90b9 + LDY #dir3Head ;90c1 + LDY #cname + JSR $FFBD ; call SETNAM + + LDA #$02 ; file number 2 + LDX $BA ; last used device number + BNE _OpenBlockSkip + LDX #$08 ; default to device 8 + +_OpenBlockSkip: + LDY #$02 ; secondary address 2 + JSR $FFBA ; call SETLFS + + LDX #0 + JSR $FFC0 ; call OPEN + BCS _OpenBlockError ; if carry set, the file could not be opened + + ; open the command channel + LDA cmdnameLength + LDX #cmdname + JSR $FFBD ; call SETNAM + LDA #$0F ; file number 15 + LDX $BA ; last used device number + LDY #$0F ; secondary address 15 + JSR $FFBA ; call SETLFS + + LDX #0 + JSR $FFC0 ; call OPEN (open command channel and send U? command) + BCS _OpenBlockError + +_OpenBlockEnd: + RTS + +_OpenBlockError: + JSR $FFB7 + TAX + + JMP _OpenBlockEnd + +; ============================================================================== + +AToPetscii: + LDY #$2f + LDX #$3a + SEC +_loop1: + INY + SBC #100 + BCS _loop1 +_loop2: + DEX + ADC #10 + BMI _loop2 + ADC #$2f + + LDY #1 + STA (r4),Y + + DEY + TXA + STA (r4),Y + + RTS From 8d4f58644811b75d09669a3b656ec3b17d717883 Mon Sep 17 00:00:00 2001 From: LGB Date: Tue, 23 Aug 2016 23:35:41 +0200 Subject: [PATCH 04/12] More unfinished works --- .gitattributes | 5 +++ Makefile | 8 ++-- loader/boot.s | 40 ++++++++++++++++--- loader/c65.cfg | 3 +- loader/c65.inc | 25 ++++++++++++ loader/uncrunch.s | 99 +++++++++++++++++++++++------------------------ 6 files changed, 119 insertions(+), 61 deletions(-) create mode 100644 .gitattributes create mode 100644 loader/c65.inc diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..8b06d4c8 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +*.inc linguist-language=Assembly +*.s linguist-language=Assembly +Makefile.* linguist-language=Makefile +Makefile linguist-language=Makefile +*.bin linguist-language=Binary diff --git a/Makefile b/Makefile index a30b1806..c153caa3 100755 --- a/Makefile +++ b/Makefile @@ -56,6 +56,7 @@ ALL_BINS= \ drv1541.bin \ drv1571.bin \ drv1581.bin \ + drvf011.bin \ amigamse.bin \ joydrv.bin \ lightpen.bin \ @@ -71,7 +72,7 @@ clean: geos.d64: compressed.prg if [ -e GEOS64.D64 ]; then \ cp GEOS64.D64 geos.d64; \ - echo delete geos geoboot | c1541 geos.d64 >/dev/null; \ + echo 'delete geos geoboot configure "geos kernal"' | c1541 geos.d64 >/dev/null; \ echo write compressed.prg geos | c1541 geos.d64 >/dev/null; \ echo \*\*\* Created geos.d64 based on GEOS64.D64.; \ else \ @@ -84,7 +85,7 @@ geos.d64: compressed.prg geos.d81: compressed.prg compressed_c65.prg compressed_c65m.prg if [ -e GEOS64.D81 ]; then \ cp GEOS64.D81 geos.d81; \ - echo delete geos geoboot | c1541 geos.d81 >/dev/null; \ + echo 'delete geos geoboot configure "geos kernal"' | c1541 geos.d81 >/dev/null; \ echo write compressed.prg geos | c1541 geos.d81 >/dev/null; \ echo write compressed_c65.prg geos65 | c1541 geos.d81 >/dev/null; \ echo write compressed_c65m.prg geos65m | c1541 geos.d81 >/dev/null; \ @@ -113,7 +114,8 @@ compressed.bin: combined.prg combined.prg: $(ALL_BINS) printf "\x00\x50" > tmp.bin cat start.bin /dev/zero | dd bs=1 count=16384 >> tmp.bin 2> /dev/null - cat drv1541.bin /dev/zero | dd bs=1 count=3456 >> tmp.bin 2> /dev/null + #cat drv1541.bin /dev/zero | dd bs=1 count=3456 >> tmp.bin 2> /dev/null + cat drvf011.bin /dev/zero | dd bs=1 count=3456 >> tmp.bin 2> /dev/null cat lokernal.bin /dev/zero | dd bs=1 count=8640 >> tmp.bin 2> /dev/null cat kernal.bin /dev/zero | dd bs=1 count=16192 >> tmp.bin 2> /dev/null cat joydrv.bin >> tmp.bin 2> /dev/null diff --git a/loader/boot.s b/loader/boot.s index 3318b1e1..fe94feb4 100644 --- a/loader/boot.s +++ b/loader/boot.s @@ -12,6 +12,9 @@ ; copy hack ... +.INCLUDE "c65.inc" + + .SEGMENT "LOADADDR" .IMPORT __STUB_LOAD__ .WORD __STUB_LOAD__ @@ -40,6 +43,7 @@ next: .WORD 0 .IMPORT uncruncher + .PROC main LDA #0 TAX @@ -73,17 +77,41 @@ next: .WORD 0 ; Call with X = HI of packed data, Y = LO of packed data ; Returns exec address in X = HI and Y = LO ; Carry will be set for error, cleared for OK - LDX #.HIBYTE(geos_kernal_compressed) - LDY #.LOBYTE(geos_kernal_compressed) + .IMPORT __GEOS_LOAD__ + LDX #.HIBYTE(__GEOS_LOAD__) + LDY #.LOBYTE(__GEOS_LOAD__) JSR uncruncher BCS @unpack_error + JMP $5000 + ; Copy disk driver in place + ; Note: I want to crunch the driver itself too, + ; maybe include *more* disk drivers, and this way + ; hot-patch GEOS at $9000 [???] with the desired + ; disk driver based on detection ie Mega65/plain C65 + .IMPORT __DISKDRIVER_LOAD__ + .IMPORT __DISKDRIVER_SIZE__ + LDX #0 + LDY #.HIBYTE(__DISKDRIVER_SIZE__) + 1 +@cp: + LDA __DISKDRIVER_LOAD__,X + STA $9000,X + INX + BNE @cp + INC @cp + 2 + INC @cp + 5 + DEY + BNE @cp NOP JMP $5000 @unpack_error: - INC 53281 + INA + STA 53281 JMP @unpack_error .ENDPROC -.SEGMENT "PACKED" -geos_kernal_compressed: - .INCBIN "compressed.bin" + +.SEGMENT "DISKDRIVER" +.INCBIN "drvf011.bin" + +.SEGMENT "GEOS" +.INCBIN "compressed.bin" diff --git a/loader/c65.cfg b/loader/c65.cfg index 2dc42fd1..737eba85 100644 --- a/loader/c65.cfg +++ b/loader/c65.cfg @@ -9,5 +9,6 @@ SEGMENTS { LOADADDR: load = LOADADDR; STUB: load = STUFF, define = yes; CODE: load = STUFF; - PACKED: load = STUFF; + DISKDRIVER: load = STUFF, define = yes; + GEOS: load = STUFF, define = yes; } diff --git a/loader/c65.inc b/loader/c65.inc new file mode 100644 index 00000000..115a6e19 --- /dev/null +++ b/loader/c65.inc @@ -0,0 +1,25 @@ +; A 65CE02/4502 capable version of CA65 would be great + +; Set 65C02, it's quite "similar" to 65C02, not including though +; the (ZP),Z addressing mode instead of (ZP), missing Z register +; and some new opcodes. Here, we only define some simple macros +; to be used by my source, that's all. +.SETCPU "65C02" +.MACRO TAZ + .BYTE $4B +.ENDMAC +.MACRO MAP + .BYTE $5C +.ENDMAC +.MACRO TAB + .BYTE $5B +.ENDMAC +.MACRO TYS + .BYTE $2B +.ENDMAC +.MACRO SEE + .BYTE $03 +.ENDMAC +.MACRO EOM + NOP +.ENDMAC diff --git a/loader/uncrunch.s b/loader/uncrunch.s index 87e291b4..0c035f93 100644 --- a/loader/uncrunch.s +++ b/loader/uncrunch.s @@ -1,16 +1,11 @@ ; Uncrunch code from pucrunch ; Somewhat reformatted to be able to be assembled with CA65 +; Also removed cli/sti/lda and sta 1 stuffs, etc ; Pucrunch (C)1997-2008 by Pasi 'Albert' Ojala, a1bert@iki.fi ; Pucrunch is now under LGPL: see the doc for details. -; SHORTY+IRQLOAD 354 bytes -; no rle =~ -83 bytes -> 271 -; fixed params =~ -48 bytes -> 306 -; 223 bytes - .CODE -.FEATURE labels_without_colons LZPOS = $9e ; 2 ZeroPage temporaries bitstr = $fb ; 1 temporary (does not need to be ZP) @@ -21,11 +16,11 @@ bitstr = $fb ; 1 temporary (does not need to be ZP) .EXPORT uncruncher .PROC uncruncher SHORTY = 0 ;1 ; assume file is ok -.if (SHORTY = 0) - sei - lda #$35 - sta 1 -.endif +;.if (SHORTY = 0) +; sei +; lda #$35 +; sta 1 +;.endif ; Setup read pointer sty INPOS stx INPOS+1 @@ -98,27 +93,27 @@ SHORTY = 0 ;1 ; assume file is ok sta bitstr jmp main -getbyt jsr getnew +getbyt: jsr getnew lda bitstr ror rts -newesc ldy esc+1 ; remember the old code (top bits for escaped byte) -escB0 ldx #2 ; ** PARAMETER 0..8 +newesc: ldy esc+1 ; remember the old code (top bits for escaped byte) +escB0: ldx #2 ; ** PARAMETER 0..8 jsr getchkf ; get & save the new escape code sta esc+1 tya ; pre-set the bits ; Fall through and get the rest of the bits. -noesc ldx #6 ; ** PARAMETER 8..0 +noesc: ldx #6 ; ** PARAMETER 8..0 jsr getchkf jsr putch ; output the escaped/normal byte ; Fall through and check the escape bits again -main ldy #0 ; Reset to a defined state +main: ldy #0 ; Reset to a defined state tya ; A = 0 -escB1 ldx #2 ; ** PARAMETER 0..8 +escB1: ldx #2 ; ** PARAMETER 0..8 jsr getchkf ; X = 0 -esc cmp #0 +esc: cmp #0 bne noesc ; Fall through to packed code @@ -139,20 +134,20 @@ esc cmp #0 ;***FALL THRU*** ; e..e011 -srle iny ; Y is 1 bigger than MSB loops +srle: iny ; Y is 1 bigger than MSB loops jsr getval ; Y is 1, get len, X = 0 sta LZPOS ; xstore - Save length LSB -mg1 cmp #64 ; ** PARAMETER 63-64 -> C clear, 64-64 -> C set.. +mg1: cmp #64 ; ** PARAMETER 63-64 -> C clear, 64-64 -> C set.. bcc chrcode ; short RLE, get bytecode -longrle ldx #2 ; ** PARAMETER 111111xxxxxx +longrle:ldx #2 ; ** PARAMETER 111111xxxxxx jsr getbits ; get 3/2/1 more bits to get a full byte, X = 0 sta LZPOS ; xstore - Save length LSB jsr getval ; length MSB, X = 0 tay ; Y is 1 bigger than MSB loops -chrcode jsr getval ; Byte Code, X = 0 +chrcode:jsr getval ; Byte Code, X = 0 tax ; this is executed most of the time anyway lda table-1,x ; Saves one jump if done here (loses one txa) @@ -166,36 +161,38 @@ chrcode jsr getval ; Byte Code, X = 0 @l1: ldx LZPOS ; xstore - get length LSB inx ; adjust for cpx#$ff;bne -> bne -dorle jsr putch +dorle: jsr putch dex bne dorle ; xstore 0..255 -> 1..256 dey bne dorle ; Y was 1 bigger than wanted originally -mainbeq beq main ; reverse condition -> jump always +mainbeq:beq main ; reverse condition -> jump always -lz77 jsr getval ; X = 0 -mg21 cmp #127 ; ** PARAMETER Clears carry (is maximum value) +lz77: jsr getval ; X = 0 +mg21: cmp #127 ; ** PARAMETER Clears carry (is maximum value) bne noeof ; EOF -eof -.if SHORTY = 0 - ; EOF - clc ; removed 'eof' label, duplication! -eof2 lda #$37 - sta 1 - cli -.endif -hi ldx #0 -lo ldy #0 +eof: + clc +eof2: +;.if SHORTY = 0 +; ; EOF +; clc ; removed 'eof' label, duplication! +;eof2 lda #$37 +; sta 1 +; cli +;.endif +hi: ldx #0 +lo: ldy #0 rts -noeof sbc #0 ; C is clear -> subtract 1 (1..126 -> 0..125) -elzpb ldx #0 ; ** PARAMETER (more bits to get) +noeof: sbc #0 ; C is clear -> subtract 1 (1..126 -> 0..125) +elzpb: ldx #0 ; ** PARAMETER (more bits to get) jsr getchkf ; clears Carry, X = 0 -lz77_2 sta LZPOS+1 ; offset MSB +lz77_2: sta LZPOS+1 ; offset MSB jsr getbyte ; clears Carry, X = 0 ; Note: Already eor:ed in the compressor.. ;eor #255 ; offset LSB 2's complement -1 (i.e. -X = ~X+1) @@ -209,7 +206,7 @@ lz77_2 sta LZPOS+1 ; offset MSB ;ldy #0 ; Y was 0 originally, we don't change it inx ; adjust for cpx#$ff;bne -> bne -lzloop lda (LZPOS),y ; using abs,y is 3 bytes longer, only 1 cycle/byte faster +lzloop: lda (LZPOS),y ; using abs,y is 3 bytes longer, only 1 cycle/byte faster jsr putch ; Note: must be copied forwards! iny ; Y does not wrap because X=0..255 and Y initially 0 dex @@ -217,7 +214,7 @@ lzloop lda (LZPOS),y ; using abs,y is 3 bytes longer, only 1 cycle/byte faster beq mainbeq ; jump through another beq (-1 byte, +3 cycles) -getnew pha ; 1 Byte/3 cycles +getnew: pha ; 1 Byte/3 cycles INPOS = *+1 lda $aaaa ; ** PARAMETER @@ -234,14 +231,14 @@ INPOS = *+1 ; getval : Gets a 'static huffman coded' value ; ** Scratches X, returns the value in A ** -getval inx ; X <- 1 +getval: inx ; X <- 1 txa ; set the top bit (value is 1..255) -gv0 asl bitstr +gv0: asl bitstr bne @l1 jsr getnew @l1: bcc getchk ; got 0-bit inx -mg cpx #7 ; ** PARAMETER unary code maximum length + 1 +mg: cpx #7 ; ** PARAMETER unary code maximum length + 1 bne gv0 beq getchk ; inverse condition -> jump always ; getval: 18 bytes @@ -249,20 +246,20 @@ mg cpx #7 ; ** PARAMETER unary code maximum length + 1 ; getbits: Gets X bits from the stream ; ** Scratches X, returns the value in A ** -getbyte ldx #7 -get1bit inx ;2 -getbits asl bitstr +getbyte:ldx #7 +get1bit:inx ;2 +getbits:asl bitstr bne @l1 jsr getnew @l1: rol ;2 -getchk dex ;2 more bits to get ? -getchkf bne getbits ;2/3 +getchk: dex ;2 more bits to get ? +getchkf:bne getbits ;2/3 clc ;2 return carry cleared rts ;6+6 OUTPOS = *+1 ; ZP -putch sta $aaaa ; ** parameter +putch: sta $aaaa ; ** parameter inc OUTPOS ; ZP bne @l0 inc OUTPOS+1 ; ZP @@ -270,7 +267,7 @@ putch sta $aaaa ; ** parameter -table .BYTE 0,0,0,0,0,0,0 +table: .BYTE 0,0,0,0,0,0,0 .BYTE 0,0,0,0,0,0,0,0 ;dc.b 0,0,0,0,0,0,0,0 ;dc.b 0,0,0,0,0,0,0,0 From 67d00c2c28da8fc0be65076d3ec0733e98010c67 Mon Sep 17 00:00:00 2001 From: LGB Date: Wed, 24 Aug 2016 01:38:25 +0200 Subject: [PATCH 05/12] Cleanup. --- Makefile | 2 +- README.md | 0 config.inc | 0 inc/const.inc | 0 inc/diskdrv.inc | 0 inc/geosmac.inc | 0 inc/geossym.inc | 0 inc/inputdrv.inc | 0 inc/kernal.inc | 0 inc/printdrv.inc | 0 loader/boot.s | 54 ++++++++++++++++------------------------------- loader/c65.cfg | 1 - loader/uglyboot.s | 15 +++++++------ 13 files changed, 28 insertions(+), 44 deletions(-) mode change 100755 => 100644 Makefile mode change 100755 => 100644 README.md mode change 100755 => 100644 config.inc mode change 100755 => 100644 inc/const.inc mode change 100755 => 100644 inc/diskdrv.inc mode change 100755 => 100644 inc/geosmac.inc mode change 100755 => 100644 inc/geossym.inc mode change 100755 => 100644 inc/inputdrv.inc mode change 100755 => 100644 inc/kernal.inc mode change 100755 => 100644 inc/printdrv.inc diff --git a/Makefile b/Makefile old mode 100755 new mode 100644 index c153caa3..a97d7aa3 --- a/Makefile +++ b/Makefile @@ -67,7 +67,7 @@ ALL_BINS= \ all: geos.d64 geos.d81 clean: - rm -f $(KERNAL_OBJECTS) drv/*.o input/*.o $(ALL_BINS) combined.prg compressed.prg geos.d64 geos.d81 compressed_c65.prg compressed.bin loader/*.o compressed_c65m.prg + rm -f $(KERNAL_OBJECTS) drv/*.o input/*.o $(ALL_BINS) combined.prg compressed.prg geos.d64 geos.d81 compressed_c65.prg compressed.bin loader/*.o compressed_c65m.prg kernal.map geos.d64: compressed.prg if [ -e GEOS64.D64 ]; then \ diff --git a/README.md b/README.md old mode 100755 new mode 100644 diff --git a/config.inc b/config.inc old mode 100755 new mode 100644 diff --git a/inc/const.inc b/inc/const.inc old mode 100755 new mode 100644 diff --git a/inc/diskdrv.inc b/inc/diskdrv.inc old mode 100755 new mode 100644 diff --git a/inc/geosmac.inc b/inc/geosmac.inc old mode 100755 new mode 100644 diff --git a/inc/geossym.inc b/inc/geossym.inc old mode 100755 new mode 100644 diff --git a/inc/inputdrv.inc b/inc/inputdrv.inc old mode 100755 new mode 100644 diff --git a/inc/kernal.inc b/inc/kernal.inc old mode 100755 new mode 100644 diff --git a/inc/printdrv.inc b/inc/printdrv.inc old mode 100755 new mode 100644 diff --git a/loader/boot.s b/loader/boot.s index fe94feb4..b369516a 100644 --- a/loader/boot.s +++ b/loader/boot.s @@ -40,7 +40,6 @@ next: .WORD 0 .CODE -.IMPORT uncruncher @@ -48,29 +47,30 @@ next: .WORD 0 LDA #0 TAX TAY - .BYTE $4B ; TAZ - .BYTE $5C ; MAP (it also inhibits interrupts till the next NOP ... errrr ... EOM), totally unmapped status - .BYTE $5B ; TAB, zero page is _zero_ page :) + TAZ + MAP + TAB INY - .BYTE $2B ; TYS, standard stack location - .BYTE $03 ; SEE, 8 bit stack + TYS + SEE + SEI + EOM ; Just to be sure, enable newVic mode LDA #$A5 STA $D02F LDA #$96 STA $D02F - ; CPU port stuff, C64-alike config - LDA #$FF + ; CPU port stuff + LDA #$2F STA 0 LDA #$37 - STA 1 ; the "CPU port" + STA 1 ; Various VIC register stuffs LDA #64 STA $D031 ; turn maybe used enhanched VIC3 capabilities OFF (other than FAST mode!) - LDA #0 - STA $D030 ; turn ROM mappings / etc OFF - STA $D019 ; disable VIC interrupts - STA $D01A + STZ $D030 ; turn ROM mappings / etc OFF + STZ $D019 ; disable VIC interrupts + STZ $D01A LDA #$15 STA $D018 ; *** Uncrunch @@ -80,29 +80,14 @@ next: .WORD 0 .IMPORT __GEOS_LOAD__ LDX #.HIBYTE(__GEOS_LOAD__) LDY #.LOBYTE(__GEOS_LOAD__) + LDA #$30 + STA 1 + .IMPORT uncruncher JSR uncruncher + LDA #$37 + STA 1 BCS @unpack_error JMP $5000 - ; Copy disk driver in place - ; Note: I want to crunch the driver itself too, - ; maybe include *more* disk drivers, and this way - ; hot-patch GEOS at $9000 [???] with the desired - ; disk driver based on detection ie Mega65/plain C65 - .IMPORT __DISKDRIVER_LOAD__ - .IMPORT __DISKDRIVER_SIZE__ - LDX #0 - LDY #.HIBYTE(__DISKDRIVER_SIZE__) + 1 -@cp: - LDA __DISKDRIVER_LOAD__,X - STA $9000,X - INX - BNE @cp - INC @cp + 2 - INC @cp + 5 - DEY - BNE @cp - NOP - JMP $5000 @unpack_error: INA STA 53281 @@ -110,8 +95,5 @@ next: .WORD 0 .ENDPROC -.SEGMENT "DISKDRIVER" -.INCBIN "drvf011.bin" - .SEGMENT "GEOS" .INCBIN "compressed.bin" diff --git a/loader/c65.cfg b/loader/c65.cfg index 737eba85..c5d8252e 100644 --- a/loader/c65.cfg +++ b/loader/c65.cfg @@ -9,6 +9,5 @@ SEGMENTS { LOADADDR: load = LOADADDR; STUB: load = STUFF, define = yes; CODE: load = STUFF; - DISKDRIVER: load = STUFF, define = yes; GEOS: load = STUFF, define = yes; } diff --git a/loader/uglyboot.s b/loader/uglyboot.s index 1160cbf4..de512ba9 100644 --- a/loader/uglyboot.s +++ b/loader/uglyboot.s @@ -11,6 +11,9 @@ ; Also, a more proper solution would be use a custom un-puprunch code in the loader without the ugly ; copy hack ... + +.INCLUDE "c65.inc" + .ORG $1FFF ; C65 basic loader start stuff .WORD basic @@ -60,19 +63,19 @@ main: LDA #0 TAX TAY - .BYTE $4B ; TAZ - .BYTE $5C ; MAP (it also inhibits interrupts till the next NOP ... errrr ... EOM), totally unmapped status - .BYTE $5B ; TAB, zero page is _zero_ page :) + TAZ + MAP ; (it also inhibits interrupts till the next NOP ... errrr ... EOM), totally unmapped status + TAB ; zero page is _zero_ page :) INY - .BYTE $2B ; TYS, standard stack location - .BYTE $03 ; SEE, 8 bit stack + TYS ; standard stack location + SEE ; 8 bit stack ; Just to be sure, enable newVic mode LDA #$A5 STA $D02F LDA #$96 STA $D02F ; CPU port stuff, C64-alike config - LDA #$FF + LDA #$2F STA 0 LDA #$37 STA 1 ; the "CPU port" From 71a4c7104e94fec2d97222734da52683921c9677 Mon Sep 17 00:00:00 2001 From: LGB Date: Thu, 25 Aug 2016 12:50:17 +0200 Subject: [PATCH 06/12] New loader, fixes, etc --- .gitattributes | 6 + .gitignore | 3 +- Makefile | 46 ++--- c65/README.md | 40 ++++ {loader => c65}/c65.inc | 0 {drv => c65}/drvf011.cfg | 0 {drv => c65}/drvf011.s | 0 loader/c65.cfg => c65/loader.cfg | 0 loader/boot.s => c65/loader.s | 50 ++--- c65/start.s | 75 +++++++ c65/uncrunch.s | 341 +++++++++++++++++++++++++++++++ config.inc | 3 +- drv/drv1581.s | 2 +- inc/const.inc | 3 + kernal/kernal.cfg | 1 + kernal/start.s | 10 +- loader/uglyboot.s | 108 ---------- loader/uncrunch.s | 275 ------------------------- 18 files changed, 521 insertions(+), 442 deletions(-) create mode 100644 c65/README.md rename {loader => c65}/c65.inc (100%) rename {drv => c65}/drvf011.cfg (100%) rename {drv => c65}/drvf011.s (100%) rename loader/c65.cfg => c65/loader.cfg (100%) rename loader/boot.s => c65/loader.s (72%) create mode 100644 c65/start.s create mode 100644 c65/uncrunch.s delete mode 100644 loader/uglyboot.s delete mode 100644 loader/uncrunch.s diff --git a/.gitattributes b/.gitattributes index 8b06d4c8..c59931ab 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,11 @@ *.inc linguist-language=Assembly *.s linguist-language=Assembly +*.asm linguist-language=Assembly Makefile.* linguist-language=Makefile Makefile linguist-language=Makefile *.bin linguist-language=Binary +*.prg linguist-language=Binary +*.d64 linguist-language=Binary +*.D64 linguist-language=Binary +*.d81 linguist-language=Binary +*.D81 linguist-language=Binary diff --git a/.gitignore b/.gitignore index cd194e4a..8fe23496 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ +.*.swp *.o -*.bin +/*.bin *.prg *.d64 *.d81 diff --git a/Makefile b/Makefile index a97d7aa3..81d106c6 100644 --- a/Makefile +++ b/Makefile @@ -34,9 +34,11 @@ KERNAL_SOURCES= \ kernal/start.s \ kernal/time.s \ kernal/tobasic.s \ - kernal/vars.s + kernal/vars.s \ + c65/start.s DEPS= \ + Makefile \ inc/c64.inc \ inc/const.inc \ inc/diskdrv.inc \ @@ -67,7 +69,7 @@ ALL_BINS= \ all: geos.d64 geos.d81 clean: - rm -f $(KERNAL_OBJECTS) drv/*.o input/*.o $(ALL_BINS) combined.prg compressed.prg geos.d64 geos.d81 compressed_c65.prg compressed.bin loader/*.o compressed_c65m.prg kernal.map + rm -f $(KERNAL_OBJECTS) drv/*.o input/*.o $(ALL_BINS) combined.bin combined.prg compressed.prg geos.d64 geos.d81 compressed_c65.prg compressed.bin c65/*.o kernal.map geos.d64: compressed.prg if [ -e GEOS64.D64 ]; then \ @@ -82,44 +84,42 @@ geos.d64: compressed.prg echo \*\*\* Created fresh geos.d64.; \ fi; -geos.d81: compressed.prg compressed_c65.prg compressed_c65m.prg +geos.d81: compressed.prg compressed_c65.prg if [ -e GEOS64.D81 ]; then \ cp GEOS64.D81 geos.d81; \ echo 'delete geos geoboot configure "geos kernal"' | c1541 geos.d81 >/dev/null; \ echo write compressed.prg geos | c1541 geos.d81 >/dev/null; \ echo write compressed_c65.prg geos65 | c1541 geos.d81 >/dev/null; \ - echo write compressed_c65m.prg geos65m | c1541 geos.d81 >/dev/null; \ echo \*\*\* Created geos.d81 based on GEOS64.D81.; \ else \ echo format geos,00 d81 geos.d81 | c1541 >/dev/null; \ echo write compressed.prg geos | c1541 geos.d81 >/dev/null; \ echo write compressed_c65.prg geos65 | c1541 geos.d81 >/dev/null; \ - echo write compressed_c65m.prg geos65m | c1541 geos.d81 >/dev/null; \ if [ -e desktop.cvt ]; then echo geoswrite desktop.cvt | c1541 geos.d81; fi >/dev/null; \ echo \*\*\* Created fresh geos.d81.; \ fi; -compressed_c65.prg: compressed.prg loader/uglyboot.o - $(LD) -t none loader/uglyboot.o -o $@ - -compressed_c65m.prg: compressed.bin loader/uncrunch.o loader/boot.o - $(LD) -C loader/c65.cfg loader/boot.o loader/uncrunch.o -o $@ +compressed_c65.prg: compressed.bin c65/uncrunch.o c65/loader.o + $(LD) -C c65/loader.cfg c65/loader.o c65/uncrunch.o -o $@ compressed.prg: combined.prg pucrunch +f -c64 -x0x5000 $< $@ -compressed.bin: combined.prg - pucrunch -c0 -x0x5000 $< $@ +compressed.bin: combined.bin + exomizer mem $<,0x5002 -o $@ + +combined.bin: $(ALL_BINS) + rm -f $@ + cat start.bin /dev/zero | dd bs=1 count=16384 >> $@ 2> /dev/null + #cat drv1541.bin /dev/zero | dd bs=1 count=3456 >> $@ 2> /dev/null + cat drvf011.bin /dev/zero | dd bs=1 count=3456 >> $@ 2> /dev/null + cat lokernal.bin /dev/zero | dd bs=1 count=8640 >> $@ 2> /dev/null + cat kernal.bin /dev/zero | dd bs=1 count=16192 >> $@ 2> /dev/null + cat joydrv.bin >> $@ 2> /dev/null -combined.prg: $(ALL_BINS) - printf "\x00\x50" > tmp.bin - cat start.bin /dev/zero | dd bs=1 count=16384 >> tmp.bin 2> /dev/null - #cat drv1541.bin /dev/zero | dd bs=1 count=3456 >> tmp.bin 2> /dev/null - cat drvf011.bin /dev/zero | dd bs=1 count=3456 >> tmp.bin 2> /dev/null - cat lokernal.bin /dev/zero | dd bs=1 count=8640 >> tmp.bin 2> /dev/null - cat kernal.bin /dev/zero | dd bs=1 count=16192 >> tmp.bin 2> /dev/null - cat joydrv.bin >> tmp.bin 2> /dev/null - mv tmp.bin combined.prg +combined.prg: combined.bin + printf "\x00\x50" > $@ + cat $< >> $@ kernal.bin: $(KERNAL_OBJECTS) kernal/kernal.cfg $(LD) -C kernal/kernal.cfg $(KERNAL_OBJECTS) -o $@ -m kernal.map @@ -137,8 +137,8 @@ drv1571.bin: drv/drv1571.o drv/drv1571.cfg $(DEPS) drv1581.bin: drv/drv1581.o drv/drv1581.cfg $(DEPS) $(LD) -C drv/drv1581.cfg drv/drv1581.o -o $@ -drvf011.bin: drv/drvf011.o drv/drvf011.cfg $(DEPS) - $(LD) -C drv/drvf011.cfg drv/drvf011.o -o $@ +drvf011.bin: c65/drvf011.o c65/drvf011.cfg $(DEPS) + $(LD) -C c65/drvf011.cfg c65/drvf011.o -o $@ amigamse.bin: input/amigamse.o input/amigamse.cfg $(DEPS) $(LD) -C input/amigamse.cfg input/amigamse.o -o $@ diff --git a/c65/README.md b/c65/README.md new file mode 100644 index 00000000..01b45a3c --- /dev/null +++ b/c65/README.md @@ -0,0 +1,40 @@ +# Commodore-65 / Mega65 + +`c65/c65.inc` sets 65C02 CPU type for CA65. Ideally, there should be 65CE02 (better +say, 4502/4510) CPU support in CA65, but till that, 65C02 is also nice, at least +we have `STZ` works this way :) Also, it defines macros for some simple opcodes, +like `MAP`, etc. + +## Loader + +`c65/loader.s` and `c65/loader.cfg` are the source and LD65 linker configuration +file for the C65 loader, which is a standard "BASIC stub" loader must be started +from C65 mode (**not from C64 mode **). It does: + +* standard BASIC "SYS stub" stuff, also used BANK 0 +* turn fancy C65 memory mappings (`MAP`, VIC-III port $30, std CPU port ...) off +* uses exomizer's decruncher routine to derunch compressed GEOS kernal image. + Exomizer is used, as - at least for me - pucrunch didn't worked because of the + overlap between the compressed kernal and the uncompressing target area (on + C65, the BASIC are starts at a higher address than on C64), I have no idea if + pucrunch supports backward uncrunching at all to avoid this problem. Also + exomizer seems to give a better result of compression, so the situation is + good enough for me. File `uncrunch.s` is simply the source of the Exomizer's + uncrunch routine, with the settings we need. + +## Kernal + +`c65/start.s` is an extension of the "purgeable init code" from address $5000. +Call to `InitC65` is done from `kernal/start.s`. Because I liked the idea to be +able to be complied with `trap=1` as well in `config.inc`, I used another memory +segment (modified `kernal/kernal.cfg`) and the C65 specific stuff purges itself +after its turn, giving control back to `_ResetHandle` which should found the +original state. + +Currently this code does almost nothing, later it can do more. + +## Disk driver code + +Well, that's simply borrowed from here: https://github.com/frehwagen/geos + +Source is `c65/drvf011.s`, LD65 linker configuration file is `c65/drvf011.s`. diff --git a/loader/c65.inc b/c65/c65.inc similarity index 100% rename from loader/c65.inc rename to c65/c65.inc diff --git a/drv/drvf011.cfg b/c65/drvf011.cfg similarity index 100% rename from drv/drvf011.cfg rename to c65/drvf011.cfg diff --git a/drv/drvf011.s b/c65/drvf011.s similarity index 100% rename from drv/drvf011.s rename to c65/drvf011.s diff --git a/loader/c65.cfg b/c65/loader.cfg similarity index 100% rename from loader/c65.cfg rename to c65/loader.cfg diff --git a/loader/boot.s b/c65/loader.s similarity index 72% rename from loader/boot.s rename to c65/loader.s index b369516a..7bebaa61 100644 --- a/loader/boot.s +++ b/c65/loader.s @@ -11,15 +11,16 @@ ; Also, a more proper solution would be use a custom un-puprunch code in the loader without the ugly ; copy hack ... - .INCLUDE "c65.inc" + .SEGMENT "LOADADDR" .IMPORT __STUB_LOAD__ .WORD __STUB_LOAD__ + .SEGMENT "STUB" .SCOPE .WORD next @@ -32,7 +33,7 @@ .BYTE <(main/100 .MOD 10+48) .BYTE <(main/10 .MOD 10+48) .BYTE <(main .MOD 10+48) - .BYTE " : GEOS FOR C65" + .BYTE " : GEOS LOADER AND KERNAL FOR C65 MODE ONLY" .BYTE 0 next: .WORD 0 .ENDSCOPE @@ -40,22 +41,22 @@ next: .WORD 0 .CODE - - - .PROC main + SEI + CLD LDA #0 TAX TAY - TAZ - MAP - TAB + TAZ ; we use Z register as zero, so STZ is about the same as on 65C02 + MAP ; no CPU mapping + TAB ; just to be sure: ZP at $0000 INY - TYS - SEE - SEI + TYS ; just to be sure: stack at $100 + SEE ; just to be sure: 8 bit stack EOM - ; Just to be sure, enable newVic mode + ; Just to be sure, enable newVic mode, to access eg VIC-3 register $30 + ; We don't need Mega65 fast mode here at any price, let's do that + ; later maybe, in c65/start.s LDA #$A5 STA $D02F LDA #$96 @@ -66,34 +67,19 @@ next: .WORD 0 LDA #$37 STA 1 ; Various VIC register stuffs - LDA #64 - STA $D031 ; turn maybe used enhanched VIC3 capabilities OFF (other than FAST mode!) STZ $D030 ; turn ROM mappings / etc OFF STZ $D019 ; disable VIC interrupts STZ $D01A - LDA #$15 - STA $D018 - ; *** Uncrunch - ; Call with X = HI of packed data, Y = LO of packed data - ; Returns exec address in X = HI and Y = LO - ; Carry will be set for error, cleared for OK - .IMPORT __GEOS_LOAD__ - LDX #.HIBYTE(__GEOS_LOAD__) - LDY #.LOBYTE(__GEOS_LOAD__) - LDA #$30 + LDA #$30 ; full RAM for uncrunching STA 1 .IMPORT uncruncher JSR uncruncher - LDA #$37 - STA 1 - BCS @unpack_error + STZ 53280 + STZ 53281 JMP $5000 -@unpack_error: - INA - STA 53281 - JMP @unpack_error .ENDPROC + .SEGMENT "GEOS" -.INCBIN "compressed.bin" +.INCBIN "compressed.bin",2 diff --git a/c65/start.s b/c65/start.s new file mode 100644 index 00000000..de2ceb24 --- /dev/null +++ b/c65/start.s @@ -0,0 +1,75 @@ +; C65 specific stuffs, already int he combined kernal image, not the loader! + +.include "config.inc" + +.if (c65) + +.segment "c65start" +.include "c65.inc" +; Note: we can't use const.inc here, as would conflict ie with MAP constant +; with the MAP opcode defined in c65.inc ... +.import _ResetHandle +.import __c65start_LOAD__ +.import __c65start_SIZE__ +.export InitC65 + +; Relocated to $100 (well, there is place in stack ...) and executed +; there. The reason for this is commented in InitC65 +.PROC relocated_segment_nullifier + sta __c65start_LOAD__,x + inx + bne relocated_segment_nullifier + inc relocated_segment_nullifier + 2 + dey + bne relocated_segment_nullifier + jmp _ResetHandle ; call the original stuff (at $5000) +.ENDPROC + + +.PROC InitC65 + sei + cld + ldx #$FF + txs + ; Patch out the call for this func. + ; It needs to be able to work with the trap=1 setting, it seems. + ; The same for "relocated_segment_nullifier" stuff at the end + lda #$78 ; sei + sta _ResetHandle + lda #$D8 ; cld + sta _ResetHandle+1 + lda #$A2 ; ldx immed. + sta _ResetHandle+2 + ; We need I/O + LDA #$35 + STA 1 + ; Various VIC register stuffs + LDA #$A5 + STA $D02F + LDA #$96 + STA $D02F + LDA #64 + STA $D031 ; turn maybe used enhanched VIC3 capabilities OFF (other than FAST mode!) + STZ $D030 ; turn ROM mappings / etc OFF + STZ $D019 ; disable VIC interrupts + STZ $D01A + LDA #$15 + STA $D018 + STA $D02F ; give up newVic mode. + ; Clear our "c65start" segment with the relocated code to $100 and then jump to + ; the original stuff there. +to_geos: + ldx #0 +@cp: + lda relocated_segment_nullifier,x + sta $100,x + inx + bpl @cp + ldx #0 + txa + ldy #.HIBYTE(__c65start_SIZE__) + 1 + EOM ; well just to be sure, a previous MAP does not cause problem with disabled interrupts ... + jmp $100 +.ENDPROC + +.endif diff --git a/c65/uncrunch.s b/c65/uncrunch.s new file mode 100644 index 00000000..4ad9af9d --- /dev/null +++ b/c65/uncrunch.s @@ -0,0 +1,341 @@ +; EXOMIZER is used now instead of pucrunch. We use "backward" crunching, as +; on C65 the start of BASIC area is at higher address, unpack address and +; packed stream is overlap! +; +; Copyright (c) 2002 - 2005 Magnus Lind. +; +; This software is provided 'as-is', without any express or implied warranty. +; In no event will the authors be held liable for any damages arising from +; the use of this software. +; +; Permission is granted to anyone to use this software for any purpose, +; including commercial applications, and to alter it and redistribute it +; freely, subject to the following restrictions: +; +; 1. The origin of this software must not be misrepresented; you must not +; claim that you wrote the original software. If you use this software in a +; product, an acknowledgment in the product documentation would be +; appreciated but is not required. +; +; 2. Altered source versions must be plainly marked as such, and must not +; be misrepresented as being the original software. +; +; 3. This notice may not be removed or altered from any distribution. +; +; 4. The names of this software and/or it's copyright holders may not be +; used to endorse or promote products derived from this software without +; specific prior written permission. +; +; ------------------------------------------------------------------- +; The decruncher jsr:s to the get_crunched_byte address when it wants to +; read a crunched byte. This subroutine has to preserve x and y register +; and must not modify the state of the carry flag. +; ------------------------------------------------------------------- +; ------------------------------------------------------------------- +; this function is the heart of the decruncher. +; It initializes the decruncher zeropage locations and precalculates the +; decrunch tables and decrunches the data +; This function will not change the interrupt status bit and it will not +; modify the memory configuration. +; ------------------------------------------------------------------- +; ------------------------------------------------------------------- +; if literal sequences is not used (the data was crunched with the -c +; flag) then the following line can be uncommented for shorter code. +;EXOD_LITERAL_SEQUENCES_NOT_USED = 1 + + +.CODE + +.EXPORT uncruncher +uncruncher = exod_decrunch + +exod_get_crunched_byte: + lda opbase + 1 + bne nowrap + dec opbase + 2 +nowrap: dec opbase + 1 + ; LGB: ie, backward decrunching. It's needed as on C65 the packed stream + ; would overlap with $5000, the target of the uncrunch process. +.IMPORT __GEOS_LOAD__ +.IMPORT __GEOS_SIZE__ +opbase: lda __GEOS_LOAD__ + __GEOS_SIZE__ + rts + +; ------------------------------------------------------------------- +; zero page addresses used +; ------------------------------------------------------------------- +exod_zp_len_lo = $a7 + +exod_zp_src_lo = $ae +exod_zp_src_hi = exod_zp_src_lo + 1 + +exod_zp_bits_hi = $fc + +exod_zp_bitbuf = $fd +exod_zp_dest_lo = exod_zp_bitbuf + 1 ; dest addr lo +exod_zp_dest_hi = exod_zp_bitbuf + 2 ; dest addr hi + +exod_tabl_bi = exod_decrunch_table +exod_tabl_lo = exod_decrunch_table + 52 +exod_tabl_hi = exod_decrunch_table + 104 + +; ------------------------------------------------------------------- +; no code below this comment has to be modified in order to generate +; a working decruncher of this source file. +; However, you may want to relocate the tables last in the file to a +; more suitable address. +; ------------------------------------------------------------------- + +; ------------------------------------------------------------------- +; jsr this label to decrunch, it will in turn init the tables and +; call the decruncher +; no constraints on register content, however the +; decimal flag has to be #0 (it almost always is, otherwise do a cld) +exod_decrunch: +; ------------------------------------------------------------------- +; init zeropage, x and y regs. (12 bytes) +; + ldy #0 + ldx #3 +exod_init_zp: + jsr exod_get_crunched_byte + sta exod_zp_bitbuf - 1,x + dex + bne exod_init_zp +; ------------------------------------------------------------------- +; calculate tables (50 bytes) +; x and y must be #0 when entering +; +exod_nextone: + inx + tya + and #$0f + beq exod_shortcut ; start new sequence + + txa ; this clears reg a + lsr ; and sets the carry flag + ldx exod_tabl_bi-1,y +exod_rolle: + rol + rol exod_zp_bits_hi + dex + bpl exod_rolle ; c = 0 after this (rol exod_zp_bits_hi) + + adc exod_tabl_lo-1,y + tax + + lda exod_zp_bits_hi + adc exod_tabl_hi-1,y +exod_shortcut: + sta exod_tabl_hi,y + txa + sta exod_tabl_lo,y + + ldx #4 + jsr exod_get_bits ; clears x-reg. + sta exod_tabl_bi,y + iny + cpy #52 + bne exod_nextone + ldy #0 + beq exod_begin +; ------------------------------------------------------------------- +; get bits (29 bytes) +; +; args: +; x = number of bits to get +; returns: +; a = #bits_lo +; x = #0 +; c = 0 +; z = 1 +; exod_zp_bits_hi = #bits_hi +; notes: +; y is untouched +; ------------------------------------------------------------------- +exod_get_bits: + lda #$00 + sta exod_zp_bits_hi + cpx #$01 + bcc exod_bits_done +exod_bits_next: + lsr exod_zp_bitbuf + bne exod_ok + pha +exod_literal_get_byte: + jsr exod_get_crunched_byte + bcc exod_literal_byte_gotten + ror + sta exod_zp_bitbuf + pla +exod_ok: + rol + rol exod_zp_bits_hi + dex + bne exod_bits_next +exod_bits_done: + rts +; ------------------------------------------------------------------- +; main copy loop (18(16) bytes) +; +exod_copy_next_hi: + dex + dec exod_zp_dest_hi + dec exod_zp_src_hi +exod_copy_next: + dey + .IFNDEF EXOD_LITERAL_SEQUENCES_NOT_USED + bcc exod_literal_get_byte + .ENDIF + lda (exod_zp_src_lo),y +exod_literal_byte_gotten: + sta (exod_zp_dest_lo),y +exod_copy_start: + tya + bne exod_copy_next +exod_begin: + txa + bne exod_copy_next_hi +; ------------------------------------------------------------------- +; decruncher entry point, needs calculated tables (21(13) bytes) +; x and y must be #0 when entering +; + .IFNDEF EXOD_LITERAL_SEQUENCES_NOT_USED + inx + jsr exod_get_bits + tay + bne exod_literal_start1 + .ELSE + dey + .ENDIF +exod_begin2: + inx + jsr exod_bits_next + lsr + iny + bcc exod_begin2 + .IFDEF EXOD_LITERAL_SEQUENCES_NOT_USED + beq exod_literal_start + .ENDIF + cpy #$11 + .IFNDEF EXOD_LITERAL_SEQUENCES_NOT_USED + bcc exod_sequence_start + beq exod_bits_done +; ------------------------------------------------------------------- +; literal sequence handling (13(2) bytes) +; + ldx #$10 + jsr exod_get_bits +exod_literal_start1: + sta > 8) + 1 diff --git a/loader/uncrunch.s b/loader/uncrunch.s deleted file mode 100644 index 0c035f93..00000000 --- a/loader/uncrunch.s +++ /dev/null @@ -1,275 +0,0 @@ -; Uncrunch code from pucrunch -; Somewhat reformatted to be able to be assembled with CA65 -; Also removed cli/sti/lda and sta 1 stuffs, etc - -; Pucrunch (C)1997-2008 by Pasi 'Albert' Ojala, a1bert@iki.fi -; Pucrunch is now under LGPL: see the doc for details. - -.CODE - -LZPOS = $9e ; 2 ZeroPage temporaries -bitstr = $fb ; 1 temporary (does not need to be ZP) - - ; Call with X = HI of packed data, Y = LO of packed data - ; Returns exec address in X = HI and Y = LO - ; Carry will be set for error, cleared for OK -.EXPORT uncruncher -.PROC uncruncher -SHORTY = 0 ;1 ; assume file is ok -;.if (SHORTY = 0) -; sei -; lda #$35 -; sta 1 -;.endif - ; Setup read pointer - sty INPOS - stx INPOS+1 - -.if SHORTY - ldx #5 -@l222: jsr getbyt ; skip 'p', 'u', endAddr HI&LO, leave starting escape in A - dex - bne @l222 -.else - jsr getbyt ; 'p' - cmp #112 - beq @l9 - sec ; error - jmp eof2 -@l9: jsr getbyt ; 'u' - cmp #117 - beq @l8 - sec ; error - jmp eof2 -@l8: jsr getbyt ; skip endAddr - jsr getbyt - jsr getbyt -.endif - sta esc+1 ; starting escape - - jsr getbyt ; read startAddr - sta OUTPOS - jsr getbyt - sta OUTPOS+1 - jsr getbyt ; read # of escape bits - sta escB0+1 - sta escB1+1 - lda #8 - sec - sbc escB1+1 - sta noesc+1 ; 8-escBits - - jsr getbyt - sta mg+1 ; maxGamma + 1 - lda #9 - sec - sbc mg+1 ; 8 - maxGamma == (8 + 1) - (maxGamma + 1) - sta longrle+1 - jsr getbyt - sta mg1+1 ; (1< LZ77 - ;tya ; A = 0 - jsr get1bit ; X = 0 - lsr ; bit -> C, A = 0 - bcc lz77_2 ; A=0 -> LZPOS+1 - ;***FALL THRU*** - - ; e..e01 - jsr get1bit ; X = 0 - lsr ; bit -> C, A = 0 - bcc newesc ; e..e010 - ;***FALL THRU*** - - ; e..e011 -srle: iny ; Y is 1 bigger than MSB loops - jsr getval ; Y is 1, get len, X = 0 - sta LZPOS ; xstore - Save length LSB -mg1: cmp #64 ; ** PARAMETER 63-64 -> C clear, 64-64 -> C set.. - bcc chrcode ; short RLE, get bytecode - -longrle:ldx #2 ; ** PARAMETER 111111xxxxxx - jsr getbits ; get 3/2/1 more bits to get a full byte, X = 0 - sta LZPOS ; xstore - Save length LSB - - jsr getval ; length MSB, X = 0 - tay ; Y is 1 bigger than MSB loops - -chrcode:jsr getval ; Byte Code, X = 0 - tax ; this is executed most of the time anyway - lda table-1,x ; Saves one jump if done here (loses one txa) - - cpx #16 ; 32 ; 31-32 -> C clear, 32-32 -> C set.. - bcc @l1 ; 1..31, we got the right byte from the table - - ; Ranks 32..64 (11111 xxxxx), get byte.. - txa ; get back the value (5 valid bits) - ldx #4 ;3 - jsr getbits ; get 3 more bits to get a full byte, X = 0 - -@l1: ldx LZPOS ; xstore - get length LSB - inx ; adjust for cpx#$ff;bne -> bne -dorle: jsr putch - dex - bne dorle ; xstore 0..255 -> 1..256 - dey - bne dorle ; Y was 1 bigger than wanted originally -mainbeq:beq main ; reverse condition -> jump always - - -lz77: jsr getval ; X = 0 -mg21: cmp #127 ; ** PARAMETER Clears carry (is maximum value) - bne noeof - ; EOF -eof: - clc -eof2: -;.if SHORTY = 0 -; ; EOF -; clc ; removed 'eof' label, duplication! -;eof2 lda #$37 -; sta 1 -; cli -;.endif -hi: ldx #0 -lo: ldy #0 - rts - - -noeof: sbc #0 ; C is clear -> subtract 1 (1..126 -> 0..125) -elzpb: ldx #0 ; ** PARAMETER (more bits to get) - jsr getchkf ; clears Carry, X = 0 - -lz77_2: sta LZPOS+1 ; offset MSB - jsr getbyte ; clears Carry, X = 0 - ; Note: Already eor:ed in the compressor.. - ;eor #255 ; offset LSB 2's complement -1 (i.e. -X = ~X+1) - adc OUTPOS ; -offset -1 + curpos (C is clear) - ldx LZPOS ; xstore = LZLEN (read before it's overwritten) - sta LZPOS - - lda OUTPOS+1 - sbc LZPOS+1 ; takes C into account - sta LZPOS+1 ; copy X+1 number of chars from LZPOS to OUTPOS - ;ldy #0 ; Y was 0 originally, we don't change it - - inx ; adjust for cpx#$ff;bne -> bne -lzloop: lda (LZPOS),y ; using abs,y is 3 bytes longer, only 1 cycle/byte faster - jsr putch ; Note: must be copied forwards! - iny ; Y does not wrap because X=0..255 and Y initially 0 - dex - bne lzloop ; X loops, (256,1..255) - beq mainbeq ; jump through another beq (-1 byte, +3 cycles) - - -getnew: pha ; 1 Byte/3 cycles - -INPOS = *+1 - lda $aaaa ; ** PARAMETER - inc INPOS - bne @l0 - inc INPOS+1 -@l0: sec - rol ; Shift out the next bit and - ; shift in C=1 (last bit marker) - sta bitstr ; bitstr initial value = $80 == empty - pla ; 1 Byte/4 cycles - rts - ; 25+12 = 37 - -; getval : Gets a 'static huffman coded' value -; ** Scratches X, returns the value in A ** -getval: inx ; X <- 1 - txa ; set the top bit (value is 1..255) -gv0: asl bitstr - bne @l1 - jsr getnew -@l1: bcc getchk ; got 0-bit - inx -mg: cpx #7 ; ** PARAMETER unary code maximum length + 1 - bne gv0 - beq getchk ; inverse condition -> jump always - ; getval: 18 bytes - ; 15 + 17*n + 6+15*n+12 + 36*n/8 = 33 + 32*n + 36*n/8 cycles - -; getbits: Gets X bits from the stream -; ** Scratches X, returns the value in A ** -getbyte:ldx #7 -get1bit:inx ;2 -getbits:asl bitstr - bne @l1 - jsr getnew -@l1: rol ;2 -getchk: dex ;2 more bits to get ? -getchkf:bne getbits ;2/3 - clc ;2 return carry cleared - rts ;6+6 - - -OUTPOS = *+1 ; ZP -putch: sta $aaaa ; ** parameter - inc OUTPOS ; ZP - bne @l0 - inc OUTPOS+1 ; ZP -@l0: rts - - - -table: .BYTE 0,0,0,0,0,0,0 - .BYTE 0,0,0,0,0,0,0,0 - ;dc.b 0,0,0,0,0,0,0,0 - ;dc.b 0,0,0,0,0,0,0,0 - -.ENDPROC From 68e735be90cb73030ef65e0a654b6057b50529dc Mon Sep 17 00:00:00 2001 From: LGB Date: Thu, 25 Aug 2016 14:57:30 +0200 Subject: [PATCH 07/12] Clean-up, Makefile reorg, bettot bin building % Some Makefile reorganization and clean-up % Minor beaty works on my sources % Build combined.bin with the help of the the assembler, not with 'dd' commands in Makefile, can be used to do conditional building of binaries as well (see the end of the config.inc) % Improving the fun section of the Makefile at the end :) --- Makefile | 88 ++++++++++++++++++++++++++++----------------------- c65/loader.s | 15 ++------- c65/start.s | 1 + config.inc | 10 ++++++ constructor.s | 26 +++++++++++++++ 5 files changed, 88 insertions(+), 52 deletions(-) create mode 100644 constructor.s diff --git a/Makefile b/Makefile index 81d106c6..a1b2f5b1 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,14 @@ -AS=ca65 -LD=ld65 - -ASFLAGS=-I inc -I . +AS = ca65 +LD = ld65 +CL = cl65 +C1541 = c1541 +EXOMIZER = exomizer +PUCRUNCH = pucrunch +D64_TEMPLATE = GEOS64.D64 +D64_RESULT = geos.d64 +D81_TEMPLATE = GEOS64.D81 +D81_RESULT = geos.d81 +ASFLAGS = -I inc -I . KERNAL_SOURCES= \ kernal/bitmask.s \ @@ -39,6 +46,7 @@ KERNAL_SOURCES= \ DEPS= \ Makefile \ + config.inc \ inc/c64.inc \ inc/const.inc \ inc/diskdrv.inc \ @@ -66,56 +74,53 @@ ALL_BINS= \ koalapad.bin \ pcanalog.bin -all: geos.d64 geos.d81 +all: $(D64_RESULT) $(D81_RESULT) clean: - rm -f $(KERNAL_OBJECTS) drv/*.o input/*.o $(ALL_BINS) combined.bin combined.prg compressed.prg geos.d64 geos.d81 compressed_c65.prg compressed.bin c65/*.o kernal.map - -geos.d64: compressed.prg - if [ -e GEOS64.D64 ]; then \ - cp GEOS64.D64 geos.d64; \ - echo 'delete geos geoboot configure "geos kernal"' | c1541 geos.d64 >/dev/null; \ - echo write compressed.prg geos | c1541 geos.d64 >/dev/null; \ - echo \*\*\* Created geos.d64 based on GEOS64.D64.; \ + rm -f $(KERNAL_OBJECTS) drv/*.o input/*.o $(ALL_BINS) combined.bin combined.prg compressed.prg $(D64_RESULT) $(D81_RESULT) compressed_c65.prg compressed.bin c65/*.o kernal.map constructor.o + +$(D64_RESULT): compressed.prg + if [ -s $(D64_TEMPLATE) ]; then \ + cp $(D64_TEMPLATE) $(D64_RESULT); \ + echo 'delete geos geoboot configure "geos kernal"' | $(C1541) $(D64_RESULT) >/dev/null; \ + echo write compressed.prg geos | $(C1541) $(D64_RESULT) >/dev/null; \ + echo \*\*\* Created $(D64_RESULT) based on $(D64_TEMPLATE).; \ else \ - echo format geos,00 d64 geos.d64 | c1541 >/dev/null; \ - echo write compressed.prg geos | c1541 geos.d64 >/dev/null; \ - if [ -e desktop.cvt ]; then echo geoswrite desktop.cvt | c1541 geos.d64; fi >/dev/null; \ - echo \*\*\* Created fresh geos.d64.; \ + rm -f $(D64_RESULT); \ + echo format geos,00 d64 $(D64_RESULT) | $(C1541) >/dev/null; \ + echo write compressed.prg geos | $(C1541) $(D64_RESULT) >/dev/null; \ + if [ -e desktop.cvt ]; then echo geoswrite desktop.cvt | $(C1541) $(D64_RESULT); fi >/dev/null; \ + echo \*\*\* Created fresh $(D64_RESULT).; \ fi; -geos.d81: compressed.prg compressed_c65.prg - if [ -e GEOS64.D81 ]; then \ - cp GEOS64.D81 geos.d81; \ - echo 'delete geos geoboot configure "geos kernal"' | c1541 geos.d81 >/dev/null; \ - echo write compressed.prg geos | c1541 geos.d81 >/dev/null; \ - echo write compressed_c65.prg geos65 | c1541 geos.d81 >/dev/null; \ - echo \*\*\* Created geos.d81 based on GEOS64.D81.; \ +$(D81_RESULT): compressed.prg compressed_c65.prg + if [ -s $(D81_TEMPLATE) ]; then \ + cp $(D81_TEMPLATE) $(D81_RESULT); \ + echo 'delete geos geoboot configure "geos kernal"' | $(C1541) $(D81_RESULT) >/dev/null; \ + echo write compressed.prg geos | $(C1541) $(D81_RESULT) >/dev/null; \ + echo write compressed_c65.prg geos65 | $(C1541) $(D81_RESULT) >/dev/null; \ + echo \*\*\* Created $(D81_RESULT) based on $(D81_TEMPLATE).; \ else \ - echo format geos,00 d81 geos.d81 | c1541 >/dev/null; \ - echo write compressed.prg geos | c1541 geos.d81 >/dev/null; \ - echo write compressed_c65.prg geos65 | c1541 geos.d81 >/dev/null; \ - if [ -e desktop.cvt ]; then echo geoswrite desktop.cvt | c1541 geos.d81; fi >/dev/null; \ - echo \*\*\* Created fresh geos.d81.; \ + rm -f $(D81_RESULT); \ + echo format geos,00 d81 $(D81_RESULT) | $(C1541) >/dev/null; \ + echo write compressed.prg geos | $(C1541) $(D81_RESULT) >/dev/null; \ + echo write compressed_c65.prg geos65 | $(C1541) $(D81_RESULT) >/dev/null; \ + if [ -e desktop.cvt ]; then echo geoswrite desktop.cvt | $(C1541) $(D81_RESULT); fi >/dev/null; \ + echo \*\*\* Created fresh $(D81_RESULT).; \ fi; compressed_c65.prg: compressed.bin c65/uncrunch.o c65/loader.o $(LD) -C c65/loader.cfg c65/loader.o c65/uncrunch.o -o $@ compressed.prg: combined.prg - pucrunch +f -c64 -x0x5000 $< $@ + $(PUCRUNCH) +f -c64 -x0x5000 $< $@ compressed.bin: combined.bin - exomizer mem $<,0x5002 -o $@ + $(EXOMIZER) mem $<,0x5002 -o $@ -combined.bin: $(ALL_BINS) - rm -f $@ - cat start.bin /dev/zero | dd bs=1 count=16384 >> $@ 2> /dev/null - #cat drv1541.bin /dev/zero | dd bs=1 count=3456 >> $@ 2> /dev/null - cat drvf011.bin /dev/zero | dd bs=1 count=3456 >> $@ 2> /dev/null - cat lokernal.bin /dev/zero | dd bs=1 count=8640 >> $@ 2> /dev/null - cat kernal.bin /dev/zero | dd bs=1 count=16192 >> $@ 2> /dev/null - cat joydrv.bin >> $@ 2> /dev/null +combined.bin: $(ALL_BINS) $(DEPS) constructor.s + $(CL) -t none -o $@ constructor.s + rm -f constructor.o combined.prg: combined.bin printf "\x00\x50" > $@ @@ -164,3 +169,8 @@ pcanalog.bin: input/pcanalog.o input/pcanalog.cfg $(DEPS) # a must! love: @echo "Not war, eh?" +the: + @echo "Just read the .PHONY line in Makefile ;-)" + +.PHONY: + clean all the love diff --git a/c65/loader.s b/c65/loader.s index 7bebaa61..a3bb3a2f 100644 --- a/c65/loader.s +++ b/c65/loader.s @@ -1,20 +1,9 @@ -; VERY ugly C65 GEOS "loader". +; Kind of C65 GEOS "loader" / basic stub / decruncher. ; -; (C)2016 LGB (Gabor Lenart) -; -; Basically it gets the pucrunch'ed (for C64) version of the GEOS build, with its BASIC stub, etc -; And copy to the address where it would be on C64, then execute it directly, bypassing the SYS stuff. -; Also it sets up an unmapped 4510 status, without VIC3 reg $30 ROM mapping and the desired CPU port value -; for some kind of faked "C64 compatibility", though, the CPU fast mode is kept turned on for some -; GEOS performance boost :) -; Note, that I was lazy to write proper linker cfg file and use segments, so it's an ugly .ORG stuff. -; Also, a more proper solution would be use a custom un-puprunch code in the loader without the ugly -; copy hack ... +; (C)2016 LGB Gábor Lénárt .INCLUDE "c65.inc" - - .SEGMENT "LOADADDR" .IMPORT __STUB_LOAD__ .WORD __STUB_LOAD__ diff --git a/c65/start.s b/c65/start.s index de2ceb24..bdcda1ab 100644 --- a/c65/start.s +++ b/c65/start.s @@ -1,4 +1,5 @@ ; C65 specific stuffs, already int he combined kernal image, not the loader! +; (C)2016 LGB Gábor Lénárt .include "config.inc" diff --git a/config.inc b/config.inc index 71658d0f..7d18ce4e 100644 --- a/config.inc +++ b/config.inc @@ -61,3 +61,13 @@ REUPresent = 0 .else REUPresent = 1 .endif + + +; ----- THIS PART CONTROLS THE CONTRUCTION OF THE FINAL BINARY IMAGE ----- +; You can even define these conditionally based on the settings above, etc! + +.DEFINE BUILDER_BIN_START_NAME "start.bin" +.DEFINE BUILDER_BIN_DSKDRV_NAME "drvf011.bin" +.DEFINE BUILDER_BIN_LOKERNAL_NAME "lokernal.bin" +.DEFINE BUILDER_BIN_KERNAL_NAME "kernal.bin" +.DEFINE BUILDER_BIN_INPDRV_NAME "joydrv.bin" diff --git a/constructor.s b/constructor.s new file mode 100644 index 00000000..b62b5dd7 --- /dev/null +++ b/constructor.s @@ -0,0 +1,26 @@ +; ---------------------------------------------------------------------------- +; WARNING! This is not a "real" assembly source too much, just a tricky use of +; an assembler to glue binaries together :) +; No native code, etc is allowed, of course! +; ---------------------------------------------------------------------------- +; Constructs the GEOS kernal from BIN files using CA65 +; I like this idea better than the 'dd' stuff in the old Makefile +; ---------------------------------------------------------------------------- +; Also, in this way, some kind of config file can be used to change the build, +; ie, what disk driver is included into the final build, etc! +; ---------------------------------------------------------------------------- +; (C)2016 LGB Gábor Lénárt + + +.INCLUDE "config.inc" + +.ORG $5000 +.INCBIN BUILDER_BIN_START_NAME +.RES $9000 - *, 0 +.INCBIN BUILDER_BIN_DSKDRV_NAME +.RES $9D80 - *, 0 +.INCBIN BUILDER_BIN_LOKERNAL_NAME +.RES $BF40 - *, 0 +.INCBIN BUILDER_BIN_KERNAL_NAME +.RES $FE80 - *, 0 +.INCBIN BUILDER_BIN_INPDRV_NAME From 4ec60d5f2af036c3a460589c7736337134b52b57 Mon Sep 17 00:00:00 2001 From: LGB Date: Fri, 2 Sep 2016 16:30:57 +0200 Subject: [PATCH 08/12] A quick update for now to clear things in doc :) --- c65/README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/c65/README.md b/c65/README.md index 01b45a3c..13a88546 100644 --- a/c65/README.md +++ b/c65/README.md @@ -31,7 +31,15 @@ segment (modified `kernal/kernal.cfg`) and the C65 specific stuff purges itself after its turn, giving control back to `_ResetHandle` which should found the original state. -Currently this code does almost nothing, later it can do more. +Currently this code does almost nothing, later it can do more (ie, M65 detection +and change disk driver to M65 specific one, so C65 is also supported this way +still). + +## Makefile and building + +Makefile was modified by me for *my* taste :-) Also the "glue" of binary fragments +done with the assembler itself, so the config.inc can be used to customize this +process, instead of hacking the Makefile ... ## Disk driver code From 65f122a1f2d3723988e0ddb58549bc52d73632de Mon Sep 17 00:00:00 2001 From: LGB Date: Thu, 8 Sep 2016 20:05:53 +0200 Subject: [PATCH 09/12] One bug fix + more comment + doc update --- c65/README.md | 6 +++++- c65/start.s | 13 +++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/c65/README.md b/c65/README.md index 13a88546..12eeba1d 100644 --- a/c65/README.md +++ b/c65/README.md @@ -5,6 +5,9 @@ say, 4502/4510) CPU support in CA65, but till that, 65C02 is also nice, at least we have `STZ` works this way :) Also, it defines macros for some simple opcodes, like `MAP`, etc. +**Breaking news**: You can mostly forget this, as it seems, new CA65 version +supports 4510 :-) + ## Loader `c65/loader.s` and `c65/loader.cfg` are the source and LD65 linker configuration @@ -39,7 +42,8 @@ still). Makefile was modified by me for *my* taste :-) Also the "glue" of binary fragments done with the assembler itself, so the config.inc can be used to customize this -process, instead of hacking the Makefile ... +process, instead of hacking the Makefile ... Modifications: `Makefile` and +new file `constructor.s` in the top directory. ## Disk driver code diff --git a/c65/start.s b/c65/start.s index bdcda1ab..82437645 100644 --- a/c65/start.s +++ b/c65/start.s @@ -20,7 +20,7 @@ sta __c65start_LOAD__,x inx bne relocated_segment_nullifier - inc relocated_segment_nullifier + 2 + inc $102 ; self-mod of the first STA arg dey bne relocated_segment_nullifier jmp _ResetHandle ; call the original stuff (at $5000) @@ -28,6 +28,7 @@ .PROC InitC65 + ; We don't do MAP, LDZ #0, stack/BP setup etc here, already done in the "BASIC stub" loader, in c65/loader.s sei cld ldx #$FF @@ -45,7 +46,7 @@ LDA #$35 STA 1 ; Various VIC register stuffs - LDA #$A5 + LDA #$A5 ; 2 values sequence for enabling "newVic" I/O mode (that is, C65 I/O, for M65, another seq is needed) STA $D02F LDA #$96 STA $D02F @@ -56,7 +57,11 @@ STZ $D01A LDA #$15 STA $D018 - STA $D02F ; give up newVic mode. + ; give up newVic mode + ; that is for GEOS may touch new I/O regs (expecting for VIC-2 "echoes" etc) and screws up ... + ; I'm not sure if this is needed, try to remove it. + ; if someone wants to use C65 feature, than it's another question + STA $D02F ; Clear our "c65start" segment with the relocated code to $100 and then jump to ; the original stuff there. to_geos: @@ -65,7 +70,7 @@ to_geos: lda relocated_segment_nullifier,x sta $100,x inx - bpl @cp + bpl @cp ; 128 bytes should be enough for everyone. ldx #0 txa ldy #.HIBYTE(__c65start_SIZE__) + 1 From 5587b7c4933f05116ce9a307fcaab1dd0f02f954 Mon Sep 17 00:00:00 2001 From: LGB Date: Wed, 14 Sep 2016 08:20:22 +0200 Subject: [PATCH 10/12] CA65 supports 4510, I use that now --- c65/README.md | 11 ++++------- c65/c65.inc | 25 ------------------------- c65/loader.s | 5 +++-- c65/start.s | 2 +- 4 files changed, 8 insertions(+), 35 deletions(-) delete mode 100644 c65/c65.inc diff --git a/c65/README.md b/c65/README.md index 12eeba1d..b2a82579 100644 --- a/c65/README.md +++ b/c65/README.md @@ -1,12 +1,9 @@ # Commodore-65 / Mega65 -`c65/c65.inc` sets 65C02 CPU type for CA65. Ideally, there should be 65CE02 (better -say, 4502/4510) CPU support in CA65, but till that, 65C02 is also nice, at least -we have `STZ` works this way :) Also, it defines macros for some simple opcodes, -like `MAP`, etc. - -**Breaking news**: You can mostly forget this, as it seems, new CA65 version -supports 4510 :-) +Now, for C65 build, you need CA65 (from the CC65 package) which knowns about +65CE02/4510 opcodes, maybe the GIT version from github.org. Thus file +`c65/c65.inc` is gone which had some intent to provide several 65CE02 opcodes +for the old CA65 versions. ## Loader diff --git a/c65/c65.inc b/c65/c65.inc deleted file mode 100644 index 115a6e19..00000000 --- a/c65/c65.inc +++ /dev/null @@ -1,25 +0,0 @@ -; A 65CE02/4502 capable version of CA65 would be great - -; Set 65C02, it's quite "similar" to 65C02, not including though -; the (ZP),Z addressing mode instead of (ZP), missing Z register -; and some new opcodes. Here, we only define some simple macros -; to be used by my source, that's all. -.SETCPU "65C02" -.MACRO TAZ - .BYTE $4B -.ENDMAC -.MACRO MAP - .BYTE $5C -.ENDMAC -.MACRO TAB - .BYTE $5B -.ENDMAC -.MACRO TYS - .BYTE $2B -.ENDMAC -.MACRO SEE - .BYTE $03 -.ENDMAC -.MACRO EOM - NOP -.ENDMAC diff --git a/c65/loader.s b/c65/loader.s index a3bb3a2f..7f7b535a 100644 --- a/c65/loader.s +++ b/c65/loader.s @@ -2,14 +2,15 @@ ; ; (C)2016 LGB Gábor Lénárt -.INCLUDE "c65.inc" +;.INCLUDE "c65.inc" + +.SETCPU "4510" .SEGMENT "LOADADDR" .IMPORT __STUB_LOAD__ .WORD __STUB_LOAD__ - .SEGMENT "STUB" .SCOPE .WORD next diff --git a/c65/start.s b/c65/start.s index 82437645..c625be4a 100644 --- a/c65/start.s +++ b/c65/start.s @@ -6,7 +6,7 @@ .if (c65) .segment "c65start" -.include "c65.inc" +.setcpu "4510" ; Note: we can't use const.inc here, as would conflict ie with MAP constant ; with the MAP opcode defined in c65.inc ... .import _ResetHandle From 1ec8c898eb3c3034ffecf7c4a6974a482749f8c9 Mon Sep 17 00:00:00 2001 From: frehwagen Date: Sat, 5 Nov 2016 18:46:28 +0100 Subject: [PATCH 11/12] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 2b98ca6f..d118364e 100755 --- a/README.md +++ b/README.md @@ -2,6 +2,10 @@ by Berkeley Softworks, reverse engineered by *Maciej Witkowiak*, *Michael Steil*. +## Branch + +This branch of the code forms my playground for testing different MEGA64 integration strategies. + ## Description [GEOS](https://en.wikipedia.org/wiki/GEOS_(8-bit_operating_system)) is a **graphical user interface for 6502-based computers**. In the 1980s, it was commercially available for the **Commodore 64**, 128 and Plus/4 as well as the Apple II. From 14a74317e8f40302d083b6b99ef22037a11f472e Mon Sep 17 00:00:00 2001 From: frehwagen Date: Sat, 5 Nov 2016 18:46:46 +0100 Subject: [PATCH 12/12] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d118364e..6719c269 100755 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ by Berkeley Softworks, reverse engineered by *Maciej Witkowiak*, *Michael Steil* ## Branch -This branch of the code forms my playground for testing different MEGA64 integration strategies. +This branch of the code forms my playground for testing different MEGA65 integration strategies. ## Description