Super Game Boy 2 DATA_SND DATA_TRN JUMP Programming Example 3 Setting New Program Counter Address
Showing that it is possible to set the SNES NMI counter to a new bank (or any specified destination address or bank) using the JUMP and supplementary DATA_SND (controls, sets, and sends data to SNES WRAM) commands to jump to the new destination from a Game Boy ROM program game. I wrote a piece of code that jumps to the credits screen instantly without needing to enter the button code. This code will now work with the original Super Game Boy BIOS since code was shifted around, causing the JUMP command to jump to a different location in memory between the SGB/SGB2 BIOS revisions.
This is part of the code I wrote to jump to the SGB/2 BIOS credits/staff roll. the DATA_SND will set RAM in the SNES WRAM resolve the graphical glitches that occur when setting the SNES program counter to a new location. the DATA_TRN is just a program loop function and the JUMP sets the program counter to a new bank at the original vector. (The demo does not actually send data to the SGB BIOS)
JUMP can be programmed to take control away from the SGB/2 BIOS directly accessing SNES RAM contents, and or allowing BIOS functions to coexist with custom SNES 65816 side code, or read RAM bank contents and data directly from the Game Boy ROM code via JOYPAD registers and screen buffer and waiting 4 frames for the SNES to receive the contents of Game Boy VRAM signal transfer as data.
DATA_SND can set any SNES WRAM 7E0000-7EFFFF address allowing you to use it as a code injector, or a Pro Action Replay cheat device to gain direct access to various functions such as Enabling SNES OBJ_TRN mode or TEST_EN speed functions, and even send custom data to that RAM address.
Here is an example video showcasing and setting DATA_SND to enable the unused and unfinished SNES OBJ_TRN mode
https://www.youtube.com/watch?v=V4pYy2lIz5E
[CODE]
1 11 MLT_REQ 89000000000000000000000000000000
1 11 MLT_REQ 89010000000000000000000000000000
1 0F DATA_SND 790B18000BA90F8F002100A9018F0360
1 0F DATA_SND 791618000B006CFCFF00000000000000
1 0F DATA_SND 790018000BEA18FBE220C210A90048AB
1 0F DATA_SND 792608000B39CD480CD034A5C9C980D0
1 0F DATA_SND 791B08000BEAEAEAEAEAA901CD4F0CD0
1 0F DATA_SND 791008000B4C2008EAEAEAEAEA60EAEA
1 10 DATA_TRN 81000B000B0000000000000000000000
1 12 JUMP 91000B000B1800000000000000000000
SNES Bank WRAM locations for DATA_TRN and DATA_SND:
SGB Command 0Fh - DATA_SND
Used to write one or more bytes directly into SNES Work RAM.
Byte Content
0 Command*8+Length (fixed length=1)
1 SNES Destination Address, low
2 SNES Destination Address, high
3 SNES Destination Address, bank number
4 Number of bytes to write (01h-0Bh)
5 Data Byte #1
6 Data Byte #2 (if any)
7 Data Byte #3 (if any)
etc.
Unused bytes at the end of the packet should be set to zero, this function is restricted to a single packet, so that not more than 11 bytes can be defined at once.
Free Addresses in SNES memory are Bank 0 1800h-1FFFh, Bank 7Fh 0000h-FFFFh.
SGB Command 10h - DATA_TRN
Used to transfer binary code or data directly into SNES RAM.
Byte Content
0 Command*8+Length (fixed length=1)
1 SNES Destination Address, low
2 SNES Destination Address, high
3 SNES Destination Address, bank number
4-F Not used (zero)
The data is sent by VRAM-Transfer (4 KBytes)
000-FFF Data
Free Addresses in SNES memory are Bank 0 1800h-1FFFh, Bank 7Fh 0000h-FFFFh. The transfer length is fixed at 4KBytes ???, so that directly writing to the free 2KBytes at 0:1800h would be a not so good idea ???
Further, the original Super Game Boy instruction manual stated that there were surprises in future games. There was very little in the way of surprises as game developers refused to touch any of the impressive Super Game Boy programming. Nintendo didn't care themselves only covered the barebones minimum.
Programming this required Game Boy Z-80 and SNES 65816 assembly knowledge; I had to reverse engineer the SGB/2 BIOS in order to find out where the credits are loaded and set the NMI to jump to the address. Took a total of about 15 minutes to complete this demonstration.
Download my original tech demo:
http://www.mediafire.com/download/na1tvj7nb88t2c2/SGB+JUMP+to+Credits+Tech+Demo+%28nensondubois%29.gb
Here is something to read regarding my shared thoughts on the Super Game Boy and how developers did not give a shit.
http://loveconquersallgam.es/tagged/super_game_boy/chrono
I have for several years reverse-engineered thousands of videogames to find unused content and I have found quite a few interesting pieces of code that developers have used to test various Super Game Boy functions (mostly sound functions) and remnants of an official Super Game Boy SDK found in several games in varying degrees of functional and alterations. I have also worked with other consoles to find different items of interest by mostly by myself.
http://gamehacking.org/vb/threads/12747-nensondubois-codes
Hopefully other people will start programming Super Game Boy tech demos.
*See you again on next project.