remove PicoDrive-specific stuff, add readme
[libpicofe.git] / linux / emu.c
diff --git a/linux/emu.c b/linux/emu.c
deleted file mode 100644 (file)
index 95666ad..0000000
+++ /dev/null
@@ -1,300 +0,0 @@
-// (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 "version.h"\r
-\r
-#include <pico/pico_int.h>\r
-\r
-\r
-static short __attribute__((aligned(4))) sndBuffer[2*44100/50];\r
-const char *renderer_names[] = { "16bit accurate", " 8bit accurate", " 8bit fast", NULL };\r
-const char *renderer_names32x[] = { "accurate", "faster", "fastest", NULL };\r
-enum renderer_types { RT_16BIT, RT_8BIT_ACC, RT_8BIT_FAST, RT_COUNT };\r
-\r
-\r
-void pemu_prep_defconfig(void)\r
-{\r
-}\r
-\r
-void pemu_validate_config(void)\r
-{\r
-       extern int PicoOpt;\r
-//     PicoOpt &= ~POPT_EXT_FM;\r
-       PicoOpt &= ~POPT_EN_SVP_DRC;\r
-}\r
-\r
-// FIXME: dupes from GP2X, need cleanup\r
-static void (*osd_text)(int x, int y, const char *text);\r
-\r
-/*\r
-static void osd_text8(int x, int y, const char *text)\r
-{\r
-       int len = strlen(text)*8;\r
-       int *p, i, h, offs;\r
-\r
-       len = (len+3) >> 2;\r
-       for (h = 0; h < 8; h++) {\r
-               offs = (x + g_screen_width * (y+h)) & ~3;\r
-               p = (int *) ((char *)g_screen_ptr + offs);\r
-               for (i = len; i; i--, p++)\r
-                       *p = 0xe0e0e0e0;\r
-       }\r
-       emu_text_out8(x, y, text);\r
-}\r
-*/\r
-\r
-static void osd_text16(int x, int y, const char *text)\r
-{\r
-       int len = strlen(text)*8;\r
-       int *p, i, h, offs;\r
-\r
-       len = (len+1) >> 1;\r
-       for (h = 0; h < 8; h++) {\r
-               offs = (x + g_screen_width * (y+h)) & ~1;\r
-               p = (int *) ((short *)g_screen_ptr + offs);\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 led_reg, pitch, scr_offs, led_offs;\r
-       led_reg = Pico_mcd->s68k_regs[0];\r
-\r
-       pitch = 320;\r
-       led_offs = 4;\r
-       scr_offs = pitch * 2 + 4;\r
-\r
-       if (currentConfig.renderer != RT_16BIT) {\r
-       #define p(x) px[(x) >> 2]\r
-               // 8-bit modes\r
-               unsigned int *px = (unsigned int *)((char *)g_screen_ptr + scr_offs);\r
-               unsigned int col_g = (led_reg & 2) ? 0xc0c0c0c0 : 0xe0e0e0e0;\r
-               unsigned int col_r = (led_reg & 1) ? 0xd0d0d0d0 : 0xe0e0e0e0;\r
-               p(pitch*0) = p(pitch*1) = p(pitch*2) = col_g;\r
-               p(pitch*0 + led_offs) = p(pitch*1 + led_offs) = p(pitch*2 + led_offs) = col_r;\r
-       #undef p\r
-       } else {\r
-       #define p(x) px[(x)*2 >> 2] = px[((x)*2 >> 2) + 1]\r
-               // 16-bit modes\r
-               unsigned int *px = (unsigned int *)((short *)g_screen_ptr + scr_offs);\r
-               unsigned int col_g = (led_reg & 2) ? 0x06000600 : 0;\r
-               unsigned int col_r = (led_reg & 1) ? 0xc000c000 : 0;\r
-               p(pitch*0) = p(pitch*1) = p(pitch*2) = col_g;\r
-               p(pitch*0 + led_offs) = p(pitch*1 + led_offs) = p(pitch*2 + led_offs) = col_r;\r
-       #undef p\r
-       }\r
-}\r
-\r
-void pemu_finalize_frame(const char *fps, const char *notice)\r
-{\r
-       if (currentConfig.renderer != RT_16BIT && !(PicoAHW & PAHW_32X)) {\r
-               unsigned short *pd = (unsigned short *)g_screen_ptr + 8 * g_screen_width;\r
-               unsigned char *ps = PicoDraw2FB + 328*8 + 8;\r
-               unsigned short *pal = HighPal;\r
-               int i, x;\r
-               if (Pico.m.dirtyPal)\r
-                       PicoDrawUpdateHighPal();\r
-               for (i = 0; i < 224; i++, ps += 8)\r
-                       for (x = 0; x < 320; x++)\r
-                               *pd++ = pal[*ps++];\r
-       }\r
-\r
-       if (notice || (currentConfig.EmuOpt & EOPT_SHOW_FPS)) {\r
-               if (notice)\r
-                       osd_text(4, g_screen_height - 8, notice);\r
-               if (currentConfig.EmuOpt & EOPT_SHOW_FPS)\r
-                       osd_text(g_screen_width - 60, g_screen_height - 8, fps);\r
-       }\r
-       if ((PicoAHW & PAHW_MCD) && (currentConfig.EmuOpt & EOPT_EN_CD_LEDS))\r
-               draw_cd_leds();\r
-}\r
-\r
-static void apply_renderer(void)\r
-{\r
-       switch (currentConfig.renderer) {\r
-       case RT_16BIT:\r
-               PicoOpt &= ~POPT_ALT_RENDERER;\r
-               PicoDrawSetOutFormat(PDF_RGB555, 0);\r
-               PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2);\r
-               break;\r
-       case RT_8BIT_ACC:\r
-               PicoOpt &= ~POPT_ALT_RENDERER;\r
-               PicoDrawSetOutFormat(PDF_8BIT, 0);\r
-               PicoDrawSetOutBuf(PicoDraw2FB + 8, 328);\r
-               break;\r
-       case RT_8BIT_FAST:\r
-               PicoOpt |=  POPT_ALT_RENDERER;\r
-               PicoDrawSetOutFormat(PDF_NONE, 0);\r
-               break;\r
-       }\r
-\r
-       if (PicoAHW & PAHW_32X) {\r
-               int only_32x = 0;\r
-               if (currentConfig.renderer == RT_16BIT)\r
-                       only_32x = 1;\r
-               else\r
-                       PicoDrawSetOutFormat(PDF_NONE, 0);\r
-               PicoDraw32xSetFrameMode(1, only_32x);\r
-               PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2);\r
-       }\r
-       //PicoDraw32xSetFrameMode(0, 0);\r
-       //PicoDrawSetOutFormat(PDF_RGB555, 1);\r
-}\r
-\r
-void plat_video_toggle_renderer(int change, int is_menu)\r
-{\r
-       currentConfig.renderer += change;\r
-       if      (currentConfig.renderer >= RT_COUNT)\r
-               currentConfig.renderer = 0;\r
-       else if (currentConfig.renderer < 0)\r
-               currentConfig.renderer = RT_COUNT - 1;\r
-\r
-       if (!is_menu)\r
-               apply_renderer();\r
-\r
-       emu_status_msg(renderer_names[currentConfig.renderer]);\r
-}\r
-\r
-void plat_video_menu_enter(int is_rom_loaded)\r
-{\r
-}\r
-\r
-void plat_video_menu_begin(void)\r
-{\r
-       g_menuscreen_ptr = g_screen_ptr;\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
-       unsigned short *d = (unsigned short *)g_screen_ptr + g_screen_width * g_screen_height;\r
-       int l = g_screen_width * 8;\r
-       memset32((int *)(d - l), 0, l * 2 / 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
-}\r
-\r
-void pemu_forced_frame(int no_scale, int do_emu)\r
-{\r
-       PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2);\r
-       PicoDraw32xSetFrameMode(0, 0);\r
-       PicoDrawSetCallbacks(NULL, NULL);\r
-       Pico.m.dirtyPal = 1;\r
-\r
-       emu_cmn_forced_frame(no_scale, do_emu);\r
-\r
-       g_menubg_src_ptr = g_screen_ptr;\r
-}\r
-\r
-static void oss_write_nonblocking(int len)\r
-{\r
-       // sndout_oss_can_write() is not reliable, only use with no_frmlimit\r
-       if ((currentConfig.EmuOpt & EOPT_NO_FRMLIMIT) && !sndout_oss_can_write(len))\r
-               return;\r
-\r
-       sndout_oss_write_nb(PsndOut, len);\r
-}\r
-\r
-void pemu_sound_start(void)\r
-{\r
-       PsndOut = NULL;\r
-\r
-       if (currentConfig.EmuOpt & EOPT_EN_SOUND)\r
-       {\r
-               int is_stereo = (PicoOpt & POPT_EN_STEREO) ? 1 : 0;\r
-\r
-               PsndRerate(Pico.m.frame_count ? 1 : 0);\r
-\r
-               printf("starting audio: %i len: %i stereo: %i, pal: %i\n",\r
-                       PsndRate, PsndLen, is_stereo, Pico.m.pal);\r
-               sndout_oss_start(PsndRate, is_stereo, 1);\r
-               sndout_oss_setvol(currentConfig.volume, currentConfig.volume);\r
-               PicoWriteSound = oss_write_nonblocking;\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
-}\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
-       // clear whole screen in all buffers\r
-       memset32(g_screen_ptr, 0, g_screen_width * g_screen_height * 2 / 4);\r
-}\r
-\r
-void pemu_loop_prep(void)\r
-{\r
-       apply_renderer();\r
-       osd_text = osd_text16;\r
-\r
-       pemu_sound_start();\r
-}\r
-\r
-void pemu_loop_end(void)\r
-{\r
-       pemu_sound_stop();\r
-\r
-       /* do one more frame for menu bg */\r
-       pemu_forced_frame(0, 1);\r
-}\r
-\r
-void plat_wait_till_us(unsigned int us_to)\r
-{\r
-       unsigned int now;\r
-\r
-       now = plat_get_ticks_us();\r
-\r
-       while ((signed int)(us_to - now) > 512)\r
-       {\r
-               usleep(1024);\r
-               now = plat_get_ticks_us();\r
-       }\r
-}\r
-\r