ncot-technology / specnext-sprites-example

An example of how to program the ZX Spectrum Next using Z88DK and C.
https://ncot.uk/spectrum-next/devlog-03-hardware-sprites/
MIT License
4 stars 0 forks source link

Problems with sprites example #1

Open danboid opened 4 months ago

danboid commented 4 months ago

Hi James

So far I have only watched your video on how to set up zcc, I haven't watched the sprites video yet but I thought I'd try building and running this under CSpect first.

I get this warning when building it:

~/src/specnext-sprites-example$ make
mkdir -p build bin
zcc +zxn -subtype=nex -vn --list -m -s -clib=sdcc_iy -pragma-include:zpragma.inc -startup=31  src/main.c -o build/zxn_sprite_1 -create-app
src/main.c:394: warning 126: unreachable code

I have attached a video of what your sprite demo looks like for me under CSpect. The sprites are just a garbled mess of pixels.

I am running zcc v22399-e4f3b9db61-20240504 under Debian Testing / trixie amd64

sprite-demo.webm

danboid commented 3 months ago

I have now got this sprite example to run correctly under CSpect.

David Crespo explained the problem and solution like this:

I think you are compiling your .nex executable correctly, but seems you aren't setting the correct path for CSpect to search for assets (in that demo, they are loading from disk, and from your screencap, looks like they haven't loaded)

If your .nex is in /sprites_demo and the assets in /sprites_demo/assets, and assuming your cwd is /sprites_demo, then the command line for CSpect should be something like

CSpect -sound -w2 -vsync -zxnext -mmc=assets multiple-sprites.nex

The -mmc parameter is key for this, it should point to where the assets are located.

Personally, I prefer to include my assets inside the executable and not load them from disk, but it's just a different approach.

In my case I found it easiest to copy zxn_sprite_1.nex and the assets dir from this repo into the same dir as CSpect.exe then I ran

mono CSpect.exe -mmc=./assets/ zxn_sprite_1.nex