gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > Is it possible to detect whether you're running on hardware?

#16661 - ScottLininger - Sun Feb 22, 2004 5:17 am

Does anyone know if there is a way to detect at runtime whether the ROM is on hardware vs. an emulator?

I would like to switch out some graphics and change the palette (for gamma reasons) when my game runs on hardware.

#16664 - tepples - Sun Feb 22, 2004 5:33 am

First of all, try to detect GAME BOY PLAYER. (Display the Magic Cookie Image and see if you get 0x030F in the joypad register after a few frames.) If you have a GAME BOY PLAYER, then you have a CRT or a display with a CRT-like gamma characteristic.

Some emulators run without a BIOS; use out-of-range MidiKey2Freq() calls to find this. Some emulators reset certain video registers on video mode switches. (VBA does or did reset the BG2 affine matrix when switching between modes 1 and 4; the GBA doesn't.) Some emulators allow a DMA channel's source address to be changed even while the DMA channel is still turned on.

No, you won't be able to distinguish GBA from GBA SP, even though GBA SP has a higher blacklevel (and thus an apparently flatter gamma) when its light is turned on.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#16675 - ScottLininger - Sun Feb 22, 2004 3:59 pm

tepples wrote:
First of all, try to detect GAME BOY PLAYER. (Display the Magic Cookie Image and see if you get 0x030F in the joypad register after a few frames.) If you have a GAME BOY PLAYER, then you have a CRT or a display with a CRT-like gamma characteristic.


When you say "display the magic cookie image", do you mean to write it to the video buffer? If so, is there a particular location on the screen?

I was under the impression that the "nintendo" image was displayed as a sprite and alpha blended with hardware as it flashes... Which if that's true wouldn't I need to display it as a sprite to get the effect you're talking about?

Is there any technical spec on the header that I could read to get a better understanding of this?

#16677 - tepples - Sun Feb 22, 2004 4:27 pm

The GBA Magic Cookie Data (156 bytes in the header, representing the Nintendo logo) and the GBP Magic Cookie Image (Game Boy Player logo) are two different things. It seems you can display the Magic Cookie Image in any video mode, as long as the pixels exactly match what the Player hardware is expecting. You can rip the image from a screenshot of Pokemon Pinball or Super Mario Advance 4.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#16699 - dagamer34 - Mon Feb 23, 2004 3:17 am

Go download the VisualHAM kit. There is a demo there that does exactly what you want. Sorry, I can't give you the code right now(and save you the trouble).

The site: www.console-dev.de

Download version 2.5 with all the HAM demos. It is not a HAM function and has the source for it also. Chances are there are some other demos useful to everyone else there too which don't use HAM directly.

You're welcome.
_________________
Little kids and Playstation 2's don't mix. :(

#16704 - FluBBa - Mon Feb 23, 2004 11:03 am

I think it was possible to do a check on the CPU pipe, in which you use self modifying code.

Code:

   ldr r1,opcode
   str r1,newop
newop
   mov r0,#0
   bx lr
opcode
mov r0,#1


the emulator will set r0 to #1 on hardware it will set r0 to #0.
I don't think it's fixed in any emulators, might be wrong though.
_________________
I probably suck, my not is a programmer.