]> Shamusworld >> Repos - rmac/commitdiff
Fix for #210 - 6502 mode with -fr working v2.2.13
authorggn <ggn@atari.org>
Wed, 26 Oct 2022 18:30:21 +0000 (21:30 +0300)
committerShamus Hammons <jlhamm@acm.org>
Wed, 21 Dec 2022 22:57:02 +0000 (16:57 -0600)
6502.c
direct.c
object.c
rmac.c
rmac.h
version.h

diff --git a/6502.c b/6502.c
index 131c6d8c106982d4cd70825ea5e8db5c875b2d52..66f2080977e2a0d73a639252a43867c672da9ef9 100644 (file)
--- a/6502.c
+++ b/6502.c
@@ -243,6 +243,7 @@ int d_6502()
        regtab = reg65tab;
        regcheck = reg65check;
        regaccept = reg65accept;
+       used_architectures |= M6502;
 
        return 0;
 }
@@ -570,6 +571,26 @@ void m6502obj(int ofd)
 }
 
 
+// Write raw 6502 org'd code.
+// Super copypasta'd from above function
+void m6502raw(int ofd)
+{
+       CHUNK * ch = sect[M6502].scode;
+
+       // If no 6502 code was generated, bail out
+       if ((ch == NULL) || (ch->challoc == 0))
+               return;
+
+       register uint8_t *p = ch->chptr;
+
+       for(uint16_t * l=&orgmap[0][0]; l<currentorg; l+=2)
+       {
+               // Write the segment data
+               uint32_t unused = write(ofd, p + l[0], l[1] - l[0]);
+       }
+}
+
+
 //
 // Generate a C64 .PRG output file
 //
index 684607f522ad6456f004032e9fe0c936c4826e33..b3a835821ea1af580232bc9b13f6cf0b93495c3b 100644 (file)
--- a/direct.c
+++ b/direct.c
@@ -2027,6 +2027,7 @@ int d_56001(void)
        regtab = reg56tab;
        regcheck = reg56check;
        regaccept = reg56accept;
+       used_architectures |= M56001P | M56001X | M56001Y | M56001L;
        return 0;
 }
 
@@ -2058,6 +2059,7 @@ int d_gpu(void)
        regtab = regrisctab;
        regcheck = regrisccheck;
        regaccept = regriscaccept;
+       //used_architectures |= MGPU;   // TODO: Should GPU/DSP have their own dedicated sections in the long run?
        return 0;
 }
 
@@ -2089,6 +2091,7 @@ int d_dsp(void)
        regtab = regrisctab;
        regcheck = regrisccheck;
        regaccept = regriscaccept;
+       //used_architectures |= MDSP;   // TODO: Should GPU/DSP have their own dedicated sections in the long run?
        return 0;
 }
 
@@ -2361,6 +2364,7 @@ int d_objproc(void)
        rgpu = 0;                       // Unset GPU assembly
        rdsp = 0;                       // Unset DSP assembly
        dsp56001 = 0;           // Unset 56001 assembly
+       //used_architectures |= MOP;    // TODO: Should OP have its own dedicated section in the long run?
        return OK;
 }
 
index f7ac8a79cda5cfde83d6bbced6cb0c27cbfa9a46..6dbf9c525aac300a44cf4127536c99f9c9f044db 100644 (file)
--- a/object.c
+++ b/object.c
@@ -864,9 +864,18 @@ for(int j=0; j<i; j++)
        }
        else if (obj_format == RAW)
        {
-               if (!org68k_active)
+               if (!org68k_active && used_architectures & (!(M6502 | M56001P | M56001X | M56001Y | M56001L)))
                        return error("cannot output absolute binary without a starting address (.org or command line)");
 
+               if (used_architectures & M6502)
+               {
+                       // Okay, this is not the best. But it'll have to do until we revamp things a bit with sections.
+                       // Basically we assume that if raw output is requested and 6502 mode was switched on, nobody
+                       // switched to other architectures. The combination doesn't make much sense anyway for now.
+                       m6502raw(fd);
+                       return 0;
+               }
+
                // Alloc memory for text + data construction.
                tds = sect[TEXT].sloc + sect[DATA].sloc;
                buf = malloc(tds);
diff --git a/rmac.c b/rmac.c
index d9158f4c82e63016daa6bd8c4e36655ece011c1d..8e5f4102ce8af450dde2e8cc64ed3abf8e84b225 100644 (file)
--- a/rmac.c
+++ b/rmac.c
@@ -62,6 +62,7 @@ int activefpu = FPU_NONE;             // Active FPU (none by default)
 int org68k_active = 0;                 // .org switch for 68k (only with RAW output format)
 uint32_t org68k_address;               // .org for 68k
 int correctMathRules;                  // 1, use C operator precedence in expressions
+uint32_t used_architectures;   // Bitmask that records exactly which architectures were used during assembly
 
 //
 // Convert a string to uppercase
@@ -377,6 +378,7 @@ int Process(int argc, char ** argv)
        regcheck = reg68check;                  // Idem
        regaccept = reg68accept;                // Idem
     correctMathRules = 0;                      // respect operator precedence
+       used_architectures = 0;                 // Initialise used architectures bitfield
        // Initialize modules
        InitSymbolTable();                              // Symbol table
        InitTokenizer();                                // Tokenizer
diff --git a/rmac.h b/rmac.h
index f8c9f4c55118808b4a8bbb7b50f32389c6037dbc..00dcd3ba49c92cb9d6b6c194076adbe7c94bc4ef 100644 (file)
--- a/rmac.h
+++ b/rmac.h
@@ -320,6 +320,7 @@ extern int *regbase;
 extern int *regtab;
 extern int *regcheck;
 extern int *regaccept;
+extern uint32_t used_architectures;
 
 // Exported functions
 void strtoupper(char * s);
index c84dae51ebf81349a6a85926f474e98be5507ce3..5e60ffae772c4346bad2ef29847cf2b7b957ea22 100644 (file)
--- a/version.h
+++ b/version.h
@@ -15,6 +15,6 @@
 
 #define MAJOR   2              // Major version number
 #define MINOR   2              // Minor version number
-#define PATCH   11             // Patch release number
+#define PATCH   13             // Patch release number
 
 #endif // __VERSION_H__