CRDB: A binary database format for the OSCR #1029
Ancyker
started this conversation in
Coding Corner
Replies: 1 comment 6 replies
-
How does one edit and modify the database? Is it compiled from the original text format at build time, or are there authoring tools, or what's the plan on the authoring end of things? |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
For a while now I've been toying around with the idea of switching the databases to a binary format to increase the speed of searching/reading from them. It's a lot of work to get set up but once it's going it should provide a much better experience. The general concept is to store the data that is currently stored in text files in a format that is more suitable for being quickly read by a computer. This means using fixed-width fields and records.
Over the weekend I made some progress on porting the NES core to this new format, which I've named CRDB (Cartridge Reader Database). I've gotten the NES cartridge database converted over to a working state and am planning to move the mappers to a database as well. After this conversion, it will add the ability for NES cartridge records to break apart the iNES data from the data used by the firmware. That should mean fewer exceptions are needed. It also will add the much-requested sub-mapper support.
The new format doesn't just add new features. It is also lighter on code, easier to work with in-code, and much faster. See the video below and notice how quick the match for the cartridge is:
2024-09-16.15.31.09-1.mp4
Note that this is faster despite having more than double the cartridge records compared to the current database -- 6,602 vs. 3,114. I didn't change the order of the files in the database either, so it has to seek around 80% of the way into the database to find the match for the cartridge in the video.
It currently uses a little more RAM but a lot less PROGMEM. This is still fluctuating as I work on it but it's at least quite promising, especially considering I haven't moved the mappers yet.
Old TXT System
New CRDB System
Keep in mind the old TXT system's code is still in there, I've only converted the NES core. Once all systems are using it the resource usage should drop even further. It's worth noting that a good bit of the increased memory usage is coming from the added support for submappers. While I haven't moved the mappper table to a database yet, the cartridge database contains submapper info.
As I only have a few NES cartridges I am not able to fully test it. As a result, both systems will be supported via a flag in the
Config.h
file. This is only temporary so that it can be made public without potentially breaking master. To move on to the next step (supporting submappers), the old option will need to be removed. After that, those more familiar with the NES that actually have cartridges to test with will be able to easily add support for new mappers and submappers. It will actually be easier to add support once this is all done.Other systems beyond the NES will also be able to make use of the CRDB files, though mostly just for CRC32s and other checksums. If anyone has any questions, feedback, or feature requests regarding the new format, I welcome the input.
Beta Was this translation helpful? Give feedback.
All reactions