Previous 15994 Revisions Next

r9421 Wednesday 20th October, 2010 at 13:59:56 UTC by Angelo Salese
[SNES]: Fixed regressed PPU open bus behaviour, fixes background graphics in Super Kick Boxing
[src/mame/machine]snes.c
[src/mame/video]snes.c

src/mame/machine/snes.c
r9420r9421
4848#include "machine/snesst10.c"
4949#include "machine/snesbsx.c"
5050
51#define USE_CYCLE_STEAL 1
52
5153/*************************************
5254
5355    Timers
r9420r9421
844846
845847*/
846848
849#if USE_CYCLE_STEAL
847850/*FIXME: missing work RAM access steal / we need to do this less "aggressive" otherwise we lose too much CPU horsepower, why? */
848851static int snes_bank_0x00_0x3f_cycles(running_machine *machine,UINT32 offset)
849852{
r9420r9421
905908
906909   return 0; //TODO: 6
907910}
911#endif
908912
909913/* 0x000000 - 0x2fffff */
910914READ8_HANDLER( snes_r_bank1 )
r9420r9421
957961   else
958962      value = snes_ram[offset];
959963
964   #if USE_CYCLE_STEAL
960965   if(!space->debugger_access())
961966      cpu_adjust_icount(space->cpu, -snes_bank_0x00_0x3f_cycles(space->machine, offset));
967   #endif
962968
963969   return value;
964970}
r9420r9421
10201026   else
10211027      value = snes_ram[0x300000 + offset];
10221028
1029   #if USE_CYCLE_STEAL
10231030   if(!space->debugger_access())
10241031      cpu_adjust_icount(space->cpu, -snes_bank_0x00_0x3f_cycles(space->machine, offset));
1032   #endif
10251033
10261034   return value;
10271035}
r9420r9421
10611069   else                                 /* Mode 21 & 25 + SuperFX games */
10621070      value = snes_ram[0x400000 + offset];
10631071
1072   #if USE_CYCLE_STEAL
10641073   if(!space->debugger_access())
10651074      cpu_adjust_icount(space->cpu, -8);
1075   #endif
10661076
10671077   return value;
10681078}
r9420r9421
10991109   else if (state->cart[0].mode & 0x0a)               /* Mode 21 & 25 */
11001110      value = snes_ram[0x600000 + offset];
11011111
1112   #if USE_CYCLE_STEAL
11021113   if(!space->debugger_access())
11031114      cpu_adjust_icount(space->cpu, -8);
1115   #endif
11041116
11051117   return value;
11061118}
r9420r9421
11351147   else
11361148      value = snes_ram[0x700000 + offset];
11371149
1150   #if USE_CYCLE_STEAL
11381151   if(!space->debugger_access())
11391152      cpu_adjust_icount(space->cpu, -8);
1153   #endif
11401154
11411155   return value;
11421156}
r9420r9421
11831197   else
11841198      value = snes_ram[0x800000 + offset];
11851199
1200   #if USE_CYCLE_STEAL
11861201   if(!space->debugger_access())
11871202      cpu_adjust_icount(space->cpu, -snes_bank_0x80_0xbf_cycles(space->machine, offset));
1203   #endif
11881204
11891205   return value;
11901206}
r9420r9421
12361252   else                        /* Mode 21 & 25 + SuperFX Games */
12371253      value = snes_ram[0xc00000 + offset];
12381254
1255   #if USE_CYCLE_STEAL
12391256   if(!space->debugger_access())
12401257      cpu_adjust_icount(space->cpu, -((snes_ram[MEMSEL] & 1) ? 6 : 8));
1258   #endif
12411259
12421260   return value;
12431261}
r9420r9421
12901308   else
12911309      logerror( "(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset );
12921310
1311   #if USE_CYCLE_STEAL
12931312   if(!space->debugger_access())
12941313      cpu_adjust_icount(space->cpu, -snes_bank_0x00_0x3f_cycles(space->machine, offset));
1314   #endif
12951315}
12961316
12971317/* 0x300000 - 0x3fffff */
r9420r9421
13471367   else
13481368      logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x300000);
13491369
1370   #if USE_CYCLE_STEAL
13501371   if(!space->debugger_access())
13511372      cpu_adjust_icount(space->cpu, -snes_bank_0x00_0x3f_cycles(space->machine, offset));
1373   #endif
13521374}
13531375
13541376/* 0x600000 - 0x6fffff */
r9420r9421
13731395   else if (state->cart[0].mode & 0x0a)
13741396      logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x600000);
13751397
1398   #if USE_CYCLE_STEAL
13761399   if(!space->debugger_access())
13771400      cpu_adjust_icount(space->cpu, -8);
1401   #endif
13781402}
13791403
13801404/* 0x700000 - 0x7dffff */
r9420r9421
13981422   else if (state->cart[0].mode & 0x0a)
13991423      logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x700000);
14001424
1425   #if USE_CYCLE_STEAL
14011426   if(!space->debugger_access())
14021427      cpu_adjust_icount(space->cpu, -8);
1428   #endif
14031429}
14041430
14051431
r9420r9421
14461472   else
14471473      logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x800000);
14481474
1475   #if USE_CYCLE_STEAL
14491476   if(!space->debugger_access())
14501477      cpu_adjust_icount(space->cpu, -snes_bank_0x80_0xbf_cycles(space->machine, offset));
1478   #endif
14511479}
14521480
14531481
r9420r9421
14861514   else if (state->cart[0].mode & 0x0a)
14871515      logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0xc00000);
14881516
1517   #if USE_CYCLE_STEAL
14891518   if(!space->debugger_access())
14901519      cpu_adjust_icount(space->cpu, -((snes_ram[MEMSEL] & 1) ? 6 : 8));
1520   #endif
14911521}
14921522
14931523
r9420r9421
15971627
15981628   // SNES hcounter has a 0-339 range.  hblank starts at counter 260.
15991629   // clayfighter sets an HIRQ at 260, apparently it wants it to be before hdma kicks off, so we'll delay 2 pixels.
1600   state->hblank_offset = 268;
1630   state->hblank_offset = 274;
16011631   timer_adjust_oneshot(state->hblank_timer, machine->primary_screen->time_until_pos(((snes_ram[STAT78] & 0x10) == SNES_NTSC) ? SNES_VTOTAL_NTSC - 1 : SNES_VTOTAL_PAL - 1, state->hblank_offset), 0);
16021632}
16031633
r9420r9421
19882018{
19892019   snes_state *state = space->machine->driver_data<snes_state>();
19902020
2021   #if USE_CYCLE_STEAL
19912022   /* every byte transfer takes 8 master cycles */
19922023   cpu_adjust_icount(space->cpu,-8);
2024   #endif
19932025
19942026   if (state->dma_channel[dma].dmap & 0x80)   /* PPU->CPU */
19952027   {
r9420r9421
21972229
21982230   /* FIXME: we also need to round to the nearest 8 master cycles */
21992231
2232   #if USE_CYCLE_STEAL
22002233   /* overhead steals 8 master cycles, correct? */
22012234   cpu_adjust_icount(space->cpu,-8);
2235   #endif
22022236
22032237   /* Assume priority of the 8 DMA channels is 0-7 */
22042238   for (i = 0; i < 8; i++)
r9420r9421
23092343         state->dma_channel[i].src_addr = abus;
23102344         state->dma_channel[i].trans_size = 0;
23112345
2346         #if USE_CYCLE_STEAL
23122347         /* active channel takes 8 master cycles */
23132348         cpu_adjust_icount(space->cpu,-8);
2349         #endif
23142350      }
23152351   }
23162352
23172353   /* finally, take yet another 8 master cycles for the aforementioned overhead */
2354   #if USE_CYCLE_STEAL
23182355   cpu_adjust_icount(space->cpu,-8);
2356   #endif
23192357}
23202358
23212359READ8_HANDLER( superfx_r_bank1 )
src/mame/video/snes.c
r9420r9421
22332233         return snes_ppu.ppu2_open_bus;
22342234   }
22352235
2236   return snes_ppu.ppu1_open_bus;
2236   /* note: remaining registers (Namely TM in Super Kick Boxing) returns MDR open bus, not PPU Open Bus! */
2237   return snes_open_bus_r(space, 0);
22372238}
22382239
22392240

Previous 15994 Revisions Next


© 1998-2018 The MESS Team