Post subject: Lua question
petaQ
He/Him
Joined: 3/8/2018
Posts: 22
Wanna use lua with Bizhawk to create a monitor for animation slowdown in SMS Lemmings. Is there a way to get a count of only the sprites currently on the screen? Looked in the help/functions list, can't find one that would do this.
creaothceann
He/Him
Editor
Joined: 4/7/2005
Posts: 1874
Location: Germany
LUA doesn't have a "count_sprites_on_screen_in_SMS_Lemmings" function. That's very game-specific. Either use the cheat search function to find values that decrease when sprites disappear and increase when new ones appear, or... you'd probably need to disassemble (parts of) the game code.
Amaraticando
It/Its
Editor, Player (159)
Joined: 1/10/2012
Posts: 673
Location: Brazil
Discover the addresses that tell you which sprites exist at the moment. In some games, the address for each sprite is clustered in a continuous region that we might cal sprite table. The first address is slot 0, the second address is slot one and so on... In Super Mario World, such a function would look like this (for lsnes: it draws the total number in the top left)
Language: lua

-- constants of the game -- this, you should discover with the RAM search local sprite_status = 0x14c8 local sprite_x_offscreen = 0x15a0 local sprite_y_offscreen = 0x186c local total_sprites = 12 local function sprite_exits(slot) return memory.readbyte('WRAM', sprite_status + slot) ~= 0 end local function is_onscreen(slot) local xoff = memory.readbyte('WRAM', sprite_x_offscreen + slot) == 0 local yoff = memory.readbyte('WRAM', sprite_y_offscreen + slot) == 0 return xoff and yoff end local function main() local count = 0 for slot = 0, total_sprites - 1 do if sprite_exits(slot) and is_onscreen(slot) then count = count + 1 end end gui.text(0, 0, count, 'white', 'black') end -- call 'main' each time the emulator repaints the screen callback.register('paint', main) -- repaint now gui.repaint()
nymx
He/Him
Editor, Judge, Expert player (2228)
Joined: 11/14/2014
Posts: 927
Location: South Pole, True Land Down Under
I've been looking through the onsite documentation and I can't find any bizhawk/lua functionality to turn off the display via my lua script. My goal is to speed up emulation until I reach my desired outcome. Any ideas on how I can do this?
I recently discovered that if you haven't reached a level of frustration with TASing any game, then you haven't done your due diligence. ---- SOYZA: Are you playing a game? NYMX: I'm not playing a game, I'm TASing. SOYZA: Oh...so its not a game...Its for real? ---- Anybody got a Quantum computer I can borrow for 20 minutes? Nevermind...eien's 64 core machine will do. :) ---- BOTing will be the end of all games. --NYMX
adelikat
He/Him
Emulator Coder, Site Developer, Site Owner, Expert player (3570)
Joined: 11/3/2004
Posts: 4754
Location: Tennessee
the new release will have "invisible emulation" as an option. Current release does not unfortunately. However, I wouldn't expect it to give you any meaningful speedups. Almost all of the speed cost in cores is the emulating of the hardware, not the displaying it on the screen.
It's hard to look this good. My TAS projects
nymx
He/Him
Editor, Judge, Expert player (2228)
Joined: 11/14/2014
Posts: 927
Location: South Pole, True Land Down Under
Ah...great to hear. I appreciate the upcoming feature! :)
I recently discovered that if you haven't reached a level of frustration with TASing any game, then you haven't done your due diligence. ---- SOYZA: Are you playing a game? NYMX: I'm not playing a game, I'm TASing. SOYZA: Oh...so its not a game...Its for real? ---- Anybody got a Quantum computer I can borrow for 20 minutes? Nevermind...eien's 64 core machine will do. :) ---- BOTing will be the end of all games. --NYMX