On a Gameboy, what happens when attempting to read/write external RAM while RAM is disabled?Windows 98 with 2GB of RAMLargest ratio between base and maximum RAMWhen did 64K RAM become about as cheap as 16K?RAM contention and what counts as different banksWhat is causing the problem with the RAM in this (claimed) Spectrum 48k?What home computer was the first to use a external ROM cartridge?What happened to ZIP RAM?Details of video memory access arbitration in Space InvadersHow does the Gameboy's memory bank switching work?What does a Nintendo Game Boy do when turned on without a game cartridge inserted?
In the Schrödinger equation, can I have a Hamiltonian without a kinetic term?
Patio gate not at right angle to the house
how can I calculate confidence interval with small sample in R?
The grades of the students in a class
integration of absolute value
Avoiding Implicit Conversion in Constructor. Explicit keyword doesn't help here
A conjectural trigonometric identity
Can you remove a blindfold using the Telekinesis spell?
What does 「ちんちんかいかい」 mean?
Balancing Humanoid fantasy races: Elves
My employer is refusing to give me the pay that was advertised after an internal job move
How to get Planck length in meters to 6 decimal places
Why would an invisible personal shield be necessary?
Adding a (stair/baby) gate without facing walls
Prepare a user to perform an action before proceeding to the next step
Derivative is just speed of change?
Applying for mortgage when living together but only one will be on the mortgage
If I buy and download a game through second Nintendo account do I own it on my main account too?
May a hotel provide accommodation for fewer people than booked?
Coworker mumbles to herself when working, how to ask her to stop?
Can I shorten this filter, that finds disk sizes over 100G?
Help me, I hate squares!
How does the barbarian's bonus damage from Rage interact with two-weapon fighting?
How can a class have multiple methods without breaking the single responsibility principle
On a Gameboy, what happens when attempting to read/write external RAM while RAM is disabled?
Windows 98 with 2GB of RAMLargest ratio between base and maximum RAMWhen did 64K RAM become about as cheap as 16K?RAM contention and what counts as different banksWhat is causing the problem with the RAM in this (claimed) Spectrum 48k?What home computer was the first to use a external ROM cartridge?What happened to ZIP RAM?Details of video memory access arbitration in Space InvadersHow does the Gameboy's memory bank switching work?What does a Nintendo Game Boy do when turned on without a game cartridge inserted?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
According to the GBdevwiki:
0000-1FFF - RAM Enable (Write Only)
Before external RAM can be read or written, it must be enabled by
writing to this address space. It is recommended to disable external
RAM after accessing it, in order to protect its contents from damage
during power down of the gameboy.
What happens if you attempt to read/write while it's disabled? Does the CPU hang? The Gameboy crash? How should I implement this in an emulator? Just return a garbage value or crash the game?
memory game-boy
add a comment |
According to the GBdevwiki:
0000-1FFF - RAM Enable (Write Only)
Before external RAM can be read or written, it must be enabled by
writing to this address space. It is recommended to disable external
RAM after accessing it, in order to protect its contents from damage
during power down of the gameboy.
What happens if you attempt to read/write while it's disabled? Does the CPU hang? The Gameboy crash? How should I implement this in an emulator? Just return a garbage value or crash the game?
memory game-boy
add a comment |
According to the GBdevwiki:
0000-1FFF - RAM Enable (Write Only)
Before external RAM can be read or written, it must be enabled by
writing to this address space. It is recommended to disable external
RAM after accessing it, in order to protect its contents from damage
during power down of the gameboy.
What happens if you attempt to read/write while it's disabled? Does the CPU hang? The Gameboy crash? How should I implement this in an emulator? Just return a garbage value or crash the game?
memory game-boy
According to the GBdevwiki:
0000-1FFF - RAM Enable (Write Only)
Before external RAM can be read or written, it must be enabled by
writing to this address space. It is recommended to disable external
RAM after accessing it, in order to protect its contents from damage
during power down of the gameboy.
What happens if you attempt to read/write while it's disabled? Does the CPU hang? The Gameboy crash? How should I implement this in an emulator? Just return a garbage value or crash the game?
memory game-boy
memory game-boy
asked Jul 22 at 4:25
David TranDavid Tran
5274 silver badges13 bronze badges
5274 silver badges13 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Technically, the behaviour is what we call "undefined,"* meaning you can't know what will happen and the system is allowed to do anything it wants in response, up to and including launching a nuclear attack on another country.
That, of course, is highly unlikely (or you clearly got your hands on a Game Boy you should not have). The most likely scenario in this case is that writes would be ignored and reads would return unknown data. Exactly what would happen may vary with the particular cart and its specific memory controller; I can imagine perfectly plausible situations where on a read from one cart always returns 0, another returns random data, and a third returns exactly the contents of the RAM (i.e., "disabling" the RAM just write-protects it).
Less plausible, but still possible, would be a cart specifically designed to have "funny" behaviour when accessing the cartridge RAM addresses while disabled. It might, for example, have extra ROM that's mapped to that space when RAM is disabled, allowing for access to more ROM with less bank switching. Or there might be special hardware on the cartridge that's manipulated by writes to that area when RAM is disabled. This would also serve as a type of copy protection (intentional or not) by making the game more difficult to run on emulators: essentially the emulator would have to know about the game and emulate the cartridge's specific hardware as well as the Game Boy itself.
It may even vary as well with the particular model of Game Boy; it's not unusual for system designers explicitly to leave behaviour undefined so that they can take advantage of this to change how the hardware operates (usually to reduce costs) in later versions of the device.
For an emulator, I would start by generating an error and halting the emulation. This will help you find the cases where you need to deal with this and determine what the behaviour should be, which will hopefully be few and far between. (Nintendo puts all games through a farily detailed QA process, so they may well be checking the code to see game developers aren't doing this.)
Once you've found a game that triggers this, you need to figure out what to do about it, which will involve researching that particular game. There may be on-line resources for it where you can get advice from people who have already dealt with the issue. You can also reverse-engineer the game code to see what it might be trying to do (and whether it's a bug or the game is actually trying to use an undocumented feature) and change your emulator to try out different actions (returning random data, returning zeros, whatever) and test to see how that works.
Once you've figured out what to do, unless you can confirm that that particular behaviour is, even though undocumented, actually stable across all versions of the Game Boy and all cartridges and their memory management units, it's probably best to make the emulator detect that game and do your choosen behaviour only for it, continuing to abort the emulation for any other software that tries to do the same thing. This will let you continue to detect other games that are using undocumented and/or undefined behaviour and deal with their specific requirements when they come up.
*What is "undefined" is fairly clear when working with specifications from the original vendor: it's certainly whatever they tell you is not defined, and usually also what they omit to define in the documentation unless the behaviour is obvious by convention.
For reverse-engineered systems we're not working from original manufacturer documentation (detailed developer documentation for the GBA exists, but is proprietary) so the definition I'm using here for "defined behaviour" is "what extensive testing has shown to be consistently true for hardware considered to be working correctly."
So for example on cartridges where $0147
= $02
(thus claiming to adhere to MBC1+RAM behaviour) and $0149
= $03
(claiming 4 × 8KB RAM banks), I would call writing $02
to $4000
-$5fff
to switch RAM bank 2 to be "defined" behaviour, as per this widely confirmed document.
Conversely, since I've seen no widely confirmed evidence of consistent results from testing writes to disabled cartridge RAM, I call that "undefined" behaviour. This could change if sufficient testing is done to come to a fairly firm conclusion about what all correctly operating cartridge and main unit combinations do.
4
Did any of the models of the Game Boy cause demons to fly out of your nose?
– Richard Ward
Jul 22 at 14:33
2
Pretty sure some of the most powerful world leaders can, indeed, trigger a nuclear attack just from playing with a misprogrammed Game Boy.
– dim
Jul 22 at 15:07
3
"This is the worst Game Boy ever! It's the size of a football and no matter what I press it's not fun to play!"
– Curt J. Sampson
Jul 22 at 21:30
On the contrary, all behaviour of the original Gameboy is well defined by now. Your emulator should do whatever the original Gameboy did - that's what the hardware is defined to do. It's not a matter of "it's undefined behaviour therefore anything can happen" - you have to do what a Gameboy does.
– immibis
Jul 22 at 22:57
@immibis The Game Boy doesn't contain all the hardware that defines its behaviour, and in fact this question is specifically about hardware that's in the cartridge, not the Game Boy itself. Further, there are also many Game Boy clones (including from Nintendo itself! e.g. the pocket, light, GBA) that you may also want to emulate that may have different behaviour from the original GB. I don't know about Nindendo's GB compatibility on the GBA, but it's certain that some non-Nintendo clones have (subtly) different hardware behaviour.
– Curt J. Sampson
Jul 22 at 23:04
|
show 6 more comments
Generally, the RAM wouldn't respond to reads or writes (obviously). Writes would be discarded, the CPU moves on. Reads would return 0xFF if the cart leaves the lines floating, though 0x00 is a possibility. There's also the chance that a particular memory mapper that's actually its own processor could hang, with results similar to yanking out the cart. As far as I know, there are not mappers like that, so you don't need to consider it.
TL;DR: Writes do nothing, reads return 0xFF
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "648"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fretrocomputing.stackexchange.com%2fquestions%2f11754%2fon-a-gameboy-what-happens-when-attempting-to-read-write-external-ram-while-ram%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Technically, the behaviour is what we call "undefined,"* meaning you can't know what will happen and the system is allowed to do anything it wants in response, up to and including launching a nuclear attack on another country.
That, of course, is highly unlikely (or you clearly got your hands on a Game Boy you should not have). The most likely scenario in this case is that writes would be ignored and reads would return unknown data. Exactly what would happen may vary with the particular cart and its specific memory controller; I can imagine perfectly plausible situations where on a read from one cart always returns 0, another returns random data, and a third returns exactly the contents of the RAM (i.e., "disabling" the RAM just write-protects it).
Less plausible, but still possible, would be a cart specifically designed to have "funny" behaviour when accessing the cartridge RAM addresses while disabled. It might, for example, have extra ROM that's mapped to that space when RAM is disabled, allowing for access to more ROM with less bank switching. Or there might be special hardware on the cartridge that's manipulated by writes to that area when RAM is disabled. This would also serve as a type of copy protection (intentional or not) by making the game more difficult to run on emulators: essentially the emulator would have to know about the game and emulate the cartridge's specific hardware as well as the Game Boy itself.
It may even vary as well with the particular model of Game Boy; it's not unusual for system designers explicitly to leave behaviour undefined so that they can take advantage of this to change how the hardware operates (usually to reduce costs) in later versions of the device.
For an emulator, I would start by generating an error and halting the emulation. This will help you find the cases where you need to deal with this and determine what the behaviour should be, which will hopefully be few and far between. (Nintendo puts all games through a farily detailed QA process, so they may well be checking the code to see game developers aren't doing this.)
Once you've found a game that triggers this, you need to figure out what to do about it, which will involve researching that particular game. There may be on-line resources for it where you can get advice from people who have already dealt with the issue. You can also reverse-engineer the game code to see what it might be trying to do (and whether it's a bug or the game is actually trying to use an undocumented feature) and change your emulator to try out different actions (returning random data, returning zeros, whatever) and test to see how that works.
Once you've figured out what to do, unless you can confirm that that particular behaviour is, even though undocumented, actually stable across all versions of the Game Boy and all cartridges and their memory management units, it's probably best to make the emulator detect that game and do your choosen behaviour only for it, continuing to abort the emulation for any other software that tries to do the same thing. This will let you continue to detect other games that are using undocumented and/or undefined behaviour and deal with their specific requirements when they come up.
*What is "undefined" is fairly clear when working with specifications from the original vendor: it's certainly whatever they tell you is not defined, and usually also what they omit to define in the documentation unless the behaviour is obvious by convention.
For reverse-engineered systems we're not working from original manufacturer documentation (detailed developer documentation for the GBA exists, but is proprietary) so the definition I'm using here for "defined behaviour" is "what extensive testing has shown to be consistently true for hardware considered to be working correctly."
So for example on cartridges where $0147
= $02
(thus claiming to adhere to MBC1+RAM behaviour) and $0149
= $03
(claiming 4 × 8KB RAM banks), I would call writing $02
to $4000
-$5fff
to switch RAM bank 2 to be "defined" behaviour, as per this widely confirmed document.
Conversely, since I've seen no widely confirmed evidence of consistent results from testing writes to disabled cartridge RAM, I call that "undefined" behaviour. This could change if sufficient testing is done to come to a fairly firm conclusion about what all correctly operating cartridge and main unit combinations do.
4
Did any of the models of the Game Boy cause demons to fly out of your nose?
– Richard Ward
Jul 22 at 14:33
2
Pretty sure some of the most powerful world leaders can, indeed, trigger a nuclear attack just from playing with a misprogrammed Game Boy.
– dim
Jul 22 at 15:07
3
"This is the worst Game Boy ever! It's the size of a football and no matter what I press it's not fun to play!"
– Curt J. Sampson
Jul 22 at 21:30
On the contrary, all behaviour of the original Gameboy is well defined by now. Your emulator should do whatever the original Gameboy did - that's what the hardware is defined to do. It's not a matter of "it's undefined behaviour therefore anything can happen" - you have to do what a Gameboy does.
– immibis
Jul 22 at 22:57
@immibis The Game Boy doesn't contain all the hardware that defines its behaviour, and in fact this question is specifically about hardware that's in the cartridge, not the Game Boy itself. Further, there are also many Game Boy clones (including from Nintendo itself! e.g. the pocket, light, GBA) that you may also want to emulate that may have different behaviour from the original GB. I don't know about Nindendo's GB compatibility on the GBA, but it's certain that some non-Nintendo clones have (subtly) different hardware behaviour.
– Curt J. Sampson
Jul 22 at 23:04
|
show 6 more comments
Technically, the behaviour is what we call "undefined,"* meaning you can't know what will happen and the system is allowed to do anything it wants in response, up to and including launching a nuclear attack on another country.
That, of course, is highly unlikely (or you clearly got your hands on a Game Boy you should not have). The most likely scenario in this case is that writes would be ignored and reads would return unknown data. Exactly what would happen may vary with the particular cart and its specific memory controller; I can imagine perfectly plausible situations where on a read from one cart always returns 0, another returns random data, and a third returns exactly the contents of the RAM (i.e., "disabling" the RAM just write-protects it).
Less plausible, but still possible, would be a cart specifically designed to have "funny" behaviour when accessing the cartridge RAM addresses while disabled. It might, for example, have extra ROM that's mapped to that space when RAM is disabled, allowing for access to more ROM with less bank switching. Or there might be special hardware on the cartridge that's manipulated by writes to that area when RAM is disabled. This would also serve as a type of copy protection (intentional or not) by making the game more difficult to run on emulators: essentially the emulator would have to know about the game and emulate the cartridge's specific hardware as well as the Game Boy itself.
It may even vary as well with the particular model of Game Boy; it's not unusual for system designers explicitly to leave behaviour undefined so that they can take advantage of this to change how the hardware operates (usually to reduce costs) in later versions of the device.
For an emulator, I would start by generating an error and halting the emulation. This will help you find the cases where you need to deal with this and determine what the behaviour should be, which will hopefully be few and far between. (Nintendo puts all games through a farily detailed QA process, so they may well be checking the code to see game developers aren't doing this.)
Once you've found a game that triggers this, you need to figure out what to do about it, which will involve researching that particular game. There may be on-line resources for it where you can get advice from people who have already dealt with the issue. You can also reverse-engineer the game code to see what it might be trying to do (and whether it's a bug or the game is actually trying to use an undocumented feature) and change your emulator to try out different actions (returning random data, returning zeros, whatever) and test to see how that works.
Once you've figured out what to do, unless you can confirm that that particular behaviour is, even though undocumented, actually stable across all versions of the Game Boy and all cartridges and their memory management units, it's probably best to make the emulator detect that game and do your choosen behaviour only for it, continuing to abort the emulation for any other software that tries to do the same thing. This will let you continue to detect other games that are using undocumented and/or undefined behaviour and deal with their specific requirements when they come up.
*What is "undefined" is fairly clear when working with specifications from the original vendor: it's certainly whatever they tell you is not defined, and usually also what they omit to define in the documentation unless the behaviour is obvious by convention.
For reverse-engineered systems we're not working from original manufacturer documentation (detailed developer documentation for the GBA exists, but is proprietary) so the definition I'm using here for "defined behaviour" is "what extensive testing has shown to be consistently true for hardware considered to be working correctly."
So for example on cartridges where $0147
= $02
(thus claiming to adhere to MBC1+RAM behaviour) and $0149
= $03
(claiming 4 × 8KB RAM banks), I would call writing $02
to $4000
-$5fff
to switch RAM bank 2 to be "defined" behaviour, as per this widely confirmed document.
Conversely, since I've seen no widely confirmed evidence of consistent results from testing writes to disabled cartridge RAM, I call that "undefined" behaviour. This could change if sufficient testing is done to come to a fairly firm conclusion about what all correctly operating cartridge and main unit combinations do.
4
Did any of the models of the Game Boy cause demons to fly out of your nose?
– Richard Ward
Jul 22 at 14:33
2
Pretty sure some of the most powerful world leaders can, indeed, trigger a nuclear attack just from playing with a misprogrammed Game Boy.
– dim
Jul 22 at 15:07
3
"This is the worst Game Boy ever! It's the size of a football and no matter what I press it's not fun to play!"
– Curt J. Sampson
Jul 22 at 21:30
On the contrary, all behaviour of the original Gameboy is well defined by now. Your emulator should do whatever the original Gameboy did - that's what the hardware is defined to do. It's not a matter of "it's undefined behaviour therefore anything can happen" - you have to do what a Gameboy does.
– immibis
Jul 22 at 22:57
@immibis The Game Boy doesn't contain all the hardware that defines its behaviour, and in fact this question is specifically about hardware that's in the cartridge, not the Game Boy itself. Further, there are also many Game Boy clones (including from Nintendo itself! e.g. the pocket, light, GBA) that you may also want to emulate that may have different behaviour from the original GB. I don't know about Nindendo's GB compatibility on the GBA, but it's certain that some non-Nintendo clones have (subtly) different hardware behaviour.
– Curt J. Sampson
Jul 22 at 23:04
|
show 6 more comments
Technically, the behaviour is what we call "undefined,"* meaning you can't know what will happen and the system is allowed to do anything it wants in response, up to and including launching a nuclear attack on another country.
That, of course, is highly unlikely (or you clearly got your hands on a Game Boy you should not have). The most likely scenario in this case is that writes would be ignored and reads would return unknown data. Exactly what would happen may vary with the particular cart and its specific memory controller; I can imagine perfectly plausible situations where on a read from one cart always returns 0, another returns random data, and a third returns exactly the contents of the RAM (i.e., "disabling" the RAM just write-protects it).
Less plausible, but still possible, would be a cart specifically designed to have "funny" behaviour when accessing the cartridge RAM addresses while disabled. It might, for example, have extra ROM that's mapped to that space when RAM is disabled, allowing for access to more ROM with less bank switching. Or there might be special hardware on the cartridge that's manipulated by writes to that area when RAM is disabled. This would also serve as a type of copy protection (intentional or not) by making the game more difficult to run on emulators: essentially the emulator would have to know about the game and emulate the cartridge's specific hardware as well as the Game Boy itself.
It may even vary as well with the particular model of Game Boy; it's not unusual for system designers explicitly to leave behaviour undefined so that they can take advantage of this to change how the hardware operates (usually to reduce costs) in later versions of the device.
For an emulator, I would start by generating an error and halting the emulation. This will help you find the cases where you need to deal with this and determine what the behaviour should be, which will hopefully be few and far between. (Nintendo puts all games through a farily detailed QA process, so they may well be checking the code to see game developers aren't doing this.)
Once you've found a game that triggers this, you need to figure out what to do about it, which will involve researching that particular game. There may be on-line resources for it where you can get advice from people who have already dealt with the issue. You can also reverse-engineer the game code to see what it might be trying to do (and whether it's a bug or the game is actually trying to use an undocumented feature) and change your emulator to try out different actions (returning random data, returning zeros, whatever) and test to see how that works.
Once you've figured out what to do, unless you can confirm that that particular behaviour is, even though undocumented, actually stable across all versions of the Game Boy and all cartridges and their memory management units, it's probably best to make the emulator detect that game and do your choosen behaviour only for it, continuing to abort the emulation for any other software that tries to do the same thing. This will let you continue to detect other games that are using undocumented and/or undefined behaviour and deal with their specific requirements when they come up.
*What is "undefined" is fairly clear when working with specifications from the original vendor: it's certainly whatever they tell you is not defined, and usually also what they omit to define in the documentation unless the behaviour is obvious by convention.
For reverse-engineered systems we're not working from original manufacturer documentation (detailed developer documentation for the GBA exists, but is proprietary) so the definition I'm using here for "defined behaviour" is "what extensive testing has shown to be consistently true for hardware considered to be working correctly."
So for example on cartridges where $0147
= $02
(thus claiming to adhere to MBC1+RAM behaviour) and $0149
= $03
(claiming 4 × 8KB RAM banks), I would call writing $02
to $4000
-$5fff
to switch RAM bank 2 to be "defined" behaviour, as per this widely confirmed document.
Conversely, since I've seen no widely confirmed evidence of consistent results from testing writes to disabled cartridge RAM, I call that "undefined" behaviour. This could change if sufficient testing is done to come to a fairly firm conclusion about what all correctly operating cartridge and main unit combinations do.
Technically, the behaviour is what we call "undefined,"* meaning you can't know what will happen and the system is allowed to do anything it wants in response, up to and including launching a nuclear attack on another country.
That, of course, is highly unlikely (or you clearly got your hands on a Game Boy you should not have). The most likely scenario in this case is that writes would be ignored and reads would return unknown data. Exactly what would happen may vary with the particular cart and its specific memory controller; I can imagine perfectly plausible situations where on a read from one cart always returns 0, another returns random data, and a third returns exactly the contents of the RAM (i.e., "disabling" the RAM just write-protects it).
Less plausible, but still possible, would be a cart specifically designed to have "funny" behaviour when accessing the cartridge RAM addresses while disabled. It might, for example, have extra ROM that's mapped to that space when RAM is disabled, allowing for access to more ROM with less bank switching. Or there might be special hardware on the cartridge that's manipulated by writes to that area when RAM is disabled. This would also serve as a type of copy protection (intentional or not) by making the game more difficult to run on emulators: essentially the emulator would have to know about the game and emulate the cartridge's specific hardware as well as the Game Boy itself.
It may even vary as well with the particular model of Game Boy; it's not unusual for system designers explicitly to leave behaviour undefined so that they can take advantage of this to change how the hardware operates (usually to reduce costs) in later versions of the device.
For an emulator, I would start by generating an error and halting the emulation. This will help you find the cases where you need to deal with this and determine what the behaviour should be, which will hopefully be few and far between. (Nintendo puts all games through a farily detailed QA process, so they may well be checking the code to see game developers aren't doing this.)
Once you've found a game that triggers this, you need to figure out what to do about it, which will involve researching that particular game. There may be on-line resources for it where you can get advice from people who have already dealt with the issue. You can also reverse-engineer the game code to see what it might be trying to do (and whether it's a bug or the game is actually trying to use an undocumented feature) and change your emulator to try out different actions (returning random data, returning zeros, whatever) and test to see how that works.
Once you've figured out what to do, unless you can confirm that that particular behaviour is, even though undocumented, actually stable across all versions of the Game Boy and all cartridges and their memory management units, it's probably best to make the emulator detect that game and do your choosen behaviour only for it, continuing to abort the emulation for any other software that tries to do the same thing. This will let you continue to detect other games that are using undocumented and/or undefined behaviour and deal with their specific requirements when they come up.
*What is "undefined" is fairly clear when working with specifications from the original vendor: it's certainly whatever they tell you is not defined, and usually also what they omit to define in the documentation unless the behaviour is obvious by convention.
For reverse-engineered systems we're not working from original manufacturer documentation (detailed developer documentation for the GBA exists, but is proprietary) so the definition I'm using here for "defined behaviour" is "what extensive testing has shown to be consistently true for hardware considered to be working correctly."
So for example on cartridges where $0147
= $02
(thus claiming to adhere to MBC1+RAM behaviour) and $0149
= $03
(claiming 4 × 8KB RAM banks), I would call writing $02
to $4000
-$5fff
to switch RAM bank 2 to be "defined" behaviour, as per this widely confirmed document.
Conversely, since I've seen no widely confirmed evidence of consistent results from testing writes to disabled cartridge RAM, I call that "undefined" behaviour. This could change if sufficient testing is done to come to a fairly firm conclusion about what all correctly operating cartridge and main unit combinations do.
edited Jul 23 at 1:18
answered Jul 22 at 6:47
Curt J. SampsonCurt J. Sampson
1,8953 silver badges31 bronze badges
1,8953 silver badges31 bronze badges
4
Did any of the models of the Game Boy cause demons to fly out of your nose?
– Richard Ward
Jul 22 at 14:33
2
Pretty sure some of the most powerful world leaders can, indeed, trigger a nuclear attack just from playing with a misprogrammed Game Boy.
– dim
Jul 22 at 15:07
3
"This is the worst Game Boy ever! It's the size of a football and no matter what I press it's not fun to play!"
– Curt J. Sampson
Jul 22 at 21:30
On the contrary, all behaviour of the original Gameboy is well defined by now. Your emulator should do whatever the original Gameboy did - that's what the hardware is defined to do. It's not a matter of "it's undefined behaviour therefore anything can happen" - you have to do what a Gameboy does.
– immibis
Jul 22 at 22:57
@immibis The Game Boy doesn't contain all the hardware that defines its behaviour, and in fact this question is specifically about hardware that's in the cartridge, not the Game Boy itself. Further, there are also many Game Boy clones (including from Nintendo itself! e.g. the pocket, light, GBA) that you may also want to emulate that may have different behaviour from the original GB. I don't know about Nindendo's GB compatibility on the GBA, but it's certain that some non-Nintendo clones have (subtly) different hardware behaviour.
– Curt J. Sampson
Jul 22 at 23:04
|
show 6 more comments
4
Did any of the models of the Game Boy cause demons to fly out of your nose?
– Richard Ward
Jul 22 at 14:33
2
Pretty sure some of the most powerful world leaders can, indeed, trigger a nuclear attack just from playing with a misprogrammed Game Boy.
– dim
Jul 22 at 15:07
3
"This is the worst Game Boy ever! It's the size of a football and no matter what I press it's not fun to play!"
– Curt J. Sampson
Jul 22 at 21:30
On the contrary, all behaviour of the original Gameboy is well defined by now. Your emulator should do whatever the original Gameboy did - that's what the hardware is defined to do. It's not a matter of "it's undefined behaviour therefore anything can happen" - you have to do what a Gameboy does.
– immibis
Jul 22 at 22:57
@immibis The Game Boy doesn't contain all the hardware that defines its behaviour, and in fact this question is specifically about hardware that's in the cartridge, not the Game Boy itself. Further, there are also many Game Boy clones (including from Nintendo itself! e.g. the pocket, light, GBA) that you may also want to emulate that may have different behaviour from the original GB. I don't know about Nindendo's GB compatibility on the GBA, but it's certain that some non-Nintendo clones have (subtly) different hardware behaviour.
– Curt J. Sampson
Jul 22 at 23:04
4
4
Did any of the models of the Game Boy cause demons to fly out of your nose?
– Richard Ward
Jul 22 at 14:33
Did any of the models of the Game Boy cause demons to fly out of your nose?
– Richard Ward
Jul 22 at 14:33
2
2
Pretty sure some of the most powerful world leaders can, indeed, trigger a nuclear attack just from playing with a misprogrammed Game Boy.
– dim
Jul 22 at 15:07
Pretty sure some of the most powerful world leaders can, indeed, trigger a nuclear attack just from playing with a misprogrammed Game Boy.
– dim
Jul 22 at 15:07
3
3
"This is the worst Game Boy ever! It's the size of a football and no matter what I press it's not fun to play!"
– Curt J. Sampson
Jul 22 at 21:30
"This is the worst Game Boy ever! It's the size of a football and no matter what I press it's not fun to play!"
– Curt J. Sampson
Jul 22 at 21:30
On the contrary, all behaviour of the original Gameboy is well defined by now. Your emulator should do whatever the original Gameboy did - that's what the hardware is defined to do. It's not a matter of "it's undefined behaviour therefore anything can happen" - you have to do what a Gameboy does.
– immibis
Jul 22 at 22:57
On the contrary, all behaviour of the original Gameboy is well defined by now. Your emulator should do whatever the original Gameboy did - that's what the hardware is defined to do. It's not a matter of "it's undefined behaviour therefore anything can happen" - you have to do what a Gameboy does.
– immibis
Jul 22 at 22:57
@immibis The Game Boy doesn't contain all the hardware that defines its behaviour, and in fact this question is specifically about hardware that's in the cartridge, not the Game Boy itself. Further, there are also many Game Boy clones (including from Nintendo itself! e.g. the pocket, light, GBA) that you may also want to emulate that may have different behaviour from the original GB. I don't know about Nindendo's GB compatibility on the GBA, but it's certain that some non-Nintendo clones have (subtly) different hardware behaviour.
– Curt J. Sampson
Jul 22 at 23:04
@immibis The Game Boy doesn't contain all the hardware that defines its behaviour, and in fact this question is specifically about hardware that's in the cartridge, not the Game Boy itself. Further, there are also many Game Boy clones (including from Nintendo itself! e.g. the pocket, light, GBA) that you may also want to emulate that may have different behaviour from the original GB. I don't know about Nindendo's GB compatibility on the GBA, but it's certain that some non-Nintendo clones have (subtly) different hardware behaviour.
– Curt J. Sampson
Jul 22 at 23:04
|
show 6 more comments
Generally, the RAM wouldn't respond to reads or writes (obviously). Writes would be discarded, the CPU moves on. Reads would return 0xFF if the cart leaves the lines floating, though 0x00 is a possibility. There's also the chance that a particular memory mapper that's actually its own processor could hang, with results similar to yanking out the cart. As far as I know, there are not mappers like that, so you don't need to consider it.
TL;DR: Writes do nothing, reads return 0xFF
add a comment |
Generally, the RAM wouldn't respond to reads or writes (obviously). Writes would be discarded, the CPU moves on. Reads would return 0xFF if the cart leaves the lines floating, though 0x00 is a possibility. There's also the chance that a particular memory mapper that's actually its own processor could hang, with results similar to yanking out the cart. As far as I know, there are not mappers like that, so you don't need to consider it.
TL;DR: Writes do nothing, reads return 0xFF
add a comment |
Generally, the RAM wouldn't respond to reads or writes (obviously). Writes would be discarded, the CPU moves on. Reads would return 0xFF if the cart leaves the lines floating, though 0x00 is a possibility. There's also the chance that a particular memory mapper that's actually its own processor could hang, with results similar to yanking out the cart. As far as I know, there are not mappers like that, so you don't need to consider it.
TL;DR: Writes do nothing, reads return 0xFF
Generally, the RAM wouldn't respond to reads or writes (obviously). Writes would be discarded, the CPU moves on. Reads would return 0xFF if the cart leaves the lines floating, though 0x00 is a possibility. There's also the chance that a particular memory mapper that's actually its own processor could hang, with results similar to yanking out the cart. As far as I know, there are not mappers like that, so you don't need to consider it.
TL;DR: Writes do nothing, reads return 0xFF
answered Jul 22 at 4:47
OrionOrion
1611 bronze badge
1611 bronze badge
add a comment |
add a comment |
Thanks for contributing an answer to Retrocomputing Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fretrocomputing.stackexchange.com%2fquestions%2f11754%2fon-a-gameboy-what-happens-when-attempting-to-read-write-external-ram-while-ram%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown