Description
Ok, time to be "that guy".
While it can be a neat trick to know that the SGB boot ROM leaves C==$14
, it can lead to both false positives and false negatives in plausible real world scenarios. Therefore I would suggest restoring the recommendation to use MLT_REQ
as the recommended way of detecting SGB functionality. Below are the ways in which it could lead to false detection, as well as addressing some of the things mentioned in that text.
False positives
The impact of a false positive is that any attempt to transfer data using _TRN
commands will be seen as garbage on the screen.
- One of the Gameboy clone boot ROMs will leave
C==$14
. By my naming conventions it is calledfortune_boot.bin
but it may exist in variously named clone consoles. - The game may run on a real SGB, through the boot ROM, without access to SGB commands. In particular one common way that this could happen is using the EZFlash Jr cartridge. This cartridge has trouble running on a SGB because of reset line issues. A common workaround to this issue is to hit the reset button at a point which allows the boot ROM to run and the menu to show. However, since the stock firmware of the EZFJ runs first and doesn't have SGB support enabled in its header, communication with the SNES BIOS is locked out after that point, including in the case that the SGB CPU is reset because a game was loaded.
False negatives
The impact of a false negative is that SGB functionality such as borders and screen colorization are disabled, when they don't need to be.
- Some cartridge menus on older flash cartridges don't reset the game, but instead store a small trampoline in WRAM which they use to jump to
$100
after setting up the cartridge's multi ROM functionality to show the ROM in question. One such example is the EMS 64M USB cartridge if using multi ROM functionality. Such a menu will almost certainly not leaveC==$14
or care to leave different register values for SGB compared to DMG. - Older emulators typically don't produce correct initial register values for SGB, instead typically giving values similar to those found on a DMG. On such emulators, SGB functionality will be disabled, even though the game would otherwise run fine in the emulator in question.
- There's one scenario where even newer more accurate emulators can fail to produce
C==$14
, namely in a "SGB+GBC" mode if such a mode exists. Both BGB and mGBA have such a mode and both (not surprisingly) start with the exact initial registers of a GBC. In this mode, SGB functionality is locked out, and the game is shown with an empty, useless border around it instead.
The conclusion is that relying solely on C==$14
for SGB detection is likely to cause real world irritation for a small but significant group of users of the software you create and should not be recommended as the main SGB detection mechanism.
Claims made in the current text
but this method is more complicated
True, but not by much. If you consider that the purpose of detecting SGB mode is typically to send over a border and/or colorize the screen, which in itself takes some setting up, the added effort in programming the detection algorithm is minor. A better solution to this point would be to create a library/example code that a developer can use as is.
and slower than checking the value of the A and C registers after startup.
So, it is true that SGB commands take some time to execute, due to a recommended delay after each command. Nintendo recommends a 70000 M cycle, or ~4 frame delay. Do that twice during detection (once to activate multiple controller mode, and then to deactivate it) and you're looking at an 8 frame delay, or ~133 ms. However, consider that on real hardware, it was directly preceded by a forced delay of anything from a 3.11 s (GBC) to 5.59 s (DMG). Also combine this with the fact that most games are expected to show a copyright, title or similar static screen as the first thing, which can be loaded before this delay and thus essentially absorbs it. Given this context, a one-time 133 ms delay before user input is accepted should barely be perceptible to a human, much less an annoyance.