# NES hack for equal pieces?

Thread in 'Competition' started by wasmachstdugern, 28 Aug 2013.

1. ### wasmachstdugern

i believe mikewiz mentioned in another thread that it was possible to hack the NES to make it deliver the same set of pieces for both players on two machines. is this true, and if so how is it done? is it labor intensive?

2. ### Kitaru

Yes kind of sort of to varying degrees depending on how you want to go about it. The common theme amongst all of them would be using a PowerPak or some other method of supplying cartridge with modified software, and then the rest of the details would be what you want to go about doing in programming land. Labor intensive? Again, varying degrees -- it ranges from "not really but you have to know what you're doing" to "yeah it kind of is" depending on how you go about implementation and what kind of quality you're expecting in the results.

The quickest change I can think of basically results in a single long piece sequence that is the same every time you boot the cart -- just make it so the random value only changes once per piece rather than constantly over time. Not very labor intensive (again, hinging on the fact that you know what you are doing and possibly already know where things are), but also not very robust. This is more or less the solution that is present in the Nintendo World Championships 1990 cart -- there can be some variance in the early game depending on some factors from the other games (actually, the Mario portion specifically), but all possible sequences converge somewhere on what is essentially one long ~22,500 piece loop (not that you'll be seeing the vast majority of that sequence, however).

Other solutions might include tearing out more of the randomization code and replacing it with some of your own or giving more fine grained control of what randomizer seed is being used (i.e. a "game #" that can be set on both carts such that they're randomizing with the same starting point and will provide the same sequence -- if we're both playing game #16384 or whatever, we're both seeing the same pieces), but quality and comprehensiveness will vary depending on a lot of factors.

3. ### wasmachstdugern

so you're telling me there's a chance...

i know nothing of this world you speak of- 1 and 0s aren't really my thing. however, i know people that could help make it happen. the reason i ask is that mike suggested this option for future competitions. the SNES 2-player mode isn't really that popular i guess.

the other option would be a game genie 2 player game that delivers identical pieces (i havent done it but i have heard it is possible).

thanks again kitaru. you seem to know the answer to any and all asinine questions i may bring up.

4. ### Kitaru

Two players on one machine with the same pieces might actually be harder to do well for a variety of reasons, haha. It would be enough of a task getting the 2P stuff cleaned up (which has been done with some impressive looking results in the Tetris Zero hack, though some quirks do remain.)

I can see Game Genie being sufficient for the simplest modification. You'd have two or three parts -- remove the constant randomness updates, add one update per piece roll, and possibly change the starting random value when the machine powers on. I don't know if it's "main tourney" ready, but maybe we could have some super prototype Game Genie same sequence tests at CTWC. Josh and I could probably whip up the three code patches necessary.

EDIT: In fact, we could have a program on a laptop that randomizes the part of the Game Genie code that affects the random value (i.e., pick the game # out of a hat, so to speak) and even precalculate the piece stats. This would open up some crazy rules possibilities, like both players being allowed to agree to mulligan if the stats show an unfavorable set of statistics. That's getting into controversial territory.

Last edited: 28 Aug 2013
5. ### wasmachstdugern

i really like all the possibilities, even if they are controversial!

6. ### boblaze

I don't get why everyone is so fascinated with getting equal pieces to two players. After the first few pieces, the players will be playing different enough that having the same pieces will not matter and the so called "luck" that we are trying to take out of the game by having the same pieces, will be right back in it. One player will be needed a few Ls at a particular time and the other will need another particular piece, the floods and droughts will still hit a particular player at a random time in their game.

7. ### wasmachstdugern

i can only speak for myself- i am actually fascinated with the possibility as a new variant, nothing else. but i dont know if everyone else is fascinated with it. it is simply a little question i had about some possibilities for a future tournament.

the real thing is that i was just daydreaming up some ways to mix things up. i have been, as i am sure many of us have been, playing this game, unaltered, for a long time and now that there seems to be a little bit of a community building around it (or at least i recently discovered an already existing community and am excited about it) i want to challenge those that love it in new ways and make it exciting. so you can go ahead and shit on my idea but i think it could be fun. it also seems you are alluding to some other situation where people have referenced this option before but i dont know about it.

as a corollary, i have overheard countless conversations about "luck" in tetris and this option would really, absolutely negate that as an excuse for poor performance. i like that idea, too.

8. ### boblaze

i would not get rid of 'luck', unless you were to program it to give you x piece is y results. giving player a the same drought at the same time as player b would not negate luck, because after an amount of pieces, they would, though still getting the same pieces, be playing a completely different game.

9. ### Kitaru

While true that there would be some divergence on account of the choices each player makes, there is no arguing the fact that they were given identical opportunities.

10. ### Matt619

go about implementation and what kind of quality you're expecting in the results.

11. ### Kitaru

Game Genie method is kind of no-go because you only get three bytes -- NOPing out the three calls to the RNG sub (one in vblank and two on the level select screen) leaves no room to add an extra call to it in the piece selection subroutine. Patching in a skip past the level select screen would spare you a byte, but a) you'd lose the ability to start at later levels and b) this doesn't solve the dearth of bytes to add another call to the RNG. Unless you can chain two Game Genies or something ridiculous, this isn't really going to work very well at all.

In spite of the knowledge that it was going to be totally broken, I did try with just the RNG advances yanked. Only re-rolls advance RNG, and otherwise you'll generally just get the seven pieces in order on the stats sidebar! Unsurprisingly, a max-out is trivial. It's not even just that the pieces keep coming in the same order -- I-pieces actually become the most likely because they are at the bottom of the list, and the re-roll will start you at some point in that list and then move forward. You end up getting 100+ I's.

If I get a PowerPak, the "NWC90 style" hack would be pretty trivial. Same idea, just without the super tight restriction of only 3 bytes to change. We could probably also hack the level select screen to have a side menu like the Height selection for B-Type that allows the initial seed and piece counter to be adjusted.

Further hackery to the randomizer itself may be worth discussing. However, the minimalistic approach may be sufficient, and it seems nice to stick close to the original behavior before going with any bigger changes.

12. ### mikewiz

I take no credit whatsoever for this. This is credited to BunnyBoy (RetroZone dude, smart guy...buy something from him).

"With no GG codes it will be a "random" sequence. Use the code VXZNKN to turn on sequence selection.

Then use code 12ZNVY where 1 is any letter, and 2 is one of A P Z L G I T Y. That will select one of 128 different sequences.

or

To get the other 128 use code 12ZNVN where 1 is anything and 2 is one of E O X U K S V N. "

Also to skip end game animation - NYIPEX

13. ### Josh Tolles

Alex- could you give me the rom addresses that need to be altered? I've been wanting to look into this a little, but haven't had time. I sprained my shoulder this weekend so now I am on med leave from work this week, so.....

EDIT: wow, didnt see mike's post. That sounds awesome....I am going to try it out tonight!

14. ### wasmachstdugern

so this is all we need to do to get everyone the same pieces for the competition!?! this sounds awesome!

15. ### DonAtreides

Just wanted to add my 2 cents: I think that having the pieces be identical for all players would be a huge benefit for spectators at tournaments. Being able to see how different players handle the same pieces would be very interesting.

16. ### Kitaru

I was messing around with them in an emulator and couldn't figure out how they were supposed to actually work. Looking at the addresses they're supposed to change, I'm not sure how they would confer any real effect. :s Typos? I'll try on real hardware later and see if that helps things.

To get it down to so few bytes gives me some ideas, though. Maybe reading the ROM itself as your "random source" yields acceptable results?

EDIT: Well, it didn't work on hardware, but it did produce some spectacular graphical results. EDIT2: That was actually a pin seating issue, though my statements regarding the effectiveness of the codes as provided stand.

Also, @Josh, I don't have the addresses on-hand at the moment, but I can get them to you later. If you have time to do some work in the debugger, though, set an execution breakpoint on AB47 and find the three places it gets called aside from the piece selection method.

Last edited: 31 Oct 2013
17. ### Josh Tolles

I checked out those codes with an emulator as well, and it didn't look right.

But I did do some research on my own, and have come up with a set of game genie codes that will, I believe, result in a single set sequence of pieces. Which is great and all, but one could kind of sort memorize that. Maybe.

I do know that the first 12 pieces always come out the same.

And this is a reset between games kind of code.

I have not tried it out for an extended period of time, so I do not know if it does something quirky like give you the same piece over and over and over again forever.

Anyway, for what its worth, if anyone wants to try this out and see how it works:

GEVOVAIA
XTEPXPAV
ALEPKPYE

Use all three together.

Changes:
$98EE to 04 (changes$98ED from CMP $05 to CMP$04)
$9902 to EA (changes this from RTS to NOP)$9904 to 38 (changes $9903 from JSR$9907 to JSR $993 EDIT: Haha I just realized what this is. this is the piece sequence for that demo mode the game goes to on the start screen! So, this mmight not work after all. Last edited: 30 Oct 2013 18. ### Kitaru Not quite that severe, but expect a lot of T's once you fall off the end of the defined demo. EDIT: Played a 896k game -- there were 177 T's by Level 29! Last edited: 31 Oct 2013 19. ### Josh Tolles I had a moment of inspiration and came up with a new approach for this, but it doesn't quite pan out the way I thought it would. At first I changed the$17's to $16's but that didn't work because a ROR of$00 stays $00 apparently. So then I noticed that RAM$0006 is written in as $86 at the start of every game and then left alone until the game is over, so I tried using that. I changed$9904 to $1C,$991D to $05, and$9925 to $06. That allowed me to ROR$0006 and load it to the next box every new piece, but that doesn't work either, because you get long, long streams of the same piece.

So, I can't figure out how to use $0006, rotate it every time, and use the first half of the program found at$9907. But I do think I am on to *some*thing here.

20. ### Kasumi

Is the goal REALLY 100% equal pieces? (i.e. no piece on the stats is ever 2 lower than any other piece) Or just a more fair random generator?

Edit: D'oh, read the thread, Kasumi! So you want ONE piece sequence, like Sega's Tetris Poweron pattern? I'll look into it.

Last edited: 3 Nov 2013