Page 1 of 1

Graphics on a Schneider JOYCE (Amstrad PCW 8256 or 8512)

Posted: Sun Jan 15, 2023 12:25 pm
by bbock
I'm not really new to the zx88dk; I have been using it for years on the ZX81, ZX Spectrum, and Amstrad NC100 platforms. Currently I am trying to use the cross compiler toolkit for the JOYCE (aka Amstrad PCW 8256 or 8512) platform. I thought I post my first steps here to make it easier for others trying to do the same thing.

My "hello world" code in a file named hellogfx.c is:

Code: Select all

#include <stdio.h>
#include <graphics.h>

int main(void)
{
    clg();
    printf("%cH", 27); // ESC H = VT100 cursor home
    printf("\n\n  graphics demo");
    
    plot(360, 128);
    
    draw(10, 10, 710, 10);
    drawto(710, 250);
    drawto(10, 250);
    drawto(10, 10);
    
    circle(360, 128, 80, 10);

    getchar();
    clg();
    printf("%c1", 27); // ESC 1 = switch on status bar
    printf("%ce", 27); // ESC e = show cursor
    
    return 0;
}
To compile this very basic code I use a batch file on Windows. The batch file content is:

Code: Select all

@echo off
set files=hellogfx.c
zcc +cpm -subtype=pcw80 -create-app %files% -o hellogfx.com
To test the code generated I copy the file hellogfx.com to the ramdisc folder of CP/M Box, a marvellous JOYCE emulator (the best, if you ask me). Then I can start the program from the M: drive.

cpmbox.png

Re: Graphics on a Schneider JOYCE (Amstrad PCW 8256 or 8512)

Posted: Mon Jan 16, 2023 3:18 pm
by stefano
Glad to see you choose the native libraries :)
For the ones feeling adventurous, there's a limited support for GSX too..
https://z88dk.org/forum/viewtopic.php?p ... Gsx#p19631

Re: Graphics on a Schneider JOYCE (Amstrad PCW 8256 or 8512)

Posted: Mon Jan 16, 2023 6:22 pm
by bbock
Hi stefano,
thank you for the hint. I have seen the GSX support in z88dk already, and I know quite a lot about GSX - I've used it with other programming languages. But most of the time I keep away from GSX, because of its overhead due to the abstraction. My next steps will be porting some of the libraries and programs I wrote in TurboPascal. Later I might come back to GSX again.

Re: Graphics on a Schneider JOYCE (Amstrad PCW 8256 or 8512)

Posted: Tue Jan 17, 2023 5:51 pm
by stefano
I totally agree, it's difficult to use, load, and takes a lot of memory.
BTW there's a bit of z88dk API compatibility shim I've set up already, just in case someone wants to send graphics to a printer :D

graphics.h and zsdcc

Posted: Fri Feb 03, 2023 10:34 am
by bbock
The above graphics test program compiles fine using the standard compiler sccz80, but when I try to compile it using zsdcc, the compile fails:

Code: Select all

zcc +cpm -subtype=pcw80 -compiler=sdcc -create-app %files% -o hellogfx.com

D:\RetroComputing\dev\z88dk_Joyce\graphic_hello>make
hellogfx.c:483: error: undefined symbol: _draw_callee
  ^---- _draw_callee
Do I have to add some extra library for zsdcc?

Re: graphics.h and zsdcc

Posted: Fri Feb 03, 2023 8:08 pm
by dom
bbock wrote: Fri Feb 03, 2023 10:34 am The above graphics test program compiles fine using the standard compiler sccz80, but when I try to compile it using zsdcc, the compile fails:

Code: Select all

zcc +cpm -subtype=pcw80 -compiler=sdcc -create-app %files% -o hellogfx.com

D:\RetroComputing\dev\z88dk_Joyce\graphic_hello>make
hellogfx.c:483: error: undefined symbol: _draw_callee
  ^---- _draw_callee
Do I have to add some extra library for zsdcc?
Nope, there was just a missing export, so should be fixed in the next nightly.

Re: Graphics on a Schneider JOYCE (Amstrad PCW 8256 or 8512)

Posted: Sun Feb 19, 2023 4:32 pm
by bbock
Sorry for answering late...

First of all I can confirm that it works with zsdcc now, thank you very much for fixing it so quickly.

But there is one more thing I don't understand: as far as I understood, the -create-app option creates an application. What an application finally is, depends on the platform. In case of a CP/M target with subtype of either pcw80 or pcw40, the option creates .dsk disk image file with 80 or 40 tracks, respectively, which can be opened by the CP/M Box emulator, for example. So far, so good.

But there must me something else -create-app is doing behind the scenes, because when I compile my vector graphics application using

Code: Select all

zcc +cpm -subtype=pcw80 -compiler=sdcc -O2 -lm -DAMALLOC -create-app %files% -o %comfile%.com
everything is fine; the graphics are drawn (at high speed, by the way). Leaving out the -create-app option results in no graphics shown and an application crash:

Code: Select all

zcc +cpm -subtype=pcw80 -compiler=sdcc -O2 -lm -DAMALLOC %files% -o %comfile%.com
The behaviour is the same for both compilers, zsdcc and sccz80.

Any ideas?

Re: Graphics on a Schneider JOYCE (Amstrad PCW 8256 or 8512)

Posted: Sun Feb 19, 2023 11:39 pm
by dom
I think its also appending the program_HIMEM.bin file that’s generated.

There’s a handful of targets, and pcw is one of them I guess, where the screen memory is paged in over where the program is so the screen access code is located out of the way.

I think there should be a way to keep it all in one binary at link time but I’ve not explored it.

Re: Graphics on a Schneider JOYCE (Amstrad PCW 8256 or 8512)

Posted: Tue Feb 21, 2023 3:11 pm
by bbock
So I guess I have to continue creating .dsk files I don't need. It seems -create-app is mandatory when using the graphics library only. For non-graphic applications I can probably skip the option.

Re: Graphics on a Schneider JOYCE (Amstrad PCW 8256 or 8512)

Posted: Tue Feb 21, 2023 4:11 pm
by dom
I looked into using PHASE, but unfortunately it doesn't work as I thought.

All appmake is doing here is "cat program_HIMEM.bin >> program.bin"

EDIT: So yes, -create-app is mandatory and there's no way to disable .dsk file generation and just output the combined .com file.

Re: Graphics on a Schneider JOYCE (Amstrad PCW 8256 or 8512)

Posted: Fri Feb 24, 2023 2:15 pm
by bbock
Tanks again for your effort. I'd like to point you to some of my latest developments - maybe to let you know your help is not in vain:
  1. Forms engine for Amstrad PCW (CP/M Plus): https://joyceforum.de/viewtopic.php?p=645 The forms package allows for easy development of input forms in applications featuring text fields, number fields, filename fields, etc. with free positioning on screen and variable lenghts. A documentation with a comprehensive code example is available, too.
  2. Vector graphics application named VECREAD for Amstrad PWC (CP/M Plus): https://joyceforum.de/viewtopic.php?p=639 The software displays vector graphics from files with a format designed for 8-Bit computers. These files can be created using my Java application TinySVG, which converts the Internet graphics format SVG into VEC or VE2 files: https://joyceforum.de/viewtopic.php?p=638
  3. Soon to come: HPGL Interpreter to display HP-GL graphics, often found in *.plt files. The software is working already, except for the PBM graphics file output.
  4. Work in progress: a z88dk C tutorial in German language, based on the Amstrad PCW: https://joyceforum.de/viewtopic.php?p=682

Re: Graphics on a Schneider JOYCE (Amstrad PCW 8256 or 8512)

Posted: Sat Feb 25, 2023 8:35 pm
by stefano
the svg 2 tiny vector format reminds me something.. ;)
have you spotted the draw_profile() function?
in the z88dk/support folder you should find the svg2c tool

Re: Graphics on a Schneider JOYCE (Amstrad PCW 8256 or 8512)

Posted: Tue Feb 28, 2023 6:40 pm
by bbock
Hello stefano,

yes, you've seen my TinySVG already, and I have seen your SVG approach, too: https://www.sinclairzxworld.com/viewtopic.php?p=43280
Thank you for pointing me toward the draw_profile() function - I've seen it already. The comments on the wiki are a bit vague, but I guess I should just try it. I'm afraid I cannot find the svg2c tool... But I assume you're talking about "z80svg.c", aren't you?

Re: Graphics on a Schneider JOYCE (Amstrad PCW 8256 or 8512)

Posted: Wed Mar 01, 2023 11:26 am
by stefano
Yes I am.. sorry it's a fuzzy period for me !
I'm mentioning it because it relies on a consolidated function set we have worked on in the past years, line drawing and surfaces as well, which makes it quite portable.
You might be interested in borrowing something.