Adding SVI boot disk support to appmake?

Post Reply
tschak909
Member
Posts: 83
Joined: Sun Sep 09, 2018 5:44 pm

Adding SVI boot disk support to appmake?

Post by tschak909 »

What would it take to add SVI boot disk support to appmake?

-Thom
User avatar
dom
Well known member
Posts: 1194
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

If it's a CP/M format disc then it's about 15 minutes work.

I'm suspecting it's not though - I'm guessing the BIOS loads a boot sector which is then responsible for loading the rest of the file?

Either way, some examples will help.
rzs
New member
Posts: 3
Joined: Thu Nov 01, 2018 9:17 pm

Post by rzs »

Here is the boot code from CP/M

The code puts the machine in 64k RAM mode and copies X sectors to a given location

Code: Select all

; -------------------------------------------------------------------------
;
;         Spectravideo SVI-328 CP/M Boot Sector
;
; -------------------------------------------------------------------------

;
;        CP/M size and entry definition
;
BIOSB        EQU        0E600h
;
;        Bank switching ports
;
PSGLAW        equ        88H                ; PSG latch port
PSGDAW        equ        8CH                ; PSG write port
PSGDAR        equ        90H                ; PSG read port
;
;        Address definition
;
FDCCMD        equ        30H                ; Command to FDC
FDCSTT        equ        FDCCMD                ; Status from FDC
FDCTRK        equ        31H                ; Track register
FDCSEC        equ        32H                ; Sector register
FDCDAT        equ        33H                ; Data register
;
;        Command definition
;
RDCMD        equ        10000000B        ; Sector read command
;
;        Miscellaneous I/O ports
;
INTRQP        equ        34H                ; Address of INTRQ and DRQ
INTRQ        equ        10000000B        ; Interrupt request bit
DRQ        equ        01000000B        ; Data request bit
;
DENSEL        equ        38H                ; Address of density select flag
DESMFM        equ        00000000B        ; Density MFM bit
DESFM        equ        00000001B        ; Density FM bit
DESMFM2 equ     00000010B       ; Density MFM bit and side 2

        org        0C100h

        ld        a, 11011101b        ; Bank 21
        out        (PSGDAW), a        ; Register already set in ROM, just enable bank

        ld        sp, 100h        ; Set temporary stack pointer

        ld        b, 17
        call        RDMSEC                ; Read remaining sectors of first track

        xor        a                
        out        (DENSEL), a        ; Set MFM density for rest of tracks
        ld        hl, 256
        ld        (BYTSEC+1), hl        ; Modify sector size
        ld        a, 18
        ld        (MAXSEC+1), a        ; Modify number of sectors / track

        ld        b, 5
        call        RDMSEC                ; Read remaing part

        jp        BIOSB                ; Jump to cold boot routine

;
;        Sector read routine
;
RDMSEC:
        push        bc
SETSEC:
        ld        a, 2
        out        (FDCSEC), a        ; Write to sector register

        ld        a, RDCMD        ; Sector read command
        out        (FDCCMD), a        ; Issue read command

        ld        c, FDCDAT
        ex        (sp), hl
        ex        (sp), hl
        ex        (sp), hl
        ex        (sp), hl
SETBUF:
        ld        hl, BIOSB        ; Load destination address
RDLOP:
        in        a, (INTRQP)        ; Read data request port
        add        a, a
        jr        c, RDONE        ; Read confirmed
        jp        p, RDLOP        ; No data valid
        ini                        ; Read data from FDC
        jr        RDLOP

RDONE:
        in        a, (FDCSTT)
        and        00011100b        ; Any errors detected?
        jr        nz, SETSEC
        ld        hl, (SETBUF+1)
BYTSEC:
        ld        de, 128                ; Sector size
        add        hl, de
        ld        (SETBUF+1), hl
        ld        hl,  SETSEC+1
        inc        (hl)                ; Increase sector count
        ld        a, (hl)
MAXSEC:
        cp        19                ; Read all sectors?
        jr        c, DECSCZ

        ld        a, 1010010b        ; Issue        FDC STEP IN command
        out        (FDCCMD), a

        ld        (hl), 1

        ex        (sp), hl        ; Wait for the drive head
        ex        (sp), hl
        ex        (sp), hl
        ex        (sp), hl
        ex        (sp), hl
        ex        (sp), hl
        ex        (sp), hl
        ex        (sp), hl
        ex        (sp), hl
        ex        (sp), hl
        ex        (sp), hl
        ex        (sp), hl
        ex        (sp), hl
        ex        (sp), hl
        ex        (sp), hl
        ex        (sp), hl
BUSY:
        in        a, (FDCSTT)        ; Get FDC status
        rra                        ; Look busy bit [LSB]
        jr        c, BUSY                ; Wait
DECSCZ:
        pop        bc
        djnz        RDMSEC
        ret

; -------------------------------------------------------------------------

        db        0, 0, 0, 0, 0, 0, 0, 0

        end
User avatar
dom
Well known member
Posts: 1194
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

That's wonderful - thank you for saving me a bit of time figuring that out for myself! I've just started working on adding support so hopefully I'll have it working this coming weekend.

It's irrelevant to this thread, but +cpm -subtype=svi will now create a CP/M disk image suitable for usage with CP/M on the svi
User avatar
dom
Well known member
Posts: 1194
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

I had a few problems with the FM/MFM transition and the .dsk format doesn't seem to work in Mame for this target - it looks like only IMD is supported.

However, there's now a new -subtype=disk option to the +svi target which will generate a raw .SVI image for use in Mame.

I've tested it in Mame with the following option:

./mame64 svi328 -exp sv601 -exp:sv601:1 sv801 -flop1 a.svi
tschak909
Member
Posts: 83
Joined: Sun Sep 09, 2018 5:44 pm

Post by tschak909 »

*hug* awesome, thanks man :)

-Thom
User avatar
dom
Well known member
Posts: 1194
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

No worries. I?m impatient and hate waiting for tapes to load so I?m much happier with a disc image.

It looks like there?s an 80 column card which might be good to support as well.
Post Reply