mirror of
https://github.com/parasyte/alt64
synced 2025-02-28 09:21:46 -05:00
moved input handler to seperate function
improved sound handling during splash screen (introduced bug with user input when accessing secondary menus more than once)
This commit is contained in:
parent
61bb4b7fec
commit
2025c86b47
399
src/menu.c
399
src/menu.c
@ -3404,199 +3404,8 @@ void loadFile(display_context_t disp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//entry point
|
void handleInput(display_context_t disp, sprite_t *contr)
|
||||||
int main(void)
|
|
||||||
{
|
{
|
||||||
int fast_boot = 0;
|
|
||||||
|
|
||||||
//reserve memory
|
|
||||||
list = malloc(sizeof(direntry_t));
|
|
||||||
|
|
||||||
//dfs init for the rom-attached virtual filesystem
|
|
||||||
if (dfs_init(DFS_DEFAULT_LOCATION) != DFS_ESUCCESS)
|
|
||||||
{
|
|
||||||
printf("Filesystem failed to start!\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// everdrive initial function
|
|
||||||
configure();
|
|
||||||
|
|
||||||
//fast boot for backup-save data
|
|
||||||
int sj = evd_readReg(0);
|
|
||||||
int save_job = evd_readReg(REG_SAV_CFG); //TODO: or the firmware is V3
|
|
||||||
|
|
||||||
if (save_job != 0)
|
|
||||||
fast_boot = 1;
|
|
||||||
|
|
||||||
//not gamepads more or less the n64 hardware-controllers
|
|
||||||
controller_init();
|
|
||||||
|
|
||||||
//filesystem on
|
|
||||||
initFilesystem();
|
|
||||||
sleep(200);
|
|
||||||
|
|
||||||
readConfigFile();
|
|
||||||
//n64 initialization
|
|
||||||
|
|
||||||
if (tv_mode != 0)
|
|
||||||
{
|
|
||||||
*(u32 *)0x80000300 = tv_mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
init_interrupts();
|
|
||||||
|
|
||||||
//background
|
|
||||||
display_init(res, DEPTH_32_BPP, 3, GAMMA_NONE, ANTIALIAS_RESAMPLE);
|
|
||||||
|
|
||||||
//bg buffer
|
|
||||||
static display_context_t disp;
|
|
||||||
|
|
||||||
//Grab a render buffer
|
|
||||||
while (!(disp = display_lock()))
|
|
||||||
;
|
|
||||||
//backgrounds from ramfs/libdragonfs
|
|
||||||
|
|
||||||
if (!fast_boot)
|
|
||||||
{
|
|
||||||
background0 = read_sprite("rom://sprites/splash.sprite");
|
|
||||||
graphics_draw_sprite(disp, 0, 0, background0); //start-picture
|
|
||||||
display_show(disp);
|
|
||||||
}
|
|
||||||
|
|
||||||
char background_path[64];
|
|
||||||
sprintf(background_path, "/ED64/wallpaper/%s", background_image);
|
|
||||||
int found;
|
|
||||||
FatRecord rec_tmpf;
|
|
||||||
found = fatFindRecord(background_path, &rec_tmpf, 0);
|
|
||||||
if (found == 0)
|
|
||||||
{
|
|
||||||
background = loadPng(background_path);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
background = read_sprite("rom://sprites/background.sprite");
|
|
||||||
}
|
|
||||||
sleep(200);
|
|
||||||
|
|
||||||
|
|
||||||
if (sound_on)
|
|
||||||
{
|
|
||||||
//load soundsystem
|
|
||||||
audio_init(44100, 2);
|
|
||||||
sndInit();
|
|
||||||
|
|
||||||
timer_init();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fast_boot)
|
|
||||||
{
|
|
||||||
if (sound_on)
|
|
||||||
playSound(1);
|
|
||||||
|
|
||||||
sleep(2000); //splash screen duration
|
|
||||||
|
|
||||||
//todo: if bgm is enabled, we should start it...
|
|
||||||
//sndPlayBGM("rom://bgm21.it");
|
|
||||||
}
|
|
||||||
|
|
||||||
border_color_1 = translate_color(border_color_1_s);
|
|
||||||
border_color_2 = translate_color(border_color_2_s);
|
|
||||||
box_color = translate_color(box_color_s);
|
|
||||||
selection_color = translate_color(selection_color_s);
|
|
||||||
selection_font_color = translate_color(selection_font_color_s);
|
|
||||||
list_font_color = translate_color(list_font_color_s);
|
|
||||||
list_dir_font_color = translate_color(list_dir_font_color_s);
|
|
||||||
|
|
||||||
while (!(disp = display_lock()))
|
|
||||||
;
|
|
||||||
|
|
||||||
drawBg(disp); //new
|
|
||||||
drawBoxNumber(disp, 1); //new
|
|
||||||
|
|
||||||
uint32_t *buffer = (uint32_t *)__get_buffer(disp); //fg disp = 2
|
|
||||||
|
|
||||||
display_show(disp); //new
|
|
||||||
|
|
||||||
backupSaveData(disp);
|
|
||||||
|
|
||||||
while (!(disp = display_lock()))
|
|
||||||
;
|
|
||||||
|
|
||||||
sprintf(pwd, "%s", "/");
|
|
||||||
readSDcard(disp, "/");
|
|
||||||
|
|
||||||
display_show(disp);
|
|
||||||
//chr input coord
|
|
||||||
x = 30;
|
|
||||||
y = 30;
|
|
||||||
|
|
||||||
position = 0;
|
|
||||||
set = 1;
|
|
||||||
sprintf(input_text, "");
|
|
||||||
|
|
||||||
//sprite for chr input
|
|
||||||
int fp = dfs_open("/n64controller.sprite");
|
|
||||||
sprite_t *contr = malloc(dfs_size(fp));
|
|
||||||
dfs_read(contr, 1, dfs_size(fp), fp);
|
|
||||||
dfs_close(fp);
|
|
||||||
|
|
||||||
//sd card speed settings from config
|
|
||||||
if (sd_speed == 2)
|
|
||||||
{
|
|
||||||
bi_speed50();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bi_speed25();
|
|
||||||
}
|
|
||||||
|
|
||||||
//system main-loop with controller inputs-scan
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
sndUpdate();
|
|
||||||
|
|
||||||
if (playing == 1)
|
|
||||||
playing = mp3_Update(buf_ptr, buf_size);
|
|
||||||
|
|
||||||
if (input_mapping == file_manager)
|
|
||||||
sleep(60);
|
|
||||||
|
|
||||||
if (input_mapping == char_input)
|
|
||||||
{
|
|
||||||
while (!(disp = display_lock()))
|
|
||||||
;
|
|
||||||
|
|
||||||
graphics_draw_sprite(disp, 0, 0, contr);
|
|
||||||
/* Set the text output color */
|
|
||||||
graphics_set_color(0x0, 0xFFFFFFFF);
|
|
||||||
|
|
||||||
chr_forecolor = graphics_make_color(0xFF, 0x14, 0x94, 0xFF); //pink
|
|
||||||
graphics_set_color(chr_forecolor, chr_backcolor);
|
|
||||||
|
|
||||||
graphics_draw_text(disp, 85, 55, "SETS");
|
|
||||||
graphics_draw_text(disp, 94, 70, "1"); //u
|
|
||||||
graphics_draw_text(disp, 104, 82, "2"); //r
|
|
||||||
graphics_draw_text(disp, 94, 93, "3"); //d
|
|
||||||
graphics_draw_text(disp, 82, 82, "4"); //l
|
|
||||||
|
|
||||||
graphics_draw_text(disp, 208, 206, "press START");
|
|
||||||
|
|
||||||
if (set == 1)
|
|
||||||
drawSet1(disp);
|
|
||||||
if (set == 2)
|
|
||||||
drawSet2(disp);
|
|
||||||
if (set == 3)
|
|
||||||
drawSet3(disp);
|
|
||||||
if (set == 4)
|
|
||||||
drawSet4(disp);
|
|
||||||
|
|
||||||
drawTextInput(disp, input_text);
|
|
||||||
|
|
||||||
/* Force backbuffer flip */
|
|
||||||
display_show(disp);
|
|
||||||
} //mapping 2 chr input drawings
|
|
||||||
|
|
||||||
//request controller
|
//request controller
|
||||||
controller_scan();
|
controller_scan();
|
||||||
struct controller_data keys = get_keys_down();
|
struct controller_data keys = get_keys_down();
|
||||||
@ -3879,7 +3688,6 @@ int main(void)
|
|||||||
{
|
{
|
||||||
loadFile(disp);
|
loadFile(disp);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (input_mapping == mempak_menu)
|
else if (input_mapping == mempak_menu)
|
||||||
{
|
{
|
||||||
@ -4634,13 +4442,212 @@ int main(void)
|
|||||||
input_mapping = file_manager;
|
input_mapping = file_manager;
|
||||||
}
|
}
|
||||||
} //key b
|
} //key b
|
||||||
|
}
|
||||||
|
|
||||||
|
//entry point
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int fast_boot = 0;
|
||||||
|
|
||||||
|
//reserve memory
|
||||||
|
list = malloc(sizeof(direntry_t));
|
||||||
|
|
||||||
|
//dfs init for the rom-attached virtual filesystem
|
||||||
|
if (dfs_init(DFS_DEFAULT_LOCATION) != DFS_ESUCCESS)
|
||||||
|
{
|
||||||
|
printf("Filesystem failed to start!\n");
|
||||||
|
while (1)
|
||||||
|
; //never leave!
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// everdrive initial function
|
||||||
|
configure();
|
||||||
|
|
||||||
|
//fast boot for backup-save data
|
||||||
|
//int sj = evd_readReg(REG_CFG); // not sure if this is needed!
|
||||||
|
int save_job = evd_readReg(REG_SAV_CFG); //TODO: or the firmware is V3
|
||||||
|
|
||||||
|
if (save_job != 0)
|
||||||
|
fast_boot = 1;
|
||||||
|
|
||||||
|
//not gamepads more or less the n64 hardware-controllers
|
||||||
|
controller_init();
|
||||||
|
|
||||||
|
//filesystem on
|
||||||
|
initFilesystem();
|
||||||
|
sleep(200);
|
||||||
|
|
||||||
|
readConfigFile();
|
||||||
|
//n64 initialization
|
||||||
|
|
||||||
|
//sd card speed settings from config
|
||||||
|
if (sd_speed == 2)
|
||||||
|
{
|
||||||
|
bi_speed50();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bi_speed25();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tv_mode != 0)
|
||||||
|
{
|
||||||
|
*(u32 *)0x80000300 = tv_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
init_interrupts();
|
||||||
|
|
||||||
|
if (sound_on)
|
||||||
|
{
|
||||||
|
//load soundsystem
|
||||||
|
audio_init(44100, 2);
|
||||||
|
sndInit();
|
||||||
|
|
||||||
|
timer_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
//background
|
||||||
|
display_init(res, DEPTH_32_BPP, 3, GAMMA_NONE, ANTIALIAS_RESAMPLE);
|
||||||
|
|
||||||
|
//bg buffer
|
||||||
|
static display_context_t disp;
|
||||||
|
|
||||||
|
//Grab a render buffer
|
||||||
|
while (!(disp = display_lock()))
|
||||||
|
;
|
||||||
|
//backgrounds from ramfs/libdragonfs
|
||||||
|
|
||||||
|
if (!fast_boot)
|
||||||
|
{
|
||||||
|
background0 = read_sprite("rom://sprites/splash.sprite");
|
||||||
|
graphics_draw_sprite(disp, 0, 0, background0); //start-picture
|
||||||
|
display_show(disp);
|
||||||
|
}
|
||||||
|
|
||||||
|
char background_path[64];
|
||||||
|
sprintf(background_path, "/ED64/wallpaper/%s", background_image);
|
||||||
|
int found;
|
||||||
|
FatRecord rec_tmpf;
|
||||||
|
found = fatFindRecord(background_path, &rec_tmpf, 0);
|
||||||
|
if (found == 0)
|
||||||
|
{
|
||||||
|
background = loadPng(background_path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
background = read_sprite("rom://sprites/background.sprite");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fast_boot)
|
||||||
|
{
|
||||||
|
if (sound_on)
|
||||||
|
{
|
||||||
|
playSound(1);
|
||||||
|
for (int s = 0; s < 200; s++) //todo: this blocks! is there a better way before the main loop starts!
|
||||||
|
{
|
||||||
|
sndUpdate();
|
||||||
sleep(10);
|
sleep(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//never return
|
//sleep(2000); //splash screen duration
|
||||||
while (1)
|
}
|
||||||
|
|
||||||
|
//todo: if bgm is enabled, we should start it...
|
||||||
|
//sndPlayBGM("rom://bgm21.it");
|
||||||
|
|
||||||
|
border_color_1 = translate_color(border_color_1_s);
|
||||||
|
border_color_2 = translate_color(border_color_2_s);
|
||||||
|
box_color = translate_color(box_color_s);
|
||||||
|
selection_color = translate_color(selection_color_s);
|
||||||
|
selection_font_color = translate_color(selection_font_color_s);
|
||||||
|
list_font_color = translate_color(list_font_color_s);
|
||||||
|
list_dir_font_color = translate_color(list_dir_font_color_s);
|
||||||
|
|
||||||
|
while (!(disp = display_lock()))
|
||||||
;
|
;
|
||||||
|
|
||||||
return 0;
|
drawBg(disp); //new
|
||||||
|
drawBoxNumber(disp, 1); //new
|
||||||
|
|
||||||
|
uint32_t *buffer = (uint32_t *)__get_buffer(disp); //fg disp = 2
|
||||||
|
|
||||||
|
display_show(disp); //new
|
||||||
|
|
||||||
|
backupSaveData(disp);
|
||||||
|
|
||||||
|
while (!(disp = display_lock()))
|
||||||
|
;
|
||||||
|
|
||||||
|
sprintf(pwd, "%s", "/");
|
||||||
|
readSDcard(disp, "/");
|
||||||
|
|
||||||
|
display_show(disp);
|
||||||
|
//chr input coord
|
||||||
|
x = 30;
|
||||||
|
y = 30;
|
||||||
|
|
||||||
|
position = 0;
|
||||||
|
set = 1;
|
||||||
|
sprintf(input_text, "");
|
||||||
|
|
||||||
|
//sprite for chr input
|
||||||
|
int fp = dfs_open("/n64controller.sprite");
|
||||||
|
sprite_t *contr = malloc(dfs_size(fp));
|
||||||
|
dfs_read(contr, 1, dfs_size(fp), fp);
|
||||||
|
dfs_close(fp);
|
||||||
|
|
||||||
|
//system main-loop with controller inputs-scan
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
if (sound_on)
|
||||||
|
sndUpdate();
|
||||||
|
|
||||||
|
handleInput(disp, contr);
|
||||||
|
|
||||||
|
if (playing == 1)
|
||||||
|
playing = mp3_Update(buf_ptr, buf_size);
|
||||||
|
|
||||||
|
if (input_mapping == file_manager)
|
||||||
|
sleep(60);
|
||||||
|
|
||||||
|
if (input_mapping == char_input)
|
||||||
|
{
|
||||||
|
while (!(disp = display_lock()))
|
||||||
|
;
|
||||||
|
|
||||||
|
graphics_draw_sprite(disp, 0, 0, contr);
|
||||||
|
/* Set the text output color */
|
||||||
|
graphics_set_color(0x0, 0xFFFFFFFF);
|
||||||
|
|
||||||
|
chr_forecolor = graphics_make_color(0xFF, 0x14, 0x94, 0xFF); //pink
|
||||||
|
graphics_set_color(chr_forecolor, chr_backcolor);
|
||||||
|
|
||||||
|
graphics_draw_text(disp, 85, 55, "SETS");
|
||||||
|
graphics_draw_text(disp, 94, 70, "1"); //u
|
||||||
|
graphics_draw_text(disp, 104, 82, "2"); //r
|
||||||
|
graphics_draw_text(disp, 94, 93, "3"); //d
|
||||||
|
graphics_draw_text(disp, 82, 82, "4"); //l
|
||||||
|
|
||||||
|
graphics_draw_text(disp, 208, 206, "press START");
|
||||||
|
|
||||||
|
if (set == 1)
|
||||||
|
drawSet1(disp);
|
||||||
|
if (set == 2)
|
||||||
|
drawSet2(disp);
|
||||||
|
if (set == 3)
|
||||||
|
drawSet3(disp);
|
||||||
|
if (set == 4)
|
||||||
|
drawSet4(disp);
|
||||||
|
|
||||||
|
drawTextInput(disp, input_text);
|
||||||
|
|
||||||
|
/* Force backbuffer flip */
|
||||||
|
display_show(disp);
|
||||||
|
} //mapping 2 chr input drawings
|
||||||
|
|
||||||
|
//sleep(10);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user