Hi @sp4, if you want you can continue this thread in another one, we are trying to compile all MSX-C related questions in a same topic in order to have all info centralized ;)
I can see the image, but it's only a black image, I don't see any graphics B-) .
P.D.: I can see you are using TED for edit files, it's the same I use, a very good MSX editor.
I wrote as follow:
#include #include void disegna(int x, int y); char spr0Pat[8]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0XFF,0xFF}; char spr0Col[8]={0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05}; int n; int main() { ginit(); /*inizializza graphic subsystem*/ color((TINY)1, (TINY)1, (TINY)1); screen((TINY)4; inispr((TINY)0); /*8x8 sprites, non expanded*/ for(n=0;n<10;n++) { disegna(90,n); } for(n=11;n<21;n++) { disegna(120,n); } return; } void disegna(int x, int y) { sprite((TINY)y, spr0Pat); colspr((TINY)y, spr=Col); putspr((TINY)y, x, 8*y, (TINY)6, (TINY)1); }
and when I compile I obtain the follow messages:
line 5 colums 25: ';' expected line 5 colums 25: missing identifier
Why there is that problem?
You have to use K&R style parameters in MSX-C. Javi explained it on his blog.
Where can I find the K&R style parameter for MSX-C in the blog of Lavandeira?
Try article17 of http://www.lavandeira.net/relearning-msx/ it contains some examples. Or better read all his blog posts and become a patreon: https://www.patreon.com/javilm :)
Sorry, but in the first link there isn't nothing about how to resolve my problem.
Can you give me any suggestion.
Actually, we haven't seen function declarations in the Relearning MSX articles yet. Here is how you do it:
void disegna(int x, int y);
Change this function declaration to:
VOID disegna();
- The type "void" doesn't exist in K&R C. There is a type "VOID" (in uppercase), which is just a redefinition of char.
- When you declare a function at the beginning of the code you just need the return value and the function name.
void disegna(int x, int y) { sprite((TINY)y, spr0Pat); colspr((TINY)y, spr=Col); putspr((TINY)y, x, 8*y, (TINY)6, (TINY)1); }
Also, change this to:
VOID disegna(x, y) int x; int y; { sprite((TINY)y, spr0Pat); colspr((TINY)y, spr0Col); putspr((TINY)y, x, 8*y, (TINY)6, (TINY)1); }
In K&R C the type of the parameters is defined before the function body.
I wrote this code for designe a blue cross in the screen for my xtetris game:
#include stdio.h #include glib.h char spr0Pat[8]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; char spr0Col[8]={0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05}; int main() { ginit(); /*Inizializza graphic subsystem*/ color((TINY)1,(TINY)1,(TINY)1); screen((TINY)4); inispr((TINY)0; for(y=0;y<10;y++) { sprite((TINY)y, spr0Pat); colspr((TINY)y, spr0Col); putspr((TINY)y, 90, 8*y, (TINY)6, (TINY)1); } for(y=11;y<21;y++) { sprite((TINY)y, spr0Pat); colspr((TINY)y, spr0Col); putspr((TINY)y, 150, 8*(y-11), (TINY)6, (TINY)1); } for(y=22;y<51;y++) { sprite((TINY)y, spr0Pat); colspr((TINY)y, spr0Col); putspr((TINY)y, 8*(x-22), 80, (TINY)6, (TINY)1); } /*for(x=51;x<63;x++) { sprite((TINY)x, spr0Pat); colspr((TINY)x, spr0Col); putspr((TINY)x, 8*(x-43), 100, (TINY)6, (TINY)1); }*/ return; }
If I compile that above and run is possible to view that below:
xtetris
How is possible to see above instede to appair a blue cross appaired a line done by a little blue sprite square.
Why?
I wrote this code for designe a blue cross in the screen for my xtetris game:
[…]
How is possible to see above instede to appair a blue cross appaired a line done by a little blue sprite square.
Why?
You're not using sprites correctly. A quick explanation (assuming you're using SCREEN 4 with 8x8 sprites):
- When you're using 8x8 sprites you can have up to 256 sprite patterns (shapes) defined in memory
- You can only have 32 sprites (planes) in the screen at a given time
- Each sprite (plane) can take the shape of one of the 256 sprite patterns
- Only 8 sprites can be on the same horizontal line at a given time
The format of the putspr() function is:
putspr(plane, x, y, color, pat) TINY plane, color, pat; int x, y;
- plane can be 0-31
- x can be 0-255
- y can be 0-191 (or 211)
- color doesn't matter in SCREEN 4. The colors for the sprite come from the sprite color table.
- pat can be 0-255. It's the pattern (shape) number.