Skip to content

Commit

Permalink
== N64 ==
Browse files Browse the repository at this point in the history
- Added Stereo Audio test
- Added tentative Dolby Pro-logic II Audio test
- Modified splash screens for black bg
  • Loading branch information
ArtemioUrbina committed Oct 2, 2024
1 parent 80530b0 commit 880ab4c
Show file tree
Hide file tree
Showing 13 changed files with 240 additions and 19 deletions.
20 changes: 12 additions & 8 deletions 240psuite/N64/240pSuite.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ void drawAudioTestsMenu() {
image *bg = NULL, *sd = NULL;

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

if(reload) {
Expand All @@ -583,7 +583,8 @@ void drawAudioTestsMenu() {
SD_blink_cycle(sd);
rdpqEnd();

drawStringS(x, y, r, sel == c ? 0 : g, sel == c ? 0 : b, "Sound Test"); y += fh; c++;
drawStringS(x, y, r, sel == c ? 0 : g, sel == c ? 0 : b, "Stereo Sound Test"); y += fh; c++;
drawStringS(x, y, r, sel == c ? 0 : g, sel == c ? 0 : b, "Prologic II Sound Test"); y += fh; c++;
drawStringS(x, y, r, sel == c ? 0 : g, sel == c ? 0 : b, "Audio Sync Test"); y += fh; c++;
drawStringS(x, y, r, sel == c ? 0 : g, sel == c ? 0 : b, "MDFourier"); y += 2*fh; c++;
drawFooter(x, &y, &sel, &c);
Expand Down Expand Up @@ -616,24 +617,27 @@ void drawAudioTestsMenu() {

switch(sel) {
case 1:

drawAudioTest();
break;
case 2:
drawAudioSyncTest();
drawAudioTestPLII();
break;
case 3:
drawMDFourier();
drawAudioSyncTest();
break;
case 4:
drawMDFourier();
break;
case 5:

break;
case 5:
case 6:
helpWindow(GENERALHELP);
break;
case 6:
case 7:
drawCredits(1);
break;
case 7:
case 8:
exit = 1;
break;
}
Expand Down
17 changes: 16 additions & 1 deletion 240psuite/N64/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ASSETS_GLTF_CONV = $(addprefix $(FILESYSTEM_DIR)/,$(notdir $(ASSETS_GLTF:%.glb=%

ASSETS_HELP = $(wildcard $(FILESYSTEM_DIR)/help/*.txt)

AUDIOCONV_FLAGS ?= --wav-compress 0
#AUDIOCONV_FLAGS ?= --wav-compress 0
#MKSPRITE_EXTRA_FLAGS ?=--verbose
MKSPRITE_EXTRA_FLAGS ?=

Expand All @@ -52,6 +52,21 @@ $(FILESYSTEM_DIR)/%.t3dm: $(ASSETS_DIR)/%.glb
@$(T3D_GLTF_TO_3D) "$<" $@
@$(N64_BINDIR)/mkasset -o $(FILESYSTEM_DIR) $@

#AUDIO

#lossless
$(FILESYSTEM_DIR)/beep.wav64: AUDIOCONV_FLAGS=--wav-compress 0
$(FILESYSTEM_DIR)/mdfourier-dac-44100.wav64: AUDIOCONV_FLAGS=--wav-compress 0

#compression level 1
$(FILESYSTEM_DIR)/sound_test_left.wav64: AUDIOCONV_FLAGS=--wav-compress 1
$(FILESYSTEM_DIR)/sound_test_right.wav64: AUDIOCONV_FLAGS=--wav-compress 1
$(FILESYSTEM_DIR)/sound_test_center.wav64: AUDIOCONV_FLAGS=--wav-compress 1
$(FILESYSTEM_DIR)/sound_test_leftsurround.wav64: AUDIOCONV_FLAGS=--wav-compress 1
$(FILESYSTEM_DIR)/sound_test_rightsurround.wav64: AUDIOCONV_FLAGS=--wav-compress 1

#GRAPHICS

$(FILESYSTEM_DIR)/240pSuite-font.sprite: MKSPRITE_FLAGS=$(MKSPRITE_EXTRA_FLAGS) --tiles 8,8
$(FILESYSTEM_DIR)/mainbg.sprite: MKSPRITE_FLAGS=$(MKSPRITE_EXTRA_FLAGS) --format CI4
$(FILESYSTEM_DIR)/sd.sprite: MKSPRITE_FLAGS=$(MKSPRITE_EXTRA_FLAGS) --format CI4
Expand Down
Binary file modified 240psuite/N64/assets/libdragon.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/sound_test_center.wav
Binary file not shown.
Binary file added 240psuite/N64/assets/sound_test_left.wav
Binary file not shown.
Binary file added 240psuite/N64/assets/sound_test_leftsurround.wav
Binary file not shown.
Binary file added 240psuite/N64/assets/sound_test_right.wav
Binary file not shown.
Binary file added 240psuite/N64/assets/sound_test_rightsurround.wav
Binary file not shown.
Binary file modified 240psuite/N64/assets/tiny3d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
200 changes: 200 additions & 0 deletions 240psuite/N64/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,203 @@ void drawAudioSyncTest() {
audio_close();
}

#define ST_BUFFERS 1
#define ST_CHANNELS 3

void drawAudioTest() {
int end = 0, sel = 0;
image *back = NULL;
joypad_buttons_t keys;
wav64_t left, right, center;

if(!openWAV(&left, "rom:/sound_test_left.wav64")) {
drawMessageBox("Sound test Left samples not present");
return;
}
if(!openWAV(&center, "rom:/sound_test_center.wav64")) {
drawMessageBox("Sound test Right samples not present");
return;
}
if(!openWAV(&right, "rom:/sound_test_right.wav64")) {
drawMessageBox("Sound test Right samples not present");
return;
}
back = loadImage("rom:/mainbg.sprite");
if(!back)
return;

audio_init(44100, ST_BUFFERS);
mixer_init(ST_CHANNELS);

mixer_ch_set_vol_dolby(0, 1, 0, 0, 0, 0);
mixer_ch_set_vol_dolby(1, 1, 1, 0, 0, 0);
mixer_ch_set_vol_dolby(2, 0, 1, 0, 0, 0);

while(!end) {
getDisplay();

rdpqStart();

rdpqClearScreen();
rdpqDrawImage(back);
rdpqEnd();

drawStringC(40, 0x00, 0xff, 0x00, "Sound Test");
drawStringS(90, 120, 0xff, sel == 0 ? 0 : 0xff, sel == 0 ? 0 : 0xff, "Left");
drawStringC(130, 0xff, sel == 1 ? 0 : 0xff, sel == 1 ? 0 : 0xff, "Center");
drawStringS(190, 120, 0xff, sel == 2 ? 0 : 0xff, sel == 2 ? 0 : 0xff, "Right");

drawNoVsyncWithAudio();

joypad_poll();
keys = controllerButtonsDown();

if(keys.d_left)
sel --;
if(keys.d_right)
sel ++;

if(sel < 0)
sel = 2;

if(sel > 2)
sel = 0;

if(keys.a) {
switch(sel) {
case 0:
wav64_play(&left, 0);
break;
case 1:
wav64_play(&center, 1);
break;
case 2:
wav64_play(&right, 2);
break;
default:
break;
}
}
if(keys.b)
end = 1;
}

freeImage(&back);

wav64_close(&left);
wav64_close(&center);
wav64_close(&right);

mixer_close();
audio_close();
}

#define SPLII_CHANNELS 5

void drawAudioTestPLII() {
int end = 0, sel = 0;
image *back = NULL;
joypad_buttons_t keys;
wav64_t left, right, center, sleft, sright;

if(!openWAV(&left, "rom:/sound_test_left.wav64")) {
drawMessageBox("Sound test Left samples not present");
return;
}
if(!openWAV(&center, "rom:/sound_test_center.wav64")) {
drawMessageBox("Sound test Center samples not present");
return;
}
if(!openWAV(&right, "rom:/sound_test_right.wav64")) {
drawMessageBox("Sound test Right samples not present");
return;
}
if(!openWAV(&sleft, "rom:/sound_test_leftsurround.wav64")) {
drawMessageBox("Sound test Surr. Left samples not present");
return;
}
if(!openWAV(&sright, "rom:/sound_test_rightsurround.wav64")) {
drawMessageBox("Sound test Surr. Right samples not present");
return;
}
back = loadImage("rom:/mainbg.sprite");
if(!back)
return;

audio_init(44100, ST_BUFFERS);
mixer_init(SPLII_CHANNELS);

mixer_ch_set_vol_dolby(0, 1, 0, 0, 0, 0);
mixer_ch_set_vol_dolby(1, 0, 0, 1, 0, 0);
mixer_ch_set_vol_dolby(2, 0, 1, 0, 0, 0);
mixer_ch_set_vol_dolby(3, 0, 0, 0, 1, 0);
mixer_ch_set_vol_dolby(4, 0, 0, 0, 0, 1);

while(!end) {
getDisplay();

rdpqStart();

rdpqClearScreen();
rdpqDrawImage(back);
rdpqEnd();

drawStringC(40, 0x00, 0xff, 0x00, "Sound Test Prologic II");
drawStringS(90, 120, 0xff, sel == 0 ? 0 : 0xff, sel == 0 ? 0 : 0xff, "Left");
drawStringC(130, 0xff, sel == 1 ? 0 : 0xff, sel == 1 ? 0 : 0xff, "Center");
drawStringS(190, 120, 0xff, sel == 2 ? 0 : 0xff, sel == 2 ? 0 : 0xff, "Right");
drawStringS(70, 140, 0xff, sel == 3 ? 0 : 0xff, sel == 3 ? 0 : 0xff, "Surr. Left");
drawStringS(170, 140, 0xff, sel == 4 ? 0 : 0xff, sel == 4 ? 0 : 0xff, "Surr. Right");

drawNoVsyncWithAudio();

joypad_poll();
keys = controllerButtonsDown();

if(keys.d_left)
sel --;
if(keys.d_right)
sel ++;

if(sel < 0)
sel = 4;

if(sel > 4)
sel = 0;

if(keys.a) {
switch(sel) {
case 0:
wav64_play(&left, 0);
break;
case 1:
wav64_play(&center, 1);
break;
case 2:
wav64_play(&right, 2);
break;
case 3:
wav64_play(&sleft, 3);
break;
case 4:
wav64_play(&sright, 4);
break;
default:
break;
}
}
if(keys.b)
end = 1;
}

freeImage(&back);

wav64_close(&left);
wav64_close(&center);
wav64_close(&right);
wav64_close(&sleft);
wav64_close(&sright);

mixer_close();
audio_close();
}
2 changes: 2 additions & 0 deletions 240psuite/N64/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@
int openWAV(wav64_t *wav64, char *fileName);
void drawAudioSyncTest();
void drawMDFourier();
void drawAudioTest();
void drawAudioTestPLII();

#endif
18 changes: 9 additions & 9 deletions 240psuite/N64/font.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ void drawStringB(int x, int y, int r, int g, int b, char *text) {
graphics_draw_text_suite(__disp, x, y, text);
}

void drawStringSCenteredInternal(int y, int r, int g, int b, char *str, int useback) {
void drawStringSCenteredInternal(int y, int r, int g, int b, char *str, int useback, bool shadow) {
int currlen = 0;
char *startstr = NULL;
int xpos = 0, len = 0;
Expand All @@ -244,9 +244,9 @@ void drawStringSCenteredInternal(int y, int r, int g, int b, char *str, int useb
if(len) {
xpos = (getDispWidth()-len)/2;
if(!useback)
drawStringS(xpos, y, r, g, b, startstr);
drawStringS(xpos + (shadow ? 1 : 0), y + (shadow ? 1 : 0), r, g, b, startstr);
else
drawStringB(xpos, y, r, g, b, startstr);
drawStringB(xpos + (shadow ? 1 : 0), y + (shadow ? 1 : 0), r, g, b, startstr);
}
*str = '\n';
startstr = str + 1;
Expand All @@ -262,21 +262,21 @@ void drawStringSCenteredInternal(int y, int r, int g, int b, char *str, int useb
if(len) {
xpos = (getDispWidth()-len)/2;
if(!useback)
drawStringS(xpos, y, r, g, b, startstr);
drawStringS(xpos + (shadow ? 1 : 0), y + (shadow ? 1 : 0), r, g, b, startstr);
else
drawStringB(xpos, y, r, g, b, startstr);
drawStringB(xpos + (shadow ? 1 : 0), y + (shadow ? 1 : 0), r, g, b, startstr);
}
}
}

void drawStringC(int y, int r, int g, int b, char *text) {
drawStringSCenteredInternal(y+1, 0, 0, 0, text, 0);
drawStringSCenteredInternal(y, r, g, b, text, 0);
//drawStringSCenteredInternal(y, 0, 0, 0, text, 0, true);
drawStringSCenteredInternal(y, r, g, b, text, 0, false);
}

void drawStringCB(int y, int r, int g, int b, char *text) {
drawStringSCenteredInternal(y+1, 0, 0, 0, text, 1);
drawStringSCenteredInternal(y, r, g, b, text, 1);
//drawStringSCenteredInternal(y, 0, 0, 0, text, 1, true);
drawStringSCenteredInternal(y, r, g, b, text, 1, false);
}


Expand Down
2 changes: 1 addition & 1 deletion 240psuite/N64/hardware.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ void drawControllerTest() {
waitVsync();

joypad_poll();
pad_held = joypad_get_buttons_held();
pad_held = joypad_get_buttons_held(JOYPAD_PORT_1);

if(pad_held.start && pad_held.d_left)
end = 1;
Expand Down

0 comments on commit 880ab4c

Please sign in to comment.