Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
meshuggahtas opened this issue Aug 23, 2017 · 22 comments
Labels
Core: mGBA Game Boy Advance (GBA) core Core: SMSHawk Sega Master System (SMS) / Sega Game Gear (GG) core Core: VirtualBoyee Nintendo Virtual Boy core Enhancement For feature requests or possible improvements re: Sub*Hawk

Comments

@meshuggahtas
Copy link

meshuggahtas commented Aug 23, 2017

@zeromus
Copy link
Contributor

zeromus commented Aug 24, 2017

we know.

@zeromus zeromus closed this as completed Aug 24, 2017
@YoshiRulz YoshiRulz added Enhancement For feature requests or possible improvements Core: NesHawk Nintendo Entertainment System (NES) / Famicom / Famicom Disk System (FDS) core Core: SMSHawk Sega Master System (SMS) / Sega Game Gear (GG) core Core: mGBA Game Boy Advance (GBA) core labels Feb 6, 2019
@YoshiRulz
Copy link
Member

SubNESHawk was fully merged into master at 9696a75.

@YoshiRulz YoshiRulz reopened this Feb 6, 2019
@meshuggahtas
Copy link
Author

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.

@YoshiRulz
Copy link
Member

YoshiRulz commented Feb 6, 2019

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 YoshiRulz added the Core: BSNES Super Nintendo Entertainment System (SNES) / Super Famicom (SFC) / Super Game Boy (SGB) core label Feb 6, 2019
@meshuggahtas
Copy link
Author

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.

@alyosha-tas
Copy link
Contributor

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.

@vadosnaprimer
Copy link
Contributor

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

@zeromus
Copy link
Contributor

zeromus commented Feb 7, 2019

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.

@alyosha-tas
Copy link
Contributor

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

@meshuggahtas
Copy link
Author

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

@zeromus
Copy link
Contributor

zeromus commented Feb 11, 2019

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.

@meshuggahtas
Copy link
Author

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)

@YoshiRulz
Copy link
Member

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 YoshiRulz added the Core: VirtualBoyee Nintendo Virtual Boy core label Feb 12, 2019
@alyosha-tas
Copy link
Contributor

alyosha-tas commented Feb 12, 2019

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
Copy link
Contributor

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.

@meshuggahtas
Copy link
Author

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)?

@alyosha-tas
Copy link
Contributor

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.

@meshuggahtas
Copy link
Author

meshuggahtas commented Feb 19, 2019

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

@adelikat
Copy link
Contributor

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.

@alyosha-tas alyosha-tas removed the Core: NesHawk Nintendo Entertainment System (NES) / Famicom / Famicom Disk System (FDS) core label Nov 11, 2021
@Zimond47

This comment was marked as off-topic.

@zeromus

This comment was marked as off-topic.

@Zimond47

This comment was marked as off-topic.

@Morilli Morilli removed the Core: BSNES Super Nintendo Entertainment System (SNES) / Super Famicom (SFC) / Super Game Boy (SGB) core label Sep 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core: mGBA Game Boy Advance (GBA) core Core: SMSHawk Sega Master System (SMS) / Sega Game Gear (GG) core Core: VirtualBoyee Nintendo Virtual Boy core Enhancement For feature requests or possible improvements re: Sub*Hawk
Projects
None yet
Development

No branches or pull requests

8 participants