mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
split memories away from Pico
saves ~3k of code on ARM because Pico no longer crosses ldr limit
This commit is contained in:
parent
e64886365d
commit
88fd63ad10
30 changed files with 633 additions and 587 deletions
|
@ -1159,7 +1159,7 @@ static void bank_switch(int b)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bank = b << 20;
|
bank = b << 20;
|
||||||
if ((Pico.m.sram_reg & SRR_MAPPED) && bank == SRam.start) {
|
if ((Pico.m.sram_reg & SRR_MAPPED) && bank == Pico.sv.start) {
|
||||||
bank_map_handler();
|
bank_map_handler();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -326,11 +326,11 @@ void p32x_pwm_state_loaded(void)
|
||||||
p32x_pwm_ctl_changed();
|
p32x_pwm_ctl_changed();
|
||||||
|
|
||||||
// for old savestates
|
// for old savestates
|
||||||
cycles_diff_sh2 = SekCycleCnt * 3 - Pico32x.pwm_cycle_p;
|
cycles_diff_sh2 = Pico.t.m68c_cnt * 3 - Pico32x.pwm_cycle_p;
|
||||||
if (cycles_diff_sh2 >= pwm_cycles || cycles_diff_sh2 < 0) {
|
if (cycles_diff_sh2 >= pwm_cycles || cycles_diff_sh2 < 0) {
|
||||||
Pico32x.pwm_irq_cnt = pwm_irq_reload;
|
Pico32x.pwm_irq_cnt = pwm_irq_reload;
|
||||||
Pico32x.pwm_cycle_p = SekCycleCnt * 3;
|
Pico32x.pwm_cycle_p = Pico.t.m68c_cnt * 3;
|
||||||
p32x_pwm_schedule(SekCycleCnt);
|
p32x_pwm_schedule(Pico.t.m68c_cnt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
72
pico/cart.c
72
pico/cart.c
|
@ -617,9 +617,9 @@ int PicoCartInsert(unsigned char *rom, unsigned int romsize, const char *carthw_
|
||||||
Pico.rom=rom;
|
Pico.rom=rom;
|
||||||
Pico.romsize=romsize;
|
Pico.romsize=romsize;
|
||||||
|
|
||||||
if (SRam.data) {
|
if (Pico.sv.data) {
|
||||||
free(SRam.data);
|
free(Pico.sv.data);
|
||||||
SRam.data = NULL;
|
Pico.sv.data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PicoCartUnloadHook != NULL) {
|
if (PicoCartUnloadHook != NULL) {
|
||||||
|
@ -949,8 +949,8 @@ static void parse_carthw(const char *carthw_cfg, int *fill_sram)
|
||||||
elprintf(EL_STATUS, "carthw:%d: bad sram_range: %08x - %08x", line, start, end);
|
elprintf(EL_STATUS, "carthw:%d: bad sram_range: %08x - %08x", line, start, end);
|
||||||
goto bad_nomsg;
|
goto bad_nomsg;
|
||||||
}
|
}
|
||||||
SRam.start = start;
|
Pico.sv.start = start;
|
||||||
SRam.end = end;
|
Pico.sv.end = end;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (is_expr("prop", &p)) {
|
else if (is_expr("prop", &p)) {
|
||||||
|
@ -959,9 +959,9 @@ static void parse_carthw(const char *carthw_cfg, int *fill_sram)
|
||||||
rstrip(p);
|
rstrip(p);
|
||||||
|
|
||||||
if (strcmp(p, "no_sram") == 0)
|
if (strcmp(p, "no_sram") == 0)
|
||||||
SRam.flags &= ~SRF_ENABLED;
|
Pico.sv.flags &= ~SRF_ENABLED;
|
||||||
else if (strcmp(p, "no_eeprom") == 0)
|
else if (strcmp(p, "no_eeprom") == 0)
|
||||||
SRam.flags &= ~SRF_EEPROM;
|
Pico.sv.flags &= ~SRF_EEPROM;
|
||||||
else if (strcmp(p, "filled_sram") == 0)
|
else if (strcmp(p, "filled_sram") == 0)
|
||||||
*fill_sram = 1;
|
*fill_sram = 1;
|
||||||
else if (strcmp(p, "force_6btn") == 0)
|
else if (strcmp(p, "force_6btn") == 0)
|
||||||
|
@ -982,8 +982,8 @@ static void parse_carthw(const char *carthw_cfg, int *fill_sram)
|
||||||
type = strtoul(p, &r, 0);
|
type = strtoul(p, &r, 0);
|
||||||
if (r == p || type < 0)
|
if (r == p || type < 0)
|
||||||
goto bad;
|
goto bad;
|
||||||
SRam.eeprom_type = type;
|
Pico.sv.eeprom_type = type;
|
||||||
SRam.flags |= SRF_EEPROM;
|
Pico.sv.flags |= SRF_EEPROM;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (is_expr("eeprom_lines", &p)) {
|
else if (is_expr("eeprom_lines", &p)) {
|
||||||
|
@ -998,9 +998,9 @@ static void parse_carthw(const char *carthw_cfg, int *fill_sram)
|
||||||
sda_out < 0 || sda_out > 15)
|
sda_out < 0 || sda_out > 15)
|
||||||
goto bad;
|
goto bad;
|
||||||
|
|
||||||
SRam.eeprom_bit_cl = scl;
|
Pico.sv.eeprom_bit_cl = scl;
|
||||||
SRam.eeprom_bit_in = sda_in;
|
Pico.sv.eeprom_bit_in = sda_in;
|
||||||
SRam.eeprom_bit_out= sda_out;
|
Pico.sv.eeprom_bit_out= sda_out;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if ((tmp = is_expr("prot_ro_value16", &p)) || is_expr("prot_rw_value16", &p)) {
|
else if ((tmp = is_expr("prot_ro_value16", &p)) || is_expr("prot_rw_value16", &p)) {
|
||||||
|
@ -1040,54 +1040,54 @@ static void PicoCartDetect(const char *carthw_cfg)
|
||||||
{
|
{
|
||||||
int fill_sram = 0;
|
int fill_sram = 0;
|
||||||
|
|
||||||
memset(&SRam, 0, sizeof(SRam));
|
memset(&Pico.sv, 0, sizeof(Pico.sv));
|
||||||
if (Pico.rom[0x1B1] == 'R' && Pico.rom[0x1B0] == 'A')
|
if (Pico.rom[0x1B1] == 'R' && Pico.rom[0x1B0] == 'A')
|
||||||
{
|
{
|
||||||
SRam.start = rom_read32(0x1B4) & ~0xff000001; // align
|
Pico.sv.start = rom_read32(0x1B4) & ~0xff000001; // align
|
||||||
SRam.end = (rom_read32(0x1B8) & ~0xff000000) | 1;
|
Pico.sv.end = (rom_read32(0x1B8) & ~0xff000000) | 1;
|
||||||
if (Pico.rom[0x1B2] & 0x40)
|
if (Pico.rom[0x1B2] & 0x40)
|
||||||
// EEPROM
|
// EEPROM
|
||||||
SRam.flags |= SRF_EEPROM;
|
Pico.sv.flags |= SRF_EEPROM;
|
||||||
SRam.flags |= SRF_ENABLED;
|
Pico.sv.flags |= SRF_ENABLED;
|
||||||
}
|
}
|
||||||
if (SRam.end == 0 || SRam.start > SRam.end)
|
if (Pico.sv.end == 0 || Pico.sv.start > Pico.sv.end)
|
||||||
{
|
{
|
||||||
// some games may have bad headers, like S&K and Sonic3
|
// some games may have bad headers, like S&K and Sonic3
|
||||||
// note: majority games use 0x200000 as starting address, but there are some which
|
// note: majority games use 0x200000 as starting address, but there are some which
|
||||||
// use something else (0x300000 by HardBall '95). Luckily they have good headers.
|
// use something else (0x300000 by HardBall '95). Luckily they have good headers.
|
||||||
SRam.start = 0x200000;
|
Pico.sv.start = 0x200000;
|
||||||
SRam.end = 0x203FFF;
|
Pico.sv.end = 0x203FFF;
|
||||||
SRam.flags |= SRF_ENABLED;
|
Pico.sv.flags |= SRF_ENABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set EEPROM defaults, in case it gets detected
|
// set EEPROM defaults, in case it gets detected
|
||||||
SRam.eeprom_type = 0; // 7bit (24C01)
|
Pico.sv.eeprom_type = 0; // 7bit (24C01)
|
||||||
SRam.eeprom_bit_cl = 1;
|
Pico.sv.eeprom_bit_cl = 1;
|
||||||
SRam.eeprom_bit_in = 0;
|
Pico.sv.eeprom_bit_in = 0;
|
||||||
SRam.eeprom_bit_out= 0;
|
Pico.sv.eeprom_bit_out= 0;
|
||||||
|
|
||||||
if (carthw_cfg != NULL)
|
if (carthw_cfg != NULL)
|
||||||
parse_carthw(carthw_cfg, &fill_sram);
|
parse_carthw(carthw_cfg, &fill_sram);
|
||||||
|
|
||||||
if (SRam.flags & SRF_ENABLED)
|
if (Pico.sv.flags & SRF_ENABLED)
|
||||||
{
|
{
|
||||||
if (SRam.flags & SRF_EEPROM)
|
if (Pico.sv.flags & SRF_EEPROM)
|
||||||
SRam.size = 0x2000;
|
Pico.sv.size = 0x2000;
|
||||||
else
|
else
|
||||||
SRam.size = SRam.end - SRam.start + 1;
|
Pico.sv.size = Pico.sv.end - Pico.sv.start + 1;
|
||||||
|
|
||||||
SRam.data = calloc(SRam.size, 1);
|
Pico.sv.data = calloc(Pico.sv.size, 1);
|
||||||
if (SRam.data == NULL)
|
if (Pico.sv.data == NULL)
|
||||||
SRam.flags &= ~SRF_ENABLED;
|
Pico.sv.flags &= ~SRF_ENABLED;
|
||||||
|
|
||||||
if (SRam.eeprom_type == 1) // 1 == 0 in PD EEPROM code
|
if (Pico.sv.eeprom_type == 1) // 1 == 0 in PD EEPROM code
|
||||||
SRam.eeprom_type = 0;
|
Pico.sv.eeprom_type = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((SRam.flags & SRF_ENABLED) && fill_sram)
|
if ((Pico.sv.flags & SRF_ENABLED) && fill_sram)
|
||||||
{
|
{
|
||||||
elprintf(EL_STATUS, "SRAM fill");
|
elprintf(EL_STATUS, "SRAM fill");
|
||||||
memset(SRam.data, 0xff, SRam.size);
|
memset(Pico.sv.data, 0xff, Pico.sv.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unusual region 'code'
|
// Unusual region 'code'
|
||||||
|
|
|
@ -318,7 +318,7 @@ static void carthw_pier_write8(u32 a, u32 d)
|
||||||
base = d << 19;
|
base = d << 19;
|
||||||
goto do_map;
|
goto do_map;
|
||||||
case 0x09:
|
case 0x09:
|
||||||
SRam.changed = 1;
|
Pico.sv.changed = 1;
|
||||||
eeprom_spi_write(d);
|
eeprom_spi_write(d);
|
||||||
break;
|
break;
|
||||||
case 0x0b:
|
case 0x0b:
|
||||||
|
@ -449,11 +449,11 @@ void carthw_pier_startup(void)
|
||||||
|
|
||||||
// save EEPROM
|
// save EEPROM
|
||||||
eeprom_state = eeprom_spi_init(&eeprom_size);
|
eeprom_state = eeprom_spi_init(&eeprom_size);
|
||||||
SRam.flags = 0;
|
Pico.sv.flags = 0;
|
||||||
SRam.size = 0x10000;
|
Pico.sv.size = 0x10000;
|
||||||
SRam.data = calloc(1, SRam.size);
|
Pico.sv.data = calloc(1, Pico.sv.size);
|
||||||
if (!SRam.data)
|
if (!Pico.sv.data)
|
||||||
SRam.size = 0;
|
Pico.sv.size = 0;
|
||||||
carthw_pier_state[2].ptr = eeprom_state;
|
carthw_pier_state[2].ptr = eeprom_state;
|
||||||
carthw_pier_state[2].size = eeprom_size;
|
carthw_pier_state[2].size = eeprom_size;
|
||||||
|
|
||||||
|
|
|
@ -210,7 +210,7 @@ void eeprom_spi_write(unsigned char data)
|
||||||
if (spi_eeprom.opcode & 0x01)
|
if (spi_eeprom.opcode & 0x01)
|
||||||
{
|
{
|
||||||
/* READ operation */
|
/* READ operation */
|
||||||
spi_eeprom.buffer = SRam.data[spi_eeprom.addr];
|
spi_eeprom.buffer = Pico.sv.data[spi_eeprom.addr];
|
||||||
spi_eeprom.state = READ_BYTE;
|
spi_eeprom.state = READ_BYTE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -266,7 +266,7 @@ void eeprom_spi_write(unsigned char data)
|
||||||
/* $C000-$FFFF (sector #3) is protected */
|
/* $C000-$FFFF (sector #3) is protected */
|
||||||
if (spi_eeprom.addr < 0xC000)
|
if (spi_eeprom.addr < 0xC000)
|
||||||
{
|
{
|
||||||
SRam.data[spi_eeprom.addr] = spi_eeprom.buffer;
|
Pico.sv.data[spi_eeprom.addr] = spi_eeprom.buffer;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ void eeprom_spi_write(unsigned char data)
|
||||||
/* $8000-$FFFF (sectors #2 and #3) is protected */
|
/* $8000-$FFFF (sectors #2 and #3) is protected */
|
||||||
if (spi_eeprom.addr < 0x8000)
|
if (spi_eeprom.addr < 0x8000)
|
||||||
{
|
{
|
||||||
SRam.data[spi_eeprom.addr] = spi_eeprom.buffer;
|
Pico.sv.data[spi_eeprom.addr] = spi_eeprom.buffer;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -290,7 +290,7 @@ void eeprom_spi_write(unsigned char data)
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
/* no sectors protected */
|
/* no sectors protected */
|
||||||
SRam.data[spi_eeprom.addr] = spi_eeprom.buffer;
|
Pico.sv.data[spi_eeprom.addr] = spi_eeprom.buffer;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -332,7 +332,7 @@ void eeprom_spi_write(unsigned char data)
|
||||||
{
|
{
|
||||||
/* read next array byte */
|
/* read next array byte */
|
||||||
spi_eeprom.addr = (spi_eeprom.addr + 1) & SIZE_MASK;
|
spi_eeprom.addr = (spi_eeprom.addr + 1) & SIZE_MASK;
|
||||||
spi_eeprom.buffer = SRam.data[spi_eeprom.addr];
|
spi_eeprom.buffer = Pico.sv.data[spi_eeprom.addr];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ PICO_INTERNAL void DmaSlowCell(unsigned int source, unsigned int a, int len, uns
|
||||||
switch (Pico.video.type)
|
switch (Pico.video.type)
|
||||||
{
|
{
|
||||||
case 1: // vram
|
case 1: // vram
|
||||||
r = Pico.vram;
|
r = PicoMem.vram;
|
||||||
for(; len; len--)
|
for(; len; len--)
|
||||||
{
|
{
|
||||||
asrc = cell_map(source >> 2) << 2;
|
asrc = cell_map(source >> 2) << 2;
|
||||||
|
@ -42,7 +42,7 @@ PICO_INTERNAL void DmaSlowCell(unsigned int source, unsigned int a, int len, uns
|
||||||
|
|
||||||
case 3: // cram
|
case 3: // cram
|
||||||
Pico.m.dirtyPal = 1;
|
Pico.m.dirtyPal = 1;
|
||||||
r = Pico.cram;
|
r = PicoMem.cram;
|
||||||
for(a2=a&0x7f; len; len--)
|
for(a2=a&0x7f; len; len--)
|
||||||
{
|
{
|
||||||
asrc = cell_map(source >> 2) << 2;
|
asrc = cell_map(source >> 2) << 2;
|
||||||
|
@ -58,7 +58,7 @@ PICO_INTERNAL void DmaSlowCell(unsigned int source, unsigned int a, int len, uns
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5: // vsram[a&0x003f]=d;
|
case 5: // vsram[a&0x003f]=d;
|
||||||
r = Pico.vsram;
|
r = PicoMem.vsram;
|
||||||
for(a2=a&0x7f; len; len--)
|
for(a2=a&0x7f; len; len--)
|
||||||
{
|
{
|
||||||
asrc = cell_map(source >> 2) << 2;
|
asrc = cell_map(source >> 2) << 2;
|
||||||
|
|
|
@ -76,16 +76,16 @@ PICO_INTERNAL int PicoResetMCD(void)
|
||||||
{
|
{
|
||||||
// reset button doesn't affect MCD hardware
|
// reset button doesn't affect MCD hardware
|
||||||
|
|
||||||
// use SRam.data for RAM cart
|
// use Pico.sv.data for RAM cart
|
||||||
if (PicoOpt & POPT_EN_MCD_RAMCART) {
|
if (PicoOpt & POPT_EN_MCD_RAMCART) {
|
||||||
if (SRam.data == NULL)
|
if (Pico.sv.data == NULL)
|
||||||
SRam.data = calloc(1, 0x12000);
|
Pico.sv.data = calloc(1, 0x12000);
|
||||||
}
|
}
|
||||||
else if (SRam.data != NULL) {
|
else if (Pico.sv.data != NULL) {
|
||||||
free(SRam.data);
|
free(Pico.sv.data);
|
||||||
SRam.data = NULL;
|
Pico.sv.data = NULL;
|
||||||
}
|
}
|
||||||
SRam.start = SRam.end = 0; // unused
|
Pico.sv.start = Pico.sv.end = 0; // unused
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -95,17 +95,17 @@ static void SekRunM68kOnce(void)
|
||||||
int cyc_do;
|
int cyc_do;
|
||||||
pevt_log_m68k_o(EVT_RUN_START);
|
pevt_log_m68k_o(EVT_RUN_START);
|
||||||
|
|
||||||
if ((cyc_do = SekCycleAim - SekCycleCnt) > 0) {
|
if ((cyc_do = Pico.t.m68c_aim - Pico.t.m68c_cnt) > 0) {
|
||||||
SekCycleCnt += cyc_do;
|
Pico.t.m68c_cnt += cyc_do;
|
||||||
|
|
||||||
#if defined(EMU_C68K)
|
#if defined(EMU_C68K)
|
||||||
PicoCpuCM68k.cycles = cyc_do;
|
PicoCpuCM68k.cycles = cyc_do;
|
||||||
CycloneRun(&PicoCpuCM68k);
|
CycloneRun(&PicoCpuCM68k);
|
||||||
SekCycleCnt -= PicoCpuCM68k.cycles;
|
Pico.t.m68c_cnt -= PicoCpuCM68k.cycles;
|
||||||
#elif defined(EMU_M68K)
|
#elif defined(EMU_M68K)
|
||||||
SekCycleCnt += m68k_execute(cyc_do) - cyc_do;
|
Pico.t.m68c_cnt += m68k_execute(cyc_do) - cyc_do;
|
||||||
#elif defined(EMU_F68K)
|
#elif defined(EMU_F68K)
|
||||||
SekCycleCnt += fm68k_emulate(cyc_do, 0) - cyc_do;
|
Pico.t.m68c_cnt += fm68k_emulate(cyc_do, 0) - cyc_do;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,39 +316,39 @@ static void SekSyncM68k(void);
|
||||||
|
|
||||||
void pcd_run_cpus_normal(int m68k_cycles)
|
void pcd_run_cpus_normal(int m68k_cycles)
|
||||||
{
|
{
|
||||||
SekCycleAim += m68k_cycles;
|
Pico.t.m68c_aim += m68k_cycles;
|
||||||
if (SekShouldInterrupt() || Pico_mcd->m.m68k_poll_cnt < 12)
|
if (SekShouldInterrupt() || Pico_mcd->m.m68k_poll_cnt < 12)
|
||||||
Pico_mcd->m.m68k_poll_cnt = 0;
|
Pico_mcd->m.m68k_poll_cnt = 0;
|
||||||
else if (Pico_mcd->m.m68k_poll_cnt >= 16) {
|
else if (Pico_mcd->m.m68k_poll_cnt >= 16) {
|
||||||
int s68k_left = pcd_sync_s68k(SekCycleAim, 1);
|
int s68k_left = pcd_sync_s68k(Pico.t.m68c_aim, 1);
|
||||||
if (s68k_left <= 0) {
|
if (s68k_left <= 0) {
|
||||||
elprintf(EL_CDPOLL, "m68k poll [%02x] x%d @%06x",
|
elprintf(EL_CDPOLL, "m68k poll [%02x] x%d @%06x",
|
||||||
Pico_mcd->m.m68k_poll_a, Pico_mcd->m.m68k_poll_cnt, SekPc);
|
Pico_mcd->m.m68k_poll_a, Pico_mcd->m.m68k_poll_cnt, SekPc);
|
||||||
SekCycleCnt = SekCycleAim;
|
Pico.t.m68c_cnt = Pico.t.m68c_aim;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SekCycleCnt = SekCycleAim - (s68k_left * 40220 >> 16);
|
Pico.t.m68c_cnt = Pico.t.m68c_aim - (s68k_left * 40220 >> 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (CYCLES_GT(SekCycleAim, SekCycleCnt)) {
|
while (CYCLES_GT(Pico.t.m68c_aim, Pico.t.m68c_cnt)) {
|
||||||
SekRunM68kOnce();
|
SekRunM68kOnce();
|
||||||
if (Pico_mcd->m.need_sync) {
|
if (Pico_mcd->m.need_sync) {
|
||||||
Pico_mcd->m.need_sync = 0;
|
Pico_mcd->m.need_sync = 0;
|
||||||
pcd_sync_s68k(SekCycleCnt, 0);
|
pcd_sync_s68k(Pico.t.m68c_cnt, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcd_run_cpus_lockstep(int m68k_cycles)
|
void pcd_run_cpus_lockstep(int m68k_cycles)
|
||||||
{
|
{
|
||||||
unsigned int target = SekCycleAim + m68k_cycles;
|
unsigned int target = Pico.t.m68c_aim + m68k_cycles;
|
||||||
do {
|
do {
|
||||||
SekCycleAim += 8;
|
Pico.t.m68c_aim += 8;
|
||||||
SekSyncM68k();
|
SekSyncM68k();
|
||||||
pcd_sync_s68k(SekCycleAim, 0);
|
pcd_sync_s68k(Pico.t.m68c_aim, 0);
|
||||||
} while (CYCLES_GT(target, SekCycleAim));
|
} while (CYCLES_GT(target, Pico.t.m68c_aim));
|
||||||
|
|
||||||
SekCycleAim = target;
|
Pico.t.m68c_aim = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PICO_CD
|
#define PICO_CD
|
||||||
|
@ -364,7 +364,7 @@ void pcd_prepare_frame(void)
|
||||||
|
|
||||||
// need this because we can't have direct mapping between
|
// need this because we can't have direct mapping between
|
||||||
// master<->slave cycle counters because of overflows
|
// master<->slave cycle counters because of overflows
|
||||||
mcd_m68k_cycle_base = SekCycleAim;
|
mcd_m68k_cycle_base = Pico.t.m68c_aim;
|
||||||
mcd_s68k_cycle_base = SekCycleAimS68k;
|
mcd_s68k_cycle_base = SekCycleAimS68k;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,7 +390,7 @@ void pcd_state_loaded(void)
|
||||||
Pico_mcd->pcm_regs_dirty = 1;
|
Pico_mcd->pcm_regs_dirty = 1;
|
||||||
|
|
||||||
// old savestates..
|
// old savestates..
|
||||||
cycles = pcd_cycles_m68k_to_s68k(SekCycleAim);
|
cycles = pcd_cycles_m68k_to_s68k(Pico.t.m68c_aim);
|
||||||
diff = cycles - SekCycleAimS68k;
|
diff = cycles - SekCycleAimS68k;
|
||||||
if (diff < -1000 || diff > 1000) {
|
if (diff < -1000 || diff > 1000) {
|
||||||
SekCycleCntS68k = SekCycleAimS68k = cycles;
|
SekCycleCntS68k = SekCycleAimS68k = cycles;
|
||||||
|
|
|
@ -602,14 +602,14 @@ static u32 PicoReadM68k8_ramc(u32 a)
|
||||||
{
|
{
|
||||||
u32 d = 0;
|
u32 d = 0;
|
||||||
if (a == 0x400001) {
|
if (a == 0x400001) {
|
||||||
if (SRam.data != NULL)
|
if (Pico.sv.data != NULL)
|
||||||
d = 3; // 64k cart
|
d = 3; // 64k cart
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((a & 0xfe0000) == 0x600000) {
|
if ((a & 0xfe0000) == 0x600000) {
|
||||||
if (SRam.data != NULL)
|
if (Pico.sv.data != NULL)
|
||||||
d = SRam.data[((a >> 1) & 0xffff) + 0x2000];
|
d = Pico.sv.data[((a >> 1) & 0xffff) + 0x2000];
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -629,9 +629,9 @@ static u32 PicoReadM68k16_ramc(u32 a)
|
||||||
static void PicoWriteM68k8_ramc(u32 a, u32 d)
|
static void PicoWriteM68k8_ramc(u32 a, u32 d)
|
||||||
{
|
{
|
||||||
if ((a & 0xfe0000) == 0x600000) {
|
if ((a & 0xfe0000) == 0x600000) {
|
||||||
if (SRam.data != NULL && (Pico_mcd->m.bcram_reg & 1)) {
|
if (Pico.sv.data != NULL && (Pico_mcd->m.bcram_reg & 1)) {
|
||||||
SRam.data[((a>>1) & 0xffff) + 0x2000] = d;
|
Pico.sv.data[((a>>1) & 0xffff) + 0x2000] = d;
|
||||||
SRam.changed = 1;
|
Pico.sv.changed = 1;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -877,7 +877,7 @@ static u32 PicoReadS68k16_bram(u32 a)
|
||||||
static void PicoWriteS68k8_bram(u32 a, u32 d)
|
static void PicoWriteS68k8_bram(u32 a, u32 d)
|
||||||
{
|
{
|
||||||
Pico_mcd->bram[(a >> 1) & 0x1fff] = d;
|
Pico_mcd->bram[(a >> 1) & 0x1fff] = d;
|
||||||
SRam.changed = 1;
|
Pico.sv.changed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PicoWriteS68k16_bram(u32 a, u32 d)
|
static void PicoWriteS68k16_bram(u32 a, u32 d)
|
||||||
|
@ -886,7 +886,7 @@ static void PicoWriteS68k16_bram(u32 a, u32 d)
|
||||||
a = (a >> 1) & 0x1fff;
|
a = (a >> 1) & 0x1fff;
|
||||||
Pico_mcd->bram[a++] = d;
|
Pico_mcd->bram[a++] = d;
|
||||||
Pico_mcd->bram[a++] = d >> 8; // TODO: verify..
|
Pico_mcd->bram[a++] = d >> 8; // TODO: verify..
|
||||||
SRam.changed = 1;
|
Pico.sv.changed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _ASM_CD_MEMORY_C
|
#ifndef _ASM_CD_MEMORY_C
|
||||||
|
@ -1175,7 +1175,7 @@ PICO_INTERNAL void PicoMemSetupCD(void)
|
||||||
PicoCpuFM68k.Fetch[i] = (unsigned long)Pico.rom;
|
PicoCpuFM68k.Fetch[i] = (unsigned long)Pico.rom;
|
||||||
// .. and RAM
|
// .. and RAM
|
||||||
for (i = M68K_FETCHBANK1*14/16; i < M68K_FETCHBANK1; i++)
|
for (i = M68K_FETCHBANK1*14/16; i < M68K_FETCHBANK1; i++)
|
||||||
PicoCpuFM68k.Fetch[i] = (unsigned long)Pico.ram - (i<<(24-FAMEC_FETCHBITS));
|
PicoCpuFM68k.Fetch[i] = (unsigned long)PicoMem.ram - (i<<(24-FAMEC_FETCHBITS));
|
||||||
// S68k
|
// S68k
|
||||||
// PRG RAM is default
|
// PRG RAM is default
|
||||||
for (i = 0; i < M68K_FETCHBANK1; i++)
|
for (i = 0; i < M68K_FETCHBANK1; i++)
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
@* See COPYING file in the top-level directory.
|
@* See COPYING file in the top-level directory.
|
||||||
@*
|
@*
|
||||||
|
|
||||||
|
#include "../pico_int_o32.h"
|
||||||
|
|
||||||
.equiv PCM_STEP_SHIFT, 11
|
.equiv PCM_STEP_SHIFT, 11
|
||||||
|
|
||||||
.text
|
.text
|
||||||
|
@ -127,9 +129,9 @@ PicoReadM68k8_cell1: @ 0x220000 - 0x23ffff, cell arranged
|
||||||
mov r3, #0x0e0000
|
mov r3, #0x0e0000
|
||||||
0:
|
0:
|
||||||
cell_map
|
cell_map
|
||||||
ldr r1, =(Pico+0x22200)
|
ldr r1, =Pico
|
||||||
add r0, r0, r3
|
add r0, r0, r3
|
||||||
ldr r1, [r1]
|
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd (used everywhere)
|
||||||
eor r0, r0, #1
|
eor r0, r0, #1
|
||||||
ldrb r0, [r1, r0]
|
ldrb r0, [r1, r0]
|
||||||
bx lr
|
bx lr
|
||||||
|
@ -140,9 +142,9 @@ PicoRead8_mcd_io:
|
||||||
cmp r1, #0x2000 @ a120xx?
|
cmp r1, #0x2000 @ a120xx?
|
||||||
bne PicoRead8_io
|
bne PicoRead8_io
|
||||||
|
|
||||||
ldr r1, =(Pico+0x22200)
|
ldr r1, =Pico
|
||||||
and r0, r0, #0x3f
|
and r0, r0, #0x3f
|
||||||
ldr r1, [r1] @ Pico.mcd (used everywhere)
|
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd
|
||||||
cmp r0, #0x0e
|
cmp r0, #0x0e
|
||||||
ldrlt pc, [pc, r0, lsl #2]
|
ldrlt pc, [pc, r0, lsl #2]
|
||||||
b m_m68k_read8_hi
|
b m_m68k_read8_hi
|
||||||
|
@ -237,9 +239,9 @@ PicoReadM68k16_cell1: @ 0x220000 - 0x23ffff, cell arranged
|
||||||
mov r3, #0x0e0000
|
mov r3, #0x0e0000
|
||||||
0:
|
0:
|
||||||
cell_map
|
cell_map
|
||||||
ldr r1, =(Pico+0x22200)
|
ldr r1, =Pico
|
||||||
add r0, r0, r3
|
add r0, r0, r3
|
||||||
ldr r1, [r1]
|
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd
|
||||||
bic r0, r0, #1
|
bic r0, r0, #1
|
||||||
ldrh r0, [r1, r0]
|
ldrh r0, [r1, r0]
|
||||||
bx lr
|
bx lr
|
||||||
|
@ -251,9 +253,9 @@ PicoRead16_mcd_io:
|
||||||
bne PicoRead16_io
|
bne PicoRead16_io
|
||||||
|
|
||||||
m_m68k_read16_m68k_regs:
|
m_m68k_read16_m68k_regs:
|
||||||
ldr r1, =(Pico+0x22200)
|
ldr r1, =Pico
|
||||||
and r0, r0, #0x3e
|
and r0, r0, #0x3e
|
||||||
ldr r1, [r1] @ Pico.mcd (used everywhere)
|
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd
|
||||||
cmp r0, #0x0e
|
cmp r0, #0x0e
|
||||||
ldrlt pc, [pc, r0, lsl #1]
|
ldrlt pc, [pc, r0, lsl #1]
|
||||||
b m_m68k_read16_hi
|
b m_m68k_read16_hi
|
||||||
|
@ -328,8 +330,9 @@ PicoWriteM68k8_cell1: @ 0x220000 - 0x23ffff, cell arranged
|
||||||
0:
|
0:
|
||||||
mov r3, r1
|
mov r3, r1
|
||||||
cell_map
|
cell_map
|
||||||
ldr r2, =(Pico+0x22200)
|
ldr r2, =Pico
|
||||||
add r0, r0, r12
|
add r0, r0, r12
|
||||||
|
ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd
|
||||||
ldr r2, [r2]
|
ldr r2, [r2]
|
||||||
eor r0, r0, #1
|
eor r0, r0, #1
|
||||||
strb r3, [r2, r0]
|
strb r3, [r2, r0]
|
||||||
|
@ -355,9 +358,9 @@ PicoWriteM68k16_cell1: @ 0x220000 - 0x23ffff, cell arranged
|
||||||
0:
|
0:
|
||||||
mov r3, r1
|
mov r3, r1
|
||||||
cell_map
|
cell_map
|
||||||
ldr r1, =(Pico+0x22200)
|
ldr r1, =Pico
|
||||||
add r0, r0, r12
|
add r0, r0, r12
|
||||||
ldr r1, [r1]
|
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd
|
||||||
bic r0, r0, #1
|
bic r0, r0, #1
|
||||||
strh r3, [r1, r0]
|
strh r3, [r1, r0]
|
||||||
bx lr
|
bx lr
|
||||||
|
@ -397,9 +400,9 @@ PicoReadS68k8_dec0: @ 0x080000 - 0x0bffff
|
||||||
PicoReadS68k8_dec1:
|
PicoReadS68k8_dec1:
|
||||||
mov r3, #0x0a0000 @ + ^ / 2
|
mov r3, #0x0a0000 @ + ^ / 2
|
||||||
0:
|
0:
|
||||||
ldr r2, =(Pico+0x22200)
|
ldr r2, =Pico
|
||||||
eor r0, r0, #2
|
eor r0, r0, #2
|
||||||
ldr r2, [r2]
|
ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd
|
||||||
movs r0, r0, lsr #1 @ +4-6 <<16
|
movs r0, r0, lsr #1 @ +4-6 <<16
|
||||||
add r2, r2, r3 @ map to our address
|
add r2, r2, r3 @ map to our address
|
||||||
ldrb r0, [r2, r0]
|
ldrb r0, [r2, r0]
|
||||||
|
@ -429,8 +432,8 @@ m_s68k_read8_regs:
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
m_s68k_read8_comm:
|
m_s68k_read8_comm:
|
||||||
ldr r1, =(Pico+0x22200)
|
ldr r1, =Pico
|
||||||
ldr r1, [r1]
|
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd
|
||||||
add r1, r1, #0x110000
|
add r1, r1, #0x110000
|
||||||
ldrb r1, [r1, r0]
|
ldrb r1, [r1, r0]
|
||||||
bic r0, r0, #1
|
bic r0, r0, #1
|
||||||
|
@ -442,9 +445,9 @@ m_s68k_read8_pcm:
|
||||||
bne m_read_null
|
bne m_read_null
|
||||||
|
|
||||||
@ must not trash r3 and r12
|
@ must not trash r3 and r12
|
||||||
ldr r1, =(Pico+0x22200)
|
ldr r1, =Pico
|
||||||
bic r0, r0, #0xff0000
|
bic r0, r0, #0xff0000
|
||||||
ldr r1, [r1]
|
ldr r1, [r1, #OFS_Pico_rom] @ Pico.mcd
|
||||||
mov r2, #0x110000
|
mov r2, #0x110000
|
||||||
orr r2, r2, #0x002200
|
orr r2, r2, #0x002200
|
||||||
cmp r0, #0x2000
|
cmp r0, #0x2000
|
||||||
|
@ -477,9 +480,9 @@ PicoReadS68k16_dec0: @ 0x080000 - 0x0bffff
|
||||||
PicoReadS68k16_dec1:
|
PicoReadS68k16_dec1:
|
||||||
mov r3, #0x0a0000 @ + ^ / 2
|
mov r3, #0x0a0000 @ + ^ / 2
|
||||||
0:
|
0:
|
||||||
ldr r2, =(Pico+0x22200)
|
ldr r2, =Pico
|
||||||
eor r0, r0, #2
|
eor r0, r0, #2
|
||||||
ldr r2, [r2]
|
ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd
|
||||||
mov r0, r0, lsr #1 @ +4-6 <<16
|
mov r0, r0, lsr #1 @ +4-6 <<16
|
||||||
add r2, r2, r3 @ map to our address
|
add r2, r2, r3 @ map to our address
|
||||||
ldrb r0, [r2, r0]
|
ldrb r0, [r2, r0]
|
||||||
|
@ -508,9 +511,9 @@ m_s68k_read16_regs:
|
||||||
|
|
||||||
|
|
||||||
.macro m_s68k_write8_2M_decode
|
.macro m_s68k_write8_2M_decode
|
||||||
ldr r2, =(Pico+0x22200)
|
ldr r2, =Pico
|
||||||
eor r0, r0, #2
|
eor r0, r0, #2
|
||||||
ldr r2, [r2] @ Pico.rom
|
ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd
|
||||||
movs r0, r0, lsr #1 @ +4-6 <<16
|
movs r0, r0, lsr #1 @ +4-6 <<16
|
||||||
add r2, r2, r3 @ map to our address
|
add r2, r2, r3 @ map to our address
|
||||||
.endm
|
.endm
|
||||||
|
@ -592,9 +595,9 @@ m_s68k_write8_pcm:
|
||||||
bxlt lr
|
bxlt lr
|
||||||
|
|
||||||
m_s68k_write8_pcm_ram:
|
m_s68k_write8_pcm_ram:
|
||||||
ldr r3, =(Pico+0x22200)
|
ldr r3, =Pico
|
||||||
bic r0, r0, #0x00e000
|
bic r0, r0, #0x00e000
|
||||||
ldr r3, [r3]
|
ldr r3, [r3, #OFS_Pico_rom] @ Pico.mcd
|
||||||
mov r0, r0, lsr #1
|
mov r0, r0, lsr #1
|
||||||
add r2, r3, #0x110000
|
add r2, r3, #0x110000
|
||||||
add r2, r2, #0x002200
|
add r2, r2, #0x002200
|
||||||
|
@ -611,9 +614,9 @@ m_s68k_write8_pcm_ram:
|
||||||
|
|
||||||
|
|
||||||
.macro m_s68k_write16_2M_decode
|
.macro m_s68k_write16_2M_decode
|
||||||
ldr r2, =(Pico+0x22200)
|
ldr r2, =Pico
|
||||||
eor r0, r0, #2
|
eor r0, r0, #2
|
||||||
ldr r2, [r2]
|
ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd
|
||||||
mov r0, r0, lsr #1 @ +4-6 <<16
|
mov r0, r0, lsr #1 @ +4-6 <<16
|
||||||
add r2, r2, r3 @ map to our address
|
add r2, r2, r3 @ map to our address
|
||||||
.endm
|
.endm
|
||||||
|
@ -692,9 +695,9 @@ m_s68k_write16_regs:
|
||||||
bne s68k_reg_write16
|
bne s68k_reg_write16
|
||||||
|
|
||||||
m_s68k_write16_regs_spec: @ special case
|
m_s68k_write16_regs_spec: @ special case
|
||||||
ldr r2, =(Pico+0x22200)
|
ldr r2, =Pico
|
||||||
mov r0, #0x110000
|
mov r0, #0x110000
|
||||||
ldr r2, [r2]
|
ldr r2, [r2, #OFS_Pico_rom] @ Pico.mcd
|
||||||
add r0, r0, #0x00000f
|
add r0, r0, #0x00000f
|
||||||
strb r1, [r2, r0] @ if (a == 0xe) s68k_regs[0xf] = d;
|
strb r1, [r2, r0] @ if (a == 0xe) s68k_regs[0xf] = d;
|
||||||
bx lr
|
bx lr
|
38
pico/debug.c
38
pico/debug.c
|
@ -40,8 +40,8 @@ char *PDebugMain(void)
|
||||||
sprintf(dstrp, "mode set 4: %02x\n", (r=reg[0xC])); MVP;
|
sprintf(dstrp, "mode set 4: %02x\n", (r=reg[0xC])); MVP;
|
||||||
sprintf(dstrp, "interlace: %i%i, cells: %i, shadow: %i\n", bit(r,2), bit(r,1), (r&0x80) ? 40 : 32, bit(r,3)); MVP;
|
sprintf(dstrp, "interlace: %i%i, cells: %i, shadow: %i\n", bit(r,2), bit(r,1), (r&0x80) ? 40 : 32, bit(r,3)); MVP;
|
||||||
sprintf(dstrp, "scroll size: w: %i, h: %i SRAM: %i; eeprom: %i (%i)\n", reg[0x10]&3, (reg[0x10]&0x30)>>4,
|
sprintf(dstrp, "scroll size: w: %i, h: %i SRAM: %i; eeprom: %i (%i)\n", reg[0x10]&3, (reg[0x10]&0x30)>>4,
|
||||||
!!(SRam.flags & SRF_ENABLED), !!(SRam.flags & SRF_EEPROM), SRam.eeprom_type); MVP;
|
!!(Pico.sv.flags & SRF_ENABLED), !!(Pico.sv.flags & SRF_EEPROM), Pico.sv.eeprom_type); MVP;
|
||||||
sprintf(dstrp, "sram range: %06x-%06x, reg: %02x\n", SRam.start, SRam.end, Pico.m.sram_reg); MVP;
|
sprintf(dstrp, "sram range: %06x-%06x, reg: %02x\n", Pico.sv.start, Pico.sv.end, Pico.m.sram_reg); MVP;
|
||||||
sprintf(dstrp, "pend int: v:%i, h:%i, vdp status: %04x\n", bit(pv->pending_ints,5), bit(pv->pending_ints,4), pv->status); MVP;
|
sprintf(dstrp, "pend int: v:%i, h:%i, vdp status: %04x\n", bit(pv->pending_ints,5), bit(pv->pending_ints,4), pv->status); MVP;
|
||||||
sprintf(dstrp, "pal: %i, hw: %02x, frame#: %i, cycles: %u\n", Pico.m.pal, Pico.m.hardware, Pico.m.frame_count, SekCyclesDone()); MVP;
|
sprintf(dstrp, "pal: %i, hw: %02x, frame#: %i, cycles: %u\n", Pico.m.pal, Pico.m.hardware, Pico.m.frame_count, SekCyclesDone()); MVP;
|
||||||
sprintf(dstrp, "M68k: PC: %06x, SR: %04x, irql: %i\n", SekPc, SekSr, SekIrqLevel); MVP;
|
sprintf(dstrp, "M68k: PC: %06x, SR: %04x, irql: %i\n", SekPc, SekSr, SekIrqLevel); MVP;
|
||||||
|
@ -117,7 +117,7 @@ char *PDebugSpriteList(void)
|
||||||
unsigned int *sprite;
|
unsigned int *sprite;
|
||||||
int code, code2, sx, sy, height;
|
int code, code2, sx, sy, height;
|
||||||
|
|
||||||
sprite=(unsigned int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite
|
sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite
|
||||||
|
|
||||||
// get sprite info
|
// get sprite info
|
||||||
code = sprite[0];
|
code = sprite[0];
|
||||||
|
@ -245,23 +245,23 @@ void PDebugShowSprite(unsigned short *screen, int stride, int which)
|
||||||
|
|
||||||
for (u=0; u < max_sprites && u <= which; u++)
|
for (u=0; u < max_sprites && u <= which; u++)
|
||||||
{
|
{
|
||||||
sprite=(int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite
|
sprite=(int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite
|
||||||
|
|
||||||
link=(sprite[0]>>16)&0x7f;
|
link=(sprite[0]>>16)&0x7f;
|
||||||
if (!link) break; // End of sprites
|
if (!link) break; // End of sprites
|
||||||
}
|
}
|
||||||
if (u >= max_sprites) return;
|
if (u >= max_sprites) return;
|
||||||
|
|
||||||
fsprite = (int *)(Pico.vram+(table&0x7ffc));
|
fsprite = (int *)(PicoMem.vram+(table&0x7ffc));
|
||||||
oldsprite[0] = fsprite[0];
|
oldsprite[0] = fsprite[0];
|
||||||
oldsprite[1] = fsprite[1];
|
oldsprite[1] = fsprite[1];
|
||||||
fsprite[0] = (sprite[0] & ~0x007f01ff) | 0x000080;
|
fsprite[0] = (sprite[0] & ~0x007f01ff) | 0x000080;
|
||||||
fsprite[1] = (sprite[1] & ~0x01ff8000) | 0x800000;
|
fsprite[1] = (sprite[1] & ~0x01ff8000) | 0x800000;
|
||||||
oldreg = pvid->reg[7];
|
oldreg = pvid->reg[7];
|
||||||
oldcol = Pico.cram[0];
|
oldcol = PicoMem.cram[0];
|
||||||
olddbg = pvid->debug_p;
|
olddbg = pvid->debug_p;
|
||||||
pvid->reg[7] = 0;
|
pvid->reg[7] = 0;
|
||||||
Pico.cram[0] = 0;
|
PicoMem.cram[0] = 0;
|
||||||
pvid->debug_p = PVD_KILL_A | PVD_KILL_B;
|
pvid->debug_p = PVD_KILL_A | PVD_KILL_B;
|
||||||
|
|
||||||
PicoFrameFull();
|
PicoFrameFull();
|
||||||
|
@ -276,7 +276,7 @@ void PDebugShowSprite(unsigned short *screen, int stride, int which)
|
||||||
fsprite[0] = oldsprite[0];
|
fsprite[0] = oldsprite[0];
|
||||||
fsprite[1] = oldsprite[1];
|
fsprite[1] = oldsprite[1];
|
||||||
pvid->reg[7] = oldreg;
|
pvid->reg[7] = oldreg;
|
||||||
Pico.cram[0] = oldcol;
|
PicoMem.cram[0] = oldcol;
|
||||||
pvid->debug_p = olddbg;
|
pvid->debug_p = olddbg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,18 +325,18 @@ void PDebugDumpMem(void)
|
||||||
dump_ram_m(buf, "dumps/cart.bin", a ? "ab" : "wb");
|
dump_ram_m(buf, "dumps/cart.bin", a ? "ab" : "wb");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
dump_ram_noswab(Pico.zram, "dumps/zram.bin");
|
dump_ram_noswab(PicoMem.zram, "dumps/zram.bin");
|
||||||
dump_ram(Pico.cram, "dumps/cram.bin");
|
dump_ram(PicoMem.cram, "dumps/cram.bin");
|
||||||
|
|
||||||
if (PicoAHW & PAHW_SMS)
|
if (PicoAHW & PAHW_SMS)
|
||||||
{
|
{
|
||||||
dump_ram_noswab(Pico.vramb, "dumps/vram.bin");
|
dump_ram_noswab(PicoMem.vramb, "dumps/vram.bin");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dump_ram(Pico.ram, "dumps/ram.bin");
|
dump_ram(PicoMem.ram, "dumps/ram.bin");
|
||||||
dump_ram(Pico.vram, "dumps/vram.bin");
|
dump_ram(PicoMem.vram, "dumps/vram.bin");
|
||||||
dump_ram(Pico.vsram,"dumps/vsram.bin");
|
dump_ram(PicoMem.vsram,"dumps/vsram.bin");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PicoAHW & PAHW_MCD)
|
if (PicoAHW & PAHW_MCD)
|
||||||
|
@ -386,12 +386,12 @@ void PDebugZ80Frame(void)
|
||||||
PsndStartFrame();
|
PsndStartFrame();
|
||||||
|
|
||||||
if (/*Pico.m.z80Run &&*/ !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80))
|
if (/*Pico.m.z80Run &&*/ !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80))
|
||||||
PicoSyncZ80(SekCycleCnt + line_sample * 488);
|
PicoSyncZ80(Pico.t.m68c_cnt + line_sample * 488);
|
||||||
if (PsndOut)
|
if (PsndOut)
|
||||||
PsndGetSamples(line_sample);
|
PsndGetSamples(line_sample);
|
||||||
|
|
||||||
if (/*Pico.m.z80Run &&*/ !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80)) {
|
if (/*Pico.m.z80Run &&*/ !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80)) {
|
||||||
PicoSyncZ80(SekCycleCnt + 224 * 488);
|
PicoSyncZ80(Pico.t.m68c_cnt + 224 * 488);
|
||||||
z80_int();
|
z80_int();
|
||||||
}
|
}
|
||||||
if (PsndOut)
|
if (PsndOut)
|
||||||
|
@ -399,15 +399,15 @@ void PDebugZ80Frame(void)
|
||||||
|
|
||||||
// sync z80
|
// sync z80
|
||||||
if (/*Pico.m.z80Run &&*/ !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80)) {
|
if (/*Pico.m.z80Run &&*/ !Pico.m.z80_reset && (PicoOpt&POPT_EN_Z80)) {
|
||||||
SekCycleCnt += Pico.m.pal ? 151809 : 127671; // cycles adjusted for converter
|
Pico.t.m68c_cnt += Pico.m.pal ? 151809 : 127671; // cycles adjusted for converter
|
||||||
PicoSyncZ80(SekCycleCnt);
|
PicoSyncZ80(Pico.t.m68c_cnt);
|
||||||
}
|
}
|
||||||
if (PsndOut && ym2612.dacen && PsndDacLine < lines)
|
if (PsndOut && ym2612.dacen && PsndDacLine < lines)
|
||||||
PsndDoDAC(lines - 1);
|
PsndDoDAC(lines - 1);
|
||||||
PsndDoPSG(lines - 1);
|
PsndDoPSG(lines - 1);
|
||||||
|
|
||||||
timers_cycle();
|
timers_cycle();
|
||||||
SekCycleAim = SekCycleCnt;
|
Pico.t.m68c_aim = Pico.t.m68c_cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PDebugCPUStep(void)
|
void PDebugCPUStep(void)
|
||||||
|
|
56
pico/draw.c
56
pico/draw.c
|
@ -215,7 +215,7 @@ static void DrawStrip(struct TileStrip *ts, int lflags, int cellskip)
|
||||||
{
|
{
|
||||||
unsigned int pack;
|
unsigned int pack;
|
||||||
|
|
||||||
code = Pico.vram[ts->nametab + (tilex & ts->xmask)];
|
code = PicoMem.vram[ts->nametab + (tilex & ts->xmask)];
|
||||||
if (code == blank)
|
if (code == blank)
|
||||||
continue;
|
continue;
|
||||||
if ((code >> 15) | (lflags & LF_FORCE)) { // high priority tile
|
if ((code >> 15) | (lflags & LF_FORCE)) { // high priority tile
|
||||||
|
@ -235,7 +235,7 @@ static void DrawStrip(struct TileStrip *ts, int lflags, int cellskip)
|
||||||
pal=((code>>9)&0x30)|sh;
|
pal=((code>>9)&0x30)|sh;
|
||||||
}
|
}
|
||||||
|
|
||||||
pack = *(unsigned int *)(Pico.vram + addr);
|
pack = *(unsigned int *)(PicoMem.vram + addr);
|
||||||
if (!pack) {
|
if (!pack) {
|
||||||
blank = code;
|
blank = code;
|
||||||
continue;
|
continue;
|
||||||
|
@ -274,7 +274,7 @@ static void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip)
|
||||||
//if((cell&1)==0)
|
//if((cell&1)==0)
|
||||||
{
|
{
|
||||||
int line,vscroll;
|
int line,vscroll;
|
||||||
vscroll=Pico.vsram[(plane_sh&1)+(cell&~1)];
|
vscroll=PicoMem.vsram[(plane_sh&1)+(cell&~1)];
|
||||||
|
|
||||||
// Find the line in the name table
|
// Find the line in the name table
|
||||||
line=(vscroll+scan)&ts->line&0xffff; // ts->line is really ymask ..
|
line=(vscroll+scan)&ts->line&0xffff; // ts->line is really ymask ..
|
||||||
|
@ -282,7 +282,7 @@ static void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip)
|
||||||
ty=(line&7)<<1; // Y-Offset into tile
|
ty=(line&7)<<1; // Y-Offset into tile
|
||||||
}
|
}
|
||||||
|
|
||||||
code=Pico.vram[ts->nametab+nametabadd+(tilex&ts->xmask)];
|
code=PicoMem.vram[ts->nametab+nametabadd+(tilex&ts->xmask)];
|
||||||
if (code==blank) continue;
|
if (code==blank) continue;
|
||||||
if (code>>15) { // high priority tile
|
if (code>>15) { // high priority tile
|
||||||
int cval = code | (dx<<16) | (ty<<25);
|
int cval = code | (dx<<16) | (ty<<25);
|
||||||
|
@ -300,7 +300,7 @@ static void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip)
|
||||||
pal=((code>>9)&0x30)|((plane_sh<<5)&0x40);
|
pal=((code>>9)&0x30)|((plane_sh<<5)&0x40);
|
||||||
}
|
}
|
||||||
|
|
||||||
pack = *(unsigned int *)(Pico.vram + addr);
|
pack = *(unsigned int *)(PicoMem.vram + addr);
|
||||||
if (!pack) {
|
if (!pack) {
|
||||||
blank = code;
|
blank = code;
|
||||||
continue;
|
continue;
|
||||||
|
@ -336,7 +336,7 @@ void DrawStripInterlace(struct TileStrip *ts)
|
||||||
{
|
{
|
||||||
unsigned int pack;
|
unsigned int pack;
|
||||||
|
|
||||||
code=Pico.vram[ts->nametab+(tilex&ts->xmask)];
|
code = PicoMem.vram[ts->nametab + (tilex & ts->xmask)];
|
||||||
if (code==blank) continue;
|
if (code==blank) continue;
|
||||||
if (code>>15) { // high priority tile
|
if (code>>15) { // high priority tile
|
||||||
int cval = (code&0xfc00) | (dx<<16) | (ty<<25);
|
int cval = (code&0xfc00) | (dx<<16) | (ty<<25);
|
||||||
|
@ -356,7 +356,7 @@ void DrawStripInterlace(struct TileStrip *ts)
|
||||||
pal=((code>>9)&0x30);
|
pal=((code>>9)&0x30);
|
||||||
}
|
}
|
||||||
|
|
||||||
pack = *(unsigned int *)(Pico.vram + addr);
|
pack = *(unsigned int *)(PicoMem.vram + addr);
|
||||||
if (!pack) {
|
if (!pack) {
|
||||||
blank = code;
|
blank = code;
|
||||||
continue;
|
continue;
|
||||||
|
@ -409,11 +409,11 @@ static void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells,
|
||||||
htab+=plane_sh&1; // A or B
|
htab+=plane_sh&1; // A or B
|
||||||
|
|
||||||
// Get horizontal scroll value, will be masked later
|
// Get horizontal scroll value, will be masked later
|
||||||
ts.hscroll=Pico.vram[htab&0x7fff];
|
ts.hscroll = PicoMem.vram[htab & 0x7fff];
|
||||||
|
|
||||||
if((pvid->reg[12]&6) == 6) {
|
if((pvid->reg[12]&6) == 6) {
|
||||||
// interlace mode 2
|
// interlace mode 2
|
||||||
vscroll=Pico.vsram[plane_sh&1]; // Get vertical scroll value
|
vscroll = PicoMem.vsram[plane_sh & 1]; // Get vertical scroll value
|
||||||
|
|
||||||
// Find the line in the name table
|
// Find the line in the name table
|
||||||
ts.line=(vscroll+(est->DrawScanline<<1))&((ymask<<1)|1);
|
ts.line=(vscroll+(est->DrawScanline<<1))&((ymask<<1)|1);
|
||||||
|
@ -426,7 +426,7 @@ static void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells,
|
||||||
ts.line=ymask|(shift[width]<<24); // save some stuff instead of line
|
ts.line=ymask|(shift[width]<<24); // save some stuff instead of line
|
||||||
DrawStripVSRam(&ts, plane_sh, cellskip);
|
DrawStripVSRam(&ts, plane_sh, cellskip);
|
||||||
} else {
|
} else {
|
||||||
vscroll=Pico.vsram[plane_sh&1]; // Get vertical scroll value
|
vscroll = PicoMem.vsram[plane_sh & 1]; // Get vertical scroll value
|
||||||
|
|
||||||
// Find the line in the name table
|
// Find the line in the name table
|
||||||
ts.line=(vscroll+est->DrawScanline)&ymask;
|
ts.line=(vscroll+est->DrawScanline)&ymask;
|
||||||
|
@ -463,7 +463,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh,
|
||||||
|
|
||||||
if (!(est->rendstatus & PDRAW_WND_DIFF_PRIO)) {
|
if (!(est->rendstatus & PDRAW_WND_DIFF_PRIO)) {
|
||||||
// check the first tile code
|
// check the first tile code
|
||||||
code=Pico.vram[nametab+tilex];
|
code = PicoMem.vram[nametab + tilex];
|
||||||
// if the whole window uses same priority (what is often the case), we may be able to skip this field
|
// if the whole window uses same priority (what is often the case), we may be able to skip this field
|
||||||
if ((code>>15) != prio) return;
|
if ((code>>15) != prio) return;
|
||||||
}
|
}
|
||||||
|
@ -480,7 +480,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh,
|
||||||
int dx, addr;
|
int dx, addr;
|
||||||
int pal;
|
int pal;
|
||||||
|
|
||||||
code=Pico.vram[nametab+tilex];
|
code = PicoMem.vram[nametab + tilex];
|
||||||
if (code==blank) continue;
|
if (code==blank) continue;
|
||||||
if ((code>>15) != prio) {
|
if ((code>>15) != prio) {
|
||||||
est->rendstatus |= PDRAW_WND_DIFF_PRIO;
|
est->rendstatus |= PDRAW_WND_DIFF_PRIO;
|
||||||
|
@ -491,7 +491,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh,
|
||||||
addr=(code&0x7ff)<<4;
|
addr=(code&0x7ff)<<4;
|
||||||
if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip
|
if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip
|
||||||
|
|
||||||
pack = *(unsigned int *)(Pico.vram + addr);
|
pack = *(unsigned int *)(PicoMem.vram + addr);
|
||||||
if (!pack) {
|
if (!pack) {
|
||||||
blank = code;
|
blank = code;
|
||||||
continue;
|
continue;
|
||||||
|
@ -512,7 +512,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh,
|
||||||
int dx, addr;
|
int dx, addr;
|
||||||
int pal;
|
int pal;
|
||||||
|
|
||||||
code=Pico.vram[nametab+tilex];
|
code = PicoMem.vram[nametab + tilex];
|
||||||
if(code==blank) continue;
|
if(code==blank) continue;
|
||||||
if((code>>15) != prio) {
|
if((code>>15) != prio) {
|
||||||
est->rendstatus |= PDRAW_WND_DIFF_PRIO;
|
est->rendstatus |= PDRAW_WND_DIFF_PRIO;
|
||||||
|
@ -533,7 +533,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh,
|
||||||
addr=(code&0x7ff)<<4;
|
addr=(code&0x7ff)<<4;
|
||||||
if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip
|
if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip
|
||||||
|
|
||||||
pack = *(unsigned int *)(Pico.vram + addr);
|
pack = *(unsigned int *)(PicoMem.vram + addr);
|
||||||
if (!pack) {
|
if (!pack) {
|
||||||
blank = code;
|
blank = code;
|
||||||
continue;
|
continue;
|
||||||
|
@ -587,7 +587,7 @@ static void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est
|
||||||
addr = (code & 0x7ff) << 4;
|
addr = (code & 0x7ff) << 4;
|
||||||
addr += code >> 25; // y offset into tile
|
addr += code >> 25; // y offset into tile
|
||||||
|
|
||||||
pack = *(unsigned int *)(Pico.vram + addr);
|
pack = *(unsigned int *)(PicoMem.vram + addr);
|
||||||
if (!pack) {
|
if (!pack) {
|
||||||
blank = (short)code;
|
blank = (short)code;
|
||||||
continue;
|
continue;
|
||||||
|
@ -615,7 +615,7 @@ static void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est
|
||||||
*zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf;
|
*zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf;
|
||||||
*zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf;
|
*zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf;
|
||||||
|
|
||||||
pack = *(unsigned int *)(Pico.vram + addr);
|
pack = *(unsigned int *)(PicoMem.vram + addr);
|
||||||
if (!pack)
|
if (!pack)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -717,7 +717,7 @@ static void DrawSprite(int *sprite, int sh)
|
||||||
if(sx<=0) continue;
|
if(sx<=0) continue;
|
||||||
if(sx>=328) break; // Offscreen
|
if(sx>=328) break; // Offscreen
|
||||||
|
|
||||||
pack = *(unsigned int *)(Pico.vram + (tile & 0x7fff));
|
pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff));
|
||||||
fTileFunc(sx, pack, pal);
|
fTileFunc(sx, pack, pal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -737,7 +737,7 @@ static NOINLINE void DrawTilesFromCacheForced(const int *hc)
|
||||||
|
|
||||||
dx = (code >> 16) & 0x1ff;
|
dx = (code >> 16) & 0x1ff;
|
||||||
pal = ((code >> 9) & 0x30);
|
pal = ((code >> 9) & 0x30);
|
||||||
pack = *(unsigned int *)(Pico.vram + addr);
|
pack = *(unsigned int *)(PicoMem.vram + addr);
|
||||||
|
|
||||||
if (code & 0x0800) TileFlip_and(dx, pack, pal);
|
if (code & 0x0800) TileFlip_and(dx, pack, pal);
|
||||||
else TileNorm_and(dx, pack, pal);
|
else TileNorm_and(dx, pack, pal);
|
||||||
|
@ -783,7 +783,7 @@ static void DrawSpriteInterlace(unsigned int *sprite)
|
||||||
if(sx<=0) continue;
|
if(sx<=0) continue;
|
||||||
if(sx>=328) break; // Offscreen
|
if(sx>=328) break; // Offscreen
|
||||||
|
|
||||||
pack = *(unsigned int *)(Pico.vram + (tile & 0x7fff));
|
pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff));
|
||||||
if (code & 0x0800) TileFlip(sx, pack, pal);
|
if (code & 0x0800) TileFlip(sx, pack, pal);
|
||||||
else TileNorm(sx, pack, pal);
|
else TileNorm(sx, pack, pal);
|
||||||
}
|
}
|
||||||
|
@ -805,7 +805,7 @@ static NOINLINE void DrawAllSpritesInterlace(int pri, int sh)
|
||||||
unsigned int *sprite;
|
unsigned int *sprite;
|
||||||
int code, sx, sy, height;
|
int code, sx, sy, height;
|
||||||
|
|
||||||
sprite=(unsigned int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite
|
sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite
|
||||||
|
|
||||||
// get sprite info
|
// get sprite info
|
||||||
code = sprite[0];
|
code = sprite[0];
|
||||||
|
@ -908,7 +908,7 @@ static void DrawSpritesSHi(unsigned char *sprited, const struct PicoEState *est)
|
||||||
if(sx<=0) continue;
|
if(sx<=0) continue;
|
||||||
if(sx>=328) break; // Offscreen
|
if(sx>=328) break; // Offscreen
|
||||||
|
|
||||||
pack = *(unsigned int *)(Pico.vram + (tile & 0x7fff));
|
pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff));
|
||||||
fTileFunc(sx, pack, pal);
|
fTileFunc(sx, pack, pal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -982,7 +982,7 @@ static void DrawSpritesHiAS(unsigned char *sprited, int sh)
|
||||||
if(sx<=0) continue;
|
if(sx<=0) continue;
|
||||||
if(sx>=328) break; // Offscreen
|
if(sx>=328) break; // Offscreen
|
||||||
|
|
||||||
pack = *(unsigned int *)(Pico.vram + (tile & 0x7fff));
|
pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff));
|
||||||
fTileFunc(sx, pack, pal);
|
fTileFunc(sx, pack, pal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1042,7 +1042,7 @@ static NOINLINE void PrepareSprites(int full)
|
||||||
unsigned int *sprite;
|
unsigned int *sprite;
|
||||||
int code2, sx, sy, height;
|
int code2, sx, sy, height;
|
||||||
|
|
||||||
sprite=(unsigned int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite
|
sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite
|
||||||
|
|
||||||
// parse sprite info
|
// parse sprite info
|
||||||
code2 = sprite[1];
|
code2 = sprite[1];
|
||||||
|
@ -1095,7 +1095,7 @@ found:;
|
||||||
unsigned int *sprite;
|
unsigned int *sprite;
|
||||||
int code, code2, sx, sy, hv, height, width;
|
int code, code2, sx, sy, hv, height, width;
|
||||||
|
|
||||||
sprite=(unsigned int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite
|
sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite
|
||||||
|
|
||||||
// parse sprite info
|
// parse sprite info
|
||||||
code = sprite[0];
|
code = sprite[0];
|
||||||
|
@ -1219,7 +1219,7 @@ void PicoDoHighPal555(int sh, int line, struct PicoEState *est)
|
||||||
|
|
||||||
Pico.m.dirtyPal = 0;
|
Pico.m.dirtyPal = 0;
|
||||||
|
|
||||||
spal = (void *)Pico.cram;
|
spal = (void *)PicoMem.cram;
|
||||||
dpal = (void *)est->HighPal;
|
dpal = (void *)est->HighPal;
|
||||||
|
|
||||||
for (i = 0; i < 0x40 / 2; i++) {
|
for (i = 0; i < 0x40 / 2; i++) {
|
||||||
|
@ -1301,9 +1301,9 @@ static void FinalizeLine8bit(int sh, int line, struct PicoEState *est)
|
||||||
rs |= PDRAW_SONIC_MODE;
|
rs |= PDRAW_SONIC_MODE;
|
||||||
est->rendstatus = rs;
|
est->rendstatus = rs;
|
||||||
if (dirty_count == 3) {
|
if (dirty_count == 3) {
|
||||||
blockcpy(est->HighPal, Pico.cram, 0x40*2);
|
blockcpy(est->HighPal, PicoMem.cram, 0x40*2);
|
||||||
} else if (dirty_count == 11) {
|
} else if (dirty_count == 11) {
|
||||||
blockcpy(est->HighPal+0x40, Pico.cram, 0x40*2);
|
blockcpy(est->HighPal+0x40, PicoMem.cram, 0x40*2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
24
pico/draw2.c
24
pico/draw2.c
|
@ -25,7 +25,7 @@ static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)];
|
||||||
static int HighCache2A[41*(TILE_ROWS+1)+1+1]; // caches for high layers
|
static int HighCache2A[41*(TILE_ROWS+1)+1+1]; // caches for high layers
|
||||||
static int HighCache2B[41*(TILE_ROWS+1)+1+1];
|
static int HighCache2B[41*(TILE_ROWS+1)+1+1];
|
||||||
|
|
||||||
unsigned short *PicoCramHigh=Pico.cram; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now)
|
unsigned short *PicoCramHigh=PicoMem.cram; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now)
|
||||||
void (*PicoPrepareCram)()=0; // prepares PicoCramHigh for renderer to use
|
void (*PicoPrepareCram)()=0; // prepares PicoCramHigh for renderer to use
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ static int TileXnormYnorm(unsigned char *pd,int addr,unsigned char pal)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i=8; i; i--, addr+=2, pd += LINE_WIDTH) {
|
for(i=8; i; i--, addr+=2, pd += LINE_WIDTH) {
|
||||||
pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
|
pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels
|
||||||
if(!pack) continue;
|
if(!pack) continue;
|
||||||
|
|
||||||
t=pack&0x0000f000; if (t) pd[0]=(unsigned char)((t>>12)|pal);
|
t=pack&0x0000f000; if (t) pd[0]=(unsigned char)((t>>12)|pal);
|
||||||
|
@ -69,7 +69,7 @@ static int TileXflipYnorm(unsigned char *pd,int addr,unsigned char pal)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i=8; i; i--, addr+=2, pd += LINE_WIDTH) {
|
for(i=8; i; i--, addr+=2, pd += LINE_WIDTH) {
|
||||||
pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
|
pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels
|
||||||
if(!pack) continue;
|
if(!pack) continue;
|
||||||
|
|
||||||
t=pack&0x000f0000; if (t) pd[0]=(unsigned char)((t>>16)|pal);
|
t=pack&0x000f0000; if (t) pd[0]=(unsigned char)((t>>16)|pal);
|
||||||
|
@ -92,7 +92,7 @@ static int TileXnormYflip(unsigned char *pd,int addr,unsigned char pal)
|
||||||
|
|
||||||
addr+=14;
|
addr+=14;
|
||||||
for(i=8; i; i--, addr-=2, pd += LINE_WIDTH) {
|
for(i=8; i; i--, addr-=2, pd += LINE_WIDTH) {
|
||||||
pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
|
pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels
|
||||||
if(!pack) continue;
|
if(!pack) continue;
|
||||||
|
|
||||||
t=pack&0x0000f000; if (t) pd[0]=(unsigned char)((t>>12)|pal);
|
t=pack&0x0000f000; if (t) pd[0]=(unsigned char)((t>>12)|pal);
|
||||||
|
@ -116,7 +116,7 @@ static int TileXflipYflip(unsigned char *pd,int addr,unsigned char pal)
|
||||||
|
|
||||||
addr+=14;
|
addr+=14;
|
||||||
for(i=8; i; i--, addr-=2, pd += LINE_WIDTH) {
|
for(i=8; i; i--, addr-=2, pd += LINE_WIDTH) {
|
||||||
pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
|
pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels
|
||||||
if(!pack) continue;
|
if(!pack) continue;
|
||||||
|
|
||||||
t=pack&0x000f0000; if (t) pd[0]=(unsigned char)((t>>16)|pal);
|
t=pack&0x000f0000; if (t) pd[0]=(unsigned char)((t>>16)|pal);
|
||||||
|
@ -161,7 +161,7 @@ static void DrawWindowFull(int start, int end, int prio, struct PicoEState *est)
|
||||||
nametab += nametab_step*start;
|
nametab += nametab_step*start;
|
||||||
|
|
||||||
// check priority
|
// check priority
|
||||||
code=Pico.vram[nametab+tile_start];
|
code=PicoMem.vram[nametab+tile_start];
|
||||||
if ((code>>15) != prio) return; // hack: just assume that whole window uses same priority
|
if ((code>>15) != prio) return; // hack: just assume that whole window uses same priority
|
||||||
|
|
||||||
scrpos+=8*LINE_WIDTH+8;
|
scrpos+=8*LINE_WIDTH+8;
|
||||||
|
@ -175,7 +175,7 @@ static void DrawWindowFull(int start, int end, int prio, struct PicoEState *est)
|
||||||
// unsigned short *pal=NULL;
|
// unsigned short *pal=NULL;
|
||||||
unsigned char pal;
|
unsigned char pal;
|
||||||
|
|
||||||
code=Pico.vram[nametab+tilex];
|
code=PicoMem.vram[nametab+tilex];
|
||||||
if (code==blank) continue;
|
if (code==blank) continue;
|
||||||
|
|
||||||
// Get tile address/2:
|
// Get tile address/2:
|
||||||
|
@ -222,7 +222,7 @@ static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend,
|
||||||
|
|
||||||
if(!(pvid->reg[11]&3)) { // full screen scroll
|
if(!(pvid->reg[11]&3)) { // full screen scroll
|
||||||
// Get horizontal scroll value
|
// Get horizontal scroll value
|
||||||
hscroll=Pico.vram[htab&0x7fff];
|
hscroll=PicoMem.vram[htab&0x7fff];
|
||||||
htab = 0; // this marks that we don't have to update scroll value
|
htab = 0; // this marks that we don't have to update scroll value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend,
|
||||||
scrpos+=8*LINE_WIDTH*(planestart-START_ROW);
|
scrpos+=8*LINE_WIDTH*(planestart-START_ROW);
|
||||||
|
|
||||||
// Get vertical scroll value:
|
// Get vertical scroll value:
|
||||||
vscroll=Pico.vsram[plane]&0x1ff;
|
vscroll=PicoMem.vsram[plane]&0x1ff;
|
||||||
scrpos+=(8-(vscroll&7))*LINE_WIDTH;
|
scrpos+=(8-(vscroll&7))*LINE_WIDTH;
|
||||||
if(vscroll&7) planeend++; // we have vertically clipped tiles due to vscroll, so we need 1 more row
|
if(vscroll&7) planeend++; // we have vertically clipped tiles due to vscroll, so we need 1 more row
|
||||||
|
|
||||||
|
@ -262,7 +262,7 @@ static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend,
|
||||||
if(htab) {
|
if(htab) {
|
||||||
int htaddr=htab+(trow<<4);
|
int htaddr=htab+(trow<<4);
|
||||||
if(trow) htaddr-=(vscroll&7)<<1;
|
if(trow) htaddr-=(vscroll&7)<<1;
|
||||||
hscroll=Pico.vram[htaddr&0x7fff];
|
hscroll=PicoMem.vram[htaddr&0x7fff];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw tiles across screen:
|
// Draw tiles across screen:
|
||||||
|
@ -276,7 +276,7 @@ static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend,
|
||||||
// unsigned short *pal=NULL;
|
// unsigned short *pal=NULL;
|
||||||
unsigned char pal;
|
unsigned char pal;
|
||||||
|
|
||||||
code=Pico.vram[nametab_row+(tilex&xmask)];
|
code=PicoMem.vram[nametab_row+(tilex&xmask)];
|
||||||
if (code==blank) continue;
|
if (code==blank) continue;
|
||||||
|
|
||||||
if (code>>15) { // high priority tile
|
if (code>>15) { // high priority tile
|
||||||
|
@ -422,7 +422,7 @@ static void DrawAllSpritesFull(int prio, int maxwidth)
|
||||||
unsigned int *sprite=NULL;
|
unsigned int *sprite=NULL;
|
||||||
int code, code2, sx, sy, height;
|
int code, code2, sx, sy, height;
|
||||||
|
|
||||||
sprite=(unsigned int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite
|
sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite
|
||||||
|
|
||||||
// get sprite info
|
// get sprite info
|
||||||
code = sprite[0];
|
code = sprite[0];
|
||||||
|
|
|
@ -353,10 +353,10 @@ DrawLayerFull:
|
||||||
|
|
||||||
mov r6, r1 @ hcache
|
mov r6, r1 @ hcache
|
||||||
|
|
||||||
ldr r11, [r12, #OFS_Pico_video]
|
ldr r11, [r12, #OFS_EST_Pico]
|
||||||
ldr r10, [r12, #OFS_Pico_vram]
|
ldr r10, [r12, #OFS_EST_PicoMem_vram]
|
||||||
ldrb r5, [r11, #13] @ pvid->reg[13]
|
ldrb r5, [r11, #OFS_Pico_video_reg+13] @ pvid->reg[13]
|
||||||
ldrb r7, [r11, #11]
|
ldrb r7, [r11, #OFS_Pico_video_reg+11]
|
||||||
|
|
||||||
sub lr, r3, r2
|
sub lr, r3, r2
|
||||||
and lr, lr, #0x00ff0000 @ lr=cells
|
and lr, lr, #0x00ff0000 @ lr=cells
|
||||||
|
@ -366,7 +366,7 @@ DrawLayerFull:
|
||||||
bic r5, r5, #0x00ff0000 @ just in case
|
bic r5, r5, #0x00ff0000 @ just in case
|
||||||
|
|
||||||
tst r7, #3 @ full screen scroll? (if ==0)
|
tst r7, #3 @ full screen scroll? (if ==0)
|
||||||
ldrb r7, [r11, #16] @ ??hh??ww
|
ldrb r7, [r11, #OFS_Pico_video_reg+16] @ ??hh??ww
|
||||||
ldreqh r5, [r10, r5]
|
ldreqh r5, [r10, r5]
|
||||||
biceq r5, r5, #0x0000fc00 @ r5=hscroll (0-0x3ff)
|
biceq r5, r5, #0x0000fc00 @ r5=hscroll (0-0x3ff)
|
||||||
movne r5, r5, lsr #1
|
movne r5, r5, lsr #1
|
||||||
|
@ -397,15 +397,15 @@ DrawLayerFull:
|
||||||
|
|
||||||
@ Find name table:
|
@ Find name table:
|
||||||
tst r0, r0
|
tst r0, r0
|
||||||
ldreqb r4, [r11, #2]
|
ldreqb r4, [r11, #OFS_Pico_video_reg+2]
|
||||||
moveq r4, r4, lsr #3
|
moveq r4, r4, lsr #3
|
||||||
ldrneb r4, [r11, #4]
|
ldrneb r4, [r11, #OFS_Pico_video_reg+4]
|
||||||
and r4, r4, #7
|
and r4, r4, #7
|
||||||
orr lr, lr, r4, lsl #13 @ lr|=nametab_bits{3}<<13
|
orr lr, lr, r4, lsl #13 @ lr|=nametab_bits{3}<<13
|
||||||
|
|
||||||
ldr r11,[sp, #9*4] @ est
|
ldr r11,[sp, #9*4] @ est
|
||||||
sub r4, r9, #(START_ROW<<24)
|
sub r4, r9, #(START_ROW<<24)
|
||||||
ldr r11, [r11, #OFS_Draw2FB]
|
ldr r11, [r11, #OFS_EST_Draw2FB]
|
||||||
mov r4, r4, asr #24
|
mov r4, r4, asr #24
|
||||||
mov r7, #328*8
|
mov r7, #328*8
|
||||||
mla r11, r4, r7, r11 @ scrpos+=8*328*(planestart-START_ROW);
|
mla r11, r4, r7, r11 @ scrpos+=8*328*(planestart-START_ROW);
|
||||||
|
@ -582,13 +582,13 @@ DrawTilesFromCacheF:
|
||||||
mov r9, #0xff000000 @ r9=prevcode=-1
|
mov r9, #0xff000000 @ r9=prevcode=-1
|
||||||
mvn r6, #0 @ r6=prevy=-1
|
mvn r6, #0 @ r6=prevy=-1
|
||||||
|
|
||||||
ldr r4, [r1, #OFS_Draw2FB]
|
ldr r4, [r1, #OFS_EST_Draw2FB]
|
||||||
ldr r2, [r0], #4 @ read y offset
|
ldr r2, [r0], #4 @ read y offset
|
||||||
mov r7, #328
|
mov r7, #328
|
||||||
mla r2, r7, r2, r4
|
mla r2, r7, r2, r4
|
||||||
sub r12, r2, #(328*8*START_ROW) @ r12=scrpos
|
sub r12, r2, #(328*8*START_ROW) @ r12=scrpos
|
||||||
|
|
||||||
ldr r10, [r1, #OFS_Pico_vram]
|
ldr r10, [r1, #OFS_EST_PicoMem_vram]
|
||||||
mov r8, r0 @ hc
|
mov r8, r0 @ hc
|
||||||
mov r0, #0xf
|
mov r0, #0xf
|
||||||
|
|
||||||
|
@ -674,11 +674,11 @@ DrawTilesFromCacheF:
|
||||||
DrawWindowFull:
|
DrawWindowFull:
|
||||||
stmfd sp!, {r4-r11,lr}
|
stmfd sp!, {r4-r11,lr}
|
||||||
|
|
||||||
ldr r11, [r3, #OFS_Pico_video]
|
ldr r11, [r3, #OFS_EST_Pico]
|
||||||
ldrb r12, [r11, #3] @ pvid->reg[3]
|
ldrb r12, [r11, #OFS_Pico_video_reg+3] @ pvid->reg[3]
|
||||||
mov r12, r12, lsl #10
|
mov r12, r12, lsl #10
|
||||||
|
|
||||||
ldr r4, [r11, #12]
|
ldr r4, [r11, #OFS_Pico_video_reg+12]
|
||||||
mov r5, #1 @ nametab_step
|
mov r5, #1 @ nametab_step
|
||||||
tst r4, #1 @ 40 cell mode?
|
tst r4, #1 @ 40 cell mode?
|
||||||
andne r12, r12, #0xf000 @ 0x3c<<10
|
andne r12, r12, #0xf000 @ 0x3c<<10
|
||||||
|
@ -689,7 +689,7 @@ DrawWindowFull:
|
||||||
and r4, r0, #0xff
|
and r4, r0, #0xff
|
||||||
mla r12, r5, r4, r12 @ nametab += nametab_step*start;
|
mla r12, r5, r4, r12 @ nametab += nametab_step*start;
|
||||||
|
|
||||||
ldr r10, [r3, #OFS_Pico_vram]
|
ldr r10, [r3, #OFS_EST_PicoMem_vram]
|
||||||
mov r4, r0, lsr #16 @ r4=start_cell_h
|
mov r4, r0, lsr #16 @ r4=start_cell_h
|
||||||
add r7, r12, r4, lsl #1
|
add r7, r12, r4, lsl #1
|
||||||
|
|
||||||
|
@ -707,7 +707,7 @@ DrawWindowFull:
|
||||||
|
|
||||||
mov r9, #0xff000000 @ r9=prevcode=-1
|
mov r9, #0xff000000 @ r9=prevcode=-1
|
||||||
|
|
||||||
ldr r11, [r3, #OFS_Draw2FB]
|
ldr r11, [r3, #OFS_EST_Draw2FB]
|
||||||
and r4, r0, #0xff
|
and r4, r0, #0xff
|
||||||
add r11, r11, #328*8
|
add r11, r11, #328*8
|
||||||
sub r4, r4, #START_ROW
|
sub r4, r4, #START_ROW
|
||||||
|
@ -760,7 +760,8 @@ DrawWindowFull:
|
||||||
tst r9, #0x080000 @ hflip?
|
tst r9, #0x080000 @ hflip?
|
||||||
bne .dwf_hflip
|
bne .dwf_hflip
|
||||||
|
|
||||||
@ Tile (r1=pdest, r3=pal, r9=prevcode, r10=Pico.vram) r2,r4,r7: scratch, r0=0xf
|
@ Tile (r1=pdest, r3=pal, r9=prevcode, r10=PicoMem.vram)
|
||||||
|
@ r2,r4,r7: scratch, r0=0xf
|
||||||
Tile 0, 0
|
Tile 0, 0
|
||||||
b .dwfloop
|
b .dwfloop
|
||||||
|
|
||||||
|
@ -870,7 +871,8 @@ DrawWindowFull:
|
||||||
cmp r6, #(END_ROW*8+8)
|
cmp r6, #(END_ROW*8+8)
|
||||||
bge 52b
|
bge 52b
|
||||||
|
|
||||||
@ Tile (r1=pdest, r3=pal, r9=prevcode, r10=Pico.vram) r2,r4,r7: scratch, r0=0xf
|
@ Tile (r1=pdest, r3=pal, r9=prevcode, r10=PicoMem.vram)
|
||||||
|
@ r2,r4,r7: scratch, r0=0xf
|
||||||
Tile \hflip, \vflip
|
Tile \hflip, \vflip
|
||||||
b 52b
|
b 52b
|
||||||
.endm
|
.endm
|
||||||
|
@ -905,8 +907,8 @@ DrawSpriteFull:
|
||||||
and r3, lr, #0x6000
|
and r3, lr, #0x6000
|
||||||
mov r3, r3, lsr #9 @ r3=pal=((code>>9)&0x30);
|
mov r3, r3, lsr #9 @ r3=pal=((code>>9)&0x30);
|
||||||
|
|
||||||
ldr r11, [r1, #OFS_Draw2FB]
|
ldr r11, [r1, #OFS_EST_Draw2FB]
|
||||||
ldr r10, [r1, #OFS_Pico_vram]
|
ldr r10, [r1, #OFS_EST_PicoMem_vram]
|
||||||
sub r1, r12, #(START_ROW*8)
|
sub r1, r12, #(START_ROW*8)
|
||||||
mov r0, #328
|
mov r0, #328
|
||||||
mla r11, r1, r0, r11 @ scrpos+=(sy-START_ROW*8)*328;
|
mla r11, r1, r0, r11 @ scrpos+=(sy-START_ROW*8)*328;
|
||||||
|
|
116
pico/draw_arm.S
116
pico/draw_arm.S
|
@ -287,10 +287,10 @@ DrawLayer:
|
||||||
ldr r12, [sp] @ est
|
ldr r12, [sp] @ est
|
||||||
stmfd sp!, {r4-r11,lr}
|
stmfd sp!, {r4-r11,lr}
|
||||||
|
|
||||||
ldr r11, [r12, #OFS_Pico_video]
|
ldr r11, [r12, #OFS_EST_Pico]
|
||||||
mov r8, #1
|
mov r8, #1
|
||||||
|
|
||||||
ldrb r7, [r11, #16] @ ??vv??hh
|
ldrb r7, [r11, #OFS_Pico_video_reg+16] @ ??vv??hh
|
||||||
|
|
||||||
mov r6, r1 @ hcache
|
mov r6, r1 @ hcache
|
||||||
orr r9, r3, r0, lsl #29 @ r9=force[31]|sh[30]|plane[29]
|
orr r9, r3, r0, lsl #29 @ r9=force[31]|sh[30]|plane[29]
|
||||||
|
@ -311,13 +311,13 @@ DrawLayer:
|
||||||
cmp r10, #7
|
cmp r10, #7
|
||||||
subge r10, r10, #1 @ r10=shift[width] (5,6,6,7)
|
subge r10, r10, #1 @ r10=shift[width] (5,6,6,7)
|
||||||
|
|
||||||
ldr r2, [r12, #OFS_DrawScanline]
|
ldr r2, [r12, #OFS_EST_DrawScanline]
|
||||||
ldr lr, [r12, #OFS_Pico_vram]
|
ldr lr, [r12, #OFS_EST_PicoMem_vram]
|
||||||
|
|
||||||
@ Find name table:
|
@ Find name table:
|
||||||
ands r0, r0, #1
|
ands r0, r0, #1
|
||||||
ldreqb r12, [r11, #2]
|
ldreqb r12, [r11, #OFS_Pico_video_reg+2]
|
||||||
ldrneb r12, [r11, #4]
|
ldrneb r12, [r11, #OFS_Pico_video_reg+4]
|
||||||
|
|
||||||
@ calculate xmask:
|
@ calculate xmask:
|
||||||
mov r5, r8, lsl r10
|
mov r5, r8, lsl r10
|
||||||
|
@ -327,8 +327,8 @@ DrawLayer:
|
||||||
movne r12, r12, lsl #13
|
movne r12, r12, lsl #13
|
||||||
and r12, r12, #(7<<13) @ r12=(ts->nametab<<1) (halfword compliant)
|
and r12, r12, #(7<<13) @ r12=(ts->nametab<<1) (halfword compliant)
|
||||||
|
|
||||||
ldrh r8, [r11, #12]
|
ldrh r8, [r11, #OFS_Pico_video_reg+12]
|
||||||
ldrb r7, [r11, #11]
|
ldrb r7, [r11, #OFS_Pico_video_reg+11]
|
||||||
|
|
||||||
mov r4, r8, lsr #8 @ pvid->reg[13]
|
mov r4, r8, lsr #8 @ pvid->reg[13]
|
||||||
mov r4, r4, lsl #10 @ htab=pvid->reg[13]<<9; (halfwords)
|
mov r4, r4, lsl #10 @ htab=pvid->reg[13]<<9; (halfwords)
|
||||||
|
@ -345,7 +345,7 @@ DrawLayer:
|
||||||
|
|
||||||
@ Get vertical scroll value:
|
@ Get vertical scroll value:
|
||||||
add r7, lr, #0x012000
|
add r7, lr, #0x012000
|
||||||
add r7, r7, #0x000180 @ r7=Pico.vsram (Pico+0x22180)
|
add r7, r7, #0x000180 @ r7=PicoMem.vsram (PicoMem+0x22180)
|
||||||
ldr r7, [r7]
|
ldr r7, [r7]
|
||||||
|
|
||||||
tst r8, #2
|
tst r8, #2
|
||||||
|
@ -392,7 +392,7 @@ DrawLayer:
|
||||||
@ cache some stuff to avoid mem access
|
@ cache some stuff to avoid mem access
|
||||||
ldr r11,[sp, #9*4] @ est
|
ldr r11,[sp, #9*4] @ est
|
||||||
mov r0, #0xf
|
mov r0, #0xf
|
||||||
ldr r11,[r11, #OFS_HighCol]
|
ldr r11,[r11, #OFS_EST_HighCol]
|
||||||
|
|
||||||
mvn r9, #0 @ r9=prevcode=-1
|
mvn r9, #0 @ r9=prevcode=-1
|
||||||
add r1, r11, r7 @ r1=pdest
|
add r1, r11, r7 @ r1=pdest
|
||||||
|
@ -497,10 +497,10 @@ DrawLayer:
|
||||||
tst r10, #1<<21 @ seen non hi-prio tile
|
tst r10, #1<<21 @ seen non hi-prio tile
|
||||||
ldr r1, [sp, #9*4] @ est
|
ldr r1, [sp, #9*4] @ est
|
||||||
mov r0, #0
|
mov r0, #0
|
||||||
ldreq r2, [r1, #OFS_rendstatus]
|
ldreq r2, [r1, #OFS_EST_rendstatus]
|
||||||
str r0, [r6] @ terminate the cache list
|
str r0, [r6] @ terminate the cache list
|
||||||
orreq r2, r2, #PDRAW_PLANE_HI_PRIO @ had a layer with all hi-prio tiles
|
orreq r2, r2, #PDRAW_PLANE_HI_PRIO @ had a layer with all hi-prio tiles
|
||||||
streq r2, [r1, #OFS_rendstatus]
|
streq r2, [r1, #OFS_EST_rendstatus]
|
||||||
|
|
||||||
ldmfd sp!, {r4-r11,lr}
|
ldmfd sp!, {r4-r11,lr}
|
||||||
bx lr
|
bx lr
|
||||||
|
@ -515,7 +515,7 @@ DrawLayer:
|
||||||
|
|
||||||
ldr r11, [sp, #9*4] @ est
|
ldr r11, [sp, #9*4] @ est
|
||||||
orr r5, r1, r10, lsl #24
|
orr r5, r1, r10, lsl #24
|
||||||
ldr r4, [r11, #OFS_DrawScanline]
|
ldr r4, [r11, #OFS_EST_DrawScanline]
|
||||||
sub r1, r3, #1
|
sub r1, r3, #1
|
||||||
orr r5, r5, r4, lsl #16 @ r5=(shift_width[31:24]|scanline[23:16]|ymask[15:0])
|
orr r5, r5, r4, lsl #16 @ r5=(shift_width[31:24]|scanline[23:16]|ymask[15:0])
|
||||||
and r1, r1, #7
|
and r1, r1, #7
|
||||||
|
@ -541,7 +541,7 @@ DrawLayer:
|
||||||
@ cache some stuff to avoid mem access
|
@ cache some stuff to avoid mem access
|
||||||
ldr r11,[sp, #9*4] @ est
|
ldr r11,[sp, #9*4] @ est
|
||||||
mov r0, #0xf
|
mov r0, #0xf
|
||||||
ldr r11,[r11, #OFS_HighCol]
|
ldr r11,[r11, #OFS_EST_HighCol]
|
||||||
|
|
||||||
mvn r9, #0 @ r9=prevcode=-1
|
mvn r9, #0 @ r9=prevcode=-1
|
||||||
add r1, r11, r7 @ r1=pdest
|
add r1, r11, r7 @ r1=pdest
|
||||||
|
@ -557,7 +557,7 @@ DrawLayer:
|
||||||
|
|
||||||
@ calc offset and read tileline code to r7, also calc ty
|
@ calc offset and read tileline code to r7, also calc ty
|
||||||
add r7, lr, #0x012000
|
add r7, lr, #0x012000
|
||||||
add r7, r7, #0x000180 @ r7=Pico.vsram (Pico+0x22180)
|
add r7, r7, #0x000180 @ r7=PicoMem.vsram (PicoMem+0x22180)
|
||||||
add r7, r7, r10,asr #23 @ vsram + ((cell&~1)<<1)
|
add r7, r7, r10,asr #23 @ vsram + ((cell&~1)<<1)
|
||||||
bic r7, r7, #3
|
bic r7, r7, #3
|
||||||
tst r10,#0x8000 @ plane1?
|
tst r10,#0x8000 @ plane1?
|
||||||
|
@ -576,7 +576,7 @@ DrawLayer:
|
||||||
mov r4, r4, lsl r7 @ nametabadd
|
mov r4, r4, lsl r7 @ nametabadd
|
||||||
|
|
||||||
and r7, r8, r8, lsr #25
|
and r7, r8, r8, lsr #25
|
||||||
add r7, lr, r7, lsl #1 @ Pico.vram+((tilex&ts->xmask) as halfwords)
|
add r7, lr, r7, lsl #1 @ PicoMem.vram+((tilex&ts->xmask) as halfwords)
|
||||||
add r7, r7, r4, lsl #1
|
add r7, r7, r4, lsl #1
|
||||||
ldrh r7, [r7, r12] @ r7=code (int, but from unsigned, no sign extend)
|
ldrh r7, [r7, r12] @ r7=code (int, but from unsigned, no sign extend)
|
||||||
|
|
||||||
|
@ -598,7 +598,7 @@ DrawLayer:
|
||||||
mov r2, r2, lsr #17
|
mov r2, r2, lsr #17
|
||||||
eorcs r2, r2, #0x0e @ if (code&0x1000) addr^=0xe;
|
eorcs r2, r2, #0x0e @ if (code&0x1000) addr^=0xe;
|
||||||
|
|
||||||
ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
|
ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels
|
||||||
|
|
||||||
bic r7, r3, #0x3f
|
bic r7, r3, #0x3f
|
||||||
and r3, r9, #0x6000
|
and r3, r9, #0x6000
|
||||||
|
@ -656,7 +656,7 @@ DrawLayer:
|
||||||
add r2, r2, r10, lsl #17
|
add r2, r2, r10, lsl #17
|
||||||
mov r2, r2, lsr #17
|
mov r2, r2, lsr #17
|
||||||
eorcs r2, r2, #0x0e @ if (code&0x1000) addr^=0xe;
|
eorcs r2, r2, #0x0e @ if (code&0x1000) addr^=0xe;
|
||||||
ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
|
ldr r2, [lr, r2, lsl #1] @ pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels
|
||||||
mov r9, r7 @ remember code
|
mov r9, r7 @ remember code
|
||||||
tst r2, r2
|
tst r2, r2
|
||||||
orrne r10, r10, #1<<22
|
orrne r10, r10, #1<<22
|
||||||
|
@ -667,10 +667,10 @@ DrawLayer:
|
||||||
tst r8, #(1<<24) @ seen non hi-prio tile
|
tst r8, #(1<<24) @ seen non hi-prio tile
|
||||||
ldr r1, [sp, #9*4] @ est
|
ldr r1, [sp, #9*4] @ est
|
||||||
mov r0, #0
|
mov r0, #0
|
||||||
ldreq r2, [r1, #OFS_rendstatus]
|
ldreq r2, [r1, #OFS_EST_rendstatus]
|
||||||
str r0, [r6] @ terminate the cache list
|
str r0, [r6] @ terminate the cache list
|
||||||
orreq r2, r2, #PDRAW_PLANE_HI_PRIO @ had a layer with all hi-prio tiles
|
orreq r2, r2, #PDRAW_PLANE_HI_PRIO @ had a layer with all hi-prio tiles
|
||||||
streq r2, [r1, #OFS_rendstatus]
|
streq r2, [r1, #OFS_EST_rendstatus]
|
||||||
|
|
||||||
ldmfd sp!, {r4-r11,lr}
|
ldmfd sp!, {r4-r11,lr}
|
||||||
bx lr
|
bx lr
|
||||||
|
@ -716,7 +716,7 @@ BackFill:
|
||||||
stmfd sp!, {r4-r9,lr}
|
stmfd sp!, {r4-r9,lr}
|
||||||
|
|
||||||
mov r0, r0, lsl #26
|
mov r0, r0, lsl #26
|
||||||
ldr lr, [r2, #OFS_HighCol]
|
ldr lr, [r2, #OFS_EST_HighCol]
|
||||||
mov r0, r0, lsr #26
|
mov r0, r0, lsr #26
|
||||||
add lr, lr, #8
|
add lr, lr, #8
|
||||||
|
|
||||||
|
@ -758,9 +758,9 @@ DrawTilesFromCache:
|
||||||
stmfd sp!, {r4-r9,r11,lr}
|
stmfd sp!, {r4-r9,r11,lr}
|
||||||
|
|
||||||
@ cache some stuff to avoid mem access
|
@ cache some stuff to avoid mem access
|
||||||
ldr r11,[r3, #OFS_HighCol]
|
ldr r11,[r3, #OFS_EST_HighCol]
|
||||||
mov r12,#0xf
|
mov r12,#0xf
|
||||||
ldr lr, [r3, #OFS_Pico_vram]
|
ldr lr, [r3, #OFS_EST_PicoMem_vram]
|
||||||
mov r9, r3 @ est
|
mov r9, r3 @ est
|
||||||
|
|
||||||
mvn r5, #0 @ r5=prevcode=-1
|
mvn r5, #0 @ r5=prevcode=-1
|
||||||
|
@ -892,14 +892,14 @@ DrawTilesFromCache:
|
||||||
|
|
||||||
@ check if we have detected layer covered with hi-prio tiles:
|
@ check if we have detected layer covered with hi-prio tiles:
|
||||||
.dtfc_check_rendflags:
|
.dtfc_check_rendflags:
|
||||||
ldr r2, [r9, #OFS_rendstatus]
|
ldr r2, [r9, #OFS_EST_rendstatus]
|
||||||
tst r2, #(PDRAW_PLANE_HI_PRIO|PDRAW_SHHI_DONE)
|
tst r2, #(PDRAW_PLANE_HI_PRIO|PDRAW_SHHI_DONE)
|
||||||
beq .dtfc_loop
|
beq .dtfc_loop
|
||||||
bic r8, r8, #1 @ sh/hi mode off
|
bic r8, r8, #1 @ sh/hi mode off
|
||||||
tst r2, #PDRAW_SHHI_DONE
|
tst r2, #PDRAW_SHHI_DONE
|
||||||
bne .dtfc_loop @ already processed
|
bne .dtfc_loop @ already processed
|
||||||
orr r2, r2, #PDRAW_SHHI_DONE
|
orr r2, r2, #PDRAW_SHHI_DONE
|
||||||
str r2, [r9, #OFS_rendstatus]
|
str r2, [r9, #OFS_EST_rendstatus]
|
||||||
|
|
||||||
add r1, r11,#8
|
add r1, r11,#8
|
||||||
mov r3, #320/4/4
|
mov r3, #320/4/4
|
||||||
|
@ -939,16 +939,16 @@ DrawSpritesSHi:
|
||||||
add r10,r0, #3 @ r10=HighLnSpr end
|
add r10,r0, #3 @ r10=HighLnSpr end
|
||||||
add r10,r10,r3 @ r10=HighLnSpr end
|
add r10,r10,r3 @ r10=HighLnSpr end
|
||||||
|
|
||||||
ldr r11,[r1, #OFS_HighCol]
|
ldr r11,[r1, #OFS_EST_HighCol]
|
||||||
mov r12,#0xf
|
mov r12,#0xf
|
||||||
ldr lr, [r1, #OFS_Pico_vram]
|
ldr lr, [r1, #OFS_EST_PicoMem_vram]
|
||||||
|
|
||||||
|
|
||||||
DrawSpriteSHi:
|
DrawSpriteSHi:
|
||||||
@ draw next sprite
|
@ draw next sprite
|
||||||
ldrb r0, [r10,#-1]!
|
ldrb r0, [r10,#-1]!
|
||||||
ldr r7, [sp] @ est
|
ldr r7, [sp] @ est
|
||||||
ldr r1, [r7, #OFS_HighPreSpr]
|
ldr r1, [r7, #OFS_EST_HighPreSpr]
|
||||||
cmp r0, #0xff
|
cmp r0, #0xff
|
||||||
ldmeqfd sp!, {r1,r4-r11,pc} @ end of list
|
ldmeqfd sp!, {r1,r4-r11,pc} @ end of list
|
||||||
and r0, r0, #0x7f
|
and r0, r0, #0x7f
|
||||||
|
@ -974,7 +974,7 @@ DrawSpriteSHi:
|
||||||
mov r5, r3, lsr #24
|
mov r5, r3, lsr #24
|
||||||
and r5, r5, #7 @ r5=height
|
and r5, r5, #7 @ r5=height
|
||||||
|
|
||||||
ldr r7, [r7, #OFS_DrawScanline]
|
ldr r7, [r7, #OFS_EST_DrawScanline]
|
||||||
mov r0, r3, lsl #16 @ r4=sy<<16 (tmp)
|
mov r0, r3, lsl #16 @ r4=sy<<16 (tmp)
|
||||||
|
|
||||||
sub r7, r7, r0, asr #16 @ r7=row=DrawScanline-sy
|
sub r7, r7, r0, asr #16 @ r7=row=DrawScanline-sy
|
||||||
|
@ -1015,7 +1015,7 @@ DrawSpriteSHi:
|
||||||
mov r8, r8, lsl #17
|
mov r8, r8, lsl #17
|
||||||
mov r8, r8, lsr #17 @ tile&=0x7fff; // Clip tile address
|
mov r8, r8, lsr #17 @ tile&=0x7fff; // Clip tile address
|
||||||
|
|
||||||
ldr r2, [lr, r8, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
|
ldr r2, [lr, r8, lsl #1] @ pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels
|
||||||
add r1, r11, r0 @ r1=pdest
|
add r1, r11, r0 @ r1=pdest
|
||||||
tst r2, r2
|
tst r2, r2
|
||||||
beq .dsprShi_loop
|
beq .dsprShi_loop
|
||||||
|
@ -1117,9 +1117,9 @@ DrawAllSprites:
|
||||||
add r10,r0, #3
|
add r10,r0, #3
|
||||||
add r10,r10,r2 @ r10=HighLnSpr end
|
add r10,r10,r2 @ r10=HighLnSpr end
|
||||||
|
|
||||||
ldr r11,[r3, #OFS_HighCol]
|
ldr r11,[r3, #OFS_EST_HighCol]
|
||||||
mov r12,#0xf
|
mov r12,#0xf
|
||||||
ldr lr, [r3, #OFS_Pico_vram]
|
ldr lr, [r3, #OFS_EST_PicoMem_vram]
|
||||||
|
|
||||||
@ + 0 : hhhhvvvv ----hhvv yyyyyyyy yyyyyyyy // v, h: horiz. size
|
@ + 0 : hhhhvvvv ----hhvv yyyyyyyy yyyyyyyy // v, h: horiz. size
|
||||||
@ + 4 : xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8
|
@ + 4 : xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8
|
||||||
|
@ -1134,12 +1134,12 @@ DrawSprite:
|
||||||
ldmeqfd sp!, {r1,r3-r11,pc} @ end of list
|
ldmeqfd sp!, {r1,r3-r11,pc} @ end of list
|
||||||
cmp r2, r8, lsr #1
|
cmp r2, r8, lsr #1
|
||||||
bne DrawSprite @ wrong priority
|
bne DrawSprite @ wrong priority
|
||||||
ldr r1, [r7, #OFS_HighPreSpr]
|
ldr r1, [r7, #OFS_EST_HighPreSpr]
|
||||||
and r0, r0, #0x7f
|
and r0, r0, #0x7f
|
||||||
add r0, r1, r0, lsl #3
|
add r0, r1, r0, lsl #3
|
||||||
|
|
||||||
ldr r3, [r0] @ sprite[0]
|
ldr r3, [r0] @ sprite[0]
|
||||||
ldr r7, [r7, #OFS_DrawScanline]
|
ldr r7, [r7, #OFS_EST_DrawScanline]
|
||||||
mov r6, r3, lsr #28
|
mov r6, r3, lsr #28
|
||||||
sub r6, r6, #1 @ r6=width-1 (inc later)
|
sub r6, r6, #1 @ r6=width-1 (inc later)
|
||||||
mov r5, r3, lsr #24
|
mov r5, r3, lsr #24
|
||||||
|
@ -1198,7 +1198,7 @@ DrawSprite:
|
||||||
mov r8, r8, lsl #17
|
mov r8, r8, lsl #17
|
||||||
mov r8, r8, lsr #17 @ tile&=0x7fff; // Clip tile address
|
mov r8, r8, lsr #17 @ tile&=0x7fff; // Clip tile address
|
||||||
|
|
||||||
ldr r2, [lr, r8, lsl #1] @ pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
|
ldr r2, [lr, r8, lsl #1] @ pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels
|
||||||
add r1, r11, r0 @ r1=pdest
|
add r1, r11, r0 @ r1=pdest
|
||||||
tst r2, r2
|
tst r2, r2
|
||||||
beq .dspr_loop
|
beq .dspr_loop
|
||||||
|
@ -1267,12 +1267,12 @@ DrawWindow:
|
||||||
ldr r12, [sp] @ est
|
ldr r12, [sp] @ est
|
||||||
stmfd sp!, {r4-r11,lr}
|
stmfd sp!, {r4-r11,lr}
|
||||||
|
|
||||||
ldr r6, [r12, #OFS_Pico_video]
|
ldr r6, [r12, #OFS_EST_Pico]
|
||||||
ldr r10, [r12, #OFS_DrawScanline]
|
ldr r10, [r12, #OFS_EST_DrawScanline]
|
||||||
mov r11, r12 @ est
|
mov r11, r12 @ est
|
||||||
ldrb r12, [r6, #3] @ pvid->reg[3]
|
ldrb r12, [r6, #OFS_Pico_video_reg+3] @ pvid->reg[3]
|
||||||
|
|
||||||
ldr r4, [r6, #12]
|
ldr r4, [r6, #OFS_Pico_video_reg+12]
|
||||||
mov r5, r10, lsr #3
|
mov r5, r10, lsr #3
|
||||||
and r10, r10, #7
|
and r10, r10, #7
|
||||||
mov r10, r10, lsl #1 @ r10=ty
|
mov r10, r10, lsl #1 @ r10=ty
|
||||||
|
@ -1286,8 +1286,8 @@ DrawWindow:
|
||||||
addeq r12, r12, r5, lsl #6 @ nametab
|
addeq r12, r12, r5, lsl #6 @ nametab
|
||||||
add r12, r12, r0, lsl #2 @ +starttile
|
add r12, r12, r0, lsl #2 @ +starttile
|
||||||
|
|
||||||
ldr lr, [r11, #OFS_Pico_vram]
|
ldr lr, [r11, #OFS_EST_PicoMem_vram]
|
||||||
ldr r6, [r11, #OFS_rendstatus]
|
ldr r6, [r11, #OFS_EST_rendstatus]
|
||||||
|
|
||||||
@ fetch the first code now
|
@ fetch the first code now
|
||||||
ldrh r7, [lr, r12]
|
ldrh r7, [lr, r12]
|
||||||
|
@ -1304,7 +1304,7 @@ DrawWindow:
|
||||||
sub r8, r1, r0
|
sub r8, r1, r0
|
||||||
|
|
||||||
@ cache some stuff to avoid mem access
|
@ cache some stuff to avoid mem access
|
||||||
ldr r11, [r11, #OFS_HighCol]
|
ldr r11, [r11, #OFS_EST_HighCol]
|
||||||
mov r8, r8, lsl #1 @ cells
|
mov r8, r8, lsl #1 @ cells
|
||||||
add r11,r11,#8
|
add r11,r11,#8
|
||||||
mvn r9, #0 @ r9=prevcode=-1
|
mvn r9, #0 @ r9=prevcode=-1
|
||||||
|
@ -1392,9 +1392,9 @@ DrawWindow:
|
||||||
and r2, r6, #PDRAW_WND_DIFF_PRIO
|
and r2, r6, #PDRAW_WND_DIFF_PRIO
|
||||||
ldmfd sp!, {r4-r11,lr}
|
ldmfd sp!, {r4-r11,lr}
|
||||||
ldr r0, [sp]
|
ldr r0, [sp]
|
||||||
ldr r1, [r0, #OFS_rendstatus]
|
ldr r1, [r0, #OFS_EST_rendstatus]
|
||||||
orr r1, r1, r2
|
orr r1, r1, r2
|
||||||
str r1, [r0, #OFS_rendstatus]
|
str r1, [r0, #OFS_EST_rendstatus]
|
||||||
|
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
|
@ -1486,17 +1486,17 @@ PicoDoHighPal555:
|
||||||
stmfd sp!, {r4-r10,lr}
|
stmfd sp!, {r4-r10,lr}
|
||||||
mov r10,r2 @ est
|
mov r10,r2 @ est
|
||||||
mov r1, #0
|
mov r1, #0
|
||||||
ldr r8, [r10, #OFS_Pico_video]
|
ldr r8, [r10, #OFS_EST_Pico]
|
||||||
|
|
||||||
PicoDoHighPal555_nopush:
|
PicoDoHighPal555_nopush:
|
||||||
orr r9, r1, r0, lsl #31 @ 0:called from FinalizeLine555, 31: s/h
|
orr r9, r1, r0, lsl #31 @ 0:called from FinalizeLine555, 31: s/h
|
||||||
|
|
||||||
add r0, r10, #OFS_HighPal
|
add r0, r10, #OFS_EST_HighPal
|
||||||
|
|
||||||
mov r1, #0
|
mov r1, #0
|
||||||
strb r1, [r8, #-0x1a] @ 0x2220e ~ dirtyPal
|
strb r1, [r8, #OFS_Pico_m_dirtyPal]
|
||||||
|
|
||||||
sub r1, r8, #0x128 @ r1=Pico.cram
|
ldr r1, [r10, #OFS_EST_PicoMem_cram]
|
||||||
mov r2, #0x40
|
mov r2, #0x40
|
||||||
mov r8, #0x0061
|
mov r8, #0x0061
|
||||||
orr r8, r8, #0x0800
|
orr r8, r8, #0x0800
|
||||||
|
@ -1507,7 +1507,7 @@ PicoDoHighPal555_nopush:
|
||||||
tst r9, #(1<<31)
|
tst r9, #(1<<31)
|
||||||
beq PicoDoHighPal555_end
|
beq PicoDoHighPal555_end
|
||||||
|
|
||||||
add r3, r10, #OFS_HighPal
|
add r3, r10, #OFS_EST_HighPal
|
||||||
|
|
||||||
@ shadowed pixels:
|
@ shadowed pixels:
|
||||||
mov r12, #0x008e
|
mov r12, #0x008e
|
||||||
|
@ -1550,7 +1550,7 @@ PicoDoHighPal555_end:
|
||||||
tst r9, #1
|
tst r9, #1
|
||||||
ldmeqfd sp!, {r4-r10,pc}
|
ldmeqfd sp!, {r4-r10,pc}
|
||||||
|
|
||||||
ldr r8, [r10, #OFS_Pico_video]
|
ldr r8, [r10, #OFS_EST_Pico]
|
||||||
b FinalizeLineRGB555_pal_done
|
b FinalizeLineRGB555_pal_done
|
||||||
|
|
||||||
|
|
||||||
|
@ -1561,33 +1561,33 @@ PicoDoHighPal555_end:
|
||||||
FinalizeLine555:
|
FinalizeLine555:
|
||||||
stmfd sp!, {r4-r10,lr}
|
stmfd sp!, {r4-r10,lr}
|
||||||
mov r10,r2 @ est
|
mov r10,r2 @ est
|
||||||
ldr r8, [r10, #OFS_Pico_video]
|
ldr r8, [r10, #OFS_EST_Pico]
|
||||||
|
|
||||||
ldrb r2, [r8, #-0x1a] @ 0x2220e ~ dirtyPal
|
ldrb r2, [r8, #OFS_Pico_m_dirtyPal]
|
||||||
mov r1, #1
|
mov r1, #1
|
||||||
tst r2, r2
|
tst r2, r2
|
||||||
bne PicoDoHighPal555_nopush
|
bne PicoDoHighPal555_nopush
|
||||||
|
|
||||||
FinalizeLineRGB555_pal_done:
|
FinalizeLineRGB555_pal_done:
|
||||||
add r3, r10, #OFS_HighPal
|
add r3, r10, #OFS_EST_HighPal
|
||||||
|
|
||||||
ldr r12, [r10, #OFS_rendstatus]
|
ldr r12, [r10, #OFS_EST_rendstatus]
|
||||||
eors r0, r0, #1 @ sh is 0
|
eors r0, r0, #1 @ sh is 0
|
||||||
mov lr, #0xff
|
mov lr, #0xff
|
||||||
tstne r12,#PDRAW_ACC_SPRITES
|
tstne r12,#PDRAW_ACC_SPRITES
|
||||||
movne lr, #0x3f
|
movne lr, #0x3f
|
||||||
|
|
||||||
ldr r1, [r10, #OFS_HighCol]
|
ldr r1, [r10, #OFS_EST_HighCol]
|
||||||
ldr r0, [r10, #OFS_DrawLineDest]
|
ldr r0, [r10, #OFS_EST_DrawLineDest]
|
||||||
add r1, r1, #8
|
add r1, r1, #8
|
||||||
|
|
||||||
ldrb r12, [r8, #12]
|
ldrb r12, [r8, #OFS_Pico_video_reg+12]
|
||||||
mov lr, lr, lsl #1
|
mov lr, lr, lsl #1
|
||||||
|
|
||||||
tst r12, #1
|
tst r12, #1
|
||||||
movne r2, #320/8 @ len
|
movne r2, #320/8 @ len
|
||||||
bne .fl_no32colRGB555
|
bne .fl_no32colRGB555
|
||||||
ldr r4, [r10, #OFS_PicoOpt]
|
ldr r4, [r10, #OFS_EST_PicoOpt]
|
||||||
mov r2, #256/8
|
mov r2, #256/8
|
||||||
ldr r4, [r4]
|
ldr r4, [r4]
|
||||||
tst r4, #0x4000
|
tst r4, #0x4000
|
||||||
|
|
|
@ -42,14 +42,14 @@ static void EEPROM_write_do(unsigned int d) // ???? ??la (l=SCL, a=SDA)
|
||||||
{
|
{
|
||||||
// we are started and SCL went high - next cycle
|
// we are started and SCL went high - next cycle
|
||||||
scyc++; // pre-increment
|
scyc++; // pre-increment
|
||||||
if(SRam.eeprom_type) {
|
if(Pico.sv.eeprom_type) {
|
||||||
// X24C02+
|
// X24C02+
|
||||||
if((ssa&1) && scyc == 18) {
|
if((ssa&1) && scyc == 18) {
|
||||||
scyc = 9;
|
scyc = 9;
|
||||||
saddr++; // next address in read mode
|
saddr++; // next address in read mode
|
||||||
/*if(SRam.eeprom_type==2) saddr&=0xff; else*/ saddr&=0x1fff; // mask
|
/*if(Pico.sv.eeprom_type==2) saddr&=0xff; else*/ saddr&=0x1fff; // mask
|
||||||
}
|
}
|
||||||
else if(SRam.eeprom_type == 2 && scyc == 27) scyc = 18;
|
else if(Pico.sv.eeprom_type == 2 && scyc == 27) scyc = 18;
|
||||||
else if(scyc == 36) scyc = 27;
|
else if(scyc == 36) scyc = 27;
|
||||||
} else {
|
} else {
|
||||||
// X24C01
|
// X24C01
|
||||||
|
@ -63,29 +63,29 @@ static void EEPROM_write_do(unsigned int d) // ???? ??la (l=SCL, a=SDA)
|
||||||
else if((sreg & 8) && (sreg & 2) && !(d&2))
|
else if((sreg & 8) && (sreg & 2) && !(d&2))
|
||||||
{
|
{
|
||||||
// we are started and SCL went low (falling edge)
|
// we are started and SCL went low (falling edge)
|
||||||
if(SRam.eeprom_type) {
|
if(Pico.sv.eeprom_type) {
|
||||||
// X24C02+
|
// X24C02+
|
||||||
if(scyc == 9 || scyc == 18 || scyc == 27); // ACK cycles
|
if(scyc == 9 || scyc == 18 || scyc == 27); // ACK cycles
|
||||||
else if( (SRam.eeprom_type == 3 && scyc > 27) || (SRam.eeprom_type == 2 && scyc > 18) ) {
|
else if( (Pico.sv.eeprom_type == 3 && scyc > 27) || (Pico.sv.eeprom_type == 2 && scyc > 18) ) {
|
||||||
if(!(ssa&1)) {
|
if(!(ssa&1)) {
|
||||||
// data write
|
// data write
|
||||||
unsigned char *pm=SRam.data+saddr;
|
unsigned char *pm=Pico.sv.data+saddr;
|
||||||
*pm <<= 1; *pm |= d&1;
|
*pm <<= 1; *pm |= d&1;
|
||||||
if(scyc == 26 || scyc == 35) {
|
if(scyc == 26 || scyc == 35) {
|
||||||
saddr=(saddr&~0xf)|((saddr+1)&0xf); // only 4 (?) lowest bits are incremented
|
saddr=(saddr&~0xf)|((saddr+1)&0xf); // only 4 (?) lowest bits are incremented
|
||||||
elprintf(EL_EEPROM, "eeprom: write done, addr inc to: %x, last byte=%02x", saddr, *pm);
|
elprintf(EL_EEPROM, "eeprom: write done, addr inc to: %x, last byte=%02x", saddr, *pm);
|
||||||
}
|
}
|
||||||
SRam.changed = 1;
|
Pico.sv.changed = 1;
|
||||||
}
|
}
|
||||||
} else if(scyc > 9) {
|
} else if(scyc > 9) {
|
||||||
if(!(ssa&1)) {
|
if(!(ssa&1)) {
|
||||||
// we latch another addr bit
|
// we latch another addr bit
|
||||||
saddr<<=1;
|
saddr<<=1;
|
||||||
if(SRam.eeprom_type == 2) saddr&=0xff; else saddr&=0x1fff; // mask
|
if(Pico.sv.eeprom_type == 2) saddr&=0xff; else saddr&=0x1fff; // mask
|
||||||
saddr|=d&1;
|
saddr|=d&1;
|
||||||
if(scyc==17||scyc==26) {
|
if(scyc==17||scyc==26) {
|
||||||
elprintf(EL_EEPROM, "eeprom: addr reg done: %x", saddr);
|
elprintf(EL_EEPROM, "eeprom: addr reg done: %x", saddr);
|
||||||
if(scyc==17&&SRam.eeprom_type==2) { saddr&=0xff; saddr|=(ssa<<7)&0x700; } // add device bits too
|
if(scyc==17&&Pico.sv.eeprom_type==2) { saddr&=0xff; saddr|=(ssa<<7)&0x700; } // add device bits too
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -99,13 +99,13 @@ static void EEPROM_write_do(unsigned int d) // ???? ??la (l=SCL, a=SDA)
|
||||||
else if(scyc > 9) {
|
else if(scyc > 9) {
|
||||||
if(!(saddr&1)) {
|
if(!(saddr&1)) {
|
||||||
// data write
|
// data write
|
||||||
unsigned char *pm=SRam.data+(saddr>>1);
|
unsigned char *pm=Pico.sv.data+(saddr>>1);
|
||||||
*pm <<= 1; *pm |= d&1;
|
*pm <<= 1; *pm |= d&1;
|
||||||
if(scyc == 17) {
|
if(scyc == 17) {
|
||||||
saddr=(saddr&0xf9)|((saddr+2)&6); // only 2 lowest bits are incremented
|
saddr=(saddr&0xf9)|((saddr+2)&6); // only 2 lowest bits are incremented
|
||||||
elprintf(EL_EEPROM, "eeprom: write done, addr inc to: %x, last byte=%02x", saddr>>1, *pm);
|
elprintf(EL_EEPROM, "eeprom: write done, addr inc to: %x, last byte=%02x", saddr>>1, *pm);
|
||||||
}
|
}
|
||||||
SRam.changed = 1;
|
Pico.sv.changed = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// we latch another addr bit
|
// we latch another addr bit
|
||||||
|
@ -129,11 +129,11 @@ static void EEPROM_upd_pending(unsigned int d)
|
||||||
sreg &= ~0xc0;
|
sreg &= ~0xc0;
|
||||||
|
|
||||||
// SCL
|
// SCL
|
||||||
d1 = (d >> SRam.eeprom_bit_cl) & 1;
|
d1 = (d >> Pico.sv.eeprom_bit_cl) & 1;
|
||||||
sreg |= d1 << 7;
|
sreg |= d1 << 7;
|
||||||
|
|
||||||
// SDA in
|
// SDA in
|
||||||
d1 = (d >> SRam.eeprom_bit_in) & 1;
|
d1 = (d >> Pico.sv.eeprom_bit_in) & 1;
|
||||||
sreg |= d1 << 6;
|
sreg |= d1 << 6;
|
||||||
|
|
||||||
Pico.m.eeprom_status = (unsigned char) sreg;
|
Pico.m.eeprom_status = (unsigned char) sreg;
|
||||||
|
@ -190,23 +190,23 @@ unsigned int EEPROM_read(void)
|
||||||
} else if (scyc > 9 && scyc < 18) {
|
} else if (scyc > 9 && scyc < 18) {
|
||||||
// started and first command word received
|
// started and first command word received
|
||||||
shift = 17-scyc;
|
shift = 17-scyc;
|
||||||
if (SRam.eeprom_type) {
|
if (Pico.sv.eeprom_type) {
|
||||||
// X24C02+
|
// X24C02+
|
||||||
if (ssa&1) {
|
if (ssa&1) {
|
||||||
elprintf(EL_EEPROM, "eeprom: read: addr %02x, cycle %i, reg %02x", saddr, scyc, sreg);
|
elprintf(EL_EEPROM, "eeprom: read: addr %02x, cycle %i, reg %02x", saddr, scyc, sreg);
|
||||||
if (shift==0) elprintf(EL_EEPROM, "eeprom: read done, byte %02x", SRam.data[saddr]);
|
if (shift==0) elprintf(EL_EEPROM, "eeprom: read done, byte %02x", Pico.sv.data[saddr]);
|
||||||
d = (SRam.data[saddr]>>shift)&1;
|
d = (Pico.sv.data[saddr]>>shift)&1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// X24C01
|
// X24C01
|
||||||
if (saddr&1) {
|
if (saddr&1) {
|
||||||
elprintf(EL_EEPROM, "eeprom: read: addr %02x, cycle %i, reg %02x", saddr>>1, scyc, sreg);
|
elprintf(EL_EEPROM, "eeprom: read: addr %02x, cycle %i, reg %02x", saddr>>1, scyc, sreg);
|
||||||
if (shift==0) elprintf(EL_EEPROM, "eeprom: read done, byte %02x", SRam.data[saddr>>1]);
|
if (shift==0) elprintf(EL_EEPROM, "eeprom: read done, byte %02x", Pico.sv.data[saddr>>1]);
|
||||||
d = (SRam.data[saddr>>1]>>shift)&1;
|
d = (Pico.sv.data[saddr>>1]>>shift)&1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (d << SRam.eeprom_bit_out);
|
return (d << Pico.sv.eeprom_bit_out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -265,8 +265,8 @@ static port_read_func *port_readers[3] = {
|
||||||
|
|
||||||
static NOINLINE u32 port_read(int i)
|
static NOINLINE u32 port_read(int i)
|
||||||
{
|
{
|
||||||
u32 data_reg = Pico.ioports[i + 1];
|
u32 data_reg = PicoMem.ioports[i + 1];
|
||||||
u32 ctrl_reg = Pico.ioports[i + 4] | 0x80;
|
u32 ctrl_reg = PicoMem.ioports[i + 4] | 0x80;
|
||||||
u32 in, out;
|
u32 in, out;
|
||||||
|
|
||||||
out = data_reg & ctrl_reg;
|
out = data_reg & ctrl_reg;
|
||||||
|
@ -310,7 +310,7 @@ NOINLINE u32 io_ports_read(u32 a)
|
||||||
case 1: d = port_read(0); break;
|
case 1: d = port_read(0); break;
|
||||||
case 2: d = port_read(1); break;
|
case 2: d = port_read(1); break;
|
||||||
case 3: d = port_read(2); break;
|
case 3: d = port_read(2); break;
|
||||||
default: d = Pico.ioports[a]; break; // IO ports can be used as RAM
|
default: d = PicoMem.ioports[a]; break; // IO ports can be used as RAM
|
||||||
}
|
}
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
@ -323,17 +323,17 @@ NOINLINE void io_ports_write(u32 a, u32 d)
|
||||||
if (1 <= a && a <= 2)
|
if (1 <= a && a <= 2)
|
||||||
{
|
{
|
||||||
Pico.m.padDelay[a - 1] = 0;
|
Pico.m.padDelay[a - 1] = 0;
|
||||||
if (!(Pico.ioports[a] & 0x40) && (d & 0x40))
|
if (!(PicoMem.ioports[a] & 0x40) && (d & 0x40))
|
||||||
Pico.m.padTHPhase[a - 1]++;
|
Pico.m.padTHPhase[a - 1]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// certain IO ports can be used as RAM
|
// certain IO ports can be used as RAM
|
||||||
Pico.ioports[a] = d;
|
PicoMem.ioports[a] = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int z80_cycles_from_68k(void)
|
static int z80_cycles_from_68k(void)
|
||||||
{
|
{
|
||||||
int m68k_cnt = SekCyclesDone() - timing.m68c_frame_start;
|
int m68k_cnt = SekCyclesDone() - Pico.t.m68c_frame_start;
|
||||||
return cycles_68k_to_z80(m68k_cnt);
|
return cycles_68k_to_z80(m68k_cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ void NOINLINE ctl_write_z80busreq(u32 d)
|
||||||
{
|
{
|
||||||
if (d)
|
if (d)
|
||||||
{
|
{
|
||||||
timing.z80c_cnt = z80_cycles_from_68k() + 2;
|
Pico.t.z80c_cnt = z80_cycles_from_68k() + 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -377,7 +377,7 @@ void NOINLINE ctl_write_z80reset(u32 d)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
timing.z80c_cnt = z80_cycles_from_68k() + 2;
|
Pico.t.z80c_cnt = z80_cycles_from_68k() + 2;
|
||||||
z80_reset();
|
z80_reset();
|
||||||
}
|
}
|
||||||
Pico.m.z80_reset = d;
|
Pico.m.z80_reset = d;
|
||||||
|
@ -414,14 +414,14 @@ static void psg_write_z80(u32 d)
|
||||||
static u32 PicoRead8_sram(u32 a)
|
static u32 PicoRead8_sram(u32 a)
|
||||||
{
|
{
|
||||||
u32 d;
|
u32 d;
|
||||||
if (SRam.start <= a && a <= SRam.end && (Pico.m.sram_reg & SRR_MAPPED))
|
if (Pico.sv.start <= a && a <= Pico.sv.end && (Pico.m.sram_reg & SRR_MAPPED))
|
||||||
{
|
{
|
||||||
if (SRam.flags & SRF_EEPROM) {
|
if (Pico.sv.flags & SRF_EEPROM) {
|
||||||
d = EEPROM_read();
|
d = EEPROM_read();
|
||||||
if (!(a & 1))
|
if (!(a & 1))
|
||||||
d >>= 8;
|
d >>= 8;
|
||||||
} else
|
} else
|
||||||
d = *(u8 *)(SRam.data - SRam.start + a);
|
d = *(u8 *)(Pico.sv.data - Pico.sv.start + a);
|
||||||
elprintf(EL_SRAMIO, "sram r8 [%06x] %02x @ %06x", a, d, SekPc);
|
elprintf(EL_SRAMIO, "sram r8 [%06x] %02x @ %06x", a, d, SekPc);
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
@ -436,12 +436,12 @@ static u32 PicoRead8_sram(u32 a)
|
||||||
static u32 PicoRead16_sram(u32 a)
|
static u32 PicoRead16_sram(u32 a)
|
||||||
{
|
{
|
||||||
u32 d;
|
u32 d;
|
||||||
if (SRam.start <= a && a <= SRam.end && (Pico.m.sram_reg & SRR_MAPPED))
|
if (Pico.sv.start <= a && a <= Pico.sv.end && (Pico.m.sram_reg & SRR_MAPPED))
|
||||||
{
|
{
|
||||||
if (SRam.flags & SRF_EEPROM)
|
if (Pico.sv.flags & SRF_EEPROM)
|
||||||
d = EEPROM_read();
|
d = EEPROM_read();
|
||||||
else {
|
else {
|
||||||
u8 *pm = (u8 *)(SRam.data - SRam.start + a);
|
u8 *pm = (u8 *)(Pico.sv.data - Pico.sv.start + a);
|
||||||
d = pm[0] << 8;
|
d = pm[0] << 8;
|
||||||
d |= pm[1];
|
d |= pm[1];
|
||||||
}
|
}
|
||||||
|
@ -459,20 +459,20 @@ static u32 PicoRead16_sram(u32 a)
|
||||||
|
|
||||||
static void PicoWrite8_sram(u32 a, u32 d)
|
static void PicoWrite8_sram(u32 a, u32 d)
|
||||||
{
|
{
|
||||||
if (a > SRam.end || a < SRam.start || !(Pico.m.sram_reg & SRR_MAPPED)) {
|
if (a > Pico.sv.end || a < Pico.sv.start || !(Pico.m.sram_reg & SRR_MAPPED)) {
|
||||||
m68k_unmapped_write8(a, d);
|
m68k_unmapped_write8(a, d);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
elprintf(EL_SRAMIO, "sram w8 [%06x] %02x @ %06x", a, d & 0xff, SekPc);
|
elprintf(EL_SRAMIO, "sram w8 [%06x] %02x @ %06x", a, d & 0xff, SekPc);
|
||||||
if (SRam.flags & SRF_EEPROM)
|
if (Pico.sv.flags & SRF_EEPROM)
|
||||||
{
|
{
|
||||||
EEPROM_write8(a, d);
|
EEPROM_write8(a, d);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
u8 *pm = (u8 *)(SRam.data - SRam.start + a);
|
u8 *pm = (u8 *)(Pico.sv.data - Pico.sv.start + a);
|
||||||
if (*pm != (u8)d) {
|
if (*pm != (u8)d) {
|
||||||
SRam.changed = 1;
|
Pico.sv.changed = 1;
|
||||||
*pm = (u8)d;
|
*pm = (u8)d;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -480,24 +480,24 @@ static void PicoWrite8_sram(u32 a, u32 d)
|
||||||
|
|
||||||
static void PicoWrite16_sram(u32 a, u32 d)
|
static void PicoWrite16_sram(u32 a, u32 d)
|
||||||
{
|
{
|
||||||
if (a > SRam.end || a < SRam.start || !(Pico.m.sram_reg & SRR_MAPPED)) {
|
if (a > Pico.sv.end || a < Pico.sv.start || !(Pico.m.sram_reg & SRR_MAPPED)) {
|
||||||
m68k_unmapped_write16(a, d);
|
m68k_unmapped_write16(a, d);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
elprintf(EL_SRAMIO, "sram w16 [%06x] %04x @ %06x", a, d & 0xffff, SekPc);
|
elprintf(EL_SRAMIO, "sram w16 [%06x] %04x @ %06x", a, d & 0xffff, SekPc);
|
||||||
if (SRam.flags & SRF_EEPROM)
|
if (Pico.sv.flags & SRF_EEPROM)
|
||||||
{
|
{
|
||||||
EEPROM_write16(d);
|
EEPROM_write16(d);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
u8 *pm = (u8 *)(SRam.data - SRam.start + a);
|
u8 *pm = (u8 *)(Pico.sv.data - Pico.sv.start + a);
|
||||||
if (pm[0] != (u8)(d >> 8)) {
|
if (pm[0] != (u8)(d >> 8)) {
|
||||||
SRam.changed = 1;
|
Pico.sv.changed = 1;
|
||||||
pm[0] = (u8)(d >> 8);
|
pm[0] = (u8)(d >> 8);
|
||||||
}
|
}
|
||||||
if (pm[1] != (u8)d) {
|
if (pm[1] != (u8)d) {
|
||||||
SRam.changed = 1;
|
Pico.sv.changed = 1;
|
||||||
pm[1] = (u8)d;
|
pm[1] = (u8)d;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -515,7 +515,7 @@ static u32 PicoRead8_z80(u32 a)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((a & 0x4000) == 0x0000)
|
if ((a & 0x4000) == 0x0000)
|
||||||
d = Pico.zram[a & 0x1fff];
|
d = PicoMem.zram[a & 0x1fff];
|
||||||
else if ((a & 0x6000) == 0x4000) // 0x4000-0x5fff
|
else if ((a & 0x6000) == 0x4000) // 0x4000-0x5fff
|
||||||
d = ym2612_read_local_68k();
|
d = ym2612_read_local_68k();
|
||||||
else
|
else
|
||||||
|
@ -538,7 +538,7 @@ static void PicoWrite8_z80(u32 a, u32 d)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((a & 0x4000) == 0x0000) { // z80 RAM
|
if ((a & 0x4000) == 0x0000) { // z80 RAM
|
||||||
Pico.zram[a & 0x1fff] = (u8)d;
|
PicoMem.zram[a & 0x1fff] = (u8)d;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((a & 0x6000) == 0x4000) { // FM Sound
|
if ((a & 0x6000) == 0x4000) { // FM Sound
|
||||||
|
@ -765,7 +765,7 @@ static void m68k_mem_setup(void);
|
||||||
|
|
||||||
PICO_INTERNAL void PicoMemSetup(void)
|
PICO_INTERNAL void PicoMemSetup(void)
|
||||||
{
|
{
|
||||||
int mask, rs, a;
|
int mask, rs, sstart, a;
|
||||||
|
|
||||||
// setup the memory map
|
// setup the memory map
|
||||||
cpu68k_map_set(m68k_read8_map, 0x000000, 0xffffff, m68k_unmapped_read8, 1);
|
cpu68k_map_set(m68k_read8_map, 0x000000, 0xffffff, m68k_unmapped_read8, 1);
|
||||||
|
@ -781,15 +781,16 @@ PICO_INTERNAL void PicoMemSetup(void)
|
||||||
cpu68k_map_set(m68k_read16_map, 0x000000, rs - 1, Pico.rom, 0);
|
cpu68k_map_set(m68k_read16_map, 0x000000, rs - 1, Pico.rom, 0);
|
||||||
|
|
||||||
// Common case of on-cart (save) RAM, usually at 0x200000-...
|
// Common case of on-cart (save) RAM, usually at 0x200000-...
|
||||||
if ((SRam.flags & SRF_ENABLED) && SRam.data != NULL) {
|
if ((Pico.sv.flags & SRF_ENABLED) && Pico.sv.data != NULL) {
|
||||||
rs = SRam.end - SRam.start;
|
sstart = Pico.sv.start;
|
||||||
|
rs = Pico.sv.end - sstart;
|
||||||
rs = (rs + mask) & ~mask;
|
rs = (rs + mask) & ~mask;
|
||||||
if (SRam.start + rs >= 0x1000000)
|
if (sstart + rs >= 0x1000000)
|
||||||
rs = 0x1000000 - SRam.start;
|
rs = 0x1000000 - sstart;
|
||||||
cpu68k_map_set(m68k_read8_map, SRam.start, SRam.start + rs - 1, PicoRead8_sram, 1);
|
cpu68k_map_set(m68k_read8_map, sstart, sstart + rs - 1, PicoRead8_sram, 1);
|
||||||
cpu68k_map_set(m68k_read16_map, SRam.start, SRam.start + rs - 1, PicoRead16_sram, 1);
|
cpu68k_map_set(m68k_read16_map, sstart, sstart + rs - 1, PicoRead16_sram, 1);
|
||||||
cpu68k_map_set(m68k_write8_map, SRam.start, SRam.start + rs - 1, PicoWrite8_sram, 1);
|
cpu68k_map_set(m68k_write8_map, sstart, sstart + rs - 1, PicoWrite8_sram, 1);
|
||||||
cpu68k_map_set(m68k_write16_map, SRam.start, SRam.start + rs - 1, PicoWrite16_sram, 1);
|
cpu68k_map_set(m68k_write16_map, sstart, sstart + rs - 1, PicoWrite16_sram, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Z80 region
|
// Z80 region
|
||||||
|
@ -816,10 +817,10 @@ PICO_INTERNAL void PicoMemSetup(void)
|
||||||
|
|
||||||
// RAM and it's mirrors
|
// RAM and it's mirrors
|
||||||
for (a = 0xe00000; a < 0x1000000; a += 0x010000) {
|
for (a = 0xe00000; a < 0x1000000; a += 0x010000) {
|
||||||
cpu68k_map_set(m68k_read8_map, a, a + 0xffff, Pico.ram, 0);
|
cpu68k_map_set(m68k_read8_map, a, a + 0xffff, PicoMem.ram, 0);
|
||||||
cpu68k_map_set(m68k_read16_map, a, a + 0xffff, Pico.ram, 0);
|
cpu68k_map_set(m68k_read16_map, a, a + 0xffff, PicoMem.ram, 0);
|
||||||
cpu68k_map_set(m68k_write8_map, a, a + 0xffff, Pico.ram, 0);
|
cpu68k_map_set(m68k_write8_map, a, a + 0xffff, PicoMem.ram, 0);
|
||||||
cpu68k_map_set(m68k_write16_map, a, a + 0xffff, Pico.ram, 0);
|
cpu68k_map_set(m68k_write16_map, a, a + 0xffff, PicoMem.ram, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup memory callbacks:
|
// Setup memory callbacks:
|
||||||
|
@ -896,10 +897,10 @@ static int get_scanline(int is_from_z80)
|
||||||
{
|
{
|
||||||
if (is_from_z80) {
|
if (is_from_z80) {
|
||||||
int mclk_z80 = z80_cyclesDone() * 15;
|
int mclk_z80 = z80_cyclesDone() * 15;
|
||||||
int mclk_line = timing.z80_scanline * 488 * 7;
|
int mclk_line = Pico.t.z80_scanline * 488 * 7;
|
||||||
while (mclk_z80 - mclk_line >= 488 * 7)
|
while (mclk_z80 - mclk_line >= 488 * 7)
|
||||||
timing.z80_scanline++, mclk_line += 488 * 7;
|
Pico.t.z80_scanline++, mclk_line += 488 * 7;
|
||||||
return timing.z80_scanline;
|
return Pico.t.z80_scanline;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Pico.m.scanline;
|
return Pico.m.scanline;
|
||||||
|
@ -1282,14 +1283,14 @@ static void z80_md_out(unsigned short p, unsigned char d)
|
||||||
|
|
||||||
static void z80_mem_setup(void)
|
static void z80_mem_setup(void)
|
||||||
{
|
{
|
||||||
z80_map_set(z80_read_map, 0x0000, 0x1fff, Pico.zram, 0);
|
z80_map_set(z80_read_map, 0x0000, 0x1fff, PicoMem.zram, 0);
|
||||||
z80_map_set(z80_read_map, 0x2000, 0x3fff, Pico.zram, 0);
|
z80_map_set(z80_read_map, 0x2000, 0x3fff, PicoMem.zram, 0);
|
||||||
z80_map_set(z80_read_map, 0x4000, 0x5fff, ym2612_read_local_z80, 1);
|
z80_map_set(z80_read_map, 0x4000, 0x5fff, ym2612_read_local_z80, 1);
|
||||||
z80_map_set(z80_read_map, 0x6000, 0x7fff, z80_md_vdp_read, 1);
|
z80_map_set(z80_read_map, 0x6000, 0x7fff, z80_md_vdp_read, 1);
|
||||||
z80_map_set(z80_read_map, 0x8000, 0xffff, z80_md_bank_read, 1);
|
z80_map_set(z80_read_map, 0x8000, 0xffff, z80_md_bank_read, 1);
|
||||||
|
|
||||||
z80_map_set(z80_write_map, 0x0000, 0x1fff, Pico.zram, 0);
|
z80_map_set(z80_write_map, 0x0000, 0x1fff, PicoMem.zram, 0);
|
||||||
z80_map_set(z80_write_map, 0x2000, 0x3fff, Pico.zram, 0);
|
z80_map_set(z80_write_map, 0x2000, 0x3fff, PicoMem.zram, 0);
|
||||||
z80_map_set(z80_write_map, 0x4000, 0x5fff, z80_md_ym2612_write, 1);
|
z80_map_set(z80_write_map, 0x4000, 0x5fff, z80_md_ym2612_write, 1);
|
||||||
z80_map_set(z80_write_map, 0x6000, 0x7fff, z80_md_vdp_br_write, 1);
|
z80_map_set(z80_write_map, 0x6000, 0x7fff, z80_md_vdp_br_write, 1);
|
||||||
z80_map_set(z80_write_map, 0x8000, 0xffff, z80_md_bank_write, 1);
|
z80_map_set(z80_write_map, 0x8000, 0xffff, z80_md_bank_write, 1);
|
||||||
|
@ -1299,8 +1300,8 @@ static void z80_mem_setup(void)
|
||||||
drZ80.z80_out = z80_md_out;
|
drZ80.z80_out = z80_md_out;
|
||||||
#endif
|
#endif
|
||||||
#ifdef _USE_CZ80
|
#ifdef _USE_CZ80
|
||||||
Cz80_Set_Fetch(&CZ80, 0x0000, 0x1fff, (FPTR)Pico.zram); // main RAM
|
Cz80_Set_Fetch(&CZ80, 0x0000, 0x1fff, (FPTR)PicoMem.zram); // main RAM
|
||||||
Cz80_Set_Fetch(&CZ80, 0x2000, 0x3fff, (FPTR)Pico.zram); // mirror
|
Cz80_Set_Fetch(&CZ80, 0x2000, 0x3fff, (FPTR)PicoMem.zram); // mirror
|
||||||
Cz80_Set_INPort(&CZ80, z80_md_in);
|
Cz80_Set_INPort(&CZ80, z80_md_in);
|
||||||
Cz80_Set_OUTPort(&CZ80, z80_md_out);
|
Cz80_Set_OUTPort(&CZ80, z80_md_out);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
|
|
||||||
# OUT OF DATE
|
# OUT OF DATE
|
||||||
|
|
||||||
|
#include "pico_int_o32.h"
|
||||||
|
|
||||||
.set noreorder
|
.set noreorder
|
||||||
.set noat
|
.set noat
|
||||||
|
|
||||||
|
@ -184,8 +186,8 @@ m_read32_table:
|
||||||
|
|
||||||
|
|
||||||
PicoMemReset:
|
PicoMemReset:
|
||||||
lui $v1, %hi(Pico+0x22204)
|
lui $v1, %hi(Pico+OFS_Pico_romsize)
|
||||||
lw $v1, %lo(Pico+0x22204)($v1) # romsize
|
lw $v1, %lo(Pico+OFS_Pico_romsize)($v1) # romsize
|
||||||
lui $t0, 8
|
lui $t0, 8
|
||||||
addu $v1, $t0
|
addu $v1, $t0
|
||||||
addiu $v1, -1
|
addiu $v1, -1
|
||||||
|
@ -235,12 +237,11 @@ m_read_neg1:
|
||||||
jr $ra
|
jr $ra
|
||||||
addiu $v0, $0, 0xffff
|
addiu $v0, $0, 0xffff
|
||||||
|
|
||||||
# loads &Pico.rom to $t3
|
# loads &Pico to $t3
|
||||||
.macro m_read_rom_try_sram is200000 size
|
.macro m_read_rom_try_sram is200000 size
|
||||||
lui $t2, %hi(SRam)
|
lui $t2, %hi(Pico)
|
||||||
addiu $t2, %lo(SRam)
|
addiu $t2, %lo(Pico)
|
||||||
lui $t3, %hi(Pico+0x22200)
|
lw $t1, OFS_Pico_sv_end($t2)
|
||||||
lw $t1, 8($t2) # SRam.end
|
|
||||||
.if \is200000
|
.if \is200000
|
||||||
ins $a0, $0, 19, 13
|
ins $a0, $0, 19, 13
|
||||||
lui $t4, 0x20
|
lui $t4, 0x20
|
||||||
|
@ -248,12 +249,11 @@ m_read_neg1:
|
||||||
.endif
|
.endif
|
||||||
subu $t4, $a0, $t1
|
subu $t4, $a0, $t1
|
||||||
bgtz $t4, 1f
|
bgtz $t4, 1f
|
||||||
addiu $t3, %lo(Pico+0x22200)
|
lw $t1, OFS_Pico_sv_start($t2)
|
||||||
lw $t1, 4($t2) # SRam.start
|
|
||||||
subu $t4, $t1, $a0
|
subu $t4, $t1, $a0
|
||||||
bgtz $t4, 1f
|
bgtz $t4, 1f
|
||||||
nop
|
nop
|
||||||
lb $t1, 0x11($t3) # Pico.m.sram_reg
|
lb $t1, OFS_Pico_m_sram_reg($t2)
|
||||||
andi $t4, $t1, 5
|
andi $t4, $t1, 5
|
||||||
beqz $t4, 1f
|
beqz $t4, 1f
|
||||||
nop
|
nop
|
||||||
|
@ -288,8 +288,8 @@ m_read_neg1:
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro m_read8_rom sect
|
.macro m_read8_rom sect
|
||||||
lui $t0, %hi(Pico+0x22200)
|
lui $t0, %hi(Pico+OFS_Pico_rom)
|
||||||
lw $t0, %lo(Pico+0x22200)($t0) # rom
|
lw $t0, %lo(Pico+OFS_Pico_rom)($t0) # rom
|
||||||
xori $a0, 1
|
xori $a0, 1
|
||||||
ins $a0, $0, 19, 13
|
ins $a0, $0, 19, 13
|
||||||
.if \sect
|
.if \sect
|
||||||
|
@ -388,15 +388,15 @@ m_read8_misc_io:
|
||||||
nop
|
nop
|
||||||
|
|
||||||
m_read8_misc_hwreg:
|
m_read8_misc_hwreg:
|
||||||
lui $v0, %hi(Pico+0x2220f)
|
lui $v0, %hi(Pico+OFS_Pico_m_hardware)
|
||||||
jr $ra
|
jr $ra
|
||||||
lb $v0, %lo(Pico+0x2220f)($v0)
|
lb $v0, %lo(Pico+OFS_Pico_m_hardware)($v0)
|
||||||
|
|
||||||
m_read8_misc_ioports:
|
m_read8_misc_ioports:
|
||||||
lui $v0, %hi(Pico+0x22000)
|
lui $v0, %hi(PicoMem+0x22000)
|
||||||
ins $v0, $t0, 0, 5
|
ins $v0, $t0, 0, 5
|
||||||
jr $ra
|
jr $ra
|
||||||
lb $v0, %lo(Pico+0x22000)($v0)
|
lb $v0, %lo(PicoMem+0x22000)($v0)
|
||||||
|
|
||||||
m_read8_misc2:
|
m_read8_misc2:
|
||||||
lui $t0, 0xa1
|
lui $t0, 0xa1
|
||||||
|
@ -423,10 +423,10 @@ m_read8_z80_misc:
|
||||||
nop
|
nop
|
||||||
|
|
||||||
m_read8_fake_ym2612:
|
m_read8_fake_ym2612:
|
||||||
lb $v0, %lo(Pico+0x22208)($t0) # Pico.m.rotate
|
lb $v0, %lo(Pico+OFS_Pico_m_rotate)($t0)
|
||||||
addiu $t1, $v0, 1
|
addiu $t1, $v0, 1
|
||||||
jr $ra
|
jr $ra
|
||||||
sb $t1, %lo(Pico+0x22208)($t0)
|
sb $t1, %lo(Pico+OFS_Pico_m_rotate)($t0)
|
||||||
|
|
||||||
# delay slot friendly
|
# delay slot friendly
|
||||||
.macro m_read8_call16 funcname is_func_ptr=0
|
.macro m_read8_call16 funcname is_func_ptr=0
|
||||||
|
@ -472,11 +472,11 @@ m_read8_vdp:
|
||||||
nop
|
nop
|
||||||
|
|
||||||
m_read8_ram:
|
m_read8_ram:
|
||||||
lui $t0, %hi(Pico)
|
lui $t0, %hi(PicoMem)
|
||||||
ins $t0, $a0, 0, 16
|
ins $t0, $a0, 0, 16
|
||||||
xori $t0, 1
|
xori $t0, 1
|
||||||
jr $ra
|
jr $ra
|
||||||
lb $v0, %lo(Pico)($t0)
|
lb $v0, %lo(PicoMem)($t0)
|
||||||
|
|
||||||
m_read8_above_rom:
|
m_read8_above_rom:
|
||||||
# might still be SRam (Micro Machines, HardBall '95)
|
# might still be SRam (Micro Machines, HardBall '95)
|
||||||
|
@ -486,8 +486,8 @@ m_read8_above_rom:
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
|
||||||
.macro m_read16_rom sect
|
.macro m_read16_rom sect
|
||||||
lui $t0, %hi(Pico+0x22200)
|
lui $t0, %hi(Pico+OFS_Pico_rom)
|
||||||
lw $t0, %lo(Pico+0x22200)($t0) # rom
|
lw $t0, %lo(Pico+OFS_Pico_rom)($t0) # rom
|
||||||
ins $a0, $0, 0, 1
|
ins $a0, $0, 0, 1
|
||||||
ins $a0, $0, 19, 13
|
ins $a0, $0, 19, 13
|
||||||
.if \sect
|
.if \sect
|
||||||
|
@ -583,11 +583,11 @@ m_read16_vdp:
|
||||||
nop
|
nop
|
||||||
|
|
||||||
m_read16_ram:
|
m_read16_ram:
|
||||||
lui $t0, %hi(Pico)
|
lui $t0, %hi(PicoMem)
|
||||||
ins $a0, $0, 0, 1
|
ins $a0, $0, 0, 1
|
||||||
ins $t0, $a0, 0, 16
|
ins $t0, $a0, 0, 16
|
||||||
jr $ra
|
jr $ra
|
||||||
lh $v0, %lo(Pico)($t0)
|
lh $v0, %lo(PicoMem)($t0)
|
||||||
|
|
||||||
m_read16_above_rom:
|
m_read16_above_rom:
|
||||||
# might still be SRam
|
# might still be SRam
|
||||||
|
@ -600,8 +600,8 @@ m_read16_above_rom:
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
|
||||||
.macro m_read32_rom sect
|
.macro m_read32_rom sect
|
||||||
lui $t0, %hi(Pico+0x22200)
|
lui $t0, %hi(Pico+OFS_Pico_rom)
|
||||||
lw $t0, %lo(Pico+0x22200)($t0) # rom
|
lw $t0, %lo(Pico+OFS_Pico_rom)($t0) # rom
|
||||||
ins $a0, $0, 0, 1
|
ins $a0, $0, 0, 1
|
||||||
ins $a0, $0, 19, 13
|
ins $a0, $0, 19, 13
|
||||||
.if \sect
|
.if \sect
|
||||||
|
@ -723,11 +723,11 @@ m_read32_vdp:
|
||||||
m_read32_call16 PicoVideoRead
|
m_read32_call16 PicoVideoRead
|
||||||
|
|
||||||
m_read32_ram:
|
m_read32_ram:
|
||||||
lui $t0, %hi(Pico)
|
lui $t0, %hi(PicoMem)
|
||||||
ins $a0, $0, 0, 1
|
ins $a0, $0, 0, 1
|
||||||
ins $t0, $a0, 0, 16
|
ins $t0, $a0, 0, 16
|
||||||
lh $v1, %lo(Pico)($t0)
|
lh $v1, %lo(PicoMem)($t0)
|
||||||
lh $v0, %lo(Pico+2)($t0)
|
lh $v0, %lo(PicoMem+2)($t0)
|
||||||
jr $ra
|
jr $ra
|
||||||
ins $v0, $v1, 16, 16
|
ins $v0, $v1, 16, 16
|
||||||
|
|
||||||
|
@ -771,11 +771,11 @@ PicoWriteRomHW_SSF2: # u32 a, u32 d
|
||||||
bnez $a0, pwr_banking
|
bnez $a0, pwr_banking
|
||||||
|
|
||||||
# sram register
|
# sram register
|
||||||
lui $t0, %hi(Pico+0x22211)
|
lui $t0, %hi(Pico+OFS_Pico_m_sram_reg)
|
||||||
lb $t1, %lo(Pico+0x22211)($t0) # Pico.m.sram_reg
|
lb $t1, %lo(Pico+OFS_Pico_m_sram_reg)($t0) # Pico.m.sram_reg
|
||||||
ins $t1, $a1, 0, 2
|
ins $t1, $a1, 0, 2
|
||||||
jr $ra
|
jr $ra
|
||||||
sb $t1, %lo(Pico+0x22211)($t0)
|
sb $t1, %lo(Pico+OFS_Pico_m_sram_reg)($t0)
|
||||||
|
|
||||||
pwr_banking:
|
pwr_banking:
|
||||||
andi $a1, 0x1f
|
andi $a1, 0x1f
|
|
@ -6,6 +6,8 @@
|
||||||
* See COPYING file in the top-level directory.
|
* See COPYING file in the top-level directory.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "pico_int_o32.h"
|
||||||
|
|
||||||
.equ SRR_MAPPED, (1 << 0)
|
.equ SRR_MAPPED, (1 << 0)
|
||||||
.equ SRR_READONLY, (1 << 1)
|
.equ SRR_READONLY, (1 << 1)
|
||||||
.equ SRF_EEPROM, (1 << 1)
|
.equ SRF_EEPROM, (1 << 1)
|
||||||
|
@ -21,35 +23,32 @@
|
||||||
.global PicoWrite8_io
|
.global PicoWrite8_io
|
||||||
.global PicoWrite16_io
|
.global PicoWrite16_io
|
||||||
|
|
||||||
PicoRead8_sram: @ u32 a, u32 d
|
PicoRead8_sram: @ u32 a
|
||||||
ldr r2, =(SRam)
|
ldr r3, =Pico
|
||||||
ldr r3, =(Pico+0x22200)
|
ldr r1, [r3, #OFS_Pico_sv_end]
|
||||||
ldr r1, [r2, #8] @ SRam.end
|
|
||||||
cmp r0, r1
|
cmp r0, r1
|
||||||
bgt m_read8_nosram
|
bgt m_read8_nosram
|
||||||
ldr r1, [r2, #4] @ SRam.start
|
ldr r2, [r3, #OFS_Pico_sv_start]
|
||||||
cmp r0, r1
|
cmp r0, r2
|
||||||
blt m_read8_nosram
|
blt m_read8_nosram
|
||||||
ldrb r1, [r3, #0x11] @ Pico.m.sram_reg
|
ldrb r1, [r3, #OFS_Pico_m_sram_reg]
|
||||||
tst r1, #SRR_MAPPED
|
tst r1, #SRR_MAPPED
|
||||||
beq m_read8_nosram
|
beq m_read8_nosram
|
||||||
ldr r1, [r2, #0x0c]
|
ldr r1, [r3, #OFS_Pico_sv_flags]
|
||||||
tst r1, #SRF_EEPROM
|
tst r1, #SRF_EEPROM
|
||||||
bne m_read8_eeprom
|
bne m_read8_eeprom
|
||||||
ldr r1, [r2, #4] @ SRam.start
|
ldr r1, [r3, #OFS_Pico_sv_data]
|
||||||
ldr r2, [r2] @ SRam.data
|
sub r0, r0, r2
|
||||||
sub r0, r0, r1
|
ldrb r0, [r0, r1]
|
||||||
add r0, r0, r2
|
|
||||||
ldrb r0, [r0]
|
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
m_read8_nosram:
|
m_read8_nosram:
|
||||||
ldr r1, [r3, #4] @ romsize
|
ldr r1, [r3, #OFS_Pico_romsize]
|
||||||
cmp r0, r1
|
cmp r0, r1
|
||||||
movgt r0, #0
|
movgt r0, #0
|
||||||
bxgt lr @ bad location
|
bxgt lr @ bad location
|
||||||
@ XXX: banking unfriendly
|
@ XXX: banking unfriendly
|
||||||
ldr r1, [r3]
|
ldr r1, [r3, #OFS_Pico_rom]
|
||||||
eor r0, r0, #1
|
eor r0, r0, #1
|
||||||
ldrb r0, [r1, r0]
|
ldrb r0, [r1, r0]
|
||||||
bx lr
|
bx lr
|
||||||
|
@ -63,7 +62,7 @@ m_read8_eeprom:
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
|
|
||||||
PicoRead8_io: @ u32 a, u32 d
|
PicoRead8_io: @ u32 a
|
||||||
bic r2, r0, #0x001f @ most commonly we get i/o port read,
|
bic r2, r0, #0x001f @ most commonly we get i/o port read,
|
||||||
cmp r2, #0xa10000 @ so check for it first
|
cmp r2, #0xa10000 @ so check for it first
|
||||||
beq io_ports_read
|
beq io_ports_read
|
||||||
|
@ -73,11 +72,11 @@ m_read8_not_io:
|
||||||
cmp r2, #0x1000
|
cmp r2, #0x1000
|
||||||
bne m_read8_not_brq
|
bne m_read8_not_brq
|
||||||
|
|
||||||
ldr r3, =(Pico+0x22200)
|
ldr r3, =Pico
|
||||||
mov r1, r0
|
mov r1, r0
|
||||||
ldr r0, [r3, #8] @ Pico.m.rotate
|
ldr r0, [r3, #OFS_Pico_m_rotate]
|
||||||
add r0, r0, #1
|
add r0, r0, #1
|
||||||
strb r0, [r3, #8]
|
strb r0, [r3, #OFS_Pico_m_rotate]
|
||||||
eor r0, r0, r0, lsl #6
|
eor r0, r0, r0, lsl #6
|
||||||
|
|
||||||
tst r1, #1
|
tst r1, #1
|
||||||
|
@ -87,8 +86,8 @@ m_read8_not_io:
|
||||||
cmp r2, #0x1100
|
cmp r2, #0x1100
|
||||||
bxne lr @ not busreq
|
bxne lr @ not busreq
|
||||||
|
|
||||||
ldrb r1, [r3, #(8+0x01)] @ Pico.m.z80Run
|
ldrb r1, [r3, #OFS_Pico_m_z80Run]
|
||||||
ldrb r2, [r3, #(8+0x0f)] @ Pico.m.z80_reset
|
ldrb r2, [r3, #OFS_Pico_m_z80_reset]
|
||||||
orr r0, r0, r1
|
orr r0, r0, r1
|
||||||
orr r0, r0, r2
|
orr r0, r0, r2
|
||||||
bx lr
|
bx lr
|
||||||
|
@ -104,36 +103,33 @@ m_read8_not_brq:
|
||||||
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||||
|
|
||||||
PicoRead16_sram: @ u32 a, u32 d
|
PicoRead16_sram: @ u32 a, u32 d
|
||||||
ldr r2, =(SRam)
|
ldr r3, =Pico
|
||||||
ldr r3, =(Pico+0x22200)
|
ldr r1, [r3, #OFS_Pico_sv_end]
|
||||||
ldr r1, [r2, #8] @ SRam.end
|
|
||||||
cmp r0, r1
|
cmp r0, r1
|
||||||
bgt m_read16_nosram
|
bgt m_read16_nosram
|
||||||
ldr r1, [r2, #4] @ SRam.start
|
ldr r2, [r3, #OFS_Pico_sv_start]
|
||||||
cmp r0, r1
|
cmp r0, r2
|
||||||
blt m_read16_nosram
|
blt m_read16_nosram
|
||||||
ldrb r1, [r3, #0x11] @ Pico.m.sram_reg
|
ldrb r1, [r3, #OFS_Pico_m_sram_reg]
|
||||||
tst r1, #SRR_MAPPED
|
tst r1, #SRR_MAPPED
|
||||||
beq m_read16_nosram
|
beq m_read16_nosram
|
||||||
ldr r1, [r2, #0x0c]
|
ldr r1, [r3, #OFS_Pico_sv_flags]
|
||||||
tst r1, #SRF_EEPROM
|
tst r1, #SRF_EEPROM
|
||||||
bne EEPROM_read
|
bne EEPROM_read
|
||||||
ldr r1, [r2, #4] @ SRam.start
|
ldr r1, [r3, #OFS_Pico_sv_data]
|
||||||
ldr r2, [r2] @ SRam.data
|
sub r0, r0, r2
|
||||||
sub r0, r0, r1
|
ldrb r1, [r0, r1]!
|
||||||
add r0, r0, r2
|
ldrb r0, [r0, #1]
|
||||||
ldrb r1, [r0], #1
|
|
||||||
ldrb r0, [r0]
|
|
||||||
orr r0, r0, r1, lsl #8
|
orr r0, r0, r1, lsl #8
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
m_read16_nosram:
|
m_read16_nosram:
|
||||||
ldr r1, [r3, #4] @ romsize
|
ldr r1, [r3, #OFS_Pico_romsize]
|
||||||
cmp r0, r1
|
cmp r0, r1
|
||||||
movgt r0, #0
|
movgt r0, #0
|
||||||
bxgt lr @ bad location
|
bxgt lr @ bad location
|
||||||
@ XXX: banking unfriendly
|
@ XXX: banking unfriendly
|
||||||
ldr r1, [r3]
|
ldr r1, [r3, #OFS_Pico_rom]
|
||||||
ldrh r0, [r1, r0]
|
ldrh r0, [r1, r0]
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
|
@ -152,19 +148,19 @@ m_read16_not_io:
|
||||||
cmp r2, #0x1000
|
cmp r2, #0x1000
|
||||||
bne m_read16_not_brq
|
bne m_read16_not_brq
|
||||||
|
|
||||||
ldr r3, =(Pico+0x22200)
|
ldr r3, =Pico
|
||||||
and r2, r0, #0xff00
|
and r2, r0, #0xff00
|
||||||
ldr r0, [r3, #8] @ Pico.m.rotate
|
ldr r0, [r3, #OFS_Pico_m_rotate]
|
||||||
add r0, r0, #1
|
add r0, r0, #1
|
||||||
strb r0, [r3, #8]
|
strb r0, [r3, #OFS_Pico_m_rotate]
|
||||||
eor r0, r0, r0, lsl #5
|
eor r0, r0, r0, lsl #5
|
||||||
eor r0, r0, r0, lsl #8
|
eor r0, r0, r0, lsl #8
|
||||||
bic r0, r0, #0x100 @ bit8 defined in this area
|
bic r0, r0, #0x100 @ bit8 defined in this area
|
||||||
cmp r2, #0x1100
|
cmp r2, #0x1100
|
||||||
bxne lr @ not busreq
|
bxne lr @ not busreq
|
||||||
|
|
||||||
ldrb r1, [r3, #(8+0x01)] @ Pico.m.z80Run
|
ldrb r1, [r3, #OFS_Pico_m_z80Run]
|
||||||
ldrb r2, [r3, #(8+0x0f)] @ Pico.m.z80_reset
|
ldrb r2, [r3, #OFS_Pico_m_z80_reset]
|
||||||
orr r0, r0, r1, lsl #8
|
orr r0, r0, r1, lsl #8
|
||||||
orr r0, r0, r2, lsl #8
|
orr r0, r0, r2, lsl #8
|
||||||
bx lr
|
bx lr
|
||||||
|
@ -202,12 +198,12 @@ m_write8_not_z80ctl:
|
||||||
eor r2, r2, #0x003000
|
eor r2, r2, #0x003000
|
||||||
eors r2, r2, #0x0000f1
|
eors r2, r2, #0x0000f1
|
||||||
bne m_write8_not_sreg
|
bne m_write8_not_sreg
|
||||||
ldr r3, =(Pico+0x22200)
|
ldr r3, =Pico
|
||||||
ldrb r2, [r3, #(8+9)] @ Pico.m.sram_reg
|
ldrb r2, [r3, #OFS_Pico_m_sram_reg]
|
||||||
and r1, r1, #(SRR_MAPPED|SRR_READONLY)
|
and r1, r1, #(SRR_MAPPED|SRR_READONLY)
|
||||||
bic r2, r2, #(SRR_MAPPED|SRR_READONLY)
|
bic r2, r2, #(SRR_MAPPED|SRR_READONLY)
|
||||||
orr r2, r2, r1
|
orr r2, r2, r1
|
||||||
strb r2, [r3, #(8+9)]
|
strb r2, [r3, #OFS_Pico_m_sram_reg]
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
m_write8_not_sreg:
|
m_write8_not_sreg:
|
||||||
|
@ -239,12 +235,12 @@ m_write16_not_z80ctl:
|
||||||
eor r2, r2, #0x003000
|
eor r2, r2, #0x003000
|
||||||
eors r2, r2, #0x0000f0
|
eors r2, r2, #0x0000f0
|
||||||
bne m_write16_not_sreg
|
bne m_write16_not_sreg
|
||||||
ldr r3, =(Pico+0x22200)
|
ldr r3, =Pico
|
||||||
ldrb r2, [r3, #(8+9)] @ Pico.m.sram_reg
|
ldrb r2, [r3, #OFS_Pico_m_sram_reg]
|
||||||
and r1, r1, #(SRR_MAPPED|SRR_READONLY)
|
and r1, r1, #(SRR_MAPPED|SRR_READONLY)
|
||||||
bic r2, r2, #(SRR_MAPPED|SRR_READONLY)
|
bic r2, r2, #(SRR_MAPPED|SRR_READONLY)
|
||||||
orr r2, r2, r1
|
orr r2, r2, r1
|
||||||
strb r2, [r3, #(8+9)]
|
strb r2, [r3, #OFS_Pico_m_sram_reg]
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
m_write16_not_sreg:
|
m_write16_not_sreg:
|
10
pico/mode4.c
10
pico/mode4.c
|
@ -31,7 +31,7 @@ static int TileNormM4(int sx, int addr, int pal)
|
||||||
unsigned char *pd = Pico.est.HighCol + sx;
|
unsigned char *pd = Pico.est.HighCol + sx;
|
||||||
unsigned int pack, t;
|
unsigned int pack, t;
|
||||||
|
|
||||||
pack = *(unsigned int *)(Pico.vram + addr); /* Get 4 bitplanes / 8 pixels */
|
pack = *(unsigned int *)(PicoMem.vram + addr); /* Get 4 bitplanes / 8 pixels */
|
||||||
if (pack)
|
if (pack)
|
||||||
{
|
{
|
||||||
PLANAR_PIXEL(0, 0)
|
PLANAR_PIXEL(0, 0)
|
||||||
|
@ -53,7 +53,7 @@ static int TileFlipM4(int sx,int addr,int pal)
|
||||||
unsigned char *pd = Pico.est.HighCol + sx;
|
unsigned char *pd = Pico.est.HighCol + sx;
|
||||||
unsigned int pack, t;
|
unsigned int pack, t;
|
||||||
|
|
||||||
pack = *(unsigned int *)(Pico.vram + addr); /* Get 4 bitplanes / 8 pixels */
|
pack = *(unsigned int *)(PicoMem.vram + addr); /* Get 4 bitplanes / 8 pixels */
|
||||||
if (pack)
|
if (pack)
|
||||||
{
|
{
|
||||||
PLANAR_PIXEL(0, 7)
|
PLANAR_PIXEL(0, 7)
|
||||||
|
@ -83,7 +83,7 @@ static void draw_sprites(int scanline)
|
||||||
if (pv->reg[0] & 8)
|
if (pv->reg[0] & 8)
|
||||||
xoff = 0;
|
xoff = 0;
|
||||||
|
|
||||||
sat = (unsigned char *)Pico.vram + ((pv->reg[5] & 0x7e) << 7);
|
sat = (unsigned char *)PicoMem.vram + ((pv->reg[5] & 0x7e) << 7);
|
||||||
if (pv->reg[1] & 2) {
|
if (pv->reg[1] & 2) {
|
||||||
addr_mask = 0xfe; h = 16;
|
addr_mask = 0xfe; h = 16;
|
||||||
} else {
|
} else {
|
||||||
|
@ -161,7 +161,7 @@ static void DrawDisplayM4(int scanline)
|
||||||
line -= 224;
|
line -= 224;
|
||||||
|
|
||||||
// Find name table:
|
// Find name table:
|
||||||
nametab = Pico.vram;
|
nametab = PicoMem.vram;
|
||||||
nametab += (pv->reg[2] & 0x0e) << (10-1);
|
nametab += (pv->reg[2] & 0x0e) << (10-1);
|
||||||
nametab += (line>>3) << (6-1);
|
nametab += (line>>3) << (6-1);
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ void PicoLineMode4(int line)
|
||||||
|
|
||||||
void PicoDoHighPal555M4(void)
|
void PicoDoHighPal555M4(void)
|
||||||
{
|
{
|
||||||
unsigned int *spal=(void *)Pico.cram;
|
unsigned int *spal=(void *)PicoMem.cram;
|
||||||
unsigned int *dpal=(void *)Pico.est.HighPal;
|
unsigned int *dpal=(void *)Pico.est.HighPal;
|
||||||
unsigned int t;
|
unsigned int t;
|
||||||
int i;
|
int i;
|
||||||
|
|
42
pico/pico.c
42
pico/pico.c
|
@ -11,6 +11,7 @@
|
||||||
#include "sound/ym2612.h"
|
#include "sound/ym2612.h"
|
||||||
|
|
||||||
struct Pico Pico;
|
struct Pico Pico;
|
||||||
|
struct PicoMem PicoMem;
|
||||||
int PicoOpt;
|
int PicoOpt;
|
||||||
int PicoSkipFrame; // skip rendering frame?
|
int PicoSkipFrame; // skip rendering frame?
|
||||||
int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU
|
int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU
|
||||||
|
@ -20,11 +21,8 @@ int PicoQuirks; // game-specific quirks
|
||||||
int PicoRegionOverride; // override the region detection 0: Auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe
|
int PicoRegionOverride; // override the region detection 0: Auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe
|
||||||
int PicoAutoRgnOrder;
|
int PicoAutoRgnOrder;
|
||||||
|
|
||||||
struct PicoSRAM SRam;
|
|
||||||
int emustatus; // rapid_ym2612, multi_ym_updates
|
int emustatus; // rapid_ym2612, multi_ym_updates
|
||||||
|
|
||||||
struct PicoTiming timing;
|
|
||||||
|
|
||||||
void (*PicoWriteSound)(int len) = NULL; // called at the best time to send sound buffer (PsndOut) to hardware
|
void (*PicoWriteSound)(int len) = NULL; // called at the best time to send sound buffer (PsndOut) to hardware
|
||||||
void (*PicoResetHook)(void) = NULL;
|
void (*PicoResetHook)(void) = NULL;
|
||||||
void (*PicoLineHook)(void) = NULL;
|
void (*PicoLineHook)(void) = NULL;
|
||||||
|
@ -34,11 +32,13 @@ void PicoInit(void)
|
||||||
{
|
{
|
||||||
// Blank space for state:
|
// Blank space for state:
|
||||||
memset(&Pico,0,sizeof(Pico));
|
memset(&Pico,0,sizeof(Pico));
|
||||||
|
memset(&PicoMem,0,sizeof(PicoMem));
|
||||||
memset(&PicoPad,0,sizeof(PicoPad));
|
memset(&PicoPad,0,sizeof(PicoPad));
|
||||||
memset(&PicoPadInt,0,sizeof(PicoPadInt));
|
memset(&PicoPadInt,0,sizeof(PicoPadInt));
|
||||||
|
|
||||||
Pico.est.Pico_video = &Pico.video;
|
Pico.est.Pico = &Pico;
|
||||||
Pico.est.Pico_vram = Pico.vram;
|
Pico.est.PicoMem_vram = PicoMem.vram;
|
||||||
|
Pico.est.PicoMem_cram = PicoMem.cram;
|
||||||
Pico.est.PicoOpt = &PicoOpt;
|
Pico.est.PicoOpt = &PicoOpt;
|
||||||
|
|
||||||
// Init CPUs:
|
// Init CPUs:
|
||||||
|
@ -61,18 +61,18 @@ void PicoExit(void)
|
||||||
PicoCartUnload();
|
PicoCartUnload();
|
||||||
z80_exit();
|
z80_exit();
|
||||||
|
|
||||||
if (SRam.data)
|
if (Pico.sv.data)
|
||||||
free(SRam.data);
|
free(Pico.sv.data);
|
||||||
pevt_dump();
|
pevt_dump();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PicoPower(void)
|
void PicoPower(void)
|
||||||
{
|
{
|
||||||
Pico.m.frame_count = 0;
|
Pico.m.frame_count = 0;
|
||||||
SekCycleCnt = SekCycleAim = 0;
|
Pico.t.m68c_cnt = Pico.t.m68c_aim = 0;
|
||||||
|
|
||||||
// clear all memory of the emulated machine
|
// clear all memory of the emulated machine
|
||||||
memset(&Pico.ram,0,(unsigned char *)&Pico.rom - Pico.ram);
|
memset(&PicoMem,0,sizeof(PicoMem));
|
||||||
|
|
||||||
memset(&Pico.video,0,sizeof(Pico.video));
|
memset(&Pico.video,0,sizeof(Pico.video));
|
||||||
memset(&Pico.m,0,sizeof(Pico.m));
|
memset(&Pico.m,0,sizeof(Pico.m));
|
||||||
|
@ -81,7 +81,7 @@ void PicoPower(void)
|
||||||
z80_reset();
|
z80_reset();
|
||||||
|
|
||||||
// my MD1 VA6 console has this in IO
|
// my MD1 VA6 console has this in IO
|
||||||
Pico.ioports[1] = Pico.ioports[2] = Pico.ioports[3] = 0xff;
|
PicoMem.ioports[1] = PicoMem.ioports[2] = PicoMem.ioports[3] = 0xff;
|
||||||
|
|
||||||
// default VDP register values (based on Fusion)
|
// default VDP register values (based on Fusion)
|
||||||
Pico.video.reg[0] = Pico.video.reg[1] = 0x04;
|
Pico.video.reg[0] = Pico.video.reg[1] = 0x04;
|
||||||
|
@ -211,12 +211,12 @@ int PicoReset(void)
|
||||||
|
|
||||||
// reset sram state; enable sram access by default if it doesn't overlap with ROM
|
// reset sram state; enable sram access by default if it doesn't overlap with ROM
|
||||||
Pico.m.sram_reg = 0;
|
Pico.m.sram_reg = 0;
|
||||||
if ((SRam.flags & SRF_EEPROM) || Pico.romsize <= SRam.start)
|
if ((Pico.sv.flags & SRF_EEPROM) || Pico.romsize <= Pico.sv.start)
|
||||||
Pico.m.sram_reg |= SRR_MAPPED;
|
Pico.m.sram_reg |= SRR_MAPPED;
|
||||||
|
|
||||||
if (SRam.flags & SRF_ENABLED)
|
if (Pico.sv.flags & SRF_ENABLED)
|
||||||
elprintf(EL_STATUS, "sram: %06x - %06x; eeprom: %i", SRam.start, SRam.end,
|
elprintf(EL_STATUS, "sram: %06x - %06x; eeprom: %i", Pico.sv.start, Pico.sv.end,
|
||||||
!!(SRam.flags & SRF_EEPROM));
|
!!(Pico.sv.flags & SRF_EEPROM));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,7 @@ PICO_INTERNAL int CheckDMA(void)
|
||||||
|
|
||||||
elprintf(EL_VDPDMA, "~Dma %i op=%i can=%i burn=%i [%u]",
|
elprintf(EL_VDPDMA, "~Dma %i op=%i can=%i burn=%i [%u]",
|
||||||
Pico.m.dma_xfers, dma_op1, xfers_can, burn, SekCyclesDone());
|
Pico.m.dma_xfers, dma_op1, xfers_can, burn, SekCyclesDone());
|
||||||
//dprintf("~aim: %i, cnt: %i", SekCycleAim, SekCycleCnt);
|
//dprintf("~aim: %i, cnt: %i", Pico.t.m68c_aim, Pico.t.m68c_cnt);
|
||||||
return burn;
|
return burn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,18 +286,18 @@ PICO_INTERNAL void PicoSyncZ80(unsigned int m68k_cycles_done)
|
||||||
int m68k_cnt;
|
int m68k_cnt;
|
||||||
int cnt;
|
int cnt;
|
||||||
|
|
||||||
m68k_cnt = m68k_cycles_done - timing.m68c_frame_start;
|
m68k_cnt = m68k_cycles_done - Pico.t.m68c_frame_start;
|
||||||
timing.z80c_aim = cycles_68k_to_z80(m68k_cnt);
|
Pico.t.z80c_aim = cycles_68k_to_z80(m68k_cnt);
|
||||||
cnt = timing.z80c_aim - timing.z80c_cnt;
|
cnt = Pico.t.z80c_aim - Pico.t.z80c_cnt;
|
||||||
|
|
||||||
pprof_start(z80);
|
pprof_start(z80);
|
||||||
|
|
||||||
elprintf(EL_BUSREQ, "z80 sync %i (%u|%u -> %u|%u)", cnt,
|
elprintf(EL_BUSREQ, "z80 sync %i (%u|%u -> %u|%u)", cnt,
|
||||||
timing.z80c_cnt, timing.z80c_cnt * 15 / 7 / 488,
|
Pico.t.z80c_cnt, Pico.t.z80c_cnt * 15 / 7 / 488,
|
||||||
timing.z80c_aim, timing.z80c_aim * 15 / 7 / 488);
|
Pico.t.z80c_aim, Pico.t.z80c_aim * 15 / 7 / 488);
|
||||||
|
|
||||||
if (cnt > 0)
|
if (cnt > 0)
|
||||||
timing.z80c_cnt += z80_run(cnt);
|
Pico.t.z80c_cnt += z80_run(cnt);
|
||||||
|
|
||||||
pprof_end(z80);
|
pprof_end(z80);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,24 +21,24 @@
|
||||||
SekRunM68k(m68k_cycles)
|
SekRunM68k(m68k_cycles)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// sync m68k to SekCycleAim
|
// sync m68k to Pico.t.m68c_aim
|
||||||
static void SekSyncM68k(void)
|
static void SekSyncM68k(void)
|
||||||
{
|
{
|
||||||
int cyc_do;
|
int cyc_do;
|
||||||
pprof_start(m68k);
|
pprof_start(m68k);
|
||||||
pevt_log_m68k_o(EVT_RUN_START);
|
pevt_log_m68k_o(EVT_RUN_START);
|
||||||
|
|
||||||
while ((cyc_do = SekCycleAim - SekCycleCnt) > 0) {
|
while ((cyc_do = Pico.t.m68c_aim - Pico.t.m68c_cnt) > 0) {
|
||||||
SekCycleCnt += cyc_do;
|
Pico.t.m68c_cnt += cyc_do;
|
||||||
|
|
||||||
#if defined(EMU_C68K)
|
#if defined(EMU_C68K)
|
||||||
PicoCpuCM68k.cycles = cyc_do;
|
PicoCpuCM68k.cycles = cyc_do;
|
||||||
CycloneRun(&PicoCpuCM68k);
|
CycloneRun(&PicoCpuCM68k);
|
||||||
SekCycleCnt -= PicoCpuCM68k.cycles;
|
Pico.t.m68c_cnt -= PicoCpuCM68k.cycles;
|
||||||
#elif defined(EMU_M68K)
|
#elif defined(EMU_M68K)
|
||||||
SekCycleCnt += m68k_execute(cyc_do) - cyc_do;
|
Pico.t.m68c_cnt += m68k_execute(cyc_do) - cyc_do;
|
||||||
#elif defined(EMU_F68K)
|
#elif defined(EMU_F68K)
|
||||||
SekCycleCnt += fm68k_emulate(cyc_do, 0) - cyc_do;
|
Pico.t.m68c_cnt += fm68k_emulate(cyc_do, 0) - cyc_do;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,11 +51,11 @@ static void SekSyncM68k(void)
|
||||||
|
|
||||||
static inline void SekRunM68k(int cyc)
|
static inline void SekRunM68k(int cyc)
|
||||||
{
|
{
|
||||||
SekCycleAim += cyc;
|
Pico.t.m68c_aim += cyc;
|
||||||
cyc = SekCycleAim - SekCycleCnt;
|
cyc = Pico.t.m68c_aim - Pico.t.m68c_cnt;
|
||||||
if (cyc <= 0)
|
if (cyc <= 0)
|
||||||
return;
|
return;
|
||||||
SekCycleCnt += cyc >> 6; // refresh slowdowns
|
Pico.t.m68c_cnt += cyc >> 6; // refresh slowdowns
|
||||||
SekSyncM68k();
|
SekSyncM68k();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ static int PicoFrameHints(void)
|
||||||
}
|
}
|
||||||
else skip=PicoSkipFrame;
|
else skip=PicoSkipFrame;
|
||||||
|
|
||||||
timing.m68c_frame_start = SekCyclesDone();
|
Pico.t.m68c_frame_start = SekCyclesDone();
|
||||||
pv->v_counter = Pico.m.scanline = 0;
|
pv->v_counter = Pico.m.scanline = 0;
|
||||||
z80_resetCycles();
|
z80_resetCycles();
|
||||||
PsndStartFrame();
|
PsndStartFrame();
|
||||||
|
@ -170,7 +170,7 @@ static int PicoFrameHints(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run scanline:
|
// Run scanline:
|
||||||
line_base_cycles = SekCyclesDone();
|
Pico.t.m68c_line_start = SekCyclesDone();
|
||||||
do_timing_hacks_as(pv, vdp_slots);
|
do_timing_hacks_as(pv, vdp_slots);
|
||||||
CPUS_RUN(CYCLES_M68K_LINE);
|
CPUS_RUN(CYCLES_M68K_LINE);
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ static int PicoFrameHints(void)
|
||||||
// there must be a delay after vblank bit is set and irq is asserted (Mazin Saga)
|
// there must be a delay after vblank bit is set and irq is asserted (Mazin Saga)
|
||||||
// also delay between F bit (bit 7) is set in SR and IRQ happens (Ex-Mutants)
|
// also delay between F bit (bit 7) is set in SR and IRQ happens (Ex-Mutants)
|
||||||
// also delay between last H-int and V-int (Golden Axe 3)
|
// also delay between last H-int and V-int (Golden Axe 3)
|
||||||
line_base_cycles = SekCyclesDone();
|
Pico.t.m68c_line_start = SekCyclesDone();
|
||||||
do_timing_hacks_vb();
|
do_timing_hacks_vb();
|
||||||
CPUS_RUN(CYCLES_M68K_VINT_LAG);
|
CPUS_RUN(CYCLES_M68K_VINT_LAG);
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ static int PicoFrameHints(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run scanline:
|
// Run scanline:
|
||||||
line_base_cycles = SekCyclesDone();
|
Pico.t.m68c_line_start = SekCyclesDone();
|
||||||
do_timing_hacks_vb();
|
do_timing_hacks_vb();
|
||||||
CPUS_RUN(CYCLES_M68K_LINE);
|
CPUS_RUN(CYCLES_M68K_LINE);
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ static int PicoFrameHints(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run scanline:
|
// Run scanline:
|
||||||
line_base_cycles = SekCyclesDone();
|
Pico.t.m68c_line_start = SekCyclesDone();
|
||||||
do_timing_hacks_as(pv, vdp_slots);
|
do_timing_hacks_as(pv, vdp_slots);
|
||||||
CPUS_RUN(CYCLES_M68K_LINE);
|
CPUS_RUN(CYCLES_M68K_LINE);
|
||||||
|
|
||||||
|
|
|
@ -128,26 +128,18 @@ extern m68ki_cpu_core PicoCpuMM68k, PicoCpuMS68k;
|
||||||
#endif
|
#endif
|
||||||
#endif // EMU_M68K
|
#endif // EMU_M68K
|
||||||
|
|
||||||
// while running, cnt represents target of current timeslice
|
|
||||||
// while not in SekRun(), it's actual cycles done
|
|
||||||
// (but always use SekCyclesDone() if you need current position)
|
|
||||||
// cnt may change if timeslice is ended prematurely or extended,
|
|
||||||
// so we use SekCycleAim for the actual target
|
|
||||||
extern unsigned int SekCycleCnt;
|
|
||||||
extern unsigned int SekCycleAim;
|
|
||||||
|
|
||||||
// number of cycles done (can be checked anywhere)
|
// number of cycles done (can be checked anywhere)
|
||||||
#define SekCyclesDone() (SekCycleCnt - SekCyclesLeft)
|
#define SekCyclesDone() (Pico.t.m68c_cnt - SekCyclesLeft)
|
||||||
|
|
||||||
// burn cycles while not in SekRun() and while in
|
// burn cycles while not in SekRun() and while in
|
||||||
#define SekCyclesBurn(c) SekCycleCnt += c
|
#define SekCyclesBurn(c) Pico.t.m68c_cnt += c
|
||||||
#define SekCyclesBurnRun(c) { \
|
#define SekCyclesBurnRun(c) { \
|
||||||
SekCyclesLeft -= c; \
|
SekCyclesLeft -= c; \
|
||||||
}
|
}
|
||||||
|
|
||||||
// note: sometimes may extend timeslice to delay an irq
|
// note: sometimes may extend timeslice to delay an irq
|
||||||
#define SekEndRun(after) { \
|
#define SekEndRun(after) { \
|
||||||
SekCycleCnt -= SekCyclesLeft - (after); \
|
Pico.t.m68c_cnt -= SekCyclesLeft - (after); \
|
||||||
SekCyclesLeft = after; \
|
SekCyclesLeft = after; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,10 +204,10 @@ extern struct DrZ80 drZ80;
|
||||||
#define Z80_STATE_SIZE 0x60
|
#define Z80_STATE_SIZE 0x60
|
||||||
|
|
||||||
#define z80_resetCycles() \
|
#define z80_resetCycles() \
|
||||||
timing.z80c_cnt = timing.z80c_aim = timing.z80_scanline = 0
|
Pico.t.z80c_cnt = Pico.t.z80c_aim = Pico.t.z80_scanline = 0
|
||||||
|
|
||||||
#define z80_cyclesDone() \
|
#define z80_cyclesDone() \
|
||||||
(timing.z80c_aim - z80_cyclesLeft)
|
(Pico.t.z80c_aim - z80_cyclesLeft)
|
||||||
|
|
||||||
#define cycles_68k_to_z80(x) ((x) * 3823 >> 13)
|
#define cycles_68k_to_z80(x) ((x) * 3823 >> 13)
|
||||||
|
|
||||||
|
@ -359,15 +351,16 @@ struct PicoEState
|
||||||
void *DrawLineDest; // draw destination
|
void *DrawLineDest; // draw destination
|
||||||
unsigned char *HighCol;
|
unsigned char *HighCol;
|
||||||
int *HighPreSpr;
|
int *HighPreSpr;
|
||||||
void *Pico_video;
|
struct Pico *Pico;
|
||||||
void *Pico_vram;
|
void *PicoMem_vram;
|
||||||
|
void *PicoMem_cram;
|
||||||
int *PicoOpt;
|
int *PicoOpt;
|
||||||
unsigned char *Draw2FB;
|
unsigned char *Draw2FB;
|
||||||
unsigned short HighPal[0x100];
|
unsigned short HighPal[0x100];
|
||||||
};
|
};
|
||||||
|
|
||||||
// some assembly stuff depend on these, do not touch!
|
// some assembly stuff still depends on these, do not touch!
|
||||||
struct Pico
|
struct PicoMem
|
||||||
{
|
{
|
||||||
unsigned char ram[0x10000]; // 0x00000 scratch ram
|
unsigned char ram[0x10000]; // 0x00000 scratch ram
|
||||||
union { // vram is byteswapped for easier reads when drawing
|
union { // vram is byteswapped for easier reads when drawing
|
||||||
|
@ -379,14 +372,6 @@ struct Pico
|
||||||
unsigned char pad[0xf0]; // unused
|
unsigned char pad[0xf0]; // unused
|
||||||
unsigned short cram[0x40]; // 0x22100
|
unsigned short cram[0x40]; // 0x22100
|
||||||
unsigned short vsram[0x40]; // 0x22180
|
unsigned short vsram[0x40]; // 0x22180
|
||||||
|
|
||||||
unsigned char *rom; // 0x22200
|
|
||||||
unsigned int romsize; // 0x22204 (on 32bits)
|
|
||||||
|
|
||||||
struct PicoMisc m;
|
|
||||||
struct PicoVideo video;
|
|
||||||
struct PicoMS ms;
|
|
||||||
struct PicoEState est;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// sram
|
// sram
|
||||||
|
@ -396,7 +381,7 @@ struct Pico
|
||||||
#define SRF_ENABLED (1 << 0)
|
#define SRF_ENABLED (1 << 0)
|
||||||
#define SRF_EEPROM (1 << 1)
|
#define SRF_EEPROM (1 << 1)
|
||||||
|
|
||||||
struct PicoSRAM
|
struct PicoCartSave
|
||||||
{
|
{
|
||||||
unsigned char *data; // actual data
|
unsigned char *data; // actual data
|
||||||
unsigned int start; // start address in 68k address space
|
unsigned int start; // start address in 68k address space
|
||||||
|
@ -412,6 +397,38 @@ struct PicoSRAM
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct PicoTiming
|
||||||
|
{
|
||||||
|
// while running, cnt represents target of current timeslice
|
||||||
|
// while not in SekRun(), it's actual cycles done
|
||||||
|
// (but always use SekCyclesDone() if you need current position)
|
||||||
|
// _cnt may change if timeslice is ended prematurely or extended,
|
||||||
|
// so we use _aim for the actual target
|
||||||
|
unsigned int m68c_cnt;
|
||||||
|
unsigned int m68c_aim;
|
||||||
|
unsigned int m68c_frame_start; // m68k cycles
|
||||||
|
unsigned int m68c_line_start;
|
||||||
|
|
||||||
|
unsigned int z80c_cnt; // z80 cycles done (this frame)
|
||||||
|
unsigned int z80c_aim;
|
||||||
|
int z80_scanline;
|
||||||
|
};
|
||||||
|
|
||||||
|
// run tools/mkoffsets pico/pico_int_o32.h if you change these
|
||||||
|
// careful with savestate compat
|
||||||
|
struct Pico
|
||||||
|
{
|
||||||
|
struct PicoVideo video;
|
||||||
|
struct PicoMisc m;
|
||||||
|
struct PicoTiming t;
|
||||||
|
struct PicoCartSave sv;
|
||||||
|
struct PicoEState est;
|
||||||
|
struct PicoMS ms;
|
||||||
|
|
||||||
|
unsigned char *rom;
|
||||||
|
unsigned int romsize;
|
||||||
|
};
|
||||||
|
|
||||||
// MCD
|
// MCD
|
||||||
#define PCM_MIXBUF_LEN ((12500000 / 384) / 50 + 1)
|
#define PCM_MIXBUF_LEN ((12500000 / 384) / 50 + 1)
|
||||||
|
|
||||||
|
@ -592,15 +609,6 @@ struct Pico32xMem
|
||||||
unsigned short pwm_fifo[2][4]; // [0] - current raw, others - fifo entries
|
unsigned short pwm_fifo[2][4]; // [0] - current raw, others - fifo entries
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PicoTiming
|
|
||||||
{
|
|
||||||
unsigned int m68c_frame_start; // m68k cycles
|
|
||||||
unsigned int z80c_cnt; // z80 cycles done (this frame)
|
|
||||||
unsigned int z80c_aim;
|
|
||||||
int z80_scanline;
|
|
||||||
};
|
|
||||||
extern struct PicoTiming timing;
|
|
||||||
|
|
||||||
// area.c
|
// area.c
|
||||||
extern void (*PicoLoadStateHook)(void);
|
extern void (*PicoLoadStateHook)(void);
|
||||||
|
|
||||||
|
@ -699,7 +707,7 @@ void pcd_state_loaded_mem(void);
|
||||||
|
|
||||||
// pico.c
|
// pico.c
|
||||||
extern struct Pico Pico;
|
extern struct Pico Pico;
|
||||||
extern struct PicoSRAM SRam;
|
extern struct PicoMem PicoMem;
|
||||||
extern int PicoPadInt[2];
|
extern int PicoPadInt[2];
|
||||||
extern int emustatus;
|
extern int emustatus;
|
||||||
extern void (*PicoResetHook)(void);
|
extern void (*PicoResetHook)(void);
|
||||||
|
@ -809,7 +817,6 @@ void ym2612_unpack_state(void);
|
||||||
|
|
||||||
|
|
||||||
// videoport.c
|
// videoport.c
|
||||||
extern int line_base_cycles;
|
|
||||||
PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d);
|
PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d);
|
||||||
PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a);
|
PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a);
|
||||||
unsigned char PicoVideoRead8DataH(void);
|
unsigned char PicoVideoRead8DataH(void);
|
||||||
|
@ -898,7 +905,7 @@ void p32x_event_schedule_sh2(SH2 *sh2, enum p32x_event event, int after);
|
||||||
void p32x_schedule_hint(SH2 *sh2, int m68k_cycles);
|
void p32x_schedule_hint(SH2 *sh2, int m68k_cycles);
|
||||||
|
|
||||||
// 32x/memory.c
|
// 32x/memory.c
|
||||||
struct Pico32xMem *Pico32xMem;
|
extern struct Pico32xMem *Pico32xMem;
|
||||||
unsigned int PicoRead8_32x(unsigned int a);
|
unsigned int PicoRead8_32x(unsigned int a);
|
||||||
unsigned int PicoRead16_32x(unsigned int a);
|
unsigned int PicoRead16_32x(unsigned int a);
|
||||||
void PicoWrite8_32x(unsigned int a, unsigned int d);
|
void PicoWrite8_32x(unsigned int a, unsigned int d);
|
||||||
|
|
|
@ -1,11 +1,26 @@
|
||||||
/* autogenerated by ./tools/mkoffsets, do not edit */
|
/* autogenerated by tools/mkoffsets, do not edit */
|
||||||
#define OFS_DrawScanline 0x00
|
#define OFS_Pico_video_reg 0x0000
|
||||||
#define OFS_rendstatus 0x04
|
#define OFS_Pico_m_rotate 0x0040
|
||||||
#define OFS_DrawLineDest 0x08
|
#define OFS_Pico_m_z80Run 0x0041
|
||||||
#define OFS_HighCol 0x0c
|
#define OFS_Pico_m_dirtyPal 0x0046
|
||||||
#define OFS_HighPreSpr 0x10
|
#define OFS_Pico_m_hardware 0x0047
|
||||||
#define OFS_Pico_video 0x14
|
#define OFS_Pico_m_z80_reset 0x004f
|
||||||
#define OFS_Pico_vram 0x18
|
#define OFS_Pico_m_sram_reg 0x0049
|
||||||
#define OFS_PicoOpt 0x1c
|
#define OFS_Pico_sv 0x007c
|
||||||
#define OFS_Draw2FB 0x20
|
#define OFS_Pico_sv_data 0x007c
|
||||||
#define OFS_HighPal 0x24
|
#define OFS_Pico_sv_start 0x0080
|
||||||
|
#define OFS_Pico_sv_end 0x0084
|
||||||
|
#define OFS_Pico_sv_flags 0x0088
|
||||||
|
#define OFS_Pico_rom 0x031c
|
||||||
|
#define OFS_Pico_romsize 0x0320
|
||||||
|
#define OFS_EST_DrawScanline 0x00
|
||||||
|
#define OFS_EST_rendstatus 0x04
|
||||||
|
#define OFS_EST_DrawLineDest 0x08
|
||||||
|
#define OFS_EST_HighCol 0x0c
|
||||||
|
#define OFS_EST_HighPreSpr 0x10
|
||||||
|
#define OFS_EST_Pico 0x14
|
||||||
|
#define OFS_EST_PicoMem_vram 0x18
|
||||||
|
#define OFS_EST_PicoMem_cram 0x1c
|
||||||
|
#define OFS_EST_PicoOpt 0x20
|
||||||
|
#define OFS_EST_Draw2FB 0x24
|
||||||
|
#define OFS_EST_HighPal 0x28
|
||||||
|
|
29
pico/sek.c
29
pico/sek.c
|
@ -10,11 +10,6 @@
|
||||||
#include "pico_int.h"
|
#include "pico_int.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
|
|
||||||
unsigned int SekCycleCnt;
|
|
||||||
unsigned int SekCycleAim;
|
|
||||||
|
|
||||||
|
|
||||||
/* context */
|
/* context */
|
||||||
// Cyclone 68000
|
// Cyclone 68000
|
||||||
#ifdef EMU_C68K
|
#ifdef EMU_C68K
|
||||||
|
@ -36,8 +31,8 @@ M68K_CONTEXT PicoCpuFM68k;
|
||||||
static int SekIntAck(int level)
|
static int SekIntAck(int level)
|
||||||
{
|
{
|
||||||
// try to emulate VDP's reaction to 68000 int ack
|
// try to emulate VDP's reaction to 68000 int ack
|
||||||
if (level == 4) { Pico.video.pending_ints = 0; elprintf(EL_INTS, "hack: @ %06x [%u]", SekPc, SekCycleCnt); }
|
if (level == 4) { Pico.video.pending_ints = 0; elprintf(EL_INTS, "hack: @ %06x [%u]", SekPc, Pico.t.m68c_cnt); }
|
||||||
else if(level == 6) { Pico.video.pending_ints &= ~0x20; elprintf(EL_INTS, "vack: @ %06x [%u]", SekPc, SekCycleCnt); }
|
else if(level == 6) { Pico.video.pending_ints &= ~0x20; elprintf(EL_INTS, "vack: @ %06x [%u]", SekPc, Pico.t.m68c_cnt); }
|
||||||
PicoCpuCM68k.irq = 0;
|
PicoCpuCM68k.irq = 0;
|
||||||
return CYCLONE_INT_ACK_AUTOVECTOR;
|
return CYCLONE_INT_ACK_AUTOVECTOR;
|
||||||
}
|
}
|
||||||
|
@ -76,8 +71,8 @@ static int SekUnrecognizedOpcode()
|
||||||
#ifdef EMU_M68K
|
#ifdef EMU_M68K
|
||||||
static int SekIntAckM68K(int level)
|
static int SekIntAckM68K(int level)
|
||||||
{
|
{
|
||||||
if (level == 4) { Pico.video.pending_ints = 0; elprintf(EL_INTS, "hack: @ %06x [%u]", SekPc, SekCycleCnt); }
|
if (level == 4) { Pico.video.pending_ints = 0; elprintf(EL_INTS, "hack: @ %06x [%u]", SekPc, Pico.t.m68c_cnt); }
|
||||||
else if(level == 6) { Pico.video.pending_ints &= ~0x20; elprintf(EL_INTS, "vack: @ %06x [%u]", SekPc, SekCycleCnt); }
|
else if(level == 6) { Pico.video.pending_ints &= ~0x20; elprintf(EL_INTS, "vack: @ %06x [%u]", SekPc, Pico.t.m68c_cnt); }
|
||||||
CPU_INT_LEVEL = 0;
|
CPU_INT_LEVEL = 0;
|
||||||
return M68K_INT_ACK_AUTOVECTOR;
|
return M68K_INT_ACK_AUTOVECTOR;
|
||||||
}
|
}
|
||||||
|
@ -168,17 +163,17 @@ PICO_INTERNAL int SekReset(void)
|
||||||
|
|
||||||
void SekStepM68k(void)
|
void SekStepM68k(void)
|
||||||
{
|
{
|
||||||
SekCycleAim=SekCycleCnt+1;
|
Pico.t.m68c_aim = Pico.t.m68c_cnt + 1;
|
||||||
#if defined(EMU_CORE_DEBUG)
|
#if defined(EMU_CORE_DEBUG)
|
||||||
SekCycleCnt+=CM_compareRun(1, 0);
|
Pico.t.m68c_cnt += CM_compareRun(1, 0);
|
||||||
#elif defined(EMU_C68K)
|
#elif defined(EMU_C68K)
|
||||||
PicoCpuCM68k.cycles=1;
|
PicoCpuCM68k.cycles=1;
|
||||||
CycloneRun(&PicoCpuCM68k);
|
CycloneRun(&PicoCpuCM68k);
|
||||||
SekCycleCnt+=1-PicoCpuCM68k.cycles;
|
Pico.t.m68c_cnt += 1 - PicoCpuCM68k.cycles;
|
||||||
#elif defined(EMU_M68K)
|
#elif defined(EMU_M68K)
|
||||||
SekCycleCnt+=m68k_execute(1);
|
Pico.t.m68c_cnt += m68k_execute(1);
|
||||||
#elif defined(EMU_F68K)
|
#elif defined(EMU_F68K)
|
||||||
SekCycleCnt+=fm68k_emulate(1, 0);
|
Pico.t.m68c_cnt += fm68k_emulate(1, 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +223,7 @@ PICO_INTERNAL void SekPackCpu(unsigned char *cpu, int is_sub)
|
||||||
|
|
||||||
*(unsigned int *)(cpu+0x40) = pc;
|
*(unsigned int *)(cpu+0x40) = pc;
|
||||||
*(unsigned int *)(cpu+0x50) =
|
*(unsigned int *)(cpu+0x50) =
|
||||||
is_sub ? SekCycleCntS68k : SekCycleCnt;
|
is_sub ? SekCycleCntS68k : Pico.t.m68c_cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
PICO_INTERNAL void SekUnpackCpu(const unsigned char *cpu, int is_sub)
|
PICO_INTERNAL void SekUnpackCpu(const unsigned char *cpu, int is_sub)
|
||||||
|
@ -268,7 +263,7 @@ PICO_INTERNAL void SekUnpackCpu(const unsigned char *cpu, int is_sub)
|
||||||
if (is_sub)
|
if (is_sub)
|
||||||
SekCycleCntS68k = *(unsigned int *)(cpu+0x50);
|
SekCycleCntS68k = *(unsigned int *)(cpu+0x50);
|
||||||
else
|
else
|
||||||
SekCycleCnt = *(unsigned int *)(cpu+0x50);
|
Pico.t.m68c_cnt = *(unsigned int *)(cpu+0x50);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -467,7 +462,7 @@ void SekTrace(int is_s68k)
|
||||||
struct ref_68k *x68k = &ref_68ks[is_s68k];
|
struct ref_68k *x68k = &ref_68ks[is_s68k];
|
||||||
u32 pc = is_s68k ? SekPcS68k : SekPc;
|
u32 pc = is_s68k ? SekPcS68k : SekPc;
|
||||||
u32 sr = is_s68k ? SekSrS68k : SekSr;
|
u32 sr = is_s68k ? SekSrS68k : SekSr;
|
||||||
u32 cycles = is_s68k ? SekCycleCntS68k : SekCycleCnt;
|
u32 cycles = is_s68k ? SekCycleCntS68k : Pico.t.m68c_cnt;
|
||||||
u32 r;
|
u32 r;
|
||||||
u8 cmd;
|
u8 cmd;
|
||||||
#ifdef CPU_CMP_W
|
#ifdef CPU_CMP_W
|
||||||
|
|
20
pico/sms.c
20
pico/sms.c
|
@ -23,7 +23,7 @@ static unsigned char vdp_data_read(void)
|
||||||
struct PicoVideo *pv = &Pico.video;
|
struct PicoVideo *pv = &Pico.video;
|
||||||
unsigned char d;
|
unsigned char d;
|
||||||
|
|
||||||
d = Pico.vramb[pv->addr];
|
d = PicoMem.vramb[pv->addr];
|
||||||
pv->addr = (pv->addr + 1) & 0x3fff;
|
pv->addr = (pv->addr + 1) & 0x3fff;
|
||||||
pv->pending = 0;
|
pv->pending = 0;
|
||||||
return d;
|
return d;
|
||||||
|
@ -44,10 +44,10 @@ static void vdp_data_write(unsigned char d)
|
||||||
struct PicoVideo *pv = &Pico.video;
|
struct PicoVideo *pv = &Pico.video;
|
||||||
|
|
||||||
if (pv->type == 3) {
|
if (pv->type == 3) {
|
||||||
Pico.cram[pv->addr & 0x1f] = d;
|
PicoMem.cram[pv->addr & 0x1f] = d;
|
||||||
Pico.m.dirtyPal = 1;
|
Pico.m.dirtyPal = 1;
|
||||||
} else {
|
} else {
|
||||||
Pico.vramb[pv->addr] = d;
|
PicoMem.vramb[pv->addr] = d;
|
||||||
}
|
}
|
||||||
pv->addr = (pv->addr + 1) & 0x3fff;
|
pv->addr = (pv->addr + 1) & 0x3fff;
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ static void xwrite(unsigned int a, unsigned char d)
|
||||||
{
|
{
|
||||||
elprintf(EL_IO, "z80 write [%04x] %02x", a, d);
|
elprintf(EL_IO, "z80 write [%04x] %02x", a, d);
|
||||||
if (a >= 0xc000)
|
if (a >= 0xc000)
|
||||||
Pico.zram[a & 0x1fff] = d;
|
PicoMem.zram[a & 0x1fff] = d;
|
||||||
if (a >= 0xfff8)
|
if (a >= 0xfff8)
|
||||||
write_bank(a, d);
|
write_bank(a, d);
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ void PicoPowerMS(void)
|
||||||
{
|
{
|
||||||
int s, tmp;
|
int s, tmp;
|
||||||
|
|
||||||
memset(&Pico.ram,0,(unsigned char *)&Pico.rom - Pico.ram);
|
memset(&PicoMem,0,sizeof(PicoMem));
|
||||||
memset(&Pico.video,0,sizeof(Pico.video));
|
memset(&Pico.video,0,sizeof(Pico.video));
|
||||||
memset(&Pico.m,0,sizeof(Pico.m));
|
memset(&Pico.m,0,sizeof(Pico.m));
|
||||||
Pico.m.pal = 0;
|
Pico.m.pal = 0;
|
||||||
|
@ -219,11 +219,11 @@ void PicoPowerMS(void)
|
||||||
void PicoMemSetupMS(void)
|
void PicoMemSetupMS(void)
|
||||||
{
|
{
|
||||||
z80_map_set(z80_read_map, 0x0000, 0xbfff, Pico.rom, 0);
|
z80_map_set(z80_read_map, 0x0000, 0xbfff, Pico.rom, 0);
|
||||||
z80_map_set(z80_read_map, 0xc000, 0xdfff, Pico.zram, 0);
|
z80_map_set(z80_read_map, 0xc000, 0xdfff, PicoMem.zram, 0);
|
||||||
z80_map_set(z80_read_map, 0xe000, 0xffff, Pico.zram, 0);
|
z80_map_set(z80_read_map, 0xe000, 0xffff, PicoMem.zram, 0);
|
||||||
|
|
||||||
z80_map_set(z80_write_map, 0x0000, 0xbfff, xwrite, 1);
|
z80_map_set(z80_write_map, 0x0000, 0xbfff, xwrite, 1);
|
||||||
z80_map_set(z80_write_map, 0xc000, 0xdfff, Pico.zram, 0);
|
z80_map_set(z80_write_map, 0xc000, 0xdfff, PicoMem.zram, 0);
|
||||||
z80_map_set(z80_write_map, 0xe000, 0xffff, xwrite, 1);
|
z80_map_set(z80_write_map, 0xe000, 0xffff, xwrite, 1);
|
||||||
|
|
||||||
#ifdef _USE_DRZ80
|
#ifdef _USE_DRZ80
|
||||||
|
@ -232,8 +232,8 @@ void PicoMemSetupMS(void)
|
||||||
#endif
|
#endif
|
||||||
#ifdef _USE_CZ80
|
#ifdef _USE_CZ80
|
||||||
Cz80_Set_Fetch(&CZ80, 0x0000, 0xbfff, (FPTR)Pico.rom);
|
Cz80_Set_Fetch(&CZ80, 0x0000, 0xbfff, (FPTR)Pico.rom);
|
||||||
Cz80_Set_Fetch(&CZ80, 0xc000, 0xdfff, (FPTR)Pico.zram);
|
Cz80_Set_Fetch(&CZ80, 0xc000, 0xdfff, (FPTR)PicoMem.zram);
|
||||||
Cz80_Set_Fetch(&CZ80, 0xe000, 0xffff, (FPTR)Pico.zram);
|
Cz80_Set_Fetch(&CZ80, 0xe000, 0xffff, (FPTR)PicoMem.zram);
|
||||||
Cz80_Set_INPort(&CZ80, z80_sms_in);
|
Cz80_Set_INPort(&CZ80, z80_sms_in);
|
||||||
Cz80_Set_OUTPort(&CZ80, z80_sms_out);
|
Cz80_Set_OUTPort(&CZ80, z80_sms_out);
|
||||||
#endif
|
#endif
|
||||||
|
|
50
pico/state.c
50
pico/state.c
|
@ -230,9 +230,9 @@ static int state_save(void *file)
|
||||||
memset(buff, 0, sizeof(buff));
|
memset(buff, 0, sizeof(buff));
|
||||||
SekPackCpu(buff, 0);
|
SekPackCpu(buff, 0);
|
||||||
CHECKED_WRITE_BUFF(CHUNK_M68K, buff);
|
CHECKED_WRITE_BUFF(CHUNK_M68K, buff);
|
||||||
CHECKED_WRITE_BUFF(CHUNK_RAM, Pico.ram);
|
CHECKED_WRITE_BUFF(CHUNK_RAM, PicoMem.ram);
|
||||||
CHECKED_WRITE_BUFF(CHUNK_VSRAM, Pico.vsram);
|
CHECKED_WRITE_BUFF(CHUNK_VSRAM, PicoMem.vsram);
|
||||||
CHECKED_WRITE_BUFF(CHUNK_IOPORTS, Pico.ioports);
|
CHECKED_WRITE_BUFF(CHUNK_IOPORTS, PicoMem.ioports);
|
||||||
ym2612_pack_state();
|
ym2612_pack_state();
|
||||||
CHECKED_WRITE(CHUNK_FM, 0x200+4, ym2612_regs);
|
CHECKED_WRITE(CHUNK_FM, 0x200+4, ym2612_regs);
|
||||||
}
|
}
|
||||||
|
@ -240,9 +240,9 @@ static int state_save(void *file)
|
||||||
CHECKED_WRITE_BUFF(CHUNK_SMS, Pico.ms);
|
CHECKED_WRITE_BUFF(CHUNK_SMS, Pico.ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECKED_WRITE_BUFF(CHUNK_VRAM, Pico.vram);
|
CHECKED_WRITE_BUFF(CHUNK_VRAM, PicoMem.vram);
|
||||||
CHECKED_WRITE_BUFF(CHUNK_ZRAM, Pico.zram);
|
CHECKED_WRITE_BUFF(CHUNK_ZRAM, PicoMem.zram);
|
||||||
CHECKED_WRITE_BUFF(CHUNK_CRAM, Pico.cram);
|
CHECKED_WRITE_BUFF(CHUNK_CRAM, PicoMem.cram);
|
||||||
CHECKED_WRITE_BUFF(CHUNK_MISC, Pico.m);
|
CHECKED_WRITE_BUFF(CHUNK_MISC, Pico.m);
|
||||||
CHECKED_WRITE_BUFF(CHUNK_VIDEO, Pico.video);
|
CHECKED_WRITE_BUFF(CHUNK_VIDEO, Pico.video);
|
||||||
|
|
||||||
|
@ -421,14 +421,14 @@ static int state_load(void *file)
|
||||||
CHECKED_READ_BUFF(buff_z80);
|
CHECKED_READ_BUFF(buff_z80);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CHUNK_RAM: CHECKED_READ_BUFF(Pico.ram); break;
|
case CHUNK_RAM: CHECKED_READ_BUFF(PicoMem.ram); break;
|
||||||
case CHUNK_VRAM: CHECKED_READ_BUFF(Pico.vram); break;
|
case CHUNK_VRAM: CHECKED_READ_BUFF(PicoMem.vram); break;
|
||||||
case CHUNK_ZRAM: CHECKED_READ_BUFF(Pico.zram); break;
|
case CHUNK_ZRAM: CHECKED_READ_BUFF(PicoMem.zram); break;
|
||||||
case CHUNK_CRAM: CHECKED_READ_BUFF(Pico.cram); break;
|
case CHUNK_CRAM: CHECKED_READ_BUFF(PicoMem.cram); break;
|
||||||
case CHUNK_VSRAM: CHECKED_READ_BUFF(Pico.vsram); break;
|
case CHUNK_VSRAM: CHECKED_READ_BUFF(PicoMem.vsram); break;
|
||||||
case CHUNK_MISC: CHECKED_READ_BUFF(Pico.m); break;
|
case CHUNK_MISC: CHECKED_READ_BUFF(Pico.m); break;
|
||||||
case CHUNK_VIDEO: CHECKED_READ_BUFF(Pico.video); break;
|
case CHUNK_VIDEO: CHECKED_READ_BUFF(Pico.video); break;
|
||||||
case CHUNK_IOPORTS: CHECKED_READ_BUFF(Pico.ioports); break;
|
case CHUNK_IOPORTS: CHECKED_READ_BUFF(PicoMem.ioports); break;
|
||||||
case CHUNK_PSG: CHECKED_READ2(28*4, sn76496_regs); break;
|
case CHUNK_PSG: CHECKED_READ2(28*4, sn76496_regs); break;
|
||||||
case CHUNK_FM:
|
case CHUNK_FM:
|
||||||
ym2612_regs = YM2612GetRegs();
|
ym2612_regs = YM2612GetRegs();
|
||||||
|
@ -553,7 +553,7 @@ readend:
|
||||||
z80_unpack(buff_z80);
|
z80_unpack(buff_z80);
|
||||||
|
|
||||||
// due to dep from 68k cycles..
|
// due to dep from 68k cycles..
|
||||||
SekCycleAim = SekCycleCnt;
|
Pico.t.m68c_aim = Pico.t.m68c_cnt;
|
||||||
if (PicoAHW & PAHW_32X)
|
if (PicoAHW & PAHW_32X)
|
||||||
Pico32xStateLoaded(0);
|
Pico32xStateLoaded(0);
|
||||||
if (PicoAHW & PAHW_MCD)
|
if (PicoAHW & PAHW_MCD)
|
||||||
|
@ -596,9 +596,9 @@ static int state_load_gfx(void *file)
|
||||||
|
|
||||||
switch (buff[0])
|
switch (buff[0])
|
||||||
{
|
{
|
||||||
case CHUNK_VRAM: CHECKED_READ_BUFF(Pico.vram); found++; break;
|
case CHUNK_VRAM: CHECKED_READ_BUFF(PicoMem.vram); found++; break;
|
||||||
case CHUNK_CRAM: CHECKED_READ_BUFF(Pico.cram); found++; break;
|
case CHUNK_CRAM: CHECKED_READ_BUFF(PicoMem.cram); found++; break;
|
||||||
case CHUNK_VSRAM: CHECKED_READ_BUFF(Pico.vsram); found++; break;
|
case CHUNK_VSRAM: CHECKED_READ_BUFF(PicoMem.vsram); found++; break;
|
||||||
case CHUNK_VIDEO: CHECKED_READ_BUFF(Pico.video); found++; break;
|
case CHUNK_VIDEO: CHECKED_READ_BUFF(Pico.video); found++; break;
|
||||||
|
|
||||||
#ifndef NO_32X
|
#ifndef NO_32X
|
||||||
|
@ -679,10 +679,10 @@ int PicoStateLoadGfx(const char *fname)
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
// assume legacy
|
// assume legacy
|
||||||
areaSeek(afile, 0x10020, SEEK_SET); // skip header and RAM
|
areaSeek(afile, 0x10020, SEEK_SET); // skip header and RAM
|
||||||
areaRead(Pico.vram, 1, sizeof(Pico.vram), afile);
|
areaRead(PicoMem.vram, 1, sizeof(PicoMem.vram), afile);
|
||||||
areaSeek(afile, 0x2000, SEEK_CUR);
|
areaSeek(afile, 0x2000, SEEK_CUR);
|
||||||
areaRead(Pico.cram, 1, sizeof(Pico.cram), afile);
|
areaRead(PicoMem.cram, 1, sizeof(PicoMem.cram), afile);
|
||||||
areaRead(Pico.vsram, 1, sizeof(Pico.vsram), afile);
|
areaRead(PicoMem.vsram, 1, sizeof(PicoMem.vsram), afile);
|
||||||
areaSeek(afile, 0x221a0, SEEK_SET);
|
areaSeek(afile, 0x221a0, SEEK_SET);
|
||||||
areaRead(&Pico.video, 1, sizeof(Pico.video), afile);
|
areaRead(&Pico.video, 1, sizeof(Pico.video), afile);
|
||||||
}
|
}
|
||||||
|
@ -715,9 +715,9 @@ void *PicoTmpStateSave(void)
|
||||||
if (t == NULL)
|
if (t == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
memcpy(t->vram, Pico.vram, sizeof(Pico.vram));
|
memcpy(t->vram, PicoMem.vram, sizeof(PicoMem.vram));
|
||||||
memcpy(t->cram, Pico.cram, sizeof(Pico.cram));
|
memcpy(t->cram, PicoMem.cram, sizeof(PicoMem.cram));
|
||||||
memcpy(t->vsram, Pico.vsram, sizeof(Pico.vsram));
|
memcpy(t->vsram, PicoMem.vsram, sizeof(PicoMem.vsram));
|
||||||
memcpy(&t->video, &Pico.video, sizeof(Pico.video));
|
memcpy(&t->video, &Pico.video, sizeof(Pico.video));
|
||||||
|
|
||||||
#ifndef NO_32X
|
#ifndef NO_32X
|
||||||
|
@ -737,9 +737,9 @@ void PicoTmpStateRestore(void *data)
|
||||||
if (t == NULL)
|
if (t == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
memcpy(Pico.vram, t->vram, sizeof(Pico.vram));
|
memcpy(PicoMem.vram, t->vram, sizeof(PicoMem.vram));
|
||||||
memcpy(Pico.cram, t->cram, sizeof(Pico.cram));
|
memcpy(PicoMem.cram, t->cram, sizeof(PicoMem.cram));
|
||||||
memcpy(Pico.vsram, t->vsram, sizeof(Pico.vsram));
|
memcpy(PicoMem.vsram, t->vsram, sizeof(PicoMem.vsram));
|
||||||
memcpy(&Pico.video, &t->video, sizeof(Pico.video));
|
memcpy(&Pico.video, &t->video, sizeof(Pico.video));
|
||||||
Pico.m.dirtyPal = 1;
|
Pico.m.dirtyPal = 1;
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
#define NEED_DMA_SOURCE
|
#define NEED_DMA_SOURCE
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
int line_base_cycles;
|
|
||||||
extern const unsigned char hcounts_32[];
|
extern const unsigned char hcounts_32[];
|
||||||
extern const unsigned char hcounts_40[];
|
extern const unsigned char hcounts_40[];
|
||||||
|
|
||||||
|
@ -33,23 +32,24 @@ static NOINLINE void VideoWrite128(u32 a, u16 d)
|
||||||
{
|
{
|
||||||
// nasty
|
// nasty
|
||||||
a = ((a & 2) >> 1) | ((a & 0x400) >> 9) | (a & 0x3FC) | ((a & 0x1F800) >> 1);
|
a = ((a & 2) >> 1) | ((a & 0x400) >> 9) | (a & 0x3FC) | ((a & 0x1F800) >> 1);
|
||||||
((u8 *)Pico.vram)[a] = d;
|
((u8 *)PicoMem.vram)[a] = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void VideoWrite(u16 d)
|
static void VideoWrite(u16 d)
|
||||||
{
|
{
|
||||||
unsigned int a=Pico.video.addr;
|
unsigned int a = Pico.video.addr;
|
||||||
|
|
||||||
switch (Pico.video.type)
|
switch (Pico.video.type)
|
||||||
{
|
{
|
||||||
case 1: if(a&1) d=(u16)((d<<8)|(d>>8)); // If address is odd, bytes are swapped (which game needs this?)
|
case 1: if (a & 1)
|
||||||
Pico.vram [(a>>1)&0x7fff]=d;
|
d = (u16)((d << 8) | (d >> 8));
|
||||||
|
PicoMem.vram [(a >> 1) & 0x7fff] = d;
|
||||||
if (a - ((unsigned)(Pico.video.reg[5]&0x7f) << 9) < 0x400)
|
if (a - ((unsigned)(Pico.video.reg[5]&0x7f) << 9) < 0x400)
|
||||||
Pico.est.rendstatus |= PDRAW_DIRTY_SPRITES;
|
Pico.est.rendstatus |= PDRAW_DIRTY_SPRITES;
|
||||||
break;
|
break;
|
||||||
case 3: Pico.m.dirtyPal = 1;
|
case 3: Pico.m.dirtyPal = 1;
|
||||||
Pico.cram [(a>>1)&0x003f]=d; break; // wraps (Desert Strike)
|
PicoMem.cram [(a >> 1) & 0x3f] = d; break;
|
||||||
case 5: Pico.vsram[(a>>1)&0x003f]=d; break;
|
case 5: PicoMem.vsram[(a >> 1) & 0x3f] = d; break;
|
||||||
case 0x81:
|
case 0x81:
|
||||||
a |= Pico.video.addr_u << 16;
|
a |= Pico.video.addr_u << 16;
|
||||||
VideoWrite128(a, d);
|
VideoWrite128(a, d);
|
||||||
|
@ -68,9 +68,9 @@ static unsigned int VideoRead(void)
|
||||||
|
|
||||||
switch (Pico.video.type)
|
switch (Pico.video.type)
|
||||||
{
|
{
|
||||||
case 0: d=Pico.vram [a&0x7fff]; break;
|
case 0: d=PicoMem.vram [a & 0x7fff]; break;
|
||||||
case 8: d=Pico.cram [a&0x003f]; break;
|
case 8: d=PicoMem.cram [a & 0x003f]; break;
|
||||||
case 4: d=Pico.vsram[a&0x003f]; break;
|
case 4: d=PicoMem.vsram[a & 0x003f]; break;
|
||||||
default:elprintf(EL_ANOMALY, "VDP read with bad type %i", Pico.video.type); break;
|
default:elprintf(EL_ANOMALY, "VDP read with bad type %i", Pico.video.type); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ static void DmaSlow(int len, unsigned int source)
|
||||||
SekCyclesBurnRun(CheckDMA());
|
SekCyclesBurnRun(CheckDMA());
|
||||||
|
|
||||||
if ((source & 0xe00000) == 0xe00000) { // Ram
|
if ((source & 0xe00000) == 0xe00000) { // Ram
|
||||||
base = (u16 *)Pico.ram;
|
base = (u16 *)PicoMem.ram;
|
||||||
mask = 0xffff;
|
mask = 0xffff;
|
||||||
}
|
}
|
||||||
else if (PicoAHW & PAHW_MCD)
|
else if (PicoAHW & PAHW_MCD)
|
||||||
|
@ -154,7 +154,7 @@ static void DmaSlow(int len, unsigned int source)
|
||||||
switch (Pico.video.type)
|
switch (Pico.video.type)
|
||||||
{
|
{
|
||||||
case 1: // vram
|
case 1: // vram
|
||||||
r = Pico.vram;
|
r = PicoMem.vram;
|
||||||
if (inc == 2 && !(a & 1) && a + len * 2 < 0x10000
|
if (inc == 2 && !(a & 1) && a + len * 2 < 0x10000
|
||||||
&& !(((source + len - 1) ^ source) & ~mask))
|
&& !(((source + len - 1) ^ source) & ~mask))
|
||||||
{
|
{
|
||||||
|
@ -178,7 +178,7 @@ static void DmaSlow(int len, unsigned int source)
|
||||||
|
|
||||||
case 3: // cram
|
case 3: // cram
|
||||||
Pico.m.dirtyPal = 1;
|
Pico.m.dirtyPal = 1;
|
||||||
r = Pico.cram;
|
r = PicoMem.cram;
|
||||||
for (; len; len--)
|
for (; len; len--)
|
||||||
{
|
{
|
||||||
r[(a / 2) & 0x3f] = base[source++ & mask];
|
r[(a / 2) & 0x3f] = base[source++ & mask];
|
||||||
|
@ -188,7 +188,7 @@ static void DmaSlow(int len, unsigned int source)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5: // vsram
|
case 5: // vsram
|
||||||
r = Pico.vsram;
|
r = PicoMem.vsram;
|
||||||
for (; len; len--)
|
for (; len; len--)
|
||||||
{
|
{
|
||||||
r[(a / 2) & 0x3f] = base[source++ & mask];
|
r[(a / 2) & 0x3f] = base[source++ & mask];
|
||||||
|
@ -219,9 +219,9 @@ static void DmaSlow(int len, unsigned int source)
|
||||||
|
|
||||||
static void DmaCopy(int len)
|
static void DmaCopy(int len)
|
||||||
{
|
{
|
||||||
u16 a=Pico.video.addr;
|
u16 a = Pico.video.addr;
|
||||||
unsigned char *vr = (unsigned char *) Pico.vram;
|
u8 *vr = (u8 *)PicoMem.vram;
|
||||||
unsigned char inc=Pico.video.reg[0xf];
|
u8 inc = Pico.video.reg[0xf];
|
||||||
int source;
|
int source;
|
||||||
elprintf(EL_VDPDMA, "DmaCopy len %i [%u]", len, SekCyclesDone());
|
elprintf(EL_VDPDMA, "DmaCopy len %i [%u]", len, SekCyclesDone());
|
||||||
|
|
||||||
|
@ -246,10 +246,10 @@ static void DmaCopy(int len)
|
||||||
|
|
||||||
static NOINLINE void DmaFill(int data)
|
static NOINLINE void DmaFill(int data)
|
||||||
{
|
{
|
||||||
unsigned short a=Pico.video.addr;
|
u16 a = Pico.video.addr;
|
||||||
unsigned char *vr=(unsigned char *) Pico.vram;
|
u8 *vr = (u8 *)PicoMem.vram;
|
||||||
unsigned char high = (unsigned char) (data >> 8);
|
u8 high = (u8)(data >> 8);
|
||||||
unsigned char inc=Pico.video.reg[0xf];
|
u8 inc = Pico.video.reg[0xf];
|
||||||
int source;
|
int source;
|
||||||
int len, l;
|
int len, l;
|
||||||
|
|
||||||
|
@ -367,7 +367,7 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d)
|
||||||
// try avoiding the sync..
|
// try avoiding the sync..
|
||||||
if (Pico.m.scanline < 224 && (pvid->reg[1]&0x40) &&
|
if (Pico.m.scanline < 224 && (pvid->reg[1]&0x40) &&
|
||||||
!(!pvid->pending &&
|
!(!pvid->pending &&
|
||||||
((pvid->command & 0xc00000f0) == 0x40000010 && Pico.vsram[pvid->addr>>1] == d))
|
((pvid->command & 0xc00000f0) == 0x40000010 && PicoMem.vsram[pvid->addr>>1] == d))
|
||||||
)
|
)
|
||||||
DrawSync(0);
|
DrawSync(0);
|
||||||
|
|
||||||
|
@ -421,7 +421,7 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num == 1 && !(d&0x40) && SekCyclesDone() - line_base_cycles <= 488-390)
|
if (num == 1 && !(d&0x40) && SekCyclesDone() - Pico.t.m68c_line_start <= 488-390)
|
||||||
blank_on = 1;
|
blank_on = 1;
|
||||||
DrawSync(blank_on);
|
DrawSync(blank_on);
|
||||||
pvid->reg[num]=(unsigned char)d;
|
pvid->reg[num]=(unsigned char)d;
|
||||||
|
@ -512,7 +512,7 @@ PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a)
|
||||||
unsigned int d;
|
unsigned int d;
|
||||||
d=pv->status;
|
d=pv->status;
|
||||||
//if (PicoOpt&POPT_ALT_RENDERER) d|=0x0020; // sprite collision (Shadow of the Beast)
|
//if (PicoOpt&POPT_ALT_RENDERER) d|=0x0020; // sprite collision (Shadow of the Beast)
|
||||||
if (SekCyclesDone() - line_base_cycles >= 488-88)
|
if (SekCyclesDone() - Pico.t.m68c_line_start >= 488-88)
|
||||||
d|=0x0004; // H-Blank (Sonic3 vs)
|
d|=0x0004; // H-Blank (Sonic3 vs)
|
||||||
|
|
||||||
d |= ((pv->reg[1]&0x40)^0x40) >> 3; // set V-Blank if display is disabled
|
d |= ((pv->reg[1]&0x40)^0x40) >> 3; // set V-Blank if display is disabled
|
||||||
|
@ -544,7 +544,7 @@ PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a)
|
||||||
{
|
{
|
||||||
unsigned int d;
|
unsigned int d;
|
||||||
|
|
||||||
d = (SekCyclesDone() - line_base_cycles) & 0x1ff; // FIXME
|
d = (SekCyclesDone() - Pico.t.m68c_line_start) & 0x1ff; // FIXME
|
||||||
if (Pico.video.reg[12]&1)
|
if (Pico.video.reg[12]&1)
|
||||||
d = hcounts_40[d];
|
d = hcounts_40[d];
|
||||||
else d = hcounts_32[d];
|
else d = hcounts_32[d];
|
||||||
|
@ -588,7 +588,7 @@ unsigned char PicoVideoRead8CtlL(void)
|
||||||
//if (PicoOpt&POPT_ALT_RENDERER) d|=0x0020; // sprite collision (Shadow of the Beast)
|
//if (PicoOpt&POPT_ALT_RENDERER) d|=0x0020; // sprite collision (Shadow of the Beast)
|
||||||
d |= ((Pico.video.reg[1]&0x40)^0x40) >> 3; // set V-Blank if display is disabled
|
d |= ((Pico.video.reg[1]&0x40)^0x40) >> 3; // set V-Blank if display is disabled
|
||||||
d |= (Pico.video.pending_ints&0x20)<<2; // V-int pending?
|
d |= (Pico.video.pending_ints&0x20)<<2; // V-int pending?
|
||||||
if (SekCyclesDone() - line_base_cycles >= 488-88) d |= 4; // H-Blank
|
if (SekCyclesDone() - Pico.t.m68c_line_start >= 488-88) d |= 4; // H-Blank
|
||||||
Pico.video.pending = 0;
|
Pico.video.pending = 0;
|
||||||
elprintf(EL_SR, "SR read (l): %02x @ %06x", d, SekPc);
|
elprintf(EL_SR, "SR read (l): %02x @ %06x", d, SekPc);
|
||||||
return d;
|
return d;
|
||||||
|
@ -603,7 +603,7 @@ unsigned char PicoVideoRead8HV_H(void)
|
||||||
// FIXME: broken
|
// FIXME: broken
|
||||||
unsigned char PicoVideoRead8HV_L(void)
|
unsigned char PicoVideoRead8HV_L(void)
|
||||||
{
|
{
|
||||||
u32 d = (SekCyclesDone() - line_base_cycles) & 0x1ff; // FIXME
|
u32 d = (SekCyclesDone() - Pico.t.m68c_line_start) & 0x1ff; // FIXME
|
||||||
if (Pico.video.reg[12]&1)
|
if (Pico.video.reg[12]&1)
|
||||||
d = hcounts_40[d];
|
d = hcounts_40[d];
|
||||||
else d = hcounts_32[d];
|
else d = hcounts_32[d];
|
||||||
|
|
|
@ -49,7 +49,7 @@ SRCS_COMMON += $(R)pico/draw_arm.S $(R)pico/draw2_arm.S
|
||||||
endif
|
endif
|
||||||
ifeq "$(asm_memory)" "1"
|
ifeq "$(asm_memory)" "1"
|
||||||
DEFINES += _ASM_MEMORY_C
|
DEFINES += _ASM_MEMORY_C
|
||||||
SRCS_COMMON += $(R)pico/memory_arm.s
|
SRCS_COMMON += $(R)pico/memory_arm.S
|
||||||
endif
|
endif
|
||||||
ifeq "$(asm_ym2612)" "1"
|
ifeq "$(asm_ym2612)" "1"
|
||||||
DEFINES += _ASM_YM2612_C
|
DEFINES += _ASM_YM2612_C
|
||||||
|
@ -62,7 +62,7 @@ SRCS_COMMON += $(R)pico/cd/misc_arm.s
|
||||||
endif
|
endif
|
||||||
ifeq "$(asm_cdmemory)" "1"
|
ifeq "$(asm_cdmemory)" "1"
|
||||||
DEFINES += _ASM_CD_MEMORY_C
|
DEFINES += _ASM_CD_MEMORY_C
|
||||||
SRCS_COMMON += $(R)pico/cd/memory_arm.s
|
SRCS_COMMON += $(R)pico/cd/memory_arm.S
|
||||||
endif
|
endif
|
||||||
ifeq "$(asm_32xdraw)" "1"
|
ifeq "$(asm_32xdraw)" "1"
|
||||||
DEFINES += _ASM_32X_DRAW
|
DEFINES += _ASM_32X_DRAW
|
||||||
|
|
|
@ -889,7 +889,7 @@ int emu_save_load_game(int load, int sram)
|
||||||
{
|
{
|
||||||
if (PicoOpt & POPT_EN_MCD_RAMCART) {
|
if (PicoOpt & POPT_EN_MCD_RAMCART) {
|
||||||
sram_size = 0x12000;
|
sram_size = 0x12000;
|
||||||
sram_data = SRam.data;
|
sram_data = Pico.sv.data;
|
||||||
if (sram_data)
|
if (sram_data)
|
||||||
memcpy32((int *)sram_data, (int *)Pico_mcd->bram, 0x2000/4);
|
memcpy32((int *)sram_data, (int *)Pico_mcd->bram, 0x2000/4);
|
||||||
} else {
|
} else {
|
||||||
|
@ -898,11 +898,11 @@ int emu_save_load_game(int load, int sram)
|
||||||
truncate = 0; // the .brm may contain RAM cart data after normal brm
|
truncate = 0; // the .brm may contain RAM cart data after normal brm
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sram_size = SRam.size;
|
sram_size = Pico.sv.size;
|
||||||
sram_data = SRam.data;
|
sram_data = Pico.sv.data;
|
||||||
}
|
}
|
||||||
if (sram_data == NULL)
|
if (sram_data == NULL)
|
||||||
return 0; // SRam forcefully disabled for this game
|
return 0; // cart saves forcefully disabled for this game
|
||||||
|
|
||||||
if (load)
|
if (load)
|
||||||
{
|
{
|
||||||
|
@ -1262,9 +1262,9 @@ void emu_init(void)
|
||||||
void emu_finish(void)
|
void emu_finish(void)
|
||||||
{
|
{
|
||||||
// save SRAM
|
// save SRAM
|
||||||
if ((currentConfig.EmuOpt & EOPT_EN_SRAM) && SRam.changed) {
|
if ((currentConfig.EmuOpt & EOPT_EN_SRAM) && Pico.sv.changed) {
|
||||||
emu_save_load_game(0, 1);
|
emu_save_load_game(0, 1);
|
||||||
SRam.changed = 0;
|
Pico.sv.changed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(currentConfig.EmuOpt & EOPT_NO_AUTOSVCFG)) {
|
if (!(currentConfig.EmuOpt & EOPT_NO_AUTOSVCFG)) {
|
||||||
|
@ -1514,10 +1514,10 @@ void emu_loop(void)
|
||||||
emu_set_fastforward(0);
|
emu_set_fastforward(0);
|
||||||
|
|
||||||
// save SRAM
|
// save SRAM
|
||||||
if ((currentConfig.EmuOpt & EOPT_EN_SRAM) && SRam.changed) {
|
if ((currentConfig.EmuOpt & EOPT_EN_SRAM) && Pico.sv.changed) {
|
||||||
plat_status_msg_busy_first("Writing SRAM/BRAM...");
|
plat_status_msg_busy_first("Writing SRAM/BRAM...");
|
||||||
emu_save_load_game(0, 1);
|
emu_save_load_game(0, 1);
|
||||||
SRam.changed = 0;
|
Pico.sv.changed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pemu_loop_end();
|
pemu_loop_end();
|
||||||
|
|
|
@ -3,10 +3,22 @@
|
||||||
|
|
||||||
#include "../pico/pico_int.h"
|
#include "../pico/pico_int.h"
|
||||||
|
|
||||||
#define DUMP(f, field) \
|
#define DUMP(f, prefix, type, field) \
|
||||||
fprintf(f, "#define %-20s 0x%02x\n", \
|
fprintf(f, "#define %-20s 0x%02x\n", \
|
||||||
"OFS_" #field, \
|
prefix #field, (int)offsetof(type, field))
|
||||||
(int)offsetof(struct PicoEState, field))
|
|
||||||
|
#define DUMP_P(f, field) \
|
||||||
|
fprintf(f, "#define %-20s 0x%04x\n", \
|
||||||
|
"OFS_Pico_" #field, (char *)&p.field - (char *)&p)
|
||||||
|
|
||||||
|
#define DUMP_PS(f, s1, field) \
|
||||||
|
fprintf(f, "#define %-20s 0x%04x\n", \
|
||||||
|
"OFS_Pico_" #s1 "_" #field, (char *)&p.s1.field - (char *)&p)
|
||||||
|
|
||||||
|
#define DUMP_EST(f, field) \
|
||||||
|
DUMP(f, "OFS_EST_", struct PicoEState, field)
|
||||||
|
|
||||||
|
extern struct Pico p;
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -21,16 +33,31 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(f, "/* autogenerated by %s, do not edit */\n", argv[0]);
|
fprintf(f, "/* autogenerated by %s, do not edit */\n", argv[0]);
|
||||||
DUMP(f, DrawScanline);
|
DUMP_PS(f, video, reg);
|
||||||
DUMP(f, rendstatus);
|
DUMP_PS(f, m, rotate);
|
||||||
DUMP(f, DrawLineDest);
|
DUMP_PS(f, m, z80Run);
|
||||||
DUMP(f, HighCol);
|
DUMP_PS(f, m, dirtyPal);
|
||||||
DUMP(f, HighPreSpr);
|
DUMP_PS(f, m, hardware);
|
||||||
DUMP(f, Pico_video);
|
DUMP_PS(f, m, z80_reset);
|
||||||
DUMP(f, Pico_vram);
|
DUMP_PS(f, m, sram_reg);
|
||||||
DUMP(f, PicoOpt);
|
DUMP_P (f, sv);
|
||||||
DUMP(f, Draw2FB);
|
DUMP_PS(f, sv, data);
|
||||||
DUMP(f, HighPal);
|
DUMP_PS(f, sv, start);
|
||||||
|
DUMP_PS(f, sv, end);
|
||||||
|
DUMP_PS(f, sv, flags);
|
||||||
|
DUMP_P (f, rom);
|
||||||
|
DUMP_P (f, romsize);
|
||||||
|
DUMP_EST(f, DrawScanline);
|
||||||
|
DUMP_EST(f, rendstatus);
|
||||||
|
DUMP_EST(f, DrawLineDest);
|
||||||
|
DUMP_EST(f, HighCol);
|
||||||
|
DUMP_EST(f, HighPreSpr);
|
||||||
|
DUMP_EST(f, Pico);
|
||||||
|
DUMP_EST(f, PicoMem_vram);
|
||||||
|
DUMP_EST(f, PicoMem_cram);
|
||||||
|
DUMP_EST(f, PicoOpt);
|
||||||
|
DUMP_EST(f, Draw2FB);
|
||||||
|
DUMP_EST(f, HighPal);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue