/
centiped.cpp
2398 lines (1982 loc) · 101 KB
/
centiped.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// license:BSD-3-Clause
// copyright-holders:Nicola Salmoria
/***************************************************************************
Atari Centipede hardware
Games supported:
* Centipede (5 sets)
* Warlords
* Millipede
* Maze Invaders (prototype)
* Bulls Eye Darts
Millipede:
136013-109.5p
136013-110.5r
The Two Bit Score "Dux" hack was circulated and common enough for inclusion
****************************************************************************
Main clock: XTAL = 12.096 MHz
6502 Clock: XTAL/8 = 1.512 MHz (0.756 when accessing playfield RAM)
Horizontal video frequency: HSYNC = XTAL/256/3 = 15.75 kHz
Video frequency: VSYNC = HSYNC/263 ?? = 59.88593 Hz (not sure, could be /262)
VBlank duration: 1/VSYNC * (23/263) = 1460 us
Centipede Memory map and Dip Switches
-------------------------------------
Memory map for Centipede directly from the Atari schematics (1981).
Address R/W D7 D6 D5 D4 D3 D2 D1 D0 Function
--------------------------------------------------------------------------------------
0000-03FF D D D D D D D D RAM
--------------------------------------------------------------------------------------
0400-07BF D D D D D D D D Playfield RAM
07C0-07CF D D D D D D D D Motion Object Picture
07D0-07DF D D D D D D D D Motion Object Vert.
07E0-07EF D D D D D D D D Motion Object Horiz.
07F0-07FF D D D D D D Motion Object Color
--------------------------------------------------------------------------------------
0800 R D D D D D D D D Option Switch 1 (0 = On)
0801 R D D D D D D D D Option Switch 2 (0 = On)
--------------------------------------------------------------------------------------
0C00 R D D D D D Horizontal Mini-Track Ball tm Inputs
R D VBLANK (1 = VBlank)
R D Self-Test (0 = On)
R D Cocktail Cabinet (1 = Cocktail)
0C01 R D D D R,C,L Coin Switches (0 = On)
R D SLAM (0 = On)
R D Player 2 Fire Switch (0 = On)
R D Player 1 Fire Switch (0 = On)
R D Player 2 Start Switch (0 = On)
R D Player 1 Start Switch (0 = On)
0C02 R D D D D D Vertical Mini-Track Ball tm Inputs
0C03 R D D D D Player 1 Joystick (R,L,Down,Up)
R D D D D Player 2 Joystick (0 = On)
--------------------------------------------------------------------------------------
1000-100F R/W D D D D D D D D Custom Audio Chip
1404 W D D D D Playfield Color RAM
140C W D D D D Motion Object Color RAM
--------------------------------------------------------------------------------------
1600 W D D D D D D D D EA ROM Address & Data Latch
1680 W D D D D EA ROM Control Latch
1700 R D D D D D D D D EA ROM Read Data
--------------------------------------------------------------------------------------
1800 W IRQ Acknowledge
--------------------------------------------------------------------------------------
1C00 W D Left Coin Counter (1 = On)
1C01 W D Center Coin Counter (1 = On)
1C02 W D Right Coin Counter (1 = On)
1C03 W D Player 1 Start LED (0 = On)
1C04 W D Player 2 Start LED (0 = On)
1C07 W D Track Ball Flip Control (0 = Player 1)
--------------------------------------------------------------------------------------
2000 W WATCHDOG
2400 W Clear Mini-Track Ball Counters
--------------------------------------------------------------------------------------
2000-3FFF R Program ROM
--------------------------------------------------------------------------------------
-EA ROM is an Erasable Reprogrammable rom to save the top 3 high scores
and other stuff.
Dip switches at N9 on the PCB
8 7 6 5 4 3 2 1 Option
-------------------------------------------------------------------------------------
On On English $
On Off German
Off On French
Off Off Spanish
-------------------------------------------------------------------------------------
On On 2 lives per game
On Off 3 lives per game $
Off On 4 lives per game
Off Off 5 lives per game
-------------------------------------------------------------------------------------
Bonus life granted at every:
On On 10,000 points
On Off 12.000 points $
Off On 15,000 points
Off Off 20,000 points
-------------------------------------------------------------------------------------
On Hard game difficulty
Off Easy game difficulty $
-------------------------------------------------------------------------------------
On 1-credit minimum $
Off 2-credit minimum
-------------------------------------------------------------------------------------
$ = Manufacturer's suggested settings
Dip switches at N8 on the PCB
8 7 6 5 4 3 2 1 Option
-------------------------------------------------------------------------------------
On On Free play
On Off 1 coin for 2 credits
Off On 1 coin for 1 credit $
Off Off 2 coins for 1 credit
-------------------------------------------------------------------------------------
On On Right coin mech X 1 $
On Off Right coin mech X 4
Off On Right coin mech X 5
Off Off Right coin mech X 6
-------------------------------------------------------------------------------------
On Left coin mech X 1 $
Off Left coin mech X 2
-------------------------------------------------------------------------------------
On On On No bonus coins $
On On Off For every 2 coins inserted, game logic
adds 1 more coin
On Off On For every 4 coins inserted, game logic
adds 1 more coin
On Off Off For every 4 coins inserted, game logic
adds 2 more coin
Off On On For every 5 coins inserted, game logic
adds 1 more coin
Off On Off For every 3 coins inserted, game logic
adds 1 more coin
-------------------------------------------------------------------------------------
$ = Manufacturer's suggested settings
Changes:
30 Apr 98 LBO
* Fixed test mode
* Changed high score to use earom routines
* Added support for alternate rom set
****************************************************************************
Millipede driver by Ivan Mackintosh
Memory map for Millipede from the Atari schematics (SP-217 1982)
----------------------------------------------------------------
Address R/W D7 D6 D5 D4 D3 D2 D1 D0 Function
--------------------------------------------------------------------------------------
0000-03FF D D D D D D D D RAM
--------------------------------------------------------------------------------------
0400-0410 R D D D D D D D D I/OSO (0400-040F POKEY 1)
0408 R D D D D D D D D Option Switch 0 (0 = On) (Bank at
--------------------------------------------------------------------------------------
0800-0810 R D D D D D D D D I/OS1 (0800-080F POKEY 2)
0808 R D D D D D D D D Option Switch 1 (0 = On) (Bank at
--------------------------------------------------------------------------------------
1000-13BF D D D D D D D D Playfield RAM (8x8 TILES, 32x30 SCREEN)
13C0-13CF D D D D D D D D Motion Object Picture
13D0-13DF D D D D D D D D Motion Object Vert.
13E0-13EF D D D D D D D D Motion Object Horiz.
13F0-13FF D D D D D D Motion Object Color
--------------------------------------------------------------------------------------
2000 R D Horizontal Mini-Track Ball HORIZ DIR
R D VBLANK (1 = VBlank)
R D Player 1 Start
R D Player 1 Fire
R D D D D Horizontal Mini-Track Ball HORIZ COUNT
R D D D D Options Switch 2 (Bottom 4 switches at P8)
--------------------------------------------------------------------------------------
2001 R D Horizontal Mini-Track Ball VERT DIR
R D Player 2 Start
R D Player 2 Fire
R D D D D Horizontal Mini-Track Ball VERT COUNT
R D D D D Options Switch 2 (Top 4 switches at P8)
--------------------------------------------------------------------------------------
2010 R D D D R,C,L Coin Switches (0 = On)
R D SLAM (0 = On)
R D D D D P1 Joystick Positions (0 = On)
--------------------------------------------------------------------------------------
2011 R D Self-Test Switch (0 = On)
R D Cabinet Select (1 = Upright, 0 = Cocktail)
R D D D D P2 Joystick Positions (Undocumented)
--------------------------------------------------------------------------------------
2030 R D D D D D D D D EA ROM Read Data
--------------------------------------------------------------------------------------
2480-248F W D D D D D D D D STAMP COLOR RAM
2490-249F W D D D D D D D D MOTION OBJECT COLOR RAM
--------------------------------------------------------------------------------------
2501 W D COIN CNTR L
2502 W D COIN CNTR R
2503 W D START LED 1
2504 W D START LED 2
2505 W D TRACKBALL ENABLE (TBEN)
2506 W D VIDEO ROTATE (VIDROT)
2507 W D CONTROL SELECT (CNTRLSEL) - (P1 = 1, P2 = 0?)
--------------------------------------------------------------------------------------
2600 W !IRQRES - IRQ Acknowledge
2680 W !WATCHDOG - CLEAR WATCHDOG
2700 W D D D D !EAROMCON - earom control
2780 W D D D D D D D D !EAROMWR - earom write
--------------------------------------------------------------------------------------
3000-3FFF R D D D D D D D D ROM (NOT USED) (Schems listed 300-3fff typo)
4000-7FFF R D D D D D D D D ROM (Schems listed 400-4fff typo)
--------------------------------------------------------------------------------------
Switch Settings for Millipede from the Atari schematics (TM-217 1982)
---------------------------------------------------------------------
Switch Settings for Price Options / 8-Toggle Switches on Millipede PCB (at B5)
--------------------------------------------------------------------------------------
8 7 6 5 4 3 2 1 Option
--------------------------------------------------------------------------------------
On On Off Off Demonstration Mode
On Off On For every 3 coins inserted, game logic
adds 1 more coin
On Off Off For every 5 coins inserted, game logic
adds 1 more coin
Off On On For every 4 coins inserted, game logic
adds 2 more coin
Off On Off For every 4 coins inserted, game logic
adds 1 more coin
Off Off On For every 2 coins inserted, game logic
adds 1 more coin
Off Off Off No Bonus Coins $
--------------------------------------------------------------------------------------
Off Left coin mech X 1 $
On Left coin mech X 2
--------------------------------------------------------------------------------------
Off Off Right coin mech X 1 $
Off On Right coin mech X 4
On Off Right coin mech X 5
On On Right coin mech X 6
--------------------------------------------------------------------------------------
On On 2 coins for 1 credit
On Off 1 coin for 1 credit $
Off On 1 coin for 2 credits
Off Off Free play
--------------------------------------------------------------------------------------
$ = Manufacturer's suggested settings
Switch Settings for Play Options / 8-Toggle Switches on Millipede PCB (at D5)
--------------------------------------------------------------------------------------
8 7 6 5 4 3 2 1 Option
--------------------------------------------------------------------------------------
Off Select Mode $
On No Select Mode
Off Easy spider $
On Hard spider
--------------------------------------------------------------------------------------
Off Off Bonus life every 12,000 points
Off On Bonus life every 15,000 points $
On Off Bonus life every 20,000 points
On On No bonus life
--------------------------------------------------------------------------------------
Off Off 2 lives per game
Off On 3 lives per game $
On Off 4 lives per game
On On 5 lives per game
--------------------------------------------------------------------------------------
Off Easy beetle $
On Hard beetle
--------------------------------------------------------------------------------------
Off Easy millipede head $
On Hard millipede head
--------------------------------------------------------------------------------------
$ = Manufacturer's suggested settings
Switch settings for Special Options / 8-Toggle Switches on Millipede PCB (at P8)
--------------------------------------------------------------------------------------
8 7 6 5 4 3 2 1 Option
--------------------------------------------------------------------------------------
On 1 coin counter
Off 2 coin counters
--------------------------------------------------------------------------------------
On 1 credit minimum $
Off 2 credit minimum
--------------------------------------------------------------------------------------
(Switches 5 and 6 unused) Select Mode Starting Score
On On 0 points
On Off 0 and bonus life level
Off On 0, bonus life level, and 2x bonus life level $
Off Off 0, bonus life level, and 2x bonus life level,
and 3x bonus life level
--------------------------------------------------------------------------------------
On On English $
On Off German
Off On French
Off Off Spanish
--------------------------------------------------------------------------------------
$ = Manufacturer's suggested settings
Notes: 15 Feb 2007 - MSH
* Real Millipede boards do not have the Joystick circuit hooked up
to the card edge.
* The Joytick and T-Ball inputs are both swapped through LS157s by
the CNTRLSEL signal at 0x2507.
* How do we hookup TBEN signal at 0x2505?
Changes: 15 Feb 2007 - MSH
* Added corrected memory map and dip switch settings from Atari Manuals.
* Added Cocktail mode (based on v0.36.1 driver from Scott Brasington)
* Removed unused dip toggles, now set to IPT_UNKNOWN
* Hooked up 2nd trackball
* Map P2 Joy inputs to work correctly. (They don't work on a real board)
****************************************************************************
Warlords Memory map and Dip Switches
------------------------------------
Address R/W D7 D6 D5 D4 D3 D2 D1 D0 Function
--------------------------------------------------------------------------------------
0000-03FF D D D D D D D D RAM
--------------------------------------------------------------------------------------
0400-07BF D D D D D D D D Screen RAM (8x8 TILES, 32x32 SCREEN)
07C0-07CF D D D D D D D D Motion Object Picture
07D0-07DF D D D D D D D D Motion Object Vert.
07E0-07EF D D D D D D D D Motion Object Horiz.
--------------------------------------------------------------------------------------
0800 R D D D D D D D D Option Switch 1 (0 = On) (DSW 1)
0801 R D D D D D D D D Option Switch 2 (0 = On) (DSW 2)
--------------------------------------------------------------------------------------
0C00 R D Cocktail Cabinet (0 = Cocktail)
R D VBLANK (1 = VBlank)
R D SELF TEST
R D DIAG STEP (Unused)
0C01 R D D D R,C,L Coin Switches (0 = On)
R D Slam (0 = On)
R D Player 4 Start Switch (0 = On)
R D Player 3 Start Switch (0 = On)
R D Player 2 Start Switch (0 = On)
R D Player 1 Start Switch (0 = On)
--------------------------------------------------------------------------------------
1000-100F W D D D D D D D D Pokey
--------------------------------------------------------------------------------------
1800 W IRQ Acknowledge
--------------------------------------------------------------------------------------
1C00-1C02 W D D D D D D D D Coin Counters
--------------------------------------------------------------------------------------
1C03-1C06 W D D D D D D D D LEDs
--------------------------------------------------------------------------------------
4000 W Watchdog
--------------------------------------------------------------------------------------
5000-7FFF R Program ROM
--------------------------------------------------------------------------------------
Game Option Settings - J2 (DSW1)
=========================
8 7 6 5 4 3 2 1 Option
------------------------------------------
On On English
On Off French
Off On Spanish
Off Off German
On Music at end of each game
Off Music at end of game for new highscore
On On 1 or 2 player game costs 1 credit
On Off 1 player game=1 credit, 2 player=2 credits
Off Off 1 or 2 player game costs 2 credits
Off On Not used
-------------------------------------------
Game Price Settings - M2 (DSW2)
========================
8 7 6 5 4 3 2 1 Option
------------------------------------------
On On Free play
On Off 1 coin for 2 credits
Off On 1 coin for 1 credit
Off Off 2 coins for 1 credit
On On Right coin mech x 1
On Off Right coin mech x 4
Off On Right coin mech x 5
Off Off Right coin mech x 6
On Left coin mech x 1
Off Left coin mech x 2
On On On No bonus coins
On On Off For every 2 coins, add 1 coin
On Off On For every 4 coins, add 1 coin
On Off Off For every 4 coins, add 2 coins
Off On On For every 5 coins, add 1 coin
------------------------------------------
Maze Invaders:
http://www.atarigames.com/safestuff/mazeinvaders.html
- The controls are somewhat like Food Fight in the way that they need to be
'calibrated' as you play or before you start by pushing a couple seconds in
each direction to assign the boundries.
***************************************************************************/
#include "emu.h"
#include "centiped.h"
#include "cpu/m6502/m6502.h"
#include "cpu/s2650/s2650.h"
#include "machine/rescap.h"
#include "machine/watchdog.h"
#include "sound/sn76496.h"
#include "sound/pokey.h"
#include "speaker.h"
/*************************************
*
* Interrupts
*
*************************************/
TIMER_DEVICE_CALLBACK_MEMBER(centiped_state::generate_interrupt)
{
int scanline = param;
/* IRQ is clocked on the rising edge of 16V, equal to the previous 32V */
if (scanline & 16)
m_maincpu->set_input_line(0, ((scanline - 1) & 32) ? ASSERT_LINE : CLEAR_LINE);
/* do a partial update now to handle sprite multiplexing (Maze Invaders) */
m_screen->update_partial(scanline);
}
void centiped_state::machine_start()
{
save_item(NAME(m_oldpos));
save_item(NAME(m_sign));
save_item(NAME(m_dsw_select));
std::fill(std::begin(m_oldpos), std::end(m_oldpos), 0);
std::fill(std::begin(m_sign), std::end(m_sign), 0);
m_dsw_select = 0;
}
void multiped_state::machine_start()
{
centiped_state::machine_start();
m_prg_bank = 0;
m_0xxx_base = 0x1400;
save_item(NAME(m_prg_bank));
save_item(NAME(m_0xxx_base));
}
MACHINE_RESET_MEMBER(centiped_state,centiped)
{
m_maincpu->set_input_line(0, CLEAR_LINE);
if (m_earom.found())
earom_control_w(0);
}
MACHINE_RESET_MEMBER(centiped_state,magworm)
{
MACHINE_RESET_CALL_MEMBER(centiped);
/* kludge: clear RAM so that magworm can be reset cleanly */
memset(m_rambase, 0, 0x400);
}
void centiped_state::irq_ack_w(uint8_t data)
{
m_maincpu->set_input_line(0, CLEAR_LINE);
}
/*************************************
*
* Input ports
*
*************************************/
/*
* This wrapper routine is necessary because Centipede requires a direction bit
* to be set or cleared. The direction bit is held until the mouse is moved
* again.
*
* There is a 4-bit counter, and two inputs from the trackball: DIR and CLOCK.
* CLOCK makes the counter move in the direction of DIR. Since DIR is latched
* only when a CLOCK arrives, the DIR bit in the input port doesn't change
* until the trackball actually moves.
*
* There is also a CLR input to the counter which could be used by the game to
* clear the counter, but Centipede doesn't use it (though it would be a good
* idea to support it anyway).
*
* The counter is read 240 times per second. There is no provision whatsoever
* to prevent the counter from wrapping around between reads.
*/
inline int centiped_state::read_trackball(int idx, int switch_port)
{
uint8_t newpos;
static const char *const portnames[] = { "IN0", "IN1", "IN2" };
static const char *const tracknames[] = { "TRACK0_X", "TRACK0_Y", "TRACK1_X", "TRACK1_Y" };
/* adjust idx if we're cocktail flipped */
if (m_flipscreen)
idx += 2;
/* if we're to read the dipswitches behind the trackball data, do it now */
if (m_dsw_select)
return (ioport(portnames[switch_port])->read() & 0x7f) | m_sign[idx];
/* get the new position and adjust the result */
newpos = ioport(tracknames[idx])->read();
if (newpos != m_oldpos[idx])
{
m_sign[idx] = (newpos - m_oldpos[idx]) & 0x80;
m_oldpos[idx] = newpos;
}
/* blend with the bits from the switch port */
return (ioport(portnames[switch_port])->read() & 0x70) | (m_oldpos[idx] & 0x0f) | m_sign[idx];
}
uint8_t centiped_state::centiped_IN0_r()
{
return read_trackball(0, 0);
}
uint8_t centiped_state::centiped_IN2_r()
{
return read_trackball(1, 2);
}
uint8_t centiped_state::milliped_IN1_r()
{
return read_trackball(1, 1);
}
uint8_t centiped_state::milliped_IN2_r()
{
uint8_t data = ioport("IN2")->read();
/* MSH - 15 Feb, 2007
* The P2 X Joystick inputs are not properly handled in
* the Milliped code, so we are forcing the P2 inputs
* into the P1 Joystick handler, this require remapping
* the inputs, and has the good side effect of disabling
* the actual Joy1 inputs while control_select is no zero.
*/
if (m_control_select != 0)
{
/* Bottom 4 bits is our joystick inputs */
uint8_t joy2data = ioport("IN3")->read() & 0x0f;
data = data & 0xf0; /* Keep the top 4 bits */
data |= (joy2data & 0x0a) >> 1; /* flip left and up */
data |= (joy2data & 0x05) << 1; /* flip right and down */
}
return data;
}
void centiped_state::input_select_w(int state)
{
m_dsw_select = !state;
}
/* used P2 controls if 1, P1 controls if 0 */
void centiped_state::control_select_w(int state)
{
m_control_select = state;
}
uint8_t centiped_state::mazeinv_input_r()
{
static const char *const sticknames[] = { "STICK0", "STICK1", "STICK2", "STICK3" };
return ioport(sticknames[m_control_select])->read();
}
void centiped_state::mazeinv_input_select_w(offs_t offset, uint8_t data)
{
m_control_select = offset & 3;
}
uint8_t centiped_state::bullsdrt_data_port_r()
{
switch (m_maincpu->pc())
{
case 0x0033:
case 0x6b19:
return 0x01;
default:
break;
}
return 0;
}
/*************************************
*
* Output ports
*
*************************************/
uint8_t centiped_state::caterplr_unknown_r()
{
return machine().rand() % 0xff;
}
void centiped_state::coin_counter_left_w(int state)
{
machine().bookkeeping().coin_counter_w(0, state);
}
void centiped_state::coin_counter_center_w(int state)
{
machine().bookkeeping().coin_counter_w(1, state);
}
void centiped_state::coin_counter_right_w(int state)
{
machine().bookkeeping().coin_counter_w(2, state);
}
void centiped_state::bullsdrt_coin_count_w(int state)
{
machine().bookkeeping().coin_counter_w(0, state);
}
/*************************************
*
* High score EAROM
*
*************************************/
uint8_t centiped_state::earom_read()
{
return m_earom->data();
}
void centiped_state::earom_write(offs_t offset, uint8_t data)
{
m_earom->set_address(offset & 0x3f);
m_earom->set_data(data);
}
void centiped_state::earom_control_w(uint8_t data)
{
// CK = DB0, C1 = /DB1, C2 = DB2, CS1 = DB3, /CS2 = GND
m_earom->set_control(BIT(data, 3), 1, !BIT(data, 1), BIT(data, 2));
m_earom->set_clk(BIT(data, 0));
}
/*************************************
*
* Centipede CPU memory handlers
*
*************************************/
void centiped_state::centiped_base_map(address_map &map)
{
map.global_mask(0x3fff);
map(0x0000, 0x03ff).ram().share("rambase");
map(0x0400, 0x07bf).ram().w(FUNC(centiped_state::centiped_videoram_w)).share("videoram");
map(0x07c0, 0x07ff).ram().share("spriteram");
map(0x0800, 0x0800).portr("DSW1");
map(0x0801, 0x0801).portr("DSW2");
map(0x0c00, 0x0c00).r(FUNC(centiped_state::centiped_IN0_r));
map(0x0c01, 0x0c01).portr("IN1");
map(0x0c02, 0x0c02).r(FUNC(centiped_state::centiped_IN2_r));
map(0x0c03, 0x0c03).portr("IN3");
map(0x1400, 0x140f).w(FUNC(centiped_state::centiped_paletteram_w)).share("paletteram");
map(0x1600, 0x163f).nopr().w(FUNC(centiped_state::earom_write));
map(0x1680, 0x1680).w(FUNC(centiped_state::earom_control_w));
map(0x1700, 0x173f).r(FUNC(centiped_state::earom_read));
map(0x1800, 0x1800).w(FUNC(centiped_state::irq_ack_w));
map(0x1c00, 0x1c07).nopr().w("outlatch", FUNC(ls259_device::write_d7));
map(0x2000, 0x2000).w("watchdog", FUNC(watchdog_timer_device::reset_w));
map(0x2000, 0x3fff).rom();
}
void centiped_state::centiped_map(address_map &map)
{
centiped_base_map(map);
map(0x1000, 0x100f).rw("pokey", FUNC(pokey_device::read), FUNC(pokey_device::write));
}
void centiped_state::centipedj_map(address_map &map) // no trackball support
{
centiped_map(map);
map.global_mask(0x3fff);
map(0x0c00, 0x0c00).portr("IN0");
map(0x0c02, 0x0c02).portr("IN2");
}
//// Centipede bootlegs ////
void centiped_state::centipdb_map(address_map &map)
{
map.global_mask(0x7fff);
map(0x0000, 0x03ff).mirror(0x4000).ram();
map(0x0400, 0x07bf).mirror(0x4000).ram().w(FUNC(centiped_state::centiped_videoram_w)).share("videoram");
map(0x07c0, 0x07ff).mirror(0x4000).ram().share("spriteram");
map(0x0800, 0x0800).mirror(0x4000).portr("DSW1");
map(0x0801, 0x0801).mirror(0x4000).portr("DSW2");
map(0x0c00, 0x0c00).mirror(0x4000).r(FUNC(centiped_state::centiped_IN0_r));
map(0x0c01, 0x0c01).mirror(0x4000).portr("IN1");
map(0x0c02, 0x0c02).mirror(0x4000).r(FUNC(centiped_state::centiped_IN2_r));
map(0x0c03, 0x0c03).mirror(0x4000).portr("IN3");
map(0x1000, 0x1001).mirror(0x4000).w(m_aysnd, FUNC(ay8910_device::data_address_w));
map(0x1001, 0x1001).mirror(0x4000).r(m_aysnd, FUNC(ay8910_device::data_r));
map(0x1002, 0x100f).mirror(0x4000).noprw();
map(0x1400, 0x140f).mirror(0x4000).w(FUNC(centiped_state::centiped_paletteram_w)).share("paletteram");
map(0x1600, 0x163f).mirror(0x4000).nopr().w(FUNC(centiped_state::earom_write));
map(0x1680, 0x1680).mirror(0x4000).w(FUNC(centiped_state::earom_control_w));
map(0x1700, 0x173f).mirror(0x4000).r(FUNC(centiped_state::earom_read));
map(0x1800, 0x1800).mirror(0x4000).w(FUNC(centiped_state::irq_ack_w));
map(0x1c00, 0x1c07).mirror(0x4000).nopr().w("outlatch", FUNC(ls259_device::write_d7));
map(0x2000, 0x2000).mirror(0x4000).w("watchdog", FUNC(watchdog_timer_device::reset_w));
map(0x2000, 0x27ff).rom();
map(0x2800, 0x3fff).mirror(0x4000).rom();
map(0x6000, 0x67ff).rom();
}
void centiped_state::magworm_map(address_map &map)
{
centiped_base_map(map);
map(0x1001, 0x1001).w(m_aysnd, FUNC(ay8910_device::address_w));
map(0x1003, 0x1003).rw(m_aysnd, FUNC(ay8910_device::data_r), FUNC(ay8910_device::data_w));
}
void centiped_state::caterplr_map(address_map &map)
{
centiped_base_map(map);
map(0x1780, 0x1780).r(FUNC(centiped_state::caterplr_unknown_r));
map(0x1000, 0x100f).rw(FUNC(centiped_state::caterplr_AY8910_r), FUNC(centiped_state::caterplr_AY8910_w));
}
void centiped_state::caterplr_AY8910_w(offs_t offset, uint8_t data)
{
m_aysnd->address_w(offset);
m_aysnd->data_w(data);
}
uint8_t centiped_state::caterplr_AY8910_r(offs_t offset)
{
m_aysnd->address_w(offset);
return m_aysnd->data_r();
}
/*************************************
*
* Millipede CPU memory handlers
*
*************************************/
void centiped_state::milliped_map(address_map &map)
{
map.global_mask(0x7fff);
map(0x0000, 0x03ff).ram();
map(0x0400, 0x040f).rw("pokey", FUNC(pokey_device::read), FUNC(pokey_device::write));
map(0x0800, 0x080f).rw("pokey2", FUNC(pokey_device::read), FUNC(pokey_device::write));
map(0x1000, 0x13bf).ram().w(FUNC(centiped_state::centiped_videoram_w)).share("videoram");
map(0x13c0, 0x13ff).ram().share("spriteram");
map(0x2000, 0x2000).r(FUNC(centiped_state::centiped_IN0_r));
map(0x2001, 0x2001).r(FUNC(centiped_state::milliped_IN1_r));
map(0x2010, 0x2010).r(FUNC(centiped_state::milliped_IN2_r));
map(0x2011, 0x2011).portr("IN3");
map(0x2030, 0x2030).r(FUNC(centiped_state::earom_read));
map(0x2480, 0x249f).w(FUNC(centiped_state::milliped_paletteram_w)).share("paletteram");
map(0x2500, 0x2507).w("outlatch", FUNC(ls259_device::write_d7));
map(0x2600, 0x2600).w(FUNC(centiped_state::irq_ack_w));
map(0x2680, 0x2680).w("watchdog", FUNC(watchdog_timer_device::reset_w));
map(0x2700, 0x2700).w(FUNC(centiped_state::earom_control_w));
map(0x2780, 0x27bf).w(FUNC(centiped_state::earom_write));
map(0x4000, 0x7fff).rom();
}
/*************************************
*
* Multipede CPU memory handlers
*
*************************************/
/*
Multipede is a daughterboard kit produced by Braze Technologies
from 2002(1st version) to 2004(1.2a). It allows users to play
Centipede and Millipede on one board.
The game can be switched at any time with P1+P2 start.
- M6502 CPU (from main pcb)
- 27C512 64KB EPROM
- 93C46P E2PROM for saving highscore/settings
- PALCE22V10H-25PC/4
- 74LS245
- 2*8KB gfx roms, on a separate smaller daughterboard
*/
void multiped_state::multiped_map(address_map &map)
{
map(0x0000, 0x7fff).mirror(0x8000).bankr("rombank");
map(0x0000, 0x03ff).ram();
map(0x0400, 0x07ff).rw(FUNC(multiped_state::multiped_0xxx_r), FUNC(multiped_state::multiped_0xxx_w));
map(0x0800, 0x080f).rw("pokey2", FUNC(pokey_device::read), FUNC(pokey_device::write));
map(0x1000, 0x13bf).ram().w(FUNC(multiped_state::centiped_videoram_w)).share("videoram");
map(0x13c0, 0x13ff).ram().share("spriteram");
map(0x1400, 0x140f).rw("pokey", FUNC(pokey_device::read), FUNC(pokey_device::write));
map(0x2000, 0x3fff).r(FUNC(multiped_state::multiped_2xxx_r));
map(0x2480, 0x249f).mirror(0x8000).w(FUNC(multiped_state::milliped_paletteram_w)).share("paletteram");
map(0x2500, 0x2507).mirror(0x8000).w("outlatch", FUNC(ls259_device::write_d7));
map(0x2600, 0x2600).mirror(0x8000).w(FUNC(multiped_state::irq_ack_w));
map(0x2680, 0x2680).mirror(0x8000).w("watchdog", FUNC(watchdog_timer_device::reset_w));
map(0x2700, 0x2700).mirror(0x8000).nopw();
map(0x2780, 0x27bf).mirror(0x8000).nopw();
map(0xa000, 0xa000).r(FUNC(multiped_state::centiped_IN0_r));
map(0xa001, 0xa001).r(FUNC(multiped_state::milliped_IN1_r));
map(0xa010, 0xa010).r(FUNC(multiped_state::milliped_IN2_r));
map(0xa011, 0xa011).portr("IN3");
map(0xa030, 0xa030).nopr();
map(0xd000, 0xd7ff).w(FUNC(multiped_state::multiped_eeprom_w));
map(0xd800, 0xd800).mirror(0x03ff).rw(FUNC(multiped_state::multiped_eeprom_r), FUNC(multiped_state::multiped_prgbank_w));
map(0xdc00, 0xdc00).mirror(0x03ff).w(FUNC(multiped_state::multiped_gfxbank_w));
}
uint8_t multiped_state::multiped_0xxx_r(offs_t offset)
{
return m_maincpu->space(AS_PROGRAM).read_byte(m_0xxx_base | offset);
}
void multiped_state::multiped_0xxx_w(offs_t offset, uint8_t data)
{
m_maincpu->space(AS_PROGRAM).write_byte(m_0xxx_base | offset, data);
}
uint8_t multiped_state::multiped_2xxx_r(offs_t offset)
{
return m_maincpu->space(AS_PROGRAM).read_byte(0xa000 | offset);
}
uint8_t multiped_state::multiped_eeprom_r()
{
return m_eeprom->do_read() ? 0x80 : 0;
}
void multiped_state::multiped_eeprom_w(offs_t offset, uint8_t data)
{
// a0: always high
// a3-a7: always low
// a8-a10: same as a0-a2
// d0-d6: N/C?
// a1 low: latch bit
if (~offset & 2)
m_eeprom->di_write((data & 0x80) ? 1 : 0);
// a2 low: write latch or select next bit to read
if (~offset & 4)
m_eeprom->clk_write((~data & 0x80) ? ASSERT_LINE : CLEAR_LINE);
// both high: reset
else if (offset & 2)
m_eeprom->cs_write((data & 0x80) ? ASSERT_LINE : CLEAR_LINE);
}
void multiped_state::multiped_prgbank_w(uint8_t data)
{
// d0-d6: N/C?
// d7: prg (and gfx) rom bank
int bank = (data & 0x80) ? 1 : 0;
if (bank != m_prg_bank)
{
m_prg_bank = bank;
multiped_gfxbank_w(m_gfx_bank << 6);
m_rombank->set_entry(bank);
if (!bank)
{
// bank 0: Millipede
// $0400-07ff: mirror of $1400-17ff (POKEY)
// $2000-3fff: mirror of $a000-bfff (I/O ports)
m_0xxx_base = 0x1400;
m_maincpu->space(AS_PROGRAM).install_read_handler(0x2000, 0x3fff, read8sm_delegate(*this, FUNC(multiped_state::multiped_2xxx_r)));
}
else
{
// bank 1: Centipede
// $0400-07ff: mirror of $1000-13ff (video and sprite RAM)
// $2000-3fff: ROM
m_0xxx_base = 0x1000;
m_maincpu->space(AS_PROGRAM).install_rom(0x2000, 0x3fff, (uint8_t*)m_rombank->base() + 0x2000);
}
}
}
/*************************************
*
* Warlords CPU memory handlers
*
*************************************/
void centiped_state::warlords_map(address_map &map)
{
map.global_mask(0x7fff);
map(0x0000, 0x03ff).ram();
map(0x0400, 0x07bf).ram().w(FUNC(centiped_state::centiped_videoram_w)).share("videoram");
map(0x07c0, 0x07ff).ram().share("spriteram");
map(0x0800, 0x0800).portr("DSW1");
map(0x0801, 0x0801).portr("DSW2");
map(0x0c00, 0x0c00).portr("IN0");
map(0x0c01, 0x0c01).portr("IN1");
map(0x1000, 0x100f).rw("pokey", FUNC(pokey_device::read), FUNC(pokey_device::write));
map(0x1800, 0x1800).w(FUNC(centiped_state::irq_ack_w));
map(0x1c00, 0x1c07).w("outlatch", FUNC(ls259_device::write_d7));
map(0x4000, 0x4000).w("watchdog", FUNC(watchdog_timer_device::reset_w));
map(0x5000, 0x7fff).rom();
}
/*************************************
*
* Maze Invaders CPU memory handlers
*
*************************************/
void centiped_state::mazeinv_map(address_map &map)
{
map.global_mask(0x7fff);
map(0x0000, 0x03ff).ram();
map(0x0400, 0x040f).rw("pokey", FUNC(pokey_device::read), FUNC(pokey_device::write));
map(0x0800, 0x080f).rw("pokey2", FUNC(pokey_device::read), FUNC(pokey_device::write));
map(0x1000, 0x13bf).ram().w(FUNC(centiped_state::centiped_videoram_w)).share("videoram");
map(0x13c0, 0x13ff).ram().share("spriteram");
map(0x2000, 0x2000).portr("IN0");
map(0x2001, 0x2001).portr("IN1");
map(0x2010, 0x2010).portr("IN2");
map(0x2011, 0x2011).portr("IN3");
map(0x2020, 0x2020).r(FUNC(centiped_state::mazeinv_input_r));
map(0x2030, 0x2030).r(FUNC(centiped_state::earom_read));
map(0x2480, 0x249f).w(FUNC(centiped_state::mazeinv_paletteram_w)).share("paletteram");
map(0x2500, 0x2507).w("outlatch", FUNC(ls259_device::write_d7));
map(0x2580, 0x2583).w(FUNC(centiped_state::mazeinv_input_select_w));
map(0x2600, 0x2600).w(FUNC(centiped_state::irq_ack_w));
map(0x2680, 0x2680).w("watchdog", FUNC(watchdog_timer_device::reset_w));
map(0x2700, 0x2700).w(FUNC(centiped_state::earom_control_w));
map(0x2780, 0x27bf).w(FUNC(centiped_state::earom_write));
map(0x3000, 0x7fff).rom();
}
/****************************************
*
* Bulls Eye Darts CPU memory handlers
*