X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=platform%2Flinux%2Femu.c;h=ddde8dab35fda230ec3e0e74a83de884b1f1c7aa;hb=93f9619ed819dee07948416c98ca2f1c70a22666;hp=65d868b59d49037e329e2a02053d731937d2e25b;hpb=f4750ee051b509a17bb940d6372a0c12faae18cd;p=picodrive.git diff --git a/platform/linux/emu.c b/platform/linux/emu.c index 65d868b..ddde8da 100644 --- a/platform/linux/emu.c +++ b/platform/linux/emu.c @@ -1,22 +1,23 @@ -// (c) Copyright 2006-2009 notaz, All rights reserved. -// Free for non-commercial use. - -// For commercial use, separate licencing terms must be obtained. +/* + * PicoDrive + * (C) notaz, 2006-2010 + * + * This work is licensed under the terms of MAME license. + * See COPYING file in the top-level directory. + */ #include #include +#include "../libpicofe/menu.h" +#include "../libpicofe/plat.h" #include "../common/emu.h" -#include "../common/menu.h" -#include "../common/plat.h" #include "../common/arm_utils.h" -#include "../linux/sndout_oss.h" -#include "version.h" +#include "../common/version.h" #include -static short __attribute__((aligned(4))) sndBuffer[2*44100/50]; const char *renderer_names[] = { "16bit accurate", " 8bit accurate", " 8bit fast", NULL }; const char *renderer_names32x[] = { "accurate", "faster", "fastest", NULL }; enum renderer_types { RT_16BIT, RT_8BIT_ACC, RT_8BIT_FAST, RT_COUNT }; @@ -28,44 +29,9 @@ void pemu_prep_defconfig(void) void pemu_validate_config(void) { - extern int PicoOpt; -// PicoOpt &= ~POPT_EXT_FM; - PicoOpt &= ~POPT_EN_SVP_DRC; -} - -// FIXME: dupes from GP2X, need cleanup -static void (*osd_text)(int x, int y, const char *text); - -/* -static void osd_text8(int x, int y, const char *text) -{ - int len = strlen(text)*8; - int *p, i, h, offs; - - len = (len+3) >> 2; - for (h = 0; h < 8; h++) { - offs = (x + g_screen_width * (y+h)) & ~3; - p = (int *) ((char *)g_screen_ptr + offs); - for (i = len; i; i--, p++) - *p = 0xe0e0e0e0; - } - emu_text_out8(x, y, text); -} -*/ - -static void osd_text16(int x, int y, const char *text) -{ - int len = strlen(text)*8; - int *p, i, h, offs; - - len = (len+1) >> 1; - for (h = 0; h < 8; h++) { - offs = (x + g_screen_width * (y+h)) & ~1; - p = (int *) ((short *)g_screen_ptr + offs); - for (i = len; i; i--, p++) - *p = (*p >> 2) & 0x39e7; - } - emu_text_out16(x, y, text); +#ifndef __arm__ + PicoIn.opt &= ~POPT_EN_DRC; +#endif } static void draw_cd_leds(void) @@ -100,10 +66,10 @@ static void draw_cd_leds(void) void pemu_finalize_frame(const char *fps, const char *notice) { - if (currentConfig.renderer != RT_16BIT && !(PicoAHW & PAHW_32X)) { + if (currentConfig.renderer != RT_16BIT && !(PicoIn.AHW & PAHW_32X)) { unsigned short *pd = (unsigned short *)g_screen_ptr + 8 * g_screen_width; - unsigned char *ps = PicoDraw2FB + 328*8 + 8; - unsigned short *pal = HighPal; + unsigned char *ps = Pico.est.Draw2FB + 328*8 + 8; + unsigned short *pal = Pico.est.HighPal; int i, x; if (Pico.m.dirtyPal) PicoDrawUpdateHighPal(); @@ -114,11 +80,11 @@ void pemu_finalize_frame(const char *fps, const char *notice) if (notice || (currentConfig.EmuOpt & EOPT_SHOW_FPS)) { if (notice) - osd_text(4, g_screen_height - 8, notice); + emu_osd_text16(4, g_screen_height - 8, notice); if (currentConfig.EmuOpt & EOPT_SHOW_FPS) - osd_text(g_screen_width - 60, g_screen_height - 8, fps); + emu_osd_text16(g_screen_width - 60, g_screen_height - 8, fps); } - if ((PicoAHW & PAHW_MCD) && (currentConfig.EmuOpt & EOPT_EN_CD_LEDS)) + if ((PicoIn.AHW & PAHW_MCD) && (currentConfig.EmuOpt & EOPT_EN_CD_LEDS)) draw_cd_leds(); } @@ -126,32 +92,23 @@ static void apply_renderer(void) { switch (currentConfig.renderer) { case RT_16BIT: - PicoOpt &= ~POPT_ALT_RENDERER; + PicoIn.opt &= ~POPT_ALT_RENDERER; PicoDrawSetOutFormat(PDF_RGB555, 0); PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2); break; case RT_8BIT_ACC: - PicoOpt &= ~POPT_ALT_RENDERER; + PicoIn.opt &= ~POPT_ALT_RENDERER; PicoDrawSetOutFormat(PDF_8BIT, 0); - PicoDrawSetOutBuf(PicoDraw2FB + 8, 328); + PicoDrawSetOutBuf(Pico.est.Draw2FB + 8, 328); break; case RT_8BIT_FAST: - PicoOpt |= POPT_ALT_RENDERER; + PicoIn.opt |= POPT_ALT_RENDERER; PicoDrawSetOutFormat(PDF_NONE, 0); break; } - if (PicoAHW & PAHW_32X) { - int only_32x = 0; - if (currentConfig.renderer == RT_16BIT) - only_32x = 1; - else - PicoDrawSetOutFormat(PDF_NONE, 0); - PicoDraw32xSetFrameMode(1, only_32x); + if (PicoIn.AHW & PAHW_32X) PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2); - } - //PicoDraw32xSetFrameMode(0, 0); - //PicoDrawSetOutFormat(PDF_RGB555, 1); } void plat_video_toggle_renderer(int change, int is_menu) @@ -168,21 +125,6 @@ void plat_video_toggle_renderer(int change, int is_menu) emu_status_msg(renderer_names[currentConfig.renderer]); } -void plat_video_menu_enter(int is_rom_loaded) -{ -} - -void plat_video_menu_begin(void) -{ - memcpy32(g_screen_ptr, g_menubg_ptr, g_screen_width * g_screen_height * 2 / 4); - g_menuscreen_ptr = g_screen_ptr; -} - -void plat_video_menu_end(void) -{ - plat_video_flip(); -} - void plat_status_msg_clear(void) { unsigned short *d = (unsigned short *)g_screen_ptr + g_screen_width * g_screen_height; @@ -209,75 +151,20 @@ void plat_update_volume(int has_changed, int is_up) { } -void pemu_forced_frame(int opts, int no_scale) +void pemu_forced_frame(int no_scale, int do_emu) { - int po_old = PicoOpt; - int eo_old = currentConfig.EmuOpt; - - PicoOpt &= ~POPT_ALT_RENDERER; - PicoOpt |= opts|POPT_ACC_SPRITES; // acc_sprites - - PicoDrawSetOutFormat(PDF_RGB555, 1); PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2); - PicoDraw32xSetFrameMode(0, 0); - + PicoDrawSetCallbacks(NULL, NULL); Pico.m.dirtyPal = 1; - PicoFrameDrawOnly(); - - PicoOpt = po_old; - currentConfig.EmuOpt = eo_old; -} - -static void updateSound(int len) -{ - len <<= 1; - if (PicoOpt & POPT_EN_STEREO) - len <<= 1; - if ((currentConfig.EmuOpt & EOPT_NO_FRMLIMIT) && !sndout_oss_can_write(len)) - return; + emu_cmn_forced_frame(no_scale, do_emu); - /* avoid writing audio when lagging behind to prevent audio lag */ - if (PicoSkipFrame != 2) - sndout_oss_write(PsndOut, len); + g_menubg_src_ptr = g_screen_ptr; } void pemu_sound_start(void) { - int target_fps = Pico.m.pal ? 50 : 60; - - PsndOut = NULL; - - if (currentConfig.EmuOpt & EOPT_EN_SOUND) - { - int snd_excess_add, frame_samples; - int is_stereo = (PicoOpt & POPT_EN_STEREO) ? 1 : 0; - - PsndRerate(Pico.m.frame_count ? 1 : 0); - - frame_samples = PsndLen; - snd_excess_add = ((PsndRate - PsndLen * target_fps)<<16) / target_fps; - if (snd_excess_add != 0) - frame_samples++; - - printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n", - PsndRate, PsndLen, snd_excess_add, is_stereo, Pico.m.pal); - sndout_oss_start(PsndRate, frame_samples, is_stereo); - sndout_oss_setvol(currentConfig.volume, currentConfig.volume); - PicoWriteSound = updateSound; - plat_update_volume(0, 0); - memset(sndBuffer, 0, sizeof(sndBuffer)); - PsndOut = sndBuffer; - } -} - -void pemu_sound_stop(void) -{ -} - -void pemu_sound_wait(void) -{ - // don't need to do anything, writes will block by themselves + emu_sound_start(); } void plat_debug_cat(char *str) @@ -293,31 +180,12 @@ void emu_video_mode_change(int start_line, int line_count, int is_32cols) void pemu_loop_prep(void) { apply_renderer(); - osd_text = osd_text16; - - pemu_sound_start(); } void pemu_loop_end(void) { - int po_old = PicoOpt; - int eo_old = currentConfig.EmuOpt; - - pemu_sound_stop(); - memset32(g_screen_ptr, 0, g_screen_width * g_screen_height * 2 / 4); - /* do one more frame for menu bg */ - PicoOpt &= ~POPT_ALT_RENDERER; - PicoOpt |= POPT_EN_SOFTSCALE|POPT_ACC_SPRITES; - - PicoDrawSetOutFormat(PDF_RGB555, 1); - PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2); - PicoDraw32xSetFrameMode(0, 0); - Pico.m.dirtyPal = 1; - PicoFrame(); - - PicoOpt = po_old; - currentConfig.EmuOpt = eo_old; + pemu_forced_frame(0, 1); } void plat_wait_till_us(unsigned int us_to) @@ -333,24 +201,7 @@ void plat_wait_till_us(unsigned int us_to) } } -const char *plat_get_credits(void) +void *plat_mem_get_for_drc(size_t size) { - return "PicoDrive v" VERSION " (c) notaz, 2006-2009\n\n\n" - "Credits:\n" - "fDave: Cyclone 68000 core,\n" - " base code of PicoDrive\n" - "Reesy & FluBBa: DrZ80 core\n" - "MAME devs: YM2612 and SN76496 cores\n" - "rlyeh and others: minimal SDK\n" - "Squidge: mmuhack\n" - "Dzz: ARM940 sample\n" - "GnoStiC / Puck2099: USB joy code\n" - "craigix: GP2X hardware\n" - "ketchupgun: skin design\n" - "\n" - "special thanks (for docs, ideas):\n" - " Charles MacDonald, Haze,\n" - " Stephane Dallongeville,\n" - " Lordus, Exophase, Rokas,\n" - " Nemesis, Tasco Deluxe"; + return NULL; }