All your base are belong to pi.
Download package (C++ input parser and script file): http://tasvideos-moviefiles.googlecode.com/files/piscript.zip
Information that is even more technical than what is covered here: Forum/Posts/342003

Goals

  • Pi
  • Pi
  • Pi

About the TAS

Well, this TAS is a bit different. Instead of ponies, you get pi.

What in the name of pi is going on

To hijack program control, you need two things:
  • A way to divert the program counter (PC) into RAM.
  • A way to write the right program.
Conventional thinking (such as in p4wn3r's 1:09.63 TAS) has shown that the address D36D-D36E is a well-used gateway to send the PC into RAM. Just put any 16-bit number there (little-endian) and the PC will jump to whatever it says when you close the menu. Furthermore, using memory-manipulation glitches such as switching Pokemon beyond the 6th position, and switching and tossing glitched items, you can pretty much write whatever you want from D16A onward. And how do you switch Pokemon beyond the 6th position, if such a thing is even imaginable? Just do a reset at the right time while saving and it will overwrite the Pokemon counter so the game thinks you have 255 Pokemon.
I inject the following sequence into D366 (don't ask): 22 00 76 00 F0 F5 D4 50 D3
Provided that the bytes from D350 to D365 are all 00 (which they are), these 9 bytes will magically hijack the GB and give you complete control of everything you ever wanted, only limited by the GB's hardware. Other sequences including shorter ones exist but I chose this sequence to be as fast as possible. To help out, the rival is given a completely illogical name.
Once the sequence is planted, I close the menu. The game reads D350 off the gateway address and thinks that it is a valid ROM address and so jumps there. The sequence and all future programs are craftily hacked together in a way that is hard to describe casually, so I'll just say this: given enough room (which I have more than enough of), you can write a very simple RAM-writing program. Congrats, you can now write whatever you want.
The payload (final program), which is only 152 bytes long, is a simple VRAM manipulator. It starts out by writing into the tile bank at positions F3-F7 the 8x8 tiles for pi, pi upside down, decimal point, zero, and one, where the last 3 are in Pokemon font (they were somehow erased after leaving the menu; none of the other digits were harmed). The program then enters an input-interactive state where you can feed it key input which can change the tile map. For this TAS, visible tilemap is practially divided into two spaces: topspace (top 12 rows) and bottomspace (bottom 6 rows). The two columns on both sides are unusable. For technical reasons, the bottomspace effectively extends below the bottom of the screen by two rows.
It works somewhat like this (0x means hexadecimal):
  • Feeding it a number from 0x00 to 0xED writes to a cache (at D600) representing the bottomspace (8 rows by 16 columns). Each number writes the tile for either pi or pi upside down in the cache at a given position. The cache exists in order to sync the bottomspace input. To perform a do-nothing-visible action, feed it the number 0xED. It writes off the bottom of the screen.
  • Feeding it the number 0xEE dumps the cache into bottomspace and clears it with the all-black tile.
  • Feeding it the number 0xEF ends the program. It fakes a GB crash and sends itself into an infinite loop.
  • Feeding it a number from 0xF0 to 0xFF writes directly to topspace (12 rows by 16 columns). Each number writes its own value (tile values F5-FF which are decimal point and digits) to the first available position in topspace. It writes serially (left to right, then top to bottom).
There is no guarantee that VRAM writing occurs in a safe (to a real GB) manner; it does not check for status of FF40-FF41 (for reference, pages 51-53 of http://marc.rawer.de/Gameboy/Docs/GBCPUman.pdf ).
Anyway, scripting VRAM to do what I want is a bit too hard to do entirely with manual hex-editing, so I wrote a simple C++ parser that converts ANSI (ASCII) into input. This allows me to use a text editor instead, and organize the script using characters that the parser ignores.

About the script used

I did my best to sync the "actions" of the tiles with the background music. First, note that dumping cache to bottomspace and writing directly to topspace cannot occur on the same frame, so they must be at least one frame apart.
Second, placing the frame on which the tile appears and the frame on which the peak of a sound effect first occurs on the same frame is not guaranteed to be perceived as sync. The human brain does not work that way. From my own testing, it seems best for the frame on which the tile appears to occur 5 or 6 frames back. Results may vary by person, state of mind, and method of encoding of course.
The normal beat window is 15 frames (this is the width between the first two notes of the Pokemon music when you start in the bedroom). This means that, when syncing to a 15-frame beat, each frame is limited to dumping 14 tiles into VRAM. Some notes occur with a window of 7-8 frames; I can pull this off early on, but I decided that later on it was too much of a hassle to maintain so I ignored those notes.
I threw in a few references to pi, games, or mathematical stuff that can easily be represented by dot matrix display. Otherwise, there's not much else to talk about. For more information about technical details, see this post: Forum/Posts/342003.
Well anyway, enjoy the TAS and help yourself to some pi. It's a neat soundclip from the Hard n' Phirm song "Pi"; however, you shouldn't look for the rest of the song or its music video unless you are willing to lose a few brain cells. You can also listen to "Mathematical Pi" if you wish.
Happy Pi Day!

Nach: Accepting as improvement to existing run.


Editor, Active player (297)
Joined: 3/8/2004
Posts: 7469
Location: Arzareth
Voted yes for replacing the pony version. This run managed to surprise me with how fast it went into action, and then again how much behavior seemingly was extracted from what was practically nothing. There was no gargantuan bootloader that is first uploaded in a most boring manner.
Editor, Player (44)
Joined: 7/11/2010
Posts: 1029
FWIW, this is more than pi minutes long. 14 seconds is more than 0.14 of a minute, because minutes are 60 seconds long, not 100 seconds long. And thanks for getting the bootloader so much shorter.
Active player (335)
Joined: 1/19/2010
Posts: 383
Location: Texas
Superb. Brilliant. Excellent. Entertaining. Obvious "YES" vote.
Joined: 1/9/2013
Posts: 27
Location: Virginia
jlun2 wrote:
Mothrayas wrote:
VBA is not deprecated.
Ok. Still..what's the point of "Masterjun's GBC Pokémon Yellow in 01:11.06" which according to the comments, is pretty much identical to the current published run but done in BizHawk if VBA is totally fine with GB(C) games?
The concern there is that the differences may or may not be up to the emulator used instead of the input created by the TASer. Here, the input and subsequent result is obviously quite different.
Skilled player (1737)
Joined: 9/17/2009
Posts: 4979
Location: ̶C̶a̶n̶a̶d̶a̶ "Kanatah"
Rydian wrote:
The concern there is that the differences may or may not be up to the emulator used instead of the input created by the TASer. Here, the input and subsequent result is obviously quite different.
Oh, of course. So I can try to obsolete a playaround that uses a less accurate emulator with the exact same emulator used because....well, this run did it so why not?
Joined: 10/21/2012
Posts: 16
If I understand it all correctly, the original "pony" version actually wrote a completely different "game" and loaded it using Yellow whereas this doesn't completely overwrite the game, it just arranges the memory in a way that creates dancing pi symbols and outputs pi to the screen in lockstep with the BGM... I'm not taking anything away from this run but completely overpowering the game with a new "game" has to account for something at least, IMO.
Patashu
He/Him
Joined: 10/2/2005
Posts: 4042
Itsbrown4606 wrote:
If I understand it all correctly, the original "pony" version actually wrote a completely different "game" and loaded it using Yellow whereas this doesn't completely overwrite the game, it just arranges the memory in a way that creates dancing pi symbols and outputs pi to the screen in lockstep with the BGM... I'm not taking anything away from this run but completely overpowering the game with a new "game" has to account for something at least, IMO.
FractalFusion executed a program that allowed him to write directly from the game's input into RAM, so he could have rewrote Pokemon Yellow into anything but settled for making pi-themed graphics.
My Chiptune music, made in Famitracker: http://soundcloud.com/patashu My twitch. I stream mostly shmups & rhythm games http://twitch.tv/patashu My youtube, again shmups and rhythm games and misc stuff: http://youtube.com/user/patashu
Player (12)
Joined: 11/23/2012
Posts: 94
Patashu wrote:
FractalFusion executed a program that allowed him to write directly from the game's input into RAM, so he could have rewrote Pokemon Yellow into anything but settled for making pi-themed graphics.
. . . which I believe to be a far better decision because pi doesn't invoke the same divisiveness that ponies do, and because the set-up is much faster. Heck, even if the previous run had Mario (something I like) in it instead of ponies, I'd be inclined to say that this run's faster set-up makes it to where I wouldn't mind it obsoleting the previous run.
Player (193)
Joined: 10/23/2010
Posts: 49
Location: Australia
This was amazing and extremely entertaining. Yes vote.
Patashu
He/Him
Joined: 10/2/2005
Posts: 4042
(For what it's worth, I think the primary reason ponies were used in the original total control TAS was because it made it very, very obvious it was not an easter egg in the game, as ponies are a contemporary fad.)
My Chiptune music, made in Famitracker: http://soundcloud.com/patashu My twitch. I stream mostly shmups & rhythm games http://twitch.tv/patashu My youtube, again shmups and rhythm games and misc stuff: http://youtube.com/user/patashu
Player (12)
Joined: 11/23/2012
Posts: 94
Patashu wrote:
(For what it's worth, I think the primary reason ponies were used in the original total control TAS was because it made it very, very obvious it was not an easter egg in the game, as ponies are a contemporary fad.)
I still think it would have been better to invoke multiple anachronistic and/or contemporary fads instead of just the one so that pony haters would have a greater chance of finding something to enjoy. Make it a medley. That said, this run is at least pi times shorter and sweeter than the previous one, which is great in a playaround where a few minutes might be spent setting things up for something to happen.
Emulator Coder
Joined: 3/9/2004
Posts: 4588
Location: In his lab studying psychology to find new ways to torture TASers and forumers
If one wanted to go for something fresh to show it wasn't in the game, they should plaster TASVideos all over the screen. Maybe even recreate part of the site look in the game (screenshot loading is easy), along with some custom music, perhaps jumping between SMB Overworld, MM2 Wily Stage 1, Bloody Tears, to hit popular TAS franchises, and recognizable tunes.
Warning: Opinions expressed by Nach or others in this post do not necessarily reflect the views, opinions, or position of Nach himself on the matter(s) being discussed therein.
Joined: 10/21/2012
Posts: 16
Patashu wrote:
FractalFusion executed a program that allowed him to write directly from the game's input into RAM, so he could have rewrote Pokemon Yellow into anything but settled for making pi-themed graphics.
So, you're basically saying they did the exact same thing, albeit with different results.
Joined: 5/9/2009
Posts: 7
Location: Concord
I give this video 3.1415926535 stars
Warepire
He/Him
Editor
Joined: 3/2/2010
Posts: 2178
Location: A little to the left of nowhere (Sweden)
Nach wrote:
If one wanted to go for something fresh to show it wasn't in the game, they should plaster TASVideos all over the screen. Maybe even recreate part of the site look in the game (screenshot loading is easy), along with some custom music, perhaps jumping between SMB Overworld, MM2 Wily Stage 1, Bloody Tears, to hit popular TAS franchises, and recognizable tunes.
Yes yes yes!
Editor, Expert player (2072)
Joined: 6/15/2005
Posts: 3282
Anyway, I'll explain how I worked on this since a week ago. After finishing the H.E.R.O. submission, I decided to work on a "Pi Day" TAS, which I only had a week to work on. Initially, I thought about doing a TI-83 submission, but then decided not to pursue it, as apart from rattling off the first 10000 digits of pi and using curves to graph the shape of a pi, the idea didn't stick with me. Then I thought about Pokemon Yellow and what bortreb did. I already knew how to hijack the game; that work was done late last year. So I started on a program that would list 3141 digits of pi at about 31.4 fps (this takes 100 seconds, and is just enough to finish the movie in 3m14s) . I finished the initial stages of the program but then decided that merely listing digits of pi at 31.4 fps was too cheap, so I dropped that one. I thought that I might as well manipulate the VRAM to match the music. After all, if I'm going to do this, I might as well make it memorable. I decided that I would divide the screen into two parts, writing the digits of pi on the top, and having pi tiles dance on the bottom. Initially I wasn't sure of what format the input should be to interact with VRAM. I also considered different sizes of screen to draw on and how many distinct tiles to use. I decided on having the bottomspace be 8 rows by 16 columns, and using two distinct tiles, which are pi and pi upside down. This way I can input a tile on each frame. I used a "cache" to store the tile locations and dump later since otherwise there would be no way to sync them. I also allow for listing the digits of pi on the topspace, something that I wanted to do for a while. It took me a while to come up with a C++ program to help with entering the necessary input, and to script the whole thing, but I managed to do it. It only took 2 or so days anyway. Oh, and to answer jlun2's question: I wanted to make something memorable, not worry about emulators. I grew up using VBA so that's what I used. bortreb used VBA for Total Control Hack as well, so I know that it works. Anyway, thanks for the response and feedback. I didn't expect there to be so many replies.
Active player (309)
Joined: 8/21/2012
Posts: 429
Location: France
Oh my Pi! I love it! For all the reasons already cited in this thread. Game + maths + rythm + art = Pi^yes*vote
Player (117)
Joined: 5/13/2009
Posts: 700
Location: suffern, ny
Voting Yes, cause of Pi(e)
[19:16] <scrimpy> silly portuguese [19:16] <scrimpy> it's like spanish, only less cool
Joined: 1/9/2013
Posts: 27
Location: Virginia
jlun2 wrote:
Rydian wrote:
The concern there is that the differences may or may not be up to the emulator used instead of the input created by the TASer. Here, the input and subsequent result is obviously quite different.
Oh, of course. So I can try to obsolete a playaround that uses a less accurate emulator with the exact same emulator used because....well, this run did it so why not?
If the newer playaround is much more entertaining, shorter to get to the fun stuff, and shows off things the previous one didn't... why would it not be accepted? That's how it already works with playaround TASes, right?
Itsbrown4606 wrote:
Patashu wrote:
FractalFusion executed a program that allowed him to write directly from the game's input into RAM, so he could have rewrote Pokemon Yellow into anything but settled for making pi-themed graphics.
So, you're basically saying they did the exact same thing, albeit with different results.
From what I've read they used the same strategy to set up, but the program they input was different, and FF's program took input to modify the screen as well.
Joined: 5/2/2009
Posts: 656
I loved the pi TAS, but I don't know it should substitute the poney TAS. As much as I dislike ponies, the other TAS makes a matrix-style screen, draws a pony and plays a music. That's kinda more than drawing pis and writing its name.
My first language is not English, so please excuse myself if I write something wrong. I'll do my best do write as cleary as I can, so cope with me here =) (ノಥ益ಥ)ノ
Player (12)
Joined: 11/23/2012
Posts: 94
OmegaWatcher wrote:
That's kinda more than drawing pis and writing its name.
You underestimate the value of pi by a factor of at least 3.14.
Experienced player (514)
Joined: 7/23/2011
Posts: 108
My only regret, is that I have but one (and not 3.14) yes votes to give this.
Player (138)
Joined: 8/27/2004
Posts: 165
Apart from all the awesome pi references outside of the video itself, I really felt like this was a better submission than the pony one. More cool stuff happens, it's more memorable, it's more interesting to watch (nothing I wanted to skip past), and it feels more like the user input is completely controlling the game. It's also much more elegant, as it not only inserts the code very quickly, but also skips the multiple input stages of the pony one. Custom graphics and music is pretty impressive for sure, and as a coder I can appreciate how much data had to be inserted for that to be a possibility. However, the way this TAS was able to put an animation on the screen, with new graphics tiles, while also displaying digits of pi, all synced to the music, just blew me away. The pony version was a good demonstration, but this is the kind of thing I would show to friends who don't know about TASes.
Joined: 1/9/2013
Posts: 27
Location: Virginia
OmegaWatcher wrote:
I loved the pi TAS, but I don't know it should substitute the poney TAS. As much as I dislike ponies, the other TAS makes a matrix-style screen, draws a pony and plays a music. That's kinda more than drawing pis and writing its name.
The other movie takes multiple times longer to actually start the custom program, which draws a static image and plays a custom tune. This TAS is much quicker to get to the custom program, and has multiple animations at once (timed to the existing music showing that he's taking control of the game instead of rewriting it totally, which is more TAS-like), with the bottom screen even showing off things like Tetris shapes, a game of Snake, the Game Of Life, Arkanoid, and possibly more references I didn't get or can't recall at the moment.
Player (12)
Joined: 11/23/2012
Posts: 94
Rydian wrote:
OmegaWatcher wrote:
I loved the pi TAS, but I don't know it should substitute the poney TAS. As much as I dislike ponies, the other TAS makes a matrix-style screen, draws a pony and plays a music. That's kinda more than drawing pis and writing its name.
The other movie takes multiple times longer to actually start the custom program, which draws a static image and plays a custom tune. This TAS is much quicker to get to the custom program, and has multiple animations at once (timed to the existing music showing that he's taking control of the game instead of rewriting it totally, which is more TAS-like), with the bottom screen even showing off things like Tetris shapes, a game of Snake, the Game Of Life, Arkanoid, and possibly more references I didn't get or can't recall at the moment.
FractalFusion could have even chosen to throw a pony reference in those animations somewhere, and I'd still say it's a better payload than the current movie, because it does so many other things and it doesn't feel like the payload is 100% "I hope you like ponies, because if not, TROLOLOLOLOLOL".