Skip to content

Commit

Permalink
== N64 ==
Browse files Browse the repository at this point in the history
- Added image data structure for drawing and scaling
- Now draws scaled assets when needed
- Help now draws more lines per page
- Resolution change added to menu
  • Loading branch information
ArtemioUrbina committed Jul 23, 2024
1 parent 3375722 commit 2a92517
Show file tree
Hide file tree
Showing 16 changed files with 554 additions and 149 deletions.
105 changes: 68 additions & 37 deletions 240psuite/N64/240pSuite.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,33 @@ void drawVideoTestsMenu(void);
int main(void) {
int sel = 1, reload = 1;
joypad_buttons_t keys;
sprite_t *bg = NULL, *sd = NULL;
image *bg = NULL, *sd = NULL;

initN64();
loadFont();

//drawIntro();
drawIntro();
while(1) {
int c = 1, x = 55, y = 90;
int r = 0xFF, g = 0xFF, b = 0xFF;

if(reload) {
bg = sprite_load("rom:/mainbg.sprite");
sd = sprite_load("rom:/sd.sprite");
freeImage(&bg);
freeImage(&sd);
bg = loadImage("rom:/mainbg.sprite");
sd = loadImage("rom:/sd.sprite");
if(sd) {
sd->x = 225;
sd->y = 75;
}
reload = 0;
}

getDisplay();

rdpqStart();
rdpqDrawImage(bg, 0, 0);
rdpqDrawImage(sd, 225, 75);
rdpqDrawImage(bg);
rdpqDrawImage(sd);
rdpqEnd();

drawStringS(x, y, r, sel == c ? 0 : g, sel == c ? 0 : b, "Test Patterns"); y += fh; c++;
Expand All @@ -60,7 +66,7 @@ int main(void) {
drawStringS(x, y, r, sel == c ? 0 : g, sel == c ? 0 : b, "Hardware Tests"); y += fh;

drawSysData();
checkMenu(GENERALHELP);
checkMenu(GENERALHELP, NULL);
waitVsync();

joypad_poll();
Expand Down Expand Up @@ -103,23 +109,29 @@ int main(void) {
void drawPatternsMenu(void) {
int sel = 1, reload = 1, exit = 0;
joypad_buttons_t keys;
sprite_t *bg = NULL, *sd = NULL;
image *bg = NULL, *sd = NULL;

while(!exit) {
int c = 1, x = 55, y = 90;
int r = 0xFF, g = 0xFF, b = 0xFF;

if(reload) {
bg = sprite_load("rom:/mainbg.sprite");
sd = sprite_load("rom:/sd.sprite");
freeImage(&bg);
freeImage(&sd);
bg = loadImage("rom:/mainbg.sprite");
sd = loadImage("rom:/sd.sprite");
if(sd) {
sd->x = 225;
sd->y = 75;
}
reload = 0;
}

getDisplay();

rdpqStart();
rdpqDrawImage(bg, 0, 0);
rdpqDrawImage(sd, 225, 75);
rdpqDrawImage(bg);
rdpqDrawImage(sd);
rdpqEnd();

drawStringS(x, y, r, sel == c ? 0 : g, sel == c ? 0 : b, "Color & Black Levels"); y += fh; c++;
Expand All @@ -128,7 +140,7 @@ void drawPatternsMenu(void) {
drawStringS(x, y + fh, r * 0.8, sel == c ? 0 : g, sel == c ? 0 : b, "Back to Main Menu"); y += fh;

drawSysData();
checkMenu(GENERALHELP);
checkMenu(GENERALHELP, NULL);
waitVsync();

joypad_poll();
Expand Down Expand Up @@ -176,23 +188,29 @@ void drawPatternsMenu(void) {
void drawPatternsColorMenu(void) {
int sel = 1, reload = 1, exit = 0;
joypad_buttons_t keys;
sprite_t *bg = NULL, *sd = NULL;
image *bg = NULL, *sd = NULL;

while(!exit) {
int c = 1, x = 45, y = 70;
int r = 0xFF, g = 0xFF, b = 0xFF;

if(reload) {
bg = sprite_load("rom:/mainbg.sprite");
sd = sprite_load("rom:/sd.sprite");
freeImage(&bg);
freeImage(&sd);
bg = loadImage("rom:/mainbg.sprite");
sd = loadImage("rom:/sd.sprite");
if(sd) {
sd->x = 225;
sd->y = 75;
}
reload = 0;
}

getDisplay();

rdpqStart();
rdpqDrawImage(bg, 0, 0);
rdpqDrawImage(sd, 225, 75);
rdpqDrawImage(bg);
rdpqDrawImage(sd);
rdpqEnd();

drawStringS(x, y, r, sel == c ? 0 : g, sel == c ? 0 : b, "PLUGE"); y += fh; c++;
Expand All @@ -208,7 +226,7 @@ void drawPatternsColorMenu(void) {
drawStringS(x, y + fh, r * 0.8, sel == c ? 0 : g, sel == c ? 0 : b, "Back to Patterns Menu"); y += fh;

drawSysData();
checkMenu(GENERALHELP);
checkMenu(GENERALHELP, NULL);
waitVsync();

joypad_poll();
Expand Down Expand Up @@ -250,23 +268,29 @@ void drawPatternsColorMenu(void) {
void drawPatternsGeometryMenu(void) {
int sel = 1, reload = 1, exit = 0;
joypad_buttons_t keys;
sprite_t *bg = NULL, *sd = NULL;
image *bg = NULL, *sd = NULL;

while(!exit) {
int c = 1, x = 55, y = 90;
int r = 0xFF, g = 0xFF, b = 0xFF;

if(reload) {
bg = sprite_load("rom:/mainbg.sprite");
sd = sprite_load("rom:/sd.sprite");
freeImage(&bg);
freeImage(&sd);
bg = loadImage("rom:/mainbg.sprite");
sd = loadImage("rom:/sd.sprite");
if(sd) {
sd->x = 225;
sd->y = 75;
}
reload = 0;
}

getDisplay();

rdpqStart();
rdpqDrawImage(bg, 0, 0);
rdpqDrawImage(sd, 225, 75);
rdpqDrawImage(bg);
rdpqDrawImage(sd);
rdpqEnd();

drawStringS(x, y, r, sel == c ? 0 : g, sel == c ? 0 : b, "Monoscope"); y += fh; c++;
Expand All @@ -276,7 +300,7 @@ void drawPatternsGeometryMenu(void) {
drawStringS(x, y + fh, r * 0.8, sel == c ? 0 : g, sel == c ? 0 : b, "Back to Patterns Menu"); y += fh;

drawSysData();
checkMenu(GENERALHELP);
checkMenu(GENERALHELP, NULL);
waitVsync();

joypad_poll();
Expand Down Expand Up @@ -318,23 +342,29 @@ void drawPatternsGeometryMenu(void) {
void drawVideoTestsMenu(void) {
int sel = 1, reload = 1, exit = 0;
joypad_buttons_t keys;
sprite_t *bg = NULL, *sd = NULL;
image *bg = NULL, *sd = NULL;

while(!exit) {
int c = 1, x = 45, y = 55;
int r = 0xFF, g = 0xFF, b = 0xFF;

if(reload) {
bg = sprite_load("rom:/mainbg.sprite");
sd = sprite_load("rom:/sd.sprite");
freeImage(&bg);
freeImage(&sd);
bg = loadImage("rom:/mainbg.sprite");
sd = loadImage("rom:/sd.sprite");
if(sd) {
sd->x = 225;
sd->y = 75;
}
reload = 0;
}

getDisplay();

rdpqStart();
rdpqDrawImage(bg, 0, 0);
rdpqDrawImage(sd, 225, 75);
rdpqDrawImage(bg);
rdpqDrawImage(sd);
rdpqEnd();

drawStringS(x, y, r, sel == c ? 0 : g, sel == c ? 0 : b, "Drop Shadow Test"); y += fh; c++;
Expand All @@ -353,7 +383,7 @@ void drawVideoTestsMenu(void) {
drawStringS(x, y + fh/2, r * 0.8, sel == c ? 0 : g, sel == c ? 0 : b, "Back to Patterns Menu"); y += fh;

drawSysData();
checkMenu(GENERALHELP);
checkMenu(GENERALHELP, NULL);
waitVsync();

joypad_poll();
Expand Down Expand Up @@ -414,14 +444,15 @@ void fadeStep(uint16_t *colorRaw) {

void drawSplash(char *name, int delay) {
joypad_buttons_t keys;
sprite_t *logo = NULL;
image *logo = NULL;
uint16_t *pal = NULL;

logo = sprite_load(name);
logo = loadImage(name);
if(!logo)
return;

pal = sprite_get_palette(logo);

logo->center = true;
pal = sprite_get_palette(logo->tiles);
if(!pal) {
freeImage(&logo);
return;
Expand All @@ -432,7 +463,7 @@ void drawSplash(char *name, int delay) {

rdpqStart();
rdpqClearScreen();
rdpqDrawImage(logo, (dW - logo->width)/2, (dH - logo->height)/2);
rdpqDrawImage(logo);
rdpqEnd();

waitVsync();
Expand All @@ -451,7 +482,7 @@ void drawSplash(char *name, int delay) {

rdpqStart();
rdpqClearScreen();
rdpqDrawImage(logo, (dW - logo->width)/2, (dH - logo->height)/2);
rdpqDrawImage(logo);
rdpqEnd();

for(unsigned int c = 0; c < 16; c++)
Expand Down
4 changes: 3 additions & 1 deletion 240psuite/N64/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ include include/n64.mk

src = $(wildcard *.c)
ASSETS_PNG = $(wildcard assets/*.png)

ASSETS_CONV = $(addprefix filesystem/,$(notdir $(ASSETS_PNG:%.png=%.sprite)))

AUDIOCONV_FLAGS ?=
Expand Down Expand Up @@ -36,6 +35,9 @@ $(BUILD_DIR)/240pSuite.elf: $(src:%.c=$(BUILD_DIR)/%.o)
clean:
rm -rf $(BUILD_DIR) 240pSuite.z64 filesystem/*.sprite

fsclean:
rm -rf $(BUILD_DIR)/*.dfs

debug: CFLAGS += -DDEBUG_BENCHMARK
debug: all

Expand Down
Binary file added 240psuite/N64/assets/donna-480.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 240psuite/N64/assets/help.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions 240psuite/N64/controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ joypad_buttons_t controllerButtonsDown() {

pad_held = joypad_get_buttons_held(JOYPAD_PORT_1);
if(pad_held.l && pad_held.r)
resetVideo();
resetIdle();
#endif
return pad_pressed;
}
Expand Down Expand Up @@ -119,7 +119,7 @@ joypad_buttons_t controllerButtonsHeld() {

#ifdef DEBUG_BENCHMARK
if(pad_held.l && pad_held.r)
resetVideo();
resetIdle();
#endif
return pad_pressed;
}
13 changes: 7 additions & 6 deletions 240psuite/N64/filesystem/help/general.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
The 240p Test Suite was designed
with two goals in mind:

1) Evaluate 240p signal
processing on modern TV sets and
video processing equipment; and
1) Evaluate 240p signal display
modern TV sets and video
processing equipment; and

2) Provide calibration patterns
generated on your game console
Expand All @@ -16,13 +16,14 @@ color levels.
Help and options are available
everywhere by pressing #CStart#C.

#C(cont...)#C
HELP (2/2)

This version of the suite
supports 240p, 288p, 576i and
480i video modes.


#C(cont...)#C
HELP (2/2)

The #YNintendo 64#Y cuts out a
few pixels on all sides of the
screen. Affected patterns show
Expand Down
16 changes: 7 additions & 9 deletions 240psuite/N64/help.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

char *helpData = NULL;

#define LINESPERPAGE 19
#define LINESPERPAGE 24

char *loadHelpFile(char *filename, char ***pages, int *npages) {
int i = 0, lines = 0, linecount = 0, currpage = 0;
Expand Down Expand Up @@ -104,7 +104,7 @@ char *loadHelpFile(char *filename, char ***pages, int *npages) {

void helpWindow(char *filename) {
int done = 0, npages = 0, page = 0;
sprite_t *back = NULL;
image *back = NULL;
char *buffer = NULL, **pages = NULL;
joypad_buttons_t keys;

Expand All @@ -115,24 +115,22 @@ void helpWindow(char *filename) {
if(!buffer)
return;

back = sprite_load("rom:/mainbg.sprite");
back = loadImage("rom:/help.sprite");
if(!back) {
free(buffer);
free(pages);
return;
}

while(!done)
{
while(!done) {
getDisplay();

rdpqStart();
rdpqDrawImage(back, 0, 0);
rdpqDrawImage(back);
rdpqEnd();

drawStringS(34, 42, 0xff, 0xff, 0xff, pages[page]);

drawStringS(95, 200, 0xBB, 0xBB, 0xBB, "Press B to return");
drawStringS(32, 16, 0xff, 0xff, 0xff, pages[page]);
drawStringS(95, 216, 0xBB, 0xBB, 0xBB, "Press B to return");
waitVsync();

joypad_poll();
Expand Down
2 changes: 0 additions & 2 deletions 240psuite/N64/help.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ extern char *helpData;
#define PASSIVELAG "/help/passivelag.txt"
#define SMPTECOLOR "/help/SMPTEColor.txt"
#define WHITEHELP "/help/white.txt"
#define LINEARITYHELP "/help/linearity.txt"
#define LIN224HELP "/help/linearity224.txt"
#define SHARPNESSHELP "/help/sharpness.txt"
#define OVERSCANHELP "/help/overscan.txt"
#define OPTIONSHELP "/help/options.txt"
Expand Down
Loading

0 comments on commit 2a92517

Please sign in to comment.