CPCWiki forum

General Category => Programming => Topic started by: reidrac on 09:06, 14 August 21

Title: Using disc via firmware
Post by: reidrac on 09:06, 14 August 21
Hi,

I'm trying to implement disc access using the firmware, but that limits a bit too much the amount of memory I have available if I have to leave the firmware mapped all the time.

My usual approach is to disable the firmware once the full game is loaded in memory, patch the int handler so the firmware is "disabled" (classic ei/ret in 0x0038) and disable upper/lower ROMs with:

        ld bc, #0x7f8c
        out (c), c


So far, so good. It is my preference so I have al the 64k available.

I was wondering, would it be possible to restore the int handler and get the ROM back so I can temporarily use the firmware for disc operations? Then, when finished, I would switch it off to have that memory back.

For this to work I'm assuming the "disc code" should be in the "safe" memory area (after 0x4000).

Would this work? I'm trying it, but I'm probably making a mistake or (most likely) there's something I don't know and, well... it could be making this actually inviable.

Any pointers/comments would be appreciated! Thanks :)
Title: Re: Using disc via firmware
Post by: Targhan on 10:00, 14 August 21
One thing you can do is reinit the ROM disc just before a disc operation. This little snippet (http://tj.gpa.free.fr/html/coding/sources.htm), courtesy of @TomEtJerry (https://www.cpcwiki.eu/forum/index.php?action=profile;u=106), will allow you to do that. Click on "Initialisation du système disque".

I believe this is what I do on Demoniak 7.
Title: Re: Using disc via firmware
Post by: johnlobo on 10:38, 14 August 21
Hi,

This is not an exact answer to your queswtion, but just in case it may help...

Have you checked FDC tools library form Targhan?? (http://www.julien-nevo.com/arkos/fdc-tools/)

If you just need to read files, maybe you don't need to use the fimware.

Regards.
Title: Re: Using disc via firmware
Post by: reidrac on 11:30, 14 August 21
Quote from: johnlobo on 10:38, 14 August 21
Hi,

This is not an exact answer to your queswtion, but just in case it may help...

Have you checked FDC tools library form Targhan?? (http://www.julien-nevo.com/arkos/fdc-tools/)

If you just need to read files, maybe you don't need to use the fimware.

Regards.

I really want to use the firmware, hoping that would make the code compatible with the M4, for example (at least, that was the case for my previously released games).
Title: Re: Using disc via firmware
Post by: reidrac on 11:33, 14 August 21
Quote from: Targhan on 10:00, 14 August 21
One thing you can do is reinit the ROM disc just before a disc operation. This little snippet (http://tj.gpa.free.fr/html/coding/sources.htm), courtesy of @TomEtJerry (https://www.cpcwiki.eu/forum/index.php?action=profile;u=106), will allow you to do that. Click on "Initialisation du système disque".

I believe this is what I do on Demoniak 7.

I will take a look, thanks. Why putting a TXT file inside a DSK? Interesting approach.

EDIT: after a quick read, there's a lot of black magic in there I didn't know about! :D I had got to something similar, but in no way as elaborate (and different address depending of the model? of course not).

Thanks again, very useful!
Title: Re: Using disc via firmware
Post by: reidrac on 16:16, 14 August 21
This works perfectly!

As suggested by the doc, I have a table with calls to different addresses depending on 464, 664 and 6128. I have tried it with emulation for now and works fine (but I guess "the test" is my 464 with the M4!).

I'm using double buffer by hw, and setting up the firmware corrupts memory from 0x8000 to 0xbfff. This is expected because it has to set variables, jump table, etc in there; so it is matter of ensuring 0xc000 is the active video memory and restore 0x8000 when the disc operation is completed. I'm not completely sure I *need* double buffer via hw, but for now I'll continue using it.

I'll keep testing (+ the real CPC test), but this looks like is what I was looking for.

Thanks a lot to @Targhan (https://www.cpcwiki.eu/forum/index.php?action=profile;u=110) for the pointer and @TomEtJerry (https://www.cpcwiki.eu/forum/index.php?action=profile;u=106) for sharing the code!

EDIT: also I've been reading the firmware disassm in @arnoldemu (https://www.cpcwiki.eu/forum/index.php?action=profile;u=122)'s website. Very useful!
Title: Re: Using disc via firmware
Post by: Arnaud on 08:13, 15 August 21
Really interesting, i could have use of it !

According to this snipet, is only memory from &B900 to &BFFF will be restored with firmware (not all system from &A67B a &BFFF) ?
In this case we have just to keep an area of &6FF Bytes with only tempory or movable data ?
Title: Re: Using disc via firmware
Post by: reidrac on 08:37, 15 August 21
Quote from: Arnaud on 08:13, 15 August 21
Really interesting, i could have use of it !

According to this snipet, is only memory from &B900 to &BFFF will be restored with firmware (not all system from &A67B a &BFFF) ?
In this case we have just to keep an area of &6FF Bytes with only tempory or movable data ?

I'm not completely sure. I suggest you look at this: https://cpctech.cpcwiki.de/docs/os.asm ; it is for the 6128 only, but it may help you to understand better what is happening "Setup HIGH KERNEL jumpblock".

This hack is great, but it makes sense only now that we are not going to get more new CPC models; back in the day this would have make the games potentially forward incompatible because changes in the ROM could break the game.
Powered by SMFPacks Menu Editor Mod