BizHawk Emulator Development


Editor, Experienced Forum User, Published Author (2799)
Joined: 5/15/2007
Posts: 3821
Location: Germany
Gameboy TASer of 2015NES TAS of 2013Gameboy TASer of 2011Gameboy TASer of 2010
I put everything in the same folder, but this doesn't work. It only loads the gb ROM.
EmuHawk --lua="myscript.lua" "dummy.gb"
Thanks so far!
Pokota
He/Him
Experienced Forum User
Joined: 2/5/2014
Posts: 776
does it work if you give the absolute path to the lua script?
Adventures in Lua When did I get a vest?
Editor, Experienced Forum User, Published Author (2799)
Joined: 5/15/2007
Posts: 3821
Location: Germany
Gameboy TASer of 2015NES TAS of 2013Gameboy TASer of 2011Gameboy TASer of 2010
Editor, Experienced Forum User, Published Author (2799)
Joined: 5/15/2007
Posts: 3821
Location: Germany
Gameboy TASer of 2015NES TAS of 2013Gameboy TASer of 2011Gameboy TASer of 2010
It seems that if a luascript crashes, file handles are not automatically closed until you close the lua console. Example: Open Bizhawk 2.2, open luascript which opens a file but runs into an error. Open Bizhawk 1.2.0, open same luascript. You get this outputted in 1.2.0's console:
LuaInterface.LuaScriptException: [string "main"]:1567: bad argument #1 to 'output' (config.cfg: Permission denied)
Also, as a very small observation, probably unrelated to the "file permission" issue, when this message appears, the console will still show the green "play" triangle and say that 1 script is running. When you click anywhere, it updates to the red rectangle and 0 scripts running. Basicly what I observe is, if a luascript crashes, some stuff is not taken care of: - console behaves as if script is still running (green triangle etc.) - Bizhawk doesn't clear file handles until the console is closed
Editor, Experienced Forum User, Published Author (2799)
Joined: 5/15/2007
Posts: 3821
Location: Germany
Gameboy TASer of 2015NES TAS of 2013Gameboy TASer of 2011Gameboy TASer of 2010
I ran into a different, more serious issue with files. Basicly I have this lua (which is heavily trimmed down from the original I was using)
Language: Lua

function GuiLoadSettings() settings = io.open("config.cfg","r") if settings~=nil then for line in settings:lines() do end settings:close() end end GuiLoadSettings() while true do print("hello world") emu.frameadvance() end
and a .cfg file with this content (There is 1 empty line before and after).


bool BoolAllowEdits : true
bool BoolBattle : false

If I run the lua in 1.12.0 or 1.13.0, it outputs:

hello world
hello world
hello world
and if I run it in 2.1.1. or 2.2, it outputs:

NLua.Exceptions.LuaScriptException: bool BoolBattle : false 
I'm not sure if it's a bug with Bizhawk or bad code usage on my part. Please help :) This is currently the only things stopping my Mario & Luigi script from running in 2.x. If you comment the for line in settings:lines() do bit out, it runs fine. Opened issue: https://github.com/TASVideos/BizHawk/issues/995
Editor, Experienced Forum User, Published Author (2799)
Joined: 5/15/2007
Posts: 3821
Location: Germany
Gameboy TASer of 2015NES TAS of 2013Gameboy TASer of 2011Gameboy TASer of 2010
MUGG wrote:
I'm trying to code a game in Bizhawk in lua and it draws images on the screen. It works perfectly in 1.12.0 but in 1.13.0 I get all sorts of random errors, such as "file not found" and then it crashes. It's unusable. (...) Opened issue here.
It looks like it isn't related to gui.drawImage(). I tried running my Mario & Luigi script in 1.13.0 and it breaks after a short time even when I disable all instances of gui.drawImage().
Masterjun
He/Him
Experienced Forum User, Published Author, Site Developer (2245)
Joined: 10/12/2010
Posts: 1137
Location: Germany
Exotic platforms TAS of 2020Speedy TAS of 2018PC TAS of 2018Glitchy TAS of 2015TASer of 2014SNES TASer of 2014TAS of 2014SNES TAS of 2014Funny TAS of 2014Glitchy TAS of 2014TASer of 2013SNES TASer of 2013NES TAS of 2013SNES TAS of 2012Funny TAS of 2012
Strange error, maybe you're doing a lot and are running out of memory? Lua doesn't have a automatic garbage collector so did you try running collectgarbage() every now and then? Looks like input.getmouse() is a problem in 1.13.0. Do you use that?
Warning: Might glitch to credits I will finish this ACE soon as possible (or will I?)
Editor, Experienced Forum User, Published Author (2799)
Joined: 5/15/2007
Posts: 3821
Location: Germany
Gameboy TASer of 2015NES TAS of 2013Gameboy TASer of 2011Gameboy TASer of 2010
Masterjun wrote:
Looks like input.getmouse() is a problem in 1.13.0. Do you use that?
Yes I do. I tried a very simple script (see below) and it crashes. That seems to be the problem. I will update the github issue.
Language: Lua

local mousex local mousey while true do mousex = input.getmouse().X mousey = input.getmouse().Y emu.frameadvance() end
Post subject: NESHawks Audio
Experienced Forum User
Joined: 11/8/2016
Posts: 9
Hello BizHawk developers, I just wanted to ask if you guys can please turn up the overall volume on the NESHawk's Emulator Core. I love the Emulator, it is great. It is just that the overall Audio volume is low, I turn up the volume on my computer to the max for my head phones and it is still kinda low. Thank you for your time.
Post subject: Re: NESHawks Audio
Alyosha
He/Him
Editor, Experienced Forum User, Published Author (3927)
Joined: 11/30/2014
Posts: 2388
Location: US
NES TASer of 2015
FadeToBacon16 wrote:
Hello BizHawk developers, I just wanted to ask if you guys can please turn up the overall volume on the NESHawk's Emulator Core. I love the Emulator, it is great. It is just that the overall Audio volume is low, I turn up the volume on my computer to the max for my head phones and it is still kinda low. Thank you for your time.
Hi, the sound seems normal to me. Check the following settings and make sure they aren't turned down: Config -> sound make sure volume is turned all the way up. Does QuickNES Sound soft as well or only NESHawk? How about other cores (i.e. SNES) ?
Experienced Forum User
Joined: 11/8/2016
Posts: 9
@Alyosha The BizHawk's volume is at 100. The QuickNes audio is louder than NESHawk, it is just that the games that I play normally automatically uses the NESHawk like for example Castlevania 3 and I'm Kid Dracula, so I stick with NESHawk's core. I wasn't saying there was something wrong with the audio of NESHawk, I was just asking if you guys can please turn up the overall volume of NESHawk (if possible) Sorry for the misunderstanding and thank you for your time.
Sonia
She/Her
Experienced Forum User
Joined: 12/6/2013
Posts: 428
Location: Brazil
FadeToBacon16 is right. Neshawk's volume is definitely lower. Just compare any game that's compatible with both cores, and you'll notice that QuickNES' volume is higher. Maybe QuickNES being louder has to do with inaccuracy? I'm not really sure.
Alyosha
He/Him
Editor, Experienced Forum User, Published Author (3927)
Joined: 11/30/2014
Posts: 2388
Location: US
NES TASer of 2015
Ok, I added a volume slider under NES->Sound Channels. Minimum setting (1) should match current NESHawk uadio. Maximum setting (10) should be 3x louder. Please try the dev build and let me know if it's enough.
Experienced Forum User
Joined: 11/8/2016
Posts: 9
@Alyosha It sounds best at 1 (NESHawks default Audio Level) So I was wrong about raising the audio level. I have a question, is it possible to force the NESHawk audio to play at a Higher Quality with a Sample rate of 44100 Hz like how the Sega Emulator Kega Fusion 3.64 does it? Thank You for your time.
Editor, Experienced Forum User, Published Author (2799)
Joined: 5/15/2007
Posts: 3821
Location: Germany
Gameboy TASer of 2015NES TAS of 2013Gameboy TASer of 2011Gameboy TASer of 2010
That one audio bug in Mario & Luigi I posted a while back is still present, in version 2.2, for your information.
Alyosha
He/Him
Editor, Experienced Forum User, Published Author (3927)
Joined: 11/30/2014
Posts: 2388
Location: US
NES TASer of 2015
FadeToBacon16 wrote:
@Alyosha It sounds best at 1 (NESHawks default Audio Level) So I was wrong about raising the audio level. I have a question, is it possible to force the NESHawk audio to play at a Higher Quality with a Sample rate of 44100 Hz like how the Sega Emulator Kega Fusion 3.64 does it? Thank You for your time.
What aspect of the sound is low quality? Can you provide an example game that sounds better in a different emulator? I don't think I can just increase the sample rate, but if you can provide a concrete example maybe there is something I can fix.
Experienced Forum User
Joined: 7/17/2012
Posts: 469
Location: Switzerland
master 7c1522cf Just load a rom. Glide64mk2 video plugin.
My Citra 3DS rerecording movie files test repositery: https://cutt.ly/vdM0jzl Youtube playlist "Citra Tests": https://cutt.ly/AdM0wg9 http://www.youtube.com/user/phoenix1291
Experienced Forum User
Joined: 3/26/2015
Posts: 3
Location: Quebec, Canada
It seems that creating a savestates currently locks the emulation for a few milliseconds due to the code running in the emulation thread. This creates a noticeable hitch during gameplay if the savestate size is too big. Wrapping the method call in another thread causes corrupted savestates due to the memory changing while the savestate is being created. From my understanding of it, most of the hitch is caused while the savestate file is written on disk. Is there a quick solution for this issue? Note: I am still working with the 1.11.9 source (haven't upgraded yet) but it seems that this still happens in the current 2.x when doing an ALT+F1 during gameplay.
creaothceann
He/Him
Editor, Experienced Forum User
Joined: 4/7/2005
Posts: 1874
Location: Germany
ircluzar wrote:
From my understanding of it, most of the hitch is caused while the savestate file is written on disk. Is there a quick solution for this issue?
Copy the data to a buffer in RAM, then write the savestate from there using another thread?
Experienced Forum User
Joined: 3/26/2015
Posts: 3
Location: Quebec, Canada
creaothceann wrote:
Copy the data to a buffer in RAM, then write the savestate from there using another thread?
That was my plan in case I don't get any other suggestions. I'm trying to edit as little BizHawk code as possible but I guess that if i don't have any other choice, that's what i'll have to do. Edit: Since my workaround is most likely going to be hacky, would it be possible that we get a proper implementation of non-hitching savestates in a future version?
Experienced Forum User, Published Author, Senior Judge, Senior Publisher (1423)
Joined: 4/17/2010
Posts: 10321
Location: RU
NES TAS of 2011
It sounds like a cool feature to me, make a ticket and see what zeromus says.
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting. If TASing is meta-play, TASVideos Movie Rules are meta-meta-play!
Editor, Emulator Coder, Experienced Forum User
Joined: 8/7/2008
Posts: 1156
We do not do this because we don't want something so important to be untrustworthy. When the client unfreezes, your savestate is complete. The hitching is a purposeful signal that it is safe to proceed. Confirm that you're not testing a core which is doing unnecessary buffer copies; several of them are, currently. I doubt the disk IO is the biggest use of time. That should be instant. Confirm inside a core with a large savestate by returning a preallocated array full of whitenoise instead of doing deeper work to create useful savestate data. You will see that it's now basically instant. After all that proof that it's a waste of time, if anyone adds this "feature" to make gamers think they're having more fun until less reliable software malfunctions and ruins their day, it *must* default to OFF, and be surrounded by a warning that it is an insane choice to change that option. It could be put into the rewind&states configuration, or config>advanced. In the meantime, try changing the rewind&states configuration backup and screenshot options.
creaothceann
He/Him
Editor, Experienced Forum User
Joined: 4/7/2005
Posts: 1874
Location: Germany
zeromus wrote:
We do not do this because we don't want something so important to be untrustworthy. When the client unfreezes, your savestate is complete. The hitching is a purposeful signal that it is safe to proceed.
Isn't that the purpose of a status message? The program can't always guarantee it's safe to proceed anyway because the hardware can't always be trusted: https://stackoverflow.com/questions/28270491/how-to-make-sure-data-is-flushed-to-hdd-not-buffered-on-file-io-writefile https://blogs.msdn.microsoft.com/oldnewthing/20100909-00/?p=12913
Editor, Emulator Coder, Experienced Forum User
Joined: 8/7/2008
Posts: 1156
We make standard issue assurances, comparable to 99% of software. The purpose of the status message is to confirm that youve hit the key in case the savestate is instant. In case it wasn't clear, this is not a negotiable subject. We will not be the vanguard of unreliable sloshy behavior r&d innovation for the thrill of gamers. That is the _opposite_ of our mission statement.
Experienced Forum User
Joined: 3/26/2015
Posts: 3
Location: Quebec, Canada
zeromus wrote:
In case it wasn't clear, this is not a negotiable subject. We will not be the vanguard of unreliable sloshy behavior r&d innovation for the thrill of gamers. That is the _opposite_ of our mission statement.
I understand perfectly your point of view towards the integrity of savestate data. I was simply looking to know if anyone knew a way to solve my issue or if it could be considered as an optional feature for a future version. This answers my questions. Thank you for the response.