Z88DK Updates break NABU-LIB compilation

The RetroNET NABU-LIB z88dk C Library for creating games and software.
User avatar
productiondave
Posts: 117
Joined: Tue Mar 28, 2023 10:01 pm

Z88DK Updates break NABU-LIB compilation

Post by productiondave »

Hi,

Merry NABUXMAS!

Two issues to discuss:

ISSUE 1: Compilation ERRORS

As mentioned here: https://github.com/DJSures/NABU-LIB/issues/9 as well as in my own independent discovery, it looks like an update to Z88DK post May 2023 causes anything including NABU-LIB.h to fail.

I did a bit of research into it and was not able to find the specific commit on Z88DK that causes the issue for us. Instead, I tracked down the inline assembly that triggers the error.

For example:
https://github.com/DJSures/NABU-LIB/blo ... -LIB.c#L56

Code: Select all

ld (INTERUPT_VECTOR_MAP_ADDRESS + 4), hl;
The compiler appears to have an issue with this. The expression within the brackets is somehow optimized into an internal pseudo instruction ldh(4),hl

Code: Select all

  ^---- ld ( 0xff00 + 4), hl
      ^---- ldh(4),hl
../../../tetris/tetris.c:2264: error: syntax error
As an experiment, I tried changing the line to:

Code: Select all

ld (0xFF04), hl;
which resulted in the compiler working.

ISSUE 2: Compiler Warnings

The compiler now does not like functions without proper prototypes. I believe this relates to the version of the C standard supported. I don't recall which version, but do recall reading something about it.

Code: Select all

../../NABU-LIB/NABULIB/NABU-LIB.h:394: warning 283: function declarator with no prototype
The fix for this is to replace every function declaration that doesn't have any arguments to explicitly declare the argument list as void.

Code: Select all

int mySnowflakeFunction(void) {
 ...
 }
 
I was able to use a search and replace to get most of them.

DJ, Do you want a pull request? Or would you like to investigate the strange syntax error for that inline assembly?

I don't think that hardcoding those 0xFF04, 0xFF06 values is a problem. But it would be good for you to confirm it too.

Thanks!
User avatar
DJ Sures
Posts: 347
Joined: Tue Mar 28, 2023 8:36 pm
Location: nabu.ca
Contact:

Re: Z88DK Updates break NABU-LIB compilation

Post by DJ Sures »

I’ll give those quick updates this weekend for ya. I’m a bit disappointed that the compiler went backward in time for compatibility of supporting those recent features. And recent as in 1980’s
User avatar
productiondave
Posts: 117
Joined: Tue Mar 28, 2023 10:01 pm

Re: Z88DK Updates break NABU-LIB compilation

Post by productiondave »

Awesome! Thanks DJ
User avatar
DJ Sures
Posts: 347
Joined: Tue Mar 28, 2023 8:36 pm
Location: nabu.ca
Contact:

Re: Z88DK Updates break NABU-LIB compilation

Post by DJ Sures »

The new z88dk has many other issues that break most of my existing programs - including my cloud cpm bios. I will host the last working version and provide a link to their nightly build page for the respective version. I don't have time to continually update my code for the direction they're taking the compiler by removing features. Their community is very supportive, so you can always buzz in and see if they have solutions or reasoning for the breaking changes.

Do you have dependencies on the latest z88dk builds that your new applications require? If not, we'll host a nabu z88dk compatible version that we can all enjoy without breaking changes.
User avatar
productiondave
Posts: 117
Joined: Tue Mar 28, 2023 10:01 pm

Re: Z88DK Updates break NABU-LIB compilation

Post by productiondave »

I'm not using anything specific for nabu games. I'm aware of some contributions to the nabu build target for fixed paddle support by brinohn but I don't have a paddle so never bothered coding for one.
User avatar
DJ Sures
Posts: 347
Joined: Tue Mar 28, 2023 8:36 pm
Location: nabu.ca
Contact:

Re: Z88DK Updates break NABU-LIB compilation

Post by DJ Sures »

I can add paddle support to nabu lib then :)
User avatar
productiondave
Posts: 117
Joined: Tue Mar 28, 2023 10:01 pm

Re: Z88DK Updates break NABU-LIB compilation

Post by productiondave »

In the meantime, I have updated my fork of NABU-LIB with the changes needed to get the compilation to work with z88dk version 2.3 https://github.com/z88dk/z88dk/releases/tag/v2.3

I have also updated the NABU-GAMES code to work with it.

While I am not too keen on pinning the version of the compiler for my games, I can understand your logic. Perhaps we should be compiling like Leo on the NABU using compilers released in 1984. :mrgreen:

Jokes aside, I think the underlying SDCC compiler is what changed and is what is causing the issues. If we use the sccz80 compiler option we might have a different experience. But then probably a major overhaul of code will be needed.

So if I am going to keep up to date with the Joneses, I should probably investigate the Z88DK native nabu support in Z88DK. It might be that much of the functionality provided by NABU-LIB (at least for my purposes) is provided natively. I will have a look to see how good it is. For example, it has built in support for the TMS VDP including support for F18A.

It has built in support for Joysticks and paddles etc, but I have an open question on the forums as it would appear this is limited to native NABU and won't work with CPM.

In terms of HCCA stuff, I don't know yet... I am not sure there have been many people developing against the NABU target in Z88DK besides a few people on this forum and in the discord. I could be the first to try games support on Z88DK for CPM...
User avatar
productiondave
Posts: 117
Joined: Tue Mar 28, 2023 10:01 pm

Re: Z88DK Updates break NABU-LIB compilation

Post by productiondave »

Here is an example of the fraembuffer test code I wrote before but without NABU lib and instead using standard libraries shipped with Z88DK.

In this case, I had to impliment my own framebuffer, but that's not too hard. This is running MODE 1.. I need to do some more figuring out for Mode 2, as it has that 1 third thing on the pattern name table. I don't think it's too hard. The header is here if you want to read it. https://github.com/z88dk/z88dk/blob/mas ... /tms99x8.h

Code: Select all

#include "video/tms99x8.h"
#include <conio.h>
#include <font/font.h>
#include <sys/ioctl.h>

#define MODE mode_1

uint8_t framebuf[0x300];

void clearfb(void) {
        uint8_t *p = framebuf;
        while(&p < 0x300) {
                *p = 0x20;
                p++;
        }
}

void fillfb(int8_t c) {
        for (uint16_t i=0; i<0x300; i++) {
                framebuf[i] = c;
        }
}

void flushfb(void) {
        //check vdp_status
        while (vdp_get_status(0) & 0x80 == 0) {
                ;;
        }
        vdp_vwrite(framebuf, _tms9918_pattern_name, 0x300);
}

void main(void) {
        uint8_t *p = framebuf;
        uint8_t c = 0x19;

        vdp_set_mode(MODE);
        vdp_set_border(VDP_INK_DARK_YELLOW);

        clearfb();

        void *font_ptr = &font_8x8_msx_system;
        console_ioctl(IOCTL_GENCON_SET_MODE, &MODE);
        console_ioctl(IOCTL_GENCON_SET_FONT32, &font_ptr);

        //vdp_vfill(_tms9918_pattern_name, 0x20, 0x300);
        flushfb();

        while(1) {
                fillfb(c);
                c++;
                if(c > 0x7f)
                        c = 0x19;

                flushfb();

                if (kbhit() != 0) {
                        break;
                }
        }
}
Compiled to run on CPM with this:

Code: Select all

./../z88dk/bin/zcc +cpm -subtype naburn -lnabu_int --list -create-app -O3 --opt-code-speed -o tester.com main.c
cp tester.img /mnt/c/dev/nabu/Nabu\ Internet\ Adapter/store/c.dsk
There are no glitchy artifacts at all on my hardware. (F18A). It works perfectly - perhaps I will try it with a stock VDP at some point too.
I will keep experimenting with sound support etc.

If I follow this path to it's logical conclusion, I will be in a pickle with the Z80-Retro! as that has zero support on Z88DK... Different IO Addresses etc.
User avatar
AGMS
Posts: 12
Joined: Tue Feb 20, 2024 9:56 pm

Re: Z88DK Updates break NABU-LIB compilation

Post by AGMS »

I finally got my NABU development environment working. After a few days of trying various things and reading documentation and forums, I finally got Z88DK to work in Fedora 39 Linux with MAME emulating the NABU. The long story is on my blog, but here are the relevant details...

I tried compiling Brick Battle, but lots of errors appear in the NABU-LIB code; you see this many times:

main.c:742: warning 283: function declarator with no prototype
main.c:855: error: syntax error
^---- ld ( 0xff00 ), hl
^---- ldh(0),hl

Go back in Git history and get Z88DK from May. Actually, it looks like the switch to SDCC 4.3.0 was done on February 6 2023, so try the change just before it, from February 3rd git checkout --recurse-submodules 492cb971987d88f91d2b046ce99d5bd34f6fadea. The build process fetches zsdcc_r13131_src.tar.gz (hmmm, actual version number is slightly earlier). And when compiled, it compiles without silly errors! The listing says:
Version 4.2.0 #13081 (Linux)

Now does Brick Battle run? I see that it loads the title screen picture off the Nabu.ca network (it's in a subdirectory too). And music is included as compiled data. Yay! Music and title screen. Plays with sound effects and everything in MAME, and exits nicely to CP/M too. Okay, we're finally in business after yet another long afternoon trying to get the build system working. Whew!
User avatar
productiondave
Posts: 117
Joined: Tue Mar 28, 2023 10:01 pm

Re: Z88DK Updates break NABU-LIB compilation

Post by productiondave »

I guess the issue I have is that z88dk is moving along with nabu support. By using an older version of z88dk you miss these new features.
Post Reply