I'm still not sure about the variable types returned by the vdp functions, but I've at least found why your code for the pink background didn't work; we weren't manipulating the correct palette line.
while true do
-- Color zero layer to pink
p, t=vdp.readpalette(3,1)
c=pal.getcolor(t[1],1)
c.R=255
c.G=0
c.B=255
c.A=255
pal.setcolor(t[1],1,c)
vdp.writepalette(3,t[1])
emu.frameadvance()
end
Since I'm using the game's built-in Debug mode to move around, the rest of your script isn't as useful to me, especially since by moving Sonic around, you still have to deal with all the collisions. From what little I've found on the subject, the first Sonic game doesn't seem to have camera coordinates that are separate from Sonic's position, unlike the other Genesis games. At least I hope so...
I'm still trying to determine if there's a timer that controls all the moving objects like in the Sonic Advance series. I've found several variables that act like counters but freezing them doesn't seem to affect platforms so far.
By the way feos, thanks for selling Gens-Rerecording to me! Even though I'm a bit angry that it renders the colors a bit differently than the old Gens (which might necessitates me to re-do some maps that are already done), the simple fact that it renders everything in 32 bits colors instead of forcing the desktop in 16 bits colors means that I don't have to exit the emulator everything I want to actually paste a screenshot in my paint program which is a big time saver!