Previous 199869 Revisions Next

r22031 Saturday 23rd March, 2013 at 10:09:11 UTC by Fabio Priuli
(MESS) megadriv.c: moved some more global variables to driver class. nw.
[src/mame/drivers]segac2.c segas18.c
[src/mame/includes]megadriv.h
[src/mame/machine]mega32x.c mega32x.h megacd.c megacd.h megadriv.c megavdp.c megavdp.h
[src/mess/drivers]megadriv.c

trunk/src/mame/drivers/segac2.c
r22030r22031
112112
113113MACHINE_RESET_MEMBER(segac2_state,segac2)
114114{
115//  megadriv_framerate = 60;
116
117
118115//  megadriv_scanline_timer = machine().device<timer_device>("md_scan_timer");
119116//  megadriv_scanline_timer->adjust(attotime::zero);
120117   segac2_bg_pal_lookup[0] = 0x00;
r22030r22031
18621859
18631860   state->m_prot_func = func;
18641861
1865   genvdp_use_cram = 0;
1866
18671862   if (upd != NULL)
18681863      machine.device("maincpu")->memory().space(AS_PROGRAM).install_legacy_write_handler(*upd, 0x880000, 0x880001, 0, 0x13fefe, FUNC(segac2_upd7759_w));
18691864}
trunk/src/mame/drivers/segas18.c
r22030r22031
169169   segaic16_tileram_0 = reinterpret_cast<UINT16 *>(memshare("tileram")->ptr());
170170   segaic16_textram_0 = reinterpret_cast<UINT16 *>(memshare("textram")->ptr());
171171
172   // configure VDP
173   m_vdp->set_use_cram(1);
174   m_vdp->set_vdp_pal(FALSE);
175   m_vdp->set_framerate(60);
176   m_vdp->set_total_scanlines(262);
177
172178   // save state
173179   save_item(NAME(m_mcu_data));
174180   save_item(NAME(m_lghost_value));
r22030r22031
202208   segaic16_tilemap_reset(machine(), 0);
203209
204210   megadriv_reset_vdp(machine());
205   genvdp_use_cram = 1;
206211
207212   // if we are running with a real live 8751, we need to boost the interleave at startup
208213   if (m_mcu != NULL && m_mcu->type() == I8751)
trunk/src/mame/machine/megavdp.c
r22030r22031
1616
1717
1818/* external gunk still has dependencies on these */
19int megadriv_framerate;
2019int megadrive_total_scanlines;
2120int megadrive_vblank_flag = 0;
22int genesis_scanline_counter = 0;
2321
2422
25// hacks for C2
26int genvdp_use_cram = 0; // c2 uses it's own palette ram
27
28
29int megadrive_region_export;
30int megadrive_region_pal;
31
32
33
34
35
3623void genesis_vdp_sndirqline_callback_default(running_machine &machine, bool state)
3724{
3825   // if you haven't actually hooked this up....
r22030r22031
163150   save_item(NAME(megadrive_imode));
164151   save_item(NAME(megadrive_irq6_pending));
165152   save_item(NAME(megadrive_irq4_pending));
166   save_item(NAME(megadrive_visible_scanlines));
167   save_item(NAME(megadrive_irq6_scanline));
168   save_item(NAME(megadrive_z80irq_scanline));
153   save_item(NAME(m_visible_scanlines));
154   save_item(NAME(m_irq6_scanline));
155   save_item(NAME(m_z80irq_scanline));
156//  save_item(NAME(m_total_scanlines));
157   save_item(NAME(m_scanline_counter));
169158
170159   m_sprite_renderline = auto_alloc_array(machine(), UINT8, 1024);
171160   m_highpri_renderline = auto_alloc_array(machine(), UINT8, 320);
r22030r22031
218207   megadrive_imode = 0;
219208   megadrive_irq6_pending = 0;
220209   megadrive_irq4_pending = 0;
210   m_scanline_counter = 0;
221211}
222212
223213void sega_genesis_vdp_device::device_reset_old()
r22030r22031
225215   // other stuff, are we sure we want to set some of these every reset?
226216   // it's called from MACHINE_RESET( megadriv )
227217   megadrive_total_scanlines = 262;
228   megadrive_visible_scanlines = 224;
229   megadrive_irq6_scanline = 224;
230   megadrive_z80irq_scanline = 226;
218   m_visible_scanlines = 224;
219   m_irq6_scanline = 224;
220   m_z80irq_scanline = 226;
231221}
232222
233223
r22030r22031
277267   m_cram[offset] = data;
278268
279269   //logerror("Wrote to CRAM addr %04x data %04x\n",m_vdp_address&0xfffe,m_cram[m_vdp_address>>1]);
280   if (genvdp_use_cram)
270   if (m_vdp_use_cram)
281271   {
282272      int r,g,b;
283273      r = ((data >> 1)&0x07);
r22030r22031
10471037         (vblank << 3) |
10481038         (megadrive_hblank_flag << 2) |
10491039         (megadrive_dma_active << 1 ) |
1050         (megadrive_region_pal<<0); // PAL MODE FLAG checked by striker for region prot..
1040         (m_vdp_pal << 0); // PAL MODE FLAG checked by striker for region prot..
10511041}
10521042
10531043static const UINT8 vc_ntsc_224[] =
r22030r22031
11511141
11521142      time_elapsed_since_megadriv_scanline_timer = megadriv_scanline_timer->time_elapsed();
11531143
1154      if (time_elapsed_since_megadriv_scanline_timer.attoseconds<(ATTOSECONDS_PER_SECOND/megadriv_framerate /megadrive_total_scanlines))
1144      if (time_elapsed_since_megadriv_scanline_timer.attoseconds<(ATTOSECONDS_PER_SECOND/m_framerate /megadrive_total_scanlines))
11551145      {
1156         value4 = (UINT16)(MAX_HPOSITION*((double)(time_elapsed_since_megadriv_scanline_timer.attoseconds) / (double)(ATTOSECONDS_PER_SECOND/megadriv_framerate /megadrive_total_scanlines)));
1146         value4 = (UINT16)(MAX_HPOSITION*((double)(time_elapsed_since_megadriv_scanline_timer.attoseconds) / (double)(ATTOSECONDS_PER_SECOND/m_framerate /megadrive_total_scanlines)));
11571147      }
11581148      else /* in some cases (probably due to rounding errors) we get some stupid results (the odd huge value where the time elapsed is much higher than the scanline time??!).. hopefully by clamping the result to the maximum we limit errors */
11591149      {
r22030r22031
11721162int sega_genesis_vdp_device::genesis_get_scanline_counter(running_machine &machine)
11731163{
11741164   if (!m_use_alt_timing)
1175      return genesis_scanline_counter;
1165      return m_scanline_counter;
11761166   else
11771167      return machine.primary_screen->vpos();
11781168}
r22030r22031
11981188   }
11991189
12001190   if (MEGADRIVE_REG01_240_LINE)
1201   {
1202      if (!megadrive_region_pal)
1203      {
1204         vpos = vc_ntsc_240[vpos%megadrive_total_scanlines];
1205      }
1206      else
1207      {
1208         vpos = vc_pal_240[vpos%megadrive_total_scanlines];
1209      }
1210
1211   }
1191      vpos = m_vdp_pal ? vc_pal_240[vpos % megadrive_total_scanlines] : vc_ntsc_240[vpos % megadrive_total_scanlines];
12121192   else
1213   {
1214      if (!megadrive_region_pal)
1215      {
1216         vpos = vc_ntsc_224[vpos%megadrive_total_scanlines];
1217      }
1218      else
1219      {
1220         vpos = vc_pal_224[vpos%megadrive_total_scanlines];
1221      }
1222   }
1193      vpos = m_vdp_pal ? vc_pal_224[vpos % megadrive_total_scanlines] : vc_ntsc_224[vpos % megadrive_total_scanlines];
12231194
12241195   if (hpos>0xf7) hpos -=0x49;
12251196
r22030r22031
27182689void sega_genesis_vdp_device::genesis_render_scanline(running_machine &machine)
27192690{
27202691   int scanline = genesis_get_scanline_counter(machine);
2721   if (scanline>=0 && scanline<megadrive_visible_scanlines)
2692   if (scanline >= 0 && scanline < m_visible_scanlines)
27222693   {
27232694      //if (MEGADRIVE_REG01_DMA_ENABLE==0) mame_printf_debug("off\n");
27242695      genesis_render_spriteline_to_spritebuffer(genesis_get_scanline_counter(machine));
r22030r22031
27442715   sega_32x_device *_32xdev = machine.device<sega_32x_device>("sega32x"); // take this out of the VDP eventually
27452716
27462717
2747   if (genesis_get_scanline_counter(machine)!=(megadrive_total_scanlines-1))
2718   if (genesis_get_scanline_counter(machine) != (megadrive_total_scanlines - 1))
27482719   {
2749      if (!m_use_alt_timing) genesis_scanline_counter++;
2720      if (!m_use_alt_timing) m_scanline_counter++;
27502721//      mame_printf_debug("scanline %d\n",genesis_get_scanline_counter(machine));
27512722      megadriv_render_timer->adjust(attotime::from_usec(1));
27522723
2753      if (genesis_get_scanline_counter(machine)==megadrive_irq6_scanline )
2724      if (genesis_get_scanline_counter(machine) == m_irq6_scanline)
27542725      {
27552726      //  mame_printf_debug("x %d",genesis_get_scanline_counter(machine));
27562727         irq6_on_timer->adjust(attotime::from_usec(6));
r22030r22031
27582729         megadrive_vblank_flag = 1;
27592730
27602731         // 32x interrupt!
2761         if (_32xdev) _32xdev->_32x_scanline_cb0(machine);
2732         if (_32xdev) _32xdev->_32x_scanline_cb0();
27622733
27632734      }
27642735
27652736
27662737
2767      if (_32xdev) _32xdev->_32x_check_framebuffer_swap();
2738      if (_32xdev) _32xdev->_32x_check_framebuffer_swap(m_scanline_counter >= m_irq6_scanline);
27682739
27692740
27702741   //  if (genesis_get_scanline_counter(machine)==0) m_irq4counter = MEGADRIVE_REG0A_HINT_VALUE;
r22030r22031
27972768      //if (genesis_get_scanline_counter(machine)==0) irq4_on_timer->adjust(attotime::from_usec(2));
27982769
27992770
2800      if (_32xdev) _32xdev->_32x_scanline_cb1();
2771      if (_32xdev) _32xdev->_32x_scanline_cb1(m_scanline_counter);
28012772
28022773
2803      if (genesis_get_scanline_counter(machine) == megadrive_z80irq_scanline)
2774      if (genesis_get_scanline_counter(machine) == m_z80irq_scanline)
28042775      {
28052776         m_genesis_vdp_sndirqline_callback(machine, true);
28062777      }
2807      if (genesis_get_scanline_counter(machine) == megadrive_z80irq_scanline + 1)
2778      if (genesis_get_scanline_counter(machine) == m_z80irq_scanline + 1)
28082779      {
28092780         m_genesis_vdp_sndirqline_callback(machine, false);
28102781      }
28112782   }
28122783   else /* pretend we're still on the same scanline to compensate for rounding errors */
28132784   {
2814      if (!m_use_alt_timing) genesis_scanline_counter = megadrive_total_scanlines - 1;
2785      if (!m_use_alt_timing) m_scanline_counter = megadrive_total_scanlines - 1;
28152786   }
28162787
28172788}
r22030r22031
28302801   //megadrive_irq6_pending = 0; /* NO! (breaks warlock) */
28312802
28322803   /* Set it to -1 here, so it becomes 0 when the first timer kicks in */
2833   if (!m_use_alt_timing) genesis_scanline_counter = -1;
2804   if (!m_use_alt_timing) m_scanline_counter = -1;
28342805   m_sprite_collision=0;//? when to reset this ..
28352806   megadrive_imode = MEGADRIVE_REG0C_INTERLEAVE; // can't change mid-frame..
28362807   m_imode_odd_frame^=1;
28372808//      machine.device("genesis_snd_z80")->execute().set_input_line(0, CLEAR_LINE); // if the z80 interrupt hasn't happened by now, clear it..
28382809
2839
2840
28412810   if (MEGADRIVE_REG01_240_LINE)
28422811   {
2843      if (!megadrive_region_pal)
2844      {
2845         /* this is invalid! */
2846         megadrive_visible_scanlines = 240;
2847         megadrive_total_scanlines = 262;
2848         megadrive_irq6_scanline = 240;
2849         megadrive_z80irq_scanline = 240;
2850      }
2851      else
2852      {
2853         megadrive_visible_scanlines = 240;
2854         megadrive_total_scanlines = 313;
2855         megadrive_irq6_scanline = 240;
2856         megadrive_z80irq_scanline = 240;
2857      }
2812      /* this is invalid in PAL! */
2813      megadrive_total_scanlines = m_base_total_scanlines;
2814      m_visible_scanlines = 240;
2815      m_irq6_scanline = 240;
2816      m_z80irq_scanline = 240;
28582817   }
28592818   else
28602819   {
2861      if (!megadrive_region_pal)
2862      {
2863         megadrive_visible_scanlines = 224;
2864         megadrive_total_scanlines=262;
2865         megadrive_irq6_scanline = 224;
2866         megadrive_z80irq_scanline = 224;
2867      }
2868      else
2869      {
2870         megadrive_visible_scanlines = 224;
2871         megadrive_total_scanlines=313;
2872         megadrive_irq6_scanline = 224;
2873         megadrive_z80irq_scanline = 224;
2874      }
2820      megadrive_total_scanlines = m_base_total_scanlines;
2821      m_visible_scanlines = 224;
2822      m_irq6_scanline = 224;
2823      m_z80irq_scanline = 224;
28752824   }
28762825
2877   if (megadrive_imode==3)
2826   if (megadrive_imode == 3)
28782827   {
2879      megadrive_visible_scanlines<<=1;
2880      megadrive_total_scanlines<<=1;
2881      megadrive_irq6_scanline <<=1;
2882      megadrive_z80irq_scanline <<=1;
2828      m_visible_scanlines <<= 1;
2829      megadrive_total_scanlines <<= 1;
2830      m_irq6_scanline <<= 1;
2831      m_z80irq_scanline <<= 1;
28832832   }
28842833
28852834
r22030r22031
28932842   }
28942843//      mame_printf_debug("my mode %02x", m_vdp_regs[0x0c]);
28952844
2896   visarea.set(0, scr_width-1, 0, megadrive_visible_scanlines-1);
2845   visarea.set(0, scr_width - 1, 0, m_visible_scanlines - 1);
28972846
28982847   machine.primary_screen->configure(480, megadrive_total_scanlines, visarea, machine.primary_screen->frame_period().attoseconds);
28992848
r22030r22031
29232872      timer.machine().scheduler().synchronize();
29242873      vdp->vdp_handle_scanline_callback(timer.machine(), param);
29252874
2926      megadriv_scanline_timer->adjust(attotime::from_hz(megadriv_framerate) / megadrive_total_scanlines);
2875      megadriv_scanline_timer->adjust(attotime::from_hz(vdp->get_framerate()) / megadrive_total_scanlines);
29272876   }
29282877   else
29292878   {
trunk/src/mame/machine/megavdp.h
r22030r22031
151151
152152TIMER_DEVICE_CALLBACK( megadriv_scanline_timer_callback_alt_timing );
153153extern void megadriv_reset_vdp(running_machine &machine);
154extern int genvdp_use_cram;
155154
156155
157156UINT16 vdp_get_word_from_68k_mem_default(running_machine &machine, UINT32 source, address_space & space68k);
r22030r22031
187186   void vdp_clear_irq6_pending(void) { megadrive_irq6_pending = 0; };
188187   void vdp_clear_irq4_pending(void) { megadrive_irq4_pending = 0; };
189188
189   // set some VDP variables at start (shall be moved to a device interface?)
190   void set_scanline_counter(int scanline) { m_scanline_counter = scanline; }
191   void set_total_scanlines(int total) { m_base_total_scanlines = total; }
192   void set_framerate(int rate) { m_framerate = rate; }
193   void set_vdp_pal(bool pal) { m_vdp_pal = pal ? 1 : 0; }
194   void set_use_cram(int cram) { m_vdp_use_cram = cram; }
195   int get_framerate() { return m_framerate; }
196
197
190198   void vdp_clear_bitmap(void)
191199   {
192200      if (m_render_bitmap)
r22030r22031
220228   int m_sprite_collision;
221229   int megadrive_irq6_pending;
222230   int megadrive_irq4_pending;
231   int m_scanline_counter;
223232
224233   int megadrive_imode;
225234
235   int m_visible_scanlines;
236   int m_irq6_scanline;
237   int m_z80irq_scanline;
238   // this is updated at runtime (atm we still need a global one, to handle 32x and SCD timers)
239   // int m_total_scanlines;
240   // this is only set at init: 262 for PAL, 313 for NTSC
241   int m_base_total_scanlines;
226242
227   int megadrive_visible_scanlines;
228   int megadrive_irq6_scanline;
229   int megadrive_z80irq_scanline;
243   int m_framerate;
244   int m_vdp_pal;
245   int m_vdp_use_cram; // c2 uses it's own palette ram, so it sets this to 0
230246
231
232247   UINT16* m_vdp_regs;
233248   UINT16* m_vram;
234249   UINT16* m_cram;
r22030r22031
244259   emu_timer* megadriv_render_timer;
245260
246261
247
248262   UINT16 vdp_vram_r(void);
249263   UINT16 vdp_vsram_r(void);
250264   UINT16 vdp_cram_r(void);
trunk/src/mame/machine/mega32x.c
r22030r22031
956956
957957   time_elapsed_since_megadriv_scanline_timer = megadriv_scanline_timer->time_elapsed();
958958
959   if (time_elapsed_since_megadriv_scanline_timer.attoseconds<(ATTOSECONDS_PER_SECOND/megadriv_framerate /megadrive_total_scanlines))
959   if (time_elapsed_since_megadriv_scanline_timer.attoseconds<(ATTOSECONDS_PER_SECOND/m_framerate /megadrive_total_scanlines))
960960   {
961      value4 = (UINT16)(MAX_HPOSITION*((double)(time_elapsed_since_megadriv_scanline_timer.attoseconds) / (double)(ATTOSECONDS_PER_SECOND/megadriv_framerate /megadrive_total_scanlines)));
961      value4 = (UINT16)(MAX_HPOSITION*((double)(time_elapsed_since_megadriv_scanline_timer.attoseconds) / (double)(ATTOSECONDS_PER_SECOND/m_framerate /megadrive_total_scanlines)));
962962   }
963963   else /* in some cases (probably due to rounding errors) we get some stupid results (the odd huge value where the time elapsed is much higher than the scanline time??!).. hopefully by clamping the result to the maximum we limit errors */
964964   {
r22030r22031
972972{
973973   // what happens if the z80 accesses it, what authorization do we use?
974974
975   int ntsc;
975976
976
977977//  printf("_32x_68k_a15180_r (a15180) %04x\n",mem_mask);
978978
979979   // read needs authorization too I think, undefined behavior otherwise
r22030r22031
982982      case 0x00:
983983
984984      // the flag is inverted compared to the megadrive
985      int ntsc;
986      if (megadrive_region_pal) ntsc = 0;
987      else ntsc = 1;
985      ntsc = m_32x_pal ? 0 : 1;
988986
989987      return (ntsc << 15) |
990            (m_32x_videopriority << 7 ) |
991            ( m_32x_240mode << 6 ) |
992            ( m_32x_displaymode << 0 );
988            (m_32x_videopriority << 7) |
989            (m_32x_240mode << 6) |
990            (m_32x_displaymode << 0);
993991
994
995
996992      case 0x02/2:
997993         return m_32x_screenshift;
998994
r22030r22031
10281024}
10291025
10301026
1031void sega_32x_device::_32x_check_framebuffer_swap(void)
1027void sega_32x_device::_32x_check_framebuffer_swap(bool enabled)
10321028{
10331029   // this logic should be correct, but makes things worse?
1034   //if (genesis_scanline_counter >= megadrive_irq6_scanline)
1030   // enabled = (genesis_scanline_counter >= megadrive_irq6_scanline) from megavdp.c
1031   //if (enabled)
10351032   {
10361033      m_32x_a1518a_reg = m_32x_fb_swap & 1;
10371034
r22030r22031
11451142         {
11461143            m_32x_fb_swap = data & 1;
11471144
1148            _32x_check_framebuffer_swap();
1145            _32x_check_framebuffer_swap(TRUE);
11491146         }
11501147
11511148         break;
r22030r22031
12121209      //if (m_sh2_master_hint_enable) printf("m_sh2_master_hint_enable enable!\n");
12131210      //if (sh2_master_pwmint_enable) printf("sh2_master_pwn_enable enable!\n");
12141211
1215      _32x_check_irqs(space.machine());
1212      _32x_check_irqs();
12161213   }
12171214}
12181215
r22030r22031
12501247      //if (m_sh2_slave_hint_enable) printf("m_sh2_slave_hint_enable enable!\n");
12511248      //if (sh2_slave_pwmint_enable) printf("sh2_slave_pwm_enable enable!\n");
12521249
1253      _32x_check_irqs(space.machine());
1254
1250      _32x_check_irqs();
12551251   }
12561252}
12571253
r22030r22031
13191315// VINT (vertical interrupt) clear
13201316/**********************************************************************************************/
13211317
1322WRITE16_MEMBER( sega_32x_device::_32x_sh2_master_4016_w ){ m_sh2_master_vint_pending = 0; _32x_check_irqs(space.machine()); }
1323WRITE16_MEMBER( sega_32x_device::_32x_sh2_slave_4016_w ) { m_sh2_slave_vint_pending = 0; _32x_check_irqs(space.machine()); }
1318WRITE16_MEMBER( sega_32x_device::_32x_sh2_master_4016_w ){ m_sh2_master_vint_pending = 0; _32x_check_irqs(); }
1319WRITE16_MEMBER( sega_32x_device::_32x_sh2_slave_4016_w ) { m_sh2_slave_vint_pending = 0; _32x_check_irqs(); }
13241320
13251321/**********************************************************************************************/
13261322// SH2 side 4018
r22030r22031
15531549
15541550
15551551
1556void sega_32x_device::_32x_check_irqs(running_machine& machine)
1552void sega_32x_device::_32x_check_irqs()
15571553{
15581554   if (m_sh2_master_vint_enable && m_sh2_master_vint_pending) m_master_cpu->set_input_line(SH2_VINT_IRQ_LEVEL,ASSERT_LINE);
15591555   else m_master_cpu->set_input_line(SH2_VINT_IRQ_LEVEL,CLEAR_LINE);
r22030r22031
15621558   else m_slave_cpu->set_input_line(SH2_VINT_IRQ_LEVEL,CLEAR_LINE);
15631559}
15641560
1565void sega_32x_device::_32x_scanline_cb0(running_machine& machine)
1561void sega_32x_device::_32x_scanline_cb0()
15661562{
15671563   m_sh2_master_vint_pending = 1;
15681564   m_sh2_slave_vint_pending = 1;
1569   _32x_check_irqs(machine);
1565   _32x_check_irqs();
15701566}
15711567
15721568
1573void sega_32x_device::_32x_scanline_cb1()
1569void sega_32x_device::_32x_scanline_cb1(int scanline)
15741570{
15751571   m_32x_hcount_compare_val++;
15761572
1577   if(m_32x_hcount_compare_val >= m_32x_hcount_reg)
1573   if (m_32x_hcount_compare_val >= m_32x_hcount_reg)
15781574   {
15791575      m_32x_hcount_compare_val = -1;
15801576
1581      if(genesis_scanline_counter < 224 || m_sh2_hint_in_vbl)
1577      if (scanline < 224 || m_sh2_hint_in_vbl)
15821578      {
1583         if(m_sh2_master_hint_enable) { m_master_cpu->set_input_line(SH2_HINT_IRQ_LEVEL,ASSERT_LINE); }
1584         if(m_sh2_slave_hint_enable) { m_slave_cpu->set_input_line(SH2_HINT_IRQ_LEVEL,ASSERT_LINE); }
1579         if (m_sh2_master_hint_enable) { m_master_cpu->set_input_line(SH2_HINT_IRQ_LEVEL,ASSERT_LINE); }
1580         if (m_sh2_slave_hint_enable) { m_slave_cpu->set_input_line(SH2_HINT_IRQ_LEVEL,ASSERT_LINE); }
15851581      }
15861582   }
15871583}
trunk/src/mame/machine/mega32x.h
r22030r22031
99#define MAX_HPOSITION 480
1010/* need to make some pwm stuff part of device */
1111#define PWM_FIFO_SIZE m_pwm_tm_reg // guess, Marsch calls this register as FIFO width
12#define PWM_CLOCK megadrive_region_pal ? ((MASTER_CLOCK_PAL*3) / 7) : ((MASTER_CLOCK_NTSC*3) / 7)
12#define PWM_CLOCK m_32x_pal ? ((MASTER_CLOCK_PAL*3) / 7) : ((MASTER_CLOCK_NTSC*3) / 7)
1313
1414
1515
r22030r22031
3333   required_device<dac_device> m_rch_pwm;
3434
3535   void pause_cpu();
36   
37   // set some variables at start, depending on region (shall be moved to a device interface?)
38   void set_framerate(int rate) { m_framerate = rate; }
39   void set_32x_pal(bool pal) { m_32x_pal = pal ? 1 : 0; }
3640
41   
3742   DECLARE_READ32_MEMBER( _32x_sh2_master_4000_common_4002_r );
3843   DECLARE_READ32_MEMBER( _32x_sh2_slave_4000_common_4002_r );
3944   DECLARE_READ32_MEMBER( _32x_sh2_common_4004_common_4006_r );
r22030r22031
102107   UINT32* _32x_render_videobuffer_to_screenbuffer_helper(running_machine &machine, int scanline);
103108   int sh2_master_pwmint_enable, sh2_slave_pwmint_enable;
104109
105   void _32x_check_framebuffer_swap(void);
106   void _32x_check_irqs(running_machine& machine);
107   void _32x_scanline_cb0(running_machine& machine);
108   void _32x_scanline_cb1();
110   void _32x_check_framebuffer_swap(bool enabled);
111   void _32x_check_irqs();
112   void _32x_scanline_cb0();
113   void _32x_scanline_cb1(int scanline);
109114
110115   /* our current main rendering code needs to know this for mixing in */
111116   int m_32x_displaymode;
r22030r22031
166171   UINT16 m_a15100_reg;
167172   int m_32x_68k_a15102_reg;
168173
174   int m_framerate;
175   int m_32x_pal;
176
169177   UINT16 m_commsram[8];
170178
171179   UINT16* m_32x_dram0;
trunk/src/mame/machine/megacd.c
r22030r22031
17051705   // timed reset of flags
17061706   scd_mode_dmna_ret_flags |= 0x0021;
17071707
1708   scd_dma_timer->adjust(attotime::from_hz(megadriv_framerate) / megadrive_total_scanlines);
1708   scd_dma_timer->adjust(attotime::from_hz(m_framerate) / megadrive_total_scanlines);
17091709
17101710}
17111711
trunk/src/mame/machine/megacd.h
r22030r22031
261261
262262   UINT16 m_a12000_halt_reset_reg;
263263
264   int m_framerate;
265
264266   void segacd_mark_tiles_dirty(running_machine& machine, int offset);
265267   int segacd_get_active_stampmap_tilemap(void);
266268
269   // set some variables at start, depending on region (shall be moved to a device interface?)
270   void set_framerate(int rate) { m_framerate = rate; }
271
267272   void SCD_GET_TILE_INFO_16x16_1x1( int& tile_region, int& tileno, int tile_index );
268273   void SCD_GET_TILE_INFO_32x32_1x1( int& tile_region, int& tileno, int tile_index );
269274   void SCD_GET_TILE_INFO_16x16_16x16( int& tile_region, int& tileno, int tile_index );
trunk/src/mame/machine/megadriv.c
r22030r22031
389389   {
390390      case 0:
391391         logerror("%06x read version register\n", space.device().safe_pc());
392         retdata = megadrive_region_export<<7 | // Export
393                  megadrive_region_pal<<6 | // NTSC
392         retdata = state->m_export << 7 | // Export
393                  state->m_pal << 6 | // NTSC or PAL?
394394                  (state->m_segacd ? 0x00 : 0x20) | // 0x20 = no sega cd
395395                  0x00 | // Unused (Always 0)
396396                  0x00 | // Bit 3 of Version Number
r22030r22031
866866
867867
868868
869
870
871
872869SCREEN_UPDATE_RGB32(megadriv)
873870{
874871   sega_genesis_vdp_device *vdp = screen.machine().device<sega_genesis_vdp_device>("gen_vdp"); // yuck
r22030r22031
900897
901898
902899
903
904
905
906
907
908
909
910
911900/*****************************************************************************************/
912901
913902
r22030r22031
929918      state->m_genz80.z80_is_reset = 1;
930919      state->m_genz80.z80_has_bus = 1;
931920      state->m_genz80.z80_bank_addr = 0;
932      genesis_scanline_counter = -1;
921      state->m_vdp->set_scanline_counter(-1);
933922      machine.scheduler().timer_set(attotime::zero, FUNC(megadriv_z80_run_state));
934923   }
935924
r22030r22031
943932
944933   if (state->m_other_hacks)
945934   {
946   //  set_refresh_rate(megadriv_framerate);
947935   //  machine.device("maincpu")->set_clock_scale(0.9950f); /* Fatal Rewind is very fussy... (and doesn't work now anyway, so don't bother with this) */
948936      if (state->m_megadrive_ram)
949937         memset(state->m_megadrive_ram,0x00,0x10000);
r22030r22031
11931181{
11941182   if (source <= 0x3fffff)
11951183   {
1196      source -= 2;   // compensate DMA lag
1184      source -= 2;    // compensate DMA lag
11971185      return space68k.read_word(source);
11981186   }
11991187   else if ((source >= 0xe00000) && (source <= 0xffffff))
r22030r22031
12291217      vdp_get_word_from_68k_mem = vdp_get_word_from_68k_mem_delayed;
12301218   }
12311219   if (machine().device("segacd"))
1232   {
1220   {
12331221      printf("SegaCD found 'segacd'\n");
12341222      vdp_get_word_from_68k_mem = vdp_get_word_from_68k_mem_delayed;
1235   }   
1223   }
12361224
12371225   m68k_set_tas_callback(machine().device("maincpu"), megadriv_tas_callback);
12381226
r22030r22031
12681256      }
12691257      mame_printf_debug("\n");
12701258   }
1259
1260   m_export = 0;
1261   m_pal = 0;
12711262}
12721263
12731264DRIVER_INIT_MEMBER(md_base_state,megadriv_c2)
12741265{
1275   genvdp_use_cram = 0;
12761266   m_other_hacks = 0;
12771267
12781268   megadriv_init_common();
1279   megadriv_framerate = 60;
1269
1270   m_vdp->set_use_cram(0); // C2 uses its own palette ram
1271   m_vdp->set_vdp_pal(FALSE);
1272   m_vdp->set_framerate(60);
1273   m_vdp->set_total_scanlines(313);
12801274}
12811275
12821276
12831277
12841278DRIVER_INIT_MEMBER(md_base_state,megadriv)
12851279{
1286   genvdp_use_cram = 1;
12871280   m_other_hacks = 1;
12881281
12891282   megadriv_init_common();
1290   megadriv_framerate = 60;
1283
1284   // todo: move this to the device interface?
1285   m_vdp->set_use_cram(1);
1286   m_vdp->set_vdp_pal(FALSE);
1287   m_vdp->set_framerate(60);
1288   m_vdp->set_total_scanlines(313);
1289   if (m_32x)
1290   {
1291      m_32x->set_framerate(60);
1292      m_32x->set_32x_pal(FALSE);
1293   }
1294   if (m_segacd)
1295      m_segacd->set_framerate(60);
1296
1297   m_export = 1;
1298   m_pal = 0;
12911299}
12921300
12931301DRIVER_INIT_MEMBER(md_base_state,megadrij)
12941302{
1295   genvdp_use_cram = 1;
12961303   m_other_hacks = 1;
12971304
12981305   megadriv_init_common();
1299   megadriv_framerate = 60;
1306
1307   // todo: move this to the device interface?
1308   m_vdp->set_use_cram(1);
1309   m_vdp->set_vdp_pal(FALSE);
1310   m_vdp->set_framerate(60);
1311   m_vdp->set_total_scanlines(313);
1312   if (m_32x)
1313   {
1314      m_32x->set_framerate(60);
1315      m_32x->set_32x_pal(FALSE);
1316   }
1317   if (m_segacd)
1318      m_segacd->set_framerate(60);
1319
1320   m_export = 0;
1321   m_pal = 0;
13001322}
13011323
13021324DRIVER_INIT_MEMBER(md_base_state,megadrie)
13031325{
1304   genvdp_use_cram = 1;
13051326   m_other_hacks = 1;
13061327
13071328   megadriv_init_common();
1308   megadriv_framerate = 50;
1329
1330   // todo: move this to the device interface?
1331   m_vdp->set_use_cram(1);
1332   m_vdp->set_vdp_pal(TRUE);
1333   m_vdp->set_framerate(50);
1334   m_vdp->set_total_scanlines(262);
1335   if (m_32x)
1336   {
1337      m_32x->set_framerate(50);
1338      m_32x->set_32x_pal(TRUE);
1339   }
1340   if (m_segacd)
1341      m_segacd->set_framerate(50);
1342
1343   m_export = 1;
1344   m_pal = 1;
13091345}
13101346
13111347DRIVER_INIT_MEMBER(md_base_state,mpnew)
r22030r22031
13691405
13701406
13711407
1372
1373
13741408SCREEN_VBLANK(megadriv)
13751409{
13761410   md_base_state *state = screen.machine().driver_data<md_base_state>();
trunk/src/mame/includes/megadriv.h
r22030r22031
106106
107107   int m_other_hacks;   // misc hacks
108108   genesis_z80_vars m_genz80;
109   int m_pal;
110   int m_export;
109111
110112   DECLARE_DRIVER_INIT(megadriv_c2);
111113   DECLARE_DRIVER_INIT(megadrie);
r22030r22031
407409/* machine/megavdp.c */
408410extern UINT16 (*vdp_get_word_from_68k_mem)(running_machine &machine, UINT32 source, address_space& space);
409411extern UINT16 vdp_get_word_from_68k_mem_default(running_machine &machine, UINT32 source, address_space& space);
410extern int megadriv_framerate;
411412extern int megadrive_total_scanlines;
412413extern int megadrive_vblank_flag;
413extern int genesis_scanline_counter;
414414extern UINT16* megadrive_vdp_palette_lookup;
415415
416extern int megadrive_region_export;
417extern int megadrive_region_pal;
418
419416/* machine/megadriv.c */
420417extern TIMER_DEVICE_CALLBACK( megadriv_scanline_timer_callback );
421418extern timer_device* megadriv_scanline_timer;
trunk/src/mess/drivers/megadriv.c
r22030r22031
456456{
457457   DRIVER_INIT_CALL(megadriv);
458458   DRIVER_INIT_CALL(mess_md_common);
459   megadrive_region_export = 1;
460   megadrive_region_pal = 0;
461459}
462460
463461DRIVER_INIT_MEMBER(md_cons_state,md_eur)
464462{
465463   DRIVER_INIT_CALL(megadrie);
466464   DRIVER_INIT_CALL(mess_md_common);
467   megadrive_region_export = 1;
468   megadrive_region_pal = 1;
469465}
470466
471467DRIVER_INIT_MEMBER(md_cons_state,md_jpn)
472468{
473469   DRIVER_INIT_CALL(megadrij);
474470   DRIVER_INIT_CALL(mess_md_common);
475   megadrive_region_export = 0;
476   megadrive_region_pal = 0;
477471}
478472
479473/****************************************** 32X emulation ****************************************/
r22030r22031
965959   switch (offset)
966960   {
967961      case 0: /* Version register ?XX?????? where XX is 00 for japan, 01 for europe and 10 for USA*/
968         retdata = (megadrive_region_export << 6) | (megadrive_region_pal << 5);
962         retdata = (state->m_export << 6) | (state->m_pal << 5);
969963         break;
970964      case 1:
971965         retdata = state->ioport("PAD")->read_safe(0);

Previous 199869 Revisions Next


© 1997-2024 The MAME Team