Comments (7)
Also, SRAM banks greater than 0 should now be mapped at offset 0x16000 following a change, see RetroAchievements/rcheevos#329
from mgba.
I'm not really sure how the memory mapping subsystem works; Any idea @CasualPokePlayer?
from mgba.
The idea of libretro's memory maps is you give it a ton of pointers with buffer lengths according to those pointers and tell libretro what the ""real"" address here is (so more or less creating a "System Bus" like map). However, since that isn't actually sufficient for exposing all useful memory, libretro has to go do a hack where it maps memory past the addressing limit of the console (so for GB/C that's >0xFFFF). I have no idea how this "select" thing in libretro's memory maps actually works (is it some kind of mask???)
from mgba.
select
specifies which bits need to match start
to be considered part of the block. disconnect
specifies bits to ignore. Here's my attempt to explain this back in 2022: https://discord.com/channels/184109094070779904/876520593636335646/946233105654628452
If
select
is 0,start
andlen
represent the full region of memory (i.e. 0x4000 and 0x2000 would be $4000-$5FFF), and the memory being read is accessible atptr + (address - start)
.
Otherwise,
select
anddisconnect
are used to map an address to a memory block. If the bits of the address masked by theselect
value match thestart
value (i.e.address & select == start & select
), then the address could be read from the associated block.disconnect
is used to mask off bits that don't apply to the block, so the actual memory being read isptr + (address & ~disconnect) - start
.
For example, on NES: $0800-$0FFF, $1000-$17FF, and $1800-$1FFF are all the same memory as $0000-$07FF. If the top 3 bits are 0, the fourth and fifth bits are ignored, and the remaining 11 bits determine where to actually read from RAM. Since the top 3 bits indicate a memory address in RAM,
select
would be 0xE000, or 0xFFFFE000 if extended for 32-bit. And since only the 11 lowest bits are significant, the other 5 bits are "disconnected", sodisconnect
would be 0xF800, or 0xFFFFF800 if extended for 32-bit.
Carrying this further, if you tried to read $193A, it would match the RAM block (address 0x193A & select 0xFFFFE000 = 0x0000, start 0x0000 & select 0xFFFFE000 = 0x0000, 0x0000 == 0x0000), and (address 0x193A & ~disconnect 0x000007FF = 0x013A), so reading $193A would return whatever is at ptr + 0x013A. if you tried to read $793A, it would not match the RAM block (address 0x793A & select 0xFFFFE000 = 0x6000, start 0x0000 & select 0xFFFFE000 = 0x0000, 0x6000 != 0x0000).
from mgba.
Gosh that's confusing. Can you confirm if this is fixed? I'll reopen if not.
from mgba.
I think descs[i].start
for the new block should be 0x16000 to line up with the virtual address similar to the one assigned to 0x10000 a few lines below.
from mgba.
You're right, I forgot to change that.
from mgba.
Related Issues (20)
- mgba update error HOT 1
- mbga crashes in the middle of a game HOT 4
- Mgba/Game is not recognizing any L button inputs HOT 1
- Mega Man Battle Network 4 romhack brief animation freeze only in mGBA
- Golden Sun Worldmap background is shaking HOT 1
- ROM Library doesn't show ROM name HOT 3
- GB Classic: F1 Race - flickering line midscreen
- [Feature Request] Allow Shortcuts mapped to a controller to affect multiple instances of MGBA
- Power Quest multiplayer is nearly unplayable
- mgba crashing
- SOOTROPOLIS gym when the right pokemon dies the game crashes
- mGBA Windows XP builds HOT 1
- Battle Chip Gate Compatibility (via third-party tools) HOT 4
- Trouble compiling on Ubuntu 22.04 HOT 1
- Performance on old 2DS HOT 1
- [Feature Request] Option to accept keyboard inputs when window is not in focus HOT 1
- Unable to save game on pokemon cartridge dump HOT 4
- Linux 32-bit Version HOT 6
- Unable to save game override settings linux appimage 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 mgba.