Skip to content
Sign up
Sign in
This repository
Explore
Features
Enterprise
Blog
Watch
19
Star
20
Fork
8
sonicretro
/
s1disasm
Code
Issues
Pull requests
Pulse
Graphs
HTTPS
clone URL
Subversion
checkout URL
You can clone with
HTTPS
or
Subversion
.
Download ZIP
Permalink
Browse files
Fixing and implementing s1p2bin
Loading branch information
...
commit
d0b1b23fc41e2f0e7cfeb7c205706223a112e6b7
1 parent
0d0e5a1
MainMemory
authored
Aug 4, 2014
Unified
Split
Showing
3 changed files
with
21 additions
and
4 deletions
.
BIN
AS/Win32/s1p2bin.exe
+20
−3
AS/s1p2bin.cpp
+1
−1
Build Scripts/build.bat
Show notes
View
BIN
AS/Win32/s1p2bin.exe
Binary file not shown
Show notes
View
23
AS/s1p2bin.cpp
@@ -74,6 +74,7 @@ bool buildRom(FILE* from, FILE* to)
int
cpuType =
0
, segmentType =
0
, granularity =
0
;
signed
long
start =
0
;
unsigned
short
length =
0
;
+
long
maxpos =
0
;
static
const
int
scratchSize =
4096
;
unsigned
char
scratch [scratchSize];
@@ -124,10 +125,24 @@ bool buildRom(FILE* from, FILE* to)
return
false
;
}
-
if
(start+
3
<
ftell
(to))
// 3 bytes of leeway for instruction patching
+
long
cur =
ftell
(to);
+
+
if
(start+
3
< cur)
// 3 bytes of leeway for instruction patching
printf
(
"
\n
Warning: overlapping allocation detected! $
%X
< $
%X
"
, start,
ftell
(to));
-
fseek
(to, start, SEEK_SET);
+
// hack to make padding directives use 0xFF without breaking backwards orgs
+
if
(start < cur || start < maxpos)
+
fseek
(to, start, SEEK_SET);
+
else
+
while
(cur < start)
+ {
+
int
dif = start - cur;
+
if
(dif > scratchSize)
+ dif = scratchSize;
+
memset
(scratch, -
1
, dif);
+
fwrite
(scratch, dif,
1
, to);
+ cur += dif;
+ }
// printf("copying $%X-$%X -> $%X-$%X\n", ftell(from), ftell(from)+length, start, start+length);
while
(length)
@@ -139,7 +154,9 @@ bool buildRom(FILE* from, FILE* to)
fwrite
(scratch, copy,
1
, to);
length -= copy;
}
-
+ cur =
ftell
(to);
+
if
(cur > maxpos)
+ maxpos = cur;
}
return
true
;
Show notes
View
2
Build Scripts/build.bat
@@ -32,7 +32,7 @@ REM // if there were errors, a log file is produced
IF
"
%1
"
==
"
-logerrors
"
(
IF
EXIST sonic.log
goto
LABLERROR3 )
REM
// combine the assembler output into a rom
-
IF
EXIST sonic.p
"
AS/Win32/
p2bin
"
sonic.p s1built.bin
-r $-$
+
IF
EXIST sonic.p
"
AS/Win32/
s1p2bin
"
sonic.p s1built.bin
REM
// done --
pause
if
we seem to have failed, then
exit
IF NOT EXIST
sonic.p
goto
LABLPAUSE
Toggle all file notes
Please
sign in
to comment.
Something went wrong with that request. Please try again.