BizHawk icon indicating copy to clipboard operation
BizHawk copied to clipboard

Request: Subframe inputs where games poll for input multiple time in a frame

Open meshuggahtas opened this issue 6 years ago • 22 comments

List of platforms I'm specifically looking for: -NES -SMS -GBA

edit: my threads on various forums so far: SMS - http://www.smspower.org/forums/17362-SMSTechnicalQuestionsAndLookingForOddities#105134 VBoy - https://www.planetvb.com/modules/newbb/viewtopic.php?topic_id=7279&forum=1 Lynx - http://atariage.com/forums/topic/288180-lynx-technical-questions-and-looking-for-oddities/ A7800 - http://atariage.com/forums/topic/288181-technical-questions-and-looking-for-oddities/

meshuggahtas avatar Aug 23 '17 18:08 meshuggahtas

we know.

zeromus avatar Aug 24 '17 15:08 zeromus

SubNESHawk was fully merged into master at 9696a7583.

YoshiRulz avatar Feb 06 '19 10:02 YoshiRulz

Totally forgot about this issue. Thanks again for working on it!

My page with relevant informations for sub frame inputs: http://tasvideos.org/MESHUGGAH/ForbiddenTechniques.html#NotPresentInBizhawk231 --> Subframe inputs tab.

In the OP I listed those 3 platforms because of known titles with potential techniques based on subframe level. The GBA one is only mentioned for the ability to subframe reset, so I'm not sure about which GitHub labels you would like to hold/throw away as only SubNESHawk came to materalization.

meshuggahtas avatar Feb 06 '19 10:02 meshuggahtas

If adding a toggle for sub-frame inputs to a core allows a really cool TAS to be made, then that core is missing features. Like SNES, which you linked to, sub-frame input led to Chrono Trigger "save glitch".

If you can find anything on SMS, do link it.

YoshiRulz avatar Feb 06 '19 10:02 YoshiRulz

The SMS one points to the discovery thread. The example is SMS Batman Returns where it might be possible to:

with subframe inputs there would be enough time to decrement the counter in only a couple of frames.

--> skipping the loading screen very fast. SG-1000 Bank Panic might have a similar trick.

(Just noting: this doesn't makes a "really cool TAS")

We (me and Alyosha) don't have knowledge about does it works in real life, at least I don't have consoles but it's on my TODO list to start gathering informations about these techniques from large forums dedicated to those platforms.

meshuggahtas avatar Feb 06 '19 11:02 meshuggahtas

Yeah I would like to have some confirmation that pause button in SMS actually does have the theorized effect on real console before attempting a subframe SMS mode.

As for SNES and GBA, I don't see how subframe mode would be even remotely possible for them.

alyosha-tas avatar Feb 07 '19 00:02 alyosha-tas

SNES allows subframe reset at the very least, which is how that "save glitch" movie was done.

vadosnaprimer avatar Feb 07 '19 04:02 vadosnaprimer

Every console should be allowing subframe input all the time with very rare exceptions. It's only a matter of time before you prove each and every one of them. You may as well assume every console needs subframe input eventually.

zeromus avatar Feb 07 '19 04:02 zeromus

I should have been clearer. I meant I don't see how it would be done with our current cores.

alyosha-tas avatar Feb 07 '19 22:02 alyosha-tas

I'm about to ask all my fancy questions related to platforms on their most active community forums. Mostly writing here because subframes will be asked for each platform and also to let Alyosha know about "news" from me/forums.

NES - we know about subframes Virtual Boy - yes, subframes are might present in games, requires tests https://www.planetvb.com/modules/newbb/viewtopic.php?topic_id=7279&post_id=42256#forumpost42256 SMS - yes, subframes are might present in games, requires tests http://www.smspower.org/forums/17362-SMSTechnicalQuestionsAndLookingForOddities#105137

meshuggahtas avatar Feb 11 '19 15:02 meshuggahtas

subframes will be requested on each platform. you need to be prioritizing, and imagining what bizhawk is going to look like with a subframe variant of every core.

zeromus avatar Feb 11 '19 15:02 zeromus

I'm not sure about priority, it all comes down to:

  • difficulty to implement subframe to a core --> should try most popular platforms with enough TASers and test cases to test it and report it back.

Well imagining is another obstacle.

  • The SubNESHawk styled "every polls as frame counter" is okay, but in the future this needs to be clearer, like lsnes: you can see which frame's which poll you are trying to input
  • Platforms with the ability to press reset (or SMS pause) button on any CPU cycle will require a different kind of inputting. You won't be interested in every single CPU cycle nor it's video frame but you would want to make it as easy as possible to change the number of cycles dependent to another event (after last poll / when total cpu cycles equal with desired number)

meshuggahtas avatar Feb 11 '19 16:02 meshuggahtas

Every core? I'd imagine N64, PSX, and Saturn get the whole controller state at once at the start of the frame. I agree though that an ISubInputPollable should be extracted sooner rather than later. And that raises the question of Virtual Boyee being waterboxed...

YoshiRulz avatar Feb 12 '19 05:02 YoshiRulz

Those systems will likely still need subframe resets for SRAM abuse, even if they do only look for controller input once per frame.

@meshuggahtas : That's interesting discussion on the SMS forums. It seems that subframe pause causing multiple NMIs would not be accurate to implement after all. Thanks for getting that information flowing.

EDIT: It would still be accurate to be able to hit pause every frame though, instead of every other frame as it is now, so that would still need to be done.

And also i would still just really like to see someone mashing the pause button on a master system in real life just to make sure it really really does behave as expected. The SMS forum posts seem to indicate that NMIit is happening at the right time anyway.

alyosha-tas avatar Feb 12 '19 23:02 alyosha-tas

A few more thoughts on this:

In the current approach taken by SubNESHawk, lag frames and vblank edges are equivalent. So counting the actual frame you are on is the same as counting lag frames, which TAStudio already does. So getting TAStudio to report frames in a nice form (1234.1 or similar) should be pretty much doable.

For cores where the state is only available at the frame level (most ported cores) I don't really see how there is a realistic way to implement subframe inputs without rewriting everything. You'd have to have a protocol to send each core a list of inputs valid for that frame. This would mean modifying both the core and BizHawk. Simple trickery like that used in SubNESHawk won't help us here.

It might be beneficial to think of ways to implement just subframe resets where full subframe inputs aren't practical. Just hacking those in there would probably provide most of the likely utility in doing targeted SRAM attacking. Even then though it would probably require a lot of work.

alyosha-tas avatar Feb 17 '19 23:02 alyosha-tas

I guess that the different ways done for subframe inputs/reset outside of extending the core doesn't constitutes a good solution (using lua script or using a debugger)?

meshuggahtas avatar Feb 18 '19 14:02 meshuggahtas

Are there any practical demonstrations of either of those working for BizHawk? I know we have oninputpoll but I'm not sure how complete the implementation is for various cores. I'm not aware of any debugger stuff.

alyosha-tas avatar Feb 18 '19 17:02 alyosha-tas

AFAIK oninputpoll (Lua function) is not implemented in all cores, some cores gives you zeroes constantly. EDIT I originally meant emu.totalexecutedcycles throwing zeroes, not oninputpoll (which is just an evet), sorry.

edit: These Lua scripts are not for BizHawk but I guess they should work (if you modify it, mostly just renaming the functions).

  1. NES SMB3 Lua http://fuzyll.com/files/smb3_glitch/dpcmglitch.lua uses memory.registerexec(0xFF29, after_poll) to write subframe input to 0x0000 In this case, 0x0000 needed because...
0F:FEBE: A001    LDY #$01     ; set controller to index 1 (controller 2)
0F:FEC0: 2012FF  JSR $FF12    ; call $FF12 to poll the controller
0F:FEC3: A500    LDA $0000    ; load byte at $0000 ($FF12 return value) into A
0F:FEC5: 48      PHA          ; push byte in A onto the stack
0F:FEC6: 2012FF  JSR $FF12    ; call $FF12 to poll the controller again
0F:FEC9: 68      PLA          ; pull byte from the stack back into A
0F:FECA: C500    CMP $0000    ; compare $0000 and A (the two poll results)
0F:FECC: D0F5    BNE $FEC3    ; if they don't match, poll again
  1. NES Gimmick lua (based on the previous script) https://drive.google.com/file/d/1lG0P1cOzPNG6qHsD3zWjXeDNkMNEkgZo/view uses memory.registerexec(0xF2EC, after_poll) to write subframe input to 0x00F5, 0x00F6, 0x0010, 0x0011

Regarding using a debugger: I meant as implementing what we would do manually. Here's my high level (as in simple) ideas:

Case A - TASer wants to press button on the next poll within the actual frame

  • Debugger breakpoint on read of input register.
  • If there was an extra polling (breakpoint triggered), somehow feed our subframe input to the core.
  • Continue emulation

Case B - TASer wants to reset at cycle N / PC == $1234

  • Debugger total executed cycles or breakpoint write/read/exec $1234
  • Perform soft reset
  • Continue emulation

meshuggahtas avatar Feb 19 '19 09:02 meshuggahtas

Alyosha, in a debug build you can go to Help -> Core Features and get a breakdown of what is or isn't implemented in a given core. And it can give you a breakdown of any core you have every loaded.

That should help get an idea of what services still need to be implemented on which cores.

adelikat avatar Feb 19 '19 23:02 adelikat

I was trying out Desert Strike on SMSHawk recently and I wasnt able to strafe which is supposed to work by holding down the 2 button. It does work the same way on the Genesis version but not for the MS version. MIght this be also a Subframe issue? That the game is not checking the button more than once per frame and thus does not recognize it as being held down?

Zimond47 avatar Jul 28 '22 16:07 Zimond47

This doesn't make any sense. If the button is held down, the game should detect it eventually, whether it polls 50 times every 1 frame or 1 time every 50 frames.

zeromus avatar Jul 28 '22 17:07 zeromus

Well... I also couldnt find any footage of someone strafing on real hardware so I assume the info that you can strafe might be wrong. Thanks for the clarification.

Zimond47 avatar Jul 29 '22 04:07 Zimond47