From time to time I try to adapt a random program to z88dk, the portability in C is something really fascinating me.
This one does not work right but builds. Is it useful as a test case or I should just remove it from the "ext" archive ?
https://github.com/z88dk/z88dk-ext/blob ... ttleship.c
Is it me or z88dk?
Re: Is it me or z88dk?
Yes, it's defintitely a test case.
I tried a bit -- haven't checked completely -- but this line certainly doesn't work as it should:
if I split this into 2 separate assignments, it works better.
There are several lines in this program with multiple assignments, you might need to check them all.
And this line:
is probably tricky and I put in some extra parentheses to it.
I haven't checked any further but perhaps you can investigate more now.
I tried a bit -- haven't checked completely -- but this line certainly doesn't work as it should:
Code: Select all
step.x = step.y = 0;
There are several lines in this program with multiple assignments, you might need to check them all.
And this line:
Code: Select all
for (d = 0; d < FULL(c) && ((pl) ? (!bd[s.x + d * step.x][s.y + d * step.y].cship) : (!bd[s.x + d * step.x][s.y + d * step.y].pship)) ; d++)
I haven't checked any further but perhaps you can investigate more now.
Re: Is it me or z88dk?
Thank you Timmy !
I tested this same game on different environments, it is definitely a critical piece of code, even recent online compilers seem to behave incorrectly.
I'm not even 100% sure the code is correct, but it is strange to observe different behaviors on different environments, unless some data overlap or memory leak is messing up the results unpredictably.
I tried to add optimizarions, now I hopefully removed them all to avoid adding further bugs.
I tested this same game on different environments, it is definitely a critical piece of code, even recent online compilers seem to behave incorrectly.
I'm not even 100% sure the code is correct, but it is strange to observe different behaviors on different environments, unless some data overlap or memory leak is messing up the results unpredictably.
I tried to add optimizarions, now I hopefully removed them all to avoid adding further bugs.
Re: Is it me or z88dk?
.. I think it can be due to the way I've adjusted the code to be compatible with z88dk.
The parameter passing wouldn't have allowed a struct in function arguments in sccz80, I've replaced it with a pointer to a struct, I bet I've done it wrong.
The parameter passing wouldn't have allowed a struct in function arguments in sccz80, I've replaced it with a pointer to a struct, I bet I've done it wrong.
Re: Is it me or z88dk?
That could very well be the case.
Well, if that's the case it's really easy to verify and fix it. So I'm not worried.
Besides, I think it's been communicated before, but z88dk mostly supports Small C or perhaps K&R C. I don't have the illusion that other, more complicated C syntax is supported. So no worries either.
Also, before I forget, I tested the code with version 2.3. So any changes that were made later in z88dk, I have not checked those.
Note 2: I also wanted to say that "&&" in this language has always been tricky. Although it's intended in C that its precedence is higher than I expect, I still fall for it every single time.
Well, if that's the case it's really easy to verify and fix it. So I'm not worried.
Besides, I think it's been communicated before, but z88dk mostly supports Small C or perhaps K&R C. I don't have the illusion that other, more complicated C syntax is supported. So no worries either.
Also, before I forget, I tested the code with version 2.3. So any changes that were made later in z88dk, I have not checked those.
Note 2: I also wanted to say that "&&" in this language has always been tricky. Although it's intended in C that its precedence is higher than I expect, I still fall for it every single time.
Re: Is it me or z88dk?
Hey, it's a lot of useful considerations, thank you!
It is pointless to publish a non working program, I'm removing it from the archive, I'll put it back in if I'll ever get it working properly.
The original copy is here:
https://github.com/cymonsgames/CymonsGa ... hip/main.c
I also forgot to try building it with sdcc, it has a very good set of warnings and in general it is a great help in adapting programs to z88dk, besides the fact it IS part of z88dk!
It is pointless to publish a non working program, I'm removing it from the archive, I'll put it back in if I'll ever get it working properly.
The original copy is here:
https://github.com/cymonsgames/CymonsGa ... hip/main.c
I also forgot to try building it with sdcc, it has a very good set of warnings and in general it is a great help in adapting programs to z88dk, besides the fact it IS part of z88dk!
Re: Is it me or z88dk?
I decided to work it out, it was too nice to remove it. Apparently chained assignments gave most of the problems.
I destroyed a good part of the program structure using a lot of globals to shrink the resulting binary.
I'm still checking it but it looks playable now.
EDIT: it looks good now, it is a bit easy to win against the computer but it is a funny piece of code
I destroyed a good part of the program structure using a lot of globals to shrink the resulting binary.
I'm still checking it but it looks playable now.
EDIT: it looks good now, it is a bit easy to win against the computer but it is a funny piece of code
Re: Is it me or z88dk?
More interesting problems, the game runs perfectly on a ZX Spectrum but self destroys itself if run on a zx81 unless the FAST mode is used.
Similarly the Sharp MZ, (after having applied a timer workaround for srand) crashes rather soon.
Similarly the Sharp MZ, (after having applied a timer workaround for srand) crashes rather soon.
Re: Is it me or z88dk?
In the meanwhile I pulled some more stuff, text3dlabyrinth is interesting (also labyriynth was though)
Re: Is it me or z88dk?
I don't think that's very important other than you initialise the game in FAST mode first. I don't know much about the ZX81 but setting FAST first might be a normal thing to do for some games. (Not for my demo though, it seems.)
I personally prefer simple code to make a game than using complex language constructs. Because it's just easier to manage.In the meanwhile I pulled some more stuff, text3dlabyrinth is interesting (also labyriynth was though)
On the other hand, with the advance of LLMs, more people will probably trying out z88dk with some C constructs, that is C but not Small.
Re: Is it me or z88dk?
The FAST mode skips the custom interrupt handler which depends on the IY index register (perhaps also AF', I don't remember right now).
Re: Is it me or z88dk?
The FAST mode skips the custom interrupt handler which depends on the IY index register (perhaps also AF', I don't remember right now).
I tend to prefer the small C and K&R (to some extent), but it is satisfactory to just build a generic program in C and get it running with almost no effort. When it builds erroneously or crashes it gets panicking though.
I tend to prefer the small C and K&R (to some extent), but it is satisfactory to just build a generic program in C and get it running with almost no effort. When it builds erroneously or crashes it gets panicking though.