[MSX-C] Q&A official thread

Page 62/63
55 | 56 | 57 | 58 | 59 | 60 | 61 | | 63

By rolandve

Champion (296)

rolandve's picture

19-01-2023, 22:28

openmsx.org.
After start, you get " this application has crashed. Do you wish to send debug information".
Latest version is from May 22. I installed QT but the lowest version I can get right now is 5.2.
Might be that MacOS is newer and that QT is also newer then the requirements of the debugger.

By rolandve

Champion (296)

rolandve's picture

20-01-2023, 12:40

I am trying to change the character set. So I want to create an array with the new values so I can ldirvm them straight in to VRAM. However, ascii C doesn't like arrays....

int nc[8] = { 0, 255, 0, 255, 0, 0, 0, 0 };

Compiler error: can't initialise, content of array is useless expressions. I've tried ' or " but that results in error missing quotes or useless expression. I've tried making it a char or a pointer, it didn't make a difference. How can I create an array and populate it with new values?

solved it for the time being with

char *nc = "\x28\x28\x28\x28\x2F\x20\x3F\x0\x0\x3F\x20\x2F\x28\x28\x28\x28\x0\xFF\x0\xFF\x0\x0\x0\x0\xFC\x4\xF4\x14\x14\x14\x14\x28\x28\x28\x28\x28\x28\x28\x28\x14\x14\x14\x14\xF4\x4\xFC\x0\x14\x14\x14\x14\x14\x14\x14\x14\x0\x0\x0\x0\xFF\x0\xFF\x0\x20\xE0\x20\xE0\x20\x0\x0\x0\x4\x7\x4\x7\x4\x0\x0\x0 ";

but this is ugly.

By ~mk~

Champion (316)

~mk~'s picture

21-01-2023, 03:52

rolandve wrote:
int nc[8] = { 0, 255, 0, 255, 0, 0, 0, 0 };

Compiler error: can't initialise, content of array is useless expressions.

If you want to define the array within a block, I think you need to define it as a static variable.
And the way you wrote it should also work, as long as its defined as global.

Regarding your earlier question about pool/symbol/hash table sizes, I believe apart from adding -rX:Y:Z parameter when invoking cf.com, you need to also use it when invoking cg.com to reserve memory.

E.g.

cf test -r2:3:2
cg -r2000 test

By rolandve

Champion (296)

rolandve's picture

22-01-2023, 23:52

I am reading certain keys (CTRL, SHIFT, ESC) in a loop using ports (not snsmat). I want to start actions if people press CTRL-N, CTRL-D, CTRL-H. Pressing the ESC key inside this loop sets the escape flag. If no key is detected, wait one Jiffy and go back. The behaviour of the system is erratic to say the least, Sometimes it works, most of the times, it hangs. Is it possible that too often, reading the keyboard through the ports can hang the system? What is a good way to do this?

By aoineko

Paladin (805)

aoineko's picture

23-01-2023, 08:55

I don't think there is any known issues to read the keyboard directly through PPI I/O port (other than key ghosting when too many keys are pressed at the same time). This is the technique I use.

That said, if you use the default BIOS interrupt code, you already have the information of all pressed keys stored in RAM at address NEWKEY (FBE5h).

By rolandve

Champion (296)

rolandve's picture

23-01-2023, 22:57

This is a nasty issue, happening in a larger project. This code below just shows what the compiler does with variables defined as unsigned through the project.


typedef struct {
  unsigned x;
  unsigned y;
} block;

main()
{
 block test;
 test.x=10;
 test.y=5;
printf("%u\n",test.x);     <- 10
printf("%u\n",test.y);    <- -5 !!! mark the minus sign
printf("%d\n",((test.y-1)*80)+test.x);     <- generates no output
printf("%u\n",((test.y-1)*80)+test.x);     <- 1125!!!
printf("%i\n",((y-1)*80)+10);      <- i, great ascii C doesn't support integer in printf....

}

anyone a clue what the compiler is doing here? Bitwise the result doesn't even look like the correct answer..

By aoineko

Paladin (805)

aoineko's picture

23-01-2023, 23:51

It would be surprising if such a basic function as printf() did not work in a professional C package.

Does it work well with signed types?

By rolandve

Champion (296)

rolandve's picture

24-01-2023, 07:16

did no tests for negative values But assigning -64 to a char is not an issue for the compiler. Using 'unsigned char' returns a 'duplicate type definition error' because unsigned is a 2 byte value.

By rolandve

Champion (296)

rolandve's picture

28-01-2023, 17:25

Some times I get heap overflows from the ascii C compiler. I've got no clue how I actually fix them, sometimes they simply go away by placing a routine somewhere else. What is the compiler telling me and why? Moving code shouldn't solve an error.....

By aoineko

Paladin (805)

aoineko's picture

28-01-2023, 19:03

I don't know MSX-C, but maybe you have the equivalent of the .map files that SDCC generates? If so, you can see where each areas and labels are placed in memory space and understand why some elements are not where you want them.

Page 62/63
55 | 56 | 57 | 58 | 59 | 60 | 61 | | 63