X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=Pico%2FMemory.c;h=bdcfaabdf925c4dd45a6cd942cb004f361a96b5a;hb=5f9a0d16309e732ad09b4f5827422cf658bed8c2;hp=22bd7ad49760bbc2c6a063051158e955161a6c99;hpb=2aa27095f2dbf5b38950fcb1f856d5ffc6a70361;p=picodrive.git diff --git a/Pico/Memory.c b/Pico/Memory.c index 22bd7ad..bdcfaab 100644 --- a/Pico/Memory.c +++ b/Pico/Memory.c @@ -105,7 +105,7 @@ PICO_INTERNAL_ASM void PicoMemReset(void) int PadRead(int i) { int pad,value,data_reg; - pad=~PicoPad[i]; // Get inverse of pad MXYZ SACB RLDU + pad=~PicoPadInt[i]; // Get inverse of pad MXYZ SACB RLDU data_reg=Pico.ioports[i+1]; // orr the bits, which are set as output @@ -344,9 +344,9 @@ PICO_INTERNAL_ASM u32 PicoRead8(u32 a) log_io(a, 8, 0); if ((a&0xff4000)==0xa00000) { d=z80Read8(a); goto end; } // Z80 Ram - if ((a&0xe700e0)==0xc00000) // VDP - d=PicoVideoRead(a); - else d=OtherRead16(a&~1, 8); + if ((a&0xe700e0)==0xc00000) { d=PicoVideoRead8(a); goto end; } // VDP + + d=OtherRead16(a&~1, 8); if ((a&1)==0) d>>=8; end: @@ -465,7 +465,7 @@ void PicoWrite16(u32 a,u16 d) static void PicoWrite32(u32 a,u32 d) { - elprintf(EL_IO, "w32: %06x, %08x", a&0xffffff, d); + elprintf(EL_IO, "w32: %06x, %08x @%06x", a&0xffffff, d, SekPc); #ifdef EMU_CORE_DEBUG lastwrite_cyc_d[lwp_cyc++&15] = d; #endif @@ -700,7 +700,7 @@ static int get_scanline(int is_from_z80) return Pico.m.scanline; } -/* probably not should be in this file, but it's near related code here */ +/* probably should not be in this file, but it's near related code here */ void ym2612_sync_timers(int z80_cycles, int mode_old, int mode_new) { int xcycles = z80_cycles << 8; @@ -719,12 +719,10 @@ void ym2612_sync_timers(int z80_cycles, int mode_old, int mode_new) if ((mode_old ^ mode_new) & 1) // turning on/off { - if (mode_old & 1) { - timer_a_offset = timer_a_next_oflow - xcycles; + if (mode_old & 1) timer_a_next_oflow = TIMER_NO_OFLOW; - } else - timer_a_next_oflow = xcycles + timer_a_offset; + timer_a_next_oflow = xcycles + timer_a_step; } if (mode_new & 1) elprintf(EL_YMTIMER, "timer a upd to %i @ %i", timer_a_next_oflow>>8, z80_cycles); @@ -736,12 +734,10 @@ void ym2612_sync_timers(int z80_cycles, int mode_old, int mode_new) if ((mode_old ^ mode_new) & 2) { - if (mode_old & 2) { - timer_b_offset = timer_b_next_oflow - xcycles; + if (mode_old & 2) timer_b_next_oflow = TIMER_NO_OFLOW; - } else - timer_b_next_oflow = xcycles + timer_b_offset; + timer_b_next_oflow = xcycles + timer_b_step; } if (mode_new & 2) elprintf(EL_YMTIMER, "timer b upd to %i @ %i", timer_b_next_oflow>>8, z80_cycles); @@ -792,8 +788,9 @@ int ym2612_write_local(u32 a, u32 d, int is_from_z80) ym2612.OPN.ST.TA = TAnew; //ym2612.OPN.ST.TAC = (1024-TAnew)*18; //ym2612.OPN.ST.TAT = 0; - timer_a_step = timer_a_offset = TIMER_A_TICK_ZCYCLES * (1024 - TAnew); + timer_a_step = TIMER_A_TICK_ZCYCLES * (1024 - TAnew); if (ym2612.OPN.ST.mode & 1) { + // this is not right, should really be done on overflow only int cycles = is_from_z80 ? z80_cyclesDone() : cycles_68k_to_z80(SekCyclesDone()); timer_a_next_oflow = (cycles << 8) + timer_a_step; } @@ -807,7 +804,7 @@ int ym2612_write_local(u32 a, u32 d, int is_from_z80) ym2612.OPN.ST.TB = d; //ym2612.OPN.ST.TBC = (256-d) * 288; //ym2612.OPN.ST.TBT = 0; - timer_b_step = timer_b_offset = TIMER_B_TICK_ZCYCLES * (256 - d); // 262800 + timer_b_step = TIMER_B_TICK_ZCYCLES * (256 - d); // 262800 if (ym2612.OPN.ST.mode & 2) { int cycles = is_from_z80 ? z80_cyclesDone() : cycles_68k_to_z80(SekCyclesDone()); timer_b_next_oflow = (cycles << 8) + timer_b_step; @@ -966,11 +963,11 @@ void ym2612_unpack_state(void) tac = (1024 - ym2612.OPN.ST.TA) << 16; tbc = (256 - ym2612.OPN.ST.TB) << 16; if (ym2612.OPN.ST.mode & 1) - timer_a_next_oflow = (double)(tac - tat) / (double)tac * timer_a_step; + timer_a_next_oflow = (int)((double)(tac - tat) / (double)tac * timer_a_step); else timer_a_next_oflow = TIMER_NO_OFLOW; if (ym2612.OPN.ST.mode & 2) - timer_b_next_oflow = (double)(tbc - tbt) / (double)tbc * timer_b_step; + timer_b_next_oflow = (int)((double)(tbc - tbt) / (double)tbc * timer_b_step); else timer_b_next_oflow = TIMER_NO_OFLOW; elprintf(EL_YMTIMER, "load: %i/%i, timer_a_next_oflow %i", tat>>16, tac>>16, timer_a_next_oflow >> 8); @@ -986,8 +983,7 @@ PICO_INTERNAL unsigned char z80_read(unsigned short a) if ((a>>13)==2) // 0x4000-0x5fff (Charles MacDonald) { - if (PicoOpt&POPT_EN_FM) ret = ym2612_read_local_z80(); - return ret; + return ym2612_read_local_z80(); } if (a>=0x8000)