Author Topic: Using disc via firmware  (Read 616 times)

0 Members and 1 Guest are viewing this topic.

Offline reidrac

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.046
  • Country: gb
  • Trying to gamedev!
    • index.php?action=treasury
    • usebox.net
    • Awards
Using disc via firmware
« on: 11: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:
Code: [Select]
        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 :)
like
0
No reactions
Released The Return of Traxtor, Golden Tail, Magica, The Dawn of Kernel, Kitsune`s Curse and Brick Rick for the CPC.

If you like my games and want to show some appreciation, you can always buy me a coffee.

Offline Targhan

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.426
  • Country: fr
    • Awards
Re: Using disc via firmware
« Reply #1 on: 12:00, 14 August 21 »
One thing you can do is reinit the ROM disc just before a disc operation. This little snippet, courtesy of @TomEtJerry, will allow you to do that. Click on "Initialisation du système disque".

I believe this is what I do on Demoniak 7.
like
0
No reactions
Targhan/Arkos

Arkos Tracker 2.0.1 now released! - Follow the news on Twitter!
Disark - A cross-platform Z80 disassembler/source converter
FDC Tool 1.1 - Read Amsdos files without the system

Imperial Mahjong
Orion Prime

Offline johnlobo

  • CPC464
  • **
  • Posts: 32
  • Country: es
    • JohnLobo at Itch.io
    • Awards
Re: Using disc via firmware
« Reply #2 on: 12: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.

Offline reidrac

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.046
  • Country: gb
  • Trying to gamedev!
    • index.php?action=treasury
    • usebox.net
    • Awards
Re: Using disc via firmware
« Reply #3 on: 13:30, 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).
like
0
No reactions
Released The Return of Traxtor, Golden Tail, Magica, The Dawn of Kernel, Kitsune`s Curse and Brick Rick for the CPC.

If you like my games and want to show some appreciation, you can always buy me a coffee.

Offline reidrac

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.046
  • Country: gb
  • Trying to gamedev!
    • index.php?action=treasury
    • usebox.net
    • Awards
Re: Using disc via firmware
« Reply #4 on: 13:33, 14 August 21 »
One thing you can do is reinit the ROM disc just before a disc operation. This little snippet, courtesy of @TomEtJerry, 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!
« Last Edit: 14:24, 14 August 21 by reidrac »
like
0
No reactions
Released The Return of Traxtor, Golden Tail, Magica, The Dawn of Kernel, Kitsune`s Curse and Brick Rick for the CPC.

If you like my games and want to show some appreciation, you can always buy me a coffee.

Offline reidrac

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.046
  • Country: gb
  • Trying to gamedev!
    • index.php?action=treasury
    • usebox.net
    • Awards
Re: Using disc via firmware
« Reply #5 on: 18: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 for the pointer and @TomEtJerry for sharing the code!

EDIT: also I've been reading the firmware disassm in @arnoldemu's website. Very useful!
« Last Edit: 19:02, 14 August 21 by reidrac »
like
0
No reactions
Released The Return of Traxtor, Golden Tail, Magica, The Dawn of Kernel, Kitsune`s Curse and Brick Rick for the CPC.

If you like my games and want to show some appreciation, you can always buy me a coffee.

Offline Arnaud

  • Supporter
  • 6128 Plus
  • *
  • Posts: 708
  • Country: fr
    • Awards
Re: Using disc via firmware
« Reply #6 on: 10: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 ?
like
0
No reactions

Offline reidrac

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.046
  • Country: gb
  • Trying to gamedev!
    • index.php?action=treasury
    • usebox.net
    • Awards
Re: Using disc via firmware
« Reply #7 on: 10:37, 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.
« Last Edit: 10:41, 15 August 21 by reidrac »
like
0
No reactions
Released The Return of Traxtor, Golden Tail, Magica, The Dawn of Kernel, Kitsune`s Curse and Brick Rick for the CPC.

If you like my games and want to show some appreciation, you can always buy me a coffee.