z80mbc2: add BLK support

This commit is contained in:
Virgil Dupras 2020-06-22 21:21:24 -04:00
parent a7660fba0e
commit 49d7a7f435
2 changed files with 36 additions and 3 deletions

View File

@ -8,7 +8,7 @@ Collapse OS on it rather simple.
In this recipe, we're going to run Collapse OS on the Z80-MBC2, interfacing In this recipe, we're going to run Collapse OS on the Z80-MBC2, interfacing
through its serial port. We're going to use the MBC's API to implement BLK on through its serial port. We're going to use the MBC's API to implement BLK on
the SD card. (the BLK part isn't done yet. TODO) the SD card.
### Gathering parts ### Gathering parts
@ -25,6 +25,16 @@ Running `make` will yield `os.bin` which is what we want.
Mount the SD card on your modern computer and copy `os.bin` as `autoboot.bin`, Mount the SD card on your modern computer and copy `os.bin` as `autoboot.bin`,
overwriting the binary that was previously there. overwriting the binary that was previously there.
We also have to copy the blkfs over. This is done by using IOS' drive system.
Each `DSxNyy.DSK` file on the card is a drive, each drive has 512 track of 32
sectors of 512 bytes, so one drive is plenty for our needs. Collapse OS
hardcodes drive 0.
Each drive is part of a set. IOS theoretically supports up to 10 sets, but the
binary shipped by default only accepts 4. You have to overwrite an existing set.
I used set 3. So, copy `blkfs` to file `DS3N00.DSK`. If you want, you can change
the name of the set by changing the contents of `DS3NAM.DAT`.
Put back the SD card in the Z80-MBC2 and power it up by connecting the FTDI Put back the SD card in the Z80-MBC2 and power it up by connecting the FTDI
adapter to it (red: VCC, black: GND, green: TX, white: RX). adapter to it (red: VCC, black: GND, green: TX, white: RX).
@ -34,7 +44,10 @@ the Z80-MBC2 appears to be hardcoded to 115200.
Then, enable IOS program selection by holding RESET and USER at the same time, Then, enable IOS program selection by holding RESET and USER at the same time,
wait 2 seconds, releasing RESET, wait 2 seconds, releasing USER. You should then wait 2 seconds, releasing RESET, wait 2 seconds, releasing USER. You should then
be given a 1-8 choice, with 4 being "Autoboot". Type 4. be given a 1-8 choice.
You begin by selecting the proper disk set, which is through choice 8, then you
select the Autoboot binary through choice 4.
You are now in Collapse OS. You are now in Collapse OS.

View File

@ -10,10 +10,30 @@ CODE (key)
BEGIN, 1 INAn, A INCr, JRZ, AGAIN, BEGIN, 1 INAn, A INCr, JRZ, AGAIN,
A DECr, PUSHA, A DECr, PUSHA,
;CODE ;CODE
: _sel ( sec )
( 32 sectors per track, 512 tracks per disk )
32 /MOD ( addr sec trk )
0x0a ( seltrk ) 1 PC! 0 PC! 0 0 PC! ( addr sec )
0x0b ( selsec ) 1 PC! 0 PC! ( addr ) ;
: _ ( addr )
( get 512 bytes )
0x86 ( readsec ) 1 PC!
512 0 DO 0 PC@ SWAP C!+ LOOP DROP
;
: FD@ 2 * DUP _sel BLK( _ 1+ _sel BLK( 512 + _ ;
: _ ( addr )
( write 512 bytes )
0x0c ( writesec ) 1 PC!
512 0 DO C@+ 0 PC! LOOP DROP
;
: FD! 2 * DUP _sel BLK( _ 1+ _sel BLK( 512 + _ ;
: FD$ ( select disk 0 )
0x09 ( seldisk ) 1 PC! 0 0 PC! ( sel disk 0 )
;
380 LOAD ( xcomp core high ) 380 LOAD ( xcomp core high )
(entry) _ (entry) _
( Update LATEST ) ( Update LATEST )
PC ORG @ 8 + ! PC ORG @ 8 + !
," CURRENT @ HERE ! " EOT, ," CURRENT @ HERE ! BLK$ FD$ ' FD@ BLK@* ! ' FD! BLK!* ! " EOT,
ORG @ 256 /MOD 2 PC! 2 PC! ORG @ 256 /MOD 2 PC! 2 PC!
H@ 256 /MOD 2 PC! 2 PC! H@ 256 /MOD 2 PC! 2 PC!