X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=platform%2Fgp2x%2Femu.c;h=c0bc71f4e880159f0f63a4852a66df82e298be9a;hb=98a27142346e05a4cef4fe89469bc09d5560edc1;hp=7db89c29253258782d95dfbe9cd6c13c886844f6;hpb=75a30842c4f9e7e95a199361b9348c9f9dede0e6;p=picodrive.git diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index 7db89c2..c0bc71f 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -7,8 +7,8 @@ * - 8bpp tile renderer * In 32x mode: * - 32x layer is overlayed on top of 16bpp one - * - line internal one done on PicoDraw2FB, then mixed with 32x - * - tile internal one done on PicoDraw2FB, then mixed with 32x + * - line internal one done on .Draw2FB, then mixed with 32x + * - tile internal one done on .Draw2FB, then mixed with 32x */ #include @@ -30,7 +30,7 @@ #include #include #include -#include +#include #ifdef BENCHMARK #define OSD_FPS_X 220 @@ -128,21 +128,6 @@ static void osd_text8(int x, int y, const char *text) 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); -} - static void osd_text8_rot(int x, int y, const char *text) { int len = strlen(text) * 8; @@ -237,7 +222,7 @@ static unsigned char __attribute__((aligned(4))) rot_buff[320*4*2]; static int EmuScanBegin16_rot(unsigned int num) { - DrawLineDest = rot_buff + (num & 3) * 320 * 2; + Pico.est.DrawLineDest = rot_buff + (num & 3) * 320 * 2; return 0; } @@ -252,7 +237,7 @@ static int EmuScanEnd16_rot(unsigned int num) static int EmuScanBegin8_rot(unsigned int num) { - DrawLineDest = rot_buff + (num & 3) * 320; + Pico.est.DrawLineDest = rot_buff + (num & 3) * 320; return 0; } @@ -277,14 +262,14 @@ static int EmuScanBegin16_ld(unsigned int num) if (emu_scan_begin) return emu_scan_begin(ld_counter); else - DrawLineDest = (char *)g_screen_ptr + 320 * ld_counter * gp2x_current_bpp / 8; + Pico.est.DrawLineDest = (char *)g_screen_ptr + 320 * ld_counter * gp2x_current_bpp / 8; return 0; } static int EmuScanEnd16_ld(unsigned int num) { - void *oldline = DrawLineDest; + void *oldline = Pico.est.DrawLineDest; if (emu_scan_end) emu_scan_end(ld_counter); @@ -295,7 +280,7 @@ static int EmuScanEnd16_ld(unsigned int num) ld_left = ld_lines; EmuScanBegin16_ld(num); - memcpy32(DrawLineDest, oldline, 320 * gp2x_current_bpp / 8 / 4); + memcpy32(Pico.est.DrawLineDest, oldline, 320 * gp2x_current_bpp / 8 / 4); if (emu_scan_end) emu_scan_end(ld_counter); @@ -325,9 +310,9 @@ static int make_local_pal_md(int fast_mode) localPal[0xf0] = 0x00ffffff; pallen = 0x100; } - else if (rendstatus & PDRAW_SONIC_MODE) { // mid-frame palette changes - bgr444_to_rgb32(localPal+0x40, HighPal); - bgr444_to_rgb32(localPal+0x80, HighPal+0x40); + else if (Pico.est.rendstatus & PDRAW_SONIC_MODE) { // mid-frame palette changes + bgr444_to_rgb32(localPal+0x40, Pico.est.HighPal); + bgr444_to_rgb32(localPal+0x80, Pico.est.HighPal+0x40); } else memcpy32(localPal+0x80, localPal, 0x40); // for spr prio mess @@ -370,9 +355,9 @@ void pemu_finalize_frame(const char *fps, const char *notice) } // a hack for VR if (PicoAHW & PAHW_SVP) - memset32((int *)(PicoDraw2FB+328*8+328*223), 0xe0e0e0e0, 328); + memset32((int *)(Pico.est.Draw2FB+328*8+328*223), 0xe0e0e0e0, 328); // do actual copy - vidcpyM2(g_screen_ptr, PicoDraw2FB+328*8, + vidcpyM2(g_screen_ptr, Pico.est.Draw2FB+328*8, !(Pico.video.reg[12] & 1), !(PicoOpt & POPT_DIS_32C_BORDER)); } else if (get_renderer() == RT_8BIT_ACC) @@ -407,7 +392,6 @@ void plat_video_flip(void) } /* XXX */ -#ifdef __GP2X__ unsigned int plat_get_ticks_ms(void) { return gp2x_get_ticks_ms(); @@ -417,7 +401,6 @@ unsigned int plat_get_ticks_us(void) { return gp2x_get_ticks_us(); } -#endif void plat_wait_till_us(unsigned int us_to) { @@ -542,7 +525,7 @@ static void vid_reset_mode(void) PicoDrawSetCallbacks(emu_scan_begin, emu_scan_end); if (is_16bit_mode()) - osd_text = (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) ? osd_text16_rot : osd_text16; + osd_text = (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) ? osd_text16_rot : emu_osd_text16; else osd_text = (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) ? osd_text8_rot : osd_text8; @@ -562,7 +545,7 @@ static void vid_reset_mode(void) if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) gp2x_mode = -gp2x_mode; - gp2x_video_changemode(gp2x_mode); + gp2x_video_changemode(gp2x_mode, Pico.m.pal); Pico.m.dirtyPal = 1; @@ -701,47 +684,20 @@ void plat_update_volume(int has_changed, int is_up) void pemu_sound_start(void) { - emu_sound_start(); - - plat_target_step_volume(¤tConfig.volume, 0); - -#if 0 - static int PsndRate_old = 0, PicoOpt_old = 0, pal_old = 0; + gp2x_soc_t soc; - PsndOut = NULL; + emu_sound_start(); - // prepare sound stuff if (currentConfig.EmuOpt & EOPT_EN_SOUND) { - int is_stereo = (PicoOpt & POPT_EN_STEREO) ? 1 : 0; - int snd_rate_oss = PsndRate; - gp2x_soc_t soc; - - memset(sndBuffer, 0, sizeof(sndBuffer)); - PsndOut = sndBuffer; - PicoWriteSound = oss_write_nonblocking; - plat_update_volume(0, 0); - - printf("starting audio: %i len: %i stereo: %i, pal: %i\n", - PsndRate, PsndLen, is_stereo, Pico.m.pal); - sndout_oss_start(snd_rate_oss, is_stereo, 1); - sndout_oss_setvol(currentConfig.volume, currentConfig.volume); - soc = soc_detect(); - if (soc == SOCID_POLLUX) + if (soc == SOCID_POLLUX) { PsndRate = pollux_get_real_snd_rate(PsndRate); - - #define SOUND_RERATE_FLAGS (POPT_EN_FM|POPT_EN_PSG|POPT_EN_STEREO|POPT_EXT_FM|POPT_EN_MCD_CDDA) - if (PsndRate != PsndRate_old || Pico.m.pal != pal_old || ((PicoOpt & POPT_EXT_FM) && crashed_940) || - ((PicoOpt ^ PicoOpt_old) & SOUND_RERATE_FLAGS)) { PsndRerate(Pico.m.frame_count ? 1 : 0); } - PsndRate_old = PsndRate; - PicoOpt_old = PicoOpt; - pal_old = Pico.m.pal; + plat_target_step_volume(¤tConfig.volume, 0); } -#endif } static const int sound_rates[] = { 44100, 32000, 22050, 16000, 11025, 8000 };