}
if (rendstatus != rendstatus_old || lines != rendlines) {
+ emu_video_mode_change(screen_offset, lines, 1);
rendstatus_old = rendstatus;
rendlines = lines;
- emu_video_mode_change(screen_offset, lines, 1);
}
DrawLineDest = (char *)DrawLineDestBase + screen_offset * DrawLineDestIncrement;
void z80_reset(void)
{
#ifdef _USE_DRZ80
+ // FIXME: reset is not correct
memset(&drZ80, 0, 0x54);
drZ80.Z80F = (1<<2); // set ZFlag
drZ80.Z80F2 = (1<<2); // set ZFlag
\r
void emu_32x_startup(void)\r
{\r
- plat_video_toggle_renderer(0, 0);\r
+ plat_video_toggle_renderer(0, 0); // HACK\r
system_announce();\r
+\r
+ // force mode change event\r
+ rendstatus_old = -1;\r
}\r
\r
void emu_reset_game(void)\r
int turbo_rate;
int renderer;
int renderer32x;
+ int filter; // pandora
} currentConfig_t;
extern currentConfig_t currentConfig, defaultConfig;
-// (c) Copyright 2006-2009 notaz, All rights reserved.\r
+// (c) Copyright 2006-2010 notaz, All rights reserved.\r
// Free for non-commercial use.\r
\r
// For commercial use, separate licencing terms must be obtained.\r
static char static_buff[64];\r
static int menu_error_time = 0;\r
char menu_error_msg[64] = { 0, };\r
+void *g_menuscreen_ptr;\r
+void *g_menubg_src_ptr;\r
void *g_menubg_ptr;\r
\r
#ifndef UIQ3\r
\r
+#if !SCREEN_SIZE_FIXED\r
+int g_menuscreen_w = MSCREEN_WIDTH;\r
+int g_menuscreen_h = MSCREEN_HEIGHT;\r
+#endif\r
+\r
static unsigned char *menu_font_data = NULL;\r
static int menu_text_color = 0xffff; // default to white\r
static int menu_sel_color = -1; // disabled\r
static void text_out16_(int x, int y, const char *text, int color)\r
{\r
int i, lh, tr, tg, tb, len;\r
- unsigned short *dest = (unsigned short *)g_screen_ptr + x + y * g_screen_width;\r
+ unsigned short *dest = (unsigned short *)g_menuscreen_ptr + x + y * g_menuscreen_w;\r
tr = (color & 0xf800) >> 8;\r
tg = (color & 0x07e0) >> 3;\r
tb = (color & 0x001f) << 3;\r
}\r
\r
lh = me_mfont_h;\r
- if (y + lh > g_screen_height)\r
- lh = g_screen_height - y;\r
+ if (y + lh > g_menuscreen_h)\r
+ lh = g_menuscreen_h - y;\r
\r
for (i = 0; i < len; i++)\r
{\r
unsigned short *dst = dest;\r
int u, l;\r
\r
- for (l = 0; l < lh; l++, dst += g_screen_width - me_mfont_w)\r
+ for (l = 0; l < lh; l++, dst += g_menuscreen_w - me_mfont_w)\r
{\r
for (u = me_mfont_w / 2; u > 0; u--, src++)\r
{\r
{\r
va_list args;\r
char buffer[256];\r
- int maxw = (g_screen_width - x) / me_mfont_w;\r
+ int maxw = (g_menuscreen_w - x) / me_mfont_w;\r
\r
if (maxw < 0)\r
return;\r
break;\r
\r
src = fontdata6x8[c];\r
- dst = (unsigned short *)g_screen_ptr + x + y * g_screen_width;\r
+ dst = (unsigned short *)g_menuscreen_ptr + x + y * g_menuscreen_w;\r
\r
while (h--)\r
{\r
dst += multiplier;\r
}\r
\r
- dst += g_screen_width - me_sfont_w;\r
+ dst += g_menuscreen_w - me_sfont_w;\r
}\r
src++;\r
}\r
static void smalltext_out16(int x, int y, const char *texto, int color)\r
{\r
char buffer[128];\r
- int maxw = (g_screen_width - x) / me_sfont_w;\r
+ int maxw = (g_menuscreen_w - x) / me_sfont_w;\r
\r
if (maxw < 0)\r
return;\r
if (menu_sel_color < 0) return; // no selection hilight\r
\r
if (y > 0) y--;\r
- dest = (unsigned short *)g_screen_ptr + x + y * g_screen_width + me_mfont_w * 2 - 2;\r
+ dest = (unsigned short *)g_menuscreen_ptr + x + y * g_menuscreen_w + me_mfont_w * 2 - 2;\r
for (h = me_mfont_h + 1; h > 0; h--)\r
{\r
dst = dest;\r
for (i = w - (me_mfont_w * 2 - 2); i > 0; i--)\r
*dst++ = menu_sel_color;\r
- dest += g_screen_width;\r
+ dest += g_menuscreen_w;\r
}\r
}\r
\r
{\r
if (is_rom_loaded)\r
{\r
+ void *src = g_menubg_src_ptr;\r
+ if (src == NULL)\r
+ src = g_menuscreen_ptr;\r
+\r
// darken the active framebuffer\r
- menu_darken_bg(g_menubg_ptr, g_screen_ptr, g_screen_width * g_screen_height, 1);\r
+ menu_darken_bg(g_menubg_ptr, src, g_menuscreen_w * g_menuscreen_h, 1);\r
}\r
else\r
{\r
\r
// should really only happen once, on startup..\r
emu_make_path(buff, "skin/background.png", sizeof(buff));\r
- if (readpng(g_menubg_ptr, buff, READPNG_BG, g_screen_width, g_screen_height) < 0)\r
- memset(g_menubg_ptr, 0, g_screen_width * g_screen_height * 2);\r
+ if (readpng(g_menubg_ptr, buff, READPNG_BG, g_menuscreen_w, g_menuscreen_h) < 0)\r
+ memset(g_menubg_ptr, 0, g_menuscreen_w * g_menuscreen_h * 2);\r
}\r
\r
plat_video_menu_enter(is_rom_loaded);\r
h = n * me_mfont_h;\r
w += me_mfont_w * 2; /* selector */\r
\r
- if (w > g_screen_width) {\r
- lprintf("width %d > %d\n", w, g_screen_width);\r
- w = g_screen_width;\r
+ if (w > g_menuscreen_w) {\r
+ lprintf("width %d > %d\n", w, g_menuscreen_w);\r
+ w = g_menuscreen_w;\r
}\r
- if (h > g_screen_height) {\r
- lprintf("height %d > %d\n", w, g_screen_height);\r
- h = g_screen_height;\r
+ if (h > g_menuscreen_h) {\r
+ lprintf("height %d > %d\n", w, g_menuscreen_h);\r
+ h = g_menuscreen_h;\r
}\r
\r
- x = g_screen_width / 2 - w / 2;\r
- y = g_screen_height / 2 - h / 2;\r
+ x = g_menuscreen_w / 2 - w / 2;\r
+ y = g_menuscreen_h / 2 - h / 2;\r
\r
/* draw */\r
plat_video_menu_begin();\r
}\r
\r
/* display help or message if we have one */\r
- h = (g_screen_height - h) / 2; // bottom area height\r
+ h = (g_menuscreen_h - h) / 2; // bottom area height\r
if (menu_error_msg[0] != 0) {\r
if (h >= me_mfont_h + 4)\r
- text_out16(5, g_screen_height - me_mfont_h - 4, menu_error_msg);\r
+ text_out16(5, g_menuscreen_h - me_mfont_h - 4, menu_error_msg);\r
else\r
lprintf("menu msg doesn't fit!\n");\r
\r
tmp = strchr(tmp + 1, '\n');\r
if (h >= l * me_sfont_h + 4)\r
for (tmp = ent_sel->help; l > 0; l--, tmp = strchr(tmp, '\n') + 1)\r
- smalltext_out16(5, g_screen_height - (l * me_sfont_h + 4), tmp, 0xffff);\r
+ smalltext_out16(5, g_menuscreen_h - (l * me_sfont_h + 4), tmp, 0xffff);\r
}\r
\r
if (draw_more != NULL)\r
p++;\r
}\r
\r
- x = g_screen_width / 2 - w * me_mfont_w / 2;\r
- y = g_screen_height / 2 - h * me_mfont_h / 2;\r
+ x = g_menuscreen_w / 2 - w * me_mfont_w / 2;\r
+ y = g_menuscreen_h / 2 - h * me_mfont_h / 2;\r
if (x < 0) x = 0;\r
if (y < 0) y = 0;\r
\r
plat_video_menu_begin();\r
\r
- for (p = creds; *p != 0 && y <= g_screen_height - me_mfont_h; y += me_mfont_h) {\r
+ for (p = creds; *p != 0 && y <= g_menuscreen_h - me_mfont_h; y += me_mfont_h) {\r
text_out16(x, y, p);\r
\r
for (; *p != 0 && *p != '\n'; p++)\r
\r
static void load_progress_cb(int percent)\r
{\r
- int ln, len = percent * g_screen_width / 100;\r
- unsigned short *dst = (unsigned short *)g_screen_ptr + g_screen_width * me_sfont_h * 2;\r
+ int ln, len = percent * g_menuscreen_w / 100;\r
+ unsigned short *dst = (unsigned short *)g_menuscreen_ptr + g_menuscreen_w * me_sfont_h * 2;\r
\r
- if (len > g_screen_width)\r
- len = g_screen_width;\r
- for (ln = me_sfont_h - 2; ln > 0; ln--, dst += g_screen_width)\r
+ if (len > g_menuscreen_w)\r
+ len = g_menuscreen_w;\r
+ for (ln = me_sfont_h - 2; ln > 0; ln--, dst += g_menuscreen_w)\r
memset(dst, 0xff, len * 2);\r
plat_video_menu_end();\r
}\r
\r
static void cdload_progress_cb(const char *fname, int percent)\r
{\r
- int ln, len = percent * g_screen_width / 100;\r
- unsigned short *dst = (unsigned short *)g_screen_ptr + g_screen_width * me_sfont_h * 2;\r
+ int ln, len = percent * g_menuscreen_w / 100;\r
+ unsigned short *dst = (unsigned short *)g_menuscreen_ptr + g_menuscreen_w * me_sfont_h * 2;\r
\r
- memset(dst, 0xff, g_screen_width * (me_sfont_h - 2) * 2);\r
+ memset(dst, 0xff, g_menuscreen_w * (me_sfont_h - 2) * 2);\r
\r
smalltext_out16(1, 3 * me_sfont_h, "Processing CD image / MP3s", 0xffff);\r
smalltext_out16(1, 4 * me_sfont_h, fname, 0xffff);\r
- dst += g_screen_width * me_sfont_h * 3;\r
+ dst += g_menuscreen_w * me_sfont_h * 3;\r
\r
- if (len > g_screen_width)\r
- len = g_screen_width;\r
- for (ln = (me_sfont_h - 2); ln > 0; ln--, dst += g_screen_width)\r
+ if (len > g_menuscreen_w)\r
+ len = g_menuscreen_w;\r
+ for (ln = (me_sfont_h - 2); ln > 0; ln--, dst += g_menuscreen_w)\r
memset(dst, 0xff, len * 2);\r
\r
plat_video_menu_end();\r
plat_video_menu_begin();\r
\r
if (!rom_loaded)\r
- menu_darken_bg(g_screen_ptr, g_screen_ptr, g_screen_width * g_screen_height, 0);\r
+ menu_darken_bg(g_menuscreen_ptr, g_menuscreen_ptr, g_menuscreen_w * g_menuscreen_h, 0);\r
\r
len = strlen(fname);\r
- if (len > g_screen_width / me_sfont_w)\r
- len = g_screen_width / me_sfont_w;\r
+ if (len > g_menuscreen_w / me_sfont_w)\r
+ len = g_menuscreen_w / me_sfont_w;\r
\r
- mid = g_screen_width / 2;\r
+ mid = g_menuscreen_w / 2;\r
text_out16(mid - me_mfont_w * 15 / 2, 8 * me_mfont_h, "About to delete");\r
smalltext_out16(mid - len * me_sfont_w / 2, 9 * me_mfont_h + 5, fname, 0xbdff);\r
text_out16(mid - me_mfont_w * 13 / 2, 11 * me_mfont_h, "Are you sure?");\r
int max_cnt, start, i, x, pos;\r
void *darken_ptr;\r
\r
- max_cnt = g_screen_height / me_sfont_h;\r
+ max_cnt = g_menuscreen_h / me_sfont_h;\r
start = max_cnt / 2 - sel;\r
n--; // exclude current dir (".")\r
\r
// if (!rom_loaded)\r
// menu_darken_bg(gp2x_screen, 320*240, 0);\r
\r
- darken_ptr = (short *)g_screen_ptr + g_screen_width * max_cnt/2 * me_sfont_h;\r
- menu_darken_bg(darken_ptr, darken_ptr, g_screen_width * me_sfont_h * 8 / 10, 0);\r
+ darken_ptr = (short *)g_menuscreen_ptr + g_menuscreen_w * max_cnt/2 * me_sfont_h;\r
+ menu_darken_bg(darken_ptr, darken_ptr, g_menuscreen_w * me_sfont_h * 8 / 10, 0);\r
\r
x = 5 + me_mfont_w + 1;\r
if (start - 2 >= 0)\r
{\r
int max_cnt, start, i, pos, active;\r
\r
- max_cnt = g_screen_height / me_sfont_h;\r
+ max_cnt = g_menuscreen_h / me_sfont_h;\r
start = max_cnt / 2 - sel;\r
\r
plat_video_menu_begin();\r
\r
w = (13 + 2) * me_mfont_w;\r
h = (1+2+10+1) * me_mfont_h;\r
- x = g_screen_width / 2 - w / 2;\r
+ x = g_menuscreen_w / 2 - w / 2;\r
if (x < 0) x = 0;\r
- y = g_screen_height / 2 - h / 2;\r
+ y = g_menuscreen_h / 2 - h / 2;\r
if (y < 0) y = 0;\r
\r
plat_video_menu_begin();\r
int x, y, w, i;\r
\r
w = ((player_idx >= 0) ? 20 : 30) * me_mfont_w;\r
- x = g_screen_width / 2 - w / 2;\r
- y = (g_screen_height - 4 * me_mfont_h) / 2 - (2 + opt_cnt) * me_mfont_h / 2;\r
+ x = g_menuscreen_w / 2 - w / 2;\r
+ y = (g_menuscreen_h - 4 * me_mfont_h) / 2 - (2 + opt_cnt) * me_mfont_h / 2;\r
if (x < me_mfont_w * 2)\r
x = me_mfont_w * 2;\r
\r
w = strlen(dev_name) * me_mfont_w;\r
if (w < 30 * me_mfont_w)\r
w = 30 * me_mfont_w;\r
- if (w > g_screen_width)\r
- w = g_screen_width;\r
+ if (w > g_menuscreen_w)\r
+ w = g_menuscreen_w;\r
\r
- x = g_screen_width / 2 - w / 2;\r
+ x = g_menuscreen_w / 2 - w / 2;\r
\r
if (!is_bind) {\r
snprintf(buff2, sizeof(buff2), "%s", in_get_key_name(-1, -PBTN_MOK));\r
snprintf(buff, sizeof(buff), "%s - bind, %s - clear", buff2,\r
in_get_key_name(-1, -PBTN_MA2));\r
- text_out16(x, g_screen_height - 4 * me_mfont_h, buff);\r
+ text_out16(x, g_menuscreen_h - 4 * me_mfont_h, buff);\r
}\r
else\r
- text_out16(x, g_screen_height - 4 * me_mfont_h, "Press a button to bind/unbind");\r
+ text_out16(x, g_menuscreen_h - 4 * me_mfont_h, "Press a button to bind/unbind");\r
\r
if (dev_count > 1) {\r
- text_out16(x, g_screen_height - 3 * me_mfont_h, dev_name);\r
- text_out16(x, g_screen_height - 2 * me_mfont_h, "Press left/right for other devs");\r
+ text_out16(x, g_menuscreen_h - 3 * me_mfont_h, dev_name);\r
+ text_out16(x, g_menuscreen_h - 2 * me_mfont_h, "Press left/right for other devs");\r
}\r
\r
plat_video_menu_end();\r
}\r
\r
str = p;\r
- for (line = from; line < g_screen_height / me_sfont_h; line++)\r
+ for (line = from; line < g_menuscreen_h / me_sfont_h; line++)\r
{\r
smalltext_out16(1, line * me_sfont_h, str, 0xffff);\r
while (*p && *p != '\n')\r
if (PicoDrawMask & PDRAW_SPRITES_HI_ON) memcpy(layer_str + 19, "spr_hi", 6);\r
if (PicoDrawMask & PDRAW_32X_ON) memcpy(layer_str + 26, "32x", 4);\r
\r
- memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2);\r
+ memset(g_menuscreen_ptr, 0, g_menuscreen_w * g_menuscreen_h * 2);\r
pemu_forced_frame(0, 0);\r
smalltext_out16(4, 1, "build: r" REVISION " "__DATE__ " " __TIME__ " " COMPILER, 0xffff);\r
- smalltext_out16(4, g_screen_height - me_sfont_h, layer_str, 0xffff);\r
+ smalltext_out16(4, g_menuscreen_h - me_sfont_h, layer_str, 0xffff);\r
}\r
\r
static void debug_menu_loop(void)\r
plat_debug_cat(tmp);\r
draw_text_debug(tmp, 0, 0);\r
if (dumped) {\r
- smalltext_out16(g_screen_width - 6 * me_sfont_h,\r
- g_screen_height - me_mfont_h, "dumped", 0xffff);\r
+ smalltext_out16(g_menuscreen_w - 6 * me_sfont_h,\r
+ g_menuscreen_h - me_mfont_h, "dumped", 0xffff);\r
dumped = 0;\r
}\r
break;\r
case 1: draw_frame_debug();\r
break;\r
- case 2: memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2);\r
+ case 2: memset(g_menuscreen_ptr, 0, g_menuscreen_w * g_menuscreen_h * 2);\r
pemu_forced_frame(0, 1);\r
- menu_darken_bg(g_screen_ptr, g_screen_ptr, g_screen_width * g_screen_height, 0);\r
- PDebugShowSpriteStats((unsigned short *)g_screen_ptr + (g_screen_height/2 - 240/2)*g_screen_width +\r
- g_screen_width/2 - 320/2, g_screen_width);\r
+ menu_darken_bg(g_menuscreen_ptr, g_menuscreen_ptr, g_menuscreen_w * g_menuscreen_h, 0);\r
+ PDebugShowSpriteStats((unsigned short *)g_menuscreen_ptr + (g_menuscreen_h/2 - 240/2)*g_menuscreen_w +\r
+ g_menuscreen_w/2 - 320/2, g_menuscreen_w);\r
break;\r
- case 3: memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2);\r
- PDebugShowPalette(g_screen_ptr, g_screen_width);\r
- PDebugShowSprite((unsigned short *)g_screen_ptr + g_screen_width*120 + g_screen_width/2 + 16,\r
- g_screen_width, spr_offs);\r
+ case 3: memset(g_menuscreen_ptr, 0, g_menuscreen_w * g_menuscreen_h * 2);\r
+ PDebugShowPalette(g_menuscreen_ptr, g_menuscreen_w);\r
+ PDebugShowSprite((unsigned short *)g_menuscreen_ptr + g_menuscreen_w*120 + g_menuscreen_w/2 + 16,\r
+ g_menuscreen_w, spr_offs);\r
draw_text_debug(PDebugSpriteList(), spr_offs, 6);\r
break;\r
case 4: plat_video_menu_begin();\r
// (c) Copyright 2006-2009 notaz, All rights reserved.
+#include "port_config.h"
+
typedef enum
{
MB_NONE = 1, /* no auto processing */
MA_OPT3_VSYNC,
MA_OPT3_GAMMAA,
MA_OPT3_BLACKLVL,
+ MA_OPT3_LAYER_X,
+ MA_OPT3_LAYER_Y,
+ MA_OPT3_LAYER_W,
+ MA_OPT3_LAYER_H,
MA_OPT3_DONE,
MA_CDOPT_TESTBIOS_USA,
MA_CDOPT_TESTBIOS_EUR,
int mask; /* bit to toggle for on/off */
signed short min; /* for ranged integer settings, to be sign-extended */
signed short max;
- int enabled:1;
- int need_to_save:1;
- int selectable:1;
+ unsigned int enabled:1;
+ unsigned int need_to_save:1;
+ unsigned int selectable:1;
int (*handler)(menu_id id, int keys);
const char * (*generate_name)(menu_id id, int *offs);
const void *data;
#define mee_range(name, id, var, min, max) \
{ name, MB_OPT_RANGE, id, &(var), 0, min, max, 1, 1, 1, NULL, NULL, NULL, NULL }
+#define mee_range_hide(name, id, var, min, max) \
+ { name, MB_OPT_RANGE, id, &(var), 0, min, max, 0, 1, 0, NULL, NULL, NULL, NULL }
+
#define mee_cust_s_h(name, id, need_save, handler, name_func, help) \
{ name, MB_OPT_CUSTOM, id, NULL, 0, 0, 0, 1, need_save, 1, handler, name_func, NULL, help }
extern me_bind_action me_ctrl_actions[15];
extern me_bind_action emuctrl_actions[]; // platform code
+extern void *g_menubg_src_ptr;
extern void *g_menubg_ptr;
+extern void *g_menuscreen_ptr;
+#if SCREEN_SIZE_FIXED
+#define g_menuscreen_w MSCREEN_WIDTH
+#define g_menuscreen_h MSCREEN_HEIGHT
+#else
+extern int g_menuscreen_w;
+extern int g_menuscreen_h;
+#endif
void menu_init(void);
void menu_plat_setup(int is_wiz);
\r
#include <stdio.h>\r
#include <stdlib.h>\r
+#include <unistd.h>\r
\r
#include "plat_gp2x.h"\r
#include "soc.h"\r
vidResetMode();\r
scaling_update();\r
\r
+ // dirty buffers better go now than during gameplay\r
+ sync();\r
+ sleep(0);\r
+\r
pemu_sound_start();\r
}\r
\r
void plat_video_menu_begin(void)
{
memcpy(g_screen_ptr, gp2x_screens[2], 320*240*2);
+ g_menuscreen_ptr = g_screen_ptr;
}
void plat_video_menu_end(void)
#define SCREEN_SIZE_FIXED 1\r
#define SCREEN_WIDTH 320\r
#define SCREEN_HEIGHT 240\r
+#define MSCREEN_WIDTH SCREEN_WIDTH\r
+#define MSCREEN_HEIGHT SCREEN_HEIGHT\r
\r
// draw2.c\r
#define START_ROW 0 // which row of tiles to start rendering at?\r
void plat_video_menu_begin(void)\r
{\r
memcpy32(g_screen_ptr, g_menubg_ptr, g_screen_width * g_screen_height * 2 / 4);\r
+ g_menubg_ptr = g_screen_ptr;\r
}\r
\r
void plat_video_menu_end(void)\r
static void realloc_screen(void)
{
int size = scr_w * scr_h * 2;
- g_screen_width = scr_w;
- g_screen_height = scr_h;
+ g_menuscreen_w = scr_w;
+ g_menuscreen_h = scr_h;
g_screen_ptr = realloc(g_screen_ptr, size);
g_menubg_ptr = realloc(g_menubg_ptr, size);
memset(g_screen_ptr, 0, size);
ret = vout_fbdev_init(&w, &h);
if (ret != 0)
exit(1);
+ g_menuscreen_w = w;
+ g_menuscreen_h = h;
g_screen_width = w;
g_menubg_ptr = realloc(g_menubg_ptr, w * g_screen_height * 2);
PicoDraw2FB = g_menubg_ptr;
#define SCREEN_SIZE_FIXED 0
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
+#define MSCREEN_WIDTH SCREEN_WIDTH
+#define MSCREEN_HEIGHT SCREEN_HEIGHT
// draw2.c
#define START_ROW 0 // which row of tiles to start rendering at?
#profile = 1\r
#drc_debug = 3\r
\r
-no_32x = 1\r
-no_sms = 1\r
-\r
-include Makefile.local\r
\r
ifeq "$(use_musashi)" "1"\r
OBJCOPY = $(CROSS)objcopy\r
\r
# frontend\r
-OBJS += pandora.o emu.o asm_utils.o\r
+OBJS += plat.o asm_utils.o\r
\r
# common\r
OBJS += platform/common/emu.o platform/common/menu.o platform/common/fonts.o platform/common/config.o \\r
PicoDrive.pxml: PicoDrive.pxml.template\r
./make_pxml.sh PicoDrive.pxml.template PicoDrive.pxml\r
\r
+platform/common/menu.o: menu.c\r
+\r
# ----------- release -----------\r
\r
VER = $(shell head -n 1 version.h | sed 's/.*"\(.*\)\.\(.*\)".*/\1\2/g')\r
+++ /dev/null
-// (c) Copyright 2006-2009 notaz, All rights reserved.\r
-// Free for non-commercial use.\r
-\r
-// For commercial use, separate licencing terms must be obtained.\r
-\r
-#include <stdio.h>\r
-#include <unistd.h>\r
-\r
-#include "../common/emu.h"\r
-#include "../common/menu.h"\r
-#include "../common/plat.h"\r
-#include "../common/arm_utils.h"\r
-#include "../linux/sndout_oss.h"\r
-#include "../linux/fbdev.h"\r
-#include "asm_utils.h"\r
-#include "version.h"\r
-\r
-#include <pico/pico_int.h>\r
-\r
-\r
-static short __attribute__((aligned(4))) sndBuffer[2*44100/50];\r
-static unsigned char temp_frame[g_screen_width * g_screen_height * 2];\r
-unsigned char *PicoDraw2FB = temp_frame;\r
-const char *renderer_names[] = { NULL };\r
-const char *renderer_names32x[] = { NULL };\r
-char cpu_clk_name[] = "Max CPU clock";\r
-\r
-enum {\r
- SCALE_1x1,\r
- SCALE_2x2_3x2,\r
- SCALE_2x2_2x2,\r
-};\r
-\r
-static int get_cpu_clock(void)\r
-{\r
- FILE *f;\r
- int ret = 0;\r
- f = fopen("/proc/pandora/cpu_mhz_max", "r");\r
- if (f) {\r
- fscanf(f, "%d", &ret);\r
- fclose(f);\r
- }\r
- return ret;\r
-}\r
-\r
-void pemu_prep_defconfig(void)\r
-{\r
- // XXX: move elsewhere\r
- g_menubg_ptr = temp_frame;\r
-\r
- defaultConfig.EmuOpt |= EOPT_VSYNC;\r
- defaultConfig.s_PicoOpt |= POPT_EN_MCD_GFX|POPT_EN_MCD_PSYNC;\r
- defaultConfig.scaling = SCALE_2x2_3x2;\r
-}\r
-\r
-void pemu_validate_config(void)\r
-{\r
- currentConfig.CPUclock = get_cpu_clock();\r
-}\r
-\r
-// FIXME: cleanup\r
-static void osd_text(int x, int y, const char *text)\r
-{\r
- int len = strlen(text)*8;\r
-\r
- if (0) {\r
- int *p, i, h;\r
- x &= ~3; // align x\r
- len = (len+3) >> 2;\r
- for (h = 0; h < 8; h++) {\r
- p = (int *) ((unsigned char *) g_screen_ptr+x+g_screen_width*(y+h));\r
- for (i = len; i; i--, p++) *p = 0xe0e0e0e0;\r
- }\r
- emu_text_out8(x, y, text);\r
- } else {\r
- int *p, i, h;\r
- x &= ~1; // align x\r
- len++;\r
- for (h = 0; h < 16; h++) {\r
- p = (int *) ((unsigned short *) g_screen_ptr+x+g_screen_width*(y+h));\r
- for (i = len; i; i--, p++) *p = 0;//(*p>>2)&0x39e7;\r
- }\r
- text_out16(x, y, text);\r
- }\r
-}\r
-\r
-static void draw_cd_leds(void)\r
-{\r
-// static\r
- int old_reg;\r
-// if (!((Pico_mcd->s68k_regs[0] ^ old_reg) & 3)) return; // no change // mmu hack problems?\r
- old_reg = Pico_mcd->s68k_regs[0];\r
-\r
- if (0) {\r
- // 8-bit modes\r
- unsigned int col_g = (old_reg & 2) ? 0xc0c0c0c0 : 0xe0e0e0e0;\r
- unsigned int col_r = (old_reg & 1) ? 0xd0d0d0d0 : 0xe0e0e0e0;\r
- *(unsigned int *)((char *)g_screen_ptr + g_screen_width*2+ 4) =\r
- *(unsigned int *)((char *)g_screen_ptr + g_screen_width*3+ 4) =\r
- *(unsigned int *)((char *)g_screen_ptr + g_screen_width*4+ 4) = col_g;\r
- *(unsigned int *)((char *)g_screen_ptr + g_screen_width*2+12) =\r
- *(unsigned int *)((char *)g_screen_ptr + g_screen_width*3+12) =\r
- *(unsigned int *)((char *)g_screen_ptr + g_screen_width*4+12) = col_r;\r
- } else {\r
- // 16-bit modes\r
- unsigned int *p = (unsigned int *)((short *)g_screen_ptr + g_screen_width*2+4);\r
- unsigned int col_g = (old_reg & 2) ? 0x06000600 : 0;\r
- unsigned int col_r = (old_reg & 1) ? 0xc000c000 : 0;\r
- *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += g_screen_width/2 - 12/2;\r
- *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += g_screen_width/2 - 12/2;\r
- *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r;\r
- }\r
-}\r
-\r
-static int emuscan_1x1(unsigned int num)\r
-{\r
- DrawLineDest = (unsigned short *)g_screen_ptr +\r
- g_screen_width * g_screen_height / 2 - g_screen_width * 240 / 2 +\r
- num*g_screen_width + g_screen_width/2 - 320/2;\r
-\r
- return 0;\r
-}\r
-\r
-#define MAKE_EMUSCAN(name_, clut_name_, offs_, len_) \\r
-static int name_(unsigned int num) \\r
-{ \\r
- unsigned char *ps = HighCol+8; \\r
- unsigned short *pd, *pal = HighPal; \\r
- int sh = Pico.video.reg[0xC] & 8; \\r
- int mask = 0xff; \\r
- \\r
- pd = (unsigned short *)g_screen_ptr + num*800*2 + offs_;\\r
- \\r
- if (Pico.m.dirtyPal) \\r
- PicoDoHighPal555(sh); \\r
- \\r
- if (!sh && (rendstatus & PDRAW_SPR_LO_ON_HI)) \\r
- mask = 0x3f; /* upper bits are priority stuff */\\r
- \\r
- clut_line##clut_name_(pd, ps, pal, (mask<<16) | len_); \\r
- \\r
- return 0; \\r
-}\r
-\r
-MAKE_EMUSCAN(emuscan_2x2_40, 2x2, 800/2 - 320*2/2, 320)\r
-MAKE_EMUSCAN(emuscan_2x2_32, 2x2, 800/2 - 256*2/2, 256)\r
-MAKE_EMUSCAN(emuscan_3x2_32, 3x2, 800/2 - 256*3/2, 256)\r
-\r
-#if 0 /* FIXME */\r
-static int EmuScanEnd16_32x(unsigned int num)\r
-{\r
- unsigned int *ps;\r
- unsigned int *pd;\r
- int len;\r
-\r
- ps = (unsigned int *)temp_frame;\r
- pd = (unsigned int *)g_screen_ptr + (num*800*2 + 800/2 - 320*2/2) / 2;\r
-\r
- for (len = 320/2; len > 0; len--, ps++) {\r
- unsigned int p, p1;\r
- p1 = *ps;\r
- p = p1 << 16;\r
- p |= p >> 16;\r
- *pd = pd[800/2] = p;\r
- pd++;\r
-\r
- p = p1 >> 16;\r
- p |= p << 16;\r
- *pd = pd[800/2] = p;\r
- pd++;\r
- }\r
-\r
- return 0;\r
-}\r
-#endif\r
-\r
-void pemu_finalize_frame(const char *fps, const char *notice)\r
-{\r
- if (notice || (currentConfig.EmuOpt & EOPT_SHOW_FPS)) {\r
- if (notice)\r
- osd_text(4, 464, notice);\r
- if (currentConfig.EmuOpt & EOPT_SHOW_FPS)\r
- osd_text(640, 464, fps);\r
- }\r
- if ((PicoAHW & PAHW_MCD) && (currentConfig.EmuOpt & EOPT_EN_CD_LEDS))\r
- draw_cd_leds();\r
-}\r
-\r
-void plat_video_toggle_renderer(int change, int is_menu)\r
-{\r
- // this will auto-select SMS/32X renderers\r
- PicoDrawSetOutFormat(PDF_RGB555, 1);\r
-}\r
-\r
-void plat_video_menu_enter(int is_rom_loaded)\r
-{\r
-}\r
-\r
-void plat_video_menu_begin(void)\r
-{\r
- memcpy32(g_screen_ptr, g_menubg_ptr, g_screen_width * g_screen_height * 2 / 4);\r
-}\r
-\r
-void plat_video_menu_end(void)\r
-{\r
- plat_video_flip();\r
-}\r
-\r
-void plat_status_msg_clear(void)\r
-{\r
- int s = g_screen_width * g_screen_height * 2;\r
- int l = g_screen_width * 16 * 2;\r
- int i;\r
-\r
- for (i = 0; i < fbdev_buffer_count; i++)\r
- memset32((int *)((char *)fbdev_buffers[i] + s - l), 0, l / 4);\r
-}\r
-\r
-void plat_status_msg_busy_next(const char *msg)\r
-{\r
- plat_status_msg_clear();\r
- pemu_finalize_frame("", msg);\r
- plat_video_flip();\r
- emu_status_msg("");\r
- reset_timing = 1;\r
-}\r
-\r
-void plat_status_msg_busy_first(const char *msg)\r
-{\r
-// memset32(g_screen_ptr, 0, g_screen_width * g_screen_height * 2 / 4);\r
- plat_status_msg_busy_next(msg);\r
-}\r
-\r
-void plat_update_volume(int has_changed, int is_up)\r
-{\r
- static int prev_frame = 0, wait_frames = 0;\r
- int vol = currentConfig.volume;\r
-\r
- if (has_changed)\r
- {\r
- if (is_up) {\r
- if (vol < 99) vol++;\r
- } else {\r
- if (vol > 0) vol--;\r
- }\r
- wait_frames = 0;\r
- sndout_oss_setvol(vol, vol);\r
- currentConfig.volume = vol;\r
- emu_status_msg("VOL: %02i", vol);\r
- prev_frame = Pico.m.frame_count;\r
- }\r
-}\r
-\r
-void pemu_forced_frame(int opts, int no_scale)\r
-{\r
- int oldscale = currentConfig.scaling;\r
- int po_old = PicoOpt;\r
-\r
- if (no_scale) {\r
- currentConfig.scaling = SCALE_1x1;\r
- emu_video_mode_change(0, 0, 0);\r
- }\r
-\r
- PicoOpt &= ~POPT_ALT_RENDERER;\r
- PicoOpt |= opts|POPT_ACC_SPRITES; // acc_sprites\r
-\r
- Pico.m.dirtyPal = 1;\r
- PicoFrameDrawOnly();\r
-\r
- PicoOpt = po_old;\r
- currentConfig.scaling = oldscale;\r
-}\r
-\r
-static void updateSound(int len)\r
-{\r
- unsigned int t;\r
-\r
- len <<= 1;\r
- if (PicoOpt & POPT_EN_STEREO)\r
- len <<= 1;\r
-\r
- // sndout_oss_can_write() not reliable..\r
- if ((currentConfig.EmuOpt & EOPT_NO_FRMLIMIT) && !sndout_oss_can_write(len))\r
- return;\r
-\r
- /* avoid writing audio when lagging behind to prevent audio lag */\r
- if (PicoSkipFrame == 2)\r
- return;\r
-\r
- t = plat_get_ticks_ms();\r
- sndout_oss_write(PsndOut, len);\r
- t = plat_get_ticks_ms() - t;\r
- if (t > 1)\r
- printf("audio lag %u\n", t);\r
-}\r
-\r
-void pemu_sound_start(void)\r
-{\r
- int target_fps = Pico.m.pal ? 50 : 60;\r
-\r
- PsndOut = NULL;\r
-\r
- if (currentConfig.EmuOpt & EOPT_EN_SOUND)\r
- {\r
- int snd_excess_add, frame_samples;\r
- int is_stereo = (PicoOpt & POPT_EN_STEREO) ? 1 : 0;\r
-\r
- PsndRerate(Pico.m.frame_count ? 1 : 0);\r
-\r
- frame_samples = PsndLen;\r
- snd_excess_add = ((PsndRate - PsndLen * target_fps)<<16) / target_fps;\r
- if (snd_excess_add != 0)\r
- frame_samples++;\r
-\r
- printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n",\r
- PsndRate, PsndLen, snd_excess_add, is_stereo, Pico.m.pal);\r
- sndout_oss_start(PsndRate, frame_samples * 2, is_stereo);\r
- //sndout_oss_setvol(currentConfig.volume, currentConfig.volume);\r
- PicoWriteSound = updateSound;\r
- plat_update_volume(0, 0);\r
- memset(sndBuffer, 0, sizeof(sndBuffer));\r
- PsndOut = sndBuffer;\r
- }\r
-}\r
-\r
-void pemu_sound_stop(void)\r
-{\r
- sndout_oss_stop();\r
-}\r
-\r
-void pemu_sound_wait(void)\r
-{\r
- // don't need to do anything, writes will block by themselves\r
-}\r
-\r
-void plat_debug_cat(char *str)\r
-{\r
-}\r
-\r
-void emu_video_mode_change(int start_line, int line_count, int is_32cols)\r
-{\r
- int i;\r
-\r
- // clear whole screen in all buffers\r
- for (i = 0; i < fbdev_buffer_count; i++)\r
- memset32(fbdev_buffers[i], 0, g_screen_width * g_screen_height * 2 / 4);\r
-\r
- PicoScanBegin = NULL;\r
- PicoScanEnd = NULL;\r
-\r
-#if 0\r
- if (PicoAHW & PAHW_32X) {\r
- /* FIXME */\r
- DrawLineDest = (unsigned short *)temp_frame;\r
- PicoDrawSetOutFormat(PDF_RGB555, 1);\r
- PicoScanEnd = EmuScanEnd16_32x;\r
- } else\r
-#endif\r
- {\r
- switch (currentConfig.scaling) {\r
- case SCALE_1x1:\r
- PicoDrawSetOutFormat(PDF_RGB555, 1);\r
- PicoScanBegin = emuscan_1x1;\r
- break;\r
- case SCALE_2x2_3x2:\r
- PicoDrawSetOutFormat(PDF_NONE, 0);\r
- PicoScanEnd = is_32cols ? emuscan_3x2_32 : emuscan_2x2_40;\r
- break;\r
- case SCALE_2x2_2x2:\r
- PicoDrawSetOutFormat(PDF_NONE, 0);\r
- PicoScanEnd = is_32cols ? emuscan_2x2_32 : emuscan_2x2_40;\r
- break;\r
- }\r
- }\r
-}\r
-\r
-void pemu_loop_prep(void)\r
-{\r
- if (currentConfig.CPUclock != get_cpu_clock()) {\r
- char buf[64];\r
- snprintf(buf, sizeof(buf), "sudo /usr/pandora/scripts/op_cpuspeed.sh %d",\r
- currentConfig.CPUclock);\r
- system(buf);\r
- }\r
-\r
- pemu_sound_start();\r
-}\r
-\r
-void pemu_loop_end(void)\r
-{\r
- int po_old = PicoOpt;\r
- int eo_old = currentConfig.EmuOpt;\r
-\r
- pemu_sound_stop();\r
- memset32(g_screen_ptr, 0, g_screen_width * g_screen_height * 2 / 4);\r
-\r
- /* do one more frame for menu bg */\r
- PicoOpt &= ~POPT_ALT_RENDERER;\r
- PicoOpt |= POPT_EN_SOFTSCALE|POPT_ACC_SPRITES;\r
- currentConfig.EmuOpt |= EOPT_16BPP;\r
-\r
- PicoDrawSetOutFormat(PDF_RGB555, 1);\r
- Pico.m.dirtyPal = 1;\r
- PicoFrame();\r
-\r
- PicoOpt = po_old;\r
- currentConfig.EmuOpt = eo_old;\r
-}\r
-\r
-void plat_wait_till_us(unsigned int us_to)\r
-{\r
- unsigned int now;\r
- signed int diff;\r
-\r
- now = plat_get_ticks_us();\r
-\r
- // XXX: need to check NOHZ\r
- diff = (signed int)(us_to - now);\r
- if (diff > 10000) {\r
- //printf("sleep %d\n", us_to - now);\r
- usleep(diff * 15 / 16);\r
- now = plat_get_ticks_us();\r
- //printf(" wake %d\n", (signed)(us_to - now));\r
- }\r
-/*\r
- while ((signed int)(us_to - now) > 512) {\r
- spend_cycles(1024);\r
- now = plat_get_ticks_us();\r
- }\r
-*/\r
-}\r
-\r
-const char *plat_get_credits(void)\r
-{\r
- return "PicoDrive v" VERSION " (c) notaz, 2006-2010\n\n\n"\r
- "Credits:\n"\r
- "fDave: Cyclone 68000 core,\n"\r
- " base code of PicoDrive\n"\r
- "Reesy & FluBBa: DrZ80 core\n"\r
- "MAME devs: YM2612 and SN76496 cores\n"\r
- "Pandora team: Pandora\n"\r
- "Inder, ketchupgun: graphics\n"\r
- "\n"\r
- "special thanks (for docs, ideas):\n"\r
- " Charles MacDonald, Haze,\n"\r
- " Stephane Dallongeville,\n"\r
- " Lordus, Exophase, Rokas,\n"\r
- " Nemesis, Tasco Deluxe";\r
-}\r
-static const char *men_scaler[] = { "1x1, 1x1", "2x2, 3x2", "2x2, 2x2", NULL };
+#include "plat.h"
+
+static const char *men_scaler[] = { "1x1, 1x1", "2x2, 3x2", "2x2, 2x2", "fullscreen", "custom", NULL };
static const char h_scaler[] = "Scalers for 40 and 32 column modes\n"
"(320 and 256 pixel wide horizontal)";
+static const char h_cscaler[] = "Displays the scaler layer, you can resize it\n"
+ "using d-pad or move it using R+d-pad";
+static const char *men_dummy[] = { NULL };
+char **pnd_filter_list;
+int g_layer_cx = 80, g_layer_cy = 0;
+int g_layer_cw = 640, g_layer_ch = 480;
+
+static int menu_loop_cscaler(menu_id id, int keys)
+{
+ unsigned int inp;
+
+ currentConfig.scaling = SCALE_CUSTOM;
+
+ pnd_setup_layer(1, g_layer_cx, g_layer_cy, g_layer_cw, g_layer_ch);
+ pnd_restore_layer_data();
+
+ for (;;)
+ {
+ plat_video_menu_begin();
+ memset(g_menuscreen_ptr, 0, g_menuscreen_w * g_menuscreen_h * 2);
+ text_out16(2, 480 - 18, "%dx%d | d-pad to resize, R+d-pad to move", g_layer_cw, g_layer_ch);
+ plat_video_menu_end();
+
+ inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_R|PBTN_MOK|PBTN_MBACK, 40);
+ if (inp & PBTN_UP) g_layer_cy--;
+ if (inp & PBTN_DOWN) g_layer_cy++;
+ if (inp & PBTN_LEFT) g_layer_cx--;
+ if (inp & PBTN_RIGHT) g_layer_cx++;
+ if (!(inp & PBTN_R)) {
+ if (inp & PBTN_UP) g_layer_ch += 2;
+ if (inp & PBTN_DOWN) g_layer_ch -= 2;
+ if (inp & PBTN_LEFT) g_layer_cw += 2;
+ if (inp & PBTN_RIGHT) g_layer_cw -= 2;
+ }
+ if (inp & (PBTN_MOK|PBTN_MBACK))
+ break;
+
+ if (inp & (PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT)) {
+ if (g_layer_cx < 0) g_layer_cx = 0;
+ if (g_layer_cx > 640) g_layer_cx = 640;
+ if (g_layer_cy < 0) g_layer_cy = 0;
+ if (g_layer_cy > 420) g_layer_cy = 420;
+ if (g_layer_cw < 160) g_layer_cw = 160;
+ if (g_layer_ch < 60) g_layer_ch = 60;
+ if (g_layer_cx + g_layer_cw > 800)
+ g_layer_cw = 800 - g_layer_cx;
+ if (g_layer_cy + g_layer_ch > 480)
+ g_layer_ch = 480 - g_layer_cy;
+ pnd_setup_layer(1, g_layer_cx, g_layer_cy, g_layer_cw, g_layer_ch);
+ }
+ }
+
+ pnd_setup_layer(0, g_layer_cx, g_layer_cy, g_layer_cw, g_layer_ch);
+
+ return 0;
+}
#define MENU_OPTIONS_GFX \
- mee_onoff ("Vsync", MA_OPT2_VSYNC, currentConfig.EmuOpt, EOPT_VSYNC), \
mee_enum_h ("Scaler", MA_OPT_SCALING, currentConfig.scaling, \
- men_scaler, h_scaler),
+ men_scaler, h_scaler), \
+ mee_enum ("Filter", MA_OPT3_FILTERING, currentConfig.filter, men_dummy), \
+ mee_onoff ("Vsync", MA_OPT2_VSYNC, currentConfig.EmuOpt, EOPT_VSYNC), \
+ mee_cust_h ("Setup custom scaler", MA_NONE, menu_loop_cscaler, NULL, h_cscaler), \
+ mee_range_hide("layer_x", MA_OPT3_LAYER_X, g_layer_cx, 0, 640), \
+ mee_range_hide("layer_y", MA_OPT3_LAYER_Y, g_layer_cy, 0, 420), \
+ mee_range_hide("layer_w", MA_OPT3_LAYER_W, g_layer_cw, 160, 800), \
+ mee_range_hide("layer_h", MA_OPT3_LAYER_H, g_layer_ch, 60, 480), \
#define MENU_OPTIONS_ADV \
mee_onoff ("SVP dynarec", MA_OPT2_SVP_DYNAREC, PicoOpt, POPT_EN_SVP_DRC), \
mee_onoff ("Status line in main menu", MA_OPT2_STATUS_LINE, currentConfig.EmuOpt, EOPT_SHOW_RTC),
#define menu_main_plat_draw NULL
+
+#include <dirent.h>
+#include <errno.h>
+
+static menu_entry e_menu_gfx_options[];
+
+void pnd_menu_init(void)
+{
+ struct dirent *ent;
+ int i, count = 0;
+ char **mfilters;
+ char buff[64];
+ DIR *dir;
+
+ dir = opendir("/etc/pandora/conf/dss_fir");
+ if (dir == NULL) {
+ perror("filter opendir");
+ return;
+ }
+
+ while (1) {
+ errno = 0;
+ ent = readdir(dir);
+ if (ent == NULL) {
+ if (errno != 0)
+ perror("readdir");
+ break;
+ }
+ if (strstr(ent->d_name, "_up_h"))
+ count++;
+ }
+
+ if (count == 0)
+ return;
+
+ mfilters = calloc(count + 1, sizeof(mfilters[0]));
+ if (mfilters == NULL)
+ return;
+
+ rewinddir(dir);
+ for (i = 0; (ent = readdir(dir)); ) {
+ char *pos;
+ size_t len;
+
+ pos = strstr(ent->d_name, "_up_h");
+ if (pos == NULL)
+ continue;
+
+ len = pos - ent->d_name;
+ if (len > sizeof(buff) - 1)
+ continue;
+
+ strncpy(buff, ent->d_name, len);
+ buff[len] = 0;
+ mfilters[i] = strdup(buff);
+ if (mfilters[i] != NULL)
+ i++;
+ }
+ closedir(dir);
+
+ i = me_id2offset(e_menu_gfx_options, MA_OPT3_FILTERING);
+ e_menu_gfx_options[i].data = (void *)mfilters;
+ pnd_filter_list = mfilters;
+}
+
+++ /dev/null
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <stdarg.h>\r
-\r
-#include "../linux/sndout_oss.h"\r
-#include "../linux/fbdev.h"\r
-#include "../linux/oshide.h"\r
-#include "../common/emu.h"\r
-\r
-void plat_early_init(void)\r
-{\r
-}\r
-\r
-void plat_init(void)\r
-{\r
- int ret, w, h;\r
-\r
- oshide_init();\r
-\r
- ret = vout_fbdev_init(&w, &h);\r
- if (ret != 0) {\r
- fprintf(stderr, "couldn't init framebuffer\n");\r
- exit(1);\r
- }\r
-\r
- if (w != g_screen_width || h != g_screen_height) {\r
- fprintf(stderr, "%dx%d not supported\n", w, h);\r
- vout_fbdev_finish();\r
- exit(1);\r
- }\r
-\r
- // snd\r
- sndout_oss_init();\r
-}\r
-\r
-void plat_finish(void)\r
-{\r
- sndout_oss_exit();\r
- vout_fbdev_finish();\r
- oshide_finish();\r
-\r
- printf("all done\n");\r
-}\r
-\r
-/* lprintf */\r
-void lprintf(const char *fmt, ...)\r
-{\r
- va_list vl;\r
-\r
- va_start(vl, fmt);\r
- vprintf(fmt, vl);\r
- va_end(vl);\r
-}\r
-\r
#include <unistd.h>
#include <sys/ioctl.h>
#include <linux/fb.h>
+#include <linux/omapfb.h>
#include <linux/kd.h>
int main()
fbdev = open("/dev/fb0", O_RDWR);
if (fbdev == -1) {
- perror("open");
- return 1;
+ perror("open fb0");
+ goto end_fb0;
}
ret = ioctl(fbdev, FBIOGET_VSCREENINFO, &fbvar);
if (ret == -1) {
perror("FBIOGET_VSCREENINFO ioctl");
- goto end_fb;
+ goto end_fb0;
}
if (fbvar.yoffset != 0) {
printf("ok\n");
}
-end_fb:
- close(fbdev);
+end_fb0:
+ if (fbdev >= 0)
+ close(fbdev);
+
+ fbdev = open("/dev/fb1", O_RDWR);
+ if (fbdev == -1) {
+ perror("open fb1");
+ goto end_fb1;
+ }
+
+ ret = ioctl(fd, OMAPFB_QUERY_PLANE, &pi);
+ ret |= ioctl(fd, OMAPFB_QUERY_MEM, &mi);
+ if (ret != 0)
+ perror("QUERY_*");
+
+ pi.enabled = 0;
+ ret = ioctl(fd, OMAPFB_SETUP_PLANE, &pi);
+ if (ret != 0)
+ perror("SETUP_PLANE");
+
+ mi.size = 0;
+ ret = ioctl(fd, OMAPFB_SETUP_MEM, &mi);
+ if (ret != 0)
+ perror("SETUP_MEM");
+
+end_fb1:
+ if (fbdev >= 0)
+ close(fbdev);
kbdfd = open("/dev/tty", O_RDWR);
if (kbdfd == -1) {
--- /dev/null
+// (c) Copyright 2006-2009 notaz, All rights reserved.\r
+// Free for non-commercial use.\r
+\r
+// For commercial use, separate licencing terms must be obtained.\r
+\r
+#include <stdio.h>\r
+#include <unistd.h>\r
+#include <stdarg.h>\r
+#include <sys/types.h>\r
+#include <sys/stat.h>\r
+#include <fcntl.h>\r
+#include <sys/ioctl.h>\r
+#include <unistd.h>\r
+#include <linux/fb.h>\r
+#include <linux/omapfb.h>\r
+\r
+#include "../common/emu.h"\r
+#include "../common/menu.h"\r
+#include "../common/plat.h"\r
+#include "../common/arm_utils.h"\r
+#include "../linux/sndout_oss.h"\r
+#include "../linux/fbdev.h"\r
+#include "plat.h"\r
+#include "asm_utils.h"\r
+#include "version.h"\r
+\r
+#include <pico/pico_int.h>\r
+\r
+\r
+static struct vout_fbdev *main_fb, *layer_fb;\r
+static int g_layer_x, g_layer_y;\r
+static int g_layer_w = 320, g_layer_h = 240;\r
+static int g_osd_fps_x, g_osd_y;\r
+\r
+static const char pnd_script_base[] = "sudo -n /usr/pandora/scripts";\r
+static short __attribute__((aligned(4))) sndBuffer[2*44100/50];\r
+static unsigned char __attribute__((aligned(4))) temp_frame[g_menuscreen_w * g_menuscreen_h * 2];\r
+static unsigned char __attribute__((aligned(4))) fb_copy[g_screen_width * g_screen_height * 2];\r
+unsigned char *PicoDraw2FB = temp_frame;\r
+const char *renderer_names[] = { NULL };\r
+const char *renderer_names32x[] = { NULL };\r
+char cpu_clk_name[] = "Max CPU clock";\r
+\r
+static int get_cpu_clock(void)\r
+{\r
+ FILE *f;\r
+ int ret = 0;\r
+ f = fopen("/proc/pandora/cpu_mhz_max", "r");\r
+ if (f) {\r
+ fscanf(f, "%d", &ret);\r
+ fclose(f);\r
+ }\r
+ return ret;\r
+}\r
+\r
+void pemu_prep_defconfig(void)\r
+{\r
+ defaultConfig.EmuOpt |= EOPT_VSYNC|EOPT_16BPP;\r
+ defaultConfig.s_PicoOpt |= POPT_EN_MCD_GFX|POPT_EN_MCD_PSYNC;\r
+ defaultConfig.scaling = SCALE_2x2_3x2;\r
+}\r
+\r
+void pemu_validate_config(void)\r
+{\r
+ currentConfig.CPUclock = get_cpu_clock();\r
+}\r
+\r
+static void osd_text(int x, int y, const char *text)\r
+{\r
+ int len = strlen(text)*8;\r
+ int i, h;\r
+\r
+ len++;\r
+ for (h = 0; h < 8; h++) {\r
+ unsigned short *p;\r
+ p = (unsigned short *)g_screen_ptr + x + g_screen_width*(y + h);\r
+ for (i = len; i; i--, p++)\r
+ *p = (*p>>2) & 0x39e7;\r
+ }\r
+ emu_text_out16(x, y, text);\r
+}\r
+\r
+static void draw_cd_leds(void)\r
+{\r
+ int old_reg;\r
+ old_reg = Pico_mcd->s68k_regs[0];\r
+\r
+ if (0) {\r
+ // 8-bit modes\r
+ unsigned int col_g = (old_reg & 2) ? 0xc0c0c0c0 : 0xe0e0e0e0;\r
+ unsigned int col_r = (old_reg & 1) ? 0xd0d0d0d0 : 0xe0e0e0e0;\r
+ *(unsigned int *)((char *)g_screen_ptr + g_screen_width*2+ 4) =\r
+ *(unsigned int *)((char *)g_screen_ptr + g_screen_width*3+ 4) =\r
+ *(unsigned int *)((char *)g_screen_ptr + g_screen_width*4+ 4) = col_g;\r
+ *(unsigned int *)((char *)g_screen_ptr + g_screen_width*2+12) =\r
+ *(unsigned int *)((char *)g_screen_ptr + g_screen_width*3+12) =\r
+ *(unsigned int *)((char *)g_screen_ptr + g_screen_width*4+12) = col_r;\r
+ } else {\r
+ // 16-bit modes\r
+ unsigned int *p = (unsigned int *)((short *)g_screen_ptr + g_screen_width*2+4);\r
+ unsigned int col_g = (old_reg & 2) ? 0x06000600 : 0;\r
+ unsigned int col_r = (old_reg & 1) ? 0xc000c000 : 0;\r
+ *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += g_screen_width/2 - 12/2;\r
+ *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += g_screen_width/2 - 12/2;\r
+ *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r;\r
+ }\r
+}\r
+\r
+static int emuscan(unsigned int num)\r
+{\r
+ DrawLineDest = (unsigned short *)g_screen_ptr + num * g_screen_width;\r
+\r
+ return 0;\r
+}\r
+\r
+void pemu_finalize_frame(const char *fps, const char *notice)\r
+{\r
+ if (notice || (currentConfig.EmuOpt & EOPT_SHOW_FPS)) {\r
+ if (notice)\r
+ osd_text(2, g_osd_y, notice);\r
+ if (currentConfig.EmuOpt & EOPT_SHOW_FPS)\r
+ osd_text(g_osd_fps_x, g_osd_y, fps);\r
+ }\r
+ if ((PicoAHW & PAHW_MCD) && (currentConfig.EmuOpt & EOPT_EN_CD_LEDS))\r
+ draw_cd_leds();\r
+}\r
+\r
+void plat_video_flip(void)\r
+{\r
+ g_screen_ptr = vout_fbdev_flip(layer_fb);\r
+}\r
+\r
+void plat_video_toggle_renderer(int change, int is_menu)\r
+{\r
+}\r
+\r
+void plat_video_menu_enter(int is_rom_loaded)\r
+{\r
+}\r
+\r
+void plat_video_menu_begin(void)\r
+{\r
+ memcpy32(g_menuscreen_ptr, g_menubg_ptr, g_menuscreen_w * g_menuscreen_h * 2 / 4);\r
+}\r
+\r
+void plat_video_menu_end(void)\r
+{\r
+ g_menuscreen_ptr = vout_fbdev_flip(main_fb);\r
+}\r
+\r
+void plat_video_wait_vsync(void)\r
+{\r
+ vout_fbdev_wait_vsync(main_fb);\r
+}\r
+\r
+void plat_status_msg_clear(void)\r
+{\r
+ vout_fbdev_clear_lines(layer_fb, g_screen_height - 8, 8);\r
+}\r
+\r
+void plat_status_msg_busy_next(const char *msg)\r
+{\r
+ plat_status_msg_clear();\r
+ pemu_finalize_frame("", msg);\r
+ plat_video_flip();\r
+ emu_status_msg("");\r
+ reset_timing = 1;\r
+}\r
+\r
+void plat_status_msg_busy_first(const char *msg)\r
+{\r
+ plat_status_msg_busy_next(msg);\r
+}\r
+\r
+void plat_update_volume(int has_changed, int is_up)\r
+{\r
+ static int prev_frame = 0, wait_frames = 0;\r
+ int vol = currentConfig.volume;\r
+\r
+ if (has_changed)\r
+ {\r
+ if (is_up) {\r
+ if (vol < 99) vol++;\r
+ } else {\r
+ if (vol > 0) vol--;\r
+ }\r
+ wait_frames = 0;\r
+ sndout_oss_setvol(vol, vol);\r
+ currentConfig.volume = vol;\r
+ emu_status_msg("VOL: %02i", vol);\r
+ prev_frame = Pico.m.frame_count;\r
+ }\r
+}\r
+\r
+void pemu_forced_frame(int opts, int no_scale)\r
+{\r
+ int oldscale = currentConfig.scaling;\r
+ int po_old = PicoOpt;\r
+\r
+ if (no_scale) {\r
+ currentConfig.scaling = SCALE_1x1;\r
+ emu_video_mode_change(8, 224, 0);\r
+ }\r
+\r
+ PicoOpt |= opts|POPT_ACC_SPRITES;\r
+\r
+ Pico.m.dirtyPal = 1;\r
+ PicoFrameDrawOnly();\r
+\r
+ PicoOpt = po_old;\r
+ currentConfig.scaling = oldscale;\r
+}\r
+\r
+static void updateSound(int len)\r
+{\r
+ unsigned int t;\r
+\r
+ len <<= 1;\r
+ if (PicoOpt & POPT_EN_STEREO)\r
+ len <<= 1;\r
+\r
+ // sndout_oss_can_write() not reliable..\r
+ if ((currentConfig.EmuOpt & EOPT_NO_FRMLIMIT) && !sndout_oss_can_write(len))\r
+ return;\r
+\r
+ /* avoid writing audio when lagging behind to prevent audio lag */\r
+ if (PicoSkipFrame == 2)\r
+ return;\r
+\r
+ t = plat_get_ticks_ms();\r
+ sndout_oss_write(PsndOut, len);\r
+ t = plat_get_ticks_ms() - t;\r
+ if (t > 1)\r
+ printf("audio lag %u\n", t);\r
+}\r
+\r
+void pemu_sound_start(void)\r
+{\r
+ int target_fps = Pico.m.pal ? 50 : 60;\r
+\r
+ PsndOut = NULL;\r
+\r
+ if (currentConfig.EmuOpt & EOPT_EN_SOUND)\r
+ {\r
+ int snd_excess_add, frame_samples;\r
+ int is_stereo = (PicoOpt & POPT_EN_STEREO) ? 1 : 0;\r
+\r
+ PsndRerate(Pico.m.frame_count ? 1 : 0);\r
+\r
+ frame_samples = PsndLen;\r
+ snd_excess_add = ((PsndRate - PsndLen * target_fps)<<16) / target_fps;\r
+ if (snd_excess_add != 0)\r
+ frame_samples++;\r
+\r
+ /*\r
+ * for 44k stereo, we do 1470 samples/frame\r
+ * OMAP driver does power of 2 buffers, so we need at least 4K buffer.\r
+ * The most we can lag is 1K samples, size of OMAP's McBSP FIFO,\r
+ * with 2K sample buffer we might sometimes lag more than that,\r
+ * thus causing underflows.\r
+ */\r
+ printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n",\r
+ PsndRate, PsndLen, snd_excess_add, is_stereo, Pico.m.pal);\r
+ sndout_oss_start(PsndRate, frame_samples * 2, is_stereo);\r
+ //sndout_oss_setvol(currentConfig.volume, currentConfig.volume);\r
+ PicoWriteSound = updateSound;\r
+ plat_update_volume(0, 0);\r
+ memset(sndBuffer, 0, sizeof(sndBuffer));\r
+ PsndOut = sndBuffer;\r
+ }\r
+}\r
+\r
+void pemu_sound_stop(void)\r
+{\r
+ sndout_oss_stop();\r
+}\r
+\r
+void pemu_sound_wait(void)\r
+{\r
+ // don't need to do anything, writes will block by themselves\r
+}\r
+\r
+void plat_debug_cat(char *str)\r
+{\r
+}\r
+\r
+static int pnd_setup_layer_(int fd, int enabled, int x, int y, int w, int h)\r
+{\r
+ struct omapfb_plane_info pi;\r
+ struct omapfb_mem_info mi;\r
+ int ret;\r
+\r
+ ret = ioctl(fd, OMAPFB_QUERY_PLANE, &pi);\r
+ if (ret != 0) {\r
+ perror("QUERY_PLANE");\r
+ return -1;\r
+ }\r
+\r
+ ret = ioctl(fd, OMAPFB_QUERY_MEM, &mi);\r
+ if (ret != 0) {\r
+ perror("QUERY_MEM");\r
+ return -1;\r
+ }\r
+\r
+ /* must disable when changing stuff */\r
+ if (pi.enabled) {\r
+ pi.enabled = 0;\r
+ ret = ioctl(fd, OMAPFB_SETUP_PLANE, &pi);\r
+ if (ret != 0)\r
+ perror("SETUP_PLANE");\r
+ }\r
+\r
+ mi.size = 320*240*2*4;\r
+ ret = ioctl(fd, OMAPFB_SETUP_MEM, &mi);\r
+ if (ret != 0) {\r
+ perror("SETUP_MEM");\r
+ return -1;\r
+ }\r
+\r
+ pi.pos_x = x;\r
+ pi.pos_y = y;\r
+ pi.out_width = w;\r
+ pi.out_height = h;\r
+ pi.enabled = enabled;\r
+\r
+ ret = ioctl(fd, OMAPFB_SETUP_PLANE, &pi);\r
+ if (ret != 0) {\r
+ perror("SETUP_PLANE");\r
+ return -1;\r
+ }\r
+\r
+ return 0;\r
+}\r
+\r
+int pnd_setup_layer(int enabled, int x, int y, int w, int h)\r
+{\r
+ return pnd_setup_layer_(vout_fbdev_get_fd(layer_fb), enabled, x, y, w, h);\r
+}\r
+\r
+void pnd_restore_layer_data(void)\r
+{\r
+ short *t = ((short *)fb_copy)[320*240 / 2 + 160];\r
+\r
+ // right now this is used by menu, which wants to preview something\r
+ // so try to get something on the layer.\r
+ if ((t[0] | t[5] | t[13]) == 0)\r
+ memset32((void *)fb_copy, 0x07000700, sizeof(fb_copy) / 4);\r
+\r
+ memcpy32(g_screen_ptr, (void *)fb_copy, 320*240*2 / 4);\r
+ plat_video_flip();\r
+}\r
+\r
+static void apply_filter(int which)\r
+{\r
+ char buf[128];\r
+ int i;\r
+\r
+ if (pnd_filter_list == NULL)\r
+ return;\r
+\r
+ for (i = 0; i < which; i++)\r
+ if (pnd_filter_list[i] == NULL)\r
+ return;\r
+\r
+ if (pnd_filter_list[i] == NULL)\r
+ return;\r
+\r
+ snprintf(buf, sizeof(buf), "%s/op_videofir.sh %s", pnd_script_base, pnd_filter_list[i]);\r
+ system(buf);\r
+}\r
+\r
+void emu_video_mode_change(int start_line, int line_count, int is_32cols)\r
+{\r
+ int fb_w = 320, fb_h = 240, fb_left = 0, fb_right = 0, fb_top = 0, fb_bottom = 0;\r
+\r
+ PicoScanBegin = emuscan;\r
+ PicoScanEnd = NULL;\r
+ PicoDrawSetOutFormat(PDF_RGB555, 1);\r
+\r
+ if (is_32cols) {\r
+ fb_w = 256;\r
+ fb_left = fb_right = 32;\r
+ }\r
+\r
+ switch (currentConfig.scaling) {\r
+ case SCALE_1x1:\r
+ g_layer_w = fb_w;\r
+ g_layer_h = fb_h;\r
+ break;\r
+ case SCALE_2x2_3x2:\r
+ g_layer_w = fb_w * (is_32cols ? 3 : 2);\r
+ g_layer_h = fb_h * 2;\r
+ break;\r
+ case SCALE_2x2_2x2:\r
+ g_layer_w = fb_w * 2;\r
+ g_layer_h = fb_h * 2;\r
+ break;\r
+ case SCALE_FULLSCREEN:\r
+ g_layer_w = 800;\r
+ g_layer_h = 480;\r
+ break;\r
+ case SCALE_CUSTOM:\r
+ g_layer_x = g_layer_cx;\r
+ g_layer_y = g_layer_cy;\r
+ g_layer_w = g_layer_cw;\r
+ g_layer_h = g_layer_ch;\r
+ break;\r
+ }\r
+\r
+ if (currentConfig.scaling != SCALE_CUSTOM) {\r
+ // center the layer\r
+ g_layer_x = 800 / 2 - g_layer_w / 2;\r
+ g_layer_y = 480 / 2 - g_layer_h / 2;\r
+ }\r
+\r
+ switch (currentConfig.scaling) {\r
+ case SCALE_FULLSCREEN:\r
+ case SCALE_CUSTOM:\r
+ fb_top = start_line;\r
+ fb_h = line_count;\r
+ break;\r
+ }\r
+ g_osd_fps_x = is_32cols ? 232 : 264;\r
+ g_osd_y = fb_top + fb_h - 8;\r
+\r
+ pnd_setup_layer(1, g_layer_x, g_layer_y, g_layer_w, g_layer_h);\r
+ vout_fbdev_resize(layer_fb, fb_w, fb_h, fb_left, fb_right, fb_top, fb_bottom, 0);\r
+ vout_fbdev_clear(layer_fb);\r
+}\r
+\r
+static void make_bg(void)\r
+{\r
+ unsigned short *s = (void *)fb_copy;\r
+ unsigned int t, *d = (unsigned int *)g_menubg_src_ptr + 80 / 2;\r
+ int x, y;\r
+\r
+ memset32(g_menubg_src_ptr, 0, 800 * 480 * 2 / 4);\r
+\r
+ for (y = 0; y < 240; y++, s += 320, d += 800*2/2) {\r
+ for (x = 0; x < 320; x++) {\r
+ t = s[x];\r
+ t |= t << 16;\r
+ d[x] = d[x + 800 / 2] = t;\r
+ }\r
+ }\r
+}\r
+\r
+void pemu_loop_prep(void)\r
+{\r
+ static int pal_old = -1;\r
+ static int filter_old = -1;\r
+ char buf[128];\r
+\r
+ if (currentConfig.CPUclock != get_cpu_clock()) {\r
+ snprintf(buf, sizeof(buf), "unset DISPLAY; echo y | %s/op_cpuspeed.sh %d",\r
+ pnd_script_base, currentConfig.CPUclock);\r
+ system(buf);\r
+ }\r
+\r
+ if (Pico.m.pal != pal_old) {\r
+ snprintf(buf, sizeof(buf), "%s/op_lcdrate.sh %d",\r
+ pnd_script_base, Pico.m.pal ? 50 : 60);\r
+ system(buf);\r
+ pal_old = Pico.m.pal;\r
+ }\r
+\r
+ if (currentConfig.filter != filter_old) {\r
+ apply_filter(currentConfig.filter);\r
+ filter_old = currentConfig.filter;\r
+ }\r
+\r
+ // make sure there is no junk left behind the layer\r
+ memset32(g_menuscreen_ptr, 0, 800 * 480 * 2 / 4);\r
+ g_menuscreen_ptr = vout_fbdev_flip(main_fb);\r
+\r
+ // emu_video_mode_change will call pnd_setup_layer()\r
+\r
+ // dirty buffers better go now than during gameplay\r
+ sync();\r
+ sleep(0);\r
+\r
+ pemu_sound_start();\r
+}\r
+\r
+void pemu_loop_end(void)\r
+{\r
+ int po_old = PicoOpt;\r
+ int eo_old = currentConfig.EmuOpt;\r
+\r
+ pemu_sound_stop();\r
+ memset32(g_screen_ptr, 0, g_screen_width * g_screen_height * 2 / 4);\r
+\r
+ /* do one more frame for menu bg */\r
+ PicoOpt |= POPT_EN_SOFTSCALE|POPT_ACC_SPRITES;\r
+ currentConfig.EmuOpt |= EOPT_16BPP;\r
+\r
+ PicoDrawSetOutFormat(PDF_RGB555, 1);\r
+ Pico.m.dirtyPal = 1;\r
+ PicoFrame();\r
+\r
+ // making a copy because enabling the layer clears it's mem\r
+ memcpy32((void *)fb_copy, g_screen_ptr, sizeof(fb_copy) / 4);\r
+ make_bg();\r
+\r
+ pnd_setup_layer(0, g_layer_x, g_layer_y, g_layer_w, g_layer_h);\r
+\r
+ PicoOpt = po_old;\r
+ currentConfig.EmuOpt = eo_old;\r
+}\r
+\r
+void plat_wait_till_us(unsigned int us_to)\r
+{\r
+ unsigned int now;\r
+ signed int diff;\r
+\r
+ now = plat_get_ticks_us();\r
+\r
+ // XXX: need to check NOHZ\r
+ diff = (signed int)(us_to - now);\r
+ if (diff > 10000) {\r
+ //printf("sleep %d\n", us_to - now);\r
+ usleep(diff * 15 / 16);\r
+ now = plat_get_ticks_us();\r
+ //printf(" wake %d\n", (signed)(us_to - now));\r
+ }\r
+/*\r
+ while ((signed int)(us_to - now) > 512) {\r
+ spend_cycles(1024);\r
+ now = plat_get_ticks_us();\r
+ }\r
+*/\r
+}\r
+\r
+const char *plat_get_credits(void)\r
+{\r
+ return "PicoDrive v" VERSION " (c) notaz, 2006-2010\n\n\n"\r
+ "Credits:\n"\r
+ "fDave: Cyclone 68000 core,\n"\r
+ " base code of PicoDrive\n"\r
+ "Reesy & FluBBa: DrZ80 core\n"\r
+ "MAME devs: YM2612 and SN76496 cores\n"\r
+ "Pandora team: Pandora\n"\r
+ "Inder, ketchupgun: graphics\n"\r
+ "\n"\r
+ "special thanks (for docs, ideas):\n"\r
+ " Charles MacDonald, Haze,\n"\r
+ " Stephane Dallongeville,\n"\r
+ " Lordus, Exophase, Rokas,\n"\r
+ " Nemesis, Tasco Deluxe";\r
+}\r
+\r
+#include "../linux/oshide.h"\r
+\r
+void plat_early_init(void)\r
+{\r
+}\r
+\r
+void plat_init(void)\r
+{\r
+ const char *main_fb_name, *layer_fb_name;\r
+ int fd, ret, w, h;\r
+\r
+ main_fb_name = getenv("FBDEV_MAIN");\r
+ if (main_fb_name == NULL)\r
+ main_fb_name = "/dev/fb0";\r
+\r
+ layer_fb_name = getenv("FBDEV_LAYER");\r
+ if (layer_fb_name == NULL)\r
+ layer_fb_name = "/dev/fb1";\r
+\r
+ // must set the layer up first to be able to use it\r
+ fd = open(layer_fb_name, O_RDWR);\r
+ if (fd == -1) {\r
+ fprintf(stderr, "%s: ", layer_fb_name);\r
+ perror("open");\r
+ exit(1);\r
+ }\r
+\r
+ ret = pnd_setup_layer_(fd, 0, g_layer_x, g_layer_y, g_layer_w, g_layer_h);\r
+ close(fd);\r
+ if (ret != 0) {\r
+ fprintf(stderr, "failed to set up layer, exiting.\n");\r
+ exit(1);\r
+ }\r
+\r
+ oshide_init();\r
+\r
+ w = h = 0;\r
+ main_fb = vout_fbdev_init(main_fb_name, &w, &h, 0);\r
+ if (main_fb == NULL) {\r
+ fprintf(stderr, "couldn't init fb: %s\n", main_fb_name);\r
+ exit(1);\r
+ }\r
+\r
+ if (w != g_menuscreen_w || h != g_menuscreen_h) {\r
+ fprintf(stderr, "%dx%d not supported on %s\n", w, h, main_fb_name);\r
+ goto fail0;\r
+ }\r
+ g_menuscreen_ptr = vout_fbdev_flip(main_fb);\r
+\r
+ w = 320; h = 240;\r
+ layer_fb = vout_fbdev_init(layer_fb_name, &w, &h, 0);\r
+ if (layer_fb == NULL) {\r
+ fprintf(stderr, "couldn't init fb: %s\n", layer_fb_name);\r
+ goto fail0;\r
+ }\r
+\r
+ if (w != g_screen_width || h != g_screen_height) {\r
+ fprintf(stderr, "%dx%d not supported on %s\n", w, h, layer_fb_name);\r
+ goto fail1;\r
+ }\r
+ g_screen_ptr = vout_fbdev_flip(layer_fb);\r
+\r
+ g_menubg_ptr = temp_frame;\r
+ g_menubg_src_ptr = temp_frame;\r
+\r
+ sndout_oss_init();\r
+ pnd_menu_init();\r
+ return;\r
+\r
+fail1:\r
+ vout_fbdev_finish(layer_fb);\r
+fail0:\r
+ vout_fbdev_finish(main_fb);\r
+ exit(1);\r
+}\r
+\r
+void plat_finish(void)\r
+{\r
+ sndout_oss_exit();\r
+ vout_fbdev_finish(main_fb);\r
+ oshide_finish();\r
+\r
+ printf("all done\n");\r
+}\r
+\r
+/* lprintf */\r
+void lprintf(const char *fmt, ...)\r
+{\r
+ va_list vl;\r
+\r
+ va_start(vl, fmt);\r
+ vprintf(fmt, vl);\r
+ va_end(vl);\r
+}\r
+\r
--- /dev/null
+
+extern char **pnd_filter_list;
+extern int g_layer_cx, g_layer_cy;
+extern int g_layer_cw, g_layer_ch;
+
+void pnd_menu_init(void);
+int pnd_setup_layer(int enabled, int x, int y, int w, int h);
+void pnd_restore_layer_data(void);
+
+enum {
+ SCALE_1x1,
+ SCALE_2x2_3x2,
+ SCALE_2x2_2x2,
+ SCALE_FULLSCREEN,
+ SCALE_CUSTOM,
+};
+
#define REDUCE_IO_CALLS 0\r
\r
#define SCREEN_SIZE_FIXED 1\r
-#define SCREEN_WIDTH 800\r
-#define SCREEN_HEIGHT 480\r
+#define SCREEN_WIDTH 320\r
+#define SCREEN_HEIGHT 240\r
+#define MSCREEN_WIDTH 800\r
+#define MSCREEN_HEIGHT 480\r
\r
// draw2.c\r
#define START_ROW 0 // which row of tiles to start rendering at?\r