Hey, are you still maintaining your disasm6 written in PHP? I made a few minor improvements to v1.4 and I'm including them in here as a patch file. All the changes have to do with handling transitions between code and data in the .cdl file. The changes are:
1. If a location is marked as both code and data in the .cdl file, then it should be treated as code (right now it's treated as data). This can happen when writing PRG-ROM to setup the mappers. For example, the North American Tetris uses "INC $8000" to reset the MMC1 mapper, but location $8000 contains valid code as well.
2. When something is decoded as hex data, disasm6 automatically reads 4 bytes at a time without checking ahead in the cdl to see if any bytes are marked as code. Once again in Tetris there are cases where a "JSR" is immediately followed by two data bytes which are a pointer for the subroutine to read. The subroutine then returns two bytes after the pointer, so the raw bytes in the .cdl file are: code code data data code code ...". Right now, disasm6 will decode all four "data data code code" bytes as if they were data only. The logic I added to handle this is in the same loop that already checks for a label somewhere in the middle of those 4 bytes which would correctly cause us to read less than 4 bytes for this line of output.
3. When using one of the "JumpTable" or "RTSTable" labels, disasm6 starts to decode
all data as table pointers until it encounters some user defined label. With my patch, the first byte marked as code will also end the decoding of the table. Otherwise, for each jump/RTS table you would need to manually add a dummy label to stop decoding any further.
Spoiler:
--- a/disasm6.php
+++ b/disasm6.php
@@ -1238,7 +1238,7 @@ while ($pass <= $lastPass)
// data byte
- if (($cdlByte & bindec('00000010')) >> 1)
+ if (($cdlByte & bindec('00000011')) == bindec('00000010'))
{
$counter_pad = dechex_pad($counter);
@@ -1298,6 +1298,12 @@ while ($pass <= $lastPass)
$isDataByte = true;
$dataStr = 'Data';
}
+
+ // code byte ends table
+ else
+ {
+ $theOldLabel = '';
+ }
}
@@ -1315,6 +1321,11 @@ while ($pass <= $lastPass)
{
if ($pass >= 1)
{
+ if ($cdlFilename !== false)
+ {
+ $cdlPos = ftell($cdlFile);
+ }
+
// check to see if a label exists in this opcode.. if so then usually it's data
for ($i = 1; $i <= $readBytes; $i++)
{
@@ -1334,6 +1345,27 @@ while ($pass <= $lastPass)
$addressingType = -1;
continue;
}
+
+ // if this byte marked as data in cdl; check if next bytes are code
+ if ($cdlFilename !== false && $isDataByte)
+ {
+ $newCdlByte = ord(fread($cdlFile, 1));
+
+ if ($newCdlByte & bindec('00000001'))
+ {
+ $invalidCounter = 0;
+ $readBytes = $i - 1;
+ $isInvalid = 1;
+ $byteLen = $i;
+ $addressingType = -1;
+ continue;
+ }
+ }
+ }
+
+ if ($cdlFilename !== false)
+ {
+ fseek($cdlFile, $cdlPos);
}
}