OVL+STR
This commit is contained in:
parent
4478e93c92
commit
436596bdd3
6
Makefile
6
Makefile
@ -8,10 +8,16 @@ cleansub:
|
|||||||
|
|
||||||
TARGET = hello_str
|
TARGET = hello_str
|
||||||
|
|
||||||
|
OVERLAYSCRIPT ?= overlay.ld
|
||||||
|
OVERLAYSECTION ?= .ovly0 .ovly1 .ovly2
|
||||||
|
|
||||||
SRCS = hello_str.c \
|
SRCS = hello_str.c \
|
||||||
src/str.c \
|
src/str.c \
|
||||||
src/mod.c \
|
src/mod.c \
|
||||||
third_party/nugget/modplayer/modplayer.c \
|
third_party/nugget/modplayer/modplayer.c \
|
||||||
HIT/SHIN1.HIT \
|
HIT/SHIN1.HIT \
|
||||||
|
OVL/hello_ovl_world/hello_ovl_world.c \
|
||||||
|
OVL/hello_tile/hello_ovl_tile.c \
|
||||||
|
OVL/hello_poly/hello_ovl_poly.c \
|
||||||
|
|
||||||
include common.mk
|
include common.mk
|
||||||
|
176
hello_str.c
176
hello_str.c
@ -1,33 +1,19 @@
|
|||||||
// The nolibgs 2021 demo disc !
|
// The nolibgs 2021 demo disc !
|
||||||
#include <sys/types.h>
|
#include "OVL/common.h"
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <libgte.h>
|
|
||||||
#include <libetc.h>
|
|
||||||
#include <libgpu.h>
|
|
||||||
// CD library
|
|
||||||
#include <libcd.h>
|
|
||||||
// CODEC library
|
|
||||||
#include <libpress.h>
|
|
||||||
// str playback
|
// str playback
|
||||||
#include "src/str.h"
|
#include "src/str.h"
|
||||||
#include "src/mod.h"
|
#include "src/mod.h"
|
||||||
|
#include "third_party/nugget/common/syscalls/syscalls.h"
|
||||||
|
#define printf ramsyscall_printf
|
||||||
|
|
||||||
#define VMODE 0 // Video Mode : 0 : NTSC, 1: PAL
|
|
||||||
#define SCREENXRES 320 // Screen width
|
|
||||||
#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 CENTERY SCREENYRES/2 // Center of screen on y
|
|
||||||
#define FONTX 960
|
|
||||||
#define FONTY 0
|
|
||||||
#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];
|
||||||
u_long ot[2][OTLEN]; // double ordering table of length 8 * 32 = 256 bits / 32 bytes
|
|
||||||
char primbuff[2][32768]; // double primitive buffer of length 32768 * 8 = 262.144 bits / 32,768 Kbytes
|
char primbuff[2][32768]; // double primitive buffer of length 32768 * 8 = 262.144 bits / 32,768 Kbytes
|
||||||
|
u_long ot[2][OTLEN]; // double ordering table of length 8 * 32 = 256 bits / 32 bytes
|
||||||
char *nextpri = primbuff[0]; // pointer to the next primitive in primbuff. Initially, points to the first bit of primbuff[0]
|
char *nextpri = primbuff[0]; // pointer to the next primitive in primbuff. Initially, points to the first bit of primbuff[0]
|
||||||
short db = 1; // index of which buffer is used, values 0, 1
|
uint8_t db = 1; // index of which buffer is used, values 0, 1
|
||||||
|
|
||||||
|
// STR playback
|
||||||
STR menu[4] = {
|
STR menu[4] = {
|
||||||
{ "\\MENU.STR;1", 256, 240, 30, 0, 0 },
|
{ "\\MENU.STR;1", 256, 240, 30, 0, 0 },
|
||||||
{ "\\MENU.STR;1", 256, 240, 30, 1, 0 },
|
{ "\\MENU.STR;1", 256, 240, 30, 1, 0 },
|
||||||
@ -41,11 +27,8 @@ u_long * nextFrame = 0;
|
|||||||
// Ring buffer frame address
|
// Ring buffer frame address
|
||||||
u_long * frameAddr = 0;
|
u_long * frameAddr = 0;
|
||||||
|
|
||||||
void init(void);
|
// OVERLAYS
|
||||||
void FntColor(CVECTOR fgcol, CVECTOR bgcol );
|
extern u_long load_all_overlays_here;
|
||||||
void display(void);
|
|
||||||
void drawBG(void);
|
|
||||||
void checkPad(void);
|
|
||||||
|
|
||||||
typedef struct OVERLAY {
|
typedef struct OVERLAY {
|
||||||
char filename[0x7c];
|
char filename[0x7c];
|
||||||
@ -54,12 +37,40 @@ typedef struct OVERLAY {
|
|||||||
char title[0xc];
|
char title[0xc];
|
||||||
} OVERLAY;
|
} OVERLAY;
|
||||||
|
|
||||||
OVERLAY menu_items[1] = {
|
int ovl_main_hello();
|
||||||
{"\\HELLO.OVL;1", 0, "", "0123456789AB"}
|
int ovl_main_tile();
|
||||||
|
int ovl_main_poly();
|
||||||
|
|
||||||
|
OVERLAY menu_items[] = {
|
||||||
|
{"\\HELLO.OVL;1", ovl_main_hello, "", "HELLO WORLD!"},
|
||||||
|
{"\\TILE.OVL;1", ovl_main_tile, "", "HELLO TILE!"},
|
||||||
|
{"\\POLY.OVL;1", ovl_main_poly, "", "HELLO POLY!"},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum OverlayNumber next_overlay = MOTHERSHIP;
|
||||||
|
enum OverlayNumber prev_overlay = MOTHERSHIP;
|
||||||
|
|
||||||
|
CVECTOR BGcolor = { 24, 108, 76 };
|
||||||
|
uint8_t loadOVL = 0;
|
||||||
|
|
||||||
|
// FONT COLOR
|
||||||
CVECTOR fntColor = { 115, 215, 45 };
|
CVECTOR fntColor = { 115, 215, 45 };
|
||||||
CVECTOR fntColorBG = { 0, 0, 0 };
|
CVECTOR fntColorBG = { 0, 0, 0 };
|
||||||
|
|
||||||
|
// FUNCTIONS
|
||||||
|
|
||||||
|
void FntColor(CVECTOR fgcol, CVECTOR bgcol );
|
||||||
|
void init(void);
|
||||||
|
void display(void);
|
||||||
|
void drawBG(void);
|
||||||
|
void checkPad(void);
|
||||||
|
int loadOverlayAndStart(OVERLAY *);
|
||||||
|
void EmptyOTag(u_long ot[2][OTLEN], char primbuff[2][32768], char * nextpri );
|
||||||
|
|
||||||
|
void (*dispp) (void);
|
||||||
|
|
||||||
|
int CDreadOK = 0;
|
||||||
|
|
||||||
void FntColor(CVECTOR fgcol, CVECTOR bgcol )
|
void FntColor(CVECTOR fgcol, CVECTOR bgcol )
|
||||||
{
|
{
|
||||||
// The debug font clut is at tx, ty + 128
|
// The debug font clut is at tx, ty + 128
|
||||||
@ -78,6 +89,7 @@ void init(void)
|
|||||||
{
|
{
|
||||||
ResetCallback();
|
ResetCallback();
|
||||||
ResetGraph(0); // Initialize drawing engine with a complete reset (0)
|
ResetGraph(0); // Initialize drawing engine with a complete reset (0)
|
||||||
|
|
||||||
InitGeom();
|
InitGeom();
|
||||||
SetGeomOffset(CENTERX,CENTERY);
|
SetGeomOffset(CENTERX,CENTERY);
|
||||||
SetGeomScreen(CENTERX);
|
SetGeomScreen(CENTERX);
|
||||||
@ -91,22 +103,22 @@ void init(void)
|
|||||||
disp[0].disp.y = 8;
|
disp[0].disp.y = 8;
|
||||||
disp[1].disp.y = 8;
|
disp[1].disp.y = 8;
|
||||||
#endif
|
#endif
|
||||||
SetDispMask(0); // Display on screen
|
SetDispMask(1); // Display on screen
|
||||||
setRGB0(&draw[0], 0, 0, 0); // set color for first draw area
|
setRGB0(&draw[0], BGcolor.r, BGcolor.g, BGcolor.b); // set color for first draw area
|
||||||
setRGB0(&draw[1], 0, 0, 0); // set color for second draw area
|
setRGB0(&draw[1], BGcolor.r, BGcolor.g, BGcolor.b); // set color for second draw area
|
||||||
draw[0].isbg = 1; // set mask for draw areas. 1 means repainting the area with the RGB color each frame
|
draw[0].isbg = 1; // set mask for draw areas. 1 means repainting the area with the RGB color each frame
|
||||||
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(FONTX, FONTY); // Load font to vram at 960,0(+128)
|
FntLoad(FONTX, FONTY); // Load font to vram at 960,0(+128)
|
||||||
FntOpen(106, 166, 48, 20, 0, 12 ); // 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
|
||||||
|
FntOpen(106, 166, 248, 120, 0, 120 ); // FntOpen(x, y, width, height, black_bg, max. nbr. chars
|
||||||
FntColor(fntColor, fntColorBG);
|
FntColor(fntColor, fntColorBG);
|
||||||
}
|
}
|
||||||
void display(void)
|
void display(void)
|
||||||
{
|
{
|
||||||
DrawSync(0); // Wait for all drawing to terminate
|
DrawSync(0); // Wait for all drawing to terminate
|
||||||
VSync(0); // Wait for the next vertical blank
|
VSync(0); // Wait for the next vertical blank
|
||||||
//~ checkMusic();
|
|
||||||
PutDispEnv(&disp[db]); // set alternate disp and draw environnments
|
PutDispEnv(&disp[db]); // set alternate disp and draw environnments
|
||||||
PutDrawEnv(&draw[db]);
|
PutDrawEnv(&draw[db]);
|
||||||
DrawOTag(&ot[db][OTLEN - 1]);
|
DrawOTag(&ot[db][OTLEN - 1]);
|
||||||
@ -151,10 +163,46 @@ void drawBG(void)
|
|||||||
addPrim(ot[db], poly); // add poly to the Ordering table
|
addPrim(ot[db], poly); // add poly to the Ordering table
|
||||||
nextpri += sizeof(POLY_FT4); // increment nextpri address with size of a POLY_F4 struct
|
nextpri += sizeof(POLY_FT4); // increment nextpri address with size of a POLY_F4 struct
|
||||||
}
|
}
|
||||||
|
void clearVRAM(void)
|
||||||
|
{
|
||||||
|
RECT vram = {0,0,1024,512};
|
||||||
|
ClearImage(&vram,0,0,0);
|
||||||
|
}
|
||||||
|
int loadOverlayAndStart(OVERLAY * overlay)
|
||||||
|
{
|
||||||
|
int CDreadResult = 0;
|
||||||
|
int next_ovl = -1;
|
||||||
|
// Load overlay file
|
||||||
|
CDreadResult = CdReadFile(overlay->filename, &load_all_overlays_here, 0);
|
||||||
|
CdReadSync(0, 0);
|
||||||
|
printf( "CD read: %d", CDreadResult);
|
||||||
|
// If file loaded sucessfully
|
||||||
|
if (CDreadResult)
|
||||||
|
{
|
||||||
|
clearVRAM();
|
||||||
|
//~ StopCallback();
|
||||||
|
ResetGraph(3);
|
||||||
|
// Execute
|
||||||
|
next_ovl = overlay->main();
|
||||||
|
EmptyOTag(&ot[db], &primbuff[db], nextpri);
|
||||||
|
setRGB(&BGcolor, 0, 150, 255);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
return next_ovl;
|
||||||
|
}
|
||||||
|
void EmptyOTag(u_long ot[2][OTLEN], char primbuff[2][32768], char * nextpri )
|
||||||
|
{
|
||||||
|
for (uint16_t p; p < OTLEN; p++)
|
||||||
|
{
|
||||||
|
ot[0][p] = 0;
|
||||||
|
ot[1][p] = 0;
|
||||||
|
}
|
||||||
|
nextpri = primbuff[!db];
|
||||||
|
}
|
||||||
void checkPad(void)
|
void checkPad(void)
|
||||||
{
|
{
|
||||||
u_short pad = 0;
|
u_long pad = 0;
|
||||||
static u_short oldPad;
|
static u_long oldPad;
|
||||||
pad = PadRead(0);
|
pad = PadRead(0);
|
||||||
|
|
||||||
if ( pad & PADLleft && !(oldPad & PADLleft) )
|
if ( pad & PADLleft && !(oldPad & PADLleft) )
|
||||||
@ -195,6 +243,13 @@ void checkPad(void)
|
|||||||
{
|
{
|
||||||
// Select sound
|
// Select sound
|
||||||
MOD_PlayNote(22, 7, 15, 63);
|
MOD_PlayNote(22, 7, 15, 63);
|
||||||
|
//~ stopSTR();
|
||||||
|
//~ stopMusic();
|
||||||
|
//~ drawMenu = 0;
|
||||||
|
//~ next_overlay = OVERLAY_HELLO;
|
||||||
|
//~ next_overlay = OVERLAY_HELLO;
|
||||||
|
//~ prev_overlay = next_overlay;
|
||||||
|
//~ next_overlay = loadOverlayAndStart(&menu_items[next_overlay]);
|
||||||
oldPad = pad;
|
oldPad = pad;
|
||||||
}
|
}
|
||||||
if ( !(pad & PADRdown) && oldPad & PADRdown )
|
if ( !(pad & PADRdown) && oldPad & PADRdown )
|
||||||
@ -203,10 +258,14 @@ void checkPad(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
int main() {
|
int main() {
|
||||||
|
int t = 0;
|
||||||
|
// STR
|
||||||
curStr = &(menu[0]);
|
curStr = &(menu[0]);
|
||||||
// Set pointers to the relevant buffer addresses
|
// Set pointers to the relevant buffer addresses
|
||||||
u_long * curVLCptr = &VlcBuff[0];
|
u_long * curVLCptr = &VlcBuff[0];
|
||||||
u_short * curIMGptr = &ImgBuff[0];
|
u_short * curIMGptr = &ImgBuff[0];
|
||||||
|
// OVL
|
||||||
|
prev_overlay = next_overlay;
|
||||||
|
|
||||||
init();
|
init();
|
||||||
PadInit(0);
|
PadInit(0);
|
||||||
@ -223,14 +282,14 @@ int main() {
|
|||||||
// Main loop
|
// Main loop
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
// Only display background STR if drawMenu is set
|
//~ // Only display background STR if drawMenu is set
|
||||||
if (drawMenu)
|
if (drawMenu)
|
||||||
{
|
{
|
||||||
SetDispMask(1);
|
//~ SetDispMask(1);
|
||||||
drawBG();
|
drawBG();
|
||||||
}
|
}
|
||||||
// While end of str is not reached, play it
|
//~ // While end of str is not reached, play it
|
||||||
if (curStr->endPlayback == 1)
|
if (curStr->endPlayback == 1 && next_overlay == MOTHERSHIP )
|
||||||
{
|
{
|
||||||
// Replay STR
|
// Replay STR
|
||||||
resetSTR(curStr);
|
resetSTR(curStr);
|
||||||
@ -238,20 +297,35 @@ int main() {
|
|||||||
if ( curStr->endPlayback == 0 )
|
if ( curStr->endPlayback == 0 )
|
||||||
{
|
{
|
||||||
playSTR(&curStr);
|
playSTR(&curStr);
|
||||||
if ( !curStr->channel )
|
//~ if ( !curStr->channel && drawMenu )
|
||||||
{
|
//~ {
|
||||||
// Display title
|
//~ // Display title
|
||||||
FntPrint("%s", menu_items[0].title);
|
//~ FntPrint("%s", menu_items[0].title);
|
||||||
// Flickering text
|
//~ // Flickering text
|
||||||
if ( sectorHeader->frameCount > 5 )
|
//~ if ( sectorHeader->frameCount > 5 )
|
||||||
{
|
//~ {
|
||||||
|
//~ FntFlush(-1);
|
||||||
|
//~ } else if ( (sectorHeader->frameCount % 2) && sectorHeader->frameCount < 5 )
|
||||||
|
//~ {
|
||||||
|
//~ FntFlush(-1);
|
||||||
|
//~ }
|
||||||
|
//~ }
|
||||||
|
}
|
||||||
|
//~ display();
|
||||||
|
if (t == 100){
|
||||||
|
drawMenu = 0;
|
||||||
|
curStr->endPlayback = 1;
|
||||||
|
stopSTR();
|
||||||
|
next_overlay = OVERLAY_HELLO;
|
||||||
|
}
|
||||||
|
if (next_overlay != -1 && next_overlay != prev_overlay){
|
||||||
|
prev_overlay = next_overlay;
|
||||||
|
next_overlay = loadOverlayAndStart(&menu_items[next_overlay]);
|
||||||
|
t = 0;
|
||||||
|
}
|
||||||
|
t++;
|
||||||
|
FntPrint("Mothership: %d\nOvl: %d %d", t, prev_overlay, next_overlay);
|
||||||
FntFlush(-1);
|
FntFlush(-1);
|
||||||
} else if ( (sectorHeader->frameCount % 2) && sectorHeader->frameCount < 5 )
|
|
||||||
{
|
|
||||||
FntFlush(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
display();
|
display();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -88,6 +88,9 @@
|
|||||||
<file name="SCES_313.37" type="data" source="hello_str.ps-exe"/>
|
<file name="SCES_313.37" type="data" source="hello_str.ps-exe"/>
|
||||||
<file name="MENU.STR" type="str" source="STR/menu.str"/>
|
<file name="MENU.STR" type="str" source="STR/menu.str"/>
|
||||||
<file name="MENU1.STR" type="str" source="STR/menu1.str"/>
|
<file name="MENU1.STR" type="str" source="STR/menu1.str"/>
|
||||||
|
<file name="POLY.OVL" type="data" source="Overlay.ovly0"/>
|
||||||
|
<file name="TILE.OVL" type="data" source="Overlay.ovly1"/>
|
||||||
|
<file name="HELLO.OVL" type="data" source="Overlay.ovly2"/>
|
||||||
|
|
||||||
<dummy sectors="1024"/>
|
<dummy sectors="1024"/>
|
||||||
|
|
||||||
|
12
src/str.c
12
src/str.c
@ -35,6 +35,17 @@ void initSTR(STR * str)
|
|||||||
CdControl(CdlSetmode, ¶m, 0);
|
CdControl(CdlSetmode, ¶m, 0);
|
||||||
loadCdFile(str);
|
loadCdFile(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void stopSTR()
|
||||||
|
{
|
||||||
|
// Disable callback
|
||||||
|
DecDCToutCallback(0);
|
||||||
|
DecDCTReset(1);
|
||||||
|
// Release two interrupt functions CdDataCallback() and CdReadyCallback() hooked by CDRead2()
|
||||||
|
StUnSetRing();
|
||||||
|
// Put CDROM on pause at current position
|
||||||
|
//~ CdControlB(CdlPause, 0, 0);
|
||||||
|
}
|
||||||
void resetSTR(STR * str)
|
void resetSTR(STR * str)
|
||||||
{
|
{
|
||||||
u_long * curVLCptr = &VlcBuff[0];
|
u_long * curVLCptr = &VlcBuff[0];
|
||||||
@ -127,7 +138,6 @@ void playSTR(STR ** str)
|
|||||||
curSlice.y = STR_POS_Y;
|
curSlice.y = STR_POS_Y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the current frame's number is bigger than the number of frames in STR,
|
// If the current frame's number is bigger than the number of frames in STR,
|
||||||
// set the endPlayback flag.
|
// set the endPlayback flag.
|
||||||
if ( sectorHeader->frameCount >= ((*str)->length - 1) )
|
if ( sectorHeader->frameCount >= ((*str)->length - 1) )
|
||||||
|
18
src/str.h
18
src/str.h
@ -1,19 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <sys/types.h>
|
#include "../OVL/common.h"
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <libgte.h>
|
|
||||||
#include <libetc.h>
|
|
||||||
#include <libgpu.h>
|
|
||||||
// CD library
|
|
||||||
#include <libcd.h>
|
|
||||||
// CODEC library
|
|
||||||
#include <libpress.h>
|
|
||||||
// printf
|
|
||||||
//~ #include "../../nolibgs_hello_worlds/thirdparty/nugget/common/syscalls/syscalls.h"
|
|
||||||
//~ #define printf ramsyscall_printf
|
|
||||||
#define SCREENXRES 320
|
|
||||||
#define SCREENYRES 240
|
|
||||||
#define STR_POS_X SCREENXRES
|
#define STR_POS_X SCREENXRES
|
||||||
#define STR_POS_Y 0
|
#define STR_POS_Y 0
|
||||||
// Ring Buffer size (reduce if flickering occurs)
|
// Ring Buffer size (reduce if flickering occurs)
|
||||||
@ -57,6 +44,7 @@ enum MENU_STATE
|
|||||||
|
|
||||||
void loadCdFile(STR * str);
|
void loadCdFile(STR * str);
|
||||||
void initSTR(STR * str);
|
void initSTR(STR * str);
|
||||||
|
void stopSTR();
|
||||||
void resetSTR(STR * str);
|
void resetSTR(STR * str);
|
||||||
void playSTR(STR ** str);
|
void playSTR(STR ** str);
|
||||||
void switchStr(STR ** curStr, int strID);
|
void switchStr(STR ** curStr, int strID);
|
||||||
|
Loading…
Reference in New Issue
Block a user