diff --git a/Makefile b/Makefile index 9eb749d..4163a25 100644 --- a/Makefile +++ b/Makefile @@ -113,6 +113,9 @@ eightball_a2e.o: eightball.c eightballutils.h eightballvm.h $(CC65BINDIR)/cc65 -Or -t apple2enh -D A2E -o eightball_a2e.s eightball.c $(CC65BINDIR)/ca65 -t apple2enh eightball_a2e.s +eightballzp_a2e.o: eightballzp_a2e.S + $(CC65BINDIR)/ca65 -t apple2enh eightballzp_a2e.S + eightballvm_a2e.o: eightballvm.c eightballutils.h eightballvm.h $(CC65BINDIR)/cc65 -r -Oirs -t apple2enh -D A2E -o eightballvm_a2e.s eightballvm.c $(CC65BINDIR)/ca65 -t apple2enh eightballvm_a2e.s @@ -128,8 +131,8 @@ eightballutils_a2e.o: eightballutils.c eightballutils.h $(CC65BINDIR)/cc65 -Or -t apple2enh -D A2E -o eightballutils_a2e.s eightballutils.c $(CC65BINDIR)/ca65 -t apple2enh eightballutils_a2e.s -bin/eb: eightball_a2e.o eightballutils_a2e.o - $(CC65BINDIR)/ld65 -m 8balla2e.map -o bin/eb -C apple2enh.cfg -D __HIMEM__=0xbf00 eightball_a2e.o eightballutils_a2e.o $(CC65LIBDIR)/apple2enh.lib +bin/eb: eightball_a2e.o eightballutils_a2e.o eightballzp_a2e.o + $(CC65BINDIR)/ld65 -m 8balla2e.map -o bin/eb -C apple2enh.cfg -D __HIMEM__=0xbf00 eightball_a2e.o eightballutils_a2e.o eightballzp_a2e.o $(CC65LIBDIR)/apple2enh.lib bin/ebvm: eightballvm_a2e.o eightballutils_a2e.o eightballvmzp_a2e.o $(CC65BINDIR)/ld65 -m 8ballvma2e.map -o bin/ebvm -C apple2enh.cfg -D __HIMEM__=0xbf00 eightballvm_a2e.o eightballutils_a2e.o eightballvmzp_a2e.o $(CC65LIBDIR)/apple2enh.lib diff --git a/bin/8ball20.prg b/bin/8ball20.prg index e3d9aeb..86d100e 100644 Binary files a/bin/8ball20.prg and b/bin/8ball20.prg differ diff --git a/bin/8ball64.prg b/bin/8ball64.prg index 86c2a0e..c1ac05f 100644 Binary files a/bin/8ball64.prg and b/bin/8ball64.prg differ diff --git a/bin/8ballvm20.prg b/bin/8ballvm20.prg index 6a29e2b..c19f24f 100644 Binary files a/bin/8ballvm20.prg and b/bin/8ballvm20.prg differ diff --git a/bin/8ballvm64.prg b/bin/8ballvm64.prg index b3a46f2..68adca3 100644 Binary files a/bin/8ballvm64.prg and b/bin/8ballvm64.prg differ diff --git a/bin/disass b/bin/disass index f86b10d..348ce3e 100755 Binary files a/bin/disass and b/bin/disass differ diff --git a/bin/disass20.prg b/bin/disass20.prg index f995691..fc6f1e0 100644 Binary files a/bin/disass20.prg and b/bin/disass20.prg differ diff --git a/bin/disass64.prg b/bin/disass64.prg index fa776be..b6fef32 100644 Binary files a/bin/disass64.prg and b/bin/disass64.prg differ diff --git a/bin/eightball b/bin/eightball index ebdea84..2ecf6e1 100755 Binary files a/bin/eightball and b/bin/eightball differ diff --git a/bin/eightballvm b/bin/eightballvm index ea089da..c934183 100755 Binary files a/bin/eightballvm and b/bin/eightballvm differ diff --git a/disk-images/eightball.d64 b/disk-images/eightball.d64 index 2ca0f91..d2077dc 100644 Binary files a/disk-images/eightball.d64 and b/disk-images/eightball.d64 differ diff --git a/disk-images/eightball.dsk b/disk-images/eightball.dsk index d2e4a97..a316f53 100644 Binary files a/disk-images/eightball.dsk and b/disk-images/eightball.dsk differ diff --git a/eightball.c b/eightball.c index 7696664..05f2814 100644 --- a/eightball.c +++ b/eightball.c @@ -53,11 +53,10 @@ * Define EXTMEMCODE to enable extended memory support for object code. * Works for Apple //e only at present, but easy to extend. * EXTMEMCODE can only be enabled if EXTMEM is also enabled. - * At present EXTMEMCODE is **BROKEN** due to apparent bug in cc65 ext mem driver */ #ifdef A2E #define EXTMEM /* Enable/disable extended memory for source code */ -#undef EXTMEMCODE /* Enable/disable extended memory for object code */ +#define EXTMEMCODE /* Enable/disable extended memory for object code */ #endif /* Shortcut define CC65 makes code clearer */ @@ -1613,24 +1612,35 @@ struct em_copy emcopy; char embuf[255]; char embuf2[255]; -char buf[3]; +char b; +extern char *addrptr; +#pragma zpsym ("addrptr"); + +/* + * This inline assembler version avoids the memory corruption + * which results from using em_copyto() in this situation. + */ void copybytetoaux(char *auxptr, char byte) { - //char *p = em_map((unsigned int)auxptr >> 8); - //*(p + (unsigned char)auxptr) = byte; - //em_commit(); - - buf[0] = byte; - buf[1] = 0; - emcopy.buf = buf; + addrptr = auxptr; /* addrptr is in zero page */ + addrptr += 0x200; /* BASE address offset */ + b = byte; + __asm__("sta $c005"); /* Write to aux mem */ + __asm__("lda %v", b); + __asm__("sta (%v)", addrptr); /* 65C02 instruction */ + __asm__("sta $c004"); /* Back to normal */ +#if 0 + b = byte; + emcopy.buf = &b; emcopy.count = 1; emcopy.offs = (unsigned char)auxptr; emcopy.page = (unsigned int)auxptr >> 8; em_copyto(&emcopy); +#endif } void copybytefromaux(char *auxptr) { - emcopy.buf = buf; + emcopy.buf = embuf; emcopy.count = 1; emcopy.offs = (unsigned char)auxptr; emcopy.page = (unsigned int)auxptr >> 8; @@ -1741,6 +1751,7 @@ void emitprmsg(void) ++rtPC; } copybytetoaux(codeptr++, 0); + ++rtPC; #else emit(VM_PRMSG); ++rtPC; @@ -1749,6 +1760,7 @@ void emitprmsg(void) ++rtPC; } *codeptr++ = 0; + /* TODO: For some reason I don't need ++rtPC here */ #endif } #ifdef A2E @@ -1812,7 +1824,7 @@ void writebytecode() while (p < end) { #ifdef EXTMEMCODE copybytefromaux(p); - q = buf; + q = embuf; #else q = p; #endif @@ -2927,7 +2939,7 @@ unsigned char doelse() /* * Code to jump over ELSE block when IF condition is true */ - return_stack[returnSP + 1] = rtPC; + return_stack[returnSP + 1] = rtPC + 1; emit_imm(VM_JMPIMM, 0xffff); /* To be filled in later */ /* @@ -2978,7 +2990,7 @@ unsigned char doendif() * actually an ELSE.) */ if (return_stack[returnSP + 1]) { - emit_fixup(return_stack[returnSP + 1] + 1, rtPC); + emit_fixup(return_stack[returnSP + 1], rtPC); } } else { /* diff --git a/eightballutils.h b/eightballutils.h index 4f963ef..f2c6ec5 100644 --- a/eightballutils.h +++ b/eightballutils.h @@ -37,7 +37,7 @@ /* */ /**************************************************************************/ -#define VERSIONSTR "0.76" +#define VERSIONSTR "0.77" void print(char *str);