Ok, I want to draw the background with the rdp. I read Chillywilly's post about the image needing to be alligned to powers of two, can be max. 255x255 and less than 4kB.
To achive that I split the background in 80 sprites. 1.sprite - 80.sprite in directory back in filesystem. Each sprite is 32x32px and 2kB, so ~160kB in total.
So inside init_n64() I first create an array for those sprites:
//create image array for background and boxart
sprite_t *back[80];
next I load the sprites into the memory
//load backgroundsprites into array
for(int b=0; b<80; b++)
{
sprintf(temp, "/back/%d.sprite", b);
fp = dfs_open(temp);
back[b] = malloc(dfs_size(fp));
dfs_read(back[b], 1, dfs_size(fp), fp);
dfs_close(fp);
}
int b=0; //need that later in while(1)
in while(1) I copied cw's function to draw background.
The sprites are ordered like this:
[1][4][7]
[2][5][8]
[3][6][9]
//puzzle background together
rdp_sync(SYNC_PIPE);
rdp_set_default_clipping();
rdp_enable_texture_copy();
rdp_attach_display(dcon);
// Draw pattern
rdp_sync(SYNC_PIPE);
for (int i=0; i<320; i+=back[b]->width)
for (int j=0; j<240; j+=back[b]->height)
{
rdp_load_texture(0, 0, MIRROR_DISABLED, back[b]);
rdp_draw_sprite(0, i, j);
b=b+1;
}
rdp_detach_display();
Just crashes with black screen. I want to draw back[0] at 0x0, then back[1] at 0x32, until it reaches 240. Then draw back[9] to 32x0 and so on.