Offline
Sweeeeeeden

Little FM 0.5.2 released. Fixes a bug where some files would incorrectly fail to load with the message “no blockjump”.

Get it here: http://blog.gg8.se/wordpress/gameboy-re … -for-lsdj/

Offline

no new feature :-(
but thx for the release!

Offline
Victoria, BC, Canada

Oh boy time for a necrobump...

The year is 2018. Ebay is bursting at the seams with cheap, readily-available bootleg carts that can be re-flashed with LSDJ. Because they are made for common games and not music, these carts only have 32kb of battery-backed SRAM. This is enough for "work memory" - saving a single song. But what if...

What if LittleFM came to the rescue? Many of the carts have 2MB flash and could potentially use the upper 1MB for save blocks as LittleFM already does. The problem is, LittleFM currently operates on 128kb complete save banks only. If it could only be modified to save/load 32kb blocks of work memory (between flash and SRAM), it could manage 8-32 song slots in a 2MB flash cart (depending on whether the save blocks needed to be 32kb or 128kb-aligned).

That would be amazing.

nitro2k01, I'm sure you have long since moved on. But do you think the logic is sound, is this theoretically possible?

Offline
NUMBSKULL

I think the issue is the gameboy can't write to the flash. Well on second though maybe they could because I don't think the bootlegs use the SND pin for write enable, rather I think it's controlled by the memory bank controller.

Offline
Sweeeeeeden

I have not moved on, even though I haven't had time to work on LittleFM for a long time now. But I have thought about the exact thing you mentioned. The technical issues are as follows:

1) Accessing the flash from the GB side. Some of these carts don't have the /wr pin hooked up as catskull alluded to. But many do actually have it available, but with scrambled address bits, so A0 and A1 might be swapped for example. This is absolutely no problem to add support for though. Worst case, you'd need to do a small solder mod to connect the /wr pin, which is something that the carts often add the facility to do, because...

2) Some carts being sold actually don't have a battery. Instead, they modify the ROM so that it writes SRAM to flash when saving, and then restores it when the game is started again. This works ok enough for games, except that you get a one second or so delay after saving the game. But these particular cartridges are problematic for LSDj use since they won't retain SRAM contents on power-down.

3) Some carts come with 3.3 V or even 1.8 V flash operated at the Gameboy's 5 V, which is a gross voltage overload. In practice, it often works ok for a $5 product (if you're willing to risk that the cartridge might stop working at any time) as long as you're only READING from the flash. On writing, the flash chip will error out because of the overvoltage. This can often be solved by putting a diode in series with the supply to drop the supply voltage a little, again with the caveat that the cart could stop working at any time. So this might, again, require a hardware modification of the cart.

4) Flash chips are by their nature sector devices. You can write to a certain byte once, but you can't write to the same byte again unless you erase a bigger area called a sector, which are often 32-128 kB big on the devices in question. LittleFM was really a quick hack which took the path of least resistance and saved data corresponding to 1-2 sectors at once. If the sectors are 128 kB big, you might choose to either waste the remaining 96 kB, or do something more tricky like saving multiple copies of the same song, or saving different songs in the same sector and defragmenting the file system every now and then or something like that.

One solution that solves both 2 and 4 simultaneously, would be to implement support for something like a file system that saves every modification to the song to flash sequentially, as an address being changed and what byte was written. This would work very well, except that it would require a lot of modifications to LSDj. At that point I might as well write my own GB tracker. While that's actually a tempting idea, it would take a LOT of work.

Offline
Victoria, BC, Canada

WOW! Thank you for the deep analysis, and for playing along with the thought experiment.

My thinking wasn't to find such a perfect solution like a full-on filesystem, but rather wondering whether the LittleFM idea could be extended to get some really rough utility out of the carts? Which is to say, what if you didn't worry about wasting most of the sector (#4)? So for example, a 2MB flash cart using the LittleFM method (in my limited understanding) would still leave space for 8 persisted songs (128kb sector * 8 in the unused 1MB following the LSDJ ROM) instead of 1. And what if we ignore carts that would make this difficult or impossible, like those without batteries(#2)? The carts that I'm playing with right now (2mb flash @3V, 32kb sram, readily flashable using Bennvenn's Joey) also have batteries and work just peachy with LSDJ, buuuut, are limited to the one song in work memory - precisely why I started wondering if the LittleFM method could be used.

But even if theoretically one could find the proper method to access the flash, (#1) through prior experience, reverse engineering, trace analysis + datasheets, or leveraging existing flasher code... it does sound like #3 is insurmountable. The Chinese carts I've been playing with are, as you say, either 3V or 1.8V. Hmm. I assume the carts that aren't battery-backed and have patched roms that write to the flash IC must do so through some programmer that can operate under, step down the 5V VCC?

I'm glad to hear it's crossed your mind as well, and thanks for writing back! Just kicking around the idea and trying to learn more about the hardware along the way. smile

Offline
Sweeeeeeden

#1 is trivial. Software wise, the protocols are well known. Hardware wise, at most you need to change one solder connection.

As for #3... If the Chinese are selling it, it works. If not in theory then at least in practice, most of the times. And if it doesn't work, that's a calculated risk in the form of negative eBay/Ali ratings.

To be specific, no there's no special programming equipment in those cartridges. Not even level shifters. Just flash connected to the GB bus. Some carts are dead on arrival but other than that it "works in practice". Again, at most you need to cut one trace and add a series diode.

Offline
Indianapolis, IN

Any chance of releasing the beta with Super GameBoy under/overclock support as well as El Cheapo support?