Comments (9)
No, I'm not going to remove the existing save and restore features, just adding some new ones.
from devkitsms.
Let me know if SMS_getROMBank()
works well enough for you 😄
from devkitsms.
Interesting!
I have a few possible workarounds but I believe the easiest is to just move the SMS_saveROMBank();
before your if
, which means you'll save the current ROM bank even when you won't need it, but not a big deal anyway...
from devkitsms.
Yes, for my case I just put them together, but it's a bug that may not be not so obvious to the newbie :-)
from devkitsms.
Well, not really a bug in my opinion but surely it's an issue some other might stumble upon.
Maybe the solution is just to use a global variable instead of a local one? Also, what do you think about this @raphnet ? 🤔
from devkitsms.
A global variable would break everything for me. In my projects, I occasionally have more than one nested use of save/restore (inside functions called from other functions...) and also use this in a line interrupt handler for music playback.
Additionally, at the moment a call to SMS_restoreROMBank in the wrong scope should fail (in most cases) with a compilation error. If a global variable were used instead, then it would compile fine, but should the user ever nest uses like I do, there will be fun surprises at run time which I'm pretty sure will be extremely confusing for a newbie, as it will be more subtle than an outright compilation error.
Perhaps the documentation just need to be improved? For instance, stating that the saving must be done somewhere that is not out of scope for the restoring later?
Also perhaps pointing out the fact that after using SMS_saveROMBank(), there is absolutely no requirement to actually switch bank, and that using SMS_restoreROMBank() can be even omitted if you know the bank was unchanged. Given this I think one could rewrite the code from the issue description like so:
SMS_saveROMBank();
if(flashCartridge) {
SMS_mapBANK(SAVE_BANK);
} else {
SMS_enableSRAM();
}
//Do saving stuff
if(!flashCartridge) {
SMS_disableSRAM();
}
SMS_restoreROMBank();
from devkitsms.
OK so maybe I could add a function that returns the currently mapped ROM bank value (a byte).
This way, one will be able to declare his own variable with the desired scope (either global or local to a function) and save the currently mapped ROM bank there.
Basically something like this would probably just work:
#define SMS_getROMBank() (ROM_bank_to_be_mapped_on_slot2)
I'm not sure about the name though. It needs to be clear that you're reading back the number of the currently mapped ROM bank... 🤔
Suggestions?
from devkitsms.
I can't think of anything better for the name. At least SMS_getROMBank()
is shorter than ROM_bank_to_be_mapped_on_slot2
...
I hope the next step is not removing SMS_saveROMBank(); and SMS_restoreROMBank() to only keep SMS_getROMBank()... That would be a bit disappointing.
from devkitsms.
I think the SMS_getROMBank() name it's fine! And as you mentioned, no need for deleting the old ones. But I'll mention in the documentation that it can only be used in the same scope :-)
from devkitsms.
Related Issues (20)
- Interrupt and VDP processing HOT 8
- 32bits variables HOT 2
- Using PSGlib with banked code HOT 4
- Macros to save/restore the bank mapped to slot2? HOT 9
- Ability to install a vblank handler HOT 7
- Need clear vram on startup HOT 3
- SG-1000 ROMs on SC-3000 - Sega standard. HOT 59
- Adding examples to this repo HOT 6
- issue with compressed songs spawning multiple banks HOT 3
- New Unsafe and Vertical Orientation Functions HOT 17
- SG/SC -> SG_byte_brief_array_to_VDP_data HOT 1
- PSGLib - Allow to set volume attenuation on SFX HOT 4
- crt0_sg.s incorrect initialization of I/O chip HOT 1
- SC-3000 Cassette Support HOT 6
- assets2banks with files > 16kb in size HOT 4
- SMS_setTileatXY HOT 2
- MetaSprite clipping? HOT 2
- Tile Id Offset Meta Sprite Feature Request HOT 2
- SMS_updateSpritePosition and SMS_updateSpriteImage HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from devkitsms.