Thanks RB,

Mame is super addictive and fun. I figure something new out every day. It's like a learning lab for old systems. I was struggling so hard trying to get the tms9918 to do something interesting with applesoft and now I've discovered lua is 300x faster and easier. I wish I'd had this back in the days of the apple 2.

I remember reading about the SuperSprite / Arcade Board in Creative Computing back in 1984 and being fascinated with the concept. Now I finally get a chance to actually give it a try.

BTW, thanks for putting in the ssprite stuff in for 0.190.


My discovery for today: how to roll your own dispatch function in lua. I'd make a mistake in a lua function that I called emu.register_frame() on and it would run away happily typing garbage in the console forever until you killed it (and your whole mame session) with CTRL+C.


Once you get a runaway, you can't see what you're typing at all with all of the output clogging the terminal.
So if you get in trouble, just type "cld()" and hit enter and that clears the dispatch_list.
Or if you like to type, type "dispatch_list = {}"



Code

dispatch_list = { }


function frame_dispatcher()
for index,my_func in pairs(dispatch_list) do  my_func() end
end


function print_hello() print("hello") end
function print_there() print("there") end
function print_howareyou() print("how are you") end

function dispatch_list_remove(a_func)
for my_index,my_func in pairs(dispatch_list) do if my_func == a_func then table.remove(dispatch_list,my_index) end end
end

function print_dispatch_list() for my_index,my_func in pairs(dispatch_list) do print(my_func) end end


table.insert(dispatch_list,print_hello) 
table.insert(dispatch_list,print_there) 
table.insert(dispatch_list,print_howareyou)


frame_dispatcher()
print_dispatch_list()

dispatch_list_remove(print_there)

frame_dispatcher()

print_dispatch_list()


function cld()
dispatch_list = {}
end


-- emu.register_frame(frame_dispatcher);
print("type cld(); to stop a runaway dispatch");
print("copy the next line and paste to execute to add our frame dispatcher:");
print("emu.register_frame(frame_dispatcher);");