Error with sleep and delay functions

Post Reply
eldeljar
Member
Posts: 26
Joined: Sun Feb 12, 2017 6:04 pm

Error with sleep and delay functions

Post by eldeljar »

Hello, I am trying to use the "sleep" function but it gives me errors.

I added "stdlib.h" and program C seems to compile correctly, but at the end it returns the error:

Code: Select all

Error at file 'sleep.c' line 23: symbol 'clock' not defined
I am using the following command:

Code: Select all

zcc + msx -no-cleanup -v -m -s --list -c-code-in-asm -subtype=rom -compiler = sdcc -SO3 --max-allocs-per-node10000 --reserve-regs- iy -create-app -pragma-define:CRT_MODEL= 1 -o test.bin @zproject.lst --fsigned-char
The sample code is:

Code: Select all

#include <msx.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>


void main (void) {

       msx_color (15, 1, 1);
       msx_set_mode (mode_2);

       sleep (1);

       while (1) {}
}
If I use the "delay" function, the error is:

Code: Select all

Error at file 'delay.c' line 23: symbol 'clock' not defined
Can these functions be used in MSX?
Do I have to add another include?

Thank you very much
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

It looks like the msx doesn't have a method to measure time in the library.
Maybe stefano can have a look.. the msx looks to have an interrupt counter @ address 0xFC9E
stefano
Well known member
Posts: 1534
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

If everything will be built correctly, you should have it by tomorrow morning ;)
The new implementation for clock() will cover both the MSX and the Spectravideo SVI.

There's an open issue on the MSX, possibly connected to the data segment alignment, in the meantime you may prefer to test your code on the Spectravideo (if so, just keep everything as it is, including the set_mode parameter!).
eldeljar
Member
Posts: 26
Joined: Sun Feb 12, 2017 6:04 pm

Post by eldeljar »

Hi, I have tried the "clock" function in MSX and it works correctly (it does not return error).

This is enough for me to continue with the game.

Thank you very much for the help.
stefano
Well known member
Posts: 1534
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

The problems I was referring to were spotted and solved today, the msx target wasn't totally broken as I feared.
I'm extending the clock support to the Memotech MTX, it will be ready soon.
Post Reply