News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

New assembler library for reading/writing to/from tape and disk without firmware

Started by santi.ontanon, 20:31, 19 October 24

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

santi.ontanon

Hi! I have recently been working on some assembler code to read/write to/from tapes and disks in CPC without using the firmware, and I put a first version of my code in Github today: https://github.com/santiontanon/paket-cpcio

I developed these libraries as part of the PAKET engine with which we are creating point and click games (the first one, "The Key: Episode 1" has already been released, but we have 2 more on the pipeline). But I thought they might be useful on their own, so, I thought I'd put them in Github separately :)

Some comments and questions though:
1) The main goal of these libraries is to be able to run without having to bring the firmware back, which (at least to me), has always seemed a bit problematic.
2) To create these libraries (for for tapes and disks), what I did was to start from a disassembly of the CPC firmware and AMSDOS, identify the necessary functions to interface with tape/disk, extract them out of the firmware, and then document them and simplify them. The tape ones were quite easy, and my library is very small. So, I am quite happy with it. The disk interface is a bit more complex and still probably needs some work to make smaller (now that I understand how the disk I/O works, I think its size can be cut in half at least, with some work).
3) So, my question is about testing: the tape one we have tested in real hardware and all works perfect. But the disk one, since disks are hard to come by in CPC nowadays, I have not dated try it in real hardware yet. It all works perfect in emulators, but never tried it in a real CPC. For these types of things how would people recommend me testing this?


MoteroV4

Quote from: santi.ontanon on 20:31, 19 October 24But the disk one, since disks are hard to come by in CPC nowadays, I have not dated try it in real hardware yet. It all works perfect in emulators, but never tried it in a real CPC. For these types of things how would people recommend me testing this?


I use since 2019 the typical PC 3.5" floppy drive connected externally to a 6128 (as a 2nd drive) through the expansion bus. With one switch the behavior is selected as units A-B or B-A and with another the side 1-2. Having the DDI-1 controller I suppose that you can also connect to a 464 but I have not tried it.
Released cpc games: Memtrainer, El Gerente (Remake)

Jean-Marie

Thank you, although there was already a tool to read/write Discs without using firmware :  FDC Tools V1.1
I just want you to avoid "reinventing the wheel" :)

Also, in PAKETDSK.ASM, there is a duplicate line :
ld hl, AMSDOS_work_RAM_sector_buffer  ; + #02b0
    ld (memory_sector_buffer_ptr), hl
    ld (memory_sector_buffer_ptr), hl

In paketdsk-internal, you can simplify the cmp HL,DE
; cp HL, DE
cp_hl_de:
    push hl
    or a
    sbc hl, de
    pop hl
    ret  

with: 
cp_hl_de:
or a        ;reset CF
sbc hl, de
add hl,de   ;restore HL : 16 bit ADD doesn't change ZF, but it changes CF (with its previous value in this case)
ret

Off-topic: I've just figured out you were the author of Westen House on MSX 😮
Congrats! I played it on an emulator when it was released (and finished it :D).
Any chance to see it on CPC one day?!

santi.ontanon

MoteroV4: Thanks!!! I would feel better about damaging 3.5'' disks haha. I'll ask some CPC friends to see if I can test it on theirs, since I think one of them has one too! great idea!

Jean-Marie: Oh! I did not know about FDC-Tools! I just downloaded them and took a look. They are cool! Much simpler than PAKETDSK and use less space (they also have much less functionality, of course, since PAKETDSK has the full firmware functionality, like encrypting files, saving previous copies of a file as .BAK in case you overwrite, allowing files larger than 16KB that use multiple extents, etc.), but still, if I would have known those existed I would have just probably used them haha :) (I did spend qute some time searching and didn't find anything though!). In any case, now I have them, and if they are useful to anyone, then no time wasted :)

And about the duplicate line, oh! that is a bug! the second one was supposed to be different! Fixed, thanks for noticing! And indeed, lots of things can be simplified, I have started simplifying things from the firmware version, but I only did a bit of work on that direction. I actually think the code could be probably cut in half with some work (the firmware does things in VERY convoluted ways!)

And indeed, Westen House is my game, haha, thanks for the kind words! About a CPC port, not sure if a port, since for CPC, the game would probably have been very different (it was built with MSX limitations in mind). But never say "no" trying to do an isometric in CPC ;)

Powered by SMFPacks Menu Editor Mod