Skip to content

Commit ee94cc6

Browse files
committed
reimplement "no bios" error screen
1 parent b3edae2 commit ee94cc6

File tree

8 files changed

+60
-37
lines changed

8 files changed

+60
-37
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ MKFONT_FLAGS ?= --range all
3535

3636
src = \
3737
$(SRC_DIR)/emu.c \
38+
$(SRC_DIR)/error.c \
3839
$(SRC_DIR)/main.c \
3940
$(SRC_DIR)/menu.c
4041

src/emu.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,8 @@ void pfu_emu_run(void)
114114
else
115115
pfu_video_render_4_3();
116116
}
117+
118+
void pfu_emu_switch(void)
119+
{
120+
emu.state = PFU_STATE_EMU;
121+
}

src/emu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33

44
void pfu_emu_run(void);
55

6+
void pfu_emu_switch(void);
7+
68
#endif

src/error.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include <libdragon.h>
2+
3+
#include "main.h"
4+
5+
void pfu_error_switch(const char *error, ...)
6+
{
7+
surface_t *disp = display_get();
8+
char message[1024];
9+
10+
va_list args;
11+
va_start(args, error);
12+
vsnprintf(message, sizeof(message), error, args);
13+
va_end(args);
14+
15+
rdpq_attach_clear(disp, NULL);
16+
rdpq_set_mode_fill(RGBA32(0x22, 0x22, 0x22, 1));
17+
rdpq_fill_rectangle(0, 0, display_get_width(), display_get_height());
18+
19+
rdpq_set_mode_copy(false);
20+
rdpq_sprite_blit(emu.icon, 48, 32, NULL);
21+
rdpq_text_printf(
22+
&(rdpq_textparms_t){
23+
.width = 640 - 64*2,
24+
.height = 480 - 64*2,
25+
.align = ALIGN_CENTER
26+
}, 1, 64, 128, message);
27+
28+
rdpq_detach_show();
29+
30+
exit(1);
31+
}

src/error.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef PRESS_F_ULTRA_ERROR_H
2+
#define PRESS_F_ULTRA_ERROR_H
3+
4+
void pfu_error_switch(const char *error, ...);
5+
6+
#endif

src/main.c

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,6 @@
1414

1515
pfu_emu_ctx_t emu;
1616

17-
void pfu_error_no_rom(void)
18-
{
19-
console_clear();
20-
printf("Press F requires ROM data\n"
21-
"to be stored on the SD Card\n"
22-
"in the \"press-f\" directory.\n\n"
23-
"Please include the sl31253.bin\n"
24-
"and sl31254.bin BIOS images.\n\n"
25-
"Alternatively, it can be\n"
26-
"compiled in statically.\n\n"
27-
"See GitHub for instructions.");
28-
console_render();
29-
exit(1);
30-
}
31-
32-
void pfu_state_set(pfu_state_type state)
33-
{
34-
switch (emu.state)
35-
{
36-
case PFU_STATE_MENU:
37-
console_close();
38-
break;
39-
case PFU_STATE_EMU:
40-
break;
41-
default:
42-
break;
43-
}
44-
emu.state = state;
45-
}
46-
4717
/**
4818
* Returns the memory location of a stamped ROM when loading as a plugin, or
4919
* 0 if doing so is not supported.
@@ -130,6 +100,8 @@ int main(void)
130100
rdpq_font_style(font2, 0, &(rdpq_fontstyle_t){
131101
.color = RGBA32(0, 0, 0, 127),
132102
.outline_color = RGBA32(0, 0, 0, 127)});
103+
rdpq_font_t *font3 = rdpq_font_load_builtin(FONT_BUILTIN_DEBUG_VAR);
104+
rdpq_text_register_font(3, font3);
133105

134106
emu.icon = sprite_load("rom:/icon.sprite");
135107
debug_init_sdfs("sd:/", -1);
@@ -144,7 +116,7 @@ int main(void)
144116

145117
/* If loaded as plugin, jump to loaded ROM, otherwise load ROM menu */
146118
if (pfu_plugin_read_rom())
147-
pfu_state_set(PFU_STATE_EMU);
119+
pfu_emu_switch();
148120
else
149121
pfu_menu_switch_roms();
150122

src/main.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,4 @@ typedef struct
4141

4242
extern pfu_emu_ctx_t emu;
4343

44-
void pfu_state_set(pfu_state_type state);
45-
4644
#endif

src/menu.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include "libpressf/src/emu.h"
44
#include "libpressf/src/font.h"
55

6+
#include "emu.h"
7+
#include "error.h"
68
#include "main.h"
79
#include "menu.h"
810

@@ -57,7 +59,7 @@ static void pfu_menu_entry_back(void)
5759
unsigned dummy = 0;
5860

5961
f8_write(&emu.system, 0x0800, &dummy, sizeof(dummy));
60-
pfu_state_set(PFU_STATE_EMU);
62+
pfu_emu_switch();
6163
pressf_reset(&emu.system);
6264
}
6365

@@ -125,7 +127,7 @@ static void pfu_menu_entry_file(pfu_menu_entry_t *entry)
125127
if (entry)
126128
{
127129
pfu_load_rom(0x0800, entry->title, entry->current_value);
128-
pfu_state_set(PFU_STATE_EMU);
130+
pfu_emu_switch();
129131
pressf_reset(&emu.system);
130132
}
131133
}
@@ -176,7 +178,7 @@ static void pfu_menu_init_roms_source(pfu_menu_ctx_t *menu, const char *src_path
176178
{
177179
if (dir.d_type == DT_REG)
178180
{
179-
/* Load BIOS if found on SD Card */
181+
/* Load BIOS if found */
180182
if (!strncmp(dir.d_name, "sl31253.bin", 8))
181183
{
182184
if (!emu.bios_a_loaded)
@@ -222,6 +224,12 @@ static void pfu_menu_init_roms(void)
222224
snprintf(menu.menu_subtitle, sizeof(menu.menu_subtitle), "%s", "Select a ROM to load.");
223225
emu.menu_roms = menu;
224226
}
227+
else
228+
pfu_error_switch("Press F Ultra requires Channel F BIOS data to be stored on\n"
229+
"the SD Card in the \"press-f\" directory.\n\n"
230+
"Please include both the $03sl31253.bin$01 and $03sl31254.bin$01 BIOS images.\n\n"
231+
"Alternatively, this data can be compiled in statically.\n\n"
232+
"See https://github.com/celerizer/Press-F-Ultra for details.");
225233
}
226234

227235
static uint8_t sine_color;
@@ -293,7 +301,7 @@ static void pfu_menu_input(void)
293301
}
294302
}
295303
else if (buttons.b)
296-
pfu_state_set(PFU_STATE_EMU);
304+
pfu_emu_switch();
297305

298306
if (menu->cursor < 0)
299307
menu->cursor = 0;

0 commit comments

Comments
 (0)