From 6056c16bf5053addba1fec6ff821a0f435f0b3da Mon Sep 17 00:00:00 2001 From: ggn Date: Tue, 13 Sep 2016 19:48:44 +0300 Subject: [PATCH] .incbin now uses the same directory sets as .include. Also some small cosmetic fixes. --- Vs2015/rmac/rmac.vcxproj | 2 +- direct.c | 26 +++++++++++++++++++++++--- mark.c | 1 + 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Vs2015/rmac/rmac.vcxproj b/Vs2015/rmac/rmac.vcxproj index a127bd8..e03e65d 100644 --- a/Vs2015/rmac/rmac.vcxproj +++ b/Vs2015/rmac/rmac.vcxproj @@ -110,7 +110,7 @@ true - $(SolutionDir)\.. + $(SolutionDir)\..\ true diff --git a/direct.c b/direct.c index dc44e8e..dc9747b 100644 --- a/direct.c +++ b/direct.c @@ -350,6 +350,8 @@ int d_incbin(void) int bytes = 0; long pos, size, bytesRead; char msg[256]; + char buf1[256]; + int i; // Check to see if we're in BSS, and, if so, throw an error if (scattr & SBSS) @@ -364,12 +366,30 @@ int d_incbin(void) return ERROR; } - if ((fd = open(string[tok[1]], _OPEN_INC)) < 0) + // 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) { - errors("cannot open include binary file (%s)", string[tok[1]]); - return ERROR; + for (i = 0; nthpath("RMACPATH", i, buf1) != 0; i++) + { + fd = strlen(buf1); + + if (fd > 0 && buf1[fd - 1] != SLASHCHAR) // Append path char if necessary + strcat(buf1, SLASHSTRING); + + strcat(buf1, string[tok[1]]); + + if ((fd = open(buf1, _OPEN_INC)) >= 0) + goto allright; + } + + return errors("cannot open: \"%s\"", string[tok[1]]); } +allright: + + size = lseek(fd, 0L, SEEK_END); pos = lseek(fd, 0L, SEEK_SET); chcheck(size); diff --git a/mark.c b/mark.c index d593b21..81a4d87 100644 --- a/mark.c +++ b/mark.c @@ -18,6 +18,7 @@ PTR markptr; // Deposit point in current mark chunk LONG mcalloc; // #bytes alloc'd to current mark chunk LONG mcused; // #bytes used in current mark chunk uint16_t curfrom; // Current "from" section +LONG markimg(register char * mp, LONG siz, LONG tsize, int okflag); // // Imports -- 2.37.2