Change color font, use ovl struct

This commit is contained in:
ABelliqueux 2021-10-24 20:32:52 +02:00
parent 6a4bd5dba2
commit ec76da6b79
2 changed files with 58 additions and 18 deletions

View File

@ -23,9 +23,8 @@
#define SCREENYRES 240 // Screen height : If VMODE is 0 = 240, if VMODE is 1 = 256 #define SCREENYRES 240 // Screen height : If VMODE is 0 = 240, if VMODE is 1 = 256
#define CENTERX SCREENXRES/2 // Center of screen on x #define CENTERX SCREENXRES/2 // Center of screen on x
#define CENTERY SCREENYRES/2 // Center of screen on y #define CENTERY SCREENYRES/2 // Center of screen on y
#define MARGINX 8 // margins for text display #define FONTX 960
#define MARGINY 16 #define FONTY 0
#define FONTSIZE 8 * 7 // Text Field Height
#define OTLEN 8 #define OTLEN 8
DISPENV disp[2]; // Double buffered DISPENV and DRAWENV DISPENV disp[2]; // Double buffered DISPENV and DRAWENV
DRAWENV draw[2]; DRAWENV draw[2];
@ -44,11 +43,40 @@ uint8_t drawMenu = 0;
u_long * nextFrame = 0; u_long * nextFrame = 0;
// Ring buffer frame address // Ring buffer frame address
u_long * frameAddr = 0; u_long * frameAddr = 0;
void init(void); void init(void);
void FntColor(CVECTOR fgcol, CVECTOR bgcol );
void display(void); void display(void);
void drawBG(void); void drawBG(void);
void checkPad(void); void checkPad(void);
typedef struct OVERLAY {
char filename[0x7c];
int (*main)();
char commandline[0x180];
char title[0xc];
} OVERLAY;
OVERLAY menu_items[1] = {
{"\\HELLO.OVL;1", 0, "", "0123456789AB"}
};
CVECTOR fntColor = { 115, 215, 45 };
CVECTOR fntColorBG = { 0, 0, 0 };
void FntColor(CVECTOR fgcol, CVECTOR bgcol )
{
// The debug font clut is at tx, ty + 128
// tx = bg color
// tx + 1 = fg color
// We can override the color by drawing a rect at these coordinates
//
RECT fg = { FONTX+1, FONTY + 128, 1, 1 };
RECT bg = { FONTX, FONTY + 128, 1, 1 };
ClearImage(&fg, fgcol.r, fgcol.g, fgcol.b);
ClearImage(&bg, bgcol.r, bgcol.g, bgcol.b);
}
void init(void) void init(void)
{ {
ResetCallback(); ResetCallback();
@ -73,8 +101,9 @@ void init(void)
draw[1].isbg = 1; draw[1].isbg = 1;
PutDispEnv(&disp[db]); // set the disp and draw environnments PutDispEnv(&disp[db]); // set the disp and draw environnments
PutDrawEnv(&draw[db]); PutDrawEnv(&draw[db]);
FntLoad(960, 0); // Load font to vram at 960,0(+128) FntLoad(FONTX, FONTY); // Load font to vram at 960,0(+128)
FntOpen(112, 168, 48, 16, 0, 20 ); // FntOpen(x, y, width, height, black_bg, max. nbr. chars FntOpen(106, 166, 48, 20, 0, 12 ); // FntOpen(x, y, width, height, black_bg, max. nbr. chars
FntColor(fntColor, fntColorBG);
} }
void display(void) void display(void)
{ {
@ -156,6 +185,17 @@ int main() {
while ( curStr->endPlayback == 0) while ( curStr->endPlayback == 0)
{ {
playSTR(&curStr); playSTR(&curStr);
if ( !curStr->channel )
{
FntPrint("%s", menu_items[0].title);
if ( sectorHeader->frameCount > 5 )
{
FntFlush(-1);
} else if ( (sectorHeader->frameCount % 2) && sectorHeader->frameCount < 5 )
{
FntFlush(-1);
}
}
display(); display();
} }
} }

View File

@ -45,10 +45,10 @@ void resetSTR(STR * str)
void switchStrCh(STR ** str) void switchStrCh(STR ** str)
{ {
// Switch current STR channel // Switch current STR channel
//~ ramsyscall_printf("p0: %p - %d - ", *str, (*str)->channel); ramsyscall_printf("p0: %p - %d - ", *str, (*str)->channel);
sectorHeader->frameCount = 0; sectorHeader->frameCount = 0;
*str = &menu[!((*str)->channel)]; *str = &menu[!((*str)->channel)];
//~ ramsyscall_printf("p1: %p\n", *str); ramsyscall_printf("p1: %p\n", *str);
StSetChannel( (*str)->channel ); StSetChannel( (*str)->channel );
(*str)->endPlayback = 1; (*str)->endPlayback = 1;
} }
@ -139,15 +139,15 @@ void playSTR(STR ** str)
drawMenu = 1; drawMenu = 1;
} }
} }
if ( (!(*str)->channel) ) //~ if ( (!(*str)->channel) )
{ //~ {
FntPrint("Hello menu!\n"); //~ FntPrint("Hello menu!\n");
if ( sectorHeader->frameCount > 5 ) //~ if ( sectorHeader->frameCount > 5 )
{ //~ {
FntFlush(-1); //~ FntFlush(-1);
} else if ( (sectorHeader->frameCount % 2) && sectorHeader->frameCount < 5 ) //~ } else if ( (sectorHeader->frameCount % 2) && sectorHeader->frameCount < 5 )
{ //~ {
FntFlush(-1); //~ FntFlush(-1);
} //~ }
} //~ }
} }