mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
some Pico work
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@442 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
406c96c547
commit
d49b10c2f2
5 changed files with 75 additions and 28 deletions
11
Pico/Pico.h
11
Pico/Pico.h
|
@ -71,8 +71,15 @@ extern int (*PicoMCDcloseTray)(void);
|
|||
extern int PicoCDBuffers;
|
||||
|
||||
// Pico/Pico.c
|
||||
extern int PicoPicoPenPos[2]; // x: 0x03c-0x17d, y: 0x200-0x2d8
|
||||
extern int PicoPicoPage;
|
||||
typedef struct
|
||||
{
|
||||
int pen_pos[2];
|
||||
int page;
|
||||
// internal
|
||||
int fifo_bytes;
|
||||
int line_counter;
|
||||
} picohw_state;
|
||||
extern picohw_state PicoPicohw;
|
||||
|
||||
// Area.c
|
||||
typedef size_t (arearw)(void *p, size_t _size, size_t _n, void *file);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "../PicoInt.h"
|
||||
#include "../sound/sn76496.h"
|
||||
|
||||
#ifndef UTYPES_DEFINED
|
||||
typedef unsigned char u8;
|
||||
|
@ -7,6 +8,7 @@ typedef unsigned int u32;
|
|||
#define UTYPES_DEFINED
|
||||
#endif
|
||||
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// Read Rom and read Ram
|
||||
|
||||
|
@ -19,7 +21,7 @@ static u32 PicoReadPico8(u32 a)
|
|||
|
||||
a&=0xffffff;
|
||||
|
||||
if ((a&0xffffe0)==0xc00000) { // VDP
|
||||
if ((a&0xfffff0)==0xc00000) { // VDP
|
||||
d=PicoVideoRead(a);
|
||||
if ((a&1)==0) d>>=8;
|
||||
goto end;
|
||||
|
@ -30,17 +32,16 @@ static u32 PicoReadPico8(u32 a)
|
|||
switch (a & 0x1f)
|
||||
{
|
||||
case 0x03:
|
||||
d = PicoPad[0]&0x0f; // d-pad
|
||||
d |= (PicoPad[0]&0x20) >> 1; // red button -> C
|
||||
d |= (PicoPad[0]&0x40) << 1; // pen tap -> A
|
||||
d = PicoPad[0]&0x1f; // d-pad
|
||||
d |= (PicoPad[0]&0x20) << 2; // red button -> C
|
||||
d = ~d;
|
||||
break;
|
||||
|
||||
case 0x05: d = (PicoPicoPenPos[0] >> 8) & 3; break; // what is MS bit for? Games read it..
|
||||
case 0x07: d = PicoPicoPenPos[0] & 0xff; break;
|
||||
case 0x09: d = (PicoPicoPenPos[1] >> 8) & 3; break;
|
||||
case 0x0b: d = PicoPicoPenPos[1] & 0xff; break;
|
||||
case 0x0d: d = (1 << (PicoPicoPage & 7)) - 1;break;
|
||||
case 0x05: d = (PicoPicohw.pen_pos[0] >> 8) & 3; 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 0x0b: d = PicoPicohw.pen_pos[1] & 0xff; break;
|
||||
case 0x0d: d = (1 << (PicoPicohw.page & 7)) - 1; break;
|
||||
case 0x12: d = 0x80; break;
|
||||
default:
|
||||
elprintf(EL_UIO, "r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc);
|
||||
|
@ -65,12 +66,13 @@ static u32 PicoReadPico16(u32 a)
|
|||
|
||||
if (a<Pico.romsize) { d = *(u16 *)(Pico.rom+a); goto end; } // Rom
|
||||
|
||||
if ((a&0xffffe0)==0xc00000) {
|
||||
if ((a&0xfffff0)==0xc00000) {
|
||||
d = PicoVideoRead(a);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (a == 0x800010) d = 0x0f;
|
||||
if (a == 0x800010)
|
||||
d = (PicoPicohw.fifo_bytes > 0x3f) ? 0 : (0x3f - PicoPicohw.fifo_bytes);
|
||||
|
||||
elprintf(EL_UIO, "r16: %06x, %04x @%06x", a&0xffffff, d, SekPc);
|
||||
|
||||
|
@ -89,7 +91,7 @@ static u32 PicoReadPico32(u32 a)
|
|||
|
||||
if (a<Pico.romsize) { u16 *pm=(u16 *)(Pico.rom+a); d = (pm[0]<<16)|pm[1]; goto end; } // Rom
|
||||
|
||||
if ((a&0xffffe0)==0xc00000) {
|
||||
if ((a&0xfffff0)==0xc00000) {
|
||||
d = (PicoVideoRead(a)<<16)|PicoVideoRead(a+2);
|
||||
goto end;
|
||||
}
|
||||
|
@ -119,7 +121,9 @@ static void PicoWritePico8(u32 a,u8 d)
|
|||
if ((a&0xe00000)==0xe00000) { *(u8 *)(Pico.ram+((a^1)&0xffff))=d; return; } // Ram
|
||||
|
||||
a&=0xffffff;
|
||||
if ((a&0xffffe0)==0xc00000) { // VDP
|
||||
if ((a&0xfffff9)==0xc00011) { if (PicoOpt&2) SN76496Write(d); return; } // PSG Sound
|
||||
|
||||
if ((a&0xfffff0)==0xc00000) { // VDP
|
||||
d&=0xff;
|
||||
PicoVideoWrite(a,(u16)(d|(d<<8))); // Byte access gets mirrored
|
||||
return;
|
||||
|
@ -135,9 +139,10 @@ static void PicoWritePico16(u32 a,u16 d)
|
|||
if ((a&0xe00000)==0xe00000) { *(u16 *)(Pico.ram+(a&0xfffe))=d; return; } // Ram
|
||||
|
||||
a&=0xfffffe;
|
||||
if ((a&0xffffe0)==0xc00000) { PicoVideoWrite(a,(u16)d); return; } // VDP
|
||||
if ((a&0xfffff0)==0xc00000) { PicoVideoWrite(a,(u16)d); return; } // VDP
|
||||
|
||||
// if (a == 0x800010) dump(d);
|
||||
if (a == 0x800010) PicoPicohw.fifo_bytes += 2;
|
||||
|
||||
elprintf(EL_UIO, "w16: %06x, %04x", a&0xffffff, d);
|
||||
}
|
||||
|
@ -155,7 +160,7 @@ static void PicoWritePico32(u32 a,u32 d)
|
|||
}
|
||||
|
||||
a&=0xfffffe;
|
||||
if ((a&0xffffe0)==0xc00000)
|
||||
if ((a&0xfffff0)==0xc00000)
|
||||
{
|
||||
// VDP:
|
||||
PicoVideoWrite(a, (u16)(d>>16));
|
||||
|
|
|
@ -3,14 +3,48 @@
|
|||
// x: 0x03c - 0x19d
|
||||
// y: 0x1fc - 0x2f7
|
||||
// 0x2f8 - 0x3f3
|
||||
int PicoPicoPenPos[2] = { 0x3c, 0x200 };
|
||||
int PicoPicoPage = 0; // 0-6
|
||||
picohw_state PicoPicohw;
|
||||
|
||||
static int prev_line_cnt_irq3 = 0, prev_line_cnt_irq5 = 0;
|
||||
|
||||
static void PicoLineHookPico(int count)
|
||||
{
|
||||
|
||||
PicoPicohw.line_counter += count;
|
||||
if ((PicoPicohw.line_counter & 0xf) == 0 || count > 10)
|
||||
{
|
||||
if (PicoPicohw.fifo_bytes > 0)
|
||||
PicoPicohw.fifo_bytes--;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (PicoPicohw.line_counter - prev_line_cnt_irq3 > 200) {
|
||||
prev_line_cnt_irq3 = PicoPicohw.line_counter;
|
||||
// just a guess/hack, allows 101 Dalmantians to boot
|
||||
elprintf(EL_ANOMALY, "irq3");
|
||||
SekInterrupt(3);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
if (PicoPicohw.line_counter - prev_line_cnt_irq5 > 512) {
|
||||
prev_line_cnt_irq5 = PicoPicohw.line_counter;
|
||||
elprintf(EL_ANOMALY, "irq5");
|
||||
SekInterrupt(5);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
PICO_INTERNAL int PicoInitPico(void)
|
||||
{
|
||||
elprintf(EL_STATUS, "Pico detected");
|
||||
PicoLineHook = PicoLineHookPico;
|
||||
|
||||
PicoAHW = PAHW_PICO;
|
||||
PicoPicoPage = 0;
|
||||
memset(&PicoPicohw, 0, sizeof(PicoPicohw));
|
||||
PicoPicohw.pen_pos[0] = 0x03c + 352/2;
|
||||
PicoPicohw.pen_pos[1] = 0x200 + 252/2;
|
||||
prev_line_cnt_irq3 = 0, prev_line_cnt_irq5 = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -365,6 +365,7 @@ typedef struct
|
|||
|
||||
#define Pico_mcd ((mcd_state *)Pico.rom)
|
||||
|
||||
|
||||
// Area.c
|
||||
PICO_INTERNAL int PicoAreaPackCpu(unsigned char *cpu, int is_sub);
|
||||
PICO_INTERNAL int PicoAreaUnpackCpu(unsigned char *cpu, int is_sub);
|
||||
|
|
|
@ -411,15 +411,15 @@ static void RunEventsPico(unsigned int events, unsigned int gp2x_keys)
|
|||
gettimeofday(¬iceMsgTime, 0);
|
||||
}
|
||||
if (events & (1 << 4)) {
|
||||
PicoPicoPage--;
|
||||
if (PicoPicoPage < 0) PicoPicoPage = 0;
|
||||
sprintf(noticeMsg, "Page %i ", PicoPicoPage);
|
||||
PicoPicohw.page--;
|
||||
if (PicoPicohw.page < 0) PicoPicohw.page = 0;
|
||||
sprintf(noticeMsg, "Page %i ", PicoPicohw.page);
|
||||
gettimeofday(¬iceMsgTime, 0);
|
||||
}
|
||||
if (events & (1 << 5)) {
|
||||
PicoPicoPage++;
|
||||
if (PicoPicoPage > 6) PicoPicoPage = 6;
|
||||
sprintf(noticeMsg, "Page %i ", PicoPicoPage);
|
||||
PicoPicohw.page++;
|
||||
if (PicoPicohw.page > 6) PicoPicohw.page = 6;
|
||||
sprintf(noticeMsg, "Page %i ", PicoPicohw.page);
|
||||
gettimeofday(¬iceMsgTime, 0);
|
||||
}
|
||||
if (pico_inp_mode != 0) {
|
||||
|
@ -428,8 +428,8 @@ static void RunEventsPico(unsigned int events, unsigned int gp2x_keys)
|
|||
if (gp2x_keys & GP2X_DOWN) { pico_pen_y++; if (pico_pen_y > 251) pico_pen_y = 251; }
|
||||
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; }
|
||||
PicoPicoPenPos[0] = 0x03c + pico_pen_x;
|
||||
PicoPicoPenPos[1] = pico_inp_mode == 1 ? (0x2f8 + pico_pen_y) : (0x1fc + pico_pen_y);
|
||||
PicoPicohw.pen_pos[0] = 0x03c + pico_pen_x;
|
||||
PicoPicohw.pen_pos[1] = pico_inp_mode == 1 ? (0x2f8 + pico_pen_y) : (0x1fc + pico_pen_y);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue