Custom CPM target | Z80-Retro!

Post Reply
productiondave
New member
Posts: 6
Joined: Wed Jan 10, 2024 11:32 pm

Custom CPM target | Z80-Retro!

Post by productiondave »

Hi,

I am looking to add support for a CPM Subtype for the Johns Basement Z80 Retro!. (https://github.com/Z80-Retro)

I figured i would start simple by getting it's unique disk layout sorted.

The cpmtools diskdefs file we are using is:

Code: Select all

diskdef z80-retro-8k-8m
  seclen 128
  tracks 16384
  sectrk 4
  blocksize 8192
  maxdir 512
  skew 1
  boottrk 32
  os 2.2
end
I appear to be struggling to get appmake to create a file that I can read back with cpmtools.

This is what I have put into appmake:
I guess I am missing something in the translation, because when I attempt to cpmls the image I get I just get garbage on the output. If I use something like NSHD8 it works fine with the appropriate diskdefs config. (IE: I can compile in Z88dk and then list the contents with cpmls) Unfortuantely the Z80-Retro! BIOS is configured for this 8k/8m setup.

Code: Select all

   ...
   ...
   ...
    { "z80retro",  "Z80 Retro (8mb)",       &z80retro_spec, 0, NULL, 1 },
    ...
    ...
    ...
static disc_spec z80retro_spec = {
    .name = "Z80Retro",
     .sectors_per_track = 4,
     .tracks = 16384,
     .sides = 1,
     .sector_size = 128,
     .gap3_length = 0x2a,   //?
     .filler_byte = 0xe5,     //?
     .boottracks = 32,
     .directory_entries = 512,
     .alternate_sides = 0,
     .extent_size = 8192,
     .byte_size_extents = 0,
     .first_sector_offset = 0,
     .has_skew = 1,
 };
My makefile is:

Code: Select all

TOP=.
BASEDIR = $(TOP)
Z88DIR = $(TOP)/../z88dk-dev
ZCC = $(Z88DIR)/bin/zcc
export PATH := $(Z88DIR)/bin/:$(PATH)
export ZCCCFG := $(Z88DIR)/lib/config

CFLAGS = +cpm -subtype z80retro --list -compiler=sdcc -create-app -O3 --opt-code-speed

all:
        $(ZCC) $(CFLAGS) -o hello.com main.c

clean:
        rm -f *.lis *.a *.bin *.o *.img *.com
The source I am compiling is just a hello world app. It compiles fine and the output is a .com file and a .img file together with the .lis file.

Code: Select all

#include <stdio.h>

void main(void) {
    printf("Hello, World!");
}
I do have another question:

For the custom stuff that I will eventually want to add support for, is there a serial console only CPM subtype I can copy to learn how to set it all up? Most of the targets have consoles on VDP. The Z80 Retro does not have a GFX console, It does have a VDP, but it's not programmed to function as a console. Only as an on demand peripheral. IE: A CPM program might init the VDP and the use it. But CPM itself is serial only.

Hope my questions make sense.

Thanks!
User avatar
dom
Well known member
Posts: 2317
Joined: Sun Jul 15, 2007 10:01 pm

Re: Custom CPM target | Z80-Retro!

Post by dom »

When you set has_skew in the table, you also need to write a list of the sector orders - that might explain why your directory listing is off. Alternatively don't bother with skew and use a container - the skew is most useful for the raw images.

By default, the CP/M target uses BDOS to handle std* so as long as the serial port is hooked up to the BDOS console functions everything should be ok.

conio.h is also partially supported if you define CONIO_NATIVE_VT100 or CONIO_NATIVE_VT52 before including conio.h
productiondave
New member
Posts: 6
Joined: Wed Jan 10, 2024 11:32 pm

Re: Custom CPM target | Z80-Retro!

Post by productiondave »

Thanks Dom,

I set skew to 0 and tried setting the container to dsk, but that failed for me. I was getting errors about stack smashing. In the end, it worked fine with the raw image type. I think I wasn't properly cleaning up the binaries between rebuilds of appmake. Now that I have figured out how to reliably do that, appmake is working for me.

Regarding the define CONIO_NATIVE_VT100 prior to including <conio.h> I get this. It compiles ok when I leave out the define. But the gotoxy() call on the retro doesn't do anything. I just get the text printed at the serial console as normal. Also tried calling clrscr() but that had no result either. My terminal software is configured for VT100.

Srouce:

Code: Select all

#define CONIO_NATIVE_VT100
#include <conio.h>

void main(void) {
    gotoxy(10,10);
    printf("Hello, World!");
}
Make reusult:

Code: Select all

make
rm -f *.lis *.a *.bin *.o *.img *.com *.dsk
./../z88dk-dev/bin/zcc +cpm -subtype z80retro --list -compiler=sdcc -O3 --opt-code-speed -o hello.com main.c
conio.h:42: macro 'textattr' redefined unidentically
        included from main.c:2
conio.h:96: macro 'gotoxy' redefined unidentically
        included from main.c:2
make: *** [Makefile:15: hello.com] Error 1
Anyway - am not too bothered about this for now. I figured I would look to see about adding Joystick support for the Retro! similar to how that's done in the Nabu as well as the VDP support. There is no native target option for the Z80-Retro so it's all within CPM. I will try to follow along with what was done for the Nabu and see how far I get.
Post Reply