There's definitely something wrong with your setup and I'm really confused too as to what's going on.
The first example with the array - I made the array size 9 and got this result:
Code: Select all
off=2 fonts.h=7 txtch=32 off=32 fontst=2
aoff=2 fonts.h=7 txtch=32 off=32 fontst=2
aoff=2 fonts.h=7 txtch=32 off=32 fontst=2
aoff=2 fonts.h=7 txtch=32 off=32 fontst=2
aoff=2 fonts.h=7 txtch=32 off=32 fontst=2
aoff=2 fonts.h=7 txtch=32 off=32 fontst=2
aoff=2 fonts.h=7 txtch=32 off=32 fontst=2
aoff=2 fonts.h=7 txtch=97 off=32 fontst=457
aoff=2 fonts.h=7 txtch=97 off=32 fontst=457
aoff=2 fonts.h=7 txtch=97 off=32 fontst=457
aoff=2 fonts.h=7 txtch=97 off=32 fontst=457
aoff=2 fonts.h=7 txtch=97 off=32 fontst=457
aoff=2 fonts.h=7 txtch=97 off=32 fontst=457
The second example with the structs, I tried out this test program:
Code: Select all
#include <string.h>
#include <stdio.h>
struct myfontspecs
{
unsigned char name[20];
unsigned char xpos;
unsigned char ypos;
unsigned char spacing;
unsigned char colour;
unsigned char fx;
};
void fox_textat(struct myfontspecs *myfont, char *text)
{
printf("Name: %s\n",myfont->name);
printf("xpos: %d\n",myfont->xpos);
printf("ypos: %d\n",myfont->ypos);
printf("spacing: %d\n",myfont->spacing);
printf("colour: %d\n",myfont->colour);
printf("fx: %d\n",myfont->fx);
}
int main() {
struct myfontspecs myfont;
strcpy(myfont.name, "sansserif5x7");
myfont.xpos = 0;
myfont.ypos = 20;
myfont.spacing = 1;
myfont.colour = 3; // _vzred;
myfont.fx = 12; // _fxnormal;
fox_textat(&myfont," a");
}
Compiled with "zcc +test test.c" and then ran with "z88dk-ticks a.bin" and got this:
Code: Select all
% z88dk-ticks a.bin
Name: sansserif5x7
xpos: 0
ypos: 20
spacing: 1
colour: 3
fx: 12
So that's working too - if you use +test do you get the same result as me?
Regarding memory allocation, it looks like we're missing a wiki page that I'll have to write this weekend. However, remove all the mallinit stuff and just use malloc/calloc/free and compile with -DAMALLOC - this will automatically setup the heap