@@ -173,20 +173,18 @@ class mirax_state : public driver_device
173
173
required_shared_ptr<uint8_t > m_spriteram;
174
174
required_shared_ptr<uint8_t > m_colorram;
175
175
176
- uint8_t m_nAyCtrl = 0 ;
177
- uint8_t m_nmi_mask = 0 ;
178
- uint8_t m_flipscreen_x = 0 ;
179
- uint8_t m_flipscreen_y = 0 ;
176
+ uint8_t m_ay_addr_latch = 0 ;
177
+ bool m_nmi_mask = false ;
178
+ bool m_flipscreen_x = false ;
179
+ bool m_flipscreen_y = false ;
180
180
181
- void audio_w (offs_t offset, uint8_t data);
181
+ void ay_addr_latch_w (offs_t offset, uint8_t data);
182
182
void nmi_mask_w (int state);
183
183
void sound_cmd_w (uint8_t data);
184
- void coin_counter0_w (int state);
185
- void coin_counter1_w (int state);
184
+ template <unsigned Which> void coin_counter_w (int state);
186
185
void flip_screen_x_w (int state);
187
186
void flip_screen_y_w (int state);
188
- void ay1_sel (uint8_t data);
189
- void ay2_sel (uint8_t data);
187
+ template <unsigned Which> void ay_data_w (uint8_t data);
190
188
191
189
void mirax_palette (palette_device &palette) const ;
192
190
@@ -238,20 +236,26 @@ void mirax_state::draw_tilemap(bitmap_ind16 &bitmap, const rectangle &cliprect,
238
236
{
239
237
for (int x = 0 ; x < 32 ; x++)
240
238
{
241
- int tile = m_videoram[32 *y+ x];
242
- int color = (m_colorram[x* 2 ]<< 8 ) | (m_colorram[(x* 2 )+ 1 ]);
243
- int x_scroll = (color & 0xff00 )>> 8 ;
244
- tile |= ((color & 0xe0 )<< 3 );
239
+ uint32_t tile = m_videoram[32 * y + x];
240
+ uint32_t color = (m_colorram[x * 2 ] << 8 ) | (m_colorram[(x * 2 ) + 1 ]);
241
+ int const x_scroll = (color & 0xff00 ) >> 8 ;
242
+ tile |= ((color & 0xe0 ) << 3 );
245
243
246
- int const res_x = m_flipscreen_x ? (248 - x* 8 ) : (x* 8 );
247
- int const res_y = m_flipscreen_y ? (248 - y* 8 + x_scroll) : (y* 8 - x_scroll);
244
+ int const res_x = m_flipscreen_x ? (248 - x * 8 ) : (x * 8 );
245
+ int const res_y = m_flipscreen_y ? (248 - y * 8 + x_scroll) : (y * 8 - x_scroll);
248
246
int const wrapy = m_flipscreen_y ? -256 : 256 ;
249
247
250
248
if ((x <= 1 || x >= 30 ) ^ draw_flag)
251
249
{
252
- gfx->opaque (bitmap,cliprect,tile,color & 7 ,(m_flipscreen_x),(m_flipscreen_y),res_x,res_y);
250
+ gfx->opaque (bitmap, cliprect,
251
+ tile, color & 7 ,
252
+ m_flipscreen_x, m_flipscreen_y,
253
+ res_x, res_y);
253
254
// wrap-around
254
- gfx->opaque (bitmap,cliprect,tile,color & 7 ,(m_flipscreen_x),(m_flipscreen_y),res_x,res_y+wrapy);
255
+ gfx->opaque (bitmap, cliprect,
256
+ tile, color & 7 ,
257
+ m_flipscreen_x, m_flipscreen_y,
258
+ res_x, res_y + wrapy);
255
259
}
256
260
}
257
261
}
@@ -264,18 +268,21 @@ void mirax_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
264
268
if (!m_spriteram[count] || !m_spriteram[count + 3 ])
265
269
continue ;
266
270
267
- int spr_offs = m_spriteram[count+ 1 ] & 0x3f ;
268
- spr_offs += (m_spriteram[count+ 2 ] & 0xe0 )<< 1 ;
269
- spr_offs += (m_spriteram[count+ 2 ] & 0x10 )<< 5 ;
271
+ uint32_t spr_offs = m_spriteram[count + 1 ] & 0x3f ;
272
+ spr_offs += (m_spriteram[count + 2 ] & 0xe0 ) << 1 ;
273
+ spr_offs += (m_spriteram[count + 2 ] & 0x10 ) << 5 ;
270
274
271
- int const color = m_spriteram[count+ 2 ] & 0x7 ;
272
- int const fx = m_flipscreen_x ^ BIT (m_spriteram[count + 1 ], 6 ); // <- guess
273
- int const fy = m_flipscreen_y ^ BIT (m_spriteram[count + 1 ], 7 );
275
+ uint32_t const color = m_spriteram[count + 2 ] & 0x7 ;
276
+ bool const fx = m_flipscreen_x ^ BIT (m_spriteram[count + 1 ], 6 ); // guess
277
+ bool const fy = m_flipscreen_y ^ BIT (m_spriteram[count + 1 ], 7 );
274
278
275
279
int const y = m_flipscreen_y ? m_spriteram[count] : 0x100 - m_spriteram[count] - 16 ;
276
- int const x = m_flipscreen_x ? 240 - m_spriteram[count+ 3 ] : m_spriteram[count+ 3 ];
280
+ int const x = m_flipscreen_x ? 240 - m_spriteram[count + 3 ] : m_spriteram[count + 3 ];
277
281
278
- m_gfxdecode->gfx (1 )->transpen (bitmap,cliprect,spr_offs,color,fx,fy,x,y,0 );
282
+ m_gfxdecode->gfx (1 )->transpen (bitmap, cliprect,
283
+ spr_offs, color,
284
+ fx, fy,
285
+ x, y, 0 );
279
286
}
280
287
}
281
288
@@ -290,29 +297,22 @@ uint32_t mirax_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap,
290
297
291
298
void mirax_state::machine_start ()
292
299
{
293
- m_nAyCtrl = 0x00 ;
294
-
295
- save_item (NAME (m_nAyCtrl));
300
+ save_item (NAME (m_ay_addr_latch));
296
301
save_item (NAME (m_nmi_mask));
297
302
save_item (NAME (m_flipscreen_x));
298
303
save_item (NAME (m_flipscreen_y));
299
304
}
300
305
301
- void mirax_state::audio_w (offs_t offset, uint8_t data)
302
- {
303
- m_nAyCtrl=offset;
304
- }
305
-
306
- void mirax_state::ay1_sel (uint8_t data)
306
+ void mirax_state::ay_addr_latch_w (offs_t offset, uint8_t data)
307
307
{
308
- m_ay[0 ]->address_w (m_nAyCtrl);
309
- m_ay[0 ]->data_w (data);
308
+ m_ay_addr_latch = offset;
310
309
}
311
310
312
- void mirax_state::ay2_sel (uint8_t data)
311
+ template <unsigned Which>
312
+ void mirax_state::ay_data_w (uint8_t data)
313
313
{
314
- m_ay[1 ]->address_w (m_nAyCtrl );
315
- m_ay[1 ]->data_w (data);
314
+ m_ay[Which ]->address_w (m_ay_addr_latch );
315
+ m_ay[Which ]->data_w (data);
316
316
}
317
317
318
318
void mirax_state::nmi_mask_w (int state)
@@ -328,15 +328,10 @@ void mirax_state::sound_cmd_w(uint8_t data)
328
328
m_audiocpu->pulse_input_line (INPUT_LINE_NMI, attotime::zero);
329
329
}
330
330
331
-
332
- void mirax_state::coin_counter0_w (int state)
333
- {
334
- machine ().bookkeeping ().coin_counter_w (0 , state);
335
- }
336
-
337
- void mirax_state::coin_counter1_w (int state)
331
+ template <unsigned Which>
332
+ void mirax_state::coin_counter_w (int state)
338
333
{
339
- machine ().bookkeeping ().coin_counter_w (1 , state);
334
+ machine ().bookkeeping ().coin_counter_w (Which , state);
340
335
}
341
336
342
337
void mirax_state::flip_screen_x_w (int state)
@@ -353,17 +348,17 @@ void mirax_state::mirax_main_map(address_map &map)
353
348
{
354
349
map (0x0000 , 0xbfff ).rom ();
355
350
map (0xc800 , 0xd7ff ).ram ();
356
- map (0xe000 , 0xe3ff ).ram ().share (" videoram " );
357
- map (0xe800 , 0xe9ff ).ram ().share (" spriteram " );
358
- map (0xea00 , 0xea3f ).ram ().share (" colorram " ); // per-column color + bank bits for the videoram
351
+ map (0xe000 , 0xe3ff ).ram ().share (m_videoram );
352
+ map (0xe800 , 0xe9ff ).ram ().share (m_spriteram );
353
+ map (0xea00 , 0xea3f ).ram ().share (m_colorram ); // per-column color + bank bits for the videoram
359
354
map (0xf000 , 0xf000 ).portr (" P1" );
360
355
map (0xf100 , 0xf100 ).portr (" P2" );
361
356
map (0xf200 , 0xf200 ).portr (" DSW1" );
362
- map (0xf300 , 0xf300 ).nopr (); // watchdog? value is always read then discarded
357
+ map (0xf300 , 0xf300 ).nopr (); // watchdog? value is always read then discarded
363
358
map (0xf400 , 0xf400 ).portr (" DSW2" );
364
359
map (0xf500 , 0xf507 ).w (" mainlatch" , FUNC (ls259_device::write_d0));
365
360
map (0xf800 , 0xf800 ).w (FUNC (mirax_state::sound_cmd_w));
366
- // map(0xf900, 0xf900) //sound cmd mirror? ack?
361
+ // map(0xf900, 0xf900) // sound cmd mirror? ack?
367
362
}
368
363
369
364
void mirax_state::mirax_sound_map (address_map &map)
@@ -374,19 +369,19 @@ void mirax_state::mirax_sound_map(address_map &map)
374
369
375
370
map (0xe000 , 0xe000 ).nopw ();
376
371
map (0xe001 , 0xe001 ).nopw ();
377
- map (0xe003 , 0xe003 ).w (FUNC (mirax_state::ay1_sel )); // 1st ay ?
372
+ map (0xe003 , 0xe003 ).w (FUNC (mirax_state::ay_data_w< 0 > )); // 1st ay ?
378
373
379
374
map (0xe400 , 0xe400 ).nopw ();
380
375
map (0xe401 , 0xe401 ).nopw ();
381
- map (0xe403 , 0xe403 ).w (FUNC (mirax_state::ay2_sel )); // 2nd ay ?
376
+ map (0xe403 , 0xe403 ).w (FUNC (mirax_state::ay_data_w< 1 > )); // 2nd ay ?
382
377
383
- map (0xf900 , 0xf9ff ).w (FUNC (mirax_state::audio_w ));
378
+ map (0xf900 , 0xf9ff ).w (FUNC (mirax_state::ay_addr_latch_w ));
384
379
}
385
380
386
381
387
- /* verified from Z80 code */
382
+ // verified from Z80 code
388
383
static INPUT_PORTS_START ( mirax )
389
- /* up/down directions are trusted according of the continue screen */
384
+ // up/down directions are trusted according of the continue screen
390
385
PORT_START(" P1" )
391
386
PORT_BIT( 0x01 , IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN )
392
387
PORT_BIT( 0x02 , IP_ACTIVE_HIGH, IPT_START1 )
@@ -428,7 +423,7 @@ static INPUT_PORTS_START( mirax )
428
423
PORT_DIPUNUSED( 0x80 , IP_ACTIVE_HIGH )
429
424
430
425
PORT_START(" DSW2" )
431
- PORT_DIPNAME( 0x01 , 0x00 , DEF_STR( Bonus_Life ) ) /* table at 0x11b5 (2 * 3 * 2 bytes) */
426
+ PORT_DIPNAME( 0x01 , 0x00 , DEF_STR( Bonus_Life ) ) // table at 0x11b5 (2 * 3 * 2 bytes)
432
427
PORT_DIPSETTING( 0x00 , " 30k 80k 150k" )
433
428
PORT_DIPSETTING( 0x01 , " 900k 950k 990k" )
434
429
PORT_DIPNAME( 0x02 , 0x00 , " Flags for Extra Life" )
@@ -440,7 +435,7 @@ static INPUT_PORTS_START( mirax )
440
435
PORT_DIPNAME( 0x08 , 0x08 , DEF_STR( Allow_Continue ) )
441
436
PORT_DIPSETTING( 0x00 , DEF_STR( No ) )
442
437
PORT_DIPSETTING( 0x08 , DEF_STR( Yes ) )
443
- /* this dip makes the game to behave like attract mode, even if you insert a coin */
438
+ // this dip makes the game to behave like attract mode, even if you insert a coin
444
439
PORT_DIPNAME( 0x10 , 0x00 , " Auto-Play Mode (Debug)" )
445
440
PORT_DIPSETTING( 0x00 , DEF_STR( No ) )
446
441
PORT_DIPSETTING( 0x10 , DEF_STR( Yes ) )
@@ -451,7 +446,7 @@ static INPUT_PORTS_START( mirax )
451
446
PORT_DIPUNUSED( 0x80 , IP_ACTIVE_HIGH )
452
447
INPUT_PORTS_END
453
448
454
- /* verified from Z80 code */
449
+ // verified from Z80 code
455
450
static INPUT_PORTS_START( miraxa )
456
451
PORT_INCLUDE( mirax )
457
452
@@ -468,7 +463,7 @@ static INPUT_PORTS_START( miraxa )
468
463
PORT_DIPSETTING( 0x30 , " 6" )
469
464
470
465
PORT_MODIFY(" DSW2" )
471
- PORT_DIPNAME( 0x01 , 0x00 , DEF_STR( Bonus_Life ) ) /* table at 0x1276 (2 * 3 * 2 bytes) */
466
+ PORT_DIPNAME( 0x01 , 0x00 , DEF_STR( Bonus_Life ) ) // table at 0x1276 (2 * 3 * 2 bytes)
472
467
PORT_DIPSETTING( 0x00 , " 30k 80k 150k" )
473
468
PORT_DIPSETTING( 0x01 , " 50k 100k 900k" )
474
469
INPUT_PORTS_END
@@ -480,16 +475,14 @@ static const gfx_layout layout16 =
480
475
RGN_FRAC (1 ,3 ),
481
476
3 ,
482
477
{ RGN_FRAC (2 ,3 ),RGN_FRAC (1 ,3 ),RGN_FRAC (0 ,3 )},
483
- { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ,
484
- 0 +8 *8 ,1 +8 *8 ,2 +8 *8 ,3 +8 *8 ,4 +8 *8 ,5 +8 *8 ,6 +8 *8 ,7 +8 *8 },
485
- { 0 *8 , 1 *8 , 2 *8 , 3 *8 , 4 *8 , 5 *8 , 6 *8 , 7 *8 ,
486
- 0 *8 +8 *8 *2 , 1 *8 +8 *8 *2 , 2 *8 +8 *8 *2 , 3 *8 +8 *8 *2 , 4 *8 +8 *8 *2 , 5 *8 +8 *8 *2 , 6 *8 +8 *8 *2 , 7 *8 +8 *8 *2 },
478
+ { STEP8 (0 ,1 ), STEP8 (8 *8 ,1 ) },
479
+ { STEP8 (0 ,8 ), STEP8 (8 *8 *2 ,8 ) },
487
480
16 *16
488
481
};
489
482
490
483
static GFXDECODE_START ( gfx_mirax )
491
- GFXDECODE_ENTRY( " gfx1 " , 0 , gfx_8x8x3_planar, 0 , 8 )
492
- GFXDECODE_ENTRY( " gfx2 " , 0 , layout16, 0 , 8 )
484
+ GFXDECODE_ENTRY( " tiles " , 0 , gfx_8x8x3_planar, 0 , 8 )
485
+ GFXDECODE_ENTRY( " sprites " , 0 , layout16, 0 , 8 )
493
486
GFXDECODE_END
494
487
495
488
@@ -509,18 +502,18 @@ void mirax_state::mirax(machine_config &config)
509
502
m_audiocpu->set_periodic_int (FUNC (mirax_state::irq0_line_hold), attotime::from_hz (4 *60 ));
510
503
511
504
ls259_device &mainlatch (LS259 (config, " mainlatch" )); // R10
512
- mainlatch.q_out_cb <0 >().set (FUNC (mirax_state::coin_counter0_w ));
505
+ mainlatch.q_out_cb <0 >().set (FUNC (mirax_state::coin_counter_w< 0 > ));
513
506
mainlatch.q_out_cb <1 >().set (FUNC (mirax_state::nmi_mask_w));
514
- mainlatch.q_out_cb <2 >().set (FUNC (mirax_state::coin_counter1_w )); // only used in 'miraxa' - see notes
507
+ mainlatch.q_out_cb <2 >().set (FUNC (mirax_state::coin_counter_w< 1 > )); // only used in 'miraxa' - see notes
515
508
// One address flips X, the other flips Y, but I can't tell which is which
516
509
// Since the value is the same for the 2 addresses, it doesn't really matter
517
510
mainlatch.q_out_cb <6 >().set (FUNC (mirax_state::flip_screen_x_w));
518
511
mainlatch.q_out_cb <7 >().set (FUNC (mirax_state::flip_screen_y_w));
519
512
520
- /* video hardware */
513
+ // video hardware
521
514
screen_device &screen (SCREEN (config, " screen" , SCREEN_TYPE_RASTER));
522
515
screen.set_refresh_hz (60 );
523
- screen.set_vblank_time (ATTOSECONDS_IN_USEC (2500 ) /* not accurate */ );
516
+ screen.set_vblank_time (ATTOSECONDS_IN_USEC (2500 )); // not accurate
524
517
screen.set_size (256 , 256 );
525
518
screen.set_visarea (0 *8 , 32 *8 -1 , 1 *8 , 31 *8 -1 );
526
519
screen.set_screen_update (FUNC (mirax_state::screen_update));
@@ -550,12 +543,12 @@ ROM_START( mirax )
550
543
ROM_REGION ( 0x10000 , " audiocpu" , 0 )
551
544
ROM_LOAD ( " mxr2-4v.rom" , 0x0000 , 0x2000 , CRC(cd2d52dc) SHA1(0d4181dc68beac338f47a2065c7b755008877896) )
552
545
553
- ROM_REGION ( 0xc000 , " gfx1 " , 0 )
546
+ ROM_REGION ( 0xc000 , " tiles " , 0 )
554
547
ROM_LOAD ( " mxe3-4v.rom" , 0x0000 , 0x4000 , CRC(0cede01f) SHA1(c723dd8ee9dc06c94a7fe5d5b5bccc42e2181af1) )
555
548
ROM_LOAD ( " mxh3-4v.rom" , 0x4000 , 0x4000 , CRC(58221502 ) SHA1(daf5c508939b44616ca76308fc33f94d364ed587) )
556
549
ROM_LOAD ( " mxk3-4v.rom" , 0x8000 , 0x4000 , CRC(6dbc2961) SHA1(5880c28f1ef704fee2d625a42682c7d65613acc8) )
557
550
558
- ROM_REGION ( 0x18000 , " gfx2 " , 0 )
551
+ ROM_REGION ( 0x18000 , " sprites " , 0 )
559
552
ROM_LOAD ( " mxe2-4v.rom" , 0x04000 , 0x4000 , CRC(2cf5d8b7) SHA1(f66bce4d413a48f6ae07974870dc0f31eefa68e9) )
560
553
ROM_LOAD ( " mxf2-4v.rom" , 0x0c000 , 0x4000 , CRC(1f42c7fa) SHA1(33e56c6ddf7676a12f57de87ec740c6b6eb1cc8c) )
561
554
ROM_LOAD ( " mxh2-4v.rom" , 0x14000 , 0x4000 , CRC(cbaff4c6) SHA1(2dc4a1f51b28e98be0cfb5ab7576047c748b6728) )
@@ -580,12 +573,12 @@ ROM_START( miraxa )
580
573
ROM_REGION ( 0x10000 , " audiocpu" , 0 )
581
574
ROM_LOAD ( " mxr2-4v.rom" , 0x0000 , 0x2000 , CRC(cd2d52dc) SHA1(0d4181dc68beac338f47a2065c7b755008877896) )
582
575
583
- ROM_REGION ( 0xc000 , " gfx1 " , 0 )
576
+ ROM_REGION ( 0xc000 , " tiles " , 0 )
584
577
ROM_LOAD ( " mxe3-4v.rom" , 0x0000 , 0x4000 , CRC(0cede01f) SHA1(c723dd8ee9dc06c94a7fe5d5b5bccc42e2181af1) )
585
578
ROM_LOAD ( " mxh3-4v.rom" , 0x4000 , 0x4000 , CRC(58221502 ) SHA1(daf5c508939b44616ca76308fc33f94d364ed587) )
586
579
ROM_LOAD ( " mxk3-4v.rom" , 0x8000 , 0x4000 , CRC(6dbc2961) SHA1(5880c28f1ef704fee2d625a42682c7d65613acc8) )
587
580
588
- ROM_REGION ( 0x18000 , " gfx2 " , 0 )
581
+ ROM_REGION ( 0x18000 , " sprites " , 0 )
589
582
ROM_LOAD ( " mxe2-4v.rom" , 0x04000 , 0x4000 , CRC(2cf5d8b7) SHA1(f66bce4d413a48f6ae07974870dc0f31eefa68e9) )
590
583
ROM_LOAD ( " mxf2-4v.rom" , 0x0c000 , 0x4000 , CRC(1f42c7fa) SHA1(33e56c6ddf7676a12f57de87ec740c6b6eb1cc8c) )
591
584
ROM_LOAD ( " mxh2-4v.rom" , 0x14000 , 0x4000 , CRC(cbaff4c6) SHA1(2dc4a1f51b28e98be0cfb5ab7576047c748b6728) )
@@ -609,12 +602,12 @@ ROM_START( miraxb )
609
602
ROM_REGION ( 0x10000 , " audiocpu" , 0 )
610
603
ROM_LOAD ( " 13.r5" , 0x0000 , 0x2000 , CRC(cd2d52dc) SHA1(0d4181dc68beac338f47a2065c7b755008877896) )
611
604
612
- ROM_REGION ( 0xc000 , " gfx1 " , 0 )
605
+ ROM_REGION ( 0xc000 , " tiles " , 0 )
613
606
ROM_LOAD ( " 4.e3" , 0x0000 , 0x4000 , CRC(0cede01f) SHA1(c723dd8ee9dc06c94a7fe5d5b5bccc42e2181af1) )
614
607
ROM_LOAD ( " 6.h3" , 0x4000 , 0x4000 , CRC(58221502 ) SHA1(daf5c508939b44616ca76308fc33f94d364ed587) )
615
608
ROM_LOAD ( " 8.k3" , 0x8000 , 0x4000 , CRC(6dbc2961) SHA1(5880c28f1ef704fee2d625a42682c7d65613acc8) )
616
609
617
- ROM_REGION ( 0x18000 , " gfx2 " , 0 )
610
+ ROM_REGION ( 0x18000 , " sprites " , 0 )
618
611
ROM_LOAD ( " 1.e2" , 0x04000 , 0x4000 , CRC(2cf5d8b7) SHA1(f66bce4d413a48f6ae07974870dc0f31eefa68e9) )
619
612
ROM_LOAD ( " 2.f2" , 0x0c000 , 0x4000 , CRC(1f42c7fa) SHA1(33e56c6ddf7676a12f57de87ec740c6b6eb1cc8c) )
620
613
ROM_LOAD ( " 3.h2" , 0x14000 , 0x4000 , CRC(cbaff4c6) SHA1(2dc4a1f51b28e98be0cfb5ab7576047c748b6728) )
0 commit comments