
Gameboy.live: A basic Gameboy emulator with terminal “cloud gaming” support - gslin
https://github.com/HFO4/gameboy.live
======
userbinator
A sign of the times: the use of the term "cloud gaming" to describe what would
once be called "network play".

 _The emulator will firstly break at the ROM entry point 0x0100 in debug mode,
which is the entry point of the game program._

That start address is the same as in CP/M, and subsequently DOS 16-bit COM-
format binaries. I wonder if Nintendo was inspired by that.

~~~
jchw
The DMG boot ROM fits into the top 0x100 bytes. To protect it from being
snooped, the last instruction shuts off the boot ROM by flipping a register
that can’t be flipped back, mapping the top 0x100 back to the cartridge (and
allowing the cartridges interrupt vectors to be installed.) So, there is no
jump to 0x100 at any point; they just fit the DMG boots ROM perfectly into
0x100 bytes and control flow leaves bootstrap right as PC hits 0x100.

This simple security mechanism was extremely effective, and lead to the DMG
BIOS being undumped until relatively recently, when it was dumped by imaging
the ROM directly and via fault injection to skip the last instruction.

~~~
menzoic
The fact that it was undumped until recently makes me want to understand this
more. Can you ELI5?

~~~
EvanAnderson
There's a description of the particular fault injection used for the Gameboy
Color here:
[https://www.its.caltech.edu/~costis/sgb_hack/](https://www.its.caltech.edu/~costis/sgb_hack/)

Fault injection is a method to cause microprocessors to execute instructions
"incorrectly" by manipulating external factors (clock frequency, input power,
etc). Getting the CPU to fail to write to a memory address, or flipping the
truth of a comparison instruction, and other "glitches" can influence
execution of security-sensitive code and ultimately undermine security
mechanisms.

The original Gameboy ROM was dumped by physically de-capping the chip and
reading out the bits: [https://dot-matrix-game.blogspot.com/2014/01/boot-
roms.html](https://dot-matrix-game.blogspot.com/2014/01/boot-roms.html)

~~~
Hackbraten
That was a super insightful read!

tl;dr For the SGB, they quadrupled the clock speed briefly to glitch over the
one instruction responsible for mapping out the ROM.

For the CGB, they halted the clock, drained the voltage to randomize the
instruction counter, then used a NOP slide that led to their payload.

------
lysium
Nice touch with the choice of the port number! Now I only have to install
telnet on my Mac to be happy! Thanks for the project!

~~~
jhatemyjob
telnet is preinstalled.

~~~
furriephillips
Interestingly, not for the newer versions of OS X
[http://osxdaily.com/2018/07/18/get-telnet-
macos/](http://osxdaily.com/2018/07/18/get-telnet-macos/)

~~~
jhatemyjob
Oh wow, that's terrible.

~~~
baroffoos
Why? The tiny % of people who need telnet are perfectly able to install it
themself.

------
eatonphil
Myself curious to write a GB emulator... how do you get images? After a quick
search I see a list of "homebrews" on a collection repo on GitHub [0]. Is
there a particularly good place to find games?

[0] [https://github.com/gbdev/awesome-
gbdev#homebrews](https://github.com/gbdev/awesome-gbdev#homebrews)

~~~
tsomctl
Being copyrighted, it's not legal to redistribute them. You're favorite
torrent search engine might be able to help, though. Or you can buy them off
eBay and dump the image yourself. I'm not sure what the current state of
dumping hardware is, but 10 years ago I hacked together one that used a PC
parallel port.

~~~
voltagex_
I can highly recommend [https://www.tindie.com/products/insidegadgets/gbxcart-
rw-gam...](https://www.tindie.com/products/insidegadgets/gbxcart-rw-
gameboygbcgba-cart-readerwriter/).

~~~
codetrotter
> Works with Windows XP or higher and Linux/Mac (console version). On
> Linux/Mac the speeds are much slower.

How come?

> You'll just need a Micro-USB or USB-C cable depending on the connector type
> you choose. Please note the USB-C connector only has the USB 2.0 lines
> attached so it may not work with devices expecting a USB-C capable device;
> you might need a USB-C to USB-A adapter and then a USB-A to USB-C cable.

Do you know if there are plans for a future revision of the hardware which
will allow for the greater speed that USB-C can provide to be utilized?

~~~
voltagex_
>> Works with Windows XP or higher and Linux/Mac (console version). On
Linux/Mac the speeds are much slower.

Not sure. It dumps the cart over serial and there were some problems with
higher speeds at one point.

> Do you know if there are plans for a future revision of the hardware which
> will allow for the greater speed that USB-C can provide to be utilized?

I don't think the carts themselves are that fast, there wouldn't be a huge
amount of benefit. At least when I tried it it wasn't even coming close to
using full USB 2 speed.

------
pbhjpbhj
Presumably Nintendo will shut this down shortly?

~~~
userbinator
Highly unlikely, given all the other GB emulators that already exist, some of
which are far more famous.

~~~
p1necone
Yeah, until you start hosting roms I don't think Nintendo cares (although
possibly begrudgingly). Once you do though... bad times.

Nintendo has even used existing open source emulators themselves in commercial
products.

~~~
BeefySwain
> Nintendo has even used existing open source emulators themselves in
> commercial products.

Source? I'd love to read more about that.

~~~
hcs
Best example I know of is PocketNES, but that was used by Jaleco in a GBA
port:

[https://waxy.org/2004/07/jaleco_borrows/](https://waxy.org/2004/07/jaleco_borrows/)

Nintendo has written or contracted a lot of emulators themselves. The
grandparent may be thinking of the pervasive use of the iNES header format,
which originated with an unofficial (though not open source) emulator:

[https://wiki.nesdev.com/w/index.php/INES](https://wiki.nesdev.com/w/index.php/INES)

------
furriephillips
The Gameboy & in fact, all games consoles completely passed me by - my
experience of hand-held gaming was Donkey Kong and TomyTronic. Now I'm going
to have a chance to see what I missed out on - sort of :)

~~~
gallerdude
Here are some unprompted recommendations :)

If you like puzzle games, Tetris, if you like adventure games, Link’s
Awakening. If you like platforming, I’d recommend any of the Super Mario Land
or Donkey Kong Land games!

~~~
soulofmischief
Hey, don't forget about the first two Pokemon generations, Pokemon TCG,
Metroid II, and Wario Land!

------
atulvi
why did you use ascii art with braille instead of half width unicode?

------
WC3w6pXxgGd
This is unbelievably impressive, especially from a college sophomore! How does
a 19 year old know how to do this / have the time to do this!?

~~~
mrmonkeyman
What do you mean? 19 year olds have no responsibilities to speak of except
"school". When I was 19 I was doing the same shit, loads ands loads of time.

