void (*PicoCartLoadProgressCB)(int percent) = NULL;\r
void (*PicoCDLoadProgressCB)(const char *fname, int percent) = NULL; // handled in Pico/cd/cd_file.c\r
\r
-static void PicoCartDetect(void);\r
+static void PicoCartDetect(const char *carthw_cfg);\r
\r
/* cso struct */\r
typedef struct _cso_struct\r
}\r
\r
// Insert a cartridge:\r
-int PicoCartInsert(unsigned char *rom,unsigned int romsize)\r
+int PicoCartInsert(unsigned char *rom, unsigned int romsize, const char *carthw_cfg)\r
{\r
// notaz: add a 68k "jump one op back" opcode to the end of ROM.\r
// This will hang the emu, but will prevent nasty crashes.\r
carthw_chunks = NULL;\r
\r
if (!(PicoAHW & (PAHW_MCD|PAHW_SMS)))\r
- PicoCartDetect();\r
+ PicoCartDetect(carthw_cfg);\r
\r
// setup correct memory map for loaded ROM\r
switch (PicoAHW) {\r
return 1;\r
}\r
\r
-static void parse_carthw(int *fill_sram)\r
+static void parse_carthw(const char *carthw_cfg, int *fill_sram)\r
{\r
int line = 0, any_checks_passed = 0, skip_sect = 0;\r
int tmp, rom_crc = 0;\r
char buff[256], *p, *r;\r
FILE *f;\r
\r
- f = fopen("carthw.cfg", "r");\r
+ f = fopen(carthw_cfg, "r");\r
if (f == NULL) {\r
- elprintf(EL_STATUS, "couldn't open carthw.txt!");\r
+ elprintf(EL_STATUS, "couldn't open carthw.cfg!");\r
return;\r
}\r
\r
/*\r
* various cart-specific things, which can't be handled by generic code\r
*/\r
-static void PicoCartDetect(void)\r
+static void PicoCartDetect(const char *carthw_cfg)\r
{\r
int fill_sram = 0;\r
\r
SRam.eeprom_bit_in = 0;\r
SRam.eeprom_bit_out= 0;\r
\r
- parse_carthw(&fill_sram);\r
+ if (carthw_cfg != NULL)\r
+ parse_carthw(carthw_cfg, &fill_sram);\r
\r
if (SRam.flags & SRF_ENABLED)\r
{\r
unsigned char HighLnSpr[240][3 + MAX_LINE_SPRITES]; // sprite_count, ^flags, tile_count, [spritep]...\r
\r
int rendstatus, rendstatus_old;\r
+int rendlines;\r
int DrawScanline;\r
int PicoDrawMask = -1;\r
\r
// MUST be called every frame\r
PICO_INTERNAL void PicoFrameStart(void)\r
{\r
+ int lines = 224;\r
+\r
// prepare to do this frame\r
rendstatus = 0;\r
- if ((Pico.video.reg[12]&6) == 6)\r
+ if ((Pico.video.reg[12] & 6) == 6)\r
rendstatus |= PDRAW_INTERLACE; // interlace mode\r
+ if (!(Pico.video.reg[12] & 1))\r
+ rendstatus |= PDRAW_32_COLS;\r
if (Pico.video.reg[1] & 8)\r
- rendstatus |= PDRAW_240LINES;\r
+ lines = 240;\r
\r
DrawScanline = 0;\r
skip_next_line = 0;\r
\r
- if (rendstatus != rendstatus_old) {\r
+ if (rendstatus != rendstatus_old || lines != rendlines) {\r
+ rendlines = lines;\r
rendstatus_old = rendstatus;\r
- emu_video_mode_change((rendstatus & PDRAW_240LINES) ? 0 : 8,\r
- (rendstatus & PDRAW_240LINES) ? 240 : 224,\r
- (Pico.video.reg[12] & 1) ? 0 : 1);\r
+ emu_video_mode_change((lines == 240) ? 0 : 8,\r
+ lines, (Pico.video.reg[12] & 1) ? 0 : 1);\r
}\r
\r
if (PicoOpt & POPT_ALT_RENDERER)\r
\r
static void PicoLine(int line, int offs, int sh, int bgc)\r
{\r
+ int skip = 0;\r
+\r
if (skip_next_line > 0) {\r
skip_next_line--;\r
return;\r
\r
DrawScanline = line;\r
if (PicoScanBegin != NULL)\r
- skip_next_line = PicoScanBegin(line + offs);\r
+ skip = PicoScanBegin(line + offs);\r
+\r
+ if (skip) {\r
+ skip_next_line = skip - 1;\r
+ return;\r
+ }\r
\r
// Draw screen:\r
BackFill(bgc, sh);\r
int sh = (Pico.video.reg[0xC] & 8) >> 3; // shadow/hilight?\r
int bgc = Pico.video.reg[7];\r
\r
- if (!(rendstatus & PDRAW_240LINES))\r
+ if (rendlines != 240)\r
offs = 8;\r
\r
// need to know which pixels are bg for 32x\r
int lines = 192;
skip_next_line = 0;
screen_offset = 24;
- rendstatus = 0;
+ rendstatus = PDRAW_32_COLS;
if ((Pico.video.reg[0] & 6) == 6 && (Pico.video.reg[1] & 0x18)) {
if (Pico.video.reg[1] & 0x08) {
- rendstatus |= PDRAW_240LINES;
screen_offset = 0;
lines = 240;
}
}
}
- if (rendstatus != rendstatus_old) {
+ if (rendstatus != rendstatus_old || lines != rendlines) {
rendstatus_old = rendstatus;
+ rendlines = lines;
emu_video_mode_change(screen_offset, lines, 1);
}
}
// this one should handle display mode changes\r
extern void emu_video_mode_change(int start_line, int line_count, int is_32cols);\r
\r
-// this must switch to 32bpp mode\r
+// this must switch to 16bpp mode\r
extern void emu_32x_startup(void);\r
\r
// optional 32X BIOS, should be left NULL if not used\r
int pm_seek(pm_file *stream, long offset, int whence);\r
int pm_close(pm_file *fp);\r
int PicoCartLoad(pm_file *f,unsigned char **prom,unsigned int *psize,int is_sms);\r
-int PicoCartInsert(unsigned char *rom,unsigned int romsize);\r
+int PicoCartInsert(unsigned char *rom, unsigned int romsize, const char *carthw_cfg);\r
void PicoCartUnload(void);\r
extern void (*PicoCartLoadProgressCB)(int percent);\r
extern void (*PicoCDLoadProgressCB)(const char *fname, int percent);\r
#define PDRAW_SONIC_MODE (1<<5) // mid-frame palette changes for 8bit renderer\r
#define PDRAW_PLANE_HI_PRIO (1<<6) // have layer with all hi prio tiles (mk3)\r
#define PDRAW_SHHI_DONE (1<<7) // layer sh/hi already processed\r
-#define PDRAW_240LINES (1<<8) // 240 line display (224 if not set)\r
+#define PDRAW_32_COLS (1<<8) // 32 column mode\r
extern int rendstatus, rendstatus_old;\r
+extern int rendlines;\r
extern unsigned short HighPal[0x100];\r
\r
// Draw2.c\r
int pico_inp_mode = 0;\r
int engineState = PGS_Menu;\r
\r
+/* tmp buff to reduce stack usage for plats with small stack */\r
+static char static_buff[512];\r
/* TODO: len checking */\r
-char rom_fname_reload[512] = { 0, };\r
-char rom_fname_loaded[512] = { 0, };\r
+char rom_fname_reload[512];\r
+char rom_fname_loaded[512];\r
int rom_loaded = 0;\r
int reset_timing = 0;\r
static unsigned int notice_msg_time; /* when started showing */\r
\r
static int find_bios(int region, char **bios_file)\r
{\r
- static char bios_path[1024];\r
int i, count;\r
const char * const *files;\r
FILE *f = NULL;\r
\r
for (i = 0; i < count; i++)\r
{\r
- emu_make_path(bios_path, files[i], sizeof(bios_path) - 4);\r
- strcat(bios_path, ".bin");\r
- f = fopen(bios_path, "rb");\r
+ emu_make_path(static_buff, files[i], sizeof(static_buff) - 4);\r
+ strcat(static_buff, ".bin");\r
+ f = fopen(static_buff, "rb");\r
if (f) break;\r
\r
- bios_path[strlen(bios_path) - 4] = 0;\r
- strcat(bios_path, ".zip");\r
- f = fopen(bios_path, "rb");\r
+ static_buff[strlen(static_buff) - 4] = 0;\r
+ strcat(static_buff, ".zip");\r
+ f = fopen(static_buff, "rb");\r
if (f) break;\r
}\r
\r
if (f) {\r
- lprintf("using bios: %s\n", bios_path);\r
+ lprintf("using bios: %s\n", static_buff);\r
fclose(f);\r
- if (bios_file) *bios_file = bios_path;\r
+ if (bios_file)\r
+ *bios_file = static_buff;\r
return 1;\r
} else {\r
- sprintf(bios_path, "no %s BIOS files found, read docs",\r
+ sprintf(static_buff, "no %s BIOS files found, read docs",\r
region != 4 ? (region == 8 ? "EU" : "JAP") : "USA");\r
- me_update_msg(bios_path);\r
+ me_update_msg(static_buff);\r
return 0;\r
}\r
}\r
}\r
\r
menu_romload_prepare(used_rom_name); // also CD load\r
+ used_rom_name = NULL; // uses static_buff\r
\r
ret = PicoCartLoad(rom, &rom_data, &rom_size, (PicoAHW & PAHW_SMS) ? 1 : 0);\r
pm_close(rom);\r
if (!ret) emu_read_config(0, 0);\r
}\r
\r
- if (PicoCartInsert(rom_data, rom_size)) {\r
+ emu_make_path(static_buff, "carthw.cfg", sizeof(static_buff));\r
+ if (PicoCartInsert(rom_data, rom_size, static_buff)) {\r
me_update_msg("Failed to load ROM.");\r
goto fail;\r
}\r
if (ext) strcat(dst, ext);\r
}\r
\r
+// <base dir><end>\r
void emu_make_path(char *buff, const char *end, int size)\r
{\r
int pos, end_len;\r
\r
char *emu_get_save_fname(int load, int is_sram, int slot)\r
{\r
- static char saveFname[512];\r
+ char *saveFname = static_buff;\r
char ext[16];\r
\r
if (is_sram)\r
pframes_done++; frames_done++;\r
diff_lim += target_frametime;\r
\r
- if (!(currentConfig.EmuOpt & EOPT_NO_FRMLIMIT)) {\r
+ if (!(currentConfig.EmuOpt & (EOPT_NO_FRMLIMIT|EOPT_EXT_FRMLIMIT))) {\r
timestamp = get_ticks();\r
diff = timestamp - timestamp_base;\r
if (!reset_timing && diff < diff_lim) // we are too fast\r
PicoFrame();\r
\r
/* frame limiter */\r
- if (!reset_timing && !(currentConfig.EmuOpt & EOPT_NO_FRMLIMIT))\r
+ if (!reset_timing && !(currentConfig.EmuOpt & (EOPT_NO_FRMLIMIT|EOPT_EXT_FRMLIMIT)))\r
{\r
timestamp = get_ticks();\r
diff = timestamp - timestamp_base;\r
#define EOPT_SHOW_RTC (1<<17)
#define EOPT_NO_FRMLIMIT (1<<18)
#define EOPT_WIZ_TEAR_FIX (1<<19)
+#define EOPT_EXT_FRMLIMIT (1<<20) // no internal frame limiter (limited by snd, etc)
enum {
EOPT_SCALE_NONE = 0,