From 920a3eb794e807ac3821e0374cc0f181422e9f17 Mon Sep 17 00:00:00 2001
From: "ol.sc"
Date: Tue, 27 Dec 2011 23:36:05 +0000
Subject: [PATCH] First steps towards supporting Apple GEOS. - The generated
file is a "Apple GEOS Convert" format. - VLIR support is yet to come. - The
"Apple GEOS UnConvert" tool is yet to come.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5336 b7a2c559-68d2-44c3-8de9-860c34a00d81
---
src/grc65/grc65.c | 107 +++++++++++++++++++++++++-----------
src/ld65/cfg/apple-geos.cfg | 96 ++++++++++++++++++++++++++++++++
2 files changed, 171 insertions(+), 32 deletions(-)
create mode 100644 src/ld65/cfg/apple-geos.cfg
diff --git a/src/grc65/grc65.c b/src/grc65/grc65.c
index e685c59cf..85ae16ffd 100644
--- a/src/grc65/grc65.c
+++ b/src/grc65/grc65.c
@@ -369,15 +369,25 @@ void DoHeader(void) {
a = findToken(hdrFTypes, token);
- switch (a) {
- case 0:
- myHead.geostype = 6;
- break;
- case 1:
- myHead.geostype = 14;
- break;
- default:
- AbEnd("filetype '%s' is not supported yet\n", token);
+ if (apple == 1) {
+ switch (a) {
+ case 0:
+ myHead.geostype = 0x82;
+ break;
+ default:
+ AbEnd("filetype '%s' is not supported yet\n", token);
+ }
+ } else {
+ switch (a) {
+ case 0:
+ myHead.geostype = 6;
+ break;
+ case 1:
+ myHead.geostype = 14;
+ break;
+ default:
+ AbEnd("filetype '%s' is not supported yet\n", token);
+ }
}
myHead.dosname = nextPhrase();
@@ -389,7 +399,8 @@ void DoHeader(void) {
/* put default values into myHead here */
myHead.author = "cc65";
myHead.info = "Program compiled with cc65 and GEOSLib.";
- myHead.dostype = 128 + 3;
+ myHead.dostype = 128;
+ if (apple == 0) myHead.dostype += 3;
myHead.structure = 0;
myHead.mode = 0;
myHead.icon = NULL;
@@ -433,7 +444,7 @@ void DoHeader(void) {
AbEnd("unknown dostype in header '%s'\n", myHead.dosname);
break;
default:
- myHead.dostype = b / 2 + 128 + 1;
+ if (apple == 0) myHead.dostype = b / 2 + 128 + 1;
break;
}
break;
@@ -442,16 +453,16 @@ void DoHeader(void) {
case -1:
AbEnd("unknown mode in header '%s'\n", myHead.dosname);
case 0:
- myHead.mode = 0x40;
+ if (apple == 0) myHead.mode = 0x40;
break;
case 1:
- myHead.mode = 0x00;
+ if (apple == 0) myHead.mode = 0x00;
break;
case 2:
- myHead.mode = 0xc0;
+ if (apple == 0) myHead.mode = 0xc0;
break;
case 3:
- myHead.mode = 0x80;
+ if (apple == 0) myHead.mode = 0x80;
break;
}
break;
@@ -480,21 +491,51 @@ void DoHeader(void) {
fprintf(outputSFile,
"\n"
- "\t\t.segment \"DIRENTRY\"\n\n"
- "\t.byte %i\n"
- "\t.word 0\n", myHead.dostype);
+ "\t\t.segment \"DIRENTRY\"\n\n");
- fillOut(myHead.dosname, 16, "$a0");
+ if (apple == 1) {
- fprintf(outputSFile,
- "\t.word 0\n"
- "\t.byte %i\n"
- "\t.byte %i\n"
- "\t.byte %i, %i, %i, %i, %i\n\n"
- "\t.word 0\n"
- "\t.byte \"PRG formatted GEOS file V1.0\"\n\n",
- myHead.structure, myHead.geostype,
- myHead.year, myHead.month, myHead.day, myHead.hour, myHead.min);
+ fprintf(outputSFile,
+ "\t.byte %i << 4 | %i\n",
+ myHead.structure + 2, strlen(myHead.dosname));
+
+ fillOut(myHead.dosname, 15, "0");
+
+ fprintf(outputSFile,
+ "\t.byte $%02x\n"
+ "\t.word 0\n"
+ "\t.word 0\n"
+ "\t.byte 0, 0, 0\n"
+ "\t.word %i << 9 | %i << 5 | %i, %i << 8 | %i\n"
+ "\t.byte 0\n"
+ "\t.byte 0\n"
+ "\t.byte 0\n"
+ "\t.word 0\n"
+ "\t.word %i << 9 | %i << 5 | %i, %i << 8 | %i\n"
+ "\t.word 0\n",
+ myHead.geostype,
+ myHead.year % 100, myHead.month, myHead.day, myHead.hour, myHead.min,
+ myHead.year % 100, myHead.month, myHead.day, myHead.hour, myHead.min);
+
+ } else {
+
+ fprintf(outputSFile,
+ "\t.byte %i\n"
+ "\t.word 0\n",
+ myHead.dostype);
+
+ fillOut(myHead.dosname, 16, "$a0");
+
+ fprintf(outputSFile,
+ "\t.word 0\n"
+ "\t.byte %i\n"
+ "\t.byte %i\n"
+ "\t.byte %i, %i, %i, %i, %i\n\n"
+ "\t.word 0\n"
+ "\t.byte \"PRG formatted GEOS file V1.0\"\n\n",
+ myHead.structure, myHead.geostype,
+ myHead.year, myHead.month, myHead.day, myHead.hour, myHead.min);
+ }
fprintf(outputSFile,
"\n"
@@ -525,7 +566,8 @@ void DoHeader(void) {
fprintf(outputSFile,
"\t.byte 0, 0, 0\n"
- "\t.byte %i\n\n", myHead.mode);
+ "\t.byte %i\n\n",
+ myHead.mode);
setLen(myHead.author, 62);
fprintf(outputSFile,
@@ -537,7 +579,8 @@ void DoHeader(void) {
setLen(myHead.info, 95);
fprintf(outputSFile,
"\t.byte \"%s\"\n"
- "\t.byte 0\n\n", myHead.info);
+ "\t.byte 0\n\n",
+ myHead.info);
if (fclose (outputSFile) != 0)
AbEnd("error closing %s: %s\n", outputSName, strerror(errno));
@@ -745,10 +788,10 @@ int main(int argc, char *argv[]) {
break;
case 't':
switch (FindTarget(argv[++i])) {
- case TGT_GEOS: // todo: TGT_GEOS-CBM
+ case TGT_GEOS: /* todo: TGT_GEOS-CBM */
apple = 0;
break;
- case TGT_COUNT: //todo: TGT_GEOS-APPLE
+ case TGT_COUNT: /* todo: TGT_GEOS-APPLE */
apple = 1;
break;
default:
diff --git a/src/ld65/cfg/apple-geos.cfg b/src/ld65/cfg/apple-geos.cfg
new file mode 100644
index 000000000..abbfd22e5
--- /dev/null
+++ b/src/ld65/cfg/apple-geos.cfg
@@ -0,0 +1,96 @@
+SYMBOLS {
+ __STACKSIZE__: type = weak, value = $0400; # 1k stack
+ __OVERLAYADDR__: type = weak, value = $0C00;
+ __OVERLAYSIZE__: type = weak, value = $2000 - $0C00;
+}
+MEMORY {
+ CVT: file = %O, start = $0, size = $20000;
+ ZP: define = yes, start = $80, size = $1A + $06;
+ VLIR0: define = yes, start = $4000, size = $A000 - $4000 - __STACKSIZE__;
+ VLIR1: define = yes, start = __OVERLAYADDR__, size = __OVERLAYSIZE__;
+ VLIR2: define = yes, start = __OVERLAYADDR__, size = __OVERLAYSIZE__;
+ VLIR3: define = yes, start = __OVERLAYADDR__, size = __OVERLAYSIZE__;
+ VLIR4: define = yes, start = __OVERLAYADDR__, size = __OVERLAYSIZE__;
+ VLIR5: define = yes, start = __OVERLAYADDR__, size = __OVERLAYSIZE__;
+ VLIR6: define = yes, start = __OVERLAYADDR__, size = __OVERLAYSIZE__;
+ VLIR7: define = yes, start = __OVERLAYADDR__, size = __OVERLAYSIZE__;
+ VLIR8: define = yes, start = __OVERLAYADDR__, size = __OVERLAYSIZE__;
+ VLIR9: define = yes, start = __OVERLAYADDR__, size = __OVERLAYSIZE__;
+ VLIR10: define = yes, start = __OVERLAYADDR__, size = __OVERLAYSIZE__;
+ VLIR11: define = yes, start = __OVERLAYADDR__, size = __OVERLAYSIZE__;
+ VLIR12: define = yes, start = __OVERLAYADDR__, size = __OVERLAYSIZE__;
+ VLIR13: define = yes, start = __OVERLAYADDR__, size = __OVERLAYSIZE__;
+ VLIR14: define = yes, start = __OVERLAYADDR__, size = __OVERLAYSIZE__;
+ VLIR15: define = yes, start = __OVERLAYADDR__, size = __OVERLAYSIZE__;
+ VLIR16: define = yes, start = __OVERLAYADDR__, size = __OVERLAYSIZE__;
+ VLIR17: define = yes, start = __OVERLAYADDR__, size = __OVERLAYSIZE__;
+ VLIR18: define = yes, start = __OVERLAYADDR__, size = __OVERLAYSIZE__;
+ VLIR19: define = yes, start = __OVERLAYADDR__, size = __OVERLAYSIZE__;
+}
+SEGMENTS {
+ ZEROPAGE: type = zp, load = ZP;
+ EXTZP: type = zp, load = ZP;
+ FILEINFO: type = ro, load = CVT, offset = $002;
+ RECORDS: type = ro, load = CVT, offset = $100, optional = yes;
+ DIRENTRY: type = ro, load = CVT, offset = $180;
+ VLIRIDX0: type = ro, load = CVT, align = $200, optional = yes;
+ STARTUP: type = ro, run = VLIR0, load = CVT, align_load = $200, define = yes;
+ LOWCODE: type = ro, run = VLIR0, load = CVT, optional = yes;
+ INIT: type = ro, run = VLIR0, load = CVT, define = yes, optional = yes;
+ CODE: type = ro, run = VLIR0, load = CVT;
+ RODATA: type = ro, run = VLIR0, load = CVT;
+ DATA: type = rw, run = VLIR0, load = CVT;
+ BSS: type = bss, load = VLIR0, define = yes;
+ VLIRIDX1: type = ro, load = CVT, align = $200, optional = yes;
+ OVERLAY1: type = ro, run = VLIR1, load = CVT, align_load = $200, optional = yes;
+ VLIRIDX2: type = ro, load = CVT, align = $200, optional = yes;
+ OVERLAY2: type = ro, run = VLIR2, load = CVT, align_load = $200, optional = yes;
+ VLIRIDX3: type = ro, load = CVT, align = $200, optional = yes;
+ OVERLAY3: type = ro, run = VLIR3, load = CVT, align_load = $200, optional = yes;
+ VLIRIDX4: type = ro, load = CVT, align = $200, optional = yes;
+ OVERLAY4: type = ro, run = VLIR4, load = CVT, align_load = $200, optional = yes;
+ VLIRIDX5: type = ro, load = CVT, align = $200, optional = yes;
+ OVERLAY5: type = ro, run = VLIR5, load = CVT, align_load = $200, optional = yes;
+ VLIRIDX6: type = ro, load = CVT, align = $200, optional = yes;
+ OVERLAY6: type = ro, run = VLIR6, load = CVT, align_load = $200, optional = yes;
+ VLIRIDX7: type = ro, load = CVT, align = $200, optional = yes;
+ OVERLAY7: type = ro, run = VLIR7, load = CVT, align_load = $200, optional = yes;
+ VLIRIDX8: type = ro, load = CVT, align = $200, optional = yes;
+ OVERLAY8: type = ro, run = VLIR8, load = CVT, align_load = $200, optional = yes;
+ VLIRIDX9: type = ro, load = CVT, align = $200, optional = yes;
+ OVERLAY9: type = ro, run = VLIR9, load = CVT, align_load = $200, optional = yes;
+ VLIRIDX10: type = ro, load = CVT, align = $200, optional = yes;
+ OVERLAY10: type = ro, run = VLIR10, load = CVT, align_load = $200, optional = yes;
+ VLIRIDX11: type = ro, load = CVT, align = $200, optional = yes;
+ OVERLAY11: type = ro, run = VLIR11, load = CVT, align_load = $200, optional = yes;
+ VLIRIDX12: type = ro, load = CVT, align = $200, optional = yes;
+ OVERLAY12: type = ro, run = VLIR12, load = CVT, align_load = $200, optional = yes;
+ VLIRIDX13: type = ro, load = CVT, align = $200, optional = yes;
+ OVERLAY13: type = ro, run = VLIR13, load = CVT, align_load = $200, optional = yes;
+ VLIRIDX14: type = ro, load = CVT, align = $200, optional = yes;
+ OVERLAY14: type = ro, run = VLIR14, load = CVT, align_load = $200, optional = yes;
+ VLIRIDX15: type = ro, load = CVT, align = $200, optional = yes;
+ OVERLAY15: type = ro, run = VLIR15, load = CVT, align_load = $200, optional = yes;
+ VLIRIDX16: type = ro, load = CVT, align = $200, optional = yes;
+ OVERLAY16: type = ro, run = VLIR16, load = CVT, align_load = $200, optional = yes;
+ VLIRIDX17: type = ro, load = CVT, align = $200, optional = yes;
+ OVERLAY17: type = ro, run = VLIR17, load = CVT, align_load = $200, optional = yes;
+ VLIRIDX18: type = ro, load = CVT, align = $200, optional = yes;
+ OVERLAY18: type = ro, run = VLIR18, load = CVT, align_load = $200, optional = yes;
+ VLIRIDX19: type = ro, load = CVT, align = $200, optional = yes;
+ OVERLAY19: type = ro, run = VLIR19, load = CVT, align_load = $200, optional = yes;
+}
+FEATURES {
+ CONDES: segment = INIT,
+ type = constructor,
+ label = __CONSTRUCTOR_TABLE__,
+ count = __CONSTRUCTOR_COUNT__;
+ CONDES: segment = RODATA,
+ type = destructor,
+ label = __DESTRUCTOR_TABLE__,
+ count = __DESTRUCTOR_COUNT__;
+ CONDES: segment = RODATA,
+ type = interruptor,
+ label = __INTERRUPTOR_TABLE__,
+ count = __INTERRUPTOR_COUNT__;
+}
--
2.39.5