So how to use Jiffy. The system starts to behave erratic, like hang.
unsigned oldJiffy; oldJiffy = Jiffy; if ( Jiffy > (oldJiffy +10 ) ) { update(); oldJiffy = Jiffy; }
What's around that code? Where's the game loop?
And remember that Jiffy will eventually overflow from 0xffff to 0x0000. That may break the Jiffy > (oldJiffy +10) comparison.
This happens in the game loop, which is about 300 lines. I intercept keystrokes (look at newkey) in it and jump to routines that handle these keystrokes. I know that Jiffy will reset, but when that happens "update" will not happen for a long time. Right below this code I placed a puts("skipped"); line. It prints 1 line and hangs. When I take this code out, this system keeps running.
1. How are Jiffy and oldJiffy declared?
2. Have you tried to step-by-step debug with OpenMSX Debugger?
3. Can you put
printf("Before If: Jiffy: %d; OldJiffy: %d", Jiffy, oldJiffy);
before the if and
printf("Before Update: Jiffy: %d; OldJiffy: %d", Jiffy, oldJiffy);
before update()?
Thanks for your reply. I worked around my issue.
I've got a new question mark.
VOID (*f_ptr) ( int*, int*); f_ptr = move;
Does this compiler support this? If so how? The compiler doesn't know what to do with this expression and complains: ) missing, ; missing, syntax error....
You can try using a typedef;
void move(int* a, int* b) {} typedef void (*f_type)(int*, int*); f_type f_ptr = move;
Do you know the C standard version/name MSX-C is based on?
Yeah, it K&R C. That was years before ANSI. But Ascii didn't really mind K&R so they made their own version. Created some strange types: TINY (char), NAT (int), VOID (char) as an example of where they didn't really get it. They defined VOID as char so people could also use VOID in their compiler, because that was becoming popular.
There are many quirks in the compiler.
Isn't there a documentation that describes this C's syntax?
And why do you want to use this compiler instead of a modern one like SDCC or z88dk?
Do you program directly on MSX?
The C's syntax that MSX-C is using is described in The C Programming Language first edition as far as I know.
Isn't there a documentation that describes this C's syntax?
And why do you want to use this compiler instead of a modern one like SDCC or z88dk?
Do you program directly on MSX?
I started my project in Ascii C. I write is Visual Studio Code, save on a (DirAs) floppy, compile on openMSX. I've got about 900 lines of Ascii C code to migrate to SDCC. I've got no idea, how much problems I wil have when I migrate to SDCC. I expect a lot of code rewrite.
In MSX c, you've got one MSX library that has all MSX specific functions (mlib). More modern frameworks like MSXgl offer more functionality to go, but also consist of more seperate header files and different function names.
One advantage of Ascii C is that all MSX functions are in mlib (the msx library) so I don't have to include different header files. I just declare the functions I need. But the limitations of the compiler are gradually pushing me towards SDCC.
The C's syntax that MSX-C is using is described in The C Programming Language first edition as far as I know.
Yes!
(*f_ptr) (); (*f_ptr) ( x,y);
does the job.