Memory problem...?
Posted: Mon Dec 28, 2020 11:38 pm
Hi,
I always wanted to develop a game for zx, but never been lucky with assembler, so I decided to learn z88dk and sp1.
I have been doing a breakout game (which will be freely available in the end), and it has been quite an interesting exercise, but I hit a problem that I do not really know how to solve. It seems related to memory, but I am not sure.
Now, the game is not complete and it's not really complex and does not have any huge amount of stuff, so I'm guessing I'm doing something really wrong, or by the way I have structured my code or by not configuring pragma stuff correctly (or both, or none).
The behavior I'm seeing is weird: if I add, for example, another function (you can remove the comments in sprite.c and sprite.h to test it - func collision_ball_die) which is not even called from the loop, I have garbled text on score or text messages. Commenting the code, the problem disappears.
The garbled text is usually one or two characters. I used a asm file to configure a font in the udg, pretty much like Blackstar or mspacman excellent examples.
The current code is available at my github, feel free to browse it: https://github.com/antoniocmateus/z88dk_sp1_yab
Please be aware that I have never developed for the zx spectrum and do not have experience in C (but I developed professionally, and still do occasionally, in other languages for many years), so you might see some code that makes you scream.
I also have to confess that, while I do know more or less the spectrum memory map, analyzing a TAP file to see what is wrong is something I never did nor do I know how. I have checked the debugger a few times in the emulator but...
So, my question is, if you're in the mood to help a noob in zx dev (and c): is this a memory related problem and if so, what am I doing wrong? Or this is something else?
Also, now that you've seen the code what can I improve in the code/structure in order to save memory? Is this philosophy generally correct or it's completely wrong?
Thank you
I always wanted to develop a game for zx, but never been lucky with assembler, so I decided to learn z88dk and sp1.
I have been doing a breakout game (which will be freely available in the end), and it has been quite an interesting exercise, but I hit a problem that I do not really know how to solve. It seems related to memory, but I am not sure.
Now, the game is not complete and it's not really complex and does not have any huge amount of stuff, so I'm guessing I'm doing something really wrong, or by the way I have structured my code or by not configuring pragma stuff correctly (or both, or none).
The behavior I'm seeing is weird: if I add, for example, another function (you can remove the comments in sprite.c and sprite.h to test it - func collision_ball_die) which is not even called from the loop, I have garbled text on score or text messages. Commenting the code, the problem disappears.
The garbled text is usually one or two characters. I used a asm file to configure a font in the udg, pretty much like Blackstar or mspacman excellent examples.
The current code is available at my github, feel free to browse it: https://github.com/antoniocmateus/z88dk_sp1_yab
Please be aware that I have never developed for the zx spectrum and do not have experience in C (but I developed professionally, and still do occasionally, in other languages for many years), so you might see some code that makes you scream.
I also have to confess that, while I do know more or less the spectrum memory map, analyzing a TAP file to see what is wrong is something I never did nor do I know how. I have checked the debugger a few times in the emulator but...
So, my question is, if you're in the mood to help a noob in zx dev (and c): is this a memory related problem and if so, what am I doing wrong? Or this is something else?
Also, now that you've seen the code what can I improve in the code/structure in order to save memory? Is this philosophy generally correct or it's completely wrong?
Thank you