Compare commits

...

2 Commits

Author SHA1 Message Date
Virgil Dupras 49d7a7f435 z80mbc2: add BLK support 2020-06-22 21:21:24 -04:00
Virgil Dupras a7660fba0e z80mbc2: new recipe
ref #82
2020-06-22 19:09:41 -04:00
3 changed files with 106 additions and 0 deletions

13
recipes/z80mbc2/Makefile Normal file
View File

@ -0,0 +1,13 @@
TARGET = os.bin
BASEDIR = ../..
EDIR = $(BASEDIR)/emul
STAGE = $(EDIR)/stage
.PHONY: all
all: $(TARGET)
$(TARGET): xcomp.fs $(STAGE)
cat xcomp.fs | $(STAGE) > $@
$(STAGE):
$(MAKE) -C $(EDIR) stage

54
recipes/z80mbc2/README.md Normal file
View File

@ -0,0 +1,54 @@
# Z80-MBC2
The [Z80-MBC2][link] combines a Z80 and an ATMEGA32A to provide a CP/m capable
computing environment. It features a SD card bootloader which makes running
Collapse OS on it rather simple.
## Recipe
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
the SD card.
### Gathering parts
* A Z80-MBC2 computer with its SD card module and a properly flashed "IOS" on
the ATMega32A.
* A FTDI-to-TTL cable to connect to the serial port.
### Building the binary
Running `make` will yield `os.bin` which is what we want.
### Running on the Z80-MBC2
Mount the SD card on your modern computer and copy `os.bin` as `autoboot.bin`,
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
adapter to it (red: VCC, black: GND, green: TX, white: RX).
The FTDI adapter will show up as something like `ttyUSB0` (or `ttyU0` on
OpenBSD). Connect to it with `screen` or `cu` or whatever you like. Baud rate of
the Z80-MBC2 appears to be hardcoded to 115200.
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
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.
[link]: https://hackaday.io/project/159973-z80-mbc2-a-4-ics-homebrew-z80-computer

39
recipes/z80mbc2/xcomp.fs Normal file
View File

@ -0,0 +1,39 @@
0xff00 CONSTANT RS_ADDR 0xfffa CONSTANT PS_ADDR
RS_ADDR 0x80 - CONSTANT RAMSTART
212 LOAD ( z80 assembler )
262 LOAD ( xcomp ) 270 LOAD ( xcomp overrides )
282 LOAD ( boot.z80 ) 353 LOAD ( xcomp core low )
CODE (emit)
A 1 LDrn, 1 OUTnA, HL POPqq, A L LDrr, 0 OUTnA,
;CODE
CODE (key)
BEGIN, 1 INAn, A INCr, JRZ, AGAIN,
A DECr, PUSHA,
;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 )
(entry) _
( Update LATEST )
PC ORG @ 8 + !
," CURRENT @ HERE ! BLK$ FD$ ' FD@ BLK@* ! ' FD! BLK!* ! " EOT,
ORG @ 256 /MOD 2 PC! 2 PC!
H@ 256 /MOD 2 PC! 2 PC!