diff --git a/cfg/geos-cbm.cfg b/cfg/geos-cbm.cfg index 4bf33fdf5..945735683 100644 --- a/cfg/geos-cbm.cfg +++ b/cfg/geos-cbm.cfg @@ -2,12 +2,32 @@ FEATURES { STARTADDRESS: default = $0400; } SYMBOLS { - __BACKBUFSIZE__: type = weak, value = $2000; - __HIMEM__: type = weak, value = $8000 - __BACKBUFSIZE__; - __OVERLAYSIZE__: type = weak, value = $0000; - __OVERLAYADDR__: type = weak, value = __HIMEM__ - __OVERLAYSIZE__; - __STACKSIZE__: type = weak, value = $0400; # 1k stack - __STACKADDR__: type = weak, value = __OVERLAYADDR__ - __STACKSIZE__; + __BACKBUFSIZE__: type = weak, value = $2000; + __HIMEM__: type = weak, value = $8000 - __BACKBUFSIZE__; + __OVERLAYSIZE__: type = weak, value = $0000; + __OVERLAYADDR__: type = weak, value = __HIMEM__ - __OVERLAYSIZE__; + __STACKSIZE__: type = weak, value = $0400; # 1k stack + __STACKADDR__: type = weak, value = __OVERLAYADDR__ - __STACKSIZE__; + __VLIR0_BLOCKS__: type = export, value = ((__VLIR0_LAST__ - __VLIR0_START__ - __BSS_SIZE__) + 253) / 254; + __VLIR1_BLOCKS__: type = export, value = ((__VLIR1_LAST__ - __VLIR1_START__) + 253) / 254; + __VLIR2_BLOCKS__: type = export, value = ((__VLIR2_LAST__ - __VLIR2_START__) + 253) / 254; + __VLIR3_BLOCKS__: type = export, value = ((__VLIR3_LAST__ - __VLIR3_START__) + 253) / 254; + __VLIR4_BLOCKS__: type = export, value = ((__VLIR4_LAST__ - __VLIR4_START__) + 253) / 254; + __VLIR5_BLOCKS__: type = export, value = ((__VLIR5_LAST__ - __VLIR5_START__) + 253) / 254; + __VLIR6_BLOCKS__: type = export, value = ((__VLIR6_LAST__ - __VLIR6_START__) + 253) / 254; + __VLIR7_BLOCKS__: type = export, value = ((__VLIR7_LAST__ - __VLIR7_START__) + 253) / 254; + __VLIR8_BLOCKS__: type = export, value = ((__VLIR8_LAST__ - __VLIR8_START__) + 253) / 254; + __VLIR9_BLOCKS__: type = export, value = ((__VLIR9_LAST__ - __VLIR9_START__) + 253) / 254; + __VLIR10_BLOCKS__: type = export, value = ((__VLIR10_LAST__ - __VLIR10_START__) + 253) / 254; + __VLIR11_BLOCKS__: type = export, value = ((__VLIR11_LAST__ - __VLIR11_START__) + 253) / 254; + __VLIR12_BLOCKS__: type = export, value = ((__VLIR12_LAST__ - __VLIR12_START__) + 253) / 254; + __VLIR13_BLOCKS__: type = export, value = ((__VLIR13_LAST__ - __VLIR13_START__) + 253) / 254; + __VLIR14_BLOCKS__: type = export, value = ((__VLIR14_LAST__ - __VLIR14_START__) + 253) / 254; + __VLIR15_BLOCKS__: type = export, value = ((__VLIR15_LAST__ - __VLIR15_START__) + 253) / 254; + __VLIR16_BLOCKS__: type = export, value = ((__VLIR16_LAST__ - __VLIR16_START__) + 253) / 254; + __VLIR17_BLOCKS__: type = export, value = ((__VLIR17_LAST__ - __VLIR17_START__) + 253) / 254; + __VLIR18_BLOCKS__: type = export, value = ((__VLIR18_LAST__ - __VLIR18_START__) + 253) / 254; + __VLIR19_BLOCKS__: type = export, value = ((__VLIR19_LAST__ - __VLIR19_START__) + 253) / 254; } MEMORY { CVT: file = %O, start = $0, size = $40000; diff --git a/samples/geos/Makefile b/samples/geos/Makefile index 0ede7e78c..1443d9709 100644 --- a/samples/geos/Makefile +++ b/samples/geos/Makefile @@ -39,10 +39,12 @@ ifdef CMD_EXE NULLDEV = nul: DEL = -del /f RMDIR = rmdir /s /q + CP = copy else NULLDEV = /dev/null DEL = $(RM) RMDIR = $(RM) -r + CP = cp endif ifdef CC65_HOME @@ -107,7 +109,11 @@ $(C1541) -attach $(0).d64 -geoswrite $(1); endef samples-geos: $(EXELIST_$(SYS)) +ifeq (,$(wildcard ./geos-template.d64)) $(C1541) -format "$@,01" d64 $@.d64 +else + $(CP) geos-template.d64 $@.d64 +endif $(foreach tool,$(EXELIST_$(SYS)),$(call samples-geos,$(tool))) else samples: @@ -172,4 +178,5 @@ clean: @$(DEL) bitmap.c 2>$(NULLDEV) @$(DEL) *.cvt 2>$(NULLDEV) @$(DEL) *.map 2>$(NULLDEV) + @$(DEL) samples-geos.d64 2>$(NULLDEV) $(foreach dir,$(DIRLIST),$(SUBDIR_recipe)) diff --git a/src/grc65/main.c b/src/grc65/main.c index 5ef9e9645..51211ddff 100644 --- a/src/grc65/main.c +++ b/src/grc65/main.c @@ -64,6 +64,9 @@ struct appheader { char *icon; }; +#define APPHEADER_STRUCTURE_SEQ 0 +#define APPHEADER_STRUCTURE_VLIR 1 + const char *mainToken[] = {"MENU", "HEADER", "ICON", "DIALOG", "MEMORY", ""}; const char *toggle[] = {"off", "no", "0", "on", "yes", "1", ""}; @@ -114,16 +117,16 @@ static void Usage (void) printf ( "Usage: %s [options] file\n" "Short options:\n" - " -V\t\t\tPrint the version number\n" - " -h\t\t\tHelp (this text)\n" - " -o name\t\tName the C output file\n" - " -s name\t\tName the asm output file\n" - " -t sys\t\tSet the target system\n" + " -V Print the version number\n" + " -h Help (this text)\n" + " -o name Name the C output file\n" + " -s name Name the asm output file\n" + " -t sys Set the target system\n" "\n" "Long options:\n" - " --help\t\tHelp (this text)\n" - " --target sys\t\tSet the target system\n" - " --version\t\tPrint the version number\n", + " --help Help (this text)\n" + " --target sys Set the target system\n" + " --version Print the version number\n", ProgName); } @@ -176,11 +179,11 @@ static void printCHeader (void) { fprintf (outputCFile, "//\n" - "//\tThis file was generated by the GEOS Resource Compiler\n" + "// This file was generated by the GEOS Resource Compiler\n" "//\n" - "//\tDO NOT EDIT! Any changes will be lost!\n" + "// DO NOT EDIT! Any changes will be lost!\n" "//\n" - "//\tEdit proper resource file instead.\n" + "// Edit proper resource file instead.\n" "//\n\n"); } @@ -189,11 +192,11 @@ static void printSHeader (void) { fprintf (outputSFile, ";\n" - ";\tThis file was generated by the GEOS Resource Compiler\n" + "; This file was generated by the GEOS Resource Compiler\n" ";\n" - ";\tDO NOT EDIT! Any changes will be lost!\n" + "; DO NOT EDIT! Any changes will be lost!\n" ";\n" - ";\tEdit proper resource file instead.\n" + "; Edit proper resource file instead.\n" ";\n\n"); } @@ -268,11 +271,11 @@ static void fillOut (char *name, int len, char *filler) int a; setLen (name, len); - fprintf (outputSFile, "\t.byte \"%s\"\n", name); + fprintf (outputSFile, " .byte \"%s\"\n", name); a = strlen (name); if (a < len) { - fprintf (outputSFile, "\t.res (%i - %i), %s\n", len, a, filler); + fprintf (outputSFile, " .res (%i - %i), %s\n", len, a, filler); } } @@ -388,15 +391,15 @@ static void DoMenu (void) fprintf (outputCFile, "\n" "const void %s = {\n" - "\t(char)%i, (char)%i,\n" - "\t(int)%i, (int)%i,\n" - "\t(char)(%i | %s),\n", + " (char)%i, (char)%i,\n" + " (int)%i, (int)%i,\n" + " (char)(%i | %s),\n", myMenu.name, myMenu.top, myMenu.bot, myMenu.left, myMenu.right, item, myMenu.type); curItem = myMenu.item; for (a = 0; a != item; a++) { fprintf (outputCFile, - "\t%s, (char)%s, (int)", + " %s, (char)%s, (int)", curItem->name, curItem->type); if ((strstr (curItem->type, "SUB_MENU") != NULL) && (strstr (curItem->type, "DYN_SUB_MENU") == NULL)) { fprintf (outputCFile, @@ -464,8 +467,10 @@ static void DoHeader (void) myHead.author = "cc65"; myHead.info = "Program compiled with cc65 and GEOSLib."; myHead.dostype = 128; - if (apple == 0) myHead.dostype += 3; - myHead.structure = 0; + if (apple == 0) { + myHead.dostype += 3; + } + myHead.structure = APPHEADER_STRUCTURE_SEQ; myHead.mode = 0; myHead.icon = NULL; @@ -542,11 +547,11 @@ static void DoHeader (void) AbEnd ("unknown structure type in header '%s'", myHead.dosname); case 0: case 1: - myHead.structure = 0; + myHead.structure = APPHEADER_STRUCTURE_SEQ; break; case 2: case 3: - myHead.structure = 1; + myHead.structure = APPHEADER_STRUCTURE_VLIR; break; } break; @@ -560,35 +565,60 @@ static void DoHeader (void) /* OK, all information is gathered, do flushout */ fprintf (outputSFile, - "\t\t.segment \"DIRENTRY\"\n\n"); + " .import __BSS_SIZE__, __STARTUP_RUN__\n" + " .import __VLIR0_START__, __VLIR0_LAST__\n" + " .import __VLIR0_BLOCKS__\n" + " .import __VLIR1_BLOCKS__\n" + " .import __VLIR2_BLOCKS__\n" + " .import __VLIR3_BLOCKS__\n" + " .import __VLIR4_BLOCKS__\n" + " .import __VLIR5_BLOCKS__\n" + " .import __VLIR6_BLOCKS__\n" + " .import __VLIR7_BLOCKS__\n" + " .import __VLIR8_BLOCKS__\n" + " .import __VLIR9_BLOCKS__\n" + " .import __VLIR10_BLOCKS__\n" + " .import __VLIR11_BLOCKS__\n" + " .import __VLIR12_BLOCKS__\n" + " .import __VLIR13_BLOCKS__\n" + " .import __VLIR14_BLOCKS__\n" + " .import __VLIR15_BLOCKS__\n" + " .import __VLIR16_BLOCKS__\n" + " .import __VLIR17_BLOCKS__\n" + " .import __VLIR18_BLOCKS__\n" + " .import __VLIR19_BLOCKS__\n\n" + ); + + fprintf (outputSFile, + " .segment \"DIRENTRY\"\n\n"); if (apple == 1) { - if (myHead.structure == 0) { + if (myHead.structure == APPHEADER_STRUCTURE_SEQ) { fprintf (outputSFile, - "\t.import __VLIR0_START__, __VLIR0_LAST__, __BSS_SIZE__\n\n"); + " .import __VLIR0_START__, __VLIR0_LAST__, __BSS_SIZE__\n\n"); } fprintf (outputSFile, - "\t.byte %i << 4 | %u\n", + " .byte %i << 4 | %u\n", myHead.structure + 2, (unsigned)strlen (myHead.dosname)); fillOut (myHead.dosname, 15, "0"); fprintf (outputSFile, - "\t.byte $%02x\n" - "\t.word 0\n" - "\t.word 0\n" - "\t.word %s\n" - "\t.byte 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\n", + " .byte $%02x\n" + " .word 0\n" + " .word 0\n" + " .word %s\n" + " .byte 0\n" + " .word %i << 9 | %i << 5 | %i, %i << 8 | %i\n" + " .byte 0\n" + " .byte 0\n" + " .byte 0\n" + " .word 0\n" + " .word %i << 9 | %i << 5 | %i, %i << 8 | %i\n" + " .word 0\n\n", myHead.geostype, - myHead.structure == 0 ? + myHead.structure == APPHEADER_STRUCTURE_SEQ ? "__VLIR0_LAST__ - __VLIR0_START__ - __BSS_SIZE__" : "0", myHead.year, myHead.month, myHead.day, myHead.hour, myHead.min, myHead.year, myHead.month, myHead.day, myHead.hour, myHead.min); @@ -596,43 +626,50 @@ static void DoHeader (void) } else { fprintf (outputSFile, - "\t.byte %i\n" - "\t.word 0\n", + " .byte %i\n" + " .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", + " .word 0\n" + " .byte %i\n" + " .byte %i\n" + " .byte %i, %i, %i, %i, %i\n\n" + /* length in blocks: + * add size of each VLIR segment, plus 1 block for the info block (icon), + * plus another block for the VLIR RECORDS table (VLIR structure only) + */ + " .word %d + __VLIR0_BLOCKS__ + __VLIR1_BLOCKS__ + __VLIR2_BLOCKS__ + __VLIR3_BLOCKS__ + __VLIR4_BLOCKS__ + __VLIR5_BLOCKS__ + __VLIR6_BLOCKS__ + __VLIR7_BLOCKS__ + __VLIR8_BLOCKS__ + __VLIR9_BLOCKS__ + __VLIR10_BLOCKS__ + __VLIR11_BLOCKS__ + __VLIR12_BLOCKS__ + __VLIR13_BLOCKS__ + __VLIR14_BLOCKS__ + __VLIR15_BLOCKS__ + __VLIR16_BLOCKS__ + __VLIR17_BLOCKS__ + __VLIR18_BLOCKS__ + __VLIR19_BLOCKS__\n" + /* PRG formatted or SEQ formatted */ + " .byte \"%s formatted GEOS file V1.0\"\n\n", myHead.structure, myHead.geostype, - myHead.year, myHead.month, myHead.day, myHead.hour, myHead.min); + myHead.year, myHead.month, myHead.day, myHead.hour, myHead.min, + (myHead.structure == APPHEADER_STRUCTURE_SEQ) ? 1 : 2, + (myHead.structure == APPHEADER_STRUCTURE_SEQ) ? "SEQ" : "PRG" + ); } fprintf (outputSFile, - "\t\t.segment \"FILEINFO\"\n\n" - "\t.import __VLIR0_START__, __STARTUP_RUN__\n\n" - "\t.byte 3, 21, 63 | $80\n"); + " .segment \"FILEINFO\"\n\n" + " .byte 3, 21, 63 | $80\n"); if (myHead.icon != NULL) { fprintf (outputSFile, - "\t.incbin \"%s\", 0, 63\n", + " .incbin \"%s\", 0, 63\n", myHead.icon); } else { for (i = 0; i != 63; i = i + 3) { fprintf (outputSFile, - "\t.byte %%%s, %%%s, %%%s\n", + " .byte %%%s, %%%s, %%%s\n", bintos (icon1[i], i1), bintos (icon1[i+1], i2), bintos (icon1[i+2], i3)); } } fprintf (outputSFile, - "\t.byte %i, %i, %i\n" - "\t.word __VLIR0_START__, __VLIR0_START__ - 1, __STARTUP_RUN__\n\n", + " .byte %i, %i, %i\n" + " .word __VLIR0_START__, __VLIR0_START__ - 1, __STARTUP_RUN__\n\n", myHead.dostype, myHead.geostype, myHead.structure); fillOut (myHead.classname, 12, "$20"); @@ -640,21 +677,21 @@ static void DoHeader (void) fillOut (myHead.version, 4, "0"); fprintf (outputSFile, - "\t.byte 0, 0, 0\n" - "\t.byte %i\n\n", + " .byte 0, 0, 0\n" + " .byte %i\n\n", myHead.mode); setLen (myHead.author, 62); fprintf (outputSFile, - "\t.byte \"%s\"\n" - "\t.byte 0\n" - "\t.res (63 - %i)\n\n", + " .byte \"%s\"\n" + " .byte 0\n" + " .res (63 - %i)\n\n", myHead.author, (int)(strlen (myHead.author) + 1)); setLen (myHead.info, 95); fprintf (outputSFile, - "\t.byte \"%s\"\n" - "\t.byte 0\n\n", + " .byte \"%s\"\n" + " .byte 0\n\n", myHead.info); if (fclose (outputSFile) != 0) { @@ -751,13 +788,13 @@ static void DoMemory (void) if (lastnumber != -1) { fprintf (outputSFile, - "\t\t.segment \"RECORDS\"\n\n"); + " .segment \"RECORDS\"\n\n"); if (apple == 1) { for (number = 0; number <= lastnumber; number++) { fprintf (outputSFile, - "\t.byte %s\n", + " .byte %s\n", overlaytable[number] == 1 ? "$00" : "$FF"); } fprintf (outputSFile, @@ -766,12 +803,12 @@ static void DoMemory (void) for (number = 0; number <= lastnumber; number++) { if (overlaytable[number] == 1) { fprintf (outputSFile, - "\t\t.segment \"VLIRIDX%i\"\n\n" - "\t.import __VLIR%i_START__, __VLIR%i_LAST__%s\n\n" - "\t.res 255\n" - "\t.byte .lobyte (__VLIR%i_LAST__ - __VLIR%i_START__%s)\n" - "\t.res 255\n" - "\t.byte .hibyte (__VLIR%i_LAST__ - __VLIR%i_START__%s)\n\n", + " .segment \"VLIRIDX%i\"\n\n" + " .import __VLIR%i_START__, __VLIR%i_LAST__%s\n\n" + " .res 255\n" + " .byte .lobyte (__VLIR%i_LAST__ - __VLIR%i_START__%s)\n" + " .res 255\n" + " .byte .hibyte (__VLIR%i_LAST__ - __VLIR%i_START__%s)\n\n", number, number, number, number == 0 ? ", __BSS_SIZE__" : "", number, number, @@ -786,7 +823,7 @@ static void DoMemory (void) for (number = 0; number <= lastnumber; number++) { if (overlaytable[number] == 1) { fprintf (outputSFile, - "\t.import __VLIR%i_START__, __VLIR%i_LAST__%s\n", + " .import __VLIR%i_START__, __VLIR%i_LAST__%s\n", number, number, number == 0 ? ", __BSS_SIZE__" : ""); } } @@ -796,14 +833,14 @@ static void DoMemory (void) for (number = 0; number <= lastnumber; number++) { if (overlaytable[number] == 1) { fprintf (outputSFile, - "\t.byte .lobyte ((__VLIR%i_LAST__ - __VLIR%i_START__%s - 1) / 254) + 1\n" - "\t.byte .lobyte ((__VLIR%i_LAST__ - __VLIR%i_START__%s - 1) .MOD 254) + 2\n", + " .byte .lobyte ((__VLIR%i_LAST__ - __VLIR%i_START__%s - 1) / 254) + 1\n" + " .byte .lobyte ((__VLIR%i_LAST__ - __VLIR%i_START__%s - 1) .MOD 254) + 2\n", number, number, number == 0 ? " - __BSS_SIZE__" : "", number, number, number == 0 ? " - __BSS_SIZE__" : ""); } else { fprintf (outputSFile, - "\t.byte $00\n" - "\t.byte $FF\n"); + " .byte $00\n" + " .byte $FF\n"); } } fprintf (outputSFile, @@ -825,19 +862,19 @@ static void DoMemory (void) if (stacksize != -1) { fprintf (outputSFile, - "\t.export __STACKSIZE__ : absolute = $%04x\n\n", + " .export __STACKSIZE__ : absolute = $%04x\n\n", stacksize); } if (overlaysize != -1) { fprintf (outputSFile, - "\t.export __OVERLAYSIZE__ : absolute = $%04x\n\n", + " .export __OVERLAYSIZE__ : absolute = $%04x\n\n", overlaysize); } if (backbuffer != -1) { fprintf (outputSFile, - "\t.export __BACKBUFSIZE__ : absolute = $%04x\n\n", + " .export __BACKBUFSIZE__ : absolute = $%04x\n\n", backbuffer ? 0x2000 : 0x0000); }