mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
Pico fixes
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@446 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
ed367a3f7c
commit
213c16adcb
5 changed files with 71 additions and 31 deletions
|
@ -38,12 +38,12 @@ static u32 PicoReadPico8(u32 a)
|
|||
d = ~d;
|
||||
break;
|
||||
|
||||
case 0x05: d = (PicoPicohw.pen_pos[0] >> 8) & 3; break; // what is MS bit for? Games read it..
|
||||
case 0x05: d = (PicoPicohw.pen_pos[0] >> 8); break; // what is MS bit for? Games read it..
|
||||
case 0x07: d = PicoPicohw.pen_pos[0] & 0xff; break;
|
||||
case 0x09: d = (PicoPicohw.pen_pos[1] >> 8) & 3; break;
|
||||
case 0x09: d = (PicoPicohw.pen_pos[1] >> 8); break;
|
||||
case 0x0b: d = PicoPicohw.pen_pos[1] & 0xff; break;
|
||||
case 0x0d: d = (1 << (PicoPicohw.page & 7)) - 1; break;
|
||||
case 0x12: d = 0x80; break;
|
||||
case 0x12: d = PicoPicohw.fifo_bytes == 0 ? 0x80 : 0; break; // guess
|
||||
default:
|
||||
elprintf(EL_UIO, "r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc);
|
||||
break;
|
||||
|
@ -74,6 +74,8 @@ static u32 PicoReadPico16(u32 a)
|
|||
|
||||
if (a == 0x800010)
|
||||
d = (PicoPicohw.fifo_bytes > 0x3f) ? 0 : (0x3f - PicoPicohw.fifo_bytes);
|
||||
else if (a == 0x800012)
|
||||
d = PicoPicohw.fifo_bytes == 0 ? 0x8000 : 0; // guess
|
||||
|
||||
elprintf(EL_UIO, "r16: %06x, %04x @%06x", a&0xffffff, d, SekPc);
|
||||
|
||||
|
@ -156,7 +158,12 @@ static void PicoWritePico16(u32 a,u16 d)
|
|||
PicoPicohw.xpcm_ptr++;
|
||||
}
|
||||
}
|
||||
else if (a == 0x800012) PicoPicohw.r12 = d;
|
||||
else if (a == 0x800012) {
|
||||
int r12_old = PicoPicohw.r12;
|
||||
PicoPicohw.r12 = d;
|
||||
if (r12_old != d)
|
||||
PicoReratePico();
|
||||
}
|
||||
|
||||
elprintf(EL_UIO, "w16: %06x, %04x", a&0xffffff, d);
|
||||
}
|
||||
|
|
|
@ -6,14 +6,15 @@
|
|||
picohw_state PicoPicohw;
|
||||
|
||||
static int prev_line_cnt_irq3 = 0, prev_line_cnt_irq5 = 0;
|
||||
static int fifo_bytes_line = (16000<<16)/60/262/2; // fifo bytes/line. FIXME: other rates, modes
|
||||
static int fifo_bytes_line = (16000<<16)/60/262/2;
|
||||
|
||||
PICO_INTERNAL void PicoReratePico(void)
|
||||
{
|
||||
int rate = (PicoPicohw.r12 & 0xf) ? 16000 : 8000;
|
||||
if (Pico.m.pal)
|
||||
fifo_bytes_line = (16000<<16)/50/312/2;
|
||||
else fifo_bytes_line = (16000<<16)/60/262/2;
|
||||
PicoPicoPCMRerate();
|
||||
fifo_bytes_line = (rate<<16)/50/312/2;
|
||||
else fifo_bytes_line = (rate<<16)/60/262/2;
|
||||
PicoPicoPCMRerate(rate);
|
||||
}
|
||||
|
||||
static void PicoLinePico(int count)
|
||||
|
@ -74,8 +75,8 @@ PICO_INTERNAL int PicoInitPico(void)
|
|||
|
||||
PicoAHW = PAHW_PICO;
|
||||
memset(&PicoPicohw, 0, sizeof(PicoPicohw));
|
||||
PicoPicohw.pen_pos[0] = 0x03c + 352/2;
|
||||
PicoPicohw.pen_pos[1] = 0x200 + 252/2;
|
||||
PicoPicohw.pen_pos[0] = 0x03c + 320/2;
|
||||
PicoPicohw.pen_pos[1] = 0x200 + 240/2;
|
||||
prev_line_cnt_irq3 = prev_line_cnt_irq5 = 0;
|
||||
|
||||
// map version register
|
||||
|
|
|
@ -28,7 +28,7 @@ static const int TableQuant[8] =
|
|||
};
|
||||
|
||||
// changed using trial and error..
|
||||
//const int quant_mul[16] = { 1, 3, 5, 7, 9, 11, 13, 15, -1, -3, -5, -7, -9, -11, -13, -15 };
|
||||
//static const int quant_mul[16] = { 1, 3, 5, 7, 9, 11, 13, 15, -1, -3, -5, -7, -9, -11, -13, -15 };
|
||||
static const int quant_mul[16] = { 1, 3, 5, 7, 9, 11, 13, -1, -1, -3, -5, -7, -9, -11, -13, -15 };
|
||||
|
||||
static int sample = 0, quant = 0, sgn = 0;
|
||||
|
@ -42,19 +42,20 @@ PICO_INTERNAL void PicoPicoPCMReset(void)
|
|||
memset(PicoPicohw.xpcm_buffer, 0, sizeof(PicoPicohw.xpcm_buffer));
|
||||
}
|
||||
|
||||
PICO_INTERNAL void PicoPicoPCMRerate(void)
|
||||
PICO_INTERNAL void PicoPicoPCMRerate(int xpcm_rate)
|
||||
{
|
||||
stepsamples = (PsndRate<<10)/16000;
|
||||
stepsamples = (PsndRate<<10)/xpcm_rate;
|
||||
}
|
||||
|
||||
#define XSHIFT 7
|
||||
#define XSHIFT 6
|
||||
|
||||
#define do_sample() \
|
||||
{ \
|
||||
sample += quant * quant_mul[srcval] >> XSHIFT; \
|
||||
int delta = quant * quant_mul[srcval] >> XSHIFT; \
|
||||
sample += delta - (delta >> 2); /* 3/4 */ \
|
||||
quant = (quant * TableQuant[srcval&7]) >> ADPCMSHIFT; \
|
||||
Limit(quant, 0x6000, 0x7f); \
|
||||
Limit(sample, 32767/2, -32768/2); \
|
||||
Limit(sample, 32767*3/4, -32768*3/4); \
|
||||
}
|
||||
|
||||
PICO_INTERNAL void PicoPicoPCMUpdate(short *buffer, int length, int stereo)
|
||||
|
|
|
@ -448,7 +448,7 @@ PICO_INTERNAL void PicoReratePico(void);
|
|||
// Pico/xpcm.c
|
||||
PICO_INTERNAL void PicoPicoPCMUpdate(short *buffer, int length, int stereo);
|
||||
PICO_INTERNAL void PicoPicoPCMReset(void);
|
||||
PICO_INTERNAL void PicoPicoPCMRerate(void);
|
||||
PICO_INTERNAL void PicoPicoPCMRerate(int xpcm_rate);
|
||||
|
||||
// Sek.c
|
||||
PICO_INTERNAL int SekInit(void);
|
||||
|
|
|
@ -53,7 +53,9 @@ char noticeMsg[64]; // notice msg to draw
|
|||
unsigned char *PicoDraw2FB = NULL; // temporary buffer for alt renderer
|
||||
int reset_timing = 0;
|
||||
|
||||
static int pico_pen_x = 0, pico_pen_y = 0, pico_inp_mode = 0;
|
||||
#define PICO_PEN_ADJUST_X 4
|
||||
#define PICO_PEN_ADJUST_Y 2
|
||||
static int pico_pen_x = 320/2, pico_pen_y = 240/2, pico_inp_mode = 0;
|
||||
|
||||
static void emu_msg_cb(const char *msg);
|
||||
static void emu_msg_tray_open(void);
|
||||
|
@ -199,7 +201,7 @@ void osd_text(int x, int y, const char *text)
|
|||
}
|
||||
}
|
||||
|
||||
static void cd_leds(void)
|
||||
static void draw_cd_leds(void)
|
||||
{
|
||||
// static
|
||||
int old_reg;
|
||||
|
@ -227,6 +229,25 @@ static void cd_leds(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void draw_pico_ptr(void)
|
||||
{
|
||||
unsigned short *p = (unsigned short *)gp2x_screen;
|
||||
|
||||
// only if pen enabled and for 16bit modes
|
||||
if (pico_inp_mode == 0 || (PicoOpt&0x10) || !(currentConfig.EmuOpt&0x80)) return;
|
||||
|
||||
if (!(Pico.video.reg[12]&1) && !(PicoOpt&POPT_DIS_32C_BORDER))
|
||||
p += 32;
|
||||
|
||||
p += 320 * (pico_pen_y + PICO_PEN_ADJUST_Y);
|
||||
p += pico_pen_x + PICO_PEN_ADJUST_X;
|
||||
p[0] ^= 0xffff;
|
||||
p[319] ^= 0xffff;
|
||||
p[320] ^= 0xffff;
|
||||
p[321] ^= 0xffff;
|
||||
p[640] ^= 0xffff;
|
||||
}
|
||||
|
||||
static int EmuScanBegin16(unsigned int num)
|
||||
{
|
||||
if (!(Pico.video.reg[1]&8)) num += 8;
|
||||
|
@ -301,7 +322,9 @@ static void blit(const char *fps, const char *notice)
|
|||
osd_text(osd_fps_x, h, fps);
|
||||
}
|
||||
if ((emu_opt & 0x400) && (PicoAHW & PAHW_MCD))
|
||||
cd_leds();
|
||||
draw_cd_leds();
|
||||
if (PicoAHW & PAHW_PICO)
|
||||
draw_pico_ptr();
|
||||
|
||||
//gp2x_video_wait_vsync();
|
||||
gp2x_video_flip();
|
||||
|
@ -404,9 +427,11 @@ static void RunEventsPico(unsigned int events, unsigned int gp2x_keys)
|
|||
pico_inp_mode++;
|
||||
if (pico_inp_mode > 2) pico_inp_mode = 0;
|
||||
switch (pico_inp_mode) {
|
||||
case 0: strcpy(noticeMsg, "Input: Joytick "); break;
|
||||
case 1: strcpy(noticeMsg, "Input: Pen on Storyware"); break;
|
||||
case 2: strcpy(noticeMsg, "Input: Pen on Pad "); break;
|
||||
case 1: strcpy(noticeMsg, "Input: Pen on Storyware"); break;
|
||||
case 0: strcpy(noticeMsg, "Input: Joytick ");
|
||||
PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000;
|
||||
break;
|
||||
}
|
||||
gettimeofday(¬iceMsgTime, 0);
|
||||
}
|
||||
|
@ -425,10 +450,17 @@ static void RunEventsPico(unsigned int events, unsigned int gp2x_keys)
|
|||
if (pico_inp_mode != 0) {
|
||||
PicoPad[0] &= ~0x0f; // release UDLR
|
||||
if (gp2x_keys & GP2X_UP) { pico_pen_y--; if (pico_pen_y < 0) pico_pen_y = 0; }
|
||||
if (gp2x_keys & GP2X_DOWN) { pico_pen_y++; if (pico_pen_y > 251) pico_pen_y = 251; }
|
||||
if (gp2x_keys & GP2X_DOWN) { pico_pen_y++; if (pico_pen_y > 239-PICO_PEN_ADJUST_Y) pico_pen_y = 239-PICO_PEN_ADJUST_Y; }
|
||||
if (gp2x_keys & GP2X_LEFT) { pico_pen_x--; if (pico_pen_x < 0) pico_pen_x = 0; }
|
||||
if (gp2x_keys & GP2X_RIGHT){ pico_pen_x++; if (pico_pen_x > 353) pico_pen_x = 353; }
|
||||
PicoPicohw.pen_pos[0] = 0x03c + pico_pen_x;
|
||||
if (gp2x_keys & GP2X_RIGHT) {
|
||||
int lim = (Pico.video.reg[12]&1) ? 319 : 255;
|
||||
pico_pen_x++;
|
||||
if (pico_pen_x > lim-PICO_PEN_ADJUST_X)
|
||||
pico_pen_x = lim-PICO_PEN_ADJUST_X;
|
||||
}
|
||||
PicoPicohw.pen_pos[0] = pico_pen_x;
|
||||
if (!(Pico.video.reg[12]&1)) PicoPicohw.pen_pos[0] += pico_pen_x/4;
|
||||
PicoPicohw.pen_pos[0] += 0x3c;
|
||||
PicoPicohw.pen_pos[1] = pico_inp_mode == 1 ? (0x2f8 + pico_pen_y) : (0x1fc + pico_pen_y);
|
||||
}
|
||||
}
|
||||
|
@ -554,7 +586,6 @@ static void RunEvents(unsigned int which)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static void updateKeys(void)
|
||||
{
|
||||
unsigned int keys, keys2, allActions[2] = { 0, 0 }, events;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue