I figured out why all the #'s periodically go dark in HHS' script - as written, the first row of values (0x81-0x8D) is cut off the top of the screen. That explains a lot!
I reformatted and commented his script in an attempt to understand it better, with some minor modifications that are in progress.
Language: lua
-- address we're targeting
target = 0xae
-- table of the lengths of the various instructions
lengths={
2,2,2,2, -- 0x(0,2,4,6,8,A,C,E)0-3
2,2,2,2, -- 0x(0,2,4,6,8,A,C,E)4-7
1,2,1,2, -- 0x(0,2,4,6,8,A,C,E)8-B
3,3,3,3, -- 0x(0,2,4,6,8,A,C,E)C-F
2,2,0,2,-- 0x(1,3,5,7,9,B,D,F)0-3
2,2,2,2,-- 0x(1,3,5,7,9,B,D,F)4-7
1,3,1,3,-- 0x(1,3,5,7,9,B,D,F)8-B
3,3,3,3 -- 0x(1,3,5,7,9,B,D,F)C-F
}
-- main loop
while true do
-- each frame, always start from same address with all variables reset except for target
startAddress=0x81
displayCol=0
displayRow=0
jumpFlag=false
postJump=false
message = 'Fail';
branchMsg = 'No Branches';
-- will show up to 16 rows
while displayRow<16 do
-- get the instruction and determine its length
op=memory.readbyte(startAddress)
opLength=lengths[AND(op,31)+1]
-- start of instruction, white
color='#ffffff'
-- we got to our target! Hooray!
if startAddress==target and not jumpFlag then
color='#00ff00'
message='Success'
end
-- JSR (20) and JMP (4c,6c) have length 3, special color
if op==0x20 or op==0x4c or op==0x6c then
color='#ff0000' -- red
opLength=3
jumpFlag=true
-- RTI (40), RTS (60), AND(1000 1111) == 2 --> 0xxx 0010 --> 02, 12, 22...72
-- length 0 for 0x12, 32...F2.
elseif opLength==0 or AND(op,0x8f)==2 or op==0x40 or op==0x60 then
color='#ff0000' -- red
opLength=1
jumpFlag=true
-- Branch instructions
-- essentially we warn
elseif AND(op,31)==0x10 then
color='#880000' -- light red
branchMsg = "May Branch"
end
-- process the bytes in an operation
for i=0,opLength-1 do
-- read the byte
x=memory.readbyte(startAddress)
-- mark bytes beyond a jump -- dark/not executed
if postJump then
color='#502020'
end
-- display the byte!
gui.text(displayCol*16,8+displayRow*8,string.format('%02X',x),color)
-- next byte in this instruction
startAddress=startAddress+1
color='#0000ff' -- data bytes
-- advance display, use next row if needed
displayCol=displayCol+1
if displayCol==16 then
displayCol=0
displayRow=displayRow+1
end
-- note that we're now beyond a jumping instruction, so further bytes won't be executed
if jumpFlag then
postJump = true
end
end
-- terminate (for this frame) if beyond target
if startAddress>target+2 or startAddress<0x80 then
gui.text(10*18,(displayRow+1)*8,message,'#ffffff');
gui.text(10*18,(displayRow+2)*8,branchMsg,'#ffffff');
break
end
end
FCEU.frameadvance();
end