typedef struct {
DISPENV disp;
DRAWENV draw;
u_long ot[8];
POLY_FT4 dobik;
POLY_FT4 tree;
} DB;
void init_robin(DB *db) {
GsIMAGE tim1;
/* Get texture information of TIM FORMAT */
GsGetTimInfo((u_long *)(TEX_ADDR+4),&tim1);
setPolyFT4(&db->dobik);
setShadeTex(&db->dobik, 1);
db->dobik.tpage = LoadTPage(tim1.pixel, 1, 0, 640, 0, 448, 64);
db->dobik.clut = LoadClut(tim1.clut, 0, 275);
}
void bg_init(DB *db) {
GsIMAGE bg_tim_data;
GsGetTimInfo((u_long *)(BG_ADDR+4), &bg_tim_data);
setPolyFT4(&db->tree);
setShadeTex(&db->tree, 1);
db->tree.tpage = LoadTPage(bg_tim_data.pixel, 1, 0, 640, 256, 512, 128);
db->tree.clut = LoadClut(bg_tim_data.clut, 640, 489);
}
int main() {
DB db[2];
DB *cdb;
u_long *ot;
ResetGraph(0);
SetDefDrawEnv(&db[0].draw, 0, 0, 320, 240);
SetDefDrawEnv(&db[1].draw, 0, 240, 320, 240);
SetDefDispEnv(&db[0].disp, 0, 240, 320, 240);
SetDefDispEnv(&db[1].disp, 0, 0, 320, 240);
bg_init(&db[0]);
bg_init(&db[1]);
init_robin(&db[0]);
init_robin(&db[1]);
SetDispMask(1);
db[0].draw.isbg = 1;
setRGB0(&db[0].draw, 60, 120, 120);
db[1].draw.isbg = 1;
setRGB0(&db[1].draw, 60, 120, 120);
while (1) {
cdb = (cdb==db)? db+1: db;
ClearOTag(cdb->ot,8);
setUVWH(&cdb->dobik, 0, 0, 64, 64);
setXYWH(&cdb->dobik, 0, 0, 64, 64);
setUVWH(&cdb->tree, 0, 0, 128, 128);
setXYWH(&cdb->tree, 50, 50, 128, 128);
ot = cdb->ot;
AddPrim(&ot[0], &cdb->tree);
AddPrim(&ot[1], &cdb->dobik);
DrawSync(0);
VSync(0);
PutDrawEnv(&cdb->draw);
PutDispEnv(&cdb->disp);
DumpOTag(cdb->ot);
DrawOTag(cdb->ot);
}
DrawSync(0);
pollhost();
return 0;
}