More stupid fun,

I wanted to be able to click on the apple graphics screen and find out the x,y coordinates and the memory location.

It got tiring to save a screenshot, then load into gimp to figure out what the coordinates were. So why not have mame help me out.

If I execute this routine, it will give me the coordinates, draw a line and a box around it where I click on the screen.

Once I know the address then I can just set a watchpoint in the debugger.

[Linked Image from i.imgur.com]

which allowed me to set a watchpoint "wp 3106,1,w" and then once it hit that, do a "history" which led me to a routine around 7E46 and disassembling at 7E00 points me to the memory addresses at 81F8 to 81FA where the player score is stored.

[Linked Image from i.imgur.com]



Code


function rem(a) print(a) end
function remp(a,b,c,d) print(a,b,c,d) end
function rem(a) end
function float(f) return string.format("%6.2f",f) end
function hex(a) return string.format("0x%02x",a) end
function calc(line) return line % 8 * 1024 + math.floor(line / 64) * 40 + math.floor((line%64) / 8) * 128 +8192 end

emu.unpause() 

function findmouse() 
print("BEGIN") 
for i=1,50 do  
emu.wait(0.25) 
rem(manager:machine():uiinput():find_mouse()) 
x,y,button,target=manager:machine():uiinput():find_mouse()
if target==nil then print ("TARGET=nil") return 
else
if button then 
print("\nBUTTON PRESSED") 
manager:machine().screens[":screen"]:draw_line(0,0,x/target:width()*559,y/target:height()*191,0xffffffff)
boxsize=4
manager:machine().screens[":screen"]:draw_box(x/target:width()*559-boxsize*2,y/target:height()*191-boxsize,x/target:width()*559+boxsize*2,y/target:height()*191+boxsize,0x22ffffff,0xffff0000)
xsize=target:width() 
ysize=target:height() 
textx=math.min(math.floor(x/xsize*560+10),400)
texty=math.min(math.floor(y/ysize*192+10),160)
manager:machine().screens[":screen"]:draw_text(textx,texty,"x="..float(x/xsize*280).." y="..float(y/ysize*192).."\n addr="..hex(calc(math.floor(y/ysize*192))+math.floor(x/xsize*279/7)),0xffffffff,0xffff0000)
emu.pause() 
return 
end 
xsize=target:width() ysize=target:height() 
io.write("\rx="..float(x/xsize*279) ..", y="..float(y/ysize*191) .."  address="..hex(calc(math.floor(y/ysize*191))+math.floor(x/xsize*279/7)).."  ") 
rem("Should it be *191 or *192?")
end
end 
end 
findmouseco=coroutine.create(findmouse) coroutine.resume(findmouseco)


A couple of notes, if you have the debugger paused, it won't work because the emu.wait() won't get fired.

If the target is nil, just click on a couple of windows and try it again.

And you have to emu.unpause() to get everything moving again.


Now to figure out where the shield gauge routine is:
[Linked Image from i.imgur.com]

Last edited by Golden Child; 01/30/19 07:32 PM.