mirror of
https://github.com/RaySollium99/libpicofe.git
synced 2025-09-05 06:47:45 -04:00
linux port fixed; some cleanups
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@706 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
fa8d133192
commit
046c454067
18 changed files with 146 additions and 466 deletions
|
@ -1,213 +0,0 @@
|
|||
/* faked 940 code just uses local copy of ym2612 */
|
||||
/* TODO: rm this */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "../../pico/sound/ym2612.h"
|
||||
//#include "../gp2x/gp2x.h"
|
||||
#include "../gp2x/emu.h"
|
||||
#include "../gp2x/code940/940shared.h"
|
||||
#include "../common/helix/pub/mp3dec.h"
|
||||
#include "../../pico/pico_int.h"
|
||||
|
||||
|
||||
// static _940_data_t shared_data_;
|
||||
static _940_ctl_t shared_ctl_;
|
||||
// static _940_data_t *shared_data = &shared_data_;
|
||||
_940_ctl_t *shared_ctl = &shared_ctl_;
|
||||
|
||||
unsigned char *mp3_mem = 0;
|
||||
|
||||
#define MP3_SIZE_MAX (0x1000000 - 4*640*480)
|
||||
|
||||
/***********************************************************/
|
||||
|
||||
|
||||
int YM2612Write_940(unsigned int a, unsigned int v, int scanline)
|
||||
{
|
||||
YM2612Write_(a, v);
|
||||
|
||||
return 0; // cause the engine to do updates once per frame only
|
||||
}
|
||||
|
||||
|
||||
void YM2612PicoStateLoad_940(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
YM2612PicoStateLoad_();
|
||||
|
||||
for(i = 0; i < 0x100; i++) {
|
||||
YM2612Write_(0, i);
|
||||
YM2612Write_(1, ym2612.REGS[i]);
|
||||
}
|
||||
for(i = 0; i < 0x100; i++) {
|
||||
YM2612Write_(2, i);
|
||||
YM2612Write_(3, ym2612.REGS[i|0x100]);
|
||||
}
|
||||
}
|
||||
|
||||
void YM2612PicoStateSave2_940(int tat, int tbt)
|
||||
{
|
||||
YM2612PicoStateSave2(tat, tbt);
|
||||
}
|
||||
|
||||
int YM2612PicoStateLoad2_940(int *tat, int *tbt)
|
||||
{
|
||||
return YM2612PicoStateLoad2(tat, tbt);
|
||||
}
|
||||
|
||||
|
||||
void sharedmem_init(void)
|
||||
{
|
||||
mp3_mem = malloc(MP3_SIZE_MAX);
|
||||
}
|
||||
|
||||
void sharedmem_deinit(void)
|
||||
{
|
||||
free(mp3_mem);
|
||||
}
|
||||
|
||||
void YM2612Init_940(int baseclock, int rate)
|
||||
{
|
||||
YM2612Init_(baseclock, rate);
|
||||
}
|
||||
|
||||
|
||||
void YM2612ResetChip_940(void)
|
||||
{
|
||||
YM2612ResetChip_();
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
static void local_decode(void)
|
||||
{
|
||||
int mp3_offs = shared_ctl->mp3_offs;
|
||||
unsigned char *readPtr = mp3_mem + mp3_offs;
|
||||
int bytesLeft = shared_ctl->mp3_len - mp3_offs;
|
||||
int offset; // frame offset from readPtr
|
||||
int err = 0;
|
||||
|
||||
if (bytesLeft <= 0) return; // EOF, nothing to do
|
||||
|
||||
offset = MP3FindSyncWord(readPtr, bytesLeft);
|
||||
if (offset < 0) {
|
||||
shared_ctl->mp3_offs = shared_ctl->mp3_len;
|
||||
return; // EOF
|
||||
}
|
||||
readPtr += offset;
|
||||
bytesLeft -= offset;
|
||||
|
||||
err = MP3Decode(shared_data->mp3dec, &readPtr, &bytesLeft,
|
||||
shared_data->mp3_buffer[shared_ctl->mp3_buffsel], 0);
|
||||
if (err) {
|
||||
if (err == ERR_MP3_INDATA_UNDERFLOW) {
|
||||
shared_ctl->mp3_offs = shared_ctl->mp3_len; // EOF
|
||||
return;
|
||||
} else if (err <= -6 && err >= -12) {
|
||||
// ERR_MP3_INVALID_FRAMEHEADER, ERR_MP3_INVALID_*
|
||||
// just try to skip the offending frame..
|
||||
readPtr++;
|
||||
}
|
||||
shared_ctl->mp3_errors++;
|
||||
shared_ctl->mp3_lasterr = err;
|
||||
}
|
||||
shared_ctl->mp3_offs = readPtr - mp3_mem;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
static FILE *loaded_mp3 = 0;
|
||||
|
||||
int YM2612UpdateOne_940(int *buffer, int length, int stereo, int is_buf_empty)
|
||||
{
|
||||
#if 0
|
||||
int cdda_on, *ym_buffer = mix_buffer;
|
||||
static int mp3_samples_ready = 0, mp3_buffer_offs = 0;
|
||||
static int mp3_play_bufsel = 1;
|
||||
|
||||
|
||||
YM2612UpdateOne_(buffer, length, stereo); // really writes to mix_buffer
|
||||
|
||||
// emulatind MCD, not data track, CDC is reading, playback was started, track not ended
|
||||
cdda_on = (PicoMCD & 1) && !(Pico_mcd->s68k_regs[0x36] & 1) && (Pico_mcd->scd.Status_CDC & 1)
|
||||
&& loaded_mp3 && shared_ctl->mp3_offs < shared_ctl->mp3_len;
|
||||
|
||||
/* mix data from previous go */
|
||||
if (cdda_on && mp3_samples_ready >= length)
|
||||
{
|
||||
if (1152 - mp3_buffer_offs >= length) {
|
||||
mix_samples(buffer, ym_buffer, shared_data->mp3_buffer[mp3_play_bufsel] + mp3_buffer_offs*2, length, stereo);
|
||||
|
||||
mp3_buffer_offs += length;
|
||||
} else {
|
||||
// collect from both buffers..
|
||||
int left = 1152 - mp3_buffer_offs;
|
||||
mix_samples(buffer, ym_buffer, shared_data->mp3_buffer[mp3_play_bufsel] + mp3_buffer_offs*2, left, stereo);
|
||||
mp3_play_bufsel ^= 1;
|
||||
mp3_buffer_offs = length - left;
|
||||
mix_samples(buffer + left * 2, ym_buffer + left * 2,
|
||||
shared_data->mp3_buffer[mp3_play_bufsel], mp3_buffer_offs, stereo);
|
||||
}
|
||||
mp3_samples_ready -= length;
|
||||
} else {
|
||||
mix_samples(buffer, ym_buffer, 0, length, stereo);
|
||||
}
|
||||
|
||||
// make sure we will have enough mp3 samples next frame
|
||||
if (cdda_on && mp3_samples_ready < length)
|
||||
{
|
||||
shared_ctl->mp3_buffsel ^= 1;
|
||||
local_decode();
|
||||
mp3_samples_ready += 1152;
|
||||
}
|
||||
#else
|
||||
return YM2612UpdateOne_(buffer, length, stereo, is_buf_empty);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void mp3_update(int *buffer, int length, int stereo)
|
||||
{
|
||||
// nothing..
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************/
|
||||
|
||||
void mp3_start_play(FILE *f, int pos) // pos is 0-1023
|
||||
{
|
||||
int byte_offs = 0;
|
||||
|
||||
if (loaded_mp3 != f)
|
||||
{
|
||||
printf("loading mp3... "); fflush(stdout);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
fread(mp3_mem, 1, MP3_SIZE_MAX, f);
|
||||
if (feof(f)) printf("done.\n");
|
||||
else printf("done. mp3 too large, not all data loaded.\n");
|
||||
shared_ctl->mp3_len = ftell(f);
|
||||
loaded_mp3 = f;
|
||||
}
|
||||
|
||||
// seek..
|
||||
if (pos) {
|
||||
byte_offs = (shared_ctl->mp3_len << 6) >> 10;
|
||||
byte_offs *= pos;
|
||||
byte_offs >>= 6;
|
||||
}
|
||||
printf("mp3 pos1024: %i, byte_offs %i/%i\n", pos, byte_offs, shared_ctl->mp3_len);
|
||||
|
||||
shared_ctl->mp3_offs = byte_offs;
|
||||
}
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ CFLAGS += -fprofile-generate
|
|||
else
|
||||
CFLAGS = -ggdb -Wall
|
||||
endif
|
||||
DEFINES = __GP2X__ _UNZIP_SUPPORT IO_STATS IN_EVDEV
|
||||
DEFINES = _UNZIP_SUPPORT IO_STATS IN_EVDEV
|
||||
CFLAGS += -I../.. -I.
|
||||
|
||||
# gtk
|
||||
|
@ -24,12 +24,12 @@ CFLAGS += `pkg-config --cflags gthread-2.0`
|
|||
LDFLAGS += `pkg-config --libs gthread-2.0`
|
||||
|
||||
# frontend
|
||||
OBJS += platform/gp2x/main.o platform/gp2x/emu.o platform/gp2x/plat.o blit.o \
|
||||
in_evdev.o plat.o sndout_oss.o gp2x.o 940ctl_ym2612.o log_io.o
|
||||
OBJS += platform/gp2x/emu.o blit.o in_evdev.o plat.o sndout_oss.o gp2x.o log_io.o
|
||||
|
||||
# common
|
||||
OBJS += platform/common/emu.o platform/common/menu.o platform/common/config.o platform/common/fonts.o \
|
||||
platform/common/readpng.o platform/common/input.o platform/common/mp3_helix.o
|
||||
OBJS += platform/common/main.o platform/common/emu.o platform/common/menu.o \
|
||||
platform/common/config.o platform/common/fonts.o platform/common/readpng.o \
|
||||
platform/common/input.o
|
||||
|
||||
ifeq "$(fake_in_gp2x)" "1"
|
||||
DEFINES += IN_GP2X FAKE_IN_GP2X
|
||||
|
@ -38,18 +38,18 @@ endif
|
|||
|
||||
# Pico
|
||||
OBJS += pico/area.o pico/cart.o pico/memory.o pico/misc.o pico/pico.o pico/sek.o \
|
||||
pico/videoport.o pico/draw2.o pico/draw.o pico/patch.o pico/debug.o
|
||||
pico/videoport.o pico/draw2.o pico/draw.o pico/patch.o pico/debug.o
|
||||
# Pico - CD
|
||||
OBJS += pico/cd/pico.o pico/cd/memory.o pico/cd/sek.o pico/cd/LC89510.o \
|
||||
pico/cd/cd_sys.o pico/cd/cd_file.o pico/cd/cue.o pico/cd/gfx_cd.o \
|
||||
pico/cd/area.o pico/cd/misc.o pico/cd/pcm.o pico/cd/buffering.o
|
||||
pico/cd/cd_sys.o pico/cd/cd_file.o pico/cd/cue.o pico/cd/gfx_cd.o \
|
||||
pico/cd/area.o pico/cd/misc.o pico/cd/pcm.o pico/cd/buffering.o
|
||||
# Pico - Pico
|
||||
OBJS += pico/pico/pico.o pico/pico/memory.o pico/pico/xpcm.o
|
||||
# Pico - sound
|
||||
OBJS += pico/sound/sound.o pico/sound/sn76496.o pico/sound/ym2612.o pico/sound/mix.o
|
||||
# Pico - carthw
|
||||
OBJS += pico/carthw/carthw.o pico/carthw/svp/svp.o pico/carthw/svp/memory.o \
|
||||
pico/carthw/svp/ssp16.o pico/carthw/svp/compiler.o
|
||||
pico/carthw/svp/ssp16.o pico/carthw/svp/compiler.o
|
||||
# zlib
|
||||
OBJS += zlib/gzio.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o \
|
||||
zlib/deflate.o zlib/crc32.o zlib/adler32.o zlib/zutil.o zlib/compress.o zlib/uncompr.o
|
||||
|
|
181
linux/gp2x.c
181
linux/gp2x.c
|
@ -12,10 +12,10 @@
|
|||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "../gp2x/emu.h"
|
||||
//#include "../gp2x/gp2x.h"
|
||||
#include "../gp2x/version.h"
|
||||
#include "../common/emu.h"
|
||||
#include "../common/menu.h"
|
||||
#include "../common/readpng.h"
|
||||
#include "sndout_oss.h"
|
||||
|
||||
#include "log_io.h"
|
||||
|
@ -28,6 +28,8 @@ static int scr_changed = 0, scr_w = SCREEN_WIDTH, scr_h = SCREEN_HEIGHT;
|
|||
|
||||
// dummies
|
||||
int mix_32_to_16l_level;
|
||||
int crashed_940 = 0;
|
||||
int default_cpu_clock = 123;
|
||||
|
||||
/* gtk */
|
||||
struct gtk_global_struct
|
||||
|
@ -210,29 +212,8 @@ static void realloc_screen(void)
|
|||
scr_changed = 0;
|
||||
}
|
||||
|
||||
void plat_init(void)
|
||||
{
|
||||
printf("entering init()\n"); fflush(stdout);
|
||||
|
||||
realloc_screen();
|
||||
memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2);
|
||||
|
||||
// snd
|
||||
sndout_oss_init();
|
||||
|
||||
gtk_initf();
|
||||
|
||||
printf("exitting init()\n"); fflush(stdout);
|
||||
}
|
||||
|
||||
void plat_finish(void)
|
||||
{
|
||||
free(g_screen_ptr);
|
||||
sndout_oss_exit();
|
||||
}
|
||||
|
||||
/* video */
|
||||
void gp2x_video_flip(void)
|
||||
/* gp2x/emu.c stuff, most to be rm'd */
|
||||
static void gp2x_video_flip_(void)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
unsigned char *image;
|
||||
|
@ -288,27 +269,17 @@ void gp2x_video_flip(void)
|
|||
realloc_screen();
|
||||
}
|
||||
|
||||
void gp2x_video_flip2(void)
|
||||
{
|
||||
gp2x_video_flip();
|
||||
}
|
||||
|
||||
void gp2x_video_changemode(int bpp)
|
||||
static void gp2x_video_changemode_ll_(int bpp)
|
||||
{
|
||||
current_bpp = bpp;
|
||||
}
|
||||
|
||||
void gp2x_video_changemode2(int bpp)
|
||||
{
|
||||
current_bpp = bpp;
|
||||
}
|
||||
|
||||
void gp2x_video_setpalette(int *pal, int len)
|
||||
static void gp2x_video_setpalette_(int *pal, int len)
|
||||
{
|
||||
memcpy(current_pal, pal, len*4);
|
||||
}
|
||||
|
||||
void gp2x_video_RGB_setscaling(int v_offs, int W, int H)
|
||||
void gp2x_memcpy_all_buffers(void *data, int offset, int len)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -317,44 +288,126 @@ void gp2x_memset_all_buffers(int offset, int byte, int len)
|
|||
memset((char *)g_screen_ptr + offset, byte, len);
|
||||
}
|
||||
|
||||
void gp2x_video_changemode(int bpp)
|
||||
{
|
||||
gp2x_video_changemode_ll_(bpp);
|
||||
}
|
||||
|
||||
void gp2x_make_fb_bufferable(int yes)
|
||||
{
|
||||
}
|
||||
|
||||
int soc_detect(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* plat */
|
||||
static char menu_bg_buffer[320*240*2];
|
||||
char cpu_clk_name[16] = "GP2X CPU clocks";
|
||||
|
||||
void plat_video_menu_enter(int is_rom_loaded)
|
||||
{
|
||||
if (is_rom_loaded)
|
||||
{
|
||||
// darken the active framebuffer
|
||||
memset(g_screen_ptr, 0, 320*8*2);
|
||||
menu_darken_bg((char *)g_screen_ptr + 320*8*2, 320*224, 1);
|
||||
memset((char *)g_screen_ptr + 320*232*2, 0, 320*8*2);
|
||||
}
|
||||
else
|
||||
{
|
||||
// should really only happen once, on startup..
|
||||
readpng(g_screen_ptr, "skin/background.png", READPNG_BG);
|
||||
}
|
||||
|
||||
memcpy(menu_bg_buffer, g_screen_ptr, 320*240*2);
|
||||
|
||||
// switch to 16bpp
|
||||
gp2x_video_changemode_ll_(16);
|
||||
gp2x_video_flip_();
|
||||
}
|
||||
|
||||
void plat_video_menu_begin(void)
|
||||
{
|
||||
memcpy(g_screen_ptr, menu_bg_buffer, 320*240*2);
|
||||
}
|
||||
|
||||
void plat_video_menu_end(void)
|
||||
{
|
||||
gp2x_video_flip_();
|
||||
}
|
||||
|
||||
void plat_validate_config(void)
|
||||
{
|
||||
// PicoOpt &= ~POPT_EXT_FM;
|
||||
}
|
||||
|
||||
void plat_early_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
void plat_init(void)
|
||||
{
|
||||
realloc_screen();
|
||||
memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2);
|
||||
|
||||
// snd
|
||||
sndout_oss_init();
|
||||
|
||||
gtk_initf();
|
||||
}
|
||||
|
||||
void plat_finish(void)
|
||||
{
|
||||
free(g_screen_ptr);
|
||||
sndout_oss_exit();
|
||||
}
|
||||
|
||||
/* nasty */
|
||||
static void do_nothing()
|
||||
{
|
||||
}
|
||||
|
||||
void *gp2x_video_flip = gp2x_video_flip_;
|
||||
void *gp2x_video_flip2 = gp2x_video_flip_;
|
||||
void *gp2x_video_changemode_ll = gp2x_video_changemode_ll_;
|
||||
void *gp2x_video_setpalette = gp2x_video_setpalette_;
|
||||
|
||||
void *gp2x_video_RGB_setscaling = do_nothing;
|
||||
void *gp2x_video_wait_vsync = do_nothing;
|
||||
void *gp2x_set_cpuclk = do_nothing;
|
||||
void *set_lcd_custom_rate = do_nothing;
|
||||
void *unset_lcd_custom_rate = do_nothing;
|
||||
void *set_lcd_gamma = do_nothing;
|
||||
void *set_ram_timings = do_nothing;
|
||||
void *unset_ram_timings = do_nothing;
|
||||
|
||||
/* joy */
|
||||
int gp2x_touchpad_read(int *x, int *y)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* 940 */
|
||||
int crashed_940 = 0;
|
||||
void pause940(int yes)
|
||||
{
|
||||
}
|
||||
|
||||
void reset940(int yes, int bank)
|
||||
{
|
||||
}
|
||||
|
||||
void gp2x_video_wait_vsync(void)
|
||||
{
|
||||
}
|
||||
|
||||
void set_gamma(int g100, int A_SNs_curve)
|
||||
{
|
||||
}
|
||||
|
||||
void set_lcd_custom_rate(int rate)
|
||||
{
|
||||
}
|
||||
|
||||
void unset_lcd_custom_rate(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* misc */
|
||||
void spend_cycles(int c)
|
||||
{
|
||||
usleep(c/200);
|
||||
}
|
||||
|
||||
int mp3_get_bitrate(FILE *f, int size)
|
||||
{
|
||||
return 128;
|
||||
}
|
||||
|
||||
void mp3_start_play(FILE *f, int pos)
|
||||
{
|
||||
}
|
||||
|
||||
void mp3_update(int *buffer, int length, int stereo)
|
||||
{
|
||||
}
|
||||
|
||||
/* lprintf */
|
||||
void lprintf(const char *fmt, ...)
|
||||
{
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
#ifndef PORT_CONFIG_H
|
||||
#define PORT_CONFIG_H
|
||||
|
||||
#include "../gp2x/version.h" /* FIXME */
|
||||
|
||||
#define NO_SYNC
|
||||
|
||||
#define CASE_SENSITIVE_FS 1 // CS filesystem
|
||||
|
|
2
linux/version.h
Normal file
2
linux/version.h
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include "../gp2x/version.h"
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue