Author Topic: Porting my multi-platform game to CPC with Z88DK  (Read 981 times)

0 Members and 1 Guest are viewing this topic.

Offline Fabrizio

  • CPC464
  • **
  • Posts: 34
  • Country: fr
  • Liked: 16
  • Likes Given: 1
I am trying to port my multi-platform 8-bit open source game
 https://github.com/Fabrizio-Caruso/ASCII-CHASE/

to multiple Z80 targets.
My game is written in almost pure ANSI C and it exists in about 14 different 8 bit versions
(mostly for 6502 through the CC65 cross compiler but also for the Spectrum through the Z88DK cross compiler)

I have succeeded with the Spectrum port but I am struggling with the CPC target, which seems broken
in Z88DK.

Anyone has tried to use Z88DK with the CPC target?


I am also trying to compile a trivial program such as the test example in
 https://www.z88dk.org/wiki/doku.php?id=examples:snippets:ansitest
For simplicity I am compiling with the -subtype=wav option and I am using the WinApe emulator
My complete compile line is:
 zcc +cpc -clib=ansi -subtype=wav -lndos -create-app -o %deliverables\cpc_ansitest ansitest.c
The program is loaded within WinApe with
 |tape
 run"
The result is a blue screen with nothing shown.
I have also tried to compile my game or just trivial snippets of code with similar results.
Am I doing something wrong?
Fabrizio

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.336
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2271
  • Likes Given: 3478
Re: Porting my multi-platform game to CPC with Z88DK
« Reply #1 on: 16:31, 30 July 17 »
I downloaded z88dk-win32-1.99B.zip. z88dk seems to be a little broken yes, or at least not obvious to use.

This was the only command-line that would compile without error for me:

zcc +cpc -clib=ansi -create-app -lcpcfs ansitest.c

This made a "a.bin" and a "a.cpc".

"a.cpc" is the one I can run.

If I tried "-subtype=wav" then I got a linker error because the subtype changes the crt0. Maybe I needed to link another library..

If I tried "-o cpc_ansitest.bin" I got a file without a header. This is wrong if you need to run the file.

So with the command-line I used you have two choices:

Use 2cdt to make a tape-image:

2cdt -n -r myprog a.cpc test.cdt

(-n means new file)
(-r means to add a.cpc but use the name 'myprog')

You can then use playtzx to make a wav from it.

OR use cpcxfs to make a disk image:

cpcxfs -nd myprog.dsk

this means create a new disk

cpcxfs myprog.dsk -p a.cpc myprog

this means to add a.cpc (but call it "myprog") to myprog.dsk

Both of these can be downloaded from www.cpctech.org.uk but you may need to build the executables of them.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.336
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2271
  • Likes Given: 3478
Re: Porting my multi-platform game to CPC with Z88DK
« Reply #2 on: 16:37, 30 July 17 »
btw, z88dk is "small-c", maybe better to use "sdcc" compiler.
sdcc.sourceforge.net

My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.843
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1067
  • Likes Given: 1789
Re: Porting my multi-platform game to CPC with Z88DK
« Reply #3 on: 13:18, 31 July 17 »
btw, z88dk is "small-c", maybe better to use "sdcc" compiler.
sdcc.sourceforge.net


I was reading on Genesis 8 that it's possible to use the SDCC Engine with Z88DK v1.99a, but that looks like old news from April 2016.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Offline reidrac

  • Supporter
  • 6128 Plus
  • *
  • Posts: 833
  • Country: gb
  • Trying to gamedev!
    • index.php?action=treasury
    • usebox.net
  • Liked: 1464
  • Likes Given: 834
Re: Porting my multi-platform game to CPC with Z88DK
« Reply #4 on: 17:44, 31 July 17 »
Unfortunately neither Z88DK or SDCC are trivial to use; that's one of the reasons for the CPCTelera to exist: it provides a preset development environment (it also provides a library of nice functions).

When I started developing games for the CPC I used Z88DK because that's what I was using for the Speccy; but then I moved to SDCC that, even with its quirks and issues, is better compiler than Z88DK.

So my advice would be to look at CPCTelera, even if you don't use any of the libraries, so you get all the tooling sorted.

Or you can put time on it (like I did!) and get SDCC to work your own way looking for the tools you need; and you may end with something pretty similar to what the CPCTelera provides but you'll learn a lot ;)
Released The Return of Traxtor, Golden Tail, Magica, The Dawn of Kernel and Kitsune`s Curse for the CPC.

If you like my games and want to show some appreciation, you can always buy me a coffee.

Offline SRS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 583
  • Country: de
  • Schneider CPC464 - what else ?
  • Liked: 571
  • Likes Given: 316
Re: Porting my multi-platform game to CPC with Z88DK
« Reply #5 on: 21:39, 01 August 17 »
Just "overflying" your source there are at least two issues for CPC conversion: you make use of MALLOC. This is quite bad (nearly not) supported for CPC in sdcc/z88dk. And you need a CONIO. Quite unusuale/not well supported for CPC, too.

If you can change that parts, CPCTELERA could be your friend.

I tried to compile you "minimal" with cpctelera. it is missing "joystick.h" i.e.

I added a simple conio from wiki: