d_nofpu, // 65 nofpu
d_opt, // 66 .opt
d_objproc, // 67 .objproc
- d_dsm, // 68 .dsm
+ (void *)d_dsm, // 68 .dsm
};
{
uint64_t address;
- if (!rgpu && !rdsp && !robjproc && !m6502 && !dsp56001)
- return error(".org permitted only in GPU/DSP/OP, 56001 and 6502 sections");
+ if (!rgpu && !rdsp && !robjproc && !m6502 && !dsp56001 && !(obj_format == RAW))
+ return error(".org permitted only in GPU/DSP/OP, 56001, 6502 and 68k (with -fr switch) sections");
// M56K can leave the expression off the org for some reason :-/
// (It's because the expression is non-standard, and so we have to look at
// N.B.: It seems that by enabling this, even though it works elsewhere, will cause symbols to royally fuck up. Will have to do some digging to figure out why.
// orgactive = 1;
}
+ else
+ {
+ // If we get here we assume it's 68k with RAW output, so this is allowed
+ if (orgactive)
+ {
+ return error("In 68k mode only one .org statement is allowed");
+ }
+
+ org68k_address = address;
+ org68k_active = 1;
+ }
ErrorIfNotAtEOL();
return 0;
//
-// Include binary file
+// Include binary file (can add addition size & position params, comma separated)
//
int d_incbin(void)
{
int fd;
int bytes = 0;
- long pos, size, bytesRead;
+ uint64_t pos, size, bytesRead;
char buf1[256];
int i;
// Attempt to open the include file in the current directory, then (if that
// failed) try list of include files passed in the enviroment string or by
// the "-d" option.
- if ((fd = open(string[tok[1]], _OPEN_INC)) < 0)
+ TOKEN filename = tok[1];
+
+ if ((fd = open(string[filename], _OPEN_INC)) < 0)
{
for(i=0; nthpath("RMACPATH", i, buf1)!=0; i++)
{
if (fd > 0 && buf1[fd - 1] != SLASHCHAR)
strcat(buf1, SLASHSTRING);
- strcat(buf1, string[tok[1]]);
+ strcat(buf1, string[filename]);
if ((fd = open(buf1, _OPEN_INC)) >= 0)
goto allright;
}
- return error("cannot open: \"%s\"", string[tok[1]]);
+ return error("cannot open: \"%s\"", string[filename]);
}
allright:
- size = lseek(fd, 0L, SEEK_END);
- pos = lseek(fd, 0L, SEEK_SET);
+ tok += 2;
+
+ if (*tok != EOL)
+ {
+ // Check size parameter (can be omitted)
+ if (*tok++ == ',')
+ {
+ if (*tok != ',')
+ {
+ if (abs_expr(&size) != OK)
+ {
+ close(fd);
+ return ERROR;
+ }
+ }
+ else
+ size = lseek(fd, 0L, SEEK_END);
+ }
+
+ // Check offset parameter (can be omitted)
+ if (*tok != EOL)
+ {
+ if (*tok++ == ',')
+ {
+ if (*tok != EOL)
+ {
+ if (abs_expr(&pos) != OK)
+ {
+ close(fd);
+ return ERROR;
+ }
+
+ lseek(fd, pos, SEEK_SET);
+ size -= pos;
+ }
+ else
+ {
+ // offset parameter omitted, so it's 0
+ pos = lseek(fd, 0L, SEEK_SET);
+ }
+ }
+ else
+ return error(comma_error);
+ }
+ else
+ pos = lseek(fd, 0L, SEEK_SET);
+ }
+ else
+ {
+ // size & pos not given, so assume offset of 0 and all of the binary
+ size = lseek(fd, 0L, SEEK_END);
+ pos = lseek(fd, 0L, SEEK_SET);
+ }
+
chcheck(size);
- DEBUG { printf("INCBIN: File '%s' is %li bytes.\n", string[tok[1]], size); }
+ DEBUG { printf("INCBIN: File '%s' is %li bytes.\n", string[filename], size); }
char * fileBuffer = (char *)malloc(size);
bytesRead = read(fd, fileBuffer, size);
if (bytesRead != size)
{
- error("was only able to read %li bytes from binary file (%s, %li bytes)", bytesRead, string[tok[1]], size);
+ error("was only able to read %li bytes from binary file (%s, %li bytes)", bytesRead, string[filename], size);
return ERROR;
}