RC 1
This commit is contained in:
parent
436596bdd3
commit
71e6175d9e
31
Makefile
31
Makefile
@ -1,15 +1,29 @@
|
||||
TARGET = nolibgs_demo
|
||||
|
||||
.PHONY: all cleansub
|
||||
all:
|
||||
$(MAKE) -C OVL/hello_cubetex clean all
|
||||
$(MAKE) -C OVL/hello_light clean all
|
||||
$(MAKE) -C OVL/hello_ovl_world clean all
|
||||
$(MAKE) -C OVL/hello_pad clean all
|
||||
$(MAKE) -C OVL/hello_poly clean all
|
||||
$(MAKE) -C OVL/hello_sprt clean all
|
||||
$(MAKE) -C OVL/hello_tile clean all
|
||||
mkpsxiso -y ./isoconfig.xml
|
||||
cleansub:
|
||||
$(MAKE) -C OVL/hello_cubetex clean
|
||||
$(MAKE) -C OVL/hello_light clean
|
||||
$(MAKE) -C OVL/hello_ovl_world clean
|
||||
$(MAKE) -C OVL/hello_pad clean
|
||||
$(MAKE) -C OVL/hello_poly clean
|
||||
$(MAKE) -C OVL/hello_sprt clean
|
||||
$(MAKE) -C OVL/hello_tile clean
|
||||
$(MAKE) clean
|
||||
rm -f hello_str.cue hello_str.bin
|
||||
rm -f $(TARGET).cue $(TARGET).bin
|
||||
rm -f *.mcd *.frag *.lua *.vert
|
||||
|
||||
TARGET = hello_str
|
||||
|
||||
OVERLAYSCRIPT ?= overlay.ld
|
||||
OVERLAYSECTION ?= .ovly0 .ovly1 .ovly2
|
||||
OVERLAYSECTION ?= .ovly0 .ovly1 .ovly2 .ovly3 .ovly4 .ovly5 .ovly6
|
||||
|
||||
SRCS = hello_str.c \
|
||||
src/str.c \
|
||||
@ -19,5 +33,14 @@ 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 \
|
||||
OVL/hello_sprt/hello_ovl_sprt.c \
|
||||
OVL/hello_cubetex/hello_ovl_cubetex.c \
|
||||
OVL/hello_light/hello_ovl_light.c \
|
||||
OVL/hello_pad/hello_ovl_pad.c \
|
||||
OVL/hello_sprt/TIM/TIM16.tim \
|
||||
OVL/hello_sprt/TIM/TIM8.tim \
|
||||
OVL/hello_sprt/TIM/TIM4.tim \
|
||||
OVL/hello_cubetex/TIM/cubetex.tim \
|
||||
|
||||
include common.mk
|
||||
|
||||
|
@ -37,8 +37,7 @@ LDFLAGS += -ltap
|
||||
LDFLAGS += -lcd
|
||||
LDFLAGS += -Wl,--end-group
|
||||
|
||||
|
||||
include $(THISDIR)../nolibgs_hello_worlds/thirdparty/nugget/common.mk
|
||||
include $(THISDIR)third_party/nugget/common.mk
|
||||
|
||||
define OBJCOPYME
|
||||
$(PREFIX)-objcopy -I binary --set-section-alignment .data=4 --rename-section .data=.rodata,alloc,load,readonly,data,contents -O $(FORMAT) -B mips $< $@
|
||||
|
261
hello_str.c
261
hello_str.c
@ -5,14 +5,15 @@
|
||||
#include "src/mod.h"
|
||||
#include "third_party/nugget/common/syscalls/syscalls.h"
|
||||
#define printf ramsyscall_printf
|
||||
|
||||
#define DBG_FNTX 32
|
||||
#define DBG_FNTY 200
|
||||
DISPENV disp[2]; // Double buffered DISPENV and DRAWENV
|
||||
DRAWENV draw[2];
|
||||
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]
|
||||
uint8_t db = 1; // index of which buffer is used, values 0, 1
|
||||
|
||||
RECT tw = {0,0,0,0};
|
||||
// STR playback
|
||||
STR menu[4] = {
|
||||
{ "\\MENU.STR;1", 256, 240, 30, 0, 0 },
|
||||
@ -22,7 +23,7 @@ STR menu[4] = {
|
||||
};
|
||||
STR * curStr;
|
||||
StHEADER * sectorHeader;
|
||||
uint8_t drawMenu = 0;
|
||||
int8_t drawMenu = 0;
|
||||
u_long * nextFrame = 0;
|
||||
// Ring buffer frame address
|
||||
u_long * frameAddr = 0;
|
||||
@ -35,41 +36,69 @@ typedef struct OVERLAY {
|
||||
int (*main)();
|
||||
char commandline[0x180];
|
||||
char title[0xc];
|
||||
CVECTOR BGcolor;
|
||||
} OVERLAY;
|
||||
|
||||
int ovl_main_hello();
|
||||
int ovl_main_tile();
|
||||
int ovl_main_poly();
|
||||
int ovl_main_sprt();
|
||||
int ovl_main_cubetex();
|
||||
int ovl_main_light();
|
||||
int ovl_main_pad();
|
||||
|
||||
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!"},
|
||||
{"\\HELLO.OVL;1", ovl_main_hello, "", "HELLO WORLD!", { 225, 220, 40 } },
|
||||
{"\\TILE.OVL;1", ovl_main_tile, "", "HELLO TILE! ", { 150, 30 , 40 } },
|
||||
{"\\POLY.OVL;1", ovl_main_poly, "", "HELLO POLY! ", { 60 , 127, 0 } },
|
||||
{"\\SPRT.OVL;1", ovl_main_sprt, "", "HELLO SPRT! ", { 0 , 108, 255 } },
|
||||
{"\\CUBTX.OVL;1", ovl_main_cubetex, "", "HELLO CUBE! ", { 255 , 200, 0 } },
|
||||
{"\\CUBLT.OVL;1", ovl_main_light, "", "HELLO LIGHT!", { 16 , 90 , 110 } },
|
||||
{"\\PAD.OVL;1", ovl_main_pad, "", "HELLO PAD! ", { 100, 40 , 140 } },
|
||||
};
|
||||
int curItem = 0;
|
||||
#define MAX_ITEMS 6
|
||||
int timeout = 200;
|
||||
|
||||
enum OverlayNumber next_overlay = MOTHERSHIP;
|
||||
enum OverlayNumber prev_overlay = MOTHERSHIP;
|
||||
|
||||
CVECTOR BGcolor = { 24, 108, 76 };
|
||||
uint8_t loadOVL = 0;
|
||||
CVECTOR BGcolor, MScolor = { 24, 108, 76 };
|
||||
uint8_t Xpressed = 0;
|
||||
|
||||
// FONT COLOR
|
||||
CVECTOR fntColor = { 115, 215, 45 };
|
||||
CVECTOR fntColorBG = { 0, 0, 0 };
|
||||
|
||||
// FUNCTIONS
|
||||
uint8_t useOT = 0;
|
||||
int CDreadOK = 0;
|
||||
|
||||
// FUNCTIONS
|
||||
void LoadTexture(u_long * tim, TIM_IMAGE * tparam);
|
||||
void FntColor(CVECTOR fgcol, CVECTOR bgcol );
|
||||
void init(void);
|
||||
void display(void);
|
||||
void drawBG(void);
|
||||
void checkPad(void);
|
||||
void clearVRAM(void);
|
||||
int loadOverlayAndStart(OVERLAY *);
|
||||
void EmptyOTag(u_long ot[2][OTLEN], char primbuff[2][32768], char * nextpri );
|
||||
void EmptyOTag(u_long ot[2][OTLEN]);
|
||||
void EmptyPrimBuf(char primbuff[2][32768], char ** nextpri);
|
||||
void preInitOvl(OVERLAY * overlay);
|
||||
void postInitOvl(OVERLAY * overlay);
|
||||
|
||||
void (*dispp) (void);
|
||||
|
||||
int CDreadOK = 0;
|
||||
void LoadTexture(u_long * tim, TIM_IMAGE * tparam){
|
||||
OpenTIM(tim);
|
||||
ReadTIM(tparam);
|
||||
LoadImage(tparam->prect, tparam->paddr);
|
||||
DrawSync(0);
|
||||
if (tparam->mode & 0x8){ // check 4th bit
|
||||
LoadImage(tparam->crect, tparam->caddr);
|
||||
DrawSync(0);
|
||||
}
|
||||
}
|
||||
|
||||
void FntColor(CVECTOR fgcol, CVECTOR bgcol )
|
||||
{
|
||||
@ -108,11 +137,18 @@ void init(void)
|
||||
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[1].isbg = 1;
|
||||
draw[0].dfe = 0; // set mask for draw areas. 1 means repainting the area with the RGB color each frame
|
||||
draw[1].dfe = 0;
|
||||
draw[0].dtd = 1;
|
||||
draw[1].dtd = 1;
|
||||
PutDispEnv(&disp[db]); // set the disp and draw environnments
|
||||
PutDrawEnv(&draw[db]);
|
||||
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, 248, 120, 0, 120 ); // FntOpen(x, y, width, height, black_bg, max. nbr. chars
|
||||
// Debug text
|
||||
FntOpen(DBG_FNTX, DBG_FNTY, 256, 120, 0, 220 ); // FntOpen(x, y, width, height, black_bg, max. nbr. chars
|
||||
// Menu text
|
||||
FntOpen(106, 166, 48, 20, 0, 12 ); // FntOpen(x, y, width, height, black_bg, max. nbr. chars
|
||||
// Change font color
|
||||
FntColor(fntColor, fntColorBG);
|
||||
}
|
||||
void display(void)
|
||||
@ -121,83 +157,99 @@ void display(void)
|
||||
VSync(0); // Wait for the next vertical blank
|
||||
PutDispEnv(&disp[db]); // set alternate disp and draw environnments
|
||||
PutDrawEnv(&draw[db]);
|
||||
DrawOTag(&ot[db][OTLEN - 1]);
|
||||
if (useOT) { DrawOTag(&ot[db][OTLEN - 1]); }
|
||||
db = !db;
|
||||
nextpri = primbuff[db]; // flip db value (0 or 1)
|
||||
if (useOT) { nextpri = primbuff[db]; } // flip db value (0 or 1)
|
||||
}
|
||||
void drawBG(void)
|
||||
{
|
||||
POLY_FT4 *poly = {0}; // pointer to a POLY_G4
|
||||
SVECTOR RotVector = {0, 0, 0}; // Initialize rotation vector {x, y, z}
|
||||
VECTOR MovVector = {0, 0, CENTERX/2, 0}; // Initialize translation vector {x, y, z, pad}
|
||||
|
||||
SVECTOR VertPos[4] = { // Set initial vertices position relative to 0,0 - see here : https://psx.arthus.net/docs/poly_f4.jpg
|
||||
{-CENTERX/2, -CENTERY/2, 1 }, // Vert 1
|
||||
{-CENTERX/2, CENTERY/2, 1 }, // Vert 2
|
||||
{ CENTERX/2, -CENTERY/2, 1 }, // Vert 3
|
||||
{ CENTERX/2, CENTERY/2, 1 } // Vert 4
|
||||
};
|
||||
MATRIX PolyMatrix = {0};
|
||||
long polydepth;
|
||||
long polyflag;
|
||||
POLY_FT4 * poly = 0; // pointer to a POLY_G4
|
||||
ClearOTagR(ot[db], OTLEN);
|
||||
|
||||
poly = (POLY_FT4 *)nextpri; // Set poly to point to the address of the next primitiv in the buffer
|
||||
// Set transform matrices for this polygon
|
||||
RotMatrix(&RotVector, &PolyMatrix); // Apply rotation matrix
|
||||
TransMatrix(&PolyMatrix, &MovVector); // Apply translation matrix
|
||||
SetRotMatrix(&PolyMatrix); // Set default rotation matrix
|
||||
SetTransMatrix(&PolyMatrix); // Set default transformation matrix
|
||||
setPolyFT4(poly); // Initialize poly as a POLY_F4
|
||||
poly->tpage = getTPage(2,0,STR_POS_X, STR_POS_Y);
|
||||
setRGB0(poly, 128, 128, 128); // Set poly color (neutra here)
|
||||
RotTransPers4(
|
||||
&VertPos[0], &VertPos[1], &VertPos[2], &VertPos[3],
|
||||
(long*)&poly->x0, (long*)&poly->x1, (long*)&poly->x2, (long*)&poly->x3,
|
||||
&polydepth,
|
||||
&polyflag
|
||||
); // Perform coordinate and perspective transformation for 4 vertices
|
||||
setRGB0(poly, 128, 128, 128); // Set poly color (neutral here)
|
||||
setXY4(poly,
|
||||
0, 0,
|
||||
0, SCREENYRES,
|
||||
SCREENXRES, 0,
|
||||
SCREENXRES, SCREENYRES);
|
||||
setUV4(poly, 0, 0,
|
||||
0, 240,
|
||||
255, 0,
|
||||
255, 240); // Set UV coordinates in order Top Left, Bottom Left, Top Right, Bottom Right
|
||||
addPrim(ot[db], poly); // add poly to the Ordering table
|
||||
nextpri += sizeof(POLY_FT4); // increment nextpri address with size of a POLY_F4 struct
|
||||
addPrim(ot[db][OTLEN-1], poly); // add poly to the Ordering table
|
||||
}
|
||||
void clearVRAM(void)
|
||||
{
|
||||
RECT vram = {0,0,1024,512};
|
||||
ClearImage(&vram,0,0,0);
|
||||
}
|
||||
|
||||
void preInitOvl(OVERLAY * overlay)
|
||||
{
|
||||
//~ clearVRAM();
|
||||
ResetCallback();
|
||||
ResetGraph(3);
|
||||
EmptyPrimBuf(primbuff, &nextpri);
|
||||
EmptyOTag(&ot[db]);
|
||||
setRGB(&BGcolor, overlay->BGcolor.r, overlay->BGcolor.g, overlay->BGcolor.b );
|
||||
}
|
||||
void postInitOvl(OVERLAY * overlay)
|
||||
{
|
||||
clearVRAM();
|
||||
//~ ResetGraph(3);
|
||||
EmptyPrimBuf(primbuff, &nextpri);
|
||||
EmptyOTag(&ot[db]);
|
||||
setRGB(&BGcolor, MScolor.r, MScolor.g, MScolor.b);
|
||||
setRGB0(&draw[0], BGcolor.r, BGcolor.g, BGcolor.b); // set color for first draw area
|
||||
setRGB0(&draw[1], BGcolor.r, BGcolor.g, BGcolor.b);
|
||||
FntLoad(FONTX, FONTY); // Load font to vram at 960,0(+128)
|
||||
FntOpen(DBG_FNTX, DBG_FNTY, 256, 120, 0, 220 ); // FntOpen(x, y, width, height, black_bg, max. nbr. chars
|
||||
// Menu text
|
||||
FntOpen(106, 166, 48, 20, 0, 12); // FntOpen(x, y, width, height, black_bg, max. nbr. chars
|
||||
// Change font color
|
||||
FntColor(fntColor, fntColorBG);
|
||||
}
|
||||
int loadOverlayAndStart(OVERLAY * overlay)
|
||||
{
|
||||
int CDreadResult = 0;
|
||||
int next_ovl = -1;
|
||||
// Load overlay file
|
||||
// Load overlay file from CD
|
||||
CDreadResult = CdReadFile(overlay->filename, &load_all_overlays_here, 0);
|
||||
CdReadSync(0, 0);
|
||||
printf( "CD read: %d", CDreadResult);
|
||||
printf(0,"CD read: %d", CDreadResult);
|
||||
// If file loaded sucessfully
|
||||
if (CDreadResult)
|
||||
{
|
||||
clearVRAM();
|
||||
//~ StopCallback();
|
||||
ResetGraph(3);
|
||||
// Execute
|
||||
// Pre OVL
|
||||
preInitOvl(overlay);
|
||||
// Exec OVL
|
||||
next_ovl = overlay->main();
|
||||
EmptyOTag(&ot[db], &primbuff[db], nextpri);
|
||||
setRGB(&BGcolor, 0, 150, 255);
|
||||
init();
|
||||
// Post OVL
|
||||
postInitOvl(overlay);
|
||||
}
|
||||
return next_ovl;
|
||||
}
|
||||
void EmptyOTag(u_long ot[2][OTLEN], char primbuff[2][32768], char * nextpri )
|
||||
//~ void EmptyOTag(u_long ot[2][OTLEN], char * primbuff, char ** nextpri )
|
||||
void EmptyPrimBuf(char primbuff[2][32768], char ** nextpri)
|
||||
{
|
||||
for(uint16_t p; p < 32768; p++)
|
||||
{
|
||||
primbuff[0][p] = 0;
|
||||
primbuff[1][p] = 0;
|
||||
}
|
||||
*nextpri = primbuff[0];
|
||||
}
|
||||
void EmptyOTag(u_long ot[2][OTLEN])
|
||||
{
|
||||
for (uint16_t p; p < OTLEN; p++)
|
||||
{
|
||||
ot[0][p] = 0;
|
||||
ot[1][p] = 0;
|
||||
}
|
||||
nextpri = primbuff[!db];
|
||||
}
|
||||
void checkPad(void)
|
||||
{
|
||||
@ -205,6 +257,7 @@ void checkPad(void)
|
||||
static u_long oldPad;
|
||||
pad = PadRead(0);
|
||||
|
||||
if (drawMenu){
|
||||
if ( pad & PADLleft && !(oldPad & PADLleft) )
|
||||
{
|
||||
// Channel 1 is transition anim, only take input when !transition
|
||||
@ -212,8 +265,14 @@ void checkPad(void)
|
||||
{
|
||||
ramsyscall_printf("Left\n");
|
||||
// Switch sound
|
||||
MOD_PlayNote(23, 12, 15, 63);
|
||||
MOD_PlayNote(22, 12, 15, 63);
|
||||
switchStr(&curStr, LEFT);
|
||||
if ( curItem < MAX_ITEMS ){
|
||||
curItem++;
|
||||
} else {
|
||||
curItem = 0;
|
||||
}
|
||||
ramsyscall_printf("curItem: %d\n", curItem);
|
||||
}
|
||||
oldPad = pad;
|
||||
}
|
||||
@ -231,6 +290,12 @@ void checkPad(void)
|
||||
// Switch sound
|
||||
MOD_PlayNote(23, 12, 15, 63);
|
||||
switchStr(&curStr, RIGHT);
|
||||
if ( curItem > 0 ){
|
||||
curItem--;
|
||||
} else {
|
||||
curItem = MAX_ITEMS;
|
||||
}
|
||||
ramsyscall_printf("curItem: %d\n", curItem);
|
||||
}
|
||||
oldPad = pad;
|
||||
}
|
||||
@ -238,36 +303,42 @@ void checkPad(void)
|
||||
{
|
||||
oldPad = pad;
|
||||
}
|
||||
}
|
||||
// Cross button
|
||||
if ( pad & PADRdown && !(oldPad & PADRdown) )
|
||||
{
|
||||
// Select sound
|
||||
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]);
|
||||
Xpressed = 1;
|
||||
oldPad = pad;
|
||||
}
|
||||
if ( !(pad & PADRdown) && oldPad & PADRdown )
|
||||
{
|
||||
Xpressed = 0;
|
||||
oldPad = pad;
|
||||
}
|
||||
if ( pad & PADstart && !(oldPad & PADstart) )
|
||||
{
|
||||
drawMenu = !drawMenu;
|
||||
oldPad = pad;
|
||||
}
|
||||
if ( !(pad & PADstart) && oldPad & PADstart )
|
||||
{
|
||||
oldPad = pad;
|
||||
}
|
||||
|
||||
}
|
||||
int main() {
|
||||
int t = 0;
|
||||
// STR
|
||||
curStr = &(menu[0]);
|
||||
// Set pointers to the relevant buffer addresses
|
||||
u_long * curVLCptr = &VlcBuff[0];
|
||||
u_short * curIMGptr = &ImgBuff[0];
|
||||
// OVL
|
||||
prev_overlay = next_overlay;
|
||||
|
||||
// Set bg color
|
||||
setRGB(&BGcolor, MScolor.r, MScolor.g, MScolor.b);
|
||||
// Mute spu to get rid of startup sound
|
||||
spuMute();
|
||||
// Init display
|
||||
init();
|
||||
// Init input
|
||||
PadInit(0);
|
||||
VSyncCallback(checkPad);
|
||||
// Init CDrom system
|
||||
@ -282,13 +353,16 @@ int main() {
|
||||
// Main loop
|
||||
while (1)
|
||||
{
|
||||
//~ // Only display background STR if drawMenu is set
|
||||
if (drawMenu)
|
||||
// Only display background STR if drawMenu is set
|
||||
if (drawMenu = 1)
|
||||
{
|
||||
//~ SetDispMask(1);
|
||||
useOT = 1;
|
||||
// Draw menu prim once
|
||||
drawBG();
|
||||
drawMenu = -1;
|
||||
|
||||
}
|
||||
//~ // While end of str is not reached, play it
|
||||
// While end of str is not reached, play it
|
||||
if (curStr->endPlayback == 1 && next_overlay == MOTHERSHIP )
|
||||
{
|
||||
// Replay STR
|
||||
@ -297,35 +371,42 @@ int main() {
|
||||
if ( curStr->endPlayback == 0 )
|
||||
{
|
||||
playSTR(&curStr);
|
||||
//~ if ( !curStr->channel && drawMenu )
|
||||
//~ {
|
||||
//~ // Display title
|
||||
//~ FntPrint("%s", menu_items[0].title);
|
||||
//~ // Flickering text
|
||||
//~ if ( sectorHeader->frameCount > 5 )
|
||||
//~ {
|
||||
//~ FntFlush(-1);
|
||||
//~ } else if ( (sectorHeader->frameCount % 2) && sectorHeader->frameCount < 5 )
|
||||
//~ {
|
||||
//~ FntFlush(-1);
|
||||
//~ }
|
||||
//~ }
|
||||
if ( curStr->channel != 1 && drawMenu )
|
||||
{
|
||||
// Display title
|
||||
FntPrint(1, "%s", menu_items[curItem].title);
|
||||
// Flickering text
|
||||
if ( sectorHeader->frameCount > 5 )
|
||||
{
|
||||
FntFlush(1);
|
||||
} else if ( (sectorHeader->frameCount % 2) && sectorHeader->frameCount < 5 )
|
||||
{
|
||||
FntFlush(1);
|
||||
}
|
||||
//~ display();
|
||||
if (t == 100){
|
||||
// If the cross button is pressed
|
||||
if( Xpressed ) {
|
||||
// If we're on the menu, animate menu
|
||||
if ( next_overlay == MOTHERSHIP ){
|
||||
// Select sound
|
||||
MOD_PlaySoundEffect(22, 7, 15, 63);
|
||||
drawMenu = 0;
|
||||
curStr->endPlayback = 1;
|
||||
stopSTR();
|
||||
next_overlay = OVERLAY_HELLO;
|
||||
stopSTR(curStr);
|
||||
useOT = 0;
|
||||
next_overlay = curItem;
|
||||
}
|
||||
if (next_overlay != -1 && next_overlay != prev_overlay){
|
||||
}
|
||||
}
|
||||
}
|
||||
// If next overlay is not current overlay, load it
|
||||
if (next_overlay != MOTHERSHIP ){
|
||||
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);
|
||||
FntPrint(0, "Mothership: %d\nOvl: %d %d %d\n%x %x %x\nstr x: %d", t, prev_overlay, next_overlay, curItem, nextpri, primbuff[0], primbuff[1], curStr->x);
|
||||
FntFlush(0);
|
||||
display();
|
||||
}
|
||||
return 0;
|
||||
|
@ -13,7 +13,7 @@
|
||||
cue_sheet - Optional, file name of the cue sheet for the image file
|
||||
(required if more than one track is specified).
|
||||
-->
|
||||
<iso_project image_name="hello_str.bin" cue_sheet="hello_str.cue">
|
||||
<iso_project image_name="nolibgs_demo.bin" cue_sheet="nolibgs_demo.cue">
|
||||
|
||||
<!-- <track>
|
||||
Specifies a track to the ISO project. This example element creates a data
|
||||
@ -46,8 +46,8 @@
|
||||
<identifiers
|
||||
system ="PLAYSTATION"
|
||||
application ="PLAYSTATION"
|
||||
volume ="HELOCD"
|
||||
volume_set ="HELOCD"
|
||||
volume ="NOLIBGS"
|
||||
volume_set ="NOLIBGS"
|
||||
publisher ="SCHNAPPY"
|
||||
data_preparer ="MKPSXISO"
|
||||
/>
|
||||
@ -85,12 +85,16 @@
|
||||
-->
|
||||
<!-- Stores system.txt as system.cnf -->
|
||||
<file name="system.cnf" type="data" source="system.cnf"/>
|
||||
<file name="SCES_313.37" type="data" source="hello_str.ps-exe"/>
|
||||
<file name="SCES_313.37" type="data" source="nolibgs_demo.ps-exe"/>
|
||||
<file name="MENU.STR" type="str" source="STR/menu.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"/>
|
||||
<file name="SPRT.OVL" type="data" source="Overlay.ovly3"/>
|
||||
<file name="CUBTX.OVL" type="data" source="Overlay.ovly4"/>
|
||||
<file name="CUBLT.OVL" type="data" source="Overlay.ovly5"/>
|
||||
<file name="PAD.OVL" type="data" source="Overlay.ovly6"/>
|
||||
|
||||
<dummy sectors="1024"/>
|
||||
|
||||
|
146
overlay.ld
Normal file
146
overlay.ld
Normal file
@ -0,0 +1,146 @@
|
||||
__heap_base = MAX(__ovly0_end, __ovly3_end);
|
||||
|
||||
SECTIONS {
|
||||
OVERLAY __bss_end : NOCROSSREFS SUBALIGN(4)
|
||||
{
|
||||
.ovlyload
|
||||
{
|
||||
load_all_overlays_here = .;
|
||||
}
|
||||
.ovly0
|
||||
{
|
||||
KEEP(OVL/hello_poly/*.o(.text))
|
||||
__ovly0_ctor = .;
|
||||
KEEP(OVL/hello_poly/*.o(.text.startup._GLOBAL__*))
|
||||
KEEP(OVL/hello_poly/*.o(.text.*))
|
||||
KEEP(OVL/hello_poly/*.o(.rodata*))
|
||||
KEEP(OVL/hello_poly/*.o(.sdata*))
|
||||
KEEP(OVL/hello_poly/*.o(.data*))
|
||||
KEEP(OVL/hello_poly/*.o(.sbss*))
|
||||
KEEP(OVL/hello_poly/*.o(.bss*))
|
||||
KEEP(OVL/hello_poly/*.o(.ctors))
|
||||
|
||||
. = ALIGN(4);
|
||||
__ovly0_end = .;
|
||||
}
|
||||
|
||||
.ovly1
|
||||
{
|
||||
KEEP(OVL/hello_tile/*.o(.text))
|
||||
__ovly1_ctor = .;
|
||||
KEEP(OVL/hello_tile/*.o(.text.startup._GLOBAL__*))
|
||||
KEEP(OVL/hello_tile/*.o(.text.*))
|
||||
KEEP(OVL/hello_tile/*.o(.rodata*))
|
||||
KEEP(OVL/hello_tile/*.o(.sdata*))
|
||||
KEEP(OVL/hello_tile/*.o(.data*))
|
||||
KEEP(OVL/hello_tile/*.o(.sbss*))
|
||||
KEEP(OVL/hello_tile/*.o(.bss*))
|
||||
KEEP(OVL/hello_tile/*.o(.ctors))
|
||||
|
||||
. = ALIGN(4);
|
||||
__ovly1_end = .;
|
||||
}
|
||||
.ovly2
|
||||
{
|
||||
KEEP(OVL/hello_ovl_world/*.o(.text))
|
||||
__ovly2_ctor = .;
|
||||
KEEP(OVL/hello_ovl_world/*.o(.text.startup._GLOBAL__*))
|
||||
KEEP(OVL/hello_ovl_world/*.o(.text.*))
|
||||
KEEP(OVL/hello_ovl_world/*.o(.rodata*))
|
||||
KEEP(OVL/hello_ovl_world/*.o(.sdata*))
|
||||
KEEP(OVL/hello_ovl_world/*.o(.data*))
|
||||
KEEP(OVL/hello_ovl_world/*.o(.sbss*))
|
||||
KEEP(OVL/hello_ovl_world/*.o(.bss*))
|
||||
KEEP(OVL/hello_ovl_world/*.o(.ctors))
|
||||
|
||||
. = ALIGN(4);
|
||||
__ovly2_end = .;
|
||||
}
|
||||
.ovly3
|
||||
{
|
||||
KEEP(OVL/hello_sprt/*.o(.text))
|
||||
__ovly3_ctor = .;
|
||||
KEEP(OVL/hello_sprt/*.o(.text.startup._GLOBAL__*))
|
||||
KEEP(OVL/hello_sprt/*.o(.text.*))
|
||||
KEEP(OVL/hello_sprt/*.o(.rodata*))
|
||||
KEEP(OVL/hello_sprt/*.o(.sdata*))
|
||||
KEEP(OVL/hello_sprt/*.o(.data*))
|
||||
KEEP(OVL/hello_sprt/*.o(.sbss*))
|
||||
KEEP(OVL/hello_sprt/*.o(.bss*))
|
||||
KEEP(OVL/hello_sprt/*.o(.ctors))
|
||||
|
||||
KEEP(OVL/hello_sprt/TIM/*.o(.text))
|
||||
__ovly3_ctor = .;
|
||||
KEEP(OVL/hello_sprt/TIM/*.o(.text.startup._GLOBAL__*))
|
||||
KEEP(OVL/hello_sprt/TIM/*.o(.text.*))
|
||||
KEEP(OVL/hello_sprt/TIM/*.o(.rodata*))
|
||||
KEEP(OVL/hello_sprt/TIM/*.o(.sdata*))
|
||||
KEEP(OVL/hello_sprt/TIM/*.o(.data*))
|
||||
KEEP(OVL/hello_sprt/TIM/*.o(.sbss*))
|
||||
KEEP(OVL/hello_sprt/TIM/*.o(.bss*))
|
||||
KEEP(OVL/hello_sprt/TIM/*.o(.ctors))
|
||||
|
||||
. = ALIGN(4);
|
||||
__ovly3_end = .;
|
||||
}
|
||||
.ovly4
|
||||
{
|
||||
KEEP(OVL/hello_cubetex/*.o(.text))
|
||||
__ovly4_ctor = .;
|
||||
KEEP(OVL/hello_cubetex/*.o(.text.startup._GLOBAL__*))
|
||||
KEEP(OVL/hello_cubetex/*.o(.text.*))
|
||||
KEEP(OVL/hello_cubetex/*.o(.rodata*))
|
||||
KEEP(OVL/hello_cubetex/*.o(.sdata*))
|
||||
KEEP(OVL/hello_cubetex/*.o(.data*))
|
||||
KEEP(OVL/hello_cubetex/*.o(.sbss*))
|
||||
KEEP(OVL/hello_cubetex/*.o(.bss*))
|
||||
KEEP(OVL/hello_cubetex/*.o(.ctors))
|
||||
|
||||
KEEP(OVL/hello_cubetex/TIM/*.o(.text))
|
||||
__ovly4_ctor = .;
|
||||
KEEP(OVL/hello_cubetex/TIM/*.o(.text.startup._GLOBAL__*))
|
||||
KEEP(OVL/hello_cubetex/TIM/*.o(.text.*))
|
||||
KEEP(OVL/hello_cubetex/TIM/*.o(.rodata*))
|
||||
KEEP(OVL/hello_cubetex/TIM/*.o(.sdata*))
|
||||
KEEP(OVL/hello_cubetex/TIM/*.o(.data*))
|
||||
KEEP(OVL/hello_cubetex/TIM/*.o(.sbss*))
|
||||
KEEP(OVL/hello_cubetex/TIM/*.o(.bss*))
|
||||
KEEP(OVL/hello_cubetex/TIM/*.o(.ctors))
|
||||
|
||||
. = ALIGN(4);
|
||||
__ovly4_end = .;
|
||||
}
|
||||
.ovly5
|
||||
{
|
||||
KEEP(OVL/hello_light/*.o(.text))
|
||||
__ovly5_ctor = .;
|
||||
KEEP(OVL/hello_light/*.o(.text.startup._GLOBAL__*))
|
||||
KEEP(OVL/hello_light/*.o(.text.*))
|
||||
KEEP(OVL/hello_light/*.o(.rodata*))
|
||||
KEEP(OVL/hello_light/*.o(.sdata*))
|
||||
KEEP(OVL/hello_light/*.o(.data*))
|
||||
KEEP(OVL/hello_light/*.o(.sbss*))
|
||||
KEEP(OVL/hello_light/*.o(.bss*))
|
||||
KEEP(OVL/hello_light/*.o(.ctors))
|
||||
|
||||
. = ALIGN(4);
|
||||
__ovly5_end = .;
|
||||
}
|
||||
.ovly6
|
||||
{
|
||||
KEEP(OVL/hello_pad/*.o(.text))
|
||||
__ovly6_ctor = .;
|
||||
KEEP(OVL/hello_pad/*.o(.text.startup._GLOBAL__*))
|
||||
KEEP(OVL/hello_pad/*.o(.text.*))
|
||||
KEEP(OVL/hello_pad/*.o(.rodata*))
|
||||
KEEP(OVL/hello_pad/*.o(.sdata*))
|
||||
KEEP(OVL/hello_pad/*.o(.data*))
|
||||
KEEP(OVL/hello_pad/*.o(.sbss*))
|
||||
KEEP(OVL/hello_pad/*.o(.bss*))
|
||||
KEEP(OVL/hello_pad/*.o(.ctors))
|
||||
|
||||
. = ALIGN(4);
|
||||
__ovly6_end = .;
|
||||
}
|
||||
}
|
||||
}
|
@ -7,6 +7,13 @@ typedef struct SpuVoiceVolume {
|
||||
|
||||
SpuVoiceVolume volumeState[24] = {0};
|
||||
|
||||
void spuMute() {
|
||||
SPU_REVERB_RIGHT = 0;
|
||||
SPU_REVERB_LEFT = 0;
|
||||
SPU_VOL_MAIN_RIGHT = 0;
|
||||
SPU_VOL_MAIN_LEFT = 0;
|
||||
}
|
||||
|
||||
static void muteSPUvoices() {
|
||||
for (unsigned i = 0; i < 24; i++) {
|
||||
// Store current volume
|
||||
@ -27,6 +34,7 @@ static void restoreSPUvoices() {
|
||||
void loadMod() {
|
||||
printf("Loading MOD:\'%s\'\n", HITFILE);
|
||||
MOD_Load((struct MODFileFormat*)HITFILE);
|
||||
MOD_SetMusicVolume(8<<8);
|
||||
printf("%02d Channels, %02d Orders\n", MOD_Channels, MOD_SongLength);
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <libspu.h>
|
||||
#include "../third_party/nugget/common/hardware/hwregs.h"
|
||||
#include "../third_party/nugget/common/hardware/irq.h"
|
||||
#include "../third_party/nugget/common/hardware/spu.h"
|
||||
#include "../third_party/nugget/common/syscalls/syscalls.h"
|
||||
#define printf ramsyscall_printf
|
||||
|
||||
@ -12,6 +13,7 @@ extern const uint8_t _binary_HIT_SHIN1_HIT_start[];
|
||||
#define HITFILE _binary_HIT_SHIN1_HIT_start
|
||||
extern long musicEvent;
|
||||
|
||||
void spuMute();
|
||||
void loadMod();
|
||||
void startMusic();
|
||||
void pauseMusic();
|
||||
|
23
src/str.c
23
src/str.c
@ -16,7 +16,7 @@ u_short ImgBuff[ 16 * SCREENYRES];
|
||||
u_long * curVLCptr = &VlcBuff[0];
|
||||
u_short * curIMGptr = &ImgBuff[0];
|
||||
|
||||
void loadCdFile(STR * str)
|
||||
static void loadCdFile(STR * str)
|
||||
{
|
||||
if ( CdSearchFile(&STRfile, str->name) == 0 ) {
|
||||
FntPrint("File not found :%s\n", str->name);
|
||||
@ -30,21 +30,20 @@ void initSTR(STR * str)
|
||||
{
|
||||
DecDCTReset(0);
|
||||
StSetRing(RingBuff, RING_SIZE);
|
||||
StSetStream(0, 1, str->length, 0, 0);
|
||||
StSetMask(0, 1, str->length);
|
||||
//~ StSetStream(0, 1, str->length, 0, 0);
|
||||
// Set CD mode to CdlModeSpeed
|
||||
CdControl(CdlSetmode, ¶m, 0);
|
||||
loadCdFile(str);
|
||||
}
|
||||
|
||||
void stopSTR()
|
||||
void stopSTR(STR * str)
|
||||
{
|
||||
// Disable callback
|
||||
DecDCToutCallback(0);
|
||||
StSetMask(1, 1, str->length);
|
||||
//~ 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);
|
||||
StClearRing();
|
||||
//~ StUnSetRing();
|
||||
}
|
||||
void resetSTR(STR * str)
|
||||
{
|
||||
@ -87,12 +86,14 @@ void playSTR(STR ** str)
|
||||
// Prepare to receive the decoded image data from the MDEC
|
||||
while ( curSlice.x < ( STR_POS_X + (*str)->x ) )
|
||||
{
|
||||
// Receive decoded data : a 16*ppw*240 px slice
|
||||
// Receive decoded data : a 16*ppw*240 px slice in long word (4B), so / 2
|
||||
DecDCTout( (u_long *) curIMGptr, curSlice.w * curSlice.h / 2);
|
||||
// Wait for transfer end
|
||||
DecDCToutSync(1);
|
||||
DecDCToutSync(0);
|
||||
// Transfer data from main memory to VRAM
|
||||
LoadImage(&curSlice, (u_long *) curIMGptr );
|
||||
// Wait for drawing to terminate
|
||||
DrawSync(0);
|
||||
// Increment drawArea's X with slice width (16 or 24 pix)
|
||||
curSlice.x += 16;
|
||||
}
|
||||
|
20
src/str.h
20
src/str.h
@ -5,7 +5,6 @@
|
||||
#define STR_POS_Y 0
|
||||
// Ring Buffer size (reduce if flickering occurs)
|
||||
#define RING_SIZE 32
|
||||
#define PPW 1
|
||||
#define DCT_MODE 2
|
||||
typedef struct STR {
|
||||
char * name;
|
||||
@ -13,27 +12,15 @@ typedef struct STR {
|
||||
uint16_t length;
|
||||
uint8_t channel, endPlayback;
|
||||
} STR;
|
||||
// 2 channels STR: ch0 = idle loop, ch1 = transition anim
|
||||
// 2 x 2 channels STR: str0 ch0 = idle loop, str0 ch1 = left transition anim - str1 ch0 = idle loop, str1 ch1 = right transition anim
|
||||
extern STR menu[4];
|
||||
// CD File descriptor
|
||||
extern CdlFILE STRfile;
|
||||
extern StHEADER * sectorHeader;
|
||||
// Parameter we want to set the CDROM with
|
||||
extern u_char param;
|
||||
// Ring buffer : 32 * 2048 = 65536 Bytes
|
||||
extern u_long RingBuff[ RING_SIZE * SECTOR_SIZE ];
|
||||
// VLC buffers : display area in words (hence /2), 160*320 == 38400 Bytes
|
||||
extern u_long VlcBuff[ SCREENXRES / 2 * SCREENYRES ];
|
||||
// If using 16bpp, fetch 16xYres strips, if 24bpp, fetch 24xYres strips, 5120*PPW Bytes
|
||||
extern u_short ImgBuff[ 16 * SCREENYRES];
|
||||
|
||||
extern u_long * curVLCptr;
|
||||
extern u_short * curIMGptr;
|
||||
// Next Ring Buffer Frame address
|
||||
extern u_long * nextFrame;
|
||||
// Ring buffer frame address
|
||||
extern u_long * frameAddr;
|
||||
extern uint8_t drawMenu;
|
||||
extern int8_t drawMenu;
|
||||
|
||||
enum MENU_STATE
|
||||
{
|
||||
@ -42,9 +29,8 @@ enum MENU_STATE
|
||||
RIGHT = 3,
|
||||
};
|
||||
|
||||
void loadCdFile(STR * str);
|
||||
void initSTR(STR * str);
|
||||
void stopSTR();
|
||||
void stopSTR(STR * str);
|
||||
void resetSTR(STR * str);
|
||||
void playSTR(STR ** str);
|
||||
void switchStr(STR ** curStr, int strID);
|
||||
|
Loading…
Reference in New Issue
Block a user