Loading and running 65816 code with Super Game Boy

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Loading and running 65816 code with Super Game Boy

Post by tepples »

nin-kuuku wrote: Fri Nov 06, 2020 7:00 am Anyway, you can also use the Super Gameboy for SNES coding. It has OK musicdriver build in (with annoying bug related to gate setting). And 128k RAM + 64k VRAM is enough memory to make good games. Also SGB+GB flashcarts are cheaper than SNES flashcarts. I'm planning to put out some SGB loader blob
Now you've piqued my interest. Let's brainstorm. These issues have kept me from just doing this myself:
  1. Needing to dump the 256 KiB firmware from my Super Game Boy so I can debug my own bootloader blob in Mesen-S, which is the primary reason I ordered an INL-Retro.
  2. Not knowing which parts of memory are safe to overwrite with DATA_TRN commands before I JUMP into the native side.
For reason A, I'd eventually like to write a firmware dumper application that copies the firmware to the GB cart. The biggest practical problem with writing a dumper is that GB flash carts tend to limit the SRAM size to about 32 KiB, and there's no counterpart to DLDI to read and write the SD card itself. Thus the dumper would need to be 8 different ROMs, each to dump one 32 KiB part to a separate SRAM save file, and then the user would concatenate the save files on the PC to produce the final ROM.

Another thing I want to experiment with is having the GB program act as a block device. The Super NES side would send a 4K sector number through the ICD2. Then the Game Boy side would receive the sector number as controller presses, load it into VRAM, and send it with the equivalent of a DATA_TRN command. It'd behave like a CD drive or an SSD. This mechanism would be amenable to high-level emulation, so that the same ROM could theoretically run on a Super Game Boy (with the GB-side block loader) and the Super NES alone (with a block loader that just does a memory copy).
User avatar
Nikku4211
Posts: 569
Joined: Sun Dec 15, 2019 1:28 pm
Location: Florida
Contact:

Re: Loading and running 65816 code with Super Game Boy

Post by Nikku4211 »

Ah, nice, storing a SNES game in a GB ROM so that you can play it on a GB flashcart. Real clever.

Anyone wanna play Space Invaders?
I have an ASD, so empathy is not natural for me. If I hurt you, I apologise.
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: Loading and running 65816 code with Super Game Boy

Post by calima »

That's an awfully convoluted way to save 30$. Plus if you want to distribute such, that means taking SGBs off the market.

A recent Japanese GB/SNES release was like that. It's a GB game with no SNES code, but they're also selling a SNES version which is just SGB + their GB cart in a normal SNES case. Destroying SGBs goes against my religion, like destroying NES games is against INL's.
User avatar
Nikku4211
Posts: 569
Joined: Sun Dec 15, 2019 1:28 pm
Location: Florida
Contact:

Re: Loading and running 65816 code with Super Game Boy

Post by Nikku4211 »

calima wrote: Fri Nov 06, 2020 10:40 am That's an awfully convoluted way to save 30$. Plus if you want to distribute such, that means taking SGBs off the market.

A recent Japanese GB/SNES release was like that. It's a GB game with no SNES code, but they're also selling a SNES version which is just SGB + their GB cart in a normal SNES case. Destroying SGBs goes against my religion, like destroying NES games is against INL's.
What about simply distributing the SNES game in a GB cart along with the GB version, just like what Space Invaders on GB did?
nin-kuuku wrote: Fri Nov 06, 2020 7:00 am Anyway, you can also use the Super Gameboy for SNES coding. It has OK musicdriver build in (with annoying bug related to gate setting). And 128k RAM + 64k VRAM is enough memory to make good games. Also SGB+GB flashcarts are cheaper than SNES flashcarts. I'm planning to put out some SGB loader blob and macros for the music that you can use with assembler of your choice.
Oh, so you have to use the SGB's own music driver, huh? Is it, like, N-SPC or something?

Is it possible to just upload an SPC that uses its own music driver? I want to be able to use a tracker instead of being stuck with either hex code or MML.

It is awesome that you're going to do the macros in the future, though.
I have an ASD, so empathy is not natural for me. If I hurt you, I apologise.
User avatar
NovaSquirrel
Posts: 483
Joined: Fri Feb 27, 2009 2:35 pm
Location: Fort Wayne, Indiana
Contact:

Re: Loading and running 65816 code with Super Game Boy

Post by NovaSquirrel »

Nikku4211 wrote: Fri Nov 06, 2020 11:26 am What about simply distributing the SNES game in a GB cart along with the GB version, just like what Space Invaders on GB did?
Or alternatively just port the SNES side to being a native SNES game, if you want to do a SNES cartridge release.

I'm intending on including a SNES version on a Game Boy Color project I'm working on, since SNES is significantly easier for me so it's no problem. I'm thinking I'm gonna upload a small bootloader to the SNES (probably in Bank 7F since Pandocs says it's entirely unused), JUMP to it, and make the Game Boy side start acting as a block device to fetch the rest of the stuff it needs. I could even potentially share data between the two versions of the game.
User avatar
nin-kuuku
Posts: 67
Joined: Tue Jan 24, 2017 1:23 am

Re: Loading and running 65816 code with Super Game Boy

Post by nin-kuuku »

Nikku4211 wrote: Fri Nov 06, 2020 10:37 am Ah, nice, storing a SNES game in a GB ROM so that you can play it on a GB flashcart. Real clever.
Anyone wanna play Space Invaders?
Space Invaders? Here is a list of 65xx games that runs on SNES WRAM alone with "16-bit" graphics and sound. They are all 128k or less:
Super Mario Bros, Legend of Zelda, Metroid, Kid Icarus, Castlevania, Megaman, Ghosts'n Goblins, Snake Rattle'n Roll, Rygar, Solstice, Duck Tales 1&2, Gradius, Lifeforce, Contra, Wizards & Warriors, Lolo 1&2, Goonies 1&2, Battle of Olympus and most importantly ... Bubble Bath Babes and Bible Adventures.
Nikku4211 wrote: Fri Nov 06, 2020 11:26 am Oh, so you have to use the SGB's own music driver, huh? Is it, like, N-SPC or something?
Is it possible to just upload an SPC that uses its own music driver? I want to be able to use a tracker instead of being stuck with either hex code or MML.
It is the same Sony driver that lot of SNES games uses. Not sure if you can load your own driver but you can use your own samples. And you can make a tracker for the build in driver.
User avatar
Nikku4211
Posts: 569
Joined: Sun Dec 15, 2019 1:28 pm
Location: Florida
Contact:

Re: Loading and running 65816 code with Super Game Boy

Post by Nikku4211 »

nin-kuuku wrote: Fri Nov 06, 2020 12:26 pm Space Invaders? Here is a list of 65xx games that runs on SNES WRAM alone with "16-bit" graphics and sound. They are all 128k or less:
Super Mario Bros, Legend of Zelda, Metroid, Kid Icarus, Castlevania, Megaman, Ghosts'n Goblins, Snake Rattle'n Roll, Rygar, Solstice, Duck Tales 1&2, Gradius, Lifeforce, Contra, Wizards & Warriors, Lolo 1&2, Goonies 1&2, Battle of Olympus and most importantly ... Bubble Bath Babes and Bible Adventures.
Okay, but keep in mind that if they were ported to SNES, they'd have to use more data for sound due to having to use samples, and if you want the graphics to be 'upgraded', you'd have to make the game take up more storage space.
nin-kuuku wrote: Fri Nov 06, 2020 12:26 pm It is the same Sony driver that lot of SNES games uses. Not sure if you can load your own driver but you can use your own samples. And you can make a tracker for the build in driver.
Someone should get to making a tracker for the driver. I have no idea if Earthbound uses the same driver(if it does, no clue if it's a later version or the same as in SGB), since EBMusEd is a tracker for Earthbound's music.
NovaSquirrel wrote: Fri Nov 06, 2020 11:37 am Or alternatively just port the SNES side to being a native SNES game, if you want to do a SNES cartridge release.
*hisssssssss*
NovaSquirrel wrote: Fri Nov 06, 2020 11:37 am I'm intending on including a SNES version on a Game Boy Color project I'm working on, since SNES is significantly easier for me so it's no problem. I'm thinking I'm gonna upload a small bootloader to the SNES (probably in Bank 7F since Pandocs says it's entirely unused), JUMP to it, and make the Game Boy side start acting as a block device to fetch the rest of the stuff it needs. I could even potentially share data between the two versions of the game.
Cool, that'd be awesome. I wonder if you'll have a choice to play either version, and if the GB version will also have SGB enhancements when played on an SGB.

What data could you share, though? I know 2BPP graphics can be shared, but not the tilemap data.
I have an ASD, so empathy is not natural for me. If I hurt you, I apologise.
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Loading and running 65816 code with Super Game Boy

Post by tepples »

calima wrote: Fri Nov 06, 2020 10:40 am That's an awfully convoluted way to save 30$. Plus if you want to distribute such, that means taking SGBs off the market.
Not necessarily. The ROM I envision would be designed as a polyglot. If burned onto a GB cart and launched through JP $0100 from the SGB, sector reading would make requests from the GB through the ICD2. If burned onto a Super NES cart and launched through JMP ($FFFC), it'd just use MVN. And if burned onto a GB cart and launched through JP $0100 on a handheld or Game Boy Player, it'd play a GB-mode side quest.
Nikku4211 wrote: Fri Nov 06, 2020 12:52 pm
NovaSquirrel wrote: Fri Nov 06, 2020 11:37 am Or alternatively just port the SNES side to being a native SNES game, if you want to do a SNES cartridge release.
*hisssssssss*
Yes, in fact, I do use Python for asset conversion.
User avatar
Nikku4211
Posts: 569
Joined: Sun Dec 15, 2019 1:28 pm
Location: Florida
Contact:

Re: Loading and running 65816 code with Super Game Boy

Post by Nikku4211 »

tepples wrote: Fri Nov 06, 2020 3:01 pm
Nikku4211 wrote: Fri Nov 06, 2020 12:52 pm
NovaSquirrel wrote: Fri Nov 06, 2020 11:37 am Or alternatively just port the SNES side to being a native SNES game, if you want to do a SNES cartridge release.
*hisssssssss*
Yes, in fact, I do use Python for asset conversion.
Didn't know my cat was a snake this entire time.
I have an ASD, so empathy is not natural for me. If I hurt you, I apologise.
Pokun
Posts: 2675
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Loading and running 65816 code with Super Game Boy

Post by Pokun »

Seems like there are a lot of misunderstandings in this thread. I don't think Nikku meant to port Space Invaders to SNES, but meant that this is like doing like what the Game Boy version of Space Invaders is doing, running 65816 code from a Game Boy ROM cartridge when a Super Game Boy is detected. This is also what I think Tepples meant from the beginning. No need to destroy any SGBs. This does require that the target audience has both a SNES and a Super Game Boy of the same region though.


I've also been very interested in doing this one day. I'm much more familiar with the Game Boy hardware than the SNES (and SGB) hardware though, so this is still far away.
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: Loading and running 65816 code with Super Game Boy

Post by Oziphantom »

If this can be emulated, this has Compo written all over it.
User avatar
Nikku4211
Posts: 569
Joined: Sun Dec 15, 2019 1:28 pm
Location: Florida
Contact:

Re: Loading and running 65816 code with Super Game Boy

Post by Nikku4211 »

Oziphantom wrote: Sat Nov 07, 2020 1:34 am If this can be emulated, this has Compo written all over it.
Recent versions of BSNES can emulate Super Game Boy-enhanced GB games with all Super Game Boy enhancements intact, so yes, you can host a compo about this.
I have an ASD, so empathy is not natural for me. If I hurt you, I apologise.
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: Loading and running 65816 code with Super Game Boy

Post by calima »

Ah, so crossing the SNES scene that has enough people to count on one hand, with the GB scene that can also be counted on one hand's fingers :beer:
User avatar
Nikku4211
Posts: 569
Joined: Sun Dec 15, 2019 1:28 pm
Location: Florida
Contact:

Re: Loading and running 65816 code with Super Game Boy

Post by Nikku4211 »

calima wrote: Sat Nov 07, 2020 12:31 pm Ah, so crossing the SNES scene that has enough people to count on one hand, with the GB scene that can also be counted on one hand's fingers :beer:
You just have to find some way to get them interested in supporting any SGB enhancements at all, since very little people use an SGB, and the GBC can do much better colour.
I have an ASD, so empathy is not natural for me. If I hurt you, I apologise.
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: Loading and running 65816 code with Super Game Boy

Post by Oziphantom »

calima wrote: Sat Nov 07, 2020 12:31 pm Ah, so crossing the SNES scene that has enough people to count on one hand, with the GB scene that can also be counted on one hand's fingers :beer:
I might be quirky enough to get a wider "demo" group interest.
Post Reply