-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmenu.h
More file actions
130 lines (117 loc) · 6.14 KB
/
Copy pathmenu.h
File metadata and controls
130 lines (117 loc) · 6.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#ifndef ROMSELECT
#define ROMSELECT
#include <stdint.h>
#include <stddef.h>
#define SWVERSION "VX.X"
#if PICO_RP2350
#if __riscv
#define PICOHWNAME_ "rp2350-riscv"
#else
#define PICOHWNAME_ "rp2350-arm"
#endif
#else
#define PICOHWNAME_ "rp2040"
#endif
#define SCREEN_COLS 40
#define SCREEN_ROWS 30
#define STARTROW 3
#define ENDROW (SCREEN_ROWS - 5)
#define PAGESIZE (ENDROW - STARTROW + 1)
#define VISIBLEPATHSIZE (SCREEN_COLS - 3)
struct charCell
{
uint8_t fgcolor;
uint8_t bgcolor;
char charvalue;
};
// Maximum number of save state slots
#define MAXSAVESTATESLOTS 6
#define SAVESTATEDIR "/SAVESTATES"
#define SLOTFORMAT SAVESTATEDIR "/%s/%08X/slot%d.sta"
#define QUICKSAVEFILEFORMAT SAVESTATEDIR "/%s/%08X/slot%d.sta"
#define AUTOSAVEFILEISCONFIGUREDFORMAT SAVESTATEDIR "/%s/%08X/AUTO.cfg"
#define AUTOSAVEFILEFORMAT SAVESTATEDIR "/%s/%08X/auto.sta"
#define RECORDEDSAMPLEFILE "/soundrecorder.wav"
#define DEFAULTSAMPLEFILEFORMAT "/Metadata/%s/sample.wav"
enum SaveStateTypes { NONE, SAVE, LOAD, SAVE_AND_EXIT, LOAD_AND_START };
extern charCell *screenBuffer;
#define screenbufferSize (sizeof(charCell) * SCREEN_COLS * SCREEN_ROWS)
void menu(const char *title, char *errorMessage, bool isFatalError, bool showSplash, const char *allowedExtensions, char *rompath);
void ClearScreen(int color);
void putText(int x, int y, const char *text, int fgcolor, int bgcolor, bool wraplines = false, int offset = 0);
void splash(); // is emulator specific
int showSettingsMenu(bool calledFromGame = false);
// Optional FDS disk-swap hooks. The NES emulator wires these up to its
// FDS implementation at startup; other emulators leave it null and the
// menu hides the option via g_settings_visibility[MOPT_FDS_DISK_SWAP].
struct MenuFdsHooks
{
int (*get_swap_value)(); // 0..NumSides-1 for "Side N", NumSides for "Ejected"
int (*get_num_sides)(); // total disk sides
void (*request_swap)(int newSide); // schedule eject + insert with newSide
void (*request_eject)(); // hold disk ejected
};
void menuSetFdsHooks(const MenuFdsHooks *hooks);
// Optional cassette-deck hooks, same idea as MenuFdsHooks above. The TI-99/4A emulator
// wires these to its CS1/CS2 implementation; other emulators leave it null and the menu
// hides the option via g_settings_visibility[MOPT_CASSETTE].
//
// A tape carries no name of its own - SAVE CS1 supplies only the device - so recording
// asks for a label, which is what default_name / name_exists are for.
struct MenuCassetteHooks
{
int (*get_num_tapes)(); // tapes found in the tape folder
const char *(*get_tape_name)(int index); // display name for 0..num-1
int (*get_selected)(); // loaded tape, or -1 for none
int (*get_mode)(); // 0 empty, 1 play, 2 record WAV, 3 record CAS
void (*default_name)(char *buf, size_t n); // pre-fills the label field
int (*name_exists)(const char *name, int mode); // drives the overwrite confirm
int (*commit)(int index, int mode, const char *name); // name only for record modes
void (*rewind)();
void (*refresh)(); // rescan the tape folder
};
void menuSetCassetteHooks(const MenuCassetteHooks *hooks);
// Longest tape label the menu will show or let you type, plus the terminator.
#define TAPE_LABEL_MAX 25
// Optional disk-drive hooks, same contract as the two above: null unless an emulator
// registers them, and the menu shows the option as "N/A" in that case. Written for the
// TI-99/4A's DSK1-3, where a drive holds one sector image at a time and swapping one in
// mid-session is normal. Images are addressed by their index in the list get_image_name()
// walks, so the menu never has to know where they live on the card.
struct MenuDiskHooks
{
int (*get_num_drives)(); // drives offered, DSK1..DSKn
int (*get_num_images)(); // images found in the disk folder
const char *(*get_image_name)(int index); // display name for 0..num-1
const char *(*get_mounted_name)(int drive); // image in that drive, or NULL when empty
int (*mount)(int drive, int index); // index -1 unmounts; 0 on success
void (*refresh)(); // rescan the disk folder
// Making a blank disk. A new image has no name of its own, so the menu asks for one -
// the same problem, and the same answer, as labelling a tape before recording.
void (*default_name)(char *buf, size_t n); // pre-fills the name field
int (*name_exists)(const char *name); // drives the overwrite confirm
int (*create)(const char *name); // formats it, rescans, returns its index or -1
};
void menuSetDiskHooks(const MenuDiskHooks *hooks);
// A TI volume name is ten characters, and the image is named to match, so the field is
// capped there rather than at the length of a filename.
#define DISK_LABEL_MAX 11
// Put a tape in the deck because the console just asked for one. Called from the
// emulator's frame loop, not from the menu: SAVE CS1 / OLD CS1 name no file, so the
// choice can only be made at the moment the DSR starts reading or writing. Pass 1 to
// record (prompts for a label) or 0 to play (offers the tapes on the card). Allocates
// and frees screenBuffer itself, like showSettingsMenu(true).
bool menuCassettePrompt(int wantRecord);
// Modal single-line text entry, driven from the USB keyboard. `buf` is pre-filled with a
// default and edited in place; returns true if the user confirmed with ENTER, false if
// they cancelled with ESC. Requires a keyboard: callers should check
// io::getCurrentKeyboardState().connected first and fall back to the default if absent.
bool showTextEntry(const char *prompt, char *buf, size_t bufsize);
void menuPumpBlankFrames(int count);
bool showSaveStateMenu(int (*savestatefunc)(const char *path), int (*loadstatefunc)(const char *path), const char *extraMessage, SaveStateTypes quickSave);
void getButtonLabels(char *buttonLabel1, char *buttonLabel2);
void getQuickSavePath(char *path, size_t pathsize);
void getSaveStatePath(char *path, size_t pathsize, int slot);
void getAutoSaveStatePath(char *path, size_t pathsize);
bool isAutoSaveStateConfigured();
#endif