Previous 199869 Revisions Next

r32425 Saturday 27th September, 2014 at 04:09:15 UTC by hap
machine/maniach.c filename different from driver name was confusing. decided to move code to the driver file instead of renaming the file, only 120 lines anyway
[src/mame]mame.mak
[src/mame/drivers]matmania.c
[src/mame/includes]matmania.h
[src/mame/machine]maniach.c
[src/mame/video]matmania.c

trunk/src/mame/machine/maniach.c
r32424r32425
1/***************************************************************************
2
3  machine.c
4
5  Functions to emulate general aspects of the machine (RAM, ROM, interrupts,
6  I/O ports)
7
8***************************************************************************/
9
10#include "emu.h"
11#include "includes/matmania.h"
12
13
14/***************************************************************************
15
16 Mania Challenge 68705 protection interface
17
18 The following is ENTIRELY GUESSWORK!!!
19
20***************************************************************************/
21
22READ8_MEMBER(matmania_state::maniach_68705_port_a_r )
23{
24   //logerror("%04x: 68705 port A read %02x\n", space.device().safe_pc(), m_port_a_in);
25   return (m_port_a_out & m_ddr_a) | (m_port_a_in & ~m_ddr_a);
26}
27
28WRITE8_MEMBER(matmania_state::maniach_68705_port_a_w )
29{
30   //logerror("%04x: 68705 port A write %02x\n", space.device().safe_pc(), data);
31   m_port_a_out = data;
32}
33
34WRITE8_MEMBER(matmania_state::maniach_68705_ddr_a_w )
35{
36   m_ddr_a = data;
37}
38
39
40
41/*
42 *  Port B connections:
43 *
44 *  all bits are logical 1 when read (+5V pullup)
45 *
46 *  1   W  when 1->0, enables latch which brings the command from main CPU (read from port A)
47 *  2   W  when 0->1, copies port A to the latch for the main CPU
48 */
49
50READ8_MEMBER(matmania_state::maniach_68705_port_b_r )
51{
52   return (m_port_b_out & m_ddr_b) | (m_port_b_in & ~m_ddr_b);
53}
54
55WRITE8_MEMBER(matmania_state::maniach_68705_port_b_w )
56{
57   //logerror("%04x: 68705 port B write %02x\n", space.device().safe_pc(), data);
58
59   if (BIT(m_ddr_b, 1) && BIT(~data, 1) && BIT(m_port_b_out, 1))
60   {
61      m_port_a_in = m_from_main;
62      m_main_sent = 0;
63      //logerror("read command %02x from main cpu\n", m_port_a_in);
64   }
65   if (BIT(m_ddr_b, 2) && BIT(data, 2) && BIT(~m_port_b_out, 2))
66   {
67      //logerror("send command %02x to main cpu\n", m_port_a_out);
68      m_from_mcu = m_port_a_out;
69      m_mcu_sent = 1;
70   }
71
72   m_port_b_out = data;
73}
74
75WRITE8_MEMBER(matmania_state::maniach_68705_ddr_b_w )
76{
77   m_ddr_b = data;
78}
79
80
81READ8_MEMBER(matmania_state::maniach_68705_port_c_r )
82{
83   m_port_c_in = 0;
84
85   if (m_main_sent)
86      m_port_c_in |= 0x01;
87
88   if (!m_mcu_sent)
89      m_port_c_in |= 0x02;
90
91   //logerror("%04x: 68705 port C read %02x\n",m_space->device().safe_pc(), m_port_c_in);
92
93   return (m_port_c_out & m_ddr_c) | (m_port_c_in & ~m_ddr_c);
94}
95
96WRITE8_MEMBER(matmania_state::maniach_68705_port_c_w )
97{
98   //logerror("%04x: 68705 port C write %02x\n", space.device().safe_pc(), data);
99   m_port_c_out = data;
100}
101
102WRITE8_MEMBER(matmania_state::maniach_68705_ddr_c_w )
103{
104   m_ddr_c = data;
105}
106
107
108WRITE8_MEMBER(matmania_state::maniach_mcu_w )
109{
110   //logerror("%04x: 3040_w %02x\n", space.device().safe_pc(), data);
111   m_from_main = data;
112   m_main_sent = 1;
113}
114
115READ8_MEMBER(matmania_state::maniach_mcu_r )
116{
117   //logerror("%04x: 3040_r %02x\n", space.device().safe_pc(), m_from_mcu);
118   m_mcu_sent = 0;
119   return m_from_mcu;
120}
121
122READ8_MEMBER(matmania_state::maniach_mcu_status_r )
123{
124   int res = 0;
125
126   /* bit 0 = when 0, mcu has sent data to the main cpu */
127   /* bit 1 = when 1, mcu is ready to receive data from main cpu */
128   //logerror("%04x: 3041_r\n", space.device().safe_pc());
129   if (!m_mcu_sent)
130      res |= 0x01;
131   if (!m_main_sent)
132      res |= 0x02;
133
134   return res;
135}
trunk/src/mame/includes/matmania.h
r32424r32425
1919      m_mcu(*this, "mcu"),
2020      m_gfxdecode(*this, "gfxdecode"),
2121      m_screen(*this, "screen"),
22      m_palette(*this, "palette") { }
22      m_palette(*this, "palette")
23   { }
2324
2425   /* memory pointers */
2526   required_shared_ptr<UINT8> m_videoram;
r32424r32425
3334   required_shared_ptr<UINT8> m_spriteram;
3435   required_shared_ptr<UINT8> m_paletteram;
3536
36   /* video-related */
37   bitmap_ind16        *m_tmpbitmap;
38   bitmap_ind16        *m_tmpbitmap2;
39
40   /* mcu */
41   /* maniach 68705 protection */
42   UINT8           m_port_a_in;
43   UINT8           m_port_a_out;
44   UINT8           m_ddr_a;
45   UINT8           m_port_b_in;
46   UINT8           m_port_b_out;
47   UINT8           m_ddr_b;
48   UINT8           m_port_c_in;
49   UINT8           m_port_c_out;
50   UINT8           m_ddr_c;
51   UINT8           m_from_main;
52   UINT8           m_from_mcu;
53   int             m_mcu_sent;
54   int             m_main_sent;
55
5637   /* devices */
5738   required_device<cpu_device> m_maincpu;
5839   required_device<cpu_device> m_audiocpu;
r32424r32425
6142   required_device<screen_device> m_screen;
6243   required_device<palette_device> m_palette;
6344
45   /* video-related */
46   bitmap_ind16 *m_tmpbitmap;
47   bitmap_ind16 *m_tmpbitmap2;
48
49   /* maniach 68705 protection */
50   UINT8 m_port_a_in;
51   UINT8 m_port_a_out;
52   UINT8 m_ddr_a;
53   UINT8 m_port_b_in;
54   UINT8 m_port_b_out;
55   UINT8 m_ddr_b;
56   UINT8 m_port_c_in;
57   UINT8 m_port_c_out;
58   UINT8 m_ddr_c;
59   UINT8 m_from_main;
60   UINT8 m_from_mcu;
61   int m_mcu_sent;
62   int m_main_sent;
63
64   DECLARE_READ8_MEMBER(maniach_68705_port_a_r);
65   DECLARE_WRITE8_MEMBER(maniach_68705_port_a_w);
66   DECLARE_READ8_MEMBER(maniach_68705_port_b_r);
67   DECLARE_WRITE8_MEMBER(maniach_68705_port_b_w);
68   DECLARE_READ8_MEMBER(maniach_68705_port_c_r);
69   DECLARE_WRITE8_MEMBER(maniach_68705_port_c_w);
70   DECLARE_WRITE8_MEMBER(maniach_68705_ddr_a_w);
71   DECLARE_WRITE8_MEMBER(maniach_68705_ddr_b_w);
72   DECLARE_WRITE8_MEMBER(maniach_68705_ddr_c_w);
73   DECLARE_WRITE8_MEMBER(maniach_mcu_w);
74   DECLARE_READ8_MEMBER(maniach_mcu_r);
75   DECLARE_READ8_MEMBER(maniach_mcu_status_r);
76
6477   DECLARE_WRITE8_MEMBER(matmania_sh_command_w);
6578   DECLARE_WRITE8_MEMBER(maniach_sh_command_w);
6679   DECLARE_WRITE8_MEMBER(matmania_paletteram_w);
6780   virtual void video_start();
6881   DECLARE_PALETTE_INIT(matmania);
69   DECLARE_MACHINE_START(matmania);
7082   DECLARE_MACHINE_START(maniach);
7183   DECLARE_MACHINE_RESET(maniach);
7284   UINT32 screen_update_matmania(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
7385   UINT32 screen_update_maniach(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
74   /*----------- defined in machine/maniach.c -----------*/
75   DECLARE_READ8_MEMBER( maniach_68705_port_a_r );
76   DECLARE_WRITE8_MEMBER( maniach_68705_port_a_w );
77   DECLARE_READ8_MEMBER( maniach_68705_port_b_r );
78   DECLARE_WRITE8_MEMBER( maniach_68705_port_b_w );
79   DECLARE_READ8_MEMBER( maniach_68705_port_c_r );
80   DECLARE_WRITE8_MEMBER( maniach_68705_port_c_w );
81   DECLARE_WRITE8_MEMBER( maniach_68705_ddr_a_w );
82   DECLARE_WRITE8_MEMBER( maniach_68705_ddr_b_w );
83   DECLARE_WRITE8_MEMBER( maniach_68705_ddr_c_w );
84   DECLARE_WRITE8_MEMBER( maniach_mcu_w );
85   DECLARE_READ8_MEMBER( maniach_mcu_r );
86   DECLARE_READ8_MEMBER( maniach_mcu_status_r );
8786};
trunk/src/mame/mame.mak
r32424r32425
19761976   $(DRIVERS)/ddragon.o $(VIDEO)/ddragon.o \
19771977   $(DRIVERS)/ddragon3.o $(VIDEO)/ddragon3.o \
19781978   $(DRIVERS)/dogfgt.o $(VIDEO)/dogfgt.o \
1979   $(DRIVERS)/matmania.o $(MACHINE)/maniach.o $(VIDEO)/matmania.o \
1979   $(DRIVERS)/matmania.o $(VIDEO)/matmania.o \
19801980   $(DRIVERS)/mystston.o $(VIDEO)/mystston.o \
19811981   $(DRIVERS)/renegade.o $(VIDEO)/renegade.o \
19821982   $(DRIVERS)/scregg.o \
trunk/src/mame/video/matmania.c
r32424r32425
4141  bit 0 -- 2.2kohm resistor  -- BLUE
4242
4343***************************************************************************/
44
4445PALETTE_INIT_MEMBER(matmania_state, matmania)
4546{
4647   const UINT8 *color_prom = memregion("proms")->base();
47   int i;
4848
49   for (i = 0; i < 64; i++)
49   for (int i = 0; i < 64; i++)
5050   {
5151      int bit0, bit1, bit2, bit3, r, g, b;
5252
r32424r32425
7777{
7878   int bit0, bit1, bit2, bit3, val;
7979   int r, g, b;
80   int offs2;
8180
8281   m_paletteram[offset] = data;
83   offs2 = offset & 0x0f;
82   offset &= 0x0f;
8483
85   val = m_paletteram[offs2];
84   val = m_paletteram[offset];
8685   bit0 = BIT(val, 0);
8786   bit1 = BIT(val, 1);
8887   bit2 = BIT(val, 2);
8988   bit3 = BIT(val, 3);
9089   r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
9190
92   val = m_paletteram[offs2 | 0x10];
91   val = m_paletteram[offset | 0x10];
9392   bit0 = BIT(val, 0);
9493   bit1 = BIT(val, 1);
9594   bit2 = BIT(val, 2);
9695   bit3 = BIT(val, 3);
9796   g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
9897
99   val = m_paletteram[offs2 | 0x20];
98   val = m_paletteram[offset | 0x20];
10099   bit0 = BIT(val, 0);
101100   bit1 = BIT(val, 1);
102101   bit2 = BIT(val, 2);
103102   bit3 = BIT(val, 3);
104103   b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
105104
106   m_palette->set_pen_color(offs2 + 64,rgb_t(r,g,b));
105   m_palette->set_pen_color(offset + 64, rgb_t(r,g,b));
107106}
108107
109108
trunk/src/mame/drivers/matmania.c
r32424r32425
3838#include "sound/3526intf.h"
3939#include "includes/matmania.h"
4040
41
4142/*************************************
4243 *
43 *  Memory handlers
44 *  Mania Challenge 68705 protection interface
4445 *
46 *  The following is ENTIRELY GUESSWORK!!!
47 *
4548 *************************************/
4649
50READ8_MEMBER(matmania_state::maniach_68705_port_a_r)
51{
52   //logerror("%04x: 68705 port A read %02x\n", space.device().safe_pc(), m_port_a_in);
53   return (m_port_a_out & m_ddr_a) | (m_port_a_in & ~m_ddr_a);
54}
55
56WRITE8_MEMBER(matmania_state::maniach_68705_port_a_w)
57{
58   //logerror("%04x: 68705 port A write %02x\n", space.device().safe_pc(), data);
59   m_port_a_out = data;
60}
61
62WRITE8_MEMBER(matmania_state::maniach_68705_ddr_a_w)
63{
64   m_ddr_a = data;
65}
66
67
68/*
69 *  Port B connections:
70 *
71 *  all bits are logical 1 when read (+5V pullup)
72 *
73 *  1   W  when 1->0, enables latch which brings the command from main CPU (read from port A)
74 *  2   W  when 0->1, copies port A to the latch for the main CPU
75 */
76
77READ8_MEMBER(matmania_state::maniach_68705_port_b_r)
78{
79   return (m_port_b_out & m_ddr_b) | (m_port_b_in & ~m_ddr_b);
80}
81
82WRITE8_MEMBER(matmania_state::maniach_68705_port_b_w)
83{
84   //logerror("%04x: 68705 port B write %02x\n", space.device().safe_pc(), data);
85
86   if (BIT(m_ddr_b, 1) && BIT(~data, 1) && BIT(m_port_b_out, 1))
87   {
88      m_port_a_in = m_from_main;
89      m_main_sent = 0;
90      //logerror("read command %02x from main cpu\n", m_port_a_in);
91   }
92   if (BIT(m_ddr_b, 2) && BIT(data, 2) && BIT(~m_port_b_out, 2))
93   {
94      //logerror("send command %02x to main cpu\n", m_port_a_out);
95      m_from_mcu = m_port_a_out;
96      m_mcu_sent = 1;
97   }
98
99   m_port_b_out = data;
100}
101
102WRITE8_MEMBER(matmania_state::maniach_68705_ddr_b_w)
103{
104   m_ddr_b = data;
105}
106
107
108READ8_MEMBER(matmania_state::maniach_68705_port_c_r)
109{
110   m_port_c_in = 0;
111
112   if (m_main_sent)
113      m_port_c_in |= 0x01;
114
115   if (!m_mcu_sent)
116      m_port_c_in |= 0x02;
117
118   //logerror("%04x: 68705 port C read %02x\n",m_space->device().safe_pc(), m_port_c_in);
119
120   return (m_port_c_out & m_ddr_c) | (m_port_c_in & ~m_ddr_c);
121}
122
123WRITE8_MEMBER(matmania_state::maniach_68705_port_c_w)
124{
125   //logerror("%04x: 68705 port C write %02x\n", space.device().safe_pc(), data);
126   m_port_c_out = data;
127}
128
129WRITE8_MEMBER(matmania_state::maniach_68705_ddr_c_w)
130{
131   m_ddr_c = data;
132}
133
134
135WRITE8_MEMBER(matmania_state::maniach_mcu_w)
136{
137   //logerror("%04x: 3040_w %02x\n", space.device().safe_pc(), data);
138   m_from_main = data;
139   m_main_sent = 1;
140}
141
142READ8_MEMBER(matmania_state::maniach_mcu_r)
143{
144   //logerror("%04x: 3040_r %02x\n", space.device().safe_pc(), m_from_mcu);
145   m_mcu_sent = 0;
146   return m_from_mcu;
147}
148
149READ8_MEMBER(matmania_state::maniach_mcu_status_r)
150{
151   int res = 0;
152
153   /* bit 0 = when 0, mcu has sent data to the main cpu */
154   /* bit 1 = when 1, mcu is ready to receive data from main cpu */
155   //logerror("%04x: 3041_r\n", space.device().safe_pc());
156   if (!m_mcu_sent)
157      res |= 0x01;
158   if (!m_main_sent)
159      res |= 0x02;
160
161   return res;
162}
163
164
165/*************************************
166 *
167 *  Misc Memory handlers
168 *
169 *************************************/
170
47171WRITE8_MEMBER(matmania_state::matmania_sh_command_w)
48172{
49173   soundlatch_byte_w(space, offset, data);
r32424r32425
296420 *
297421 *************************************/
298422
299MACHINE_START_MEMBER(matmania_state,matmania)
300{
301}
302
303423static MACHINE_CONFIG_START( matmania, matmania_state )
304424
305425   /* basic machine hardware */
r32424r32425
310430   MCFG_CPU_ADD("audiocpu", M6502, 1200000)    /* 1.2 MHz ???? */
311431   MCFG_CPU_PROGRAM_MAP(matmania_sound_map)
312432   MCFG_CPU_PERIODIC_INT_DRIVER(matmania_state, nmi_line_pulse, 15*60) /* ???? */
313                        /* IRQs are caused by the main CPU */
314   MCFG_QUANTUM_TIME(attotime::from_hz(600))
315433
316   MCFG_MACHINE_START_OVERRIDE(matmania_state,matmania)
434   MCFG_QUANTUM_TIME(attotime::from_hz(6000))
317435
318436   /* video hardware */
319437   MCFG_SCREEN_ADD("screen", RASTER)
r32424r32425
344462
345463MACHINE_START_MEMBER(matmania_state,maniach)
346464{
347   MACHINE_START_CALL_MEMBER(matmania);
348
349465   save_item(NAME(m_port_a_in));
350466   save_item(NAME(m_port_a_out));
351467   save_item(NAME(m_ddr_a));
r32424r32425
387503
388504   MCFG_CPU_ADD("audiocpu", M6809, 1500000)    /* 1.5 MHz ???? */
389505   MCFG_CPU_PROGRAM_MAP(maniach_sound_map)
390                        /* IRQs are caused by the main CPU */
391506
392507   MCFG_CPU_ADD("mcu", M68705, 1500000*2)  /* (don't know really how fast, but it doesn't need to even be this fast) */
393508   MCFG_CPU_PROGRAM_MAP(maniach_mcu_map)
r32424r32425
421536   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)
422537MACHINE_CONFIG_END
423538
539
424540/*************************************
425541 *
426542 *  ROM definition(s)
r32424r32425
656772 *************************************/
657773
658774GAME( 1985, matmania, 0,        matmania, matmania, driver_device, 0, ROT270, "Technos Japan (Taito America license)", "Mat Mania", GAME_SUPPORTS_SAVE )
659GAME( 1985, excthour, matmania, matmania, maniach, driver_device,  0, ROT270, "Technos Japan (Taito license)", "Exciting Hour", GAME_SUPPORTS_SAVE )
660GAME( 1986, maniach,  0,        maniach,  maniach, driver_device,  0, ROT270, "Technos Japan (Taito America license)", "Mania Challenge (set 1)", GAME_SUPPORTS_SAVE )
661GAME( 1986, maniach2, maniach,  maniach,  maniach, driver_device,  0, ROT270, "Technos Japan (Taito America license)", "Mania Challenge (set 2)", GAME_SUPPORTS_SAVE )  /* earlier version? */
775GAME( 1985, excthour, matmania, matmania, maniach,  driver_device, 0, ROT270, "Technos Japan (Taito license)", "Exciting Hour", GAME_SUPPORTS_SAVE )
776GAME( 1986, maniach,  0,        maniach,  maniach,  driver_device, 0, ROT270, "Technos Japan (Taito America license)", "Mania Challenge (set 1)", GAME_SUPPORTS_SAVE )
777GAME( 1986, maniach2, maniach,  maniach,  maniach,  driver_device, 0, ROT270, "Technos Japan (Taito America license)", "Mania Challenge (set 2)", GAME_SUPPORTS_SAVE ) /* earlier version? */

Previous 199869 Revisions Next


© 1997-2024 The MAME Team