0
I’m with a project of a Gameboy emulator for android, so far what I got was:
- Identify the game type (Gameboy, Super Gameboy, Gameboy Color, etc).
- Identify the game region.
- Extract the game title.
First of all all all all the references to build it I’m taking of this website who mapped the entire Gameboy, and this cpu manual (out some open-source emulators).
In the code snippet I use to identify the type of game I do as follows:
if (m_ROM[0x0143] & 0x80){
__android_log_write(ANDROID_LOG_DEBUG, "Cartridge", "GameBoy Color Game");
return 1;
}else if(m_ROM[0x0146] & 0x03){
__android_log_write(ANDROID_LOG_DEBUG, "Cartridge", "Supper GameBoy Game");
return 2;
}else{
__android_log_write(ANDROID_LOG_DEBUG, "Cartridge", "GameBoy or other");
return 0;
}
It works perfectly, it is even easy to understand because it is all very well documented, but what I cannot understand is what & is doing, from what I read in some books that I have it works to get the address of something as a reference operator, or turning bits off, that leaves me confused, because in practice this as "if the address 0x0143 contain 0x80 then it is a game of Gameboy color".
@Jeffersonquesado even the mentioned question is in Javascript, the answer would be for C++? I’m asking because I don’t know deeply Javascript.
– lemoce
Thank you for warning !
– Samuel Ives
@lemoce bitwise operators are the same. Perhaps some change in the amount of bits of the variables involved, which in C++ will occur integer promotion, and endianism would interfere. Apart from these corner cases (which do not affect this specific issue), the behavior is exactly the same
– Jefferson Quesado