FCEUX lua script for auto-splits, automatically starting timer, xpos on 4-2
7 years ago
United States

Hi all. I wrote this speedrunning companion script for SMB1 running on FCEUX.

https://raw.githubusercontent.com/Hubcapp/smb1-timer-splits-xpos/master/smb1_timer_splits_xpos.lua

Let me know if there are any bugs.

If you're using Windows, these keyboard toggles may or may not work. If you're on Linux or macOS they WON'T work (as of FCEUX release 2.2.3, there is no keyboard input accessible via lua):

¤ Press ] to toggle showing the offset between your current run time and your PB run time (in framerules)

¤ Press F4 to toggle a framerule counter at the bottom left of the screen

¤ Press F6 to toggle displaying splits, PB offsets, and time spent on the last level

¤ Press F8 to toggle displaying how many pixels Mario is from the left side of the screen on World 4-2

¤ Press F9 to toggle displaying your total framerule offset (useful if you are consistent enough to know how to react to enemies depending on what framerule you're on)

On Linux and macOS, you may edit the source code to toggle these variables. They're all up at the top with comments.

Edited by the author 7 years ago
United States

Nice work. I've modded blubblers timer to autosplit too (http://pastebin.com/zxqkXu1g) but I'm not much of a coder.

One thing on the splits: For whatever reason, looking at when 0x075F and 0x075C/0x0760 change doesn't work when using a warp zone. When you hit a pipe in a warp zone, 0x075F and 0x075C/0x0760 change immediately when you hit the pipe. However, the frame rule is factored in sometime after that when the lives screen is displayed. The only way I could get it to work was to see when 0x075F or 0x075C changed then when 0x0772 = 2. This ends up splitting right after the lives screen.

The mods might need to weigh in on the legality of using the 4-2 xpos display during actual runs. It may be considered too much of a "tool assistance" although I think everyone is just doing a 3-bump 4-2 at this point anyway.

United States

Thanks for the insight on the 0x0772 = 2 requirement, I'll add that into the check.

Regarding legality of xpos display on 4-2, I can understand the "it's tool assistance" argument on that. If you normally go for the 3-bump and see it's 132, you'll go for the 2-bump, leading to more fast 4-2 times. But I feel like also it's kind of a tool assisted speedrun already with splits. Knowing what framerule you're on lets you manipulate the AI. So maybe xpos display is okay. I'm fine either way.

India

Everything is working fine except when you are using save states it is showing wrong time. and why you are using state variable to check if player's game over or not when you already have lives variable (0x075A) you can just check if value is zero means game is over..

Edited by the author 7 years ago
United States

Timer works fine with savestates for me (goes back to time when you saved the state). Doesn't matter if we detect game over with state variable or lives variable. The lives actually go to 255 (lives variable in lua = 256 b/c I add 1) when you game over. I'm guessing you can't actually get 255 lives in normal game play, but I'm not sure, so I just use the state variable.

When you say "everything is working fine" I hope that means the keyboard toggles work, so that's nice.

Edited by the author 7 years ago
India

Yes keyboard toggles works fine . And yes i guess you cannot take 255 lives and its 1Byte unsigned so 255+1 = Overflowing of data goes next to lowest number possible thats 0 . And you should also consider adding this feature, comparing our current spilts with our PB and it should say how many framerules we are ahead or behind from our PB .

United States

Thank you for this! very very clever :)

United States

I updated the script with support for personal bests and automatic framerule offset detection.

United States

@Hubcapp Awesome! I will be looking forward to It.

United States

@sullyrox It happened already. :P Code in the first post's link is automatically updated to latest. I can't think of any other features the script is missing, except for possibly outputting splits to a txt file for external program to render. However most people are using the livesplit plugin or just footpedals, and I don't know what format livesplit uses to read in from txt file, if that's even a feature, and I wouldn't use it personally. The splits at the top left are designed with defaults to not block any essential game play.

The script may have a problem with the starting condition. I posted about it in the SMB1 discord channel, but no one responded. I need RTA timed fm2 movies in order to debug it. Or, if anyone knows how to convert the times on TASvideos.org to RTA that would help too. Here's my post from discord:

Hey all. Working on a new speedrunning companion script for FCEUX. Unsure that I'm correctly detecting the starting frame. Send me your RTA timed fm2 movies so I can figure it out, please. Script available here https://www.speedrun.com/smb1/thread/0cnds

current condition is if startFrame == -1 and world == 1 and level == 1 and gameTimer == 400 then startFrame = movie.framecount(); end;

which I suspect is not correct because startFrame can be a non-framerule-multiple of other startFrames. I may have to add "and memory.readbyte(0x0772) == 2" to the condition like I did for detecting the other splits, but I really just need more RTA timed movies so that I can make sure it's working properly

Germany

4-2 xpos display: Either it helps and it should be banned or it doesn't help and you shouldn't use it. Either way don't use it on runs.

frame-timed fm2s: the TAS is 4:54.03 and my any% pbs have fm2s too

detecting split/start: I used Mario's facing direction for a script I made in the past (http://pastebin.com/a25nBnUc). 0x0033 is 0 until the first left/right input is registered, so it was very easy to detect start and level changes this way. Although it doesn't work, when someone doesn't hold right at the start of every level.

United States

4-2 xpos display: I think it does help people who would normally always 3-bump go for 2-bump if able to, so if you consider runs with xpos display invalid for submission, then I can put a disclaimer saying as much when it's enabled.

Fm2s: This script correctly times the TAS, but I feel like it might be coincidence. All files I found here http://tasvideos.org/userfiles/game/1 are in bk2 format for BizHawk or don't have RTA times on them. BizHawk is not a Linux compatible program, and doesn't work without Direct3D support which is unusably buggy in VirtualBox at this time, so I can't run it.

If you could link me to some FM2s, or know how to convert BK2 to FM2 or know how to convert times on the Walkathon, Warpless, or Coins movies to RTA times, any of those would let me debug these times.

detecting split/start: I'll try using that memory address, thanks. Still need FM2s.

Germany

I should have clarified any% runs. This is 4:59.80 for example: http://dehacked.2y.net/microstorage.php/info/860650141/SMB-1229.fm2 All my other any% pbs have fm2s linked in the youtube description too.

United States

I think it'll time anything that starts frame 196 correctly. I guess that's all the FM2s you make and all the FM2s on tasvideos.org. I don't know about other starting frames.

Alaska, USA

is there any way this could get ported to bizhawk (neshawk core)?

To be clear, is use of the autosplitter allowed in runs? It seems that it would be useful in e.g. warpless runs. So by the logic of the post about xpos i_o_l made above, I would think it would not be allowed.

But I wanted to verify this, in case it's different when you're only keeping track of time rather than exposing an internal program variable. After all, I think almost every runner uses some splitter, and you could view manual splitters as a useful tool as well.

Ontario, Canada

Auto splitter is allowed but currently xpos has to be off.

Thanks for the info, 6regory.

Ukraine

How to use this script?

dc likes this
Venezuela

I dont know how to use the scripts

Game stats
Followers
7,783
Runs
8,790
Players
1,781
Latest news
Requirements for High-Level Any% Runs

Any% (NTSC) runs below 4:57.000 must now fulfill additional requirements in order to be verified.

  • The run's full session must be included in the submission description.
  • For emulator runs below 4:57.000, some form of input display must be visible for the duration of the run. A hand-cam or input
3 months ago