Previous 15994 Revisions Next

r1479 Friday 4th January, 2008 at 00:46:25 UTC by Nathan Woods
Updated to MAME 0.122u3 core
[docs]messnew.txt
[src/emu]driver.h fileio.h mame.c mame.h memory.c memory.h romload.c ui.c uimenu.c
[src/emu/cpu]x86log.h
[src/emu/cpu/e132xs]e132xs.c
[src/emu/cpu/i8051]i8051.c
[src/emu/cpu/mc68hc11]hc11dasm.c
[src/emu/cpu/mips]psx.c
[src/emu/cpu/rsp]rsp_dasm.c
[src/emu/cpu/sharc]sharcdsm.c
[src/emu/cpu/tms32051]dis32051.c
[src/emu/debug]debugcmd.c debugcpu.c debugcpu.h
[src/emu/drivers]xtal.h*
[src/emu/machine]adc083x.c ds2401.c generic.c i2cmem.c x76f041.c x76f100.c
[src/emu/sound]discrete.c k054539.c psx.c sidenvel.c tms5110r.c
[src/lib/util]astring.h cdrom.c corefile.h options.c pool.c
[src/mame]mame.mak mamedriv.c
[src/mame/audio]mario.c
[src/mame/drivers]btoads.c cninja.c dkong.c flstory.c funkyjet.c itech8.c ksys573.c legionna.c mario.c midyunit.c midzeus.c namcos1.c namcos11.c namcos12.c sbrkout.c seta.c simpsons.c sslam.c suprloco.c taitosj.c toki.c zn.c
[src/mame/includes]dc.h mario.h* midzeus.h
[src/mame/layout]crusnexo.lay*
[src/mame/machine]dc.c decoprot.c flstory.c namcos1.c psx.c snes.c snesdsp1.c zs01.c
[src/mame/video]btoads.c dc.c flstory.c legionna.c liberate.c mario.c namcos1.c psx.c suprloco.c
[src/osd/windows]debugwin.c ledutil.c main.c windows.mak winmain.c

src/mame/audio/mario.c
r1478r1479
11#include "driver.h"
22#include "cpu/i8039/i8039.h"
3#include "sound/dac.h"
4#include "sound/ay8910.h"
35#include "sound/samples.h"
46
7#include "includes/mario.h"
58
9/****************************************************************
10 *
11 * Defines and Macros
12 *
13 ****************************************************************/
614
15#define ACTIVELOW_PORT_BIT(P,A,D)   ((P & (~(1 << A))) | ((D ^ 1) << A))
16#define ACTIVEHIGH_PORT_BIT(P,A,D)   ((P & (~(1 << A))) | (D << A))
17
18/*************************************
19 *
20 *  statics
21 *
22 *************************************/
23
24static UINT8 p[8] = { 0,0xf0,0,0,0,0,0,0 };
25static UINT8 t[2] = { 0,0 };
26
27static UINT8 last;
28
29/****************************************************************
30 *
31 * Initialization
32 *
33 ****************************************************************/
34
35static SOUND_START( mario )
36{
37   p[1] = 0xf0;
38   state_save_register_global_array(p);
39   state_save_register_global_array(t);
40   state_save_register_global(last);
41}
42
43/****************************************************************
44 *
45 * I/O Handlers - static
46 *
47 ****************************************************************/
48
49static READ8_HANDLER( mario_sh_p1_r )
50{
51   return p[1];
52}
53
54static READ8_HANDLER( mario_sh_p2_r )
55{
56   return p[2];
57}
58
59static READ8_HANDLER( mario_sh_t0_r )
60{
61   return t[0];
62}
63
64static READ8_HANDLER( mario_sh_t1_r )
65{
66   return t[1];
67}
68
69static READ8_HANDLER( mario_sh_tune_r )
70{
71   return soundlatch_r(offset);
72}
73
74static WRITE8_HANDLER( mario_sh_sound_w )
75{
76   DAC_data_w(0,data);
77}
78
79static WRITE8_HANDLER( mario_sh_p1_w )
80{
81   p[1] = data;
82}
83
84static WRITE8_HANDLER( mario_sh_p2_w )
85{
86   p[2] = data;
87}
88
89/****************************************************************
90 *
91 * I/O Handlers - global
92 *
93 ****************************************************************/
94
95WRITE8_HANDLER( mario_sh_getcoin_w )
96{
97   t[0] = data;
98}
99
100WRITE8_HANDLER( mario_sh_crab_w )
101{
102   p[1] = ACTIVEHIGH_PORT_BIT(p[1],0,data);
103}
104
105WRITE8_HANDLER( mario_sh_turtle_w )
106{
107   p[1] = ACTIVEHIGH_PORT_BIT(p[1],1,data);
108}
109
110WRITE8_HANDLER( mario_sh_fly_w )
111{
112   p[1] = ACTIVEHIGH_PORT_BIT(p[1],2,data);
113}
114
115WRITE8_HANDLER( masao_sh_irqtrigger_w )
116{
117   if (last == 1 && data == 0)
118   {
119      /* setting bit 0 high then low triggers IRQ on the sound CPU */
120      cpunum_set_input_line_and_vector(1,0,HOLD_LINE,0xff);
121   }
122
123   last = data;
124}
125
126WRITE8_HANDLER( mario_sh_tuneselect_w )
127{
128   soundlatch_w(offset,data);
129}
130
7131WRITE8_HANDLER( mario_sh_w )
8132{
9133   if (data)
r1478r1479
62186      }
63187   }
64188}
189
190/*************************************
191 *
192 *  Sound CPU memory handlers
193 *
194 *************************************/
195
196static ADDRESS_MAP_START( mario_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
197   AM_RANGE(0x0000, 0x0fff) AM_ROM
198ADDRESS_MAP_END
199
200static ADDRESS_MAP_START( mario_sound_io_map, ADDRESS_SPACE_IO, 8 )
201   AM_RANGE(0x00, 0xff) AM_READWRITE(mario_sh_tune_r, mario_sh_sound_w)
202   AM_RANGE(I8039_p1, I8039_p1) AM_READWRITE(mario_sh_p1_r, mario_sh_p1_w)
203   AM_RANGE(I8039_p2, I8039_p2) AM_READWRITE(mario_sh_p2_r, mario_sh_p2_w)
204   AM_RANGE(I8039_t0, I8039_t0) AM_READ(mario_sh_t0_r)
205   AM_RANGE(I8039_t1, I8039_t1) AM_READ(mario_sh_t1_r)
206ADDRESS_MAP_END
207
208static ADDRESS_MAP_START( masao_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
209   AM_RANGE(0x0000, 0x0fff) AM_ROM
210   AM_RANGE(0x2000, 0x23ff) AM_RAM
211   AM_RANGE(0x4000, 0x4000) AM_READWRITE(AY8910_read_port_0_r, AY8910_write_port_0_w)
212   AM_RANGE(0x6000, 0x6000) AM_WRITE(AY8910_control_port_0_w)
213ADDRESS_MAP_END
214
215/*************************************
216 *
217 *  Sound Interfaces
218 *
219 *************************************/
220
221static const char *const mario_sample_names[] =
222{
223   "*mario",
224
225   /* 7f01 - 7f07 sounds */
226   "ice.wav",    /* 0x02 ice appears (formerly effect0.wav) */
227   "coin.wav",   /* 0x06 coin appears (formerly effect1.wav) */
228   "skid.wav",   /* 0x07 skid */
229
230   /* 7c00 */
231   "run.wav",        /* 03, 02, 01 - 0x1b */
232
233   /* 7c80 */
234   "luigirun.wav",   /* 03, 02, 01 - 0x1c */
235
236    0   /* end of array */
237};
238
239static const struct Samplesinterface samples_interface =
240{
241   3,   /* 3 channels */
242   mario_sample_names
243};
244
245static const struct AY8910interface ay8910_interface =
246{
247   soundlatch_r
248};
249
250
251/*************************************
252 *
253 *  Machine driver
254 *
255 *************************************/
256
257MACHINE_DRIVER_START( mario_audio )
258
259   MDRV_CPU_ADD(I8039, I8035_CLOCK)  /* audio CPU */         /* 730 kHz */
260   MDRV_CPU_PROGRAM_MAP(mario_sound_map, 0)
261   MDRV_CPU_IO_MAP(mario_sound_io_map, 0)
262
263   MDRV_SOUND_START(mario)
264
265   MDRV_SPEAKER_STANDARD_MONO("mono")
266
267   MDRV_SOUND_ADD(DAC, 0)
268   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
269
270   MDRV_SOUND_ADD(SAMPLES, 0)
271   MDRV_SOUND_CONFIG(samples_interface)
272   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
273
274MACHINE_DRIVER_END
275
276MACHINE_DRIVER_START( masao_audio )
277
278   MDRV_CPU_ADD(Z80,24576000/16) /* audio CPU */   /* ???? */
279   MDRV_CPU_PROGRAM_MAP(masao_sound_map,0)
280
281   MDRV_SOUND_START(mario)
282
283   MDRV_SPEAKER_STANDARD_MONO("mono")
284
285   MDRV_SOUND_ADD(AY8910, 14318000/6)
286   MDRV_SOUND_CONFIG(ay8910_interface)
287   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
288
289MACHINE_DRIVER_END
290
src/mame/machine/flstory.c
r1478r1479
99
1010#include "driver.h"
1111
12extern UINT8 *onna34ro_workram;
13extern UINT8 *victnine_workram;
1214
1315static UINT8 from_main,from_mcu;
1416static int mcu_sent = 0,main_sent = 0;
r1478r1479
140142
141143WRITE8_HANDLER( onna34ro_mcu_w )
142144{
143   UINT8 *RAM = memory_region(REGION_CPU1);
144   UINT16 score_adr = RAM[0xe29e]*0x100 + RAM[0xe29d];
145   UINT16 score_adr = onna34ro_workram[0x29e]*0x100 + onna34ro_workram[0x29d];
145146
146147   switch (data)
147148   {
r1478r1479
152153         from_mcu = 0x6a;
153154         break;
154155      case 0x40:
155         from_mcu = RAM[score_adr];         /* score l*/
156         if(score_adr >= 0xe000 && score_adr < 0xe800)
157            from_mcu = onna34ro_workram[score_adr - 0xe000];         /* score l*/
156158         break;
157159      case 0x41:
158         from_mcu = RAM[score_adr+1];      /* score m*/
160         if(score_adr >= 0xe000 && score_adr < 0xe800)
161            from_mcu = onna34ro_workram[(score_adr+1) - 0xe000];      /* score m*/
159162         break;
160163      case 0x42:
161         from_mcu = RAM[score_adr+2] & 0x0f;   /* score h*/
164         if(score_adr >= 0xe000 && score_adr < 0xe800)
165            from_mcu = onna34ro_workram[(score_adr+2) - 0xe000] & 0x0f;   /* score h*/
162166         break;
163167      default:
164168         from_mcu = 0x80;
r1478r1479
178182}
179183
180184
181#define VICTNINE_MCU_SEED   (memory_region(REGION_CPU1)[0xE685])
185#define VICTNINE_MCU_SEED   (victnine_workram[0x685])
182186
183187static const UINT8 victnine_mcu_data[0x100] =
184188{
r1478r1479
245249      }
246250      else if (data >= 0x38 && data <= 0x3a)
247251      {
248         UINT8 *RAM = memory_region(REGION_CPU1);
249
250         from_mcu = RAM[0xe691 - 0x38 + data];
252         from_mcu = victnine_workram[0x691 - 0x38 + data];
251253      }
252254      else
253255      {
src/mame/machine/dc.c
r1478r1479
44
55*/
66
7#include "mamecore.h"
78#include "driver.h"
89#include "dc.h"
910
11#define DEBUG_REGISTERS   (1)
12
13#if DEBUG_REGISTERS
14
15#define DEBUG_SYSCTRL   (1)
16#define DEBUG_MAPLE   (0)
17
18#if DEBUG_SYSCTRL
19static const char *sysctrl_names[] =
20{
21   "CH2 DMA dest",
22   "CH2 DMA length",
23   "CH2 DMA start",
24   "5f680c",
25   "Sort DMA start link table addr",
26   "Sort DMA link base addr",
27   "Sort DMA link address bit width",
28   "Sort DMA link address shift control",
29   "Sort DMA start",
30   "5f6824", "5f6828", "5f682c", "5f6830",
31   "5f6834", "5f6838", "5f683c",
32   "DBREQ # signal mask control",
33   "BAVL # signal wait count",
34   "DMA priority count",
35   "CH2 DMA max burst length",
36   "5f6850", "5f6854", "5f6858", "5f685c",
37   "5f6860", "5f6864", "5f6868", "5f686c",
38   "5f6870", "5f6874", "5f6878", "5f687c",
39   "TA FIFO remaining",
40   "TA texture memory bus select 0",
41   "TA texture memory bus select 1",
42   "FIFO status",
43   "System reset", "5f6894", "5f6898",
44   "System bus version",
45   "SH4 root bus split enable",
46   "5f68a4", "5f68a8", "5f68ac",
47   "5f68b0", "5f68b4", "5f68b8", "5f68bc",
48   "5f68c0", "5f68c4", "5f68c8", "5f68cc",
49   "5f68d0", "5f68d4", "5f68d8", "5f68dc",
50   "5f68e0", "5f68e4", "5f68e8", "5f68ec",
51   "5f68f0", "5f68f4", "5f68f8", "5f68fc",
52   "Normal IRQ status",
53   "External IRQ status",
54   "Error IRQ status", "5f690c",
55   "Level 2 normal IRQ mask",
56   "Level 2 external IRQ mask",
57   "Level 2 error IRQ mask", "5f691c",
58   "Level 4 normal IRQ mask",
59   "Level 4 external IRQ mask",
60   "Level 4 error IRQ mask", "5f692c",
61   "Level 6 normal IRQ mask",
62   "Level 6 external IRQ mask",
63   "Level 6 error IRQ mask", "5f693c",
64   "Normal IRQ PVR-DMA startup mask",
65   "External IRQ PVR-DMA startup mask",
66   "5f6948", "5f694c",
67   "Normal IRQ G2-DMA startup mask",
68   "External IRQ G2-DMA startup mask"
69};
70#endif
71
72#if DEBUG_MAPLE
73static const char *maple_names[] =
74{
75   "5f6c00",
76   "DMA command table addr",
77   "5f6c08", "5f6c0c",
78   "DMA trigger select",
79   "DMA enable",
80   "DMA start", "5f6c1c",
81   "5f6c20", "5f6c24", "5f6c28", "5f6c2c",
82   "5f6c30", "5f6c34", "5f6c38", "5f6c3c",
83   "5f6c40", "5f6c44", "5f6c48", "5f6c4c",
84   "5f6c50", "5f6c54", "5f6c58", "5f6c5c",
85   "5f6c60", "5f6c64", "5f6c68", "5f6c6c",
86   "5f6c70", "5f6c74", "5f6c78", "5f6c7c",
87   "System control",
88   "Status",
89   "DMA hard trigger clear",
90   "DMA address range",
91   "5f6c90", "5f6c94", "5f6c98", "5f6c9c",
92   "5f6ca0", "5f6ca4", "5f6ca8", "5f6cac",
93   "5f6cb0", "5f6cb4", "5f6cb8", "5f6cbc",
94   "5f6cc0", "5f6cc4", "5f6cc8", "5f6ccc",
95   "5f6cd0", "5f6cd4", "5f6cd8", "5f6cdc",
96   "5f6ce0", "5f6ce4",
97   "MSB select", "5f6cec", "5f6cf0",
98   "Txd address counter",
99   "Rxd address counter",
100   "Rxd base address"
101
102};
103#endif
104
105#endif
106
107// selected Maple registers
108enum
109{
110   MAPLE_DMACMD = 1,
111   MAPLE_DMATRIGGERSEL = 4,
112   MAPLE_DMAENABLE = 5,
113   MAPLE_DMASTART = 6,
114   MAPLE_SYSCTRL = 0x20,
115   MAPLE_STATUS = 0x21,
116};
117
118static UINT32 sysctrl_regs[0x200/4];
119static UINT32 maple_regs[0x100/4];
120
121// register decode helper
122
123INLINE int decode_reg_64(UINT32 offset, UINT64 mem_mask, UINT64 *shift)
124{
125   int reg = offset * 2;
126
127   *shift = 0;
128
129   if (mem_mask == U64(0x00000000ffffffff))
130   {
131      reg++;
132      *shift = 32;
133    }
134
135   return reg;
136}
137
138// I/O functions
139
10140READ64_HANDLER( dc_sysctrl_r )
11141{
12   return 0;
142   int reg;
143   UINT64 shift;
144
145   reg = decode_reg_64(offset, mem_mask, &shift);
146
147   #if DEBUG_SYSCTRL
148   mame_printf_verbose("SYSCTRL: read %x @ %x (reg %x: %s), mask %llx (PC=%x)\n", sysctrl_regs[reg], offset, reg, sysctrl_names[reg], mem_mask, activecpu_get_pc());
149   #endif
150
151   return (UINT64)sysctrl_regs[reg] << shift;
13152}
14153
15154WRITE64_HANDLER( dc_sysctrl_w )
16155{
17   mame_printf_verbose("SYSCTRL: write %llx to %x, mask %llx\n", data, offset, mem_mask);
156   int reg;
157   UINT64 shift;
158
159   reg = decode_reg_64(offset, mem_mask, &shift);
160
161   #if DEBUG_SYSCTRL
162   mame_printf_verbose("SYSCTRL: write %llx to %x (reg %x: %s), mask %llx\n", data>>shift, offset, reg, sysctrl_names[reg], mem_mask);
163   #endif
164
165   sysctrl_regs[reg] |= data >> shift;
18166}
19167
20168READ64_HANDLER( dc_maple_r )
21169{
22   return 0;
170   int reg;
171   UINT64 shift;
172
173   reg = decode_reg_64(offset, mem_mask, &shift);
174
175   return (UINT64)maple_regs[reg] << shift;
23176}
24177
25178WRITE64_HANDLER( dc_maple_w )
26179{
27   mame_printf_verbose("MAPLE: write %llx to %x, mask %llx\n", data, offset, mem_mask);
180   int reg;
181   UINT64 shift;
182
183   reg = decode_reg_64(offset, mem_mask, &shift);
184
185   #if DEBUG_MAPLE
186   mame_printf_verbose("MAPLE: write %llx to %x (reg %x: %s), mask %llx\n", data >> shift, offset, reg, maple_names[reg], mem_mask);
187   #endif
188
189   maple_regs[reg] |= data >> shift;
28190}
29191
30192READ64_HANDLER( dc_gdrom_r )
r1478r1479
77239   mame_printf_verbose("RTC: write %llx to %x, mask %llx\n", data, offset, mem_mask);
78240}
79241
80MACHINE_RESET( dc )
81{
82   /* halt the ARM7 */
83   cpunum_set_input_line(1, INPUT_LINE_RESET, ASSERT_LINE);
84}
85
86242READ64_HANDLER( dc_aica_reg_r )
87243{
88244   return 0;
r1478r1479
93249   mame_printf_verbose("AICA REG: write %llx to %x, mask %llx\n", data, offset, mem_mask);
94250}
95251
252MACHINE_RESET( dc )
253{
254   /* halt the ARM7 */
255   cpunum_set_input_line(1, INPUT_LINE_RESET, ASSERT_LINE);
256
257   memset(sysctrl_regs, 0, sizeof(sysctrl_regs));
258   memset(maple_regs, 0, sizeof(maple_regs));
259
260   sysctrl_regs[0x27] = 0x00000008;   // Naomi BIOS requires at least this version
261}
262
263// called at vblank
264void dc_vblank( void )
265{
266   // is system control set for automatic polling on VBL?
267   if ((maple_regs[MAPLE_SYSCTRL] & 0xffff0000) == 0x3a980000)
268   {
269      // is enabled?
270      if (maple_regs[MAPLE_DMAENABLE] == 1)
271      {
272         // is started?
273         if (maple_regs[MAPLE_DMASTART] == 1)
274         {
275            UINT32 cmd, dest, addr = maple_regs[MAPLE_DMACMD];
276
277            // process the command list
278            // first word: bit 31 set = last command in list, 16-17 = port, 8-10 = pattern, 0-7 = xfer length
279            // second word: destination address
280            // third word: what to send to port A
281            cmd = 0;
282            while (!(cmd & 0x80000000))
283            {
284               // read command word
285               cmd = program_read_dword(addr);
286
287               dest = program_read_dword(addr+4);
288
289               // just indicate "no connection" for now
290               program_write_dword(dest, 0);
291               program_write_dword(dest+4, 0xffffffff);
292
293               // skip fixed packet header
294               addr += 8;
295               // skip transfer data
296               addr += ((cmd & 0xff) + 1) * 4;
297            }
298
299
300            #if DEBUG_MAPLE
301            mame_printf_verbose("MAPLE: automatic read, table @ %x\n", addr);
302            #endif
303
304            // indicate transfer completed
305            maple_regs[MAPLE_DMASTART] = 0;
306         }
307      }
308   }
309}
310
src/mame/machine/namcos1.c
r1478r1479
44
55#define NAMCOS1_MAX_BANK 0x400
66
7/* from drivers */
8void namcos1_init_DACs(void);
9
710/* from video */
811READ8_HANDLER( namcos1_videoram_r );
912WRITE8_HANDLER( namcos1_videoram_w );
r1478r1479
570573
571574static int mcu_patch_data;
572575static int namcos1_reset = 0;
576static int wdog;
577static int chip[16];
573578
574579WRITE8_HANDLER( namcos1_cpu_control_w )
575580{
r1478r1479
589594
590595WRITE8_HANDLER( namcos1_watchdog_w )
591596{
592   static int wdog;
593
594597   wdog |= 1 << (cpu_getactivecpu());
595598   if (wdog == 7 || !namcos1_reset)
596599   {
r1478r1479
702705
703706static void namcos1_bankswitch(int cpu, offs_t offset, UINT8 data)
704707{
705   static int chip[16];
706708   int bank = (cpu*8) + (( offset >> 9) & 0x07);
707709
708710   if (offset & 1)
r1478r1479
865867   /* mcu patch data clear */
866868   mcu_patch_data = 0;
867869   namcos1_reset = 0;
870
871   namcos1_init_DACs();
872   memset(key, 0, sizeof(key));
873   memset(chip, 0, sizeof(chip));
874   wdog = 0;
868875}
869876
870877
r1478r1479
949956
950957static void namcos1_driver_init(const struct namcos1_specific *specific )
951958{
952   const struct namcos1_specific no_key =
959   static const struct namcos1_specific no_key =
953960   {
954961      no_key_r,no_key_w
955962   };
r1478r1479
9981005*******************************************************************************/
9991006DRIVER_INIT( dspirit )
10001007{
1001   const struct namcos1_specific dspirit_specific=
1008   static const struct namcos1_specific dspirit_specific=
10021009   {
10031010      key_type1_r,key_type1_w, 0x36
10041011   };
r1478r1479
10101017*******************************************************************************/
10111018DRIVER_INIT( wldcourt )
10121019{
1013   const struct namcos1_specific worldcourt_specific=
1020   static const struct namcos1_specific worldcourt_specific=
10141021   {
10151022      key_type1_r,key_type1_w, 0x35
10161023   };
r1478r1479
10221029*******************************************************************************/
10231030DRIVER_INIT( blazer )
10241031{
1025   const struct namcos1_specific blazer_specific=
1032   static const struct namcos1_specific blazer_specific=
10261033   {
10271034      key_type1_r,key_type1_w, 0x13
10281035   };
r1478r1479
10341041*******************************************************************************/
10351042DRIVER_INIT( puzlclub )
10361043{
1037   const struct namcos1_specific puzlclub_specific=
1044   static const struct namcos1_specific puzlclub_specific=
10381045   {
10391046      key_type1_r,key_type1_w, 0x35
10401047   };
r1478r1479
10461053*******************************************************************************/
10471054DRIVER_INIT( pacmania )
10481055{
1049   const struct namcos1_specific pacmania_specific=
1056   static const struct namcos1_specific pacmania_specific=
10501057   {
10511058      key_type2_r,key_type2_w, 0x12
10521059   };
r1478r1479
10581065*******************************************************************************/
10591066DRIVER_INIT( alice )
10601067{
1061   const struct namcos1_specific alice_specific=
1068   static const struct namcos1_specific alice_specific=
10621069   {
10631070      key_type2_r,key_type2_w, 0x25
10641071   };
r1478r1479
10701077*******************************************************************************/
10711078DRIVER_INIT( galaga88 )
10721079{
1073   const struct namcos1_specific galaga88_specific=
1080   static const struct namcos1_specific galaga88_specific=
10741081   {
10751082      key_type2_r,key_type2_w, 0x31
10761083   };
r1478r1479
10821089*******************************************************************************/
10831090DRIVER_INIT( ws )
10841091{
1085   const struct namcos1_specific ws_specific=
1092   static const struct namcos1_specific ws_specific=
10861093   {
10871094      key_type2_r,key_type2_w, 0x07
10881095   };
r1478r1479
10941101*******************************************************************************/
10951102DRIVER_INIT( bakutotu )
10961103{
1097   const struct namcos1_specific bakutotu_specific=
1104   static const struct namcos1_specific bakutotu_specific=
10981105   {
10991106      key_type2_r,key_type2_w, 0x22
11001107   };
r1478r1479
11311138*******************************************************************************/
11321139DRIVER_INIT( splatter )
11331140{
1134   const struct namcos1_specific splatter_specific=
1141   static const struct namcos1_specific splatter_specific=
11351142   {
11361143      key_type3_r,key_type3_w, 181, 3, 4,-1,-1,-1,-1
11371144   };
r1478r1479
11441151*******************************************************************************/
11451152DRIVER_INIT( rompers )
11461153{
1147   const struct namcos1_specific rompers_specific=
1154   static const struct namcos1_specific rompers_specific=
11481155   {
11491156      key_type3_r,key_type3_w, 182, 7,-1,-1,-1,-1,-1
11501157   };
r1478r1479
11561163*******************************************************************************/
11571164DRIVER_INIT( blastoff )
11581165{
1159   const struct namcos1_specific blastoff_specific=
1166   static const struct namcos1_specific blastoff_specific=
11601167   {
11611168      key_type3_r,key_type3_w, 183, 0, 7, 3, 5,-1,-1
11621169   };
r1478r1479
11681175*******************************************************************************/
11691176DRIVER_INIT( ws89 )
11701177{
1171   const struct namcos1_specific ws89_specific=
1178   static const struct namcos1_specific ws89_specific=
11721179   {
11731180      key_type3_r,key_type3_w, 184, 2,-1,-1,-1,-1,-1
11741181   };
r1478r1479
11801187*******************************************************************************/
11811188DRIVER_INIT( tankfrce )
11821189{
1183   const struct namcos1_specific tankfrce_specific=
1190   static const struct namcos1_specific tankfrce_specific=
11841191   {
11851192      key_type3_r,key_type3_w, 185, 5,-1, 1,-1, 2,-1
11861193   };
r1478r1479
11921199*******************************************************************************/
11931200DRIVER_INIT( dangseed )
11941201{
1195   const struct namcos1_specific dangseed_specific=
1202   static const struct namcos1_specific dangseed_specific=
11961203   {
11971204      key_type3_r,key_type3_w, 308, 6,-1, 5,-1, 0, 4
11981205   };
r1478r1479
12041211*******************************************************************************/
12051212DRIVER_INIT( pistoldm )
12061213{
1207   const struct namcos1_specific pistoldm_specific=
1214   static const struct namcos1_specific pistoldm_specific=
12081215   {
12091216      key_type3_r,key_type3_w, 309, 1, 2, 0,-1, 4,-1
12101217   };
r1478r1479
12161223*******************************************************************************/
12171224DRIVER_INIT( ws90 )
12181225{
1219   const struct namcos1_specific ws90_specific=
1226   static const struct namcos1_specific ws90_specific=
12201227   {
12211228      key_type3_r,key_type3_w, 310, 4,-1, 7,-1, 3,-1
12221229   };
r1478r1479
12281235*******************************************************************************/
12291236DRIVER_INIT( soukobdx )
12301237{
1231   const struct namcos1_specific soukobdx_specific=
1238   static const struct namcos1_specific soukobdx_specific=
12321239   {
12331240      key_type3_r,key_type3_w, 311, 2, 3/*?*/, 0,-1, 4,-1
12341241   };
src/mame/machine/snes.c
r1478r1479
4343static emu_timer *snes_hirq_timer;
4444static UINT16 hblank_offset;
4545static UINT16 snes_htmult;   /* in 512 wide, we run HTOTAL double and halve it on latching */
46static UINT8 has_dsp1;
4647
4748// full graphic variables
4849static UINT16 vram_fgr_high, vram_fgr_increment, vram_fgr_count, vram_fgr_mask, vram_fgr_shift, vram_read_buffer;
r1478r1479
279280{
280281   int i;
281282
282   /* Init DSP1 interface */
283   InitDSP1();
283   /* Init DSP1 */
284   DSP1_reset();
284285
285286   /* Init VRAM */
286287   memset( snes_vram, 0, SNES_VRAM_SIZE );
r1478r1479
436437   {
437438      if ((address >= 0x8000) && (offset >= 0x200000))
438439      {
439         return dsp1_read(address);
440         if (address >= 0xc000)
441            return DSP1_getSr();
442         else
443            return DSP1_getDr();
440444      }
441445   }
442446
443447   if( address <= 0x1fff )                        /* Mirror of Low RAM */
448   {
444449      return program_read_byte(0x7e0000 + address );
450   }
445451   else if( address >= 0x2000 && address <= 0x5fff )   /* I/O */
452   {
446453      return snes_r_io( address );
454   }
447455   else if( address >= 0x6000 && address <= 0x7fff )   /* Reserved */
448456   {
449457      if( snes_cart.mode == SNES_MODE_20 )
450      return 0xff;
451   else
452         return dsp1_read(address);
458      {
459         return 0xff;
460      }
461      else
462      {
463         if (address >= 0x7000)
464            return DSP1_getSr();
465         else
466            return DSP1_getDr();
467      }
453468   }
454469   else
455470   {
456471      if( snes_cart.mode == SNES_MODE_20 )
472      {
457473         return snes_ram[offset];
474      }
458475      else   /* MODE_21 */
476      {
459477         return snes_ram[0xc00000 + offset];
478      }
460479   }
461480
462481   return 0xff;
r1478r1479
471490   {
472491      if (address >= 0x8000)
473492      {
474         return dsp1_read(address);
493         if (address >= 0xc000)
494            return DSP1_getSr();
495         else
496            return DSP1_getDr();
475497      }
476498   }
477499
r1478r1479
482504   else if( address >= 0x6000 && address <= 0x7fff )
483505   {
484506      if( snes_cart.mode == SNES_MODE_20 )
507      {
485508         return 0xff;                  /* Reserved */
509      }
486510      else   /* MODE_21 */
487511      {
488512         int mask;
r1478r1479
533557
534558   if (address < 0x8000)
535559   {
536      return dsp1_read(address);
560      if (address >= 0x4000)
561         return DSP1_getSr();
562      else
563         return DSP1_getDr();
537564   }
538565
539566   return 0xff;
r1478r1479
567594
568595   if ((address >= 0x8000) && (offset >= 0x200000))
569596   {
570      dsp1_write(address, data);
597      DSP1_setDr(data);
571598      return;
572599   }
573600
r1478r1479
580607      logerror( "Attempt to write to reserved address: %X\n", offset );
581608   else
582609      {
583         dsp1_write(address, data);
610         DSP1_setDr(data);
584611         return;
585612      }
586613   else
r1478r1479
594621
595622   if (address >= 0x8000)
596623   {
597      dsp1_write(address, data);
624      DSP1_setDr(data);
598625      return;
599626   }
600627
r1478r1479
629656
630657   if (address < 0x8000)
631658   {
632      dsp1_write(address, data);
659      DSP1_setDr(data);
633660      return;
634661   }
635662}
src/mame/machine/zs01.c
r1478r1479
1212
1313#define VERBOSE_LEVEL ( 0 )
1414
15INLINE void verboselog( int n_level, const char *s_fmt, ... )
15INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
1616{
1717   if( VERBOSE_LEVEL >= n_level )
1818   {
r1478r1479
532532                        memset( &c->read_buffer[ 0 ], 0xff, 2 );
533533                     }
534534
535                     verboselog( 1, "zs01(%d) <- status: %02x%02\n", chip,
535                     verboselog( 1, "zs01(%d) <- status: %02x%02x\n", chip,
536536                        c->read_buffer[ 0 ], c->read_buffer[ 1 ] );
537537
538538                     verboselog( 1, "zs01(%d) <- data: %02x%02x%02x%02x%02x%02x%02x%02x\n", chip,
src/mame/machine/decoprot.c
r1478r1479
701701         return deco16_prot_ram[0x104>>1];
702702      case 0x3a8 >> 1: /* See 93e4/9376 */
703703         return deco16_prot_ram[0x500>>1];
704      case 0x3e8 >> 1:
704
705      // The top byte of 0x50c is used as a bitmask of completed levels,
706      // checked at end of each (0x0100 = level 1 completed,
707      // 0x3000 = levels 5 & 6 completed, 0x3f00 = levels 1-6 completed, etc)
708      case 0x56c >> 1:
705709         return deco16_prot_ram[0x50c>>1];
706710
711      // The game compares $ffc0 to check for all 6 basic levels
712      // being completed.  (which is 0x3f00 inverted and shifted)
713      // If wrong value is returned here the level select screen is
714      // incorrectly shown and leads to a crash as that screen
715      // cannot cope with all levels being already completed.
716      case 0x3e8 >> 1:
717         return (deco16_prot_ram[0x50c>>1] >> 8) ^ 0xffff;
718
707719      case 0x4e4 >> 1:
708720         return deco16_prot_ram[0x702>>1];
709721      case 0x562 >> 1:
710722         return deco16_prot_ram[0x18e>>1];
711      case 0x56c >> 1:
712         return deco16_prot_ram[0x50c>>1];
713723
714724      case 0x688 >> 1:
715725         return deco16_prot_ram[0x300>>1];
r1478r1479
737747         return (readinputport(3) + (readinputport(4) << 8));
738748   }
739749
740   if (activecpu_get_pc()!=0xc0ea)   logerror("CPU #0 PC %06x: warning - read unmapped control address %06x\n",activecpu_get_pc(),offset<<1);
750   if (activecpu_get_pc()!=0xc0ea)
751      logerror("CPU #0 PC %06x: warning - read unmapped control address %06x (ctrl %04x)\n",activecpu_get_pc(),offset<<1, readinputport(0));
741752
742753   return 0;
743754}
src/mame/machine/snesdsp1.c
r1478r1479
44
55  File to handle emulation of the SNES "DSP-1" add-on chip.
66
7  R. Belmont
8  Code from http://users.tpg.com.au/trauma/dsp/dsp1.html
9  By The Dumper (Electrical Engineering), Neviksti (Physics), Overload (Computer Science), Andreas Naive (Mathematics)
7  Original C++ "dsp1emul.cpp" by Andreas Naive
8  Based on research by Overload, The Dumper, Neviksti and Andreas Naive
9  MAME/MESS C conversion by R. Belmont
1010
11  This is up to date with the source version that was posted May 29, 2006.
11  This is up to date with the source version dated June 2006.
1212
1313***************************************************************************/
1414
15static INT16 dsp1_waitcmd, dsp1_in_cnt, dsp1_out_cnt, dsp1_in_idx, dsp1_out_idx, dsp1_first_parm, dsp1_cur_cmd;
16static int has_dsp1;
17static UINT8 dsp1_in[32], dsp1_out[16];
18
1915#define DSP1_VERSION 0x0102
2016
21// 1FH - Memory Dump (DSP1B Data ROM)
22// Input    byte(1FH) integer(Undefined)
23// Output   integer[1024]
17// The DSP-1 status register has 16 bits, but only
18// the upper 8 bits can be accessed from an external device, so all these
19// positions are referred to the upper byte (bits D8 to D15)
2420
25static UINT16 DSP1ROM[1024];
21enum SrFlags {DRC=0x04, DRS=0x10, RQM=0x80};
2622
27// Command Translation Table
23// According to Overload's docs, these are the meanings of the flags:
24// DRC: The Data Register Control (DRC) bit specifies the data transfer length to and from the host CPU.
25//   0: Data transfer to and from the DSP-1 is 16 bits.
26//   1: Data transfer to and from the DSP-1 is 8 bits.
27// DRS: The Data Register Status (DRS) bit indicates the data transfer status in the case of transfering 16-bit data.
28//   0: Data transfer has terminated.
29//   1: Data transfer in progress.
30// RQM: The Request for Master (RQM) indicates that the DSP1 is requesting host CPU for data read/write.
31//   0: Internal Data Register Transfer.
32//   1: External Data Register Transfer.
2833
29static const INT16 DSP1_CmdTable[64] = {
30     0x0000,  0x0001,  0x0002,  0x0003,  0x0004,  0x0001,  0x0006,  0x000f,
31     0x0008,  0x000d,  0x000a,  0x000b,  0x000c,  0x000d,  0x000e,  0x000f,
32     0x0010,  0x0011,  0x0002,  0x0013,  0x0014,  0x0011,  0x0006,  0x001f,
33     0x0018,  0x001d,  0x001a,  0x001b,  0x001c,  0x001d,  0x000e,  0x001f,
34     0x0020,  0x0021,  0x0002,  0x0023,  0x0004,  0x0021,  0x0006,  0x002f,
35     0x0028,  0x002d,  0x001a,  0x002b,  0x000c,  0x002d,  0x000e,  0x002f,
36     0x0010,  0x0001,  0x0002,  0x0003,  0x0014,  0x0001,  0x0006,  0x001f,
37     0x0038,  0x000d,  0x001a,  0x000b,  0x001c,  0x000d,  0x000e,  0x001f};
34enum FsmMajorState {WAIT_COMMAND, READ_DATA, WRITE_DATA};
35enum MaxDataAccesses {MAX_READS=7, MAX_WRITES=1024};
3836
39// Optimised for Performance
37struct DSP1_Command {
38        void (*callback)(INT16 *, INT16 *);
39        unsigned int reads;
40        unsigned int writes;
41};
4042
41static const INT16 DSP1_MulTable[256] = {
42     0x0000,  0x0003,  0x0006,  0x0009,  0x000c,  0x000f,  0x0012,  0x0015,
43     0x0019,  0x001c,  0x001f,  0x0022,  0x0025,  0x0028,  0x002b,  0x002f,
44     0x0032,  0x0035,  0x0038,  0x003b,  0x003e,  0x0041,  0x0045,  0x0048,
45     0x004b,  0x004e,  0x0051,  0x0054,  0x0057,  0x005b,  0x005e,  0x0061,
46     0x0064,  0x0067,  0x006a,  0x006d,  0x0071,  0x0074,  0x0077,  0x007a,
47     0x007d,  0x0080,  0x0083,  0x0087,  0x008a,  0x008d,  0x0090,  0x0093,
48     0x0096,  0x0099,  0x009d,  0x00a0,  0x00a3,  0x00a6,  0x00a9,  0x00ac,
49     0x00af,  0x00b3,  0x00b6,  0x00b9,  0x00bc,  0x00bf,  0x00c2,  0x00c5,
50     0x00c9,  0x00cc,  0x00cf,  0x00d2,  0x00d5,  0x00d8,  0x00db,  0x00df,
51     0x00e2,  0x00e5,  0x00e8,  0x00eb,  0x00ee,  0x00f1,  0x00f5,  0x00f8,
52     0x00fb,  0x00fe,  0x0101,  0x0104,  0x0107,  0x010b,  0x010e,  0x0111,
53     0x0114,  0x0117,  0x011a,  0x011d,  0x0121,  0x0124,  0x0127,  0x012a,
54     0x012d,  0x0130,  0x0133,  0x0137,  0x013a,  0x013d,  0x0140,  0x0143,
55     0x0146,  0x0149,  0x014d,  0x0150,  0x0153,  0x0156,  0x0159,  0x015c,
56     0x015f,  0x0163,  0x0166,  0x0169,  0x016c,  0x016f,  0x0172,  0x0175,
57     0x0178,  0x017c,  0x017f,  0x0182,  0x0185,  0x0188,  0x018b,  0x018e,
58     0x0192,  0x0195,  0x0198,  0x019b,  0x019e,  0x01a1,  0x01a4,  0x01a8,
59     0x01ab,  0x01ae,  0x01b1,  0x01b4,  0x01b7,  0x01ba,  0x01be,  0x01c1,
60     0x01c4,  0x01c7,  0x01ca,  0x01cd,  0x01d0,  0x01d4,  0x01d7,  0x01da,
61     0x01dd,  0x01e0,  0x01e3,  0x01e6,  0x01ea,  0x01ed,  0x01f0,  0x01f3,
62     0x01f6,  0x01f9,  0x01fc,  0x0200,  0x0203,  0x0206,  0x0209,  0x020c,
63     0x020f,  0x0212,  0x0216,  0x0219,  0x021c,  0x021f,  0x0222,  0x0225,
64     0x0228,  0x022c,  0x022f,  0x0232,  0x0235,  0x0238,  0x023b,  0x023e,
65     0x0242,  0x0245,  0x0248,  0x024b,  0x024e,  0x0251,  0x0254,  0x0258,
66     0x025b,  0x025e,  0x0261,  0x0264,  0x0267,  0x026a,  0x026e,  0x0271,
67     0x0274,  0x0277,  0x027a,  0x027d,  0x0280,  0x0284,  0x0287,  0x028a,
68     0x028d,  0x0290,  0x0293,  0x0296,  0x029a,  0x029d,  0x02a0,  0x02a3,
69     0x02a6,  0x02a9,  0x02ac,  0x02b0,  0x02b3,  0x02b6,  0x02b9,  0x02bc,
70     0x02bf,  0x02c2,  0x02c6,  0x02c9,  0x02cc,  0x02cf,  0x02d2,  0x02d5,
71     0x02d8,  0x02db,  0x02df,  0x02e2,  0x02e5,  0x02e8,  0x02eb,  0x02ee,
72     0x02f1,  0x02f5,  0x02f8,  0x02fb,  0x02fe,  0x0301,  0x0304,  0x0307,
73     0x030b,  0x030e,  0x0311,  0x0314,  0x0317,  0x031a,  0x031d,  0x0321};
43static const struct DSP1_Command mCommandTable[0x40];
44static const INT16 DSP1_MaxAZS_Exp[16];
45static const INT16 DSP1_SinTable[256];
46static const INT16 DSP1_MulTable[256];
47static UINT16 DSP1_DataRom[1024];
7448
75static const INT16 DSP1_SinTable[256] = {
76     0x0000,  0x0324,  0x0647,  0x096a,  0x0c8b,  0x0fab,  0x12c8,  0x15e2,
77     0x18f8,  0x1c0b,  0x1f19,  0x2223,  0x2528,  0x2826,  0x2b1f,  0x2e11,
78     0x30fb,  0x33de,  0x36ba,  0x398c,  0x3c56,  0x3f17,  0x41ce,  0x447a,
79     0x471c,  0x49b4,  0x4c3f,  0x4ebf,  0x5133,  0x539b,  0x55f5,  0x5842,
80     0x5a82,  0x5cb4,  0x5ed7,  0x60ec,  0x62f2,  0x64e8,  0x66cf,  0x68a6,
81     0x6a6d,  0x6c24,  0x6dca,  0x6f5f,  0x70e2,  0x7255,  0x73b5,  0x7504,
82     0x7641,  0x776c,  0x7884,  0x798a,  0x7a7d,  0x7b5d,  0x7c29,  0x7ce3,
83     0x7d8a,  0x7e1d,  0x7e9d,  0x7f09,  0x7f62,  0x7fa7,  0x7fd8,  0x7ff6,
84     0x7fff,  0x7ff6,  0x7fd8,  0x7fa7,  0x7f62,  0x7f09,  0x7e9d,  0x7e1d,
85     0x7d8a,  0x7ce3,  0x7c29,  0x7b5d,  0x7a7d,  0x798a,  0x7884,  0x776c,
86     0x7641,  0x7504,  0x73b5,  0x7255,  0x70e2,  0x6f5f,  0x6dca,  0x6c24,
87     0x6a6d,  0x68a6,  0x66cf,  0x64e8,  0x62f2,  0x60ec,  0x5ed7,  0x5cb4,
88     0x5a82,  0x5842,  0x55f5,  0x539b,  0x5133,  0x4ebf,  0x4c3f,  0x49b4,
89     0x471c,  0x447a,  0x41ce,  0x3f17,  0x3c56,  0x398c,  0x36ba,  0x33de,
90     0x30fb,  0x2e11,  0x2b1f,  0x2826,  0x2528,  0x2223,  0x1f19,  0x1c0b,
91     0x18f8,  0x15e2,  0x12c8,  0x0fab,  0x0c8b,  0x096a,  0x0647,  0x0324,
92    -0x0000, -0x0324, -0x0647, -0x096a, -0x0c8b, -0x0fab, -0x12c8, -0x15e2,
93    -0x18f8, -0x1c0b, -0x1f19, -0x2223, -0x2528, -0x2826, -0x2b1f, -0x2e11,
94    -0x30fb, -0x33de, -0x36ba, -0x398c, -0x3c56, -0x3f17, -0x41ce, -0x447a,
95    -0x471c, -0x49b4, -0x4c3f, -0x4ebf, -0x5133, -0x539b, -0x55f5, -0x5842,
96    -0x5a82, -0x5cb4, -0x5ed7, -0x60ec, -0x62f2, -0x64e8, -0x66cf, -0x68a6,
97    -0x6a6d, -0x6c24, -0x6dca, -0x6f5f, -0x70e2, -0x7255, -0x73b5, -0x7504,
98    -0x7641, -0x776c, -0x7884, -0x798a, -0x7a7d, -0x7b5d, -0x7c29, -0x7ce3,
99    -0x7d8a, -0x7e1d, -0x7e9d, -0x7f09, -0x7f62, -0x7fa7, -0x7fd8, -0x7ff6,
100    -0x7fff, -0x7ff6, -0x7fd8, -0x7fa7, -0x7f62, -0x7f09, -0x7e9d, -0x7e1d,
101    -0x7d8a, -0x7ce3, -0x7c29, -0x7b5d, -0x7a7d, -0x798a, -0x7884, -0x776c,
102    -0x7641, -0x7504, -0x73b5, -0x7255, -0x70e2, -0x6f5f, -0x6dca, -0x6c24,
103    -0x6a6d, -0x68a6, -0x66cf, -0x64e8, -0x62f2, -0x60ec, -0x5ed7, -0x5cb4,
104    -0x5a82, -0x5842, -0x55f5, -0x539b, -0x5133, -0x4ebf, -0x4c3f, -0x49b4,
105    -0x471c, -0x447a, -0x41ce, -0x3f17, -0x3c56, -0x398c, -0x36ba, -0x33de,
106    -0x30fb, -0x2e11, -0x2b1f, -0x2826, -0x2528, -0x2223, -0x1f19, -0x1c0b,
107    -0x18f8, -0x15e2, -0x12c8, -0x0fab, -0x0c8b, -0x096a, -0x0647, -0x0324
108};
49static struct SharedData { // some RAM variables shared between commands
50        INT16 MatrixA[3][3];          // attitude matrix A
51        INT16 MatrixB[3][3];
52        INT16 MatrixC[3][3];
53        INT16 CentreX, CentreY, CentreZ;   // center of projection
54        INT16 CentreZ_C, CentreZ_E;
55        INT16 VOffset;                     // vertical offset of the screen with regard to the centre of projection
56        INT16 Les, C_Les, E_Les;
57        INT16 SinAas, CosAas;
58        INT16 SinAzs, CosAzs;
59        INT16 SinAZS, CosAZS;
60        INT16 SecAZS_C1, SecAZS_E1;
61        INT16 SecAZS_C2, SecAZS_E2;
62        INT16 Nx, Ny, Nz;    // normal vector to the screen (norm 1, points toward the center of projection)
63        INT16 Gx, Gy, Gz;    // center of the screen (global coordinates)
64        INT16 Hx, Hy;        // horizontal vector of the screen (Hz=0, norm 1, points toward the right of the screen)
65        INT16 Vx, Vy, Vz;    // vertical vector of the screen (norm 1, points toward the top of the screen)
10966
110#define INCR 2048
111static double CosTable2[INCR];
112static double SinTable2[INCR];
67} shared;
11368
114#define Angle(x) (((x)/(65536/INCR)) & (INCR-1))
115#define Cos(x) ((double) CosTable2[x])
116#define Sin(x) ((double) SinTable2[x])
69static UINT8 mSr;            // status register
70static int mSrLowByteAccess;
71static UINT16 mDr;           // "internal" representation of the data register
72static enum FsmMajorState mFsmMajorState;     // current major state of the FSM
73static UINT8 mCommand;                  // current command processed by the FSM
74static UINT8 mDataCounter;                 // #UINT16 read/writes counter used by the FSM
75static INT16 mReadBuffer[MAX_READS];
76static INT16 mWriteBuffer[MAX_WRITES];
77static UINT8 mFreeze;                   // need explanation?  ;)
11778
118// init DSP1 math tables
119static void InitDSP1(void)
79static void DSP1_fsmStep(UINT8 read, UINT8 *data);            // FSM logic
80
81// commands
82static void DSP1_memoryTest(INT16 *input, INT16 *output);
83static void DSP1_memoryDump(INT16 *input, INT16 *output);
84static void DSP1_memorySize(INT16 *input, INT16 *output);
85static void DSP1_multiply(INT16* input, INT16* output);
86static void DSP1_multiply2(INT16* input, INT16* output);
87static void DSP1_inverse(INT16 *input, INT16 *output);
88static void DSP1_triangle(INT16 *input, INT16 *output);
89static void DSP1_radius(INT16 *input, INT16 *output);
90static void DSP1_range(INT16 *input, INT16 *output);
91static void DSP1_range2(INT16 *input, INT16 *output);
92static void DSP1_distance(INT16 *input, INT16 *output);
93static void DSP1_rotate(INT16 *input, INT16 *output);
94static void DSP1_polar(INT16 *input, INT16 *output);
95static void DSP1_attitudeA(INT16 *input, INT16 *output);
96static void DSP1_attitudeB(INT16 *input, INT16 *output);
97static void DSP1_attitudeC(INT16 *input, INT16 *output);
98static void DSP1_objectiveA(INT16 *input, INT16 *output);
99static void DSP1_objectiveB(INT16 *input, INT16 *output);
100static void DSP1_objectiveC(INT16 *input, INT16 *output);
101static void DSP1_subjectiveA(INT16 *input, INT16 *output);
102static void DSP1_subjectiveB(INT16 *input, INT16 *output);
103static void DSP1_subjectiveC(INT16 *input, INT16 *output);
104static void DSP1_scalarA(INT16 *input, INT16 *output);
105static void DSP1_scalarB(INT16 *input, INT16 *output);
106static void DSP1_scalarC(INT16 *input, INT16 *output);
107static void DSP1_gyrate(INT16 *input, INT16 *output);
108static void DSP1_parameter(INT16 *input, INT16 *output);
109static void DSP1_raster(INT16 *input, INT16 *output);
110static void DSP1_target(INT16 *input, INT16 *output);
111static void DSP1_project(INT16 *input, INT16 *output);
112
113// auxiliar functions
114static INT16 DSP1_sin(INT16 Angle);
115static INT16 DSP1_cos(INT16 Angle);
116static void inverse(INT16 Coefficient, INT16 Exponent, INT16 *iCoefficient, INT16 *iExponent);
117static INT16 denormalizeAndClip(INT16 C, INT16 E);
118static void normalize(INT16 m, INT16 *Coefficient, INT16 *Exponent);
119static void normalizeDouble(INT32 Product, INT16 *Coefficient, INT16 *Exponent);
120static INT16 shiftR(INT16 C, INT16 E);
121
122//////////////////////////////////////////////////////////////////
123
124UINT8 DSP1_getSr(void)
120125{
126   mSrLowByteAccess = ~mSrLowByteAccess;
127   if (mSrLowByteAccess)
128   {
129      return 0;
130   }
131   else
132   {
133      return mSr;
134   }
135}
136
137//////////////////////////////////////////////////////////////////
138
139UINT8 DSP1_getDr(void)
140{
141   UINT8 oDr;
142
143   DSP1_fsmStep(1, &oDr);
144   return oDr;
145}
146
147//////////////////////////////////////////////////////////////////
148
149void DSP1_setDr(UINT8 iDr)
150{
151    DSP1_fsmStep(0, &iDr);
152}
153
154//////////////////////////////////////////////////////////////////
155
156void DSP1_reset(void)
157{
121158   UINT32 i;
122159   UINT8 *dspin = memory_region(REGION_USER6);
123160
124   dsp1_waitcmd = dsp1_first_parm = 1;
161   mSr = DRC|RQM;
162   mSrLowByteAccess = FALSE;
163   mDr = 0x0080;    // Only a supposition. Is this correct?
164   mFreeze = FALSE;
165   mFsmMajorState = WAIT_COMMAND;
166   memset(&shared, 0, sizeof(struct SharedData)); // another supposition
125167
126   for (i=0; i<INCR; i++)
127   {
128      CosTable2[i] = (cos((double)(2*M_PI*i/INCR)));
129      SinTable2[i] = (sin((double)(2*M_PI*i/INCR)));
130   }
131
132168   // expand the DSP-1 data ROM
133169   for (i = 0; i < 2048; i+=2)
134170   {
135      DSP1ROM[i/2] = dspin[i]<<8 | dspin[i+1];
171      DSP1_DataRom[i/2] = dspin[i]<<8 | dspin[i+1];
136172   }
137173}
138174
139static INT16 Gx, Nx, CentreX;
140static INT16 Gy, Ny, CentreY;
141static INT16 Gz, Nz, CentreZ;
142static INT16 Les_C, Les_E, Les_G;
175//////////////////////////////////////////////////////////////////
143176
144static INT16 VOffset;
177// Though the DSP-1 is unaware of the type of operation (read or write)
178// we need to know what is being done by the program, as the class
179// is responsible for maintaining the binding between the
180// "external" and "internal" representations of the DR (data register).
145181
146static INT16 VPlane_C, VPlane_E;
182static void DSP1_fsmStep(UINT8 read, UINT8 *data)
183{
184   if (0 == (mSr&RQM)) return;
185   // Now RQM would be cleared; however, as this code is not to be used in
186   // a multithread environment, we will simply fake RQM operation.
187   // (The only exception would be Op1A's freeze.)
147188
148// Azimuth and Zenith angles
149static INT16 SinAas, CosAas, SinAzs, CosAzs;
189   // binding
190   if (read)
191   {
192      if (mSr&DRS)
193         *data = (UINT8)(mDr>>8);
194      else
195         *data = (UINT8)(mDr);
196   }
197   else
198   {
199      if (mSr&DRS)
200      {
201         mDr &= 0x00ff;
202         mDr |= *data<<8;
203      }
204      else
205      {
206         mDr &= 0xff00;
207         mDr |= *data;
208      }
209   }
150210
151// Clipped Zenith angle
152static INT16 SinAzsB, CosAzsB;
153static INT16 SecAZS_C1;
154static INT16 SecAZS_E1;
155static INT16 SecAZS_C2;
156static INT16 SecAZS_E2;
157211
158static INT16 DSP1_Sin(INT16 Angle)
159{
160   int S;
212   switch (mFsmMajorState)
213   {
214      case WAIT_COMMAND:
215         mCommand = (UINT8)(mDr);
216         if (!(mCommand & 0xc0))   // valid command?
217         {
218            switch(mCommand)
219            {
220               // freeze cases
221               case 0x1a:
222               case 0x2a:
223               case 0x3a:
224                  mFreeze = TRUE;
225                  break;
226               // normal cases
227               default:
228                  mDataCounter=0;
229                  mFsmMajorState = READ_DATA;
230                  mSr &= ~DRC;
231                  break;
232            }
233         }
234         break;
235      case READ_DATA:
236         mSr ^= DRS;
237         if (!(mSr&DRS))
238         {
239            mReadBuffer[mDataCounter++] = (INT16)(mDr);
240            if (mDataCounter >= mCommandTable[mCommand].reads)
241            {
242               (*mCommandTable[mCommand].callback)(mReadBuffer, mWriteBuffer);
243               if (0 != mCommandTable[mCommand].writes)  // any output?
244               {
245                  mDataCounter = 0;
246                  mDr = (UINT16)(mWriteBuffer[mDataCounter]);
247                  mFsmMajorState = WRITE_DATA;
248               }
249               else
250               {
251                  mDr = 0x0080;  // valid command completion
252                  mFsmMajorState = WAIT_COMMAND;
253                  mSr |= DRC;
254               }
255            }
256         }
257         break;
258      case WRITE_DATA:
259         mSr ^= DRS;
260         if (!(mSr&DRS))
261         {
262            ++mDataCounter;
263            if (mDataCounter >= mCommandTable[mCommand].writes)
264            {
265               if ((mCommand == 0x0a)&&(mDr != 0x8000))
266               {
267                  // works in continuous mode
268                  mReadBuffer[0]++;   // next raster line
269                  (*mCommandTable[mCommand].callback)(mReadBuffer, mWriteBuffer);
270                  mDataCounter = 0;
271                  mDr = (UINT16)(mWriteBuffer[mDataCounter]);
272               }
273               else
274               {
275                  mDr = 0x0080;  // valid command completion
276                  mFsmMajorState = WAIT_COMMAND;
277                  mSr |= DRC;
278               }
279            }
280            else
281            {
282               mDr = (UINT16)(mWriteBuffer[mDataCounter]);
283            }
284         }
285         break;
286   }
161287
162   if (Angle < 0) {
163      if (Angle == -32768) return 0;
164      return -DSP1_Sin(-Angle);
165   }
166288
167   S = DSP1_SinTable[Angle >> 8] + (DSP1_MulTable[Angle & 0xff] * DSP1_SinTable[0x40 + (Angle >> 8)] >> 15);
168   if (S > 32767) S = 32767;
169   return (INT16) S;
289
290   // Now RQM would be set (except when executing Op1A -command equals 0x1a, 0x2a or 0x3a-).
291   if (mFreeze)
292      mSr &= ~RQM;
170293}
171294
172static INT16 DSP1_Cos(INT16 Angle)
173{
174   int S;
295//////////////////////////////////////////////////////////////////
175296
176   if (Angle < 0) {
177      if (Angle == -32768) return -32768;
178      Angle = -Angle;
179   }
180   S = DSP1_SinTable[0x40 + (Angle >> 8)] - (DSP1_MulTable[Angle & 0xff] * DSP1_SinTable[Angle >> 8] >> 15);
181   if (S < -32768) S = -32767;
182   return (INT16) S;
183}
297// The info on this table follows Overload's docs.
184298
185static void DSP1_Normalize(INT16 m, INT16 *Coefficient, INT16 *Exponent)
299static const struct DSP1_Command mCommandTable[0x40] =
186300{
187   INT16 i = 0x4000;
188   INT16 e = 0;
301   {&DSP1_multiply, 2, 1},   //0x00
302   {&DSP1_attitudeA, 4, 0},    //0x01
303   {&DSP1_parameter, 7, 4},   //0x02
304   {&DSP1_subjectiveA, 3, 3},    //0x03
305   {&DSP1_triangle, 2, 2},   //0x04
306   {&DSP1_attitudeA, 4, 0},   //0x01
307   {&DSP1_project, 3, 3},   //0x06
308   {&DSP1_memoryTest, 1, 1},   //0x0f
309   {&DSP1_radius, 3, 2},   //0x08
310   {&DSP1_objectiveA, 3, 3},   //0x0d
311   {&DSP1_raster, 1, 4},   // 0x0a. This will normally work in continuous mode
312   {&DSP1_scalarA, 3, 1},   //0x0b
313   {&DSP1_rotate, 3, 2},   //0x0c
314   {&DSP1_objectiveA, 3, 3},   //0x0d
315   {&DSP1_target, 2, 2},   //0x0e
316   {&DSP1_memoryTest, 1, 1},   //0x0f
189317
190   if (m < 0)
191      while ((m & i) && i)
192      {
193         i >>= 1;
194         e++;
195      }
196   else
197      while (!(m & i) && i)
198      {
199         i >>= 1;
200         e++;
201      }
318   {&DSP1_inverse, 2, 2},   //0x10
319   {&DSP1_attitudeB, 4, 0},   //0x11
320   {&DSP1_parameter, 7, 4},   //0x02
321   {&DSP1_subjectiveB, 3, 3},   //0x13
322   {&DSP1_gyrate, 6, 3},   //0x14
323   {&DSP1_attitudeB, 4, 0},   //0x11
324   {&DSP1_project, 3, 3},   //0x06
325   {&DSP1_memoryDump, 1, 1024},   //0x1f
326   {&DSP1_range, 4, 1},   //0x18
327   {&DSP1_objectiveB, 3, 3},   //0x1d
328   {0, 0, 0},   // 0x1a; the chip freezes
329   {&DSP1_scalarB, 3, 1},   //0x1b
330   {&DSP1_polar, 6, 3},   //0x1c
331   {&DSP1_objectiveB, 3, 3},   //0x1d
332   {&DSP1_target, 2, 2},   //0x0e
333   {&DSP1_memoryDump, 1, 1024},   //0x1f
202334
203   if (e > 0)
204      *Coefficient = m * DSP1ROM[0x0021 + e] << 1;
205   else
206      *Coefficient = m;
335   {&DSP1_multiply2, 2, 1},   //0x20
336   {&DSP1_attitudeC, 4, 0},   //0x21
337   {&DSP1_parameter, 7, 4},   //0x02
338   {&DSP1_subjectiveC, 3, 3},   //0x23
339   {&DSP1_triangle, 2, 2},   //0x04
340   {&DSP1_attitudeC, 4, 0},   //0x21
341   {&DSP1_project, 3, 3},   //0x06
342   {&DSP1_memorySize, 1, 1},    //0x2f
343   {&DSP1_distance, 3, 1},   //0x28
344   {&DSP1_objectiveC, 3, 3},   //0x2d
345   {0, 0, 0},   // 0x1a; the chip freezes
346   {&DSP1_scalarC, 3, 1},   //0x2b
347   {&DSP1_rotate, 3, 2},   //0x0c
348   {&DSP1_objectiveC, 3, 3},   //0x2d
349   {&DSP1_target, 2, 2},   //0x0e
350   {&DSP1_memorySize, 1, 1},   //0x2f
207351
208   *Exponent -= e;
209}
352   {&DSP1_inverse, 2, 2},   //0x10
353   {&DSP1_attitudeA, 4, 0},   //0x01
354   {&DSP1_parameter, 7, 4},   //0x02
355   {&DSP1_subjectiveA, 3, 3},   //0x03
356   {&DSP1_gyrate, 6, 3},   //0x14
357   {&DSP1_attitudeA, 4, 0},   //0x01
358   {&DSP1_project, 3, 3},   //0x06
359   {&DSP1_memoryDump, 1, 1024},   //0x1f
360   {&DSP1_range2, 4, 1},   //0x38
361   {&DSP1_objectiveA, 3, 3},   //0x0d
362   {0, 0, 0},   // 0x1a; the chip freezes
363   {&DSP1_scalarA, 3, 1},   //0x0b
364   {&DSP1_polar, 6, 3},   //0x1c
365   {&DSP1_objectiveA, 3, 3},   //0x0d
366   {&DSP1_target, 2, 2},   //0x0e
367   {&DSP1_memoryDump, 1, 1024},   //0x1f
368};
210369
211static void DSP1_NormalizeDouble(int Product, INT16 *Coefficient, INT16 *Exponent)
370//////////////////////////////////////////////////////////////////
371
372static void DSP1_memoryTest(INT16 *input, INT16 *output)
212373{
213   INT16 n = Product & 0x7fff;
214   INT16 m = Product >> 15;
215   INT16 i = 0x4000;
216   INT16 e = 0;
374//   INT16 *Size = &input[0];
375   INT16 *Result = &output[0];
217376
218   if (m < 0)
219      while ((m & i) && i)
220      {
221         i >>= 1;
222         e++;
223      }
224   else
225      while (!(m & i) && i)
226      {
227         i >>= 1;
228         e++;
229      }
377   *Result = 0x0000;
378}
230379
231   if (e > 0)
232   {
233      *Coefficient = m * DSP1ROM[0x0021 + e] << 1;
380//////////////////////////////////////////////////////////////////
234381
235      if (e < 15)
236         *Coefficient += n * DSP1ROM[0x0040 - e] >> 15;
237      else
238      {
239         i = 0x4000;
382static void DSP1_memoryDump(INT16 *input, INT16 *output)
383{
384   memcpy(output, DSP1_DataRom, 1024);
385}
240386
241         if (m < 0)
242            while ((n & i) && i)
243            {
244               i >>= 1;
245               e++;
246            }
247         else
248            while (!(n & i) && i)
249            {
250               i >>= 1;
251               e++;
252            }
387//////////////////////////////////////////////////////////////////
253388
254         if (e > 15)
255            *Coefficient = n * DSP1ROM[0x0012 + e] << 1;
256         else
257            *Coefficient += n;
258      }
259   }
260   else
261      *Coefficient = m;
389static void DSP1_memorySize(INT16 *input, INT16 *output)
390{
391   INT16 *Size = &output[0];
262392
263   *Exponent = e;
393   *Size = 0x0100;
264394}
265395
266static INT16 DSP1_Truncate(INT16 C, INT16 E)
267{
268   if (E > 0) {
269      if (C > 0) return 32767; else if (C < 0) return -32767;
270   } else {
271      if (E < 0) return C * DSP1ROM[0x0031 + E] >> 15;
272   }
273   return C;
274}
396//////////////////////////////////////////////////////////////////
275397
276// 00H - 16-bit Multiplication (Bit Perfect)
277// Input    byte(00H) integer(Multiplicand) integer(Multiplier)
278// Output   integer(Product)
398// 16-bit multiplication
279399
280static void DSP1_Multiply(INT16 Multiplicand, INT16 Multiplier, INT16 *Product)
400static void DSP1_multiply(INT16 *input, INT16 *output)
281401{
282   *Product = (Multiplicand * Multiplier >> 15);
402   INT16 Multiplicand = input[0];
403   INT16 Multiplier = input[1];
404   INT16 *Product = &output[0];
405
406   *Product = Multiplicand * Multiplier >> 15;
283407}
284408
285// 20H - 16-bit Multiplication (Bit Perfect)
286// Input    byte(20H) integer(Multiplicand) integer(Multiplier)
287// Output   integer(Product)
409//////////////////////////////////////////////////////////////////
288410
289#ifdef UNUSED_FUNCTION
290static void DSP1_Multiply1(INT16 Multiplicand, INT16 Multiplier, INT16 *Product)
411// 16-bit multiplication. 'Alternative' method. Can anyone check this carefully?
412
413static void DSP1_multiply2(INT16 *input, INT16 *output)
291414{
292   *Product = (Multiplicand * Multiplier >> 15) + 1;
415   INT16 Multiplicand = input[0];
416   INT16 Multiplier = input[1];
417   INT16* Product = &output[0];
418
419   *Product = (Multiplicand * Multiplier >> 15)+1;
293420}
294#endif
295421
296// 10H - Inverse Calculation (Bit Perfect)
297// Input    byte(10H) integer(Coefficient) integer(Exponent)
298// Output   integer(Coefficient) integer(Exponent)
422//////////////////////////////////////////////////////////////////
299423
300static void DSP1_Inverse(INT16 Coefficient, INT16 Exponent, INT16 *iCoefficient, INT16 *iExponent)
424// This command determines the inverse of a floating point decimal number.
425
426static void DSP1_inverse(INT16 *input, INT16 *output)
301427{
302   // Step One: Division by Zero
303   if (Coefficient == 0x0000)
304   {
305      *iCoefficient = 0x7fff;
306      *iExponent = 0x002f;
307   }
308   else
309   {
310      INT16 Sign = 1;
428   INT16 Coefficient = input[0];
429   INT16 Exponent = input[1];
430   INT16* iCoefficient = &output[0];
431   INT16* iExponent = &output[1];
311432
312      // Step Two: Remove Sign
313      if (Coefficient < 0)
314      {
315         if (Coefficient < -32767) Coefficient = -32767;
316         Coefficient = -Coefficient;
317         Sign = -1;
318      }
433   inverse(Coefficient, Exponent, iCoefficient, iExponent);
434}
319435
320      // Step Three: Normalize
321      while (Coefficient <  0x4000)
322      {
323         Coefficient <<= 1;
324         Exponent--;
325      }
436//////////////////////////////////////////////////////////////////
326437
327      // Step Four: Special Case
328      if (Coefficient == 0x4000)
329         if (Sign == 1) *iCoefficient = 0x7fff;
330         else  {
331            *iCoefficient = -0x4000;
332            Exponent--;
333         }
334      else {
335         // Step Five: Initial Guess
336         INT16 i = DSP1ROM[((Coefficient - 0x4000) >> 7) + 0x0065];
438// Vector component calculation. Determines the X and Y components for a
439// two-dimensional vector whose size and direction is known.
440// Y = Radius * sin(Angle)
441// X = Radius * cos(Angle)
337442
338         // Step Six: Iterate Newton's Method
339         i = (i + (-i * (Coefficient * i >> 15) >> 15)) << 1;
340         i = (i + (-i * (Coefficient * i >> 15) >> 15)) << 1;
443static void DSP1_triangle(INT16 *input, INT16 *output)
444{
445   INT16 Angle = input[0];
446   INT16 Radius = input[1];
447   INT16* Y = &output[0];
448   INT16* X = &output[1];
341449
342         *iCoefficient = i * Sign;
343      }
344
345      *iExponent = 1 - Exponent;
346   }
450   *Y = DSP1_sin(Angle) * Radius >> 15;
451   *X = DSP1_cos(Angle) * Radius >> 15;
347452}
348453
349// 04H - Trigonometric Calculation (Bit Perfect)
350// Input    byte(04H) integer(Angle) integer(Radius)
351// Output   integer(Sine) integer(Cosine)
454//////////////////////////////////////////////////////////////////
352455
353static void DSP1_Triangle(INT16 Angle, INT16 Radius, INT16 *S, INT16 *C)
456// Determines the squared norm of a vector (X,Y,Z)
457// The output is Radius = X^2+Y^2+Z^2 (double integer)
458
459static void DSP1_radius(INT16 *input, INT16 *output)
354460{
355   *S = DSP1_Sin(Angle) * Radius >> 15;
356   *C = DSP1_Cos(Angle) * Radius >> 15;
357}
461   INT16 X = input[0];
462   INT16 Y = input[1];
463   INT16 Z = input[2];
464   INT16* RadiusLow = &output[0];
465   INT16* RadiusHigh = &output[1];
358466
359// 08H - Vector Size Calculation (Bit Perfect)
360// Input    byte(08H) integer(X) integer(Y) integer(Z)
361// Output   double(Radius)
467   INT32 Radius;
362468
363static void DSP1_Radius(INT16 X, INT16 Y, INT16 Z, int *Radius)
364{
365   *Radius = (X * X + Y * Y + Z * Z) << 1;
469   Radius = (X * X + Y * Y + Z * Z) << 1;
470   *RadiusLow = (INT16)(Radius);
471   *RadiusHigh = (INT16)(Radius>>16);
366472}
367473
368// 18H - Vector Size Comparison (Bit Perfect)
369// Input    byte(18H) integer(X) integer(Y) integer(Z) integer(Radius)
370// Output   integer(Range)
474//////////////////////////////////////////////////////////////////
371475
372static void DSP1_Range(INT16 X, INT16 Y, INT16 Z, INT16 Radius, INT16 *Range)
476// Vector size comparison. This command compares the size of the vector (X,Y,Z) and the distance (R)
477// from a particular point, and so may be used to determine if a point is within the sphere or radius R.
478// The output is D = X^2+Y^2+Z^2-R^2
479
480static void DSP1_range(INT16 *input, INT16 *output)
373481{
374   *Range = ((X * X + Y * Y + Z * Z - Radius * Radius) >> 15);
482   INT16 X = input[0];
483   INT16 Y = input[1];
484   INT16 Z = input[2];
485   INT16 Radius = input[3];
486   INT16* Range = &output[0];
487
488   *Range = (X * X + Y * Y + Z * Z - Radius * Radius) >> 15;
375489}
376490
377// 38H - Vector Size Comparison (Bit Perfect)
378// Input    byte(38H) integer(X) integer(Y) integer(Z) integer(Radius)
379// Output   integer(Range)
491//////////////////////////////////////////////////////////////////
380492
381#ifdef UNUSED_FUNCTION
382static void DSP1_Range1(INT16 X, INT16 Y, INT16 Z, INT16 Radius, INT16 *Range)
493// Vector size comparison. 'Alternative' method.
494
495static void DSP1_range2(INT16 *input, INT16 *output)
383496{
384   *Range = ((X * X + Y * Y + Z * Z - Radius * Radius) >> 15) + 1;
497   INT16 X = input[0];
498   INT16 Y = input[1];
499   INT16 Z = input[2];
500   INT16 Radius = input[3];
501   INT16* Range = &output[0];
502
503   *Range = ((X * X + Y * Y + Z * Z - Radius * Radius) >> 15) + 1;
385504}
386#endif
387505
388// 28H - Vector Absolute Value Calculation (Bit Perfect)
389// Input    byte(28H) integer(X) integer(Y) integer(Z)
390// Output   integer(Distance)
506//////////////////////////////////////////////////////////////////
391507
392static void DSP1_Distance(INT16 X, INT16 Y, INT16 Z, INT16 *Distance)
508// This command calculates the norm of a (X,Y,Z) vector, or the distance from
509// the point (X,Y,Z) to (0,0,0), as you prefer to see it.
510// Distance = sqrt(X^2+Y^2+Z^2)
511// The square root of a number 'a' is calculated by doing this: you
512// write 'a' as b*2^2n, with 'b' between 1/4 and 1; then, you calculate
513// c=sqrt(b) by using lineal interpolation between points of a
514// look-up table and, finally, you output the result as c*2^n.
515
516static void DSP1_distance(INT16 *input, INT16 *output)
393517{
394   int Radius = X * X + Y * Y + Z * Z;
395   INT16 C, E, Pos, Node1, Node2;
518   INT16 X = input[0];
519   INT16 Y = input[1];
520   INT16 Z = input[2];
521   INT16* Distance = &output[0];
522   INT16 Pos, Node1, Node2;
396523
397   if (Radius == 0) *Distance = 0;
398   else
399   {
400      DSP1_NormalizeDouble(Radius, &C, &E);
401      if (E & 1) C = C * 0x4000 >> 15;
524   INT32 Radius = X * X + Y * Y + Z * Z;
402525
403      Pos = C * 0x0040 >> 15;
404526
405      Node1 = DSP1ROM[0x00d5 + Pos];
406      Node2 = DSP1ROM[0x00d6 + Pos];
527   if (Radius == 0) Distance = 0;
528   else
529   {
530      INT16 C, E;
531      normalizeDouble(Radius, &C, &E);
532      if (E & 1) C = C * 0x4000 >> 15;
407533
408      *Distance = ((Node2 - Node1) * (C & 0x1ff) >> 9) + Node1;
534   Pos = C * 0x0040 >> 15;
409535
536      Node1 = DSP1_DataRom[0x00d5 + Pos];
537      Node2 = DSP1_DataRom[0x00d6 + Pos];
538
539      *Distance = ((Node2 - Node1) * (C & 0x1ff) >> 9) + Node1;
540
410541#if DSP1_VERSION < 0x0102
411542      if (Pos & 1) *Distance -= (Node2 - Node1);
412543#endif
413544      *Distance >>= (E >> 1);
414   }
545   }
415546}
416547
417// 0CH - 2D Coordinate Rotation (Bit Perfect)
418// Input    byte(0CH) integer(Angle) integer(X) integer(Y)
419// Output   integer(X) integer(Y)
548//////////////////////////////////////////////////////////////////
420549
421static void DSP1_Rotate(INT16 Angle, INT16 X1, INT16 Y1, INT16 *X2, INT16 *Y2)
550// Determines the (X2, Y2) coordinates obtained by rotating (X1, Y1)
551// clockwise for an angle 'Angle'. The official documentation says
552// 'counterclockwise', but it's obviously wrong (surprise! :P)
553//
554// In matrix notation:
555// |X2|    |cos(Angle)   sin(Angle)| |X1|
556// |  | =  |                       | |  |
557// |Y2|    |-sin(Angle   cos(Angle)| |Y1|
558
559static void DSP1_rotate(INT16 *input, INT16 *output)
422560{
423   *X2 = (Y1 * DSP1_Sin(Angle) >> 15) + (X1 * DSP1_Cos(Angle) >> 15);
424   *Y2 = (Y1 * DSP1_Cos(Angle) >> 15) - (X1 * DSP1_Sin(Angle) >> 15);
561   INT16 Angle = input[0];
562   INT16 X1 = input[1];
563   INT16 Y1 = input[2];
564   INT16* X2 = &output[0];
565   INT16* Y2 = &output[1];
566
567   *X2 = (Y1 * DSP1_sin(Angle) >> 15) + (X1 * DSP1_cos(Angle) >> 15);
568   *Y2 = (Y1 * DSP1_cos(Angle) >> 15) - (X1 * DSP1_sin(Angle) >> 15);
425569}
426570
427// 1CH - 3D Coordinate Rotation (Bit Perfect)
428// Input    byte(1CH) integer(Az) integer(Ay) integer(Ax) integer(X) integer(Y) integer(Z)
429// Output   integer(X) integer(Y) integer(Z)
571//////////////////////////////////////////////////////////////////
430572
431#ifdef UNUSED_FUNCTION
432static void DSP1_Polar(INT16 Az, INT16 Ay, INT16 Ax, INT16 X1, INT16 Y1, INT16 Z1, INT16 *X2, INT16 *Y2, INT16 *Z2)
573// Calculate the coordinates (X2, Y2, Z2) obtained when rotating (X1, Y1, Z1)
574// three-dimensionally. Rotation is done in the order of Az around the Z axis,
575// Ay around the Y axis and Ax around the X axis. As occur with the "attitude" commands
576// (see comments in the "gyrate" command), qthis doesn't match what explained in
577// the official documentation, but it's coherent with what it is done in the "attitude"
578// command (but not with the "gyrate" command).
579//
580// In matrix notation:
581// |X2|   |1      0      0  | |cosRy   0   -sinRy| | cosRz  sinRz    0| |X1|
582// |Y2| = |0    cosRx  sinRx| |  0     1      0  | |-sinRz  cosRz    0| |Y1|
583// |Z2|   |0   -sinRx  cosRx| |sinRy   0    cosRy| |   0      0      1| |Z1|
584
585static void DSP1_polar(INT16 *input, INT16 *output)
433586{
434   INT16 X, Y, Z;
587   INT16 Az = input[0];
588   INT16 Ay = input[1];
589   INT16 Ax = input[2];
590   INT16 X1 = input[3];
591   INT16 Y1 = input[4];
592   INT16 Z1 = input[5];
593   INT16* X2 = &output[0];
594   INT16* Y2 = &output[1];
595   INT16* Z2 = &output[2];
435596
436   // Rotate Around Z
437   X = (Y1 * DSP1_Sin(Az) >> 15) + (X1 * DSP1_Cos(Az) >> 15);
438   Y = (Y1 * DSP1_Cos(Az) >> 15) - (X1 * DSP1_Sin(Az) >> 15);
439   X1 = X; Y1 = Y;
597   INT16 X, Y, Z;
440598
441   // Rotate Around Y
442   Z = (X1 * DSP1_Sin(Ay) >> 15) + (Z1 * DSP1_Cos(Ay) >> 15);
443   X = (X1 * DSP1_Cos(Ay) >> 15) - (Z1 * DSP1_Sin(Ay) >> 15);
444   *X2 = X; Z1 = Z;
599   // Rotate Around Z
600   X = (Y1 * DSP1_sin(Az) >> 15) + (X1 * DSP1_cos(Az) >> 15);
601   Y = (Y1 * DSP1_cos(Az) >> 15) - (X1 * DSP1_sin(Az) >> 15);
602   X1 = X; Y1 = Y;
445603
446   // Rotate Around X
447   Y = (Z1 * DSP1_Sin(Ax) >> 15) + (Y1 * DSP1_Cos(Ax) >> 15);
448   Z = (Z1 * DSP1_Cos(Ax) >> 15) - (Y1 * DSP1_Sin(Ax) >> 15);
449   *Y2 = Y; *Z2 = Z;
604   // Rotate Around Y
605   Z = (X1 * DSP1_sin(Ay) >> 15) + (Z1 * DSP1_cos(Ay) >> 15);
606   X = (X1 * DSP1_cos(Ay) >> 15) - (Z1 * DSP1_sin(Ay) >> 15);
607   *X2 = X; Z1 = Z;
608
609   // Rotate Around X
610   Y = (Z1 * DSP1_sin(Ax) >> 15) + (Y1 * DSP1_cos(Ax) >> 15);
611   Z = (Z1 * DSP1_cos(Ax) >> 15) - (Y1 * DSP1_sin(Ax) >> 15);
612   *Y2 = Y; *Z2 = Z;
450613}
451#endif
452614
453// 02H - Projection Parameter Setting (Bit Perfect)
454// Input    byte(02H) integer(Fx) integer(Fy) integer(Fz) integer(Lfe) integer(Les) integer(Aas) integer(Azs)
455// Output   integer(Vof) integer(Vva) integer(Cx) integer(Cy)
615//////////////////////////////////////////////////////////////////
456616
457static const INT16 MaxAZS_Exp[16] = {
458   0x38b4, 0x38b7, 0x38ba, 0x38be, 0x38c0, 0x38c4, 0x38c7, 0x38ca,
459   0x38ce, 0x38d0, 0x38d4, 0x38d7, 0x38da, 0x38dd, 0x38e0, 0x38e4
460};
617// Set up the elements of an "attitude matrix" (there are other ones):
618//           S | cosRz  sinRz    0| |cosRy   0   -sinRy| |1      0      0  |
619// MatrixA = - |-sinRz  cosRz    0| |  0     1      0  | |0    cosRx  sinRx|
620//           2 |   0      0      1| |sinRy   0    cosRy| |0   -sinRx  cosRx|
621// This matrix is thought to be used within the following framework:
622// let's suppose we define positive rotations around a system of orthogonal axes in this manner:
623// a rotation of +90 degrees around axis3 converts axis2 into axis1
624// a rotation of +90 degrees around axis2 converts axis1 into axis3
625// a rotation of +90 degrees around axis1 converts axis3 into axis2
626// and let's suppose that we have defined a new orthonormal axes system (FLU)
627// by doing the following operations about the standard one (XYZ):
628// first rotating the XYZ system around Z by an angle Rz (obtaining X'Y'Z'),
629// then rotating the resulting system around Y by an angle Ry (obtaining X''Y''Z'')
630// and, finally, rotating the resulting system around X by an angle Rx (obtaining FLU)
631// This FLU (forward/left/up) system represents an "attitude" and, then, the matrix here defined
632// is the change of coordinates matrix that transform coordinates in the FLU
633// system (the "object coordinates") into the standard XYZ system (the "global coordinates"),
634// multiplied by a scale factor S/2, that is:
635// |x|   S             |f|
636// |y| * - = MatrixA * |l|
637// |z|   2             |u|
638// In a similar way, if we use the transpose of the matrix, we can transform global coordinates
639// into object coordinates:
640// |f|   S                        |x|
641// |l| * - = MatrixA_transposed * |y|
642// |u|   2                        |z|
643//
644// input[0]: S
645// input[1]: Rz
646// input[2]: Ry
647// input[3]: Rx
461648
462static INT16 FxParm, FyParm, FzParm, AasParm, AzsParm, LfeParm, LesParm;
463
464static void DSP1_Parameter(INT16 Fx, INT16 Fy, INT16 Fz, INT16 Lfe, INT16 Les, INT16 Aas, INT16 Azs, INT16 *Vof, INT16 *Vva, INT16 *Cx, INT16 *Cy)
649static void DSP1_attitudeA(INT16 *input, INT16 *output)
465650{
466   INT16 CSec, C, E;
651   INT16 S = input[0];
652   INT16 Rz = input[1];
653   INT16 Ry = input[2];
654   INT16 Rx = input[3];
467655
468   // Copy Zenith angle for clipping
469   INT16 AzsB = Azs;
656   INT16 SinRz = DSP1_sin(Rz);
657   INT16 CosRz = DSP1_cos(Rz);
658   INT16 SinRy = DSP1_sin(Ry);
659   INT16 CosRy = DSP1_cos(Ry);
660   INT16 SinRx = DSP1_sin(Rx);
661   INT16 CosRx = DSP1_cos(Rx);
470662
471   INT16 MaxAZS;
663   S >>= 1;
472664
473   // store off parameters for use by the Project operation
474   FxParm = Fx;
475   FyParm = Fy;
476   FzParm = Fz;
477   AasParm = Aas;
478   AzsParm = Azs;
479   LfeParm = Lfe;
480   LesParm = Les;
665   shared.MatrixA[0][0] = (S * CosRz >> 15) * CosRy >> 15;
666   shared.MatrixA[0][1] = ((S * SinRz >> 15) * CosRx >> 15) + (((S * CosRz >> 15) * SinRx >> 15) * SinRy >> 15);
667   shared.MatrixA[0][2] = ((S * SinRz >> 15) * SinRx >> 15) - (((S * CosRz >> 15) * CosRx >> 15) * SinRy >> 15);
481668
482   // Store Sine and Cosine of Azimuth and Zenith angle
483   SinAas = DSP1_Sin(Aas);
484   CosAas = DSP1_Cos(Aas);
485   SinAzs = DSP1_Sin(Azs);
486   CosAzs = DSP1_Cos(Azs);
669   shared.MatrixA[1][0] = -((S * SinRz >> 15) * CosRy >> 15);
670   shared.MatrixA[1][1] = ((S * CosRz >> 15) * CosRx >> 15) - (((S * SinRz >> 15) * SinRx >> 15) * SinRy >> 15);
671   shared.MatrixA[1][2] = ((S * CosRz >> 15) * SinRx >> 15) + (((S * SinRz >> 15) * CosRx >> 15) * SinRy >> 15);
487672
488   Nx = SinAzs * -SinAas >> 15;
489   Ny = SinAzs * CosAas >> 15;
490   Nz = CosAzs * 0x7fff >> 15;
673   shared.MatrixA[2][0] = S * SinRy >> 15;
674   shared.MatrixA[2][1] = -((S * SinRx >> 15) * CosRy >> 15);
675   shared.MatrixA[2][2] = (S * CosRx >> 15) * CosRy >> 15;
676}
491677
492   // Center of Projection
493   CentreX = Fx + (Lfe * Nx >> 15);
494   CentreY = Fy + (Lfe * Ny >> 15);
495   CentreZ = Fz + (Lfe * Nz >> 15);
678//////////////////////////////////////////////////////////////////
496679
497   Gx = CentreX - (Les * Nx >> 15);
498   Gy = CentreY - (Les * Ny >> 15);
499   Gz = CentreZ - (Les * Nz >> 15);
680// Same than 'attitudeA', but with a difference attitude matrix (matrixB)
500681
501   Les_E = 0;
502   DSP1_Normalize(Les, &Les_C, &Les_E);
503   Les_G = Les;
682static void DSP1_attitudeB(INT16 *input, INT16 *output)
683{
684   INT16 S = input[0];
685   INT16 Rz = input[1];
686   INT16 Ry = input[2];
687   INT16 Rx = input[3];
504688
505   E = 0;
506   DSP1_Normalize(CentreZ, &C, &E);
689   INT16 SinRz = DSP1_sin(Rz);
690   INT16 CosRz = DSP1_cos(Rz);
691   INT16 SinRy = DSP1_sin(Ry);
692   INT16 CosRy = DSP1_cos(Ry);
693   INT16 SinRx = DSP1_sin(Rx);
694   INT16 CosRx = DSP1_cos(Rx);
507695
508   VPlane_C = C;
509   VPlane_E = E;
696   S >>= 1;
510697
511   // Determine clip boundary and clip Zenith angle if necessary
512   MaxAZS = MaxAZS_Exp[-E];
698   shared.MatrixB[0][0] = (S * CosRz >> 15) * CosRy >> 15;
699   shared.MatrixB[0][1] = ((S * SinRz >> 15) * CosRx >> 15) + (((S * CosRz >> 15) * SinRx >> 15) * SinRy >> 15);
700   shared.MatrixB[0][2] = ((S * SinRz >> 15) * SinRx >> 15) - (((S * CosRz >> 15) * CosRx >> 15) * SinRy >> 15);
513701
514   if (AzsB < 0) {
515      MaxAZS = -MaxAZS;
516      if (AzsB < MaxAZS + 1) AzsB = MaxAZS + 1;
517   } else {
518      if (AzsB > MaxAZS) AzsB = MaxAZS;
519   }
702   shared.MatrixB[1][0] = -((S * SinRz >> 15) * CosRy >> 15);
703   shared.MatrixB[1][1] = ((S * CosRz >> 15) * CosRx >> 15) - (((S * SinRz >> 15) * SinRx >> 15) * SinRy >> 15);
704   shared.MatrixB[1][2] = ((S * CosRz >> 15) * SinRx >> 15) + (((S * SinRz >> 15) * CosRx >> 15) * SinRy >> 15);
520705
521   // Store Sine and Cosine of clipped Zenith angle
522   SinAzsB = DSP1_Sin(AzsB);
523   CosAzsB = DSP1_Cos(AzsB);
706   shared.MatrixB[2][0] = S * SinRy >> 15;
707   shared.MatrixB[2][1] = -((S * SinRx >> 15) * CosRy >> 15);
708   shared.MatrixB[2][2] = (S * CosRx >> 15) * CosRy >> 15;
709}
524710
525   DSP1_Inverse(CosAzsB, 0, &SecAZS_C1, &SecAZS_E1);
526   DSP1_Normalize(C * SecAZS_C1 >> 15, &C, &E);
527   E += SecAZS_E1;
711//////////////////////////////////////////////////////////////////
528712
529   C = DSP1_Truncate(C, E) * SinAzsB >> 15;
713// Same than 'attitudeA', but with a difference attitude matrix (matrixC)
530714
531   CentreX += C * SinAas >> 15;
532   CentreY -= C * CosAas >> 15;
715static void DSP1_attitudeC(INT16 *input, INT16 *output)
716{
717   INT16 S = input[0];
718   INT16 Rz = input[1];
719   INT16 Ry = input[2];
720   INT16 Rx = input[3];
533721
534   *Cx = CentreX;
535   *Cy = CentreY;
722   INT16 SinRz = DSP1_sin(Rz);
723   INT16 CosRz = DSP1_cos(Rz);
724   INT16 SinRy = DSP1_sin(Ry);
725   INT16 CosRy = DSP1_cos(Ry);
726   INT16 SinRx = DSP1_sin(Rx);
727   INT16 CosRx = DSP1_cos(Rx);
536728
537   // Raster number of imaginary center and horizontal line
538   *Vof = 0;
729   S >>= 1;
539730
540   if ((Azs != AzsB) || (Azs == MaxAZS))
541   {
542      INT16 Aux;
731   shared.MatrixC[0][0] = (S * CosRz >> 15) * CosRy >> 15;
732   shared.MatrixC[0][1] = ((S * SinRz >> 15) * CosRx >> 15) + (((S * CosRz >> 15) * SinRx >> 15) * SinRy >> 15);
733   shared.MatrixC[0][2] = ((S * SinRz >> 15) * SinRx >> 15) - (((S * CosRz >> 15) * CosRx >> 15) * SinRy >> 15);
543734
544      if (Azs == -32768) Azs = -32767;
735   shared.MatrixC[1][0] = -((S * SinRz >> 15) * CosRy >> 15);
736   shared.MatrixC[1][1] = ((S * CosRz >> 15) * CosRx >> 15) - (((S * SinRz >> 15) * SinRx >> 15) * SinRy >> 15);
737   shared.MatrixC[1][2] = ((S * CosRz >> 15) * SinRx >> 15) + (((S * SinRz >> 15) * CosRx >> 15) * SinRy >> 15);
545738
546      C = Azs - MaxAZS;
547      if (C >= 0) C--;
548      Aux = ~(C << 2);
739   shared.MatrixC[2][0] = S * SinRy >> 15;
740   shared.MatrixC[2][1] = -((S * SinRx >> 15) * CosRy >> 15);
741   shared.MatrixC[2][2] = (S * CosRx >> 15) * CosRy >> 15;
742}
549743
550      C = Aux * DSP1ROM[0x0328] >> 15;
551      C = (C * Aux >> 15) + DSP1ROM[0x0327];
552      *Vof -= (C * Aux >> 15) * Les >> 15;
744//////////////////////////////////////////////////////////////////
553745
554      C = Aux * Aux >> 15;
555      Aux = (C * DSP1ROM[0x0324] >> 15) + DSP1ROM[0x0325];
556      CosAzsB += (C * Aux >> 15) * CosAzsB >> 15;
557   }
746// Convert global coordinates (X,Y,Z) to object coordinates (F,L,U)
747// See the comment in "attitudeA" for a explanation about the calculation.
748//
749// input[0]: X ; input[1]: Y ; input[2]: Z
750// &output[0]: F ; &output[1]: L ; &output[2]: U
558751
559   VOffset = Les * CosAzsB >> 15;
752static void DSP1_objectiveA(INT16 *input, INT16 *output)
753{
754   INT16 X = input[0];
755   INT16 Y = input[1];
756   INT16 Z = input[2];
757   INT16* F = &output[0];
758   INT16* L = &output[1];
759   INT16* U = &output[2];
560760
561   DSP1_Inverse(SinAzsB, 0, &CSec, &E);
562   DSP1_Normalize(VOffset, &C, &E);
563   DSP1_Normalize(C * CSec >> 15, &C, &E);
761   *F = (shared.MatrixA[0][0] * X >> 15) + (shared.MatrixA[1][0] * Y >> 15) + (shared.MatrixA[2][0] * Z >> 15);
762   *L = (shared.MatrixA[0][1] * X >> 15) + (shared.MatrixA[1][1] * Y >> 15) + (shared.MatrixA[2][1] * Z >> 15);
763   *U = (shared.MatrixA[0][2] * X >> 15) + (shared.MatrixA[1][2] * Y >> 15) + (shared.MatrixA[2][2] * Z >> 15);
764}
564765
565   if (C == -32768) { C >>= 1; E++; }
766//////////////////////////////////////////////////////////////////
566767
567   *Vva = DSP1_Truncate(-C, E);
768// Same than 'objectiveA', but for the 'B' attitude
568769
569   // Store Secant of clipped Zenith angle
570   DSP1_Inverse(CosAzsB, 0, &SecAZS_C2, &SecAZS_E2);
770static void DSP1_objectiveB(INT16 *input, INT16 *output)
771{
772   INT16 X = input[0];
773   INT16 Y = input[1];
774   INT16 Z = input[2];
775   INT16* F = &output[0];
776   INT16* L = &output[1];
777   INT16* U = &output[2];
778
779   *F = (shared.MatrixB[0][0] * X >> 15) + (shared.MatrixB[1][0] * Y >> 15) + (shared.MatrixB[2][0] * Z >> 15);
780   *L = (shared.MatrixB[0][1] * X >> 15) + (shared.MatrixB[1][1] * Y >> 15) + (shared.MatrixB[2][1] * Z >> 15);
781   *U = (shared.MatrixB[0][2] * X >> 15) + (shared.MatrixB[1][2] * Y >> 15) + (shared.MatrixB[2][2] * Z >> 15);
571782}
572783
573// 06H - Object Projection Calculation
574// Input    byte(06H) integer(X) integer(Y) integer(Z)
575// Output   integer(H) integer(V) integer(M)
784//////////////////////////////////////////////////////////////////
576785
577static void DSP1_Project(INT16 X, INT16 Y, INT16 Z, INT16 *H, INT16 *V, UINT16 *M)
786// Same than 'objectiveA', but for the 'C' attitude
787
788static void DSP1_objectiveC(INT16 *input, INT16 *output)
578789{
579   double Px, Py, Pz, Px1, Py1, Pz1, Px2, Py2, Pz2;
580   INT32 dTan;
790   INT16 X = input[0];
791   INT16 Y = input[1];
792   INT16 Z = input[2];
793   INT16* F = &output[0];
794   INT16* L = &output[1];
795   INT16* U = &output[2];
581796
582   Px = X - FxParm;
583   Py = Y - FyParm;
584   Pz = Z - FzParm;
797   *F = (shared.MatrixC[0][0] * X >> 15) + (shared.MatrixC[1][0] * Y >> 15) + (shared.MatrixC[2][0] * Z >> 15);
798   *L = (shared.MatrixC[0][1] * X >> 15) + (shared.MatrixC[1][1] * Y >> 15) + (shared.MatrixC[2][1] * Z >> 15);
799   *U = (shared.MatrixC[0][2] * X >> 15) + (shared.MatrixC[1][2] * Y >> 15) + (shared.MatrixC[2][2] * Z >> 15);
800}
585801
586   // rotate around the Z axis
587   dTan = Angle(-AasParm+32768);
588   Px1 = (Px*Cos(dTan)+Py*-Sin(dTan));
589   Py1 = (Px*Sin(dTan)+Py*Cos(dTan));
590   Pz1 = Pz;
802//////////////////////////////////////////////////////////////////
591803
592   // rotate around the X axis
593   dTan = Angle(-AzsParm);
594   Px2 = Px1;
595   Py2 = (Py1*Cos(dTan)+Pz1*-Sin(dTan));
596   Pz2 = (Py1*Sin(dTan)+Pz1*Cos(dTan));
804// Convert object coordinates (F,L,U) to object coordinates (X,Y,Z)
805// See the comment in "attitudeA" for a explanation about the calculation.
806//
807// input[0]: F ; input[1]: L ; input[2]: U
808// &output[0]: X ; &output[1]: Y ; &output[2]: Z
597809
598   Pz2 = Pz2-LfeParm;
810static void DSP1_subjectiveA(INT16 *input, INT16 *output)
811{
812   INT16 F = input[0];
813   INT16 L = input[1];
814   INT16 U = input[2];
815   INT16* X = &output[0];
816   INT16* Y = &output[1];
817   INT16* Z = &output[2];
599818
600   if (Pz2 < 0)
601   {
602      double dM;
819   *X = (shared.MatrixA[0][0] * F >> 15) + (shared.MatrixA[0][1] * L >> 15) + (shared.MatrixA[0][2] * U >> 15);
820   *Y = (shared.MatrixA[1][0] * F >> 15) + (shared.MatrixA[1][1] * L >> 15) + (shared.MatrixA[1][2] * U >> 15);
821   *Z = (shared.MatrixA[2][0] * F >> 15) + (shared.MatrixA[2][1] * L >> 15) + (shared.MatrixA[2][2] * U >> 15);
822}
603823
604      *H = (INT16)(-Px2*LesParm/-Pz2);
605      *V = (INT16)(-Py2*LesParm/-Pz2);
824//////////////////////////////////////////////////////////////////
606825
607      dM = (double)LesParm;
608      dM *= 256.0;
609      dM /= -Pz2;
826// Same than 'subjectiveA', but for the 'B' attitude
610827
611      if (dM > 65535.0)
612      {
613         dM = 65535.0;
614      }
615      else if (dM < 0.0)
616      {
617         dM = 0.0;
618      }
828static void DSP1_subjectiveB(INT16 *input, INT16 *output)
829{
830   INT16 F = input[0];
831   INT16 L = input[1];
832   INT16 U = input[2];
833   INT16* X = &output[0];
834   INT16* Y = &output[1];
835   INT16* Z = &output[2];
619836
620      *M = (UINT16)dM;
621   }
622   else
623   {
624      *H = 0;
625      *V = 224;
626      *M = 65535;
627   }
837   *X = (shared.MatrixB[0][0] * F >> 15) + (shared.MatrixB[0][1] * L >> 15) + (shared.MatrixB[0][2] * U >> 15);
838   *Y = (shared.MatrixB[1][0] * F >> 15) + (shared.MatrixB[1][1] * L >> 15) + (shared.MatrixB[1][2] * U >> 15);
839   *Z = (shared.MatrixB[2][0] * F >> 15) + (shared.MatrixB[2][1] * L >> 15) + (shared.MatrixB[2][2] * U >> 15);
628840}
629841
630// 0AH - Raster Data Calculation (Bit Perfect)
631// Input    byte(0AH) integer(Vs)
632// Output   integer(An) integer(Bn) integer(Cn) integer(Dn)
842//////////////////////////////////////////////////////////////////
633843
634static void DSP1_Raster(INT16 Vs, INT16 *An, INT16 *Bn, INT16 *Cn, INT16 *Dn)
844// Same than 'subjectiveA', but for the 'C' attitude
845
846static void DSP1_subjectiveC(INT16 *input, INT16 *output)
635847{
636   INT16 C, E, C1, E1;
848   INT16 F = input[0];
849   INT16 L = input[1];
850   INT16 U = input[2];
851   INT16* X = &output[0];
852   INT16* Y = &output[1];
853   INT16* Z = &output[2];
637854
638   DSP1_Inverse((Vs * SinAzs >> 15) + VOffset, 7, &C, &E);
639   E += VPlane_E;
855   *X = (shared.MatrixC[0][0] * F >> 15) + (shared.MatrixC[0][1] * L >> 15) + (shared.MatrixC[0][2] * U >> 15);
856   *Y = (shared.MatrixC[1][0] * F >> 15) + (shared.MatrixC[1][1] * L >> 15) + (shared.MatrixC[1][2] * U >> 15);
857   *Z = (shared.MatrixC[2][0] * F >> 15) + (shared.MatrixC[2][1] * L >> 15) + (shared.MatrixC[2][2] * U >> 15);
858}
640859
641   C1 = C * VPlane_C >> 15;
642   E1 = E + SecAZS_E2;
860//////////////////////////////////////////////////////////////////
643861
644   DSP1_Normalize(C1, &C, &E);
862// This command calculates the inner product (S) of a vector (X,Y,Z) and
863// the first column of MatrixA. It should be noted that that first column
864// represent the global coordinates of an unity vector in the forward
865// direction in the object coordinate system (coordinates (1,0,0) in the FLU
866// axes system).
867//
868// input[0]: X ; input[1]: Y ; input[2]: Z
869// &output[0]: S
645870
646   C = DSP1_Truncate(C, E);
871static void DSP1_scalarA(INT16 *input, INT16 *output)
872{
873   INT16 X = input[0];
874   INT16 Y = input[1];
875   INT16 Z = input[2];
876   INT16* S = &output[0];
647877
648   *An = C * CosAas >> 15;
649   *Cn = C * SinAas >> 15;
878   *S = (X * shared.MatrixA[0][0] + Y * shared.MatrixA[1][0] + Z * shared.MatrixA[2][0]) >> 15;
879}
650880
651   DSP1_Normalize(C1 * SecAZS_C2 >> 15, &C, &E1);
881//////////////////////////////////////////////////////////////////
652882
653   C = DSP1_Truncate(C, E1);
883// Same than 'scalarA', but for the 'B' attitude
654884
655   *Bn = C * -SinAas >> 15;
656   *Dn = C * CosAas >> 15;
885static void DSP1_scalarB(INT16 *input, INT16 *output)
886{
887   INT16 X = input[0];
888   INT16 Y = input[1];
889   INT16 Z = input[2];
890   INT16* S = &output[0];
891
892   *S = (X * shared.MatrixB[0][0] + Y * shared.MatrixB[1][0] + Z * shared.MatrixB[2][0]) >> 15;
657893}
658894
659// 0EH - Coordinate Calculation of a Selected Point on the Screen (Bit Perfect)
660// Input    byte(0EH) integer(H) integer(V)
661// Output   integer(X) integer(Y)
895//////////////////////////////////////////////////////////////////
662896
663static void DSP1_Target(INT16 H, INT16 V, INT16 *X, INT16 *Y)
897// Same than 'scalarA', but for the 'C' attitude
898
899static void DSP1_scalarC(INT16 *input, INT16 *output)
664900{
665   INT16 C, E, C1, E1;
901   INT16 X = input[0];
902   INT16 Y = input[1];
903   INT16 Z = input[2];
904   INT16* S = &output[0];
666905
667   DSP1_Inverse((V * SinAzs >> 15) + VOffset, 8, &C, &E);
668   E += VPlane_E;
906   *S = (X * shared.MatrixC[0][0] + Y * shared.MatrixC[1][0] + Z * shared.MatrixC[2][0]) >> 15;
907}
669908
670   C1 = C * VPlane_C >> 15;
671   E1 = E + SecAZS_E1;
909//////////////////////////////////////////////////////////////////
672910
673   H <<= 8;
911// This command determines the final attitude angles after the body with attitude angles (Ax, Ay, Az) with
912// respect to the global coordinates is rotated by the minor angular displacements (DeltaF, DeltaL, DeltaU).
913// It means that the XYZ axes are rotated by (Ax, Ay, Az) to obtain the FLU axes and, then, these
914// are rotated by (DeltaF, DeltaL, DeltaU). The command calculates and return the new FLU angles respect to the
915// XYZ system (Rx, Ry, Rz)
916// The formulae are:
917// Rx = Ax + (DeltaU*sin(Ay)+DeltaF*cos(Ay))
918// Ry = Ay + DeltaL - tan(Ax)*(DeltaU*cos(Ay)+DeltaF*sin(Ay))
919// Rz = Az + sec(Ax)*(DeltaU*cos(Ay)-DeltaF*sin(Ay))
920//
921// Now the discussion: according to the official documentation, as described in various commands, you pass from
922// XYZ to FLU by doing the rotations in the order Y, X, Z. In this command, the formulae are coherent with the
923// fact that Y is the first axis to do a rotation around it. However, in the "attitude" command, while the official
924// document describe it that way, we have discovered, when reverse engineering the command, that the calculated
925// matrix do the rotation around Y in the second place. This incoherent behaviour of various commands is, in my
926// opinion, a pretty severe implementation error. However, if you only use small "minor displacements", the error term
927// introduced by that incoherence should be almost negligible.
674928
675   DSP1_Normalize(C1, &C, &E);
929static void DSP1_gyrate(INT16 *input, INT16 *output)
930{
931   INT16 Az = input[0];
932   INT16 Ax = input[1];
933   INT16 Ay = input[2];
934   INT16 U = input[3];
935   INT16 F = input[4];
936   INT16 L = input[5];
937   INT16* Rz = &output[0];
938   INT16* Rx = &output[1];
939   INT16* Ry = &output[2];
676940
677   C = DSP1_Truncate(C, E) * H >> 15;
941   INT16 CSec, ESec, CSin, C, E;
942   INT16 SinAy = DSP1_sin(Ay);
943   INT16 CosAy = DSP1_cos(Ay);
678944
679   *X = CentreX + (C * CosAas >> 15);
680   *Y = CentreY - (C * SinAas >> 15);
945   inverse(DSP1_cos(Ax), 0, &CSec, &ESec);
681946
682   V <<= 8;
947   // Rotation Around Z
948   normalizeDouble(U * CosAy - F * SinAy, &C, &E);
683949
684   DSP1_Normalize(C1 * SecAZS_C1 >> 15, &C, &E1);
950 E = ESec - E;
685951
686   C = DSP1_Truncate(C, E1) * V >> 15;
952 normalize(C * CSec >> 15, &C, &E);
687953
688   *X += C * -SinAas >> 15;
689   *Y += C * CosAas >> 15;
954   *Rz = Az + denormalizeAndClip(C, E);
955
956   // Rotation Around X
957   *Rx = Ax + (U * SinAy >> 15) + (F * CosAy >> 15);
958
959   // Rotation Around Y
960   normalizeDouble(U * CosAy + F * SinAy, &C, &E);
961
962   E = ESec - E;
963
964   normalize(DSP1_sin(Ax), &CSin, &E);
965
966   normalize(-(C * (CSec * CSin >> 15) >> 15), &C, &E);
967
968   *Ry = Ay + denormalizeAndClip(C, E) + L;
690969}
691970
692// 01H - Set Attitude A (Bit Perfect)
693// Input    byte(01H) integer(M) integer(Az) integer(Ay) integer(Ax)
694// Output   None
971//////////////////////////////////////////////////////////////////
695972
696static INT16 MatrixA[3][3];
973static const INT16 DSP1_MaxAZS_Exp[16] = {
974   0x38b4, 0x38b7, 0x38ba, 0x38be, 0x38c0, 0x38c4, 0x38c7, 0x38ca,
975   0x38ce, 0x38d0, 0x38d4, 0x38d7, 0x38da, 0x38dd, 0x38e0, 0x38e4
976};
697977
698static void DSP1_Attitude_A(INT16 M, INT16 Az, INT16 Ay, INT16 Ax)
978//////////////////////////////////////////////////////////////////
979
980
981// Set-up the projection framework. Besides returning some values, it store in RAM some values that
982// will be used by the other three projection commands (raster, target an project)
983// Input:
984// (Fx, Fy, Fz)-> coordinates of base point (global coordinates)
985// Lfe-> distance between the base point and the viewpoint (center of projection)
986// Les-> distance between the base point and the screen
987// Aas-> azimuth angle (0 degrees is east; 90 degrees is north)
988// Azs-> zenith angle (0 degrees is zenith)
989// Output:
990// Vof-> raster line of imaginary center (whatever it means ;) )
991// Vva-> raster line representing the horizon line
992// (Cx, Cy)-> coordinates of the projection of the center of the screen over the ground (ground coordinates)
993
994static void DSP1_parameter(INT16 *input, INT16 *output)
699995{
700   INT16 SinAz = DSP1_Sin(Az);
701   INT16 CosAz = DSP1_Cos(Az);
702   INT16 SinAy = DSP1_Sin(Ay);
703   INT16 CosAy = DSP1_Cos(Ay);
704   INT16 SinAx = DSP1_Sin(Ax);
705   INT16 CosAx = DSP1_Cos(Ax);
996   INT16 Fx = input[0];
997   INT16 Fy = input[1];
998   INT16 Fz = input[2];
999   INT16 Lfe = input[3];
1000   INT16 Les = input[4];
1001   INT16 Aas = input[5];
1002   INT16 Azs = input[6];
1003   INT16* Vof = &output[0];
1004   INT16* Vva = &output[1];
1005   INT16* Cx = &output[2];
1006   INT16* Cy = &output[3];
7061007
707   M >>= 1;
1008   INT16 CSec, C, E;
1009   INT16 LfeNx, LfeNy, LfeNz;
1010   INT16 LesNx, LesNy, LesNz;
1011   INT16 AZS, MaxAZS;
7081012
709   MatrixA[0][0] = (M * CosAz >> 15) * CosAy >> 15;
710   MatrixA[0][1] = -((M * SinAz >> 15) * CosAy >> 15);
711   MatrixA[0][2] = M * SinAy >> 15;
1013   // Copy Zenith angle for clipping
1014   AZS = Azs;
7121015
713   MatrixA[1][0] = ((M * SinAz >> 15) * CosAx >> 15) + (((M * CosAz >> 15) * SinAx >> 15) * SinAy >> 15);
714   MatrixA[1][1] = ((M * CosAz >> 15) * CosAx >> 15) - (((M * SinAz >> 15) * SinAx >> 15) * SinAy >> 15);
715   MatrixA[1][2] = -((M * SinAx >> 15) * CosAy >> 15);
1016   // Store Les and his coefficient and exponent when normalized
1017   shared.Les = Les;
1018   shared.E_Les=0;
1019   normalize(Les, &shared.C_Les, &shared.E_Les);
7161020
717   MatrixA[2][0] = ((M * SinAz >> 15) * SinAx >> 15) - (((M * CosAz >> 15) * CosAx >> 15) * SinAy >> 15);
718   MatrixA[2][1] = ((M * CosAz >> 15) * SinAx >> 15) + (((M * SinAz >> 15) * CosAx >> 15) * SinAy >> 15);
719   MatrixA[2][2] = (M * CosAx >> 15) * CosAy >> 15;
720}
1021   // Store Sine and Cosine of Azimuth and Zenith angle
1022   shared.SinAas = DSP1_sin(Aas);
1023   shared.CosAas = DSP1_cos(Aas);
1024   shared.SinAzs = DSP1_sin(Azs);
1025   shared.CosAzs = DSP1_cos(Azs);
7211026
722// 11H - Set Attitude B (Bit Perfect)
723// Input    byte(11H) integer(M) integer(Az) integer(Ay) integer(Ax)
724// Output   None
1027   // normal vector to the screen (norm 1, points toward the center of projection)
1028   shared.Nx = shared.SinAzs * -shared.SinAas >> 15;
1029   shared.Ny = shared.SinAzs * shared.CosAas >> 15;
1030   shared.Nz = shared.CosAzs * 0x7fff >> 15;
7251031
726static INT16 MatrixB[3][3];
1032   // horizontal vector of the screen (Hz=0, norm 1, points toward the right of the screen)
1033   shared.Hx = shared.CosAas*0x7fff>>15;
1034   shared.Hy = shared.SinAas*0x7fff>>15;
7271035
728static void DSP1_Attitude_B(INT16 M, INT16 Az, INT16 Ay, INT16 Ax)
729{
730   INT16 SinAz = DSP1_Sin(Az);
731   INT16 CosAz = DSP1_Cos(Az);
732   INT16 SinAy = DSP1_Sin(Ay);
733   INT16 CosAy = DSP1_Cos(Ay);
734   INT16 SinAx = DSP1_Sin(Ax);
735   INT16 CosAx = DSP1_Cos(Ax);
1036   // vertical vector of the screen (norm 1, points toward the top of the screen)
1037   shared.Vx = shared.CosAzs*-shared.SinAas>>15;
1038   shared.Vy = shared.CosAzs*shared.CosAas>>15;
1039   shared.Vz = -shared.SinAzs*0x7fff>>15;
7361040
737   M >>= 1;
1041   LfeNx = Lfe*shared.Nx>>15;
1042   LfeNy = Lfe*shared.Ny>>15;
1043   LfeNz = Lfe*shared.Nz>>15;
7381044
739   MatrixB[0][0] = (M * CosAz >> 15) * CosAy >> 15;
740   MatrixB[0][1] = -((M * SinAz >> 15) * CosAy >> 15);
741   MatrixB[0][2] = M * SinAy >> 15;
1045   // Center of Projection
1046   shared.CentreX = Fx+LfeNx;
1047   shared.CentreY = Fy+LfeNy;
1048   shared.CentreZ = Fz+LfeNz;
7421049
743   MatrixB[1][0] = ((M * SinAz >> 15) * CosAx >> 15) + (((M * CosAz >> 15) * SinAx >> 15) * SinAy >> 15);
744   MatrixB[1][1] = ((M * CosAz >> 15) * CosAx >> 15) - (((M * SinAz >> 15) * SinAx >> 15) * SinAy >> 15);
745   MatrixB[1][2] = -((M * SinAx >> 15) * CosAy >> 15);
1050   LesNx = Les*shared.Nx>>15;
1051   LesNy = Les*shared.Ny>>15;
1052   LesNz = Les*shared.Nz>>15;
7461053
747   MatrixB[2][0] = ((M * SinAz >> 15) * SinAx >> 15) - (((M * CosAz >> 15) * CosAx >> 15) * SinAy >> 15);
748   MatrixB[2][1] = ((M * CosAz >> 15) * SinAx >> 15) + (((M * SinAz >> 15) * CosAx >> 15) * SinAy >> 15);
749   MatrixB[2][2] = (M * CosAx >> 15) * CosAy >> 15;
750}
1054   // center of the screen (global coordinates)
1055   shared.Gx=shared.CentreX-LesNx;
1056   shared.Gy=shared.CentreY-LesNy;
1057   shared.Gz=shared.CentreZ-LesNz;
7511058
752// 21H - Set Attitude C (Bit Perfect)
753// Input    byte(21H) integer(M) integer(Az) integer(Ay) integer(Ax)
754// Output   None
7551059
756static INT16 MatrixC[3][3];
1060   E = 0;
1061   normalize(shared.CentreZ, &C, &E);
7571062
758#ifdef UNUSED_FUNCTION
759static void DSP1_Attitude_C(INT16 M, INT16 Az, INT16 Ay, INT16 Ax)
760{
761   INT16 SinAz = DSP1_Sin(Az);
762   INT16 CosAz = DSP1_Cos(Az);
763   INT16 SinAy = DSP1_Sin(Ay);
764   INT16 CosAy = DSP1_Cos(Ay);
765   INT16 SinAx = DSP1_Sin(Ax);
766   INT16 CosAx = DSP1_Cos(Ax);
1063   shared.CentreZ_C = C;
1064   shared.CentreZ_E = E;
7671065
768   M >>= 1;
1066   // Determine clip boundary and clip Zenith angle if necessary
1067   // (Why to clip? Maybe to avoid the screen can only show sky with no ground? Only a guess...)
1068   MaxAZS = DSP1_MaxAZS_Exp[-E];
7691069
770   MatrixC[0][0] = (M * CosAz >> 15) * CosAy >> 15;
771   MatrixC[0][1] = -((M * SinAz >> 15) * CosAy >> 15);
772   MatrixC[0][2] = M * SinAy >> 15;
1070   if (AZS < 0) {
1071      MaxAZS = -MaxAZS;
1072      if (AZS < MaxAZS + 1) AZS = MaxAZS + 1;
1073   } else {
1074      if (AZS > MaxAZS) AZS = MaxAZS;
1075   }
7731076
774   MatrixC[1][0] = ((M * SinAz >> 15) * CosAx >> 15) + (((M * CosAz >> 15) * SinAx >> 15) * SinAy >> 15);
775   MatrixC[1][1] = ((M * CosAz >> 15) * CosAx >> 15) - (((M * SinAz >> 15) * SinAx >> 15) * SinAy >> 15);
776   MatrixC[1][2] = -((M * SinAx >> 15) * CosAy >> 15);
1077   // Store Sine and Cosine of clipped Zenith angle
1078   shared.SinAZS = DSP1_sin(AZS);
1079   shared.CosAZS = DSP1_cos(AZS);
7771080
778   MatrixC[2][0] = ((M * SinAz >> 15) * SinAx >> 15) - (((M * CosAz >> 15) * CosAx >> 15) * SinAy >> 15);
779   MatrixC[2][1] = ((M * CosAz >> 15) * SinAx >> 15) + (((M * SinAz >> 15) * CosAx >> 15) * SinAy >> 15);
780   MatrixC[2][2] = (M * CosAx >> 15) * CosAy >> 15;
781}
782#endif
1081   // calculate the separation of (cx, cy) from the projection of
1082   // the 'centre of projection' over the ground... (CentreZ*tg(AZS))
1083   inverse(shared.CosAZS, 0, &shared.SecAZS_C1, &shared.SecAZS_E1);
1084   normalize(C * shared.SecAZS_C1 >> 15, &C, &E);
1085   E += shared.SecAZS_E1;
1086   C = denormalizeAndClip(C, E) * shared.SinAZS >> 15;
7831087
784// 0DH - Convert from Global to Object Coordinates A (Bit Perfect)
785// Input    byte(0DH) integer(X) integer(Y) integer(Z)
786// Output   integer(F) integer(L) integer(U)
1088   // ... and then take into account the position of the centre of
1089   // projection and the azimuth angle
1090   shared.CentreX += C * shared.SinAas >> 15;
1091   shared.CentreY -= C * shared.CosAas >> 15;
7871092
788static void DSP1_Objective_A(INT16 X, INT16 Y, INT16 Z, INT16 *F, INT16 *L, INT16 *U)
789{
790   *F = (X * MatrixA[0][0] >> 15) + (Y * MatrixA[0][1] >> 15) + (Z * MatrixA[0][2] >> 15);
791   *L = (X * MatrixA[1][0] >> 15) + (Y * MatrixA[1][1] >> 15) + (Z * MatrixA[1][2] >> 15);
792   *U = (X * MatrixA[2][0] >> 15) + (Y * MatrixA[2][1] >> 15) + (Z * MatrixA[2][2] >> 15);
793}
1093   *Cx = shared.CentreX;
1094   *Cy = shared.CentreY;
7941095
795// 1DH - Convert from Global to Object Coordinates B (Bit Perfect)
796// Input    byte(1DH) integer(X) integer(Y) integer(Z)
797// Output   integer(F) integer(L) integer(U)
1096   // Raster number of imaginary center and horizontal line
1097   *Vof = 0;
7981098
799void DSP1_Objective_B(INT16 X, INT16 Y, INT16 Z, INT16 *F, INT16 *L, INT16 *U)
800{
801   *F = (X * MatrixB[0][0] >> 15) + (Y * MatrixB[0][1] >> 15) + (Z * MatrixB[0][2] >> 15);
802   *L = (X * MatrixB[1][0] >> 15) + (Y * MatrixB[1][1] >> 15) + (Z * MatrixB[1][2] >> 15);
803   *U = (X * MatrixB[2][0] >> 15) + (Y * MatrixB[2][1] >> 15) + (Z * MatrixB[2][2] >> 15);
804}
1099   if ((Azs != AZS) || (Azs == MaxAZS))
1100   {
1101      INT16 Aux;
8051102
806// 2DH - Convert from Global to Object Coordinates C (Bit Perfect)
807// Input    byte(2DH) integer(X) integer(Y) integer(Z)
808// Output   integer(F) integer(L) integer(U)
1103      // correct vof and vva when Azs is outside the 'non-clipping interval'
1104      // we have only some few Taylor coefficients, so we cannot guess which ones
1105      // are the approximated functions and, what is worse, we don't know why
1106      // the own clipping stuff (and, particularly, this correction) is done
1107      if (Azs == -32768) Azs = -32767;
8091108
810static void DSP1_Objective_C(INT16 X, INT16 Y, INT16 Z, INT16 *F, INT16 *L, INT16 *U)
811{
812   *F = (X * MatrixC[0][0] >> 15) + (Y * MatrixC[0][1] >> 15) + (Z * MatrixC[0][2] >> 15);
813   *L = (X * MatrixC[1][0] >> 15) + (Y * MatrixC[1][1] >> 15) + (Z * MatrixC[1][2] >> 15);
814   *U = (X * MatrixC[2][0] >> 15) + (Y * MatrixC[2][1] >> 15) + (Z * MatrixC[2][2] >> 15);
815}
1109      C = Azs - MaxAZS;
1110      if (C >= 0) C--;
1111      Aux = ~(C << 2);
8161112
817// 03H - Conversion from Object to Global Coordinates A (Bit Perfect)
818// Input    byte(03H) integer(F) integer(L) integer(U)
819// Output   integer(X) integer(Y) integer(Z)
1113      // Vof += x+(1/3)*x^3, where x ranges from 0 to PI/4 when Azs-MaxAZS goes from 0 to 0x2000
1114      C = Aux * DSP1_DataRom[0x0328] >> 15;
1115      C = (C * Aux >> 15) + DSP1_DataRom[0x0327];
1116      *Vof -= (C * Aux >> 15) * Les >> 15;
8201117
821static void DSP1_Subjective_A(INT16 F, INT16 L, INT16 U, INT16 *X, INT16 *Y, INT16 *Z)
822{
823   *X = (F * MatrixA[0][0] >> 15) + (L * MatrixA[1][0] >> 15) + (U * MatrixA[2][0] >> 15);
824   *Y = (F * MatrixA[0][1] >> 15) + (L * MatrixA[1][1] >> 15) + (U * MatrixA[2][1] >> 15);
825   *Z = (F * MatrixA[0][2] >> 15) + (L * MatrixA[1][2] >> 15) + (U * MatrixA[2][2] >> 15);
826}
1118      // CosAZS *= 1+(1/2)*x^2+(5/24)*x^24, where x ranges from 0 to PI/4 when Azs-MaxAZS goes from 0 to 0x2000
1119      C = Aux * Aux >> 15;
1120      Aux = (C * DSP1_DataRom[0x0324] >> 15) + DSP1_DataRom[0x0325];
1121      shared.CosAZS += (C * Aux >> 15) * shared.CosAZS >> 15;
1122   }
8271123
828// 13H - Conversion from Object to Global Coordinates B (Bit Perfect)
829// Input    byte(13H) integer(F) integer(L) integer(U)
830// Output   integer(X) integer(Y) integer(Z)
1124   // vertical offset of the screen with regard to the horizontal plane
1125   // containing the centre of projection
1126   shared.VOffset = Les * shared.CosAZS >> 15;
8311127
832static void DSP1_Subjective_B(INT16 F, INT16 L, INT16 U, INT16 *X, INT16 *Y, INT16 *Z)
833{
834   *X = (F * MatrixB[0][0] >> 15) + (L * MatrixB[1][0] >> 15) + (U * MatrixB[2][0] >> 15);
835   *Y = (F * MatrixB[0][1] >> 15) + (L * MatrixB[1][1] >> 15) + (U * MatrixB[2][1] >> 15);
836   *Z = (F * MatrixB[0][2] >> 15) + (L * MatrixB[1][2] >> 15) + (U * MatrixB[2][2] >> 15);
1128   // The horizon line (the line in the screen that is crossed by the horizon plane
1129   // -the horizontal plane containing the 'centre of projection'-),
1130   // will be at distance Les*cotg(AZS) from the centre of the screen. This is difficult
1131   // to explain but easily seen in a graph. To better see it, consider it in this way:
1132   // Les*tg(AZS-90), draw some lines and apply basic trigonometry. ;)
1133   inverse(shared.SinAZS, 0, &CSec, &E);
1134   normalize(shared.VOffset, &C, &E);
1135   normalize(C * CSec >> 15, &C, &E);
1136
1137   if (C == -32768) { C >>= 1; E++; }
1138
1139   *Vva = denormalizeAndClip(-C, E);
1140
1141   // Store Secant of clipped Zenith angle
1142   inverse(shared.CosAZS, 0, &shared.SecAZS_C2, &shared.SecAZS_E2);
8371143}
8381144
839// 23H - Conversion from Object to Global Coordinates C (Bit Perfect)
840// Input    byte(23H) integer(F) integer(L) integer(U)
841// Output   integer(X) integer(Y) integer(Z)
1145//////////////////////////////////////////////////////////////////
8421146
843static void DSP1_Subjective_C(INT16 F, INT16 L, INT16 U, INT16 *X, INT16 *Y, INT16 *Z)
1147// Calculates the matrix which transform an object situated on a raster line (Vs) into
1148// his projection over the ground. The modified SecAZS is used here, so
1149// i don't understand the fine details, but, basically, it's done
1150// this way: The vertical offset between the point of projection and the
1151// raster line is calculated (Vs*SinAzs>>15)+VOffset, then the height of
1152// the center of projection is measured in that units (*CentreZ_C). If, now
1153// you consider the "reference case" (center of projection at an unit of height),
1154// the projection of a thin strip containing the raster line will have the same
1155// width (as the raster line would be on the ground in this case, but will suffer a
1156// change of scale in height (as the ground and the vertical axis would form an angle of 180-Azs degrees).
1157// This scale factor, when the angle 'center of screen-center of projection-raster line' is small,
1158// can be aproximated by the one of the center of the screen, 1/cos(Azs).(**) (Here is when it's used
1159// SecAZS). By last, you have to consider the effect of the azimuth angle Aas, and you are done.
1160//
1161// Using matrix notation:
1162//                    |A     B|    Centre_ZS     | cos(Aas)   -sin(Aas)|   |1           0|
1163// ProjectionMatrix = |       | = ----------- *  |                     | * |             |
1164//                    |C     D|   Vs*sin(Azs)    |sin(Aas)     cos(Aas)|   |0    sec(Azs)|
1165//
1166// (**)
1167// If Les=1, the vertical offset between the center
1168// of projection and the center of the screen is Cos(Azs); then, if the vertical
1169// offset is 1, the ratio of the projection over the ground respect to the
1170// line on the screen is 1/cos(Azs).
1171
1172static void DSP1_raster(INT16 *input, INT16 *output)
8441173{
845   *X = (F * MatrixC[0][0] >> 15) + (L * MatrixC[1][0] >> 15) + (U * MatrixC[2][0] >> 15);
846   *Y = (F * MatrixC[0][1] >> 15) + (L * MatrixC[1][1] >> 15) + (U * MatrixC[2][1] >> 15);
847   *Z = (F * MatrixC[0][2] >> 15) + (L * MatrixC[1][2] >> 15) + (U * MatrixC[2][2] >> 15);
848}
1174   INT16 Vs = input[0];
1175   INT16* An = &output[0];
1176   INT16* Bn = &output[1];
1177   INT16* Cn = &output[2];
1178   INT16* Dn = &output[3];
8491179
850// 0BH - Calculation of Inner Product with Forward Attitude A and a Vector (Bit Perfect)
851// Input    byte(0BH) integer(X) integer(Y) integer(Z)
852// Output   integer(S)
1180   INT16 C, E, C1, E1;
8531181
854static void DSP1_Scalar_A(INT16 X, INT16 Y, INT16 Z, INT16 *S)
855{
856   *S = ((X * MatrixA[0][0]) + (Y * MatrixA[0][1]) + (Z * MatrixA[0][2])) >> 15;
1182   inverse((Vs * shared.SinAzs >> 15) + shared.VOffset, 7, &C, &E);
1183
1184   E += shared.CentreZ_E;
1185   C1 = C * shared.CentreZ_C >> 15;
1186
1187   E1 = E + shared.SecAZS_E2;
1188
1189   normalize(C1, &C, &E);
1190   C = denormalizeAndClip(C, E);
1191
1192   *An = C * shared.CosAas >> 15;
1193   *Cn = C * shared.SinAas >> 15;
1194
1195   normalize(C1 * shared.SecAZS_C2 >> 15, &C, &E1);
1196   C = denormalizeAndClip(C, E1);
1197
1198   *Bn = C * -shared.SinAas >> 15;
1199   *Dn = C * shared.CosAas >> 15;
8571200}
8581201
859// 1BH - Calculation of Inner Product with Forward Attitude B and a Vector (Bit Perfect)
860// Input    byte(1BH) integer(X) integer(Y) integer(Z)
861// Output   integer(S)
1202//////////////////////////////////////////////////////////////////
8621203
863static void DSP1_Scalar_B(INT16 X, INT16 Y, INT16 Z, INT16 *S)
1204// Calculate the projection over the ground of a selected point of screen
1205// It simply apply the projection matrix described in the "Raster" command
1206// to the vector (H,V) transposed, and add the result to the position of
1207// the centre of projection.
1208// The only special point to take into account is the directions on the screen:
1209// H is positive rightward, but V is positive downward; this is why
1210// the signs take that configuration
1211
1212static void DSP1_target(INT16 *input, INT16 *output)
8641213{
865   *S = ((X * MatrixB[0][0]) + (Y * MatrixB[0][1]) + (Z * MatrixB[0][2])) >> 15;
866}
1214   INT16 H = input[0];
1215   INT16 V = input[1];
1216   INT16* X = &output[0];
1217   INT16* Y = &output[1];
8671218
868// 2BH - Calculation of Inner Product with Forward Attitude C and a Vector (Bit Perfect)
869// Input    byte(2BH) integer(X) integer(Y) integer(Z)
870// Output   integer(S)
1219   INT16 C, E, C1, E1;
8711220
872static void DSP1_Scalar_C(INT16 X, INT16 Y, INT16 Z, INT16 *S)
873{
874   *S = ((X * MatrixC[0][0]) + (Y * MatrixC[0][1]) + (Z * MatrixC[0][2])) >> 15;
1221   inverse((V * shared.SinAzs >> 15) + shared.VOffset, 8, &C, &E);
1222
1223   E += shared.CentreZ_E;
1224   C1 = C * shared.CentreZ_C >> 15;
1225
1226   E1 = E + shared.SecAZS_E1;
1227
1228   H <<= 8;
1229   normalize(C1, &C, &E);
1230   C = denormalizeAndClip(C, E) * H >> 15;
1231
1232   *X = shared.CentreX + (C * shared.CosAas >> 15);
1233   *Y = shared.CentreY - (C * shared.SinAas >> 15);
1234
1235   V <<= 8;
1236   normalize(C1 * shared.SecAZS_C1 >> 15, &C, &E1);
1237   C = denormalizeAndClip(C, E1) * V >> 15;
1238
1239   *X += C * -shared.SinAas >> 15;
1240   *Y += C * shared.CosAas >> 15;
8751241}
8761242
877// 14H - 3D Angle Rotation (Bit Perfect)
878// Input    byte(14H) integer(Az) integer(Ax) integer(Ay) integer(U) integer(F) integer(L)
879// Output   integer(Rz) integer(Rx) integer(Ry)
1243//////////////////////////////////////////////////////////////////
8801244
881static void DSP1_Gyrate(INT16 Az, INT16 Ax, INT16 Ay, INT16 U, INT16 F, INT16 L, INT16 *Rz, INT16 *Rx, INT16 *Ry)
1245// Calculation of the projection over the screen (H,V) of an object (X,Y,Z) and his
1246// 'enlargement ratio' (M). The positive directions on the screen are as described
1247// in the targe command. M is scaled down by 2^-7, that is, M==0x0100 means ratio 1:1
1248
1249static void DSP1_project(INT16 *input, INT16 *output)
8821250{
883   INT16 CSec, ESec, CSin, C, E;
1251   INT16 X = input[0];
1252   INT16 Y = input[1];
1253   INT16 Z = input[2];
1254   INT16* H = &output[0];
1255   INT16* V = &output[1];
1256   INT16* M = &output[2];
8841257
885   DSP1_Inverse(DSP1_Cos(Ax), 0, &CSec, &ESec);
1258   INT32 aux, aux4;
1259   INT16 E, E2, E3, E4, E5, refE, E6, E7;
1260   INT16 C2, C4, C6, C8, C9, C10, C11, C12, C16, C17, C18, C19, C20, C21, C22, C23, C24, C25, C26;
1261   INT16 Px, Py, Pz;
8861262
887   // Rotation Around Z
888   DSP1_NormalizeDouble(U * DSP1_Cos(Ay) - F * DSP1_Sin(Ay), &C, &E);
1263   E4=E3=E2=E=E5=0;
8891264
890   E = ESec - E;
1265   normalizeDouble((INT32)(X)-shared.Gx, &Px, &E4);
1266   normalizeDouble((INT32)(Y)-shared.Gy, &Py, &E);
1267   normalizeDouble((INT32)(Z)-shared.Gz, &Pz, &E3);
1268   Px>>=1; E4--;   // to avoid overflows when calculating the scalar products
1269   Py>>=1; E--;
1270   Pz>>=1; E3--;
8911271
892   DSP1_Normalize(C * CSec >> 15, &C, &E);
1272   refE = (E<E3)?E:E3;
1273   refE = (refE<E4)?refE:E4;
8931274
894   *Rz = Az + DSP1_Truncate(C, E);
1275   Px=shiftR(Px,E4-refE);    // normalize them to the same exponent
1276   Py=shiftR(Py,E-refE);
1277   Pz=shiftR(Pz,E3-refE);
8951278
896   // Rotation Around X
897   *Rx = Ax + (U * DSP1_Sin(Ay) >> 15) + (F * DSP1_Cos(Ay) >> 15);
1279   C11=- (Px*shared.Nx>>15);
1280   C8=- (Py*shared.Ny>>15);
1281   C9=- (Pz*shared.Nz>>15);
1282   C12=C11+C8+C9;   // this cannot overflow!
8981283
899   // Rotation Around Y
900   DSP1_NormalizeDouble(U * DSP1_Cos(Ay) + F * DSP1_Sin(Ay), &C, &E);
1284   aux4=C12;   // de-normalization with 32-bits arithmetic
1285   refE = 16-refE;    // refE can be up to 3
1286   if (refE>=0)
1287      aux4 <<=(refE);
1288   else
1289      aux4 >>=-(refE);
1290   if (aux4==-1) aux4 = 0;      // why?
1291   aux4>>=1;
9011292
902   E = ESec - E;
1293   aux = (UINT16)(shared.Les) + aux4;   // Les - the scalar product of P with the normal vector of the screen
1294   normalizeDouble(aux, &C10, &E2);
1295   E2 = 15-E2;
9031296
904   DSP1_Normalize(DSP1_Sin(Ax), &CSin, &E);
1297   inverse(C10, 0, &C4, &E4);
1298   C2=C4*shared.C_Les>>15;                 // scale factor
9051299
906   DSP1_Normalize(-(C * (CSec * CSin >> 15) >> 15), &C, &E);
9071300
908   *Ry = Ay + DSP1_Truncate(C, E) + L;
909}
1301   // H
1302   E7=0;
1303   C16= (Px*shared.Hx>>15);
1304   C20= (Py*shared.Hy>>15);
1305   C17=C16+C20;   // scalar product of P with the normalized horizontal vector of the screen...
9101306
911// 0FH - Memory Test (Bit Perfect)
912// Input    byte(0FH) integer(Size)
913// Output   integer(Result)
1307   C18=C17*C2>>15;    // ... multiplied by the scale factor
1308   normalize(C18, &C19, &E7);
1309   *H=denormalizeAndClip(C19, shared.E_Les-E2+refE+E7);
9141310
915static void DSP1_MemoryTest(INT16 Size, INT16 *Result)
916{
917   *Result = 0x0000;
1311   // V
1312   E6=0;
1313   C21 = Px*shared.Vx>>15;
1314   C22 = Py*shared.Vy>>15;
1315   C23 = Pz*shared.Vz>>15;
1316   C24=C21+C22+C23;   // scalar product of P with the normalized vertical vector of the screen...
1317
1318   C26=C24*C2>>15;    // ... multiplied by the scale factor
1319   normalize(C26, &C25, &E6);
1320   *V=denormalizeAndClip(C25, shared.E_Les-E2+refE+E6);
1321
1322   // M
1323   normalize(C2, &C6, &E4);
1324   *M=denormalizeAndClip(C6, E4+shared.E_Les-E2-7); // M is the scale factor divided by 2^7
9181325}
9191326
920// 2FH - Memory Size Calculation (Bit Perfect)
921// Input    byte(2FH) integer(Undefined)
922// Output   integer(Size)
1327//////////////////////////////////////////////////////////////////
9231328
924static void DSP1_MemorySize(INT16 *Size)
1329// Calculate the sine of the input parameter
1330// this is done by linear interpolation between
1331// the points of a look-up table
1332
1333static INT16 DSP1_sin(INT16 Angle)
9251334{
926   *Size = 0x0100;
1335   INT32 S;
1336
1337   if (Angle < 0) {
1338      if (Angle == -32768) return 0;
1339      return -sin(-Angle);
1340   }
1341   S = DSP1_SinTable[Angle >> 8] + (DSP1_MulTable[Angle & 0xff] * DSP1_SinTable[0x40 + (Angle >> 8)] >> 15);
1342   if (S > 32767) S = 32767;
1343   return (INT16) S;
9271344}
9281345
929// ********************************************************************************************
930// MAME/MESS interface for above DSP1 code
931// ********************************************************************************************
1346//////////////////////////////////////////////////////////////////
9321347
933// DSP1 interface
934static UINT8 dsp1_read(UINT16 address)
1348// Calculate the cosine of the input parameter.
1349// It's used the same method than in sin(INT16)
1350
1351static INT16 DSP1_cos(INT16 Angle)
9351352{
936   // check data vs. status
937   if (((address & 0xf000) == 0x6000) || ((address & 0x7fff) < 0x4000))
938   {
939      // data reg
940      if (dsp1_out_cnt)
941      {
942         UINT8 temp = (UINT8)dsp1_out[dsp1_out_idx++];
943         if (--dsp1_out_cnt == 0)
944         {
945            if ((dsp1_cur_cmd == 0x1a) || (dsp1_cur_cmd == 0x0a))
946            {
947               INT16 tr, tr1, tr2, tr3;
1353   INT32 S;
9481354
949               DSP1_Raster(dsp1_in[0]|dsp1_in[1]<<8, &tr, &tr1, &tr2, &tr3);
950               dsp1_in[0]++;
951               if (dsp1_in[0] == 0) dsp1_in[1]++;
952               dsp1_out_cnt = 8;
953               dsp1_out[0] = tr&0xff;
954               dsp1_out[1] = (tr>>8)&0xff;
955               dsp1_out[2] = tr1&0xff;
956               dsp1_out[3] = (tr1>>8)&0xff;
957               dsp1_out[4] = tr2&0xff;
958               dsp1_out[5] = (tr2>>8)&0xff;
959               dsp1_out[6] = tr3&0xff;
960               dsp1_out[7] = (tr3>>8)&0xff;
961               dsp1_out_idx = 0;
962            }
963            else if (dsp1_cur_cmd == 0x1f)
964            {
965               if ((dsp1_out_idx % 2) != 0)
966               {
967                  return DSP1ROM[dsp1_out_idx>>1] & 0xff;
968               }
969               else
970               {
971                  return (DSP1ROM[dsp1_out_idx>>1] >> 8) & 0xff;
972               }
973            }
974         }
975         dsp1_waitcmd = 1;
976//          printf("dsp_r: %02x\n", temp);
977         return temp;
978      }
979      else
980      {
981//          printf("dsp_r: %02x\n", 0xff);
982         return 0xff;   // indicate "no data"
983      }
984   }
985
986   // status register
987//  printf("dsp_r: %02x\n", 0x80);
988   return 0x80;
1355   if (Angle < 0) {
1356      if (Angle == -32768) return -32768;
1357      Angle = -Angle;
1358   }
1359   S = DSP1_SinTable[0x40 + (Angle >> 8)] - (DSP1_MulTable[Angle & 0xff] * DSP1_SinTable[Angle >> 8] >> 15);
1360   if (S < -32768) S = -32767;
1361   return (INT16) S;
9891362}
9901363
991static void dsp1_write(UINT16 address, UINT8 data)
992{
993   // check data vs. status
994   if (((address & 0xf000) == 0x6000) || ((address & 0x7fff) < 0x4000))
995   {
996//      printf("DSP_w: %02x cmd %02x wait %d dsp1_in_cnt %d\n", data, dsp1_cur_cmd, dsp1_waitcmd, dsp1_in_cnt);
1364//////////////////////////////////////////////////////////////////
9971365
998      if (((dsp1_cur_cmd == 0x0a) || (dsp1_cur_cmd == 0x1a)) && (dsp1_out_cnt != 0))
999      {
1000         dsp1_out_cnt--;
1001         dsp1_out_idx++;
1002         return;
1003      }
1004      else if (dsp1_waitcmd)
1005      {
1006         dsp1_cur_cmd = data;
1007         dsp1_in_idx = 0;
1008         dsp1_waitcmd = 0;
1009         dsp1_first_parm = 1;
1010         switch (data)
1011         {
1012            case 0x00: dsp1_in_cnt = 2; break;
1013            case 0x10: case 0x30: dsp1_in_cnt = 2; break;
1014            case 0x20: dsp1_in_cnt = 2; break;
1015            case 0x04: case 0x24: dsp1_in_cnt = 2; break;
1016            case 0x08: dsp1_in_cnt = 3; break;
1017            case 0x18: dsp1_in_cnt = 4; break;
1018            case 0x28: dsp1_in_cnt = 3; break;
1019            case 0x38: dsp1_in_cnt = 4; break;
1020            case 0x0c: case 0x2c: dsp1_in_cnt = 3; break;
1021            case 0x1c: case 0x3c: dsp1_in_cnt = 6; break;
1022            case 0x02: case 0x12: case 0x22: case 0x32: dsp1_in_cnt = 7; break;
1023            case 0x0a: dsp1_in_cnt = 1; break;
1024            case 0x1a: case 0x2a: case 0x3a:  dsp1_cur_cmd = 0x1a; dsp1_in_cnt = 1; break;
1025            case 0x06: case 0x16: case 0x26: case 0x36: dsp1_in_cnt = 3; break;
1026            case 0x0e: case 0x1e: case 0x2e: case 0x3e: dsp1_in_cnt = 2; break;
1027            case 0x01: case 0x05: case 0x31: case 0x35: dsp1_in_cnt = 4; break;
1028            case 0x11: case 0x15: dsp1_in_cnt = 4; break;
1029            case 0x21: case 0x25: dsp1_in_cnt = 4; break;
1030            case 0x0d: case 0x3d: case 0x09: case 0x39: dsp1_in_cnt = 3; break;
1031            case 0x19: case 0x1d: dsp1_in_cnt = 3; break;
1032            case 0x29: case 0x2d: dsp1_in_cnt = 3;   break;
1033            case 0x03: case 0x33: dsp1_in_cnt = 3;   break;
1034            case 0x13: dsp1_in_cnt = 3;   break;
1035            case 0x23: dsp1_in_cnt = 3;   break;
1036            case 0x0b: case 0x3b: dsp1_in_cnt = 3;   break;
1037            case 0x1b: dsp1_in_cnt = 3;   break;
1038            case 0x2b: dsp1_in_cnt = 3;   break;
1039            case 0x14: case 0x34: dsp1_in_cnt = 6;   break;
1040            case 0x07: case 0x0f: dsp1_in_cnt = 1;   break;
1041            case 0x27: case 0x2F: dsp1_in_cnt=1; break;
1042            case 0x17: case 0x37: case 0x3F: dsp1_cur_cmd = 0x1f; dsp1_in_cnt = 1; break;
1043            case 0x1f: dsp1_in_cnt = 1;   break;
1366// Determines the inverse of a floating point decimal number
1367// iCoefficient*2^iExponent = 1/(Coefficient*2^Exponent), with the output
1368// normalized (iCoefficient represents a number whose absolute value is between 1/2 and 1)
1369// To invert 'Coefficient' a first initial guess is taken from a look-up table
1370// and, then, two iterations of the Newton method (applied to the function
1371// f(x)=1/(2*x)-Coefficient) are done. This results in a close approximation (iCoefficient) to a number 'y'
1372// that verify Coefficient*y=1/2. This is why you have to correct the exponent by one
1373// unit at the end.
10441374
1045            case 0x80:
1046               dsp1_in_cnt = 0;
1047               dsp1_waitcmd = 1;
1048               dsp1_first_parm = 1;
1049               break;
1050         }
1375static void inverse(INT16 Coefficient, INT16 Exponent, INT16 *iCoefficient, INT16 *iExponent)
1376{
1377   // Step One: Division by Zero
1378   if (Coefficient == 0x0000)
1379   {
1380      *iCoefficient = 0x7fff;
1381      *iExponent = 0x002f;
1382   }
1383   else
1384   {
1385      INT16 Sign = 1;
10511386
1052         // that gives us parameter lengths in words, convert to bytes
1053         dsp1_in_cnt *= 2;
1054      }
1055      else
1056      {
1057         dsp1_in[dsp1_in_idx++] = data;
1058         dsp1_first_parm = 0;
1059      }
1387      // Step Two: Remove Sign
1388      if (Coefficient < 0)
1389      {
1390         if (Coefficient < -32767) Coefficient = -32767;
1391         Coefficient = -Coefficient;
1392         Sign = -1;
1393      }
10601394
1061      if ((dsp1_waitcmd) || ((dsp1_first_parm) && (data == 0x80)))
1062      {
1063         dsp1_waitcmd = 1;
1064         dsp1_first_parm = 0;
1065      }
1066      else if (((dsp1_first_parm) && (dsp1_in_cnt != 0)) || ((dsp1_in_cnt == 0) && (dsp1_in_idx == 0)))
1067      {
1068      }
1069      else
1070      {
1071         if (dsp1_in_cnt)
1072         {
1073            if (--dsp1_in_cnt == 0)
1074            {
1075               INT16 tr = 0, tr1 = 0, tr2 = 0, tr3 = 0;
1076               INT32 ltr;
1395      // Step Three: Normalize
1396      while (Coefficient < 0x4000)
1397      {
1398         Coefficient <<= 1;
1399         Exponent--;
1400      }
10771401
1078               // time to run the command
1079               dsp1_waitcmd = 1;
1080               dsp1_out_idx = 0;
1081               switch (dsp1_cur_cmd)
1082               {
1083                  case 0x00:
1084                     DSP1_Multiply(dsp1_in[0]|dsp1_in[1]<<8, dsp1_in[2]|dsp1_in[3]<<8, &tr);
1085                     dsp1_out_cnt = 2;
1086                     break;
1402      // Step Four: Special Case
1403      if (Coefficient == 0x4000)
1404         if (Sign == 1) *iCoefficient = 0x7fff;
1405      else  {
1406         *iCoefficient = -0x4000;
1407         Exponent--;
1408      }
1409      else {
1410         // Step Five: Initial Guess
1411         INT16 i = DSP1_DataRom[((Coefficient - 0x4000) >> 7) + 0x0065];
10871412
1088                  case 0x01:
1089                  case 0x05:
1090                  case 0x31:
1091                  case 0x35:
1092                     DSP1_Attitude_A(dsp1_in[0]|dsp1_in[1]<<8, dsp1_in[2]|dsp1_in[3]<<8, dsp1_in[4]|dsp1_in[5]<<8, dsp1_in[6]|dsp1_in[7]<<8);
1093                     dsp1_out_cnt = 0;
1094                     break;
1413         // Step Six: Iterate Newton's Method
1414         i = (i + (-i * (Coefficient * i >> 15) >> 15)) << 1;
1415         i = (i + (-i * (Coefficient * i >> 15) >> 15)) << 1;
10951416
1096                  case 0x02:
1097                  case 0x12:
1098                  case 0x22:
1099                  case 0x32:
1100                     DSP1_Parameter(dsp1_in[0]|dsp1_in[1]<<8, dsp1_in[2]|dsp1_in[3]<<8, dsp1_in[4]|dsp1_in[5]<<8, dsp1_in[6]|dsp1_in[7]<<8,
1101                               dsp1_in[8]|dsp1_in[9]<<8, dsp1_in[10]|dsp1_in[11]<<8, dsp1_in[12]|dsp1_in[13]<<8, &tr, &tr1, &tr2, &tr3);
1102                     dsp1_out_cnt = 8;
1103                     break;
1417         *iCoefficient = i * Sign;
1418      }
11041419
1105                  case 0x03:
1106                  case 0x33:
1107                     DSP1_Subjective_A(dsp1_in[0]|dsp1_in[1]<<8, dsp1_in[2]|dsp1_in[3]<<8, dsp1_in[4]|dsp1_in[5]<<8, &tr, &tr1, &tr2);
1108                     dsp1_out_cnt = 6;
1109                     break;
1420      *iExponent = 1 - Exponent;
1421   }
1422}
11101423
1111                  case 0x04:
1112                  case 0x24:
1113                     DSP1_Triangle(dsp1_in[0]|dsp1_in[1]<<8, dsp1_in[2]|dsp1_in[3]<<8, &tr, &tr1);
1114                     dsp1_out_cnt = 4;
1115                     break;
1424//////////////////////////////////////////////////////////////////
11161425
1117                  case 0x06:
1118                  case 0x16:
1119                  case 0x26:
1120                  case 0x36:
1121                     DSP1_Project(dsp1_in[0]|dsp1_in[1]<<8, dsp1_in[2]|dsp1_in[3]<<8, dsp1_in[4]|dsp1_in[5]<<8, &tr, &tr1, (UINT16 *) &tr2);
1122                            dsp1_out_cnt = 6;
1123                     break;
1426static INT16 denormalizeAndClip(INT16 C, INT16 E)
1427{
1428   if (E > 0) {
1429      if (C > 0) return 32767; else if (C < 0) return -32767;
1430   } else {
1431      if (E < 0) return C * DSP1_DataRom[0x0031 + E] >> 15;
1432   }
1433   return C;
1434}
11241435
1125                  case 0x0a:
1126                  case 0x1a:
1127                  case 0x2a:
1128                  case 0x3a:
1129                     DSP1_Raster(dsp1_in[0]|dsp1_in[1]<<8, &tr, &tr1, &tr2, &tr3);
1130                     dsp1_in[0]++;
1131                     if (dsp1_in[0] == 0) dsp1_in[1]++;
1132                     dsp1_out_cnt = 8;
1133                     dsp1_in_idx = 0;
1134                     break;
1436//////////////////////////////////////////////////////////////////
11351437
1136                  case 0x08:
1137                     DSP1_Radius(dsp1_in[0]|dsp1_in[1]<<8, dsp1_in[2]|dsp1_in[3]<<8, dsp1_in[4]|dsp1_in[5]<<8, &ltr);
1138                     tr = (ltr & 0xffff);
1139                     tr1 = (ltr >> 16) & 0xffff;
1140                     dsp1_out_cnt = 4;
1141                     break;
1438// Normalize the input number (m), understood as ranging from -1 to 1,
1439// to the form: Coefficient*2^Exponent,
1440// where the absolute value of Coefficient is >= 1/2
1441// (Coefficient>=0x4000 or Coefficient <= (INT16)0xc001)
11421442
1143                  case 0x09:
1144                  case 0x0d:
1145                  case 0x39:
1146                  case 0x3d:
1147                     DSP1_Objective_A(dsp1_in[0]|dsp1_in[1]<<8, dsp1_in[2]|dsp1_in[3]<<8, dsp1_in[4]|dsp1_in[5]<<8, &tr, &tr1, &tr2);
1148                     dsp1_out_cnt = 6;
1149                     break;
1443static void normalize(INT16 m, INT16 *Coefficient, INT16 *Exponent)
1444{
1445   INT16 i = 0x4000;
1446   INT16 e = 0;
11501447
1151                  case 0x0b:
1152                  case 0x3b:
1153                     DSP1_Scalar_A(dsp1_in[0]|dsp1_in[1]<<8, dsp1_in[2]|dsp1_in[3]<<8, dsp1_in[4]|dsp1_in[5]<<8, &tr);
1154                     dsp1_out_cnt = 2;
1155                     break;
1448   if (m < 0)
1449      while ((m & i) && i)
1450   {
1451      i >>= 1;
1452      e++;
1453   }
1454   else
1455      while (!(m & i) && i)
1456   {
1457      i >>= 1;
1458      e++;
1459   }
11561460
1157                  case 0x0c:
1158                  case 0x2c:
1159                     DSP1_Rotate(dsp1_in[0]|dsp1_in[1]<<8, dsp1_in[2]|dsp1_in[3]<<8, dsp1_in[4]|dsp1_in[5]<<8, &tr, &tr1);
1160                     dsp1_out_cnt = 4;
1161                     break;
1461   if (e > 0)
1462      *Coefficient = m * DSP1_DataRom[0x21 + e] << 1;
1463   else
1464      *Coefficient = m;
11621465
1163                  case 0x0e:
1164                  case 0x1e:
1165                  case 0x2e:
1166                  case 0x3e:
1167                     DSP1_Target(dsp1_in[0]|dsp1_in[1]<<8, dsp1_in[2]|dsp1_in[3]<<8, &tr, &tr1);
1168                     dsp1_out_cnt = 4;
1169                     break;
1466   *Exponent -= e;
1467}
11701468
1171                  case 0x07:
1172                  case 0x0f:
1173                     DSP1_MemoryTest(dsp1_in[0]|dsp1_in[1]<<8, &tr);
1174                     dsp1_out_cnt = 2;
1175                     break;
1469//////////////////////////////////////////////////////////////////
11761470
1177                  case 0x10:
1178                  case 0x30:
1179                     DSP1_Inverse(dsp1_in[0]|dsp1_in[1]<<8, dsp1_in[2]|dsp1_in[3]<<8, &tr, &tr1);
1180                     dsp1_out_cnt = 4;
1181                     break;
1471// Same than 'normalize' but with an INT32 input
11821472
1183                  case 0x11:
1184                  case 0x15:
1185                     DSP1_Attitude_B(dsp1_in[0]|dsp1_in[1]<<8, dsp1_in[2]|dsp1_in[3]<<8, dsp1_in[4]|dsp1_in[5]<<8, dsp1_in[6]|dsp1_in[7]<<8);
1186                     dsp1_out_cnt = 0;
1187                     break;
1473static void normalizeDouble(INT32 Product, INT16 *Coefficient, INT16 *Exponent)
1474{
1475   INT16 n = Product & 0x7fff;
1476   INT16 m = Product >> 15;
1477   INT16 i = 0x4000;
1478   INT16 e = 0;
11881479
1189                  case 0x13:
1190                     DSP1_Subjective_B(dsp1_in[0]|dsp1_in[1]<<8, dsp1_in[2]|dsp1_in[3]<<8, dsp1_in[4]|dsp1_in[5]<<8, &tr, &tr1, &tr2);
1191                     dsp1_out_cnt = 6;
1192                     break;
1480   if (m < 0)
1481      while ((m & i) && i)
1482   {
1483      i >>= 1;
1484      e++;
1485   }
1486   else
1487      while (!(m & i) && i)
1488   {
1489      i >>= 1;
1490      e++;
1491   }
11931492
1194                  case 0x14:
1195                  case 0x34:
1196                     DSP1_Gyrate(dsp1_in[0]|dsp1_in[1]<<8, dsp1_in[2]|dsp1_in[3]<<8, dsp1_in[4]|dsp1_in[5]<<8, dsp1_in[6]|dsp1_in[7]<<8,
1197                               dsp1_in[8]|dsp1_in[9]<<8, dsp1_in[10]|dsp1_in[11]<<8, &tr, &tr1, &tr2);
1198                     dsp1_out_cnt = 6;
1199                     break;
1493   if (e > 0)
1494   {
1495      *Coefficient = m * DSP1_DataRom[0x0021 + e] << 1;
12001496
1201                  case 0x18:
1202                     DSP1_Range(dsp1_in[0]|dsp1_in[1]<<8, dsp1_in[2]|dsp1_in[3]<<8, dsp1_in[4]|dsp1_in[5]<<8, dsp1_in[6]|dsp1_in[7]<<8, &tr);
1203                     dsp1_out_cnt = 2;
1204                     break;
1497      if (e < 15)
1498         *Coefficient += n * DSP1_DataRom[0x0040 - e] >> 15;
1499      else
1500      {
1501         i = 0x4000;
12051502
1206                  case 0x19:
1207                  case 0x1d:
1208                     DSP1_Objective_B(dsp1_in[0]|dsp1_in[1]<<8, dsp1_in[2]|dsp1_in[3]<<8, dsp1_in[4]|dsp1_in[5]<<8, &tr, &tr1, &tr2);
1209                     dsp1_out_cnt = 6;
1210                     break;
1503         if (m < 0)
1504            while ((n & i) && i)
1505         {
1506            i >>= 1;
1507            e++;
1508         }
1509         else
1510            while (!(n & i) && i)
1511         {
1512            i >>= 1;
1513            e++;
1514         }
12111515
1212                  case 0x1b:
1213                     DSP1_Scalar_B(dsp1_in[0]|dsp1_in[1]<<8, dsp1_in[2]|dsp1_in[3]<<8, dsp1_in[4]|dsp1_in[5]<<8, &tr);
1214                     dsp1_out_cnt = 2;
1215                     break;
1516         if (e > 15)
1517            *Coefficient = n * DSP1_DataRom[0x0012 + e] << 1;
1518         else
1519            *Coefficient += n;
1520      }
1521   }
1522   else
1523      *Coefficient = m;
12161524
1217                  case 0x1f:
1218                     dsp1_out_cnt = 2048;
1219                     break;
1525   *Exponent = e;
1526}
12201527
1221                  case 0x23:
1222                     DSP1_Subjective_C(dsp1_in[0]|dsp1_in[1]<<8, dsp1_in[2]|dsp1_in[3]<<8, dsp1_in[4]|dsp1_in[5]<<8, &tr, &tr1, &tr2);
1223                     dsp1_out_cnt = 6;
1224                     break;
1528//////////////////////////////////////////////////////////////////
12251529
1226                  case 0x28:
1227                     DSP1_Distance(dsp1_in[0]|dsp1_in[1]<<8, dsp1_in[2]|dsp1_in[3]<<8, dsp1_in[4]|dsp1_in[5]<<8, &tr);
1228                     dsp1_out_cnt = 2;
1229                     break;
1530// Shift to the right
12301531
1231                  case 0x29:
1232                  case 0x2d:
1233                     DSP1_Objective_C(dsp1_in[0]|dsp1_in[1]<<8, dsp1_in[2]|dsp1_in[3]<<8, dsp1_in[4]|dsp1_in[5]<<8, &tr, &tr1, &tr2);
1234                     dsp1_out_cnt = 6;
1235                     break;
1532static INT16 shiftR(INT16 C, INT16 E)
1533{
1534   return (C * DSP1_DataRom[0x0031 + E] >> 15);
1535}
12361536
1237                  case 0x2b:
1238                     DSP1_Scalar_C(dsp1_in[0]|dsp1_in[1]<<8, dsp1_in[2]|dsp1_in[3]<<8, dsp1_in[4]|dsp1_in[5]<<8, &tr);
1239                     dsp1_out_cnt = 2;
1240                     break;
1537//////////////////////////////////////////////////////////////////
12411538
1242                  case 0x27:
1243                  case 0x2f:
1244                     DSP1_MemorySize(&tr);
1245                     dsp1_out_cnt = 2;
1246                     break;
1539static const INT16 DSP1_SinTable[256] = {
1540   0x0000,  0x0324,  0x0647,  0x096a,  0x0c8b,  0x0fab,  0x12c8,  0x15e2,
1541   0x18f8,  0x1c0b,  0x1f19,  0x2223,  0x2528,  0x2826,  0x2b1f,  0x2e11,
1542   0x30fb,  0x33de,  0x36ba,  0x398c,  0x3c56,  0x3f17,  0x41ce,  0x447a,
1543   0x471c,  0x49b4,  0x4c3f,  0x4ebf,  0x5133,  0x539b,  0x55f5,  0x5842,
1544   0x5a82,  0x5cb4,  0x5ed7,  0x60ec,  0x62f2,  0x64e8,  0x66cf,  0x68a6,
1545   0x6a6d,  0x6c24,  0x6dca,  0x6f5f,  0x70e2,  0x7255,  0x73b5,  0x7504,
1546   0x7641,  0x776c,  0x7884,  0x798a,  0x7a7d,  0x7b5d,  0x7c29,  0x7ce3,
1547   0x7d8a,  0x7e1d,  0x7e9d,  0x7f09,  0x7f62,  0x7fa7,  0x7fd8,  0x7ff6,
1548   0x7fff,  0x7ff6,  0x7fd8,  0x7fa7,  0x7f62,  0x7f09,  0x7e9d,  0x7e1d,
1549   0x7d8a,  0x7ce3,  0x7c29,  0x7b5d,  0x7a7d,  0x798a,  0x7884,  0x776c,
1550   0x7641,  0x7504,  0x73b5,  0x7255,  0x70e2,  0x6f5f,  0x6dca,  0x6c24,
1551   0x6a6d,  0x68a6,  0x66cf,  0x64e8,  0x62f2,  0x60ec,  0x5ed7,  0x5cb4,
1552   0x5a82,  0x5842,  0x55f5,  0x539b,  0x5133,  0x4ebf,  0x4c3f,  0x49b4,
1553   0x471c,  0x447a,  0x41ce,  0x3f17,  0x3c56,  0x398c,  0x36ba,  0x33de,
1554   0x30fb,  0x2e11,  0x2b1f,  0x2826,  0x2528,  0x2223,  0x1f19,  0x1c0b,
1555   0x18f8,  0x15e2,  0x12c8,  0x0fab,  0x0c8b,  0x096a,  0x0647,  0x0324,
1556   -0x0000, -0x0324, -0x0647, -0x096a, -0x0c8b, -0x0fab, -0x12c8, -0x15e2,
1557   -0x18f8, -0x1c0b, -0x1f19, -0x2223, -0x2528, -0x2826, -0x2b1f, -0x2e11,
1558   -0x30fb, -0x33de, -0x36ba, -0x398c, -0x3c56, -0x3f17, -0x41ce, -0x447a,
1559   -0x471c, -0x49b4, -0x4c3f, -0x4ebf, -0x5133, -0x539b, -0x55f5, -0x5842,
1560   -0x5a82, -0x5cb4, -0x5ed7, -0x60ec, -0x62f2, -0x64e8, -0x66cf, -0x68a6,
1561   -0x6a6d, -0x6c24, -0x6dca, -0x6f5f, -0x70e2, -0x7255, -0x73b5, -0x7504,
1562   -0x7641, -0x776c, -0x7884, -0x798a, -0x7a7d, -0x7b5d, -0x7c29, -0x7ce3,
1563   -0x7d8a, -0x7e1d, -0x7e9d, -0x7f09, -0x7f62, -0x7fa7, -0x7fd8, -0x7ff6,
1564   -0x7fff, -0x7ff6, -0x7fd8, -0x7fa7, -0x7f62, -0x7f09, -0x7e9d, -0x7e1d,
1565   -0x7d8a, -0x7ce3, -0x7c29, -0x7b5d, -0x7a7d, -0x798a, -0x7884, -0x776c,
1566   -0x7641, -0x7504, -0x73b5, -0x7255, -0x70e2, -0x6f5f, -0x6dca, -0x6c24,
1567   -0x6a6d, -0x68a6, -0x66cf, -0x64e8, -0x62f2, -0x60ec, -0x5ed7, -0x5cb4,
1568   -0x5a82, -0x5842, -0x55f5, -0x539b, -0x5133, -0x4ebf, -0x4c3f, -0x49b4,
1569   -0x471c, -0x447a, -0x41ce, -0x3f17, -0x3c56, -0x398c, -0x36ba, -0x33de,
1570   -0x30fb, -0x2e11, -0x2b1f, -0x2826, -0x2528, -0x2223, -0x1f19, -0x1c0b,
1571   -0x18f8, -0x15e2, -0x12c8, -0x0fab, -0x0c8b, -0x096a, -0x0647, -0x0324};
12471572
1248                  default:
1249                     printf("Unhandled DSP1 command: %02x\n", dsp1_cur_cmd);
1250                     break;
1573   //////////////////////////////////////////////////////////////////
12511574
1252               }
1575// Optimised for Performance
1576static const INT16 DSP1_MulTable[256] = {
1577      0x0000,  0x0003,  0x0006,  0x0009,  0x000c,  0x000f,  0x0012,  0x0015,
1578      0x0019,  0x001c,  0x001f,  0x0022,  0x0025,  0x0028,  0x002b,  0x002f,
1579      0x0032,  0x0035,  0x0038,  0x003b,  0x003e,  0x0041,  0x0045,  0x0048,
1580      0x004b,  0x004e,  0x0051,  0x0054,  0x0057,  0x005b,  0x005e,  0x0061,
1581      0x0064,  0x0067,  0x006a,  0x006d,  0x0071,  0x0074,  0x0077,  0x007a,
1582      0x007d,  0x0080,  0x0083,  0x0087,  0x008a,  0x008d,  0x0090,  0x0093,
1583      0x0096,  0x0099,  0x009d,  0x00a0,  0x00a3,  0x00a6,  0x00a9,  0x00ac,
1584      0x00af,  0x00b3,  0x00b6,  0x00b9,  0x00bc,  0x00bf,  0x00c2,  0x00c5,
1585      0x00c9,  0x00cc,  0x00cf,  0x00d2,  0x00d5,  0x00d8,  0x00db,  0x00df,
1586      0x00e2,  0x00e5,  0x00e8,  0x00eb,  0x00ee,  0x00f1,  0x00f5,  0x00f8,
1587      0x00fb,  0x00fe,  0x0101,  0x0104,  0x0107,  0x010b,  0x010e,  0x0111,
1588      0x0114,  0x0117,  0x011a,  0x011d,  0x0121,  0x0124,  0x0127,  0x012a,
1589      0x012d,  0x0130,  0x0133,  0x0137,  0x013a,  0x013d,  0x0140,  0x0143,
1590      0x0146,  0x0149,  0x014d,  0x0150,  0x0153,  0x0156,  0x0159,  0x015c,
1591      0x015f,  0x0163,  0x0166,  0x0169,  0x016c,  0x016f,  0x0172,  0x0175,
1592      0x0178,  0x017c,  0x017f,  0x0182,  0x0185,  0x0188,  0x018b,  0x018e,
1593      0x0192,  0x0195,  0x0198,  0x019b,  0x019e,  0x01a1,  0x01a4,  0x01a8,
1594      0x01ab,  0x01ae,  0x01b1,  0x01b4,  0x01b7,  0x01ba,  0x01be,  0x01c1,
1595      0x01c4,  0x01c7,  0x01ca,  0x01cd,  0x01d0,  0x01d4,  0x01d7,  0x01da,
1596      0x01dd,  0x01e0,  0x01e3,  0x01e6,  0x01ea,  0x01ed,  0x01f0,  0x01f3,
1597      0x01f6,  0x01f9,  0x01fc,  0x0200,  0x0203,  0x0206,  0x0209,  0x020c,
1598      0x020f,  0x0212,  0x0216,  0x0219,  0x021c,  0x021f,  0x0222,  0x0225,
1599      0x0228,  0x022c,  0x022f,  0x0232,  0x0235,  0x0238,  0x023b,  0x023e,
1600      0x0242,  0x0245,  0x0248,  0x024b,  0x024e,  0x0251,  0x0254,  0x0258,
1601      0x025b,  0x025e,  0x0261,  0x0264,  0x0267,  0x026a,  0x026e,  0x0271,
1602      0x0274,  0x0277,  0x027a,  0x027d,  0x0280,  0x0284,  0x0287,  0x028a,
1603      0x028d,  0x0290,  0x0293,  0x0296,  0x029a,  0x029d,  0x02a0,  0x02a3,
1604      0x02a6,  0x02a9,  0x02ac,  0x02b0,  0x02b3,  0x02b6,  0x02b9,  0x02bc,
1605      0x02bf,  0x02c2,  0x02c6,  0x02c9,  0x02cc,  0x02cf,  0x02d2,  0x02d5,
1606      0x02d8,  0x02db,  0x02df,  0x02e2,  0x02e5,  0x02e8,  0x02eb,  0x02ee,
1607      0x02f1,  0x02f5,  0x02f8,  0x02fb,  0x02fe,  0x0301,  0x0304,  0x0307,
1608      0x030b,  0x030e,  0x0311,  0x0314,  0x0317,  0x031a,  0x031d,  0x0321};
12531609
1254               // copy up to 8 bytes of result into the buffer
1255               dsp1_out[0] = tr&0xff;
1256               dsp1_out[1] = (tr>>8)&0xff;
1257               dsp1_out[2] = tr1&0xff;
1258               dsp1_out[3] = (tr1>>8)&0xff;
1259               dsp1_out[4] = tr2&0xff;
1260               dsp1_out[5] = (tr2>>8)&0xff;
1261               dsp1_out[6] = tr3&0xff;
1262               dsp1_out[7] = (tr3>>8)&0xff;
1263            }
1264         }
1265      }
1266   }
1267}
1610//////////////////////////////////////////////////////////////////
12681611
1612// Data ROM, as logged from a DSP-1B with the 0x1f command;
1613// it contains the tables and constants used by the commands.
1614// The tables used are: two shift tables (0x022-0x031 and 0x031-0x040 -this last one
1615// with an error in 0x03c which has survived to all the DSP-1 revisions-); a inverse
1616// table (used as initial guess) at 0x065-0x0e4; a square root table (used also
1617// as initial guess) at 0x0e5-0x115; two sin and cos tables (used as nodes to construct
1618// a interpolation curve) at, respectively, 0x116-0x197 and 0x196-0x215.
1619// As a curiosity, in the positions 0x21c-0x31c it's contained a
1620// 257-points arccos table that, apparently, have been not used anywhere
1621// (maybe for the MaxAZS_Exp table?).
1622static UINT16 DSP1_DataRom[1024];
src/mame/machine/psx.c
r1478r1479
1313
1414#define VERBOSE_LEVEL ( 0 )
1515
16INLINE void verboselog( int n_level, const char *s_fmt, ... )
16INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
1717{
1818   if( VERBOSE_LEVEL >= n_level )
1919   {
r1478r1479
726726      if( m_p_n_sio_baud[ n_port ] != 0 && n_prescaler != 0 )
727727      {
728728         n_time = attotime_mul(ATTOTIME_IN_HZ(33868800), n_prescaler * m_p_n_sio_baud[n_port]);
729         verboselog( 2, "sio_timer_adjust( %d ) = %f ( %d x %d )\n", n_port, n_time, n_prescaler, m_p_n_sio_baud[ n_port ] );
729         verboselog( 2, "sio_timer_adjust( %d ) = %s ( %d x %d )\n", n_port, attotime_string(n_time, 9), n_prescaler, m_p_n_sio_baud[ n_port ] );
730730      }
731731      else
732732      {
src/mame/mamedriv.c
r1478r1479
42084208   DRIVER( gatedoom )   /* MAC (c) 1990 Data East Corporation (US) */
42094209   DRIVER( gatedom1 )   /* MAC (c) 1990 Data East Corporation (US) */
42104210   DRIVER( edrandy )   /* MAD (c) 1990 Data East Corporation (World) */
4211   DRIVER( edrandy2 )   /* MAD (c) 1990 Data East Corporation (World) */
42114212   DRIVER( edrandy1 )   /* MAD (c) 1990 Data East Corporation (World) */
4212   DRIVER( edrandy0 )   /* MAD (c) 1990 Data East Corporation (World) */
42134213   DRIVER( edrandyj )   /* MAD (c) 1990 Data East Corporation (Japan) */
42144214   DRIVER( supbtime )   /* MAE (c) 1990 Data East Corporation (World) */
42154215   DRIVER( supbtima )   /* MAE (c) 1990 Data East Corporation (World) */
42164216   DRIVER( supbtimj )   /* MAE (c) 1990 Data East Corporation (Japan) */
42174217   DRIVER( mutantf )   /* MAF (c) 1992 Data East Corporation (World) */
4218   DRIVER( mutantfa )   /* MAF (c) 1992 Data East Corporation (World) */
4218   DRIVER( mutantf4 )   /* MAF (c) 1992 Data East Corporation (World) */
4219   DRIVER( mutantf3 )   /* MAF (c) 1992 Data East Corporation (World) */
42194220   DRIVER( deathbrd )   /* MAF (c) 1992 Data East Corporation (Japan) */
42204221   DRIVER( cninja )   /* MAG (c) 1991 Data East Corporation (World) */
4221   DRIVER( cninja0 )   /* MAG (c) 1991 Data East Corporation (World) */
4222   DRIVER( cninja1 )   /* MAG (c) 1991 Data East Corporation (World) */
42224223   DRIVER( cninjau )   /* MAG (c) 1991 Data East Corporation (US) */
42234224   DRIVER( joemac )   /* MAG (c) 1991 Data East Corporation (Japan) */
42244225   DRIVER( stoneage )   /* bootleg */
r1478r1479
45554556   DRIVER( simps4pa )   /* GX072 (c) 1991 */
45564557   DRIVER( simpsn2p )   /* GX072 (c) 1991 */
45574558   DRIVER( simps2pa )   /* GX072 (c) 1991 */
4559   DRIVER( simp2pa )   /* GX072 (c) 1991 (Asia) */
45584560   DRIVER( simps2pj )   /* GX072 (c) 1991 (Japan) */
45594561   DRIVER( esckids )   /* GX975 (c) 1991 (Asia) */
45604562   DRIVER( esckidsj )   /* GX975 (c) 1991 (Japan) */
src/mame/includes/dc.h
r1478r1479
2828
2929MACHINE_RESET( dc );
3030
31void dc_vblank( void );
32
3133/*----------- defined in video/dc.c -----------*/
3234
3335READ64_HANDLER( pvr_ctrl_r );
src/mame/includes/midzeus.h
r1478r1479
44
55**************************************************************************/
66
7#define MIDZEUS_VIDEO_CLOCK      66000000
7#define MIDZEUS_VIDEO_CLOCK      XTAL_66_6667MHz
88
99
1010/*----------- defined in video/midzeus.c -----------*/
src/mame/includes/mario.h
r0r1479
1#ifndef MARIO_H_
2#define MARIO_H_
3
4/*
5 * From the schematics:
6 *
7 * Video generation like dkong/dkongjr. However, clock is 24MHZ
8 * 7C -> 100 => 256 - 124 = 132 ==> 264 Scanlines
9 */
10
11#define MASTER_CLOCK          XTAL_24MHz
12#define PIXEL_CLOCK            (MASTER_CLOCK / 4)
13#define CLOCK_1H            (MASTER_CLOCK / 8)
14#define CLOCK_16H            (CLOCK_1H / 16)
15#define CLOCK_1VF            ((CLOCK_16H) / 12 / 2)
16#define CLOCK_2VF            ((CLOCK_1VF) / 2)
17
18#define HTOTAL               (384)
19#define HBSTART               (256)
20#define HBEND               (0)
21#define VTOTAL               (264)
22#define VBSTART               (240)
23#define VBEND               (16)
24
25#define Z80_MASTER_CLOCK      XTAL_8MHz
26#define Z80_CLOCK            (Z80_MASTER_CLOCK / 2) /* verified on pcb */
27
28#define I8035_MASTER_CLOCK      XTAL_11MHz /* verified on pcb: 730Khz */
29#define I8035_DIVIDER         (15)
30#define I8035_CLOCK            (I8035_MASTER_CLOCK/I8035_DIVIDER)
31
32#define MARIO_PALETTE_LENGTH   (256)
33
34typedef struct _mario_state mario_state;
35struct _mario_state
36{
37   /* memory pointers */
38
39   /* machine states */
40
41   /* sound state */
42
43   /* video state */
44
45   /* Save state relevant */
46
47   UINT8 dummy;   /* structs need to have something */
48};
49
50/*----------- defined in video/mario.c -----------*/
51
52WRITE8_HANDLER( mario_videoram_w );
53WRITE8_HANDLER( mario_gfxbank_w );
54WRITE8_HANDLER( mario_palettebank_w );
55WRITE8_HANDLER( mario_scroll_w );
56
57PALETTE_INIT( mario );
58VIDEO_START( mario );
59VIDEO_UPDATE( mario );
60
61
62/*----------- defined in audio/mario.c -----------*/
63
64WRITE8_HANDLER( mario_sh_w );
65WRITE8_HANDLER( mario_sh1_w );
66WRITE8_HANDLER( mario_sh2_w );
67WRITE8_HANDLER( mario_sh3_w );
68
69WRITE8_HANDLER( mario_sh_getcoin_w );
70WRITE8_HANDLER( mario_sh_crab_w );
71WRITE8_HANDLER( mario_sh_turtle_w );
72WRITE8_HANDLER( mario_sh_fly_w );
73WRITE8_HANDLER( mario_sh_tuneselect_w );
74WRITE8_HANDLER( masao_sh_irqtrigger_w );
75
76MACHINE_DRIVER_EXTERN( mario_audio );
77MACHINE_DRIVER_EXTERN( masao_audio );
78
79#endif /*MARIO_H_*/
src/mame/mame.mak
r1478r1479
492492   $(DRIVERS)/rampart.o $(VIDEO)/rampart.o \
493493   $(DRIVERS)/relief.o $(VIDEO)/relief.o \
494494   $(DRIVERS)/runaway.o $(VIDEO)/runaway.o \
495   $(DRIVERS)/sbrkout.o $(MACHINE)/sbrkout.o $(VIDEO)/sbrkout.o \
495   $(DRIVERS)/sbrkout.o \
496496   $(DRIVERS)/shuuz.o $(VIDEO)/shuuz.o \
497497   $(DRIVERS)/skullxbo.o $(VIDEO)/skullxbo.o \
498498   $(DRIVERS)/skydiver.o $(AUDIO)/skydiver.o $(VIDEO)/skydiver.o \
r1478r1479
16811681$(DRIVERS)/meadows.o:   $(LAYOUT)/deadeye.lh \
16821682                  $(LAYOUT)/gypsyjug.lh
16831683
1684$(DRIVERS)/midzeus.o:   $(LAYOUT)/crusnexo.lh
1685
16841686$(DRIVERS)/nbmj8688.o:   $(LAYOUT)/nbmj8688.lh
16851687
16861688$(DRIVERS)/peplus.o:   $(LAYOUT)/peplus.lh \
src/mame/video/psx.c
r1478r1479
2525
2626#define VERBOSE_LEVEL ( 0 )
2727
28INLINE void verboselog( int n_level, const char *s_fmt, ... )
28INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
2929{
3030   if( VERBOSE_LEVEL >= n_level )
3131   {
src/mame/video/flstory.c
r1478r1479
109109
110110}
111111
112READ8_HANDLER( victnine_gfxctrl_r )
113{
114   return gfxctrl;
115}
116
112117WRITE8_HANDLER( victnine_gfxctrl_w )
113118{
114119   if (gfxctrl == data)
r1478r1479
127132
128133}
129134
130#ifdef UNUSED_FUNCTION
131READ8_HANDLER( flstory_scrlram_r )
132{
133   return flstory_scrlram[offset];
134}
135#endif
136
137135WRITE8_HANDLER( flstory_scrlram_w )
138136{
139137   flstory_scrlram[offset] = data;
src/mame/video/dc.c
r1478r1479
66#include "driver.h"
77#include "dc.h"
88
9#define DEBUG_PVRCTRL (1)
10#define DEBUG_PVRTA   (1)
11
12static UINT32 pvrctrl_regs[0x100/4];
13static UINT32 pvrta_regs[0x2000/4];
14
915VIDEO_START(dc)
1016{
17   memset(pvrctrl_regs, 0, sizeof(pvrctrl_regs));
18   memset(pvrta_regs, 0, sizeof(pvrta_regs));
19
20   pvrta_regs[0] = 0x17fd11db;   // vendor and device ID of HOLLY chip
21   pvrta_regs[1] = 1;      // chip revision
1122}
1223
1324VIDEO_UPDATE(dc)
1425{
26   dc_vblank();
27
1528   return 0;
1629}
1730
31// register decode helper
32
33INLINE int decode_reg_64(UINT32 offset, UINT64 mem_mask, UINT64 *shift)
34{
35   int reg = offset * 2;
36
37   *shift = 0;
38
39   if (mem_mask == U64(0x00000000ffffffff))
40   {
41      reg++;
42      *shift = 32;
43    }
44
45   return reg;
46}
47
1848READ64_HANDLER( pvr_ctrl_r )
1949{
20   return 0;
50   int reg;
51   UINT64 shift;
52
53   reg = decode_reg_64(offset, mem_mask, &shift);
54
55   #if DEBUG_PVRCTRL
56   mame_printf_verbose("PVRCTRL: read %x @ %x (reg %x), mask %llx (PC=%x)\n", pvrctrl_regs[reg], offset, reg, mem_mask, activecpu_get_pc());
57   #endif
58
59   return (UINT64)pvrctrl_regs[reg] << shift;
2160}
2261
2362WRITE64_HANDLER( pvr_ctrl_w )
2463{
25   mame_printf_verbose("PVRCTRL: write %llx to %x, mask %llx\n", data, offset, mem_mask);
64   int reg;
65   UINT64 shift;
66
67   reg = decode_reg_64(offset, mem_mask, &shift);
68
69   #if DEBUG_PVRCTRL
70   mame_printf_verbose("PVRCTRL: write %llx to %x (reg %x), mask %llx\n", data>>shift, offset, reg, mem_mask);
71   #endif
72
73   pvrctrl_regs[reg] |= data >> shift;
2674}
2775
2876READ64_HANDLER( pvr_ta_r )
2977{
30   return 0;
78   int reg;
79   UINT64 shift;
80
81   reg = decode_reg_64(offset, mem_mask, &shift);
82
83   #if DEBUG_PVRTA
84   mame_printf_verbose("PVRTA: read %x @ %x (reg %x), mask %llx (PC=%x)\n", pvrta_regs[reg], offset, reg, mem_mask, activecpu_get_pc());
85   #endif
86
87   return (UINT64)pvrta_regs[reg] << shift;
3188}
3289
3390WRITE64_HANDLER( pvr_ta_w )
3491{
35   mame_printf_verbose("PVR TA: write %llx to %x, mask %llx\n", data, offset, mem_mask);
92   int reg;
93   UINT64 shift;
94
95   reg = decode_reg_64(offset, mem_mask, &shift);
96
97   #if DEBUG_PVRTA
98   mame_printf_verbose("PVRTA: write %llx to %x (reg %x %x), mask %llx\n", data>>shift, offset, reg, (reg*4)+0x8000, mem_mask);
99   #endif
100
101   pvrta_regs[reg] |= data >> shift;
36102}
37103
38104
r1478r1479
45111{
46112   mame_printf_verbose("YUV FIFO: write %llx to %x, mask %llx\n", data, offset, mem_mask);
47113}
48
src/mame/video/btoads.c
r1478r1479
2929
3030static UINT8 *vram_fg_draw, *vram_fg_display;
3131
32static int xscroll0, yscroll0;
33static int xscroll1, yscroll1;
34static int screen_control;
32static INT32 xscroll0, yscroll0;
33static INT32 xscroll1, yscroll1;
34static UINT8 screen_control;
3535
3636static UINT16 sprite_source_offs;
3737static UINT8 *sprite_dest_base;
r1478r1479
5252   /* initialize the swapped pointers */
5353   vram_fg_draw = (UINT8 *)btoads_vram_fg0;
5454   vram_fg_display = (UINT8 *)btoads_vram_fg1;
55
56   state_save_register_global(xscroll0);
57   state_save_register_global(xscroll1);
58   state_save_register_global(yscroll0);
59   state_save_register_global(yscroll1);
60   state_save_register_global(screen_control);
61
62   state_save_register_global(sprite_source_offs);
63   state_save_register_global(sprite_dest_offs);
64   state_save_register_global(misc_control);
5565}
5666
5767
r1478r1479
341351   int coladdr = fulladdr & 0x3ff;
342352   int x;
343353
354   if (BT_DEBUG)
355      popmessage("screen_control = %02X", screen_control);
356
344357   /* for each scanline, switch off the render mode */
345358   switch (screen_control & 3)
346359   {
347360      /* mode 0: used in ship level, snake boss, title screen (free play) */
361      /* priority is:
362            1. BG1 pixels with the high bit set
363            2. Sprites
364            3. BG1
365            4. BG0
366        */
348367      case 0:
349
350      /* mode 2: used in EOA screen, jetpack level, first level, high score screen */
351      case 2:
352368         for (x = params->heblnk; x < params->hsblnk; x += 2, coladdr++)
353369         {
370            UINT16 bg0pix = bg0_base[(coladdr + xscroll0) & 0xff];
371            UINT16 bg1pix = bg1_base[(coladdr + xscroll1) & 0xff];
354372            UINT8 sprpix = spr_base[coladdr & 0xff];
355373
356            if (sprpix)
357            {
374            if (bg1pix & 0x80)
375               dst[x + 0] = bg1pix & 0xff;
376            else if (sprpix)
358377               dst[x + 0] = sprpix;
378            else if (bg1pix & 0xff)
379               dst[x + 0] = bg1pix & 0xff;
380            else
381               dst[x + 0] = bg0pix & 0xff;
382
383            if (bg1pix & 0x8000)
384               dst[x + 1] = bg1pix >> 8;
385            else if (sprpix)
359386               dst[x + 1] = sprpix;
360            }
387            else if (bg1pix >> 8)
388               dst[x + 1] = bg1pix >> 8;
361389            else
362            {
363               UINT16 bg0pix = bg0_base[(coladdr + xscroll0) & 0xff];
364               UINT16 bg1pix = bg1_base[(coladdr + xscroll1) & 0xff];
365
366               if (bg1pix & 0xff)
367                  dst[x + 0] = bg1pix & 0xff;
368               else
369                  dst[x + 0] = bg0pix & 0xff;
370
371               if (bg1pix >> 8)
372                  dst[x + 1] = bg1pix >> 8;
373               else
374                  dst[x + 1] = bg0pix >> 8;
375            }
390               dst[x + 1] = bg0pix >> 8;
376391         }
377392         break;
378393
379394      /* mode 1: used in snow level, title screen (free play), top part of rolling ball level */
395      /* priority is:
396            1. Sprite pixels with high bit clear
397            2. BG0
398            3. BG1 pixels with high bit set
399            4. Sprite pixels with high bit set
400            5. BG1
401        */
380402      case 1:
381403         for (x = params->heblnk; x < params->hsblnk; x += 2, coladdr++)
382404         {
r1478r1479
413435         }
414436         break;
415437
438      /* mode 2: used in EOA screen, jetpack level, first level, high score screen */
439      /* priority is:
440            1. Sprites
441            2. BG1
442            3. BG0
443        */
444      case 2:
445         for (x = params->heblnk; x < params->hsblnk; x += 2, coladdr++)
446         {
447            UINT8 sprpix = spr_base[coladdr & 0xff];
448
449            if (sprpix)
450            {
451               dst[x + 0] = sprpix;
452               dst[x + 1] = sprpix;
453            }
454            else
455            {
456               UINT16 bg0pix = bg0_base[(coladdr + xscroll0) & 0xff];
457               UINT16 bg1pix = bg1_base[(coladdr + xscroll1) & 0xff];
458
459               if (bg1pix & 0xff)
460                  dst[x + 0] = bg1pix & 0xff;
461               else
462                  dst[x + 0] = bg0pix & 0xff;
463
464               if (bg1pix >> 8)
465                  dst[x + 1] = bg1pix >> 8;
466               else
467                  dst[x + 1] = bg0pix >> 8;
468            }
469         }
470         break;
471
416472      /* mode 3: used in toilet level, toad intros, bottom of rolling ball level */
473      /* priority is:
474            1. BG1 pixels with the high bit set
475            2. Sprite pixels with the high bit set
476            3. BG1
477            4. Sprites
478            5. BG0
479        */
417480      case 3:
418481         for (x = params->heblnk; x < params->hsblnk; x += 2, coladdr++)
419482         {
src/mame/video/liberate.c
r1478r1479
190190   {
191191      int multi,fx,fy,sx,sy,sy2,code,color;
192192
193      code = spriteram[offs+1] + ( ( spriteram[offs+0] & 0x60 ) << 3 );
194      sx = (240 - spriteram[offs+3]);
195   //if (sx < -7) sx += 256;
193      /*
194            Byte 0: 0x01 - ?
195                    0x02 - Y flip
196                    0x04 - X flip
197                    0x08 - Colour?
198                    0x10 - Multi sprite set
199                    0x60 - Tile (high bits)
200                    0x80 - ?
201            Byte 1: 0xff - Tile (low bits)
202            Byte 2: 0xff - Y position
203            Byte 3: 0xff - X position
204        */
196205
197      sy = 240-spriteram[offs+2];
198      color = 0;//(spriteram[offs+1] & 0x03);// + ((spriteram[offs+1] & 0x08) >> 1);
206      code = spriteram[offs+1] + ((spriteram[offs+0] & 0x60) << 3);
207      sx = 240 - spriteram[offs+3];
208      sy = 240 - spriteram[offs+2];
209      color = ((spriteram[offs+1] & 0x08) >> 3); // ?
199210
200//      if (pri==0 && color!=0) continue;
201//      if (pri==1 && color==0) continue;
202
203211      fx = spriteram[offs+0] & 0x04;
204      fy = spriteram[offs+0] & 0x08; // or 0x02 ?
212      fy = spriteram[offs+0] & 0x02;
205213      multi = spriteram[offs+0] & 0x10;
206214
215      if (multi && fy==0) sy-=16;
207216
208      if (multi) sy-=16;
209
210217      if (flip_screen) {
211218         sy=240-sy;
212219         sx=240-sx;
220         if (fy)
221            sy2=sy+16;
222         else
223            sy2=sy-16;
213224         if (fx) fx=0; else fx=1;
214225         if (fy) fy=0; else fy=1;
215         sy2=sy-16;
216226      }
217      else sy2=sy+16;
227      else {
228         if (fy)
229            sy2=sy-16;
230         else
231            sy2=sy+16;
232      }
218233
219       drawgfx(bitmap,machine->gfx[1],
220              code,
221            color,
222            fx,fy,
223            sx,sy,
224            cliprect,TRANSPARENCY_PEN,0);
225        if (multi)
226          drawgfx(bitmap,machine->gfx[1],
227            code+1,
228            color,
229            fx,fy,
230            sx,sy2,
231            cliprect,TRANSPARENCY_PEN,0);
234          drawgfx(bitmap,machine->gfx[1],
235                 code,
236               color,
237               fx,fy,
238               sx,sy,
239               cliprect,TRANSPARENCY_PEN,0);
240           if (multi)
241             drawgfx(bitmap,machine->gfx[1],
242               code+1,
243               color,
244               fx,fy,
245               sx,sy2,
246               cliprect,TRANSPARENCY_PEN,0);
232247   }
233248}
234249
src/mame/video/namcos1.c
r1478r1479
5050
5151static tilemap *bg_tilemap[6];
5252static UINT8 *tilemap_maskdata;
53static int copy_sprites;
5354
5455
5556
r1478r1479
142143      machine->shadow_table[machine->pens[i]] = machine->pens[i + 0x0800];
143144
144145   spriteram = &namcos1_spriteram[0x800];
146
147   memset(namcos1_playfield_control, 0, sizeof(namcos1_playfield_control));
148   copy_sprites = 0;
145149}
146150
147151
r1478r1479
212216
213217
214218
215static int copy_sprites;
216219
217220READ8_HANDLER( namcos1_spriteram_r )
218221{
src/mame/video/legionna.c
r1478r1479
319319if (input_code_pressed_once (KEYCODE_Z))
320320   {
321321      dislayer[0] ^= 1;
322      ui_popup("bg0: %01x",dislayer[0]);
322      popmessage("bg0: %01x",dislayer[0]);
323323   }
324324
325325   if (input_code_pressed_once (KEYCODE_X))
326326   {
327327      dislayer[1] ^= 1;
328      ui_popup("bg1: %01x",dislayer[1]);
328      popmessage("bg1: %01x",dislayer[1]);
329329   }
330330
331331   if (input_code_pressed_once (KEYCODE_C))
332332   {
333333      dislayer[2] ^= 1;
334      ui_popup("bg2: %01x",dislayer[2]);
334      popmessage("bg2: %01x",dislayer[2]);
335335   }
336336
337337   if (input_code_pressed_once (KEYCODE_V))
338338   {
339339      dislayer[3] ^= 1;
340      ui_popup("sprites: %01x",dislayer[3]);
340      popmessage("sprites: %01x",dislayer[3]);
341341   }
342342
343343   if (input_code_pressed_once (KEYCODE_B))
344344   {
345345      dislayer[4] ^= 1;
346      ui_popup("text: %01x",dislayer[4]);
346      popmessage("text: %01x",dislayer[4]);
347347   }
348348#endif
349349
src/mame/video/mario.c
r1478r1479
77***************************************************************************/
88
99#include "driver.h"
10#include "video/resnet.h"
1011
12#include "includes/mario.h"
13
1114static UINT8 gfx_bank, palette_bank;
15static int monitor;
1216
1317static tilemap *bg_tilemap;
1418
19static const res_net_decode_info mario_decode_info =
20{
21   1,      // there may be two proms needed to construct color
22   0,      // start at 0
23   255,   // end at 255
24   //  R,   G,   B
25   {   0,   0,   0},      // offsets
26   {   5,   2,   0},      // shifts
27   {0x07,0x07,0x03}       // masks
28};
29
30static const res_net_info mario_net_info =
31{
32   RES_NET_VCC_5V | RES_NET_VBIAS_5V | RES_NET_VIN_MB7052 | RES_NET_MONITOR_SANYO_EZV20,
33   {
34      { RES_NET_AMP_DARLINGTON, 470, 0, 3, { 1000, 470, 220 } },
35      { RES_NET_AMP_DARLINGTON, 470, 0, 3, { 1000, 470, 220 } },
36      { RES_NET_AMP_EMITTER,    680, 0, 2, {  470, 220,   0 } }  // dkong
37   }
38};
39
40static const res_net_info mario_net_info_std =
41{
42   RES_NET_VCC_5V | RES_NET_VBIAS_5V | RES_NET_VIN_MB7052,
43   {
44      { RES_NET_AMP_DARLINGTON, 470, 0, 3, { 1000, 470, 220 } },
45      { RES_NET_AMP_DARLINGTON, 470, 0, 3, { 1000, 470, 220 } },
46      { RES_NET_AMP_EMITTER,    680, 0, 2, {  470, 220,   0 } }  // dkong
47   }
48};
49
1550/***************************************************************************
1651
1752  Convert the color PROMs into a more useable format.
r1478r1479
3469***************************************************************************/
3570PALETTE_INIT( mario )
3671{
37   int i;
38   #define TOTAL_COLORS(gfxn) (machine->gfx[gfxn]->total_colors * machine->gfx[gfxn]->color_granularity)
39   #define COLOR(gfxn,offs) (colortable[machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs])
72   rgb_t   *rgb;
4073
74   rgb = compute_res_net_all(color_prom, &mario_decode_info, &mario_net_info);
75   palette_set_colors(machine, 0, rgb, 256);
76   free(rgb);
77   rgb = compute_res_net_all(color_prom+256, &mario_decode_info, &mario_net_info_std);
78   palette_set_colors(machine, 256, rgb, 256);
79   free(rgb);
4180
42   for (i = 0;i < machine->drv->total_colors;i++)
43   {
44      int bit0,bit1,bit2,r,g,b;
45
46
47      /* red component */
48      bit0 = (*color_prom >> 5) & 1;
49      bit1 = (*color_prom >> 6) & 1;
50      bit2 = (*color_prom >> 7) & 1;
51      r = 255 - (0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2);
52      /* green component */
53      bit0 = (*color_prom >> 2) & 1;
54      bit1 = (*color_prom >> 3) & 1;
55      bit2 = (*color_prom >> 4) & 1;
56      g = 255 - (0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2);
57      /* blue component */
58      bit0 = (*color_prom >> 0) & 1;
59      bit1 = (*color_prom >> 1) & 1;
60      b = 255 - (0x55 * bit0 + 0xaa * bit1);
61
62      palette_set_color(machine,i,MAKE_RGB(r,g,b));
63      color_prom++;
64   }
65
66   /* characters use the same palette as sprites, however characters */
67   /* use only colors 64-127 and 192-255. */
68   for (i = 0;i < 8;i++)
69   {
70      COLOR(0,4*i) = 8*i + 64;
71      COLOR(0,4*i+1) = 8*i+1 + 64;
72      COLOR(0,4*i+2) = 8*i+2 + 64;
73      COLOR(0,4*i+3) = 8*i+3 + 64;
74   }
75   for (i = 0;i < 8;i++)
76   {
77      COLOR(0,4*i+8*4) = 8*i + 192;
78      COLOR(0,4*i+8*4+1) = 8*i+1 + 192;
79      COLOR(0,4*i+8*4+2) = 8*i+2 + 192;
80      COLOR(0,4*i+8*4+3) = 8*i+3 + 192;
81   }
82
83   /* sprites */
84   for (i = 0;i < TOTAL_COLORS(1);i++)
85      COLOR(1,i) = i;
81   palette_normalize_range(machine->palette, 0, 255, 0, 255);
82   palette_normalize_range(machine->palette, 256, 511, 0, 255);
8683}
8784
8885WRITE8_HANDLER( mario_videoram_w )
r1478r1479
117114static TILE_GET_INFO( get_bg_tile_info )
118115{
119116   int code = videoram[tile_index] + 256 * gfx_bank;
120   int color = (videoram[tile_index] >> 5) + 8 * palette_bank;
117   int color;
121118
119   color =  ((videoram[tile_index] >> 2) & 0x38) | 0x40 | (palette_bank<<7) | (monitor<<8);
120   color = color >> 2;
122121   SET_TILE_INFO(0, code, color, 0);
123122}
124123
r1478r1479
141140      {
142141         drawgfx(bitmap,machine->gfx[1],
143142               spriteram[offs + 2],
144               (spriteram[offs + 1] & 0x0f) + 16 * palette_bank,
143               (spriteram[offs + 1] & 0x0f) + 16 * palette_bank+32 * monitor,
145144               spriteram[offs + 1] & 0x80,spriteram[offs + 1] & 0x40,
146               spriteram[offs + 3] - 8,240 - spriteram[offs] + 8,
145               spriteram[offs + 3] - 8,(VBSTART - 1) - spriteram[offs] + 8,
147146               cliprect,TRANSPARENCY_PEN,0);
148147      }
149148   }
r1478r1479
151150
152151VIDEO_UPDATE( mario )
153152{
153   int t;
154   t = readinputportbytag("MONITOR");
155   if (t != monitor)
156   {
157      monitor = t;
158      tilemap_mark_all_tiles_dirty(ALL_TILEMAPS);
159   }
154160   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
155161   draw_sprites(machine, bitmap, cliprect);
156162   return 0;
src/mame/video/suprloco.c
r1478r1479
99#include "driver.h"
1010
1111UINT8 *suprloco_videoram;
12UINT8 *suprloco_scrollram;
1213
1314static tilemap *bg_tilemap;
1415static int control;
r1478r1479
116117   tilemap_mark_tile_dirty(bg_tilemap,offset/2);
117118}
118119
119static int suprloco_scrollram[32];
120
121120WRITE8_HANDLER( suprloco_scrollram_w )
122121{
123122   int adj = flip_screen ? -8 : 8;
r1478r1479
126125   tilemap_set_scrollx(bg_tilemap,offset, data - adj);
127126}
128127
129READ8_HANDLER( suprloco_scrollram_r )
130{
131   return suprloco_scrollram[offset];
132}
133
134128WRITE8_HANDLER( suprloco_control_w )
135129{
136130   /* There is probably a palette select in here */
r1478r1479
152146   coin_counter_w(1, data & 0x02);
153147
154148   flip_screen_set(data & 0x80);
155   tilemap_set_scrolly(bg_tilemap,0,flip_screen ? -32 : 0);
156149
157150   control = data;
158151}
r1478r1479
208201   }
209202   else
210203   {
211      adjy = sy + height + 30;  /* some of the sprites are still off by a pixel */
204      adjy = sy + height - 1;  /* some of the sprites are still off by a pixel */
212205      dy = -1;
213206   }
214207
src/mame/layout/crusnexo.lay
r0r1479
1<?xml version="1.0"?>
2<mamelayout version="2">
3   <element name="digit" defstate="0">
4      <led7seg>
5         <color red="1.0" green="0.3" blue="0.0" />
6      </led7seg>
7   </element>
8
9   <element name="led" defstate="0">
10      <disk state="1">
11         <color red="0.2" green="1.0" blue="0.2" />
12      </disk>
13   </element>
14
15   <element name="start" defstate="0">
16      <disk state="0">
17         <bounds x="0.1" y="0" width="0.8" height="1" />
18         <color red="0.1" green="0.1" blue="0.1" />
19      </disk>
20      <disk state="1">
21         <bounds x="0.1" y="0" width="0.8" height="1" />
22         <color red="1.0" green="1.0" blue="1.0" />
23      </disk>
24      <text string="START">
25         <color red="0.0" green="0.0" blue="0.0" />
26         <bounds x="0" y="0.1" width="1" height="0.8" />
27      </text>
28   </element>
29
30   <element name="radio" defstate="1">
31      <disk state="0">
32         <bounds x="0.1" y="0" width="0.8" height="1" />
33         <color red="0.1" green="0.1" blue="0.1" />
34      </disk>
35      <disk state="1">
36         <bounds x="0.1" y="0" width="0.8" height="1" />
37         <color red="1.0" green="1.0" blue="1.0" />
38      </disk>
39      <text string="RADIO">
40         <color red="0.0" green="0.0" blue="0.0" />
41         <bounds x="0" y="0.1" width="1" height="0.8" />
42      </text>
43   </element>
44
45   <element name="view1" defstate="0">
46      <disk state="0">
47         <bounds x="0.1" y="0" width="0.8" height="1" />
48         <color red="0.1" green="0.02" blue="0.02" />
49      </disk>
50      <disk state="1">
51         <bounds x="0.1" y="0" width="0.8" height="1" />
52         <color red="1.0" green="0.2" blue="0.2" />
53      </disk>
54      <text string="VIEW 1">
55         <color red="0.0" green="0.0" blue="0.0" />
56         <bounds x="0" y="0.1" width="1" height="0.8" />
57      </text>
58   </element>
59
60   <element name="view2" defstate="0">
61      <disk state="0">
62         <bounds x="0.1" y="0" width="0.8" height="1" />
63         <color red="0.1" green="0.1" blue="0.1" />
64      </disk>
65      <disk state="1">
66         <bounds x="0.1" y="0" width="0.8" height="1" />
67         <color red="1.0" green="1.0" blue="1.0" />
68      </disk>
69      <text string="VIEW 2">
70         <color red="0.0" green="0.0" blue="0.0" />
71         <bounds x="0" y="0.1" width="1" height="0.8" />
72      </text>
73   </element>
74
75   <element name="view3" defstate="0">
76      <disk state="0">
77         <bounds x="0.1" y="0" width="0.8" height="1" />
78         <color red="0.02" green="0.02" blue="0.1" />
79      </disk>
80      <disk state="1">
81         <bounds x="0.1" y="0" width="0.8" height="1" />
82         <color red="0.2" green="0.2" blue="1.0" />
83      </disk>
84      <text string="VIEW 3">
85         <color red="0.0" green="0.0" blue="0.0" />
86         <bounds x="0" y="0.1" width="1" height="0.8" />
87      </text>
88   </element>
89
90   
91   <view name="Simple LEDs">
92      <bounds left="0" top="0" right="4" bottom="3.472" />
93
94      <screen index="0">
95         <bounds left="0" top="0" right="4" bottom="3" />
96      </screen>
97
98      <bezel name="digit6" element="digit">
99         <bounds x="1.70" y="3.136" width="0.134" height="0.2" />
100      </bezel>
101      <bezel name="digit5" element="digit">
102         <bounds x="1.90" y="3.136" width="0.134" height="0.2" />
103      </bezel>
104      <bezel name="digit4" element="digit">
105         <bounds x="2.10" y="3.136" width="0.134" height="0.2" />
106      </bezel>
107
108      <bezel name="led0" element="led">
109         <bounds x="0.533" y="3.461" width="0.02" height="0.02" />
110      </bezel>
111      <bezel name="led1" element="led">
112         <bounds x="0.533" y="3.370" width="0.02" height="0.02" />
113      </bezel>
114      <bezel name="led2" element="led">
115         <bounds x="0.549" y="3.279" width="0.02" height="0.02" />
116      </bezel>
117      <bezel name="led3" element="led">
118         <bounds x="0.596" y="3.195" width="0.02" height="0.02" />
119      </bezel>
120      <bezel name="led4" element="led">
121         <bounds x="0.670" y="3.123" width="0.02" height="0.02" />
122      </bezel>
123      <bezel name="led5" element="led">
124         <bounds x="0.767" y="3.067" width="0.02" height="0.02" />
125      </bezel>
126      <bezel name="led6" element="led">
127         <bounds x="0.879" y="3.032" width="0.02" height="0.02" />
128      </bezel>
129      <bezel name="led7" element="led">
130         <bounds x="1.000" y="3.020" width="0.02" height="0.02" />
131      </bezel>
132      <bezel name="led16" element="led">
133         <bounds x="1.121" y="3.032" width="0.02" height="0.02" />
134      </bezel>
135      <bezel name="led17" element="led">
136         <bounds x="1.233" y="3.067" width="0.02" height="0.02" />
137      </bezel>
138
139      <bezel name="led8" element="led">
140         <bounds x="3.467" y="3.461" width="0.02" height="0.02" />
141      </bezel>
142      <bezel name="led9" element="led">
143         <bounds x="3.467" y="3.370" width="0.02" height="0.02" />
144      </bezel>
145      <bezel name="led10" element="led">
146         <bounds x="3.451" y="3.279" width="0.02" height="0.02" />
147      </bezel>
148      <bezel name="led11" element="led">
149         <bounds x="3.404" y="3.195" width="0.02" height="0.02" />
150      </bezel>
151      <bezel name="led12" element="led">
152         <bounds x="3.330" y="3.123" width="0.02" height="0.02" />
153      </bezel>
154      <bezel name="led13" element="led">
155         <bounds x="3.233" y="3.067" width="0.02" height="0.02" />
156      </bezel>
157      <bezel name="led14" element="led">
158         <bounds x="3.121" y="3.032" width="0.02" height="0.02" />
159      </bezel>
160      <bezel name="led15" element="led">
161         <bounds x="3.000" y="3.020" width="0.02" height="0.02" />
162      </bezel>
163      <bezel name="led22" element="led">
164         <bounds x="2.879" y="3.032" width="0.02" height="0.02" />
165      </bezel>
166      <bezel name="led23" element="led">
167         <bounds x="2.767" y="3.067" width="0.02" height="0.02" />
168      </bezel>
169
170      <bezel name="lamp0" element="start">
171         <bounds x="3.5" y="3.3" width="0.4" height="0.1" />
172      </bezel>
173      <bezel name="lamp1" element="view1">
174         <bounds x="0.1" y="3.1" width="0.4" height="0.1" />
175      </bezel>
176      <bezel name="lamp2" element="view2">
177         <bounds x="0.1" y="3.2" width="0.4" height="0.1" />
178      </bezel>
179      <bezel name="lamp3" element="view3">
180         <bounds x="0.1" y="3.3" width="0.4" height="0.1" />
181      </bezel>
182   </view>   
183</mamelayout>
src/mame/drivers/midyunit.c
r1478r1479
2727        * Super Hi Impact Proto V4.0: You need to at least reset the high score
2828            table from the UTILITIES menu.  It's best to do a FULL FACTORY RESTORE
2929
30
31Super High Impact
32Midway, 1991
33
34This game runs on (typical) Midway Y-Unit hardware. The PCB is a base
35board 'system' that can run other Y-Unit games by swapping ROMs and
36the protection chip.
37
38PCB Layout
39----------
40
415770-12555-00 REV. - A
42|-------------------------------------------------------------------|
43|                     6264  PAL    53461 53461 53461 48MHZ 24MHz  J6|
44|J4                                53461 53461 53461                |
45|                                  53461 53461 53461                |
46|                                  53461 53461 53461                |
47|J2           MAX691  6264  PAL                         |-----|     |
48|                         PAL PAL                       |TMS  |   J7|
49|RESET_SW                                               |34010|     |
50|  LED1                                                 |-----|     |
51|    LED2             6264 PAL PAL                                  |
52|                                                                   |
53|J       41464 41464                                              J8|
54|A  PAL  41464 41464                                                |
55|M                                                                  |
56|M                                                                  |
57|A           U89  U90  U91  U92  U93     U95  U96  U97  U98         |
58|                                                     |--------|    |
59|                                                     |L1A3787 |    |
60|                                                     |WILLIAMS|    |
61|                                                     |5410-12239   |
62|                                                     |--------|    |
63|DSW1 DSW2                                                          |
64|BATTERY                                             *A-5346-40017-8|
65|                                                                   |
66| J13   J12  U105 U106 U107 U108 U109    U111 U112 U113 U114        |
67|-------------------------------------------------------------------|
68Notes:
69      *    - Intel P5C090-50 protection chip labelled 'A-5346-40017-8'
70             clocks on pin1 6.00MHz, pin4 6.00MHz, pin21 6.00MHz
71     J*    - multi-pin connectors for additional controls, cabinet switches
72             and power input and output
73     J8    - used to connect external sound PCB via a flat cable.
74     J2    - Used to supply power to external sound PCB
75     34010 - clock 6.000MHz [48/8]
76     LED1  - power active
77     LED2  - data active, flickers while PCB is working
78     U89/105  - main program EPROMs 27C010
79     Other U* - 27C020 EPROMs
80
81
82Sound PCB
83---------
84
855766-12702-00 REV. B
86|----------------------------------------|
87|    3.579545MHz 6116  U4  U19  U20      |
88|  YM2151                                |
89|YM3012                                  |
90|      458                         6809  |
91| 458                                    |
92|         MC1408                         |
93|J1            6821                      |
94|                                        |
95| 458    55536                  8MHz     |
96|     458                                |
97|                                        |
98|J2                                     J|
99|         J3     J4       TDA2002 TDA2002|
100|----------------------------------------|
101Notes:
102      6809   - clock 2.000MHz [8/4]
103      YM2151 - clock 3.579545MHz
104      55536  - Harris HC-55536 Continuously Variable Slope Delta Modulator
105      6116   - 2k x8 SRAM
106      U*     - 27C010 EPROMs
107      J4     - flat cable connector from main board J8
108      J3     - power input connector
109      J2     - connector for volume pot
110      J      - speakers output connector
111
30112**************************************************************************/
31113
32114#include "driver.h"
src/mame/drivers/sslam.c
r1478r1479
9898UINT16 *sslam_spriteram, *sslam_regs;
9999
100100static UINT8 playmark_oki_control = 0, playmark_oki_command = 0;
101static UINT8 playmark_oki_bank = 0;
101102
102103
103
104104/**************************************************************************
105105   This table converts commands sent from the main CPU, into sample numbers
106106   played back by the sound processor (the 87C751).
r1478r1479
371371            sslam_play(sslam_melody, sslam_sound);
372372         }
373373         else if (sslam_sound >= 0x60) {
374            sslam_snd_bank = 0;
374            if (sslam_snd_bank != 0)
375375               OKIM6295_set_bank_base(0, (0 * 0x40000));
376376            sslam_snd_bank = 0;
377377            switch (sslam_sound)
r1478r1479
469469
470470static WRITE8_HANDLER( playmark_snd_control_w )
471471{
472   static int oki_old_bank = -1;
473
474472   playmark_oki_control = data;
475473
476474   if(data & 3)
477475   {
478      if(oki_old_bank != (data & 3))
476      if(playmark_oki_bank != ((data & 3) - 1))
479477      {
480         oki_old_bank = data & 3;
481         OKIM6295_set_bank_base(0, 0x40000 * (oki_old_bank - 1));
478         playmark_oki_bank = (data & 3) - 1;
479         OKIM6295_set_bank_base(0, 0x40000 * playmark_oki_bank);
482480      }
483481   }
484482
r1478r1479
965963{
966964   state_save_register_global(playmark_oki_control);
967965   state_save_register_global(playmark_oki_command);
966   state_save_register_global(playmark_oki_bank);
968967}
969968
970969
src/mame/drivers/zn.c
r1478r1479
2626
2727#define VERBOSE_LEVEL ( 0 )
2828
29INLINE void verboselog( int n_level, const char *s_fmt, ... )
29INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
3030{
3131   if( VERBOSE_LEVEL >= n_level )
3232   {
src/mame/drivers/midzeus.c
r1478r1479
1616**************************************************************************/
1717
1818#include "driver.h"
19#include "debugger.h"
1920#include "cpu/tms34010/tms34010.h"
2021#include "cpu/adsp2100/adsp2100.h"
2122#include "includes/midzeus.h"
r1478r1479
2324#include "machine/timekpr.h"
2425#include "audio/dcs.h"
2526
27#include "crusnexo.lh"
2628
27#define CPU_CLOCK      60000000
2829
30#define CPU_CLOCK      XTAL_60MHz
31
2932#define BEAM_DY         3
3033#define BEAM_DX         3
3134#define BEAM_XOFFS      40      /* table in the code indicates an offset of 20 with a beam height of 7 */
r1478r1479
3538static emu_timer *      gun_timer[2];
3639static INT32          gun_x[2], gun_y[2];
3740
41static UINT8         crusnexo_leds_select;
42static UINT8         keypad_select;
43static UINT8         bitlatch[10];
44
3845static UINT32 *ram_base;
3946static UINT32 *zpram;
4047static size_t zpram_size;
4148static UINT8 cmos_protected;
4249
50static UINT32 *linkram;
51
4352static emu_timer *timer[2];
4453
4554static UINT32 *tms32031_control;
r1478r1479
6776   state_save_register_global(gun_irq_state);
6877   state_save_register_global_array(gun_x);
6978   state_save_register_global_array(gun_y);
79   state_save_register_global(crusnexo_leds_select);
80   state_save_register_global(keypad_select);
7081}
7182
7283
r1478r1479
114125
115126static WRITE32_HANDLER( cmos_w )
116127{
117   if (!cmos_protected)
128   if (bitlatch[2] && !cmos_protected)
118129      COMBINE_DATA(&generic_nvram32[offset]);
130   else
131      logerror("%06X:timekeeper_w with bitlatch[2] = %d, cmos_protected = %d\n", activecpu_get_pc(), bitlatch[2], cmos_protected);
119132   cmos_protected = TRUE;
120133}
121134
122135
123136static READ32_HANDLER( cmos_r )
124137{
125   return generic_nvram32[offset];
138   return generic_nvram32[offset] | 0xffffff00;
126139}
127140
128141
r1478r1479
135148
136149/*************************************
137150 *
138 *  Timekeeper access (Zeus 2 only)
151 *  Timekeeper and ZPRAM access
152 *  (Zeus 2 only)
139153 *
140154 *************************************/
141155
142156static READ32_HANDLER( timekeeper_r )
143157{
144   UINT8 result = timekeeper_0_r(offset);
145//  logerror("%06X:cmos_time_r(%X) = %02X\n", activecpu_get_pc(), offset, result);
146   return result;
158   return timekeeper_0_r(offset) | 0xffffff00;
147159}
148160
149161
150162static WRITE32_HANDLER( timekeeper_w )
151163{
152   if (!cmos_protected)
153   {
154//      logerror("%06X:cmos_time_w(%X) = %02X\n", activecpu_get_pc(), offset, data);
164   if (bitlatch[2] && !cmos_protected)
155165      timekeeper_0_w(offset, data);
156   }
166   else
167      logerror("%06X:timekeeper_w with bitlatch[2] = %d, cmos_protected = %d\n", activecpu_get_pc(), bitlatch[2], cmos_protected);
157168   cmos_protected = TRUE;
158169}
159170
160171
161
162/*************************************
163 *
164 *  Zero-power RAM access (Zeus 2 only)
165 *
166 *************************************/
167
168static WRITE32_HANDLER( zpram_w )
172static READ32_HANDLER( zpram_r )
169173{
170   /* ZPRAM seems to use the same protection control as CMOS */
171//  if (!cmos_protected)
172      COMBINE_DATA(zpram + offset);
173   cmos_protected = TRUE;
174   return zpram[offset] | 0xffffff00;
174175}
175176
176177
177static READ32_HANDLER( zpram_r )
178static WRITE32_HANDLER( zpram_w )
178179{
179   return zpram[offset] | 0xffffff00;
180   if (bitlatch[2])
181      COMBINE_DATA(&zpram[offset]);
182   else
183      logerror("%06X:zpram_w with bitlatch[2] = %d\n", activecpu_get_pc(), bitlatch[2]);
180184}
181185
182186
r1478r1479
203207
204208/*************************************
205209 *
210 *  Miscellaneous bit latches
211 *
212 *************************************/
213
214static READ32_HANDLER( bitlatches_r )
215{
216   switch (offset)
217   {
218      /* unknown purpose; two bits are apparently used */
219      case 1:
220         return bitlatch[offset] | ~3;
221
222      /* CMOS/ZPRAM extra enable latch; only low bit is used */
223      case 2:
224         return bitlatch[offset] | ~1;
225
226      /* unknown purpose; mk4/invasn/thegrid read at startup; invasn freaks if it is 1 at startup */
227      /* only low bit is used */
228      case 3:
229         return bitlatch[offset] | ~1;
230
231      /* ROM bank selection on Zeus 2; two bits are used */
232      case 5:
233         return bitlatch[offset] | ~3;
234
235      /* unknown purpose; crusnexo reads at startup: if (val & 0xf0) == 0xa0 it affects */
236      /* how the Zeus is used (reg 0x5d is set to 0x54580006) */
237      /* thegrid does the same, writing either 0xD4580006 or 0xC4180006 depending */
238      /* this is the value reported as DISK JR ASIC version in thegrid startup test */
239      case 6:
240         return 0xa0 | ~0xff;
241
242      /* unknown purpose */
243      default:
244         logerror("%06X:bitlatches_r(%X)\n", activecpu_get_pc(), offset);
245         break;
246   }
247   return ~0;
248}
249
250
251static WRITE32_HANDLER( bitlatches_w )
252{
253   UINT32 oldval = bitlatch[offset];
254   bitlatch[offset] = data;
255
256   switch (offset)
257   {
258      /* unknown purpose */
259      default:
260         if (oldval ^ data)
261            logerror("%06X:bitlatches_w(%X) = %X\n", activecpu_get_pc(), offset, data);
262         break;
263
264      /* unknown purpose; crusnexo toggles this between 0 and 1 every 20 frames; thegrid writes 1 */
265      case 0:
266         if (data != 0 && data != 1)
267            logerror("%06X:bitlatches_w(%X) = %X (unexpected)\n", activecpu_get_pc(), offset, data);
268         break;
269
270      /* unknown purpose; mk4/invasn write 1 here at initialization; crusnexo/thegrid write 3 */
271      case 1:
272         if (data != 1 && data != 3)
273            logerror("%06X:bitlatches_w(%X) = %X (unexpected)\n", activecpu_get_pc(), offset, data);
274         break;
275
276      /* CMOS/ZPRAM extra enable latch; only low bit is used */
277      case 2:
278         break;
279
280      /* unknown purpose; invasn writes 2 here at startup */
281      case 4:
282         if (data != 2)
283            logerror("%06X:bitlatches_w(%X) = %X (unexpected)\n", activecpu_get_pc(), offset, data);
284         break;
285
286      /* ROM bank selection on Zeus 2 */
287      case 5:
288         memory_set_bank(1, bitlatch[offset] & 3);
289         break;
290
291      /* unknown purpose; crusnexo/thegrid write 1 at startup */
292      case 7:
293         if (data != 1)
294            logerror("%06X:bitlatches_w(%X) = %X (unexpected)\n", activecpu_get_pc(), offset, data);
295         break;
296
297      /* unknown purpose; crusnexo writes 4 at startup; thegrid writes 6 */
298      case 8:
299         if (data != 4 && data != 6)
300            logerror("%06X:bitlatches_w(%X) = %X (unexpected)\n", activecpu_get_pc(), offset, data);
301         break;
302
303      /* unknown purpose; thegrid writes 1 at startup */
304      case 9:
305         if (data != 1)
306            logerror("%06X:bitlatches_w(%X) = %X (unexpected)\n", activecpu_get_pc(), offset, data);
307         break;
308   }
309}
310
311
312
313/*************************************
314 *
315 *  7-segment LED controls
316 *
317 *************************************/
318
319static READ32_HANDLER( crusnexo_leds_r )
320{
321   /* reads appear to just be for synchronization */
322   return ~0;
323}
324
325
326static WRITE32_HANDLER( crusnexo_leds_w )
327{
328   int bit, led;
329
330   switch (offset)
331   {
332      case 0:   /* unknown purpose */
333         break;
334
335      case 1:   /* controls lamps */
336         for (bit = 0; bit < 8; bit++)
337            output_set_lamp_value(bit, (data >> bit) & 1);
338         break;
339
340      case 2:   /* sets state of selected LEDs */
341
342         /* selection bits 4-6 select the 3 7-segment LEDs */
343         for (bit = 4; bit < 7; bit++)
344            if ((crusnexo_leds_select & (1 << bit)) == 0)
345               output_set_digit_value(bit, ~data & 0xff);
346
347         /* selection bits 0-2 select the tachometer LEDs */
348         for (bit = 0; bit < 3; bit++)
349            if ((crusnexo_leds_select & (1 << bit)) == 0)
350               for (led = 0; led < 8; led++)
351                  output_set_led_value(bit * 8 + led, (~data >> led) & 1);
352         break;
353
354      case 3:   /* selects which set of LEDs we are addressing */
355         crusnexo_leds_select = data;
356         break;
357   }
358}
359
360
361/*************************************
362 *
363 *  Link controller access (Zeus 2 only)
364 *
365 *************************************/
366
367// read 8d0003, check bit 1, skip some stuff if 0
368// write junk to 9e0000
369
370static READ32_HANDLER( linkram_r )
371{
372   logerror("%06X:unknown_8a000_r(%02X)\n", activecpu_get_pc(), offset);
373   if (offset == 0)
374      return 0x30313042;
375   else if (offset == 0x3c)
376      return 0xffffffff;
377   return linkram[offset];
378}
379
380static WRITE32_HANDLER( linkram_w )
381{
382   logerror("%06X:unknown_8a000_w(%02X) = %08X\n", activecpu_get_pc(),  offset, data);
383   COMBINE_DATA(&linkram[offset]);
384}
385
386
387
388/*************************************
389 *
206390 *  TMS32031 I/O accesses
207391 *
208392 *************************************/
r1478r1479
262446}
263447
264448
449static WRITE32_HANDLER( keypad_select_w )
450{
451   if (offset == 1)
452      keypad_select = data;
453}
265454
455
456static UINT32 keypad_r(void *param)
457{
458   UINT32 bits = readinputportbytag(param);
459   UINT8 select = keypad_select;
460   while ((select & 1) != 0)
461   {
462      select >>= 1;
463      bits >>= 4;
464   }
465   return bits;
466}
467
468
469
266470/*************************************
267471 *
268472 *  Analog input handling
r1478r1479
373577 *
374578 *************************************/
375579
376
377// read 8d0003, check bit 1, skip some stuff if 0
378// write junk to 9e0000
379
380static UINT32 *unknown_8a0000;
381static UINT32 *unknown_8d0000;
382static READ32_HANDLER( unknown_8d0000_r )
383{
384   return unknown_8d0000[offset];
385}
386static WRITE32_HANDLER( unknown_8d0000_w )
387{
388//  logerror("%06X:write to %06X = %08X\n", activecpu_get_pc(), 0x8d0000 + offset, data);
389   COMBINE_DATA(&unknown_8d0000[offset]);
390}
391static WRITE32_HANDLER( unknown_9d0000_w )
392{
393//  logerror("%06X:write to %06X = %08X\n", activecpu_get_pc(), 0x9d0000 + offset, data);
394   COMBINE_DATA(&unknown_8d0000[offset]);
395}
396
397static WRITE32_HANDLER( rombank_select_w )
398{
399   if (data >= 0 && data <= 2)
400      memory_set_bank(1, data);
401}
402
403static READ32_HANDLER( unknown_8a0000_r )
404{
405   logerror("%06X:unknown_8a000_r(%02X)\n", activecpu_get_pc(), offset);
406   if (offset == 0)
407      return 0x30313042;
408   return unknown_8a0000[offset];
409}
410
411static WRITE32_HANDLER( unknown_8a0000_w )
412{
413   logerror("%06X:unknown_8a000_w(%02X) = %08X\n", activecpu_get_pc(),  offset, data);
414   COMBINE_DATA(&unknown_8a0000[offset]);
415}
416
417
418580static ADDRESS_MAP_START( zeus_map, ADDRESS_SPACE_PROGRAM, 32 )
419581   ADDRESS_MAP_FLAGS( AMEF_UNMAP(1) )
420582   AM_RANGE(0x000000, 0x03ffff) AM_RAM AM_BASE(&ram_base)
421583   AM_RANGE(0x400000, 0x41ffff) AM_RAM
422584   AM_RANGE(0x808000, 0x80807f) AM_READWRITE(tms32031_control_r, tms32031_control_w) AM_BASE(&tms32031_control)
423585   AM_RANGE(0x880000, 0x8803ff) AM_READWRITE(zeus_r, zeus_w) AM_BASE(&zeusbase)
424   AM_RANGE(0x8d0000, 0x8d0003) AM_READWRITE(unknown_8d0000_r, unknown_8d0000_w) AM_BASE(&unknown_8d0000)
586   AM_RANGE(0x8d0000, 0x8d0004) AM_READWRITE(bitlatches_r, bitlatches_w)
425587   AM_RANGE(0x990000, 0x99000f) AM_READWRITE(midway_ioasic_r, midway_ioasic_w)
426   AM_RANGE(0x9d0000, 0x9d0001) AM_WRITE(unknown_9d0000_w)
427588   AM_RANGE(0x9e0000, 0x9e0000) AM_WRITENOP      // watchdog?
428589   AM_RANGE(0x9f0000, 0x9f7fff) AM_READWRITE(cmos_r, cmos_w) AM_BASE(&generic_nvram32) AM_SIZE(&generic_nvram_size)
429590   AM_RANGE(0x9f8000, 0x9f8000) AM_WRITE(cmos_protect_w)
r1478r1479
437598   AM_RANGE(0x400000, 0x43ffff) AM_RAM
438599   AM_RANGE(0x808000, 0x80807f) AM_READWRITE(tms32031_control_r, tms32031_control_w) AM_BASE(&tms32031_control)
439600   AM_RANGE(0x880000, 0x88007f) AM_READWRITE(zeus2_r, zeus2_w) AM_BASE(&zeusbase)
440   AM_RANGE(0x8a0000, 0x8a0027) AM_READWRITE(unknown_8a0000_r, unknown_8a0000_w) AM_BASE(&unknown_8a0000)
441   AM_RANGE(0x8d0000, 0x8d0003) AM_READWRITE(unknown_8d0000_r, unknown_8d0000_w) AM_BASE(&unknown_8d0000)
442   AM_RANGE(0x8d0005, 0x8d0005) AM_WRITE(rombank_select_w)
601   AM_RANGE(0x8a0000, 0x8a003f) AM_READWRITE(linkram_r, linkram_w) AM_BASE(&linkram)
602   AM_RANGE(0x8d0000, 0x8d000a) AM_READWRITE(bitlatches_r, bitlatches_w)
443603   AM_RANGE(0x900000, 0x91ffff) AM_READWRITE(zpram_r, zpram_w) AM_BASE(&zpram) AM_SIZE(&zpram_size) AM_MIRROR(0x020000)
444604   AM_RANGE(0x990000, 0x99000f) AM_READWRITE(midway_ioasic_r, midway_ioasic_w)
445605   AM_RANGE(0x9c0000, 0x9c000f) AM_READWRITE(analog_r, analog_w)
r1478r1479
450610   AM_RANGE(0xc00000, 0xffffff) AM_ROMBANK(1) AM_REGION(REGION_USER2, 0)
451611ADDRESS_MAP_END
452612
613/*
453614
615    mk4:
454616
617        writes to 9D0000: 00000009, FFFFFFFF
618        reads from 9D0000
619        writes to 9D0001: 00000000
620        writes to 9D0003: 00000374
621        writes to 9D0005: 00000000
622
623    crusnexo:
624
625        reads from 8A0000
626
627        writes to 9D0000: 00000000, 00000008, 00000009, FFFFFFFF
628        reads from 9D0000
629        writes to 9D0001: 00000000, 00000004, 00000204
630        writes to 9D0003: 00000374
631            -- hard coded to $374 at startup
632        writes to 9D0004: 0000000F
633            -- hard coded to $F at startup
634
635        writes to 9E0008: 00000000
636
637        writes to 9E8000: 00810081
638
639    thegrid:
640
641        writes to 9D0000: 00000008, 00000009, 0000008D
642        writes to 9D0001: 00000000, 00000004, 00000204
643        writes to 9D0003: 00000354
644        reads from 9D0003
645        writes to 9D0004: FFFFFFFF
646        writes to 9D0005: 00000000
647
648        writes to 9E8000: 00810081
649*/
650
651
455652/*************************************
456653 *
457654 *  Input ports
r1478r1479
751948   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
752949
753950   PORT_START
951   PORT_BIT( 0x0007, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_CUSTOM( keypad_r, "KEYPAD" )
952   PORT_BIT( 0xfff8, IP_ACTIVE_LOW, IPT_UNUSED )
953
954   PORT_START_TAG("KEYPAD")
754955   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(3)   /* keypad 3 */
755956   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(3)   /* keypad 1 */
756957   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(3)   /* keypad 2 */
757   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(3)   /* keypad 2 */
758   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_PLAYER(3)   /* keypad 2 */
759   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_PLAYER(3)   /* keypad 2 */
760   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_PLAYER(3)   /* keypad 2 */
761   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_PLAYER(3)   /* keypad 2 */
762   PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
958   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_PLAYER(3)   /* keypad 6 */
959   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(3)   /* keypad 4 */
960   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_PLAYER(3)   /* keypad 5 */
961   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON9 ) PORT_PLAYER(3)   /* keypad 9 */
962   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_PLAYER(3)   /* keypad 7 */
963   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_PLAYER(3)   /* keypad 8 */
964   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON12 ) PORT_PLAYER(3)   /* keypad # */
965   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON11 ) PORT_PLAYER(3)   /* keypad * */
966   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON10 ) PORT_PLAYER(3)   /* keypad 0 */
763967
764968   PORT_START_TAG("ANALOG3")
765969   PORT_BIT( 0xff, 0x80, IPT_PADDLE ) PORT_MINMAX(0x10,0xf0) PORT_SENSITIVITY(25) PORT_KEYDELTA(20)
r1478r1479
10771281static DRIVER_INIT( mk4 )
10781282{
10791283   dcs2_init(0, 0);
1080   midway_ioasic_init(MIDWAY_IOASIC_STANDARD, 461/* or 474 */, 97, NULL);
1284   midway_ioasic_init(MIDWAY_IOASIC_STANDARD, 461/* or 474 */, 94, NULL);
10811285   midway_ioasic_set_shuffle_state(1);
10821286}
10831287
r1478r1479
10851289static DRIVER_INIT( invasn )
10861290{
10871291   dcs2_init(0, 0);
1088   midway_ioasic_init(MIDWAY_IOASIC_STANDARD, 468/* or 488 */, 97, NULL);
1292   midway_ioasic_init(MIDWAY_IOASIC_STANDARD, 468/* or 488 */, 94, NULL);
10891293   memory_install_readwrite32_handler(0, ADDRESS_SPACE_PROGRAM, 0x9c0000, 0x9c0000, 0, 0, invasn_gun_r, invasn_gun_w);
10901294}
10911295
r1478r1479
10951299   dcs2_init(0, 0);
10961300   midway_ioasic_init(MIDWAY_IOASIC_STANDARD, 472/* or 476,477,478,110 */, 99, NULL);
10971301   memory_configure_bank(1, 0, 3, memory_region(REGION_USER2), 0x400000*4);
1302
1303   memory_install_readwrite32_handler(0, ADDRESS_SPACE_PROGRAM, 0x9b0004, 0x9b0007, 0, 0, crusnexo_leds_r, crusnexo_leds_w);
1304   memory_install_write32_handler    (0, ADDRESS_SPACE_PROGRAM, 0x8d0009, 0x8d000a, 0, 0, keypad_select_w);
10981305}
10991306
11001307
r1478r1479
11161323GAME( 1997, mk4,      0,     midzeus,  mk4,      mk4,      ROT0, "Midway", "Mortal Kombat 4 (3.0)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
11171324GAME( 1997, mk4a,     mk4,   midzeus,  mk4,      mk4,      ROT0, "Midway", "Mortal Kombat 4 (2.1)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
11181325GAME( 1999, invasn,   0,     midzeus,  invasn,   invasn,   ROT0, "Midway", "Invasion (Midway)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
1119GAME( 1999, crusnexo, 0,     midzeus2, crusnexo, crusnexo, ROT0, "Midway", "Cruis'n Exotica", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
1326GAMEL( 1999, crusnexo, 0,     midzeus2, crusnexo, crusnexo, ROT0, "Midway", "Cruis'n Exotica", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE, layout_crusnexo )
11201327GAME( 2001, thegrid,  0,     midzeus2, thegrid,  thegrid,  ROT0, "Midway", "The Grid (version 1.1)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
src/mame/drivers/dkong.c
r1478r1479
511511   if  (!lst && (readinputportbytag("TST") & 0x01))
512512   {
513513      ui_snd = (ui_snd + 1) % 10;
514      ui_popup("Sound %d", ui_snd);
514      popmessage("Sound %d", ui_snd);
515515   }
516516   lst = readinputportbytag("TST") & 0x01;
517517   if (ui_snd<8)
r1478r1479
14631463static const gfx_layout pestplce_spritelayout =
14641464{
14651465   16,16,                                   /* 16*16 sprites */
1466   RGN_FRAC(1,2),                           /* 256 sprites */
1466   RGN_FRAC(1,4),                           /* 256 sprites */
14671467   2,                                       /* 2 bits per pixel */
14681468   { RGN_FRAC(1,2), RGN_FRAC(0,2) },       /* the two bitplanes are separated */
14691469   { STEP8(0,1), STEP8(RGN_FRAC(1,4),1) }, /* the two halves of the sprite are separated */
src/mame/drivers/simpsons.c
r1478r1479
322322
323323***************************************************************************/
324324
325ROM_START( simpsons )
325ROM_START( simpsons ) /* World 4 Player */
326326   ROM_REGION( 0x8b000, REGION_CPU1, 0 ) /* code + banked roms + banked ram */
327   ROM_LOAD( "072-g02.16c",      0x10000, 0x20000, CRC(580ce1d6) SHA1(5b07fb8e8041e1663980aa35d853fdc13b22dac5) )
328   ROM_LOAD( "072-g01.17c",      0x30000, 0x20000, CRC(9f843def) SHA1(858432b59101b0577c5cec6ac0c7c20ab0780c9a) )
329   ROM_LOAD( "072-j13.13c",      0x50000, 0x20000, CRC(aade2abd) SHA1(10f178d5ed399b4866266e075d91ca3db26798f8) )
330   ROM_LOAD( "072-j12.15c",      0x70000, 0x18000, CRC(479e12f2) SHA1(15a6cb12e68b4773a29ab463640a43f8e814de59) )
331   ROM_CONTINUE(            0x08000, 0x08000 )
327   ROM_LOAD( "072-g02.16c", 0x10000, 0x20000, CRC(580ce1d6) SHA1(5b07fb8e8041e1663980aa35d853fdc13b22dac5) )
328   ROM_LOAD( "072-g01.17c", 0x30000, 0x20000, CRC(9f843def) SHA1(858432b59101b0577c5cec6ac0c7c20ab0780c9a) )
329   ROM_LOAD( "072-j13.13c", 0x50000, 0x20000, CRC(aade2abd) SHA1(10f178d5ed399b4866266e075d91ca3db26798f8) )
330   ROM_LOAD( "072-j12.15c", 0x70000, 0x18000, CRC(479e12f2) SHA1(15a6cb12e68b4773a29ab463640a43f8e814de59) )
331   ROM_CONTINUE(       0x08000, 0x08000 )
332332
333333   ROM_REGION( 0x28000, REGION_CPU2, 0 ) /* Z80 code + banks */
334   ROM_LOAD( "072-e03.6g",       0x00000, 0x08000, CRC(866b7a35) SHA1(98905764eb4c7d968ccc17618a1f24ee12e33c0e) )
335   ROM_CONTINUE(            0x10000, 0x18000 )
334   ROM_LOAD( "072-e03.6g", 0x00000, 0x08000, CRC(866b7a35) SHA1(98905764eb4c7d968ccc17618a1f24ee12e33c0e) )
335   ROM_CONTINUE(      0x10000, 0x18000 )
336336
337337   ROM_REGION( 0x100000, REGION_GFX1, 0 ) /* graphics ( dont dispose as the program can read them, 0 ) */
338338   ROM_LOAD( "072-b07.18h", 0x000000, 0x080000, CRC(ba1ec910) SHA1(0805ccb641271dea43185dc0365732260db1763d) )   /* tiles */
r1478r1479
349349   ROM_LOAD( "072-d04.1d", 0x100000, 0x040000, CRC(78778013) SHA1(edbd6d83b0d1a20df39bb160b92395586fa3c32d) )
350350ROM_END
351351
352ROM_START( simps4pa )
352ROM_START( simps4pa ) /* World 4 Player, later? (by use of later leters) */
353353   ROM_REGION( 0x8b000, REGION_CPU1, 0 ) /* code + banked roms + banked ram */
354   ROM_LOAD( "072-g02.16c",      0x10000, 0x20000, CRC(580ce1d6) SHA1(5b07fb8e8041e1663980aa35d853fdc13b22dac5) )
355   ROM_LOAD( "072-g01.17c",      0x30000, 0x20000, CRC(9f843def) SHA1(858432b59101b0577c5cec6ac0c7c20ab0780c9a) )
356   ROM_LOAD( "simpm13.13c",      0x50000, 0x20000, CRC(f36c9423) SHA1(4a7311ffcb2e6916006c1e79dfc231e7fc570781) )
357   ROM_LOAD( "simpl12.15c",      0x70000, 0x18000, CRC(84f9d9ba) SHA1(d52f999b7c8125daea5e9b5754c6e82c17861d1b) )
358   ROM_CONTINUE(                 0x08000, 0x08000 )
354   ROM_LOAD( "072-g02.16c", 0x10000, 0x20000, CRC(580ce1d6) SHA1(5b07fb8e8041e1663980aa35d853fdc13b22dac5) )
355   ROM_LOAD( "072-g01.17c", 0x30000, 0x20000, CRC(9f843def) SHA1(858432b59101b0577c5cec6ac0c7c20ab0780c9a) )
356   ROM_LOAD( "072-m13.13c", 0x50000, 0x20000, CRC(f36c9423) SHA1(4a7311ffcb2e6916006c1e79dfc231e7fc570781) )
357   ROM_LOAD( "072-l12.15c", 0x70000, 0x18000, CRC(84f9d9ba) SHA1(d52f999b7c8125daea5e9b5754c6e82c17861d1b) )
358   ROM_CONTINUE(            0x08000, 0x08000 )
359359
360360   ROM_REGION( 0x28000, REGION_CPU2, 0 ) /* Z80 code + banks */
361   ROM_LOAD( "072-e03.6g",       0x00000, 0x08000, CRC(866b7a35) SHA1(98905764eb4c7d968ccc17618a1f24ee12e33c0e) )
362   ROM_CONTINUE(              0x10000, 0x18000 )
361   ROM_LOAD( "072-e03.6g", 0x00000, 0x08000, CRC(866b7a35) SHA1(98905764eb4c7d968ccc17618a1f24ee12e33c0e) )
362   ROM_CONTINUE(        0x10000, 0x18000 )
363363
364364   ROM_REGION( 0x100000, REGION_GFX1, 0 ) /* graphics ( dont dispose as the program can read them, 0 ) */
365365   ROM_LOAD( "072-b07.18h", 0x000000, 0x080000, CRC(ba1ec910) SHA1(0805ccb641271dea43185dc0365732260db1763d) ) /* tiles */
r1478r1479
377377ROM_END
378378
379379
380ROM_START( simpsn2p )
380ROM_START( simpsn2p ) /* World 2 Player */
381381   ROM_REGION( 0x8b000, REGION_CPU1, 0 ) /* code + banked roms + banked ram */
382   ROM_LOAD( "072-g02.16c",      0x10000, 0x20000, CRC(580ce1d6) SHA1(5b07fb8e8041e1663980aa35d853fdc13b22dac5) )
383   ROM_LOAD( "simp_p01.17c",     0x30000, 0x20000, CRC(07ceeaea) SHA1(c18255ae1d578c2d53de80d6323cdf41cbe47b57) )
384   ROM_LOAD( "simp_013.13c",     0x50000, 0x20000, CRC(8781105a) SHA1(ef2f16f7a56d3715536511c674df4b3aab1be2bd) )
385   ROM_LOAD( "simp_012.15c",     0x70000, 0x18000, CRC(244f9289) SHA1(eeda7f5c7340cbd1a1cd576af48cd5d1a629914a) )
386   ROM_CONTINUE(            0x08000, 0x08000 )
382   ROM_LOAD( "072-g02.16c",  0x10000, 0x20000, CRC(580ce1d6) SHA1(5b07fb8e8041e1663980aa35d853fdc13b22dac5) )
383   ROM_LOAD( "072-p01.17c",  0x30000, 0x20000, CRC(07ceeaea) SHA1(c18255ae1d578c2d53de80d6323cdf41cbe47b57) )
384   ROM_LOAD( "072-013.13c",  0x50000, 0x20000, CRC(8781105a) SHA1(ef2f16f7a56d3715536511c674df4b3aab1be2bd) )
385   ROM_LOAD( "072-012.15c",  0x70000, 0x18000, CRC(244f9289) SHA1(eeda7f5c7340cbd1a1cd576af48cd5d1a629914a) )
386   ROM_CONTINUE(        0x08000, 0x08000 )
387387
388388   ROM_REGION( 0x28000, REGION_CPU2, 0 ) /* Z80 code + banks */
389   ROM_LOAD( "072-g03.6g",       0x00000, 0x08000, CRC(76c1850c) SHA1(9047c6b26c4e33c74eb7400a807d3d9f206f7bbe) )
390   ROM_CONTINUE(            0x10000, 0x18000 )
389   ROM_LOAD( "072-g03.6g", 0x00000, 0x08000, CRC(76c1850c) SHA1(9047c6b26c4e33c74eb7400a807d3d9f206f7bbe) )
390   ROM_CONTINUE(      0x10000, 0x18000 )
391391
392392   ROM_REGION( 0x100000, REGION_GFX1, 0 ) /* graphics ( dont dispose as the program can read them, 0 ) */
393393   ROM_LOAD( "072-b07.18h", 0x000000, 0x080000, CRC(ba1ec910) SHA1(0805ccb641271dea43185dc0365732260db1763d) )   /* tiles */
r1478r1479
404404   ROM_LOAD( "072-d04.1d", 0x100000, 0x040000, CRC(78778013) SHA1(edbd6d83b0d1a20df39bb160b92395586fa3c32d) )
405405ROM_END
406406
407ROM_START( simps2pa )
407ROM_START( simps2pa ) /* World 2 Player, alt */
408408   ROM_REGION( 0x8b000, REGION_CPU1, 0 ) /* code + banked roms + banked ram */
409        ROM_LOAD( "072-g02.16c",      0x010000, 0x020000, CRC(580ce1d6) SHA1(5b07fb8e8041e1663980aa35d853fdc13b22dac5) )
410        ROM_LOAD( "simp1.17c",        0x030000, 0x020000, CRC(07ceeaea) SHA1(c18255ae1d578c2d53de80d6323cdf41cbe47b57) )
411        ROM_LOAD( "simp4.13c",        0x050000, 0x020000, CRC(54e6df66) SHA1(1b83ae56cf1deb51b04880fa421f06568c938a99) )
412        ROM_LOAD( "simp3.15c",        0x070000, 0x018000, CRC(96636225) SHA1(5de95606e5c9337f18bc42f4df791cacafa20399) )
413   ROM_CONTINUE(            0x08000, 0x08000 )
409        ROM_LOAD( "072-g02.16c", 0x10000, 0x20000, CRC(580ce1d6) SHA1(5b07fb8e8041e1663980aa35d853fdc13b22dac5) )
410   ROM_LOAD( "072-p01.17c", 0x30000, 0x20000, CRC(07ceeaea) SHA1(c18255ae1d578c2d53de80d6323cdf41cbe47b57) )
411        ROM_LOAD( "072-_13.13c", 0x50000, 0x20000, CRC(54e6df66) SHA1(1b83ae56cf1deb51b04880fa421f06568c938a99) ) /* Uknown revision/region code */
412        ROM_LOAD( "072-_12.15c", 0x70000, 0x18000, CRC(96636225) SHA1(5de95606e5c9337f18bc42f4df791cacafa20399) ) /* Uknown revision/region code */
413   ROM_CONTINUE(       0x08000, 0x08000 )
414414
415415   ROM_REGION( 0x28000, REGION_CPU2, 0 ) /* Z80 code + banks */
416   ROM_LOAD( "072-g03.6g",       0x00000, 0x08000, CRC(76c1850c) SHA1(9047c6b26c4e33c74eb7400a807d3d9f206f7bbe) )
417   ROM_CONTINUE(            0x10000, 0x18000 )
416   ROM_LOAD( "072-g03.6g", 0x00000, 0x08000, CRC(76c1850c) SHA1(9047c6b26c4e33c74eb7400a807d3d9f206f7bbe) )
417   ROM_CONTINUE(      0x10000, 0x18000 )
418418
419419   ROM_REGION( 0x100000, REGION_GFX1, 0 ) /* graphics ( dont dispose as the program can read them, 0 ) */
420420   ROM_LOAD( "072-b07.18h", 0x000000, 0x080000, CRC(ba1ec910) SHA1(0805ccb641271dea43185dc0365732260db1763d) )   /* tiles */
r1478r1479
431431   ROM_LOAD( "072-d04.1d", 0x100000, 0x040000, CRC(78778013) SHA1(edbd6d83b0d1a20df39bb160b92395586fa3c32d) )
432432ROM_END
433433
434ROM_START( simps2pj )
434ROM_START( simp2pa ) /* Asia 2 Player */
435435   ROM_REGION( 0x8b000, REGION_CPU1, 0 ) /* code + banked roms + banked ram */
436   ROM_LOAD( "072-s02.16c",      0x10000, 0x20000, CRC(265f7a47) SHA1(d39c19a5e303f822313409343b209947f4c47ae4) )
437   ROM_LOAD( "072-t01.17c",      0x30000, 0x20000, CRC(91de5c2d) SHA1(1e18a5585ed821ec7cda69bdcdbfa4e6c71455c6) )
438   ROM_LOAD( "072-213.13c",      0x50000, 0x20000, CRC(b326a9ae) SHA1(f222c33f2e8b306f2f0ef6f0da9febbf8219e1a4) )
439   ROM_LOAD( "072-212.15c",      0x70000, 0x18000, CRC(584d9d37) SHA1(61b9df4dfb323b7284894e5e1eb9d713ebf64721) )
440   ROM_CONTINUE(            0x08000, 0x08000 )
436   ROM_LOAD( "072-g02.16c", 0x10000, 0x20000, CRC(580ce1d6) SHA1(5b07fb8e8041e1663980aa35d853fdc13b22dac5) ) /* Same as both world 2p sets */
437   ROM_LOAD( "072-p01.17c", 0x30000, 0x20000, CRC(07ceeaea) SHA1(c18255ae1d578c2d53de80d6323cdf41cbe47b57) ) /* Same as both world 2p sets */
438   ROM_LOAD( "072-113.13c", 0x50000, 0x20000, CRC(8781105a) SHA1(ef2f16f7a56d3715536511c674df4b3aab1be2bd) ) /* Same as world set simpsn2p */
439   ROM_LOAD( "072-112.15c", 0x70000, 0x18000, CRC(3bd69404) SHA1(e055fed7e9bde8315ae2f9b2d35bc05fece6b80b) )
440   ROM_CONTINUE(       0x08000, 0x08000 )
441441
442442   ROM_REGION( 0x28000, REGION_CPU2, 0 ) /* Z80 code + banks */
443   ROM_LOAD( "072-g03.6g",       0x00000, 0x08000, CRC(76c1850c) SHA1(9047c6b26c4e33c74eb7400a807d3d9f206f7bbe) )
444   ROM_CONTINUE(            0x10000, 0x18000 )
443   ROM_LOAD( "072-e03.6g", 0x00000, 0x08000, CRC(866b7a35) SHA1(98905764eb4c7d968ccc17618a1f24ee12e33c0e) )
444   ROM_CONTINUE(      0x10000, 0x18000 )
445445
446446   ROM_REGION( 0x100000, REGION_GFX1, 0 ) /* graphics ( dont dispose as the program can read them, 0 ) */
447447   ROM_LOAD( "072-b07.18h", 0x000000, 0x080000, CRC(ba1ec910) SHA1(0805ccb641271dea43185dc0365732260db1763d) )   /* tiles */
r1478r1479
458458   ROM_LOAD( "072-d04.1d", 0x100000, 0x040000, CRC(78778013) SHA1(edbd6d83b0d1a20df39bb160b92395586fa3c32d) )
459459ROM_END
460460
461ROM_START( simps2pj ) /* Japan 2 Player */
462   ROM_REGION( 0x8b000, REGION_CPU1, 0 ) /* code + banked roms + banked ram */
463   ROM_LOAD( "072-s02.16c", 0x10000, 0x20000, CRC(265f7a47) SHA1(d39c19a5e303f822313409343b209947f4c47ae4) )
464   ROM_LOAD( "072-t01.17c", 0x30000, 0x20000, CRC(91de5c2d) SHA1(1e18a5585ed821ec7cda69bdcdbfa4e6c71455c6) )
465   ROM_LOAD( "072-213.13c", 0x50000, 0x20000, CRC(b326a9ae) SHA1(f222c33f2e8b306f2f0ef6f0da9febbf8219e1a4) )
466   ROM_LOAD( "072-212.15c", 0x70000, 0x18000, CRC(584d9d37) SHA1(61b9df4dfb323b7284894e5e1eb9d713ebf64721) )
467   ROM_CONTINUE(       0x08000, 0x08000 )
461468
469   ROM_REGION( 0x28000, REGION_CPU2, 0 ) /* Z80 code + banks */
470   ROM_LOAD( "072-g03.6g", 0x00000, 0x08000, CRC(76c1850c) SHA1(9047c6b26c4e33c74eb7400a807d3d9f206f7bbe) )
471   ROM_CONTINUE(      0x10000, 0x18000 )
462472
473   ROM_REGION( 0x100000, REGION_GFX1, 0 ) /* graphics ( dont dispose as the program can read them, 0 ) */
474   ROM_LOAD( "072-b07.18h", 0x000000, 0x080000, CRC(ba1ec910) SHA1(0805ccb641271dea43185dc0365732260db1763d) )   /* tiles */
475   ROM_LOAD( "072-b06.16h", 0x080000, 0x080000, CRC(cf2bbcab) SHA1(47afea47f9bc8cb5eb1c7b7fbafe954b3e749aeb) )
476
477   ROM_REGION( 0x400000, REGION_GFX2, 0 ) /* graphics ( dont dispose as the program can read them, 0 ) */
478   ROM_LOAD( "072-b08.3n",  0x000000, 0x100000, CRC(7de500ad) SHA1(61b76b8f402e3bde1509679aaaa28ef08cafb0ab) )   /* sprites */
479   ROM_LOAD( "072-b09.8n",  0x100000, 0x100000, CRC(aa085093) SHA1(925239d79bf607021d371263352618876f59c1f8) )
480   ROM_LOAD( "072-b10.12n", 0x200000, 0x100000, CRC(577dbd53) SHA1(e603e03e3dcba766074561faa92afafa5761953d) )
481   ROM_LOAD( "072-b11.16l", 0x300000, 0x100000, CRC(55fab05d) SHA1(54db8559d71ed257de9a29c8808654eaea0df9e2) )
482
483   ROM_REGION( 0x140000, REGION_SOUND1, 0 ) /* samples for the 053260 */
484   ROM_LOAD( "072-d05.1f", 0x000000, 0x100000, CRC(1397a73b) SHA1(369422c84cca5472967af54b8351e29fcd69f621) )
485   ROM_LOAD( "072-d04.1d", 0x100000, 0x040000, CRC(78778013) SHA1(edbd6d83b0d1a20df39bb160b92395586fa3c32d) )
486ROM_END
487
463488/***************************************************************************
464489
465490  Game driver(s)
r1478r1479
472497   konami_rom_deinterleave_4(REGION_GFX2);
473498}
474499
475GAME( 1991, simpsons, 0,        simpsons, simpsons, simpsons, ROT0, "Konami", "The Simpsons (4 Players)", 0 )
476GAME( 1991, simps4pa, simpsons, simpsons, simpsons, simpsons, ROT0, "Konami", "The Simpsons (4 Players alt)", 0 )
477GAME( 1991, simpsn2p, simpsons, simpsons, simpsn2p, simpsons, ROT0, "Konami", "The Simpsons (2 Players)", 0 )
478GAME( 1991, simps2pa, simpsons, simpsons, simpsons, simpsons, ROT0, "Konami", "The Simpsons (2 Players alt)", 0 )
500// the region warning, if one exists, is shown after the high-score screen in attract mode
501GAME( 1991, simpsons, 0,        simpsons, simpsons, simpsons, ROT0, "Konami", "The Simpsons (4 Players World, set 1)", 0 )
502GAME( 1991, simps4pa, simpsons, simpsons, simpsons, simpsons, ROT0, "Konami", "The Simpsons (4 Players World, set 2)", 0 )
503GAME( 1991, simpsn2p, simpsons, simpsons, simpsn2p, simpsons, ROT0, "Konami", "The Simpsons (2 Players World, set 1)", 0 )
504GAME( 1991, simps2pa, simpsons, simpsons, simpsons, simpsons, ROT0, "Konami", "The Simpsons (2 Players World, set 2)", 0 )
505GAME( 1991, simp2pa,  simpsons, simpsons, simpsn2p, simpsons, ROT0, "Konami", "The Simpsons (2 Players Asia)", 0 )
479506GAME( 1991, simps2pj, simpsons, simpsons, simpsn2p, simpsons, ROT0, "Konami", "The Simpsons (2 Players Japan)", 0 )
src/mame/drivers/namcos11.c
r1478r1479
273273
274274#define VERBOSE_LEVEL ( 0 )
275275
276INLINE void verboselog( int n_level, const char *s_fmt, ... )
276INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
277277{
278278   if( VERBOSE_LEVEL >= n_level )
279279   {
src/mame/drivers/itech8.c
r1478r1479
13911391
13921392   PORT_START   /* 60 */
13931393   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN3 )
1394   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("P2 Soft") PORT_PLAYER(1)
1394   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("P1 Soft") PORT_PLAYER(1)
13951395   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)
13961396   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)
13971397   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)
src/mame/drivers/flstory.c
r1478r1479
3333WRITE8_HANDLER( flstory_gfxctrl_w );
3434READ8_HANDLER( flstory_scrlram_r );
3535WRITE8_HANDLER( flstory_scrlram_w );
36READ8_HANDLER( victnine_gfxctrl_r );
3637WRITE8_HANDLER( victnine_gfxctrl_w );
3738
3839READ8_HANDLER( flstory_68705_portA_r );
r1478r1479
5455READ8_HANDLER( victnine_mcu_r );
5556READ8_HANDLER( victnine_mcu_status_r );
5657
58UINT8 *onna34ro_workram;
59UINT8 *victnine_workram;
5760
5861static UINT8 snd_data;
5962static UINT8 snd_flag;
r1478r1479
106109   }
107110}
108111
109
110static ADDRESS_MAP_START( readmem, ADDRESS_SPACE_PROGRAM, 8 )
111   AM_RANGE(0x0000, 0xbfff) AM_READ(MRA8_ROM)
112   AM_RANGE(0xc000, 0xc7ff) AM_READ(MRA8_RAM)
113   AM_RANGE(0xc800, 0xcfff) AM_READ(MRA8_RAM) /* unknown */
114   AM_RANGE(0xd000, 0xd000) AM_READ(flstory_mcu_r)
115   AM_RANGE(0xd400, 0xd400) AM_READ(from_snd_r)
112static ADDRESS_MAP_START( flstory_map, ADDRESS_SPACE_PROGRAM, 8 )
113   AM_RANGE(0x0000, 0xbfff) AM_ROM
114   AM_RANGE(0xc000, 0xc7ff) AM_RAM AM_WRITE(flstory_videoram_w) AM_BASE(&videoram) AM_SIZE(&videoram_size)
115   AM_RANGE(0xc800, 0xcfff) AM_RAM /* unknown */
116   AM_RANGE(0xd000, 0xd000) AM_READWRITE(flstory_mcu_r, flstory_mcu_w)
117   AM_RANGE(0xd001, 0xd001) AM_WRITENOP   /* watchdog? */
118   AM_RANGE(0xd002, 0xd002) AM_WRITENOP   /* coin lock out? */
119   AM_RANGE(0xd400, 0xd400) AM_READWRITE(from_snd_r, sound_command_w)
116120   AM_RANGE(0xd401, 0xd401) AM_READ(snd_flag_r)
117   AM_RANGE(0xd403, 0xd403) AM_READ(MRA8_NOP) /* unknown */
121   AM_RANGE(0xd403, 0xd403) AM_NOP   /* unknown */
118122   AM_RANGE(0xd800, 0xd800) AM_READ(input_port_0_r)
119123   AM_RANGE(0xd801, 0xd801) AM_READ(input_port_1_r)
120124   AM_RANGE(0xd802, 0xd802) AM_READ(input_port_2_r)
r1478r1479
122126   AM_RANGE(0xd804, 0xd804) AM_READ(input_port_4_r)
123127   AM_RANGE(0xd805, 0xd805) AM_READ(flstory_mcu_status_r)
124128   AM_RANGE(0xd806, 0xd806) AM_READ(input_port_5_r)
125   AM_RANGE(0xdc00, 0xdcff) AM_READ(MRA8_RAM) /* spriteram / scrollram */
126   AM_RANGE(0xdd00, 0xdeff) AM_READ(flstory_palette_r)
127   AM_RANGE(0xe000, 0xe7ff) AM_READ(MRA8_RAM)
128ADDRESS_MAP_END
129
130static ADDRESS_MAP_START( writemem, ADDRESS_SPACE_PROGRAM, 8 )
131   AM_RANGE(0x0000, 0xbfff) AM_WRITE(MWA8_ROM)
132   AM_RANGE(0xc000, 0xc7ff) AM_WRITE(flstory_videoram_w) AM_BASE(&videoram) AM_SIZE(&videoram_size)
133   AM_RANGE(0xc800, 0xcfff) AM_WRITE(MWA8_RAM)
134   AM_RANGE(0xd000, 0xd000) AM_WRITE(flstory_mcu_w)
135   AM_RANGE(0xd001, 0xd001) AM_WRITE(MWA8_NOP)   /* watchdog? */
136   AM_RANGE(0xd002, 0xd002) AM_WRITE(MWA8_NOP)   /* coin lock out? */
137   AM_RANGE(0xd400, 0xd400) AM_WRITE(sound_command_w)
138   AM_RANGE(0xd403, 0xd403) AM_WRITE(MWA8_NOP)   /* unknown */
139129//  AM_RANGE(0xda00, 0xda00) AM_WRITE(MWA8_RAM)
140   AM_RANGE(0xdc00, 0xdc9f) AM_WRITE(MWA8_RAM) AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
141   AM_RANGE(0xdca0, 0xdcbf) AM_WRITE(flstory_scrlram_w) AM_BASE(&flstory_scrlram)
142   AM_RANGE(0xdcc0, 0xdcff) AM_WRITE(MWA8_RAM) /* unknown */
143   AM_RANGE(0xdd00, 0xdeff) AM_WRITE(flstory_palette_w)
130   AM_RANGE(0xdc00, 0xdc9f) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
131   AM_RANGE(0xdca0, 0xdcbf) AM_RAM AM_WRITE(flstory_scrlram_w) AM_BASE(&flstory_scrlram)
132   AM_RANGE(0xdcc0, 0xdcff) AM_RAM /* unknown */
133   AM_RANGE(0xdd00, 0xdeff) AM_READWRITE(flstory_palette_r, flstory_palette_w)
144134   AM_RANGE(0xdf03, 0xdf03) AM_WRITE(flstory_gfxctrl_w)
145   AM_RANGE(0xe000, 0xe7ff) AM_WRITE(MWA8_RAM)   /* work RAM */
135   AM_RANGE(0xe000, 0xe7ff) AM_RAM   /* work RAM */
146136ADDRESS_MAP_END
147137
148static ADDRESS_MAP_START( onna34ro_readmem, ADDRESS_SPACE_PROGRAM, 8 )
149   AM_RANGE(0x0000, 0xbfff) AM_READ(MRA8_ROM)
150   AM_RANGE(0xc000, 0xc7ff) AM_READ(MRA8_RAM)
151   AM_RANGE(0xc800, 0xcfff) AM_READ(MRA8_RAM) /* unknown */
152   AM_RANGE(0xd000, 0xd000) AM_READ(onna34ro_mcu_r)
153   AM_RANGE(0xd400, 0xd400) AM_READ(from_snd_r)
138static ADDRESS_MAP_START( onna34ro_map, ADDRESS_SPACE_PROGRAM, 8 )
139   AM_RANGE(0x0000, 0xbfff) AM_ROM
140   AM_RANGE(0xc000, 0xc7ff) AM_RAM AM_WRITE(flstory_videoram_w) AM_BASE(&videoram) AM_SIZE(&videoram_size)
141   AM_RANGE(0xc800, 0xcfff) AM_RAM   /* unknown */
142   AM_RANGE(0xd000, 0xd000) AM_READWRITE(onna34ro_mcu_r, onna34ro_mcu_w)
143   AM_RANGE(0xd001, 0xd001) AM_WRITENOP   /* watchdog? */
144   AM_RANGE(0xd002, 0xd002) AM_WRITENOP   /* coin lock out? */
145   AM_RANGE(0xd400, 0xd400) AM_READWRITE(from_snd_r, sound_command_w)
154146   AM_RANGE(0xd401, 0xd401) AM_READ(snd_flag_r)
155   AM_RANGE(0xd403, 0xd403) AM_READ(MRA8_NOP) /* unknown */
147   AM_RANGE(0xd403, 0xd403) AM_NOP   /* unknown */
156148   AM_RANGE(0xd800, 0xd800) AM_READ(input_port_0_r)
157149   AM_RANGE(0xd801, 0xd801) AM_READ(input_port_1_r)
158150   AM_RANGE(0xd802, 0xd802) AM_READ(input_port_2_r)
r1478r1479
160152   AM_RANGE(0xd804, 0xd804) AM_READ(input_port_4_r)
161153   AM_RANGE(0xd805, 0xd805) AM_READ(onna34ro_mcu_status_r)
162154   AM_RANGE(0xd806, 0xd806) AM_READ(input_port_5_r)
163   AM_RANGE(0xdc00, 0xdcff) AM_READ(MRA8_RAM) /* spriteram / scrollram */
164   AM_RANGE(0xdd00, 0xdeff) AM_READ(flstory_palette_r)
165   AM_RANGE(0xe000, 0xe7ff) AM_READ(MRA8_RAM)
166ADDRESS_MAP_END
167
168static ADDRESS_MAP_START( onna34ro_writemem, ADDRESS_SPACE_PROGRAM, 8 )
169   AM_RANGE(0x0000, 0xbfff) AM_WRITE(MWA8_ROM)
170   AM_RANGE(0xc000, 0xc7ff) AM_WRITE(flstory_videoram_w) AM_BASE(&videoram) AM_SIZE(&videoram_size)
171   AM_RANGE(0xc800, 0xcfff) AM_WRITE(MWA8_RAM)
172   AM_RANGE(0xd000, 0xd000) AM_WRITE(onna34ro_mcu_w)
173   AM_RANGE(0xd001, 0xd001) AM_WRITE(MWA8_NOP)   /* watchdog? */
174   AM_RANGE(0xd002, 0xd002) AM_WRITE(MWA8_NOP)   /* coin lock out? */
175   AM_RANGE(0xd400, 0xd400) AM_WRITE(sound_command_w)
176   AM_RANGE(0xd403, 0xd403) AM_WRITE(MWA8_NOP)   /* unknown */
177155//  AM_RANGE(0xda00, 0xda00) AM_WRITE(MWA8_RAM)
178   AM_RANGE(0xdc00, 0xdc9f) AM_WRITE(MWA8_RAM) AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
179   AM_RANGE(0xdca0, 0xdcbf) AM_WRITE(flstory_scrlram_w) AM_BASE(&flstory_scrlram)
180   AM_RANGE(0xdcc0, 0xdcff) AM_WRITE(MWA8_RAM) /* unknown */
181   AM_RANGE(0xdd00, 0xdeff) AM_WRITE(flstory_palette_w)
156   AM_RANGE(0xdc00, 0xdc9f) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
157   AM_RANGE(0xdca0, 0xdcbf) AM_RAM AM_WRITE(flstory_scrlram_w) AM_BASE(&flstory_scrlram)
158   AM_RANGE(0xdcc0, 0xdcff) AM_RAM /* unknown */
159   AM_RANGE(0xdd00, 0xdeff) AM_READWRITE(flstory_palette_r, flstory_palette_w)
182160   AM_RANGE(0xdf03, 0xdf03) AM_WRITE(flstory_gfxctrl_w)
183   AM_RANGE(0xe000, 0xe7ff) AM_WRITE(MWA8_RAM)   /* work RAM */
161   AM_RANGE(0xe000, 0xe7ff) AM_RAM   AM_BASE(&onna34ro_workram) /* work RAM */
184162ADDRESS_MAP_END
185163
186164static READ8_HANDLER( victnine_port_5_r )
r1478r1479
188166   return (victnine_mcu_status_r(0) & 3) | (readinputport(5) & ~3);
189167}
190168
191static ADDRESS_MAP_START( victnine_readmem, ADDRESS_SPACE_PROGRAM, 8 )
192   AM_RANGE(0x0000, 0xbfff) AM_READ(MRA8_ROM)
193   AM_RANGE(0xc000, 0xc7ff) AM_READ(MRA8_RAM)
194   AM_RANGE(0xc800, 0xcfff) AM_READ(MRA8_RAM) /* unknown */
195   AM_RANGE(0xd000, 0xd000) AM_READ(victnine_mcu_r)
196   AM_RANGE(0xd002, 0xd002) AM_READ(MRA8_NOP)   /* unknown */
197   AM_RANGE(0xd400, 0xd400) AM_READ(from_snd_r)
169static ADDRESS_MAP_START( victnine_map, ADDRESS_SPACE_PROGRAM, 8 )
170   AM_RANGE(0x0000, 0xbfff) AM_ROM
171   AM_RANGE(0xc000, 0xc7ff) AM_RAM AM_WRITE(flstory_videoram_w) AM_BASE(&videoram) AM_SIZE(&videoram_size)
172   AM_RANGE(0xc800, 0xcfff) AM_RAM   /* unknown */
173   AM_RANGE(0xd000, 0xd000) AM_READWRITE(victnine_mcu_r, victnine_mcu_w)
174   AM_RANGE(0xd001, 0xd001) AM_WRITENOP   /* watchdog? */
175   AM_RANGE(0xd002, 0xd002) AM_READWRITE(MRA8_NOP, MWA8_NOP)   /* unknown read & coin lock out? */
176   AM_RANGE(0xd400, 0xd400) AM_READWRITE(from_snd_r, sound_command_w)
198177   AM_RANGE(0xd401, 0xd401) AM_READ(snd_flag_r)
199   AM_RANGE(0xd403, 0xd403) AM_READ(MRA8_NOP) /* unknown */
178   AM_RANGE(0xd403, 0xd403) AM_READNOP /* unknown */
200179   AM_RANGE(0xd800, 0xd800) AM_READ(input_port_0_r)
201180   AM_RANGE(0xd801, 0xd801) AM_READ(input_port_1_r)
202181   AM_RANGE(0xd802, 0xd802) AM_READ(input_port_2_r)
r1478r1479
205184   AM_RANGE(0xd805, 0xd805) AM_READ(victnine_port_5_r)
206185   AM_RANGE(0xd806, 0xd806) AM_READ(input_port_6_r)
207186   AM_RANGE(0xd807, 0xd807) AM_READ(input_port_7_r)
208   AM_RANGE(0xdc00, 0xdcff) AM_READ(MRA8_RAM) /* spriteram / scrollram */
209   AM_RANGE(0xdd00, 0xdeff) AM_READ(flstory_palette_r)
210   AM_RANGE(0xe000, 0xe7ff) AM_READ(MRA8_RAM)
211ADDRESS_MAP_END
212
213static ADDRESS_MAP_START( victnine_writemem, ADDRESS_SPACE_PROGRAM, 8 )
214   AM_RANGE(0x0000, 0xbfff) AM_WRITE(MWA8_ROM)
215   AM_RANGE(0xc000, 0xc7ff) AM_WRITE(flstory_videoram_w) AM_BASE(&videoram) AM_SIZE(&videoram_size)
216   AM_RANGE(0xc800, 0xcfff) AM_WRITE(MWA8_RAM)
217   AM_RANGE(0xd000, 0xd000) AM_WRITE(victnine_mcu_w)
218   AM_RANGE(0xd001, 0xd001) AM_WRITE(MWA8_NOP)   /* watchdog? */
219   AM_RANGE(0xd002, 0xd002) AM_WRITE(MWA8_NOP)   /* coin lock out? */
220   AM_RANGE(0xd400, 0xd400) AM_WRITE(sound_command_w)
221187//  AM_RANGE(0xda00, 0xda00) AM_WRITE(MWA8_RAM)
222   AM_RANGE(0xdc00, 0xdc9f) AM_WRITE(MWA8_RAM) AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
223   AM_RANGE(0xdca0, 0xdcbf) AM_WRITE(flstory_scrlram_w) AM_BASE(&flstory_scrlram)
224   AM_RANGE(0xdce0, 0xdce0) AM_WRITE(victnine_gfxctrl_w)
225   AM_RANGE(0xdce1, 0xdce1) AM_WRITE(MWA8_NOP)   /* unknown */
226   AM_RANGE(0xdd00, 0xdeff) AM_WRITE(flstory_palette_w)
227   AM_RANGE(0xe000, 0xe7ff) AM_WRITE(MWA8_RAM)   /* work RAM */
188   AM_RANGE(0xdc00, 0xdc9f) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
189   AM_RANGE(0xdca0, 0xdcbf) AM_RAM AM_WRITE(flstory_scrlram_w) AM_BASE(&flstory_scrlram)
190   AM_RANGE(0xdce0, 0xdce0) AM_READWRITE(victnine_gfxctrl_r, victnine_gfxctrl_w)
191   AM_RANGE(0xdce1, 0xdce1) AM_WRITENOP   /* unknown */
192   AM_RANGE(0xdd00, 0xdeff) AM_READWRITE(flstory_palette_r, flstory_palette_w)
193   AM_RANGE(0xe000, 0xe7ff) AM_RAM   AM_BASE(&victnine_workram) /* work RAM */
228194ADDRESS_MAP_END
229195
230static ADDRESS_MAP_START( sound_readmem, ADDRESS_SPACE_PROGRAM, 8 )
231   AM_RANGE(0x0000, 0xbfff) AM_READ(MRA8_ROM)
232   AM_RANGE(0xc000, 0xc7ff) AM_READ(MRA8_RAM)
233   AM_RANGE(0xd800, 0xd800) AM_READ(soundlatch_r)
234   AM_RANGE(0xda00, 0xda00) AM_READ(MRA8_NOP) /* unknown */
235   AM_RANGE(0xde00, 0xde00) AM_READ(MRA8_NOP) /* unknown */
236   AM_RANGE(0xe000, 0xefff) AM_READ(MRA8_ROM)   /* space for diagnostics ROM */
237ADDRESS_MAP_END
238
239196static int vol_ctrl[16];
240197
241198static MACHINE_RESET( ta7630 )
r1478r1479
301258}
302259
303260
304static ADDRESS_MAP_START( sound_writemem, ADDRESS_SPACE_PROGRAM, 8 )
305   AM_RANGE(0x0000, 0xbfff) AM_WRITE(MWA8_ROM)
306   AM_RANGE(0xc000, 0xc7ff) AM_WRITE(MWA8_RAM)
261static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 )
262   AM_RANGE(0x0000, 0xbfff) AM_ROM
263   AM_RANGE(0xc000, 0xc7ff) AM_RAM
307264   AM_RANGE(0xc800, 0xc800) AM_WRITE(AY8910_control_port_0_w)
308265   AM_RANGE(0xc801, 0xc801) AM_WRITE(AY8910_write_port_0_w)
309266   AM_RANGE(0xca00, 0xca0d) AM_WRITE(MSM5232_0_w)
310267   AM_RANGE(0xcc00, 0xcc00) AM_WRITE(sound_control_0_w)
311268   AM_RANGE(0xce00, 0xce00) AM_WRITE(sound_control_1_w)
312   AM_RANGE(0xd800, 0xd800) AM_WRITE(to_main_w)
313   AM_RANGE(0xda00, 0xda00) AM_WRITE(nmi_enable_w)
269   AM_RANGE(0xd800, 0xd800) AM_READWRITE(soundlatch_r, to_main_w)
270   AM_RANGE(0xda00, 0xda00) AM_READWRITE(MRA8_NOP, nmi_enable_w)         /* unknown read*/
314271   AM_RANGE(0xdc00, 0xdc00) AM_WRITE(nmi_disable_w)
315   AM_RANGE(0xde00, 0xde00) AM_WRITE(DAC_0_signed_data_w)      /* signed 8-bit DAC */
316   AM_RANGE(0xe000, 0xefff) AM_WRITE(MWA8_ROM)
272   AM_RANGE(0xde00, 0xde00) AM_READWRITE(MRA8_NOP, DAC_0_signed_data_w)   /* signed 8-bit DAC &  unknown read */
273   AM_RANGE(0xe000, 0xefff) AM_ROM                                 /* space for diagnostics ROM */
317274ADDRESS_MAP_END
318275
319static ADDRESS_MAP_START( m68705_readmem, ADDRESS_SPACE_PROGRAM, 8 )
276static ADDRESS_MAP_START( flstory_m68705_map, ADDRESS_SPACE_PROGRAM, 8 )
320277   ADDRESS_MAP_FLAGS( AMEF_ABITS(11) )
321   AM_RANGE(0x0000, 0x0000) AM_READ(flstory_68705_portA_r)
322   AM_RANGE(0x0001, 0x0001) AM_READ(flstory_68705_portB_r)
323   AM_RANGE(0x0002, 0x0002) AM_READ(flstory_68705_portC_r)
324   AM_RANGE(0x0010, 0x007f) AM_READ(MRA8_RAM)
325   AM_RANGE(0x0080, 0x07ff) AM_READ(MRA8_ROM)
326ADDRESS_MAP_END
327
328static ADDRESS_MAP_START( m68705_writemem, ADDRESS_SPACE_PROGRAM, 8 )
329   ADDRESS_MAP_FLAGS( AMEF_ABITS(11) )
330   AM_RANGE(0x0000, 0x0000) AM_WRITE(flstory_68705_portA_w)
331   AM_RANGE(0x0001, 0x0001) AM_WRITE(flstory_68705_portB_w)
332   AM_RANGE(0x0002, 0x0002) AM_WRITE(flstory_68705_portC_w)
278   AM_RANGE(0x0000, 0x0000) AM_READWRITE(flstory_68705_portA_r, flstory_68705_portA_w)
279   AM_RANGE(0x0001, 0x0001) AM_READWRITE(flstory_68705_portB_r, flstory_68705_portB_w)
280   AM_RANGE(0x0002, 0x0002) AM_READWRITE(flstory_68705_portC_r, flstory_68705_portC_w)
333281   AM_RANGE(0x0004, 0x0004) AM_WRITE(flstory_68705_ddrA_w)
334282   AM_RANGE(0x0005, 0x0005) AM_WRITE(flstory_68705_ddrB_w)
335283   AM_RANGE(0x0006, 0x0006) AM_WRITE(flstory_68705_ddrC_w)
336   AM_RANGE(0x0010, 0x007f) AM_WRITE(MWA8_RAM)
337   AM_RANGE(0x0080, 0x07ff) AM_WRITE(MWA8_ROM)
284   AM_RANGE(0x0010, 0x007f) AM_RAM
285   AM_RANGE(0x0080, 0x07ff) AM_ROM
338286ADDRESS_MAP_END
339287
340288
r1478r1479
734682
735683   /* basic machine hardware */
736684   MDRV_CPU_ADD(Z80,10733000/2)      /* ??? */
737   MDRV_CPU_PROGRAM_MAP(readmem,writemem)
685   MDRV_CPU_PROGRAM_MAP(flstory_map,0)
738686   MDRV_CPU_VBLANK_INT(irq0_line_hold,1)
739687
740688   MDRV_CPU_ADD(Z80,8000000/2)
741689   /* audio CPU */      /* 4 MHz */
742   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
690   MDRV_CPU_PROGRAM_MAP(sound_map,0)
743691   MDRV_CPU_VBLANK_INT(irq0_line_hold,2)   /* IRQ generated by ??? */
744692                  /* NMI generated by the main CPU */
745693
746694   MDRV_CPU_ADD(M68705,4000000/M68705_CLOCK_DIVIDER)   /* ??? */
747   MDRV_CPU_PROGRAM_MAP(m68705_readmem,m68705_writemem)
695   MDRV_CPU_PROGRAM_MAP(flstory_m68705_map,0)
748696
749697   MDRV_SCREEN_REFRESH_RATE(60)
750698   MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION)
r1478r1479
782730
783731   /* basic machine hardware */
784732   MDRV_CPU_ADD(Z80,10733000/2)      /* ??? */
785   MDRV_CPU_PROGRAM_MAP(onna34ro_readmem,onna34ro_writemem)
733   MDRV_CPU_PROGRAM_MAP(onna34ro_map,0)
786734   MDRV_CPU_VBLANK_INT(irq0_line_hold,1)
787735
788736   MDRV_CPU_ADD(Z80,8000000/2)
789737   /* audio CPU */      /* 4 MHz */
790   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
738   MDRV_CPU_PROGRAM_MAP(sound_map,0)
791739   MDRV_CPU_VBLANK_INT(irq0_line_hold,2)   /* IRQ generated by ??? */
792740                  /* NMI generated by the main CPU */
793741//  MDRV_CPU_ADD(M68705,4000000/M68705_CLOCK_DIVIDER)  /* ??? */
r1478r1479
829777
830778   /* basic machine hardware */
831779   MDRV_CPU_ADD(Z80,8000000/2)      /* 4 MHz */
832   MDRV_CPU_PROGRAM_MAP(victnine_readmem,victnine_writemem)
780   MDRV_CPU_PROGRAM_MAP(victnine_map,0)
833781   MDRV_CPU_VBLANK_INT(irq0_line_hold,1)
834782
835783   MDRV_CPU_ADD(Z80,8000000/2)
836784   /* audio CPU */      /* 4 MHz */
837   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
785   MDRV_CPU_PROGRAM_MAP(sound_map,0)
838786   MDRV_CPU_VBLANK_INT(irq0_line_hold,2)   /* IRQ generated by ??? */
839787                  /* NMI generated by the main CPU */
840788//  MDRV_CPU_ADD(M68705,4000000/M68705_CLOCK_DIVIDER)  /* ??? */
src/mame/drivers/namcos12.c
r1478r1479
931931
932932#define VERBOSE_LEVEL ( 0 )
933933
934INLINE void verboselog( int n_level, const char *s_fmt, ... )
934INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
935935{
936936   if( VERBOSE_LEVEL >= n_level )
937937   {
src/mame/drivers/funkyjet.c
r1478r1479
467467
468468/******************************************************************************/
469469
470GAME( 1992, funkyjet, 0,        funkyjet, funkyjet, funkyjet, ROT0, "[Data East] (Mitchell license)", "Funky Jet (World)", 0 )
471GAME( 1992, funkyjej, funkyjet, funkyjet, funkyjej, funkyjet, ROT0, "Data East Corporation", "Funky Jet (Japan)", 0 )
472GAME( 1995, sotsugyo, 0,        funkyjet, sotsugyo, funkyjet, ROT0, "Mitchell (Atlus license)", "Sotsugyo Shousho", 0 )
470GAME( 1992, funkyjet, 0,        funkyjet, funkyjet, funkyjet, ROT0, "[Data East] (Mitchell license)", "Funky Jet (World)", GAME_SUPPORTS_SAVE )
471GAME( 1992, funkyjej, funkyjet, funkyjet, funkyjej, funkyjet, ROT0, "Data East Corporation", "Funky Jet (Japan)", GAME_SUPPORTS_SAVE )
472GAME( 1995, sotsugyo, 0,        funkyjet, sotsugyo, funkyjet, ROT0, "Mitchell (Atlus license)", "Sotsugyo Shousho", GAME_SUPPORTS_SAVE )
src/mame/drivers/btoads.c
r1478r1479
3535 *
3636 *************************************/
3737
38static MACHINE_START( btoads )
39{
40   state_save_register_global(main_to_sound_data);
41   state_save_register_global(main_to_sound_ready);
42   state_save_register_global(sound_to_main_data);
43   state_save_register_global(sound_to_main_ready);
44   state_save_register_global(sound_int_state);
45}
46
47
3848static MACHINE_RESET( btoads )
3949{
4050   tlc34076_reset(6);
r1478r1479
333343   MDRV_CPU_IO_MAP(sound_io_map,0)
334344   MDRV_CPU_PERIODIC_INT(irq0_line_assert, 183)
335345
346   MDRV_MACHINE_START(btoads)
336347   MDRV_MACHINE_RESET(btoads)
337348   MDRV_NVRAM_HANDLER(generic_1fill)
338349
r1478r1479
384395 *
385396 *************************************/
386397
387GAME( 1994, btoads, 0, btoads, btoads, 0,  ROT0, "Rare", "Battle Toads", 0 )
398GAME( 1994, btoads, 0, btoads, btoads, 0,  ROT0, "Rare", "Battle Toads", GAME_SUPPORTS_SAVE )
src/mame/drivers/seta.c
r1478r1479
73037303                                Orbs
73047304***************************************************************************/
73057305
7306/* The CPU clock has been verified/measured, PCB only has one OSC and it's 14.318180 MHz */
7307
73067308static MACHINE_DRIVER_START( orbs )
73077309
73087310   /* basic machine hardware */
7309   MDRV_CPU_ADD(M68000, 16000000)   /* 16 MHz or 14.318180MHz */
7311   MDRV_CPU_ADD(M68000, 14318180/2)   /* 7.143 MHz */
73107312   MDRV_CPU_PROGRAM_MAP(orbs_readmem,orbs_writemem)
73117313   MDRV_CPU_VBLANK_INT(seta_interrupt_1_and_2,SETA_INTERRUPTS_NUM)
73127314
r1478r1479
73277329   /* sound hardware */
73287330   MDRV_SPEAKER_STANDARD_STEREO("left", "right")
73297331
7330   MDRV_SOUND_ADD(X1_010, 16000000)   /* 16 MHz */
7332   MDRV_SOUND_ADD(X1_010, 14318180)   /* 14.318180 MHz */
73317333   MDRV_SOUND_CONFIG(seta_sound_intf)
73327334   MDRV_SOUND_ROUTE(0, "left", 1.0)
73337335   MDRV_SOUND_ROUTE(1, "right", 1.0)
src/mame/drivers/namcos1.c
r1478r1479
345345#include "sound/namco.h"
346346#include "sound/dac.h"
347347
348static int dac0_value, dac1_value, dac0_gain, dac1_gain;
349
350
348351/* from video */
349352VIDEO_START( namcos1 );
350353VIDEO_UPDATE( namcos1 );
r1478r1479
420423   coin_counter_w(1,data & 4);
421424}
422425
423static int dac0_value ,dac1_value, dac0_gain=0x80, dac1_gain=0x80;
424
425426static void namcos1_update_DACs(void)
426427{
427428   DAC_signed_data_16_w(0,0x8000 + (dac0_value * dac0_gain) + (dac1_value * dac1_gain));
428429}
429430
431void namcos1_init_DACs(void)
432{
433   dac0_value = 0;
434   dac1_value = 0;
435   dac0_gain=0x80;
436   dac1_gain=0x80;
437}
438
430439static WRITE8_HANDLER( namcos1_dac_gain_w )
431440{
432441   int value;
src/mame/drivers/toki.c
r1478r1479
88Coin inputs are handled by the sound CPU, so they don't work with sound
99disabled. Use the service switch instead.
1010
11--
12Mametesters bug tokiu056gre - "tokiu: "0000000" is always displayed as the top hiscore during gameplay,
13regardless of what it actually is. This does not happen in the other Toki sets."
1114
15Notes by bmcphail@vcmame.net, 1/1/2008
16
17Toki stores high score at $60008 in main ram (init code at $ADA, compared with player score at $1A1BA)
18Tokiu stores high score at $60010 instead (init code at $B16, equivalent compare code at $1a204), $60008
19is used for different purposes in many parts of the code.
20
21Both games feature a common routine ($1cba2 in toki, $1cbfa in tokiu) that prints the high score to screen,
22the problem is that the version in Tokiu has not been adjusted for the different high score location and
23it reads from the $68008 location instead of $680010.  From analysing the code I'm certain this is a bug
24in the original USA version code and not an emulation bug.
25
26
27
1228TODO
1329----
1430
src/mame/drivers/cninja.c
r1478r1479
3131
3232  Emulation by Bryan McPhail, mish@tendril.co.uk
3333
34Note about verision levels using Mutant Fighter as the example:
35  Version 1  HD-00
36  Version 2  HD-00-1
37  Version 3  HD-00-2
38  Version 4  HD-00-3
39    ect...
40
3441***************************************************************************/
3542
3643#include "driver.h"
r1478r1479
125132   logerror("%08x:  Unmapped IRQ write %d %04x\n",activecpu_get_pc(),offset,data);
126133}
127134
135static READ16_HANDLER( robo2_dip3_r ) { return readinputport(3); }
136
128137static READ16_HANDLER( robocop2_prot_r )
129138{
130139    switch (offset<<1) {
r1478r1479
244253   AM_RANGE(0x156000, 0x156fff) AM_READ(MRA16_RAM)
245254   AM_RANGE(0x15c000, 0x15c7ff) AM_READ(MRA16_RAM)
246255   AM_RANGE(0x15e000, 0x15e7ff) AM_READ(MRA16_RAM)
256   AM_RANGE(0x1f8000, 0x1f8001) AM_READ(robo2_dip3_r) /* Dipswitch #3 */
247257ADDRESS_MAP_END
248258
249259static ADDRESS_MAP_START( robocop2_writemem, ADDRESS_SPACE_PROGRAM, 16 )
r1478r1479
375385   AM_RANGE(0x9800, 0x9800) AM_WRITE(OKIM6295_data_0_w)
376386ADDRESS_MAP_END
377387
388/***********************************************************
389              Basic INPUT PORTS, DIPs
390***********************************************************/
391
392#define DATAEAST_2BUTTON \
393   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) \
394   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) \
395   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) \
396   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1) \
397   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) \
398   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) \
399   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNUSED ) \
400   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 ) \
401   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) \
402   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) \
403   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) \
404   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) \
405   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) \
406   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) \
407   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNUSED ) \
408   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 )
409
410#define DATAEAST_COINAGE \
411   PORT_DIPNAME( 0x0007, 0x0007, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SW1:1,2,3") \
412   PORT_DIPSETTING(      0x0000, DEF_STR( 3C_1C ) ) \
413   PORT_DIPSETTING(      0x0001, DEF_STR( 2C_1C ) ) \
414   PORT_DIPSETTING(      0x0007, DEF_STR( 1C_1C ) ) \
415   PORT_DIPSETTING(      0x0006, DEF_STR( 1C_2C ) ) \
416   PORT_DIPSETTING(      0x0005, DEF_STR( 1C_3C ) ) \
417   PORT_DIPSETTING(      0x0004, DEF_STR( 1C_4C ) ) \
418   PORT_DIPSETTING(      0x0003, DEF_STR( 1C_5C ) ) \
419   PORT_DIPSETTING(      0x0002, DEF_STR( 1C_6C ) ) \
420   PORT_DIPNAME( 0x0038, 0x0038, DEF_STR( Coin_B ) ) PORT_DIPLOCATION("SW1:4,5,6") \
421   PORT_DIPSETTING(      0x0000, DEF_STR( 3C_1C ) ) \
422   PORT_DIPSETTING(      0x0008, DEF_STR( 2C_1C ) ) \
423   PORT_DIPSETTING(      0x0038, DEF_STR( 1C_1C ) ) \
424   PORT_DIPSETTING(      0x0030, DEF_STR( 1C_2C ) ) \
425   PORT_DIPSETTING(      0x0028, DEF_STR( 1C_3C ) ) \
426   PORT_DIPSETTING(      0x0020, DEF_STR( 1C_4C ) ) \
427   PORT_DIPSETTING(      0x0018, DEF_STR( 1C_5C ) ) \
428   PORT_DIPSETTING(      0x0010, DEF_STR( 1C_6C ) )
429
378430/**********************************************************************************/
379431
380432static INPUT_PORTS_START( edrandy )
433
381434   PORT_START
382   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
383   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
384   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
385   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
386   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
387   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
388   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNUSED )
389   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 )
390   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
391   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
392   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
393   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
394   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
395   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
396   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNUSED )
397   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 )
435   DATAEAST_2BUTTON
398436
399437   PORT_START
400438   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
r1478r1479
402440   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
403441   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_VBLANK )
404442
405   PORT_START
406   PORT_DIPNAME( 0x0007, 0x0007, DEF_STR( Coin_A ) )
407   PORT_DIPSETTING(      0x0000, DEF_STR( 3C_1C ) )
408   PORT_DIPSETTING(      0x0001, DEF_STR( 2C_1C ) )
409   PORT_DIPSETTING(      0x0007, DEF_STR( 1C_1C ) )
410   PORT_DIPSETTING(      0x0006, DEF_STR( 1C_2C ) )
411   PORT_DIPSETTING(      0x0005, DEF_STR( 1C_3C ) )
412   PORT_DIPSETTING(      0x0004, DEF_STR( 1C_4C ) )
413   PORT_DIPSETTING(      0x0003, DEF_STR( 1C_5C ) )
414   PORT_DIPSETTING(      0x0002, DEF_STR( 1C_6C ) )
415   PORT_DIPNAME( 0x0038, 0x0038, DEF_STR( Coin_B ) )
416   PORT_DIPSETTING(      0x0000, DEF_STR( 3C_1C ) )
417   PORT_DIPSETTING(      0x0008, DEF_STR( 2C_1C ) )
418   PORT_DIPSETTING(      0x0038, DEF_STR( 1C_1C ) )
419   PORT_DIPSETTING(      0x0030, DEF_STR( 1C_2C ) )
420   PORT_DIPSETTING(      0x0028, DEF_STR( 1C_3C ) )
421   PORT_DIPSETTING(      0x0020, DEF_STR( 1C_4C ) )
422   PORT_DIPSETTING(      0x0018, DEF_STR( 1C_5C ) )
423   PORT_DIPSETTING(      0x0010, DEF_STR( 1C_6C ) )
424   PORT_DIPNAME( 0x0040, 0x0000, DEF_STR( Flip_Screen ) )
443   PORT_START_TAG("DSW")
444
445   DATAEAST_COINAGE
446
447   PORT_DIPNAME( 0x0040, 0x0000, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SW1:7")
425448   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
426449   PORT_DIPSETTING(      0x0040, DEF_STR( On ) )
427   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) )   /* Listed as "Don't Change" in the manual */
428   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
429   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
430   PORT_DIPNAME( 0x0300, 0x0300, "Player's Power" )   /* Energy */
450   PORT_DIPNAME( 0x0080, 0x0080, "Credit(s) to Start" ) PORT_DIPLOCATION("SW1:8") /* Also, if Coin A and B are on 1/1, 0x00 gives 2 to start, 1 to continue */
451   PORT_DIPSETTING(      0x0080, "1" )
452   PORT_DIPSETTING(      0x0000, "2" )
453
454   PORT_DIPNAME( 0x0300, 0x0300, "Player's Power" ) PORT_DIPLOCATION("SW2:1,2")   /* Energy */
431455   PORT_DIPSETTING(      0x0100, DEF_STR( Very_Low ) )   /* 2.5 */
432456   PORT_DIPSETTING(      0x0000, DEF_STR( Low ) )      /* 3 */
433457   PORT_DIPSETTING(      0x0300, DEF_STR( Medium ) )   /* 3.5 */
434458   PORT_DIPSETTING(      0x0200, DEF_STR( High ) )      /* 4.5 */
435   PORT_DIPNAME( 0x0c00, 0x0c00, DEF_STR( Difficulty ) )
459   PORT_DIPNAME( 0x0c00, 0x0c00, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW2:3,4")
436460   PORT_DIPSETTING(      0x0800, DEF_STR( Easy ) )
437461   PORT_DIPSETTING(      0x0c00, DEF_STR( Normal ) )
438462   PORT_DIPSETTING(      0x0400, DEF_STR( Hard ) )
439463   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
440   PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) )   /* Listed as "Don't Change" in the manual */
464   PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW2:5")   /* Listed as "Don't Change" in the manual */
441465   PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
442466   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
443   PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) )   /* Listed as "Don't Change" in the manual */
467   PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW2:6")   /* Listed as "Don't Change" in the manual */
444468   PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
445469   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
446   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Continues ) )
470   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Continues ) ) PORT_DIPLOCATION("SW2:7")
447471   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
448472   PORT_DIPSETTING(      0x4000, DEF_STR( On ) )
449   PORT_DIPNAME( 0x8000, 0x0000, DEF_STR( Demo_Sounds ) )
473   PORT_DIPNAME( 0x8000, 0x0000, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW2:8")
450474   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
451475   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
452476INPUT_PORTS_END
453477
478static INPUT_PORTS_START( edrandc )
479   PORT_INCLUDE(edrandy)
480
481   PORT_MODIFY("DSW")
482   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW1:8")   /* Listed as "Don't Change" in the manual */
483   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
484   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
485INPUT_PORTS_END
486
454487static INPUT_PORTS_START( cninja )
488
455489   PORT_START
456   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
457   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
458   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
459   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
460   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
461   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
462   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNUSED )
463   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 )
464   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
465   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
466   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
467   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
468   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
469   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
470   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNUSED )
471   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 )
490   DATAEAST_2BUTTON
472491
473492   PORT_START
474493   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
r1478r1479
476495   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
477496   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_VBLANK )
478497
479   PORT_START
480   PORT_DIPNAME( 0x0007, 0x0007, DEF_STR( Coin_A ) )
481   PORT_DIPSETTING(      0x0000, DEF_STR( 3C_1C ) )
482   PORT_DIPSETTING(      0x0001, DEF_STR( 2C_1C ) )
483   PORT_DIPSETTING(      0x0007, DEF_STR( 1C_1C ) )
484   PORT_DIPSETTING(      0x0006, DEF_STR( 1C_2C ) )
485   PORT_DIPSETTING(      0x0005, DEF_STR( 1C_3C ) )
486   PORT_DIPSETTING(      0x0004, DEF_STR( 1C_4C ) )
487   PORT_DIPSETTING(      0x0003, DEF_STR( 1C_5C ) )
488   PORT_DIPSETTING(      0x0002, DEF_STR( 1C_6C ) )
489   PORT_DIPNAME( 0x0038, 0x0038, DEF_STR( Coin_B ) )
490   PORT_DIPSETTING(      0x0000, DEF_STR( 3C_1C ) )
491   PORT_DIPSETTING(      0x0008, DEF_STR( 2C_1C ) )
492   PORT_DIPSETTING(      0x0038, DEF_STR( 1C_1C ) )
493   PORT_DIPSETTING(      0x0030, DEF_STR( 1C_2C ) )
494   PORT_DIPSETTING(      0x0028, DEF_STR( 1C_3C ) )
495   PORT_DIPSETTING(      0x0020, DEF_STR( 1C_4C ) )
496   PORT_DIPSETTING(      0x0018, DEF_STR( 1C_5C ) )
497   PORT_DIPSETTING(      0x0010, DEF_STR( 1C_6C ) )
498   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Flip_Screen ) )
498   PORT_START_TAG("DSW")   /* Dip switch bank 1 */
499
500   DATAEAST_COINAGE
501
502   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SW1:7")
499503   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
500504   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
501   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) )   /* If DS #1-#6 are all ON */
505   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW1:8")   /* If DS #1-#6 are all ON */
502506   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )      /*  Standard Coin Credit */
503507   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )      /*  2 Coins to Start / 1 Coin to Continue */
504   PORT_DIPNAME( 0x0300, 0x0300, DEF_STR( Lives ) )
508
509   PORT_DIPNAME( 0x0300, 0x0300, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW2:1,2") /* Dip switch bank 2 */
505510   PORT_DIPSETTING(      0x0100, "1" )
506511   PORT_DIPSETTING(      0x0000, "2" )
507512   PORT_DIPSETTING(      0x0300, "3" )
508513   PORT_DIPSETTING(      0x0200, "4" )
509   PORT_DIPNAME( 0x0c00, 0x0c00, DEF_STR( Difficulty ) )
514   PORT_DIPNAME( 0x0c00, 0x0c00, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW2:3,4")
510515   PORT_DIPSETTING(      0x0800, DEF_STR( Easy ) )
511516   PORT_DIPSETTING(      0x0c00, DEF_STR( Normal ) )
512517   PORT_DIPSETTING(      0x0400, DEF_STR( Hard ) )
513518   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
514   PORT_DIPNAME( 0x1000, 0x1000, "Restore Life Meter" )   /* Recovery of Life After Defeated Boss */
519   PORT_DIPNAME( 0x1000, 0x1000, "Restore Life Meter" ) PORT_DIPLOCATION("SW2:5")   /* Recovery of Life After Defeated Boss */
515520   PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
516521   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
517   PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) )   /* Listed as "Don't Change" in the manual */
522   PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW2:6")   /* Listed as "Don't Change" in the manual */
518523   PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
519524   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
520   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) )   /* Listed as "Don't Change" in the manual */
525   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW2:7")   /* Listed as "Don't Change" in the manual */
521526   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
522527   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
523   PORT_DIPNAME( 0x8000, 0x0000, DEF_STR( Demo_Sounds ) )
528   PORT_DIPNAME( 0x8000, 0x0000, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW2:8")
524529   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
525530   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
526531INPUT_PORTS_END
527532
528533static INPUT_PORTS_START( cninjau )
529   PORT_START
530   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
531   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
532   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
533   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
534   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
535   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
536   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNUSED )
537   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 )
538   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
539   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
540   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
541   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
542   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
543   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
544   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNUSED )
545   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 )
534   PORT_INCLUDE(cninja)
546535
547   PORT_START
548   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
549   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
550   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
551   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_VBLANK )
552
553   PORT_START
554   PORT_DIPNAME( 0x0007, 0x0007, DEF_STR( Coin_A ) )
555   PORT_DIPSETTING(      0x0000, DEF_STR( 3C_1C ) )
556   PORT_DIPSETTING(      0x0001, DEF_STR( 2C_1C ) )
557   PORT_DIPSETTING(      0x0007, DEF_STR( 1C_1C ) )
558   PORT_DIPSETTING(      0x0006, DEF_STR( 1C_2C ) )
559   PORT_DIPSETTING(      0x0005, DEF_STR( 1C_3C ) )
560   PORT_DIPSETTING(      0x0004, DEF_STR( 1C_4C ) )
561   PORT_DIPSETTING(      0x0003, DEF_STR( 1C_5C ) )
562   PORT_DIPSETTING(      0x0002, DEF_STR( 1C_6C ) )
563   PORT_DIPNAME( 0x0038, 0x0038, DEF_STR( Coin_B ) )
564   PORT_DIPSETTING(      0x0000, DEF_STR( 3C_1C ) )
565   PORT_DIPSETTING(      0x0008, DEF_STR( 2C_1C ) )
566   PORT_DIPSETTING(      0x0038, DEF_STR( 1C_1C ) )
567   PORT_DIPSETTING(      0x0030, DEF_STR( 1C_2C ) )
568   PORT_DIPSETTING(      0x0028, DEF_STR( 1C_3C ) )
569   PORT_DIPSETTING(      0x0020, DEF_STR( 1C_4C ) )
570   PORT_DIPSETTING(      0x0018, DEF_STR( 1C_5C ) )
571   PORT_DIPSETTING(      0x0010, DEF_STR( 1C_6C ) )
572   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Flip_Screen ) )
573   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
574   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
575   PORT_DIPNAME( 0x0080, 0x0080, "Credit(s) to Start" ) /* Also, if Coin A and B are on 1/1, 0x00 gives 2 to start, 1 to continue */
536   PORT_MODIFY("DSW")
537   PORT_DIPNAME( 0x0080, 0x0080, "Credit(s) to Start" ) PORT_DIPLOCATION("SW1:8") /* Also, if Coin A and B are on 1/1, 0x00 gives 2 to start, 1 to continue */
576538   PORT_DIPSETTING(      0x0080, "1" )
577539   PORT_DIPSETTING(      0x0000, "2" )
578   PORT_DIPNAME( 0x0300, 0x0300, DEF_STR( Lives ) )
579   PORT_DIPSETTING(      0x0100, "1" )
580   PORT_DIPSETTING(      0x0000, "2" )
581   PORT_DIPSETTING(      0x0300, "3" )
582   PORT_DIPSETTING(      0x0200, "4" )
583   PORT_DIPNAME( 0x0c00, 0x0c00, DEF_STR( Difficulty ) )
584   PORT_DIPSETTING(      0x0800, DEF_STR( Easy ) )
585   PORT_DIPSETTING(      0x0c00, DEF_STR( Normal ) )
586   PORT_DIPSETTING(      0x0400, DEF_STR( Hard ) )
587   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
588   PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) )   /* Listed as "Don't Change" in the manual */
589   PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
590   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
591   PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) )   /* Listed as "Don't Change" in the manual */
592   PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
593   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
594   PORT_DIPNAME( 0x4000, 0x4000, "Restore Life Meter" )   /* Life Meter Restored when Big Boss is Defeated */
595   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
596   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
597   PORT_DIPNAME( 0x8000, 0x0000, DEF_STR( Demo_Sounds ) )
598   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
599   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
600540INPUT_PORTS_END
601541
602542static INPUT_PORTS_START( robocop2 )
r1478r1479
624564   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
625565   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_VBLANK )
626566
627   PORT_START   /* Dip switch bank 1 */
628   PORT_DIPNAME( 0x0007, 0x0007, DEF_STR( Coin_A ) )
629   PORT_DIPSETTING(      0x0000, DEF_STR( 3C_1C ) )
630   PORT_DIPSETTING(      0x0001, DEF_STR( 2C_1C ) )
631   PORT_DIPSETTING(      0x0007, DEF_STR( 1C_1C ) )
632   PORT_DIPSETTING(      0x0006, DEF_STR( 1C_2C ) )
633   PORT_DIPSETTING(      0x0005, DEF_STR( 1C_3C ) )
634   PORT_DIPSETTING(      0x0004, DEF_STR( 1C_4C ) )
635   PORT_DIPSETTING(      0x0003, DEF_STR( 1C_5C ) )
636   PORT_DIPSETTING(      0x0002, DEF_STR( 1C_6C ) )
637   PORT_DIPNAME( 0x0038, 0x0038, DEF_STR( Coin_B ) )
638   PORT_DIPSETTING(      0x0000, DEF_STR( 3C_1C ) )
639   PORT_DIPSETTING(      0x0008, DEF_STR( 2C_1C ) )
640   PORT_DIPSETTING(      0x0038, DEF_STR( 1C_1C ) )
641   PORT_DIPSETTING(      0x0030, DEF_STR( 1C_2C ) )
642   PORT_DIPSETTING(      0x0028, DEF_STR( 1C_3C ) )
643   PORT_DIPSETTING(      0x0020, DEF_STR( 1C_4C ) )
644   PORT_DIPSETTING(      0x0018, DEF_STR( 1C_5C ) )
645   PORT_DIPSETTING(      0x0010, DEF_STR( 1C_6C ) )
646   PORT_DIPNAME( 0x0040, 0x0000, DEF_STR( Flip_Screen ) )
567   PORT_START_TAG("DSW")   /* Dip switch bank 1 */
568
569   DATAEAST_COINAGE
570
571   PORT_DIPNAME( 0x0040, 0x0000, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SW1:7")
647572   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
648573   PORT_DIPSETTING(      0x0040, DEF_STR( On ) )
649   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unused ) )
574   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unused ) ) PORT_DIPLOCATION("SW1:8")
650575   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
651576   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
652   PORT_DIPNAME( 0x0300, 0x0300, DEF_STR( Lives ) ) /* Dip switch bank 2 */
577
578   PORT_DIPNAME( 0x0300, 0x0300, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW2:1,2") /* Dip switch bank 2 */
653579   PORT_DIPSETTING(      0x0100, "1" )
654580   PORT_DIPSETTING(      0x0000, "2" )
655581   PORT_DIPSETTING(      0x0300, "3" )
656582   PORT_DIPSETTING(      0x0200, "4" )
657   PORT_DIPNAME( 0x0c00, 0x0c00, DEF_STR( Difficulty ) )
658   PORT_DIPSETTING(      0x0800, DEF_STR( Easy ) )
659   PORT_DIPSETTING(      0x0c00, DEF_STR( Normal ) )
660   PORT_DIPSETTING(      0x0400, DEF_STR( Hard ) )
661   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
662   PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) )
663   PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
664   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
665   PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) )
666   PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
667   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
668   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) )
669   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
670   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
671   PORT_DIPNAME( 0x8000, 0x0000, DEF_STR( Demo_Sounds ) )
583   PORT_DIPNAME( 0x0c00, 0x0c00, "Time" ) PORT_DIPLOCATION("SW2:3,4")
584   PORT_DIPSETTING(      0x0800, "400 Seconds" )
585   PORT_DIPSETTING(      0x0c00, "300 Seconds" )
586   PORT_DIPSETTING(      0x0400, "200 Seconds" )
587   PORT_DIPSETTING(      0x0000, "100 Seconds" )
588   PORT_DIPNAME( 0x3000, 0x3000, "Health" ) PORT_DIPLOCATION("SW2:5,6")
589   PORT_DIPSETTING(      0x0000, "17" )
590   PORT_DIPSETTING(      0x1000, "24" )
591   PORT_DIPSETTING(      0x3000, "33" )
592   PORT_DIPSETTING(      0x2000, "40" )
593   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Continues ) ) PORT_DIPLOCATION("SW2:7")
594   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
595   PORT_DIPSETTING(      0x4000, DEF_STR( On ) )
596   PORT_DIPNAME( 0x8000, 0x0000, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW2:8")
672597   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
673598   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
599
600   PORT_START
601   PORT_DIPNAME( 0x0003, 0x0003, "Bullets" ) PORT_DIPLOCATION("SW3:1,2")   /* Dip switch bank 3 */
602   PORT_DIPSETTING(      0x0000, "Least" )
603   PORT_DIPSETTING(      0x0001, "Less" )
604   PORT_DIPSETTING(      0x0003, DEF_STR( Normal ) )
605   PORT_DIPSETTING(      0x0002, "More" )
606   PORT_DIPNAME( 0x000c, 0x000c, "Enemy Movement" ) PORT_DIPLOCATION("SW3:3,4")
607   PORT_DIPSETTING(      0x0008, "Slow" )
608   PORT_DIPSETTING(      0x000c, DEF_STR( Normal ) )
609   PORT_DIPSETTING(      0x0004, "Fast" )
610   PORT_DIPSETTING(      0x0000, "Fastest" )
611   PORT_DIPNAME( 0x0030, 0x0030, "Enemy Strength" ) PORT_DIPLOCATION("SW3:5,6")
612   PORT_DIPSETTING(      0x0020, "Less" )
613   PORT_DIPSETTING(      0x0030, DEF_STR( Normal ) )
614   PORT_DIPSETTING(      0x0010, "More" )
615   PORT_DIPSETTING(      0x0000, "Most" )
616   PORT_DIPNAME( 0x0040, 0x0040, "Enemy Weapon Speed" ) PORT_DIPLOCATION("SW3:7")
617   PORT_DIPSETTING(      0x0040, DEF_STR( Normal ) )
618   PORT_DIPSETTING(      0x0000, "Fast" )
619   PORT_DIPNAME( 0x0080, 0x0080, "Game Over Message" ) PORT_DIPLOCATION("SW3:8") /* This refers to the system shut down text just before the actual "GAME OVER" */
620   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
621   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
674622INPUT_PORTS_END
675623
676624static INPUT_PORTS_START( mutantf )
625
677626   PORT_START
678   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
679   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
680   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
681   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
682   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
683   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
684   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNUSED )
685   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 )
686   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
687   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
688   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
689   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
690   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
691   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
692   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNUSED )
693   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 )
627   DATAEAST_2BUTTON
694628
695629   PORT_START
696630   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
r1478r1479
698632   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
699633   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_VBLANK )
700634
701   PORT_START
702   PORT_DIPNAME( 0x0007, 0x0007, DEF_STR( Coin_A ) )
703   PORT_DIPSETTING(      0x0000, DEF_STR( 3C_1C ) )
704   PORT_DIPSETTING(      0x0001, DEF_STR( 2C_1C ) )
705   PORT_DIPSETTING(      0x0007, DEF_STR( 1C_1C ) )
706   PORT_DIPSETTING(      0x0006, DEF_STR( 1C_2C ) )
707   PORT_DIPSETTING(      0x0005, DEF_STR( 1C_3C ) )
708   PORT_DIPSETTING(      0x0004, DEF_STR( 1C_4C ) )
709   PORT_DIPSETTING(      0x0003, DEF_STR( 1C_5C ) )
710   PORT_DIPSETTING(      0x0002, DEF_STR( 1C_6C ) )
711   PORT_DIPNAME( 0x0038, 0x0038, DEF_STR( Coin_B ) )
712   PORT_DIPSETTING(      0x0000, DEF_STR( 3C_1C ) )
713   PORT_DIPSETTING(      0x0008, DEF_STR( 2C_1C ) )
714   PORT_DIPSETTING(      0x0038, DEF_STR( 1C_1C ) )
715   PORT_DIPSETTING(      0x0030, DEF_STR( 1C_2C ) )
716   PORT_DIPSETTING(      0x0028, DEF_STR( 1C_3C ) )
717   PORT_DIPSETTING(      0x0020, DEF_STR( 1C_4C ) )
718   PORT_DIPSETTING(      0x0018, DEF_STR( 1C_5C ) )
719   PORT_DIPSETTING(      0x0010, DEF_STR( 1C_6C ) )
720   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Flip_Screen ) )
635   PORT_START_TAG("DSW")   /* Dip switch bank 1 */
636
637   DATAEAST_COINAGE
638
639   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SW1:7")
721640   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
722641   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
723   PORT_DIPNAME( 0x0080, 0x0080, "Continue Coin" )
724   PORT_DIPSETTING(      0x0080, DEF_STR( Normal ) )
725   PORT_DIPSETTING(      0x0000, "Two Coin Start" )
726   PORT_DIPNAME( 0x0300, 0x0300, "Timer Decrement" )
642   PORT_DIPNAME( 0x0080, 0x0080, "Credit(s) to Start" ) PORT_DIPLOCATION("SW1:8")
643   PORT_DIPSETTING(      0x0080, "1" )
644   PORT_DIPSETTING(      0x0000, "2" )
645
646   PORT_DIPNAME( 0x0300, 0x0300, "Timer Decrement" ) PORT_DIPLOCATION("SW2:1,2")
727647   PORT_DIPSETTING(      0x0100, "Slow" )
728648   PORT_DIPSETTING(      0x0300, DEF_STR( Normal ) )
729649   PORT_DIPSETTING(      0x0200, "Fast" )
730650   PORT_DIPSETTING(      0x0000, "Very Fast" )
731   PORT_DIPNAME( 0x0c00, 0x0c00, DEF_STR( Difficulty ) )
651   PORT_DIPNAME( 0x0c00, 0x0c00, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW2:3,4")
732652   PORT_DIPSETTING(      0x0800, DEF_STR( Easy ) )
733653   PORT_DIPSETTING(      0x0c00, DEF_STR( Normal ) )
734654   PORT_DIPSETTING(      0x0400, DEF_STR( Hard ) )
735655   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
736   PORT_DIPNAME( 0x3000, 0x3000, "Life Per Stage" )
656   PORT_DIPNAME( 0x3000, 0x3000, "Life Per Stage" ) PORT_DIPLOCATION("SW2:5,6")
737657   PORT_DIPSETTING(      0x0000, "Least" )
738658   PORT_DIPSETTING(      0x1000, "Little" )
739659   PORT_DIPSETTING(      0x2000, "Less" )
740660   PORT_DIPSETTING(      0x3000, DEF_STR( Normal ) )
741   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Continues ) )
661   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Continues ) ) PORT_DIPLOCATION("SW2:7")
742662   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
743663   PORT_DIPSETTING(      0x4000, DEF_STR( On ) )
744   PORT_DIPNAME( 0x8000, 0x0000, DEF_STR( Demo_Sounds ) )
664   PORT_DIPNAME( 0x8000, 0x0000, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW2:8")
745665   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
746666   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
747667INPUT_PORTS_END
r1478r1479
10881008
10891009/**********************************************************************************/
10901010
1091ROM_START( cninja )
1011ROM_START( cninja ) /* World ver 4 */
10921012   ROM_REGION( 0xc0000, REGION_CPU1, 0 ) /* 68000 code */
10931013   ROM_LOAD16_BYTE( "gn-02-3.1k", 0x00000, 0x20000, CRC(39aea12a) SHA1(5de4e26d2c03c559249720b6a204567673754774) )
10941014   ROM_LOAD16_BYTE( "gn-05-2.3k", 0x00001, 0x20000, CRC(0f4360ef) SHA1(d60b3377e818a037d0f94383dd207865853f529d) )
r1478r1479
11291049   ROM_LOAD( "mb7122h.7v", 0x00000,  0x400,  CRC(a1267336) SHA1(d11ea9d78526ac3c0dc6e57a2da5914273ad1e3f) )   /* Priority  Unused */
11301050ROM_END
11311051
1132ROM_START( cninja0 )
1052ROM_START( cninja1 ) /* World ver 1 */
11331053   ROM_REGION( 0xc0000, REGION_CPU1, 0 ) /* 68000 code */
11341054   ROM_LOAD16_BYTE( "gn-02.1k",  0x00000, 0x20000, CRC(ccc59524) SHA1(430ae28ca38ec6a97b00cc3dee02d57e073819d4) )
11351055   ROM_LOAD16_BYTE( "gn-05.3k",  0x00001, 0x20000, CRC(a002cbe4) SHA1(76f57e49fc41a779856f70feb14432a8ffd08bff) )
r1478r1479
11701090   ROM_LOAD( "mb7122h.7v", 0x00000,  0x400,  CRC(a1267336) SHA1(d11ea9d78526ac3c0dc6e57a2da5914273ad1e3f) )   /* Priority  Unused */
11711091ROM_END
11721092
1173ROM_START( cninjau )
1093ROM_START( cninjau ) /* US ver 4 */
11741094   ROM_REGION( 0xc0000, REGION_CPU1, 0 ) /* 68000 code */
11751095   ROM_LOAD16_BYTE( "gm-02-3.1k", 0x00000, 0x20000, CRC(d931c3b1) SHA1(336390072a3a085fc534d9e2443c76104093b24f) )
11761096   ROM_LOAD16_BYTE( "gm-05-2.3k", 0x00001, 0x20000, CRC(7417d3fb) SHA1(24c65101585955d56440b63a307021b5c137d7b9) )
r1478r1479
12111131   ROM_LOAD( "mb7122h.7v", 0x00000,  0x400,  CRC(a1267336) SHA1(d11ea9d78526ac3c0dc6e57a2da5914273ad1e3f) )   /* Priority  Unused */
12121132ROM_END
12131133
1214ROM_START( joemac )
1134ROM_START( joemac ) /* Japan ver 1 */
12151135   ROM_REGION( 0xc0000, REGION_CPU1, 0 ) /* 68000 code */
12161136   ROM_LOAD16_BYTE( "gl-02-2.1k", 0x00000, 0x20000,  CRC(80da12e2) SHA1(1037ed56c15dbe1eb8bb8b70f0bc3affc1119782) )
12171137   ROM_LOAD16_BYTE( "gl-05-2.3k", 0x00001, 0x20000,  CRC(fe4dbbbb) SHA1(85a3c5470270ebfc695fc5e937cf133a33860bec) )
r1478r1479
12921212   /* No extra Oki samples in the bootleg */
12931213ROM_END
12941214
1295ROM_START( edrandy )
1215ROM_START( edrandy ) /* World ver 3 */
12961216   ROM_REGION( 0x100000, REGION_CPU1, 0 ) /* 68000 code */
12971217     ROM_LOAD16_BYTE( "gg-00-2.k1", 0x00000, 0x20000, CRC(ce1ba964) SHA1(da21734721344eff41a64a7f2382d5c027a24782) )
12981218   ROM_LOAD16_BYTE( "gg-04-2.k3", 0x00001, 0x20000, CRC(24caed19) SHA1(bdca689dbb13685e71d3385a9ff7b356d2459d45) )
r1478r1479
13411261   ROM_LOAD( "ge-12.v7", 0x00000,  0x400,  CRC(278f674f) SHA1(d4f5b9770d6d2ddebf1b999e291c80a3e274d492) )   /* Priority Unused, same as Robocop 2 */
13421262ROM_END
13431263
1344ROM_START( edrandy1 )
1264ROM_START( edrandy2 ) /* World ver 2 */
13451265   ROM_REGION( 0x100000, REGION_CPU1, 0 ) /* 68000 code */
13461266     ROM_LOAD16_BYTE( "gg00-1.k1", 0x00000, 0x20000, CRC(a029cc4a) SHA1(3801fd6df6d1299972eeadbdbba1b0b7acf89139) )
13471267     ROM_LOAD16_BYTE( "gg04-1.k3", 0x00001, 0x20000, CRC(8b7928a4) SHA1(4075713a830c9d5e324bb790468ec555fa747106) )
r1478r1479
13901310   ROM_LOAD( "ge-12.v7", 0x00000,  0x400,  CRC(278f674f) SHA1(d4f5b9770d6d2ddebf1b999e291c80a3e274d492) )   /* Priority Unused, same as Robocop 2 */
13911311ROM_END
13921312
1393ROM_START( edrandy0 ) /* Original version of the World set??? */
1313ROM_START( edrandy1 ) /* World ver 1 */
13941314   ROM_REGION( 0x100000, REGION_CPU1, 0 ) /* 68000 code */
13951315     ROM_LOAD16_BYTE( "1.k1",     0x00000, 0x20000, CRC(f184cdaa) SHA1(7d4a1e8acf6737a9d74d78eb414f32885ffa9846) ) /* roms were simply labeled 1 through 12 */
13961316     ROM_LOAD16_BYTE( "5.k3",     0x00001, 0x20000, CRC(7e3a4b81) SHA1(e768dd710a8b38add9fd8d9bfc88ad3a3c353ba5) )
r1478r1479
14391359   ROM_LOAD( "ge-12.v7", 0x00000,  0x400,  CRC(278f674f) SHA1(d4f5b9770d6d2ddebf1b999e291c80a3e274d492) )   /* Priority Unused, same as Robocop 2 */
14401360ROM_END
14411361
1442ROM_START( edrandyj )
1362ROM_START( edrandyj ) /* Japan ver 3 */
14431363   ROM_REGION( 0x100000, REGION_CPU1, 0 ) /* 68000 code */
14441364     ROM_LOAD16_BYTE( "ge-00-2.k1",   0x00000, 0x20000, CRC(b3d2403c) SHA1(9747dbe7905e1453e3e7764c874c523c54970e2e) )
14451365     ROM_LOAD16_BYTE( "ge-04-2.k3",   0x00001, 0x20000, CRC(8a9624d6) SHA1(d5a9b56bc8a1d67fa28df95299cb205e9c965310) )
r1478r1479
16381558   ROM_LOAD( "go-12.v7", 0x00000,  0x400,  CRC(278f674f) SHA1(d4f5b9770d6d2ddebf1b999e291c80a3e274d492) )   /* Priority  Unused */
16391559ROM_END
16401560
1641ROM_START( mutantf )
1561ROM_START( mutantf ) /* World ver 5 */
16421562   ROM_REGION( 0x80000, REGION_CPU1, 0 ) /* 68000 code */
16431563   ROM_LOAD16_BYTE("hd-03-4.2c", 0x00000, 0x20000, CRC(94859545) SHA1(4b218442bf1ba01b9b6b54c0037c76c827b79d35) )
16441564   ROM_LOAD16_BYTE("hd-00-4.2a", 0x00001, 0x20000, CRC(3cdb648f) SHA1(f803d2894d4c32de770861c70f837377afd329fe) )
1645   ROM_LOAD16_BYTE("hf-04-1.4c", 0x40000, 0x20000, CRC(fd2ea8d7) SHA1(00e50d42fcc7f6d5076963b02f5abb36275dc993) )
1646   ROM_LOAD16_BYTE("hf-01-1.4a", 0x40001, 0x20000, CRC(48a247ac) SHA1(c69d67e44ffae92b261de247f8d3eac2e02fcf11) )
1565   ROM_LOAD16_BYTE("hd-04-1.4c", 0x40000, 0x20000, CRC(fd2ea8d7) SHA1(00e50d42fcc7f6d5076963b02f5abb36275dc993) )
1566   ROM_LOAD16_BYTE("hd-01-1.4a", 0x40001, 0x20000, CRC(48a247ac) SHA1(c69d67e44ffae92b261de247f8d3eac2e02fcf11) )
16471567
16481568   ROM_REGION( 0x10000, REGION_CPU2, 0 )   /* Sound CPU */
1649   ROM_LOAD( "hf-12.21j",  0x00000,  0x10000,  CRC(13d55f11) SHA1(6438dca57f43b3ca6d273bf82b62104a49260132) )
1569   ROM_LOAD( "hd-12.21j",  0x00000,  0x10000,  CRC(13d55f11) SHA1(6438dca57f43b3ca6d273bf82b62104a49260132) )
16501570
16511571   ROM_REGION( 0x0a0000, REGION_GFX1, ROMREGION_DISPOSE ) /* chars */
1652   ROM_LOAD16_BYTE( "hf-06-1.8d", 0x000000, 0x10000, CRC(8b7a558b) SHA1(06f1f6910b9a54e208ee9a0b734d5df946016236) )
1653   ROM_LOAD16_BYTE( "hf-07-1.9d", 0x000001, 0x10000, CRC(d2a3d449) SHA1(10ad634eb0238f6e9ba04266e4dbaf9470f5d169) )
1572   ROM_LOAD16_BYTE( "hd-06-1.8d", 0x000000, 0x10000, CRC(8b7a558b) SHA1(06f1f6910b9a54e208ee9a0b734d5df946016236) )
1573   ROM_LOAD16_BYTE( "hd-07-1.9d", 0x000001, 0x10000, CRC(d2a3d449) SHA1(10ad634eb0238f6e9ba04266e4dbaf9470f5d169) )
16541574
16551575   ROM_REGION( 0x080000, REGION_GFX2, ROMREGION_DISPOSE )
16561576   ROM_LOAD( "maf-00.8a", 0x000000, 0x80000,  CRC(e56f528d) SHA1(3908d9b189fa4895c532d1d1f133df0913810cf9) ) /* tiles 3 */
r1478r1479
16821602   ROM_LOAD( "maf-09.18l",    0x00000, 0x80000, CRC(28e7ed81) SHA1(e168a2748b75c647f6f9c0d7d25d4f046aa98094) )
16831603ROM_END
16841604
1685ROM_START( mutantfa )
1605ROM_START( mutantf4 ) /* World ver 4 */
16861606   ROM_REGION( 0x80000, REGION_CPU1, 0 ) /* 68000 code */
16871607   ROM_LOAD16_BYTE("hd-03-3.2c", 0x00000, 0x20000, CRC(e6f53574) SHA1(98d5a76bda52346e4bee5b1b0755e3fee4ad8283) )
16881608   ROM_LOAD16_BYTE("hd-00-3.2a", 0x00001, 0x20000, CRC(d3055454) SHA1(83531ae52e5928ac64279bcb98878eef291f8f70) )
1689   ROM_LOAD16_BYTE("hf-04-1.4c", 0x40000, 0x20000, CRC(fd2ea8d7) SHA1(00e50d42fcc7f6d5076963b02f5abb36275dc993) )
1690   ROM_LOAD16_BYTE("hf-01-1.4a", 0x40001, 0x20000, CRC(48a247ac) SHA1(c69d67e44ffae92b261de247f8d3eac2e02fcf11) )
1609   ROM_LOAD16_BYTE("hd-04-1.4c", 0x40000, 0x20000, CRC(fd2ea8d7) SHA1(00e50d42fcc7f6d5076963b02f5abb36275dc993) )
1610   ROM_LOAD16_BYTE("hd-01-1.4a", 0x40001, 0x20000, CRC(48a247ac) SHA1(c69d67e44ffae92b261de247f8d3eac2e02fcf11) )
16911611
16921612   ROM_REGION( 0x10000, REGION_CPU2, 0 )   /* Sound CPU */
1693   ROM_LOAD( "hf-12.21j",  0x00000,  0x10000,  CRC(13d55f11) SHA1(6438dca57f43b3ca6d273bf82b62104a49260132) )
1613   ROM_LOAD( "hd-12.21j",  0x00000,  0x10000,  CRC(13d55f11) SHA1(6438dca57f43b3ca6d273bf82b62104a49260132) )
16941614
16951615   ROM_REGION( 0x0a0000, REGION_GFX1, ROMREGION_DISPOSE ) /* chars */
1696   ROM_LOAD16_BYTE( "hf-06-1.8d", 0x000000, 0x10000, CRC(8b7a558b) SHA1(06f1f6910b9a54e208ee9a0b734d5df946016236) )
1697   ROM_LOAD16_BYTE( "hf-07-1.9d", 0x000001, 0x10000, CRC(d2a3d449) SHA1(10ad634eb0238f6e9ba04266e4dbaf9470f5d169) )
1616   ROM_LOAD16_BYTE( "hd-06-1.8d", 0x000000, 0x10000, CRC(8b7a558b) SHA1(06f1f6910b9a54e208ee9a0b734d5df946016236) )
1617   ROM_LOAD16_BYTE( "hd-07-1.9d", 0x000001, 0x10000, CRC(d2a3d449) SHA1(10ad634eb0238f6e9ba04266e4dbaf9470f5d169) )
16981618
16991619   ROM_REGION( 0x080000, REGION_GFX2, ROMREGION_DISPOSE )
17001620   ROM_LOAD( "maf-00.8a", 0x000000, 0x80000,  CRC(e56f528d) SHA1(3908d9b189fa4895c532d1d1f133df0913810cf9) ) /* tiles 3 */
r1478r1479
17261646   ROM_LOAD( "maf-09.18l",    0x00000, 0x80000, CRC(28e7ed81) SHA1(e168a2748b75c647f6f9c0d7d25d4f046aa98094) )
17271647ROM_END
17281648
1729ROM_START( deathbrd )
1649ROM_START( mutantf3 ) /* World ver 3 */
17301650   ROM_REGION( 0x80000, REGION_CPU1, 0 ) /* 68000 code */
1651   ROM_LOAD16_BYTE("hd-03-2.2c", 0x00000, 0x20000, CRC(0586c4fa) SHA1(bba9f7e57be0e70185b8103af26443ce832e7413) )
1652   ROM_LOAD16_BYTE("hd-00-2.2a", 0x00001, 0x20000, CRC(6f8ec48e) SHA1(5fcc2ae4ce409598ca9d0c28ba60f3de3874efa5) )
1653   ROM_LOAD16_BYTE("hd-04-1.4c", 0x40000, 0x20000, CRC(fd2ea8d7) SHA1(00e50d42fcc7f6d5076963b02f5abb36275dc993) )
1654   ROM_LOAD16_BYTE("hd-01-1.4a", 0x40001, 0x20000, CRC(48a247ac) SHA1(c69d67e44ffae92b261de247f8d3eac2e02fcf11) )
1655
1656   ROM_REGION( 0x10000, REGION_CPU2, 0 )   /* Sound CPU */
1657   ROM_LOAD( "hd-12.21j",  0x00000,  0x10000,  CRC(13d55f11) SHA1(6438dca57f43b3ca6d273bf82b62104a49260132) )
1658
1659   ROM_REGION( 0x0a0000, REGION_GFX1, ROMREGION_DISPOSE ) /* chars */
1660   ROM_LOAD16_BYTE( "hd-06-1.8d", 0x000000, 0x10000, CRC(8b7a558b) SHA1(06f1f6910b9a54e208ee9a0b734d5df946016236) )
1661   ROM_LOAD16_BYTE( "hd-07-1.9d", 0x000001, 0x10000, CRC(d2a3d449) SHA1(10ad634eb0238f6e9ba04266e4dbaf9470f5d169) )
1662
1663   ROM_REGION( 0x080000, REGION_GFX2, ROMREGION_DISPOSE )
1664   ROM_LOAD( "maf-00.8a", 0x000000, 0x80000,  CRC(e56f528d) SHA1(3908d9b189fa4895c532d1d1f133df0913810cf9) ) /* tiles 3 */
1665
1666   ROM_REGION( 0x100000, REGION_GFX3, ROMREGION_DISPOSE )
1667   ROM_LOAD( "maf-01.9a",  0x000000, 0x40000,  CRC(c3d5173d) SHA1(2b6559bf65d7cc5b957ad347b64cf6a18f661686) ) /* tiles 1 */
1668   ROM_CONTINUE(           0x080000, 0x40000 )
1669   ROM_LOAD( "maf-02.11a", 0x040000, 0x40000,  CRC(0b37d849) SHA1(a0606fb8130a2e86a241ce5ce0b4f61373a88c17) ) /* tiles 2 */
1670   ROM_CONTINUE(           0x0c0000, 0x40000 )
1671
1672   ROM_REGION( 0x500000, REGION_GFX4, ROMREGION_DISPOSE ) /* sprites */
1673   ROM_LOAD16_BYTE( "maf-03.18a",   0x000000, 0x100000, CRC(f4366d2c) SHA1(20964d0e1b879b3e5cb5d18a46d2a17dca2b4171) )
1674   ROM_LOAD16_BYTE( "maf-04.20a",   0x200000, 0x100000, CRC(0c8f654e) SHA1(e566d4b789b345e20caf7e061e43be7c2e1be9b2) )
1675   ROM_LOAD16_BYTE( "maf-05.21a",   0x400000, 0x080000, CRC(b0cfeb80) SHA1(b8519c604b03eb8bcf26d00a43b39d48f1b45ab5) )
1676   ROM_LOAD16_BYTE( "maf-06.18d",   0x000001, 0x100000, CRC(f5c7a9b5) SHA1(92efc9401347598c90acf62c9aef30109c990ad6) )
1677   ROM_LOAD16_BYTE( "maf-07.20d",   0x200001, 0x100000, CRC(fd6008a3) SHA1(7b680424eca3804c70fa0c4dc415d665c8626498) )
1678   ROM_LOAD16_BYTE( "maf-08.21d",   0x400001, 0x080000, CRC(e41cf1e7) SHA1(06524e1aed0adc4c32c92e16a00dc983014f4994) )
1679
1680   ROM_REGION( 0x40000, REGION_GFX5, ROMREGION_DISPOSE ) /* sprites 2 */
1681   ROM_LOAD32_BYTE("hf-08.15a", 0x00001, 0x10000, CRC(93b7279f) SHA1(14304a1ffe1bc791bfa83f8200793d897449133c) )
1682   ROM_LOAD32_BYTE("hf-09.17a", 0x00003, 0x10000, CRC(05e2c074) SHA1(ec95303e8196424864964b5d2ae862bf75571e83) )
1683   ROM_LOAD32_BYTE("hf-10.15c", 0x00000, 0x10000, CRC(9b06f418) SHA1(d1579ae36676e38c96ee55a1ffa20aa307a21654) )
1684   ROM_LOAD32_BYTE("hf-11.17c", 0x00002, 0x10000, CRC(3859a531) SHA1(a2a0c1aa28181b5ef6c075ff0118178340389693) )
1685
1686   ROM_REGION( 0x40000, REGION_SOUND1, 0 )   /* ADPCM samples */
1687   ROM_LOAD( "maf-10.20l",    0x00000, 0x40000, CRC(7c57f48b) SHA1(9a5624553b3b038d70f9b517f410a635c00a8771) )
1688
1689   ROM_REGION( 0x80000, REGION_SOUND2, 0 )   /* ADPCM samples */
1690   ROM_LOAD( "maf-09.18l",    0x00000, 0x80000, CRC(28e7ed81) SHA1(e168a2748b75c647f6f9c0d7d25d4f046aa98094) )
1691ROM_END
1692
1693ROM_START( deathbrd ) /* Japan ver 3 */
1694   ROM_REGION( 0x80000, REGION_CPU1, 0 ) /* 68000 code */
17311695   ROM_LOAD16_BYTE("hf-03-2.2c", 0x00000, 0x20000, CRC(fb86fff3) SHA1(af4cfc19ec85e0aa49b5e46d95bdd94a20922cce) )
17321696   ROM_LOAD16_BYTE("hf-00-2.2a", 0x00001, 0x20000, CRC(099aa422) SHA1(b62f261b1903dd2d1a308f7abb9584b3726204b5) )
1733   ROM_LOAD16_BYTE("hf-04-1.4c", 0x40000, 0x20000, CRC(fd2ea8d7) SHA1(00e50d42fcc7f6d5076963b02f5abb36275dc993) )
1734   ROM_LOAD16_BYTE("hf-01-1.4a", 0x40001, 0x20000, CRC(48a247ac) SHA1(c69d67e44ffae92b261de247f8d3eac2e02fcf11) )
1697   ROM_LOAD16_BYTE("hd-04-1.4c", 0x40000, 0x20000, CRC(fd2ea8d7) SHA1(00e50d42fcc7f6d5076963b02f5abb36275dc993) ) /* May have the "HD" or "HF" region code label */
1698   ROM_LOAD16_BYTE("hd-01-1.4a", 0x40001, 0x20000, CRC(48a247ac) SHA1(c69d67e44ffae92b261de247f8d3eac2e02fcf11) ) /* May have the "HD" or "HF" region code label */
17351699
17361700   ROM_REGION( 0x10000, REGION_CPU2, 0 )   /* Sound CPU */
1737   ROM_LOAD( "hf-12.21j",  0x00000,  0x10000,  CRC(13d55f11) SHA1(6438dca57f43b3ca6d273bf82b62104a49260132) )
1701   ROM_LOAD( "hd-12.21j",  0x00000,  0x10000,  CRC(13d55f11) SHA1(6438dca57f43b3ca6d273bf82b62104a49260132) ) /* May have the "HD" or "HF" region code label */
17381702
17391703   ROM_REGION( 0x0a0000, REGION_GFX1, ROMREGION_DISPOSE ) /* chars */
1740   ROM_LOAD16_BYTE( "hf-06-1.8d", 0x000000, 0x10000, CRC(8b7a558b) SHA1(06f1f6910b9a54e208ee9a0b734d5df946016236) )
1741   ROM_LOAD16_BYTE( "hf-07-1.9d", 0x000001, 0x10000, CRC(d2a3d449) SHA1(10ad634eb0238f6e9ba04266e4dbaf9470f5d169) )
1704   ROM_LOAD16_BYTE( "hd-06-1.8d", 0x000000, 0x10000, CRC(8b7a558b) SHA1(06f1f6910b9a54e208ee9a0b734d5df946016236) ) /* May have the "HD" or "HF" region code label */
1705   ROM_LOAD16_BYTE( "hd-07-1.9d", 0x000001, 0x10000, CRC(d2a3d449) SHA1(10ad634eb0238f6e9ba04266e4dbaf9470f5d169) ) /* May have the "HD" or "HF" region code label */
17421706
17431707   ROM_REGION( 0x080000, REGION_GFX2, ROMREGION_DISPOSE )
17441708   ROM_LOAD( "maf-00.8a", 0x000000, 0x80000,  CRC(e56f528d) SHA1(3908d9b189fa4895c532d1d1f133df0913810cf9) ) /* tiles 3 */
r1478r1479
18241788
18251789/**********************************************************************************/
18261790
1827GAME( 1990, edrandy,  0,       edrandy,  edrandy, 0,        ROT0, "Data East Corporation", "The Cliffhanger - Edward Randy (World revision 2)", 0 )
1828GAME( 1990, edrandy1, edrandy, edrandy,  edrandy, 0,        ROT0, "Data East Corporation", "The Cliffhanger - Edward Randy (World revision 1)", 0 )
1829GAME( 1990, edrandy0, edrandy, edrandy,  edrandy, 0,        ROT0, "Data East Corporation", "The Cliffhanger - Edward Randy (World)", 0 )
1830GAME( 1990, edrandyj, edrandy, edrandy,  edrandy, 0,        ROT0, "Data East Corporation", "The Cliffhanger - Edward Randy (Japan revision 2)", 0 )
1831GAME( 1991, cninja,   0,       cninja,   cninja,  cninja,   ROT0, "Data East Corporation", "Caveman Ninja (World revision 3)", 0 )
1832GAME( 1991, cninja0,  cninja,  cninja,   cninja,  cninja,   ROT0, "Data East Corporation", "Caveman Ninja (World revision 0)", 0 )
1833GAME( 1991, cninjau,  cninja,  cninja,   cninjau, cninja,   ROT0, "Data East Corporation", "Caveman Ninja (US)", 0 )
1834GAME( 1991, joemac,   cninja,  cninja,   cninja,  cninja,   ROT0, "Data East Corporation", "Tatakae Genshizin Joe & Mac (Japan)", 0 )
1791GAME( 1990, edrandy,  0,       edrandy,  edrandy, 0,        ROT0, "Data East Corporation", "The Cliffhanger - Edward Randy (World ver 3)", 0 )
1792GAME( 1990, edrandy2, edrandy, edrandy,  edrandc, 0,        ROT0, "Data East Corporation", "The Cliffhanger - Edward Randy (World ver 2)", 0 )
1793GAME( 1990, edrandy1, edrandy, edrandy,  edrandc, 0,        ROT0, "Data East Corporation", "The Cliffhanger - Edward Randy (World ver 1)", 0 )
1794GAME( 1990, edrandyj, edrandy, edrandy,  edrandc, 0,        ROT0, "Data East Corporation", "The Cliffhanger - Edward Randy (Japan ver 3)", 0 )
1795GAME( 1991, cninja,   0,       cninja,   cninja,  cninja,   ROT0, "Data East Corporation", "Caveman Ninja (World ver 4)", 0 )
1796GAME( 1991, cninja1,  cninja,  cninja,   cninja,  cninja,   ROT0, "Data East Corporation", "Caveman Ninja (World ver 1)", 0 )
1797GAME( 1991, cninjau,  cninja,  cninja,   cninjau, cninja,   ROT0, "Data East Corporation", "Caveman Ninja (US ver 4)", 0 )
1798GAME( 1991, joemac,   cninja,  cninja,   cninja,  cninja,   ROT0, "Data East Corporation", "Tatakae Genshizin Joe & Mac (Japan ver 1)", 0 )
18351799GAME( 1991, stoneage, cninja,  stoneage, cninja,  stoneage, ROT0, "bootleg", "Stoneage", 0 )
18361800GAME( 1991, robocop2, 0,       robocop2, robocop2,0,        ROT0, "Data East Corporation", "Robocop 2 (Euro/Asia v0.10)", 0 )
18371801GAME( 1991, robocp2u, robocop2,robocop2, robocop2,0,        ROT0, "Data East Corporation", "Robocop 2 (US v0.05)", 0 )
18381802GAME( 1991, robocp2j, robocop2,robocop2, robocop2,0,        ROT0, "Data East Corporation", "Robocop 2 (Japan v0.11)", 0 )
1839GAME( 1992, mutantf,  0,       mutantf,  mutantf, mutantf,  ROT0, "Data East Corporation", "Mutant Fighter (World Rev 4, EM-5)", 0 )
1840GAME( 1992, mutantfa, mutantf, mutantf,  mutantf, mutantf,  ROT0, "Data East Corporation", "Mutant Fighter (World Rev 3, EM-4)", 0 )
1841GAME( 1992, deathbrd, mutantf, mutantf,  mutantf, mutantf,  ROT0, "Data East Corporation", "Death Brade (Japan Rev 2, JM-3)", 0 )
1803GAME( 1992, mutantf,  0,       mutantf,  mutantf, mutantf,  ROT0, "Data East Corporation", "Mutant Fighter (World ver EM-5)", 0 )
1804GAME( 1992, mutantf4, mutantf, mutantf,  mutantf, mutantf,  ROT0, "Data East Corporation", "Mutant Fighter (World ver EM-4)", 0 )
1805GAME( 1992, mutantf3, mutantf, mutantf,  mutantf, mutantf,  ROT0, "Data East Corporation", "Mutant Fighter (World ver EM-3)", 0 )
1806GAME( 1992, deathbrd, mutantf, mutantf,  mutantf, mutantf,  ROT0, "Data East Corporation", "Death Brade (Japan ver JM-3)", 0 )
src/mame/drivers/taitosj.c
r1478r1479
666611010101----1010   W xxxxxxxx EXROM2     high 8 bits of address to read from graphics ROMs
676711010101----1011   W xxxxxxxx EPORT1     command to sound CPU
686811010101----1100   W -------x EPORT2     single bit signal to audio CPU (not used?)
6911010101----1101   W -------- TIME RESET wathcdog reset
6911010101----1101   W -------- TIME RESET watchdog reset
707011010101----1110   W -------x COIN LOCK  coin lockout
717111010101----1110   W ------x- SOUND STOP mute sound
727211010101----1110   W -xxxxx-- n.c.
src/mame/drivers/ksys573.c
r1478r1479
222222
223223#define VERBOSE_LEVEL ( 0 )
224224
225INLINE void verboselog( int n_level, const char *s_fmt, ... )
225INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
226226{
227227   if( VERBOSE_LEVEL >= n_level )
228228   {
r1478r1479
289289static READ32_HANDLER( mb89371_r )
290290{
291291   UINT32 data = 0xffffffff;
292   verboselog( 2, "mb89371_r %08x %08x\n", offset, mem_mask, data );
292   verboselog( 2, "mb89371_r %08x %08x %08x\n", offset, mem_mask, data );
293293   return data;
294294}
295295
r1478r1479
20022002      break;
20032003   }
20042004
2005   verboselog( 2, "gtrfrks_io_r( %08x, %08x ) %08x\n", data );
2005   verboselog( 2, "gtrfrks_io_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
20062006   return data;
20072007}
20082008
20092009static WRITE32_HANDLER( gtrfrks_io_w )
20102010{
2011   verboselog( 2, "gtrfrks_io_w( %08x, %08x ) %08x\n", data );
2011   verboselog( 2, "gtrfrks_io_w( %08x, %08x ) %08x\n", offset, mem_mask, data );
20122012
20132013   switch( offset )
20142014   {
r1478r1479
26212621
26222622static WRITE32_HANDLER( dmx_io_w )
26232623{
2624   verboselog( 2, "dmx_io_w( %08x, %08x ) %08x\n", data );
2624   verboselog( 2, "dmx_io_w( %08x, %08x ) %08x\n", offset, mem_mask, data );
26252625
26262626   switch( offset )
26272627   {
src/mame/drivers/sbrkout.c
r1478r1479
1212
1313****************************************************************************
1414
15    Note:  I'm cheating a little bit with the paddle control.  The original
16    game handles the paddle control as following.  The paddle is a potentiometer.
17    Every VBlank signal triggers the start of a voltage ramp.  Whenever the
18    ramp has the same value as the potentiometer, an NMI is generated.  In the
19    NMI code, the current scanline value is used to calculate the value to
20    put into location $1F in memory.  I cheat in this driver by just putting
21    the paddle value directly into $1F, which has the same net result.
15    To do:
2216
23    If you have any questions about how this driver works, don't hesitate to
24    ask.  - Mike Balfour (mab22@po.cwru.edu)
17    * Merge with Sprint 1
2518
26    CHANGES:
27    MAB 05 MAR 99 - changed overlay support to use artwork functions
19****************************************************************************
2820
21    Stephh's notes (based on the games M6502 code and some tests) :
2922
30Stephh's notes (based on the games M6502 code and some tests) :
23      - Each time the game is reset, it is set to "Cavity".
24        I can't remember if it's the correct behaviour or not,
25        but the VBLANK interruption is not called in "demo mode".
26      - You can only select the game after 1st coin is inserted
27        and before you press BUTTON1 to launch the first ball,
28        then the VBLANK interruption is no more called.
29        This means that player 2 plays the same game as player 1.
3130
32  - Each time the game is reset, it is set to "Cavity".
33    I can't remember if it's the correct behaviour or not,
34    but the VBLANK interruption is not called in "demo mode".
35  - You can only select the game after 1st coin is inserted
36    and before you press BUTTON1 to launch the first ball,
37    then the VBLANK interruption is no more called.
38    This means that player 2 plays the same game as player 1.
39
4031***************************************************************************/
4132
4233#include "driver.h"
4334#include "sound/dac.h"
44#include "includes/sbrkout.h"
4535
4636#include "sbrkout.lh"
4737
4838
39
4940/*************************************
5041 *
51 *  Temporary sound hardware
42 *  Constants
5243 *
5344 *************************************/
5445
55#define TIME_4V ATTOTIME_IN_SEC(4075000/4)
46#define MAIN_CLOCK      XTAL_12_096MHz
47#define TIME_4V       ATTOTIME_IN_HZ(MAIN_CLOCK/2/256/2/4)
5648
57static UINT8 *sbrkout_sound;
5849
59static WRITE8_HANDLER( sbrkout_dac_w )
50
51/*************************************
52 *
53 *  Globals
54 *
55 *************************************/
56
57static emu_timer *scanline_timer;
58static emu_timer *pot_timer;
59
60static tilemap *bg_tilemap;
61
62static UINT8 sync2_value;
63static UINT8 pot_mask[2];
64static UINT8 pot_trigger[2];
65
66
67
68/*************************************
69 *
70 *  Prototypes
71 *
72 *************************************/
73
74static TIMER_CALLBACK( scanline_callback );
75static TIMER_CALLBACK( pot_trigger_callback );
76
77
78
79/*************************************
80 *
81 *  Machine setup
82 *
83 *************************************/
84
85static MACHINE_START( sbrkout )
6086{
61   sbrkout_sound[offset]=data;
87   memory_set_bankptr(1, &videoram[0x380]);
88   scanline_timer = timer_alloc(scanline_callback, NULL);
89   pot_timer = timer_alloc(pot_trigger_callback, NULL);
90
91   state_save_register_global(sync2_value);
92   state_save_register_global_array(pot_mask);
93   state_save_register_global_array(pot_trigger);
6294}
6395
6496
65static TIMER_CALLBACK( sbrkout_tones_4V )
97static MACHINE_RESET( sbrkout )
6698{
67   static int vlines=0;
99   timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 0, 0), 0, attotime_never);
100}
68101
69   if ((*sbrkout_sound) & vlines)
70      DAC_data_w(0,255);
102
103
104/*************************************
105 *
106 *  Interrupts
107 *
108 *************************************/
109
110static TIMER_CALLBACK( scanline_callback )
111{
112   int scanline = param;
113
114   /* force a partial update before anything happens */
115   video_screen_update_partial(0, scanline);
116
117   /* if this is a rising edge of 16V, assert the CPU interrupt */
118   if (scanline % 32 == 16)
119      cpunum_set_input_line(0, 0, ASSERT_LINE);
120
121   /* update the DAC state */
122   DAC_data_w(0, (videoram[0x380 + 0x11] & (scanline >> 2)) ? 255 : 0);
123
124   /* on the VBLANK, read the pot and schedule an interrupt time for it */
125   if (scanline == machine->screen[0].visarea.max_y + 1)
126   {
127      UINT8 potvalue = readinputportbytag("PADDLE");
128      timer_adjust(pot_timer, video_screen_get_time_until_pos(0, 72 + (potvalue / 2), (potvalue % 2) * 128), 0, attotime_never);
129   }
130
131   /* call us back in 4 scanlines */
132   scanline += 4;
133   if (scanline >= machine->screen[0].height)
134      scanline = 0;
135   timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, attotime_never);
136}
137
138
139static WRITE8_HANDLER( irq_ack_w )
140{
141   cpunum_set_input_line(0, 0, CLEAR_LINE);
142}
143
144
145
146/*************************************
147 *
148 *  Inputs
149 *
150 *************************************/
151
152static READ8_HANDLER( switches_r )
153{
154   UINT8 result = 0xff;
155
156   /* DIP switches are selected by ADR0+ADR1 if ADR3 == 0 */
157   if ((offset & 0x0b) == 0x00)
158      result &= (readinputportbytag("DIPS") << 6) | 0x3f;
159   if ((offset & 0x0b) == 0x01)
160      result &= (readinputportbytag("DIPS") << 4) | 0x3f;
161   if ((offset & 0x0b) == 0x02)
162      result &= (readinputportbytag("DIPS") << 0) | 0x3f;
163   if ((offset & 0x0b) == 0x03)
164      result &= (readinputportbytag("DIPS") << 2) | 0x3f;
165
166   /* other switches are selected by ADR0+ADR1+ADR2 if ADR4 == 0 */
167   if ((offset & 0x17) == 0x00)
168      result &= (readinputportbytag("SELECT") << 7) | 0x7f;
169   if ((offset & 0x17) == 0x04)
170      result &= ((pot_trigger[0] & ~pot_mask[0]) << 7) | 0x7f;
171   if ((offset & 0x17) == 0x05)
172      result &= ((pot_trigger[1] & ~pot_mask[1]) << 7) | 0x7f;
173   if ((offset & 0x17) == 0x06)
174      result &= readinputportbytag("SERVE");
175   if ((offset & 0x17) == 0x07)
176      result &= (readinputportbytag("SELECT") << 6) | 0x7f;
177
178   return result;
179}
180
181
182static void update_nmi_state(void)
183{
184   if ((pot_trigger[0] & ~pot_mask[0]) | (pot_trigger[1] & ~pot_mask[1]))
185      cpunum_set_input_line(0, INPUT_LINE_NMI, ASSERT_LINE);
71186   else
72      DAC_data_w(0,0);
187      cpunum_set_input_line(0, INPUT_LINE_NMI, CLEAR_LINE);
188}
73189
74   vlines = (vlines+1) % 16;
190
191static TIMER_CALLBACK( pot_trigger_callback )
192{
193   pot_trigger[param] = 1;
194   update_nmi_state();
75195}
76196
77197
78static MACHINE_RESET( sbrkout )
198static WRITE8_HANDLER( pot_mask1_w )
79199{
80   timer_pulse(TIME_4V, NULL, 0, sbrkout_tones_4V);
200   pot_mask[0] = ~offset & 1;
201   pot_trigger[0] = 0;
202   update_nmi_state();
81203}
82204
83205
206static WRITE8_HANDLER( pot_mask2_w )
207{
208   pot_mask[1] = ~offset & 1;
209   pot_trigger[1] = 0;
210   update_nmi_state();
211}
212
213
214
84215/*************************************
85216 *
86 *  Palette generation
217 *  Lamps and other outputs
87218 *
88219 *************************************/
89220
90static PALETTE_INIT( sbrkout )
221/*
222    The LEDs are turned on and off by two consecutive memory addresses.  The
223    first address turns them off, the second address turns them on.  This is
224    reversed for the Serve LED, which has a NOT on the signal.
225*/
226
227static WRITE8_HANDLER( start_1_led_w )
91228{
92   palette_set_color(machine,0,MAKE_RGB(0x00,0x00,0x00));
93   palette_set_color(machine,1,MAKE_RGB(0xff,0xff,0xff));
229   output_set_led_value(0, offset & 1);
94230}
95231
96232
233static WRITE8_HANDLER( start_2_led_w )
234{
235   output_set_led_value(1, offset & 1);
236}
97237
238
239static WRITE8_HANDLER( serve_led_w )
240{
241   output_set_led_value(0, ~offset & 1);
242}
243
244
245static WRITE8_HANDLER( coincount_w )
246{
247   coin_counter_w(0, offset & 1);
248}
249
250
251
98252/*************************************
99253 *
100 *  Main CPU memory handlers
254 *  Video timing
101255 *
102256 *************************************/
103257
104static ADDRESS_MAP_START( readmem, ADDRESS_SPACE_PROGRAM, 8 )
105   AM_RANGE(0x001f, 0x001f) AM_READ(input_port_6_r) /* paddle value */
106   AM_RANGE(0x0000, 0x00ff) AM_READ(MRA8_RAM) /* Zero Page RAM */
107   AM_RANGE(0x0100, 0x01ff) AM_READ(MRA8_RAM) /* ??? */
108   AM_RANGE(0x0400, 0x077f) AM_READ(MRA8_RAM) /* Video Display RAM */
109   AM_RANGE(0x0828, 0x0828) AM_READ(sbrkout_select1_r) /* Select 1 */
110   AM_RANGE(0x082f, 0x082f) AM_READ(sbrkout_select2_r) /* Select 2 */
111   AM_RANGE(0x082e, 0x082e) AM_READ(input_port_5_r) /* Serve Switch */
112   AM_RANGE(0x0830, 0x0833) AM_READ(sbrkout_read_DIPs_r) /* DIP Switches */
113   AM_RANGE(0x0840, 0x0840) AM_READ(input_port_1_r) /* Coin Switches */
114   AM_RANGE(0x0880, 0x0880) AM_READ(input_port_2_r) /* Start Switches */
115   AM_RANGE(0x08c0, 0x08c0) AM_READ(input_port_3_r) /* Self Test Switch */
116   AM_RANGE(0x0c00, 0x0c00) AM_READ(input_port_4_r) /* Vertical Sync Counter */
117   AM_RANGE(0x2c00, 0x3fff) AM_READ(MRA8_ROM) /* PROGRAM */
118   AM_RANGE(0xfff0, 0xffff) AM_READ(MRA8_ROM) /* PROM8 for 6502 vectors */
119ADDRESS_MAP_END
258static READ8_HANDLER( sync_r )
259{
260   int hpos = video_screen_get_hpos(0);
261   sync2_value = (hpos >= 128 && hpos <= Machine->screen[0].visarea.max_x);
262   return video_screen_get_vpos(0);
263}
120264
121265
122static ADDRESS_MAP_START( writemem, ADDRESS_SPACE_PROGRAM, 8 )
123   AM_RANGE(0x0011, 0x0011) AM_WRITE(sbrkout_dac_w) AM_BASE(&sbrkout_sound) /* Noise Generation Bits */
124   AM_RANGE(0x0010, 0x0014) AM_WRITE(MWA8_RAM) AM_BASE(&sbrkout_horiz_ram) /* Horizontal Ball Position */
125   AM_RANGE(0x0018, 0x001d) AM_WRITE(MWA8_RAM) AM_BASE(&sbrkout_vert_ram) /* Vertical Ball Position / ball picture */
126   AM_RANGE(0x0000, 0x00ff) AM_WRITE(MWA8_RAM) /* WRAM */
127   AM_RANGE(0x0100, 0x01ff) AM_WRITE(MWA8_RAM) /* ??? */
128   AM_RANGE(0x0400, 0x07ff) AM_WRITE(sbrkout_videoram_w) AM_BASE(&videoram) /* DISPLAY */
129   AM_RANGE(0x0c10, 0x0c11) AM_WRITE(sbrkout_serve_led_w) /* Serve LED */
130   AM_RANGE(0x0c30, 0x0c31) AM_WRITE(sbrkout_start_1_led_w) /* 1 Player Start Light */
131   AM_RANGE(0x0c40, 0x0c41) AM_WRITE(sbrkout_start_2_led_w) /* 2 Player Start Light */
132   AM_RANGE(0x0c50, 0x0c51) AM_WRITE(MWA8_RAM) /* NMI Pot Reading Enable */
133   AM_RANGE(0x0c70, 0x0c71) AM_WRITE(MWA8_RAM) /* Coin Counter */
134   AM_RANGE(0x0c80, 0x0c80) AM_WRITE(MWA8_NOP) /* Watchdog */
135   AM_RANGE(0x0e00, 0x0e00) AM_WRITE(MWA8_NOP) /* IRQ Enable? */
136   AM_RANGE(0x1000, 0x1000) AM_WRITE(MWA8_RAM) /* LSB of Pot Reading */
137   AM_RANGE(0x2c00, 0x3fff) AM_WRITE(MWA8_ROM) /* PROM1-PROM8 */
266static READ8_HANDLER( sync2_r )
267{
268   return (sync2_value << 7) | 0x7f;
269}
270
271
272
273/*************************************
274 *
275 *  Background tilemap
276 *
277 *************************************/
278
279static TILE_GET_INFO( get_bg_tile_info )
280{
281   int code = (videoram[tile_index] & 0x80) ? videoram[tile_index] : 0;
282   SET_TILE_INFO(0, code, 0, 0);
283}
284
285
286static VIDEO_START( sbrkout )
287{
288   bg_tilemap = tilemap_create(get_bg_tile_info, tilemap_scan_rows, TILEMAP_TYPE_PEN, 8, 8, 32, 32);
289}
290
291
292static WRITE8_HANDLER( sbrkout_videoram_w )
293{
294   videoram[offset] = data;
295   tilemap_mark_tile_dirty(bg_tilemap, offset);
296}
297
298
299
300/*************************************
301 *
302 *  Video update
303 *
304 *************************************/
305
306static VIDEO_UPDATE( sbrkout )
307{
308   int ball;
309
310   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
311
312   for (ball = 2; ball >= 0; ball--)
313   {
314      int code = ((videoram[0x380 + 0x18 + ball * 2 + 1] & 0x80) >> 7);
315      int sx = 31 * 8 - videoram[0x380 + 0x10 + ball * 2];
316      int sy = 30 * 8 - videoram[0x380 + 0x18 + ball * 2];
317
318      drawgfx(bitmap, machine->gfx[1], code, 0, 0, 0, sx, sy, cliprect, TRANSPARENCY_PEN, 0);
319   }
320   return 0;
321}
322
323
324
325/*************************************
326 *
327 *  Main CPU memory handlers
328 *
329 *************************************/
330
331/* full memory map derived from schematics */
332static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
333   ADDRESS_MAP_FLAGS( AMEF_ABITS(14) )
334   AM_RANGE(0x0000, 0x007f) AM_MIRROR(0x380) AM_RAMBANK(1)
335   AM_RANGE(0x0400, 0x07ff) AM_READWRITE(MRA8_RAM, sbrkout_videoram_w) AM_BASE(&videoram)
336   AM_RANGE(0x0800, 0x083f) AM_READ(switches_r)
337   AM_RANGE(0x0840, 0x0840) AM_MIRROR(0x003f) AM_READ_PORT("COIN")
338   AM_RANGE(0x0880, 0x0880) AM_MIRROR(0x003f) AM_READ_PORT("START")
339   AM_RANGE(0x08c0, 0x08c0) AM_MIRROR(0x003f) AM_READ_PORT("SERVICE")
340   AM_RANGE(0x0c00, 0x0c00) AM_MIRROR(0x03ff) AM_READ(sync_r)
341   AM_RANGE(0x0c10, 0x0c11) AM_MIRROR(0x000e) AM_WRITE(serve_led_w)
342   AM_RANGE(0x0c30, 0x0c31) AM_MIRROR(0x000e) AM_WRITE(start_1_led_w)
343   AM_RANGE(0x0c40, 0x0c41) AM_MIRROR(0x000e) AM_WRITE(start_2_led_w)
344   AM_RANGE(0x0c50, 0x0c51) AM_MIRROR(0x000e) AM_WRITE(pot_mask1_w)
345   AM_RANGE(0x0c60, 0x0c61) AM_MIRROR(0x000e) AM_WRITE(pot_mask2_w)
346   AM_RANGE(0x0c70, 0x0c71) AM_MIRROR(0x000e) AM_WRITE(coincount_w)
347   AM_RANGE(0x0c80, 0x0c80) AM_MIRROR(0x007f) AM_WRITE(watchdog_reset_w)
348   AM_RANGE(0x0e00, 0x0e00) AM_MIRROR(0x007f) AM_WRITE(irq_ack_w)
349   AM_RANGE(0x1000, 0x1000) AM_MIRROR(0x03ff) AM_READ(sync2_r)
350   AM_RANGE(0x2800, 0x3fff) AM_ROM
138351ADDRESS_MAP_END
139352
140353
r1478r1479
146359 *************************************/
147360
148361static INPUT_PORTS_START( sbrkout )
149   PORT_START      /* DSW - fake port, gets mapped to Super Breakout ports */
362   PORT_START_TAG("DIPS")
150363   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Language ) )
151364   PORT_DIPSETTING(   0x00, DEF_STR( English ) )
152365   PORT_DIPSETTING(   0x01, DEF_STR( German ) )
153366   PORT_DIPSETTING(   0x02, DEF_STR( French ) )
154367   PORT_DIPSETTING(   0x03, DEF_STR( Spanish ) )
155   PORT_DIPNAME( 0x0C, 0x08, DEF_STR( Coinage ) )
156   PORT_DIPSETTING(   0x0C, DEF_STR( 2C_1C ) )
368   PORT_DIPNAME( 0x0c, 0x08, DEF_STR( Coinage ) )
369   PORT_DIPSETTING(   0x0c, DEF_STR( 2C_1C ) )
157370   PORT_DIPSETTING(   0x08, DEF_STR( 1C_1C ) )
158371   PORT_DIPSETTING(   0x04, DEF_STR( 1C_2C ) )
159372   PORT_DIPSETTING(   0x00, DEF_STR( Free_Play ) )
160373   PORT_DIPNAME( 0x70, 0x00, "Extended Play" )
161374   /* Progressive */
162   PORT_DIPSETTING(   0x10, "200" )   PORT_CONDITION("SELECT",0x07,PORTCOND_EQUALS,0x01)
163   PORT_DIPSETTING(   0x20, "400" )   PORT_CONDITION("SELECT",0x07,PORTCOND_EQUALS,0x01)
164   PORT_DIPSETTING(   0x30, "600" )   PORT_CONDITION("SELECT",0x07,PORTCOND_EQUALS,0x01)
165   PORT_DIPSETTING(   0x40, "900" )   PORT_CONDITION("SELECT",0x07,PORTCOND_EQUALS,0x01)
166   PORT_DIPSETTING(   0x50, "1200" )   PORT_CONDITION("SELECT",0x07,PORTCOND_EQUALS,0x01)
167   PORT_DIPSETTING(   0x60, "1600" )   PORT_CONDITION("SELECT",0x07,PORTCOND_EQUALS,0x01)
168   PORT_DIPSETTING(   0x70, "2000" )   PORT_CONDITION("SELECT",0x07,PORTCOND_EQUALS,0x01)
375   PORT_DIPSETTING(   0x10, "200" )   PORT_CONDITION("SELECT",0x03,PORTCOND_EQUALS,0x00)
376   PORT_DIPSETTING(   0x20, "400" )   PORT_CONDITION("SELECT",0x03,PORTCOND_EQUALS,0x00)
377   PORT_DIPSETTING(   0x30, "600" )   PORT_CONDITION("SELECT",0x03,PORTCOND_EQUALS,0x00)
378   PORT_DIPSETTING(   0x40, "900" )   PORT_CONDITION("SELECT",0x03,PORTCOND_EQUALS,0x00)
379   PORT_DIPSETTING(   0x50, "1200" )   PORT_CONDITION("SELECT",0x03,PORTCOND_EQUALS,0x00)
380   PORT_DIPSETTING(   0x60, "1600" )   PORT_CONDITION("SELECT",0x03,PORTCOND_EQUALS,0x00)
381   PORT_DIPSETTING(   0x70, "2000" )   PORT_CONDITION("SELECT",0x03,PORTCOND_EQUALS,0x00)
169382   /* Double */
170   PORT_DIPSETTING(   0x10, "200" )   PORT_CONDITION("SELECT",0x07,PORTCOND_EQUALS,0x02)
171   PORT_DIPSETTING(   0x20, "400" )   PORT_CONDITION("SELECT",0x07,PORTCOND_EQUALS,0x02)
172   PORT_DIPSETTING(   0x30, "600" )   PORT_CONDITION("SELECT",0x07,PORTCOND_EQUALS,0x02)
173   PORT_DIPSETTING(   0x40, "800" )   PORT_CONDITION("SELECT",0x07,PORTCOND_EQUALS,0x02)
174   PORT_DIPSETTING(   0x50, "1000" )   PORT_CONDITION("SELECT",0x07,PORTCOND_EQUALS,0x02)
175   PORT_DIPSETTING(   0x60, "1200" )   PORT_CONDITION("SELECT",0x07,PORTCOND_EQUALS,0x02)
176   PORT_DIPSETTING(   0x70, "1500" )   PORT_CONDITION("SELECT",0x07,PORTCOND_EQUALS,0x02)
383   PORT_DIPSETTING(   0x10, "200" )   PORT_CONDITION("SELECT",0x03,PORTCOND_EQUALS,0x02)
384   PORT_DIPSETTING(   0x20, "400" )   PORT_CONDITION("SELECT",0x03,PORTCOND_EQUALS,0x02)
385   PORT_DIPSETTING(   0x30, "600" )   PORT_CONDITION("SELECT",0x03,PORTCOND_EQUALS,0x02)
386   PORT_DIPSETTING(   0x40, "800" )   PORT_CONDITION("SELECT",0x03,PORTCOND_EQUALS,0x02)
387   PORT_DIPSETTING(   0x50, "1000" )   PORT_CONDITION("SELECT",0x03,PORTCOND_EQUALS,0x02)
388   PORT_DIPSETTING(   0x60, "1200" )   PORT_CONDITION("SELECT",0x03,PORTCOND_EQUALS,0x02)
389   PORT_DIPSETTING(   0x70, "1500" )   PORT_CONDITION("SELECT",0x03,PORTCOND_EQUALS,0x02)
177390   /* Cavity */
178   PORT_DIPSETTING(   0x10, "200" )   PORT_CONDITION("SELECT",0x07,PORTCOND_EQUALS,0x04)
179   PORT_DIPSETTING(   0x20, "300" )   PORT_CONDITION("SELECT",0x07,PORTCOND_EQUALS,0x04)
180   PORT_DIPSETTING(   0x30, "400" )   PORT_CONDITION("SELECT",0x07,PORTCOND_EQUALS,0x04)
181   PORT_DIPSETTING(   0x40, "700" )   PORT_CONDITION("SELECT",0x07,PORTCOND_EQUALS,0x04)
182   PORT_DIPSETTING(   0x50, "900" )   PORT_CONDITION("SELECT",0x07,PORTCOND_EQUALS,0x04)
183   PORT_DIPSETTING(   0x60, "1100" )   PORT_CONDITION("SELECT",0x07,PORTCOND_EQUALS,0x04)
184   PORT_DIPSETTING(   0x70, "1400" )   PORT_CONDITION("SELECT",0x07,PORTCOND_EQUALS,0x04)
391   PORT_DIPSETTING(   0x10, "200" )   PORT_CONDITION("SELECT",0x03,PORTCOND_EQUALS,0x01)
392   PORT_DIPSETTING(   0x20, "300" )   PORT_CONDITION("SELECT",0x03,PORTCOND_EQUALS,0x01)
393   PORT_DIPSETTING(   0x30, "400" )   PORT_CONDITION("SELECT",0x03,PORTCOND_EQUALS,0x01)
394   PORT_DIPSETTING(   0x40, "700" )   PORT_CONDITION("SELECT",0x03,PORTCOND_EQUALS,0x01)
395   PORT_DIPSETTING(   0x50, "900" )   PORT_CONDITION("SELECT",0x03,PORTCOND_EQUALS,0x01)
396   PORT_DIPSETTING(   0x60, "1100" )   PORT_CONDITION("SELECT",0x03,PORTCOND_EQUALS,0x01)
397   PORT_DIPSETTING(   0x70, "1400" )   PORT_CONDITION("SELECT",0x03,PORTCOND_EQUALS,0x01)
185398   PORT_DIPSETTING(   0x00, DEF_STR( None ) )
186399   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Lives ) )
187400   PORT_DIPSETTING(   0x80, "3" )
188401   PORT_DIPSETTING(   0x00, "5" )
189402
190   PORT_START      /* IN0 */
191   PORT_BIT ( 0x40, IP_ACTIVE_HIGH, IPT_COIN1 )
192   PORT_BIT ( 0x80, IP_ACTIVE_HIGH, IPT_COIN2 )
403   PORT_START_TAG("COIN")
404   PORT_BIT( 0x3f, IP_ACTIVE_LOW, IPT_UNUSED )
405   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_COIN1 )
406   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_COIN2 )
193407
194   PORT_START      /* IN1 */
195   PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_START1 )
196   PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_START2 )
408   PORT_START_TAG("START")
409   PORT_BIT( 0x3f, IP_ACTIVE_LOW, IPT_UNUSED )
410   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 )
411   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
197412
198   PORT_START      /* IN2 */
199   PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_TILT )
413   PORT_START_TAG("SERVICE")
414   PORT_BIT( 0x3f, IP_ACTIVE_LOW, IPT_UNUSED )
415   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_TILT )
200416   PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
201417
202   PORT_START      /* IN3 */
203   PORT_BIT ( 0xFF, IP_ACTIVE_LOW, IPT_VBLANK )
418   PORT_START_TAG("SERVE")
419   PORT_BIT( 0x7f, IP_ACTIVE_LOW, IPT_UNUSED )
420   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON1 )
204421
205   PORT_START      /* IN4 */
206   PORT_BIT ( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON1 )
422   PORT_START_TAG("PADDLE")
423   PORT_BIT( 0xff, 0x00, IPT_PADDLE ) PORT_SENSITIVITY(50) PORT_KEYDELTA(10) PORT_CENTERDELTA(0)
207424
208   PORT_START      /* IN5 */
209   PORT_BIT( 0xff, 0x00, IPT_PADDLE ) PORT_SENSITIVITY(50) PORT_KEYDELTA(10) PORT_CENTERDELTA(0) PORT_REVERSE
210
211425   PORT_START_TAG("SELECT")      /* IN6 - fake port, used to set the game select dial */
212   PORT_CONFNAME( 0x07, 0x01, "Game Select" )
213   PORT_CONFSETTING(    0x01, "Progressive" )
426   PORT_CONFNAME( 0x03, 0x00, "Game Select" )
427   PORT_CONFSETTING(    0x00, "Progressive" )
214428   PORT_CONFSETTING(    0x02, "Double" )
215   PORT_CONFSETTING(    0x04, "Cavity" )
429   PORT_CONFSETTING(    0x01, "Cavity" )
216430INPUT_PORTS_END
217431
218432
r1478r1479
263477static MACHINE_DRIVER_START( sbrkout )
264478
265479   /* basic machine hardware */
266   MDRV_CPU_ADD(M6502,375000)       /* 375 KHz? Should be 750KHz? */
267   MDRV_CPU_PROGRAM_MAP(readmem,writemem)
268   MDRV_CPU_VBLANK_INT(sbrkout_interrupt,1)
480   MDRV_CPU_ADD(M6502,MAIN_CLOCK/16)       /* 375 KHz? Should be 750KHz? */
481   MDRV_CPU_PROGRAM_MAP(main_map,0)
269482
270   MDRV_SCREEN_REFRESH_RATE(60)
271   MDRV_SCREEN_VBLANK_TIME(DEFAULT_REAL_60HZ_VBLANK_DURATION)
272
483   MDRV_MACHINE_START(sbrkout)
273484   MDRV_MACHINE_RESET(sbrkout)
485   MDRV_WATCHDOG_VBLANK_INIT(8)
274486
275487   /* video hardware */
276488   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
277   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
278   MDRV_SCREEN_SIZE(32*8, 28*8)
279   MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 0*8, 28*8-1)
280489   MDRV_GFXDECODE(sbrkout)
281490   MDRV_PALETTE_LENGTH(2)
282491
283   MDRV_PALETTE_INIT(sbrkout)
492   MDRV_SCREEN_ADD("main", 0)
493   MDRV_SCREEN_RAW_PARAMS(MAIN_CLOCK/2, 384, 0, 256, 262, 0, 224)
494   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
495
496   MDRV_PALETTE_INIT(black_and_white)
284497   MDRV_VIDEO_START(sbrkout)
285498   MDRV_VIDEO_UPDATE(sbrkout)
286499
287500   /* sound hardware */
288501   MDRV_SPEAKER_STANDARD_MONO("mono")
289
290502   MDRV_SOUND_ADD(DAC, 0)
291503   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
292504MACHINE_DRIVER_END
r1478r1479
300512 *************************************/
301513
302514ROM_START( sbrkout )
303   ROM_REGION( 0x10000, REGION_CPU1, 0 )
515   ROM_REGION( 0x4000, REGION_CPU1, 0 )
304516   ROM_LOAD( "033453.c1",    0x2800, 0x0800, CRC(a35d00e3) SHA1(53617ed1d362e82d6f45abd66056bffe23300e3b) )
305517   ROM_LOAD( "033454.d1",    0x3000, 0x0800, CRC(d42ea79a) SHA1(66c9b29226cde36d1ac6d1e81f34ebb5c79eded4) )
306518   ROM_LOAD( "033455.e1",    0x3800, 0x0800, CRC(e0a6871c) SHA1(1bdfa73d7b8d91e1c68b7847fc310cac314ee02d) )
307   ROM_RELOAD(               0xf800, 0x0800 )
308519
309520   ROM_REGION( 0x0400, REGION_GFX1, ROMREGION_DISPOSE )
310521   ROM_LOAD( "033280.p4",    0x0000, 0x0200, CRC(5a69ce85) SHA1(ad9078d12495c350738bdb0b1e1b6120d9e01f60) )
r1478r1479
315526
316527   ROM_REGION( 0x0120, REGION_PROMS, 0 )
317528   ROM_LOAD( "006400.m2",    0x0000, 0x0100, CRC(b8094b4c) SHA1(82dc6799a19984f3b204ee3aeeb007e55afc8be3) )   /* sync (not used) */
318   ROM_LOAD( "006401.e2",    0x0100, 0x0020, CRC(857df8db) SHA1(06313d5bde03220b2bc313d18e50e4bb1d0cfbbb) )   /* unknown */
529   ROM_LOAD( "006401.e2",    0x0100, 0x0020, CRC(857df8db) SHA1(06313d5bde03220b2bc313d18e50e4bb1d0cfbbb) )   /* memory mapper */
319530ROM_END
320531
321532
r1478r1479
326537 *
327538 *************************************/
328539
329GAMEL( 1978, sbrkout, 0, sbrkout, sbrkout, 0, ROT270, "Atari", "Super Breakout", 0, layout_sbrkout )
540GAMEL( 1978, sbrkout, 0, sbrkout, sbrkout, 0, ROT270, "Atari", "Super Breakout", GAME_SUPPORTS_SAVE, layout_sbrkout )
src/mame/drivers/legionna.c
r1478r1479
10091009//  xp = (param1 & 0x00f0) >> 4;
10101010//  yp = (param1 & 0x0f00) >> 8;
10111011
1012//  ui_popup("%04x %04x",param1,param2);
1012//  popmessage("%04x %04x",param1,param2);
10131013
10141014   xp = 0;
10151015   yp = 0;
r1478r1479
11721172      case (0x420/2):
11731173      {
11741174         //coin counter write
1175         //ui_popup("%04x",mcu_ram[offset]);
1175         //popmessage("%04x",mcu_ram[offset]);
11761176         prot_bcd[0] = protection_bcd_jsr(mcu_ram[offset]);
11771177         //prot_bcd = mcu_ram[offset] - 0x22;
11781178         break;
r1478r1479
12051205            break;
12061206            case 0x4100: break;
12071207            case 0x41c0: break;
1208            //default: ui_popup("%04x",mcu_ram[offset]);
1208            //default: popmessage("%04x",mcu_ram[offset]);
12091209         }
12101210         break;
12111211      }
r1478r1479
14711471     if(offset > (0x500/2) && offset < (0x600/2))
14721472     {
14731473        logerror("CPU0 PC %06x MCU read offset: %04x\n",activecpu_get_previouspc(),offset*2);
1474      //ui_popup("PC %06x MCU read: %04x",activecpu_get_previouspc(),offset*2);
1474      //popmessage("PC %06x MCU read: %04x",activecpu_get_previouspc(),offset*2);
14751475   }
14761476
14771477   return mcu_ram[offset];
r1478r1479
15011501            break;
15021502            case 0x4100: break;
15031503            case 0x41c0: break;
1504            //default: ui_popup("%04x",mcu_ram[offset]);
1504            //default: popmessage("%04x",mcu_ram[offset]);
15051505         }
15061506         break;
15071507      }
r1478r1479
16141614      case (0x420/2):
16151615      {
16161616         //coin counter write
1617         //ui_popup("%04x",mcu_ram[offset]);
1617         //popmessage("%04x",mcu_ram[offset]);
16181618         prot_bcd[0] = protection_bcd_jsr(mcu_ram[offset]);
16191619         //prot_bcd = mcu_ram[offset] - 0x22;
16201620         break;
r1478r1479
16561656         {
16571657            case 0xa180:/*do the job [1]*/
16581658            {
1659               //ui_popup("%08x %08x %04x",dma_src,dma_dst,dma_size);
1659               //popmessage("%08x %08x %04x",dma_src,dma_dst,dma_size);
16601660               /*fix the offset for easier reading*/
16611661               dma_src+=4;
16621662               //dma_dst+=4;
r1478r1479
18421842
18431843//      default:
18441844//      logerror("CPU0 PC %06x MCU write offset: %04x data: %04x\n",activecpu_get_previouspc(),offset*2,data);
1845//      ui_popup("CPU0 PC %06x MCU write offset: %04x data: %04x",activecpu_get_previouspc(),offset*2,data);
1845//      popmessage("CPU0 PC %06x MCU write offset: %04x data: %04x",activecpu_get_previouspc(),offset*2,data);
18461846   }
18471847}
18481848
src/mame/drivers/mario.c
r1478r1479
11/***************************************************************************
22
3TODO:
4    - combine memory maps
5    - discrete sound
6    - combine sh_* writes into one routine
7
8Done:
9    - fixed mario0110u1gre
10    - rewrote driver, separate MACHINE_DRIVER(mario_audio)
11    - palette from schematics
12    - video timing from schematics
13    - driver configuration switch Nintendo/Std Monitor
14    - got rid of COLORTABLE
15    - clocks as defines in .h
16    - use XTAL_*
17
318Mario Bros memory map (preliminary):
419
520driver by Mirko Buffoni
r1478r1479
6984***************************************************************************/
7085
7186#include "driver.h"
72#include "cpu/i8039/i8039.h"
73#include "sound/dac.h"
74#include "sound/ay8910.h"
75#include "sound/samples.h"
7687
77static UINT8 p[8] = { 0,0xf0,0,0,0,0,0,0 };
78static UINT8 t[2] = { 0,0 };
88#include "mario.h"
7989
80static UINT8 last;
90/*************************************
91 *
92 *  Main CPU memory handlers
93 *
94 *************************************/
8195
82
83extern WRITE8_HANDLER( mario_videoram_w );
84extern WRITE8_HANDLER( mario_gfxbank_w );
85extern WRITE8_HANDLER( mario_palettebank_w );
86extern WRITE8_HANDLER( mario_scroll_w );
87
88extern PALETTE_INIT( mario );
89extern VIDEO_START( mario );
90extern VIDEO_UPDATE( mario );
91
92/*
93 *  from audio/mario.c
94 */
95extern WRITE8_HANDLER( mario_sh_w );
96extern WRITE8_HANDLER( mario_sh1_w );
97extern WRITE8_HANDLER( mario_sh2_w );
98extern WRITE8_HANDLER( mario_sh3_w );
99
100
101static MACHINE_START( mario )
102{
103   state_save_register_global_array(p);
104   state_save_register_global_array(t);
105   state_save_register_global(last);
106}
107
108
109#define ACTIVELOW_PORT_BIT(P,A,D)   ((P & (~(1 << A))) | ((D ^ 1) << A))
110#define ACTIVEHIGH_PORT_BIT(P,A,D)   ((P & (~(1 << A))) | (D << A))
111
112
113static WRITE8_HANDLER( mario_sh_getcoin_w )    { t[0] = data; }
114static WRITE8_HANDLER( mario_sh_crab_w )       { p[1] = ACTIVEHIGH_PORT_BIT(p[1],0,data); }
115static WRITE8_HANDLER( mario_sh_turtle_w )     { p[1] = ACTIVEHIGH_PORT_BIT(p[1],1,data); }
116static WRITE8_HANDLER( mario_sh_fly_w )        { p[1] = ACTIVEHIGH_PORT_BIT(p[1],2,data); }
117static WRITE8_HANDLER( mario_sh_tuneselect_w ) { soundlatch_w(offset,data); }
118
119static READ8_HANDLER( mario_sh_p1_r )   { return p[1]; }
120static READ8_HANDLER( mario_sh_p2_r )   { return p[2]; }
121static READ8_HANDLER( mario_sh_t0_r )   { return t[0]; }
122static READ8_HANDLER( mario_sh_t1_r )   { return t[1]; }
123static READ8_HANDLER( mario_sh_tune_r ) { return soundlatch_r(offset); }
124
125static WRITE8_HANDLER( mario_sh_sound_w )
126{
127   DAC_data_w(0,data);
128}
129static WRITE8_HANDLER( mario_sh_p1_w )
130{
131   p[1] = data;
132}
133static WRITE8_HANDLER( mario_sh_p2_w )
134{
135   p[2] = data;
136}
137static WRITE8_HANDLER( masao_sh_irqtrigger_w )
138{
139   if (last == 1 && data == 0)
140   {
141      /* setting bit 0 high then low triggers IRQ on the sound CPU */
142      cpunum_set_input_line_and_vector(1,0,HOLD_LINE,0xff);
143   }
144
145   last = data;
146}
147
14896static ADDRESS_MAP_START( readmem, ADDRESS_SPACE_PROGRAM, 8 )
14997   AM_RANGE(0x0000, 0x5fff) AM_READ(MRA8_ROM)
15098   AM_RANGE(0x6000, 0x6fff) AM_READ(MRA8_RAM)
r1478r1479
198146
199147static ADDRESS_MAP_START( mario_writeport, ADDRESS_SPACE_IO, 8 )
200148   ADDRESS_MAP_FLAGS( AMEF_ABITS(8) )
201   AM_RANGE(0x00, 0x00) AM_WRITE(MWA8_NOP)  /* unknown... is this a trigger? */
149   AM_RANGE(0x00, 0x00) AM_WRITE(MWA8_NOP)  /*Z80 DMA Ctrl port */
202150ADDRESS_MAP_END
203151
152/*************************************
153 *
154 *  Port definitions
155 *
156 *************************************/
204157
205static ADDRESS_MAP_START( readmem_sound, ADDRESS_SPACE_PROGRAM, 8 )
206   AM_RANGE(0x0000, 0x0fff) AM_READ(MRA8_ROM)
207ADDRESS_MAP_END
208
209static ADDRESS_MAP_START( writemem_sound, ADDRESS_SPACE_PROGRAM, 8 )
210   AM_RANGE(0x0000, 0x0fff) AM_WRITE(MWA8_ROM)
211ADDRESS_MAP_END
212
213static ADDRESS_MAP_START( readport_sound, ADDRESS_SPACE_IO, 8 )
214   AM_RANGE(0x00, 0xff) AM_READ(mario_sh_tune_r)
215   AM_RANGE(I8039_p1, I8039_p1) AM_READ(mario_sh_p1_r)
216   AM_RANGE(I8039_p2, I8039_p2) AM_READ(mario_sh_p2_r)
217   AM_RANGE(I8039_t0, I8039_t0) AM_READ(mario_sh_t0_r)
218   AM_RANGE(I8039_t1, I8039_t1) AM_READ(mario_sh_t1_r)
219ADDRESS_MAP_END
220
221static ADDRESS_MAP_START( writeport_sound, ADDRESS_SPACE_IO, 8 )
222   AM_RANGE(0x00, 0xff) AM_WRITE(mario_sh_sound_w)
223   AM_RANGE(I8039_p1, I8039_p1) AM_WRITE(mario_sh_p1_w)
224   AM_RANGE(I8039_p2, I8039_p2) AM_WRITE(mario_sh_p2_w)
225ADDRESS_MAP_END
226
227
228
229158static INPUT_PORTS_START( mario )
230159   PORT_START_TAG("IN0")
231160   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_PLAYER(1)
r1478r1479
268197   PORT_DIPSETTING(    0x80, DEF_STR( Medium ) )
269198   PORT_DIPSETTING(    0x40, DEF_STR( Hard ) )
270199   PORT_DIPSETTING(    0xc0, DEF_STR( Hardest ) )
200
201   PORT_START_TAG("MONITOR")
202   PORT_CONFNAME( 0x01, 0x00, "Monitor" )
203   PORT_CONFSETTING(    0x00, "Nintendo" )
204   PORT_CONFSETTING(    0x01, "Std 15.72Khz" )
205
271206INPUT_PORTS_END
272207
273208static INPUT_PORTS_START( marioo )
r1478r1479
318253INPUT_PORTS_END
319254
320255
256/*************************************
257 *
258 *  Graphics definitions
259 *
260 *************************************/
321261
322262static const gfx_layout charlayout =
323263{
r1478r1479
344284   16*8   /* every sprite takes 16 consecutive bytes */
345285};
346286
347
348
349287static GFXDECODE_START( mario )
350288   GFXDECODE_ENTRY( REGION_GFX1, 0, charlayout,      0, 16 )
351   GFXDECODE_ENTRY( REGION_GFX2, 0, spritelayout, 16*4, 32 )
289   GFXDECODE_ENTRY( REGION_GFX2, 0, spritelayout,      0, 32 )
352290GFXDECODE_END
353291
354292
293/*************************************
294 *
295 *  Machine driver
296 *
297 *************************************/
355298
356static const char *const mario_sample_names[] =
357{
358   "*mario",
359
360   /* 7f01 - 7f07 sounds */
361   "ice.wav",    /* 0x02 ice appears (formerly effect0.wav) */
362   "coin.wav",   /* 0x06 coin appears (formerly effect1.wav) */
363   "skid.wav",   /* 0x07 skid */
364
365   /* 7c00 */
366   "run.wav",        /* 03, 02, 01 - 0x1b */
367
368   /* 7c80 */
369   "luigirun.wav",   /* 03, 02, 01 - 0x1c */
370
371    0   /* end of array */
372};
373
374static const struct Samplesinterface samples_interface =
375{
376   3,   /* 3 channels */
377   mario_sample_names
378};
379
380static const struct AY8910interface ay8910_interface =
381{
382   soundlatch_r
383};
384
385static ADDRESS_MAP_START( masao_sound_readmem, ADDRESS_SPACE_PROGRAM, 8 )
386   AM_RANGE(0x0000, 0x0fff) AM_READ(MRA8_ROM)
387   AM_RANGE(0x2000, 0x23ff) AM_READ(MRA8_RAM)
388   AM_RANGE(0x4000, 0x4000) AM_READ(AY8910_read_port_0_r)
389ADDRESS_MAP_END
390
391static ADDRESS_MAP_START( masao_sound_writemem, ADDRESS_SPACE_PROGRAM, 8 )
392   AM_RANGE(0x0000, 0x0fff) AM_WRITE(MWA8_ROM)
393   AM_RANGE(0x2000, 0x23ff) AM_WRITE(MWA8_RAM)
394   AM_RANGE(0x6000, 0x6000) AM_WRITE(AY8910_control_port_0_w)
395   AM_RANGE(0x4000, 0x4000) AM_WRITE(AY8910_write_port_0_w)
396ADDRESS_MAP_END
397
398
399299static MACHINE_DRIVER_START( mario )
400300
401301   /* basic machine hardware */
402   MDRV_CPU_ADD(Z80, 8000000/2)   /* verified on pcb */
302   MDRV_CPU_ADD(Z80, Z80_CLOCK)   /* verified on pcb */
403303   MDRV_CPU_PROGRAM_MAP(readmem,writemem)
404304   MDRV_CPU_IO_MAP(0,mario_writeport)
405305   MDRV_CPU_VBLANK_INT(nmi_line_pulse,1)
406306
407   MDRV_CPU_ADD(I8039, 730000)
408   /* audio CPU */         /* verified on pcb */
409   MDRV_CPU_PROGRAM_MAP(readmem_sound,writemem_sound)
410   MDRV_CPU_IO_MAP(readport_sound,writeport_sound)
411
412   MDRV_MACHINE_START(mario)
413   MDRV_SCREEN_REFRESH_RATE(60)
414   MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION)
415
416307   /* video hardware */
417308   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
418309   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
419   MDRV_SCREEN_SIZE(32*8, 32*8)
420   MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1)
310   MDRV_SCREEN_RAW_PARAMS(PIXEL_CLOCK, HTOTAL, HBEND, HBSTART, VTOTAL, VBEND, VBSTART)
421311   MDRV_GFXDECODE(mario)
422   MDRV_PALETTE_LENGTH(256)
423   MDRV_COLORTABLE_LENGTH(16*4+32*8)
312   MDRV_PALETTE_LENGTH(512)
424313
425314   MDRV_PALETTE_INIT(mario)
426315   MDRV_VIDEO_START(mario)
427316   MDRV_VIDEO_UPDATE(mario)
428317
429318   /* sound hardware */
430   MDRV_SPEAKER_STANDARD_MONO("mono")
431
432   MDRV_SOUND_ADD(DAC, 0)
433   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
434
435   MDRV_SOUND_ADD(SAMPLES, 0)
436   MDRV_SOUND_CONFIG(samples_interface)
437   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
319   MDRV_IMPORT_FROM(mario_audio)
438320MACHINE_DRIVER_END
439321
440322
r1478r1479
445327   MDRV_CPU_PROGRAM_MAP(readmem,masao_writemem)
446328   MDRV_CPU_VBLANK_INT(nmi_line_pulse,1)
447329
448   MDRV_CPU_ADD(Z80,24576000/16)
449   /* audio CPU */   /* ???? */
450   MDRV_CPU_PROGRAM_MAP(masao_sound_readmem,masao_sound_writemem)
451
452   MDRV_MACHINE_START(mario)
453   MDRV_SCREEN_REFRESH_RATE(60)
454   MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION)
455
456330   /* video hardware */
457331   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
458332   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
459   MDRV_SCREEN_SIZE(32*8, 32*8)
460   MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1)
333   MDRV_SCREEN_RAW_PARAMS(PIXEL_CLOCK, HTOTAL, HBEND, HBSTART, VTOTAL, VBEND, VBSTART)
461334   MDRV_GFXDECODE(mario)
462   MDRV_PALETTE_LENGTH(256)
463   MDRV_COLORTABLE_LENGTH(16*4+32*8)
335   MDRV_PALETTE_LENGTH(512)
464336
465337   MDRV_PALETTE_INIT(mario)
466338   MDRV_VIDEO_START(mario)
467339   MDRV_VIDEO_UPDATE(mario)
468340
469341   /* sound hardware */
470   MDRV_SPEAKER_STANDARD_MONO("mono")
471
472   MDRV_SOUND_ADD(AY8910, 14318000/6)
473   MDRV_SOUND_CONFIG(ay8910_interface)
474   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
342   MDRV_IMPORT_FROM(masao_audio)
475343MACHINE_DRIVER_END
476344
477345
346/*************************************
347 *
348 *  ROM definitions
349 *
350 *************************************/
478351
479
480/***************************************************************************
481
482  Game driver(s)
483
484***************************************************************************/
485
486352ROM_START( mario )
487353   ROM_REGION( 0x10000, REGION_CPU1, 0 )
488354   ROM_LOAD( "tma1-c.7f_e-1",     0x0000, 0x2000, CRC(c0c6e014) SHA1(36a04f9ca1c2a583477cb8a6f2ef94e044e08296) )
r1478r1479
587453   ROM_LOAD( "mario.4p",     0x0000, 0x0200, CRC(afc9bd41) SHA1(90b739c4c7f24a88b6ac5ca29b06c032906a2801) )
588454ROM_END
589455
456/*************************************
457 *
458 *  Game drivers
459 *
460 *************************************/
590461
591
592462GAME( 1983, mario,    0,       mario,   mario,   0, ROT180, "Nintendo of America", "Mario Bros. (US, set 1)", GAME_SUPPORTS_SAVE )
593463GAME( 1983, marioo,   mario,   mario,   marioo,  0, ROT180, "Nintendo of America", "Mario Bros. (US, set 2)", GAME_SUPPORTS_SAVE )
594464GAME( 1983, marioj,   mario,   mario,   marioj,  0, ROT180, "Nintendo", "Mario Bros. (Japan)", GAME_SUPPORTS_SAVE )
src/mame/drivers/suprloco.c
r1478r1479
1818#include "sound/sn76496.h"
1919
2020extern UINT8 *suprloco_videoram;
21extern UINT8 *suprloco_scrollram;
2122
2223PALETTE_INIT( suprloco );
2324VIDEO_START( suprloco );
2425VIDEO_UPDATE( suprloco );
2526WRITE8_HANDLER( suprloco_videoram_w );
2627WRITE8_HANDLER( suprloco_scrollram_w );
27READ8_HANDLER( suprloco_scrollram_r );
2828WRITE8_HANDLER( suprloco_control_w );
2929READ8_HANDLER( suprloco_control_r );
3030
r1478r1479
3737   cpu_spinuntil_time(ATTOTIME_IN_USEC(50));
3838}
3939
40
41static ADDRESS_MAP_START( readmem, ADDRESS_SPACE_PROGRAM, 8 )
42   AM_RANGE(0x0000, 0x7fff) AM_READ(MRA8_ROM)
43   AM_RANGE(0x8000, 0xbfff) AM_READ(MRA8_ROM)
44   AM_RANGE(0xc000, 0xc1ff) AM_READ(MRA8_RAM)
40static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
41   AM_RANGE(0x0000, 0x7fff) AM_ROM
42   AM_RANGE(0x8000, 0xbfff) AM_ROM
43   AM_RANGE(0xc000, 0xc1ff) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
4544   AM_RANGE(0xc800, 0xc800) AM_READ(input_port_0_r)
4645   AM_RANGE(0xd000, 0xd000) AM_READ(input_port_1_r)
4746   AM_RANGE(0xd800, 0xd800) AM_READ(input_port_2_r)
4847   AM_RANGE(0xe000, 0xe000) AM_READ(input_port_3_r)
4948   AM_RANGE(0xe001, 0xe001) AM_READ(input_port_4_r)
50   AM_RANGE(0xe801, 0xe801) AM_READ(suprloco_control_r)
51   AM_RANGE(0xf000, 0xf6ff) AM_READ(MRA8_RAM)
52   AM_RANGE(0xf7e0, 0xf7ff) AM_READ(suprloco_scrollram_r)
53   AM_RANGE(0xf800, 0xffff) AM_READ(MRA8_RAM)
54ADDRESS_MAP_END
55
56static ADDRESS_MAP_START( writemem, ADDRESS_SPACE_PROGRAM, 8 )
57   AM_RANGE(0x0000, 0x7fff) AM_WRITE(MWA8_ROM)
58   AM_RANGE(0x8000, 0xbfff) AM_WRITE(MWA8_ROM)
59   AM_RANGE(0xc000, 0xc1ff) AM_WRITE(MWA8_RAM) AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
6049   AM_RANGE(0xe800, 0xe800) AM_WRITE(suprloco_soundport_w)
61   AM_RANGE(0xe801, 0xe801) AM_WRITE(suprloco_control_w)
62   AM_RANGE(0xf000, 0xf6ff) AM_WRITE(suprloco_videoram_w) AM_BASE(&suprloco_videoram)
63   AM_RANGE(0xf7e0, 0xf7ff) AM_WRITE(suprloco_scrollram_w)
64   AM_RANGE(0xf800, 0xffff) AM_WRITE(MWA8_RAM)
50   AM_RANGE(0xe801, 0xe801) AM_READWRITE(suprloco_control_r, suprloco_control_w)
51   AM_RANGE(0xf000, 0xf6ff) AM_RAM AM_WRITE(suprloco_videoram_w) AM_BASE(&suprloco_videoram)
52   AM_RANGE(0xf700, 0xf7df) AM_RAM /* unused */
53   AM_RANGE(0xf7e0, 0xf7ff) AM_RAM AM_WRITE(suprloco_scrollram_w) AM_BASE(&suprloco_scrollram)
54   AM_RANGE(0xf800, 0xffff) AM_RAM
6555ADDRESS_MAP_END
6656
67
68static ADDRESS_MAP_START( sound_readmem, ADDRESS_SPACE_PROGRAM, 8 )
69   AM_RANGE(0x0000, 0x7fff) AM_READ(MRA8_ROM)
70   AM_RANGE(0x8000, 0x87ff) AM_READ(MRA8_RAM)
71   AM_RANGE(0xe000, 0xe000) AM_READ(soundlatch_r)
72ADDRESS_MAP_END
73
74static ADDRESS_MAP_START( sound_writemem, ADDRESS_SPACE_PROGRAM, 8 )
75   AM_RANGE(0x0000, 0x7fff) AM_WRITE(MWA8_ROM)
76   AM_RANGE(0x8000, 0x87ff) AM_WRITE(MWA8_RAM)
57static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 )
58   AM_RANGE(0x0000, 0x7fff) AM_ROM
59   AM_RANGE(0x8000, 0x87ff) AM_RAM
7760   AM_RANGE(0xa000, 0xa003) AM_WRITE(SN76496_0_w)
7861   AM_RANGE(0xc000, 0xc003) AM_WRITE(SN76496_1_w)
62   AM_RANGE(0xe000, 0xe000) AM_READ(soundlatch_r)
7963ADDRESS_MAP_END
8064
8165
r1478r1479
8569   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
8670   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
8771   PORT_SERVICE_NO_TOGGLE(0x04, IP_ACTIVE_LOW)
88   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN3 )
72   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE1 )
8973   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 )
9074   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 )
9175   PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
r1478r1479
184168
185169   /* basic machine hardware */
186170   MDRV_CPU_ADD(Z80, 4000000)   /* 4 MHz (?) */
187   MDRV_CPU_PROGRAM_MAP(readmem,writemem)
171   MDRV_CPU_PROGRAM_MAP(main_map,0)
188172   MDRV_CPU_VBLANK_INT(irq0_line_hold,1)
189173
190174   MDRV_CPU_ADD(Z80, 4000000)
191175   /* audio CPU */
192   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
176   MDRV_CPU_PROGRAM_MAP(sound_map,0)
193177   MDRV_CPU_VBLANK_INT(irq0_line_hold,4)         /* NMIs are caused by the main CPU */
194178
195179   MDRV_SCREEN_REFRESH_RATE(60)
src/osd/windows/windows.mak
r1478r1479
4242
4343
4444#-------------------------------------------------
45# overrides
46#-------------------------------------------------
47
48# turn on unicode for all 64-bit builds regardless
49ifndef UNICODE
50ifdef PTR64
51UNICODE = 1
52endif
53endif
54
55
56
57#-------------------------------------------------
4558# object and source roots
4659#-------------------------------------------------
4760
r1478r1479
111124CC += /wd4267
112125endif
113126
127# explicitly set the entry point for UNICODE builds
128ifdef UNICODE
129LD += /ENTRY:wmainCRTStartup
130endif
131
114132# add some VC++-specific defines
115133DEFS += -D_CRT_SECURE_NO_DEPRECATE -DXML_STATIC -D__inline__=__inline -Dsnprintf=_snprintf
116134
r1478r1479
122140
123141$(VCONV): $(WINOBJ)/vconv.o
124142   @echo Linking $@...
125ifdef PTR64
126   @link.exe /nologo $^ version.lib bufferoverflowu.lib /out:$@
127else
128143   @link.exe /nologo $^ version.lib /out:$@
129endif
130144
131145$(WINOBJ)/vconv.o: $(WINSRC)/vconv.c
132146   @echo Compiling $<...
r1478r1479
259273# rule for making the ledutil sample
260274#-------------------------------------------------
261275
262ledutil$(EXE): $(WINOBJ)/ledutil.o $(LIBOCORE)
276LEDUTIL = ledutil$(EXE)
277TOOLS += $(LEDUTIL)
278
279LEDUTILOBJS = \
280   $(WINOBJ)/ledutil.o
281
282$(LEDUTIL): $(LEDUTILOBJS) $(LIBOCORE)
263283   @echo Linking $@...
264284   $(LD) $(LDFLAGS) $^ $(LIBS) -o $@
265285
266TOOLS += ledutil$(EXE)
267286
268287
269
270288#-------------------------------------------------
271289# rule for making the verinfo tool
272290#-------------------------------------------------
273291
274292VERINFO = $(WINOBJ)/verinfo$(EXE)
293BUILD += $(VERINFO)
275294
276$(VERINFO): $(WINOBJ)/verinfo.o $(LIBOCORE)
295VERINFOOBJS = \
296   $(WINOBJ)/verinfo.o
297
298$(VERINFO): $(VERINFOOBJS) $(LIBOCORE)
277299   @echo Linking $@...
278300   $(LD) $(LDFLAGS) $^ $(LIBS) -o $@
279301
280BUILD += $(VERINFO)
281302
282303
283304
src/osd/windows/ledutil.c
r1478r1479
171171//  main
172172//============================================================
173173
174int utf8_main(int argc, char *argv[])
174int main(int argc, char *argv[])
175175{
176176   const char *arg = (argc > 1) ? argv[1] : "";
177177   int exitcode = 1;
src/osd/windows/winmain.c
r1478r1479
217217//  utf8_main
218218//============================================================
219219
220int utf8_main(int argc, char **argv)
220int main(int argc, char **argv)
221221{
222222   char *ext;
223223
src/osd/windows/debugwin.c
r1478r1479
156156struct _memorycombo_item
157157{
158158   memorycombo_item *      next;
159   char               name[256];
159   TCHAR               name[256];
160160   UINT8               cpunum;
161161   UINT8               spacenum;
162162   void *               base;
r1478r1479
17211721   memorycombo_item **tail = &memorycombo;
17221722   UINT32 cpunum, spacenum;
17231723   int rgnnum, itemnum;
1724   TCHAR *t_cpunum_name, *t_address_space_names;
17241725
17251726   // first add all the CPUs' address spaces
17261727   for (cpunum = 0; cpunum < MAX_CPU; cpunum++)
r1478r1479
17351736               ci->cpunum = cpunum;
17361737               ci->spacenum = spacenum;
17371738               ci->prefsize = MIN(cpuinfo->space[spacenum].databytes, 8);
1738               sprintf(ci->name, "CPU #%d (%s) %s memory", cpunum, cpunum_name(cpunum), address_space_names[spacenum]);
1739               t_cpunum_name = tstring_from_utf8(cpunum_name(cpunum));
1740               t_address_space_names = tstring_from_utf8(address_space_names[spacenum]);
1741               _sntprintf(ci->name, ARRAY_LENGTH(ci->name), TEXT("CPU #%d (%s) %s memory"), cpunum, t_cpunum_name, t_address_space_names);
1742               free(t_address_space_names),
1743               t_address_space_names = NULL;
1744               free(t_cpunum_name);
1745               t_cpunum_name = NULL;
17391746               *tail = ci;
17401747               tail = &ci->next;
17411748            }
r1478r1479
17441751   // then add all the memory regions
17451752   for (rgnnum = 0; rgnnum < MAX_MEMORY_REGIONS; rgnnum++)
17461753   {
1754      TCHAR* t_memory_region_name;
17471755      UINT8 *base = memory_region(rgnnum);
17481756      UINT32 type = memory_region_type(Machine, rgnnum);
17491757      if (base != NULL && type > REGION_INVALID && (type - REGION_INVALID) < ARRAY_LENGTH(memory_region_names))
r1478r1479
17681776         ci->prefsize = MIN(width, 8);
17691777         ci->offset_xor = width - 1;
17701778         ci->little_endian = little_endian;
1771         strcpy(ci->name, memory_region_names[type - REGION_INVALID]);
1779         t_memory_region_name = tstring_from_utf8(memory_region_names[type - REGION_INVALID]);
1780         _tcscpy(ci->name, t_memory_region_name);
1781         free(t_memory_region_name);
1782         t_memory_region_name = NULL;
17721783         *tail = ci;
17731784         tail = &ci->next;
17741785      }
r1478r1479
17801791      UINT32 valsize, valcount;
17811792      const char *name;
17821793      void *base;
1794      TCHAR* t_name;
17831795
17841796      /* stop when we run out of items */
17851797      name = state_save_get_indexed_item(itemnum, &base, &valsize, &valcount);
r1478r1479
17951807         ci->length = valcount * valsize;
17961808         ci->prefsize = MIN(valsize, 8);
17971809         ci->little_endian = TRUE;
1798         strcpy(ci->name, strrchr(name, '/') + 1);
1810         t_name = tstring_from_utf8(name);
1811         _tcscpy(ci->name, _tcsrchr(t_name, TEXT('/')) + 1);
1812         free(t_name);
1813         t_name = NULL;
17991814         *tail = ci;
18001815         tail = &ci->next;
18011816      }
r1478r1479
18161831   debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_RAW_OFFSET_XOR, ci->offset_xor);
18171832   debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_RAW_LITTLE_ENDIAN, ci->little_endian);
18181833   debug_view_set_property_UINT32(info->view[0].view, DVP_MEM_BYTES_PER_CHUNK, ci->prefsize);
1819   win_set_window_text_utf8(info->wnd, ci->name);
1834   SetWindowText(info->wnd, ci->name);
18201835}
18211836
18221837
r1478r1479
18711886   SetWindowLongPtr(info->editwnd, GWLP_USERDATA, (LONG_PTR)info);
18721887   SetWindowLongPtr(info->editwnd, GWLP_WNDPROC, (LONG_PTR)debug_edit_proc);
18731888   SendMessage(info->editwnd, WM_SETFONT, (WPARAM)debug_font, (LPARAM)FALSE);
1874   SendMessage(info->editwnd, WM_SETTEXT, (WPARAM)0, (LPARAM)"0");
1889   SendMessage(info->editwnd, WM_SETTEXT, (WPARAM)0, (LPARAM)TEXT("0"));
18751890   SendMessage(info->editwnd, EM_LIMITTEXT, (WPARAM)MAX_EDIT_STRING, (LPARAM)0);
18761891   SendMessage(info->editwnd, EM_SETSEL, (WPARAM)0, (LPARAM)-1);
18771892
r1478r1479
22042219   SetWindowLongPtr(info->editwnd, GWLP_USERDATA, (LONG_PTR)info);
22052220   SetWindowLongPtr(info->editwnd, GWLP_WNDPROC, (LONG_PTR)debug_edit_proc);
22062221   SendMessage(info->editwnd, WM_SETFONT, (WPARAM)debug_font, (LPARAM)FALSE);
2207   SendMessage(info->editwnd, WM_SETTEXT, (WPARAM)0, (LPARAM)"curpc");
2222   SendMessage(info->editwnd, WM_SETTEXT, (WPARAM)0, (LPARAM)TEXT("curpc"));
22082223   SendMessage(info->editwnd, EM_LIMITTEXT, (WPARAM)MAX_EDIT_STRING, (LPARAM)0);
22092224   SendMessage(info->editwnd, EM_SETSEL, (WPARAM)0, (LPARAM)-1);
22102225
r1478r1479
22172232   // populate the combobox
22182233   for (cpunum = 0; cpunum < MAX_CPU; cpunum++)
22192234   {
2235      TCHAR* t_cpunum_name;
22202236      const debug_cpu_info *cpuinfo = debug_get_cpu_info(cpunum);
22212237      if (cpuinfo->valid)
22222238         if (cpuinfo->space[ADDRESS_SPACE_PROGRAM].databytes)
22232239         {
2224            char name[100];
2240            TCHAR name[100];
22252241            int item;
2226            sprintf(name, "CPU #%d (%s)", cpunum, cpunum_name(cpunum));
2242            t_cpunum_name = tstring_from_utf8(cpunum_name(cpunum));
2243            _sntprintf(name, ARRAY_LENGTH(name), TEXT("CPU #%d (%s)"), cpunum, t_cpunum_name);
2244            free(t_cpunum_name);
2245            t_cpunum_name = NULL;
22272246            item = SendMessage(info->otherwnd[0], CB_ADDSTRING, 0, (LPARAM)name);
22282247            if (cpunum == curcpu)
22292248               cursel = item;
r1478r1479
27512770
27522771   // then update the caption
27532772   snprintf(title, ARRAY_LENGTH(title), "Debug: %s - CPU %d (%s)", Machine->gamedrv->name, cpu_getactivecpu(), activecpu_name());
2754   win_get_window_text_utf8(main_console->wnd, curtitle, sizeof(curtitle) / sizeof(curtitle[0]));
2773   win_get_window_text_utf8(main_console->wnd, curtitle, ARRAY_LENGTH(curtitle));
27552774   if (strcmp(title, curtitle))
27562775      win_set_window_text_utf8(main_console->wnd, title);
27572776}
src/osd/windows/main.c
r1478r1479
2828#ifndef MESSLIB
2929#if !defined(WINUI) || defined(MESS)
3030#undef main
31#undef wmain
3132#endif
3233#endif
3334
src/emu/debug/debugcpu.c
r1478r1479
4242FILE *debug_source_file;
4343symbol_table *global_symtable;
4444
45static const char *const address_space_name[] = { "program", "data", "I/O" };
46
4745static UINT64 wpdata;
4846static UINT64 wpaddr;
4947
r1478r1479
15511549      /* if the bottom of the list is over the threshhold, print it */
15521550      debug_hotspot_entry *spot = &info->hotspots[info->hotspot_count - 1];
15531551      if (spot->count > info->hotspot_threshhold)
1554         debug_console_printf("Hotspot @ %s %08X (PC=%08X) hit %d times (fell off bottom)\n", address_space_name[spot->spacenum], spot->access, spot->pc, spot->count);
1552         debug_console_printf("Hotspot @ %s %08X (PC=%08X) hit %d times (fell off bottom)\n", address_space_names[spot->spacenum], spot->access, spot->pc, spot->count);
15551553
15561554      /* move everything else down and insert this one at the top */
15571555      memmove(&info->hotspots[1], &info->hotspots[0], sizeof(info->hotspots[0]) * (info->hotspot_count - 1));
src/emu/debug/debugcpu.h
r1478r1479
177177void            debug_refresh_display(void);
178178int               debug_get_execution_state(void);
179179UINT32            debug_get_execution_counter(void);
180void            debug_trace_printf(int cpunum, const char *fmt, ...);
180void            debug_trace_printf(int cpunum, const char *fmt, ...) ATTR_PRINTF(2,3);
181181void            debug_source_script(const char *file);
182182void            debug_flush_traces(void);
183183
src/emu/debug/debugcmd.c
r1478r1479
12751275
12761276static void execute_wplist(int ref, int params, const char *param[])
12771277{
1278   static const char *const spacenames[ADDRESS_SPACES] = { "program", "data", "I/O" };
12791278   int cpunum, printed = 0;
12801279   char buffer[256];
12811280
r1478r1479
12951294               static const char *const types[] = { "unkn ", "read ", "write", "r/w  " };
12961295               debug_cpu_watchpoint *wp;
12971296
1298               debug_console_printf("CPU %d %s space watchpoints:\n", cpunum, spacenames[spacenum]);
1297               debug_console_printf("CPU %d %s space watchpoints:\n", cpunum, address_space_names[spacenum]);
12991298
13001299               /* loop over the watchpoints */
13011300               for (wp = cpuinfo->space[spacenum].first_wp; wp; wp = wp->next)
src/emu/cpu/sharc/sharcdsm.c
r1478r1479
2828
2929
3030static char *output;
31static void print(const char *fmt, ...)
31static void ATTR_PRINTF(1,2) print(const char *fmt, ...)
3232{
3333   va_list vl;
3434
src/emu/cpu/x86log.h
r1478r1479
3838void x86log_free_context(x86log_context *log);
3939
4040/* add a comment associated with a given code pointer */
41void x86log_add_comment(x86log_context *log, x86code *base, const char *format, ...);
41void x86log_add_comment(x86log_context *log, x86code *base, const char *format, ...) ATTR_PRINTF(3, 4);
4242
4343/* mark a given range as data for logging purposes */
4444void x86log_mark_as_data(x86log_context *log, x86code *base, x86code *end, int size);
r1478r1479
4747void x86log_disasm_code_range(x86log_context *log, const char *label, x86code *start, x86code *stop);
4848
4949/* manually printf information to the log file */
50void x86log_printf(x86log_context *log, const char *format, ...);
50void x86log_printf(x86log_context *log, const char *format, ...) ATTR_PRINTF(2, 3);
5151
5252
5353#endif   /* __X86LOG_H__ */
src/emu/cpu/e132xs/e132xs.c
r1478r1479
15421542   if (IO1_LINE_STATE && (FCR & 0x00000005) == 0x00000004)
15431543   {
15441544      execute_int(get_trap_addr(IO1));
1545      (*hyperstone.irq_callback)(IRQ_IO3);
1545      (*hyperstone.irq_callback)(IRQ_IO1);
15461546      return;
15471547   }
15481548
src/emu/cpu/mc68hc11/hc11dasm.c
r1478r1479
11531153static char *output;
11541154static const UINT8 *rombase;
11551155
1156static void print(const char *fmt, ...)
1156static void ATTR_PRINTF(1,2) print(const char *fmt, ...)
11571157{
11581158   va_list vl;
11591159
src/emu/cpu/rsp/rsp_dasm.c
r1478r1479
6666
6767static char *output;
6868
69static void print(const char *fmt, ...)
69static void ATTR_PRINTF(1,2) print(const char *fmt, ...)
7070{
7171   va_list vl;
7272
src/emu/cpu/tms32051/dis32051.c
r1478r1479
5959
6060static char *output;
6161
62static void print(const char *fmt, ...)
62static void ATTR_PRINTF(1,2) print(const char *fmt, ...)
6363{
6464   va_list vl;
6565
src/emu/cpu/i8051/i8051.c
r1478r1479
114114   UINT8   cur_irq;      //Holds value of any current IRQ being serviced
115115   UINT8   irq_priority;   //Holds value of the current IRQ Priority Level
116116   UINT8   rwm;         //Signals that the current instruction is a read/write/modify instruction
117   int prev_used_cycles;   //Track previous # of used cycles
118   int last_int0;         //Store state of int0
119   int last_int1;         //Store state of int1
120   UINT8 int_vec;         //Pending Interrupt Vector
121   int priority_request;   //Priority level of incoming new irq
117   UINT8   prev_used_cycles;   //Track previous # of used cycles
118   UINT8   last_int0;         //Store state of int0
119   UINT8   last_int1;         //Store state of int1
120   UINT8   int_vec;         //Pending Interrupt Vector
121   UINT8   priority_request;   //Priority level of incoming new irq
122122   //SFR Registers         (Note: Appear in order as they do in memory)
123123   UINT8   po;            //Port 0
124124   UINT8   sp;            //Stack Pointer
r1478r1479
484484   state_save_register_item("i8051", index, i8051.subtype);
485485   state_save_register_item("i8051", index, i8051.rwm );
486486   state_save_register_item("i8051", index, i8051.cur_irq );
487   state_save_register_item("i8051", index, i8051.irq_priority );
488   state_save_register_item("i8051", index, i8051.prev_used_cycles );
489   state_save_register_item("i8051", index, i8051.last_int0 );
490   state_save_register_item("i8051", index, i8051.last_int1 );
491   state_save_register_item("i8051", index, i8051.int_vec );
492   state_save_register_item("i8051", index, i8051.priority_request );
487493   //SFR Registers
488494   state_save_register_item("i8051", index, i8051.po);
489495   state_save_register_item("i8051", index, i8051.sp);
r1478r1479
505511   state_save_register_item("i8051", index, i8051.ip);
506512   //8052 Only registers
507513   #if (HAS_I8052 || HAS_I8752)
514      state_save_register_item("i8051", index, i8051.t2con);
508515      state_save_register_item("i8051", index, i8051.rcap2l);
509516      state_save_register_item("i8051", index, i8051.rcap2h);
510517      state_save_register_item("i8051", index, i8051.tl2);
r1478r1479
513520   state_save_register_item("i8051", index, i8051.psw);
514521   state_save_register_item("i8051", index, i8051.acc);
515522   state_save_register_item("i8051", index, i8051.b);
523   state_save_register_item_array("i8051", index, i8051.IntRam);
516524}
517525
518526/* Reset registers to the initial values */
src/emu/cpu/mips/psx.c
r1478r1479
129129};
130130
131131#if 0
132void GTELOG(const char *a,...)
132void ATTR_PRINTF(1,2) GTELOG(const char *a,...)
133133{
134134   va_list va;
135135   char s_text[ 1024 ];
r1478r1479
139139   logerror( "%08x: GTE: %08x %s\n", mipscpu.pc, INS_COFUN( mipscpu.op ), s_text );
140140}
141141#else
142INLINE void GTELOG(const char *a, ...) {}
142INLINE void ATTR_PRINTF(1,2) GTELOG(const char *a, ...) {}
143143#endif
144144
145145static UINT32 getcp2dr( int n_reg );
r1478r1479
31263126      }
31273127      break;
31283128   }
3129   ui_popup_time( 1, "unknown GTE op %08x", gteop );
3129   popmessage( "unknown GTE op %08x", gteop );
31303130   logerror( "%08x: unknown GTE op %08x\n", mipscpu.pc, gteop );
31313131   mips_stop();
31323132}
src/emu/uimenu.c
r1478r1479
206206    to the string pool
207207-------------------------------------------------*/
208208
209INLINE const char *CLIB_DECL menu_string_pool_add(const char *format, ...)
209INLINE const char *CLIB_DECL ATTR_PRINTF(1,2) menu_string_pool_add(const char *format, ...)
210210{
211211   char *result = &menu_string_pool[menu_string_pool_offset];
212212   va_list arg;
src/emu/memory.c
r1478r1479
143143#define HANDLER_IS_BANK(h)      ((FPTR)(h) >= STATIC_BANK1 && (FPTR)(h) <= STATIC_BANKMAX)
144144#define HANDLER_IS_STATIC(h)   ((FPTR)(h) < STATIC_COUNT)
145145
146#define HANDLER_TO_BANK(h)      ((FPTR)(h))
146#define HANDLER_TO_BANK(h)      ((UINT32)(FPTR)(h))
147147#define BANK_TO_HANDLER(b)      ((genf *)(FPTR)(b))
148148
149149#define SPACE_SHIFT(s,a)      (((s)->ashift < 0) ? ((a) << -(s)->ashift) : ((a) >> (s)->ashift))
r1478r1479
870870
871871
872872/*-------------------------------------------------
873    memory_get_bank - return the currently
874    selected bank
875-------------------------------------------------*/
876
877int memory_get_bank(int banknum)
878{
879   /* validation checks */
880   if (banknum < STATIC_BANK1 || banknum > MAX_EXPLICIT_BANKS || !bankdata[banknum].used)
881      fatalerror("memory_get_bank called with invalid bank %d", banknum);
882   if (bankdata[banknum].dynamic)
883      fatalerror("memory_get_bank called with dynamic bank %d", banknum);
884   return bankdata[banknum].curentry;
885}
886
887
888
889/*-------------------------------------------------
873890    memory_set_bankptr - set the base of a bank
874891-------------------------------------------------*/
875892
r1478r1479
21182135   int allocatemem = (memory == NULL);
21192136   int region;
21202137
2121   VPRINTF(("allocate_memory_block(%d,%d,%08X,%08X,%08X)\n", cpunum, spacenum, start, end, (UINT32)memory));
2138   VPRINTF(("allocate_memory_block(%d,%d,%08X,%08X,%p)\n", cpunum, spacenum, start, end, memory));
21222139
21232140   /* if we weren't passed a memory block, allocate one and clear it to zero */
21242141   if (allocatemem)
r1478r1479
21882205            if (map->share && shared_ptr[map->share])
21892206            {
21902207               map->memory = shared_ptr[map->share];
2191                VPRINTF(("memory range %08X-%08X -> shared_ptr[%d] [%08X]\n", map->start, map->end, map->share, (UINT32)map->memory));
2208                VPRINTF(("memory range %08X-%08X -> shared_ptr[%d] [%p]\n", map->start, map->end, map->share, map->memory));
21922209             }
21932210
21942211            /* otherwise, look for a match in this block */
r1478r1479
21992216                  if (map->start >= start && map->end <= end)
22002217                  {
22012218                     map->memory = base + (map->start - start);
2202                      VPRINTF(("memory range %08X-%08X -> found in block from %08X-%08X [%08X]\n", map->start, map->end, start, end, (UINT32)map->memory));
2219                      VPRINTF(("memory range %08X-%08X -> found in block from %08X-%08X [%p]\n", map->start, map->end, start, end, map->memory));
22032220                   }
22042221               }
22052222               else
r1478r1479
22072224                  if (map->start >= start && map->start + map->mask <= end)
22082225                  {
22092226                     map->memory = base + (map->start - start);
2210                      VPRINTF(("memory range %08X-%08X -> found in block from %08X-%08X [%08X]\n", map->start, map->end, start, end, (UINT32)map->memory));
2227                      VPRINTF(("memory range %08X-%08X -> found in block from %08X-%08X [%p]\n", map->start, map->end, start, end, map->memory));
22112228                   }
22122229               }
22132230            }
r1478r1479
22902307            if (!IS_AMENTRY_EXTENDED(map) && map->start == bankdata[banknum].base)
22912308            {
22922309               bank_ptr[banknum] = map->memory;
2293                VPRINTF(("assigned bank %d pointer to memory from range %08X-%08X [%08X]\n", banknum, map->start, map->end, (UINT32)map->memory));
2310                VPRINTF(("assigned bank %d pointer to memory from range %08X-%08X [%p]\n", banknum, map->start, map->end, map->memory));
22942311               break;
22952312            }
22962313
r1478r1479
23282345         {
23292346            if (maskoffs >= map->start && maskoffs <= map->end)
23302347            {
2331               VPRINTF(("found in entry %08X-%08X [%08X]\n", map->start, map->end, (UINT32)map->memory + (maskoffs - map->start)));
2348               VPRINTF(("found in entry %08X-%08X [%p]\n", map->start, map->end, (UINT8 *)map->memory + (maskoffs - map->start)));
23322349               return (UINT8 *)map->memory + (maskoffs - map->start);
23332350            }
23342351         }
r1478r1479
23362353         {
23372354            if ((maskoffs & map->end) == map->start)
23382355            {
2339               VPRINTF(("found in entry %08X-%08X [%08X]\n", map->start, map->end, (UINT32)map->memory + (maskoffs - map->start)));
2356               VPRINTF(("found in entry %08X-%08X [%p]\n", map->start, map->end, (UINT8 *)map->memory + (maskoffs - map->start)));
23402357               return (UINT8 *)map->memory + (maskoffs - map->start);
23412358            }
23422359         }
r1478r1479
23462363   for (blocknum = 0, block = memory_block_list; blocknum < memory_block_count; blocknum++, block++)
23472364      if (block->cpunum == cpunum && block->spacenum == spacenum && block->start <= offset && block->end > offset)
23482365      {
2349         VPRINTF(("found in allocated memory block %08X-%08X [%08X]\n", block->start, block->end, (UINT32)block->data + (offset - block->start)));
2366         VPRINTF(("found in allocated memory block %08X-%08X [%p]\n", block->start, block->end, block->data + (offset - block->start)));
23502367         return block->data + offset - block->start;
23512368      }
23522369
src/emu/memory.h
r1478r1479
953953void      memory_configure_bank(int banknum, int startentry, int numentries, void *base, offs_t stride);
954954void      memory_configure_bank_decrypted(int banknum, int startentry, int numentries, void *base, offs_t stride);
955955void      memory_set_bank(int banknum, int entrynum);
956int       memory_get_bank(int banknum);
956957void      memory_set_bankptr(int banknum, void *base);
957958
958959/* ----- debugging ----- */
src/emu/mame.c
r1478r1479
11531153    popmessage - pop up a user-visible message
11541154-------------------------------------------------*/
11551155
1156void CLIB_DECL popmessage(const char *text, ...)
1156void CLIB_DECL popmessage(const char *format, ...)
11571157{
1158   extern void CLIB_DECL ui_popup(const char *text, ...) ATTR_PRINTF(1,2);
1159   va_list arg;
1158   /* if the format is NULL, it is a signal to clear the popmessage */
1159   if (format == NULL)
1160      ui_popup_time(0, " ");
11601161
1161   /* dump to the buffer */
1162   va_start(arg, text);
1163   vsnprintf(giant_string_buffer, GIANT_STRING_BUFFER_SIZE, text, arg);
1164   va_end(arg);
1162   /* otherwise, generate the buffer and call the UI to display the message */
1163   else
1164   {
1165      extern void CLIB_DECL ui_popup(const char *format, ...) ATTR_PRINTF(1,2);
1166      va_list arg;
11651167
1166   /* pop it in the UI */
1167   ui_popup("%s", giant_string_buffer);
1168      /* dump to the buffer */
1169      va_start(arg, format);
1170      vsnprintf(giant_string_buffer, GIANT_STRING_BUFFER_SIZE, format, arg);
1171      va_end(arg);
1172
1173      /* pop it in the UI */
1174      ui_popup_time((int)strlen(giant_string_buffer) / 40 + 2, "%s", giant_string_buffer);
1175   }
11681176}
11691177
11701178
r1478r1479
11731181    OSD-defined output streams
11741182-------------------------------------------------*/
11751183
1176void CLIB_DECL logerror(const char *text, ...)
1184void CLIB_DECL logerror(const char *format, ...)
11771185{
11781186   running_machine *machine = Machine;
11791187
r1478r1479
11911199         profiler_mark(PROFILER_LOGERROR);
11921200
11931201         /* dump to the buffer */
1194         va_start(arg, text);
1195         vsnprintf(giant_string_buffer, GIANT_STRING_BUFFER_SIZE, text, arg);
1202         va_start(arg, format);
1203         vsnprintf(giant_string_buffer, GIANT_STRING_BUFFER_SIZE, format, arg);
11961204         va_end(arg);
11971205
11981206         /* log to all callbacks */
src/emu/machine/x76f100.c
r1478r1479
1414
1515#define VERBOSE_LEVEL ( 0 )
1616
17INLINE void verboselog( int n_level, const char *s_fmt, ... )
17INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
1818{
1919   if( VERBOSE_LEVEL >= n_level )
2020   {
src/emu/machine/ds2401.c
r1478r1479
1313
1414#define VERBOSE_LEVEL ( 0 )
1515
16INLINE void verboselog( int n_level, const char *s_fmt, ... )
16INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
1717{
1818   if( VERBOSE_LEVEL >= n_level )
1919   {
src/emu/machine/generic.c
r1478r1479
7474      servicecoinlockedout[counternum] = 0;
7575   }
7676
77   /* register coin save state */
78   state_save_register_item_array("coin", 0, coin_count);
79   state_save_register_item_array("coin", 0, coinlockedout);
80   state_save_register_item_array("coin", 0, servicecoinlockedout);
81   state_save_register_item_array("coin", 0, lastcoin);
82
7783   /* reset NVRAM size and pointers */
7884   generic_nvram_size = 0;
7985   generic_nvram = NULL;
src/emu/machine/x76f041.c
r1478r1479
1616
1717#define VERBOSE_LEVEL ( 0 )
1818
19INLINE void verboselog( int n_level, const char *s_fmt, ... )
19INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
2020{
2121   if( VERBOSE_LEVEL >= n_level )
2222   {
src/emu/machine/adc083x.c
r1478r1479
1111
1212#define VERBOSE_LEVEL ( 0 )
1313
14INLINE void verboselog( int n_level, const char *s_fmt, ... )
14INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
1515{
1616   if( VERBOSE_LEVEL >= n_level )
1717   {
r1478r1479
6868
6969   if( chip >= MAX_ADC083X_CHIPS )
7070   {
71      verboselog( 0, "adc083x_init( %d ) chip %d out of range\n", chip );
71      verboselog( 0, "adc083x_init( %d ) chip out of range\n", chip );
7272      return;
7373   }
7474
r1478r1479
134134
135135   if( chip >= MAX_ADC083X_CHIPS )
136136   {
137      verboselog( 0, "adc083x_cs_write( %d ) chip %d out of range\n", chip );
137      verboselog( 0, "adc083x_cs_write( %d ) chip out of range\n", chip );
138138      return;
139139   }
140140
r1478r1479
254254
255255   if( chip >= MAX_ADC083X_CHIPS )
256256   {
257      verboselog( 0, "adc083x_clk_write( %d ) chip %d out of range\n", chip );
257      verboselog( 0, "adc083x_clk_write( %d ) chip out of range\n", chip );
258258      return;
259259   }
260260
r1478r1479
398398
399399   if( chip >= MAX_ADC083X_CHIPS )
400400   {
401      verboselog( 0, "adc083x_di_write( %d ) chip %d out of range\n", chip );
401      verboselog( 0, "adc083x_di_write( %d ) chip out of range\n", chip );
402402      return;
403403   }
404404
r1478r1479
418418
419419   if( chip >= MAX_ADC083X_CHIPS )
420420   {
421      verboselog( 0, "adc083x_se_write( %d ) chip %d out of range\n", chip );
421      verboselog( 0, "adc083x_se_write( %d ) chip out of range\n", chip );
422422      return;
423423   }
424424
r1478r1479
438438
439439   if( chip >= MAX_ADC083X_CHIPS )
440440   {
441      verboselog( 0, "adc083x_sars_read( %d ) chip %d out of range\n", chip );
441      verboselog( 0, "adc083x_sars_read( %d ) chip out of range\n", chip );
442442      return 0;
443443   }
444444
r1478r1479
454454
455455   if( chip >= MAX_ADC083X_CHIPS )
456456   {
457      verboselog( 0, "adc083x_do_read( %d ) chip %d out of range\n", chip );
457      verboselog( 0, "adc083x_do_read( %d ) chip out of range\n", chip );
458458      return 0;
459459   }
460460
src/emu/machine/i2cmem.c
r1478r1479
2525
2626#define VERBOSE_LEVEL ( 0 )
2727
28INLINE void verboselog( int n_level, const char *s_fmt, ... )
28INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
2929{
3030   if( VERBOSE_LEVEL >= n_level )
3131   {
src/emu/mame.h
r1478r1479
369369/* ----- miscellaneous bits & pieces ----- */
370370
371371/* pop-up a user visible message */
372void CLIB_DECL popmessage(const char *text,...) ATTR_PRINTF(1,2);
372void CLIB_DECL popmessage(const char *format,...) ATTR_PRINTF(1,2);
373373
374374/* log to the standard error.log file */
375void CLIB_DECL logerror(const char *text,...) ATTR_PRINTF(1,2);
375void CLIB_DECL logerror(const char *format,...) ATTR_PRINTF(1,2);
376376
377377/* adds a callback to be called on logerror() */
378378void add_logerror_callback(running_machine *machine, void (*callback)(running_machine *, const char *));
src/emu/sound/k054539.c
r1478r1479
377377      if (input_code_pressed_once(KEYCODE_DEL_PAD))
378378      {
379379         gc_active ^= 1;
380         if (!gc_active) ui_popup_time(0, " ");
380         if (!gc_active) popmessage(NULL);
381381      }
382382
383383      if (gc_active)
src/emu/sound/tms5110r.c
r1478r1479
4545     112, 118, 120, 129, 134, 140, 147, 153 },
4646   {
4747      /* K1  */
48      { -504, -497, -493, -488, -471, -471, -460, -446,
49        -427, -405, -378, -344, -501, -259, -206, -148,
50         -86,   -5,   45,  110,  168,  131,  277,  320,
48      { -504, -497, -493, -488, -480, -471, -460, -446,
49        -427, -408, -378, -344, -305, -259, -206, -148,
50         -86,   -5,   45,  110,  168,  227,  277,  325,
5151         357,  388,  413,  434,  451,  464,  474,  482 },
5252      /* K2  */
53      { -349, -376, -305, -264, -252, -223, -192, -158,
53      { -349, -328, -305, -280, -252, -223, -192, -158,
5454        -124,  -88,  -51,  -14,  23,    60,   97,  133,
55         167,  215,  230,  259, 286,   310,  333,  354,
56         372,  389,  404,  417, 429,   439,   449, 506 },
55         167,  199,  230,  259, 287,   310,  333,  354,
56         372,  389,  404,  417, 427,   439,   449, 506 },
5757      /* K3  */
58      { -397, -365, -327, -266, -229, -170, -104, -36,
58      { -397, -365, -327, -282, -232, -170, -104, -36,
5959          35,  104,  169,  228,  281,  326,  364, 396 },
6060      /* K4  */
61      { -369, -334, -296, -246, -191, -131, -67,  -1,
61      { -376, -334, -296, -248, -191, -131, -67,  -1,
6262          64,  128,  188,  243,  291,  332, 367, 397 },
6363      /* K5  */
6464      { -319, -286, -250, -211, -168, -122, -74, -25,
65          24,   73,  121,  167,  210,  249, 285, 318 },
65          24,   73,  121,  167,  210,  233, 285, 319 },
6666      /* K6  */
6767      { -290, -252, -209, -163, -114, -62,  -9,  44,
6868          97,  147,  194,  255,  278, 313, 344, 371 },
6969      /* K7  */
70      { -291, -256, -216, -174, -128, -96, -31,  19,
71          69,  117,  163,  206,  246, 280, 316, 345 },
70      { -291, -256, -216, -174, -128, -80, -31,  19,
71          69,  117,  163,  207,  246, 283, 316, 345 },
7272      /* K8  */
73      { -218, -133, -38, 56, 152, 251, 305, 361 },
73      { -219, -133, -38, 59, 152, 235, 305, 361 },
7474      /* K9  */
75      { -225, -157, -82, -3, 76, 151, 220, 280 },
75      { -225, -157, -81,   -3,   76, 151, 220, 280 },
7676      /* K10 */
77      { -179, -122, -61, 1, 62, 123, 179, 247 },
77      { -179, - 90, -61,    1,   63, 123, 179, 247 },
7878   },
7979   /* Chirptable */
8080   {   0,  42, -44, 50, -78, 18, 37, 20,
src/emu/sound/discrete.c
r1478r1479
123123 *
124124 *************************************/
125125
126static void CLIB_DECL discrete_log(const char *text, ...)
126static void CLIB_DECL ATTR_PRINTF(1,2) discrete_log(const char *text, ...)
127127{
128128   if (DISCRETE_DEBUGLOG)
129129   {
src/emu/sound/psx.c
r1478r1479
1616
1717#define VERBOSE_LEVEL ( 0 )
1818
19INLINE void verboselog( int n_level, const char *s_fmt, ... )
19INLINE void ATTR_PRINTF(2,3) verboselog( int n_level, const char *s_fmt, ... )
2020{
2121   if( VERBOSE_LEVEL >= n_level )
2222   {
src/emu/sound/sidenvel.c
r1478r1479
8787  static UINT32 decayReleaseRatesP[16];
8888#endif
8989
90const UINT32 attackTabLen = 255;
90static const UINT32 attackTabLen = 255;
9191static UINT32 releaseTabLen;
9292static UINT32 releasePos[256];
9393
src/emu/ui.c
r1478r1479
814814
815815
816816/*-------------------------------------------------
817    ui_popup - popup a message for a standard
818    amount of time
819-------------------------------------------------*/
820
821void CLIB_DECL ui_popup(const char *text, ...)
822{
823   int seconds;
824   va_list arg;
825
826   /* extract the text */
827   va_start(arg,text);
828   vsprintf(messagebox_text, text, arg);
829   messagebox_backcolor = UI_FILLCOLOR;
830   va_end(arg);
831
832   /* set a timer */
833   seconds = (int)strlen(messagebox_text) / 40 + 2;
834   popup_text_end = osd_ticks() + osd_ticks_per_second() * seconds;
835}
836
837
838/*-------------------------------------------------
839817    ui_popup_time - popup a message for a specific
840818    amount of time
841819-------------------------------------------------*/
src/emu/driver.h
r1478r1479
6868#include "output.h"
6969#include "tilemap.h"
7070#include "romload.h"
71#include "drivers/xtal.h"
7172#include "machine/generic.h"
7273#include "audio/generic.h"
7374#include "video/generic.h"
src/emu/fileio.h
r1478r1479
141141int mame_fputs(mame_file *f, const char *s);
142142
143143/* printf-style text write to a file */
144int CLIB_DECL mame_fprintf(mame_file *f, const char *fmt, ...);
144int CLIB_DECL mame_fprintf(mame_file *f, const char *fmt, ...) ATTR_PRINTF(2,3);
145145
146146
147147
src/emu/drivers/xtal.h
r0r1479
1/*************************************************************************
2
3    xtal.h
4
5    Documentation and consistent naming for known existing crystals.
6
7    Copyright (c) 1996-2007, Nicola Salmoria and the MAME Team.
8    Visit http://mamedev.org for licensing and usage restrictions.
9
10***************************************************************************
11
12    PCB Crystal Reference
13    ----------------------
14       _____     ________
15       |16 |    |o       |
16       |MHZ|    |16.0MHZ |
17       |___|    |________|
18       |   |
19
20    There is a finite list of _manufactured_ crystals. This file aims
21    to document all of the known speeds that crystals were available in.
22    Feel free to add to the list if you find another speed crystal on
23    a PCB, but please DON'T GUESS!
24
25    Remember that some very high frequencies (typically above 100MHz) are
26    generated by a frequency multiplying IC from a lower frequency
27    crystal.
28
29    This is intended as a reference of existing parts to prevent incorrect
30    clock speed measurements with digital frequency counters being used
31    in drivers. When measuring clocks, remember that most parts have a
32    tolerance so be sure to reference existing parts only and not just
33    accept direct readings as 100% true.
34
35    (Thanks to Guru for starting this documentation.)
36
37**************************************************************************/
38
39enum
40{
41/*
42    Name                = Frequency     Examples
43    ------------------    ------------  ------------------------------------------------------------ */
44   XTAL_32_768kHz      = 327680,      /* 32.768kHz, used to drive RTC chips */
45   XTAL_1MHz          = 1000000,
46   XTAL_2MHz          = 2000000,
47   XTAL_3MHz          = 3000000,      /* Probably only used to drive 68705 or similar MCUs on 80's Taito PCBs */
48   XTAL_3_579545MHz      = 3579545,
49   XTAL_3_6864MHz     = 3686400,      /* CPS3 */
50   XTAL_4MHz          = 4000000,
51   XTAL_4_224MHz      = 4224000,      /* Used to drive OKI M6295 chips, usually with /4 divider */
52   XTAL_4_9152MHz      = 4915200,
53   XTAL_6MHz          = 6000000,
54   XTAL_7_3728MHz      = 7372800,
55   XTAL_8MHz          = 8000000,
56   XTAL_10MHz         = 10000000,
57   XTAL_10_595MHz     = 10595000,      /* Mad Alien */
58   XTAL_11MHz           = 11000000,      /* Mario I8039 sound */
59   XTAL_11_289MHz     = 11289000,      /* Vanguard */
60   XTAL_12MHz         = 12000000,
61   XTAL_12_096MHz       = 12096000,
62   XTAL_12_288MHz     = 12288000,      /* Sega Model 3 digital audio board */
63   XTAL_13_3MHz        = 13300000,      /* BMC bowling */
64   XTAL_13_33056MHz    = 13330560,      /* Taito L */
65   XTAL_14MHz         = 14000000,
66   XTAL_14_31818MHz     = 14318180,
67   XTAL_14_705882MHz     = 14705882,      /* Aleck64 */
68   XTAL_14_7456MHz    = 14745600,      /* Namco System 12 & System Super 22/23 for H8/3002 CPU */
69   XTAL_15_468MHz     = 15468000,      /* Bank Panic h/w, Sega G80 */
70   XTAL_16MHz         = 16000000,
71   XTAL_16_9344MHz     = 16934400,      /* Usually used to drive 90's Yamaha OPL/FM chips */
72   XTAL_18MHz         = 18000000,
73   XTAL_18_432MHz     = 18432000,
74   XTAL_19_968MHz     = 19968000,      /* Used mostly by Space Invaders games by Taito/Midway and clones */
75   XTAL_20MHz         = 20000000,
76   XTAL_21_3MHz        = 21300000,
77   XTAL_21_4772MHz    = 21477200,      /* BMC bowling */
78   XTAL_22MHz         = 22000000,
79   XTAL_24MHz         = 24000000,      /* Mario */
80   XTAL_24_576MHz     = 24576000,      /* Pole Position h/w, Model 3 CPU board */
81   XTAL_25MHz         = 25000000,      /* Namco System 22, Taito GNET */
82   XTAL_25_1748MHz     = 25174800,      /* Sega S16A, S16B */
83   XTAL_26_66666MHz    = 26666660,      /* Irem M92 but most use 27MHz */
84   XTAL_26_686MHz       = 26686000,      /* Typically used on 90's Taito PCBs to drive the custom chips */
85   XTAL_27MHz         = 27000000,      /* Some Banpresto games macrossp and Irem M92 */
86   XTAL_27_164MHz     = 27164000,      /* Typically used on 90's Taito PCBs to drive the custom chips */
87   XTAL_28MHz         = 28000000,
88   XTAL_28_63636MHz     = 28636360,      /* later Leland games and Atari GT */
89   XTAL_30_4761MHz     = 30476100,      /* Taito JC */
90   XTAL_32MHz         = 32000000,
91   XTAL_32_22MHz        = 32220000,      /* Typically used on 90's Data East PCBs */
92   XTAL_32_5304MHz     = 32530400,      /* Seta 2 */
93   XTAL_33MHz         = 33000000,      /* Sega Model 3 video board */
94   XTAL_33_333MHz     = 33333000,      /* Sega Model 3 CPU board, Vegas */
95   XTAL_33_8688MHz     = 33868800,      /* Usually used to drive 90's Yamaha OPL/FM chips with /2 divider */
96   XTAL_36MHz         = 36000000,      /* Sega Model 1 video board */
97   XTAL_38_76922MHz     = 38769220,      /* Namco System 21 video board */
98   XTAL_40MHz         = 40000000,
99   XTAL_42_9545MHz     = 42954500,      /* CPS3 */
100   XTAL_45MHz         = 45000000,      /* Eolith with Hyperstone CPUs */
101   XTAL_45_158MHz     = 45158000,      /* Sega Model 2A video board, Model 3 CPU board */
102   XTAL_48MHz         = 48000000,
103   XTAL_49_152MHz     = 49152000,      /* Used on some Namco PCBs, Baraduke h/w, System 21, Super System 22  */
104   XTAL_50MHz         = 50000000,
105   XTAL_52MHz         = 52000000,      /* Cojag */
106   XTAL_53_693175MHz     = 53693175,      /* PSX-based h/w, Sony ZN1-2-based */
107   XTAL_54MHz         = 54000000,      /* Taito JC */
108   XTAL_57_2727MHz     = 57272700,      /* Psikyo SH2 with /2 divider */
109   XTAL_60MHz         = 60000000,
110   XTAL_61_44MHz      = 61440000,      /* dkong */
111   XTAL_64MHz         = 64000000,      /* BattleToads */
112   XTAL_66_6667MHz      = 66666700,      /* later Midway games */
113   XTAL_67_7376MHz     = 67737600,      /* PSX-based h/w, Sony ZN1-2-based */
114   XTAL_100MHz        = 100000000,   /* PSX-based Namco System 12, Vegas, Sony ZN1-2-based */
115   XTAL_101_4912MHz     = 101491200,   /* PSX-based Namco System 10 */
116
117/* Resonators (There are probably more. Almost always used for driving OKI sound chips) */
118
119   XTAL_384kHz         = 384000,
120   XTAL_640kHz         = 640000
121};
122
123
124/*
125
126For further reference:
127
128A search at http://search.digikey.com/scripts/DkSearch/dksus.dll?Cat=852333;keywords=cry
129reveals the following shipping frequencies as of 1/1/2008:
130
13120kHz
13225.600kHz
13326.667kHz
13428kHz
135
13630kHz
13730.720kHz
13830.76kHz
13931.2kHz
14031.25kHz
14131.5kHz
14232.000kHz
14332.56kHz
14432.768kHz
14532.919kHz
14634kHz
14736kHz
14838kHz
14938.4kHz
15039.500kHz
151
15240kHz
15344.100kHz
15446.604kHz
15546.6084kHz
156
15750kHz
15859.787kHz
159
16060.000kHz
16160.002kHz
16260.005kHz
16365.535kHz
16465.536kHz
16569kHz
166
16770kHz
16871kHz
16972kHz
17073kHz
17174kHz
17274.3kHz
17374.4kHz
17475kHz
17576kHz
17676.79kHz
17776.8kHz
17876.81kHz
17977kHz
18077.204kHz
18177.287kHz
18277.500kHz
18377.503kHz
18477.504kHz
18578kHz
18679kHz
187
18883kHz
189
19096kHz
19196.006kHz
192
193100kHz
194111kHz
195117.72kHz
196120kHz
197120.8475kHz
198125kHz
199131.072kHz
200149.475kHz
201153.600kHz
202
203200kHz
204
205307.2kHz
206
2071.000MHz
2081.8432MHz
209
2102.000MHz
2112.048MHz
2122.097152MHz
2132.4576MHz
2142.5MHz
2152.560MHz
2162.949120MHz
217
2183.000MHz
2193.276MHz
2203.2768MHz
2213.579MHz
2223.579545MHz
2233.640MHz
2243.6864MHz
2253.700MHz
2263.859MHz
2273.93216MHz
228
2294.000MHz
2304.032MHz
2314.096MHz
2324.09625MHz
2334.194MHz
2344.194304MHz
2354.332MHz
2364.433MHz
2374.433616MHz
2384.433618MHz
2394.433619MHz
2404.74687MHz
2414.800MHz
2424.8970MHz
2434.90625MHz
2444.915MHz
2454.9152MHz
246
2475.000MHz
2485.0688MHz
2495.120MHz
2505.185MHz
2515.223438MHz
2525.5MHz
2535.5296MHz
2545.9904MHz
255
2566.000MHz
2576.14MHz
2586.144MHz
2596.1760MHz
2606.400 MHz
2616.49830MHz
2626.5MHz
2636.5536MHz
2646.612813MHz
2656.7458MHz
2666.757MHz
2676.76438MHz
268
2697.1505MHz
2707.15909 MHz
2717.2MHz
2727.3728MHz
2737.68MHz
2747.94888MHz
275
2768.000MHz
2778.000156MHz
2788.192MHz
2798.388608MHz
2808.432MHz
2818.5MHz
2828.6432MHz
283
2849.000MHz
2859.216MHz
2869.509375MHz
2879.545MHz
2889.6MHz
2899.7941MHz
2909.830MHz
2919.8304MHz
2929.84375MHz
2939.8438MHz
294
29510.000MHz
29610.240MHz
29710.245MHz
29810.6244MHz
29910.738635MHz
30010.73865MHz
301
30211.000MHz
30311.046MHz
30411.0592MHz
30511.228MHz
30611.2896MHz
30711.520MHz
30811.981350MHz
309
31012.000MHz
31112.000393MHz
31212.096MHz
31312.1875MHz
31412.288MHz
31512.352MHz
31612.500MHz
31712.688MHz
31812.800MHz
31912.96MHz
320
32113.000MHz
32213.0625MHz
32313.225MHz
32413.2256MHz
32513.500MHz
32613.5168MHz
32713.56MHz
32813.605MHz
32913.824MHz
33013.94916MHz
331
33214.00MHz
33314.318MHz
33414.31818MHz
33514.3359MHz
33614.3594MHz
33714.4MHz
33814.5MHz
33914.69MHz
34014.7456MHz
34114.850MHz
342
34315MHz
34415.360MHz
345
34616.000MHz
34716.000312MHz
34816.128MHz
34916.257MHz
35016.3676MHz
35116.368MHz
35216.384MHz
35316.576MHz
35416.6660MHz
35516.667MHz
35616.670MHz
35716.800MHz
35816.934MHz
35916.9344MHz
360
36117.734475MHz
362
36318.000MHz
36418.432MHz
36518.869MHz
366
36719.200MHz
36819.440MHz
36919.660MHz
37019.6608MHz
37119.68MHz
37219.800MHz
373
37420.000MHz
37520.35625MHz
37620.3563MHz
37720.480MHz
378
37921.47727MHz
380
38122.000MHz
38222.118MHz
38322.1184MHz
38422.400MHz
38522.5MHz
38622.5792MHz
38722.6278MHz
388
38923MHz
39023.2643MHz
39123.5MHz
39223.5122MHz
39323.592MHz
394
39524.000MHz
39624.00014MHz
39724.5MHz
39824.545454 MHz
39924.5535MHz
40024.576MHz
40124.704MHz
40224.7456MHz
403
40425.000MHz
40525MHz
40625.175MHz
40725.2235MHz
40825.4563MHz
40925.5MHz
410
41126.000MHz
41226.45125MHz
41326.4513MHz
41426.5MHz
41526.5971MHz
41626.800MHz
417
41827.000MHz
41927.1344MHz
42027.3067MHz
42127.4688MHz
422
42328.000MHz
42428.224MHz
42528.259375MHz
42628.2594MHz
42728.322MHz
42828.375MHz
42928.5938MHz
43028.636MHz
43128.6363MHz
43228.63636MHz
433
43429.4912MHz
43529.498928MHz
43629.500MHz
437
43830.000MHz
43932.000MHz
44032.514MHz
44132.768MHz
44233.000MHz
44333.333MHz
44433.3333MHz
44533.8688MHz
44635.2512MHz
44735.3280MHz
44836.000MHz
44938.000MHz
45038.00053MHz
45138.400MHz
45238.880MHz
45339MHz
454
45540.000MHz
45640.320MHz
45740.960 MHz
45842.000MHz
45944.000MHz
46044.2368MHz
46144.545MHz
46244.736MHz
46344.800MHz
46444.900MHz
46545.000MHz
46646.000MHz
46748.000MHz
46849.152MHz
46949.86MHz
470
47150.000MHz
47253.125MHz
47355.000MHz
474
47560.000MHz
47664.000MHz
47766.000MHz
47866.666MHz
47966.6666MHz
480
48173.66979MHz
48275.957292MHz
48376.121875MHz
484
48580.000MHz
486
487100.00MHz
488
489*/
src/emu/romload.c
r1478r1479
162162    debugload - log data to a file
163163-------------------------------------------------*/
164164
165static void CLIB_DECL debugload(const char *string, ...)
165static void CLIB_DECL ATTR_PRINTF(1,2) debugload(const char *string, ...)
166166{
167167#ifdef LOG_LOAD
168168   static int opened;
src/lib/util/cdrom.c
r1478r1479
2424***************************************************************************/
2525
2626#define VERBOSE   (0)
27#if VERBOSE
2728#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
29#else
30#define LOG(x)
31#endif
2832
2933void CLIB_DECL logerror(const char *text,...);
3034
35
36
3137/***************************************************************************
3238    TYPE DEFINITIONS
3339***************************************************************************/
src/lib/util/pool.c
r1478r1479
8888***************************************************************************/
8989
9090static void memory_destruct(void *object, size_t size);
91static void report_failure(object_pool *pool, const char *format, ...);
91static void report_failure(object_pool *pool, const char *format, ...) ATTR_PRINTF(2,3);
9292
9393
9494
r1478r1479
268268   /* if we have an invalid type, fail */
269269   if (type == NULL)
270270   {
271      report_failure(pool, "pool_object_add (via %s:%d): Attempted to add object of unknown type", file, line, (int)size);
271      report_failure(pool, "pool_object_add (via %s:%d): Attempted to add object of unknown type with size %d", file, line, (int)size);
272272      return object;
273273   }
274274
src/lib/util/astring.h
r1478r1479
7070astring *astring_substr(astring *str, int start, int count);
7171
7272/* formatted printf to an astring */
73int astring_printf(astring *dst, const char *format, ...);
73int astring_printf(astring *dst, const char *format, ...) ATTR_PRINTF(2,3);
7474
7575
7676
src/lib/util/options.c
r1478r1479
100100static void update_data(core_options *opts, options_data *data, const char *newdata, int priority);
101101static int parse_option_name(core_options *opts, const char *srcstring, options_data *data);
102102
103static void message(core_options *opts, options_message msgtype, const char *format, ...);
103static void message(core_options *opts, options_message msgtype, const char *format, ...) ATTR_PRINTF(3,4);
104104static UINT32 hash_value(core_options *opts, const char *str);
105static void output_printf(void (*output)(const char *s), const char *format, ...);
105static void output_printf(void (*output)(const char *s), const char *format, ...) ATTR_PRINTF(2,3);
106106
107107
108108
src/lib/util/corefile.h
r1478r1479
100100
101101/* printf-style text write to a file */
102102int core_vfprintf(core_file *f, const char *fmt, va_list va);
103int CLIB_DECL core_fprintf(core_file *f, const char *fmt, ...);
103int CLIB_DECL core_fprintf(core_file *f, const char *fmt, ...) ATTR_PRINTF(2,3);
104104
105105
106106
docs/messnew.txt
r1478r1479
3131
3232Source Changes:
3333----------------
34- The core is based on MAME 0.122u2.  This incorporates all features of the
34- The core is based on MAME 0.122u3.  This incorporates all features of the
3535  update to this core.  [MAME team]
3636
3737- Conditional logging cleanups.  [Atari Ace]

Previous 15994 Revisions Next


© 1998-2018 The MESS Team