As the
Consolation Team Contest didn't quite work out the way I thought it would, here I am reviving this thread for one last push.
By the way, laponge36 had submitted this for week 2, which I sadly can't view with my problems (encode requested):
http://dehacked.2y.net/microstorage.php/info/1572741131/Sorcerer%27s%20Maze%20241356.pjm
If the suggested route for the CTC looks like a bad choice, there's no CTC anymore, so if you do think it's time to start at World 4, now might be a good time to do so.
Though, it would appear I neglected to post my lua scripts then. I'll fix that mistake now...
This one just paints a tiny box on each ball. Mousing over the box will provide basic stats on the angle and speed of the ball, though the OldScratchStuff generally dumps more addresses:
Download SM.luaLanguage: lua
local R1u, R1s= memory.readbyte , memory.readbytesigned
local R2u, R2s= memory.readword , memory.readwordsigned
local R4u, R4s= memory.readdword, memory.readdwordsigned
local keys, lastkeys= input.get(),input.get()
--*****************************************************************************
local function UpdateKeys() lastkeys= keys; keys= input.get() end
local function Press(k) return keys[k] and (not lastkeys[k]) end
--*****************************************************************************
local function Limits(v,l,h) return math.max(math.min(v,h),l) end
local function Within(v,l,h) return (v >= l) and (v <= h) end
local function HexStr(v) return string.upper(string.format("%x",v)) end
--*****************************************************************************
--*****************************************************************************
local function GuiTextRight(x,y,t,c)
--*****************************************************************************
c= c or -1
x= x - #tostring(t)*4
gui.text(x,y,t,c)
end
local red= -0x00FFFF01 --Bypass some bug I call "80Red"
gui.opacity(0.75)
local BallStart= 0x00115BE4
--*****************************************************************************
local function Fn()
--*****************************************************************************
UpdateKeys()
-- for j= 0, 33 do
-- GuiTextRight(66, 2+7*j,R2s(0x001137A4+2*j),-1)
-- end
local MouseCount= 0
for i= 0, 99 do
local addr= BallStart + 0xAC*i
if R1u(addr) ~= 0 then
local x,y= R2u(addr+0x74),R2u(addr+0x76)
gui.box(x-1,y-1,x+1,y+1,0x00FF0080,0x00FF00FF)
if Within(keys.xmouse,x-1,x+1) and Within(keys.ymouse,y-1,y+1) then
gui.line(x,y, x+R4s(addr+0x2C)/10 , y+R4s(addr+0x30)/10 , red)
GuiTextRight(20, 2+20*MouseCount, R4s(addr+0x38)) --Position
GuiTextRight(20,10+20*MouseCount, R4s(addr+0x3C))
GuiTextRight(40, 2+20*MouseCount, R4s(addr+0x2C)) --Velocity
GuiTextRight(40,10+20*MouseCount, R4s(addr+0x30))
GuiTextRight(60, 2+20*MouseCount, R2u(addr+0x22)) --Speed/Angle
GuiTextRight(60,10+20*MouseCount, R2u(addr+0x20))
MouseCount= MouseCount+1
end
end -- If ball exists
end -- For loop
end -- Function
gui.register(Fn)
--*****************************************************************************
local function OldScratchStuff()
--*****************************************************************************
UpdateKeys()
for j= 0, 23 do
GuiTextRight(9,2+7*j,HexStr((j+0x00)*2),0x00FF00FF)
end
for j= 0, 23 do
GuiTextRight(83,2+7*j,HexStr(R2u(0x00119F0C+(j+0x00)*2)))
end
for i= 0, 10 do
local addr= BallStart + 0xAC*i
if R2u(addr) ~= 0 then
for j= 0, 23 do
GuiTextRight(33+23*i, 2+7*j,R2s(addr+2*(j+0x00)))
end
-- if bit.band(R2u(addr+2),4) == 0 then
local Angle= R2u(addr+0x9A) / 2048 * math.pi
local Speed= R2u(addr+0x98)
GuiTextRight(33+23*i, 180, math.floor(Speed*math.sin(Angle)))
GuiTextRight(33+23*i, 190, math.floor(Speed*math.cos(Angle)))
-- end
end
end
end
--gui.register(OldScratchStuff)
--*****************************************************************************
while true do -- I did observe a glitch with joypad.set without this loop.
--*****************************************************************************
emu.frameadvance()
end
And this one merely logs certain events (using the Output Console via print). Might not be bad to take a look:
Download SM_logger.luaLanguage: lua
local OutputFn= print -- print, or to a file?
local R1u, R1s= memory.readbyte , memory.readbytesigned
local R2u, R2s= memory.readword , memory.readwordsigned
local R4u, R4s= memory.readdword, memory.readdwordsigned
local keys, lastkeys= input.get(),input.get()
--*****************************************************************************
local function UpdateKeys() lastkeys= keys; keys= input.get() end
local function Press(k) return keys[k] and (not lastkeys[k]) end
--*****************************************************************************
local function Limits(v,l,h) return math.max(math.min(v,h),l) end
local function Within(v,l,h) return (v >= l) and (v <= h) end
local function HexStr(v) return string.upper(string.format("%x",v)) end
--*****************************************************************************
--*****************************************************************************
local function GuiTextRight(x,y,t,c)
--*****************************************************************************
c= c or -1
x= x - #tostring(t)*4
gui.text(x,y,t,c)
end
local red= -0x00DFFF01 --Bypass some bug I call "80Red"
local BallArray= {};
for i= 0, 99 do BallArray[i]= {exist= false,st=0} end
--*****************************************************************************
local function RecordBall(ball, addr)
--*****************************************************************************
ball.exist= (R2u(addr ) ~= 0)
ball.st= R2u(addr+0x02)
end
--*****************************************************************************
local function EdgeCheck(case1, case2, msg1, msg2)
--*****************************************************************************
if case1 and (not case2) then OutputFn(msg1)
elseif (not case1) and case2 then OutputFn(msg2) end
end
--*****************************************************************************
local function MessageLog(b, ball, addr)
--*****************************************************************************
--Existance
local temp= R2u(addr)
EdgeCheck(temp ~= 0 , ball.exist,
movie.framecount() .. " + Ball #" .. b .. " spawned at " .. R4u(addr+0x14) .. " " .. R4u(addr+0x10) .. " - s" .. R2u(addr+0x22) .. " a" .. R2u(addr+0x20),
movie.framecount() .. " - Ball #" .. b .. " deleted."
)
if (temp == 0) then return end -- Uh, it doesn't exist. Stop messages.
--Status
temp= R2u(addr+2)
EdgeCheck(bit.band(temp,1) ~= 0, bit.band(ball.st,1) ~= 0,
movie.framecount() .. " #" .. b .. " hit ceiling",
movie.framecount() .. " #" .. b .. " hit paddle, (pad x" .. R4u(0x001137B4) .. ") - s" .. R2u(addr+0x22) .. " a" .. R2u(addr+0x20)
)
EdgeCheck(bit.band(temp,4) ~= 0, bit.band(ball.st,4) ~= 0,
movie.framecount() .. " #" .. b .. " released from paddle.",
movie.framecount() .. " #" .. b .. " is stuck to paddle."
)
end
--*****************************************************************************
local function HandleBalls()
--*****************************************************************************
for b= 0, 99 do
local ball= BallArray[b]
local addr= 0x00115BE4 + 0xAC*b
MessageLog(b, ball, addr)
RecordBall(ball, addr)
end
end
emu.registerafter(HandleBalls)
--*****************************************************************************
while true do -- I did observe a glitch with joypad.set without this loop.
--*****************************************************************************
emu.frameadvance()
end
And these are my current notes on memory addresses:
0x0011322E - Blocks left
0x0010B030 - Player Control
00115BE4 [size=0xAC][count=100] Ball stuff
+00,2x Does ball exist? Some sort of identifier?
+02,2x Bit-packed:
0x0001 - Allowed to hit paddle? 0 = No (still going up from paddle hit) 1 = Yes
0x0004 - Released from paddle? 0 = Stuck to paddle 1 = Flying free
+04,2? Ball power-up (giant, fire)
+06,2s Angle (precise to 4096)
+08,2? Fire ball related.
+0A,2s Is it fire ball? -1 = No 0 = Yes
+0C,2? Giant ball related.
+0E
+10,4? X-pos
+14,4? Y-pos
+18
+1A
+1C
+1E
+20,2s Angle (2)
+22,2u Speed
+24,4? X-pos (2)
+28,4? Y-pos (2)
+2C,4s X-vel
+30,4s Y-vel
+34,2s Angle (3)
+36,2u Speed (2)
+38,4? X-pos (3)
+3C,4? Y-pos (3)
+40
+42
+44
+46
+48,4? X-pos (4, halfstep?)
+4C,4? Y-pos (4, halfstep?)
+50,4u X-vel, absolute value?
+54,4u Y-vel, absolute value?
+58
+5A
+5C
+5E
+60
+62
+64
+66
+68
+6A
+6C
+6E
+70
+72
+74,2u X-pixel
+76,2u Y-pixel
+78,2u X-pixel: Trail1
+7A,2u Y-pixel: Trail1
+7C,2u X-pixel: Trail2
+7E,2u Y-pixel: Trail2
+80,2u X-pixel: Trail3
+82,2u Y-pixel: Trail3
+84,2u X-pixel: Trail4
+86,2u Y-pixel: Trail4
+88,2u X-pixel: Trail5
+8A,2u Y-pixel: Trail5
+8C,2u X-pixel: Trail6
+8E,2u Y-pixel: Trail6
+90,2u X-pixel: Trail7
+92,2u Y-pixel: Trail7
+94,2u X-pixel: Trail8
+96,2u Y-pixel: Trail8
+98,2u Speed (used only for sticky ball or pre-launch)
+9A,2s Angle (used only for sticky ball or pre-launch)
+9C,2u Timer for sticky ball (or pre-launch)
+9E,2s Countdown timer?
+A0,2? Related to ball speed? Incremented by timer at +9E
+A2,2x Which wall was last hit?
+A4
+A6
+A8
+AA
edit: Oh, my post in the CTC is more informative... Copying that instead
I'd love to work on this myself, but the fact I can't make lapogne36's run sync here, but DarkKobold can on his computer, kind of scares me away, probably due to the fact I don't believe I can produce a movie that will sync on anyone else's machine.
Regardless, this TAS does have my support. If there's anything you want done in script form, I will attempt to work one up. I just need a request, the more specific the better, or else I'd just be aimlessly scripting around.