|
|
|
@ -55,15 +55,9 @@ void display_init() |
|
|
|
// ISR subsystem to the kernel |
|
|
|
ResetGraph(0); |
|
|
|
|
|
|
|
//SetVideoMode(MODE_NTSC); |
|
|
|
|
|
|
|
// Define display environments, first on top and second on bottom |
|
|
|
SetDefDispEnv(&disp[0], 0, 0, SCREENWIDTH, SCREENHEIGHT); |
|
|
|
SetDefDispEnv(&disp[1], 0, SCREENHEIGHT, SCREENWIDTH, SCREENHEIGHT); |
|
|
|
|
|
|
|
// Define drawing environments, first on bottom and second on top |
|
|
|
SetDefDrawEnv(&draw[0], 0, SCREENHEIGHT, SCREENWIDTH, SCREENHEIGHT); |
|
|
|
SetDefDrawEnv(&draw[1], 0, 0, SCREENWIDTH, SCREENHEIGHT); |
|
|
|
// Start the display in progressive mode |
|
|
|
int screenHeight; |
|
|
|
display_reset(0, &screenHeight); |
|
|
|
|
|
|
|
// Set and enable clear color |
|
|
|
setRGB0(&draw[0], 49, 77, 121); |
|
|
|
@ -84,14 +78,51 @@ void display_init() |
|
|
|
FntLoad(960, 0); |
|
|
|
|
|
|
|
// Open up a test font text stream |
|
|
|
FntOpen(0, 8, SCREENWIDTH, SCREENHEIGHT, 0, 512); |
|
|
|
FntOpen(0, 8, SCREENWIDTH, screenHeight, 0, 512); |
|
|
|
|
|
|
|
// Initialize GTE |
|
|
|
InitGeom(); |
|
|
|
gte_SetGeomOffset(SCREENWIDTH >> 1, SCREENHEIGHT >> 1); |
|
|
|
gte_SetGeomOffset(SCREENWIDTH >> 1, screenHeight >> 1); |
|
|
|
gte_SetGeomScreen(180); // Screen depth for FOV control. Determines the distance of the camera to the near plane. |
|
|
|
} |
|
|
|
|
|
|
|
void display_reset(u_char interlaced, int *outScreenHeight) |
|
|
|
{ |
|
|
|
int screenHeight, yOffset; |
|
|
|
if (GetVideoMode() == MODE_NTSC) |
|
|
|
{ |
|
|
|
screenHeight = SCREENHEIGHT_NTSC; |
|
|
|
yOffset = (240 - SCREENHEIGHT_NTSC) >> 1; // Vertically center the image for NTSC displays |
|
|
|
|
|
|
|
// Scale Y coordinates to correct the aspect ratio for NTSC's typical visible screen area |
|
|
|
aspect_scale.vy = 224 * ONE / 240; |
|
|
|
} |
|
|
|
else // MODE_PAL |
|
|
|
{ |
|
|
|
screenHeight = SCREENHEIGHT_PAL; |
|
|
|
yOffset = (288 - SCREENHEIGHT_PAL) >> 1; // Vertically center the image for PAL displays |
|
|
|
|
|
|
|
// Scale Y coordinates to correct the aspect ratio for PAL's non-square pixels |
|
|
|
aspect_scale.vy = 256 * ONE / 240; |
|
|
|
} |
|
|
|
|
|
|
|
// Define display environments, first on top and second on bottom |
|
|
|
SetDefDispEnv(&disp[0], 0, 0, SCREENWIDTH, screenHeight); |
|
|
|
SetDefDispEnv(&disp[1], 0, screenHeight, SCREENWIDTH, screenHeight); |
|
|
|
|
|
|
|
// Define drawing environments, first on bottom and second on top |
|
|
|
SetDefDrawEnv(&draw[0], 0, screenHeight, SCREENWIDTH, screenHeight); |
|
|
|
SetDefDrawEnv(&draw[1], 0, 0, SCREENWIDTH, screenHeight); |
|
|
|
|
|
|
|
disp[0].screen.y = disp[1].screen.y = yOffset; |
|
|
|
disp[0].screen.h = disp[1].screen.h = screenHeight; |
|
|
|
|
|
|
|
gte_SetGeomOffset(SCREENWIDTH >> 1, screenHeight >> 1); |
|
|
|
|
|
|
|
if (outScreenHeight != NULL) |
|
|
|
*outScreenHeight = screenHeight; |
|
|
|
} |
|
|
|
|
|
|
|
void display_start() |
|
|
|
{ |
|
|
|
curOT = ot[db]; |
|
|
|
@ -143,7 +174,6 @@ void *display_allocPrim(size_t size) |
|
|
|
if (nextpri + size > primbuff[db] + PRIMBUFLEN) |
|
|
|
return NULL; |
|
|
|
|
|
|
|
// TODO: maybe add a bounds check? |
|
|
|
void *prim = nextpri; |
|
|
|
nextpri += size; |
|
|
|
return prim; |
|
|
|
|