Previous 15994 Revisions Next

r3515 Sunday 2nd November, 2008 at 21:24:53 UTC by Nathan Woods
Updated to MAME 0.128u2 core
[docs]messnew.txt
[src/emu]render.h uimenu.c
[src/emu/cpu]cpu.mak
[src/emu/cpu/dsp56k]dsp56dsm.c dsp56ops.c
[src/emu/cpu/m6502]6502dasm.c
[src/emu/cpu/mcs51]mcs51.c* mcs51.h* mcs51dasm.c* mcs51ops.c*
[src/emu/cpu/mips]mips3com.h
[src/emu/cpu/nec]nec.c nec.h necea.h necmodrm.h
[src/emu/cpu/powerpc]ppccom.h
[src/emu/drivers]xtal.h
[src/emu/machine]ldcore.c pd4990a.c z80ctc.h
[src/emu/sound]disc_dev.c disc_flt.c disc_mth.c disc_wav.c discrete.c discrete.h fm.c nes_apu.c
[src/lib/util]cdrom.c
[src/mame]mame.mak mamedriv.c
[src/mame/audio]dkong.c firetrk.c hitme.c madalien.c mw8080bw.c phoenix.c qix.c toaplan2.c
[src/mame/drivers]acommand.c ambush.c arabian.c ashnojoe.c astinvad.c astrof.c bbusters.c bionicc.c cardline.c cave.c chanbara.c circusc.c cop01.c cosmic.c cps2.c ddealer.c dreamwld.c dwarfd.c expro02.c exprraid.c firefox.c gstriker.c gyruss.c hotblock.c jalmah.c jokrwild.c* karnov.c limenko.c m72.c macrossp.c magicfly.c magictg.c megadriv.c megadriv.h merit.c meritm.c micro3d.c mirage.c missb2.c namcos12.c naomi.c neodrvr.c nmk16.c peplus.c plygonet.c powerins.c re900.c* renegade.c segac2.c sliver.c snesb.c snookr10.c sslam.c strnskil.c stv.c superchs.c superqix.c taito_f2.c toaplan2.c ttchamp.c twin16.c twins.c videopkr.c
[src/mame/includes]bzone.h cave.h cchasm.h cps1.h dc.h galaxold.h gottlieb.h snes.h snk.h starwars.h stv.h toaplan2.h* tx1.h
[src/mame/layout]re900.lay*
[src/mame/machine]asic65.c cps2crpt.c dc.c namcos2.c neoboot.c neocrypt.c playch10.c
[src/mame/video]cischeat.c dc.c m72.c plygonet.c popeye.c segag80r.c silkroad.c suprnova.c thepit.c toaplan2.c twin16.c tx1.c
[src/mess]mess.mak
[src/tools]src2html.c

src/mame/audio/qix.c
r3514r3515
6060   DISCRETE_TRANSFORM2(QIX_VOL_DATA_R, QIX_VOL_DATA, 0x0f, "01&")
6161
6262   /* Work out the parallel resistance of the selected resistors. */
63   DISCRETE_COMP_ADDER(NODE_10, 1, QIX_VOL_DATA_L, &qix_attn_table)
64   DISCRETE_COMP_ADDER(NODE_20, 1, QIX_VOL_DATA_R, &qix_attn_table)
63   DISCRETE_COMP_ADDER(NODE_10, QIX_VOL_DATA_L, &qix_attn_table)
64   DISCRETE_COMP_ADDER(NODE_20, QIX_VOL_DATA_R, &qix_attn_table)
6565
6666   /* Then use it for the resistor divider network. */
6767   DISCRETE_TRANSFORM3(NODE_11, NODE_10, RES_K(10), QIX_DAC_DATA, "001+/2*")
src/mame/audio/phoenix.c
r3514r3515
389389   /* - phoenix wing hit                           */
390390   /************************************************/
391391   DISCRETE_COMP_ADDER(NODE_30,            /* total capacitance of selected capacitors */
392                  1,                  /* ENAB */
393392                  PHOENIX_EFFECT_2_FREQ,   /* passed selection bits */
394393                  &phoenix_effect2_cap_sel)
395394   /* Part of the frequency select also effects the gain */
src/mame/audio/toaplan2.c
r3514r3515
11#include "driver.h"
22#include "sound/okim6295.h"
3#include "includes/toaplan2.h"
34
45/****************************************************************************
56  The Toaplan 2 hardware with V25+ secondary CPU controls the sound through
src/mame/audio/hitme.c
r3514r3515
6767   DISCRETE_LOGIC_DFLIPFLOP(NODE_22,1,NODE_21,1,HITME_OUT1,HITME_ENABLE_VAL)
6868
6969   /* The output of the latch goes through a series of various capacitors in parallel. */
70   DISCRETE_COMP_ADDER(NODE_23,1,NODE_22,&desc_hitme_adder)
70   DISCRETE_COMP_ADDER(NODE_23,NODE_22,&desc_hitme_adder)
7171
7272   /* The combined capacitance is input to a 555 timer in astable mode. */
7373   DISCRETE_555_ASTABLE(NODE_24,1,22e3,39e3,NODE_23,&desc_hitme_555)
src/mame/audio/dkong.c
r3514r3515
1818
1919/* Set to 1 to disable DAC and post-mixer filters */
2020#define      DK_NO_FILTERS   (0)
21/* Set to 1 to use faster custom mixer */
22#define      DK_USE_CUSTOM   (1)
2123
2224/* Issue surrounded by this define need to be analyzed and
2325 * reviewed at a lator time.
r3514r3515
5052
5153#define DS_SOUND0         NODE_208
5254#define DS_SOUND1         NODE_209
53#define DS_SOUND2         NODE_210
54#define DS_SOUND6         NODE_211
55#define DS_SOUND7         NODE_212
56#define DS_SOUND9         NODE_213
55#define DS_SOUND6         NODE_210
56#define DS_SOUND7         NODE_211
57#define DS_SOUND9         NODE_212
5758
5859#define DS_ADJ_DAC         NODE_240
5960
r3514r3515
183184   0                   /* Output bit */
184185};
185186
187static const double dkong_diode_mix_table[2] = {DK_1N5553_V, DK_1N5553_V * 2};
188
186189static const discrete_mixer_desc dkong_rc_jump_desc =
187190{
188191   DISC_MIXER_IS_RESISTOR,
r3514r3515
252255   CAP_N(22), CAP_N(10), 0
253256};
254257
258#if DK_USE_CUSTOM
259/************************************************************************
260 *
261 * Custom dkong mixer
262 *
263 * input[0]    - In1 (Logic)
264 * input[1]    - In2
265 * input[2]    - R1
266 * input[3]    - R2
267 * input[4]    - R3
268 * input[5]    - R4
269 * input[6]    - C
270 * input[7]    - B+
271 *
272 *              V (B+)                               V (B+)
273 *                v                                    v
274 *                |       Node Output <----.       .-- | -----
275 *                Z                        |       |   Z
276 *                Z R1                     |       |   Z 5k
277 *                Z                        |       |   Z     555
278 *          |\    |     R2          R4     |           |    internal
279 *  In1 >---| >o--+---/\/\/\--+---/\/\/\---+-----------+ CV
280 *          |/                |            |           |
281 *                            |           ---      |   Z
282 *             R3             |           --- C    |   Z 10k
283 *  In2 >----/\/\/\-----------'            |       |   Z
284 *                                         |       '-- | -----
285 *                                        Gnd         Gnd
286 *
287 ************************************************************************/
288#define DKONG_CUSTOM_IN1      (*(node->input[0]))
289#define DKONG_CUSTOM_IN2      (*(node->input[1]))
290#define DKONG_CUSTOM_R1         (*(node->input[2]))
291#define DKONG_CUSTOM_R2         (*(node->input[3]))
292#define DKONG_CUSTOM_R3         (*(node->input[4]))
293#define DKONG_CUSTOM_R4         (*(node->input[5]))
294#define DKONG_CUSTOM_C         (*(node->input[6]))
295#define DKONG_CUSTOM_V         (*(node->input[7]))
296
297struct dkong_custom_mixer_context
298{
299   double i_in1[2];
300   double r_in[2];
301   double r_total[2];
302   double exp[2];
303};
304
305static void dkong_custom_mixer_step(node_description *node)
306{
307   struct dkong_custom_mixer_context *context = node->context;
308
309   int      in_1    = (int)DKONG_CUSTOM_IN1;
310
311   /* start of with 555 current */
312   double   i_total = DKONG_CUSTOM_V / RES_K(5);
313   /* add in current from In1 */
314   i_total += context->i_in1[in_1];
315   /* add in current from In2 */
316   i_total += DKONG_CUSTOM_IN2 / DKONG_CUSTOM_R3;
317   /* charge cap */
318   /* node->output is cap voltage, (i_total * context->r_total[in_1]) is current charge voltage */
319   node->output[0] += (i_total * context->r_total[in_1] - node->output[0]) * context->exp[in_1];
320}
321
322#define   NE555_CV_R      RES_2_PARALLEL(RES_K(5), RES_K(10))
323
324static void dkong_custom_mixer_reset(node_description *node)
325{
326   struct dkong_custom_mixer_context *context = node->context;
327
328   /* everything is based on the input to the O.C. inverter */
329   /* precalculate current from In1 */
330   context->i_in1[0] = DKONG_CUSTOM_V / (DKONG_CUSTOM_R1 + DKONG_CUSTOM_R2);
331   context->i_in1[1] = 0;
332   /* precalculate total resistance for input circuit */
333   context->r_in[0] = RES_2_PARALLEL((DKONG_CUSTOM_R1 + DKONG_CUSTOM_R2), DKONG_CUSTOM_R3);
334   context->r_in[1] = RES_2_PARALLEL(DKONG_CUSTOM_R2, DKONG_CUSTOM_R3);
335   /* precalculate total charging resistance */
336   context->r_total[0] = RES_2_PARALLEL(context->r_in[0] + DKONG_CUSTOM_R4, NE555_CV_R);
337   context->r_total[1] = RES_2_PARALLEL((context->r_in[1] + DKONG_CUSTOM_R4), NE555_CV_R);
338   /* precalculate charging exponents */
339   context->exp[0] = RC_CHARGE_EXP(context->r_total[0] * DKONG_CUSTOM_C);
340   context->exp[1] = RC_CHARGE_EXP(context->r_total[1] * DKONG_CUSTOM_C);
341
342   node->output[0] = 0;
343}
344
345static const discrete_custom_info dkong_custom_mixer_info =
346{
347   &dkong_custom_mixer_reset,
348   &dkong_custom_mixer_step,
349   sizeof(struct dkong_custom_mixer_context),
350   NULL
351};
352#endif
353
255354static DISCRETE_SOUND_START(dkong2b)
256355
257356   /************************************************/
r3514r3515
259358   /************************************************/
260359
261360   /* DISCRETE_INPUT_DATA */
262    DISCRETE_INPUT_NOT(DS_SOUND2_INV)
263    DISCRETE_INPUT_NOT(DS_SOUND1_INV)
264    DISCRETE_INPUT_NOT(DS_SOUND0_INV)
265    DISCRETE_INPUT_NOT(DS_DISCHARGE_INV)
266    DISCRETE_INPUT_DATA(DS_DAC)
361   DISCRETE_INPUT_NOT(DS_SOUND2_INV)
362   DISCRETE_INPUT_NOT(DS_SOUND1_INV)   /* IC 6J, pin 12 */
363   DISCRETE_INPUT_NOT(DS_SOUND0_INV)   /* IC 6J, pin 2 */
364   DISCRETE_INPUT_NOT(DS_DISCHARGE_INV)
365   DISCRETE_INPUT_DATA(DS_DAC)
267366   /* Mixing - DAC */
268367   DISCRETE_ADJUSTMENT_TAG(DS_ADJ_DAC, 0, 1, DISC_LINADJ, "VR2")
269368
270369   /************************************************/
271   /* SIGNALS                                      */
272   /************************************************/
273
274   DISCRETE_LOGIC_INVERT(DS_SOUND0,1,DS_SOUND0_INV)
275   DISCRETE_LOGIC_INVERT(DS_SOUND1,1,DS_SOUND1_INV)
276   DISCRETE_LOGIC_INVERT(DS_SOUND2,1,DS_SOUND2_INV)
277
278   /************************************************/
279370   /* Stomp                                        */
280371   /************************************************/
281372   /* Noise */
r3514r3515
287378   /* C21 is discharged via Q5 BE */
288379   DISCRETE_RCDISC_MODULATED(NODE_15,DS_SOUND2_INV,0,DK_R10,0,0,DK_R9,DK_C21,DK_SUP_V)
289380   /* Q5 */
290    DISCRETE_TRANSFORM2(NODE_16, NODE_15, 0.6, "01>")
291    DISCRETE_RCDISC2(NODE_17,NODE_16,DK_SUP_V,DK_R8+DK_R7,0.0,DK_R7,DK_C20)
381   DISCRETE_TRANSFORM2(NODE_16, NODE_15, 0.6, "01>")
382   DISCRETE_RCDISC2(NODE_17,NODE_16,DK_SUP_V,DK_R8+DK_R7,0.0,DK_R7,DK_C20)
292383
293    DISCRETE_DIODE_MIXER2(NODE_18, DK_1N5553_V, NODE_13, NODE_13) /* D3 */
294   DISCRETE_DIODE_MIXER2(NODE_20, DK_1N5553_V, NODE_17, NODE_18) /* D1, D2 */
384   DISCRETE_DIODE_MIXER2(NODE_20, NODE_17, NODE_13, &dkong_diode_mix_table) /* D1, D2 + D3 */
295385
296    DISCRETE_RCINTEGRATE(NODE_22,NODE_20,DK_R5, RES_2_PARALLEL(DK_R4+DK_R3,DK_R6),0,DK_C19,DK_SUP_V,DISC_RC_INTEGRATE_TYPE1)
297    DISCRETE_MULTIPLY(DS_OUT_SOUND0,1,NODE_22,DK_R3/R_SERIES(DK_R3,DK_R4))
386   DISCRETE_RCINTEGRATE(NODE_22,NODE_20,DK_R5, RES_2_PARALLEL(DK_R4+DK_R3,DK_R6),0,DK_C19,DK_SUP_V,DISC_RC_INTEGRATE_TYPE1)
387   DISCRETE_MULTIPLY(DS_OUT_SOUND0,1,NODE_22,DK_R3/R_SERIES(DK_R3,DK_R4))
298388
299389   /************************************************/
300390   /* Jump                                         */
301391   /************************************************/
302392/*  tt */
303   DISCRETE_MULTIPLY(NODE_24,1,DS_SOUND1,DK_SUP_V)
304393   /* 4049B Inverter Oscillator build from 3 inverters */
305394   DISCRETE_INVERTER_OSC(NODE_25,1,0,DK_R38,DK_R39,DK_C26,0,&dkong_inverter_osc_desc_jump)
306395
396#if DK_USE_CUSTOM
397   /* custom mixer for 555 CV voltage */
398   DISCRETE_CUSTOM8(NODE_28, DS_SOUND1_INV, NODE_25,
399            DK_R32, DK_R50, DK_R51, DK_R49, DK_C24, DK_SUP_V, &dkong_custom_mixer_info)
400#else
401   DISCRETE_LOGIC_INVERT(DS_SOUND1,1,DS_SOUND1_INV)
402   DISCRETE_MULTIPLY(NODE_24,1,DS_SOUND1,DK_SUP_V)
307403   DISCRETE_TRANSFORM3(NODE_26,DS_SOUND1,DK_R32,DK_R49+DK_R50,"01*2+")
308404   DISCRETE_MIXER4(NODE_28, 1, NODE_24, NODE_25, DK_SUP_V, 0,&dkong_rc_jump_desc)
309    /* 555 Voltage controlled */
310    DISCRETE_555_ASTABLE_CV(NODE_29, 1, RES_K(47), RES_K(27), CAP_N(47), NODE_28,
311                      &dkong_555_vco_desc)
405#endif
406   /* 555 Voltage controlled */
407   DISCRETE_555_ASTABLE_CV(NODE_29, 1, RES_K(47), RES_K(27), CAP_N(47), NODE_28,
408                     &dkong_555_vco_desc)
312409
313410   /* Jump trigger */
314411   DISCRETE_RCDISC_MODULATED(NODE_33,DS_SOUND1_INV,0,DK_R32,0,0,DK_R31,DK_C18,DK_SUP_V)
315412
316    DISCRETE_TRANSFORM2(NODE_34, NODE_33, 0.6, "01>")
317    DISCRETE_RCDISC2(NODE_35, NODE_34,DK_SUP_V,R_SERIES(DK_R30,DK_R29),0.0,DK_R29,DK_C17)
413   DISCRETE_TRANSFORM2(NODE_34, NODE_33, 0.6, "01>")
414   DISCRETE_RCDISC2(NODE_35, NODE_34,DK_SUP_V,R_SERIES(DK_R30,DK_R29),0.0,DK_R29,DK_C17)
318415
319    DISCRETE_DIODE_MIXER2(NODE_36, DK_1N5553_V, NODE_29, NODE_29)
320    DISCRETE_DIODE_MIXER2(NODE_38, DK_1N5553_V, NODE_36, NODE_35)
416   DISCRETE_DIODE_MIXER2(NODE_38, NODE_35, NODE_29, &dkong_diode_mix_table)
321417
322    DISCRETE_RCINTEGRATE(NODE_39,NODE_38,DK_R27, RES_2_PARALLEL(DK_R28,DK_R26+DK_R25),0,DK_C16,DK_SUP_V,DISC_RC_INTEGRATE_TYPE1)
323    DISCRETE_MULTIPLY(DS_OUT_SOUND1,1,NODE_39,DK_R25/(DK_R26+DK_R25))
418   DISCRETE_RCINTEGRATE(NODE_39,NODE_38,DK_R27, RES_2_PARALLEL(DK_R28,DK_R26+DK_R25),0,DK_C16,DK_SUP_V,DISC_RC_INTEGRATE_TYPE1)
419   DISCRETE_MULTIPLY(DS_OUT_SOUND1,1,NODE_39,DK_R25/(DK_R26+DK_R25))
324420
325421   /************************************************/
326422   /* Walk                                         */
327423   /************************************************/
328   DISCRETE_MULTIPLY(NODE_50,1,DS_SOUND0,DK_SUP_V)
329424   DISCRETE_INVERTER_OSC(NODE_51,1,0,DK_R47,DK_R48,DK_C30,0,&dkong_inverter_osc_desc_walk)
330425
426#if DK_USE_CUSTOM
427   /* custom mixer for 555 CV voltage */
428   DISCRETE_CUSTOM8(NODE_54, DS_SOUND0_INV, NODE_51,
429            DK_R36, DK_R45, DK_R46, DK_R44, DK_C29, DK_SUP_V, &dkong_custom_mixer_info)
430#else
431   DISCRETE_LOGIC_INVERT(DS_SOUND0,1,DS_SOUND0_INV)
432   DISCRETE_MULTIPLY(NODE_50,1,DS_SOUND0,DK_SUP_V)
331433   DISCRETE_TRANSFORM3(NODE_52,DS_SOUND0,DK_R46,R_SERIES(DK_R44,DK_R45),"01*2+")
332434   DISCRETE_MIXER4(NODE_54, 1, NODE_50, NODE_51, DK_SUP_V, 0,&dkong_rc_walk_desc)
435#endif
333436
334    /* 555 Voltage controlled */
335    DISCRETE_555_ASTABLE_CV(NODE_55, 1, RES_K(47), RES_K(27), CAP_N(33), NODE_54, &dkong_555_vco_desc)
437   /* 555 Voltage controlled */
438   DISCRETE_555_ASTABLE_CV(NODE_55, 1, RES_K(47), RES_K(27), CAP_N(33), NODE_54, &dkong_555_vco_desc)
336439   /* Trigger */
337440   DISCRETE_RCDISC_MODULATED(NODE_60,DS_SOUND0_INV,NODE_55,DK_R36,DK_R18,DK_R35,DK_R17,DK_C25,DK_SUP_V)
338441   /* Filter and divide - omitted C22 */
r3514r3515
372475
373476   /* Amplifier: internal amplifier */
374477   DISCRETE_ADDER2(NODE_289,1,NODE_288,5.0*43.0/(100.0+43.0))
375    DISCRETE_RCINTEGRATE(NODE_294,NODE_289,0,150,1000, CAP_U(33),DK_SUP_V,DISC_RC_INTEGRATE_TYPE3)
376    DISCRETE_CRFILTER(NODE_295,1,NODE_294, RES_K(50), DK_C13)
478   DISCRETE_RCINTEGRATE(NODE_294,NODE_289,0,150,1000, CAP_U(33),DK_SUP_V,DISC_RC_INTEGRATE_TYPE3)
479   DISCRETE_CRFILTER(NODE_295,1,NODE_294, RES_K(50), DK_C13)
377480   /*DISCRETE_CRFILTER(NODE_295,1,NODE_294, 1000, DK_C13) */
378481   /* EZV20 equivalent filter circuit ... */
379482   DISCRETE_CRFILTER(NODE_296,1,NODE_295, RES_K(1), CAP_U(4.7))
r3514r3515
515618   /************************************************/
516619
517620   /* DISCRETE_INPUT_DATA */
518    DISCRETE_INPUT_NOT(DS_SOUND0_INV)
519    DISCRETE_INPUT_NOT(DS_SOUND1_INV)
520    DISCRETE_INPUT_NOT(DS_SOUND2_INV)
521    DISCRETE_INPUT_NOT(DS_SOUND6_INV)
522    DISCRETE_INPUT_NOT(DS_SOUND7_INV)
523    DISCRETE_INPUT_NOT(DS_DISCHARGE_INV)
524    DISCRETE_INPUT_DATA(DS_DAC)
621   DISCRETE_INPUT_NOT(DS_SOUND0_INV)
622   DISCRETE_INPUT_NOT(DS_SOUND1_INV)
623   DISCRETE_INPUT_NOT(DS_SOUND2_INV)
624   DISCRETE_INPUT_NOT(DS_SOUND6_INV)
625   DISCRETE_INPUT_NOT(DS_SOUND7_INV)
626   DISCRETE_INPUT_NOT(DS_DISCHARGE_INV)
627   DISCRETE_INPUT_DATA(DS_DAC)
525628
526629   /* Mixing - DAC */
527630   DISCRETE_ADJUSTMENT_TAG(DS_ADJ_DAC, 0, 1, DISC_LINADJ, "VR2")
r3514r3515
550653   /* C21 is discharged via Q5 BE */
551654
552655   DISCRETE_RCDISC_MODULATED(NODE_16,DS_SOUND2_INV,0,RS_R_NN01,0,0,RS_R9*2,RS_C20,DK_SUP_V)
553    DISCRETE_TRANSFORM2(NODE_17, NODE_16, 0.6, "01>") /* TR2 */
554    DISCRETE_RCDISC2(NODE_18,NODE_17,DK_SUP_V,RS_R8+RS_R7,0.0,RS_R7,RS_C19)
656   DISCRETE_TRANSFORM2(NODE_17, NODE_16, 0.6, "01>") /* TR2 */
657   DISCRETE_RCDISC2(NODE_18,NODE_17,DK_SUP_V,RS_R8+RS_R7,0.0,RS_R7,RS_C19)
555658
556    DISCRETE_DIODE_MIXER2(NODE_19, DK_1N5553_V, NODE_13, NODE_13) /* D3 */
557   DISCRETE_DIODE_MIXER2(NODE_20, DK_1N5553_V, NODE_18, NODE_19) /* D1, D2 */
659   DISCRETE_DIODE_MIXER2(NODE_20, NODE_18, NODE_13, &dkong_diode_mix_table) /* D1, D2 + D3 */
558660
559    DISCRETE_RCINTEGRATE(NODE_22,NODE_20,RS_R5, RES_2_PARALLEL(RS_R4+RS_R3,RS_R6),0,RS_C18,DK_SUP_V,DISC_RC_INTEGRATE_TYPE1)
560    DISCRETE_MULTIPLY(DS_OUT_SOUND2,1,NODE_22,RS_R3/R_SERIES(RS_R3,RS_R4))
661   DISCRETE_RCINTEGRATE(NODE_22,NODE_20,RS_R5, RES_2_PARALLEL(RS_R4+RS_R3,RS_R6),0,RS_C18,DK_SUP_V,DISC_RC_INTEGRATE_TYPE1)
662   DISCRETE_MULTIPLY(DS_OUT_SOUND2,1,NODE_22,RS_R3/R_SERIES(RS_R3,RS_R4))
561663
562664   /************************************************/
563665   /* SOUND1                                       */
r3514r3515
566668   /* C21 is discharged via Q5 BE */
567669
568670   DISCRETE_RCDISC_MODULATED(NODE_26,DS_SOUND1_INV,0,RS_R_NN02,0,0,RS_R32,RS_C31,DK_SUP_V)
569    DISCRETE_TRANSFORM2(NODE_27, NODE_26, 0.6, "01>") /* TR5 */
570    DISCRETE_RCDISC2(NODE_28,NODE_27,DK_SUP_V,RS_R31+RS_R30,0.0,RS_R30,RS_C30)
671   DISCRETE_TRANSFORM2(NODE_27, NODE_26, 0.6, "01>") /* TR5 */
672   DISCRETE_RCDISC2(NODE_28,NODE_27,DK_SUP_V,RS_R31+RS_R30,0.0,RS_R30,RS_C30)
571673
572    DISCRETE_DIODE_MIXER2(NODE_29, DK_1N5553_V, NODE_14, NODE_14) /* D3 */
573   DISCRETE_DIODE_MIXER2(NODE_30, DK_1N5553_V, NODE_28, NODE_29) /* D1, D2 */
674   DISCRETE_DIODE_MIXER2(NODE_30, NODE_28, NODE_14, &dkong_diode_mix_table) /* D1, D2 + D3 */
574675
575    DISCRETE_RCINTEGRATE(NODE_31,NODE_30,RS_R28, RES_2_PARALLEL(RS_R27+RS_R26,RS_R29),0,RS_C29,DK_SUP_V,DISC_RC_INTEGRATE_TYPE1)
576    DISCRETE_MULTIPLY(DS_OUT_SOUND1,1,NODE_31,RS_R26/R_SERIES(RS_R26,RS_R27))
676   DISCRETE_RCINTEGRATE(NODE_31,NODE_30,RS_R28, RES_2_PARALLEL(RS_R27+RS_R26,RS_R29),0,RS_C29,DK_SUP_V,DISC_RC_INTEGRATE_TYPE1)
677   DISCRETE_MULTIPLY(DS_OUT_SOUND1,1,NODE_31,RS_R26/R_SERIES(RS_R26,RS_R27))
577678
578679   /************************************************/
579680   /* SOUND0                                       */
r3514r3515
582683   DISCRETE_INVERTER_OSC(NODE_41,1,0,RS_R57,RS_R58,RS_C53,0,&radarscp_inverter_osc_desc_0)
583684   DISCRETE_MIXER3(NODE_42, 1, NODE_41, DK_SUP_V, 0,&radarscp_mixer_desc_0)
584685
585    /* 555 Voltage controlled */
586    DISCRETE_555_ASTABLE_CV(NODE_43, DS_SOUND6, RES_K(47), RES_K(27), RS_C49, NODE_42, &radarscp_555_vco_desc)
686   /* 555 Voltage controlled */
687   DISCRETE_555_ASTABLE_CV(NODE_43, DS_SOUND6, RES_K(47), RES_K(27), RS_C49, NODE_42, &radarscp_555_vco_desc)
587688
588689   DISCRETE_RCDISC_MODULATED(NODE_44,DS_SOUND0_INV,NODE_43,RS_R39,RS_R18,RS_R37,RS_R38,RS_C22,DK_SUP_V)
589690   DISCRETE_CRFILTER(NODE_45, 1, NODE_44, RS_R15+RS_R16, RS_C33)
r3514r3515
598699   DISCRETE_INVERTER_OSC(NODE_52,1,0,RS_R48,RS_R49,RS_C47,0,&radarscp_inverter_osc_desc_7)
599700
600701   DISCRETE_MIXER3(NODE_53, 1, NODE_51, DK_SUP_V, 0,&radarscp_mixer_desc_7)
601    /* 555 Voltage controlled */
602    DISCRETE_555_ASTABLE_CV(NODE_54, DS_SOUND7, RES_K(47), RES_K(27), RS_C48, NODE_53, &radarscp_555_vco_desc)
702   /* 555 Voltage controlled */
703   DISCRETE_555_ASTABLE_CV(NODE_54, DS_SOUND7, RES_K(47), RES_K(27), RS_C48, NODE_53, &radarscp_555_vco_desc)
603704
604    DISCRETE_RCINTEGRATE(NODE_55,NODE_52,RS_R46, RS_R46,0,RS_C45,DK_SUP_V,DISC_RC_INTEGRATE_TYPE1)
605    DISCRETE_TRANSFORM4(NODE_56, NODE_55, DS_SOUND7,NODE_54,2.5, "01*23<*")
705   DISCRETE_RCINTEGRATE(NODE_55,NODE_52,RS_R46, RS_R46,0,RS_C45,DK_SUP_V,DISC_RC_INTEGRATE_TYPE1)
706   DISCRETE_TRANSFORM4(NODE_56, NODE_55, DS_SOUND7,NODE_54,2.5, "01*23<*")
606707   DISCRETE_CRFILTER(NODE_57, 1, NODE_56, RS_R43+RS_R44, RS_C46)
607708   DISCRETE_MULTIPLY(DS_OUT_SOUND7, 1, NODE_57, RS_R44/(RS_R43+RS_R44))
608709
r3514r3515
634735
635736   /* Amplifier: internal amplifier */
636737   DISCRETE_ADDER2(NODE_289,1,NODE_288,5.0*43.0/(100.0+43.0))
637    DISCRETE_RCINTEGRATE(NODE_294,NODE_289,0,150,1000, CAP_U(33),DK_SUP_V,DISC_RC_INTEGRATE_TYPE3)
738   DISCRETE_RCINTEGRATE(NODE_294,NODE_289,0,150,1000, CAP_U(33),DK_SUP_V,DISC_RC_INTEGRATE_TYPE3)
638739   DISCRETE_CRFILTER(NODE_295,1,NODE_294, 1000, DK_C13)
639740   DISCRETE_OUTPUT(NODE_295, 32767.0/5.0 * 3)
640741
r3514r3515
748849   /************************************************/
749850
750851   /* DISCRETE_INPUT_DATA */
751    DISCRETE_INPUT_NOT(DS_SOUND0_INV)
752    DISCRETE_INPUT_NOT(DS_SOUND1_INV)
753    DISCRETE_INPUT_NOT(DS_SOUND2_INV)
754    DISCRETE_INPUT_NOT(DS_SOUND6_INV)
755    DISCRETE_INPUT_NOT(DS_SOUND7_INV)
756    DISCRETE_INPUT_NOT(DS_SOUND9_INV)
757    DISCRETE_INPUT_NOT(DS_DISCHARGE_INV)
758    DISCRETE_INPUT_DATA(DS_DAC)
852   DISCRETE_INPUT_NOT(DS_SOUND0_INV)
853   DISCRETE_INPUT_NOT(DS_SOUND1_INV)
854   DISCRETE_INPUT_NOT(DS_SOUND2_INV)
855   DISCRETE_INPUT_NOT(DS_SOUND6_INV)
856   DISCRETE_INPUT_NOT(DS_SOUND7_INV)
857   DISCRETE_INPUT_NOT(DS_SOUND9_INV)
858   DISCRETE_INPUT_NOT(DS_DISCHARGE_INV)
859   DISCRETE_INPUT_DATA(DS_DAC)
759860
760861   /************************************************/
761862   /* SIGNALS                                      */
762863   /************************************************/
763864
764    DISCRETE_LOGIC_INVERT(DS_SOUND7,1,DS_SOUND7_INV)
865   DISCRETE_LOGIC_INVERT(DS_SOUND7,1,DS_SOUND7_INV)
765866   DISCRETE_LOGIC_INVERT(DS_SOUND9,1,DS_SOUND9_INV)
766867
767868   /************************************************/
r3514r3515
872973 *
873974 ****************************************************************/
874975
875SOUND_START( dkong)
976static SOUND_START( dkong)
876977{
877978   dkong_state *state = machine->driver_data;
878979
r3514r3515
10521153
10531154static ADDRESS_MAP_START( dkong_sound_io_map, ADDRESS_SPACE_IO, 8 )
10541155   AM_RANGE(0x00, 0xFF) AM_DEVREAD(LATCH8, "ls175.3d", dkong_tune_r)
1055                       AM_WRITE(dkong_voice_w)
1156                   AM_WRITE(dkong_voice_w)
10561157   AM_RANGE(MCS48_PORT_BUS, MCS48_PORT_BUS) AM_DEVREAD(LATCH8, "ls175.3d", dkong_tune_r)
1057                                  AM_WRITE(dkong_voice_w)
1158                           AM_WRITE(dkong_voice_w)
10581159   AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_WRITE(dkong_p1_w) /* only write to dac */
10591160   AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_LATCH8_READWRITE("virtual_p2")
10601161   AM_RANGE(MCS48_PORT_T0, MCS48_PORT_T0) AM_LATCH8_READBIT("ls259.6h", 5)
r3514r3515
10731174   AM_RANGE(0x00, 0x00) AM_MIRROR(0xff) AM_DEVREAD(LATCH8, "ls175.3d", latch8_r)
10741175   AM_RANGE(0x00, 0xff) AM_WRITE(dkong_p1_w) /* DAC here */
10751176   AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_LATCH8_READ("virtual_p1")
1076                               AM_WRITE(M58817_command_w)
1177                         AM_WRITE(M58817_command_w)
10771178   AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_LATCH8_WRITE("virtual_p2")
10781179   AM_RANGE(MCS48_PORT_T0, MCS48_PORT_T0) AM_LATCH8_READBIT("ls259.6h", 5)
10791180   AM_RANGE(MCS48_PORT_T1, MCS48_PORT_T1) AM_LATCH8_READBIT("ls259.6h", 4)
src/mame/audio/firetrk.c
r3514r3515
626626   /* Also I shifted the frequencies up for it to  */
627627   /* sound different from the player's car.       */
628628   /************************************************/
629   DISCRETE_COMP_ADDER(NODE_30, 1, MONTECAR_DRONE_LOUD_DATA, &montecar_drone_vol_res)   // make sure to change the node value in the mixer table if you change this node number
629   DISCRETE_COMP_ADDER(NODE_30, MONTECAR_DRONE_LOUD_DATA, &montecar_drone_vol_res)   // make sure to change the node value in the mixer table if you change this node number
630630
631631   DISCRETE_ADJUSTMENT_TAG(NODE_40,
632632            RES_K(260),   // R85 + R88 @ max
src/mame/audio/madalien.c
r3514r3515
205205      &madalien_555_1l)
206206   // The speed frequencies seem strange but the components have been GuruVerified
207207   // There is not much change in selected frequency.  99Hz, 110.6Hz, 124Hz
208   DISCRETE_COMP_ADDER(NODE_51, 1, MADALIEN_8910_PORTB_45, &madalien_555_1f_r_select)
208   DISCRETE_COMP_ADDER(NODE_51, MADALIEN_8910_PORTB_45, &madalien_555_1f_r_select)
209209   DISCRETE_555_ASTABLE_CV(NODE_52,   // IC 1F pin 3 out
210210      MADALIEN_8910_PORTB_45,         // enabled by gate O2 pin 13
211211      NODE_51,
r3514r3515
222222   DISCRETE_DAC_R1(NODE_55, 1, NODE_54, DEFAULT_TTL_V_LOGIC_1, &madalien_effect1a_dac)
223223   DISCRETE_DAC_R1(NODE_56, 1, NODE_54, DEFAULT_TTL_V_LOGIC_1, &madalien_effect1b_dac)
224224   DISCRETE_RCFILTER(NODE_57, 1, NODE_56, RES_K(22)/2 + RES_K(22), CAP_U(.033))
225   DISCRETE_COMP_ADDER(NODE_59, 1, MADALIEN_8910_PORTB_23, &madalien_effect_1b_vol_r)
225   DISCRETE_COMP_ADDER(NODE_59, MADALIEN_8910_PORTB_23, &madalien_effect_1b_vol_r)
226226
227227   /************************************************
228228     * Enemy motor
src/mame/audio/mw8080bw.c
r3514r3515
516516               16,                     /* SIZE */
517517               &maze_74147_table)
518518   DISCRETE_COMP_ADDER(MAZE_R305_306_308,      /* value of selected parallel circuit R305, R306, R308 */
519               1,                     /* ENAB */
520519               NODE_32,               /* DATA */
521520               &maze_r305_306_308)
522521   DISCRETE_COMP_ADDER(MAZE_R303_309,         /* value of selected parallel circuit R303, R309 */
523               1,                     /* ENAB */
524522               MAZE_PLAYER_SEL,         /* DATA */
525523               &maze_r303_309)
526524   DISCRETE_OP_AMP_OSCILLATOR(NODE_36,         /* IC J1, pin 4 */
r3514r3515
985983     * Tone generator
986984     ************************************************/
987985   DISCRETE_COMP_ADDER(CHECKMAT_R401_402_400,   /* value of selected parallel circuit R401, R402, R400 */
988               1,                     /* ENAB */
989986               CHECKMAT_TONE_DATA_45,      /* DATA */
990987               &checkmat_r401_402_400)
991988   DISCRETE_COMP_ADDER(CHECKMAT_R407_406_410,   /* value of selected parallel circuit R407, R406, R410 */
992               1,                     /* ENAB */
993989               CHECKMAT_TONE_DATA_67,      /* DATA */
994990               &checkmat_r407_406_410)
995991   DISCRETE_OP_AMP_OSCILLATOR(NODE_30,         /* IC N3/4, pin 4 */
r3514r3515
34413437#define INVADERS_FLEET(_board)                                             \
34423438   DISCRETE_INPUT_DATA  (INVADERS_NODE(INVADERS_FLEET_DATA, _board))               \
34433439   DISCRETE_COMP_ADDER(INVADERS_NODE(30, _board),                                      \
3444               1,                                    /* ENAB */          \
34453440               INVADERS_NODE(INVADERS_FLEET_DATA, _board),      /* DATA */          \
34463441               &invaders_thump_resistors)                                          \
34473442   DISCRETE_555_ASTABLE(INVADERS_NODE(31, _board),               /* IC F3, pin 6 */  \
src/mame/machine/playch10.c
r3514r3515
664664static int gboard_scanline_latch;
665665static int gboard_banks[2];
666666static int gboard_4screen;
667static int gboard_last_bank = 0xff;
667static int gboard_last_bank;
668668static int gboard_command;
669669
670670static void gboard_scanline_cb( int num, int scanline, int vblank, int blanked )
r3514r3515
946946   gboard_banks[1] = 0x1f;
947947   gboard_scanline_counter = 0;
948948   gboard_scanline_latch = 0;
949   gboard_last_bank = 0xff;
950   gboard_command = 0;
949951
950952   /* common init */
951953   DRIVER_INIT_CALL(playch10);
src/mame/machine/asic65.c
r3514r3515
1919 *
2020 *************************************/
2121
22static UINT8     asic65_type;
23static int       asic65_command;
24static UINT16    asic65_param[32];
25static UINT16    asic65_yorigin = 0x1800;
26static UINT8     asic65_param_index;
27static UINT8     asic65_result_index;
28static UINT8     asic65_reset_state;
29static UINT8     asic65_last_bank;
22static struct _asic65_t
23{
24   UINT8     type;
25   int       command;
26   UINT16    param[32];
27   UINT16    yorigin;
28   UINT8     param_index;
29   UINT8     result_index;
30   UINT8     reset_state;
31   UINT8     last_bank;
3032
31/* ROM-based interface states */
32static UINT8   asic65_cpunum;
33static UINT8   asic65_tfull;
34static UINT8    asic65_68full;
35static UINT8    asic65_cmd;
36static UINT8    asic65_xflg;
37static UINT16    asic65_68data;
38static UINT16    asic65_tdata;
33   /* ROM-based interface states */
34   UINT8   cpunum;
35   UINT8   tfull;
36   UINT8    _68full;
37   UINT8    cmd;
38   UINT8    xflg;
39   UINT16    _68data;
40   UINT16    tdata;
3941
40static FILE * asic65_log;
42   FILE * log;
43} asic65;
4144
4245WRITE16_HANDLER( asic65_w );
4346WRITE16_HANDLER( asic65_data_w );
r3514r3515
125128
126129void asic65_config(running_machine *machine, int asictype)
127130{
128   asic65_type = asictype;
129   if (asic65_type == ASIC65_ROMBASED)
130      asic65_cpunum = mame_find_cpu_index(machine, "asic65");
131   memset(&asic65, 0, sizeof(asic65));
132   asic65.type = asictype;
133   asic65.yorigin = 0x1800;
134   if (asic65.type == ASIC65_ROMBASED)
135      asic65.cpunum = mame_find_cpu_index(machine, "asic65");
131136}
132137
133138
r3514r3515
141146void asic65_reset(running_machine *machine, int state)
142147{
143148   /* rom-based means reset and clear states */
144   if (asic65_type == ASIC65_ROMBASED)
145      cpunum_set_input_line(machine, asic65_cpunum, INPUT_LINE_RESET, state ? ASSERT_LINE : CLEAR_LINE);
149   if (asic65.type == ASIC65_ROMBASED)
150      cpunum_set_input_line(machine, asic65.cpunum, INPUT_LINE_RESET, state ? ASSERT_LINE : CLEAR_LINE);
146151
147152   /* otherwise, do it manually */
148153   else
r3514r3515
150155      cpunum_suspend(mame_find_cpu_index(machine, "asic65"), SUSPEND_REASON_DISABLE, 1);
151156
152157      /* if reset is being signalled, clear everything */
153      if (state && !asic65_reset_state)
154         asic65_command = -1;
158      if (state && !asic65.reset_state)
159         asic65.command = -1;
155160
156161      /* if reset is going high, latch the command */
157      else if (!state && asic65_reset_state)
162      else if (!state && asic65.reset_state)
158163      {
159         if (asic65_command != -1)
160            asic65_data_w(machine, 1, asic65_command, 0xffff);
164         if (asic65.command != -1)
165            asic65_data_w(machine, 1, asic65.command, 0xffff);
161166      }
162167
163168      /* update the state */
164      asic65_reset_state = state;
169      asic65.reset_state = state;
165170   }
166171}
167172
r3514r3515
175180
176181static TIMER_CALLBACK( m68k_asic65_deferred_w )
177182{
178   asic65_tfull = 1;
179   asic65_cmd = param >> 16;
180   asic65_tdata = param;
181   cpunum_set_input_line(machine, asic65_cpunum, 0, ASSERT_LINE);
183   asic65.tfull = 1;
184   asic65.cmd = param >> 16;
185   asic65.tdata = param;
186   cpunum_set_input_line(machine, asic65.cpunum, 0, ASSERT_LINE);
182187}
183188
184189
185190WRITE16_HANDLER( asic65_data_w )
186191{
187192   /* logging */
188   if (LOG_ASIC && !asic65_log) asic65_log = fopen("asic65.log", "w");
193   if (LOG_ASIC && !asic65.log) asic65.log = fopen("asic65.log", "w");
189194
190195   /* rom-based use a deferred write mechanism */
191   if (asic65_type == ASIC65_ROMBASED)
196   if (asic65.type == ASIC65_ROMBASED)
192197   {
193198      timer_call_after_resynch(NULL, data | (offset << 16), m68k_asic65_deferred_w);
194199      cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(20));
r3514r3515
198203   /* parameters go to offset 0 */
199204   if (!(offset & 1))
200205   {
201      if (asic65_log) fprintf(asic65_log, " W=%04X", data);
206      if (asic65.log) fprintf(asic65.log, " W=%04X", data);
202207
203208      /* add to the parameter list, but don't overflow */
204      asic65_param[asic65_param_index++] = data;
205      if (asic65_param_index >= 32)
206         asic65_param_index = 32;
209      asic65.param[asic65.param_index++] = data;
210      if (asic65.param_index >= 32)
211         asic65.param_index = 32;
207212   }
208213
209214   /* commands go to offset 2 */
210215   else
211216   {
212      int command = (data < MAX_COMMANDS) ? command_map[asic65_type][data] : OP_UNKNOWN;
213      if (asic65_log) fprintf(asic65_log, "\n(%06X)%c%04X:", activecpu_get_previouspc(), (command == OP_UNKNOWN) ? '*' : ' ', data);
217      int command = (data < MAX_COMMANDS) ? command_map[asic65.type][data] : OP_UNKNOWN;
218      if (asic65.log) fprintf(asic65.log, "\n(%06X)%c%04X:", activecpu_get_previouspc(), (command == OP_UNKNOWN) ? '*' : ' ', data);
214219
215220      /* set the command number and reset the parameter/result indices */
216      asic65_command = data;
217      asic65_result_index = asic65_param_index = 0;
221      asic65.command = data;
222      asic65.result_index = asic65.param_index = 0;
218223   }
219224}
220225
221226
222227READ16_HANDLER( asic65_r )
223228{
224   int command = (asic65_command < MAX_COMMANDS) ? command_map[asic65_type][asic65_command] : OP_UNKNOWN;
229   int command = (asic65.command < MAX_COMMANDS) ? command_map[asic65.type][asic65.command] : OP_UNKNOWN;
225230   INT64 element, result64 = 0;
226231   UINT16 result = 0;
227232
228233   /* rom-based just returns latched data */
229   if (asic65_type == ASIC65_ROMBASED)
234   if (asic65.type == ASIC65_ROMBASED)
230235   {
231      asic65_68full = 0;
236      asic65._68full = 0;
232237      cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(5));
233      return asic65_68data;
238      return asic65._68data;
234239   }
235240
236241   /* update results */
237242   switch (command)
238243   {
239244      case OP_UNKNOWN:   /* return bogus data */
240         popmessage("ASIC65: Unknown cmd %02X", asic65_command);
245         popmessage("ASIC65: Unknown cmd %02X", asic65.command);
241246         break;
242247
243248      case OP_REFLECT:   /* reflect data */
244         if (asic65_param_index >= 1)
245            result = asic65_param[--asic65_param_index];
249         if (asic65.param_index >= 1)
250            result = asic65.param[--asic65.param_index];
246251         break;
247252
248253      case OP_CHECKSUM:   /* compute checksum (should be XX27) */
r3514r3515
258263         break;
259264
260265      case OP_RESET:   /* reset */
261         asic65_result_index = asic65_param_index = 0;
266         asic65.result_index = asic65.param_index = 0;
262267         break;
263268
264269      case OP_SIN:   /* sin */
265         if (asic65_param_index >= 1)
266            result = (int)(16384. * sin(M_PI * (double)(INT16)asic65_param[0] / 32768.));
270         if (asic65.param_index >= 1)
271            result = (int)(16384. * sin(M_PI * (double)(INT16)asic65.param[0] / 32768.));
267272         break;
268273
269274      case OP_COS:   /* cos */
270         if (asic65_param_index >= 1)
271            result = (int)(16384. * cos(M_PI * (double)(INT16)asic65_param[0] / 32768.));
275         if (asic65.param_index >= 1)
276            result = (int)(16384. * cos(M_PI * (double)(INT16)asic65.param[0] / 32768.));
272277         break;
273278
274279      case OP_ATAN:   /* vector angle */
275         if (asic65_param_index >= 4)
280         if (asic65.param_index >= 4)
276281         {
277            INT32 xint = (INT32)((asic65_param[0] << 16) | asic65_param[1]);
278            INT32 yint = (INT32)((asic65_param[2] << 16) | asic65_param[3]);
282            INT32 xint = (INT32)((asic65.param[0] << 16) | asic65.param[1]);
283            INT32 yint = (INT32)((asic65.param[2] << 16) | asic65.param[3]);
279284            double a = atan2((double)yint, (double)xint);
280285            result = (INT16)(a * 32768. / M_PI);
281286         }
r3514r3515
284289      case OP_TMATRIXMULT:   /* matrix multiply by transpose */
285290         /* if this is wrong, the labels on the car selection screen */
286291         /* in Race Drivin' will be off */
287         if (asic65_param_index >= 9+6)
292         if (asic65.param_index >= 9+6)
288293         {
289            INT32 v0 = (INT32)((asic65_param[9] << 16) | asic65_param[10]);
290            INT32 v1 = (INT32)((asic65_param[11] << 16) | asic65_param[12]);
291            INT32 v2 = (INT32)((asic65_param[13] << 16) | asic65_param[14]);
294            INT32 v0 = (INT32)((asic65.param[9] << 16) | asic65.param[10]);
295            INT32 v1 = (INT32)((asic65.param[11] << 16) | asic65.param[12]);
296            INT32 v2 = (INT32)((asic65.param[13] << 16) | asic65.param[14]);
292297
293298            /* 2 results per element */
294            switch (asic65_result_index / 2)
299            switch (asic65.result_index / 2)
295300            {
296301               case 0:
297                  result64 = (INT64)v0 * (INT16)asic65_param[0] +
298                           (INT64)v1 * (INT16)asic65_param[3] +
299                           (INT64)v2 * (INT16)asic65_param[6];
302                  result64 = (INT64)v0 * (INT16)asic65.param[0] +
303                           (INT64)v1 * (INT16)asic65.param[3] +
304                           (INT64)v2 * (INT16)asic65.param[6];
300305                  break;
301306
302307               case 1:
303                  result64 = (INT64)v0 * (INT16)asic65_param[1] +
304                           (INT64)v1 * (INT16)asic65_param[4] +
305                           (INT64)v2 * (INT16)asic65_param[7];
308                  result64 = (INT64)v0 * (INT16)asic65.param[1] +
309                           (INT64)v1 * (INT16)asic65.param[4] +
310                           (INT64)v2 * (INT16)asic65.param[7];
306311                  break;
307312
308313               case 2:
309                  result64 = (INT64)v0 * (INT16)asic65_param[2] +
310                           (INT64)v1 * (INT16)asic65_param[5] +
311                           (INT64)v2 * (INT16)asic65_param[8];
314                  result64 = (INT64)v0 * (INT16)asic65.param[2] +
315                           (INT64)v1 * (INT16)asic65.param[5] +
316                           (INT64)v2 * (INT16)asic65.param[8];
312317                  break;
313318            }
314319
315320            /* remove lower 14 bits and pass back either upper or lower words */
316321            result64 >>= 14;
317            result = (asic65_result_index & 1) ? (result64 & 0xffff) : ((result64 >> 16) & 0xffff);
318            asic65_result_index++;
322            result = (asic65.result_index & 1) ? (result64 & 0xffff) : ((result64 >> 16) & 0xffff);
323            asic65.result_index++;
319324         }
320325         break;
321326
322327      case OP_MATRIXMULT:   /* matrix multiply???? */
323         if (asic65_param_index >= 9+6)
328         if (asic65.param_index >= 9+6)
324329         {
325            INT32 v0 = (INT32)((asic65_param[9] << 16) | asic65_param[10]);
326            INT32 v1 = (INT32)((asic65_param[11] << 16) | asic65_param[12]);
327            INT32 v2 = (INT32)((asic65_param[13] << 16) | asic65_param[14]);
330            INT32 v0 = (INT32)((asic65.param[9] << 16) | asic65.param[10]);
331            INT32 v1 = (INT32)((asic65.param[11] << 16) | asic65.param[12]);
332            INT32 v2 = (INT32)((asic65.param[13] << 16) | asic65.param[14]);
328333
329334            /* 2 results per element */
330            switch (asic65_result_index / 2)
335            switch (asic65.result_index / 2)
331336            {
332337               case 0:
333                  result64 = (INT64)v0 * (INT16)asic65_param[0] +
334                           (INT64)v1 * (INT16)asic65_param[1] +
335                           (INT64)v2 * (INT16)asic65_param[2];
338                  result64 = (INT64)v0 * (INT16)asic65.param[0] +
339                           (INT64)v1 * (INT16)asic65.param[1] +
340                           (INT64)v2 * (INT16)asic65.param[2];
336341                  break;
337342
338343               case 1:
339                  result64 = (INT64)v0 * (INT16)asic65_param[3] +
340                           (INT64)v1 * (INT16)asic65_param[4] +
341                           (INT64)v2 * (INT16)asic65_param[5];
344                  result64 = (INT64)v0 * (INT16)asic65.param[3] +
345                           (INT64)v1 * (INT16)asic65.param[4] +
346                           (INT64)v2 * (INT16)asic65.param[5];
342347                  break;
343348
344349               case 2:
345                  result64 = (INT64)v0 * (INT16)asic65_param[6] +
346                           (INT64)v1 * (INT16)asic65_param[7] +
347                           (INT64)v2 * (INT16)asic65_param[8];
350                  result64 = (INT64)v0 * (INT16)asic65.param[6] +
351                           (INT64)v1 * (INT16)asic65.param[7] +
352                           (INT64)v2 * (INT16)asic65.param[8];
348353                  break;
349354            }
350355
351356            /* remove lower 14 bits and pass back either upper or lower words */
352357            result64 >>= 14;
353            result = (asic65_result_index & 1) ? (result64 & 0xffff) : ((result64 >> 16) & 0xffff);
354            asic65_result_index++;
358            result = (asic65.result_index & 1) ? (result64 & 0xffff) : ((result64 >> 16) & 0xffff);
359            asic65.result_index++;
355360         }
356361         break;
357362
358363      case OP_YORIGIN:
359         if (asic65_param_index >= 1)
360            asic65_yorigin = asic65_param[asic65_param_index - 1];
364         if (asic65.param_index >= 1)
365            asic65.yorigin = asic65.param[asic65.param_index - 1];
361366         break;
362367
363368      case OP_TRANSFORM:   /* 3d transform */
364         if (asic65_param_index >= 2)
369         if (asic65.param_index >= 2)
365370         {
366371            /* param 0 == 1/z */
367372            /* param 1 == height */
r3514r3515
370375            /* return 0 == scale factor for 1/z */
371376            /* return 1 == transformed X */
372377            /* return 2 == transformed Y, taking height into account */
373            element = (INT16)asic65_param[0];
374            if (asic65_param_index == 2)
378            element = (INT16)asic65.param[0];
379            if (asic65.param_index == 2)
375380            {
376               result64 = (element * (INT16)asic65_param[1]) >> 8;
381               result64 = (element * (INT16)asic65.param[1]) >> 8;
377382               result64 -= 1;
378383               if (result64 > 0x3fff) result64 = 0;
379384            }
380            else if (asic65_param_index == 3)
385            else if (asic65.param_index == 3)
381386            {
382               result64 = (element * (INT16)asic65_param[2]) >> 15;
387               result64 = (element * (INT16)asic65.param[2]) >> 15;
383388               result64 += 0xa8;
384389            }
385            else if (asic65_param_index == 4)
390            else if (asic65.param_index == 4)
386391            {
387               result64 = (INT16)((element * (INT16)asic65_param[3]) >> 10);
388               result64 = (INT16)asic65_yorigin - result64 - (result64 << 1);
392               result64 = (INT16)((element * (INT16)asic65.param[3]) >> 10);
393               result64 = (INT16)asic65.yorigin - result64 - (result64 << 1);
389394            }
390395            result = result64 & 0xffff;
391396         }
392397         break;
393398
394399      case OP_INITBANKS:   /* initialize banking */
395         asic65_last_bank = 0;
400         asic65.last_bank = 0;
396401         break;
397402
398403      case OP_SETBANK:   /* set a bank */
r3514r3515
411416            { 0x77f0,0x77fe,0x77f2,0x77fc,0x77f4,0x77fa,0x77f6,0x77f8 },
412417            { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 },
413418         };
414         if (asic65_param_index >= 1)
419         if (asic65.param_index >= 1)
415420         {
416            if (asic65_param_index < sizeof(banklist) && banklist[asic65_param[0]] < 4)
417               asic65_last_bank = banklist[asic65_param[0]];
418            result = bankaddr[asic65_last_bank][(asic65_result_index < 8) ? asic65_result_index : 7];
419            asic65_result_index++;
421            if (asic65.param_index < sizeof(banklist) && banklist[asic65.param[0]] < 4)
422               asic65.last_bank = banklist[asic65.param[0]];
423            result = bankaddr[asic65.last_bank][(asic65.result_index < 8) ? asic65.result_index : 7];
424            asic65.result_index++;
420425         }
421426         break;
422427      }
r3514r3515
427432         {
428433            0x0eb2,0x1000,0x171b,0x3d28
429434         };
430         result = bankverify[asic65_last_bank];
435         result = bankverify[asic65.last_bank];
431436         break;
432437      }
433438   }
434439
435   if (LOG_ASIC && !asic65_log) asic65_log = fopen("asic65.log", "w");
436   if (asic65_log) fprintf(asic65_log, " (R=%04X)", result);
440   if (LOG_ASIC && !asic65.log) asic65.log = fopen("asic65.log", "w");
441   if (asic65.log) fprintf(asic65.log, " (R=%04X)", result);
437442
438443   return result;
439444}
r3514r3515
441446
442447READ16_HANDLER( asic65_io_r )
443448{
444   if (asic65_type == ASIC65_ROMBASED)
449   if (asic65.type == ASIC65_ROMBASED)
445450   {
446451      /* bit 15 = TFULL */
447452      /* bit 14 = 68FULL */
448453      /* bit 13 = XFLG */
449454      /* bit 12 = controlled by jumper */
450455      cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(5));
451      return (asic65_tfull << 15) | (asic65_68full << 14) | (asic65_xflg << 13) | 0x0000;
456      return (asic65.tfull << 15) | (asic65._68full << 14) | (asic65.xflg << 13) | 0x0000;
452457   }
453458   else
454459   {
r3514r3515
467472
468473static WRITE16_HANDLER( asic65_68k_w )
469474{
470   asic65_68full = 1;
471   asic65_68data = data;
475   asic65._68full = 1;
476   asic65._68data = data;
472477}
473478
474479
475480static READ16_HANDLER( asic65_68k_r )
476481{
477   asic65_tfull = 0;
478   cpunum_set_input_line(machine, asic65_cpunum, 0, CLEAR_LINE);
479   return asic65_tdata;
482   asic65.tfull = 0;
483   cpunum_set_input_line(machine, asic65.cpunum, 0, CLEAR_LINE);
484   return asic65.tdata;
480485}
481486
482487
483488static WRITE16_HANDLER( asic65_stat_w )
484489{
485   asic65_xflg = data & 1;
490   asic65.xflg = data & 1;
486491}
487492
488493
r3514r3515
492497   /* bit 14 = TFULL */
493498   /* bit 13 = CMD */
494499   /* bit 12 = controlled by jumper (0 = test?) */
495   return (asic65_68full << 15) | (asic65_tfull << 14) | (asic65_cmd << 13) | 0x1000;
500   return (asic65._68full << 15) | (asic65.tfull << 14) | (asic65.cmd << 13) | 0x1000;
496501}
497502
498503
499504static READ16_HANDLER( asci65_get_bio )
500505{
501   if (!asic65_tfull)
506   if (!asic65.tfull)
502507      cpu_spinuntil_int();
503   return asic65_tfull ? CLEAR_LINE : ASSERT_LINE;
508   return asic65.tfull ? CLEAR_LINE : ASSERT_LINE;
504509}
505510
506511
src/mame/machine/neoboot.c
r3514r3515
686686      }
687687   }
688688
689   /* Patched by protection chip (Altera) ? */
689690   rom[0x2D15C/2] = 0x000B;
690691   rom[0x2D15E/2] = 0xBB00;
691692   rom[0x2D1E4/2] = 0x6002;
src/mame/machine/dc.c
r3514r3515
126126extern UINT32 dma_offset;
127127static UINT8 maple0x86data1[0x80];
128128static UINT8 maple0x86data2[0x400];
129static emu_timer *dc_rtc_timer;
129130
130131static const UINT32 maple0x82answer[]=
131132{
r3514r3515
133134   0x05200083,0x5245544e,0x53495250,0x43205345,0x544c2c4f,0x20202e44,0x38393931,0x5c525043
134135};
135136
136// register decode helper
137// register decode helpers
137138
138INLINE int decode_reg_64(UINT32 offset, UINT64 mem_mask, UINT64 *shift)
139// this accepts only 32-bit accesses
140INLINE int decode_reg32_64(UINT32 offset, UINT64 mem_mask, UINT64 *shift)
139141{
140142   int reg = offset * 2;
141143
r3514r3515
157159   return reg;
158160}
159161
162// this accepts only 32 and 16 bit accesses
163INLINE int decode_reg3216_64(UINT32 offset, UINT64 mem_mask, UINT64 *shift)
164{
165   int reg = offset * 2;
166
167   *shift = 0;
168
169   // non 16&32-bit accesses have not yet been seen here, we need to know when they are
170   if ((mem_mask != U64(0x0000ffff00000000)) && (mem_mask != U64(0x000000000000ffff)) &&
171       (mem_mask != U64(0xffffffff00000000)) && (mem_mask != U64(0x00000000ffffffff)))
172   {
173      mame_printf_verbose("Wrong mask! (PC=%x)\n", activecpu_get_pc());
174//      debugger_break(Machine);
175   }
176
177   if (mem_mask & U64(0x0000ffff00000000))
178   {
179      reg++;
180      *shift = 32;
181    }
182
183   return reg;
184}
185
160186int compute_interrupt_level(void)
161187{
162188   UINT32 ln,lx,le;
r3514r3515
219245   int reg;
220246   UINT64 shift;
221247
222   reg = decode_reg_64(offset, mem_mask, &shift);
248   reg = decode_reg32_64(offset, mem_mask, &shift);
223249
224250   #if DEBUG_SYSCTRL
225251   if ((reg != 0x40) && (reg != 0x41) && (reg != 0x42) && (reg != 0x23) && (reg > 2))   // filter out IRQ status reads
r3514r3515
236262   int reg;
237263   UINT64 shift;
238264   UINT32 old,dat;
265   UINT32 address;
239266   struct sh4_ddt_dma ddtdata;
240267
241   reg = decode_reg_64(offset, mem_mask, &shift);
268   reg = decode_reg32_64(offset, mem_mask, &shift);
242269   dat = (UINT32)(data >> shift);
243270   old = dc_sysctrl_regs[reg];
244271   dc_sysctrl_regs[reg] = dat; // 5f6800+off*4=dat
245272   switch (reg)
246273   {
247274      case SB_C2DST:
248         ddtdata.destination=dc_sysctrl_regs[SB_C2DSTAT];
275         address=dc_sysctrl_regs[SB_C2DSTAT];
276         ddtdata.destination=address;
249277         ddtdata.length=dc_sysctrl_regs[SB_C2DLEN];
250278         ddtdata.size=1;
251279         ddtdata.direction=0;
r3514r3515
253281         ddtdata.mode=25; //011001
254282         cpunum_set_info_ptr(0,CPUINFO_PTR_SH4_EXTERNAL_DDT_DMA,&ddtdata);
255283         #if DEBUG_SYSCTRL
256         mame_printf_verbose("SYSCTRL: Ch2 dma %x from %08x to %08x (lmmode0=%d lmmode1=%d)\n", dc_sysctrl_regs[SB_C2DLEN], ddtdata.source-ddtdata.length, dc_sysctrl_regs[SB_C2DSTAT],dc_sysctrl_regs[SB_LMMODE0],dc_sysctrl_regs[SB_LMMODE1]);
284         if ((address >= 0x11000000) && (address <= 0x11FFFFFF))
285            if (dc_sysctrl_regs[SB_LMMODE0])
286               mame_printf_verbose("SYSCTRL: Ch2 direct display lists dma %x from %08x to %08x (lmmode0=%d lmmode1=%d)\n", dc_sysctrl_regs[SB_C2DLEN], ddtdata.source-ddtdata.length, dc_sysctrl_regs[SB_C2DSTAT],dc_sysctrl_regs[SB_LMMODE0],dc_sysctrl_regs[SB_LMMODE1]); // 1
287            else
288               mame_printf_verbose("SYSCTRL: Ch2 direct textures dma %x from %08x to %08x (lmmode0=%d lmmode1=%d)\n", dc_sysctrl_regs[SB_C2DLEN], ddtdata.source-ddtdata.length, dc_sysctrl_regs[SB_C2DSTAT],dc_sysctrl_regs[SB_LMMODE0],dc_sysctrl_regs[SB_LMMODE1]); // 0
289         else if ((address >= 0x13000000) && (address <= 0x13FFFFFF))
290            if (dc_sysctrl_regs[SB_LMMODE1])
291               mame_printf_verbose("SYSCTRL: Ch2 direct display lists dma %x from %08x to %08x (lmmode0=%d lmmode1=%d)\n", dc_sysctrl_regs[SB_C2DLEN], ddtdata.source-ddtdata.length, dc_sysctrl_regs[SB_C2DSTAT],dc_sysctrl_regs[SB_LMMODE0],dc_sysctrl_regs[SB_LMMODE1]); // 1
292            else
293               mame_printf_verbose("SYSCTRL: Ch2 direct textures dma %x from %08x to %08x (lmmode0=%d lmmode1=%d)\n", dc_sysctrl_regs[SB_C2DLEN], ddtdata.source-ddtdata.length, dc_sysctrl_regs[SB_C2DSTAT],dc_sysctrl_regs[SB_LMMODE0],dc_sysctrl_regs[SB_LMMODE1]); // 0
294         else if ((address >= 0x10800000) && (address <= 0x10ffffff))
295            mame_printf_verbose("SYSCTRL: Ch2 YUV dma %x from %08x to %08x (lmmode0=%d lmmode1=%d)\n", dc_sysctrl_regs[SB_C2DLEN], ddtdata.source-ddtdata.length, dc_sysctrl_regs[SB_C2DSTAT],dc_sysctrl_regs[SB_LMMODE0],dc_sysctrl_regs[SB_LMMODE1]);
296         else if ((address >= 0x10000000) && (address <= 0x107fffff))
297            mame_printf_verbose("SYSCTRL: Ch2 TA Display List dma %x from %08x to %08x (lmmode0=%d lmmode1=%d)\n", dc_sysctrl_regs[SB_C2DLEN], ddtdata.source-ddtdata.length, dc_sysctrl_regs[SB_C2DSTAT],dc_sysctrl_regs[SB_LMMODE0],dc_sysctrl_regs[SB_LMMODE1]);
298         else
299            mame_printf_verbose("SYSCTRL: Ch2 unknown dma %x from %08x to %08x (lmmode0=%d lmmode1=%d)\n", dc_sysctrl_regs[SB_C2DLEN], ddtdata.source-ddtdata.length, dc_sysctrl_regs[SB_C2DSTAT],dc_sysctrl_regs[SB_LMMODE0],dc_sysctrl_regs[SB_LMMODE1]);
257300         #endif
258         dc_sysctrl_regs[SB_C2DSTAT]=dc_sysctrl_regs[SB_C2DSTAT]+ddtdata.length;
301         dc_sysctrl_regs[SB_C2DSTAT]=address+ddtdata.length;
259302         dc_sysctrl_regs[SB_C2DLEN]=0;
260303         dc_sysctrl_regs[SB_C2DST]=0;
261304         dc_sysctrl_regs[SB_ISTNRM] |= IST_DMA_CH2;
r3514r3515
272315      case SB_ISTERR:
273316         dc_sysctrl_regs[SB_ISTERR] = old & ~dat;
274317         break;
318      case SB_SDST:
319         #if DEBUG_SYSCTRL
320         mame_printf_verbose("SYSCTRL: Sort-DMA not supported yet !!!\n");
321         #endif
322         break;
275323   }
276324   update_interrupt_status();
277325
r3514r3515
288336   int reg;
289337   UINT64 shift;
290338
291   reg = decode_reg_64(offset, mem_mask, &shift);
339   reg = decode_reg32_64(offset, mem_mask, &shift);
292340
293341   #if DEBUG_MAPLE_REGS
294342   mame_printf_verbose("MAPLE:  Unmapped read %08x\n", 0x5f6c00+reg*4);
r3514r3515
310358   int a;
311359   int off,len;
312360
313   reg = decode_reg_64(offset, mem_mask, &shift);
361   reg = decode_reg32_64(offset, mem_mask, &shift);
314362   dat = (UINT32)(data >> shift);
315363   old = maple_regs[reg];
316364
r3514r3515
497545                                    // first function
498546                                    maple0x86data2[pos+10]=1;
499547                                    maple0x86data2[pos+11]=2; // number of players
500                                    maple0x86data2[pos+12]=9; // switches per player (27 = mahjong)
548                                    maple0x86data2[pos+12]=9+4; // switches per player (27 = mahjong)
501549                                    maple0x86data2[pos+13]=0;
502550                                    // second function
503551                                    maple0x86data2[pos+14]=2;
r3514r3515
685733   int reg;
686734   UINT64 shift;
687735
688   reg = decode_reg_64(offset, mem_mask, &shift);
736   reg = decode_reg32_64(offset, mem_mask, &shift);
689737   mame_printf_verbose("G1CTRL:  Unmapped read %08x\n", 0x5f7400+reg*4);
690738   return (UINT64)g1bus_regs[reg] << shift;
691739}
r3514r3515
698746   struct sh4_ddt_dma ddtdata;
699747   UINT8 *ROM = (UINT8 *)memory_region(machine, "user1");
700748
701   reg = decode_reg_64(offset, mem_mask, &shift);
749   reg = decode_reg32_64(offset, mem_mask, &shift);
702750   dat = (UINT32)(data >> shift);
703751   old = g1bus_regs[reg];
704752
r3514r3515
735783   int reg;
736784   UINT64 shift;
737785
738   reg = decode_reg_64(offset, mem_mask, &shift);
786   reg = decode_reg32_64(offset, mem_mask, &shift);
739787   mame_printf_verbose("G2CTRL:  Unmapped read %08x\n", 0x5f7800+reg*4);
740788   return 0;
741789}
r3514r3515
746794   UINT64 shift;
747795   UINT32 dat;
748796
749   reg = decode_reg_64(offset, mem_mask, &shift);
797   reg = decode_reg32_64(offset, mem_mask, &shift);
750798   dat = (UINT32)(data >> shift);
799   switch (reg)
800   {
801   case SB_ADTSEL:
802      mame_printf_verbose("G2CTRL: initiation mode %d\n",dat);
803      break;
804   case SB_ADST:
805      mame_printf_verbose("G2CTRL: AICA:G2-DMA start\n");
806      break;
807   }
751808   mame_printf_verbose("G2CTRL: [%08x=%x] write %llx to %x, mask %llx\n", 0x5f7800+reg*4, dat, data, offset, mem_mask);
752809}
753810
r3514r3515
756813   int reg;
757814   UINT64 shift;
758815
759   reg = decode_reg_64(offset, mem_mask, &shift);
816   reg = decode_reg32_64(offset, mem_mask, &shift);
760817
761818   // from ElSemi: this makes Atomiswave do it's "verbose boot" with a Sammy logo and diagnostics instead of just running the cart.
762819   // our PVR emulation is apparently not good enough for that to work yet though.
r3514r3515
775832   UINT64 shift;
776833   UINT32 dat;
777834
778   reg = decode_reg_64(offset, mem_mask, &shift);
835   reg = decode_reg32_64(offset, mem_mask, &shift);
779836   dat = (UINT32)(data >> shift);
780837   mame_printf_verbose("MODEM: [%08x=%x] write %llx to %x, mask %llx\n", 0x600000+reg*4, dat, data, offset, mem_mask);
781838}
r3514r3515
785842   int reg;
786843   UINT64 shift;
787844
788   reg = decode_reg_64(offset, mem_mask, &shift);
845   reg = decode_reg3216_64(offset, mem_mask, &shift);
789846   mame_printf_verbose("RTC:  Unmapped read %08x\n", 0x710000+reg*4);
790   return 0;
847   return (UINT64)dc_rtcregister[reg] << shift;
791848}
792849
793850WRITE64_HANDLER( dc_rtc_w )
r3514r3515
796853   UINT64 shift;
797854   UINT32 old,dat;
798855
799   reg = decode_reg_64(offset, mem_mask, &shift);
856   reg = decode_reg3216_64(offset, mem_mask, &shift);
800857   dat = (UINT32)(data >> shift);
801858   old = dc_rtcregister[reg];
802859   dc_rtcregister[reg] = dat & 0xFFFF; // 5f6c00+off*4=dat
r3514r3515
811868   case RTC2:
812869      if (dc_rtcregister[RTC3] == 0)
813870         dc_rtcregister[reg] = old;
871      else
872         timer_adjust_periodic(dc_rtc_timer, attotime_zero, 0, ATTOTIME_IN_SEC(1));
814873      break;
815874   case RTC3:
816875      dc_rtcregister[RTC3] &= 1;
r3514r3515
819878   mame_printf_verbose("RTC: [%08x=%x] write %llx to %x, mask %llx\n", 0x710000 + reg*4, dat, data, offset, mem_mask);
820879}
821880
822#ifdef UNUSED_FUNCTION
823static void dc_rtc_increment(void)
881static TIMER_CALLBACK(dc_rtc_increment)
824882{
825883    dc_rtcregister[RTC2] = (dc_rtcregister[RTC2] + 1) & 0xFFFF;
826884    if (dc_rtcregister[RTC2] == 0)
827885        dc_rtcregister[RTC1] = (dc_rtcregister[RTC1] + 1) & 0xFFFF;
828886}
829#endif
830887
831888MACHINE_START( dc )
832889{
r3514r3515
844901   memset(dc_rtcregister, 0, sizeof(dc_rtcregister));
845902   memset(dc_coin_counts, 0, sizeof(dc_coin_counts));
846903
904   dc_rtc_timer = timer_alloc(dc_rtc_increment, 0);
905   timer_adjust_periodic(dc_rtc_timer, attotime_zero, 0, ATTOTIME_IN_SEC(1));
906
847907   dc_sysctrl_regs[SB_SBREV] = 0x0b;
848908   for (a=0;a < 0x80;a++)
849909      maple0x86data1[a]=0x11+a;
r3514r3515
860920   int reg;
861921   UINT64 shift;
862922
863   reg = decode_reg_64(offset, mem_mask, &shift);
923   reg = decode_reg32_64(offset, mem_mask, &shift);
864924
865925//  mame_printf_verbose("AICA REG: [%08x] read %llx, mask %llx\n", 0x700000+reg*4, (UINT64)offset, mem_mask);
866926
r3514r3515
873933   UINT64 shift;
874934   UINT32 dat;
875935
876   reg = decode_reg_64(offset, mem_mask, &shift);
936   reg = decode_reg32_64(offset, mem_mask, &shift);
877937   dat = (UINT32)(data >> shift);
878938
879939   if (reg == (0x2c00/4))
src/mame/machine/namcos2.c
r3514r3515
1919int namcos2_gametype;
2020
2121static unsigned mFinalLapProtCount;
22static int namcos2_mcu_analog_ctrl;
23static int namcos2_mcu_analog_data;
24static int namcos2_mcu_analog_complete;
25static UINT8 *namcos2_eeprom;
26static int sendval;
2227
28
2329READ16_HANDLER( namcos2_flap_prot_r )
2430{
2531   static const UINT16 table0[8] = { 0x0000,0x0040,0x0440,0x2440,0x2480,0xa080,0x8081,0x8041 };
r3514r3515
6975/*************************************************************/
7076
7177#define namcos2_eeprom_size 0x2000
72static UINT8 *namcos2_eeprom;
7378
7479static void
7580ResetAllSubCPUs( running_machine *machine, int state )
r3514r3515
102107{
103108   int loop;
104109   mFinalLapProtCount = 0;
110   namcos2_mcu_analog_ctrl=0;
111   namcos2_mcu_analog_data=0xaa;
112   namcos2_mcu_analog_complete=0;
113   sendval = 0;
105114
106115   /* Initialise the bank select in the sound CPU */
107116   namcos2_sound_bankselect_w(machine,0,0); /* Page in bank 0 */
r3514r3515
238247suzuk8h2    1993
239248sws93       1993    334         $014e
240249 *************************************************************/
241static int sendval = 0;
250
242251READ16_HANDLER( namcos2_68k_key_r )
243252{
244253   switch (namcos2_gametype)
r3514r3515
724733/*                                                            */
725734/**************************************************************/
726735
727static int namcos2_mcu_analog_ctrl=0;
728static int namcos2_mcu_analog_data=0xaa;
729static int namcos2_mcu_analog_complete=0;
730
731736WRITE8_HANDLER( namcos2_mcu_analog_ctrl_w )
732737{
733738   namcos2_mcu_analog_ctrl = data & 0xff;
src/mame/machine/neocrypt.c
r3514r3515
850850}
851851
852852
853int m1_address_scramble(int address, UINT16 key)
853static int m1_address_scramble(int address, UINT16 key)
854854{
855855   int block;
856856   int aux;
src/mame/machine/cps2crpt.c
r3514r3515
867867   { "sfz2br1",  { 0xac134599,0x61f8bb2e }, 0x100000 },   // 0C80 3039 9783  cmpi.l  #$30399783,D0
868868   { "sfz2h",    { 0xf98a2d42,0x597b089f }, 0x100000 },   // 0C80 3039 9783  cmpi.l  #$30399783,D0
869869   { "sfz2n",    { 0xe32bf89c,0xa57b46dc }, 0x100000 },   // 0C80 3039 9783  cmpi.l  #$30399783,D0
870   { "sfz2aj",   { 0x99450c88,0xa00a2c4d }, 0x100000 },   // 0C80 8E73 9110  cmpi.l  #$8E739110,D0
871   { "sfz2ah",   { 0x95f15b7c,0x200c08c6 }, 0x100000 },   // 0C80 8E73 9110  cmpi.l  #$8E739110,D0
872   { "sfz2ab",   { 0x73cd4a28,0xff83af1c }, 0x100000 },   // 0C80 8E73 9110  cmpi.l  #$8E739110,D0
873   { "sfz2aa",   { 0xf172c0d0,0x040621a6 }, 0x100000 },   // 0C80 8E73 9110  cmpi.l  #$8E739110,D0
870   { "sfz2al",   { 0xf172c0d0,0x040621a6 }, 0x100000 },   // 0C80 8E73 9110  cmpi.l  #$8E739110,D0
871   { "sfz2alj",  { 0x99450c88,0xa00a2c4d }, 0x100000 },   // 0C80 8E73 9110  cmpi.l  #$8E739110,D0
872   { "sfz2alh",  { 0x95f15b7c,0x200c08c6 }, 0x100000 },   // 0C80 8E73 9110  cmpi.l  #$8E739110,D0
873   { "sfz2alb",  { 0x73cd4a28,0xff83af1c }, 0x100000 },   // 0C80 8E73 9110  cmpi.l  #$8E739110,D0
874874   { "spf2t",    { 0x706a8750,0x7d0fc185 }, 0x040000 },   // 0C80 3039 9819  cmpi.l  #$30399819,D0
875875   { "spf2xj",   { 0xb12c835a,0xe90976ff }, 0x040000 },   // 0C80 3039 9819  cmpi.l  #$30399819,D0
876876   { "spf2ta",   { 0x9c48e1ab,0xd60f34fb }, 0x040000 },   // 0C80 3039 9819  cmpi.l  #$30399819,D0
src/mame/mamedriv.c
r3514r3515
21202120   /* More Toaplan Games */
21212121   DRIVER( tekipaki )   /* TP-020 (c) 1991 Toaplan */
21222122   DRIVER( ghox )      /* TP-021 (c) 1991 Toaplan */
2123   DRIVER( ghoxa )      /* TP-021 (c) 1991 Toaplan */
2123   DRIVER( ghoxj )      /* TP-021 (c) 1991 Toaplan */
21242124   DRIVER( dogyuun )   /* TP-022 (c) 1992 Toaplan */
21252125   DRIVER( kbash )      /* TP-023 (c) 1993 Toaplan */
21262126   DRIVER( kbash2 )   /* bootleg */
r3514r3515
26522652   DRIVER( megaman2 )   /* 08/07/1996 (c) 1996 (US) */
26532653   DRIVER( megamn2a )   /* 08/07/1996 (c) 1996 (Asia) */
26542654   DRIVER( rckman2j )   /* 08/07/1996 (c) 1996 (Japan) */
2655   DRIVER( sfz2aj )   /* 05/08/1996 (c) 1996 (Japan) */
2656   DRIVER( sfz2ah )   /* 13/08/1996 (c) 1996 (Hispanic) */
2657   DRIVER( sfz2ab )   /* 13/08/1996 (c) 1996 (Brazil) */
2658   DRIVER( sfz2aa )   /* 26/08/1996 (c) 1996 (Asia) */
2655   DRIVER( sfz2al )   /* 26/08/1996 (c) 1996 (Asia) */
2656   DRIVER( sfz2alj )   /* 05/08/1996 (c) 1996 (Japan) */
2657   DRIVER( sfz2alh )   /* 13/08/1996 (c) 1996 (Hispanic) */
2658   DRIVER( sfz2alb )   /* 13/08/1996 (c) 1996 (Brazil) */
26592659   DRIVER( xmvsf )      /* 04/10/1996 (c) 1996 (Euro) */
26602660   DRIVER( xmvsfr1 )   /* 10/09/1996 (c) 1996 (Euro) */
26612661   DRIVER( xmvsfu )   /* 23/10/1996 (c) 1996 (US) */
r3514r3515
69456945   DRIVER( mayjin3 )
69466946
69476947   /* Atlus games */
6948   DRIVER( powerins )   /* (c) 1993 Atlus (Japan) */
6949   DRIVER( powerina )   /* (c) 1993 Atlus (Japan) */
6950   DRIVER( powerinb )   /* (c) 1993 Atlus (Japan) */
6948   DRIVER( powerins )   /* (c) 1993 Atlus (USA) */
6949   DRIVER( powerinj )   /* (c) 1993 Atlus (Japan) */
6950   DRIVER( powerina )   /* (c) 1993 Atlus (bootleg of USA version) */
6951   DRIVER( powerinb )   /* (c) 1993 Atlus (bootleg of USA version) */
69516952   DRIVER( ohmygod )   /* (c) 1993 Atlus (Japan) */
69526953   DRIVER( naname )   /* (c) 1994 Atlus (Japan) */
69536954   DRIVER( blmbycar )   /* (c) 1994 ABM & Gecas - uses same gfx chip as powerins? */
r3514r3515
82788279   DRIVER( lucky74a )   /* (c) 1988 Wing Co., Ltd */
82798280   DRIVER( magictg )   /* (c) 199? Acclaim */
82808281   DRIVER( magictga )   /* (c) 199? Acclaim */
8282   DRIVER( re900 )      /* (c) 1993 Entretenimientos GEMINIS */
8283   DRIVER( bs94 )      /* (c) 1994 Entretenimientos GEMINIS */
8284   DRIVER( jokrwild )   /* (c) 1988 Sigma */
82818285
82828286   /* InterFlip / Recreativos Franco */
82838287   DRIVER( videopkr )   /* (c) 1984 InterFlip */
src/mame/includes/stv.h
r3514r3515
1414
1515/*----------- defined in drivers/stvinit.c -----------*/
1616
17DRIVER_INIT( ic13 );
1817NVRAM_HANDLER( stv );
1918void install_stvbios_speedups(running_machine *machine);
20DRIVER_INIT(bakubaku);
2119DRIVER_INIT(mausuke);
2220DRIVER_INIT(puyosun);
2321DRIVER_INIT(shienryu);
src/mame/includes/bzone.h
r3514r3515
1010/*----------- defined in drivers/bzone.c -----------*/
1111
1212extern UINT8 rb_input_select;
13READ8_HANDLER( bzone_IN0_r );
1413
1514
1615/*----------- defined in audio/bzone.c -----------*/
src/mame/includes/tx1.h
r3514r3515
7474extern UINT16 *tx1_rcram;
7575extern size_t tx1_objram_size;
7676PALETTE_INIT( tx1 );
77WRITE16_HANDLER( tx1_vram_w );
7877VIDEO_START( tx1 );
7978VIDEO_UPDATE( tx1 );
8079VIDEO_EOF( tx1 );
r3514r3515
8988extern UINT16 *buggyboy_vram;
9089extern size_t buggyboy_objram_size;
9190extern size_t buggyboy_rcram_size;
92PALETTE_INIT( buggybjr );
9391PALETTE_INIT( buggyboy );
94WRITE16_HANDLER( buggyboy_vram_w );
9592VIDEO_START( buggyboy );
9693VIDEO_UPDATE( buggyboy );
9794VIDEO_EOF( buggyboy );
9895
9996extern UINT16 *buggybjr_vram;
100WRITE16_HANDLER( buggybjr_vram_w );
10197VIDEO_START( buggybjr );
10298VIDEO_UPDATE( buggybjr );
10399WRITE16_HANDLER( buggyboy_slincs_w );
src/mame/includes/cps1.h
r3514r3515
1414INTERRUPT_GEN( cps1_qsound_interrupt );
1515
1616READ16_HANDLER( cps1_dsw_r );
17READ16_HANDLER( cps1_in1_r );
18READ16_HANDLER( cps1_in2_r );
19READ16_HANDLER( cps1_in3_r );
2017WRITE16_HANDLER( cps1_coinctrl_w );
2118INTERRUPT_GEN( cps1_interrupt );
2219
src/mame/includes/snk.h
r3514r3515
66
77/*----------- defined in drivers/snk.c -----------*/
88
9extern UINT8 *snk_rambase;
10
119extern READ8_HANDLER ( snk_cpuA_nmi_trigger_r );
1210extern WRITE8_HANDLER( snk_cpuA_nmi_ack_w );
1311
r3514r3515
2018extern PALETTE_INIT( tnk3 );
2119
2220extern VIDEO_START( marvins );
23extern VIDEO_START( madcrash );
2421extern VIDEO_START( jcross );
2522extern VIDEO_START( sgladiat );
2623extern VIDEO_START( hal21 );
src/mame/includes/dc.h
r3514r3515
4343#define SB_C2DSTAT   ((0x005F6800-0x005F6800)/4)
4444#define SB_C2DLEN   ((0x005F6804-0x005F6800)/4)
4545#define SB_C2DST   ((0x005F6808-0x005F6800)/4)
46#define SB_SDST      ((0x005F6820-0x005F6800)/4)
4647#define SB_LMMODE0   ((0x005F6884-0x005F6800)/4)
4748#define SB_LMMODE1   ((0x005F6888-0x005F6800)/4)
4849#define SB_SBREV   ((0x005F689c-0x005F6800)/4)
r3514r3515
8889#define SB_G1CRDYC   ((0x005F74B4-0x005F7400)/4)
8990#define SB_GDAPRO   ((0x005F74B8-0x005F7400)/4)
9091
92#define SB_ADTSEL   ((0x005F7810-0x005F7800)/4)
93#define SB_ADTRG   SB_ADTSEL
94#define SB_ADEN      ((0x005F7814-0x005F7800)/4)
95#define SB_ADST      ((0x005F7818-0x005F7800)/4)
96
97#define SB_PDST      ((0x005F7c18-0x005F7c00)/4)
98
9199#define RTC1      ((0x00710000-0x00710000)/4)
92100#define RTC2      ((0x00710004-0x00710000)/4)
93101#define RTC3      ((0x00710008-0x00710000)/4)
r3514r3515
122130#define FB_R_SIZE      ((0x005F805c-0x005F8000)/4)
123131#define FB_W_SOF1      ((0x005F8060-0x005F8000)/4)
124132#define FB_W_SOF2      ((0x005F8064-0x005F8000)/4)
133#define FPU_PARAM_CFG   ((0x005F807C-0x005F8000)/4)
125134#define VO_CONTROL      ((0x005F80E8-0x005F8000)/4)
126135#define PAL_RAM_CTRL   ((0x005F8108-0x005F8000)/4)
127136#define ISP_BACKGND_T   ((0x005F808C-0x005F8000)/4)
src/mame/includes/gottlieb.h
r3514r3515
2929extern UINT8 gottlieb_gfxcharlo;
3030extern UINT8 gottlieb_gfxcharhi;
3131extern UINT8 *gottlieb_charram;
32extern UINT8 *gottlieb_riot_regs;
3332
3433extern WRITE8_HANDLER( gottlieb_videoram_w );
3534extern WRITE8_HANDLER( gottlieb_charram_w );
src/mame/includes/cchasm.h
r3514r3515
55*************************************************************************/
66
77#include "sound/custom.h"
8#include "machine/z80ctc.h"
89
910/*----------- defined in machine/cchasm.c -----------*/
1011
r3514r3515
1213
1314/*----------- defined in audio/cchasm.c -----------*/
1415
16extern z80ctc_interface cchasm_ctc_intf;
17
1518READ8_HANDLER( cchasm_snd_io_r );
1619WRITE8_HANDLER( cchasm_snd_io_w );
1720
src/mame/includes/snes.h
r3514r3515
394394extern READ8_HANDLER( snes_r_bank7 );
395395extern WRITE8_HANDLER( snes_w_bank1 );
396396extern WRITE8_HANDLER( snes_w_bank2 );
397extern WRITE8_HANDLER( snes_w_bank3 );
398397extern WRITE8_HANDLER( snes_w_bank4 );
399398extern WRITE8_HANDLER( snes_w_bank5 );
400399extern WRITE8_HANDLER( snes_w_bank6 );
src/mame/includes/toaplan2.h
r0r3515
1/*----------- defined in audio/toaplan2.c -----------*/
2
3void dogyuun_okisnd_w(running_machine *machine, int data);
4void kbash_okisnd_w(running_machine *machine, int data);
5void fixeight_okisnd_w(running_machine *machine, int data);
6void batsugun_okisnd_w(running_machine *machine, int data);
7
8
9/*----------- defined in drivers/toaplan2.c -----------*/
10
11extern int toaplan2_sub_cpu;
12
13
14/*----------- defined in video/toaplan2.c -----------*/
15
16extern UINT16 *toaplan2_txvideoram16;
17extern UINT16 *toaplan2_txvideoram16_offs;
18extern UINT16 *toaplan2_txscrollram16;
19extern UINT16 *toaplan2_tx_gfxram16;
20
21extern  size_t toaplan2_tx_vram_size;
22extern  size_t toaplan2_tx_offs_vram_size;
23extern  size_t toaplan2_tx_scroll_vram_size;
24extern  size_t batrider_paletteram16_size;
25
26VIDEO_EOF( toaplan2_0 );
27VIDEO_EOF( toaplan2_1 );
28VIDEO_START( toaplan2_0 );
29VIDEO_START( toaplan2_1 );
30VIDEO_START( truxton2_0 );
31VIDEO_START( bgaregga_0 );
32VIDEO_START( batrider_0 );
33VIDEO_UPDATE( toaplan2_0 );
34VIDEO_UPDATE( truxton2_0 );
35VIDEO_UPDATE( dogyuun_1 );
36VIDEO_UPDATE( batsugun_1 );
37VIDEO_UPDATE( batrider_0 );
38VIDEO_UPDATE( mahoudai_0 );
39
40WRITE16_HANDLER( toaplan2_0_voffs_w );
41WRITE16_HANDLER( toaplan2_1_voffs_w );
42
43READ16_HANDLER ( toaplan2_0_videoram16_r );
44READ16_HANDLER ( toaplan2_1_videoram16_r );
45WRITE16_HANDLER( toaplan2_0_videoram16_w );
46WRITE16_HANDLER( toaplan2_1_videoram16_w );
47
48READ16_HANDLER ( toaplan2_txvideoram16_r );
49WRITE16_HANDLER( toaplan2_txvideoram16_w );
50READ16_HANDLER ( toaplan2_txvideoram16_offs_r );
51WRITE16_HANDLER( toaplan2_txvideoram16_offs_w );
52READ16_HANDLER ( toaplan2_txscrollram16_r );
53WRITE16_HANDLER( toaplan2_txscrollram16_w );
54READ16_HANDLER ( toaplan2_tx_gfxram16_r );
55WRITE16_HANDLER( toaplan2_tx_gfxram16_w );
56READ16_HANDLER ( raizing_tx_gfxram16_r );
57WRITE16_HANDLER( raizing_tx_gfxram16_w );
58
59WRITE16_HANDLER( toaplan2_0_scroll_reg_select_w );
60WRITE16_HANDLER( toaplan2_1_scroll_reg_select_w );
61WRITE16_HANDLER( toaplan2_0_scroll_reg_data_w );
62WRITE16_HANDLER( toaplan2_1_scroll_reg_data_w );
63
64WRITE16_HANDLER( batrider_objectbank_w );
65WRITE16_HANDLER( batrider_textdata_decode );
66
67READ16_HANDLER ( pipibibi_videoram16_r );
68WRITE16_HANDLER( pipibibi_videoram16_w );
69READ16_HANDLER ( pipibibi_spriteram16_r );
70WRITE16_HANDLER( pipibibi_spriteram16_w );
71WRITE16_HANDLER( pipibibi_scroll_w );
src/mame/includes/galaxold.h
r3514r3515
105105DRIVER_INIT( checkmaj );
106106DRIVER_INIT( dingo );
107107DRIVER_INIT( dingoe );
108DRIVER_INIT( kingball );
109108DRIVER_INIT( mooncrsu );
110109DRIVER_INIT( mooncrst );
111110DRIVER_INIT( mooncrgx );
112111DRIVER_INIT( moonqsr );
113112DRIVER_INIT( checkman );
114DRIVER_INIT( azurian );
115113DRIVER_INIT( 4in1 );
116114DRIVER_INIT( ladybugg );
117DRIVER_INIT( gmgalax );
118115
119116WRITE8_HANDLER( galaxold_nmi_enable_w );
120117
r3514r3515
131128READ8_HANDLER( scramblb_protection_1_r );
132129READ8_HANDLER( scramblb_protection_2_r );
133130
134WRITE8_HANDLER( kingball_speech_dip_w );
135WRITE8_HANDLER( kingball_sound1_w );
136WRITE8_HANDLER( kingball_sound2_w );
137
138131WRITE8_HANDLER( _4in1_bank_w );
139132CUSTOM_INPUT( _4in1_fake_port_r );
140133
141134WRITE8_HANDLER( zigzag_sillyprotection_w );
142135
143136INTERRUPT_GEN( hunchbks_vh_interrupt );
144INTERRUPT_GEN( gmgalax_vh_interrupt );
145137
146138
147139/*----------- defined in machine/scramble.c -----------*/
r3514r3515
175167DRIVER_INIT( rescue );
176168DRIVER_INIT( minefld );
177169DRIVER_INIT( losttomb );
178DRIVER_INIT( superbon );
179170DRIVER_INIT( hustler );
180171DRIVER_INIT( billiard );
181172DRIVER_INIT( mrkougar );
src/mame/includes/cave.h
r3514r3515
66
77/*----------- defined in video/cave.c -----------*/
88
9extern UINT16 *cave_spriteram16_2;
10
911extern int cave_spritetype;
1012extern int cave_kludge;
1113
src/mame/includes/starwars.h
r3514r3515
4747WRITE8_HANDLER( starwars_soundrst_w );
4848
4949READ8_HANDLER( starwars_sin_r );
50READ8_HANDLER( starwars_m6532_r );
51
5250WRITE8_HANDLER( starwars_sout_w );
53WRITE8_HANDLER( starwars_m6532_w );
src/mame/mame.mak
r3514r3515
15901590   $(DRIVERS)/itgambl3.o \
15911591   $(DRIVERS)/itgamble.o \
15921592   $(DRIVERS)/jackpool.o \
1593   $(DRIVERS)/jokrwild.o \
15931594   $(DRIVERS)/jongkyo.o \
15941595   $(DRIVERS)/kingpin.o \
15951596   $(DRIVERS)/koikoi.o \
r3514r3515
16341635   $(DRIVERS)/quizpun2.o \
16351636   $(DRIVERS)/rbmk.o \
16361637   $(DRIVERS)/rcorsair.o \
1638   $(DRIVERS)/re900.o \
16371639   $(DRIVERS)/sfkick.o \
16381640   $(DRIVERS)/shangkid.o $(VIDEO)/shangkid.o \
16391641   $(DRIVERS)/skyarmy.o \
r3514r3515
17671769
17681770$(DRIVERS)/qix.o:      $(LAYOUT)/elecyoyo.lh
17691771
1772$(DRIVERS)/re900.o:   $(LAYOUT)/re900.lh
1773
17701774$(DRIVERS)/sbrkout.o:   $(LAYOUT)/sbrkout.lh
17711775
17721776$(DRIVERS)/sderby.o:   $(LAYOUT)/sderby.lh \
src/mame/video/suprnova.c
r3514r3515
11381138                  }
11391139                  else
11401140                  {
1141                     bgpendata = 0;
1141                     bgpendata = pendata2&0x7fff;
11421142                     bgpri = 0;;
11431143                  }
11441144               }
src/mame/video/popeye.c
r3514r3515
1111UINT8 *popeye_background_pos;
1212UINT8 *popeye_palettebank;
1313static UINT8 *popeye_bitmapram;
14static size_t popeye_bitmapram_size = 0x2000;
14static const size_t popeye_bitmapram_size = 0x2000;
1515
1616static bitmap_t *tmpbitmap2;
1717static int invertmask;
1818static int bitmap_type;
1919enum { TYPE_SKYSKIPR, TYPE_POPEYE };
2020
21#define BGRAM_SIZE 0x2000
22
2321static tilemap *fg_tilemap;
2422
2523
src/mame/video/segag80r.c
r3514r3515
2525static UINT8 spaceod_fixed_color;
2626static UINT8 spaceod_bg_control;
2727static UINT8 spaceod_bg_detect;
28static UINT8 spaceod_bg_detect_tile_color = 1;
28static const UINT8 spaceod_bg_detect_tile_color = 1;
2929
3030static tilemap *bg_tilemap;
3131static UINT8 bg_enable;
src/mame/video/dc.c
r3514r3515
66#include "driver.h"
77#include "dc.h"
88#include "cpu/sh4/sh4.h"
9#include "render.h"
10#include "rendutil.h"
911
1012#define DEBUG_FIFO_POLY (0)
1113#define DEBUG_PVRCTRL   (0)
r3514r3515
120122   reg = decode_reg_64(offset, mem_mask, &shift);
121123   dat = (UINT32)(data >> shift);
122124
125   switch (reg)
126   {
127   case SB_PDST:
128      #if DEBUG_PVRCTRL
129      mame_printf_verbose("PVRCTRL: PVR-DMA start\n");
130      #endif
131      break;
132   }
133
123134   #if DEBUG_PVRCTRL
124135   mame_printf_verbose("PVRCTRL: [%08x=%x] write %llx to %x (reg %x), mask %llx\n", 0x5f7c00+reg*4, dat, data>>shift, offset, reg, mem_mask);
125136   #endif
r3514r3515
153164   int reg;
154165   UINT64 shift;
155166   UINT32 old,dat;
167   //UINT32 sizera,offsetra,v;
156168   int a;
157169
158170   reg = decode_reg_64(offset, mem_mask, &shift);
r3514r3515
194206      mame_printf_verbose("Start Render Received:\n");
195207      mame_printf_verbose("  Region Array at %08x\n",pvrta_regs[REGION_BASE]);
196208      mame_printf_verbose("  ISP/TSP Parameters at %08x\n",pvrta_regs[PARAM_BASE]);
209      if (pvrta_regs[FPU_PARAM_CFG] & 0x200000)
210         sizera=6;
211      else
212         sizera=5;
213      offsetra=pvrta_regs[REGION_BASE];
214      for (;;)
215      {
216         v=program_read_dword_64le(0x05000000+offsetra);
217         mame_printf_verbose("Tile X:%d Y:%d\n  ", (v >> 2) & 0x3f, (v >> 8) & 0x3f);
218         offsetra = offsetra+4;
219         v=program_read_dword_64le(0x05000000+offsetra);
220         if (!(v & 0x80000000))
221            mame_printf_verbose("OLP %d ",v & 0xFFFFFC);
222         offsetra = offsetra+4;
223         v=program_read_dword_64le(0x05000000+offsetra);
224         if (!(v & 0x80000000))
225            mame_printf_verbose("OMVLP %d ",v & 0xFFFFFC);
226         offsetra = offsetra+4;
227         v=program_read_dword_64le(0x05000000+offsetra);
228         if (!(v & 0x80000000))
229            mame_printf_verbose("TLP %d ",v & 0xFFFFFC);
230         offsetra = offsetra+4;
231         v=program_read_dword_64le(0x05000000+offsetra);
232         if (!(v & 0x80000000))
233            mame_printf_verbose("TMVLP %d ",v & 0xFFFFFC);
234         if (sizera == 6)
235         {
236            offsetra = offsetra+4;
237            v=program_read_dword_64le(0x05000000+offsetra);
238            if (!(v & 0x80000000))
239               mame_printf_verbose("PTLP %d ",v & 0xFFFFFC);
240         }
241         mame_printf_verbose("\n");
242         if (v & 0x80000000)
243            break;
244      }
197245      #endif
198246      // select buffer to draw using PARAM_BASE
199247      for (a=0;a < 4;a++)
r3514r3515
312360   state_ta.tafifo_pos &= state_ta.tafifo_mask;
313361   if (state_ta.tafifo_pos == 0)
314362   {
363      // Para Control
315364      state_ta.paracontrol=(tafifo_buff[0] >> 24) & 0xff;
316365      // 0 end of list
317366      // 1 user tile clip
r3514r3515
327376      if ((state_ta.paratype >= 4) && (state_ta.paratype <= 6))
328377      {
329378         state_ta.global_paratype = state_ta.paratype;
379         // Group Control
330380         state_ta.groupcontrol=(tafifo_buff[0] >> 16) & 0xff;
331381         state_ta.groupen=(state_ta.groupcontrol >> 7) & 1;
332382         state_ta.striplen=(state_ta.groupcontrol >> 2) & 3;
333383         state_ta.userclip=(state_ta.groupcontrol >> 0) & 3;
384         // Obj Control
334385         state_ta.objcontrol=(tafifo_buff[0] >> 0) & 0xffff;
335386         state_ta.shadow=(state_ta.objcontrol >> 7) & 1;
336387         state_ta.volume=(state_ta.objcontrol >> 6) & 1;
r3514r3515
357408               return;
358409            }
359410         }
411         // decide number of words when not a vertex
360412         state_ta.tafifo_vertexwords=pvr_wordsvertex[state_ta.parameterconfig];
361413         if ((state_ta.paratype == 4) && ((state_ta.listtype != 1) && (state_ta.listtype != 3)))
362414            if (pvr_wordspolygon[state_ta.parameterconfig] == 16)
r3514r3515
366418               return;
367419            }
368420      }
369      else
370      {
371         state_ta.tafifo_mask = 7;
372      }
421      state_ta.tafifo_mask = 7;
373422
374423      // now we heve all the needed words
375424      // here we should generate the data for the various tiles
r3514r3515
404453         state_ta.listtype_used |= (2+8);
405454      }
406455      else if (state_ta.paratype == 1)
407      {
456      { // user tile clip
408457         #if DEBUG_PVRDLIST
409458         mame_printf_verbose("Para Type 1 User Tile Clip\n");
410459         mame_printf_verbose(" (%d , %d)-(%d , %d)\n", tafifo_buff[4], tafifo_buff[5], tafifo_buff[6], tafifo_buff[7]);
411460         #endif
412461      }
413462      else if (state_ta.paratype == 2)
414      {
463      { // object list set
415464         #if DEBUG_PVRDLIST
416465         mame_printf_verbose("Para Type 2 Object List Set at %08x\n", tafifo_buff[1]);
417466         mame_printf_verbose(" (%d , %d)-(%d , %d)\n", tafifo_buff[4], tafifo_buff[5], tafifo_buff[6], tafifo_buff[7]);
r3514r3515
424473         #endif
425474      }
426475      else
427      {
476      { // global parameter or vertex parameter
428477         #if DEBUG_PVRDLIST
429         mame_printf_verbose("Para Type %d End of Strip %d", state_ta.paratype, state_ta.endofstrip);
478         mame_printf_verbose("Para Type %d", state_ta.paratype);
479         if (state_ta.paratype == 7)
480            mame_printf_verbose(" End of Strip %d", state_ta.endofstrip);
430481         if (state_ta.listtype_used & 3)
431482            mame_printf_verbose(" List Type %d", state_ta.listtype);
432483         mame_printf_verbose("\n");
r3514r3515
635686{
636687UINT32 *bmpaddr;
637688int ix, iy, i, inc, x, y, dx, dy, plotx, ploty;
689int dxix, dyiy;
690render_bounds line, clip;
638691
639   if ((state_ta.grab[index].showvertices[to].x < 0) || (state_ta.grab[index].showvertices[to].x > 639))
692   clip.x0=0;
693   clip.y0=0;
694   clip.x1=639;
695   clip.y1=479;
696   line.x0=state_ta.grab[index].showvertices[from].x;
697   line.y0=state_ta.grab[index].showvertices[from].y;
698   line.x1=state_ta.grab[index].showvertices[to].x;
699   line.y1=state_ta.grab[index].showvertices[to].y;
700   if (render_clip_line(&line, &clip))
640701      return;
641   if ((state_ta.grab[index].showvertices[from].x < 0) || (state_ta.grab[index].showvertices[from].x > 639))
642      return;
643   if ((state_ta.grab[index].showvertices[to].y < 0) || (state_ta.grab[index].showvertices[to].y > 479))
644      return;
645   if ((state_ta.grab[index].showvertices[from].y < 0) || (state_ta.grab[index].showvertices[from].y > 479))
646      return;
647    dx = state_ta.grab[index].showvertices[to].x - state_ta.grab[index].showvertices[from].x;
648   dy = state_ta.grab[index].showvertices[to].y - state_ta.grab[index].showvertices[from].y;
649    plotx = state_ta.grab[index].showvertices[from].x;
650   ploty = state_ta.grab[index].showvertices[from].y;
651    ix = abs(dx);
702   dx=line.x1-line.x0;
703   dy=line.y1-line.y0;
704   plotx=line.x0;
705   ploty=line.y0;
706   ix = abs(dx);
652707   iy = abs(dy);
653708   inc = max(ix,iy);
654709   x = y = 0;
710   dxix = (dx ? dx/ix : 0);
711   dyiy = (dy ? dy/iy : 0);
655712
656    for (i=0; i <= inc; ++i)
713   for (i=0; i <= inc; ++i)
657714    {
658715      x += ix;  y += iy;
659716
660717      if (x > inc)
661718      {
662719         x -= inc;
663         plotx += (dx ? dx/ix : 0);
720         plotx += dxix;
664721         bmpaddr = BITMAP_ADDR32(bitmap,ploty,plotx);
665722         *bmpaddr = MAKE_RGB(0, 0, 255);
666723      }
667724      if (y > inc)
668725      {
669726         y -= inc;
670         ploty += (dy ? dy/iy : 0);
727         ploty += dyiy;
671728         bmpaddr = BITMAP_ADDR32(bitmap,ploty,plotx);
672729         *bmpaddr = MAKE_RGB(0, 0, 255);
673730      }
r3514r3515
9641021
9651022static TIMER_CALLBACK(vbout)
9661023{
967   dc_sysctrl_regs[SB_ISTNRM] |= IST_VBL_OUT; // V Blank-out interrupt
1024UINT32 a;
1025
1026   a=dc_sysctrl_regs[SB_ISTNRM] | IST_VBL_OUT;
1027   dc_sysctrl_regs[SB_ISTNRM] = a; // V Blank-out interrupt
9681028   update_interrupt_status();
9691029
9701030   timer_adjust_oneshot(vbout_timer, attotime_never, 0);
r3514r3515
10001060{
10011061static int useframebuffer=1;
10021062
1003   if (pvrta_regs[VO_CONTROL] & (1 << 3))
1004   {
1005      fillbitmap(bitmap,pvrta_regs[VO_BORDER_COL] & 0xFFFFFF,cliprect);
1006      return 0;
1007   }
1008
10091063   if ((useframebuffer) && !state_ta.start_render_received)
10101064   {
1011      testdrawscreenframebuffer(bitmap,cliprect);
1065      if (pvrta_regs[VO_CONTROL] & (1 << 3))
1066         fillbitmap(bitmap,pvrta_regs[VO_BORDER_COL] & 0xFFFFFF,cliprect);
1067      else
1068         testdrawscreenframebuffer(bitmap,cliprect);
10121069      return 0;
10131070   }
10141071
r3514r3515
10161073   {
10171074      useframebuffer=0;
10181075      testdrawscreen(bitmap,cliprect);
1076      if (pvrta_regs[VO_CONTROL] & (1 << 3))
1077         fillbitmap(bitmap,pvrta_regs[VO_BORDER_COL] & 0xFFFFFF,cliprect);
10191078      state_ta.start_render_received=0;
10201079      state_ta.renderselect= -1;
10211080      dc_sysctrl_regs[SB_ISTNRM] |= IST_EOR_TSP;   // TSP end of render
src/mame/video/toaplan2.c
r3514r3515
146146
147147#include "driver.h"
148148#include "cpu/m68000/m68000.h"
149#include "includes/toaplan2.h"
149150
150151
151152
r3514r3515
154155#define TOAPLAN2_TOP_VRAM_SIZE  0x1000   /* Top Layer  RAM size */
155156#define TOAPLAN2_SPRITERAM_SIZE 0x800   /* Sprite     RAM size */
156157#define RAIZING_TX_GFXRAM_SIZE  0x8000   /* GFX data decode RAM size */
157extern  size_t toaplan2_tx_vram_size;       /* 0x2000 Text layer RAM size */
158extern  size_t toaplan2_tx_offs_vram_size;    /* 0x200 Text layer tile flip and positon ? */
159extern  size_t toaplan2_tx_scroll_vram_size; /* 0x200 Text layer scroll ? */
160extern  size_t batrider_paletteram16_size;
158size_t toaplan2_tx_vram_size;       /* 0x2000 Text layer RAM size */
159size_t toaplan2_tx_offs_vram_size;    /* 0x200 Text layer tile flip and positon ? */
160size_t toaplan2_tx_scroll_vram_size; /* 0x200 Text layer scroll ? */
161size_t batrider_paletteram16_size;
161162
162163
163164
r3514r3515
181182UINT16 *toaplan2_txscrollram16;      /* Text layer scroll ? */
182183UINT16 *toaplan2_tx_gfxram16;         /* Text Layer RAM based tiles */
183184static UINT16 *raizing_tx_gfxram16;         /* Text Layer RAM based tiles (Batrider) */
184static int toaplan2_overflow_vram;      /* Teki Paki VRAM test is bugged. It goes out of range */
185static UINT16 toaplan2_overflow_vram;      /* Teki Paki VRAM test is bugged. It goes out of range */
185186
186static int toaplan2_scroll_reg[2];
187static int toaplan2_voffs[2];
188static int bg_scrollx[2];
189static int bg_scrolly[2];
190static int fg_scrollx[2];
191static int fg_scrolly[2];
192static int top_scrollx[2];
193static int top_scrolly[2];
194static int sprite_scrollx[2];
195static int sprite_scrolly[2];
187static UINT16 toaplan2_scroll_reg[2];
188static UINT16 toaplan2_voffs[2];
189static UINT16 bg_scrollx[2];
190static UINT16 bg_scrolly[2];
191static UINT16 fg_scrollx[2];
192static UINT16 fg_scrolly[2];
193static UINT16 top_scrollx[2];
194static UINT16 top_scrolly[2];
195static UINT16 sprite_scrollx[2];
196static UINT16 sprite_scrolly[2];
196197static int objectbank_dirty = 0;      /* dirty flag of object bank (for Batrider) */
197static int batrider_object_bank[8];      /* Batrider object bank */
198static UINT16 batrider_object_bank[8];      /* Batrider object bank */
198199
199200#ifdef MAME_DEBUG
200201static int display_bg[2]  = { 1, 1 };
r3514r3515
205206#endif
206207static int display_sp[2] = { 1, 1 };
207208
208static int sprite_priority[2][16];
209static int bg_flip[2] = { 0, 0 };
210static int fg_flip[2] = { 0, 0 };
211static int top_flip[2] = { 0, 0 };
212static int sprite_flip[2] = { 0, 0 };
213static int tx_flip = 0;
209static UINT8 bg_flip[2] = { 0, 0 };
210static UINT8 fg_flip[2] = { 0, 0 };
211static UINT8 top_flip[2] = { 0, 0 };
212static UINT8 sprite_flip[2] = { 0, 0 };
213static UINT8 tx_flip = 0;
214214
215extern int toaplan2_sub_cpu;
216
215static UINT8 sprite_priority[2][16];
217216static UINT8 top_tile_priority[2][16];
218217static UINT8 fg_tile_priority[2][16];
219218static UINT8 bg_tile_priority[2][16];
r3514r3515
492491   }
493492}
494493
494static void register_state_save(int vrams)
495{
496   state_save_register_global_array(toaplan2_scroll_reg);
497   state_save_register_global_array(toaplan2_voffs);
498   state_save_register_global_array(bg_scrollx);
499   state_save_register_global_array(bg_scrolly);
500   state_save_register_global_array(fg_scrollx);
501   state_save_register_global_array(fg_scrolly);
502   state_save_register_global_array(top_scrollx);
503   state_save_register_global_array(top_scrolly);
504   state_save_register_global_array(sprite_scrollx);
505   state_save_register_global_array(sprite_scrolly);
506   state_save_register_global_array(batrider_object_bank);
507
508   state_save_register_global_array(bg_flip);
509   state_save_register_global_array(fg_flip);
510   state_save_register_global_array(top_flip);
511   state_save_register_global_array(sprite_flip);
512   state_save_register_global(tx_flip);
513
514   state_save_register_global_2d_array(sprite_priority);
515   state_save_register_global_2d_array(top_tile_priority);
516   state_save_register_global_2d_array(fg_tile_priority);
517   state_save_register_global_2d_array(bg_tile_priority);
518
519   switch (vrams)
520   {
521   case 2:
522      state_save_register_global_pointer(spriteram16_new[1], TOAPLAN2_SPRITERAM_SIZE/2);
523      state_save_register_global_pointer(spriteram16_now[1], TOAPLAN2_SPRITERAM_SIZE/2);
524      state_save_register_global_pointer(topvideoram16[1], TOAPLAN2_TOP_VRAM_SIZE/2);
525      state_save_register_global_pointer(fgvideoram16[1], TOAPLAN2_FG_VRAM_SIZE/2);
526      state_save_register_global_pointer(bgvideoram16[1], TOAPLAN2_BG_VRAM_SIZE/2);
527      /* fall through */
528   case 1:
529      state_save_register_global_pointer(spriteram16_new[0], TOAPLAN2_SPRITERAM_SIZE/2);
530      state_save_register_global_pointer(spriteram16_now[0], TOAPLAN2_SPRITERAM_SIZE/2);
531      state_save_register_global_pointer(topvideoram16[0], TOAPLAN2_TOP_VRAM_SIZE/2);
532      state_save_register_global_pointer(fgvideoram16[0], TOAPLAN2_FG_VRAM_SIZE/2);
533      state_save_register_global_pointer(bgvideoram16[0], TOAPLAN2_BG_VRAM_SIZE/2);
534      /* fall through */
535   default:
536      break;
537   }
538
539}
540
495541VIDEO_START( toaplan2_0 )
496542{
497543   defaultOffsets();
498544   toaplan2_vh_start(0);
545   register_state_save(1);
499546}
500547
501548VIDEO_START( toaplan2_1 )
r3514r3515
503550   toaplan2_vh_start(0);
504551   toaplan2_vh_start(1);
505552   defaultOffsets();
553   register_state_save(2);
506554}
507555
508556VIDEO_START( truxton2_0 )
r3514r3515
528576      defaultOffsets();
529577      tilemap_set_scrolldx(tx_tilemap, 0x1d4 +1, 0x2a);
530578   }
579
580   register_state_save(1);
531581}
532582
533583VIDEO_START( bgaregga_0 )
r3514r3515
536586   truxton2_create_tilemaps_0();
537587   tilemap_set_scrolldx(tx_tilemap, 0x1d4, 0x2a);
538588   defaultOffsets();
589   register_state_save(1);
539590}
540591
541592VIDEO_START( batrider_0 )
542593{
543594   raizing_tx_gfxram16 = auto_malloc(RAIZING_TX_GFXRAM_SIZE);
544595   memset(raizing_tx_gfxram16,0,RAIZING_TX_GFXRAM_SIZE);
596   state_save_register_global_pointer(raizing_tx_gfxram16, RAIZING_TX_GFXRAM_SIZE/2);
545597
546598   toaplan2_vram_alloc(0);
547599   spriteram16_n[0] = spriteram16_new[0];
r3514r3515
550602
551603   tilemap_set_scrolldx(tx_tilemap, 0x1d4, 0x2a);
552604   defaultOffsets();
605   register_state_save(1);
553606}
554607
555608
r3514r3515
559612
560613***************************************************************************/
561614
562static void toaplan2_voffs_w(offs_t offset, UINT16 data, UINT32 mem_mask, int controller)
615static void toaplan2_voffs_w(offs_t offset, UINT16 data, UINT16 mem_mask, int controller)
563616{
564617   if (data >= 0x1c00)
565618      logerror("Hmmm, unknown video controller %01x layer being selected (%08x)\n",controller,data);
r3514r3515
719772
720773static int toaplan2_videoram16_r(offs_t offset, int controller)
721774{
722   static UINT16 video_data = 0;
723   static offs_t vram_offset;
775   UINT16 video_data = 0;
776   offs_t vram_offset;
724777
725778
726779   switch (toaplan2_voffs[controller] & 0xfc00)
r3514r3515
763816   return toaplan2_videoram16_r(offset, 1);
764817}
765818
766static void toaplan2_videoram16_w(offs_t offset, UINT16 data, UINT32 mem_mask, int controller)
819static void toaplan2_videoram16_w(offs_t offset, UINT16 data, UINT16 mem_mask, int controller)
767820{
768821   offs_t vram_offset;
769822
r3514r3515
810863}
811864
812865
813static void toaplan2_scroll_reg_select_w(offs_t offset, UINT16 data, UINT32 mem_mask, int controller)
866static void toaplan2_scroll_reg_select_w(offs_t offset, UINT16 data, UINT16 mem_mask, int controller)
814867{
815868   if (ACCESSING_BITS_0_7)
816869   {
r3514r3515
835888}
836889
837890
838static void toaplan2_scroll_reg_data_w(running_machine *machine, offs_t offset, UINT16 data, UINT32 mem_mask, int controller)
891static void toaplan2_scroll_reg_data_w(running_machine *machine, offs_t offset, UINT16 data, UINT16 mem_mask, int controller)
839892{
840893   /************************************************************************/
841894   /***** layer X and Y flips can be set independantly, so emulate it ******/
src/mame/video/cischeat.c
r3514r3515
5959/* Variables only used here: */
6060
6161static int cischeat_ip_select;
62static int shift_ret = 1;
6263
6364#ifdef MAME_DEBUG
6465static int debugsprites;   // For debug purposes
r3514r3515
141142/* 32 colour codes for the tiles */
142143VIDEO_START( cischeat )
143144{
145   shift_ret = 1;
144146   VIDEO_START_CALL(megasys1);
145147
146148    megasys1_bits_per_color_code = 5;
r3514r3515
184186
185187CUSTOM_INPUT( cischeat_shift_r )
186188{
187   static int ret = 1; /* start with low shift */
188189   switch ( (input_port_read(field->port->machine, "FAKE") >> 2) & 3 )
189190   {
190      case 1 : ret = 1;   break;   // low  shift: button 3
191      case 2 : ret = 0;   break;   // high shift: button 4
191      case 1 : shift_ret = 1;   break;   // low  shift: button 3
192      case 2 : shift_ret = 0;   break;   // high shift: button 4
192193   }
193   return ret;
194   return shift_ret;
194195}
195196
196197/*
src/mame/video/plygonet.c
r3514r3515
2222{
2323   int attr, code;
2424
25   code = ttl_vram[tile_index]&0xff;
26   attr = 0;
25   code = ttl_vram[tile_index]&0xfff;
2726
27   attr = ttl_vram[tile_index]>>12;   // palette in all 4 bits?
28
2829   SET_TILE_INFO(ttl_gfx_index, code, attr, 0);
2930}
3031
r3514r3515
4546   tilemap_mark_tile_dirty(ttl_tilemap, offset*2+1);
4647}
4748
49static TILEMAP_MAPPER( plygonet_scan )
50{
51   return row * num_cols + (col^1);
52}
53
4854VIDEO_START( polygonet )
4955{
5056   static const gfx_layout charlayout =
r3514r3515
7278   machine->gfx[ttl_gfx_index]->total_colors = machine->config->total_colors / 16;
7379
7480   // create the tilemap
75   ttl_tilemap = tilemap_create(ttl_get_tile_info, tilemap_scan_rows,  8, 8, 64, 32);
81   ttl_tilemap = tilemap_create(ttl_get_tile_info, plygonet_scan,  8, 8, 64, 32);
7682
7783   tilemap_set_transparent_pen(ttl_tilemap, 0);
7884
src/mame/video/tx1.c
r3514r3515
7575   TX1_RDFLAG_TNLF,
7676   TX1_RDFLAG_STLF,
7777   TX1_RDFLAG_SCCHGF
78} tx1_roadreg;
78};
7979
8080static struct
8181{
src/mame/video/m72.c
r3514r3515
132132
133133   tilemap_set_transmask(bg_tilemap,0,0xffff,0x0000);
134134   tilemap_set_transmask(bg_tilemap,1,0x00ff,0xff00);
135   tilemap_set_transmask(bg_tilemap,2,0x0001,0xfffe);
135   //tilemap_set_transmask(bg_tilemap,2,0x0001,0xfffe);
136   tilemap_set_transmask(bg_tilemap,2,0x0007,0xfff8);
136137
137138   memset(m72_spriteram,0,spriteram_size);
138139
src/mame/video/silkroad.c
r3514r3515
135135
136136
137137
138static int enable1, enable2, enable3;
139
138140VIDEO_START(silkroad)
139141{
142   enable1 = enable2 = enable3 = 1;
143
140144   fg_tilemap = tilemap_create(get_fg_tile_info,tilemap_scan_rows,16,16,64, 64);
141145      tilemap_set_transparent_pen(fg_tilemap,0);
142146
r3514r3515
147151      tilemap_set_transparent_pen(fg3_tilemap,0);
148152}
149153
150static int enable1=1,enable2=1,enable3=1;
151
152154VIDEO_UPDATE(silkroad)
153155{
154156   fillbitmap(bitmap,0x7c0,cliprect);
src/mame/video/twin16.c
r3514r3515
2727static UINT16 scrollx[3], scrolly[3];
2828static UINT16 video_register;
2929
30enum {
30enum
31{
3132   TWIN16_SCREEN_FLIPY      = 0x01,   /* ? breaks devils world text layer */
3233   TWIN16_SCREEN_FLIPX      = 0x02,   /* confirmed: Hard Puncher Intro */
3334   TWIN16_UNKNOWN1         = 0x04,   /* ?Hard Puncher uses this */
r3514r3515
4445}
4546
4647WRITE16_HANDLER( twin16_paletteram_word_w )
47{ // identical to tmnt_paletteram_w
48{    // identical to tmnt_paletteram_w
4849   COMBINE_DATA(paletteram16 + offset);
4950   offset &= ~1;
5051
r3514r3515
5960
6061WRITE16_HANDLER( twin16_video_register_w )
6162{
62   switch (offset) {
63   case 0:
64      COMBINE_DATA( &video_register );
63   switch (offset)
64   {
65      case 0:
66         COMBINE_DATA( &video_register );
6567
66      flip_screen_x_set(video_register & TWIN16_SCREEN_FLIPX);
68         flip_screen_x_set(video_register & TWIN16_SCREEN_FLIPX);
6769
68      if (twin16_custom_video)
69         flip_screen_y_set(video_register & TWIN16_SCREEN_FLIPY);
70      else
71         flip_screen_y_set(~video_register & TWIN16_SCREEN_FLIPY);
70         if (twin16_custom_video)
71            flip_screen_y_set(video_register & TWIN16_SCREEN_FLIPY);
72         else
73            flip_screen_y_set(~video_register & TWIN16_SCREEN_FLIPY);
7274
73      break;
75         break;
7476
75   case 1: COMBINE_DATA( &scrollx[0] ); break;
76   case 2: COMBINE_DATA( &scrolly[0] ); break;
77   case 3: COMBINE_DATA( &scrollx[1] ); break;
78   case 4: COMBINE_DATA( &scrolly[1] ); break;
79   case 5: COMBINE_DATA( &scrollx[2] ); break;
80   case 6: COMBINE_DATA( &scrolly[2] ); break;
77      case 1: COMBINE_DATA( &scrollx[0] ); break;
78      case 2: COMBINE_DATA( &scrolly[0] ); break;
79      case 3: COMBINE_DATA( &scrollx[1] ); break;
80      case 4: COMBINE_DATA( &scrolly[1] ); break;
81      case 5: COMBINE_DATA( &scrollx[2] ); break;
82      case 6: COMBINE_DATA( &scrolly[2] ); break;
8183
82   default:
83      logerror("unknown video_register write:%d", data );
84      break;
84      default:
85         logerror("unknown video_register write:%d", data );
86         break;
8587   }
8688}
8789
88static void draw_sprite( /* slow slow slow, but it's ok for now */
89   bitmap_t *bitmap,
90   const UINT16 *pen_data,
91   int pal_base,
92   int xpos, int ypos,
93   int width, int height,
94   int flipx, int flipy, int pri )
90/* slow slow slow, but it's ok for now */
91static void draw_sprite( bitmap_t *bitmap,const UINT16 *pen_data, int pal_base, int xpos, int ypos, int width, int height, int flipx, int flipy, int pri )
9592{
96
9793   int x,y,pval;
9894   if( xpos>=320 ) xpos -= 65536;
9995   if( ypos>=256 ) ypos -= 65536;
10096
10197   if (pri) pval=2; else pval=8;
10298
99   for( y=0; y<height; y++ )
103100   {
101      int sy = (flipy)?(ypos+height-1-y):(ypos+y);
102      if( sy>=16 && sy<256-16 )
104103      {
105         for( y=0; y<height; y++ )
104         UINT16 *dest = BITMAP_ADDR16(bitmap, sy, 0);
105         UINT8 *pdest = BITMAP_ADDR8(priority_bitmap, sy, 0);
106
107         for( x=0; x<width; x++ )
106108         {
107            int sy = (flipy)?(ypos+height-1-y):(ypos+y);
108            if( sy>=16 && sy<256-16 )
109            int sx = (flipx)?(xpos+width-1-x):(xpos+x);
110            if( sx>=0 && sx<320 )
109111            {
110               UINT16 *dest = BITMAP_ADDR16(bitmap, sy, 0);
111               UINT8 *pdest = BITMAP_ADDR8(priority_bitmap, sy, 0);
112               UINT16 pen = pen_data[x/4];
113               switch( x%4 )
114               {
115                  case 0: pen = pen>>12; break;
116                  case 1: pen = (pen>>8)&0xf; break;
117                  case 2: pen = (pen>>4)&0xf; break;
118                  case 3: pen = pen&0xf; break;
119               }
112120
113               for( x=0; x<width; x++ )
121               if( pen )
114122               {
115                  int sx = (flipx)?(xpos+width-1-x):(xpos+x);
116                  if( sx>=0 && sx<320 )
123                  if(pdest[sx]<pval)
117124                  {
118                     UINT16 pen = pen_data[x/4];
119                     switch( x%4 )
120                     {
121                     case 0: pen = pen>>12; break;
122                     case 1: pen = (pen>>8)&0xf; break;
123                     case 2: pen = (pen>>4)&0xf; break;
124                     case 3: pen = pen&0xf; break;
125                     }
126
127                     if( pen )
128                     {
129                        if(pdest[sx]<pval) { dest[sx] = pal_base + pen; }
130
131                        pdest[sx]|=0x10;
132                     }
125                     dest[sx] = pal_base + pen;
133126                  }
127                  pdest[sx]|=0x10;
134128               }
135129            }
136            pen_data += width/4;
137130         }
138131      }
132      pen_data += width/4;
139133   }
140134}
141135
r3514r3515
148142   const UINT16 *finish = &spriteram16[0x1800];
149143
150144   memset( &spriteram16[0x1800], 0, 0x800 );
151   while( source<finish ){
145   while( source<finish )
146   {
152147      UINT16 priority = source[0];
153      if( priority & 0x8000 ){
148      if( priority & 0x8000 )
149      {
154150         UINT16 *dest = &spriteram16[0x1800 + 4*(priority&0xff)];
155151
156152         INT32 xpos = (0x10000*source[4])|source[5];
r3514r3515
202198   const UINT16 *source = 0x1800+buffered_spriteram16 + 0x800 - 4;
203199   const UINT16 *finish = 0x1800+buffered_spriteram16;
204200
205   for (; source >= finish; source -= 4) {
201   for (; source >= finish; source -= 4)
202   {
206203      UINT16 attributes = source[3];
207204      UINT16 code = source[0];
208205
209      if((code!=0xffff) && (attributes&0x8000)) {
206      if((code!=0xffff) && (attributes&0x8000))
207      {
210208         int xpos = source[1];
211209         int ypos = source[2];
212210
r3514r3515
217215         int flipy = attributes&0x0200;
218216         int flipx = attributes&0x0100;
219217
220         if( twin16_custom_video == 1 ) {
218         if( twin16_custom_video == 1 )
219         {
221220            pen_data = twin16_gfx_rom + 0x80000;
222221         }
223         else {
224            switch( (code>>12)&0x3 ){ /* bank select */
222         else
223         {
224            switch( (code>>12)&0x3 )
225            { /* bank select */
225226               case 0:
226227               pen_data = twin16_gfx_rom;
227228               break;
r3514r3515
262263
263264         pen_data += code*0x40;
264265
265         if( video_register&TWIN16_SCREEN_FLIPY ){
266         if( video_register&TWIN16_SCREEN_FLIPY )
267         {
266268            if (ypos>65000) ypos=ypos-65536; /* Bit hacky */
267269            ypos = 256-ypos-height;
268270            flipy = !flipy;
269271         }
270         if( video_register&TWIN16_SCREEN_FLIPX ){
272         if( video_register&TWIN16_SCREEN_FLIPX )
273         {
271274            if (xpos>65000) xpos=xpos-65536; /* Bit hacky */
272275            xpos = 320-xpos-width;
273276            flipx = !flipx;
r3514r3515
281284   }
282285}
283286
284static void draw_layer( bitmap_t *bitmap, int opaque ){
287static void draw_layer( bitmap_t *bitmap, int opaque )
288{
285289   const UINT16 *gfx_base;
286290   const UINT16 *source = videoram16;
287291   int i, xxor, yxor;
r3514r3515
290294   int tile_flipx = 0; // video_register&TWIN16_TILE_FLIPX;
291295   int tile_flipy = video_register&TWIN16_TILE_FLIPY;
292296
293   if( ((video_register&TWIN16_PLANE_ORDER)?1:0) != opaque ){
297   if( ((video_register&TWIN16_PLANE_ORDER)?1:0) != opaque )
298   {
294299      source += 0x1000;
295300      dx = scrollx[2];
296301      dy = scrolly[2];
297302      palette = 1;
298303   }
299   else {
304   else
305   {
300306      source += 0x0000;
301307      dx = scrollx[1];
302308      dy = scrolly[1];
303309      palette = 0;
304310   }
305311
306   if( twin16_custom_video == 1 ){
312   if( twin16_custom_video == 1 )
313   {
307314      gfx_base = twin16_gfx_rom;
308315      bank_table[3] = (gfx_bank>>(4*3))&0xf;
309316      bank_table[2] = (gfx_bank>>(4*2))&0xf;
310317      bank_table[1] = (gfx_bank>>(4*1))&0xf;
311318      bank_table[0] = (gfx_bank>>(4*0))&0xf;
312319   }
313   else {
320   else
321   {
314322      gfx_base = twin16_tile_gfx_ram;
315323      bank_table[0] = 0;
316324      bank_table[1] = 1;
r3514r3515
318326      bank_table[3] = 3;
319327   }
320328
321   if( video_register&TWIN16_SCREEN_FLIPX ){
329   if( video_register&TWIN16_SCREEN_FLIPX )
330   {
322331      dx = 256-dx-64;
323332      tile_flipx = !tile_flipx;
324333   }
325334
326   if( video_register&TWIN16_SCREEN_FLIPY ){
335   if( video_register&TWIN16_SCREEN_FLIPY )
336   {
327337      dy = 256-dy;
328338      tile_flipy = !tile_flipy;
329339   }
r3514r3515
418428
419429VIDEO_START( twin16 )
420430{
421   fg_tilemap = tilemap_create(get_fg_tile_info, tilemap_scan_rows_flip_y,
422       8, 8, 64, 32);
431   fg_tilemap = tilemap_create(get_fg_tile_info, tilemap_scan_rows_flip_y, 8, 8, 64, 32);
423432
424433   tilemap_set_transparent_pen(fg_tilemap, 0);
425434}
426435
427436VIDEO_START( fround )
428437{
429   fg_tilemap = tilemap_create(get_fg_tile_info, tilemap_scan_rows,
430       8, 8, 64, 32);
438   fg_tilemap = tilemap_create(get_fg_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
431439
432440   tilemap_set_transparent_pen(fg_tilemap, 0);
433441}
434442
443VIDEO_UPDATE( twin16 )
444{
445   fillbitmap(priority_bitmap,0,cliprect);
446   draw_layer( bitmap,1 );
447
448   if (twin16_custom_video)
449   {
450      draw_layer( bitmap,0 );
451      draw_sprites( bitmap );
452   }
453   else   // devilw, vulcan - different priorities order? there should be an enable bit somewhere...
454   {
455      draw_sprites( bitmap );
456      draw_layer( bitmap,0 );
457   }
458
459   tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 0);
460   return 0;
461}
462
435463VIDEO_EOF( twin16 )
436464{
437465   if( twin16_spriteram_process_enable() && need_process_spriteram )
r3514r3515
442470   buffer_spriteram16_w(machine,0,0,0xffff);
443471}
444472
445VIDEO_UPDATE( twin16 )
446{
447   fillbitmap(priority_bitmap,0,cliprect);
448   draw_layer( bitmap,1 );
449   draw_layer( bitmap,0 );
450   draw_sprites( bitmap );
451   tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 0);
452   return 0;
453}
454
455VIDEO_UPDATE( vulcan )
456{
457   fillbitmap(priority_bitmap,0,cliprect);
458   draw_layer( bitmap,1 );
459   draw_sprites( bitmap );
460   draw_layer( bitmap,0 );
461   tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 0);
462   return 0;
463}
src/mame/video/thepit.c
r3514r3515
103103      UINT8 g = BITSWAP8(color_prom[i + 0x20], 7, 6, 0, 1, 2, 3, 4, 5) & 0x1f;
104104      UINT8 b = BITSWAP8(color_prom[i + 0x00], 0, 1, 2, 3, 4, 5, 6, 7) & 0x1f;
105105
106      palette_set_color_rgb(machine, i + 8, pal5bit(r), pal5bit(g), pal5bit(b));
106      palette_set_color_rgb(machine, i, pal5bit(r), pal5bit(g), pal5bit(b));
107107   }
108108
109109   /* allocate primary colors for the background and foreground
src/mame/layout/re900.lay
r0r3515
1<?xml version="1.0"?>
2<mamelayout version="2">
3
4   <element name="BALL0">
5      <disk state = "0">
6         <color red="0.0" green="0.3" blue="0" />
7      </disk>
8      <disk state = "1">
9         <color red="0" green="1" blue="0" />
10      </disk>
11   </element>
12
13   <element name="BALL">
14      <disk state = "0">
15         <color red="0.3" green="0" blue="0" />
16      </disk>
17      <disk state = "1">
18         <color red="1" green="0" blue="0" />
19      </disk>
20   </element>
21
22   <element name="L0" defstate="1">
23      <rect state="0">
24         <color red="0.7" green="0.0" blue="0.0" />
25      </rect>
26      <text state ="0" string="Operator Key">
27         <color red="0.0" green="0.0" blue="0.0" />
28      </text>
29      <rect state="1">
30         <color red="0.0" green="0.7" blue="0.0" />
31      </rect>
32      <text state ="1" string="Operator Key">
33         <color red="0.0" green="0.0" blue="0.0" />
34      </text>
35   </element>
36
37
38   <element name="L1" defstate="0">
39      <rect state="1">
40         <color red="0.7" green="0.0" blue="0.0" />
41      </rect>
42      <rect state="0">
43         <color red="0.3" green="0.0" blue="0.0" />
44      </rect>
45      <text string="P1">
46         <color red="0.0" green="0.0" blue="0.0" />
47         <bounds x="0" y="0.1" width="1" height="0.8" />
48      </text>
49   </element>
50
51   <element name="L2" defstate="0">
52      <rect state="1">
53         <color red="0.7" green="0.0" blue="0.0" />
54      </rect>
55      <rect state="0">
56         <color red="0.3" green="0.0" blue="0.0" />
57      </rect>
58      <text string="P2">
59         <color red="0.0" green="0.0" blue="0.0" />
60         <bounds x="0" y="0.1" width="1" height="0.8" />
61      </text>
62   </element>
63
64   <element name="L3" defstate="0">
65      <rect state="1">
66         <color red="0.7" green="0.0" blue="0.0" />
67      </rect>
68      <rect state="0">
69         <color red="0.3" green="0.0" blue="0.0" />
70      </rect>
71      <text string="P3">
72         <color red="0.0" green="0.0" blue="0.0" />
73         <bounds x="0" y="0.1" width="1" height="0.8" />
74      </text>
75   </element>
76
77   <element name="L4" defstate="0">
78      <rect state="1">
79         <color red="0.7" green="0.0" blue="0.0" />
80      </rect>
81      <rect state="0">
82         <color red="0.3" green="0.0" blue="0.0" />
83      </rect>
84      <text string="P4">
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   <element name="L5" defstate="0">
91      <rect state="1">
92         <color red="0.7" green="0.0" blue="0.0" />
93      </rect>
94      <rect state="0">
95         <color red="0.3" green="0.0" blue="0.0" />
96      </rect>
97      <text string="P5">
98         <color red="0.0" green="0.0" blue="0.0" />
99         <bounds x="0" y="0.1" width="1" height="0.8" />
100      </text>
101   </element>
102
103   <element name="L6" defstate="0">
104      <rect state="1">
105         <color red="0.7" green="0.0" blue="0.0" />
106      </rect>
107      <rect state="0">
108         <color red="0.3" green="0.0" blue="0.0" />
109      </rect>
110      <text string="P6">
111         <color red="0.0" green="0.0" blue="0.0" />
112         <bounds x="0" y="0.1" width="1" height="0.8" />
113      </text>
114   </element>
115
116   <view name="Lamps">
117
118      <screen index="0">
119         <bounds left="100" top="96" right="832" bottom="1072" />
120      </screen>
121
122      <bezel name="lamp0" element="L0">
123         <bounds x="1135" y="870" width="200" height="45" />
124      </bezel>
125      <bezel name="lamp1" element="L1">
126         <bounds x="1000" y="950" width="70" height="45" />
127      </bezel>
128      <bezel name="lamp2" element="L2">
129         <bounds x="1080" y="950" width="70" height="45" />
130      </bezel>
131      <bezel name="lamp3" element="L3">
132         <bounds x="1160" y="950" width="70" height="45" />
133      </bezel>
134      <bezel name="lamp4" element="L4">
135         <bounds x="1240" y="950" width="70" height="45" />
136      </bezel>
137      <bezel name="lamp5" element="L5">
138         <bounds x="1320" y="950" width="70" height="45" />
139      </bezel>
140      <bezel name="lamp6" element="L6">
141         <bounds x="1400" y="950" width="70" height="45" />
142      </bezel>
143      <bezel name="lamp20" element="BALL0">   
144         <bounds x="1321.5755279531" y="319.178830824334" width="16" height="16" />
145      </bezel>   
146      <bezel name="lamp21" element="BALL">   
147         <bounds x="1332.56513467655" y="335.702636395822" width="16" height="16" />
148      </bezel>   
149      <bezel name="lamp22" element="BALL">   
150         <bounds x="1340.60412921523" y="353.84601461785" width="16" height="16" />
151      </bezel>   
152      <bezel name="lamp23" element="BALL">   
153         <bounds x="1345.46124433281" y="373.087013532536" width="16" height="16" />
154      </bezel>   
155      <bezel name="lamp24" element="BALL">   
156         <bounds x="1346.9967496707" y="392.872104633103" width="16" height="16" />
157      </bezel>   
158      <bezel name="lamp25" element="BALL">   
159         <bounds x="1345.16647153601" y="412.632106871213" width="16" height="16" />
160      </bezel>   
161      <bezel name="lamp26" element="BALL">   
162         <bounds x="1340.0230636983" y="431.798560959421" width="16" height="16" />
163      </bezel>   
164      <bezel name="lamp27" element="BALL">   
165         <bounds x="1331.71449263647" y="449.820082909883" width="16" height="16" />
166      </bezel>   
167      <bezel name="lamp28" element="BALL">   
168         <bounds x="1320.4797808126" y="466.178226347788" width="16" height="16" />
169      </bezel>   
170      <bezel name="lamp29" element="BALL">   
171         <bounds x="1306.64213043088" y="480.402397269624" width="16" height="16" />
172      </bezel>   
173      <bezel name="lamp30" element="BALL">   
174         <bounds x="1290.59962549863" y="492.083392175853" width="16" height="16" />
175      </bezel>   
176      <bezel name="lamp31" element="BALL">   
177         <bounds x="1272.81377967425" y="500.885170110556" width="16" height="16" />
178      </bezel>   
179      <bezel name="lamp32" element="BALL">   
180         <bounds x="1253.7962593595" y="506.554519947908" width="16" height="16" />
181      </bezel>   
182      <bezel name="lamp33" element="BALL">   
183         <bounds x="1234.09416398871" y="508.928344815248" width="16" height="16" />
184      </bezel>   
185      <bezel name="lamp34" element="BALL">   
186         <bounds x="1214.27428697419" y="507.938354093155" width="16" height="16" />
187      </bezel>   
188      <bezel name="lamp35" element="BALL">   
189         <bounds x="1194.90681009169" y="503.613028012232" width="16" height="16" />
190      </bezel>   
191      <bezel name="lamp36" element="BALL">   
192         <bounds x="1176.54890038884" y="496.076798328726" width="16" height="16" />
193      </bezel>   
194      <bezel name="lamp37" element="BALL">   
195         <bounds x="1159.72868150364" y="485.546468649452" width="16" height="16" />
196      </bezel>   
197      <bezel name="lamp38" element="BALL">   
198         <bounds x="1144.93004050891" y="472.32497738676" width="16" height="16" />
199      </bezel>   
200      <bezel name="lamp39" element="BALL">   
201         <bounds x="1132.57870736225" y="456.792682771969" width="16" height="16" />
202      </bezel>   
203      <bezel name="lamp40" element="BALL">   
204         <bounds x="1123.03000743027" y="439.396420641569" width="16" height="16" />
205      </bezel>   
206      <bezel name="lamp41" element="BALL">   
207         <bounds x="1116.55863942476" y="420.636649783757" width="16" height="16" />
208      </bezel>   
209      <bezel name="lamp42" element="BALL">   
210         <bounds x="1113.35077282082" y="401.053054650283" width="16" height="16" />
211      </bezel>   
212      <bezel name="lamp43" element="BALL">   
213         <bounds x="1113.49869210012" y="381.209019617376" width="16" height="16" />
214      </bezel>   
215      <bezel name="lamp44" element="BALL">   
216         <bounds x="1116.99814189431" y="361.675421442988" width="16" height="16" />
217      </bezel>   
218      <bezel name="lamp45" element="BALL">   
219         <bounds x="1123.74844940422" y="343.014206181865" width="16" height="16" />
220      </bezel>   
221      <bezel name="lamp46" element="BALL">   
222         <bounds x="1133.55542057307" y="325.762223020679" width="16" height="16" />
223      </bezel>   
224      <bezel name="lamp47" element="BALL">   
225         <bounds x="1146.13692669582" y="310.415780104371" width="16" height="16" />
226      </bezel>   
227      <bezel name="lamp48" element="BALL">   
228         <bounds x="1161.13102074843" y="297.416366654444" width="16" height="16" />
229      </bezel>   
230      <bezel name="lamp49" element="BALL">   
231         <bounds x="1178.10634994466" y="287.137952127882" width="16" height="16" />
232      </bezel>   
233      <bezel name="lamp50" element="BALL">   
234         <bounds x="1196.57456497046" y="279.876227796751" width="16" height="16" />
235      </bezel>   
236      <bezel name="lamp51" element="BALL">   
237         <bounds x="1216.00436890452" y="275.840100248669" width="16" height="16" />
238      </bezel>   
239      <bezel name="lamp52" element="BALL">   
240         <bounds x="1235.83680166342" y="275.145681524636" width="16" height="16" />
241      </bezel>   
242      <bezel name="lamp53" element="BALL">   
243         <bounds x="1255.5013202655" y="277.812948787016" width="16" height="16" />
244      </bezel>   
245      <bezel name="lamp54" element="BALL">   
246         <bounds x="1274.43221231367" y="283.765169612954" width="16" height="16" />
247      </bezel>   
248      <bezel name="lamp55" element="BALL">   
249         <bounds x="1292.08487051111" y="292.831109446467" width="16" height="16" />
250      </bezel>   
251      <bezel name="lamp56" element="BALL">   
252         <bounds x="1307.95146002158" y="304.749957704861" width="16" height="16" />
253      </bezel>   
254
255   </view>
256</mamelayout>
src/mame/drivers/expro02.c
r3514r3515
241241
242242
243243static INPUT_PORTS_START( galsnewa )
244   PORT_START("DSW1")
245   PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Difficulty ) )
246   PORT_DIPSETTING(      0x0002, DEF_STR( Easy ) )
247   PORT_DIPSETTING(      0x0003, DEF_STR( Normal ) )
248   PORT_DIPSETTING(      0x0001, DEF_STR( Hard ) )
249   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
250   PORT_BIT( 0x000C, IP_ACTIVE_LOW, IPT_UNUSED )
251   PORT_DIPNAME( 0x0030, 0x0030, DEF_STR( Lives ) )
244   PORT_INCLUDE( galsnew )
245
246   PORT_MODIFY("DSW1")
247   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) )   PORT_DIPLOCATION("SWA:3")
248   PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
249   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
250   PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) )   PORT_DIPLOCATION("SWA:4")
251   PORT_DIPSETTING(      0x0008, DEF_STR( Off ) )
252   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
253   PORT_DIPNAME( 0x0030, 0x0030, DEF_STR( Lives ) )   PORT_DIPLOCATION("SWA:5,6")
252254   PORT_DIPSETTING(      0x0010, "2" )
253255   PORT_DIPSETTING(      0x0030, "3" )
254256   PORT_DIPSETTING(      0x0020, "4" )
255257   PORT_DIPSETTING(      0x0000, "5" )
256   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Demo_Sounds ) )
258   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Demo_Sounds ) )   PORT_DIPLOCATION("SWA:7")
257259   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
258260   PORT_DIPSETTING(      0x0040, DEF_STR( On ) )
259   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unused ) )
261INPUT_PORTS_END
262
263
264static INPUT_PORTS_START( galsnewj )
265   PORT_INCLUDE( galsnewa )
266
267   PORT_MODIFY("DSW1")
268   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) )   PORT_DIPLOCATION("SWA:8")
260269   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
261270   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
262271
263   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY PORT_PLAYER(1)
264   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_PLAYER(1)
265   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_PLAYER(1)
266   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_PLAYER(1)
267   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
268   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
269   PORT_BIT( 0xC000, IP_ACTIVE_LOW, IPT_UNUSED )
272   PORT_MODIFY("DSW2")
273   PORT_DIPUNUSED_DIPLOC( 0x0008, 0x0008, "SWB:4" )
274   PORT_DIPNAME( 0x0030, 0x0030, DEF_STR( Coin_A ) )   PORT_DIPLOCATION("SWB:5,6")
275   PORT_DIPSETTING(      0x0010, DEF_STR( 2C_1C ) )
276   PORT_DIPSETTING(      0x0030, DEF_STR( 1C_1C ) )
277   PORT_DIPSETTING(      0x0000, DEF_STR( 2C_3C ) )
278   PORT_DIPSETTING(      0x0020, DEF_STR( 1C_2C ) )
279   PORT_DIPNAME( 0x00c0, 0x00c0, DEF_STR( Coin_B ) )   PORT_DIPLOCATION("SWB:7,8")
280   PORT_DIPSETTING(      0x0040, DEF_STR( 2C_1C ) )
281   PORT_DIPSETTING(      0x00c0, DEF_STR( 1C_1C ) )
282   PORT_DIPSETTING(      0x0000, DEF_STR( 2C_3C ) )
283   PORT_DIPSETTING(      0x0080, DEF_STR( 1C_2C ) )
284INPUT_PORTS_END
270285
271   PORT_START("DSW2")
272   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_UNUSED )
273   PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Flip_Screen ) )   /* flip screen? */
274   PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
275   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
276   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Test ) )
277   PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
278   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
279   PORT_DIPNAME( 0x0038, 0x0038, DEF_STR( Coin_A ) )
280   PORT_DIPSETTING(      0x0028, DEF_STR( 2C_1C ) )
281   PORT_DIPSETTING(      0x0038, DEF_STR( 1C_1C ) )
282   PORT_DIPSETTING(      0x0018, DEF_STR( 1C_2C ) )
283   PORT_DIPSETTING(      0x0010, DEF_STR( 1C_3C ) )
284   PORT_DIPSETTING(      0x0000, DEF_STR( 1C_4C ) )
285   PORT_DIPSETTING(      0x0008, DEF_STR( 1C_6C ) )
286   PORT_DIPNAME( 0x0040, 0x0040, "Coin B-1" )
287   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
288   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
289   PORT_DIPNAME( 0x0080, 0x0080, "Coin B-2" )
286
287static INPUT_PORTS_START( fantasia )
288   PORT_INCLUDE( galsnewa )
289
290   PORT_MODIFY("DSW1")
291   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) )   PORT_DIPLOCATION("SWA:8")
290292   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
291293   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
292   /* Coinage - Japan (0x03ffff.b = 01) and US (0x03ffff.b = 02)
293    PORT_DIPNAME( 0x0030, 0x0030, DEF_STR( Coin_A ) )
294    PORT_DIPSETTING(      0x0010, DEF_STR( 2C_1C ) )
295    PORT_DIPSETTING(      0x0030, DEF_STR( 1C_1C ) )
296    PORT_DIPSETTING(      0x0000, DEF_STR( 2C_3C ) )
297    PORT_DIPSETTING(      0x0020, DEF_STR( 1C_2C ) )
298    PORT_DIPNAME( 0x00c0, 0x00c0, DEF_STR( Coin_B ) )
299    PORT_DIPSETTING(      0x0040, DEF_STR( 2C_1C ) )
300    PORT_DIPSETTING(      0x00c0, DEF_STR( 1C_1C ) )
301    PORT_DIPSETTING(      0x0000, DEF_STR( 2C_3C ) )
302    PORT_DIPSETTING(      0x0080, DEF_STR( 1C_2C ) )
303    */
304   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY PORT_PLAYER(2)
305   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_PLAYER(2)
306   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_PLAYER(2)
307   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_PLAYER(2)
308   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
309   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)   /* "Shot2" in "test mode" */
310   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
311   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
312
313   PORT_START("DSW3")
314   PORT_BIT( 0x00ff, IP_ACTIVE_LOW, IPT_UNKNOWN )
315   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_START1 )
316   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_START2 )
317   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_COIN1 )
318   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_COIN2 )
319   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_UNKNOWN )
320   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_TILT )
321   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_SERVICE1 )
322   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
323294INPUT_PORTS_END
324295
325static WRITE16_HANDLER( galsnew_paletteram_w )
326{
327   data = COMBINE_DATA(&paletteram16[offset]);
328   palette_set_color_rgb(machine,offset,pal5bit(data >> 6),pal5bit(data >> 11),pal5bit(data >> 1));
329}
296/*************************************
297 *
298 *  Sound handlers
299 *
300 *************************************/
330301
331302static WRITE16_HANDLER( galsnew_6295_bankswitch_w )
332303{
r3514r3515
337308   }
338309}
339310
311/*************************************
312 *
313 *  Video handlers
314 *
315 *************************************/
316
317static WRITE16_HANDLER( galsnew_paletteram_w )
318{
319   data = COMBINE_DATA(&paletteram16[offset]);
320   palette_set_color_rgb(machine,offset,pal5bit(data >> 6),pal5bit(data >> 11),pal5bit(data >> 1));
321}
322
340323static UINT16 vram_0_bank_num = 0, vram_1_bank_num = 0;
341324
342WRITE16_HANDLER(galsnew_vram_0_bank_w)
325static WRITE16_HANDLER(galsnew_vram_0_bank_w)
343326{
344327   int i;
345328   if(vram_0_bank_num != data)
r3514r3515
355338   }
356339}
357340
358WRITE16_HANDLER(galsnew_vram_1_bank_w)
341static WRITE16_HANDLER(galsnew_vram_1_bank_w)
359342{
360343   int i;
361344   if(vram_1_bank_num != data)
r3514r3515
371354   }
372355}
373356
357/*************************************
358 *
359 *  CPU memory handlers
360 *
361 *************************************/
362
374363static ADDRESS_MAP_START( galsnew_map, ADDRESS_SPACE_PROGRAM, 16 )
375364   AM_RANGE(0x000000, 0x03ffff) AM_ROM // main program
376365   AM_RANGE(0x080000, 0x0fffff) AM_ROM AM_REGION("user2",0) // other data
r3514r3515
439428   AM_RANGE(0xf00000, 0xf00001) AM_READWRITE(okim6295_status_0_msb_r,okim6295_data_0_msb_w)
440429ADDRESS_MAP_END
441430
431/*************************************
432 *
433 *  Initialization & interrupts
434 *
435 *************************************/
436
442437static INTERRUPT_GEN( galsnew_interrupt )
443438{
444439   cpunum_set_input_line(machine, 0, cpu_getiloops() + 3, HOLD_LINE);   /* IRQs 5, 4, and 3 */
r3514r3515
458453   kaneko16_priority.sprite[3] = 8;   // above all
459454}
460455
456/*************************************
457 *
458 *  Graphics definitions
459 *
460 *************************************/
461
461462static const gfx_layout layout_16x16x4 =
462463{
463464   16,16,
r3514r3515
475476   GFXDECODE_ENTRY( "gfx2", 0, layout_16x16x4, 0x400,      0x40 ) // [0] bg tiles
476477GFXDECODE_END
477478
479/*************************************
480 *
481 *  Machine driver
482 *
483 *************************************/
484
478485static MACHINE_DRIVER_START( galsnew )
479486
480487   /* basic machine hardware */
r3514r3515
509516   MDRV_SOUND_ADD("oki", OKIM6295, 12000000/6)
510517   MDRV_SOUND_CONFIG(okim6295_interface_pin7low)
511518   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
519
512520MACHINE_DRIVER_END
513521
522
514523static MACHINE_DRIVER_START( fantasia )
515524
516525   /* basic machine hardware */
517   MDRV_CPU_ADD("main", M68000, 12000000)
526   MDRV_IMPORT_FROM( galsnew )
527   MDRV_CPU_MODIFY("main")
518528   MDRV_CPU_PROGRAM_MAP(fantasia_map,0)
519   MDRV_CPU_VBLANK_INT_HACK(galsnew_interrupt,3)
520529
521   /* video hardware */
522   MDRV_SCREEN_ADD("main", RASTER)
523   MDRV_SCREEN_REFRESH_RATE(60)
524   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */)
525   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
526   MDRV_SCREEN_SIZE(256, 256)
527   MDRV_SCREEN_VISIBLE_AREA(0, 256-1, 0, 256-32-1)
530   MDRV_WATCHDOG_TIME_INIT(UINT64_ATTOTIME_IN_SEC(0))   /* a guess, and certainly wrong */
528531
529   MDRV_GFXDECODE(1x4bit_1x4bit)
530   MDRV_PALETTE_LENGTH(2048 + 32768)
531   MDRV_MACHINE_RESET( galsnew )
532MACHINE_DRIVER_END
532533
533   MDRV_VIDEO_START(galsnew)
534   MDRV_VIDEO_UPDATE(galsnew)
535   MDRV_PALETTE_INIT(berlwall)
534/*************************************
535 *
536 *  ROM definition(s)
537 *
538 *************************************/
536539
537   /* arm watchdog */
538   //MDRV_WATCHDOG_TIME_INIT(UINT64_ATTOTIME_IN_SEC(3))    /* a guess, and certainly wrong */
539
540   /* sound hardware */
541   MDRV_SPEAKER_STANDARD_MONO("mono")
542
543   MDRV_SOUND_ADD("oki", OKIM6295, 12000000/6)
544   MDRV_SOUND_CONFIG(okim6295_interface_pin7low)
545   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
546MACHINE_DRIVER_END
547
548540ROM_START( galsnew ) /* EXPRO-02 PCB */
549541   ROM_REGION( 0x40000, "main", 0 )   /* 68000 code */
550542   ROM_LOAD16_BYTE( "pm110u_u87-01.u87", 0x000000, 0x20000, CRC(b793a57d) SHA1(12d57b2b4add532f0d0453c25b30d34b3449d717) ) /* US region */
r3514r3515
694686   ROM_LOAD16_BYTE( "gscr3_11.rom", 0x100000, 0x80000, CRC(6d00a4c5) SHA1(8fc0d78200b82ab87658d364ebe2f2e7239722e7) )
695687ROM_END
696688
689/*************************************
690 *
691 *  Generic driver initialization
692 *
693 *************************************/
697694
698DRIVER_INIT(galsnew)
695static DRIVER_INIT(galsnew)
699696{
700697   UINT32 *src = (UINT32 *)memory_region(machine, "gfx3" );
701698   UINT32 *dst = (UINT32 *)memory_region(machine, "gfx2" );
r3514r3515
726723   }
727724}
728725
726/*************************************
727 *
728 *  Game driver(s)
729 *
730 *************************************/
729731
730
731732GAME( 1990, galsnew,  0,       galsnew, galsnew,  galsnew, ROT90, "Kaneko", "Gals Panic (US, EXPRO-02 PCB)", 0 )
732733GAME( 1990, galsnewa, galsnew, galsnew, galsnewa, galsnew, ROT90, "Kaneko", "Gals Panic (Export, EXPRO-02 PCB)", 0 )
733GAME( 1990, galsnewj, galsnew, galsnew, galsnewa, galsnew, ROT90, "Kaneko (Taito license)", "Gals Panic (Japan, EXPRO-02 PCB)", 0 )
734GAME( 1990, galsnewj, galsnew, galsnew, galsnewj, galsnew, ROT90, "Kaneko (Taito license)", "Gals Panic (Japan, EXPRO-02 PCB)", 0 )
734735
735GAME( 1994, fantasia, 0,       fantasia,    galsnew, galsnew, ROT90, "Comad & New Japan System", "Fantasia", GAME_NO_COCKTAIL )
736GAME( 1994, fantasia, 0,       fantasia,fantasia, galsnew, ROT90, "Comad & New Japan System", "Fantasia", GAME_NO_COCKTAIL )
src/mame/drivers/sslam.c
r3514r3515
8181
8282
8383#include "driver.h"
84#include "cpu/i8051/i8051.h"
84#include "cpu/mcs51/mcs51.h"
8585#include "sound/okim6295.h"
8686
8787
r3514r3515
395395static WRITE16_HANDLER( powerbls_sound_w )
396396{
397397   soundlatch_w(machine,0,data & 0xff);
398   cpunum_set_input_line(machine, 1,I8051_INT1_LINE,HOLD_LINE);
398   cpunum_set_input_line(machine, 1,MCS51_INT1_LINE,HOLD_LINE);
399399}
400400
401401/* Memory Maps */
src/mame/drivers/arabian.c
r3514r3515
55    driver by Dan Boris
66
77    Games supported:
8        * Arabian
8        * Arabian [2 sets]
99
1010    Known bugs:
1111        * none at this time
r3514r3515
245245   PORT_START("IN0")
246246   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 )
247247   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 )
248   PORT_SERVICE( 0x04, IP_ACTIVE_HIGH )
248   PORT_SERVICE( 0x04, IP_ACTIVE_HIGH )                    /* also adds 1 credit */
249249   PORT_BIT( 0xf8, IP_ACTIVE_HIGH, IPT_UNKNOWN )
250250
251251   PORT_START("DSW1")
252   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Lives ))            PORT_DIPLOCATION("SW1:!1")
252   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Lives ) )            PORT_DIPLOCATION("SW1:!1")
253253   PORT_DIPSETTING(    0x00, "3" )
254254   PORT_DIPSETTING(    0x01, "5" )
255   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Cabinet ))         PORT_DIPLOCATION("SW1:!2")
256   PORT_DIPSETTING(    0x02, DEF_STR( Upright ))
257   PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ))
258   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Flip_Screen ))      PORT_DIPLOCATION("SW1:!3")
259   PORT_DIPSETTING(    0x04, DEF_STR( Off ))
260   PORT_DIPSETTING(    0x00, DEF_STR( On ))
261   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Difficulty ))      PORT_DIPLOCATION("SW1:!4") /* Carry Bowls to Next Life */
262   PORT_DIPSETTING(    0x00, DEF_STR( Easy ))
263   PORT_DIPSETTING(    0x08, DEF_STR( Hard ))
264   PORT_DIPNAME( 0xf0, 0x00, DEF_STR( Coinage ))         PORT_DIPLOCATION("SW1:!5,!6,!7,!8")
255   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Cabinet ) )          PORT_DIPLOCATION("SW1:!2")
256   PORT_DIPSETTING(    0x02, DEF_STR( Upright ) )
257   PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
258   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Flip_Screen ) )      PORT_DIPLOCATION("SW1:!3")
259   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
260   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
261   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Difficulty ) )       PORT_DIPLOCATION("SW1:!4")    /* Carry Bowls to Next Life */
262   PORT_DIPSETTING(    0x00, DEF_STR( Easy ) )             /* not reset "ARABIAN" letters */
263   PORT_DIPSETTING(    0x08, DEF_STR( Hard ) )             /* reset "ARABIAN" letters */
264   PORT_DIPNAME( 0xf0, 0x00, DEF_STR( Coinage ) )          PORT_DIPLOCATION("SW1:!5,!6,!7,!8")
265265   PORT_DIPSETTING(    0x10, "A 2/1 B 2/1" )
266266   PORT_DIPSETTING(    0x20, "A 2/1 B 1/3" )
267267   PORT_DIPSETTING(    0x00, "A 1/1 B 1/1" )
r3514r3515
272272   PORT_DIPSETTING(    0x70, "A 1/1 B 1/6" )
273273   PORT_DIPSETTING(    0x80, "A 1/2 B 1/2" )
274274   PORT_DIPSETTING(    0x90, "A 1/2 B 1/4" )
275   PORT_DIPSETTING(    0xa0, "A 1/2 B 1/6" )
275   PORT_DIPSETTING(    0xa0, "A 1/2 B 1/5" )
276   PORT_DIPSETTING(    0xe0, "A 1/2 B 1/6" )
276277   PORT_DIPSETTING(    0xb0, "A 1/2 B 1/10" )
277278   PORT_DIPSETTING(    0xc0, "A 1/2 B 1/11" )
278279   PORT_DIPSETTING(    0xd0, "A 1/2 B 1/12" )
279   PORT_DIPSETTING(    0xf0, DEF_STR( Free_Play ))
280   /* 0xe0 gives A 1/2 B 1/6 */
280   PORT_DIPSETTING(    0xf0, DEF_STR( Free_Play ) )
281281
282282   PORT_START("COM0")
283283   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
284284   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_START1 )
285285   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_START2 )
286   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_COIN3 )      /* IN3 */
286   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_SERVICE1 )   /* IN3 : "AUX-S" */
287287
288288   PORT_START("COM1")
289289   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY
290   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY
291   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY
292   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY
290   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT )  PORT_8WAY
291   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP )    PORT_8WAY
292   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN )  PORT_8WAY
293293
294294   PORT_START("COM2")
295295   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 )
r3514r3515
299299
300300   PORT_START("COM3")
301301   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_COCKTAIL
302   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL
303   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_COCKTAIL
304   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL
302   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT )  PORT_8WAY PORT_COCKTAIL
303   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP )    PORT_8WAY PORT_COCKTAIL
304   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN )  PORT_8WAY PORT_COCKTAIL
305305
306306   PORT_START("COM4")
307307   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_COCKTAIL
r3514r3515
310310   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN )   /* IN19 */
311311
312312   PORT_START("COM5")
313   PORT_DIPNAME( 0x01, 0x01, "Coin Counters" )            PORT_DIPLOCATION("SW2:!1")
313   PORT_DIPNAME( 0x01, 0x01, "Coin Counters" )             PORT_DIPLOCATION("SW2:!1")
314314   PORT_DIPSETTING(    0x01, "1" )
315315   PORT_DIPSETTING(    0x00, "2" )
316   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds ))      PORT_DIPLOCATION("SW2:!2")
317   PORT_DIPSETTING(    0x02, DEF_STR( Off ))
318   PORT_DIPSETTING(    0x00, DEF_STR( On ))
319   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ))      PORT_DIPLOCATION("SW2:!3,!4")
320   PORT_DIPSETTING(    0x04, "20K" )
321   PORT_DIPSETTING(    0x08, "40K" )
322   PORT_DIPSETTING(    0x0c, "20K, 50K, 100K, Every 100K" )
316   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds ) )      PORT_DIPLOCATION("SW2:!2")
317   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
318   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
319   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )       PORT_DIPLOCATION("SW2:!3,!4")
320   PORT_DIPSETTING(    0x0c, "30k 70k 40k+" )              /* last bonus life at 870k : max. 22 bonus lives */
321   PORT_DIPSETTING(    0x04, "20k only" )
322   PORT_DIPSETTING(    0x08, "40k only" )
323323   PORT_DIPSETTING(    0x00, DEF_STR( None ) )
324324INPUT_PORTS_END
325325
326static INPUT_PORTS_START( arabiana )
327   PORT_INCLUDE( arabian )
326328
329   PORT_MODIFY("COM5")
330   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )       PORT_DIPLOCATION("SW2:!3,!4")
331   PORT_DIPSETTING(    0x0c, "20k 50k 150k 100k+" )        /* last bonus life at 850k : max. 10 bonus lives */
332   PORT_DIPSETTING(    0x04, "20k only" )
333   PORT_DIPSETTING(    0x08, "40k only" )
334   PORT_DIPSETTING(    0x00, DEF_STR( None ) )
335INPUT_PORTS_END
327336
337
338
328339/*************************************
329340 *
330341 *  Sound definitions
r3514r3515
437448 *
438449 *************************************/
439450
440GAME( 1983, arabian,  0,       arabian, arabian, arabian, ROT270, "Sun Electronics",                   "Arabian",         0 )
441GAME( 1983, arabiana, arabian, arabian, arabian, arabian, ROT270, "[Sun Electronics] (Atari license)", "Arabian (Atari)", 0 )
451GAME( 1983, arabian,  0,        arabian,  arabian,  arabian,  ROT270, "Sun Electronics",                   "Arabian",         0 )
452GAME( 1983, arabiana, arabian,  arabian,  arabiana, arabian,  ROT270, "[Sun Electronics] (Atari license)", "Arabian (Atari)", 0 )
src/mame/drivers/ambush.c
r3514r3515
9393   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
9494
9595   PORT_START("INPUTS")
96   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY
97   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY
98   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY
96   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )    PORT_8WAY
97   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )  PORT_8WAY
98   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )  PORT_8WAY
9999   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY
100   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_COCKTAIL
101   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL
102   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL
100   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )    PORT_8WAY PORT_COCKTAIL
101   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )  PORT_8WAY PORT_COCKTAIL
102   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )  PORT_8WAY PORT_COCKTAIL
103103   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_COCKTAIL
104104
105105   PORT_START("DSW1")
106   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) )         PORT_DIPLOCATION("SW1:1,2")
106   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) )            PORT_DIPLOCATION("SW1:1,2")
107107   PORT_DIPSETTING(    0x00, "3" )
108108   PORT_DIPSETTING(    0x01, "4" )
109109   PORT_DIPSETTING(    0x02, "5" )
110110   PORT_DIPSETTING(    0x03, "6" )
111   PORT_DIPNAME( 0x1c, 0x00, DEF_STR( Coinage ) )         PORT_DIPLOCATION("SW1:3,4,5")
112   PORT_DIPSETTING(    0x14, DEF_STR( 3C_1C ) )
111   PORT_DIPNAME( 0x1c, 0x00, DEF_STR( Coinage ) )          PORT_DIPLOCATION("SW1:3,4,5")
113112   PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) )
114113   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
114   PORT_DIPSETTING(    0x14, DEF_STR( 2C_3C ) )
115115   PORT_DIPSETTING(    0x04, DEF_STR( 1C_2C ) )
116116   PORT_DIPSETTING(    0x18, DEF_STR( 2C_5C ) )
117117   PORT_DIPSETTING(    0x08, DEF_STR( 1C_3C ) )
118118   PORT_DIPSETTING(    0x0c, DEF_STR( 1C_4C ) )
119119   PORT_DIPSETTING(    0x1c, "Service Mode/Free Play" )
120   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Difficulty ) )      PORT_DIPLOCATION("SW1:6")
120   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Difficulty ) )       PORT_DIPLOCATION("SW1:6")
121121   PORT_DIPSETTING(    0x00, DEF_STR( Easy ) )
122122   PORT_DIPSETTING(    0x20, DEF_STR( Hard ) )
123   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Bonus_Life ) )      PORT_DIPLOCATION("SW1:7")
123   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Bonus_Life ) )       PORT_DIPLOCATION("SW1:7")
124124   PORT_DIPSETTING(    0x40, "80000" )
125125   PORT_DIPSETTING(    0x00, "120000" )
126   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Cabinet ) )         PORT_DIPLOCATION("SW1:8")
126   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Cabinet ) )          PORT_DIPLOCATION("SW1:8")
127127   PORT_DIPSETTING(    0x80, DEF_STR( Upright ) )
128128   PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
129129INPUT_PORTS_END
130130
131static INPUT_PORTS_START( ambusht )
132   PORT_INCLUDE( ambush )
131133
134   PORT_MODIFY("DSW1")
135   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Allow_Continue ) )   PORT_DIPLOCATION("SW1:3")
136   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
137   PORT_DIPSETTING(    0x04, DEF_STR( Yes ) )
138   PORT_DIPNAME( 0x08, 0x00, "Service Mode/Free Play" )    PORT_DIPLOCATION("SW1:4")
139   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
140   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
141   PORT_DIPNAME( 0x10, 0x00, DEF_STR( Coinage ) )          PORT_DIPLOCATION("SW1:5")
142   PORT_DIPSETTING(    0x00, "A 1/1 B 1/2" )
143   PORT_DIPSETTING(    0x10, "A 2/1 B 1/3" )
144INPUT_PORTS_END
145
146
132147static const gfx_layout charlayout =
133148{
134149   8,8,    /* 8*8 chars */
r3514r3515
239254   ROM_LOAD( "14.bpr",        0x0300, 0x0100, CRC(622a8ce7) SHA1(6834f67874251f2ef3a33aec893311f5d10e496f) )  /* They don't look like color PROMs */
240255ROM_END
241256
242/* displays an M next to ROM 1 during the test, why? */
257/* displays an M next to ROM 1 during the test, why is internal cheksum wrong (0x02 instead of 0x00) ? */
243258ROM_START( ambusht )
244259   ROM_REGION( 0x10000, "main", 0 )
245260   ROM_LOAD( "a1.i7",    0x0000, 0x2000, CRC(a7cd149d) SHA1(470ebe60bc23a7908fb96caef8074d65f8c57625) )
r3514r3515
278293   ROM_LOAD( "14.bpr",        0x0300, 0x0100, CRC(622a8ce7) SHA1(6834f67874251f2ef3a33aec893311f5d10e496f) )  /* They don't look like color PROMs */
279294ROM_END
280295
281GAME( 1983, ambush, 0,      ambush, ambush, 0, ROT0, "Nippon Amuse Co-Ltd", "Ambush", 0 )
282GAME( 1983, ambusht,ambush, ambush, ambush, 0, ROT0, "Tecfri", "Ambush (Tecfri)", 0 )
283GAME( 1983, ambushv,ambush, ambush, ambush, 0, ROT0, "Volt Elec co-ltd", "Ambush (Volt Elec co-ltd)", 0 )
296GAME( 1983, ambush,   0,        ambush,   ambush,   0, ROT0, "Nippon Amuse Co-Ltd", "Ambush", 0 )
297GAME( 1983, ambushv,  ambush,   ambush,   ambush,   0, ROT0, "Volt Elec co-ltd", "Ambush (Volt Elec co-ltd)", 0 )
298GAME( 1983, ambusht,  ambush,   ambush,   ambusht,  0, ROT0, "Tecfri", "Ambush (Tecfri)", 0 )
src/mame/drivers/twins.c
r3514r3515
100100{
101101   int y,x,count;
102102   int i;
103   static int xxx=320,yyy=204;
103   static const int xxx=320,yyy=204;
104104
105105   fillbitmap(bitmap, get_black_pen(screen->machine), 0);
106106
r3514r3515
205205{
206206   int y,x,count;
207207   int i;
208   static int xxx=320,yyy=204;
208   static const int xxx=320,yyy=204;
209209
210210   fillbitmap(bitmap, get_black_pen(screen->machine), 0);
211211
src/mame/drivers/powerins.c
r3514r3515
488488
489489ROM_START( powerins )
490490   ROM_REGION( 0x100000, "main", 0 )      /* 68000 Code */
491   ROM_LOAD16_WORD_SWAP( "93095-3a.u108", 0x00000, 0x80000, CRC(9825ea3d) SHA1(567fd8e3d866a58a68608ea20c5d3fc16cf9f444) )
492   ROM_LOAD16_WORD_SWAP( "93095-4.u109",  0x80000, 0x80000, CRC(d3d7a782) SHA1(7846de0ebb09bd9b2534cd451ff9aa5175e60647) )
493
494   ROM_REGION( 0x20000, "sound", 0 )      /* Z80 Code */
495   ROM_LOAD( "93095-2.u90",  0x00000, 0x20000, CRC(4b123cc6) SHA1(ed61d3a2ab20c86b91fd7bafa717be3ce26159be) )
496
497   ROM_REGION( 0x280000, "gfx1", ROMREGION_DISPOSE )   /* Layer 0 */
498   ROM_LOAD( "93095-5.u16",  0x000000, 0x100000, CRC(b1371808) SHA1(15fca313314ff2e0caff35841a2fdda97f6235a8) )
499   ROM_LOAD( "93095-6.u17",  0x100000, 0x100000, CRC(29c85d80) SHA1(abd54f9c8bade21ea918a426627199da04193165) )
500   ROM_LOAD( "93095-7.u18",  0x200000, 0x080000, CRC(2dd76149) SHA1(975e4d371fdfbbd9a568da4d4c91ffd3f0ae636e) )
501
502   ROM_REGION( 0x100000, "gfx2", ROMREGION_DISPOSE )   /* Layer 1 */
503   ROM_LOAD( "93095-1.u15",  0x000000, 0x020000, CRC(6a579ee0) SHA1(438e87b930e068e0cf7352e614a14049ebde6b8a) )
504
505   ROM_REGION( 0x800000, "gfx3", ROMREGION_DISPOSE )   /* Sprites */
506   ROM_LOAD( "93095-12.u116", 0x000000, 0x100000, CRC(35f3c2a3) SHA1(70efebfe248401ba3d766dc0e4bcc2846cd0d9a0) )
507   ROM_LOAD( "93095-13.u117", 0x100000, 0x100000, CRC(1ebd45da) SHA1(99b0ac734890673064b2a4b4b57ff2694e338dea) )
508   ROM_LOAD( "93095-14.u118", 0x200000, 0x100000, CRC(760d871b) SHA1(4887122ad0518c90f08c11a7a6b694f3fd218498) )
509   ROM_LOAD( "93095-15.u119", 0x300000, 0x100000, CRC(d011be88) SHA1(837409a2584abdf22e022b0f06181a600a974cbe) )
510   ROM_LOAD( "93095-16.u120", 0x400000, 0x100000, CRC(a9c16c9c) SHA1(a34e81324c875c2a57f778d1dbdda8da81850a29) )
511   ROM_LOAD( "93095-17.u121", 0x500000, 0x100000, CRC(51b57288) SHA1(821473d51565bc0a8b9a979723ce1307b97e517e) )
512   ROM_LOAD( "93095-18.u122", 0x600000, 0x100000, CRC(b135e3f2) SHA1(339fb4007ca0f379b7554a1c4f711f494a371fb2) )
513   ROM_LOAD( "93095-19.u123", 0x700000, 0x100000, CRC(67695537) SHA1(4c78ce3e36f27d2a6a9e50e8bf896335d4d0958a) )
514
515   ROM_REGION( 0x240000, "oki1", 0 )   /* 8 bit adpcm (banked) */
516   ROM_LOAD( "93095-10.u48", 0x040000, 0x100000, CRC(329ac6c5) SHA1(e809b94e2623141f5a48995cfa97fe1ead7ab40b) )
517   ROM_LOAD( "93095-11.u49", 0x140000, 0x100000, CRC(75d6097c) SHA1(3c89a7c9b12087e2d969b822419d3e5f98f5cb1d) )
518
519   ROM_REGION( 0x240000, "oki2", 0 )   /* 8 bit adpcm (banked) */
520   ROM_LOAD( "93095-8.u46",  0x040000, 0x100000, CRC(f019bedb) SHA1(4b6e10f85671c75b666e547887d403d6e607cec8) )
521   ROM_LOAD( "93095-9.u47",  0x140000, 0x100000, CRC(adc83765) SHA1(9e760443f9de21c1bb7e33eaa1541023fcdc60ab) )
522
523   ROM_REGION( 0x0220, "proms", 0 )      /* unknown */
524   ROM_LOAD( "22.u81",       0x000000, 0x0020, CRC(67d5ec4b) SHA1(87d32948a0c88277dcdd0eaa035bde40fc7db5fe) )
525   ROM_LOAD( "21.u71",       0x000020, 0x0100, CRC(182cd81f) SHA1(3a76bea81b34ea7ccf56044206721058aa5b03e6) )
526   ROM_LOAD( "20.u54",       0x000100, 0x0100, CRC(38bd0e2f) SHA1(20d311869642cd96bb831fdf4a458e0d872f03eb) )
527ROM_END
528
529ROM_START( powerinj )
530   ROM_REGION( 0x100000, "main", 0 )      /* 68000 Code */
491531   ROM_LOAD16_WORD_SWAP( "93095-3j.u108", 0x00000, 0x80000, CRC(3050a3fb) SHA1(e7e729bf62266e2e78ccd84cf937abb99de18ad5) )
492532   ROM_LOAD16_WORD_SWAP( "93095-4.u109",  0x80000, 0x80000, CRC(d3d7a782) SHA1(7846de0ebb09bd9b2534cd451ff9aa5175e60647) )
493533
r3514r3515
685725
686726
687727/* all supported sets give a 93.10.20 date */
688GAME( 1993, powerins, 0,        powerins, powerinj, 0, ROT0, "Atlus", "Gouketsuji Ichizoku (Japan)", 0 )
728GAME( 1993, powerins, 0,        powerins, powerins, 0, ROT0, "Atlus", "Power Instinct (USA)", 0 )
729GAME( 1993, powerinj, powerins, powerins, powerinj, 0, ROT0, "Atlus", "Gouketsuji Ichizoku (Japan)", 0 )
689730GAME( 1993, powerina, powerins, powerina, powerins, 0, ROT0, "Atlus", "Power Instinct (USA, bootleg set 1)", 0 )
690731GAME( 1993, powerinb, powerins, powerinb, powerins, 0, ROT0, "Atlus", "Power Instinct (USA, bootleg set 2)", 0 )
src/mame/drivers/megadriv.c
r3514r3515
9494static int _32x_slave_cpu_number;
9595static int _32x_is_connected;
9696
97static int sh2_are_running;
98static int _32x_adapter_enabled;
99static int _32x_access_auth;
100static int _32x_screenshift;
101
102static int sh2_master_vint_enable, sh2_slave_vint_enable;
103static int sh2_master_hint_enable, sh2_slave_hint_enable;
104static int sh2_master_cmdint_enable, sh2_slave_cmdint_enable;
105static int sh2_master_pwmint_enable, sh2_slave_pwnint_enable;
106
107
108#define SH2_VRES_IRQ_LEVEL 14
109#define SH2_VINT_IRQ_LEVEL 12
110#define SH2_HINT_IRQ_LEVEL 10
111#define SH2_CINT_IRQ_LEVEL 8
112#define SH2_PINT_IRQ_LEVEL 6
113
114
97115static UINT16* _32x_dram0;
98116static UINT16* _32x_dram1;
99117static UINT16 *_32x_display_dram, *_32x_access_dram;
r3514r3515
107125
108126static int _genesis_snd_z80_cpu_number;
109127
110int segac2_bg_pal_lookup[4] = { 0x00, 0x10, 0x20, 0x30 };
111int segac2_sp_pal_lookup[4] = { 0x00, 0x10, 0x20, 0x30 };
128int segac2_bg_pal_lookup[4];
129int segac2_sp_pal_lookup[4];
112130
113131// hacks for C2
114int genvdp_use_cram = 1; // c2 uses it's own palette ram
132int genvdp_use_cram = 0; // c2 uses it's own palette ram
115133int genesis_has_z80;
116134int genesis_always_irq6 = 0; // c2 never enables the irq6, different source??
117int genesis_other_hacks = 1; // misc hacks
135int genesis_other_hacks = 0; // misc hacks
118136
119137INLINE UINT16 get_hposition(void);
120138
r3514r3515
25072525/****************************************** 32X related ******************************************/
25082526
25092527
2528
2529static READ16_HANDLER( _32x_68k_palette_r )
2530{
2531   return _32x_palette[offset];
2532}
2533
2534static WRITE16_HANDLER( _32x_68k_palette_w )
2535{
2536   int r,g,b, p;
2537
2538   COMBINE_DATA(&_32x_palette[offset]);
2539   data = _32x_palette[offset];
2540
2541   r = ((data >> 0)  & 0x1f);
2542   g = ((data >> 5)  & 0x1f);
2543   b = ((data >> 10) & 0x1f);
2544   p = ((data >> 15) & 0x01); // priority 'through' bit
2545
2546   _32x_palette_lookup[offset] = (r << 10) | (g << 5) | (b << 0);
2547
2548   palette_set_color_rgb(Machine,offset+0x40,pal5bit(r),pal5bit(g),pal5bit(b));
2549
2550}
2551
2552static WRITE32_HANDLER( _32x_sh2_palette_w)
2553{
2554
2555   if (ACCESSING_BITS_16_31)
2556   {
2557      _32x_68k_palette_w(machine,offset*2,(data>>16)&0xffff,(mem_mask>>16)&0xffff);
2558   }
2559
2560   if (ACCESSING_BITS_0_15)
2561   {
2562      _32x_68k_palette_w(machine,offset*2+1,(data>>0)&0xffff,(mem_mask>>0)&0xffff);
2563   }
2564}
2565
2566
2567static READ16_HANDLER( _32x_68k_dram_r )
2568{
2569   return _32x_access_dram[offset];
2570}
2571
2572static WRITE16_HANDLER( _32x_68k_dram_w )
2573{
2574   COMBINE_DATA(&_32x_access_dram[offset]);
2575}
2576
2577
2578static WRITE32_HANDLER( _32x_sh2_dram_w)
2579{
2580
2581   if (ACCESSING_BITS_16_31)
2582   {
2583      _32x_68k_dram_w(machine,offset*2,(data>>16)&0xffff,(mem_mask>>16)&0xffff);
2584   }
2585
2586   if (ACCESSING_BITS_0_15)
2587   {
2588      _32x_68k_dram_w(machine,offset*2+1,(data>>0)&0xffff,(mem_mask>>0)&0xffff);
2589   }
2590}
2591
2592
2593static WRITE16_HANDLER( _32x_68k_dram_overwrite_w )
2594{
2595   if (ACCESSING_BITS_8_15)
2596   {
2597      if (data & 0xff00)
2598      {
2599         _32x_access_dram[offset] = (_32x_access_dram[offset]&0x00ff) | (data & 0xff00);
2600      }
2601   }
2602
2603   if (ACCESSING_BITS_0_7)
2604   {
2605      if (data & 0x00ff)
2606      {
2607         _32x_access_dram[offset] = (_32x_access_dram[offset]&0xff00) | (data & 0x00ff);
2608      }
2609   }
2610}
2611
2612static WRITE32_HANDLER( _32x_sh2_dram_overwrite_w )
2613{
2614   if (ACCESSING_BITS_16_31)
2615   {
2616      _32x_68k_dram_overwrite_w(machine,offset*2,(data>>16)&0xffff,(mem_mask>>16)&0xffff);
2617   }
2618
2619   if (ACCESSING_BITS_0_15)
2620   {
2621      _32x_68k_dram_overwrite_w(machine,offset*2+1,(data>>0)&0xffff,(mem_mask>>0)&0xffff);
2622   }
2623}
2624
2625
2626
2627static READ32_HANDLER( _32x_sh2_dram_r )
2628{
2629   UINT32 retvalue = 0x00000000;
2630
2631   if (ACCESSING_BITS_16_31) // 4108
2632   {
2633      UINT16 ret = 0x0000;
2634      ret = _32x_68k_dram_r(machine,offset*2,(mem_mask>>16)&0xffff);
2635      retvalue |= ret << 16;
2636   }
2637
2638   if (ACCESSING_BITS_0_15) // 4108
2639   {
2640      UINT16 ret = 0x0000;
2641      ret = _32x_68k_dram_r(machine,offset*2+1,(mem_mask>>0)&0xffff);
2642      retvalue |= ret << 0;
2643   }
2644
2645   return retvalue;
2646}
2647
2648
2649/*
2650a1518a / 410a
2651
2652vhp- ---- ---- --fb
2653
2654v = 1=vblank   r/o
2655h = 1=hblank   r/o
2656p = 0=palette access approval   r/o
2657- = unused
2658f = 0=MD framebuffer access, 1 = SH2   r/o
2659b = 0=DRAM0 accessed by VDP, 1=DRAM1   r/w
2660*/
2661static UINT16 _32x_a1518a_reg;
2662static READ16_HANDLER( _32x_68k_fbcontrol_r )
2663{
2664   UINT16 retdata = _32x_a1518a_reg;
2665   UINT16 hpos = get_hposition();
2666   int megadrive_hblank_flag = 0;
2667
2668   if (megadrive_vblank_flag) retdata |= 0x8000;
2669
2670   if (hpos>400) megadrive_hblank_flag = 1;
2671   if (hpos>460) megadrive_hblank_flag = 0;
2672
2673   if (megadrive_hblank_flag) retdata |= 0x4000;
2674
2675//  printf("_32x_68k_fbcontrol_r\n");
2676
2677
2678   return retdata;
2679}
2680
2681static WRITE16_HANDLER( _32x_68k_fbcontrol_w )
2682{
2683   // bit 0 is the framebuffer select;
2684   _32x_a1518a_reg = (_32x_a1518a_reg & 0xfffe) | (data & 1);
2685
2686   if (_32x_a1518a_reg & 1)
2687   {
2688      _32x_access_dram = _32x_dram0;
2689      _32x_display_dram = _32x_dram1;
2690   }
2691   else
2692   {
2693      _32x_display_dram = _32x_dram0;
2694      _32x_access_dram = _32x_dram1;
2695   }
2696}
2697
2698
2699static READ32_HANDLER( sh2_4108_410a_r )
2700{
2701   UINT32 retvalue = 0x00000000;
2702   if (ACCESSING_BITS_16_31) // 4108
2703   {
2704      UINT16 ret = 0x0000;
2705      printf("sh2 read access 4108\n");
2706      retvalue |= (ret << 16);
2707   }
2708   if (ACCESSING_BITS_0_15) // 410a
2709   {
2710      UINT16 ret = 0x0000;
2711      ret = _32x_68k_fbcontrol_r(machine, offset*2+1, mem_mask);
2712      retvalue |= ret;
2713
2714   }
2715   return retvalue;
2716}
2717
2718
2719static WRITE32_HANDLER( sh2_4108_410a_w )
2720{
2721   if (ACCESSING_BITS_16_31) // 4108
2722   {
2723      printf("sh2 write access 4108\n");
2724   }
2725   if (ACCESSING_BITS_0_15) // 410a
2726   {
2727      _32x_68k_fbcontrol_w(machine,offset*2+1,(data>>0)&0xffff,(mem_mask>>0)&0xffff);
2728   }
2729}
2730
2731static READ16_HANDLER( _32x_4100_r )
2732{
2733   return 0x0000;
2734}
2735
2736static READ16_HANDLER( _32x_4102_r )
2737{
2738   return 0x0000;
2739}
2740
2741static READ32_HANDLER( sh2_4100_4102_r )
2742{
2743   UINT32 retvalue = 0x00000000;
2744   if (ACCESSING_BITS_16_31) // 4100
2745   {
2746      UINT16 ret = 0x0000;
2747      ret = _32x_4100_r(machine, offset*2, mem_mask>>16);
2748      retvalue |= (ret << 16);
2749   }
2750   if (ACCESSING_BITS_0_15) // 4102
2751   {
2752      UINT16 ret = 0x0000;
2753      ret = _32x_4102_r(machine, offset*2+1, mem_mask);
2754      retvalue |= ret;
2755
2756   }
2757   return retvalue;
2758}
2759
2760
2761static WRITE16_HANDLER( _32x_4100_w )
2762{
2763
2764}
2765
2766static WRITE16_HANDLER( _32x_4102_w )
2767{
2768   _32x_screenshift = data & 1; // allows 1 pixel shifting
2769   //printf("screenshift %d\n",_32x_screenshift);
2770}
2771
2772static WRITE32_HANDLER( sh2_4100_4102_w )
2773{
2774   if (ACCESSING_BITS_16_31) // 4100
2775   {
2776      _32x_4100_w(machine,offset*2,(data>>16)&0xffff,(mem_mask>>16)&0xffff);
2777   }
2778   if (ACCESSING_BITS_0_15) // 4102
2779   {
2780      _32x_4102_w(machine,offset*2+1,(data>>0)&0xffff,(mem_mask>>0)&0xffff);
2781   }
2782}
2783
2784
25102785static ADDRESS_MAP_START( sh2_main_map, ADDRESS_SPACE_PROGRAM, 32 )
2511   AM_RANGE(0x0000000 , 0x0003fff) AM_ROM
2786   AM_RANGE(0x00000000, 0x00003fff) AM_ROM
2787
2788   AM_RANGE(0x00004100, 0x00004103) AM_READWRITE( sh2_4100_4102_r, sh2_4100_4102_w )
2789   AM_RANGE(0x00004108, 0x0000410b) AM_READWRITE( sh2_4108_410a_r, sh2_4108_410a_w )
2790
2791   AM_RANGE(0x00004200, 0x000043ff) AM_WRITE(_32x_sh2_palette_w)
2792   AM_RANGE(0x04000000, 0x0401ffff) AM_READWRITE(_32x_sh2_dram_r, _32x_sh2_dram_w)
2793   AM_RANGE(0x04020000, 0x0403ffff) AM_WRITE(_32x_sh2_dram_overwrite_w)
2794
2795   AM_RANGE(0x06000000, 0x0603ffff) AM_RAM AM_SHARE(10)
2796   AM_RANGE(0x02000000, 0x023fffff) AM_ROM AM_REGION("gamecart_sh2", 0)
2797
2798   AM_RANGE(0xc0000000, 0xc00003ff) AM_RAM
25122799ADDRESS_MAP_END
25132800
25142801static ADDRESS_MAP_START( sh2_slave_map, ADDRESS_SPACE_PROGRAM, 32 )
2515   AM_RANGE(0x0000000 , 0x0003fff) AM_ROM
2802   AM_RANGE(0x00000000, 0x00003fff) AM_ROM
2803
2804   AM_RANGE(0x00004108, 0x0000410b) AM_READWRITE( sh2_4108_410a_r, sh2_4108_410a_w )
2805
2806   AM_RANGE(0x00004200, 0x000043ff) AM_WRITE(_32x_sh2_palette_w)
2807   AM_RANGE(0x04000000, 0x0401ffff) AM_READWRITE(_32x_sh2_dram_r, _32x_sh2_dram_w)
2808   AM_RANGE(0x04020000, 0x0403ffff) AM_WRITE(_32x_sh2_dram_overwrite_w)
2809
2810   AM_RANGE(0x06000000, 0x0603ffff) AM_RAM AM_SHARE(10)
2811   AM_RANGE(0x02000000, 0x023fffff) AM_ROM AM_REGION("gamecart_sh2", 0)
2812
2813   AM_RANGE(0xc0000000, 0xc00003ff) AM_RAM
25162814ADDRESS_MAP_END
25172815
25182816static ADDRESS_MAP_START( segacd_map, ADDRESS_SPACE_PROGRAM, 16 )
r3514r3515
43404638   if (_32x_is_connected)
43414639   {
43424640      UINT32 lineoffs;
4641      int start;
4642
43434643      lineoffs = _32x_display_dram[scanline];
43444644
4345      for (x=0;x<320;x++)
4645      if (_32x_screenshift == 0) start=0;
4646      else start = -1;
4647
4648      for (x=start;x<320;x++)
43464649      {
43474650         UINT16 coldata;
43484651         coldata = _32x_display_dram[lineoffs];
43494652
43504653         {
4351            if  ((_32x_palette[(coldata & 0xff00)>>8] & 0x8000)==0x8000)
4352               lineptr[x] = _32x_palette_lookup[(coldata & 0xff00)>>8];
4654            if (x>=0)
4655               if  ((_32x_palette[(coldata & 0xff00)>>8] & 0x8000)==0x8000)
4656                  lineptr[x] = _32x_palette_lookup[(coldata & 0xff00)>>8];
43534657
43544658            x++;
43554659
4356            if  ((_32x_palette[(coldata & 0x00ff)>>0] & 0x8000)==0x8000)
4357               lineptr[x] = _32x_palette_lookup[(coldata & 0x00ff)];
4660            if (x>=0)
4661               if  ((_32x_palette[(coldata & 0x00ff)>>0] & 0x8000)==0x8000)
4662                  lineptr[x] = _32x_palette_lookup[(coldata & 0x00ff)];
43584663         }
43594664
43604665         lineoffs++;
r3514r3515
47065011         timer_adjust_oneshot(irq6_on_timer,  ATTOTIME_IN_USEC(6), 0);
47075012         megadrive_irq6_pending = 1;
47085013         megadrive_vblank_flag = 1;
5014
5015         // 32x interrupt!
5016         if (_32x_is_connected)
5017         {
5018            if (sh2_master_vint_enable) cpunum_set_input_line(machine,  _32x_master_cpu_number,SH2_VINT_IRQ_LEVEL,ASSERT_LINE);
5019            if (sh2_slave_vint_enable) cpunum_set_input_line(machine,  _32x_slave_cpu_number,SH2_VINT_IRQ_LEVEL,ASSERT_LINE);
5020         }
5021
47095022      }
47105023
47115024      if (megadrive_vblank_flag>=224)
r3514r3515
48725185   if (_32x_master_cpu_number != -1)
48735186   {
48745187      cpunum_set_input_line(machine, _32x_master_cpu_number, INPUT_LINE_RESET, ASSERT_LINE);
4875      cpunum_set_input_line(machine, _32x_master_cpu_number, INPUT_LINE_HALT, ASSERT_LINE);
48765188   }
48775189
48785190   if (_32x_slave_cpu_number != -1)
48795191   {
48805192      cpunum_set_input_line(machine, _32x_slave_cpu_number, INPUT_LINE_RESET, ASSERT_LINE);
4881      cpunum_set_input_line(machine, _32x_slave_cpu_number, INPUT_LINE_HALT, ASSERT_LINE);
48825193   }
48835194
48845195   if (_segacd_68k_cpu_number != -1 )
r3514r3515
51845495   MDRV_CPU_ADD("32x_slave_sh2", SH2, (MASTER_CLOCK_NTSC*3)/7 )
51855496   MDRV_CPU_PROGRAM_MAP(sh2_slave_map, 0)
51865497   MDRV_CPU_CONFIG(sh2_conf_slave)
5498
51875499MACHINE_DRIVER_END
51885500
51895501MACHINE_DRIVER_START( genesis_scd )
r3514r3515
54355747// these are tests for 'special case' hardware to make sure I don't break anything while rearranging things
54365748//
54375749
5438/*
5439a1518a / 410a
5750static UINT16 _32x_autofill_length;
5751static UINT16 _32x_autofill_address;
5752static UINT16 _32x_autofill_data;
54405753
5441vhp- ---- ---- --fb
5754static UINT16 _32x_a15104;
54425755
5443v = 1=vblank   r/o
5444h = 1=hblank   r/o
5445p = 0=palette access approval   r/o
5446- = unused
5447f = 0=MD framebuffer access, 1 = SH2   r/o
5448b = 0=DRAM0 accessed by VDP, 1=DRAM1   r/w
5449*/
5450static UINT16 _32x_a1518a_reg;
5451static READ16_HANDLER( _32x_68k_fbcontrol_r )
5452{
5756// 4014 VRES IRQ Clear Register
5757static WRITE16_HANDLER( sh2_master_4014_w ){cpunum_set_input_line(machine,  _32x_master_cpu_number,SH2_VRES_IRQ_LEVEL,CLEAR_LINE);}
5758static WRITE16_HANDLER( sh2_slave_4014_w ) { cpunum_set_input_line(machine, _32x_slave_cpu_number, SH2_VRES_IRQ_LEVEL,CLEAR_LINE);}
5759// 4016 VINT IRQ Clear Register
5760static WRITE16_HANDLER( sh2_master_4016_w ){cpunum_set_input_line(machine,  _32x_master_cpu_number,SH2_VINT_IRQ_LEVEL,CLEAR_LINE);}
5761static WRITE16_HANDLER( sh2_slave_4016_w ) { cpunum_set_input_line(machine, _32x_slave_cpu_number, SH2_VINT_IRQ_LEVEL,CLEAR_LINE);}
5762// 4018 HINT IRQ Clear Register
5763static WRITE16_HANDLER( sh2_master_4018_w ){ cpunum_set_input_line(machine, _32x_master_cpu_number,SH2_HINT_IRQ_LEVEL,CLEAR_LINE);}
5764static WRITE16_HANDLER( sh2_slave_4018_w ) { cpunum_set_input_line(machine, _32x_slave_cpu_number, SH2_HINT_IRQ_LEVEL,CLEAR_LINE);}
5765// 401A CMD IRQ Clear Register
5766static WRITE16_HANDLER( sh2_master_401a_w ){ cpunum_set_input_line(machine, _32x_master_cpu_number,SH2_CINT_IRQ_LEVEL,CLEAR_LINE);}
5767static WRITE16_HANDLER( sh2_slave_401a_w ) { cpunum_set_input_line(machine, _32x_slave_cpu_number, SH2_CINT_IRQ_LEVEL,CLEAR_LINE);}
5768// 401C PWM IRQ Clear Register
5769static WRITE16_HANDLER( sh2_master_401c_w ){ cpunum_set_input_line(machine, _32x_master_cpu_number,SH2_PINT_IRQ_LEVEL,CLEAR_LINE);}
5770static WRITE16_HANDLER( sh2_slave_401c_w ) { cpunum_set_input_line(machine, _32x_slave_cpu_number, SH2_PINT_IRQ_LEVEL,CLEAR_LINE);}
54535771
5454   UINT16 retdata = _32x_a1518a_reg;
5455   UINT16 hpos = get_hposition();
5456   int megadrive_hblank_flag = 0;
54575772
5458   if (megadrive_vblank_flag) retdata |= 0x8000;
5773static READ32_HANDLER( sh2_master_4014_4016_r )
5774{
5775   if (ACCESSING_BITS_16_31)
5776   {
5777      sh2_master_4014_w(machine,offset*2,(0x0000>>16)&0xffff,(mem_mask>>16)&0xffff);
5778   }
54595779
5460   if (hpos>400) megadrive_hblank_flag = 1;
5461   if (hpos>460) megadrive_hblank_flag = 0;
5780   if (ACCESSING_BITS_0_15)
5781   {
5782      sh2_master_4016_w(machine,offset*2+1,(0x0000>>0)&0xffff,(mem_mask>>0)&0xffff);
5783   }
54625784
5463   if (megadrive_hblank_flag) retdata |= 0x4000;
5464
5465   return retdata;
5785   return 0x0000;
54665786}
54675787
5468static WRITE16_HANDLER( _32x_68k_fbcontrol_w )
5788static WRITE32_HANDLER( sh2_master_4014_4016_w )
54695789{
5470   // bit 0 is the framebuffer select;
5471   _32x_a1518a_reg = (_32x_a1518a_reg & 0xfffe) | (data & 1);
5790   if (ACCESSING_BITS_16_31)
5791   {
5792      sh2_master_4014_w(machine,offset*2,(data>>16)&0xffff,(mem_mask>>16)&0xffff);
5793   }
54725794
5473   if (_32x_a1518a_reg & 1)
5795   if (ACCESSING_BITS_0_15)
54745796   {
5475      _32x_access_dram = _32x_dram0;
5476      _32x_display_dram = _32x_dram1;
5797      sh2_master_4016_w(machine,offset*2+1,(data>>0)&0xffff,(mem_mask>>0)&0xffff);
54775798   }
5478   else
5799}
5800
5801static WRITE32_HANDLER( sh2_slave_4014_4016_w )
5802{
5803   if (ACCESSING_BITS_16_31)
54795804   {
5480      _32x_display_dram = _32x_dram0;
5481      _32x_access_dram = _32x_dram1;
5805      sh2_slave_4014_w(machine,offset*2,(data>>16)&0xffff,(mem_mask>>16)&0xffff);
54825806   }
54835807
5808   if (ACCESSING_BITS_0_15)
5809   {
5810      sh2_slave_4016_w(machine,offset*2+1,(data>>0)&0xffff,(mem_mask>>0)&0xffff);
5811   }
54845812}
54855813
5814static WRITE32_HANDLER( sh2_master_4018_401a_w )
5815{
5816   if (ACCESSING_BITS_16_31)
5817   {
5818      printf("master 4018\n");
5819      sh2_master_4018_w(machine,offset*2,(data>>16)&0xffff,(mem_mask>>16)&0xffff);
5820   }
54865821
5822   if (ACCESSING_BITS_0_15)
5823   {
5824      printf("master 401a\n");
54875825
5826      sh2_master_401a_w(machine,offset*2+1,(data>>0)&0xffff,(mem_mask>>0)&0xffff);
5827   }
5828}
54885829
5830static WRITE32_HANDLER( sh2_slave_4018_401a_w )
5831{
5832   if (ACCESSING_BITS_16_31)
5833   {
5834      printf("slave 4018\n");
5835      sh2_slave_4018_w(machine,offset*2,(data>>16)&0xffff,(mem_mask>>16)&0xffff);
5836   }
54895837
5490static READ16_HANDLER( _32x_68k_dram_r )
5838   if (ACCESSING_BITS_0_15)
5839   {
5840      printf("slave 401a\n");
5841      sh2_slave_401a_w(machine,offset*2+1,(data>>0)&0xffff,(mem_mask>>0)&0xffff);
5842   }
5843}
5844
5845static WRITE32_HANDLER( sh2_master_401c_401e_w )
54915846{
5492   return _32x_access_dram[offset];
5847   if (ACCESSING_BITS_16_31)
5848   {
5849      sh2_master_401c_w(machine,offset*2,(data>>16)&0xffff,(mem_mask>>16)&0xffff);
5850   }
5851
5852   if (ACCESSING_BITS_0_15)
5853   {
5854      printf("401e master write?! %08x %08x\n",data,mem_mask);
5855   }
54935856}
54945857
5495static WRITE16_HANDLER( _32x_68k_dram_w )
5858static WRITE32_HANDLER( sh2_slave_401c_401e_w )
54965859{
5497   COMBINE_DATA(&_32x_access_dram[offset]);
5860   if (ACCESSING_BITS_16_31)
5861   {
5862      sh2_slave_401c_w(machine,offset*2,(data>>16)&0xffff,(mem_mask>>16)&0xffff);
5863   }
5864
5865   if (ACCESSING_BITS_0_15)
5866   {
5867      printf("401e slave write?! %08x %08x\n",data,mem_mask);
5868   }
54985869}
5870/*
54995871
5500static READ16_HANDLER( _32x_68k_palette_r )
5872-------------------------------------------------------------------------------------------------
58734000  (sh2 side)
5874-------------------------------------------------------------------------------------------------
5875
5876f--- --ec h--- VHCP
5877
5878f = framebuffer permission (0 md, 1 sh2)
5879e = Adapter enabled (0 no, 1 yes)
5880c = Cart Inserted (0 yes, 1 no)
5881h = H Interrupt allowed within Vblank (0 no, 1 yes)
5882
5883*** these are independent for each SH2 ***
5884V = V Interrupt Mask (0 masked, 1 allowed)
5885H = H Interrupt Mask (0 masked, 1 allowed)
5886C = Command Interrupt Mask (0 masked, 1 allowed)
5887P = PWM Interrupt Mask (0 masked, 1 allowed)
5888
5889-------------------------------------------------------------------------------------------------
58904002 Stand By Change Register
5891-------------------------------------------------------------------------------------------------
5892
5893Write Only
5894Prohibited from Application
5895
5896-------------------------------------------------------------------------------------------------
58974004 H Count Register (H Interrupt)
5898-------------------------------------------------------------------------------------------------
58990 = every line
5900
5901-------------------------------------------------------------------------------------------------
59024006 DReq Control Register
5903-------------------------------------------------------------------------------------------------
5904
5905-------------------------------------------------------------------------------------------------
59064008 68k To SH2 DReq Source Address Register ( High Bits )
5907-------------------------------------------------------------------------------------------------
5908
5909-------------------------------------------------------------------------------------------------
5910400A 68k To SH2 DReq Source Address Register ( Low Bits )
5911-------------------------------------------------------------------------------------------------
5912
5913-------------------------------------------------------------------------------------------------
5914400C 68k To SH2 DReq Destination Address Register ( High Bits )
5915-------------------------------------------------------------------------------------------------
5916
5917-------------------------------------------------------------------------------------------------
5918400E 68k To SH2 DReq Destination Address Register ( Low Bits )
5919-------------------------------------------------------------------------------------------------
5920
5921-------------------------------------------------------------------------------------------------
59224010 68k To SH2 DReq Length Register
5923-------------------------------------------------------------------------------------------------
5924
5925-------------------------------------------------------------------------------------------------
59264012 FIFO Register
5927-------------------------------------------------------------------------------------------------
5928
5929-------------------------------------------------------------------------------------------------
59304014 VRES IRQ Clear Register
5931-------------------------------------------------------------------------------------------------
5932Clears Interrupt which is caused by pressing RESET button
5933
5934-------------------------------------------------------------------------------------------------
59354016 VINT IRQ Clear Register
5936-------------------------------------------------------------------------------------------------
5937Clears Vertical Blank Interrupt
5938
5939-------------------------------------------------------------------------------------------------
59404018 HINT IRQ Clear Register
5941-------------------------------------------------------------------------------------------------
5942Clears Horizontal Blank Interrupt
5943
5944-------------------------------------------------------------------------------------------------
5945401A CMD IRQ Clear Register
5946-------------------------------------------------------------------------------------------------
5947Clears 'Command' Interrupt
5948
5949-------------------------------------------------------------------------------------------------
5950401C PWM IRQ Clear Register
5951-------------------------------------------------------------------------------------------------
5952Clears 'PWM' (Sound / Timer) Interrupt
5953
5954-------------------------------------------------------------------------------------------------
5955401E ??????????????????????
5956-------------------------------------------------------------------------------------------------
5957
5958-------------------------------------------------------------------------------------------------
59594020 Comms Reg 1
5960------------------------------------------------------------------------------------------------
59614022 Comms Reg 2
5962------------------------------------------------------------------------------------------------
59634024 Comms Reg 3
5964------------------------------------------------------------------------------------------------
59654026 Comms Reg 4
5966------------------------------------------------------------------------------------------------
59674028 Comms Reg 5
5968------------------------------------------------------------------------------------------------
5969402A Comms Reg 6
5970------------------------------------------------------------------------------------------------
5971402C Comms Reg 7
5972------------------------------------------------------------------------------------------------
5973402E Comms Reg 8
5974------------------------------------------------------------------------------------------------
5975
5976------------------------------------------------------------------------------------------------
59774030 PWM Control Register
5978------------------------------------------------------------------------------------------------
5979
5980------------------------------------------------------------------------------------------------
59814032 Cycle Register
5982------------------------------------------------------------------------------------------------
5983
5984------------------------------------------------------------------------------------------------
59854034 LCH Pulse Width Register
5986------------------------------------------------------------------------------------------------
5987
5988------------------------------------------------------------------------------------------------
59894036 RCH Pulse Width Register
5990------------------------------------------------------------------------------------------------
5991
5992------------------------------------------------------------------------------------------------
59934038 Mono Pulse Width Register
5994------------------------------------------------------------------------------------------------
5995
5996
5997------------------------------------------------------------------------------------------------
59984100 Bitmap Mode Register
5999------------------------------------------------------------------------------------------------
6000
6001------------------------------------------------------------------------------------------------
60024102 Screen Shift Control Register
6003------------------------------------------------------------------------------------------------
6004
6005------------------------------------------------------------------------------------------------
60064104 Auto Fill Length Register
6007------------------------------------------------------------------------------------------------
6008
6009------------------------------------------------------------------------------------------------
60104106 Auto Fill Start Address Register
6011------------------------------------------------------------------------------------------------
6012
6013------------------------------------------------------------------------------------------------
60144108 Auto Fill Data Register
6015------------------------------------------------------------------------------------------------
6016
6017------------------------------------------------------------------------------------------------
6018410A Frame Buffer Control Register
6019------------------------------------------------------------------------------------------------
6020
6021
6022*/
6023
6024
6025/*
6026
602715106 DREQ
6028
6029 ---- ---- F--- -K0R
6030
6031 F = Fifo FULL
6032 K = 68k CPU Write mode (0 = no, 1 = CPU write)
6033 0 = always 0
6034 R = RV (0 = no operation, 1 = DMA Start allowed)
6035
6036*/
6037
6038static UINT16 a15106_reg;
6039
6040
6041static READ16_HANDLER( _32x_68k_a15106_r)
55016042{
5502   return _32x_palette[offset];
6043   UINT16 retval;
6044
6045   retval = a15106_reg;
6046
6047   //if (fifo_full) retval |= 0x0080;
6048
6049   return retval;
55036050}
55046051
5505static WRITE16_HANDLER( _32x_68k_palette_w )
6052static WRITE16_HANDLER( _32x_68k_a15106_w )
55066053{
5507   int r,g,b, p;
6054   if (ACCESSING_BITS_0_7)
6055   {
6056      a15106_reg = data & 0x5;
6057      printf("_32x_68k_a15106_w %04x\n", data);
55086058
5509   COMBINE_DATA(&_32x_palette[offset]);
5510   data = _32x_palette[offset];
6059      if (a15106_reg & 0x4)
6060         printf(" --- 68k Write Mode enabled\n");
6061      else
6062         printf(" --- 68k Write Mode disabled\n");
55116063
5512   r = ((data >> 0)  & 0x1f);
5513   g = ((data >> 5)  & 0x1f);
5514   b = ((data >> 10) & 0x1f);
5515   p = ((data >> 15) & 0x01); // priority 'through' bit
6064      if (a15106_reg & 0x1)
6065         printf(" --- DMA Start Allowed \n");
6066      else
6067         printf(" --- DMA Start No Operation\n");
55166068
5517   _32x_palette_lookup[offset] = (r << 10) | (g << 5) | (b << 0);
6069   }
55186070
5519   palette_set_color_rgb(Machine,offset+0x40,pal5bit(r),pal5bit(g),pal5bit(b));
55206071
55216072}
55226073
5523/*
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
55246086// returns MARS, the system ID of the 32x
55256087static READ16_HANDLER( _32x_68k_MARS_r )
55266088{
r3514r3515
55356097
55366098    return 0x0000;
55376099}
5538*/
55396100
5540DRIVER_INIT( _32x )
6101UINT16 comms_port[8];
6102
6103static READ32_HANDLER( sh2_commsport_r )
55416104{
5542   memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000000, 0x03fffff, 0, 0, SMH_BANK10, SMH_BANK10);
5543   memory_set_bankptr( 10, memory_region(machine, "gamecart") );
6105   timer_call_after_resynch(NULL, 0, NULL);
6106   return (comms_port[offset*2] << 16) | (comms_port[offset*2+1]);
6107}
55446108
5545   memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0880000, 0x08fffff, 0, 0, SMH_BANK11, SMH_BANK11); // 'fixed' 512kb rom bank
5546   memory_set_bankptr( 11, memory_region(machine, "gamecart") );
55476109
5548   memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0900000, 0x09fffff, 0, 0, SMH_BANK12, SMH_BANK12); // 'bankable' 1024kb rom bank
5549   memory_set_bankptr( 12, memory_region(machine, "gamecart") );
6110static READ16_HANDLER( _32x_68k_comms_r )
6111{
6112   timer_call_after_resynch(NULL, 0, NULL);
6113   return comms_port[offset];
6114}
55506115
5551//  memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000000, 0x00000ff, 0, 0, SMH_BANK10, SMH_BANK10);
5552//  memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000100, 0x03fffff, 0, 0, SMH_NOP, SMH_NOP );
5553//  memory_set_bankptr( 10, memory_region(machine, "32x_68k_bios") );
6116static WRITE16_HANDLER( _32x_68k_comms_w )
6117{
6118   COMBINE_DATA(&comms_port[offset]);
6119   timer_call_after_resynch(NULL, 0, NULL);
55546120
6121}
6122
6123
6124static WRITE32_HANDLER( sh2_commsport_w )
6125{
6126//  printf("comms write %d %08x %08x\n",offset, data, mem_mask);
6127
6128   if (ACCESSING_BITS_16_31)
6129   {
6130      _32x_68k_comms_w(machine,offset*2, (data >> 16) & 0xffff, (mem_mask >> 16) & 0xffff);
6131   }
6132   if (ACCESSING_BITS_0_15)
6133   {
6134      _32x_68k_comms_w(machine,offset*2+1, (data) & 0xffff, (mem_mask) & 0xffff);
6135   }
6136}
6137
6138//static int sh2_master_vint_enable, sh2_slave_vint_enable;
6139//static int sh2_master_hint_enable, sh2_slave_hint_enable;
6140//static int sh2_master_cmdint_enable, sh2_slave_cmdint_enable;
6141//static int sh2_master_pwmint_enable, sh2_slave_pwnint_enable;
6142
6143
6144static WRITE16_HANDLER( _sh2_master_irq_control_w )
6145{
6146   if (ACCESSING_BITS_8_15)
6147   {
6148      //printf("_sh2_master_irq_control_w adapter use stuff write\n");
6149
6150      _32x_access_auth = (data &0x80) >> 7;
6151   }
6152
6153   if (ACCESSING_BITS_0_7)
6154   {
6155      sh2_master_vint_enable = data & 0x8;
6156      sh2_master_hint_enable = data & 0x4;
6157      sh2_master_cmdint_enable = data & 0x2;
6158      sh2_master_pwmint_enable = data & 0x1;
6159   }
6160}
6161
6162static WRITE16_HANDLER( _sh2_slave_irq_control_w )
6163{
6164   if (ACCESSING_BITS_8_15)
6165   {
6166      //printf("_sh2_slave_irq_control_w adapter use stuff write\n");
6167      _32x_access_auth = (data &0x80) >> 7;
6168
6169   }
6170
6171   if (ACCESSING_BITS_0_7)
6172   {
6173      sh2_slave_vint_enable = data & 0x8;
6174      sh2_slave_hint_enable = data & 0x4;
6175      sh2_slave_cmdint_enable = data & 0x2;
6176      sh2_slave_pwnint_enable = data & 0x1;
6177   }
6178}
6179
6180
6181static WRITE32_HANDLER( sh2_4000_master_w )
6182{
6183   if (ACCESSING_BITS_16_31) // 4000
6184   {
6185      //printf("sh2_4000_master_w %08x %08x\n",data,mem_mask);
6186      _sh2_master_irq_control_w(machine, offset*2, (data >> 16) & 0xffff, (mem_mask >> 16) & 0xffff);
6187
6188   }
6189
6190   if (ACCESSING_BITS_0_15) // 4002
6191   {
6192      //printf("sh2_4002_master_w %08x %08x\n",data,mem_mask);
6193   }
6194
6195}
6196
6197static WRITE32_HANDLER( sh2_4000_slave_w )
6198{
6199   if (ACCESSING_BITS_16_31) // 4000
6200   {
6201      //printf("sh2_4000_slave_w %08x %08x\n",data,mem_mask);
6202      _sh2_slave_irq_control_w(machine, offset*2, (data >> 16) & 0xffff, (mem_mask >> 16) & 0xffff);
6203
6204   }
6205
6206   if (ACCESSING_BITS_0_15) // 4002
6207   {
6208      //printf("sh2_4002_slave_w %08x %08x\n",data,mem_mask);
6209   }
6210}
6211
6212/* 4000 - 4002 reads */
6213
6214static READ16_HANDLER( _32x_4000_master_r )
6215{
6216   UINT16 retvalue = 0x0200;
6217   retvalue |= _32x_access_auth << 15;
6218   return retvalue;
6219}
6220
6221static READ16_HANDLER( _32x_4000_slave_r )
6222{
6223   UINT16 retvalue = 0x0200;
6224   retvalue |= _32x_access_auth << 15;
6225   return retvalue;
6226}
6227
6228static READ16_HANDLER( _32x_4002_r )
6229{
6230   printf("read 4002\n");
6231   return 0x0000;
6232}
6233
6234static READ32_HANDLER( sh2_4000_master_r )
6235{
6236   UINT32 retvalue = 0x00000000;
6237
6238   if (ACCESSING_BITS_16_31) // 4000
6239   {
6240      UINT16 ret = 0x0000;
6241      ret = _32x_4000_master_r(machine,offset*2,(mem_mask>>16)&0xffff);
6242      retvalue |= ret << 16;
6243   }
6244
6245   if (ACCESSING_BITS_0_15) // 4002
6246   {
6247      UINT16 ret = 0x0000;
6248      ret = _32x_4002_r(machine,offset*2+1,(mem_mask>>0)&0xffff);
6249      retvalue |= ret << 0;
6250   }
6251
6252   return retvalue;
6253}
6254
6255
6256static READ32_HANDLER( sh2_4000_slave_r )
6257{
6258   UINT32 retvalue = 0x00000000;
6259
6260   if (ACCESSING_BITS_16_31) // 4000
6261   {
6262      UINT16 ret = 0x0000;
6263      ret = _32x_4000_slave_r(machine,offset*2,(mem_mask>>16)&0xffff);
6264      retvalue |= ret << 16;
6265   }
6266
6267   if (ACCESSING_BITS_0_15) // 4002
6268   {
6269      UINT16 ret = 0x0000;
6270      ret = _32x_4002_r(machine,offset*2+1,(mem_mask>>0)&0xffff);
6271      retvalue |= ret << 0;
6272   }
6273
6274   return retvalue;
6275}
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289static READ16_HANDLER( _32x_68k_a15184_r )
6290{
6291   return _32x_autofill_length;
6292}
6293
6294static WRITE16_HANDLER( _32x_68k_a15184_w )
6295{
6296   if (ACCESSING_BITS_0_7)
6297   {
6298      _32x_autofill_length = data & 0xff;
6299      printf("32x set autofill length to %02x\n",_32x_autofill_length);
6300   }
6301
6302   if (ACCESSING_BITS_8_15)
6303   {
6304
6305   }
6306}
6307
6308static READ16_HANDLER( _32x_68k_a15186_r )
6309{
6310   return _32x_autofill_address;
6311}
6312
6313static WRITE16_HANDLER( _32x_68k_a15186_w )
6314{
6315   if (ACCESSING_BITS_0_7)
6316   {
6317      _32x_autofill_address = (_32x_autofill_address & 0xff00) | (data & 0x00ff);
6318   }
6319
6320   if (ACCESSING_BITS_8_15)
6321   {
6322      _32x_autofill_address = (_32x_autofill_address & 0x00ff) | (data & 0xff00);
6323   }
6324
6325   printf("32x set autofill address to %04x\n",_32x_autofill_address);
6326}
6327
6328static READ16_HANDLER( _32x_68k_a15188_r )
6329{
6330   return _32x_autofill_data;
6331}
6332
6333static WRITE16_HANDLER( _32x_68k_a15188_w )
6334{
6335   if (ACCESSING_BITS_0_7)
6336   {
6337      _32x_autofill_data = (_32x_autofill_data & 0xff00) | (data & 0x00ff);
6338   }
6339
6340   if (ACCESSING_BITS_8_15)
6341   {
6342      _32x_autofill_data = (_32x_autofill_data & 0x00ff) | (data & 0xff00);
6343   }
6344
6345   printf("32x set autofill data to %04x (performing fill)\n",_32x_autofill_data);
6346}
6347
6348
6349
6350
6351
6352static READ16_HANDLER( _32x_68k_a15104_r )
6353{
6354   return _32x_a15104;
6355}
6356
6357static WRITE16_HANDLER( _32x_68k_a15104_w )
6358{
6359   if (ACCESSING_BITS_0_7)
6360   {
6361      _32x_a15104 = (_32x_a15104 & 0xff00) | (data & 0x00ff);
6362   }
6363
6364   if (ACCESSING_BITS_8_15)
6365   {
6366      _32x_a15104 = (_32x_a15104 & 0x00ff) | (data & 0xff00);
6367   }
6368
6369   memory_set_bankptr( 12, memory_region(machine, "gamecart")+((_32x_a15104&0x3)*0x100000) );
6370
6371
6372}
6373
6374
6375static UINT16 a15100_reg;
6376
6377static READ16_HANDLER( _32x_68k_a15100_r )
6378{
6379   return (_32x_access_auth<<15) | 0x0080;
6380}
6381
6382static READ16_HANDLER( _32x_68k_bitmapmode_r )
6383{
6384   return 0x8001;
6385}
6386
6387static WRITE16_HANDLER( _32x_68k_bitmapmode_w )
6388{
6389   printf("_32x_68k_bitmapmode_w (a15180) %04x %04x\n",data,mem_mask);
6390}
6391
6392static WRITE16_HANDLER( _32x_68k_a15100_w )
6393{
6394   printf("_32x_68k_a15100_w\n");
6395
6396   if (ACCESSING_BITS_0_7)
6397   {
6398      a15100_reg = (a15100_reg & 0xff00) | (data & 0x00ff);
6399
6400      if (data & 0x02)
6401      {
6402         cpunum_set_input_line(machine, _32x_master_cpu_number, INPUT_LINE_RESET, CLEAR_LINE);
6403         cpunum_set_input_line(machine, _32x_slave_cpu_number, INPUT_LINE_RESET, CLEAR_LINE);
6404      }
6405
6406      if (data & 0x01)
6407      {
6408         _32x_adapter_enabled = 1;
6409         memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0880000, 0x08fffff, 0, 0, SMH_BANK11, SMH_BANK11); // 'fixed' 512kb rom bank
6410         memory_set_bankptr( 11, memory_region(machine, "gamecart") );
6411
6412         memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0900000, 0x09fffff, 0, 0, SMH_BANK12, SMH_BANK12); // 'bankable' 1024kb rom bank
6413         memory_set_bankptr( 12, memory_region(machine, "gamecart") );
6414
6415         memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000000, 0x03fffff, 0, 0, SMH_BANK10, SMH_BANK10);
6416         memory_set_bankptr( 10, memory_region(machine, "32x_68k_bios") );
6417
6418         memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0a15184, 0x0a15185, 0, 0, _32x_68k_a15184_r,    _32x_68k_a15184_w); // autofill length reg
6419         memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0a15186, 0x0a15187, 0, 0, _32x_68k_a15186_r,    _32x_68k_a15186_w); // autofill address reg
6420         memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0a15188, 0x0a15189, 0, 0, _32x_68k_a15188_r,    _32x_68k_a15188_w); // autofill data reg / start fill
6421
6422
6423         memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0a15180, 0x0a15181, 0, 0, _32x_68k_bitmapmode_r, _32x_68k_bitmapmode_w); // mode control regs
6424
6425         memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0a1518a, 0x0a1518b, 0, 0, _32x_68k_fbcontrol_r, _32x_68k_fbcontrol_w); // framebuffer control regs
6426
6427         memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0840000, 0x085ffff, 0, 0, _32x_68k_dram_r, _32x_68k_dram_w); // access to 'display ram' (framebuffer)
6428         memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0a15200, 0x0a153ff, 0, 0, _32x_68k_palette_r, _32x_68k_palette_w); // access to 'palette' xRRRRRGGGGGBBBBB
6429
6430
6431      }
6432      else
6433      {
6434         _32x_adapter_enabled = 0;
6435
6436         memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000000, 0x03fffff, 0, 0, SMH_BANK10, SMH_BANK10);
6437         memory_set_bankptr( 10, memory_region(machine, "gamecart") );
6438
6439
6440      }
6441   }
6442
6443   if (ACCESSING_BITS_8_15)
6444   {
6445      a15100_reg = (a15100_reg & 0x00ff) | (data & 0xff00);
6446      _32x_access_auth = (data & 0x8000)>>15;
6447   }
6448}
6449
6450static int a15102_reg;
6451
6452static READ16_HANDLER( _32x_68k_a15102_r )
6453{
6454   printf("_32x_68k_a15102_r\n");
6455   return a15102_reg;
6456}
6457
6458static WRITE16_HANDLER( _32x_68k_a15102_w )
6459{
6460   if (ACCESSING_BITS_0_7)
6461   {
6462      a15102_reg = data;
6463
6464      if (data&0x1)
6465      {
6466         printf("68k -> SH2 master int command\n");
6467         if (sh2_master_cmdint_enable) cpunum_set_input_line(machine, _32x_master_cpu_number,SH2_CINT_IRQ_LEVEL,ASSERT_LINE);
6468      }
6469
6470      if (data&0x2)
6471      {
6472         printf("68k -> SH2 slave int command\n");
6473         cpunum_set_input_line(machine, _32x_slave_cpu_number,SH2_CINT_IRQ_LEVEL,ASSERT_LINE);
6474      }
6475   }
6476}
6477
6478
6479
6480DRIVER_INIT( _32x )
6481{
6482
6483
55556484   _32x_dram0 = auto_malloc(0x20000);
55566485   _32x_dram1 = auto_malloc(0x20000);
55576486
r3514r3515
55686497   _32x_display_dram = _32x_dram0;
55696498   _32x_access_dram = _32x_dram1;
55706499
5571   memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0840000, 0x085ffff, 0, 0, _32x_68k_dram_r, _32x_68k_dram_w); // access to 'display ram' (framebuffer)
6500   _32x_adapter_enabled = 0;
55726501
5573   memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0a15200, 0x0a153ff, 0, 0, _32x_68k_palette_r, _32x_68k_palette_w); // access to 'palette' xRRRRRGGGGGBBBBB
6502   if (_32x_adapter_enabled == 0)
6503   {
6504      memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000000, 0x03fffff, 0, 0, SMH_BANK10, SMH_BANK10);
6505      memory_set_bankptr( 10, memory_region(machine, "gamecart") );
6506   };
55746507
6508
6509   a15100_reg = 0x0000;
6510   memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa15100, 0xa15101, 0, 0, _32x_68k_a15100_r, _32x_68k_a15100_w); // framebuffer control regs
6511   memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa15102, 0xa15103, 0, 0, _32x_68k_a15102_r, _32x_68k_a15102_w); // send irq to sh2
6512   memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa15104, 0xa15105, 0, 0, _32x_68k_a15104_r,    _32x_68k_a15104_w); // 68k BANK rom set
6513   memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa15106, 0xa15107, 0, 0, _32x_68k_a15106_r,    _32x_68k_a15106_w); // dreq stuff
6514
6515   memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa15120, 0xa1512f, 0, 0, _32x_68k_comms_r,    _32x_68k_comms_w); // comms regs
6516
6517   memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0a130ec, 0x0a130ef, 0, 0, _32x_68k_MARS_r); // system ID
6518
6519
6520
6521   /* SH2 stuff */
6522   memory_install_readwrite32_handler(machine, 2, ADDRESS_SPACE_PROGRAM, 0x4000, 0x4003, 0, 0, sh2_4000_master_r, sh2_4000_master_w);
6523   memory_install_readwrite32_handler(machine, 3, ADDRESS_SPACE_PROGRAM, 0x4000, 0x4003, 0, 0, sh2_4000_slave_r, sh2_4000_slave_w );
6524
6525   /* Install Interrupt Clear Registers */
6526   memory_install_readwrite32_handler(machine, 2, ADDRESS_SPACE_PROGRAM, 0x4014, 0x4017, 0, 0, sh2_master_4014_4016_r, sh2_master_4014_4016_w );
6527   memory_install_write32_handler(machine, 3, ADDRESS_SPACE_PROGRAM, 0x4014, 0x4017, 0, 0, sh2_slave_4014_4016_w );
6528   memory_install_write32_handler(machine, 2, ADDRESS_SPACE_PROGRAM, 0x4018, 0x401b, 0, 0, sh2_master_4018_401a_w );
6529   memory_install_write32_handler(machine, 3, ADDRESS_SPACE_PROGRAM, 0x4018, 0x401b, 0, 0, sh2_slave_4018_401a_w );
6530   memory_install_write32_handler(machine, 2, ADDRESS_SPACE_PROGRAM, 0x401c, 0x401f, 0, 0, sh2_master_401c_401e_w );
6531   memory_install_write32_handler(machine, 3, ADDRESS_SPACE_PROGRAM, 0x401c, 0x401f, 0, 0, sh2_slave_401c_401e_w );
6532
6533
6534   memory_install_readwrite32_handler(machine, 2, ADDRESS_SPACE_PROGRAM, 0x4020, 0x402f, 0, 0, sh2_commsport_r, sh2_commsport_w );
6535   memory_install_readwrite32_handler(machine, 3, ADDRESS_SPACE_PROGRAM, 0x4020, 0x402f, 0, 0, sh2_commsport_r, sh2_commsport_w );
6536
6537   /* Interrupts are masked / disabled at first */
6538   sh2_master_vint_enable = sh2_slave_vint_enable = 0;
6539   sh2_master_hint_enable = sh2_slave_hint_enable = 0;
6540   sh2_master_cmdint_enable = sh2_slave_cmdint_enable = 0;
6541   sh2_master_pwmint_enable = sh2_slave_pwnint_enable = 0;
6542
6543   // start in a reset state
6544   sh2_are_running = 0;
6545
55756546   _32x_a1518a_reg = 0x00; // inital value
5576   memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0a1518a, 0x0a1518b, 0, 0, _32x_68k_fbcontrol_r, _32x_68k_fbcontrol_w); // framebuffer control regs
6547   _32x_a15104 = 0x00;
55776548
5578//  memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0a130ec, 0x0a151ef, 0, 0, _32x_68k_MARS_r); // system ID
6549   _32x_autofill_length = 0;
6550   _32x_autofill_address = 0;
6551   _32x_autofill_data = 0;
6552   _32x_screenshift = 0;
55796553
5580
55816554   DRIVER_INIT_CALL(megadriv);
55826555}
55836556
5584#if
6557#if 1
55856558
55866559ROM_START( 32x_bios )
55876560   ROM_REGION16_BE( 0x400000, "main", ROMREGION_ERASE00 )
55886561
55896562   ROM_REGION16_BE( 0x400000, "gamecart", 0 ) /* 68000 Code */
5590   ROM_LOAD( "32xquin.rom", 0x000000,  0x005d124, CRC(93d4b0a3) SHA1(128bd0b6e048c749da1a2f4c3abd6a867539a293))
6563//  ROM_LOAD( "32xquin.rom", 0x000000,  0x005d124, CRC(93d4b0a3) SHA1(128bd0b6e048c749da1a2f4c3abd6a867539a293))
55916564//  ROM_LOAD( "32x_babe.rom", 0x000000,  0x14f80, CRC(816b0cb4) SHA1(dc16d3170d5809b57192e03864b7136935eada64) )
55926565//  ROM_LOAD( "32xhot.rom", 0x000000,  0x01235c, CRC(da9c93c9) SHA1(a62652eb8ad8c62b36f6b1ffb96922d045c4e3ac))
55936566//  ROM_LOAD( "knux.rom", 0x000000,  0x300000, CRC(d0b0b842) SHA1(0c2fff7bc79ed26507c08ac47464c3af19f7ced7) )
6567//  ROM_LOAD( "32x_g_bios.bin", 0x000000,  0x000100, CRC(5c12eae8) SHA1(dbebd76a448447cb6e524ac3cb0fd19fc065d944) )
6568//  ROM_LOAD( "32x_rot.bin", 0x000000,   0x0001638, CRC(98c25033) SHA1(8d9ab3084bd29e60b8cdf4b9f1cb755eb4c88d29) )
6569//  ROM_LOAD( "32x_3d.bin", 0x000000,   0x6568, CRC(0171743e) SHA1(bbe6fec182baae5e4d47d263fae6b419db5366ae) )
6570//  ROM_LOAD( "32x_spin.bin", 0x000000,   0x012c28, CRC(3d1d1191) SHA1(221a74408653e18cef8ce2f9b4d33ed93e4218b7) )
6571//  ROM_LOAD( "32x_doom.bin", 0x000000,   0x300000, CRC(208332fd) SHA1(b68e9c7af81853b8f05b8696033dfe4c80327e38) )
6572    ROM_LOAD( "32x_koli.bin", 0x000000,   0x300000, CRC(20ca53ef) SHA1(191ae0b525ecf32664086d8d748e0b35f776ddfe) ) // works but stutters.. probably flags
6573//  ROM_LOAD( "32x_head.bin", 0x000000,   0x300000, CRC(1) SHA1(1) ) // works but stutters.. probably flags
55946574
6575   ROM_REGION32_BE( 0x400000, "gamecart_sh2", 0 ) /* Copy for the SH2 */
6576   ROM_COPY( "gamecart", 0x0, 0x0, 0x400000)
6577
55956578   ROM_REGION16_BE( 0x400000, "32x_68k_bios", 0 ) /* 68000 Code */
6579//  ROM_COPY( "gamecart", 0x0, 0x0, 0x400000)
55966580   ROM_LOAD( "32x_g_bios.bin", 0x000000,  0x000100, CRC(5c12eae8) SHA1(dbebd76a448447cb6e524ac3cb0fd19fc065d944) )
55976581
55986582   ROM_REGION( 0x400000, "32x_master_sh2", 0 ) /* SH2 Code */
r3514r3515
56416625   ROM_LOAD( "g_virrea.bin", 0x000000, 0x200000, CRC(5a943df9) SHA1(2c08ea556c79d48e88ff5202944c161ae1b41c63) )
56426626ROM_END
56436627
5644GAME( 1994, 32x_bios,    0,        genesis_32x,        megadriv,    _32x,    ROT0,   "Sega", "32X Bios", GAME_NOT_WORKING )
5645GAME( 1994, segacd,      0,        genesis_scd,        megadriv,    megadriv,ROT0,   "Sega", "Sega-CD Model 2 BIOS V2.11 (U)", GAME_NOT_WORKING )
5646GAME( 1994, 32x_scd,     0,        genesis_32x_scd,    megadriv,    _32x,    ROT0,   "Sega", "Sega-CD Model 2 BIOS V2.11 (U) (with 32X)", GAME_NOT_WORKING )
6628//GAME( 1994, 32x_bios,    0,        genesis_32x,        megadriv,    _32x,    ROT0,   "Sega", "32X Bios", GAME_NOT_WORKING )
6629//GAME( 1994, segacd,      0,        genesis_scd,        megadriv,    megadriv,ROT0,   "Sega", "Sega-CD Model 2 BIOS V2.11 (U)", GAME_NOT_WORKING )
6630//GAME( 1994, 32x_scd,     0,        genesis_32x_scd,    megadriv,    _32x,    ROT0,   "Sega", "Sega-CD Model 2 BIOS V2.11 (U) (with 32X)", GAME_NOT_WORKING )
56476631GAME( 1994, g_virr,      0,        megdsvp,            megadriv,   megadriv, ROT0,   "Sega", "Virtua Racing (U) [!]", 0 )
56486632GAME( 1994, g_virrj ,    g_virr,   megdsvp,            megadriv,   megadrij, ROT0,   "Sega", "Virtua Racing (J) [!]", 0 )
56496633GAME( 1994, g_virre ,    g_virr,   megdsvppal,         megadriv,   megadrie, ROT0,   "Sega", "Virtua Racing (E) [!]", 0 )
src/mame/drivers/megadriv.h
r3514r3515
1extern DRIVER_INIT( megadriv_c2 );
12extern DRIVER_INIT( megadrie );
23extern DRIVER_INIT( megadriv );
34extern DRIVER_INIT( megadrij );
4extern DRIVER_INIT( megadsvp );
5extern DRIVER_INIT( _32x );
56
67INPUT_PORTS_EXTERN(megadriv);
78INPUT_PORTS_EXTERN(aladbl);
r3514r3515
910INPUT_PORTS_EXTERN(ssf2ghw);
1011INPUT_PORTS_EXTERN(megdsvp);
1112
13MACHINE_DRIVER_EXTERN( megdsvppal );
1214MACHINE_DRIVER_EXTERN(megadriv);
1315MACHINE_DRIVER_EXTERN(megadpal);
14MACHINE_DRIVER_EXTERN(_32x);
1516MACHINE_DRIVER_EXTERN(megdsvp);
17MACHINE_DRIVER_EXTERN( genesis_32x );
18MACHINE_DRIVER_EXTERN( genesis_scd );
19MACHINE_DRIVER_EXTERN( genesis_32x_scd );
1620
1721extern UINT16* megadriv_backupram;
1822extern int megadriv_backupram_length;
r3514r3515
3943extern void (*megadrive_io_write_data_port_ptr)(int offset, UINT16 data);
4044extern UINT8 megadrive_io_data_regs[3];
4145extern UINT8 megadrive_io_ctrl_regs[3];
46
47extern UINT16* megadrive_vdp_palette_lookup;
48extern UINT16* megadrive_vdp_palette_lookup_sprite; // for C2
49extern UINT16* megadrive_vdp_palette_lookup_shadow;
50extern UINT16* megadrive_vdp_palette_lookup_highlight;
51
52extern int segac2_bg_pal_lookup[4];
53extern int segac2_sp_pal_lookup[4];
54
55extern int genvdp_use_cram;
56extern int genesis_has_z80;
57extern int genesis_always_irq6;
58extern int genesis_other_hacks;
src/mame/drivers/ashnojoe.c
r3514r3515
44
55driver by David Haywood and bits from Pierpaolo Prazzoli
66
7todo:
8- sound
9- frequencies
10- 1 unused rom
117
128Upper board marked: W9011
139
r3514r3515
8076#include "sound/2203intf.h"
8177#include "sound/msm5205.h"
8278
83extern UINT16 *ashnojoetileram16, *ashnojoetileram16_2, *ashnojoetileram16_3, *ashnojoetileram16_4, *ashnojoetileram16_5, *ashnojoetileram16_6, *ashnojoetileram16_7;
79extern UINT16 *ashnojoetileram16, *ashnojoetileram16_2, *ashnojoetileram16_3, *ashnojoetileram16_4;
80extern UINT16 *ashnojoetileram16_5, *ashnojoetileram16_6, *ashnojoetileram16_7;
8481extern UINT16 *ashnojoe_tilemap_reg;
8582
8683extern WRITE16_HANDLER( ashnojoe_tileram_w );
r3514r3515
9693extern VIDEO_START( ashnojoe );
9794extern VIDEO_UPDATE( ashnojoe );
9895
96static UINT8 adpcm_byte;
97static int soundlatch_status;
98static int msm5205_vclk_toggle;
99
100
99101static READ16_HANDLER(fake_4a00a_r)
100102{
101   //if it returns 1 there's no sound. is it used to sync the game and sound?
102   //or just a debug enable/disble register?
103   /* If it returns 1 there's no sound. Is it used to sync the game and sound?
104    or just a debug enable/disable register? */
103105   return 0;
104   //return 1;
105106}
106107
107108static WRITE16_HANDLER( ashnojoe_soundlatch_w )
108109{
109   if(ACCESSING_BITS_0_7)
110   if (ACCESSING_BITS_0_7)
110111   {
111      soundlatch_w(machine,0,data & 0xff);
112      //needed?
113      cpunum_set_input_line(machine, 1,0,HOLD_LINE);
112      soundlatch_status = 1;
113      soundlatch_w(machine, 0, data & 0xff);
114114   }
115115}
116116
r3514r3515
124124   AM_RANGE(0x047000, 0x047fff) AM_RAM_WRITE(ashnojoe_tileram7_w) AM_BASE(&ashnojoetileram16_7)
125125   AM_RANGE(0x048000, 0x048fff) AM_RAM_WRITE(ashnojoe_tileram_w) AM_BASE(&ashnojoetileram16)
126126   AM_RANGE(0x049000, 0x049fff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE(&paletteram16)
127   AM_RANGE(0x04a000, 0x04a001) AM_READ_PORT("P1")      // p1 inputs, coins
128   AM_RANGE(0x04a002, 0x04a003) AM_READ_PORT("P2")      // p2 inputs
129   AM_RANGE(0x04a004, 0x04a005) AM_READ_PORT("DSW")   // dipswitches
127   AM_RANGE(0x04a000, 0x04a001) AM_READ_PORT("P1")
128   AM_RANGE(0x04a002, 0x04a003) AM_READ_PORT("P2")
129   AM_RANGE(0x04a004, 0x04a005) AM_READ_PORT("DSW")
130130   AM_RANGE(0x04a006, 0x04a007) AM_WRITE(SMH_RAM) AM_BASE(&ashnojoe_tilemap_reg)
131131   AM_RANGE(0x04a008, 0x04a009) AM_WRITE(ashnojoe_soundlatch_w)
132132   AM_RANGE(0x04a00a, 0x04a00b) AM_READ(fake_4a00a_r)   // ??
r3514r3515
136136   AM_RANGE(0x080000, 0x0bffff) AM_ROM
137137ADDRESS_MAP_END
138138
139static READ8_HANDLER(fake_6_r)
139
140static WRITE8_HANDLER( adpcm_w )
140141{
141   // if it returns 0 the cpu doesn't read from port $4 ?
142   int ret = 0;
143   ret ^= 1;
144   return ret;
145   /* FIXME: earlier attemts to remove ?
146    return 1;
147    return 0;
148    return mame_rand(machine);
149    */
142   adpcm_byte = data;
150143}
151144
152static WRITE8_HANDLER( adpcm_data_w )
145static READ8_HANDLER( sound_latch_r )
153146{
154   msm5205_data_w(0, data & 0xf);
155   msm5205_data_w(0, data>>4);
147   soundlatch_status = 0;
148   return soundlatch_r(machine, 0);
156149}
157150
151static READ8_HANDLER( sound_latch_status_r )
152{
153   return soundlatch_status;
154}
155
158156static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 )
159157   AM_RANGE(0x0000, 0x5fff) AM_ROM
160158   AM_RANGE(0x6000, 0x7fff) AM_RAM
r3514r3515
165163   ADDRESS_MAP_GLOBAL_MASK(0xff)
166164   AM_RANGE(0x00, 0x00) AM_READWRITE(ym2203_status_port_0_r, ym2203_control_port_0_w)
167165   AM_RANGE(0x01, 0x01) AM_READWRITE(ym2203_read_port_0_r, ym2203_write_port_0_w)
168   AM_RANGE(0x02, 0x02) AM_WRITE(adpcm_data_w)
169   AM_RANGE(0x04, 0x04) AM_READ(soundlatch_r) //PC: 15D -> cp $7f
170   AM_RANGE(0x06, 0x06) AM_READ(fake_6_r/*soundlatch_r */) //PC: 14A -> and $1
166   AM_RANGE(0x02, 0x02) AM_WRITE(adpcm_w)
167   AM_RANGE(0x04, 0x04) AM_READ(sound_latch_r)
168   AM_RANGE(0x06, 0x06) AM_READ(sound_latch_status_r)
171169ADDRESS_MAP_END
172170
171
173172static INPUT_PORTS_START( ashnojoe )
174173   PORT_START("P1")   /* player 1 16-bit */
175174   PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_4WAY PORT_PLAYER(1)
r3514r3515
257256   PORT_DIPSETTING(      0x8000, DEF_STR( On ) )
258257INPUT_PORTS_END
259258
259
260260static const gfx_layout tiles8x8_layout =
261261{
262262   8,8,
r3514r3515
289289   GFXDECODE_ENTRY( "gfx5", 0, tiles16x16_layout, 0, 0x100 )
290290GFXDECODE_END
291291
292static void irqhandler(running_machine *machine, int irq)
292
293static void ym2203_irq_handler(running_machine *machine, int irq)
293294{
294   cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE);
295   cpunum_set_input_line(machine, 1, 0, irq ? ASSERT_LINE : CLEAR_LINE);
295296}
296297
297static WRITE8_HANDLER(writeA)
298static WRITE8_HANDLER( ym2203_write_a )
298299{
299   if (data == 0xff) return;   // this gets called at 8910 startup with 0xff before the 5205 exists, causing a crash
300   /* This gets called at 8910 startup with 0xff before the 5205 exists, causing a crash */
301   if (data == 0xff)
302      return;
300303
301304   msm5205_reset_w(0, !(data & 0x01));
302305}
303306
304static WRITE8_HANDLER(writeB)
307static WRITE8_HANDLER( ym2203_write_b )
305308{
306309   memory_set_bankptr(4, memory_region(machine, "adpcm") + ((data & 0xf) * 0x8000));
307310}
308311
309static void ashnojoe_adpcm_int (running_machine *machine, int data)
310{
311   cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, PULSE_LINE);
312}
313
314static const msm5205_interface msm5205_config =
315{
316   ashnojoe_adpcm_int,   /* interrupt function */
317   MSM5205_S48_4B      /* 4KHz 4-bit */
318};
319
320312static const ym2203_interface ym2203_config =
321313{
322314   {
r3514r3515
324316      AY8910_DEFAULT_LOADS,
325317      NULL,
326318      NULL,
327      writeA,
328      writeB,
319      ym2203_write_a,
320      ym2203_write_b,
329321   },
330   irqhandler
322   ym2203_irq_handler
331323};
332324
325static void ashnojoe_vclk_cb(running_machine *machine, int data)
326{
327   if (msm5205_vclk_toggle == 0)
328   {
329      msm5205_data_w(0, adpcm_byte >> 4);
330   }
331   else
332   {
333      msm5205_data_w(0, adpcm_byte & 0xf);
334      cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, PULSE_LINE);
335   }
336
337   msm5205_vclk_toggle ^= 1;
338}
339
340static const msm5205_interface msm5205_config =
341{
342   ashnojoe_vclk_cb,
343   MSM5205_S48_4B
344};
345
346
333347static DRIVER_INIT( ashnojoe )
334348{
335349   memory_set_bankptr(4, memory_region(machine, "adpcm"));
r3514r3515
338352static MACHINE_DRIVER_START( ashnojoe )
339353
340354   /* basic machine hardware */
341   MDRV_CPU_ADD("main", M68000, 8000000) /* 8 MHz (verified on pcb) */
355   MDRV_CPU_ADD("main", M68000, 8000000)
342356   MDRV_CPU_PROGRAM_MAP(ashnojoe_map,0)
343357   MDRV_CPU_VBLANK_INT("main", irq1_line_hold)
344358
345   MDRV_CPU_ADD("audio", Z80, 4000000) /* 4 MHz (verified on pcb) */
359   MDRV_CPU_ADD("audio", Z80, 4000000)
346360   MDRV_CPU_PROGRAM_MAP(sound_map,0)
347361   MDRV_CPU_IO_MAP(sound_portmap,0)
348362
r3514r3515
363377   /* sound hardware */
364378   MDRV_SPEAKER_STANDARD_MONO("mono")
365379
366   MDRV_SOUND_ADD("ym", YM2203, 4000000)  /* 4 MHz (verified on pcb) */
380   MDRV_SOUND_ADD("ym", YM2203, 4000000)
367381   MDRV_SOUND_CONFIG(ym2203_config)
368   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
382   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.1)
369383
370384   MDRV_SOUND_ADD("msm", MSM5205, 384000)
371385   MDRV_SOUND_CONFIG(msm5205_config)
372   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
386   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
373387MACHINE_DRIVER_END
374388
375389ROM_START( scessjoe )
r3514r3515
405419   ROM_LOAD16_WORD_SWAP( "sj408-nw.7g", 0x200000, 0x80000, CRC(6a3b1ea1) SHA1(e39a6e52d930f291bf237cf9db3d4b3d2fad53e0) )
406420   ROM_LOAD16_WORD_SWAP( "sj409-nw.7j", 0x280000, 0x80000, CRC(d8764213) SHA1(89eadefb956863216c8e3d0380394aba35e8c856) )
407421
408   ROM_REGION( 0x80000, "adpcm", 0 )   /* samples? */
422   ROM_REGION( 0x80000, "adpcm", 0 )
409423   ROM_LOAD( "sj401-nw.10r", 0x00000, 0x80000, CRC(25dfab59) SHA1(7d50159204ba05323a2442778f35192e66117dda) )
410424ROM_END
411425
r3514r3515
442456   ROM_LOAD16_WORD_SWAP( "sj408-nw.7g", 0x200000, 0x80000, CRC(6a3b1ea1) SHA1(e39a6e52d930f291bf237cf9db3d4b3d2fad53e0) )
443457   ROM_LOAD16_WORD_SWAP( "sj409-nw.7j", 0x280000, 0x80000, CRC(d8764213) SHA1(89eadefb956863216c8e3d0380394aba35e8c856) )
444458
445   ROM_REGION( 0x80000, "adpcm", 0 )   /* samples? */
459   ROM_REGION( 0x80000, "adpcm", 0 )
446460   ROM_LOAD( "sj401-nw.10r", 0x00000, 0x80000, CRC(25dfab59) SHA1(7d50159204ba05323a2442778f35192e66117dda) )
447461ROM_END
448462
449GAME( 1990, scessjoe, 0,        ashnojoe, ashnojoe, ashnojoe, ROT0, "WAVE / Taito Corporation", "Success Joe (World)", GAME_IMPERFECT_SOUND )
450GAME( 1990, ashnojoe, scessjoe, ashnojoe, ashnojoe, ashnojoe, ROT0, "WAVE / Taito Corporation", "Ashita no Joe (Japan)", GAME_IMPERFECT_SOUND )
451
463GAME( 1990, scessjoe, 0,        ashnojoe, ashnojoe, ashnojoe, ROT0, "WAVE / Taito Corporation", "Success Joe (World)",   0 )
464GAME( 1990, ashnojoe, scessjoe, ashnojoe, ashnojoe, ashnojoe, ROT0, "WAVE / Taito Corporation", "Ashita no Joe (Japan)", 0 )
src/mame/drivers/astrof.c
r3514r3515
4242    Known issues/to-do's:
4343        * Is Astro Fighter supposed to have a blue background???
4444        * Analog sound in all games
45        * Verify DIPs for clones
46        * Figure out unknown DIPs for Space Fighter Mark II (set 2)
4745
4846****************************************************************************/
4947
r3514r3515
567565
568566   PORT_START("P1")
569567   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_2WAY
570   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY
568   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY
571569   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 )
572570   PORT_BIT( 0xf8, IP_ACTIVE_HIGH, IPT_UNUSED )
573571
574572   PORT_START("P2")
575573   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_COCKTAIL
576   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_COCKTAIL
574   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_COCKTAIL
577575   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
578576   PORT_BIT( 0xf8, IP_ACTIVE_HIGH, IPT_UNUSED )
579577
580578   PORT_START("DSW")
581   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW:1,2")
579   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) )            PORT_DIPLOCATION("SW:1,2")
582580   PORT_DIPSETTING(    0x00, "3" )
583581   PORT_DIPSETTING(    0x01, "4" )
584582   PORT_DIPSETTING(    0x02, "5" )
585583   PORT_DIPSETTING(    0x03, "6" )
586   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW:3,4")
584   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) )          PORT_DIPLOCATION("SW:3,4")
587585   PORT_DIPSETTING(    0x08, DEF_STR( 2C_1C ) )
588  /*PORT_DIPSETTING(    0x0c, DEF_STR( 2C_1C ) )*/
586//  PORT_DIPSETTING(    0x0c, DEF_STR( 2C_1C ) )            /* duplicate settings */
589587   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
590588   PORT_DIPSETTING(    0x04, DEF_STR( 1C_2C ) )
591   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SW:5,6")
592   PORT_DIPSETTING(    0x00, "3000" )
593   PORT_DIPSETTING(    0x10, "5000" )
594   PORT_DIPSETTING(    0x20, "7000" )
589   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) )       PORT_DIPLOCATION("SW:5,6")    /* table at 0xf6b2 */
590   PORT_DIPSETTING(    0x00, "5000" )
591   PORT_DIPSETTING(    0x10, "7000" )
592   PORT_DIPSETTING(    0x20, "10000" )
595593   PORT_DIPSETTING(    0x30, DEF_STR( None ) )
596   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW:7")
594   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Difficulty ) )       PORT_DIPLOCATION("SW:7")
597595   PORT_DIPSETTING(    0x00, DEF_STR( Easy ) )
598596   PORT_DIPSETTING(    0x40, DEF_STR( Hard ) )
599597   PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_VBLANK )
600598
601599   PORT_START("CAB")
602   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW:8")
600   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )          PORT_DIPLOCATION("SW:8")
603601   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
604602   PORT_DIPSETTING(    0x01, DEF_STR( Cocktail ) )
605603   PORT_BIT( 0xfe, IP_ACTIVE_HIGH, IPT_UNUSED )
r3514r3515
610608   PORT_BIT( 0xfc, IP_ACTIVE_HIGH, IPT_UNUSED )
611609INPUT_PORTS_END
612610
613
611/* same as 'astrof', but inputs are ACTIVE_HIGH instead of ACTIVE_LOW */
614612static INPUT_PORTS_START( abattle )
615613   PORT_START("IN")
616614   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_START1 )
r3514r3515
620618
621619   PORT_START("P1")
622620   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY
623   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY
621   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY
624622   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON1 )
625623   PORT_BIT( 0xf8, IP_ACTIVE_HIGH, IPT_UNUSED )
626624
627625   PORT_START("P2")
628626   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_COCKTAIL
629   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_COCKTAIL
627   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_COCKTAIL
630628   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_COCKTAIL
631629   PORT_BIT( 0xf8, IP_ACTIVE_HIGH, IPT_UNUSED )
632630
633631   PORT_START("DSW")
634   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW:1,2")
632   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) )            PORT_DIPLOCATION("SW:1,2")
635633   PORT_DIPSETTING(    0x00, "3" )
636634   PORT_DIPSETTING(    0x01, "4" )
637635   PORT_DIPSETTING(    0x02, "5" )
638636   PORT_DIPSETTING(    0x03, "6" )
639   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW:3,4")
637   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) )          PORT_DIPLOCATION("SW:3,4")
640638   PORT_DIPSETTING(    0x08, DEF_STR( 2C_1C ) )
641  /*PORT_DIPSETTING(    0x0c, DEF_STR( 2C_1C ) )*/
639//  PORT_DIPSETTING(    0x0c, DEF_STR( 2C_1C ) )            /* duplicate settings */
642640   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
643641   PORT_DIPSETTING(    0x04, DEF_STR( 1C_2C ) )
644   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SW:5,6")
642   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) )       PORT_DIPLOCATION("SW:5,6")    /* table at 0xf87a */
645643   PORT_DIPSETTING(    0x00, "5000" )
646644   PORT_DIPSETTING(    0x10, "7000" )
647645   PORT_DIPSETTING(    0x20, "10000" )
648646   PORT_DIPSETTING(    0x30, DEF_STR( None ) )
649   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW:7")
647   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Difficulty ) )       PORT_DIPLOCATION("SW:7")
650648   PORT_DIPSETTING(    0x00, DEF_STR( Easy ) )
651649   PORT_DIPSETTING(    0x40, DEF_STR( Hard ) )
652650   PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_VBLANK )
653651
654652   PORT_START("CAB")
655   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW:8")
653   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )          PORT_DIPLOCATION("SW:8")
656654   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
657655   PORT_DIPSETTING(    0x01, DEF_STR( Cocktail ) )
658656   PORT_BIT( 0xfe, IP_ACTIVE_HIGH, IPT_UNUSED )
r3514r3515
673671
674672   PORT_START("P1")
675673   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_2WAY
676   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY
674   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY
677675   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 )
678676   PORT_BIT( 0xf8, IP_ACTIVE_HIGH, IPT_UNUSED )
679677
680678   PORT_START("P2")
681679   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_COCKTAIL
682   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_COCKTAIL
680   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_COCKTAIL
683681   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
684682   PORT_BIT( 0xf8, IP_ACTIVE_HIGH, IPT_UNUSED )
685683
686684   PORT_START("DSW")
687   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW:1")   /* most likely not used */
688   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
689   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
690   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW:2")
685   PORT_DIPUNUSED_DIPLOC( 0x01, 0x00, "SW:1" )
686   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Lives ) )            PORT_DIPLOCATION("SW:2")
691687   PORT_DIPSETTING(    0x00, "3" )
692688   PORT_DIPSETTING(    0x02, "5" )
693   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW:3,4")
689   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) )          PORT_DIPLOCATION("SW:3,4")
694690   PORT_DIPSETTING(    0x08, DEF_STR( 2C_1C ) )
695  /*PORT_DIPSETTING(    0x0c, DEF_STR( 2C_1C ) )*/
691//  PORT_DIPSETTING(    0x0c, DEF_STR( 2C_1C ) )            /* duplicate settings */
696692   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
697693   PORT_DIPSETTING(    0x04, DEF_STR( 1C_2C ) )
698   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SW:5,6")
694   PORT_DIPNAME( 0x30, 0x00, "Free Credit" )              PORT_DIPLOCATION("SW:5,6")    /* table at 0xfa58 */
699695   PORT_DIPSETTING(    0x00, "1500" )
700696   PORT_DIPSETTING(    0x10, "2000" )
701697   PORT_DIPSETTING(    0x20, "2500" )
702698   PORT_DIPSETTING(    0x30, "3000" )
703   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW:7")   /* most likely not used */
704   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
705   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
699   PORT_DIPUNUSED_DIPLOC( 0x40, 0x00, "SW:7" )
706700   PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_VBLANK )
707701
708702   PORT_START("CAB")
709   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW:8")
703   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )          PORT_DIPLOCATION("SW:8")
710704   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
711705   PORT_DIPSETTING(    0x01, DEF_STR( Cocktail ) )
712706   PORT_BIT( 0xfe, IP_ACTIVE_HIGH, IPT_UNUSED )
r3514r3515
717711   PORT_BIT( 0xfc, IP_ACTIVE_HIGH, IPT_UNUSED )
718712INPUT_PORTS_END
719713
720
721714static INPUT_PORTS_START( spfgmk22 )
722715   PORT_START("IN")
723716   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
r3514r3515
727720
728721   PORT_START("P1")
729722   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_2WAY
730   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY
723   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY
731724   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 )
732725   PORT_BIT( 0xf8, IP_ACTIVE_HIGH, IPT_UNUSED )
733726
r3514r3515
738731   PORT_BIT( 0xf8, IP_ACTIVE_HIGH, IPT_UNUSED )
739732
740733   PORT_START("DSW")
741   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW:1")   /* used */
742   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
743   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
744   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW:2")
734   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Difficulty ) )       PORT_DIPLOCATION("SW:1")
735   PORT_DIPSETTING(    0x00, DEF_STR( Easy ) )
736   PORT_DIPSETTING(    0x01, DEF_STR( Hard ) )
737   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Lives ) )            PORT_DIPLOCATION("SW:2")
745738   PORT_DIPSETTING(    0x00, "3" )
746739   PORT_DIPSETTING(    0x02, "5" )
747   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW:3,4")
740   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) )          PORT_DIPLOCATION("SW:3,4")
748741   PORT_DIPSETTING(    0x08, DEF_STR( 2C_1C ) )
749  /*PORT_DIPSETTING(    0x0c, DEF_STR( 2C_1C ) )*/
742//  PORT_DIPSETTING(    0x0c, DEF_STR( 2C_1C ) )            /* duplicate settings */
750743   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
751744   PORT_DIPSETTING(    0x04, DEF_STR( 1C_2C ) )
752   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SW:5,6")
745   PORT_DIPNAME( 0x30, 0x00, "Free Credit" )              PORT_DIPLOCATION("SW:5,6")    /* table at 0xf9f8 */
753746   PORT_DIPSETTING(    0x00, "2000" )
754747   PORT_DIPSETTING(    0x10, "3000" )
755748   PORT_DIPSETTING(    0x20, "4000" )
756749   PORT_DIPSETTING(    0x30, "5000" )
757   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW:7")   /* used */
758   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
759   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
750   PORT_DIPNAME( 0x40, 0x00, "Kill Saucer after Invaders" ) PORT_DIPLOCATION("SW:7")
751   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
752   PORT_DIPSETTING(    0x40, DEF_STR( Yes ) )              /* if saucer lands, game is over */
760753   PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_VBLANK )
761754
762755   PORT_START("CAB")
763   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW:8")
756   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )          PORT_DIPLOCATION("SW:8")
764757   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
765758   PORT_DIPSETTING(    0x01, DEF_STR( Cocktail ) )
766759   PORT_BIT( 0xfe, IP_ACTIVE_HIGH, IPT_UNUSED )
r3514r3515
781774
782775   PORT_START("P1")
783776   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY
784   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY
785   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY
786   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY
777   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )  PORT_4WAY
778   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )  PORT_4WAY
779   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )    PORT_4WAY
787780   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
788781   PORT_BIT( 0xe0, IP_ACTIVE_HIGH, IPT_UNUSED )
789782
790783   PORT_START("P2")
791784   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_COCKTAIL
792   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_COCKTAIL
793   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_COCKTAIL
794   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY PORT_COCKTAIL
785   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )  PORT_4WAY PORT_COCKTAIL
786   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )  PORT_4WAY PORT_COCKTAIL
787   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )    PORT_4WAY PORT_COCKTAIL
795788   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
796789   PORT_BIT( 0xe0, IP_ACTIVE_HIGH, IPT_UNUSED )
797790
798791     PORT_START("DSW")
799   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW:1,2")
792   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) )            PORT_DIPLOCATION("SW:1,2")
800793   PORT_DIPSETTING(    0x00, "3" )
801794   PORT_DIPSETTING(    0x01, "4" )
802795   PORT_DIPSETTING(    0x02, "5" )
803796   PORT_DIPSETTING(    0x03, "6" )
804   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW:3,4")
797   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) )          PORT_DIPLOCATION("SW:3,4")
805798   PORT_DIPSETTING(    0x08, DEF_STR( 2C_1C ) )
806  /*PORT_DIPSETTING(    0x0c, DEF_STR( 2C_1C ) )*/
799//  PORT_DIPSETTING(    0x0c, DEF_STR( 2C_1C ) )            /* duplicate settings */
807800   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
808801   PORT_DIPSETTING(    0x04, DEF_STR( 1C_2C ) )
809   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SW:5,6")
802   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) )       PORT_DIPLOCATION("SW:5,6")    /* table at 0xf428 */
810803   PORT_DIPSETTING(    0x00, "5000" )
811804   PORT_DIPSETTING(    0x10, "7000" )
812805   PORT_DIPSETTING(    0x20, "10000" )
813806   PORT_DIPSETTING(    0x30, DEF_STR( None ) )
814   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW:7")
807   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Difficulty ) )       PORT_DIPLOCATION("SW:7")
815808   PORT_DIPSETTING(    0x00, DEF_STR( Easy ) )
816809   PORT_DIPSETTING(    0x40, DEF_STR( Hard ) )
817810   PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_VBLANK )
818811
819812   PORT_START("CAB")
820   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW:8")
813   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )          PORT_DIPLOCATION("SW:8")
821814   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
822815   PORT_DIPSETTING(    0x01, DEF_STR( Cocktail ) )
823816   PORT_BIT( 0xfe, IP_ACTIVE_HIGH, IPT_UNUSED )
r3514r3515
828821   PORT_BIT( 0xfc, IP_ACTIVE_HIGH, IPT_UNUSED )
829822INPUT_PORTS_END
830823
824static INPUT_PORTS_START( tomahaw1 )
825   PORT_INCLUDE( tomahawk )
831826
827   PORT_MODIFY("DSW")
828   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) )       PORT_DIPLOCATION("SW:5,6")    /* table at 0xf3c8 */
829   PORT_DIPSETTING(    0x00, "3000" )
830   PORT_DIPSETTING(    0x10, "5000" )
831   PORT_DIPSETTING(    0x20, "7000" )
832   PORT_DIPSETTING(    0x30, DEF_STR( None ) )
833   PORT_DIPUNUSED_DIPLOC( 0x40, 0x00, "SW:7" )
834INPUT_PORTS_END
832835
836
837
833838/*************************************
834839 *
835840 *  Machine drivers
r3514r3515
12371242GAME( 1979, spfghmk2, 0,        spfghmk2, spfghmk2, 0,       ROT90, "Data East",   "Space Fighter Mark II (set 1)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE )
12381243GAME( 1979, spfgmk22, spfghmk2, spfghmk2, spfgmk22, 0,       ROT90, "Data East",   "Space Fighter Mark II (set 2)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE )
12391244GAME( 1980, tomahawk, 0,        tomahawk, tomahawk, 0,       ROT90, "Data East",   "Tomahawk 777 (rev 5)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1240GAME( 1980, tomahaw1, tomahawk, tomahawk, tomahawk, 0,       ROT90, "Data East",   "Tomahawk 777 (rev 1)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1245GAME( 1980, tomahaw1, tomahawk, tomahawk, tomahaw1, 0,       ROT90, "Data East",   "Tomahawk 777 (rev 1)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
src/mame/drivers/karnov.c
r3514r3515
524524   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE1 )
525525
526526   PORT_START("DSW")
527   PORT_DIPNAME( 0x000c, 0x000c, DEF_STR( Coin_B ) )
528   PORT_DIPSETTING(      0x0000, DEF_STR( 4C_1C ) )
529   PORT_DIPSETTING(      0x0004, DEF_STR( 3C_1C ) )
530   PORT_DIPSETTING(      0x0008, DEF_STR( 2C_1C ) )
531   PORT_DIPSETTING(      0x000c, DEF_STR( 1C_1C ) )
532   PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Coin_A ) )
533   PORT_DIPSETTING(      0x0003, DEF_STR( 1C_2C ) )
534   PORT_DIPSETTING(      0x0002, DEF_STR( 1C_3C ) )
535   PORT_DIPSETTING(      0x0001, DEF_STR( 1C_4C ) )
536   PORT_DIPSETTING(      0x0000, DEF_STR( 1C_6C ) )
537   PORT_DIPUNKNOWN( 0x0010, 0x0010 )
538   PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Demo_Sounds ) )
539   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
540   PORT_DIPSETTING(      0x0020, DEF_STR( On ) )
541   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Flip_Screen ) )
542   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
543   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
544   PORT_DIPNAME( 0x0080, 0x0000, DEF_STR( Cabinet ) )
545   PORT_DIPSETTING(      0x0000, DEF_STR( Upright ) )
546   PORT_DIPSETTING(      0x0080, DEF_STR( Cocktail ) )
547
548   PORT_DIPNAME( 0x0300, 0x0300, DEF_STR( Lives ) )
549   PORT_DIPSETTING(      0x0100, "1" )
550   PORT_DIPSETTING(      0x0300, "3" )
551   PORT_DIPSETTING(      0x0200, "5" )
552   PORT_DIPSETTING(      0x0000, "Infinite (Cheat)")
553   PORT_DIPNAME( 0x0c00, 0x0c00, DEF_STR( Difficulty ) )
554   PORT_DIPSETTING(      0x0400, DEF_STR( Easy ) )
555   PORT_DIPSETTING(      0x0c00, DEF_STR( Normal ) )
556   PORT_DIPSETTING(      0x0800, DEF_STR( Hard ) )
557   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
558   PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Allow_Continue ) )
559   PORT_DIPSETTING(      0x0000, DEF_STR( No ) )
560   PORT_DIPSETTING(      0x1000, DEF_STR( Yes ) )
561   PORT_DIPUNKNOWN( 0x2000, 0x2000 )
562   PORT_DIPNAME( 0x4000, 0x4000, "Freeze" )
563   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
564   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
565   PORT_DIPUNUSED( 0x8000, 0x8000 )
566INPUT_PORTS_END
567
568static INPUT_PORTS_START( chelnovu )
569   PORT_INCLUDE( common )
570
571   PORT_MODIFY("SYSTEM")
572   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED )
573   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNUSED )
574   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
575
576   PORT_START("FAKE")   /* Dummy input for i8751 */
577   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2 )
578   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 )
579   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE1 )
580
581   PORT_START("DSW")
527582   PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Coin_B ) )
528583   PORT_DIPSETTING(      0x0000, DEF_STR( 2C_1C ) )
529584   PORT_DIPSETTING(      0x0003, DEF_STR( 1C_1C ) )
r3514r3515
9961051GAME( 1987, karnovj,  karnov,  karnov,   karnov,  karnovj,  ROT0,   "Data East Corporation", "Karnov (Japan)", 0 )
9971052GAME( 1987, wndrplnt, 0,       wndrplnt, wndrplnt,wndrplnt, ROT270, "Data East Corporation", "Wonder Planet (Japan)", 0 )
9981053GAME( 1988, chelnov,  0,       karnov,   chelnov, chelnovw, ROT0,   "Data East Corporation", "Chelnov - Atomic Runner (World)", 0 )
999GAME( 1988, chelnovu, chelnov, karnov,   chelnov, chelnov,  ROT0,   "Data East USA",         "Chelnov - Atomic Runner (US)", 0 )
1000GAME( 1988, chelnovj, chelnov, karnov,   chelnov, chelnovj, ROT0,   "Data East Corporation", "Chelnov - Atomic Runner (Japan)", 0 )
1054GAME( 1988, chelnovu, chelnov, karnov,   chelnovu, chelnov,  ROT0,   "Data East USA",         "Chelnov - Atomic Runner (US)", 0 )
1055GAME( 1988, chelnovj, chelnov, karnov,   chelnovu, chelnovj, ROT0,   "Data East Corporation", "Chelnov - Atomic Runner (Japan)", 0 )
src/mame/drivers/magictg.c
r3514r3515
114114#include "cpu/mips/mips3.h"
115115
116116
117VIDEO_START(magictg)
117static VIDEO_START(magictg)
118118{
119119
120120}
121121
122VIDEO_UPDATE(magictg)
122static VIDEO_UPDATE(magictg)
123123{
124124   return 0;
125125}
r3514r3515
174174   ROM_REGION32_BE( 0x80000, "user2", 0 ) /* ADSP 2181 code? */
175175   ROM_LOAD( "magic.20u", 0x00000, 0x80000, CRC(50968301) SHA1(e9bdd0c942f0c66e18aa8de5a04edb51cdf1fee8) )
176176
177   ROM_REGION32_BE( 0x400000, "user3", 0 ) /* ADSP samples */
178   ROM_LOAD( "magic.snd0.u8", 0x000000, 0x100000, BAD_DUMP CRC(ef3384ed) SHA1(0b2fa03e3da691590c705ff9d4e26ffbe374cd0f) )
179   ROM_LOAD( "magic.snd1.u14",0x100000, 0x100000, BAD_DUMP CRC(d591dc93) SHA1(6a7627659de8b9e4cde7c314504f0ee087ecab4d) )
180   ROM_LOAD( "magic.snd2.u13",0x200000, 0x100000, BAD_DUMP CRC(d81cb2e1) SHA1(f62f85ce094cfe48373d0929bfdb76522315da81) )
181   ROM_LOAD( "magic.snd3.u7", 0x300000, 0x100000, BAD_DUMP CRC(6c8e0475) SHA1(9cafbc85d20390e9cd5d55e3c48a049e40a833ca) ) // basically empty
177   ROM_REGION32_BE( 0x1000000, "user3", 0 ) /* ADSP samples */
178   ROM_LOAD( "magic.snd0.u8", 0x000000, 0x400000, CRC(3cb81717) SHA1(9d35796381ca57e9782e0338c456e63c31d11266) )
179   ROM_LOAD( "magic.snd1.u14",0x400000, 0x400000, CRC(b4ef9977) SHA1(dedc79e5d506bb0d1649a41b9912dcc999e1da72) )
180   ROM_LOAD( "magic.snd2.u13",0x800000, 0x400000, CRC(3728f16e) SHA1(6b7da30b100d053e95aa96edf74a0474f1493dfb) )
181   ROM_LOAD( "magic.snd3.u7", 0xc00000, 0x400000, CRC(11a1cb63) SHA1(a1048d3cd580747c20eb0b4e816e7e4e0f5c8c2b) )
182182
183   ROM_REGION( 0x400000, "user4", 0 ) /* ? */
184   ROM_LOAD( "magic.s0.u9",  0x000000, 0x100000, BAD_DUMP CRC(b1d9e54e) SHA1(c4964fcab4aa3d37cbfaeac0c35be31597fdd0aa) )
185   ROM_LOAD( "magic.s1.u10", 0x100000, 0x100000, BAD_DUMP CRC(ccce2af7) SHA1(23d6e1bcf1ae9787f20b9bb14c2553b9a6d6b12c) )
186   ROM_LOAD( "magic.s2.u12", 0x200000, 0x100000, BAD_DUMP CRC(eb8d1607) SHA1(353410b20d121b0bbecef4735a692f0c1d09ce9b) )
187   ROM_LOAD( "magic.s3.u11", 0x300000, 0x100000, BAD_DUMP CRC(58c33f8e) SHA1(af09105b17b95882f7ff90ec64081e8b1d429e0b) )
183   ROM_REGION( 0x2000000, "user4", 0 ) /* Jpeg GFX data */
184   /* each of these contains 2x 0x400000 blocks */
185   ROM_LOAD( "magic_s0.u9",  0x0000000, 0x800000, CRC(a01b5b99) SHA1(e77f2e9b08a97d6118e1e307b38ea79d0177e9b8) )
186   ROM_LOAD( "magic_s1.u10", 0x0800000, 0x800000, CRC(d5a1a557) SHA1(2511ee8d08da765a2fa2d42fb504793f9e8b615c) )
187   ROM_LOAD( "magic_s2.u12", 0x1000000, 0x800000, CRC(06ed6770) SHA1(884a3e4c97a50fa926546eb6def2c11c5732ba88) )
188   ROM_LOAD( "magic_s3.u11", 0x1800000, 0x800000, CRC(71d4c252) SHA1(aeab2542b9d5fb63f4d60b808010a657a895c1d7) )
188189
189   ROM_REGION( 0x100000, "user5", 0 ) /* ? */
190   ROM_LOAD( "magic.k0.u20", 0x000000, 0x100000, BAD_DUMP CRC(aeb617fa) SHA1(4853c1c3631b798312d9146a90158490f2252119) )
190   ROM_REGION( 0x400000, "user5", 0 ) /* 'key' data */
191   ROM_LOAD( "magic.k0.u20", 0x000000, 0x400000, CRC(63ab0e9e) SHA1(c4f0b009860ee499496ed7fc1f14ef1e221c1085) )
191192ROM_END
192193
193194ROM_START( magictga )
r3514r3515
202203   ROM_REGION32_BE( 0x80000, "user2", 0 ) /* ADSP 2181 code? */
203204   ROM_LOAD( "magic.20u", 0x00000, 0x80000, CRC(50968301) SHA1(e9bdd0c942f0c66e18aa8de5a04edb51cdf1fee8) )
204205
205   ROM_REGION32_BE( 0x400000, "user3", 0 ) /* ADSP samples */
206   ROM_LOAD( "magic.snd0.u8", 0x000000, 0x100000, BAD_DUMP CRC(ef3384ed) SHA1(0b2fa03e3da691590c705ff9d4e26ffbe374cd0f) )
207   ROM_LOAD( "magic.snd1.u14",0x100000, 0x100000, BAD_DUMP CRC(d591dc93) SHA1(6a7627659de8b9e4cde7c314504f0ee087ecab4d) )
208   ROM_LOAD( "magic.snd2.u13",0x200000, 0x100000, BAD_DUMP CRC(d81cb2e1) SHA1(f62f85ce094cfe48373d0929bfdb76522315da81) )
209   ROM_LOAD( "magic.snd3.u7", 0x300000, 0x100000, BAD_DUMP CRC(6c8e0475) SHA1(9cafbc85d20390e9cd5d55e3c48a049e40a833ca) ) // basically empty
206   ROM_REGION32_BE( 0x1000000, "user3", 0 ) /* ADSP samples */
207   ROM_LOAD( "magic.snd0.u8", 0x000000, 0x400000, CRC(3cb81717) SHA1(9d35796381ca57e9782e0338c456e63c31d11266) )
208   ROM_LOAD( "magic.snd1.u14",0x400000, 0x400000, CRC(b4ef9977) SHA1(dedc79e5d506bb0d1649a41b9912dcc999e1da72) )
209   ROM_LOAD( "magic.snd2.u13",0x800000, 0x400000, CRC(3728f16e) SHA1(6b7da30b100d053e95aa96edf74a0474f1493dfb) )
210   ROM_LOAD( "magic.snd3.u7", 0xc00000, 0x400000, CRC(11a1cb63) SHA1(a1048d3cd580747c20eb0b4e816e7e4e0f5c8c2b) )
210211
211   ROM_REGION( 0x400000, "user4", 0 ) /* ? */
212   ROM_LOAD( "magic.s0.u9",  0x000000, 0x100000, BAD_DUMP CRC(b1d9e54e) SHA1(c4964fcab4aa3d37cbfaeac0c35be31597fdd0aa) )
213   ROM_LOAD( "magic.s1.u10", 0x100000, 0x100000, BAD_DUMP CRC(ccce2af7) SHA1(23d6e1bcf1ae9787f20b9bb14c2553b9a6d6b12c) )
214   ROM_LOAD( "magic.s2.u12", 0x200000, 0x100000, BAD_DUMP CRC(eb8d1607) SHA1(353410b20d121b0bbecef4735a692f0c1d09ce9b) )
215   ROM_LOAD( "magic.s3.u11", 0x300000, 0x100000, BAD_DUMP CRC(58c33f8e) SHA1(af09105b17b95882f7ff90ec64081e8b1d429e0b) )
212   ROM_REGION( 0x2000000, "user4", 0 ) /* Jpeg GFX data */
213   /* each of these contains 2x 0x400000 blocks */
214   ROM_LOAD( "magic_s0.u9",  0x0000000, 0x800000, CRC(a01b5b99) SHA1(e77f2e9b08a97d6118e1e307b38ea79d0177e9b8) )
215   ROM_LOAD( "magic_s1.u10", 0x0800000, 0x800000, CRC(d5a1a557) SHA1(2511ee8d08da765a2fa2d42fb504793f9e8b615c) )
216   ROM_LOAD( "magic_s2.u12", 0x1000000, 0x800000, CRC(06ed6770) SHA1(884a3e4c97a50fa926546eb6def2c11c5732ba88) )
217   ROM_LOAD( "magic_s3.u11", 0x1800000, 0x800000, CRC(71d4c252) SHA1(aeab2542b9d5fb63f4d60b808010a657a895c1d7) )
216218
217   ROM_REGION( 0x100000, "user5", 0 ) /* ? */
218   ROM_LOAD( "magic.k0.u20", 0x000000, 0x100000, BAD_DUMP CRC(aeb617fa) SHA1(4853c1c3631b798312d9146a90158490f2252119) )
219   ROM_REGION( 0x400000, "user5", 0 ) /* 'key' data */
220   ROM_LOAD( "magic.k0.u20", 0x000000, 0x400000, CRC(63ab0e9e) SHA1(c4f0b009860ee499496ed7fc1f14ef1e221c1085) )
219221   #endif
220222ROM_END
221223
src/mame/drivers/videopkr.c
r3514r3515
258258
259259#include "driver.h"
260260#include "cpu/mcs48/mcs48.h"
261#include "cpu/i8051/i8051.h"
261#include "cpu/mcs51/mcs51.h"
262262#include "sound/ay8910.h"
263263#include "sound/dac.h"
264264#include "videopkr.lh"
r3514r3515
288288static UINT8 te_40103;
289289static UINT8 ld_40103;
290290
291UINT8 ant_jckp, jckp, ant_cio, c_io, hp_1, hp_2, bell, aux3, dvrt;
292unsigned long count0, count1, count2, count3, count4;
291static UINT8 ant_jckp, jckp, ant_cio, c_io, hp_1, hp_2, bell, aux3, dvrt;
292static unsigned long count0, count1, count2, count3, count4;
293293
294294/* Baby vars */
295295static UINT8 sbp0, sbp2, sbp3;
r3514r3515
302302static tilemap *bg_tilemap;
303303
304304/* BCD to Seven Segment Decoder */
305UINT8 dec_7seg(int data)
305static UINT8 dec_7seg(int data)
306306{
307307   UINT8 segment;
308308   switch (data)
r3514r3515
324324}
325325
326326/* Display a seven digit counter on layout - Index points to less significant digit*/
327void count_7dig(unsigned long data, UINT8 index)
327static void count_7dig(unsigned long data, UINT8 index)
328328{
329329   UINT8 i;
330330   char strn[7];
r3514r3515
336336   }
337337}
338338
339PALETTE_INIT( videopkr )
339static PALETTE_INIT( videopkr )
340340{
341341   int j;
342342
r3514r3515
362362   }
363363}
364364
365PALETTE_INIT( babypkr )
365static PALETTE_INIT( babypkr )
366366{
367367   int j;
368368
r3514r3515
402402}
403403
404404
405VIDEO_START( videopkr )
405static VIDEO_START( videopkr )
406406{
407407   bg_tilemap = tilemap_create(get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
408408}
409409
410VIDEO_START( vidadcba )
410static VIDEO_START( vidadcba )
411411{
412412   bg_tilemap = tilemap_create(get_bg_tile_info, tilemap_scan_rows, 16, 8, 32, 32);
413413}
414414
415415
416VIDEO_UPDATE( videopkr )
416static VIDEO_UPDATE( videopkr )
417417{
418418   tilemap_mark_all_tiles_dirty(bg_tilemap);
419419   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
src/mame/drivers/limenko.c
r3514r3515
2626#include "driver.h"
2727#include "machine/eeprom.h"
2828#include "sound/okim6295.h"
29#include "cpu/i8051/i8051.h"
29#include "cpu/mcs51/mcs51.h"
3030
3131static tilemap *bg_tilemap, *md_tilemap, *fg_tilemap;
3232static UINT32 *bg_videoram, *md_videoram, *fg_videoram, *limenko_videoreg;
src/mame/drivers/chanbara.c
r3514r3515
163163static UINT8 scroll;
164164static UINT8 scrollhi;
165165
166VIDEO_UPDATE( chanbara )
166static VIDEO_UPDATE( chanbara )
167167{
168168   tilemap_set_scrolly(bg2_tilemap,0,scroll | (scrollhi << 8));
169169   tilemap_draw(bitmap, cliprect, bg2_tilemap, 0, 0);
src/mame/drivers/bbusters.c
r3514r3515
245245
246246/******************************************************************************/
247247
248static READ16_HANDLER( sound_cpu_r )
248static int sound_status;
249
250static READ16_HANDLER( sound_status_r )
249251{
250   return 0x01;
252   return sound_status;
251253}
252254
255static WRITE8_HANDLER( sound_status_w )
256{
257   sound_status = data;
258}
259
260static WRITE16_HANDLER( sound_cpu_w )
261{
262   if (ACCESSING_BITS_0_7)
263   {
264      soundlatch_w(machine, 0, data&0xff);
265      cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, PULSE_LINE);
266   }
267}
268
253269/* Eprom is byte wide, top half of word _must_ be 0xff */
254270static READ16_HANDLER( eprom_r )
255271{
r3514r3515
283299   return 0;
284300}
285301
286static WRITE16_HANDLER( sound_cpu_w )
287{
288   soundlatch_w(machine, 0, data&0xff);
289   cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, PULSE_LINE);
290}
291
292302static READ16_HANDLER( mechatt_gun_r )
293303{
294304   int x, y;
r3514r3515
311321   AM_RANGE(0x080000, 0x08ffff) AM_RAM AM_BASE(&bbuster_ram)
312322   AM_RANGE(0x090000, 0x090fff) AM_RAM_WRITE(bbuster_video_w) AM_BASE(&videoram16)
313323   AM_RANGE(0x0a0000, 0x0a0fff) AM_RAM AM_BASE(&spriteram16) AM_SIZE(&spriteram_size)
324   AM_RANGE(0x0a1000, 0x0a7fff) AM_RAM      /* service mode */
314325   AM_RANGE(0x0a8000, 0x0a8fff) AM_RAM AM_BASE(&spriteram16_2) AM_SIZE(&spriteram_2_size)
326   AM_RANGE(0x0a9000, 0x0affff) AM_RAM      /* service mode */
315327   AM_RANGE(0x0b0000, 0x0b1fff) AM_RAM_WRITE(bbuster_pf1_w) AM_BASE(&bbuster_pf1_data)
316328   AM_RANGE(0x0b2000, 0x0b3fff) AM_RAM_WRITE(bbuster_pf2_w) AM_BASE(&bbuster_pf2_data)
329   AM_RANGE(0x0b4000, 0x0b5fff) AM_RAM      /* service mode */
317330   AM_RANGE(0x0b8000, 0x0b8003) AM_WRITE(SMH_RAM) AM_BASE(&bbuster_pf1_scroll_data)
318331   AM_RANGE(0x0b8008, 0x0b800b) AM_WRITE(SMH_RAM) AM_BASE(&bbuster_pf2_scroll_data)
319332   AM_RANGE(0x0d0000, 0x0d0fff) AM_RAM_WRITE(paletteram16_RRRRGGGGBBBBxxxx_word_w) AM_BASE(&paletteram16)
r3514r3515
322335   AM_RANGE(0x0e0004, 0x0e0005) AM_READ_PORT("IN1")   /* Player 3 */
323336   AM_RANGE(0x0e0008, 0x0e0009) AM_READ_PORT("DSW1")   /* Dip 1 */
324337   AM_RANGE(0x0e000a, 0x0e000b) AM_READ_PORT("DSW2")   /* Dip 2 */
325   AM_RANGE(0x0e0018, 0x0e0019) AM_READ(sound_cpu_r)
338   AM_RANGE(0x0e0018, 0x0e0019) AM_READ(sound_status_r)
326339   AM_RANGE(0x0e8000, 0x0e8001) AM_READWRITE(kludge_r, gun_select_w)
327340   AM_RANGE(0x0e8002, 0x0e8003) AM_READ(control_3_r)
328341   AM_RANGE(0x0f0008, 0x0f0009) AM_WRITE(SMH_NOP)
r3514r3515
347360   AM_RANGE(0x0e0002, 0x0e0003) AM_READ_PORT("DSW1")
348361   AM_RANGE(0x0e0004, 0x0e0007) AM_READ(mechatt_gun_r)
349362   AM_RANGE(0x0e4002, 0x0e4003) AM_WRITE(SMH_NOP) /* Gun force feedback? */
350   AM_RANGE(0x0e8000, 0x0e8001) AM_READWRITE(sound_cpu_r, sound_cpu_w)
363   AM_RANGE(0x0e8000, 0x0e8001) AM_READWRITE(sound_status_r, sound_cpu_w)
351364ADDRESS_MAP_END
352365
353366/******************************************************************************/
r3514r3515
355368static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 )
356369   AM_RANGE(0x0000, 0xefff) AM_ROM
357370   AM_RANGE(0xf000, 0xf7ff) AM_RAM
358   AM_RANGE(0xf800, 0xf800) AM_READ(soundlatch_r)
371   AM_RANGE(0xf800, 0xf800) AM_READWRITE(soundlatch_r, sound_status_w)
359372ADDRESS_MAP_END
360373
361374static ADDRESS_MAP_START( sound_portmap, ADDRESS_SPACE_IO, 8 )
src/mame/drivers/gstriker.c
r3514r3515
180180
181181//UINT16 *gs_videoram3;
182182static UINT16 *gs_mixer_regs;
183static UINT16 dmmy_8f_ret;
183184
184185
185186/*** MISC READ / WRITE HANDLERS **********************************************/
186187
187188static READ16_HANDLER(dmmy_8f)
188189{
189   static int ret = 0xFFFF;
190   ret = ~ret;
191   return ret;
190   dmmy_8f_ret = ~dmmy_8f_ret;
191   return dmmy_8f_ret;
192192}
193193
194194/*** SOUND RELATED ***********************************************************/
r3514r3515
986986
987987static void mcu_init( running_machine *machine )
988988{
989   dmmy_8f_ret = 0xFFFF;
990   pending_command = 0;
991   mcu_data = 0;
992
989993   memory_install_write16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x20008a, 0x20008b, 0, 0, twrldc94_mcu_w);
990994   memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x20008a, 0x20008b, 0, 0, twrldc94_mcu_r);
991995
src/mame/drivers/strnskil.c
r3514r3515
266266   PORT_DIPUNUSED_DIPLOC( 0x10, 0x10, "SW2:5" )   /*  These four dips are unused according to the manual */
267267   PORT_DIPUNUSED_DIPLOC( 0x20, 0x20, "SW2:6" )
268268   PORT_DIPUNUSED_DIPLOC( 0x40, 0x40, "SW2:7" )
269   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW2:8" )
269   PORT_DIPNAME( 0x80, 0x00, "Freeze" ) PORT_DIPLOCATION("SW2:8") //game stands in a tight loop at $14-$16 -> $866 if this is putted off
270   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
271   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
270272
271273   PORT_START("P1")      /* d804 */
272274   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
src/mame/drivers/cosmic.c
r3514r3515
998998GFXDECODE_END
999999
10001000
1001static const char *cosmica_sample_names[] =
1001static const char *const cosmica_sample_names[] =
10021002{
10031003   "*cosmica",
10041004   "backgr.wav",
src/mame/drivers/cps2.c
r3514r3515
54035403   ROM_LOAD16_WORD_SWAP( "sz2.12m",   0x200000, 0x200000, CRC(2237bc53) SHA1(96d5693047e4cf1ed10a8ee1905cea267a278e92) )
54045404ROM_END
54055405
5406ROM_START( sfz2aj )
5406ROM_START( sfz2alj )
54075407   ROM_REGION( CODE_SIZE, "main", 0 )      /* 68000 code */
54085408   ROM_LOAD16_WORD_SWAP( "szaj.03a", 0x000000, 0x80000, CRC(a3802fe3) SHA1(c983a15ed675b22aebfe6ac55890b4e0b5eb8d48) )
54095409   ROM_LOAD16_WORD_SWAP( "szaj.04a", 0x080000, 0x80000, CRC(e7ca87c7) SHA1(e44c930b27431dd2b983d93471a440d292e7a8bb) )
r3514r3515
54325432   ROM_LOAD16_WORD_SWAP( "sz2.12m",   0x200000, 0x200000, CRC(2237bc53) SHA1(96d5693047e4cf1ed10a8ee1905cea267a278e92) )
54335433ROM_END
54345434
5435ROM_START( sfz2aa )
5435ROM_START( sfz2al )
54365436   ROM_REGION( CODE_SIZE, "main", 0 )      /* 68000 code */
54375437   ROM_LOAD16_WORD_SWAP( "szaa.03", 0x000000, 0x80000, CRC(88e7023e) SHA1(34e74ec54c05d75e5cf207abb6e536fcca233b8b) )
54385438   ROM_LOAD16_WORD_SWAP( "szaa.04", 0x080000, 0x80000, CRC(ae8ec36e) SHA1(b2f3de9e33169f6266aaabd5eae6c057ea10dcab) )
r3514r3515
54615461   ROM_LOAD16_WORD_SWAP( "sz2.12m",   0x200000, 0x200000, CRC(2237bc53) SHA1(96d5693047e4cf1ed10a8ee1905cea267a278e92) )
54625462ROM_END
54635463
5464ROM_START( sfz2ah )
5464ROM_START( sfz2alh )
54655465   ROM_REGION( CODE_SIZE, "main", 0 )      /* 68000 code */
54665466   ROM_LOAD16_WORD_SWAP( "szah.03", 0x000000, 0x80000, CRC(06f93d1d) SHA1(495de176ba55b35270fc05f19edf17a0f249ff0e) )
54675467   ROM_LOAD16_WORD_SWAP( "szah.04", 0x080000, 0x80000, CRC(e62ee914) SHA1(def4f27c1b64be5143234f1f402260adae66cdde) )
r3514r3515
54905490   ROM_LOAD16_WORD_SWAP( "sz2.12m",   0x200000, 0x200000, CRC(2237bc53) SHA1(96d5693047e4cf1ed10a8ee1905cea267a278e92) )
54915491ROM_END
54925492
5493ROM_START( sfz2ab )
5493ROM_START( sfz2alb )
54945494   ROM_REGION( CODE_SIZE, "main", 0 )      /* 68000 code */
54955495   ROM_LOAD16_WORD_SWAP( "szab.03", 0x000000, 0x80000, CRC(cb436eca) SHA1(406bea614429f78c0150c2f5042abc8673a6722e) )
54965496   ROM_LOAD16_WORD_SWAP( "szab.04", 0x080000, 0x80000, CRC(14534bea) SHA1(8fff2cd9221ef12de9364cc15429b6df6bacc48e) )
r3514r3515
74567456GAME( 1996, sfz2br1,  sfa2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 (Brazil 960304)", 0 )
74577457GAME( 1996, sfz2h,    sfa2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 (Hispanic 960304)", 0 )
74587458GAME( 1996, sfz2n,    sfa2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 (Oceania 960229)", 0 )
7459GAME( 1996, sfz2aj,   sfa2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 Alpha (Japan 960805)", 0 )
7460GAME( 1996, sfz2ah,   sfa2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 Alpha (Hispanic 960813)", 0 )
7461GAME( 1996, sfz2ab,   sfa2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 Alpha (Brazil 960813)", 0 )
7462GAME( 1996, sfz2aa,   sfa2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 Alpha (Asia 960826)", 0 )
7459GAME( 1996, sfz2al,   0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 Alpha (Asia 960826)", 0 )
7460GAME( 1996, sfz2alj,  sfz2al,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 Alpha (Japan 960805)", 0 )
7461GAME( 1996, sfz2alh,  sfz2al,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 Alpha (Hispanic 960813)", 0 )
7462GAME( 1996, sfz2alb,  sfz2al,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 Alpha (Brazil 960813)", 0 )
74637463GAME( 1996, spf2t,    0,        cps2, cps2_2p2b, cps2,     ROT0,   "Capcom", "Super Puzzle Fighter II Turbo (USA 960620)", 0 )
74647464GAME( 1996, spf2xj,   spf2t,    cps2, cps2_2p2b, cps2,     ROT0,   "Capcom", "Super Puzzle Fighter II X (Japan 960531)", 0 )
74657465GAME( 1996, spf2ta,   spf2t,    cps2, cps2_2p2b, cps2,     ROT0,   "Capcom", "Super Puzzle Fighter II Turbo (Asia 960529)", 0 )
src/mame/drivers/namcos12.c
r3514r3515
10081008
10091009static UINT32 m_n_dmaoffset;
10101010static UINT32 m_n_dmabias;
1011static UINT32 m_n_tektagdmaoffset = 0xffffffff;
1011static UINT32 m_n_tektagdmaoffset;
10121012
10131013static WRITE32_HANDLER( dmaoffset_w )
10141014{
r3514r3515
13301330   return ret;
13311331}
13321332
1333static int s12_lastpB = 0x50, s12_setstate = 0, s12_setnum, s12_settings[8];
1333static int s12_lastpB, s12_setstate, s12_setnum, s12_settings[8];
13341334
13351335static READ8_HANDLER( s12_mcu_portB_r )
13361336{
r3514r3515
14381438   psx_dma_install_read_handler( 5, namcos12_rom_read );
14391439
14401440   memory_configure_bank( 1, 0, memory_region_length( machine, "user2" ) / 0x200000, memory_region( machine, "user2" ), 0x200000 );
1441
1442   s12_porta = 0;
1443   s12_rtcstate = 0;
1444   s12_lastpB = 0x50;
1445   s12_setstate = 0;
1446   s12_setnum = 0;
1447   memset(s12_settings, 0, sizeof(s12_settings));
1448
1449   m_n_tektagdmaoffset = 0xffffffff;
1450   m_n_dmaoffset = 0;
1451   m_n_dmabias = 0;
14411452   m_n_bankoffset = 0;
14421453   memory_set_bank( 1, 0 );
14431454
src/mame/drivers/missb2.c
r3514r3515
426426   ROM_REGION( 0x20000, "oki", 0 ) /* samples */
427427   ROM_LOAD( "msbub2-u.13", 0x00000, 0x20000, BAD_DUMP CRC(14f07386) SHA1(097897d92226f900e11dbbdd853aff3ac46ff016) )
428428
429   /* I doubt this prom is on the board, it's loaded so we can share video emulation with bubble bobble */
429430   ROM_REGION( 0x0100, "proms", 0 )
430431   ROM_LOAD( "a71-25.bin",  0x0000, 0x0100, CRC(2d0f8545) SHA1(089c31e2f614145ef2743164f7b52ae35bc06808) )   /* video timing - taken from bublbobl */
431432ROM_END
r3514r3515
444445
445446/* Game Drivers */
446447
447GAME( 1996, missb2, bublbobl, missb2, missb2, missb2, ROT0,  "Alpha Co", "Miss Bubble 2", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
448GAME( 1996, missb2, 0, missb2, missb2, missb2, ROT0,  "Alpha Co", "Miss Bubble 2", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
src/mame/drivers/ddealer.c
r3514r3515
337337
338338
339339
340WRITE16_HANDLER( back_vram_w )
340static WRITE16_HANDLER( back_vram_w )
341341{
342342   COMBINE_DATA(&back_vram[offset]);
343343   tilemap_mark_tile_dirty(back_tilemap,offset);
344344}
345345
346346
347WRITE16_HANDLER( ddealer_vregs_w )
347static WRITE16_HANDLER( ddealer_vregs_w )
348348{
349349   COMBINE_DATA(&ddealer_vregs[offset]);
350350}
src/mame/drivers/bionicc.c
r3514r3515
203203   PORT_DIPSETTING(      0x0018, DEF_STR( 1C_6C ) )
204204   PORT_SERVICE_DIPLOC(  0x0040, IP_ACTIVE_LOW, "SWB:7" )
205205   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Flip_Screen ) )   PORT_DIPLOCATION("SWB:8")
206   PORT_DIPSETTING(      0x0080, DEF_STR( Off ))
206   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
207207   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
208208   PORT_DIPNAME( 0x0300, 0x0300, DEF_STR( Lives ) )      PORT_DIPLOCATION("SWA:1,2")
209209   PORT_DIPSETTING(      0x0300, "3" )
r3514r3515
213213   PORT_DIPNAME( 0x0400, 0x0400, DEF_STR( Cabinet ) )      PORT_DIPLOCATION("SWA:3")
214214   PORT_DIPSETTING(      0x0400, DEF_STR( Upright ) )
215215   PORT_DIPSETTING(      0x0000, DEF_STR( Cocktail ) )
216   PORT_DIPNAME( 0x1800, 0x1800, DEF_STR( Bonus_Life ) )   PORT_DIPLOCATION("SWA:4,5")
217   PORT_DIPSETTING(      0x1800, "20K, 40K, every 60K")
218   PORT_DIPSETTING(      0x1000, "30K, 50K, every 70K" )
219   PORT_DIPSETTING(      0x0800, "20K and 60K only")
220   PORT_DIPSETTING(      0x0000, "30K and 70K only" )
216   PORT_DIPNAME( 0x1800, 0x1800, DEF_STR( Bonus_Life ) )   PORT_DIPLOCATION("SWA:4,5")   /* table at 0x00483a */
217   PORT_DIPSETTING(      0x1800, "20k 40k 100k 60k+" )
218   PORT_DIPSETTING(      0x1000, "30k 50k 120k 70k+" )
219   PORT_DIPSETTING(      0x0800, "20k 60k")
220   PORT_DIPSETTING(      0x0000, "30k 70k" )
221221   PORT_DIPNAME( 0x6000, 0x4000, DEF_STR( Difficulty ) )   PORT_DIPLOCATION("SWA:6,7")
222222   PORT_DIPSETTING(      0x4000, DEF_STR( Easy ) )
223   PORT_DIPSETTING(      0x6000, DEF_STR( Medium ))
224   PORT_DIPSETTING(      0x2000, DEF_STR( Hard ))
223   PORT_DIPSETTING(      0x6000, DEF_STR( Medium ) )
224   PORT_DIPSETTING(      0x2000, DEF_STR( Hard ) )
225225   PORT_DIPSETTING(      0x0000, DEF_STR( Hardest ) )
226   PORT_DIPNAME( 0x8000, 0x8000, "Freeze" )            PORT_DIPLOCATION("SWA:8") /* Listed as "Unused" */
227   PORT_DIPSETTING(      0x8000, DEF_STR( Off ))
226   PORT_DIPNAME( 0x8000, 0x8000, "Freeze" )            PORT_DIPLOCATION("SWA:8")     /* Listed as "Unused" */
227   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
228228   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
229229
230230   PORT_START("P1")
231231   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 )
232232   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 )
233233   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY
234   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY
235   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY
236   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY
234   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )  PORT_8WAY
235   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )  PORT_8WAY
236   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )    PORT_8WAY
237237   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
238238   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
239239
r3514r3515
241241   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL
242242   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
243243   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_COCKTAIL
244   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL
245   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL
246   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_COCKTAIL
244   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )  PORT_8WAY PORT_COCKTAIL
245   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )  PORT_8WAY PORT_COCKTAIL
246   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )    PORT_8WAY PORT_COCKTAIL
247247   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
248248   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
249249INPUT_PORTS_END
src/mame/drivers/sliver.c
r3514r3515
6767#include "driver.h"
6868#include "deprecat.h"
6969#include "sound/okim6295.h"
70#include "cpu/i8051/i8051.h"
70#include "cpu/mcs51/mcs51.h"
7171
7272#define FIFO_SIZE 1024
7373#define IO_SIZE    0x100
r3514r3515
8080static UINT16 fifo[FIFO_SIZE];
8181static UINT16 fptr;
8282
83static int jpeg_addr=-1;
83static int jpeg_addr;
8484static UINT16 jpeg1,jpeg2;
8585static int jpeg_h=0;
8686static int jpeg_w=0;
r3514r3515
391391static WRITE16_HANDLER(sound_w)
392392{
393393      soundlatch_w(machine,0,data & 0xff);
394      cpunum_set_input_line(machine, 1, I8051_INT0_LINE, HOLD_LINE);
394      cpunum_set_input_line(machine, 1, MCS51_INT0_LINE, HOLD_LINE);
395395}
396396
397397static ADDRESS_MAP_START( sliver_map, ADDRESS_SPACE_PROGRAM, 16 )
r3514r3515
588588
589589static DRIVER_INIT(sliver)
590590{
591   jpeg_addr = -1;
591592   colorram=auto_malloc(256*3);
592593}
593594
src/mame/drivers/snesb.c
r3514r3515
650650   0x2b,0x25,0x28,0x2f,0x26,0x22,0x23,0x2a,0x2d,0x24,0x2e,0x20,0x27,0x2c,0x21,0x29
651651};
652652
653DRIVER_INIT( sblast2b )
653static DRIVER_INIT( sblast2b )
654654{
655655   int i, cipherText, plainText, newAddress;
656656   UINT8 *src = memory_region(machine, "user7");
src/mame/drivers/toaplan2.c
r3514r3515
1515    Name        Board No      Maker         Game name
1616    ----------------------------------------------------------------------------
1717    tekipaki    TP-020        Toaplan       Teki Paki
18    ghox        TP-021        Toaplan       Ghox
18    ghox        TP-021        Toaplan       Ghox (Spinner with single up/down axis control)
19    ghoxj       TP-021        Toaplan       Ghox (8-Way Joystick controls)
1920    dogyuun     TP-022        Toaplan       Dogyuun
2021    kbash       TP-023        Toaplan       Knuckle Bash
2122    kbash2      bootleg       Toaplan       Knuckle Bash 2
r3514r3515
251252#include "sound/3812intf.h"
252253#include "sound/okim6295.h"
253254#include "sound/ymz280b.h"
255#include "includes/toaplan2.h"
254256
255257
256258/**************** Machine stuff ******************/
r3514r3515
269271static UINT16 *V25_shared_ram;         /* Really 8bit RAM connected to Z180 */
270272static UINT16 *fixeight_sec_cpu_mem;
271273
272/************ Video RAM related values ************/
273extern UINT16 *toaplan2_txvideoram16;
274extern UINT16 *toaplan2_txvideoram16_offs;
275extern UINT16 *toaplan2_txscrollram16;
276extern UINT16 *toaplan2_tx_gfxram16;
277size_t toaplan2_tx_vram_size;
278size_t toaplan2_tx_offs_vram_size;
279size_t toaplan2_tx_scroll_vram_size;
280size_t batrider_paletteram16_size;
281
282274/********** Status related values **********/
283275int toaplan2_sub_cpu = 0;
284static int mcu_data = 0;
285static int video_status;
276static UINT16 mcu_data = 0;
277static UINT16 video_status;
286278static INT8 old_p1_paddle_h;      /* For Ghox */
287279static INT8 old_p2_paddle_h;
288static int current_bank;         /* Z80 bank used in Battle Garegga and Batrider */
280static INT8 current_bank;         /* Z80 bank used in Battle Garegga and Batrider */
289281static int raizing_sndirq_line;      /* IRQ4 for batrider, IRQ2 for bbakraid */
290static int raizing_Z80_busreq;
282static UINT16 raizing_Z80_busreq;
291283static int bbakraid_unlimited_ver;
292284
293/**************** Video stuff ******************/
294WRITE16_HANDLER( toaplan2_0_voffs_w );
295WRITE16_HANDLER( toaplan2_1_voffs_w );
296
297READ16_HANDLER ( toaplan2_0_videoram16_r );
298READ16_HANDLER ( toaplan2_1_videoram16_r );
299WRITE16_HANDLER( toaplan2_0_videoram16_w );
300WRITE16_HANDLER( toaplan2_1_videoram16_w );
301
302READ16_HANDLER ( toaplan2_txvideoram16_r );
303WRITE16_HANDLER( toaplan2_txvideoram16_w );
304READ16_HANDLER ( toaplan2_txvideoram16_offs_r );
305WRITE16_HANDLER( toaplan2_txvideoram16_offs_w );
306READ16_HANDLER ( toaplan2_txscrollram16_r );
307WRITE16_HANDLER( toaplan2_txscrollram16_w );
308READ16_HANDLER ( toaplan2_tx_gfxram16_r );
309WRITE16_HANDLER( toaplan2_tx_gfxram16_w );
310READ16_HANDLER ( raizing_tx_gfxram16_r );
311WRITE16_HANDLER( raizing_tx_gfxram16_w );
312
313WRITE16_HANDLER( toaplan2_0_scroll_reg_select_w );
314WRITE16_HANDLER( toaplan2_1_scroll_reg_select_w );
315WRITE16_HANDLER( toaplan2_0_scroll_reg_data_w );
316WRITE16_HANDLER( toaplan2_1_scroll_reg_data_w );
317
318WRITE16_HANDLER( batrider_objectbank_w );
319WRITE16_HANDLER( batrider_textdata_decode );
320
321VIDEO_EOF( toaplan2_0 );
322VIDEO_EOF( toaplan2_1 );
323VIDEO_START( toaplan2_0 );
324VIDEO_START( toaplan2_1 );
325VIDEO_START( truxton2_0 );
326VIDEO_START( bgaregga_0 );
327VIDEO_START( batrider_0 );
328VIDEO_UPDATE( toaplan2_0 );
329VIDEO_UPDATE( truxton2_0 );
330VIDEO_UPDATE( dogyuun_1 );
331VIDEO_UPDATE( batsugun_1 );
332VIDEO_UPDATE( batrider_0 );
333VIDEO_UPDATE( mahoudai_0 );
334
335
336/********* Video wrappers for PIPIBIBI *********/
337READ16_HANDLER ( pipibibi_videoram16_r );
338WRITE16_HANDLER( pipibibi_videoram16_w );
339READ16_HANDLER ( pipibibi_spriteram16_r );
340WRITE16_HANDLER( pipibibi_spriteram16_w );
341WRITE16_HANDLER( pipibibi_scroll_w );
342
343
344/***************** Sound stuff *****************/
345void dogyuun_okisnd_w(running_machine *machine, int data);
346void kbash_okisnd_w(running_machine *machine, int data);
347void fixeight_okisnd_w(running_machine *machine, int data);
348void batsugun_okisnd_w(running_machine *machine, int data);
349
350285static MACHINE_RESET(batsugun);
351286#if USE_V25
352287static READ16_HANDLER( batsugun_share_r );
r3514r3515
401336   UINT8 *Z80 = (UINT8 *)memory_region(machine, "audio");
402337
403338   // Set Z80 bank switch - default bank is 2
404   current_bank = 2;
405   memory_set_bankptr(1, &Z80[0x10000]);
339   current_bank = 4;
340   memory_configure_bank(1, 0, 10, Z80, 0x4000);
341   memory_set_bank(1, 4);
406342
407343   if (memory_region(machine, "oki1") != NULL)
408344      NMK112_init(0, "oki1", "oki2");
r3514r3515
411347   MACHINE_RESET_CALL(toaplan2);
412348}
413349
350static void register_state_save(void)
351{
352   state_save_register_global(mcu_data);
353   state_save_register_global(video_status);
354   state_save_register_global(old_p1_paddle_h);
355   state_save_register_global(old_p2_paddle_h);
356   state_save_register_global(current_bank);
357   state_save_register_global(raizing_Z80_busreq);
358}
359
414360static DRIVER_INIT( T2_Z80 )      /* init_t2_Z80(); */
415361{
416362   toaplan2_sub_cpu = CPU_2_Z80;
363   register_state_save();
417364}
418365
419366static DRIVER_INIT( T2_Z180 )
420367{
421368   toaplan2_sub_cpu = CPU_2_HD647180;
369   register_state_save();
422370}
423371
424372static DRIVER_INIT( T2_V25 )
425373{
426374   toaplan2_sub_cpu = CPU_2_V25;
375   register_state_save();
427376}
428377
429378static DRIVER_INIT( T2_noZ80 )
430379{
431380   toaplan2_sub_cpu = CPU_2_NONE;
381   register_state_save();
432382}
433383
434384static DRIVER_INIT( fixeight )
r3514r3515
441391   #endif
442392
443393   toaplan2_sub_cpu = CPU_2_V25;
394   register_state_save();
444395}
445396
446397static DRIVER_INIT( fixeighb )
r3514r3515
449400   memory_set_bankptr(1, &bgdata[0x40000]); /* $80000 - $fffff */
450401
451402   toaplan2_sub_cpu = CPU_2_NONE;
403   register_state_save();
452404}
453405
454406static DRIVER_INIT( pipibibi )
r3514r3515
530482   }
531483
532484   toaplan2_sub_cpu = CPU_2_Z80;
485   register_state_save();
533486}
534487
535488static DRIVER_INIT( batrider )
536489{
537490   raizing_sndirq_line = 4;
538491   toaplan2_sub_cpu = CPU_2_Z80;
492   register_state_save();
539493}
540494
541495static DRIVER_INIT( bbakraid )
r3514r3515
543497   bbakraid_unlimited_ver = 0;
544498   raizing_sndirq_line = 2;
545499   toaplan2_sub_cpu = CPU_2_Z80;
500   register_state_save();
546501}
547502
548503static DRIVER_INIT( bbakradu )
r3514r3515
550505   bbakraid_unlimited_ver = 1;
551506   raizing_sndirq_line = 2;
552507   toaplan2_sub_cpu = CPU_2_Z80;
508   register_state_save();
553509}
554510
555511
r3514r3515
10761032
10771033static WRITE8_HANDLER( bgaregga_bankswitch_w )
10781034{
1079   UINT8 *RAM = (UINT8 *)memory_region(machine, "audio");
1080   int bankaddress;
1081   int bank;
1035   int bank = (data & 0x0f) - 10 + 4;
10821036
1083   bank = (data & 0x0f) - 10;
1084
10851037   if (bank != current_bank)
10861038   {
10871039      current_bank = bank;
1088      bankaddress = 0x10000 + 0x4000 * current_bank;
1089      memory_set_bankptr(1, &RAM[bankaddress]);
1040      memory_set_bank(1, bank);
10901041   }
10911042}
10921043
r3514r3515
11231074
11241075static WRITE8_HANDLER( batrider_bankswitch_w )
11251076{
1126   UINT8 *RAM = (UINT8 *)memory_region(machine, "audio");
1127   int bankaddress;
1128   int bank;
1077   int bank = data & 0x0f;
1078   bank = (bank > 1) ? bank + 2 : bank;
11291079
1130   bank = data & 0x0f;
1131
11321080   if (bank != current_bank)
11331081   {
11341082      current_bank = bank;
1135      logerror("Z80 cpu set bank #%d\n", bank);
1136      if (bank > 1)
1137         bankaddress = 0x10000 + 0x4000 * (current_bank - 2);
1138      else
1139         bankaddress = 0x4000 * current_bank;
1140      memory_set_bankptr(1, &RAM[bankaddress]);
1083      memory_set_bank(1, bank);
11411084   }
11421085}
11431086
r3514r3515
42004143ROM_END
42014144
42024145
4203ROM_START( ghox )
4146ROM_START( ghox ) /* Spinner with single axis (up/down) controls */
42044147   ROM_REGION( 0x040000, "main", 0 )         /* Main 68K code */
42054148   ROM_LOAD16_BYTE( "tp021-01.u10", 0x000000, 0x020000, CRC(9e56ac67) SHA1(daf241d9e55a6e60fc004ed61f787641595b1e62) )
42064149   ROM_LOAD16_BYTE( "tp021-02.u11", 0x000001, 0x020000, CRC(15cac60f) SHA1(6efa3a50a5dfe6ef4072738d6a7d0d95dca8a675) )
r3514r3515
42174160ROM_END
42184161
42194162
4220ROM_START( ghoxa )
4163ROM_START( ghoxj ) /* 8-way joystick for controls */
42214164   ROM_REGION( 0x040000, "main", 0 )         /* Main 68K code */
42224165   ROM_LOAD16_BYTE( "tp021-01a.u10", 0x000000, 0x020000, CRC(c11b13c8) SHA1(da7defc1d3b6ddded910ba56c31fbbdb5ed57b09) )
42234166   ROM_LOAD16_BYTE( "tp021-02a.u11", 0x000001, 0x020000, CRC(8d426767) SHA1(1ed4a8bcbf4352257e7d58cb5c2c91eb48c2f047) )
r3514r3515
50484991/* Whoopee  init   to be changed to T2_Z180   when (if) HD647180 is dumped */
50494992
50504993/*  ( YEAR  NAME      PARENT    MACHINE   INPUT     INIT      MONITOR COMPANY    FULLNAME     FLAGS ) */
5051GAME( 1991, tekipaki, 0,        tekipaki, tekipaki, T2_Z180,  ROT0,   "Toaplan", "Teki Paki", GAME_NO_SOUND )
5052GAME( 1991, ghox,     0,        ghox,     ghox,     T2_Z180,  ROT270, "Toaplan", "Ghox (set 1)", GAME_NO_SOUND )
5053GAME( 1991, ghoxa,    ghox,     ghox,     ghox,     T2_Z180,  ROT270, "Toaplan", "Ghox (set 2)", GAME_NO_SOUND )
5054GAME( 1992, dogyuun,  0,        dogyuun,  dogyuun,  T2_V25,   ROT270, "Toaplan", "Dogyuun", GAME_NO_SOUND )
5055GAME( 1993, kbash,    0,        kbash,    kbash,    T2_V25,   ROT0,   "Toaplan", "Knuckle Bash", GAME_IMPERFECT_SOUND )
5056GAME( 1999, kbash2,   0,        kbash2,   kbash2,   T2_noZ80, ROT0,   "bootleg", "Knuckle Bash 2 (bootleg)", 0 )
5057GAME( 1992, truxton2, 0,        truxton2, truxton2, T2_noZ80, ROT270, "Toaplan", "Truxton II / Tatsujin Oh", 0 )
5058GAME( 1991, pipibibs, 0,        pipibibs, pipibibs, T2_Z80,   ROT0,   "Toaplan", "Pipi & Bibis / Whoopee!! (Z80 sound cpu)", 0 )
5059GAME( 1991, whoopee,  pipibibs, whoopee,  whoopee,  T2_Z80,   ROT0,   "Toaplan", "Whoopee!! / Pipi & Bibis", 0 )
5060GAME( 1991, pipibibi, pipibibs, pipibibi, pipibibi, pipibibi, ROT0,   "[Toaplan] Ryouta Kikaku", "Pipi & Bibis / Whoopee!! (bootleg ?)", 0 )
5061GAME( 1992, fixeight, 0,        fixeight, fixeight, fixeight, ROT270, "Toaplan", "FixEight", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_NOT_WORKING )
5062GAME( 1992, fixeighb, fixeight, fixeighb, fixeighb, fixeighb, ROT270, "bootleg", "FixEight (bootleg)", 0 )
5063GAME( 1992, grindstm, vfive,    vfive,    grindstm, T2_V25,   ROT270, "Toaplan", "Grind Stormer", GAME_NO_SOUND )
5064GAME( 1992, grindsta, vfive,    vfive,    grindstm, T2_V25,   ROT270, "Toaplan", "Grind Stormer (older set)", GAME_NO_SOUND )
5065GAME( 1993, vfive,    0,        vfive,    vfive,    T2_V25,   ROT270, "Toaplan", "V-Five (Japan)", GAME_NO_SOUND )
5066GAME( 1993, batsugun, 0,        batsugun, batsugun, T2_V25,   ROT270, "Toaplan", "Batsugun (set 1)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
5067GAME( 1993, batsugna, batsugun, batsugun, batsugun, T2_V25,   ROT270, "Toaplan", "Batsugun (set 2)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
5068GAME( 1993, batugnsp, batsugun, batsugun, batsugun, T2_V25,   ROT270, "Toaplan", "Batsugun (Special Ver.)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
5069GAME( 1994, snowbro2, 0,        snowbro2, snowbro2, T2_noZ80, ROT0,   "[Toaplan] Hanafram", "Snow Bros. 2 - With New Elves / Otenki Paradise", 0 )
5070GAME( 1993, mahoudai, 0,        mahoudai, mahoudai, T2_Z80,   ROT270, "Raizing (Able license)", "Mahou Daisakusen (Japan)", 0 )
5071GAME( 1993, sstriker, mahoudai, mahoudai, sstriker, T2_Z80,   ROT270, "Raizing", "Sorcer Striker (World)" , 0) // from korean board
5072GAME( 1993, sstrikra, mahoudai, mahoudai, sstriker, T2_Z80,   ROT270, "Raizing", "Sorcer Striker (World, alt)" , 0) // verified on two different PCBs
5073GAME( 1994, shippumd, 0,        shippumd, shippumd, T2_Z80,   ROT270, "Raizing / Eighting", "Shippu Mahou Daisakusen (Japan)", 0 )
5074GAME( 1994, kingdmgp, shippumd, shippumd, kingdmgp, T2_Z80,   ROT270, "Raizing / Eighting", "Kingdom Grandprix (World)" , 0) // from korean board, missing letters on credits screen but this is correct
5075GAME( 1996, bgaregga, 0,        bgaregga, bgaregga, T2_Z80,   ROT270, "Raizing / Eighting", "Battle Garegga (Europe / USA / Japan / Asia) (Sat Feb 3 1996)", 0 )
5076GAME( 1996, bgareghk, bgaregga, bgaregga, bgareghk, T2_Z80,   ROT270, "Raizing / Eighting", "Battle Garegga (Austria / Hong Kong) (Sat Feb 3 1996)", 0 )
5077GAME( 1996, bgaregnv, bgaregga, bgaregga, bgareghk, T2_Z80,   ROT270, "Raizing / Eighting", "Battle Garegga - New Version (Austria / Hong Kong) (Sat Mar 2 1996)" , 0) // displays New Version only when set to HK
5078GAME( 1996, bgaregt2, bgaregga, bgaregga, bgaregga, T2_Z80,   ROT270, "Raizing / Eighting", "Battle Garegga - Type 2 (Europe / USA / Japan / Asia) (Sat Mar 2 1996)" , 0) // displays Type 2 only when set to Europe
5079GAME( 1996, bgaregcn, bgaregga, bgaregga, bgaregcn, T2_Z80,   ROT270, "Raizing / Eighting", "Battle Garegga - Type 2 (Denmark / China) (Tue Apr 2 1996)", 0 ) // displays Type 2 only when set to Denmark
5080GAME( 1998, batrider, 0,        batrider, batrider, batrider, ROT270, "Raizing / Eighting", "Armed Police Batrider - B Version (Japan) (Fri Feb 13 1998)", 0 )
5081GAME( 1998, batridra, batrider, batrider, batrider, batrider, ROT270, "Raizing / Eighting", "Armed Police Batrider (Japan) (Mon Dec 22 1997)", 0 )
5082GAME( 1998, batridrk, batrider, batrider, batrider, batrider, ROT270, "Raizing / Eighting", "Armed Police Batrider (Korea) (Fri Feb 13 1998)", 0 )
5083GAME( 1999, bbakraid, 0,        bbakraid, bbakraid, bbakraid, ROT270, "Eighting", "Battle Bakraid (Japan) (Wed Apr 7 1999)", 0)
5084GAME( 1999, bbakradu, bbakraid, bbakraid, bbakraid, bbakradu, ROT270, "Eighting", "Battle Bakraid - Unlimited Version (Japan) (Tue Jun 8 1999)", 0)
4994GAME( 1991, tekipaki, 0,        tekipaki, tekipaki, T2_Z180,  ROT0,   "Toaplan", "Teki Paki", GAME_NO_SOUND | GAME_SUPPORTS_SAVE )
4995GAME( 1991, ghox,     0,        ghox,     ghox,     T2_Z180,  ROT270, "Toaplan", "Ghox (Spinner with Up/Down Axis)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE )
4996GAME( 1991, ghoxj,    ghox,     ghox,     ghox,     T2_Z180,  ROT270, "Toaplan", "Ghox (8-Way Joystick)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE )
4997GAME( 1992, dogyuun,  0,        dogyuun,  dogyuun,  T2_V25,   ROT270, "Toaplan", "Dogyuun", GAME_NO_SOUND | GAME_SUPPORTS_SAVE )
4998GAME( 1993, kbash,    0,        kbash,    kbash,    T2_V25,   ROT0,   "Toaplan", "Knuckle Bash", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
4999GAME( 1999, kbash2,   0,        kbash2,   kbash2,   T2_noZ80, ROT0,   "bootleg", "Knuckle Bash 2 (bootleg)", GAME_SUPPORTS_SAVE )
5000GAME( 1992, truxton2, 0,        truxton2, truxton2, T2_noZ80, ROT270, "Toaplan", "Truxton II / Tatsujin Oh", GAME_SUPPORTS_SAVE )
5001GAME( 1991, pipibibs, 0,        pipibibs, pipibibs, T2_Z80,   ROT0,   "Toaplan", "Pipi & Bibis / Whoopee!! (Z80 sound cpu)", GAME_SUPPORTS_SAVE )
5002GAME( 1991, whoopee,  pipibibs, whoopee,  whoopee,  T2_Z80,   ROT0,   "Toaplan", "Whoopee!! / Pipi & Bibis", GAME_SUPPORTS_SAVE )
5003GAME( 1991, pipibibi, pipibibs, pipibibi, pipibibi, pipibibi, ROT0,   "[Toaplan] Ryouta Kikaku", "Pipi & Bibis / Whoopee!! (bootleg ?)", GAME_SUPPORTS_SAVE )
5004GAME( 1992, fixeight, 0,        fixeight, fixeight, fixeight, ROT270, "Toaplan", "FixEight", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
5005GAME( 1992, fixeighb, fixeight, fixeighb, fixeighb, fixeighb, ROT270, "bootleg", "FixEight (bootleg)", GAME_SUPPORTS_SAVE )
5006GAME( 1992, grindstm, vfive,    vfive,    grindstm, T2_V25,   ROT270, "Toaplan", "Grind Stormer", GAME_NO_SOUND | GAME_SUPPORTS_SAVE )
5007GAME( 1992, grindsta, vfive,    vfive,    grindstm, T2_V25,   ROT270, "Toaplan", "Grind Stormer (older set)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE )
5008GAME( 1993, vfive,    0,        vfive,    vfive,    T2_V25,   ROT270, "Toaplan", "V-Five (Japan)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE )
5009GAME( 1993, batsugun, 0,        batsugun, batsugun, T2_V25,   ROT270, "Toaplan", "Batsugun (set 1)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
5010GAME( 1993, batsugna, batsugun, batsugun, batsugun, T2_V25,   ROT270, "Toaplan", "Batsugun (set 2)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
5011GAME( 1993, batugnsp, batsugun, batsugun, batsugun, T2_V25,   ROT270, "Toaplan", "Batsugun (Special Ver.)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
5012GAME( 1994, snowbro2, 0,        snowbro2, snowbro2, T2_noZ80, ROT0,   "[Toaplan] Hanafram", "Snow Bros. 2 - With New Elves / Otenki Paradise", GAME_SUPPORTS_SAVE )
5013GAME( 1993, mahoudai, 0,        mahoudai, mahoudai, T2_Z80,   ROT270, "Raizing (Able license)", "Mahou Daisakusen (Japan)", GAME_SUPPORTS_SAVE )
5014GAME( 1993, sstriker, mahoudai, mahoudai, sstriker, T2_Z80,   ROT270, "Raizing", "Sorcer Striker (World)" , GAME_SUPPORTS_SAVE ) // from korean board
5015GAME( 1993, sstrikra, mahoudai, mahoudai, sstriker, T2_Z80,   ROT270, "Raizing", "Sorcer Striker (World, alt)" , GAME_SUPPORTS_SAVE ) // verified on two different PCBs
5016GAME( 1994, shippumd, 0,        shippumd, shippumd, T2_Z80,   ROT270, "Raizing / Eighting", "Shippu Mahou Daisakusen (Japan)", GAME_SUPPORTS_SAVE )
5017GAME( 1994, kingdmgp, shippumd, shippumd, kingdmgp, T2_Z80,   ROT270, "Raizing / Eighting", "Kingdom Grandprix (World)" , GAME_SUPPORTS_SAVE ) // from korean board, missing letters on credits screen but this is correct
5018GAME( 1996, bgaregga, 0,        bgaregga, bgaregga, T2_Z80,   ROT270, "Raizing / Eighting", "Battle Garegga (Europe / USA / Japan / Asia) (Sat Feb 3 1996)", GAME_SUPPORTS_SAVE )
5019GAME( 1996, bgareghk, bgaregga, bgaregga, bgareghk, T2_Z80,   ROT270, "Raizing / Eighting", "Battle Garegga (Austria / Hong Kong) (Sat Feb 3 1996)", GAME_SUPPORTS_SAVE )
5020GAME( 1996, bgaregnv, bgaregga, bgaregga, bgareghk, T2_Z80,   ROT270, "Raizing / Eighting", "Battle Garegga - New Version (Austria / Hong Kong) (Sat Mar 2 1996)" , GAME_SUPPORTS_SAVE ) // displays New Version only when set to HK
5021GAME( 1996, bgaregt2, bgaregga, bgaregga, bgaregga, T2_Z80,   ROT270, "Raizing / Eighting", "Battle Garegga - Type 2 (Europe / USA / Japan / Asia) (Sat Mar 2 1996)" , GAME_SUPPORTS_SAVE ) // displays Type 2 only when set to Europe
5022GAME( 1996, bgaregcn, bgaregga, bgaregga, bgaregcn, T2_Z80,   ROT270, "Raizing / Eighting", "Battle Garegga - Type 2 (Denmark / China) (Tue Apr 2 1996)", GAME_SUPPORTS_SAVE ) // displays Type 2 only when set to Denmark
5023GAME( 1998, batrider, 0,        batrider, batrider, batrider, ROT270, "Raizing / Eighting", "Armed Police Batrider - B Version (Japan) (Fri Feb 13 1998)", GAME_SUPPORTS_SAVE )
5024GAME( 1998, batridra, batrider, batrider, batrider, batrider, ROT270, "Raizing / Eighting", "Armed Police Batrider (Japan) (Mon Dec 22 1997)", GAME_SUPPORTS_SAVE )
5025GAME( 1998, batridrk, batrider, batrider, batrider, batrider, ROT270, "Raizing / Eighting", "Armed Police Batrider (Korea) (Fri Feb 13 1998)", GAME_SUPPORTS_SAVE )
5026GAME( 1999, bbakraid, 0,        bbakraid, bbakraid, bbakraid, ROT270, "Eighting", "Battle Bakraid (Japan) (Wed Apr 7 1999)", GAME_SUPPORTS_SAVE )
5027GAME( 1999, bbakradu, bbakraid, bbakraid, bbakraid, bbakradu, ROT270, "Eighting", "Battle Bakraid - Unlimited Version (Japan) (Tue Jun 8 1999)", GAME_SUPPORTS_SAVE )
src/mame/drivers/magicfly.c
r3514r3515
2525    *** Hardware notes ***
2626
2727
28    - CPU  1x R6502P
29    - CRTC 1x MC6845P
30    - RAMs 1x MK48Z02B-20  CMOS 2K*8 zeropower SRAM (near prg ROM)
31           2x HM6116LP-4   2K*8 SRAM (near GFX ROMs)
32    - CLK  1x oscillator 10.000 MHz
28    - CPU:  1x R6502P.
3329
34    - ROMs 1x AM27128      (NS3.1)
35           2x SEEQ DQ2764  (1, 2)
36           1x SGS M2764    (NS1)
37    - PLDs 1x PAL16R4A     (read protected)
30    - CRTC: 1x MC6845P.
3831
39    - 1x TDA 2002      (8W. car radio audio amplifier)
32    - RAM:  1x MK48Z02B-20.  CMOS 2K*8 zeropower SRAM (NVRAM).
33            2x HM6116LP-4.   2K*8 SRAM (Video RAM, only 1st half used).
34
35    - CLK:  1x crystal @ 10.000 MHz.
36
37    - ROMs: 1x AM27128.      (NS3.1)
38            2x SEEQ DQ2764.  (1, 2)
39            1x SGS M2764.    (NS1)
40
41    - PLDs: 1x PAL16R4A.     (read protected)
42
43    - SOUND: 1x delta-sigma DAC (1-bit/Bitstream).
44             1x TDA2002 (8W. car radio audio amplifier)
45
46
47    Other components:
48
4049    - 3x OUAZ SS-112D  (relay 1 pole 12v)
4150    - 1x 4 DIP switches
4251    - 1x 30x2 edge connector
r3514r3515
97106    |_________________________________________________________________|
98107
99108
100    Magic Fly & 7 e Mezzo PAL16R4A Fuse Maps were converted to the new bin format and added to respective sets.
101
102
103109    Pinouts (from 7mezzo pinout sheet)
104110    ----------------------------------
105111
r3514r3515
164170    Memory Map (magicfly)
165171    ---------------------
166172
167    $0000 - $00FF    RAM    ; Zero page (pointers and registers).
173    $0000 - $00FF    RAM    ; Zero page (pointers and registers) (NVRAM).
168174
169175        ($0D)            ; Incremented each time a NMI is triggered.
170176        ($1D)            ; In case of 0x00, NMI do nothing and return.
r3514r3515
193199        ($6E - $6F)      ; Balloon #3 secondi (bet).
194200        ($70 - $71)      ; Balloon #4 secondi (bet).
195201        ($72 - $73)      ; Balloon #5 secondi (bet).
196        ($94)            ; Store bit 7 of content to be ORed with $39 and written to input selector at $3000.
202        ($94)            ; Store bit 7 of contents to be ORed with $39 and written to output port ($3000).
197203        ($96 - $98)      ; Store values from content of $2800 (input port) & 0x80, & 0x40, & 0x10.
198204        ($9B - $A8)      ; Text scroll buffer.
199205
200    $0100 - $01FF    RAM    ; 6502 Stack Pointer.
206    $0100 - $01FF    RAM    ; 6502 Stack Pointer (NVRAM).
201207
202    $0200 - $07FF    RAM    ; General purpose RAM.
208    $0200 - $07FF    RAM    ; General purpose RAM (NVRAM).
203209
204210    $0800 - $0801    MC6845 ; MC6845 use $0800 for register addressing and $0801 for register values (see code at $CE86).
205211
r3514r3515
213219    $1800 - $1BFF    Color RAM  ; Initialized in subroutine starting at $CF83, filled with value stored in $5F.
214220                                ; (In 7mezzo is located at $CB13 using $64 and $65 to store video and color ram values.)
215221
216    $2800 - $2800    Input port ; Multiplexed input port (code at $CE96). Only reads.
217                                ; NMI routine read from here and store new values in $003A - $003D and copy old ones to $003F - $0042.
218                                ; Code accept only bits 0-3 & 5 as valid. If another bit is activated will produce an I/O error. (code at $CD0C)
222    $2800 - $2800    Input port ; Multiplexed input port (code at $CE96).
223                                ; NMI routine read from here and store new values in $3A-$3D and copy old ones to $3F-$42.
224                                ; Code accept only bits 0-1-2-3-5 as valid inputs. For DIP switches, only bits 4-6-7 are valid.
225                                ; If an invalid bit is activated, it will produce an I/O error. (code at $CD0C)
219226
220    $3000 - $3000    Input selector  ; Only writes. NMI write 0x01, 0x02, 0x04, 0x08.
221                                     ; Main code at $C152 do a complex loop with boolean operations and write 0x00/0x80 here.
227    $3000 - $3000    Output port:
222228
229                         Input selector,  ; NMI writes the lower 4 bits to select input.
230                         Counters.        ; Bits 4-5-6 are used for Coin1, Coin2, and Payout counters.
231                         Sound DAC,       ; Bit 7 is used to transmit DAC data.
232
223233    $C000 - $FFFF    ROM space       ; Program ROMs.
224234
225235
r3514r3515
249259*******************************************************************************
250260
251261
262    Game Notes
263    ----------
264
265    Settings (valid for both games):
266
267    Press F2 to enter the input test (game should be without credits).
268    In the input test, you can exit with BET + DEAL, or access the bookkeeping
269    mode pressing BET + DEAL again. In the bookkeping mode keep pressed the PAYOUT
270    key and press BET to change the percentage (all books will be erased). Press
271    again BET + DEAL to exit to a quick RAM & sound test, and then to game mode.
272
273
274    * Magic Fly
275
276    How to play...
277
278    Insert coins to get credits.
279    Choose a balloon to raise, and select it with SELECT button. Bet on other balloons
280    using the SELECT/BET key (to bet 1 credit) or BETx10 (to bet 10 credits). Once done,
281    press the DEAL/LAST BET key to start the game. All balloons will explode revealing
282    numbers. The last one to explode will be the raised one. If your number(s) are higher
283    than the one hidden in the raised balloon, you'll win!
284
285    You can repeat the last bet pressing the DEAL/LAST BET key.
286
287
288    * 7 e Mezzo
289
290    This game is a sort of blackjack, but using a spanish cards set. The objetive is
291    to get 7 and half points (as 21 in blackjack). If you got more than 7 and half,
292    you're busted.
293
294    All cards have their own value, except for 10, 11 and 12 that are half point.
295    Special hands have their own price.
296
297    Sun 7 + sun king = 100 (by credit).
298    Any 7 + any king =  16 (by credit).
299    Any 7 and half   =   8 (by credit).
300    Pass             =   2 (by credit).
301
302
303    How to play...
304
305    Insert coins to get credits.
306    Bet using the BET button. Press DEAL to get the cards.
307    You can hit a new card pressing DEAL, or stop pressing STAND. The dealer will hit
308    cards to the maximum allowed. If you beat the dealer, you'll be asked to enter the
309    double-up game. Press DOUBLE to go on, or TAKE to get the credits.
310
311    In the double-up game, a covered card should be shown. Press BIG or SMALL to get
312    your chance...
313
314
315
316*******************************************************************************
317
318
252319    Driver updates:
253320
254321
r3514r3515
308375    - Added technical references to register $63 (magicfly).
309376    - Switched crystal to new predefined format.
310377
378    [2008-10-25]
379    - Added sound support to magicfly and 7mezzo.
380    - Hooked coin counters to magicfly and 7mezzo.
381    - Inverted the graphics banks to be straight with the hardware accesses.
382    - Updated the memory map description and technical notes.
383    - Added game notes and documented the test/settings/bookkeeping modes.
311384
385
312386    TODO:
313387
314388    - Correct colors. (where is the palette?)
315    - Figure out the sound. (no remaining writes...)
389    - Confirm the CPU clock (there is some lag in MF controls).
316390    - Split the driver.
317391
318392
r3514r3515
323397
324398#include "driver.h"
325399#include "video/mc6845.h"
400#include "sound/dac.h"
326401
327402
328403/*************************
r3514r3515
351426    ---- x---   Seems to be a kind of attribute (maybe related to color). Not totally understood yet.
352427    ---x ----   Tiles bank.
353428    -xx- ----   Aparently not used.
354    x--- ----   Mirrored from bit 3. The code check this one to boot the game.  */
429    x--- ----   Mirrored from bit 3. The code check this one to boot the game.
355430
431*/
356432   int attr = colorram[tile_index];
357433   int code = videoram[tile_index];
358434   int bank = (attr & 0x10) >> 4;   /* bit 4 switch the gfx banks */
359435   int color = attr & 0x07;         /* bits 0-2 for color */
360436
361   bank = bank ^ 1;    /* GFX banks are inverted */
362
363437    /* Seems that bit 7 is mirrored from bit 3 to have a normal boot */
364438    /* Boot only check the first color RAM offset */
365439
r3514r3515
382456    ---- x---   Seems to be a kind of attribute (maybe related to color). Not totally understood yet.
383457    ---x ----   Tiles bank.
384458    -xx- ----   Aparently not used.
385    x--- ----   Mirrored from bit 2. The code check this one to boot the game.  */
459    x--- ----   Mirrored from bit 2. The code check this one to boot the game.
386460
461*/
387462   int attr = colorram[tile_index];
388463   int code = videoram[tile_index];
389464   int bank = (attr & 0x10) >> 4;    /* bit 4 switch the gfx banks */
390465   int color = attr & 0x07;          /* bits 0-2 for color */
391466
392   bank = bank ^ 1;    /* GFX banks are inverted */
393
394467    /* Seems that bit 7 is mirrored from bit 2 to have a normal boot */
395468    /* Boot only check the first color RAM offset */
396469
r3514r3515
438511*         R/W Handlers        *
439512******************************/
440513
441static int mux_data = 0;
514static int input_selector = 0;
442515
443516static READ8_HANDLER( mux_port_r )
444517{
445   switch( mux_data & 0x0f )   /* bits 0-3 */
518   switch( input_selector )
446519   {
447      case 0x01: return input_port_read(machine, "IN0-0");
448      case 0x02: return input_port_read(machine, "IN0-1");
449      case 0x04: return input_port_read(machine, "IN0-2");
450      case 0x08: return input_port_read(machine, "IN0-3");
451      case 0x00: return input_port_read(machine, "DSW0");
520      case 0x01: return input_port_read(machine, "IN0-0"); break;
521      case 0x02: return input_port_read(machine, "IN0-1"); break;
522      case 0x04: return input_port_read(machine, "IN0-2"); break;
523      case 0x08: return input_port_read(machine, "IN0-3"); break;
524      case 0x00: return input_port_read(machine, "DSW0"); break;
452525   }
453526   return 0xff;
454527}
455528
456static WRITE8_HANDLER( mux_w )
529static WRITE8_HANDLER( mux_port_w )
457530{
458   mux_data = data;
531/*  - bits -
532    7654 3210
533    ---- xxxx   Input selector.
534    ---x ----   Coin 2.
535    --x- ----   Payout.
536    -x-- ----   Coin 1.
537    x--- ----   Sound DAC.
538
539*/
540   input_selector = data & 0x0f;   /* Input Selector */
541
542   dac_data_w(0, data & 0x80);      /* Sound DAC */
543
544   coin_counter_w(0, data & 0x40);   /* Coin1 */
545   coin_counter_w(1, data & 0x10);   /* Coin2 */
546   coin_counter_w(2, data & 0x20);   /* Payout */
459547}
460548
461549
r3514r3515
467555   AM_RANGE(0x0000, 0x07ff) AM_RAM AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size)    /* MK48Z02B NVRAM */
468556   AM_RANGE(0x0800, 0x0800) AM_DEVWRITE(MC6845, "crtc", mc6845_address_w)
469557   AM_RANGE(0x0801, 0x0801) AM_DEVREADWRITE(MC6845, "crtc", mc6845_register_r, mc6845_register_w)
470   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(magicfly_videoram_w) AM_BASE(&videoram)        /* HM6116LP #1 (2K x 8) RAM (only 1st half used) */
471   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(magicfly_colorram_w) AM_BASE(&colorram)        /* HM6116LP #2 (2K x 8) RAM (only 1st half used) */
472   AM_RANGE(0x2800, 0x2800) AM_READ(mux_port_r)  /* multiplexed input port */
473   AM_RANGE(0x3000, 0x3000) AM_WRITE(mux_w)      /* input selector */
474   AM_RANGE(0xc000, 0xffff) AM_ROM               /* ROM space */
558   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(magicfly_videoram_w) AM_BASE(&videoram)   /* HM6116LP #1 (2K x 8) RAM (only 1st half used) */
559   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(magicfly_colorram_w) AM_BASE(&colorram)   /* HM6116LP #2 (2K x 8) RAM (only 1st half used) */
560   AM_RANGE(0x2800, 0x2800) AM_READ(mux_port_r)   /* multiplexed input port */
561   AM_RANGE(0x3000, 0x3000) AM_WRITE(mux_port_w)   /* output port */
562   AM_RANGE(0xc000, 0xffff) AM_ROM               /* ROM space */
475563ADDRESS_MAP_END
476564
477565
r3514r3515
608696*    Graphics Layouts    *
609697*************************/
610698
611static const gfx_layout charlayout =
699static const gfx_layout tilelayout =
612700{
613701   8, 8,
614702   256,
615   1,
616   { 0 },
703   3,
704   { 0, 0x2800*8, 0x4800*8 },   /* bitplanes are separated. */
617705   { 0, 1, 2, 3, 4, 5, 6, 7 },
618706   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
619707   8*8
620708};
621709
622static const gfx_layout tilelayout =
710static const gfx_layout charlayout =
623711{
624712   8, 8,
625713   256,
626   3,
627   { 0, (0x2800*8), (0x4800*8) },   /* bitplanes are separated. */
714   1,
715   { 0 },
628716   { 0, 1, 2, 3, 4, 5, 6, 7 },
629717   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
630718   8*8
r3514r3515
636724******************************/
637725
638726static GFXDECODE_START( magicfly )
639   GFXDECODE_ENTRY( "gfx1",   0x1800,   charlayout, 0, 16 )
640   GFXDECODE_ENTRY( "gfx1",   0x1000,   tilelayout, 16, 16 )
727   GFXDECODE_ENTRY( "gfx1", 0x1000, tilelayout, 16, 16 )
728   GFXDECODE_ENTRY( "gfx1", 0x1800, charlayout, 0, 16 )
641729GFXDECODE_END
642730
643731
r3514r3515
670758   MDRV_VIDEO_UPDATE(magicfly)
671759
672760   MDRV_DEVICE_ADD("crtc", MC6845)
761
762   /* sound hardware */
763   MDRV_SPEAKER_STANDARD_MONO("mono")
764   MDRV_SOUND_ADD("dac", DAC, 0)
765   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
673766MACHINE_DRIVER_END
674767
675768static MACHINE_DRIVER_START( 7mezzo )
676769
677770   /* basic machine hardware */
678771   MDRV_IMPORT_FROM(magicfly)
679   MDRV_CPU_MODIFY("main")
680772
681773   /* video hardware */
682774   MDRV_VIDEO_START(7mezzo)
r3514r3515
721813*************************/
722814
723815/*    YEAR  NAME      PARENT  MACHINE   INPUT     INIT   ROT    COMPANY      FULLNAME    FLAGS... */
724GAME( 198?, magicfly, 0,      magicfly, magicfly, 0,     ROT0, "P&A Games", "Magic Fly", GAME_IMPERFECT_COLORS | GAME_NO_SOUND )
725GAME( 198?, 7mezzo,   0,      7mezzo,   7mezzo,   0,     ROT0, "Unknown",   "7 e Mezzo", GAME_IMPERFECT_COLORS | GAME_NO_SOUND )
816GAME( 198?, magicfly, 0,      magicfly, magicfly, 0,     ROT0, "P&A Games", "Magic Fly", GAME_IMPERFECT_COLORS )
817GAME( 198?, 7mezzo,   0,      7mezzo,   7mezzo,   0,     ROT0, "Unknown",   "7 e Mezzo", GAME_IMPERFECT_COLORS )
src/mame/drivers/cop01.c
r3514r3515
178178
179179static INPUT_PORTS_START( cop01 )
180180   PORT_START("P1")
181   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY
182   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY
183   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY
181   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )    PORT_8WAY
182   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )  PORT_8WAY
183   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )  PORT_8WAY
184184   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY
185185   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
186186   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
r3514r3515
188188   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
189189
190190   PORT_START("P2")
191   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_COCKTAIL
192   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL
193   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL
191   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )    PORT_8WAY PORT_COCKTAIL
192   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )  PORT_8WAY PORT_COCKTAIL
193   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )  PORT_8WAY PORT_COCKTAIL
194194   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_COCKTAIL
195195   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
196196   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL
r3514r3515
218218   PORT_DIPSETTING(    0x08, DEF_STR( 2C_3C ) )
219219   PORT_DIPSETTING(    0x0c, DEF_STR( 1C_3C ) )
220220   PORT_DIPSETTING(    0x04, DEF_STR( 1C_6C ) )
221   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) ) /* Listed as "Unused" in the manual */
222   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
223   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
221   PORT_DIPUNUSED( 0x10, IP_ACTIVE_LOW )
224222   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) )
225223   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
226224   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
r3514r3515
242240   PORT_DIPSETTING(    0x04, "4" )
243241   PORT_DIPSETTING(    0x08, "5" )
244242   PORT_DIPSETTING(    0x00, "6" )
245   PORT_DIPNAME( 0x10, 0x10, "1st Bonus Life" )
246   PORT_DIPSETTING(    0x10, "20000" )
247   PORT_DIPSETTING(    0x00, "30000" )
248   PORT_DIPNAME( 0x60, 0x60, "2nd Bonus Life" )
249   PORT_DIPSETTING(    0x60, "30000" )
250   PORT_DIPSETTING(    0x20, "50000" )
251   PORT_DIPSETTING(    0x40, "100000" )
252   PORT_DIPSETTING(    0x00, "150000" )
253   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) ) /* Listed as "Unused" in the manual */
254   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
255   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
243   /* DP2:3,4,5 defined in manual/test-mode as:
244    PORT_DIPNAME( 0x10, 0x10, "1st Bonus Life" )
245    PORT_DIPSETTING(    0x10, "20000" )
246    PORT_DIPSETTING(    0x00, "30000" )
247    PORT_DIPNAME( 0x60, 0x60, "2nd Bonus Life" )
248    PORT_DIPSETTING(    0x60, "30000" )
249    PORT_DIPSETTING(    0x20, "50000" )
250    PORT_DIPSETTING(    0x40, "100000" )
251    PORT_DIPSETTING(    0x00, "150000" ) */
252   PORT_DIPNAME( 0x70, 0x70, DEF_STR( Bonus_Life ) )
253   PORT_DIPSETTING(    0x70, "20k 50k 30k+" )
254   PORT_DIPSETTING(    0x30, "20k 70k 50k+" )
255   PORT_DIPSETTING(    0x50, "20k 120k 100k+" )
256   PORT_DIPSETTING(    0x10, "20k 170k 150k+" )
257   PORT_DIPSETTING(    0x60, "30k 60k 30k+" )
258   PORT_DIPSETTING(    0x20, "30k 80k 50k+" )
259   PORT_DIPSETTING(    0x40, "30k 130k 100k+" )
260   PORT_DIPSETTING(    0x00, "30k 180k 150k+" )
261   PORT_DIPUNUSED( 0x80, IP_ACTIVE_LOW )
256262INPUT_PORTS_END
257263
258/* There is an ingame bug at 0x00e4 to 0x00e6 that performs the 'rrca' instead of 'rlca'
259   so you DSW1-8 has no effect and you can NOT start a game at areas 5 to 8. */
264/* There is an ingame bug at 0x00e4 to 0x00e6 that performs 3 times 'rrca' instead of 'rlca'
265   so DSW1-8 has no effect and you can NOT start a game at areas 5 to 8. */
260266static INPUT_PORTS_START( mightguy )
261267   PORT_START("P1")
262   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY
263   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY
264   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY
268   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )    PORT_8WAY
269   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )  PORT_8WAY
270   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )  PORT_8WAY
265271   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY
266272   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
267273   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
r3514r3515
269275   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
270276
271277   PORT_START("P2")
272   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_COCKTAIL
273   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL
274   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL
278   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )    PORT_8WAY PORT_COCKTAIL
279   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )  PORT_8WAY PORT_COCKTAIL
280   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )  PORT_8WAY PORT_COCKTAIL
275281   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_COCKTAIL
276282   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
277283   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL
r3514r3515
284290   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN1 )
285291   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN2 )
286292   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE1 )
287   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE )   /* same as the service dip switch */
293   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE )            /* same as the service dip switch */
288294   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
289295   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
290296
r3514r3515
295301   PORT_DIPSETTING(   0x01, "5" )
296302   PORT_DIPSETTING(   0x00, "6" )
297303   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Bonus_Life ) )
298   PORT_DIPSETTING(   0x04, "every 200000" )
299   PORT_DIPSETTING(   0x00, "only 500000" )
304   PORT_DIPSETTING(   0x04, "Every 200k" )
305   PORT_DIPSETTING(   0x00, "500k only" )
300306   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) )
301307   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
302308   PORT_DIPSETTING(   0x08, DEF_STR( On ) )
r3514r3515
320326   PORT_DIPSETTING(   0x04, DEF_STR( 2C_3C ) )
321327   PORT_DIPSETTING(   0x0c, DEF_STR( 1C_3C ) )
322328   PORT_DIPSETTING(   0x08, DEF_STR( 1C_6C ) )
323   PORT_DIPNAME( 0x30, 0x20, DEF_STR( Difficulty ) )
329   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Difficulty ) )
324330   PORT_DIPSETTING(   0x30, DEF_STR( Easy ) )
325331   PORT_DIPSETTING(   0x20, DEF_STR( Normal ) )
326332   PORT_DIPSETTING(   0x10, DEF_STR( Hard ) )
src/mame/drivers/circusc.c
r3514r3515
1111To enter service mode, keep 1&2 pressed on reset
1212
1313
14'circusc2' ingame bug :
15-----------------------
16
17  "Test mode" displays 2, 3, 4 and 7 lives instead of 3, 4, 5 and 7
18  due to code at 0xcb38 :
19
20    CB38: B6 30 88         LDA   $1800
21    CB3B: 43               COMA
22    CB3C: 84 2B            ANDA  #$03
23    CB3E: 81 8B            CMPA  #$03
24    CB40: 25 20            BCS   $CB44
25    CB42: 86 87            LDA   #$05
26    CB44: 8B 20            ADDA  #$02
27
28  In other sets, you have the following (code from 'circusc') :
29
30    CB38: B6 30 88         LDA   $1800
31    CB3B: 43               COMA
32    CB3C: 84 2B            ANDA  #$03
33    CB3E: 81 8B            CMPA  #$03
34    CB40: 25 20            BCS   $CB44
35    CB42: 86 86            LDA   #$04
36    CB44: 8B 21            ADDA  #$03
37
38  Ingame lives are correct though (same code for 'circusc' and 'circusc2') :
39
40    6B93: 96 0D            LDA   $2F
41    6B95: 84 81            ANDA  #$03
42    6B97: 8B 2B            ADDA  #$03
43    6B99: 81 8E            CMPA  #$06
44    6B9B: 25 2A            BCS   $6B9F
45    6B9D: 86 8F            LDA   #$07
46
47
1448***************************************************************************/
1549
1650#include "driver.h"
r3514r3515
241275   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
242276   PORT_DIPSETTING(    0x04, DEF_STR( Cocktail ) )
243277   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Bonus_Life ) )   PORT_DIPLOCATION("SW2:4")
244   PORT_DIPSETTING(    0x08, "20000 70000" )
245   PORT_DIPSETTING(    0x00, "30000 80000" )
246   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW2:5")
247   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
248   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
278   PORT_DIPSETTING(    0x08, "20k 90k 70k+" )
279   PORT_DIPSETTING(    0x00, "30k 110k 80k+" )
280   PORT_DIPUNUSED_DIPLOC( 0x10, 0x00, "SW2:5" )
249281   PORT_DIPNAME( 0x60, 0x40, DEF_STR( Difficulty ) )   PORT_DIPLOCATION("SW2:6,7")
250282   PORT_DIPSETTING(    0x60, DEF_STR( Easy ) )
251283   PORT_DIPSETTING(    0x40, DEF_STR( Normal ) )
src/mame/drivers/plygonet.c
r3514r3515
108108   }
109109   else
110110   {
111      return (input_port_read(machine, "IN0")<<24);
111      UINT8 lowInputBits = input_port_read(machine, "IN1");
112      UINT8 highInputBits = input_port_read(machine, "IN0");
113      return ((highInputBits << 24) | (lowInputBits << 16));
112114   }
113115
114116   logerror("unk access to eeprom port (mask %x)\n", mem_mask);
r3514r3515
148150}
149151
150152/* irqs 3, 5, and 7 have valid vectors                */
151/* irq 3 does ??? (network)                           */
152/* irq 5 does ??? (polygon end of draw or VBL?)       */
153/* irq 3 is network.  don't generate if you don't emulate the network h/w! */
154/* irq 5 is vblank */
153155/* irq 7 does nothing (it jsrs to a rts and then rte) */
154156
155157static INTERRUPT_GEN(polygonet_interrupt)
156158{
157   if (cpu_getiloops())
158      cpunum_set_input_line(machine, 0, MC68000_IRQ_5, HOLD_LINE);
159   else
160      cpunum_set_input_line(machine, 0, MC68000_IRQ_3, HOLD_LINE);
159   cpunum_set_input_line(machine, 0, MC68000_IRQ_5, HOLD_LINE);
161160}
162161
163162/* sound CPU communications */
r3514r3515
276275   return 0x08000000;
277276}
278277
279
280278/**********************************************************************************/
281279/*******                            DSP56k maps                             *******/
282280/**********************************************************************************/
r3514r3515
464462}
465463
466464
465WRITE32_HANDLER( plygonet_palette_w )
466{
467   int r,g,b;
467468
469   COMBINE_DATA(&paletteram32[offset]);
470
471    r = (paletteram32[offset] >>16) & 0xff;
472   g = (paletteram32[offset] >> 8) & 0xff;
473   b = (paletteram32[offset] >> 0) & 0xff;
474
475   palette_set_color(machine,offset,MAKE_RGB(r,g,b));
476}
477
478
468479/**********************************************************************************/
469480
470481static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 32 )
471482   AM_RANGE(0x000000, 0x1fffff) AM_ROM
472   AM_RANGE(0x200000, 0x21ffff) AM_RAM      /* PSAC2 tilemap */
473   AM_RANGE(0x440000, 0x440fff) AM_RAM      /* PSAC2 lineram */
483   AM_RANGE(0x200000, 0x21ffff) AM_RAM_WRITE(plygonet_palette_w) AM_BASE(&paletteram32)   // is all of this region the palette?
484   AM_RANGE(0x440000, 0x440fff) AM_RAM      /* PSAC2 lineram? */
474485   AM_RANGE(0x480000, 0x480003) AM_READ(polygonet_eeprom_r)
475486   AM_RANGE(0x4C0000, 0x4C0003) AM_WRITE(polygonet_eeprom_w)
476487   AM_RANGE(0x500000, 0x503fff) AM_RAM_WRITE(shared_ram_write) AM_BASE(&shared_ram)
r3514r3515
479490   AM_RANGE(0x540000, 0x540fff) AM_READWRITE(polygonet_ttl_ram_r, polygonet_ttl_ram_w)
480491   AM_RANGE(0x541000, 0x54101f) AM_RAM
481492   AM_RANGE(0x580000, 0x5807ff) AM_RAM
482   AM_RANGE(0x580800, 0x580803) AM_READWRITE(network_r, SMH_NOP)
483   AM_RANGE(0x580800, 0x580803) AM_RAM      /* network RAM | registers? */
493   AM_RANGE(0x580800, 0x580803) AM_READ(network_r) AM_WRITENOP   /* network RAM | registers? */
484494//  AM_RANGE(0x600000, 0x600000)
485495   AM_RANGE(0x600004, 0x600007) AM_WRITE(sound_w)
486496   AM_RANGE(0x600008, 0x60000b) AM_READ(sound_r)
r3514r3515
502512static ADDRESS_MAP_START( dsp_data_map, ADDRESS_SPACE_DATA, 16 )
503513   AM_RANGE(0x0800, 0x5fff) AM_RAM         /* Appears to not be affected by banking? */
504514   AM_RANGE(0x6000, 0x6fff) AM_READWRITE(dsp56k_ram_bank00_read, dsp56k_ram_bank00_write)
505   AM_RANGE(0x7000, 0x7fff) AM_READWRITE(dsp56k_ram_bank01_read, dsp56k_ram_bank01_write)   /* Mirrored in program space @ 0x8000 */
515   AM_RANGE(0x7000, 0x7fff) AM_READWRITE(dsp56k_ram_bank01_read, dsp56k_ram_bank01_write)   /* Mirrored in program space @ 0x7000 */
506516   AM_RANGE(0x8000, 0xbfff) AM_READWRITE(dsp56k_ram_bank02_read, dsp56k_ram_bank02_write)
507517   AM_RANGE(0xc000, 0xdfff) AM_READWRITE(dsp56k_shared_ram_read, dsp56k_shared_ram_write)
508518   AM_RANGE(0xe000, 0xffbf) AM_READWRITE(dsp56k_ram_bank04_read, dsp56k_ram_bank04_write)
r3514r3515
584594static MACHINE_DRIVER_START( plygonet )
585595   MDRV_CPU_ADD("main", M68EC020, 16000000)   /* 16 MHz (xtal is 32.0 MHz) */
586596   MDRV_CPU_PROGRAM_MAP(main_map, 0)
587   MDRV_CPU_VBLANK_INT_HACK(polygonet_interrupt, 2)
597   MDRV_CPU_VBLANK_INT("main", polygonet_interrupt)
588598
589599   MDRV_CPU_ADD("dsp", DSP56156, 10000000)      /* xtal is 40.0 MHz */
590600   MDRV_CPU_PROGRAM_MAP(dsp_program_map, 0)
r3514r3515
608618   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
609619   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
610620   MDRV_SCREEN_SIZE(64*8, 32*8)
611   MDRV_SCREEN_VISIBLE_AREA(0, 64*8-1, 0, 32*8-1)
621   MDRV_SCREEN_VISIBLE_AREA(48, 48+384-1, 0, 32*8-1)
612622
613623   MDRV_PALETTE_LENGTH(32768)
614624
r3514r3515
631641
632642static INPUT_PORTS_START( polygonet )
633643   PORT_START("IN0")
634   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN)
635   PORT_SERVICE_NO_TOGGLE( 0x02, IP_ACTIVE_LOW )
636   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN)
637   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN)
638   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN)
639   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN)
640   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN)
641   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN)
644   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 )   /* Service */
645   PORT_SERVICE_NO_TOGGLE( 0x02, IP_ACTIVE_LOW )   /* Test Switch */
646   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 )   /* Coin Mech Switch 1 */
647   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON3 )
648   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON4 )   /* SW1 */
649   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON5 )   /* SW2 */
650   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON6 )
651   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON7 )
652
653   PORT_START("IN1")
654   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON8 )   /* Joy2 Up */
655   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON9 )   /* Joy2 Down */
656   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON10 )   /* Joy1 Up */
657   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON11 )   /* Joy1 Down */
658   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON12 )   /* Joy1 Fire */
659   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON13 )   /* Joy2 Fire */
660   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON14 )
661   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON15 )
642662INPUT_PORTS_END
643663
644664static DRIVER_INIT(polygonet)
src/mame/drivers/naomi.c
r3514r3515
796796
797797static WRITE64_HANDLER( naomi_rom_board_w )
798798{
799   if ((offset == 1) && ACCESSING_BITS_32_47)
799   if ((offset == 1) && (ACCESSING_BITS_32_47 || ACCESSING_BITS_32_63))
800800   {
801801      // DMA_OFFSETH
802802      dma_offset &= 0xffff;
r3514r3515
821821      rom_offset &= 0xffff0000;
822822      rom_offset |= ((data >> 32) & 0xffff);
823823   }
824   if ((offset == 1) && ACCESSING_BITS_0_15)
824   else if ((offset == 1) && ACCESSING_BITS_0_15)
825825   {
826826      // ROM_DATA
827827      // Doa2 writes here (16 bit decryption key ?)
r3514r3515
924924   AM_RANGE(0x10000000, 0x107fffff) AM_WRITE( ta_fifo_poly_w )
925925   AM_RANGE(0x10800000, 0x10ffffff) AM_WRITE( ta_fifo_yuv_w )
926926   AM_RANGE(0x11000000, 0x11ffffff) AM_RAM AM_SHARE(2)                                 // another mirror of texture memory
927   AM_RANGE(0x13000000, 0x13ffffff) AM_RAM AM_SHARE(2)                                 // another mirror of texture memory
927928   AM_RANGE(0xa0000000, 0xa01fffff) AM_ROM AM_REGION("main", 0)
928929ADDRESS_MAP_END
929930
src/mame/drivers/stv.c
r3514r3515
122122 on SMPC or controls fail
123123-mausuke/bakubaku/grdforce: need to sort out transparency on the colour mapped sprites
124124-bakubaku: no sound? Caused by missing irq?
125-myfairld: Doesn't work with -sound enabled because of a sound ram check at relative
126 addresses of $700/$710/$720/$730,so I'm not removing the NOT_WORKING flag due of that.Also
127 Micronet programmers had the "great" idea to *not* use the ST-V input standards,infact
125-myfairld: Apparently this game gives a black screen (either test mode and in-game mode),but let it wait for about
126 10 seconds and the game will load everything.This is because of a hellishly slow m68k sub-routine located at 54c2.
127 Likely to not be a bug but an in-game design issue.
128-myfairld: Micronet programmers had the "great" idea to *not* use the ST-V input standards,infact
128129 joystick panel is mapped with input_port(10) instead of input_port(2),so for now use
129130 the mahjong panel instead.
130131-kiwames: the VDP1 sprites refresh is too slow,causing the "Draw by request" mode to
r3514r3515
176177#include "includes/stv.h"
177178
178179#define USE_SLAVE 1
179/*Enable the following to play 'myfairld' without using the -nosound switch.*/
180#define UGLY_SOUND_HACK 0
181180
182181#ifdef MAME_DEBUG
183182#define LOG_CDB  0
r3514r3515
722721   if (ACCESSING_BITS_24_31)   { byte = 0; readdata = stv_SMPC_r8(machine, offset+byte) << 24; }
723722   if (ACCESSING_BITS_16_23)   { byte = 1; readdata = stv_SMPC_r8(machine, offset+byte) << 16; }
724723   if (ACCESSING_BITS_8_15)   { byte = 2; readdata = stv_SMPC_r8(machine, offset+byte) << 8;  }
725   if (ACCESSING_BITS_0_7)   { byte = 3; readdata = stv_SMPC_r8(machine, offset+byte) << 0;  }
724   if (ACCESSING_BITS_0_7)      { byte = 3; readdata = stv_SMPC_r8(machine, offset+byte) << 0;  }
726725
727726   return readdata;
728727}
r3514r3515
738737   if (ACCESSING_BITS_24_31)   { byte = 0; writedata = data >> 24; }
739738   if (ACCESSING_BITS_16_23)   { byte = 1; writedata = data >> 16; }
740739   if (ACCESSING_BITS_8_15)   { byte = 2; writedata = data >> 8;  }
741   if (ACCESSING_BITS_0_7)   { byte = 3; writedata = data >> 0;  }
740   if (ACCESSING_BITS_0_7)      { byte = 3; writedata = data >> 0;  }
742741
743742   writedata &= 0xff;
744743
r3514r3515
784783         cpunum_set_input_line_and_vector(machine, 0, 0xe, HOLD_LINE , 0x41);
785784      }
786785      stv_vblank = 0;
787      #if UGLY_SOUND_HACK
788      sound_ram[0x700/2] = 0x0000;
789      sound_ram[0x710/2] = 0x0000;
790      sound_ram[0x720/2] = 0x0000;
791      sound_ram[0x730/2] = 0x0000;
792      #endif
793786   }
794787   else if(scanline <= 223 && scanline >= 1)/*Correct?*/
795788   {
r3514r3515
37163709
37173710/* Almost */
37183711GAME( 1997, vmahjong,  stvbios, stv, stvmp,      stv,          ROT0,   "Micronet",                    "Virtual Mahjong (J 961214 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
3719GAME( 1998, myfairld,  stvbios, stv, stvmp,      stv,          ROT0,   "Micronet",                    "Virtual Mahjong 2 - My Fair Lady (J 980608 V1.000)", GAME_NO_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_NOT_WORKING )
3712GAME( 1998, myfairld,  stvbios, stv, stvmp,      stv,          ROT0,   "Micronet",                    "Virtual Mahjong 2 - My Fair Lady (J 980608 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
37203713GAME( 1998, twcup98,   stvbios, stv, stv,        twcup98,      ROT0,   "Tecmo",                       "Tecmo World Cup '98 (JUET 980410 V1.000)", GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS|GAME_NOT_WORKING ) // player movement
37213714GAME( 1998, stress,    stvbios, stv, stv,        stv,          ROT0,   "Sega",                       "Stress Busters (J 981020 V1.000)", GAME_NOT_WORKING ) // needs printer
37223715
src/mame/drivers/superchs.c
r3514r3515
442442   MDRV_VIDEO_UPDATE(superchs)
443443
444444   /* sound hardware */
445   TAITO_F3_SOUND_SYSTEM_ES5505(13343000)
445   TAITO_F3_SOUND_SYSTEM_ES5505(30476100/2)
446446MACHINE_DRIVER_END
447447
448448/***************************************************************************/
src/mame/drivers/dreamwld.c
r3514r3515
3434      VSync @ 58Hz
3535
3636
37Stephh's notes (based on the game M68EC020 code and some tests) :
38
39  - Don't trust the "test mode" as it displays Dip Switches infos
40    that are in fact unused by the game ! Leftover from another game ?
41
42    PORT_START("DSW")
43    PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Lives ) )        PORT_DIPLOCATION("SW2:1,2")
44    PORT_DIPSETTING(      0x0002, "1" )
45    PORT_DIPSETTING(      0x0003, "2" )
46    PORT_DIPSETTING(      0x0001, "3" )
47    PORT_DIPSETTING(      0x0000, "4" )
48    PORT_DIPUNUSED_DIPLOC( 0x0004, IP_ACTIVE_LOW, "SW2:3" )
49    PORT_DIPUNUSED_DIPLOC( 0x0008, IP_ACTIVE_LOW, "SW2:4" )
50    PORT_DIPUNUSED_DIPLOC( 0x0010, IP_ACTIVE_LOW, "SW2:5" )
51    PORT_DIPNAME( 0x0060, 0x0060, "Ticket Payout" )         PORT_DIPLOCATION("SW2:6,7")
52    PORT_DIPSETTING(      0x0000, DEF_STR( No ) )
53    PORT_DIPSETTING(      0x0020, "Little" )
54    PORT_DIPSETTING(      0x0060, DEF_STR( Normal ) )
55    PORT_DIPSETTING(      0x0040, "Much" )
56    PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Free_Play ) )    PORT_DIPLOCATION("SW2:8")
57    PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
58    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
59    PORT_DIPNAME( 0x0100, 0x0000, DEF_STR( Demo_Sounds ) )  PORT_DIPLOCATION("SW1:1")
60    PORT_DIPSETTING(      0x0100, DEF_STR( Off ) )
61    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
62    PORT_DIPNAME( 0x0e00, 0x0e00, DEF_STR( Coinage ) )      PORT_DIPLOCATION("SW1:2,3,4")
63    PORT_DIPSETTING(      0x0000, DEF_STR( 5C_1C ) )
64    PORT_DIPSETTING(      0x0200, DEF_STR( 4C_1C ) )
65    PORT_DIPSETTING(      0x0400, DEF_STR( 3C_1C ) )
66    PORT_DIPSETTING(      0x0600, DEF_STR( 2C_1C ) )
67    PORT_DIPSETTING(      0x0e00, DEF_STR( 1C_1C ) )
68    PORT_DIPSETTING(      0x0a00, DEF_STR( 2C_3C ) )
69    PORT_DIPSETTING(      0x0c00, DEF_STR( 1C_2C ) )
70    PORT_DIPSETTING(      0x0800, DEF_STR( 1C_3C ) )
71    PORT_DIPNAME( 0x7000, 0x7000, DEF_STR( Difficulty ) )   PORT_DIPLOCATION("SW1:5,6,7")
72    PORT_DIPSETTING(      0x2000, "Level 1" )
73    PORT_DIPSETTING(      0x1000, "Level 2" )
74    PORT_DIPSETTING(      0x0000, "Level 3" )
75    PORT_DIPSETTING(      0x7000, "Level 4" )
76    PORT_DIPSETTING(      0x6000, "Level 5" )
77    PORT_DIPSETTING(      0x5000, "Level 6" )
78    PORT_DIPSETTING(      0x4000, "Level 7" )
79    PORT_DIPSETTING(      0x3000, "Level 8" )
80    PORT_SERVICE_DIPLOC( 0x8000, IP_ACTIVE_LOW, "SW1:8" )
81
3782*/
3883
3984#include "driver.h"
r3514r3515
140185   SET_TILE_INFO(1,tileno+dreamwld_tilebank[1]*0x2000,0xc0+colour,0);
141186}
142187
143static VIDEO_START(dreamwld)
188static VIDEO_START( dreamwld )
144189{
145190   dreamwld_bg_tilemap = tilemap_create(get_dreamwld_bg_tile_info,tilemap_scan_rows, 16, 16, 64,32);
146191   dreamwld_bg2_tilemap = tilemap_create(get_dreamwld_bg2_tile_info,tilemap_scan_rows, 16, 16, 64,32);
r3514r3515
149194   dreamwld_tilebank[0] = dreamwld_tilebank[1] = 0;
150195}
151196
152static VIDEO_UPDATE(dreamwld)
197static VIDEO_UPDATE( dreamwld )
153198{
154199   tilemap_set_scrolly( dreamwld_bg_tilemap,0, dreamwld_bg_scroll[(0x400/4)]+32 );
155200   tilemap_set_scrolly( dreamwld_bg2_tilemap,0, dreamwld_bg_scroll[(0x400/4)+2]+32 );
r3514r3515
205250   palette_set_color_rgb(machine, color, pal5bit(dat >> 10), pal5bit(dat >> 5), pal5bit(dat >> 0));
206251}
207252
208static READ32_HANDLER(dreamwld_6295_0_r)
253static READ32_HANDLER( dreamwld_6295_0_r )
209254{
210255   return okim6295_status_0_r(machine, 0)<<24;
211256}
212257
213static WRITE32_HANDLER(dreamwld_6295_0_w)
258static WRITE32_HANDLER( dreamwld_6295_0_w )
214259{
215260   if (ACCESSING_BITS_24_31)
216261   {
r3514r3515
244289   }
245290}
246291
247static READ32_HANDLER(dreamwld_6295_1_r)
292static READ32_HANDLER( dreamwld_6295_1_r )
248293{
249294   return okim6295_status_1_r(machine, 0)<<24;
250295}
251296
252static WRITE32_HANDLER(dreamwld_6295_1_w)
297static WRITE32_HANDLER( dreamwld_6295_1_w )
253298{
254299   if (ACCESSING_BITS_24_31)
255300   {
r3514r3515
297342ADDRESS_MAP_END
298343
299344
300
301static INPUT_PORTS_START(dreamwld)
345static INPUT_PORTS_START( dreamwld )
302346   PORT_START("INPUTS")   /* 32bit */
303347   PORT_BIT( 0x00000001, IP_ACTIVE_LOW, IPT_COIN1 )
304348   PORT_BIT( 0x00000002, IP_ACTIVE_LOW, IPT_COIN2 )
305   PORT_DIPNAME( 0x00000004, 0x00000004, "Not Dips?" ) // i don't think these are dips, they're probably just unused parts of the coin port input
306   PORT_DIPSETTING(          0x00000004, DEF_STR( Off ) )
307   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
308   PORT_DIPNAME( 0x00000008, 0x00000008, DEF_STR( Unknown ) )
309   PORT_DIPSETTING(          0x00000008, DEF_STR( Off ) )
310   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
311   PORT_DIPNAME( 0x00000010, 0x00000010, DEF_STR( Unknown ) )
312   PORT_DIPSETTING(          0x00000010, DEF_STR( Off ) )
313   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
314   PORT_DIPNAME( 0x00000020, 0x00000020, DEF_STR( Unknown ) )
315   PORT_DIPSETTING(          0x00000020, DEF_STR( Off ) )
316   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
317   PORT_DIPNAME( 0x00000040, 0x00000040, DEF_STR( Unknown ) )
318   PORT_DIPSETTING(          0x00000040, DEF_STR( Off ) )
319   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
320   PORT_DIPNAME( 0x00000080, 0x00000080, DEF_STR( Unknown ) )
321   PORT_DIPSETTING(          0x00000080, DEF_STR( Off ) )
322   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
323   PORT_DIPNAME( 0x00000100, 0x00000100, DEF_STR( Unknown ) )
324   PORT_DIPSETTING(          0x00000100, DEF_STR( Off ) )
325   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
326   PORT_DIPNAME( 0x00000200, 0x00000200, DEF_STR( Unknown ) )
327   PORT_DIPSETTING(          0x00000200, DEF_STR( Off ) )
328   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
329   PORT_DIPNAME( 0x00000400, 0x00000400, DEF_STR( Unknown ) )
330   PORT_DIPSETTING(          0x00000400, DEF_STR( Off ) )
331   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
332   PORT_DIPNAME( 0x00000800, 0x00000800, DEF_STR( Unknown ) )
333   PORT_DIPSETTING(          0x00000800, DEF_STR( Off ) )
334   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
335   PORT_DIPNAME( 0x00001000, 0x00001000, DEF_STR( Unknown ) )
336   PORT_DIPSETTING(          0x00001000, DEF_STR( Off ) )
337   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
338   PORT_DIPNAME( 0x00002000, 0x00002000, DEF_STR( Unknown ) )
339   PORT_DIPSETTING(          0x00002000, DEF_STR( Off ) )
340   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
341   PORT_DIPNAME( 0x00004000, 0x00004000, DEF_STR( Unknown ) )
342   PORT_DIPSETTING(          0x00004000, DEF_STR( Off ) )
343   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
344   PORT_DIPNAME( 0x00008000, 0x00008000, DEF_STR( Unknown ) )
345   PORT_DIPSETTING(          0x00008000, DEF_STR( Off ) )
346   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
347
349   PORT_BIT( 0x0000fffc, IP_ACTIVE_LOW, IPT_UNUSED )
348350   PORT_BIT( 0x00010000, IP_ACTIVE_LOW, IPT_START2 )
349   PORT_BIT( 0x00020000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
350   PORT_BIT( 0x00040000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
351   PORT_BIT( 0x00080000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
352   PORT_BIT( 0x00100000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)
351   PORT_BIT( 0x00020000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2) /* "Book" (when you get one of them) */
352   PORT_BIT( 0x00040000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) /* "Jump" */
353   PORT_BIT( 0x00080000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) /* "Dig" */
354   PORT_BIT( 0x00100000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )  PORT_PLAYER(2)
353355   PORT_BIT( 0x00200000, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
354   PORT_BIT( 0x00400000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)
355   PORT_BIT( 0x00800000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2)
356   PORT_BIT( 0x00400000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )  PORT_PLAYER(2)
357   PORT_BIT( 0x00800000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )    PORT_PLAYER(2)
356358   PORT_BIT( 0x01000000, IP_ACTIVE_LOW, IPT_START1 )
357   PORT_BIT( 0x02000000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
358   PORT_BIT( 0x04000000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
359   PORT_BIT( 0x08000000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
360   PORT_BIT( 0x10000000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)
359   PORT_BIT( 0x02000000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) /* "Book" (when you get one of them) */
360   PORT_BIT( 0x04000000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) /* "Jump" */
361   PORT_BIT( 0x08000000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) /* "Dig" */
362   PORT_BIT( 0x10000000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )  PORT_PLAYER(1)
361363   PORT_BIT( 0x20000000, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)
362   PORT_BIT( 0x40000000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)
363   PORT_BIT( 0x80000000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
364   PORT_BIT( 0x40000000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )  PORT_PLAYER(1)
365   PORT_BIT( 0x80000000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )    PORT_PLAYER(1)
364366
365367   PORT_START("c00004")   /* 32bit */
366368   PORT_BIT( 0x0000ffff, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(custom_port_read, "DSW")
367369   PORT_BIT( 0xffff0000, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(custom_port_read, "DSW")
368370
369   PORT_START("DSW")   /* 16bit */
371   PORT_START("DSW")      /* 16bit */
370372   PORT_DIPNAME( 0x0003, 0x0003, DEF_STR( Lives ) )        PORT_DIPLOCATION("SW2:1,2")
371   PORT_DIPSETTING(      0x0001, "1" )
372   PORT_DIPSETTING(      0x0003, "2" )
373   PORT_DIPSETTING(      0x0002, "3" )
374   PORT_DIPSETTING(      0x0000, "4" )
375   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) )
376   PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
377   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
378   PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) )
379   PORT_DIPSETTING(      0x0008, DEF_STR( Off ) )
380   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
381   PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) )
382   PORT_DIPSETTING(      0x0010, DEF_STR( Off ) )
383   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
384   PORT_DIPNAME( 0x0060, 0x0060, "Ticket Payout" )       PORT_DIPLOCATION("SW2:6,7")
385   PORT_DIPSETTING(      0x0000, DEF_STR( No ) )
386   PORT_DIPSETTING(      0x0020, "Little" )
387   PORT_DIPSETTING(      0x0060, DEF_STR( Normal ) )
388   PORT_DIPSETTING(      0x0040, "Much" )
389   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Free_Play ) )  PORT_DIPLOCATION("SW2:8")
373   PORT_DIPSETTING(      0x0002, "2" )
374   PORT_DIPSETTING(      0x0003, "3" )
375   PORT_DIPSETTING(      0x0001, "4" )
376   PORT_DIPSETTING(      0x0000, "5" )
377   PORT_DIPUNUSED_DIPLOC( 0x0004, IP_ACTIVE_LOW, "SW2:3" )
378   PORT_DIPUNUSED_DIPLOC( 0x0008, IP_ACTIVE_LOW, "SW2:4" )
379   PORT_DIPUNUSED_DIPLOC( 0x0010, IP_ACTIVE_LOW, "SW2:5" )
380   PORT_DIPUNUSED_DIPLOC( 0x0020, IP_ACTIVE_LOW, "SW2:6" ) /* see notes - "Ticket Payout" */
381   PORT_DIPUNUSED_DIPLOC( 0x0040, IP_ACTIVE_LOW, "SW2:7" ) /* see notes - "Ticket Payout" */
382   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Free_Play ) )    PORT_DIPLOCATION("SW2:8")     /* gives in fact 99 credits */
390383   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
391384   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
392
393   PORT_DIPNAME( 0x0100, 0x0000, DEF_STR( Demo_Sounds ) )  PORT_DIPLOCATION("SW1:1")
394   PORT_DIPSETTING(      0x0100, DEF_STR( Off ) )
395   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
396   PORT_DIPNAME( 0x0e00, 0x0e00, DEF_STR( Coinage ) )  PORT_DIPLOCATION("SW1:2,3,4")
385   PORT_DIPUNUSED_DIPLOC( 0x0100, IP_ACTIVE_LOW, "SW1:1" ) /* see notes - "Demo Sounds" */
386   PORT_DIPNAME( 0x0e00, 0x0e00, DEF_STR( Coinage ) )      PORT_DIPLOCATION("SW1:2,3,4")
397387   PORT_DIPSETTING(      0x0000, DEF_STR( 5C_1C ) )
398388   PORT_DIPSETTING(      0x0200, DEF_STR( 4C_1C ) )
399389   PORT_DIPSETTING(      0x0400, DEF_STR( 3C_1C ) )
r3514r3515
402392   PORT_DIPSETTING(      0x0a00, DEF_STR( 2C_3C ) )
403393   PORT_DIPSETTING(      0x0c00, DEF_STR( 1C_2C ) )
404394   PORT_DIPSETTING(      0x0800, DEF_STR( 1C_3C ) )
405   PORT_DIPNAME( 0x7000, 0x7000, DEF_STR( Difficulty ) )  PORT_DIPLOCATION("SW1:5,6,7")
406   PORT_DIPSETTING(      0x2000, "Level 1" )
407   PORT_DIPSETTING(      0x1000, "Level 2" )
408   PORT_DIPSETTING(      0x0000, "Level 3" )
409   PORT_DIPSETTING(      0x7000, "Level 4" )
410   PORT_DIPSETTING(      0x6000, "Level 5" )
411   PORT_DIPSETTING(      0x5000, "Level 6" )
412   PORT_DIPSETTING(      0x4000, "Level 7" )
413   PORT_DIPSETTING(      0x3000, "Level 8" )
395   PORT_DIPUNUSED_DIPLOC( 0x1000, IP_ACTIVE_LOW, "SW1:5" ) /* see notes - "Difficulty" */
396   PORT_DIPUNUSED_DIPLOC( 0x2000, IP_ACTIVE_LOW, "SW1:6" ) /* see notes - "Difficulty" */
397   PORT_DIPUNUSED_DIPLOC( 0x4000, IP_ACTIVE_LOW, "SW1:7" ) /* see notes - "Difficulty" */
414398   PORT_SERVICE_DIPLOC( 0x8000, IP_ACTIVE_LOW, "SW1:8" )
415399INPUT_PORTS_END
416400
src/mame/drivers/firefox.c
r3514r3515
518518 *
519519 *************************************/
520520
521INPUT_PORTS_START( firefox )
521static INPUT_PORTS_START( firefox )
522522   PORT_START("rdin0")
523523   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 )
524524   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 )
src/mame/drivers/dwarfd.c
r3514r3515
8686#include "sound/ay8910.h"
8787
8888//should be taken from crt params
89static int maxy=25;
90static int maxx=80;
89static const int maxy=25;
90static const int maxx=80;
9191static int bank=0;
9292
9393static UINT8 *videobuf;
src/mame/drivers/renegade.c
r3514r3515
506506    else coin = 0;
507507*/
508508
509   static int count;
510   count = !count;
511   if (count)
509   if (cpu_getiloops())
512510      cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE);
513511   else
514512      cpunum_set_input_line(machine, 0, 0, HOLD_LINE);
src/mame/drivers/meritm.c
r3514r3515
318318   }
319319}
320320
321static int layer0_enabled, layer1_enabled;
322
321323static VIDEO_START( meritm )
322324{
325   layer0_enabled = layer1_enabled = 1;
326
323327   vdp0_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
324328   v9938_init (machine, 0, machine->primary_screen, vdp0_bitmap, MODEL_V9938, 0x20000, meritm_vdp0_interrupt);
325329   v9938_reset(0);
r3514r3515
336340
337341}
338342
339static int layer0_enabled = 1, layer1_enabled = 1;
340
341343static VIDEO_UPDATE( meritm )
342344{
343345   if(input_code_pressed_once(KEYCODE_Q))
src/mame/drivers/mirage.c
r3514r3515
11/* Mirage Youjuu Mahjongden
22
33TODO:
4-eeprom emulation?
5-priorities
6-sample banking
4-eeprom emulation? Software settings all changes if you toggle the "flip screen" dip-switch
5-priorities.
76
87Notes:To enter into Test Mode you need to keep pressed the Mahjong A button at start-up.
98*/
r3514r3515
133132   return 0;
134133}
135134
136
137static READ16_HANDLER( mirage_controls_r )
138{
139   return input_port_read(machine, "SYSTEM_IN");
140}
141
142static READ16_HANDLER( random_readers )
143{
144   return mame_rand(machine);
145}
146
147135static UINT32 mux_data;
148136
149137static WRITE16_HANDLER( mirage_mux_w )
150138{
151   mux_data = data & 0xffff;
139   mux_data = data & 0x1f;
152140}
153141
154142static READ16_HANDLER( mirage_input_r )
r3514r3515
165153   return 0xffff;
166154}
167155
156static WRITE16_HANDLER( okim1_rombank_w )
157{
158   if(ACCESSING_BITS_0_7)
159   {
160      UINT8 *oki = memory_region(machine, "oki2");
161      memcpy(&oki[0], &oki[(data & 3) * 0x40000] + 0x40000, 0x40000);
162   }
163}
164
165static WRITE16_HANDLER( okim0_rombank_w )
166{
167   /*bits 4-6 used?Volume control?*/
168
169   if(ACCESSING_BITS_0_7)
170   {
171      UINT8 *oki = memory_region(machine, "oki1");
172      memcpy(&oki[0], &oki[(data & 7) * 0x40000] + 0x40000, 0x40000);
173   }
174}
175
168176static ADDRESS_MAP_START( mirage_readmem, ADDRESS_SPACE_PROGRAM, 16 )
169177   AM_RANGE(0x000000, 0x07ffff) AM_READ(SMH_ROM)
170178
r3514r3515
178186
179187   AM_RANGE(0x130000, 0x1307ff) AM_READ(SMH_RAM)
180188
181   AM_RANGE(0x140006, 0x140007) AM_READ(random_readers)
189//  AM_RANGE(0x140006, 0x140007) AM_READ(random_readers)
182190
183   AM_RANGE(0x150006, 0x150007) AM_READ(SMH_NOP)
191//  AM_RANGE(0x150006, 0x150007) AM_READ(SMH_NOP)
184192
185193   AM_RANGE(0x16c006, 0x16c007) AM_READ(mirage_input_r)
186194
187   AM_RANGE(0x16e002, 0x16e003) AM_READ(mirage_controls_r)
195   AM_RANGE(0x16e002, 0x16e003) AM_READ_PORT("SYSTEM_IN")
188196
189197   AM_RANGE(0x170000, 0x173fff) AM_READ(SMH_RAM)
190
191198ADDRESS_MAP_END
192199
193200static ADDRESS_MAP_START( mirage_writemem, ADDRESS_SPACE_PROGRAM, 16 )
r3514r3515
204211
205212   AM_RANGE(0x130000, 0x1307ff) AM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE(&paletteram16)
206213
207   AM_RANGE(0x140000, 0x140001) AM_READWRITE(okim6295_status_1_lsb_r, okim6295_data_1_lsb_w)
208   AM_RANGE(0x140002, 0x140003) AM_READWRITE(okim6295_status_1_lsb_r, okim6295_data_1_lsb_w)
214   AM_RANGE(0x140000, 0x14000f) AM_READWRITE(okim6295_status_1_lsb_r, okim6295_data_1_lsb_w)
215   AM_RANGE(0x150000, 0x15000f) AM_READWRITE(okim6295_status_0_lsb_r, okim6295_data_0_lsb_w)
209216
210//  AM_RANGE(0x140008, 0x140009) AM_WRITE(okim1_rombank_w)
211
212   AM_RANGE(0x150000, 0x150001) AM_READWRITE(okim6295_status_0_lsb_r, okim6295_data_0_lsb_w)
213   AM_RANGE(0x150002, 0x150003) AM_READWRITE(okim6295_status_0_lsb_r, okim6295_data_0_lsb_w)
214
215//  AM_RANGE(0x150008, 0x150009) AM_WRITE(okim0_rombank_w)
216
217217   AM_RANGE(0x160000, 0x160001) AM_WRITE(SMH_NOP)
218218
219219   AM_RANGE(0x168000, 0x16800f) AM_WRITE(SMH_RAM) AM_BASE(&deco16_pf12_control)
220220
221221   AM_RANGE(0x16a000, 0x16a001) AM_WRITE(SMH_NOP)
222222
223   AM_RANGE(0x16c000, 0x16c001) AM_WRITE(SMH_NOP)
224   AM_RANGE(0x16c002, 0x16c003) AM_WRITE(SMH_NOP)
223   AM_RANGE(0x16c000, 0x16c001) AM_WRITE(okim1_rombank_w)
224   AM_RANGE(0x16c002, 0x16c003) AM_WRITE(okim0_rombank_w)
225225   AM_RANGE(0x16c004, 0x16c005) AM_WRITE(mirage_mux_w)
226226
227227   AM_RANGE(0x16e000, 0x16e001) AM_WRITE(SMH_NOP)
r3514r3515
382382
383383   MDRV_SOUND_ADD("oki2", OKIM6295, 1000000)
384384   MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified
385   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
385   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
386386MACHINE_DRIVER_END
387387
388388
r3514r3515
398398     ROM_LOAD16_BYTE( "mbl-01.11a", 0x000001, 0x200000, CRC(895be69a) SHA1(541d8f37fb4cf99312b80a0eb0d729fbbeab5f4f) )
399399   ROM_LOAD16_BYTE( "mbl-02.12a", 0x000000, 0x200000, CRC(474f6104) SHA1(ff81b32b90192c3d5f27c436a9246aa6caaeeeee) )
400400
401   ROM_REGION( 0x200000, "oki1", 0 )   /* M6295 samples */
402   ROM_LOAD( "mbl-03.10a", 0x000000, 0x200000, CRC(4a599703) SHA1(b49e84faa2d6acca952740d30fc8d1a33ac47e79) )
401   ROM_REGION( 0x240000, "oki1", 0 )   /* M6295 samples */
402   ROM_LOAD( "mbl-03.10a", 0x040000, 0x200000, CRC(4a599703) SHA1(b49e84faa2d6acca952740d30fc8d1a33ac47e79) )
403   ROM_RELOAD(            0x000000, 0x040000 )
403404
404   ROM_REGION( 0x100000, "oki2", 0 )   /* M6295 samples */
405   ROM_LOAD( "mbl-04.12k", 0x000000, 0x100000, CRC(b533123d) SHA1(2cb2f11331d00c2d282113932ed2836805f4fc6e) )
405   ROM_REGION( 0x140000, "oki2", 0 )   /* M6295 samples */
406   ROM_LOAD( "mbl-04.12k", 0x040000, 0x100000, CRC(b533123d) SHA1(2cb2f11331d00c2d282113932ed2836805f4fc6e) )
407   ROM_RELOAD(            0x000000, 0x040000 )
406408ROM_END
407409
408#if 0
409static void descramble_sound( running_machine *machine, const char *region )
410{
411   UINT8 *rom = memory_region(machine, region);
412   int length = memory_region_length(machine, region);
413   UINT8 *buf1 = malloc_or_die(length);
414   UINT32 x;
415
416   for (x=0;x<length;x++)
417   {
418      UINT32 addr;
419
420      addr = BITSWAP24 (x,23,22,21,0, 20,
421                          19,18,17,16,
422                          15,14,13,12,
423                          11,10,9, 8,
424                          7, 6, 5, 4,
425                          3, 2, 1 );
426
427      buf1[addr] = rom[x];
428   }
429
430   memcpy(rom,buf1,length);
431
432   free (buf1);
433
434#if 0
435   {
436      FILE *fp;
437      fp=fopen("sound.dmp", "w+b");
438      if (fp)
439      {
440         fwrite(rom, length, 1, fp);
441         fclose(fp);
442      }
443   }
444#endif
445
446}
447#endif
448
449410static DRIVER_INIT( mirage )
450411{
451412   deco56_decrypt_gfx(machine, "gfx1");
452   //descramble_sound(machine, "oki1");
453413}
454414
455GAME( 1994, mirage, 0,        mirage, mirage, mirage, ROT0, "Mitchell", "Mirage Youjuu Mahjongden (Japan)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
415GAME( 1994, mirage, 0,        mirage, mirage, mirage, ROT0, "Mitchell", "Mirage Youjuu Mahjongden (Japan)", GAME_IMPERFECT_GRAPHICS )
src/mame/drivers/jalmah.c
r3514r3515
1818  adding a value to these RAM areas according to what button is pressed.
1919
2020TODO:
21-Understand what are RANGE registers for.They seems to be related to the scroll
22 registers;
23-In all the games there are square gaps during gameplay,maybe we can call a simple fillbitmap and
24 remove the jalmah_tilemap_draw custom code;
25-Fix kakumei2 GFX3 rom region,maybe bad dump (half length)?
2621-Fully understand priorities,chances are that it just uses a mix between the priority
27 number and 1+ prom(s);
28-Fix daireika GFX rom loading and check if urashima has a "mode 3" for the layer 0
29 tilemap;
22 number,1+ prom(s) and the color number inside the video ram.Might need a test with the proper hardware;
23-In all the games there are square gaps during gameplay,caused by the imperfect priority system (see above);
24-Check if urashima has a "mode 3" for the layer 0 tilemap;
3025-Complete the dip-switches in the first version of this board;
3126-There could be timing issues caused by MCU simulation at $80004;
32-daireika/kakumei2/urashima have problems with the tx layer vertical scrolling during the attract
33 mode, likely to be a paging issue;
34-Fix the sound banking in the first version of the MCU.A bank issue?
35-urashima might use three layers instead of two or it's all mirrored.It can be checked when you win
36 a match in particular circumstances because there's a write in a unmapped region;
37-Massive clean-ups needed for the MCU snippet programs;
27-Fix the sound banking in the first version of the MCU.Protection-related (should be somewhere on the work ram/shared ram)
28-Fix kakumei2 GFX3 rom region,maybe it's a bad dump (half length)?
29-urashima: might use three/four layers instead of two.It can be checked when you win
30 a match in particular circumstances because there's a write in the 94000-9bfff region;
31-kakumei: inserting two credits will give an "informaion" with A-E button choices and nothing appears
32 to work,protection?
33-Fix the sound banking in urashima/mjzoomin/daireika;
34-Massive clean-ups needed for the MCU snippet programs and the input-ports;
3835
3936Notes (1st MCU ver.):
4037-$f000e is bogus,maybe the program snippets can modify this value,or the MCU itself can
r3514r3515
107104#include "cpu/m68000/m68000.h"
108105#include "sound/okim6295.h"
109106
110static tilemap *sc3_tilemap, *sc0_tilemap,*sc1_tilemap,*sc2_tilemap;
111static UINT16 *sc3_vram, *sc0_vram,*sc1_vram,*sc2_vram;
112static UINT16 *jm_regs,*jm_ram,*jm_mcu_code;
107/******************************************************************************************
108
109Video Hardware start
110
111******************************************************************************************/
112
113static tilemap *sc3_tilemap_0,*sc3_tilemap_2,*sc3_tilemap_3,
114            *sc0_tilemap_0,*sc0_tilemap_1,*sc0_tilemap_2,*sc0_tilemap_3,
115               *sc1_tilemap_0,*sc1_tilemap_1,*sc1_tilemap_2,*sc1_tilemap_3,
116            *sc2_tilemap_0,*sc2_tilemap_1,*sc2_tilemap_2,*sc2_tilemap_3;
117static UINT16 *sc3_vram,*sc0_vram,*sc1_vram,*sc2_vram;
113118static UINT16 *jm_scrollram,*jm_vregs;
114119static UINT16 sc0bank,pri;
115/*
116MCU program number,different for each game(n.b. the numbering scheme is *mine*,do not
117take it seriously...):
1180x11 = daireika
1190x12 = urashima
1200x13 = mjzoomin
1210x21 = kakumei
1220x22 = kakumei2
1230x23 = suchipi
124120
125xxxx ---- MCU program revision
126---- xxxx MCU program number assignment for each game.
127*/
128static UINT8 mcu_prg;
129#define DAIREIKA_MCU (0x11)
130#define URASHIMA_MCU (0x12)
131#define MJZOOMIN_MCU (0x13)
132#define KAKUMEI_MCU  (0x21)
133#define KAKUMEI2_MCU (0x22)
134#define SUCHIPI_MCU  (0x23)
121/*4096x512 tilemap*/
122static TILEMAP_MAPPER( range0_16x16 )
123{
124   /* logical (col,row) -> memory offset */
125   return (row & 0x0f) + ((col & 0xff) << 4) + ((row & 0x70) << 8);
126}
135127
136static int respcount;
128/*2048x1024 tilemap*/
129static TILEMAP_MAPPER( range1_16x16 )
130{
131   /* logical (col,row) -> memory offset */
132   return (row & 0x0f) + ((col & 0x7f) << 4) + ((row & 0xf0) << 7);
133}
137134
138static TILEMAP_MAPPER( bg_scan )
135/*1024x2048 tilemap*/
136static TILEMAP_MAPPER( range2_16x16 )
139137{
140138   /* logical (col,row) -> memory offset */
141   return (row & 0x0f) + ((col & 0xff) << 4) + ((row & 0x70) << 8);
139   return (row & 0x0f) + ((col & 0x3f) << 4) + ((row & 0x1f0) << 6);
142140}
143141
142/*512x4096 tilemap*/
143static TILEMAP_MAPPER( range3_16x16 )
144{
145   /* logical (col,row) -> memory offset */
146   return (row & 0x0f) + ((col & 0x1f) << 4) + ((row & 0x3f0) << 5);
147}
148
149
150/*1024x512 tilemap*/
151static TILEMAP_MAPPER( range2_8x8 )
152{
153   /* logical (col,row) -> memory offset */
154   return (row & 0x1f) + ((col & 0x7f) * 0x20) + ((row & 0x20) * 0x80);
155}
156
157/*512x1024 tilemap*/
158static TILEMAP_MAPPER( range3_8x8 )
159{
160   return (row & 0x1f) + ((col & 0x3f) * 0x20) + ((row & 0x60) * 0x40);
161}
162
144163static TILE_GET_INFO( get_sc0_tile_info )
145164{
146165   int code = sc0_vram[tile_index];
r3514r3515
151170         0);
152171}
153172
154static TILE_GET_INFO( get_sc3_tile_info )
173static TILE_GET_INFO( get_sc1_tile_info )
155174{
156   int code = sc3_vram[tile_index];
175   int code = sc1_vram[tile_index];
157176   SET_TILE_INFO(
158         0,
177         2,
159178         code & 0xfff,
160179         code >> 12,
161180         0);
r3514r3515
171190         0);
172191}
173192
174static TILE_GET_INFO( get_sc1_tile_info )
193static TILE_GET_INFO( get_sc3_tile_info )
175194{
176   int code = sc1_vram[tile_index];
195   int code = sc3_vram[tile_index];
177196   SET_TILE_INFO(
178         2,
197         0,
179198         code & 0xfff,
180199         code >> 12,
181200         0);
r3514r3515
183202
184203static VIDEO_START( jalmah )
185204{
186   sc0_tilemap = tilemap_create(get_sc0_tile_info,bg_scan,16,16,256,32);
187   sc1_tilemap = tilemap_create(get_sc1_tile_info,bg_scan,16,16,256,32);
188   sc2_tilemap = tilemap_create(get_sc2_tile_info,bg_scan,16,16,256,32);
189   sc3_tilemap = tilemap_create(get_sc3_tile_info,tilemap_scan_cols,8,8,256,32);
205   sc0_tilemap_0 = tilemap_create(get_sc0_tile_info,range0_16x16,16,16,256,32);
206   sc0_tilemap_1 = tilemap_create(get_sc0_tile_info,range1_16x16,16,16,128,64);
207   sc0_tilemap_2 = tilemap_create(get_sc0_tile_info,range2_16x16,16,16,64,128);
208   sc0_tilemap_3 = tilemap_create(get_sc0_tile_info,range3_16x16,16,16,32,256);
190209
210   sc1_tilemap_0 = tilemap_create(get_sc1_tile_info,range0_16x16,16,16,256,32);
211   sc1_tilemap_1 = tilemap_create(get_sc1_tile_info,range1_16x16,16,16,128,64);
212   sc1_tilemap_2 = tilemap_create(get_sc1_tile_info,range2_16x16,16,16,64,128);
213   sc1_tilemap_3 = tilemap_create(get_sc1_tile_info,range3_16x16,16,16,32,256);
214
215   sc2_tilemap_0 = tilemap_create(get_sc2_tile_info,range0_16x16,16,16,256,32);
216   sc2_tilemap_1 = tilemap_create(get_sc2_tile_info,range1_16x16,16,16,128,64);
217   sc2_tilemap_2 = tilemap_create(get_sc2_tile_info,range2_16x16,16,16,64,128);
218   sc2_tilemap_3 = tilemap_create(get_sc2_tile_info,range3_16x16,16,16,32,256);
219
220   sc3_tilemap_0 = tilemap_create(get_sc3_tile_info,tilemap_scan_cols,8,8,256,32);
221//  sc3_tilemap_1 = tilemap_create(get_sc3_tile_info,tilemap_scan_cols,8,8,256,32);
222   sc3_tilemap_2 = tilemap_create(get_sc3_tile_info,range2_8x8,8,8,128,64);
223   sc3_tilemap_3 = tilemap_create(get_sc3_tile_info,range3_8x8,8,8,64,128);
224
191225   jm_scrollram = auto_malloc(0x80);
192226   jm_vregs = auto_malloc(0x40);
193227
194   tilemap_set_transparent_pen(sc0_tilemap,15);
195   tilemap_set_transparent_pen(sc1_tilemap,15);
196   tilemap_set_transparent_pen(sc2_tilemap,15);
197   tilemap_set_transparent_pen(sc3_tilemap,15);
228   tilemap_set_transparent_pen(sc0_tilemap_0,15);
229   tilemap_set_transparent_pen(sc0_tilemap_1,15);
230   tilemap_set_transparent_pen(sc0_tilemap_2,15);
231   tilemap_set_transparent_pen(sc0_tilemap_3,15);
232
233   tilemap_set_transparent_pen(sc1_tilemap_0,15);
234   tilemap_set_transparent_pen(sc1_tilemap_1,15);
235   tilemap_set_transparent_pen(sc1_tilemap_2,15);
236   tilemap_set_transparent_pen(sc1_tilemap_3,15);
237
238   tilemap_set_transparent_pen(sc2_tilemap_0,15);
239   tilemap_set_transparent_pen(sc2_tilemap_1,15);
240   tilemap_set_transparent_pen(sc2_tilemap_2,15);
241   tilemap_set_transparent_pen(sc2_tilemap_3,15);
242
243   tilemap_set_transparent_pen(sc3_tilemap_0,15);
244   tilemap_set_transparent_pen(sc3_tilemap_2,15);
245   tilemap_set_transparent_pen(sc3_tilemap_3,15);
198246}
199247
200/*two tilemaps instead of four*/
201248static VIDEO_START( urashima )
202249{
203   sc0_tilemap = tilemap_create(get_sc0_tile_info,bg_scan,16,16,256,32);
204//  sc1_tilemap = tilemap_create(get_sc1_tile_info,bg_scan,TILEMAP_TRANSPARENT,16,16,256,32);
205//  sc2_tilemap = tilemap_create(get_sc2_tile_info,bg_scan,TILEMAP_TRANSPARENT,16,16,256,32);
206   sc3_tilemap = tilemap_create(get_sc3_tile_info,tilemap_scan_cols,8,8,256,32);
250   sc0_tilemap_0 = tilemap_create(get_sc0_tile_info,range0_16x16,16,16,256,32);
251   sc3_tilemap_0 = tilemap_create(get_sc3_tile_info,range2_8x8,8,8,128,64);
207252
208253   jm_scrollram = auto_malloc(0x80);
209254   jm_vregs = auto_malloc(0x40);
210255
211   tilemap_set_transparent_pen(sc0_tilemap,15);
212//  tilemap_set_transparent_pen(sc1_tilemap,15);
213//  tilemap_set_transparent_pen(sc2_tilemap,15);
214   tilemap_set_transparent_pen(sc3_tilemap,15);
256   tilemap_set_transparent_pen(sc0_tilemap_0,15);
257   tilemap_set_transparent_pen(sc3_tilemap_0,15);
215258}
216259
260static UINT8 sc0_prin,sc1_prin,sc2_prin,sc3_prin;
261
262static void jalmah_priority_system(void)
263{
264//  UINT8 *pri_rom = memory_region(Machine, "user1");
265   /*
266    Case by case priorities:
267    kakumei: title screen     = 0/23  (0-1 unused)
268             attract mode     = 0/0123 (?)
269             card table       = 0/013 (2 unused)
270             gameplay         = 0/0123
271    kakumei2:title screen     = 0/0123
272             attract mode     = 4/013 (2 unused) also 4/0213
273             card table       = 9/013 (2 unused)
274             character screen = 9/013 (2 unused)
275             gameplay         = 2/03  (1-2 unused) also 2/013 (2 unused)
276             continue screen  = 9/013 (2 unused)
277    suchipi: title screen     = 0/03  (1-2 unused)
278             attract mode     = 6/103 (2 unused) also 6/1023
279             card table       = 1/013 (2 unused)
280             character screen = 4/0213
281             victory screen   = 6/0123 also 6/1023
282             gameplay         = d/0123
283    mjzoomin doesn't seem to use the priority number (0/0123)
284    daireika/urashima uses priority number with the protection device
285    daireika: gameplay        = x/103 (2 unused),might be 6
286    good results:
287    0/0123
288    4/0213
289    6/1023
290    */
291   static const UINT16 pri_scheme[0x10] = { 0x0123, 0x0123, 0x0123, 0x0123, 0x0213, 0x0123, 0x1023, 0x0123,
292                                  0x0123, 0x1203, 0x0123, 0x0123, 0x0123, 0x0123, 0x0123, 0x0123    };
293//  UINT8 prinum[0x10];
294
295//  for(i=0;i<0x10;i++)
296//      prinum[i] = pri_rom[i+pri*0x10];
297   sc0_prin = (pri_scheme[pri] & 0xf000) >> 12;
298   sc1_prin = (pri_scheme[pri] & 0x0f00) >> 8;
299   sc2_prin = (pri_scheme[pri] & 0x00f0) >> 4;
300   sc3_prin = (pri_scheme[pri] & 0x000f) >> 0;
301
302//  popmessage("%04x",pri);
303   /*
304    popmessage("%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x %02x"
305    ,prinum[0x00],prinum[0x01],prinum[0x02],prinum[0x03]
306    ,prinum[0x04],prinum[0x05],prinum[0x06],prinum[0x07]
307    ,prinum[0x08],prinum[0x09],prinum[0x0a],prinum[0x0b]
308    ,prinum[0x0c],prinum[0x0d],prinum[0x0e],prinum[0x0f],pri);
309    */
310}
311
312static void draw_sc0_layer(bitmap_t *bitmap, const rectangle *cliprect,int trans)
313{
314   switch(jm_vregs[0] & 3)
315   {
316      case 0: tilemap_draw(bitmap,cliprect,sc0_tilemap_0,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break;
317      case 1: tilemap_draw(bitmap,cliprect,sc0_tilemap_1,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break;
318      case 2: tilemap_draw(bitmap,cliprect,sc0_tilemap_2,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break;
319      case 3: tilemap_draw(bitmap,cliprect,sc0_tilemap_3,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break;
320   }
321}
322
323static void draw_sc1_layer(bitmap_t *bitmap, const rectangle *cliprect,int trans)
324{
325   switch(jm_vregs[1] & 3)
326   {
327      case 0: tilemap_draw(bitmap,cliprect,sc1_tilemap_0,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break;
328      case 1: tilemap_draw(bitmap,cliprect,sc1_tilemap_1,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break;
329      case 2: tilemap_draw(bitmap,cliprect,sc1_tilemap_2,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break;
330      case 3: tilemap_draw(bitmap,cliprect,sc1_tilemap_3,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break;
331   }
332}
333
334static void draw_sc2_layer(bitmap_t *bitmap, const rectangle *cliprect,int trans)
335{
336   switch(jm_vregs[2] & 3)
337   {
338      case 0: tilemap_draw(bitmap,cliprect,sc2_tilemap_0,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break;
339      case 1: tilemap_draw(bitmap,cliprect,sc2_tilemap_1,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break;
340      case 2: tilemap_draw(bitmap,cliprect,sc2_tilemap_2,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break;
341      case 3: tilemap_draw(bitmap,cliprect,sc2_tilemap_3,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break;
342   }
343}
344
345static void draw_sc3_layer(bitmap_t *bitmap, const rectangle *cliprect,int trans)
346{
347   switch(jm_vregs[3] & 3)
348   {
349      case 0:
350      case 1: tilemap_draw(bitmap,cliprect,sc3_tilemap_0,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break;
351      case 2: tilemap_draw(bitmap,cliprect,sc3_tilemap_2,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break;
352      case 3: tilemap_draw(bitmap,cliprect,sc3_tilemap_3,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break;
353   }
354}
355
356static VIDEO_UPDATE( jalmah )
357{
358   static UINT8 cur_prin;
359   jalmah_priority_system();
360
361   tilemap_set_scrollx( sc0_tilemap_0, 0, jm_scrollram[0] & 0xfff);
362   tilemap_set_scrollx( sc0_tilemap_1, 0, jm_scrollram[0] & 0x7ff);
363   tilemap_set_scrollx( sc0_tilemap_2, 0, jm_scrollram[0] & 0x3ff);
364   tilemap_set_scrollx( sc0_tilemap_3, 0, jm_scrollram[0] & 0x1ff);
365
366   tilemap_set_scrollx( sc1_tilemap_0, 0, jm_scrollram[1] & 0xfff);
367   tilemap_set_scrollx( sc1_tilemap_1, 0, jm_scrollram[1] & 0x7ff);
368   tilemap_set_scrollx( sc1_tilemap_2, 0, jm_scrollram[1] & 0x3ff);
369   tilemap_set_scrollx( sc1_tilemap_3, 0, jm_scrollram[1] & 0x1ff);
370
371   tilemap_set_scrollx( sc2_tilemap_0, 0, jm_scrollram[2] & 0xfff);
372   tilemap_set_scrollx( sc2_tilemap_1, 0, jm_scrollram[2] & 0x7ff);
373   tilemap_set_scrollx( sc2_tilemap_2, 0, jm_scrollram[2] & 0x3ff);
374   tilemap_set_scrollx( sc2_tilemap_3, 0, jm_scrollram[2] & 0x1ff);
375
376   tilemap_set_scrollx( sc3_tilemap_0, 0, jm_scrollram[3] & 0x7ff);
377//  empty
378   tilemap_set_scrollx( sc3_tilemap_2, 0, jm_scrollram[3] & 0x3ff);
379   tilemap_set_scrollx( sc3_tilemap_3, 0, jm_scrollram[3] & 0x1ff);
380
381
382   tilemap_set_scrolly( sc0_tilemap_0, 0, jm_scrollram[4] & 0x1ff);
383   tilemap_set_scrolly( sc0_tilemap_1, 0, jm_scrollram[4] & 0x3ff);
384   tilemap_set_scrolly( sc0_tilemap_2, 0, jm_scrollram[4] & 0x7ff);
385   tilemap_set_scrolly( sc0_tilemap_3, 0, jm_scrollram[4] & 0xfff);
386
387   tilemap_set_scrolly( sc1_tilemap_0, 0, jm_scrollram[5] & 0x1ff);
388   tilemap_set_scrolly( sc1_tilemap_1, 0, jm_scrollram[5] & 0x3ff);
389   tilemap_set_scrolly( sc1_tilemap_2, 0, jm_scrollram[5] & 0x7ff);
390   tilemap_set_scrolly( sc1_tilemap_3, 0, jm_scrollram[5] & 0xfff);
391
392   tilemap_set_scrolly( sc2_tilemap_0, 0, jm_scrollram[6] & 0x1ff);
393   tilemap_set_scrolly( sc2_tilemap_1, 0, jm_scrollram[6] & 0x3ff);
394   tilemap_set_scrolly( sc2_tilemap_2, 0, jm_scrollram[6] & 0x7ff);
395   tilemap_set_scrolly( sc2_tilemap_3, 0, jm_scrollram[6] & 0xfff);
396
397   tilemap_set_scrolly( sc3_tilemap_0, 0, jm_scrollram[7] & 0xff);
398//  empty
399   tilemap_set_scrolly( sc3_tilemap_2, 0, jm_scrollram[7] & 0x1ff);
400   tilemap_set_scrolly( sc3_tilemap_3, 0, jm_scrollram[7] & 0x3ff);
401
402    fillbitmap(bitmap, Machine->pens[0x10f], cliprect);//selectable by a ram address?
403
404   for(cur_prin=0;cur_prin<4;cur_prin++)
405   {
406      if(cur_prin==sc0_prin) { draw_sc0_layer(bitmap,cliprect,sc0_prin); }
407      if(cur_prin==sc1_prin) { draw_sc1_layer(bitmap,cliprect,sc1_prin); }
408      if(cur_prin==sc2_prin) { draw_sc2_layer(bitmap,cliprect,sc2_prin); }
409      if(cur_prin==sc3_prin) { draw_sc3_layer(bitmap,cliprect,sc3_prin); }
410   }
411
412   return 0;
413}
414
415static VIDEO_UPDATE( urashima )
416{
417   /*this game doesn't use the RANGE register at all.*/
418   tilemap_set_scrollx( sc0_tilemap_0, 0, jm_scrollram[0]);
419   tilemap_set_scrollx( sc3_tilemap_0, 0, jm_scrollram[3]);
420   tilemap_set_scrolly( sc0_tilemap_0, 0, jm_scrollram[4]);
421   tilemap_set_scrolly( sc3_tilemap_0, 0, jm_scrollram[7]);
422
423   fillbitmap(bitmap, Machine->pens[0x1ff], cliprect);//selectable by a ram address?
424   if(jm_vregs[0] & 1) { tilemap_draw(bitmap,cliprect,sc0_tilemap_0,0,0); }
425    if(jm_vregs[3] & 1) { tilemap_draw(bitmap,cliprect,sc3_tilemap_0,0,0); }
426   return 0;
427}
428
429static WRITE16_HANDLER( sc0_vram_w )
430{
431   COMBINE_DATA(&sc0_vram[offset]);
432   /*2048x256 tilemap*/
433   tilemap_mark_tile_dirty(sc0_tilemap_0,offset);
434   /*1024x512 tilemap*/
435   tilemap_mark_tile_dirty(sc0_tilemap_1,offset);
436   /*512x1024 tilemap*/
437   tilemap_mark_tile_dirty(sc0_tilemap_2,offset);
438   /*256x2048 tilemap*/
439   tilemap_mark_tile_dirty(sc0_tilemap_3,offset);
440}
441
442static WRITE16_HANDLER( sc3_vram_w )
443{
444   COMBINE_DATA(&sc3_vram[offset]);
445   /*2048x256 tilemap*/
446   tilemap_mark_tile_dirty(sc3_tilemap_0,offset);
447   /*1024x512 tilemap*/
448   tilemap_mark_tile_dirty(sc3_tilemap_2,offset);
449   /*512x1024 tilemap*/
450   tilemap_mark_tile_dirty(sc3_tilemap_3,offset);
451}
452
453static WRITE16_HANDLER( sc1_vram_w )
454{
455   COMBINE_DATA(&sc1_vram[offset]);
456   /*2048x256 tilemap*/
457   tilemap_mark_tile_dirty(sc1_tilemap_0,offset);
458   /*1024x512 tilemap*/
459   tilemap_mark_tile_dirty(sc1_tilemap_1,offset);
460   /*512x1024 tilemap*/
461   tilemap_mark_tile_dirty(sc1_tilemap_2,offset);
462   /*256x2048 tilemap*/
463   tilemap_mark_tile_dirty(sc1_tilemap_3,offset);
464}
465
466static WRITE16_HANDLER( sc2_vram_w )
467{
468   COMBINE_DATA(&sc2_vram[offset]);
469   /*2048x256 tilemap*/
470   tilemap_mark_tile_dirty(sc2_tilemap_0,offset);
471   /*1024x512 tilemap*/
472   tilemap_mark_tile_dirty(sc2_tilemap_1,offset);
473   /*512x1024 tilemap*/
474   tilemap_mark_tile_dirty(sc2_tilemap_2,offset);
475   /*256x2048 tilemap*/
476   tilemap_mark_tile_dirty(sc2_tilemap_3,offset);
477}
478
479static WRITE16_HANDLER( jalmah_tilebank_w )
480{
481   /*
482     xxxx ---- fg bank (used by suchipi)
483     ---- xxxx Priority number (trusted,see mjzoomin)
484    */
485   //popmessage("Write to tilebank %02x",data);
486   if (ACCESSING_BITS_0_7)
487   {
488      if (sc0bank != ((data & 0xf0) >> 4))
489      {
490         sc0bank = (data & 0xf0) >> 4;
491         tilemap_mark_all_tiles_dirty(sc0_tilemap_0);
492         tilemap_mark_all_tiles_dirty(sc0_tilemap_1);
493         tilemap_mark_all_tiles_dirty(sc0_tilemap_2);
494         tilemap_mark_all_tiles_dirty(sc0_tilemap_3);
495      }
496      if (pri != (data & 0x0f))
497         pri = data & 0x0f;
498   }
499}
500
501static WRITE16_HANDLER( jalmah_scroll_w )
502{
503   //logerror("[%04x]<-%04x\n",(offset+0x10)*2,data);
504   switch(offset+(0x10))
505   {
506      /*These 4 are just video regs,see mjzoomin test*/
507      /*
508            ---x ---- Always on,8x8 tiles switch?
509            ---- --xx RANGE registers
510        */
511      case (0x24/2): jm_vregs[0] = data; break;
512      case (0x2c/2): jm_vregs[1] = data; break;
513      case (0x34/2): jm_vregs[2] = data; break;
514      case (0x3c/2): jm_vregs[3] = data; break;
515
516      case (0x20/2): jm_scrollram[0] = data; break;
517      case (0x28/2): jm_scrollram[1] = data; break;
518      case (0x30/2): jm_scrollram[2] = data; break;
519      case (0x38/2): jm_scrollram[3] = data; break;
520      case (0x22/2): jm_scrollram[4] = data; break;
521      case (0x2a/2): jm_scrollram[5] = data; break;
522      case (0x32/2): jm_scrollram[6] = data; break;
523      case (0x3a/2): jm_scrollram[7] = data; break;
524      //default:    popmessage("[%04x]<-%04x",offset+0x10,data);
525   }
526}
527
528static WRITE16_HANDLER( urashima_bank_w )
529{
530   if (ACCESSING_BITS_0_7)
531   {
532      if (sc0bank != (data & 0x0f))
533      {
534         sc0bank = (data & 0x0f);
535         tilemap_mark_all_tiles_dirty(sc0_tilemap_0);
536         //tilemap_mark_all_tiles_dirty(sc0_tilemap_2);
537         //tilemap_mark_all_tiles_dirty(sc0_tilemap_3);
538      }
539   }
540}
541
542static WRITE16_HANDLER( urashima_sc0_vram_w )
543{
544   COMBINE_DATA(&sc0_vram[offset]);
545   tilemap_mark_tile_dirty(sc0_tilemap_0,offset);
546}
547
548static WRITE16_HANDLER( urashima_sc3_vram_w )
549{
550   COMBINE_DATA(&sc3_vram[offset]);
551   tilemap_mark_tile_dirty(sc3_tilemap_0,offset);
552}
553
554/*Urashima Mahjong uses a bigger (and mostly unused/wasted) video register ram.*/
555static WRITE16_HANDLER( urashima_vregs_w )
556{
557   //logerror("[%04x]<-%04x\n",(offset)*2,data);
558   switch(offset)
559   {
560      case 0x082/2: jm_vregs[0] = data;     break; //sc0 plane enable
561      case 0x084/2: jm_scrollram[0] = data; break; //sc0 x offset
562      case 0x086/2: jm_scrollram[4] = data; break; //sc0 y offset
563
564//      case 0x182/2: jm_vregs[0] = data;     break;
565//      case 0x184/2: jm_scrollram[0] = data; break;
566//      case 0x186/2: jm_scrollram[4] = data; break;
567
568//      case 0x382/2: jm_vregs[0] = data;     break;
569//      case 0x384/2: jm_scrollram[0] = data; break;
570//      case 0x386/2: jm_scrollram[4] = data; break;
571
572      case 0x882/2: jm_vregs[3] = data;     break; //sc3 plane enable
573      case 0x884/2: jm_scrollram[3] = data; break; //sc3 x offset
574      case 0x886/2: jm_scrollram[7] = data; break; //sc3 y offset
575
576      /*WRONG!*/
577      case 0x602/2: jm_vregs[0] = data;     break;
578      case 0x604/2: jm_scrollram[0] = data; break;
579      case 0x606/2: jm_scrollram[4] = data; break;
580
581      case 0x77a/2: jm_vregs[0] = data;     break; //sc0 plane enable,flip screen
582      case 0x77c/2: jm_scrollram[0] = data; break; //sc0 x offset,flip screen
583      case 0x77e/2: jm_scrollram[4] = data; break; //sc0 y offset,flip screen
584
585      case 0xf7a/2: jm_vregs[3] = data;     break; //sc3 plane enable,flip screen
586      case 0xf7c/2: jm_scrollram[3] = data; break; //sc3 x offset,flip screen
587      case 0xf7e/2: jm_scrollram[7] = data; break; //sc3 y offset,flip screen
588      default: break;
589   }
590   //popmessage("%04x %04x %04x %04x %02x %02x",jm_scrollram[0],jm_scrollram[4],jm_scrollram[3],jm_scrollram[7],jm_vregs[0],jm_vregs[3]);
591}
592
593/******************************************************************************************
594
595Protection file start
596
597******************************************************************************************/
598
599static UINT16 *jm_shared_ram,*jm_mcu_code;
600
601/*
602MCU program number,different for each game(n.b. the numbering scheme is *mine*,do not
603take it seriously...):
6040x11 = daireika
6050x12 = urashima
6060x13 = mjzoomin
6070x21 = kakumei
6080x22 = kakumei2
6090x23 = suchipi
610
611xxxx ---- MCU program revision
612---- xxxx MCU program number assignment for each game.
613*/
614
615static UINT8 mcu_prg;
616#define DAIREIKA_MCU (0x11)
617#define URASHIMA_MCU (0x12)
618#define MJZOOMIN_MCU (0x13)
619#define KAKUMEI_MCU  (0x21)
620#define KAKUMEI2_MCU (0x22)
621#define SUCHIPI_MCU  (0x23)
622
623static int respcount;
624
217625#define MCU_READ(tag, _bit_, _offset_, _retval_) \
218if((0xffff - input_port_read(machine, tag)) & _bit_) { jm_regs[_offset_] = _retval_; }
626if((0xffff - input_port_read(machine, tag)) & _bit_) { jm_shared_ram[_offset_] = _retval_; }
219627
628/*Funky "DMA" / protection thing*/
629/*---- -x-- "DMA" execute.*/
630/*---- ---x used too very often,I don't have any clue of what it is,it might just be the source or the destination address.*/
631static WRITE16_HANDLER( urashima_dma_w )
632{
633   if(data & 4)
634   {
635      UINT32 i;
636      for(i=0;i<0x200;i+=2)
637         program_write_word(0x88200+i,program_read_word(0x88400+i));
638   }
639}
640
641/*same as $f00c0 sub-routine,but with additional work-around,to remove from here...*/
642static void daireika_palette_dma(running_machine *machine,UINT16 val)
643{
644   UINT32 index_1,index_2,src_addr,tmp_addr;
645   /*a0=301c0+jm_shared_ram[0x540/2] & 0xf00 */
646   /*a1=88000*/
647   src_addr = 0x301c0 + (val * 0x40);
648//  popmessage("%08x",src_addr);
649   for(index_1=0;index_1<0x200;index_1+=0x20)
650   {
651      tmp_addr = src_addr;
652      src_addr = program_read_dword(src_addr);
653
654      for(index_2=0;index_2<0x20;index_2+=2)
655         program_write_word(0x88000+index_2+index_1,program_read_word(src_addr+index_2));
656
657      src_addr = tmp_addr + 4;
658   }
659}
660
220661/*RAM-based protection handlings*/
221662static void daireika_mcu_run(running_machine *machine)
222663{
664   static UINT16 prg_prot,dma_old;
665
666   if(((jm_shared_ram[0x550/2] & 0xf00) == 0x700) && ((jm_shared_ram[0x540/2] & 0xf00) != dma_old))
667   {
668      dma_old = jm_shared_ram[0x540/2] & 0xf00;
669      daireika_palette_dma(machine,((jm_shared_ram[0x540/2] & 0x0f00) >> 8));
670   }
671
672   if((0xffff - input_port_read(machine, "SYSTEM")) & 0x0008)   //service_mode
673   {
674      jm_shared_ram[0x000/2] = input_port_read(machine, "KEY0");
675      jm_shared_ram[0x002/2] = input_port_read(machine, "KEY1");
676      jm_shared_ram[0x004/2] = input_port_read(machine, "KEY2");
677      jm_shared_ram[0x006/2] = input_port_read(machine, "KEY3");
678      jm_shared_ram[0x008/2] = input_port_read(machine, "KEY4");
679      jm_shared_ram[0x00a/2] = input_port_read(machine, "KEY5");
680   }
681   else
682   {
683      jm_shared_ram[0x000/2] = 0x0000;
684      MCU_READ("KEY1", 0x0001, 0x000/2, 0x00);      /*FF*/
685      MCU_READ("KEY2", 0x0400, 0x000/2, 0x01);      /*A*/
686      MCU_READ("KEY2", 0x1000, 0x000/2, 0x02);      /*B*/
687      MCU_READ("KEY2", 0x0200, 0x000/2, 0x03);      /*C*/
688      MCU_READ("KEY2", 0x0800, 0x000/2, 0x04);      /*D*/
689      MCU_READ("KEY2", 0x0004, 0x000/2, 0x05);      /*E*/
690      MCU_READ("KEY2", 0x0010, 0x000/2, 0x06);      /*F*/
691      MCU_READ("KEY2", 0x0002, 0x000/2, 0x07);      /*G*/
692      MCU_READ("KEY2", 0x0008, 0x000/2, 0x08);      /*H*/
693      MCU_READ("KEY1", 0x0400, 0x000/2, 0x09);      /*I*/
694      MCU_READ("KEY1", 0x1000, 0x000/2, 0x0a);      /*J*/
695      MCU_READ("KEY1", 0x0200, 0x000/2, 0x0b);      /*K*/
696      MCU_READ("KEY1", 0x0800, 0x000/2, 0x0c);      /*L*/
697      MCU_READ("KEY1", 0x0004, 0x000/2, 0x0d);      /*M*/
698      MCU_READ("KEY1", 0x0010, 0x000/2, 0x0e);      /*N*/
699      MCU_READ("KEY0", 0x0200, 0x000/2, 0x0f);      /*RON   (trusted)*/
700      MCU_READ("KEY0", 0x1000, 0x000/2, 0x10);      /*REACH (trusted)*/
701      MCU_READ("KEY0", 0x0400, 0x000/2, 0x11);      /*KAN            */
702      MCU_READ("KEY1", 0x0008, 0x000/2, 0x12);      /*PON            */
703      MCU_READ("KEY1", 0x0002, 0x000/2, 0x13);      /*CHI   (trusted)*/
704      MCU_READ("KEY0", 0x0004, 0x000/2, 0x14);      /*START1*/
705   }
706   prg_prot++;
707   if(prg_prot > 0x10) { prg_prot = 0; }
708   jm_shared_ram[0x00e/2] = prg_prot;
709}
710
711static void mjzoomin_mcu_run(running_machine *machine)
712{
223713   static UINT16 prg_prot;
224714
225715   if((0xffff - input_port_read(machine, "SYSTEM")) & 0x0008)   //service_mode
226716   {
227      jm_regs[0x000/2] = input_port_read(machine, "KEY0");
228      jm_regs[0x002/2] = input_port_read(machine, "KEY1");
229      jm_regs[0x004/2] = input_port_read(machine, "KEY2");
230      jm_regs[0x006/2] = input_port_read(machine, "KEY3");
231      jm_regs[0x008/2] = input_port_read(machine, "KEY4");
232      jm_regs[0x00a/2] = input_port_read(machine, "KEY5");
717      jm_shared_ram[0x000/2] = input_port_read(machine, "KEY0");
718      jm_shared_ram[0x002/2] = input_port_read(machine, "KEY1");
719      jm_shared_ram[0x004/2] = input_port_read(machine, "KEY2");
720      jm_shared_ram[0x006/2] = input_port_read(machine, "KEY3");
721      jm_shared_ram[0x008/2] = input_port_read(machine, "KEY4");
722      jm_shared_ram[0x00a/2] = input_port_read(machine, "KEY5");
233723   }
234724   else
235725   {
236      jm_regs[0x000/2] = 0x0000;
726      jm_shared_ram[0x000/2] = 0x0000;
237727      MCU_READ("KEY1", 0x0001, 0x000/2, 0x00);      /*FF*/
238728      MCU_READ("KEY2", 0x0400, 0x000/2, 0x01);      /*A*/
239729      MCU_READ("KEY2", 0x1000, 0x000/2, 0x02);      /*B*/
r3514r3515
256746      MCU_READ("KEY1", 0x0002, 0x000/2, 0x13);      /*CHI   (trusted)*/
257747      MCU_READ("KEY0", 0x0004, 0x000/2, 0x14);      /*START1*/
258748   }
259   if(MJZOOMIN_MCU)
260      jm_regs[0x00c/2] = mame_rand(machine) & 0xffff;
749   jm_shared_ram[0x00c/2] = mame_rand(machine) & 0xffff;
261750   prg_prot++;
262751   if(prg_prot > 0x10) { prg_prot = 0; }
263   jm_regs[0x00e/2] = prg_prot;
264
752   jm_shared_ram[0x00e/2] = prg_prot;
265753}
266754
267755static void urashima_mcu_run(running_machine *machine)
r3514r3515
270758
271759   if((0xffff - input_port_read(machine, "SYSTEM")) & 0x0008)   //service_mode
272760   {
273      jm_regs[0x300/2] = input_port_read(machine, "KEY0");
274      jm_regs[0x302/2] = input_port_read(machine, "KEY1");
275      jm_regs[0x304/2] = input_port_read(machine, "KEY2");
276      jm_regs[0x306/2] = input_port_read(machine, "KEY3");
277      jm_regs[0x308/2] = input_port_read(machine, "KEY4");
278      jm_regs[0x30a/2] = input_port_read(machine, "KEY5");
761      jm_shared_ram[0x300/2] = input_port_read(machine, "KEY0");
762      jm_shared_ram[0x302/2] = input_port_read(machine, "KEY1");
763      jm_shared_ram[0x304/2] = input_port_read(machine, "KEY2");
764      jm_shared_ram[0x306/2] = input_port_read(machine, "KEY3");
765      jm_shared_ram[0x308/2] = input_port_read(machine, "KEY4");
766      jm_shared_ram[0x30a/2] = input_port_read(machine, "KEY5");
279767   }
280768   else
281769   {
282      jm_regs[0x300/2] = 0x0000;
770      jm_shared_ram[0x300/2] = 0x0000;
283771      MCU_READ("KEY1", 0x0001, 0x300/2, 0x00);      /*FF*/
284772      MCU_READ("KEY2", 0x0400, 0x300/2, 0x01);      /*A*/
285773      MCU_READ("KEY2", 0x1000, 0x300/2, 0x02);      /*B*/
r3514r3515
302790      MCU_READ("KEY1", 0x0002, 0x300/2, 0x13);      /*CHI   (trusted)*/
303791      MCU_READ("KEY0", 0x0004, 0x300/2, 0x14);      /*START1*/
304792   }
305   jm_regs[0x30c/2] = mame_rand(machine) & 0xffff;
793   jm_shared_ram[0x30c/2] = mame_rand(machine) & 0xffff;
306794   prg_prot++;
307795   if(prg_prot > 0x10) { prg_prot = 0; }
308   jm_regs[0x30e/2] = prg_prot;
796   jm_shared_ram[0x30e/2] = prg_prot;
309797}
310798
311799static void second_mcu_run(running_machine *machine)
312800{
313801   if((0xffff - input_port_read(machine, "DSW")) & 0x0004)   //service_mode
314802   {
315      jm_regs[0x200/2] = input_port_read(machine, "KEY0");
316      jm_regs[0x202/2] = input_port_read(machine, "KEY1");
317      jm_regs[0x204/2] = input_port_read(machine, "KEY2");
803      jm_shared_ram[0x200/2] = input_port_read(machine, "KEY0");
804      jm_shared_ram[0x202/2] = input_port_read(machine, "KEY1");
805      jm_shared_ram[0x204/2] = input_port_read(machine, "KEY2");
318806   }
319807   else
320808   {
321      jm_regs[0x200/2] = 0x0000;
809      jm_shared_ram[0x200/2] = 0x0000;
322810      MCU_READ("KEY1", 0x0001, 0x200/2, 0x00);      /*FF*/
323811      MCU_READ("KEY2", 0x0400, 0x200/2, 0x01);      /*A*/
324812      MCU_READ("KEY2", 0x1000, 0x200/2, 0x02);      /*B*/
r3514r3515
343831
344832//      MCU_READ("KEY0", 0x0004, 0x7b8/2, 0x03);        /*START1(correct?)  */
345833   }
346   jm_regs[0x20c/2] = mame_rand(machine) & 0xffff; //kakumei2
834   jm_shared_ram[0x20c/2] = mame_rand(machine) & 0xffff; //kakumei2
347835
348836}
349837
350#define jalmah_tilemap_draw(_tilemap_) \
351   tilemap_draw(bitmap,cliprect,_tilemap_,(opaque & 1) ? 0 : TILEMAP_DRAW_OPAQUE,0); \
352   if(!opaque) { opaque = 1; }
353
354static VIDEO_UPDATE( jalmah )
838static TIMER_DEVICE_CALLBACK( jalmah_mcu_sim )
355839{
356   int opaque = 0;
357   #ifdef MAME_DEBUG
358   static UINT8 sc_db;
359   #endif
360
361   tilemap_set_scrollx( sc0_tilemap, 0, jm_scrollram[0] + ((jm_vregs[0] & 3) ? ((jm_scrollram[4] & 0x200) * 4) : 0));
362   tilemap_set_scrollx( sc1_tilemap, 0, jm_scrollram[1] + ((jm_vregs[1] & 3) ? ((jm_scrollram[5] & 0x200) * 4) : 0));
363   tilemap_set_scrollx( sc2_tilemap, 0, jm_scrollram[2] + ((jm_vregs[2] & 3) ? ((jm_scrollram[6] & 0x200) * 4) : 0));
364   tilemap_set_scrollx( sc3_tilemap, 0, jm_scrollram[3] + ((jm_vregs[3] & 3) ? ((jm_scrollram[7] & 0x200) * 4) : 0));
365   tilemap_set_scrolly( sc0_tilemap, 0, jm_scrollram[4] & 0x1ff);
366   tilemap_set_scrolly( sc1_tilemap, 0, jm_scrollram[5] & 0x1ff);
367   tilemap_set_scrolly( sc2_tilemap, 0, jm_scrollram[6] & 0x1ff);
368   tilemap_set_scrolly( sc3_tilemap, 0, jm_scrollram[7] & 0x1ff);
369
370   #ifdef MAME_DEBUG
371   if(input_code_pressed_once(JOYCODE_Y_UP_SWITCH))
372      sc_db++;
373   if(input_code_pressed_once(JOYCODE_Y_DOWN_SWITCH))
374      sc_db--;
375   if(sc_db > 3)
376      sc_db = 3;
377   //popmessage("%04x %04x %04x %04x %04x %04x",jm_vregs[0],jm_vregs[1],jm_vregs[2],jm_vregs[3],sc0bank,pri);
378   popmessage("%04d %04d %04x %02x %01x",jm_scrollram[0+sc_db],jm_scrollram[4+sc_db],jm_vregs[0+sc_db],sc_db,pri);
379   #endif
380   /*
381    Case by case priorities:
382    kakumei: title screen     = 0/23  (0-1 unused)
383             attract mode     = 0/0123 (?)
384             card table       = 0/013 (2 unused)
385             gameplay         = 0/0123
386    kakumei2:title screen     = 0/0123
387             attract mode     = 4/013 (2 unused) also 4/0213
388             card table       = 9/013 (2 unused)
389             character screen = 9/013 (2 unused)
390             gameplay         = 2/03  (1-2 unused) also 2/013 (2 unused)
391             continue screen  = 9/013 (2 unused)
392    suchipi: title screen     = 0/03  (1-2 unused)
393             attract mode     = 6/103 (2 unused) also 6/1023
394             card table       = 1/013 (2 unused)
395             character screen = 4/0213
396             victory screen   = 6/0123 also 6/1023
397             gameplay         = d/0123
398    mjzoomin doesn't seem to use the priority number (0/0123)
399    daireika/urashima uses priority number with the protection device
400    daireika: gameplay        = x/103 (2 unused),might be 6
401    good results:
402    0/0123
403    4/0213
404    6/1023
405    */
406   if(!(pri & 2) || (pri & 0x8)) { jalmah_tilemap_draw(sc0_tilemap); }
407   if(!(pri & 4) || (pri & 0x8)) { jalmah_tilemap_draw(sc1_tilemap); }
408   if(!(pri & 2) || (pri & 0x8)) { jalmah_tilemap_draw(sc2_tilemap); }
409   if(pri & 4 && (!(pri & 0x8))) { jalmah_tilemap_draw(sc1_tilemap); }
410   if(pri & 2 && (!(pri & 0x8))) { jalmah_tilemap_draw(sc0_tilemap); }
411   if(pri & 2 && (!(pri & 0x8))) { jalmah_tilemap_draw(sc2_tilemap); }
412   jalmah_tilemap_draw(sc3_tilemap);
413   return 0;
414}
415
416VIDEO_UPDATE( urashima )
417{
418   int opaque = 0;
419
420   /*this game doesn't use the RANGE register at all.*/
421   tilemap_set_scrollx( sc0_tilemap, 0, jm_scrollram[0]);
422   tilemap_set_scrollx( sc3_tilemap, 0, jm_scrollram[3]);
423   tilemap_set_scrolly( sc0_tilemap, 0, jm_scrollram[4] & 0x1ff);
424   tilemap_set_scrolly( sc3_tilemap, 0, jm_scrollram[7] & 0x1ff);
425
426   fillbitmap(bitmap, Machine->pens[0], cliprect);
427   if(jm_vregs[0] & 1) { jalmah_tilemap_draw(sc0_tilemap); }
428    if(jm_vregs[3] & 1) { jalmah_tilemap_draw(sc3_tilemap); }
429   return 0;
430}
431
432static VIDEO_EOF( jalmah )
433{
434840   switch(mcu_prg)
435841   {
436842      /*
r3514r3515
441847            #define KAKUMEI2_MCU (0x22)
442848            #define SUCHIPI_MCU  (0x23)
443849        */
444         case MJZOOMIN_MCU:
445         case DAIREIKA_MCU: daireika_mcu_run(machine); break;
446         case URASHIMA_MCU: urashima_mcu_run(machine); break;
850         case MJZOOMIN_MCU: mjzoomin_mcu_run(timer->machine); break;
851         case DAIREIKA_MCU: daireika_mcu_run(timer->machine); break;
852         case URASHIMA_MCU: urashima_mcu_run(timer->machine); break;
447853         case KAKUMEI_MCU:
448854         case KAKUMEI2_MCU:
449         case SUCHIPI_MCU:  second_mcu_run(machine); break;
855         case SUCHIPI_MCU:  second_mcu_run(timer->machine); break;
450856   }
451857}
452858
453static WRITE16_HANDLER( sc0_vram_w )
454{
455   COMBINE_DATA(&sc0_vram[offset]);
456   tilemap_mark_tile_dirty(sc0_tilemap,offset);
457}
859/******************************************************************************************
458860
459static WRITE16_HANDLER( sc1_vram_w )
460{
461   COMBINE_DATA(&sc1_vram[offset]);
462   tilemap_mark_tile_dirty(sc1_tilemap,offset);
463}
861Basic driver start
464862
465static WRITE16_HANDLER( sc3_vram_w )
466{
467   COMBINE_DATA(&sc3_vram[offset]);
468   tilemap_mark_tile_dirty(sc3_tilemap,offset);
469}
863******************************************************************************************/
470864
471static WRITE16_HANDLER( sc2_vram_w )
472{
473   COMBINE_DATA(&sc2_vram[offset]);
474   tilemap_mark_tile_dirty(sc2_tilemap,offset);
475}
865static UINT8 oki_rom,oki_bank,oki_za;
476866
477static WRITE16_HANDLER( jalmah_tilebank_w )
478{
479   /*
480     xxxx ---- fg bank (used by suchipi)
481     ---- xxxx Priority number (trusted,see mjzoomin)
482    */
483   //popmessage("Write to tilebank %02x",data);
484   if (ACCESSING_BITS_0_7)
485   {
486      if (sc0bank != ((data & 0xf0) >> 4))
487      {
488         sc0bank = (data & 0xf0) >> 4;
489         tilemap_mark_all_tiles_dirty(sc0_tilemap);
490      }
491      if (pri != (data & 0x0f))
492         pri = data & 0x0f;
493   }
494}
495
496#ifdef UNUSED_FUNCTION
497static WRITE16_HANDLER( jalmah_reg_w )
498{
499   COMBINE_DATA(&jm_regs[offset]);
500}
501#endif
502
503static WRITE16_HANDLER( jalmah_scroll_w )
504{
505   logerror("[%04x]<-%04x\n",(offset+0x10)*2,data);
506   switch(offset+(0x10))
507   {
508      /*These 4 are just video regs,see mjzoomin test*/
509      /*
510            ---x ---- Always on,8x8 tiles switch?
511            ---- --xx RANGE registers
512        */
513      case (0x24/2): jm_vregs[0] = data; break;
514      case (0x2c/2): jm_vregs[1] = data; break;
515      case (0x34/2): jm_vregs[2] = data; break;
516      case (0x3c/2): jm_vregs[3] = data; break;
517
518      case (0x20/2): jm_scrollram[0] = data; break;
519      case (0x28/2): jm_scrollram[1] = data; break;
520      case (0x30/2): jm_scrollram[2] = data; break;
521      case (0x38/2): jm_scrollram[3] = data; break;
522      case (0x22/2): jm_scrollram[4] = data; break;
523      case (0x2a/2): jm_scrollram[5] = data; break;
524      case (0x32/2): jm_scrollram[6] = data; break;
525      case (0x3a/2): jm_scrollram[7] = data; break;
526      //default:    popmessage("[%04x]<-%04x",offset+0x10,data);
527   }
528}
529
530/*Urashima Mahjong uses a bigger (and mostly unused/wasted) video register ram.*/
531static WRITE16_HANDLER( urashima_sc0vregs_w )
532{
533   //logerror("[%04x]<-%04x\n",(offset+0x10)*2,data);
534   switch(offset)
535   {
536      //case 0: break;
537      /*---- ---x plane enable*/
538      case 1: jm_vregs[0] = data; break; /*plane enable*/
539      case 2: jm_scrollram[0] = data; break;
540      case 3: break;
541   }
542}
543
544static WRITE16_HANDLER( urashima_sc3vregs_w )
545{
546   //logerror("[%04x]<-%04x\n",(offset+0x10)*2,data);
547   switch(offset)
548   {
549      /*---- ---x plane enable*/
550      //case 0:
551      case 1: jm_vregs[3] = data; break;
552      case 2: jm_scrollram[7] = data; break;
553      case 3: jm_scrollram[3] = data; break;
554   }
555}
556
557static UINT8 oki_rom,oki_bank;
558
559867static WRITE16_HANDLER( jalmah_okirom_w )
560868{
561869   if(ACCESSING_BITS_0_7)
562870   {
563871      UINT8 *oki = memory_region(machine, "oki");
564872      oki_rom = data & 1;
565      memcpy(&oki[0x20000], &oki[(oki_rom * 0x80000) + (oki_bank * 0x20000) + 0x40000], 0x20000);
873      /*ZA appears to be related to the banking*/
874      oki_za = (data & 2) ? 1 : 0;
875      memcpy(&oki[0x20000], &oki[(oki_rom * 0x80000) + ((oki_bank+oki_za) * 0x20000) + 0x40000], 0x20000);
566876   }
567
568   /*what "ZA" stands for? Used by Kakumei 2.*/
569   if(data & 2)
570      mame_printf_debug("ZA = 2\n");
877   //popmessage("PC=%06x %02x %02x %02x",activecpu_get_pc(),oki_rom,oki_za,oki_bank);
571878}
572879
573880static WRITE16_HANDLER( jalmah_okibank_w )
r3514r3515
576883   {
577884      UINT8 *oki = memory_region(machine, "oki");
578885      oki_bank = data & 3;
579      memcpy(&oki[0x20000], &oki[(oki_rom * 0x80000) + (oki_bank * 0x20000) + 0x40000], 0x20000);
886      memcpy(&oki[0x20000], &oki[(oki_rom * 0x80000) + ((oki_bank+oki_za) * 0x20000) + 0x40000], 0x20000);
580887   }
888   //popmessage("PC=%06x %02x %02x %02x",activecpu_get_pc(),oki_rom,oki_za,oki_bank);
581889}
582890
583891static WRITE16_HANDLER( jalmah_flip_screen_w )
r3514r3515
588896//  popmessage("%04x",data);
589897}
590898
591/*Funky "DMA" / protection thing*/
592/*---- -x-- "DMA" execute.*/
593/*---- ---x used too very often,I don't have any clue of what it is,it might just be the source or the destination address.*/
594WRITE16_HANDLER( urashima_dma_w )
595{
596   if(data & 4)
597   {
598      UINT32 i;
599      for(i=0;i<0x200;i+=2)
600         program_write_word(0x88200+i,program_read_word(0x88400+i));
601   }
602}
603
604WRITE16_HANDLER( urashima_bank_w )
605{
606   if (ACCESSING_BITS_0_7)
607   {
608      if (sc0bank != (data & 0x0f))
609      {
610         sc0bank = (data & 0x0f);
611         tilemap_mark_all_tiles_dirty(sc0_tilemap);
612      }
613   }
614}
615
616899static ADDRESS_MAP_START( jalmah, ADDRESS_SPACE_PROGRAM, 16 )
617900   AM_RANGE(0x000000, 0x07ffff) AM_ROM
618901   AM_RANGE(0x080000, 0x080001) AM_READ_PORT("SYSTEM")
r3514r3515
632915   AM_RANGE(0x094000, 0x097fff) AM_RAM_WRITE(sc1_vram_w) AM_BASE(&sc1_vram)
633916   AM_RANGE(0x098000, 0x09bfff) AM_RAM_WRITE(sc2_vram_w) AM_BASE(&sc2_vram)
634917   AM_RANGE(0x09c000, 0x09ffff) AM_RAM_WRITE(sc3_vram_w) AM_BASE(&sc3_vram)
635   AM_RANGE(0x0f0000, 0x0f0fff) AM_RAM AM_BASE(&jm_regs)/*shared with MCU*/
636   AM_RANGE(0x0f1000, 0x0fffff) AM_RAM AM_BASE(&jm_ram)
918   AM_RANGE(0x0f0000, 0x0f0fff) AM_RAM AM_BASE(&jm_shared_ram)/*shared with MCU*/
919   AM_RANGE(0x0f1000, 0x0fffff) AM_RAM /*Work Ram*/
637920   AM_RANGE(0x100000, 0x10ffff) AM_RAM AM_BASE(&jm_mcu_code)/*extra RAM for MCU code prg (NOT ON REAL HW!!!)*/
638921ADDRESS_MAP_END
639922
r3514r3515
652935   AM_RANGE(0x080040, 0x080041) AM_READWRITE(okim6295_status_0_lsb_r, okim6295_data_0_lsb_w)
653936   //       0x084000, 0x084001  ?
654937   AM_RANGE(0x088000, 0x0887ff) AM_RAM_WRITE(paletteram16_RRRRGGGGBBBBRGBx_word_w) AM_BASE(&paletteram16) /* Palette RAM */
655   AM_RANGE(0x090000, 0x09bfff) AM_RAM_WRITE(sc0_vram_w) AM_BASE(&sc0_vram)
656//  AM_RANGE(0x094000, 0x097fff) AM_RAM_WRITE(sc0_vram_w)
657//  AM_RANGE(0x098000, 0x09bfff) AM_RAM_WRITE(sc0_vram_w)
658//  AM_RANGE(0x094000, 0x097fff) AM_RAM_WRITE(sc1_vram_w) AM_BASE(&sc1_vram)/*unused*/
659//  AM_RANGE(0x098000, 0x09bfff) AM_RAM_WRITE(sc2_vram_w) AM_BASE(&sc2_vram)/*unused*/
938   AM_RANGE(0x090000, 0x093fff) AM_RAM_WRITE(urashima_sc0_vram_w) AM_BASE(&sc0_vram)
939   AM_RANGE(0x094000, 0x097fff) AM_RAM_WRITE(urashima_sc0_vram_w)
940   AM_RANGE(0x098000, 0x09bfff) AM_RAM_WRITE(urashima_sc0_vram_w)
941//  AM_RANGE(0x094000, 0x097fff) AM_RAM_WRITE(urashima_sc1_vram_w) AM_BASE(&sc1_vram)/*unused*/
942//  AM_RANGE(0x098000, 0x09bfff) AM_RAM_WRITE(urashima_sc2_vram_w) AM_BASE(&sc2_vram)/*unused*/
660943   /*$9c000-$9cfff Video Registers*/
661/**/AM_RANGE(0x09c080, 0x09c09f) AM_READ(SMH_RAM) AM_WRITE(urashima_sc0vregs_w)
944/**/AM_RANGE(0x09c000, 0x09dfff) AM_WRITE(urashima_vregs_w)
662945/**///AM_RANGE(0x09c480, 0x09c49f) AM_READ(SMH_RAM) AM_WRITE(urashima_sc2vregs_w)
663/**/AM_RANGE(0x09c880, 0x09c89f) AM_READ(SMH_RAM) AM_WRITE(urashima_sc3vregs_w)
664   AM_RANGE(0x09e000, 0x0a1fff) AM_RAM_WRITE(sc3_vram_w) AM_BASE(&sc3_vram)
665   AM_RANGE(0x0f0000, 0x0f0fff) AM_RAM AM_BASE(&jm_regs)/*shared with MCU*/
666   AM_RANGE(0x0f1000, 0x0fffff) AM_RAM AM_BASE(&jm_ram)
946   AM_RANGE(0x09e000, 0x0a1fff) AM_RAM_WRITE(urashima_sc3_vram_w) AM_BASE(&sc3_vram)
947   AM_RANGE(0x0f0000, 0x0f0fff) AM_RAM AM_BASE(&jm_shared_ram)/*shared with MCU*/
948   AM_RANGE(0x0f1000, 0x0fffff) AM_RAM /*Work Ram*/
667949   AM_RANGE(0x100000, 0x10ffff) AM_RAM AM_BASE(&jm_mcu_code)/*extra RAM for MCU code prg (NOT ON REAL HW!!!)*/
668950ADDRESS_MAP_END
669951
r3514r3515
9281210/*different color offsets*/
9291211static GFXDECODE_START( urashima )
9301212   GFXDECODE_ENTRY( "gfx1", 0, charlayout, 0x000, 16 )
931   GFXDECODE_ENTRY( "gfx2", 0, tilelayout, 0x300, 16 )
932   GFXDECODE_ENTRY( "gfx3", 0, tilelayout, 0x200, 16 )
1213   GFXDECODE_ENTRY( "gfx2", 0, tilelayout, 0x100, 16 )
1214   GFXDECODE_ENTRY( "gfx3", 0, tilelayout, 0x100, 16 )
9331215   GFXDECODE_ENTRY( "gfx4", 0, tilelayout, 0x100, 16 )
9341216GFXDECODE_END
9351217
r3514r3515
9591241
9601242   MDRV_VIDEO_START(jalmah)
9611243   MDRV_VIDEO_UPDATE(jalmah)
962   MDRV_VIDEO_EOF(jalmah)
9631244
1245   MDRV_TIMER_ADD_PERIODIC("mcusim", jalmah_mcu_sim, HZ(10000)) // not real, but for simulating the MCU
1246
9641247   MDRV_SPEAKER_STANDARD_MONO("mono")
965
9661248   MDRV_SOUND_ADD("oki", OKIM6295, 4000000)
9671249   MDRV_SOUND_CONFIG(okim6295_interface_pin7low)
9681250   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
r3514r3515
9941276   ROM_LOAD16_BYTE( "um-1.15c",  0x00001, 0x20000, CRC(5f5c8f39) SHA1(cef663965c3112f87788d6a871e609c0b10ef9a2) )
9951277   ROM_RELOAD(                   0x40001, 0x20000 )
9961278
1279   ROM_REGION( 0x1000, "mcu", 0 ) /* M50747 MCU Code */
1280   ROM_LOAD( "mcu", 0x0000, 0x1000, NO_DUMP )
1281
9971282   ROM_REGION( 0x140000, "oki", ROMREGION_ERASEFF ) /* Samples */
998   ROM_LOAD( "um-3.22c",      0x00000, 0x80000, CRC(9fd8c8fa) SHA1(0346f74c03a4daa7a84b64c9edf0e54297c82fd9) )
999   ROM_RELOAD(                0x40000, 0x80000 )
1283   ROM_LOAD( "um-3.22c",      0x40000, 0x80000, CRC(9fd8c8fa) SHA1(0346f74c03a4daa7a84b64c9edf0e54297c82fd9) )
1284   ROM_COPY( "oki" ,         0x40000, 0x00000, 0x40000 )
10001285
10011286   ROM_REGION( 0x20000, "gfx1", ROMREGION_DISPOSE )
10021287   ROM_LOAD( "um-5.22j",      0x000000, 0x020000, CRC(991776a2) SHA1(56740553d7d26aaeb9bec8557727030950bb01f7) )   /* 8x8 tiles */
r3514r3515
10391324   ROM_LOAD16_BYTE( "mj2.bin", 0x00000, 0x20000, CRC(c54d2f9b) SHA1(d59fc5a9e5bbb96b3b6a43378f4f2215c368b671) )
10401325   ROM_RELOAD(                 0x40000, 0x20000 )
10411326
1327   ROM_REGION( 0x1000, "mcu", 0 ) /* M50747 MCU Code */
1328   ROM_LOAD( "mcu", 0x0000, 0x1000, NO_DUMP )
1329
10421330   ROM_REGION( 0x140000, "oki", ROMREGION_ERASEFF ) /* Samples */
1043   ROM_LOAD( "mj3.bin", 0x00000, 0x80000, CRC(65bb350c) SHA1(e77866f2d612a0973adc616717e7c89a37d6c48e) )
1044   ROM_RELOAD(          0x40000, 0x80000 )
1331   ROM_LOAD( "mj3.bin", 0x40000, 0x80000, CRC(65bb350c) SHA1(e77866f2d612a0973adc616717e7c89a37d6c48e) )
1332   ROM_COPY( "oki" ,    0x40000, 0x00000, 0x40000 )
10451333
10461334   ROM_REGION( 0x20000, "gfx1", 0 ) /* BG0 */
10471335   ROM_LOAD( "mj14.bin", 0x00000, 0x10000, CRC(c84c5577) SHA1(6437368d3be39739d62158590ecd373aa070a9b2) )
r3514r3515
10511339   ROM_LOAD( "mj10.bin", 0x00000, 0x80000, CRC(1f5509a5) SHA1(4dcdee0e159956cf73f5f85ce278479be2a9ca9f) )
10521340
10531341   ROM_REGION( 0x40000, "gfx3", 0 ) /* BG2 */
1054   ROM_LOAD( "mj11.bin",  0x00000, 0x20000, CRC(14867c51) SHA1(b282b5048a55c9ad72ceb0d23f010a0fee78704f) )
1055   ROM_COPY( "gfx4", 0x20000, 0x20000, 0x20000 )/*mj10.bin*/
1056
1057   ROM_REGION( 0x40000, "gfx2", 0 ) /* BG1 */
1058   ROM_COPY( "gfx3", 0x00000, 0x00000, 0x20000 )/*mj10.bin*/
1342//  ROM_COPY( "gfx4",     0x20000, 0x20000, 0x20000 )/*mj10.bin*/
1343   ROM_LOAD( "mj11.bin", 0x00000, 0x20000, CRC(14867c51) SHA1(b282b5048a55c9ad72ceb0d23f010a0fee78704f) )
10591344   ROM_LOAD( "mj12.bin", 0x20000, 0x20000, CRC(236f809f) SHA1(9e15dd8a810a9d4f7f75f084d6bd277ea7d0e40a) )
10601345
1346   ROM_REGION( 0x10000, "gfx2", 0 ) /* BG1 */
1347   ROM_COPY( "gfx1",      0x10000, 0x00000, 0x10000 )/*mj12.bin*/
1348
10611349   ROM_REGION( 0x220, "user1", 0 ) /* Proms */
10621350   ROM_LOAD( "mj15.bpr", 0x000, 0x100, CRC(ebac41f9) SHA1(9d1629d977849663392cbf03a3ddf76665f88608) )
10631351   ROM_LOAD( "mj16.bpr", 0x100, 0x100, CRC(8d5dc1f6) SHA1(9f723e7cd44f8c09ec30b04725644346484ec753) )
r3514r3515
10781366   ROM_LOAD16_BYTE( "zoomin-2.bin", 0x00000, 0x20000, CRC(c7eb982c) SHA1(9006ded2aa1fef38bde114110d76b20747c32658) )
10791367   ROM_RELOAD(                      0x40000, 0x20000 )
10801368
1369   ROM_REGION( 0x1000, "mcu", 0 ) /* M50747 MCU Code */
1370   ROM_LOAD( "mcu", 0x0000, 0x1000, NO_DUMP )
1371
10811372   ROM_REGION( 0x140000, "oki", ROMREGION_ERASEFF ) /* Samples */
1082   ROM_LOAD( "zoomin-3.bin", 0x00000, 0x80000, CRC(07d7b8cd) SHA1(e05ce80ffb945b04f93f8c49d0c840b0bff6310b) )
1083   ROM_RELOAD(               0x40000, 0x80000 )
1373   ROM_LOAD( "zoomin-3.bin", 0x40000, 0x80000, CRC(07d7b8cd) SHA1(e05ce80ffb945b04f93f8c49d0c840b0bff6310b) )
1374   ROM_COPY( "oki" ,          0x40000, 0x00000, 0x40000 )
10841375
10851376   ROM_REGION( 0x20000, "gfx1", 0 ) /* BG0 */
10861377   ROM_LOAD( "zoomin14.bin", 0x00000, 0x20000, CRC(4e32aa45) SHA1(450a3449ca8b4f0dfe8b62cceaee9366eaf3dc3d) )
r3514r3515
11151406   ROM_LOAD16_BYTE( "mj-re-2.bin", 0x00000, 0x20000, CRC(37eff266) SHA1(1d9e88c0270daadfafff1f73eb617e77b1d199d6) )
11161407   ROM_RELOAD(                     0x40000, 0x20000 )
11171408
1409   ROM_REGION( 0x1000, "mcu", 0 ) /* M50747 MCU Code */
1410   ROM_LOAD( "mcu", 0x0000, 0x1000, NO_DUMP )
1411
11181412   ROM_REGION( 0x140000, "oki", ROMREGION_ERASEFF ) /* Samples */
11191413   ROM_LOAD( "rom3.bin", 0x00000, 0x40000, CRC(c9b7a526) SHA1(edec57e66d4ff601c8fdef7b1405af84a3f3d883) )
11201414   ROM_RELOAD(           0x40000, 0x40000 )
r3514r3515
11491443   ROM_LOAD16_BYTE( "mj-8956.1", 0x00001, 0x40000, CRC(db4ce32f) SHA1(1ae13627b9922143f462b1c3bbed87374f6e1667) )
11501444   ROM_LOAD16_BYTE( "mj-8956.2", 0x00000, 0x40000, CRC(0f942507) SHA1(7ec2fbeb9a34dfc80c4df3de8397388db13f5c7c) )
11511445
1446   ROM_REGION( 0x1000, "mcu", 0 ) /* M50747 MCU Code */
1447   ROM_LOAD( "mcu", 0x0000, 0x1000, NO_DUMP )
1448
11521449   ROM_REGION( 0x140000, "oki", ROMREGION_ERASEFF ) /* Samples */
1153   ROM_LOAD( "92000-01.3", 0x00000, 0x80000, CRC(4b0ed440) SHA1(11961d217a41f92b60d5083a5e346c245f7db620) )
1154   ROM_RELOAD(            0x40000, 0x80000 )
1450   ROM_LOAD( "92000-01.3", 0x040000, 0x80000, CRC(4b0ed440) SHA1(11961d217a41f92b60d5083a5e346c245f7db620) )
1451   ROM_COPY( "oki" ,        0x040000, 0x00000, 0x40000 )
11551452
11561453   ROM_REGION( 0x20000, "gfx1", 0 ) /* BG0 */
11571454   ROM_LOAD( "mj-8956.14", 0x00000, 0x20000, CRC(2b2fe999) SHA1(d9d601e2c008791f5bff6e7b1340f754dd094201) )
r3514r3515
11611458
11621459   ROM_REGION( 0x40000, "gfx3", 0 ) /* BG2 */
11631460   ROM_LOAD( "mj-8956.12", 0x00000, 0x20000, BAD_DUMP CRC(43f7853d) SHA1(54fb523b27e79aa295900c478f09cc080fea0adf) )
1164   /*0x20000-0x40000 used maybe above rom is bad? */
1461   /*0x20000-0x40000 used,above rom is likely to be bad (half length) */
1462   ROM_COPY( "gfx3",         0x00000, 0x20000, 0x08000 )/*mj-8956.12*/
1463   ROM_COPY( "gfx3",         0x08000, 0x28000, 0x08000 )/*mj-8956.12*/
1464   ROM_COPY( "gfx3",         0x10000, 0x30000, 0x08000 )/*mj-8956.12*/
1465   ROM_COPY( "gfx3",         0x18000, 0x38000, 0x08000 )/*mj-8956.12*/
11651466
11661467   ROM_REGION( 0x80000, "gfx4", 0 ) /* BG3 */
11671468   ROM_LOAD( "92000-02.10", 0x00000, 0x80000, CRC(338fa9b2) SHA1(05ba4b3c44249cf92be238bf53d6345dc49b0881) )
r3514r3515
12201521   ROM_LOAD16_BYTE( "1.bin", 0x00001, 0x40000, CRC(e37cc745) SHA1(73b3314d27a0332068e0d2bbc08d7401e371da1b) )
12211522   ROM_LOAD16_BYTE( "2.bin", 0x00000, 0x40000, CRC(42ecf88a) SHA1(7bb85470bc9f94c867646afeb91c4730599ea299) )
12221523
1524   ROM_REGION( 0x1000, "mcu", 0 ) /* M50747 MCU Code */
1525   ROM_LOAD( "mcu", 0x0000, 0x1000, NO_DUMP )
1526
12231527   ROM_REGION( 0x140000, "oki", ROMREGION_ERASEFF ) /* Samples */
1224   ROM_LOAD( "3.bin", 0x00000, 0x80000, CRC(691b5387) SHA1(b8bc9f904eab7653566042b18d89276d537ba586) )
1225   ROM_RELOAD(        0x40000, 0x80000 )
1528   ROM_LOAD( "3.bin", 0x40000, 0x80000, CRC(691b5387) SHA1(b8bc9f904eab7653566042b18d89276d537ba586) )
12261529   ROM_LOAD( "4.bin", 0xc0000, 0x80000, CRC(3fe932a1) SHA1(9e768b901738ee9eba207a67c4fd19efb0035a68) )
1530   ROM_COPY( "oki" ,  0x40000, 0x00000, 0x40000 )
12271531
12281532   ROM_REGION( 0x20000, "gfx1", 0 ) /* BG0 */
12291533   ROM_LOAD( "14.bin", 0x00000, 0x20000, CRC(e465a540) SHA1(10e19599ab90b0c0b6ef6ee41f16620bd1ba6800) )
r3514r3515
12501554
12511555/******************************************************************************************
12521556
1253MCU simulations
1557MCU code snippets
12541558
12551559******************************************************************************************/
12561560
r3514r3515
12711575   res = resp[respcount++];
12721576   if (respcount >= sizeof(resp)/sizeof(resp[0])) respcount = 0;
12731577
1274logerror("%04x: mcu_r %02x\n",activecpu_get_pc(),res);
1578//  logerror("%04x: mcu_r %02x\n",activecpu_get_pc(),res);
12751579
12761580   return res;
12771581}
r3514r3515
12831587{
12841588   if(ACCESSING_BITS_0_7 && data)
12851589   {
1286      //jm_regs[0x30e/2] = ?
1287
1288      //popmessage("%04x %02x",jm_regs[0x030e/2],data);
1289
12901590      /*******************************************************
12911591        1st M68k code uploaded by the MCU (sound prg)
12921592        *******************************************************/
1293      jm_regs[0x0320/2] = 0x4ef9;
1294      jm_regs[0x0322/2] = 0x0010;
1295      jm_regs[0x0324/2] = 0x2000;//jmp $102000
1593      jm_shared_ram[0x0320/2] = 0x4ef9;
1594      jm_shared_ram[0x0322/2] = 0x0010;
1595      jm_shared_ram[0x0324/2] = 0x2000;//jmp $102000
12961596
12971597      jm_mcu_code[0x2000/2] = 0x0040;
12981598      jm_mcu_code[0x2002/2] = 0x0080;//ori $80,D0
r3514r3515
13181618        *******************************************************/
13191619      /*similar to mjzoomin but with offset summed with 0x300?*/
13201620      /*tx scrollx = $200*/
1321      jm_regs[0x03c6/2] = 0x6008;//bra $+10
1322      jm_regs[0x03d0/2] = 0x4ef9;
1323      jm_regs[0x03d2/2] = 0x0010;
1324      jm_regs[0x03d4/2] = 0x0000;//jmp $100000
1621      jm_shared_ram[0x03c6/2] = 0x6008;//bra $+10
1622      jm_shared_ram[0x03d0/2] = 0x4ef9;
1623      jm_shared_ram[0x03d2/2] = 0x0010;
1624      jm_shared_ram[0x03d4/2] = 0x0000;//jmp $100000
13251625      jm_mcu_code[0x0000/2] = 0x4E71;//0x33fc;//CAREFUL!!!
13261626      jm_mcu_code[0x0002/2] = 0x4E71;//0x0400;
13271627      jm_mcu_code[0x0004/2] = 0x4E71;//0x0008;
r3514r3515
13431643      /*******************************************************
13441644        2nd M68k code uploaded by the MCU (tile upload)
13451645        *******************************************************/
1346      jm_regs[0x03ca/2] = 0x4ef9;
1347      jm_regs[0x03cc/2] = 0x0010;
1348      jm_regs[0x03ce/2] = 0x0800;//jmp $100800
1646      jm_shared_ram[0x03ca/2] = 0x4ef9;
1647      jm_shared_ram[0x03cc/2] = 0x0010;
1648      jm_shared_ram[0x03ce/2] = 0x0800;//jmp $100800
13491649      jm_mcu_code[0x0800/2] = 0x32da;
13501650      jm_mcu_code[0x0802/2] = 0x51c8;
13511651      jm_mcu_code[0x0804/2] = 0xfffc;
r3514r3515
13531653      /*******************************************************
13541654        3rd M68k code uploaded by the MCU (palette upload)
13551655        *******************************************************/
1356      jm_regs[0x03c0/2] = 0x4ef9;
1357      jm_regs[0x03c2/2] = 0x0010;
1358      jm_regs[0x03c4/2] = 0x1000;//jmp $101000
1656      jm_shared_ram[0x03c0/2] = 0x4ef9;
1657      jm_shared_ram[0x03c2/2] = 0x0010;
1658      jm_shared_ram[0x03c4/2] = 0x1000;//jmp $101000
13591659
13601660
13611661      jm_mcu_code[0x1000/2] = 0x4e71;//0x92fc;
r3514r3515
14911791   res = resp[respcount++];
14921792   if (respcount >= sizeof(resp)/sizeof(resp[0])) respcount = 0;
14931793
1494   logerror("%04x: mcu_r %02x\n",activecpu_get_pc(),res);
1794//  logerror("%04x: mcu_r %02x\n",activecpu_get_pc(),res);
14951795
14961796   return res;
14971797}
r3514r3515
15071807   static UINT16 i;
15081808   if(ACCESSING_BITS_0_7 && data)
15091809   {
1510      /*MCU program upload complete/upload kind*/
1511      //jm_regs[0x000e/2] = 0x0005;
1512
15131810      /*******************************************************
15141811        1st M68k code uploaded by the MCU.
15151812        random number generator (guess)
15161813        *******************************************************/
1517      jm_regs[0x0140/2] = 0x4ef9;
1518      jm_regs[0x0142/2] = 0x0010;
1519      jm_regs[0x0144/2] = 0x0800;
1814      jm_shared_ram[0x0140/2] = 0x4ef9;
1815      jm_shared_ram[0x0142/2] = 0x0010;
1816      jm_shared_ram[0x0144/2] = 0x0800;
15201817
15211818      /*
15221819        33c5 0010 07fe move.w  D5, $1007fe.l
15231820        3A39 000F 000C move.w  $f000c, D5
1524        da86             add.w   D6,D5
1525        0245 003f        and.w   $3f,D5
1821        da86           add.w   D6,D5
1822        0245 003f      and.w   $3f,D5
15261823        33C5 000F 000C move.w  D5, $f000c.l
15271824        3a39 0010 07fe move.w  $1007fe, D5
1528        4e75             rts
1825        4e75           rts
15291826        */
15301827      for(i=0;i<0x11;i++)
15311828         jm_mcu_code[(0x0800/2)+i] = dai_mcu_code[i];
r3514r3515
15331830      /*******************************************************
15341831        2nd M68k code uploaded by the MCU.
15351832        *******************************************************/
1536      jm_regs[0x0020/2] = 0x4ef9;
1537      jm_regs[0x0022/2] = 0x0010;
1538      jm_regs[0x0024/2] = 0x2000;//jmp $102000
1833      jm_shared_ram[0x0020/2] = 0x4ef9;
1834      jm_shared_ram[0x0022/2] = 0x0010;
1835      jm_shared_ram[0x0024/2] = 0x2000;//jmp $102000
15391836      jm_mcu_code[0x2000/2] = 0x0040;
15401837      jm_mcu_code[0x2002/2] = 0x0080;//ori $80,D0
15411838      jm_mcu_code[0x2004/2] = 0x33c0;
r3514r3515
15591856        3rd M68k code uploaded by the MCU.
15601857        see mjzoomin_mcu_w
15611858        *******************************************************/
1562      jm_regs[0x00c6/2] = 0x6000;
1563      jm_regs[0x00c8/2] = 0x0008;//bra +$8,needed because we have only two bytes here
1859      jm_shared_ram[0x00c6/2] = 0x6000;
1860      jm_shared_ram[0x00c8/2] = 0x0008;//bra +$8,needed because we have only two bytes here
15641861                               //and we need three...
1565      jm_regs[0x00d0/2] = 0x4ef9;
1566      jm_regs[0x00d2/2] = 0x0010;
1567      jm_regs[0x00d4/2] = 0x0000;//jmp $100000
1568      //jm_regs[0x00cc/2] = 0x4e75;//rts //needed? we can use jmp instead of jsr...
1862      jm_shared_ram[0x00d0/2] = 0x4ef9;
1863      jm_shared_ram[0x00d2/2] = 0x0010;
1864      jm_shared_ram[0x00d4/2] = 0x0000;//jmp $100000
1865      //jm_shared_ram[0x00cc/2] = 0x4e75;//rts //needed? we can use jmp instead of jsr...
15691866      jm_mcu_code[0x0000/2] = 0x2050;//movea.l (A0),A0
15701867      jm_mcu_code[0x0002/2] = 0x32d8;//move.w (A0)+,(A1)+
15711868      jm_mcu_code[0x0004/2] = 0x51c9;
r3514r3515
15761873        They seem video code cleaning functions
15771874        *******************************************************/
15781875      //108800
1579      jm_regs[0x0100/2] = 0x4ef9;
1580      jm_regs[0x0102/2] = 0x0010;
1581      jm_regs[0x0104/2] = 0x8800;
1876      jm_shared_ram[0x0100/2] = 0x4ef9;
1877      jm_shared_ram[0x0102/2] = 0x0010;
1878      jm_shared_ram[0x0104/2] = 0x8800;
15821879
15831880      jm_mcu_code[0x8800/2] = 0x4df9;
15841881      jm_mcu_code[0x8802/2] = 0x0009;
r3514r3515
15991896      jm_mcu_code[0x8820/2] = 0x4e75; //rts
16001897
16011898      //108880
1602      jm_regs[0x0108/2] = 0x4ef9;
1603      jm_regs[0x010a/2] = 0x0010;
1604      jm_regs[0x010c/2] = 0x8880;
1899      jm_shared_ram[0x0108/2] = 0x4ef9;
1900      jm_shared_ram[0x010a/2] = 0x0010;
1901      jm_shared_ram[0x010c/2] = 0x8880;
16051902
16061903      jm_mcu_code[0x8880/2] = 0x4df9;
16071904      jm_mcu_code[0x8882/2] = 0x0009;
r3514r3515
16221919      jm_mcu_code[0x88a0/2] = 0x4e75; //rts
16231920
16241921      //108900
1625      jm_regs[0x0110/2] = 0x4ef9;
1626      jm_regs[0x0112/2] = 0x0010;
1627      jm_regs[0x0114/2] = 0x8900;
1922      jm_shared_ram[0x0110/2] = 0x4ef9;
1923      jm_shared_ram[0x0112/2] = 0x0010;
1924      jm_shared_ram[0x0114/2] = 0x8900;
16281925
16291926      jm_mcu_code[0x8900/2] = 0x4df9;
16301927      jm_mcu_code[0x8902/2] = 0x0009;
r3514r3515
16451942      jm_mcu_code[0x8920/2] = 0x4e75; //rts
16461943
16471944      /*TX function?*/
1648      jm_regs[0x0126/2] = 0x4ef9;
1649      jm_regs[0x0128/2] = 0x0010;
1650      jm_regs[0x012a/2] = 0x8980;
1945      jm_shared_ram[0x0126/2] = 0x4ef9;
1946      jm_shared_ram[0x0128/2] = 0x0010;
1947      jm_shared_ram[0x012a/2] = 0x8980;
16511948
16521949      //pri $f0590
16531950      jm_mcu_code[0x8980/2] = 0x33fc;
r3514r3515
16731970      jm_mcu_code[0x89a8/2] = 0x4e75; //rts
16741971
16751972/*
1676        jm_regs[0x0100/2] = 0x4ef9;
1677        jm_regs[0x0102/2] = 0x0010;
1678        jm_regs[0x0104/2] = 0x1000;//jmp $101000
1679        //jm_regs[0x00c6/2] = 0x4e75;//rts
1973        jm_shared_ram[0x0100/2] = 0x4ef9;
1974        jm_shared_ram[0x0102/2] = 0x0010;
1975        jm_shared_ram[0x0104/2] = 0x1000;//jmp $101000
1976        //jm_shared_ram[0x00c6/2] = 0x4e75;//rts
16801977        jm_mcu_code[0x1000/2] = 0x33c2;
16811978        jm_mcu_code[0x1002/2] = 0x0010;
16821979        jm_mcu_code[0x1004/2] = 0x17fe; //move.w D2,$1017fe
r3514r3515
16991996      /*******************************************************
17001997        5th M68k code uploaded by the MCU (palette upload)
17011998        *******************************************************/
1702      jm_regs[0x00c0/2] = 0x4ef9;
1703      jm_regs[0x00c2/2] = 0x0010;
1704      jm_regs[0x00c4/2] = 0x1000;//jmp $101000
1705      //jm_regs[0x00c6/2] = 0x4e75;//rts
1999      jm_shared_ram[0x00c0/2] = 0x4ef9;
2000      jm_shared_ram[0x00c2/2] = 0x0010;
2001      jm_shared_ram[0x00c4/2] = 0x1000;//jmp $101000
2002      //jm_shared_ram[0x00c6/2] = 0x4e75;//rts
17062003      jm_mcu_code[0x1000/2] = 0x33c2;
17072004      jm_mcu_code[0x1002/2] = 0x0010;
17082005      jm_mcu_code[0x1004/2] = 0x17fe; //move.w D2,$1017fe
r3514r3515
17352032      /*******************************************************
17362033        6th M68k code uploaded by the MCU (tile upload)
17372034        *******************************************************/
1738      jm_regs[0x00ca/2] = 0x4ef9;
1739      jm_regs[0x00cc/2] = 0x0010;
1740      jm_regs[0x00ce/2] = 0x1800;//jmp $101800
1741      //jm_regs[0x00c6/2] = 0x4e75;//rts
2035      jm_shared_ram[0x00ca/2] = 0x4ef9;
2036      jm_shared_ram[0x00cc/2] = 0x0010;
2037      jm_shared_ram[0x00ce/2] = 0x1800;//jmp $101800
2038      //jm_shared_ram[0x00c6/2] = 0x4e75;//rts
17422039
17432040      jm_mcu_code[0x1800/2] = 0x22da;//move.l (A2)+,(A1)+
17442041      jm_mcu_code[0x1802/2] = 0xb5fc;
r3514r3515
17702067   res = resp[respcount++];
17712068   if (respcount >= sizeof(resp)/sizeof(resp[0])) respcount = 0;
17722069
1773   logerror("%04x: mcu_r %02x\n",activecpu_get_pc(),res);
2070//  logerror("%04x: mcu_r %02x\n",activecpu_get_pc(),res);
17742071
17752072   return res;
17762073}
17772074
1778/*4eb9*/
17792075/*
17802076data value is REQ under mjzoomin video test menu.It is related to the MCU?
17812077*/
r3514r3515
17832079{
17842080   if(ACCESSING_BITS_0_7 && data)
17852081   {
1786      /*******************************************************
2082      /******************************************************
17872083        1st M68k code uploaded by the MCU(Service Mode PC=2a56).
1788        Program passes some parameters before entering into the sub-routine (jsr)
2084        Program passes some parameters before entering into
2085        the sub-routine (jsr)
17892086        D1 = 0xf
17902087        A0 = 1026e
17912088        A1 = 88600
1792        (A0) is the vector number for take the real palette address.
1793        *******************************************************/
1794      jm_regs[0x00c6/2] = 0x4ef9;
1795      jm_regs[0x00c8/2] = 0x0010;
1796      jm_regs[0x00ca/2] = 0x0000;//jsr $100000
1797      //jm_regs[0x00cc/2] = 0x4e75;//rts //needed? we can use jmp instead of jsr...
2089        (A0) is the vector number for take the real palette
2090        address.
2091        ******************************************************/
2092      jm_shared_ram[0x00c6/2] = 0x4ef9;
2093      jm_shared_ram[0x00c8/2] = 0x0010;
2094      jm_shared_ram[0x00ca/2] = 0x0000;//jsr $100000
2095      //jm_shared_ram[0x00cc/2] = 0x4e75;//rts //needed? we can use jmp instead of jsr...
17982096      jm_mcu_code[0x0000/2] = 0x2050;//movea.l (A0),A0
17992097      jm_mcu_code[0x0002/2] = 0x32d8;//move.w (A0)+,(A1)+
18002098      jm_mcu_code[0x0004/2] = 0x51c9;
r3514r3515
18042102        2nd M68k code uploaded by the MCU (Sound read/write)
18052103        (Note:copied from suchipi,check here the sound banking)
18062104        *******************************************************/
1807      jm_regs[0x0020/2] = 0x4ef9;
1808      jm_regs[0x0022/2] = 0x0010;
1809      jm_regs[0x0024/2] = 0x1800;//jmp $101800
1810      jm_mcu_code[0x1800/2] = 0x0040;
1811      jm_mcu_code[0x1802/2] = 0x0080;//ori $80,D0
1812      jm_mcu_code[0x1804/2] = 0x33c0;
1813      jm_mcu_code[0x1806/2] = 0x0008;
1814      jm_mcu_code[0x1808/2] = 0x0040;
1815      jm_mcu_code[0x180a/2] = 0x4e71;//= 0x6100;
1816      jm_mcu_code[0x180c/2] = 0x4e71;//= 0x000c;
1817      jm_mcu_code[0x180e/2] = 0x33fc;
1818      jm_mcu_code[0x1810/2] = 0x0010;
1819      jm_mcu_code[0x1812/2] = 0x0008;
2105      jm_shared_ram[0x0020/2] = 0x4ef9;
2106      jm_shared_ram[0x0022/2] = 0x0010;
2107      jm_shared_ram[0x0024/2] = 0x1800;//jmp $101800
2108
2109      /*Wrong,it reads from the rom...*/
2110      //0x33c2 0011 80fe move.w D2,$1180fe
2111      //0x0642 addi.w $1,D2
2112      //0x0001
2113      //0x0242 andi.w $3,D2 ;might be not needed
2114      //0x0003
2115
2116      //0x33c2 move.w D2,$80018 ;sound bank
2117      //0x0008
2118      //0x0018
2119      //0x3439 0011 80fe move.w $1180fe,D2
2120      jm_mcu_code[0x1800/2] = 0x33c2;
2121      jm_mcu_code[0x1802/2] = 0x0011;
2122      jm_mcu_code[0x1804/2] = 0x80fe;
2123      jm_mcu_code[0x1806/2] = 0x0642;
2124      jm_mcu_code[0x1808/2] = 0x0001;
2125      jm_mcu_code[0x180a/2] = 0x0242;
2126      jm_mcu_code[0x180c/2] = 0x0003;
2127      jm_mcu_code[0x180e/2] = 0x33c2;
2128      jm_mcu_code[0x1810/2] = 0x0008;
2129      jm_mcu_code[0x1812/2] = 0x0018;
18202130      jm_mcu_code[0x1814/2] = 0x0040;
1821      jm_mcu_code[0x1816/2] = 0x4e75;
1822      jm_mcu_code[0x1818/2] = 0x3239;
2131      jm_mcu_code[0x1816/2] = 0x0080;//ori $80,D0
2132      jm_mcu_code[0x1818/2] = 0x33c0;//move.w D0,$80040
18232133      jm_mcu_code[0x181a/2] = 0x0008;
18242134      jm_mcu_code[0x181c/2] = 0x0040;
1825      jm_mcu_code[0x181e/2] = 0x0241;
1826      jm_mcu_code[0x1820/2] = 0x0001;
1827      jm_mcu_code[0x1822/2] = 0x66f4;
1828      jm_mcu_code[0x1824/2] = 0x4e75;
2135      jm_mcu_code[0x181e/2] = 0x33fc;//move.w $10,$80040
2136      jm_mcu_code[0x1820/2] = 0x0010;
2137      jm_mcu_code[0x1822/2] = 0x0008;
2138      jm_mcu_code[0x1824/2] = 0x0040;
2139      jm_mcu_code[0x1826/2] = 0x3439;
2140      jm_mcu_code[0x1828/2] = 0x0011;
2141      jm_mcu_code[0x182a/2] = 0x80fe;
2142      jm_mcu_code[0x182c/2] = 0x4e75;
2143      //jm_mcu_code[0x1818/2] = 0x3239;
2144      //jm_mcu_code[0x181a/2] = 0x0008;
2145      //jm_mcu_code[0x181c/2] = 0x0040;
2146      //jm_mcu_code[0x181e/2] = 0x0241;
2147      //jm_mcu_code[0x1820/2] = 0x0001;
2148      //jm_mcu_code[0x1822/2] = 0x66f4;
2149      //jm_mcu_code[0x1824/2] = 0x4e75;
18292150      /*******************************************************
1830        3rd M68k code uploaded by the MCU(palette upload, 99,(9)%
1831        sure on this ;-)
2151        3rd M68k code uploaded by the MCU(palette upload)
18322152        *******************************************************/
1833      jm_regs[0x00c0/2] = 0x4ef9;
1834      jm_regs[0x00c2/2] = 0x0010;
1835      jm_regs[0x00c4/2] = 0x1000;//jmp $101000
1836      //jm_regs[0x00c6/2] = 0x4e75;//rts
2153      jm_shared_ram[0x00c0/2] = 0x4ef9;
2154      jm_shared_ram[0x00c2/2] = 0x0010;
2155      jm_shared_ram[0x00c4/2] = 0x1000;//jmp $101000
2156      //jm_shared_ram[0x00c6/2] = 0x4e75;//rts
18372157      jm_mcu_code[0x1000/2] = 0x33c2;
18382158      jm_mcu_code[0x1002/2] = 0x0010;
18392159      jm_mcu_code[0x1004/2] = 0x17fe; //move.w D2,$1017fe
r3514r3515
18822202   res = resp[respcount++];
18832203   if (respcount >= sizeof(resp)/sizeof(resp[0])) respcount = 0;
18842204
1885   //popmessage("%04x: mcu_r %02x",activecpu_get_pc(),res);
2205//  popmessage("%04x: mcu_r %02x",activecpu_get_pc(),res);
18862206
18872207   return res;
18882208}
r3514r3515
19032223   res = resp[respcount++];
19042224   if (respcount >= sizeof(resp)/sizeof(resp[0])) respcount = 0;
19052225
1906   //popmessage("%04x: mcu_r %02x",activecpu_get_pc(),res);
2226//  popmessage("%04x: mcu_r %02x",activecpu_get_pc(),res);
19072227
19082228   return res;
19092229}
r3514r3515
19532273}
19542274
19552275/*First version of the MCU*/
1956GAME( 1989, urashima, 0, urashima, jalmah,  urashima, ROT0, "UPL",         "Otogizoushi Urashima Mahjong",         GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
1957GAME( 1989, daireika, 0, jalmah,   jalmah,  daireika, ROT0, "Jaleco / NMK", "Mahjong Daireikai",               GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
1958GAME( 1990, mjzoomin, 0, jalmah,   jalmah,  mjzoomin, ROT0, "Jaleco",       "Mahjong Channel Zoom In",            GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
2276GAME( 1989, urashima, 0, urashima,   jalmah,     urashima, ROT0, "UPL",            "Otogizoushi Urashima Mahjong",         GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
2277GAME( 1989, daireika, 0, jalmah,   jalmah,     daireika, ROT0, "Jaleco / NMK", "Mahjong Daireikai",               GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
2278GAME( 1990, mjzoomin, 0, jalmah,   jalmah,     mjzoomin, ROT0, "Jaleco",       "Mahjong Channel Zoom In",            GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
19592279/*Second version of the MCU*/
1960GAME( 1990, kakumei,  0, jalmah, jalmah2, kakumei,  ROT0, "Jaleco",       "Mahjong Kakumei",                      GAME_IMPERFECT_GRAPHICS )
1961GAME( 1992, kakumei2, 0, jalmah, jalmah2a,kakumei2, ROT0, "Jaleco",       "Mahjong Kakumei 2 - Princess League",  GAME_IMPERFECT_GRAPHICS )
1962GAME( 1993, suchipi,  0, jalmah, jalmah2a,suchipi,  ROT0, "Jaleco",       "Idol Janshi Su-Chi-Pie Special",       GAME_IMPERFECT_GRAPHICS )
2280GAME( 1990, kakumei,  0, jalmah,   jalmah2,    kakumei,  ROT0, "Jaleco",       "Mahjong Kakumei",                  GAME_IMPERFECT_GRAPHICS )
2281GAME( 1992, kakumei2, 0, jalmah,   jalmah2a,   kakumei2, ROT0, "Jaleco",       "Mahjong Kakumei 2 - Princess League",   GAME_IMPERFECT_GRAPHICS )
2282GAME( 1993, suchipi,  0, jalmah,   jalmah2a,   suchipi,  ROT0, "Jaleco",       "Idol Janshi Su-Chi-Pie Special",      GAME_IMPERFECT_GRAPHICS )
src/mame/drivers/merit.c
r3514r3515
232232}
233233
234234
235MC6845_ON_HSYNC_CHANGED(hsync_changed)
235static MC6845_ON_HSYNC_CHANGED(hsync_changed)
236236{
237237   /* update any video up to the current scanline */
238238   video_screen_update_now(device->machine->primary_screen);
239239}
240240
241MC6845_ON_VSYNC_CHANGED(vsync_changed)
241static MC6845_ON_VSYNC_CHANGED(vsync_changed)
242242{
243243   cpunum_set_input_line(device->machine, 0, 0, vsync ? ASSERT_LINE : CLEAR_LINE);
244244}
src/mame/drivers/m72.c
r3514r3515
8989#include "iremipt.h"
9090#include "m72.h"
9191#include "cpu/nec/nec.h"
92#include "cpu/i8051/i8051.h"
92#include "cpu/mcs51/mcs51.h"
9393
94
9594#define MASTER_CLOCK      XTAL_32MHz
9695#define SOUND_CLOCK         XTAL_3_579545MHz
9796
r3514r3515
115114static TIMER_CALLBACK( synch_callback )
116115{
117116   //cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(8000000));
118   cpu_boost_interleave(ATTOTIME_IN_HZ(MASTER_CLOCK/4/12), ATTOTIME_IN_SEC(8));
117   cpu_boost_interleave(ATTOTIME_IN_HZ(MASTER_CLOCK/4/12), ATTOTIME_IN_SEC(25));
119118}
120119
121120static MACHINE_RESET( m72 )
r3514r3515
195194   ram[offset] = val;
196195}
197196
198static TIMER_CALLBACK( mcu_irq0_clear )
199{
200   cputag_set_input_line(machine, "mcu", 0, CLEAR_LINE);
201}
202197
203
204198static WRITE16_HANDLER( m72_main_mcu_sound_w )
205199{
206200   if (data & 0xfff0)
r3514r3515
228222      protection_ram[offset] = val;
229223      cputag_set_input_line(machine, "mcu", 0, ASSERT_LINE);
230224      /* Line driven, most likely by write line */
231      timer_set(ATTOTIME_IN_CYCLES(2, mame_find_cpu_index(machine, "mcu")), NULL, 0, mcu_irq0_clear);
225      //timer_set(ATTOTIME_IN_CYCLES(2, mame_find_cpu_index(machine, "mcu")), NULL, 0, mcu_irq0_clear);
226      //timer_set(ATTOTIME_IN_CYCLES(0, mame_find_cpu_index(machine, "mcu")), NULL, 0, mcu_irq0_raise);
232227   }
233228   else
234229      timer_call_after_resynch( protection_ram, (offset<<16) | val, delayed_ram16_w);
r3514r3515
247242{
248243   UINT8 ret;
249244
245   if (offset == 0x0fff || offset == 0x0ffe)
246   {
247      cputag_set_input_line(machine, "mcu", 0, CLEAR_LINE);
248   }
249
250250   if (offset&1) ret = (protection_ram[offset/2] & 0xff00)>>8;
251251   else ret = (protection_ram[offset/2] & 0x00ff);
252252
r3514r3515
256256static INTERRUPT_GEN( m72_mcu_int )
257257{
258258   //mcu_snd_cmd_latch |= 0x11; /* 0x10 is special as well - FIXME */
259   mcu_snd_cmd_latch = 0x10 | (mame_rand(machine) & 1); /* 0x10 is special as well - FIXME */
259   mcu_snd_cmd_latch = 0x11;// | (mame_rand(machine) & 1); /* 0x10 is special as well - FIXME */
260260   cputag_set_input_line(machine, "mcu", 1, ASSERT_LINE);
261261}
262262
r3514r3515
335335   /* sound cpu */
336336   memory_install_write8_handler(machine, sndnum, ADDRESS_SPACE_IO, 0x82, 0x82, 0xff, 0, m72_snd_cpu_sample_w);
337337   memory_install_read8_handler (machine, sndnum, ADDRESS_SPACE_IO, 0x84, 0x84, 0xff, 0, m72_snd_cpu_sample_r);
338
339#if 0
340   /* running the mcu at twice the speed, the following
341     * timeouts have to be modified.
342     * At normal speed, the timing heavily depends on opcode
343     * prefetching on the V30.
344     */
345   {
346      UINT8 *rom=memory_region(machine, "mcu");
347
348      rom[0x12d+5] += 1; printf(" 5: %d\n", rom[0x12d+5]);
349      rom[0x12d+8] += 5;  printf(" 8: %d\n", rom[0x12d+8]);
350      rom[0x12d+11] += 7; printf("11: %d\n", rom[0x12d+11]);
351      rom[0x12d+14] += 9; printf("14: %d\n", rom[0x12d+14]);
352      rom[0x12d+17] += 1; printf("17: %d\n", rom[0x12d+17]);
353      rom[0x12d+20] += 10; printf("20: %d\n", rom[0x12d+20]);
354      rom[0x12d+23] += 3; printf("23: %d\n", rom[0x12d+23]);
355      rom[0x12d+26] += 2; printf("26: %d\n", rom[0x12d+26]);
356      rom[0x12d+29] += 2; printf("29: %d\n", rom[0x12d+29]);
357      rom[0x12d+32] += 16; printf("32: %d\n", rom[0x12d+32]);
358   }
359#endif
338360}
339361
340362
r3514r3515
10351057   AM_RANGE(0x42, 0x42) AM_WRITE(m72_sound_irq_ack_w)
10361058ADDRESS_MAP_END
10371059
1038#if 0
1039/* TODO: internal - should be removed */
1040static ADDRESS_MAP_START( mcu_map, ADDRESS_SPACE_PROGRAM, 8 )
1041   //ADDRESS_MAP_UNMAP_HIGH
1042   AM_RANGE(0x0000, 0x0fff) AM_ROM
1043ADDRESS_MAP_END
1044#endif
1045
1046#if 0
1047static ADDRESS_MAP_START( mcu_data_map, ADDRESS_SPACE_DATA, 8 )
1048   //ADDRESS_MAP_UNMAP_HIGH
1049   AM_RANGE(0x0000, 0x0000) AM_READWRITE(m72_mcu_sample_r, m72_mcu_low_w)
1050   AM_RANGE(0x0001, 0x0001) AM_WRITE(m72_mcu_high_w)
1051   AM_RANGE(0x0002, 0x0002) AM_READWRITE(m72_mcu_snd_r, m72_mcu_ack_w)
1052   /* shared at b0000 - b0fff on the main cpu */
1053   AM_RANGE(0xc000, 0xcfff) AM_RAM AM_READWRITE(m72_mcu_data_r,m72_mcu_data_w )
1054ADDRESS_MAP_END
1055
10561060static ADDRESS_MAP_START( mcu_io_map, ADDRESS_SPACE_IO, 8 )
1057   //ADDRESS_MAP_UNMAP_HIGH
1058   AM_RANGE(0x0000, 0x0003) AM_READWRITE(m72_mcu_port_r, m72_mcu_port_w)
1059ADDRESS_MAP_END
1060#else
1061static ADDRESS_MAP_START( mcu_io_map, ADDRESS_SPACE_IO, 8 )
10621061   /* External access */
10631062   AM_RANGE(0x0000, 0x0000) AM_READWRITE(m72_mcu_sample_r, m72_mcu_low_w)
10641063   AM_RANGE(0x0001, 0x0001) AM_WRITE(m72_mcu_high_w)
r3514r3515
10701069   AM_RANGE(MCS51_PORT_P0, MCS51_PORT_P3) AM_READWRITE(m72_mcu_port_r, m72_mcu_port_w)
10711070ADDRESS_MAP_END
10721071
1073#endif
1074
10751072#define COIN_MODE_1 \
10761073   PORT_DIPNAME( 0x00f0, 0x00f0, DEF_STR( Coinage ) ) PORT_CONDITION("DSW", 0x0400, PORTCOND_NOTEQUALS, 0x0000) PORT_DIPLOCATION("SW1:5,6,7,8") \
10771074   PORT_DIPSETTING(      0x00a0, DEF_STR( 6C_1C ) ) \
r3514r3515
18671864
18681865   MDRV_IMPORT_FROM(m72_base)
18691866
1870   MDRV_CPU_ADD("mcu",I8751, MASTER_CLOCK/2)
1871   /* internal - MDRV_CPU_PROGRAM_MAP(mcu_map,0) */
1872   //MDRV_CPU_DATA_MAP(mcu_data_map,0)
1867   MDRV_CPU_ADD("mcu",I8751, MASTER_CLOCK/4)
18731868   MDRV_CPU_IO_MAP(mcu_io_map,0)
18741869   MDRV_CPU_VBLANK_INT("main", m72_mcu_int)
1875   //MDRV_INTERLEAVE(1000)
18761870
18771871MACHINE_DRIVER_END
18781872
src/mame/drivers/re900.c
r0r3515
1/***********************************************************************************
2
3    re900.c
4
5    Ruleta RE-900 - Entretenimientos GEMINIS & GENATRON (C) 1993
6
7    Driver by Grull Osgo.
8    Additional work by Roberto Fresca.
9
10    Games running on this hardware:
11
12    * Ruleta RE-900,    1993, Entretenimientos GEMINIS.
13    * Buena Suerte '94  1994, Entretenimientos GEMINIS.
14
15
16************************************************************************************
17
18    Hardware Info
19    =============
20
21    * Main board:
22
23    1x AMD P80C31BH                 Main CPU.
24    1x AY-3-8910                    Sound & I/O System.
25    1x TMS-9129-NL                  Video System.
26
27    1x 27C512 EPROM                 Program ROM.
28    1x MS6264L-10PC (8Kx8) SRAM     Data Memory (Battery Backed RAM).
29    2x TMS4416-15NL (64Kx4) DRAM    Video Memory.
30
31    1x 11.0592 MHz Crystal          CPU clock.
32    1x 10.738635 MHz. Crystal       Video System clock.
33    1x MAX691CPE                    Power supervisor system, Data RAM Protect and Watchdog.
34
35    1x 3.6 Ni-Cd Battery            Data Memory.
36    1x LM380N-8                     1 Channel Audio Amplifier.
37
38
39************************************************************************************
40
41    Game Info
42    =========
43
44    * RE-900 Electronic Roulette.- 6 Players - W/ Random Bonus Multiplier (up to 10x)
45
46    How to play...
47
48    This Roulette allow up to 6 players. To start the machine, turn the Operator Key
49    (the the Operator Key light will turn green). Whilest this key is turned ON, you
50    can insert credits, play, and payout. Once the key is turned OFF (red light), you
51    can play, but credits can't be entered/taken.
52
53    You can select the player number through key "L" (the respective player light will
54    lite on). Key-In for all 6 players are keys 1-2-3-4-5-6 and Key-Out are Q-W-E-R-T-Y
55    respectively. Up-Down-Left-Right to place cursor, and left CTRL to place a bet.
56    After a short time without activity, the roulette start to play, simulating the ball
57    with an array of leds...
58
59    We made a full artwork that allow you to play this game with bells and whistles.
60
61
62    * Buena Suerte ?94 Video Poker Game w/ Double Up feature - 1 Player.
63
64    This game is a reprogrammed version of the Buena Suerte! poker game, to run on this
65    GEMINIS RE900 hardware.
66
67    Graphics are worse than original BS, but sounds are improved through the AY-8910.
68
69
70***********************************************************************************/
71
72
73#define MAIN_CLOCK      XTAL_11_0592MHz
74#define VDP_CLOCK      XTAL_10_730MHz
75#define TMS_CLOCK      VDP_CLOCK / 24
76
77#include "driver.h"
78#include "cpu/mcs51/mcs51.h"
79#include "video/tms9928a.h"
80#include "sound/ay8910.h"
81#include "re900.lh"
82
83static UINT8 *re900_rom;
84static UINT8 psg_pa, psg_pb = 0, mux_data = 0, ledant = 0, player = 1, stat_a= 1;
85
86
87/****************
88* Read Handlers *
89****************/
90
91static READ8_HANDLER (re_psg_portA_r)
92{
93   if ((input_port_read(machine, "IN0") & 0x01) == 0)
94   {
95      output_set_lamp_value(0,1);      // Operator Key ON
96   }
97
98   else
99   {
100      output_set_lamp_value(0,0);      // Operator Key OFF
101   }
102
103   return input_port_read(machine, "IN0");
104}
105
106static READ8_HANDLER (re_psg_portB_r)
107{
108   UINT8 retval = 0xff;
109   logerror("llamada a re_psg_portB_r\n");
110   /* This is a hack to select the active player due to Keyboard size restrictions  */
111
112   output_set_lamp_value(player,1);
113
114   if (input_port_read(machine, "IN_S"))
115   {
116      if (!stat_a)
117      {
118         output_set_lamp_value(1, 0);
119         output_set_lamp_value(2, 0);
120         output_set_lamp_value(3, 0);
121         output_set_lamp_value(4, 0);
122         output_set_lamp_value(5, 0);
123         output_set_lamp_value(6, 0);
124         player++;
125
126         if (player == 7)
127         {
128            player = 1;
129         }
130
131         output_set_lamp_value(player, 1); /* It shows active player via layout buttons   */
132         stat_a = 1;
133      }
134   }
135
136   else
137   {
138      stat_a = 0;
139   }
140   /* End of Select Player Hack */
141
142   /* "INA": Unified port to share the player Keys among all players - Key In & Key Out have their own buttons on keyboard. */
143   switch( mux_data )
144   {
145      case 0x01: retval = (input_port_read(machine, "IN6") | 0x80 ) - (( player == 6 ) ? (input_port_read(machine, "INA") | 0x80 ) ^ 0xff: 0x00 ); break; /* Player 6 */
146      case 0x02: retval = (input_port_read(machine, "IN5") | 0x80 ) - (( player == 5 ) ? (input_port_read(machine, "INA") | 0x80 ) ^ 0xff: 0x00 ); break; /* Player 5 */
147      case 0x04: retval = (input_port_read(machine, "IN4") | 0x80 ) - (( player == 4 ) ? (input_port_read(machine, "INA") | 0x80 ) ^ 0xff: 0x00 ); break; /* Player 4 */
148      case 0x08: retval = (input_port_read(machine, "IN3") | 0x80 ) - (( player == 3 ) ? (input_port_read(machine, "INA") | 0x80 ) ^ 0xff: 0x00 ); break; /* Player 3 */
149      case 0x10: retval = (input_port_read(machine, "IN2") | 0x80 ) - (( player == 2 ) ? (input_port_read(machine, "INA") | 0x80 ) ^ 0xff: 0x00 ); break; /* Player 2 */
150      case 0x20: retval = (input_port_read(machine, "IN1") | 0x80 ) - (( player == 1 ) ? (input_port_read(machine, "INA") | 0x80 ) ^ 0xff: 0x00 ); break; /* Player 1 */
151   }
152
153   return retval;
154}
155
156static READ8_HANDLER (bs94_portA_r)
157{
158   return input_port_read(machine, "IN0");
159}
160
161static READ8_HANDLER (bs94_portB_r)
162{
163   return input_port_read(machine, "IN1");
164}
165
166static READ8_HANDLER (rom_r)
167{
168   return re900_rom[offset];
169}
170
171
172/***********************
173*    Write Handlers    *
174***********************/
175
176static WRITE8_HANDLER (re_mux_port_A_w)
177{
178   psg_pa = data;
179   mux_data = ((data >> 2) & 0x3f) ^ 0x3f;
180}
181
182static WRITE8_HANDLER (re_mux_port_B_w)
183{
184   UINT8 led;
185   psg_pb = data;
186   led = (psg_pa >> 2) & 0x3f;
187
188   if (data == 0x7f)
189   {
190      output_set_lamp_value(20 + led, 1);
191
192      if (led != ledant)
193      {
194         output_set_lamp_value(20 + ledant, 0);
195         ledant = led;
196      }
197   }
198}
199
200static WRITE8_HANDLER (cpu_port_0_w)
201{
202//  output_set_lamp_value(7,1 ^ ( (data >> 4) & 1)); /* Cont. Sal */
203//  output_set_lamp_value(8,1 ^ ( (data >> 5) & 1)); /* Cont. Ent */
204}
205
206static WRITE8_HANDLER(re900_watchdog_reset_w)
207{
208   //watchdog_reset_w(machine,0,0); /* To do! */
209}
210
211
212/*******************************
213*    Memory Map Information    *
214*******************************/
215
216static ADDRESS_MAP_START( mem_prg, ADDRESS_SPACE_PROGRAM, 8 )
217   AM_RANGE(0x0000, 0xffff) AM_ROM AM_BASE(&re900_rom)
218ADDRESS_MAP_END
219
220static ADDRESS_MAP_START( mem_io, ADDRESS_SPACE_IO, 8 )
221   AM_RANGE(0x0000, 0xbfff) AM_READ (rom_r)
222   AM_RANGE(0xc000, 0xdfff) AM_RAM AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size)
223   AM_RANGE(0xe000, 0xe000) AM_WRITE(TMS9928A_vram_w)
224   AM_RANGE(0xe001, 0xe001) AM_WRITE(TMS9928A_register_w)
225   AM_RANGE(0xe800, 0xe800) AM_WRITE(ay8910_control_port_0_w)
226   AM_RANGE(0xe801, 0xe801) AM_WRITE(ay8910_write_port_0_w)
227   AM_RANGE(0xe802, 0xe802) AM_READ(ay8910_read_port_0_r)
228   AM_RANGE(0xe000, 0xefff) AM_WRITE(re900_watchdog_reset_w)
229   AM_RANGE(MCS51_PORT_P0, MCS51_PORT_P0) AM_WRITE(cpu_port_0_w)
230   AM_RANGE(MCS51_PORT_P2, MCS51_PORT_P2) AM_NOP
231   AM_RANGE(MCS51_PORT_P3, MCS51_PORT_P3) AM_NOP
232ADDRESS_MAP_END
233
234
235static INTERRUPT_GEN( re900_video_interrupt )
236{
237   TMS9928A_interrupt(machine);
238}
239
240static void vdp_interrupt (running_machine *machine, int state)
241{
242   cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, state ? ASSERT_LINE : CLEAR_LINE );
243}
244
245
246/************************
247*      Input ports      *
248************************/
249
250INPUT_PORTS_START( re900 )
251
252   PORT_START("IN0")
253   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Operator Key") PORT_TOGGLE PORT_CODE(KEYCODE_0)
254   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Auditor Key")  PORT_TOGGLE PORT_CODE(KEYCODE_9)
255
256   PORT_START("INA")
257   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Bet")
258   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Left")         PORT_CODE(KEYCODE_LEFT)
259   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Right")        PORT_CODE(KEYCODE_RIGHT)
260   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Up")           PORT_CODE(KEYCODE_UP)
261   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("Down")         PORT_CODE(KEYCODE_DOWN)
262   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNUSED )
263   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
264   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
265
266   PORT_START("IN1")
267   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
268   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED )
269   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED )
270   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
271   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED )
272   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P1 Key-In")   PORT_CODE(KEYCODE_1)
273   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P1 Key-Out")  PORT_CODE(KEYCODE_Q)
274   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
275
276   PORT_START("IN2")
277   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
278   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED )
279   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED )
280   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
281   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED )
282   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P2 Key-In")   PORT_CODE(KEYCODE_2)
283   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P2 Key-Out")  PORT_CODE(KEYCODE_W)
284   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
285
286   PORT_START("IN3")
287   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
288   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED )
289   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED )
290   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
291   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED )
292   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P3 Key-In")   PORT_CODE(KEYCODE_3)
293   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P3 Key-Out")  PORT_CODE(KEYCODE_E)
294   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
295
296   PORT_START("IN4")
297   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
298   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED )
299   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED )
300   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
301   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED )
302   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P4 Key-In")   PORT_CODE(KEYCODE_4)
303   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P4 Key-Out")  PORT_CODE(KEYCODE_R)
304   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
305
306   PORT_START("IN5")
307   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
308   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED )
309   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED )
310   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
311   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED )
312   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P5 Key-In")   PORT_CODE(KEYCODE_5)
313   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P5 Key-Out")  PORT_CODE(KEYCODE_T)
314   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
315
316   PORT_START("IN6")
317   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
318   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED )
319   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED )
320   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
321   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED )
322   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P6 Key-In")   PORT_CODE(KEYCODE_6)
323   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P6 Key-Out")  PORT_CODE(KEYCODE_Y)
324   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
325
326   PORT_START("IN_S")
327   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON8 ) PORT_NAME("Player Select")  PORT_CODE(KEYCODE_L)
328   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED )
329   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED )
330   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED )
331   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED )
332   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED )
333   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED )
334   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )
335INPUT_PORTS_END
336
337INPUT_PORTS_START( bs94 )
338   PORT_START("IN0")
339   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Bet")       PORT_CODE(KEYCODE_2)
340   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Double")    PORT_CODE(KEYCODE_3)
341   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Deal/Draw") PORT_CODE(KEYCODE_1)
342   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Hold 5")    PORT_CODE(KEYCODE_B)
343   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("Take")      PORT_CODE(KEYCODE_4)
344   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("Hold 4")    PORT_CODE(KEYCODE_V)
345   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_NAME("Cancel")    PORT_CODE(KEYCODE_N)
346   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_NAME("Hold 3")    PORT_CODE(KEYCODE_C)
347
348   PORT_START("IN1")
349   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Operator")  PORT_TOGGLE PORT_CODE(KEYCODE_0)
350   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Hold 2")    PORT_CODE(KEYCODE_X)
351   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Card High") PORT_CODE(KEYCODE_A)
352   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Hold 1")    PORT_CODE(KEYCODE_Z)
353   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("Card Low")  PORT_CODE(KEYCODE_S)
354   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("Key In")    PORT_CODE(KEYCODE_5)
355   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_NAME("Key Out")   PORT_CODE(KEYCODE_8)
356   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_NAME("Auditor")   PORT_CODE(KEYCODE_9)
357INPUT_PORTS_END
358
359
360/***************************
361*    TMS9928a Interfase    *
362***************************/
363
364static const TMS9928a_interface tms9928a_interface =
365{
366   TMS99x8A,      /* TMS9128NL on pcb */
367   0x4000,
368   0, 0,
369   vdp_interrupt
370};
371
372
373/*************************
374*    AY8910 Interfase    *
375*************************/
376
377static const ay8910_interface ay8910_re900 =
378{
379   AY8910_LEGACY_OUTPUT,
380   AY8910_DEFAULT_LOADS,
381   re_psg_portA_r,
382   re_psg_portB_r,
383   re_mux_port_A_w,
384   re_mux_port_B_w
385};
386
387static const ay8910_interface ay8910_bs94 =
388{
389   AY8910_LEGACY_OUTPUT,
390   AY8910_DEFAULT_LOADS,
391   bs94_portA_r,
392   bs94_portB_r,
393   0,
394   0
395};
396
397/***************************
398*      Machine Driver      *
399***************************/
400
401static MACHINE_DRIVER_START( re900 )
402
403   /* basic machine hardware */
404   MDRV_CPU_ADD("main", I8051, MAIN_CLOCK)
405   MDRV_CPU_PROGRAM_MAP(mem_prg, 0)
406   MDRV_CPU_IO_MAP(mem_io, 0)
407   MDRV_CPU_VBLANK_INT("main", re900_video_interrupt)
408
409   /* video hardware */
410   MDRV_IMPORT_FROM(tms9928a)
411   MDRV_SCREEN_MODIFY("main")
412   MDRV_SCREEN_REFRESH_RATE(60)
413
414   MDRV_NVRAM_HANDLER(generic_0fill)
415
416   /* sound hardware   */
417   MDRV_SPEAKER_STANDARD_MONO("mono")
418   MDRV_SOUND_ADD("ay_re900", AY8910, TMS_CLOCK) /* From TMS9128NL - Pin 37 (GROMCLK) */
419   MDRV_SOUND_CONFIG(ay8910_re900)
420   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5)
421MACHINE_DRIVER_END
422
423static MACHINE_DRIVER_START( bs94 )
424
425   MDRV_IMPORT_FROM(re900)
426
427   /* sound hardware   */
428   MDRV_SOUND_MODIFY("ay_re900")
429   MDRV_SOUND_CONFIG(ay8910_bs94)
430   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5)
431MACHINE_DRIVER_END
432
433
434/*************************
435*        Rom Load        *
436*************************/
437
438ROM_START( re900 )
439   ROM_REGION( 0x10000, "main", 0 )
440   ROM_LOAD( "re900.bin", 0x0000, 0x10000, CRC(967ae944) SHA1(104bab79fd50a8e38ae15058dbe47a59f1ec4b05) )
441ROM_END
442
443ROM_START( bs94 )
444   ROM_REGION( 0x10000, "main", 0 )
445   ROM_LOAD( "bs94.bin",  0x0000, 0x10000, CRC(bbd484ce) SHA1(4128e488ca806842c3639e05c4c9cf4c0da2990d) )
446ROM_END
447
448
449/************************
450*      Driver Init      *
451************************/
452
453static DRIVER_INIT( re900 )
454{
455   TMS9928A_configure(&tms9928a_interface);
456   player = 1;
457   stat_a = 1;
458}
459
460
461/*************************
462*      Game Drivers      *
463*************************/
464
465/*     YEAR  NAME   PARENT MACHINE INPUT  INIT   ROT     COMPANY                    FULLNAME            FLAGS LAYOUT */
466GAMEL( 1993, re900, 0,     re900,  re900, re900, ROT90, "Entretenimientos GEMINIS", "Ruleta RE-900",    0,    layout_re900)
467GAME ( 1994, bs94 , 0,     bs94,   bs94 , re900, ROT0,  "Entretenimientos GEMINIS", "Buena Suerte '94", 0)
src/mame/drivers/exprraid.c
r3514r3515
11/***************************************************************************
22
3Express Raider - (c) 1986 Data East USA
3Express Raider - (c) 1986 Data East Corporation / Data East USA
44
55Ernesto Corvi
66ernesto@imagina.com
77
8Last Modified 14th Jul 2003
9
108Memory Map:
119Main CPU: ( 6502 )
12100000-05ff RAM
r3514r3515
21192800-2801 Protection
22203800-3800 VBblank ( bootleg 1 only )
23214000-ffff SMH_ROM
22ffc0-ffc0 VBblank ( bootleg 2 only )
2423
2524Sound Cpu: ( 6809 )
26250000-1fff RAM
r3514r3515
58572nd bootleg set expects to read vblank status from 0xFFC0, country warning
5958sign is intact, however Credit is spelt incorrectly.
6059
60
61Stephh's notes (based on the games M6502 code and some tests) :
62
631) 'exprraid'
64
65  - "@ 1986 DATA EAST USA, INC." (US)
66  - Number of enemies on "shoot" stages is determined by the level
67    (see code at 0x5d21 where location 0x0e is level number-1).
68    Note that time tables are coded backwards (locomotive first,
69    then 5th wagon, then 4th wagon ... up to 1st wagon).
70    This number of enemies is also supposed to be determined
71    by "Difficulty" settings (DSW1 bits 3 and 4).
72    There is however an ingame bug that reads DSW1 bits 4 and 5 :
73
74      5D2F: AD 03 18      lda  $1803
75      5D32: 49 FF         eor  #$FF
76      5D34: 4A            lsr  a
77      5D35: 4A            lsr  a
78      5D36: 4A            lsr  a
79      5D37: 29 06         and  #$06
80
81    So number of enemies is also determined by "Demo Sound" setting !
82    Correct code shall be :
83
84      5D37: 29 03         and  #$03
85
86  - Time for each wagon on "shoot" stage is determined by the level
87    (see code at 0x6873 where location 0x0e is level number-1).
88    Note that time tables are coded backwards (locomotive first,
89    then 5th wagon, then 4th wagon ... up to 1st wagon).
90  - In the US manual, "bonus lives" settings are told be either
91    "Every 50000" or "50000/80000".
92    However, when you look at code at 0xe4a1, you'll notice that
93    settings shall be "50000 only" and "50000/80000".
94  - "Coin Mode" as well "Mode 2 Coinage" settings (DSW0 bits 0 to 4)
95    are undocumented in the US manual.
96    "Coin Mode" is tested though via code at 0xe7c5.
97    Coinage tables :
98      * 0xe7e2 : COIN1 - 0xe7ea : COIN2 (Mode 1)
99      * 0xe7f2 : COIN1 - 0xe7fa : COIN2 (Mode 2)
100  - "Force Coinage" (DSW1 bit 6) setting is undocumented in the US manual.
101    It is tested though via code at 0xe794.
102    When this Dip Switch is set to "On", pressing COIN1 or COIN2 always
103    adds 1 credit regardless of the "Coinage" and "Coin Mode" settings.
104  - At the begining of each level, you have text in upper case
105    which gives you some hints to pass the level or some advice.
106  - In this version, due to extra code at 0xfd80, you only have 4 wagons
107    for the "shoot" stages instead of 5.
108  - Continue play is always available and score is NOT reset to 0.
109
1102) 'exprrada'
111
112  - "@ 1986 DATA EAST CORPORATION" + no code to display the Warning screen (World)
113  - Same way to code number of enemies in "shoot" stages as in 'exprraid'
114    (code at 5ce4) and same ingame bug :
115
116      5CF4: AD 03 18      lda  $1803
117      5CF7: 49 FF         eor  #$FF
118      5CF9: 4A            lsr  a
119      5CFA: 4A            lsr  a
120      5CFB: 4A            lsr  a
121      5CFC: 29 06         and  #$06
122
123    Correct code shall be :
124
125      5CFC: 29 03         and  #$03
126
127    You'll notice by looking at the tables that there are sometimes
128    more enemies than in 'exprraid'.
129  - Time for each wagon on "shoot" stage is determined by the level
130    (see code at 0x6834 where location 0x0e is level number-1).
131    This time is also supposed to be determined by "Difficulty"
132    settings (DSW1 bits 3 and 4).
133    There is however an ingame bug that reads DSW1 bits 4 and 5 :
134
135      683B: AD 03 18      lda  $1803
136      683E: 49 FF         eor  #$FF
137      6840: 4A            lsr  a
138      6841: 4A            lsr  a
139      6842: 4A            lsr  a
140      6843: 4A            lsr  a
141      6844: 29 03         and  #$03
142
143    So Time is also determined by "Demo Sound" setting because of
144    extra "lsr a" instruction at 0x6843 !
145    Correct code shall be :
146
147      6843: EA            nop
148
149    Fortunately, table at 0x685f is filled with 0x30 so you'll
150    always have 30 seconds to "clear" the wagon (which is more
151    than the time you have in 'exprraid').
152    For the locomotive, time is always set to 0x20 = 20 seconds
153    (which is again more than the time you have in 'exprraid').
154  - "Bonus lives" routine starts at 0xe49b.
155  - Coinage related stuff starts at 0xe78e.
156    Coinage tables :
157      * 0xe7dc : COIN1 - 0xe7e4 : COIN2 (Mode 1)
158      * 0xe7ec : COIN1 - 0xe7f4 : COIN2 (Mode 2)
159  - At the begining of each level, you have text in lower case
160    which doesn't give you any hints to pass the level nor advice.
161  - In this version, you always have 5 wagons for the "shoot" stages.
162  - Continue play is always available but score is reset to 0.
163
1643) 'wexpress'
165
166  - "@ 1986 DATA EAST CORPORATION" + no code to display the Warning screen (World)
167  - This version is based on 'exprrada' so all comments also fit
168    for this set. The main difference is that reads from 0x2800
169    and 0x2801 (protection) are either discarded (jumps are noped
170    or patched) or changed to read what shall be the correct value
171    (reads from 0x2801 occur almost all the time).
172    So IMO this set looks like a World bootleg .
173
1744) 'wexpresb'
175
176  - "@ 1986 DATA EAST CORPORATION" + extra code to display the Warning screen (Japan)
177  - Modified Warning screen
178  - This version is heavily based on 'exprrada' (even if I think
179    that there shall exist a "better" Japan undumped version)
180    so all comments also fit for this set. The main difference is
181    the way protection is bypassed (in a different way than 'wexpress'
182    as reads from 0x2801 only occur when a life is lost).
183    The other difference is that you can NOT continue a game.
184  - "Bonus lives" routine starts at 0xe4e5.
185  - Coinage related stuff starts at 0xe7d8.
186  - Coinage tables :
187      * 0xe826 : COIN1 - 0xe82e : COIN2 (Mode 1)
188      * 0xe836 : COIN1 - 0xe83e : COIN2 (Mode 2)
189
1905) 'wexpresc'
191
192  - "@ 1986 DATA EAST CORPORATION" + extra code to display the Warning screen (Japan)
193  - Original Warning screen
194  - "CREDIT" mispelled to "CRDDIT".
195  - This version is heavily based on 'exprrada' (even if I think
196    that there shall exist a "better" Japan undumped version)
197    so all comments also fit for this set. The main difference is
198    the way protection is bypassed (in a different way than 'wexpress'
199    but also in a different way than 'wexpresb' as reads from 0x2801
200    occur when you lose a life but also on "shoot" stages).
201    The other difference is that you can NOT continue a game as in 'wexpresb'.
202  - "Bonus lives" routine starts at 0xe4e5 (same as 'wexpresb')
203  - Coinage related stuff starts at 0xe7d8 (same as 'wexpresb').
204  - Coinage tables (same as 'wexpresb') :
205      * 0xe826 : COIN1 - 0xe82e : COIN2 (Mode 1)
206      * 0xe836 : COIN1 - 0xe83e : COIN2 (Mode 2)
207
208
61209***************************************************************************/
62210
63211#include "driver.h"
r3514r3515
148296
149297   PORT_START("DSW0")   /* DSW 0 - 0x1800 */
150298   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coin_A ) )
151   PORT_DIPSETTING(    0x00, DEF_STR( 2C_1C ) )
152   PORT_DIPSETTING(    0x03, DEF_STR( 1C_1C ) )
153   PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
154   PORT_DIPSETTING(    0x01, DEF_STR( 1C_3C ) )
299   PORT_DIPSETTING(    0x00, DEF_STR( 2C_1C ) ) PORT_CONDITION("DSW0",0x10,PORTCOND_EQUALS,0x10)
300   PORT_DIPSETTING(    0x03, DEF_STR( 1C_1C ) ) PORT_CONDITION("DSW0",0x10,PORTCOND_EQUALS,0x10)
301   PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) ) PORT_CONDITION("DSW0",0x10,PORTCOND_EQUALS,0x10)
302   PORT_DIPSETTING(    0x03, DEF_STR( 1C_2C ) ) PORT_CONDITION("DSW0",0x10,PORTCOND_EQUALS,0x00)
303   PORT_DIPSETTING(    0x01, DEF_STR( 1C_3C ) ) PORT_CONDITION("DSW0",0x10,PORTCOND_EQUALS,0x10)
304   PORT_DIPSETTING(    0x02, DEF_STR( 1C_3C ) ) PORT_CONDITION("DSW0",0x10,PORTCOND_EQUALS,0x00)
305   PORT_DIPSETTING(    0x01, DEF_STR( 1C_4C ) ) PORT_CONDITION("DSW0",0x10,PORTCOND_EQUALS,0x00)
306   PORT_DIPSETTING(    0x00, DEF_STR( 1C_6C ) ) PORT_CONDITION("DSW0",0x10,PORTCOND_EQUALS,0x00)
155307   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Coin_B ) )
156   PORT_DIPSETTING(    0x00, DEF_STR( 2C_1C ) )
157   PORT_DIPSETTING(    0x0c, DEF_STR( 1C_1C ) )
158   PORT_DIPSETTING(    0x08, DEF_STR( 1C_2C ) )
159   PORT_DIPSETTING(    0x04, DEF_STR( 1C_3C ) )
160   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED )
308   PORT_DIPSETTING(    0x00, DEF_STR( 4C_1C ) ) PORT_CONDITION("DSW0",0x10,PORTCOND_EQUALS,0x00)
309   PORT_DIPSETTING(    0x04, DEF_STR( 3C_1C ) ) PORT_CONDITION("DSW0",0x10,PORTCOND_EQUALS,0x00)
310   PORT_DIPSETTING(    0x00, DEF_STR( 2C_1C ) ) PORT_CONDITION("DSW0",0x10,PORTCOND_EQUALS,0x10)
311   PORT_DIPSETTING(    0x08, DEF_STR( 2C_1C ) ) PORT_CONDITION("DSW0",0x10,PORTCOND_EQUALS,0x00)
312   PORT_DIPSETTING(    0x0c, DEF_STR( 1C_1C ) ) PORT_CONDITION("DSW0",0x10,PORTCOND_EQUALS,0x10)
313   PORT_DIPSETTING(    0x0c, DEF_STR( 1C_1C ) ) PORT_CONDITION("DSW0",0x10,PORTCOND_EQUALS,0x00)
314   PORT_DIPSETTING(    0x08, DEF_STR( 1C_2C ) ) PORT_CONDITION("DSW0",0x10,PORTCOND_EQUALS,0x10)
315   PORT_DIPSETTING(    0x04, DEF_STR( 1C_3C ) ) PORT_CONDITION("DSW0",0x10,PORTCOND_EQUALS,0x10)
316   PORT_DIPNAME( 0x10, 0x10, "Coin Mode" )                 /* see notes */
317   PORT_DIPSETTING(    0x10, "Mode 1" )
318   PORT_DIPSETTING(    0x00, "Mode 2" )
161319   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Flip_Screen ) )
162320   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
163321   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
164322   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Cabinet ) )
165323   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
166324   PORT_DIPSETTING(    0x40, DEF_STR( Cocktail ) )
167   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
325   PORT_DIPUNUSED( 0x80, IP_ACTIVE_LOW )
168326
169327   PORT_START("IN1")   /* IN 1 - 0x1801 */
170328   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY
171   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY
172   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY
173   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY
329   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )  PORT_8WAY
330   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )    PORT_8WAY
331   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )  PORT_8WAY
174332   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
175333   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
176334   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 )
r3514r3515
178336
179337   PORT_START("IN2")   /* IN 2 - 0x1802 */
180338   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_COCKTAIL
181   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL
182   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_COCKTAIL
183   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL
339   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )  PORT_8WAY PORT_COCKTAIL
340   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )    PORT_8WAY PORT_COCKTAIL
341   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )  PORT_8WAY PORT_COCKTAIL
184342   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
185343   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL
186344   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 )
187345   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 )
188346
189   PORT_START("DSW1")   /* IN 3 - 0x1803 */
347   PORT_START("DSW1")   /* DSW 1 - 0x1803 */
190348   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )
191349   PORT_DIPSETTING(    0x01, "1" )
192350   PORT_DIPSETTING(    0x03, "3" )
193351   PORT_DIPSETTING(    0x02, "5" )
194352   PORT_DIPSETTING(   0x00, DEF_STR( Infinite ) )
195   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Bonus_Life ) )
196   PORT_DIPSETTING(    0x04, "50K+" )
197   PORT_DIPSETTING(    0x00, "50K 80K" )
198   PORT_DIPNAME( 0x18, 0x18, DEF_STR( Difficulty ) )
199   PORT_DIPSETTING(    0x10, DEF_STR( Easy ) )
200   PORT_DIPSETTING(    0x18, DEF_STR( Normal ) )
353   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Bonus_Life ) )       /* see notes */
354   PORT_DIPSETTING(    0x00, "50k 80k" )
355   PORT_DIPSETTING(    0x04, "50k only" )
356   PORT_DIPNAME( 0x18, 0x18, DEF_STR( Difficulty ) )       /* see notes */
357   PORT_DIPSETTING(    0x18, DEF_STR( Easy ) )
358   PORT_DIPSETTING(    0x10, DEF_STR( Normal ) )
201359   PORT_DIPSETTING(    0x08, DEF_STR( Hard ) )
202360   PORT_DIPSETTING(    0x00, DEF_STR( Very_Hard ) )
203   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) )
361   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) )      /* see notes */
204362   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
205363   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
206   PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
364   PORT_DIPNAME( 0x40, 0x40, "Force Coinage = 1C/1C" )     /* see notes */
365   PORT_DIPSETTING(    0x40, DEF_STR( No ) )
366   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
367   PORT_DIPUNUSED( 0x80, IP_ACTIVE_LOW )
207368INPUT_PORTS_END
208369
209370
src/mame/drivers/micro3d.c
r3514r3515
2525#include "deprecat.h"
2626#include "cpu/tms34010/tms34010.h"
2727#include "cpu/tms34010/34010ops.h"
28#include "cpu/i8051/i8051.h"
28#include "cpu/mcs51/mcs51.h"
2929#include "sound/2151intf.h"
3030#include "sound/upd7759.h"
3131#include "sound/dac.h"
r3514r3515
549549                        {
550550                           cpunum_set_input_line_and_vector(machine, 0,3, HOLD_LINE, M68681.IVR);         // Generate an interrupt, if allowed.
551551                        }
552                        cpunum_set_input_line(machine, 2, I8051_RX_LINE, ASSERT_LINE);                      // Generate 8031 interrupt
552                        cpunum_set_input_line(machine, 2, MCS51_RX_LINE, ASSERT_LINE);                      // Generate 8031 interrupt
553553                        mame_printf_debug("Sound board TX: %4X at PC=%4X\n",value,activecpu_get_pc());
554554#endif
555555                        M68681.SRB &=~0x0400;                   // Data has been sent - TX ready for more.
556                        cpunum_set_input_line(machine, 2, I8051_RX_LINE, ASSERT_LINE);                      // Generate 8031 interrupt
556                        cpunum_set_input_line(machine, 2, MCS51_RX_LINE, ASSERT_LINE);                      // Generate 8031 interrupt
557557                        mame_printf_debug("Sound board TX: %4X at PC=%4X\n",value,activecpu_get_pc());
558558                        break;
559559
src/mame/drivers/superqix.c
r3514r3515
109109#include "driver.h"
110110#include "deprecat.h"
111111#include "cpu/m6805/m6805.h"
112#include "cpu/i8051/i8051.h"
112#include "cpu/mcs51/mcs51.h"
113113#include "sound/ay8910.h"
114114#include "sound/samples.h"
115115
src/mame/drivers/astinvad.c
r3514r3515
368368   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_START1 )
369369   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
370370   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 )
371   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY
371   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY
372372   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY
373373   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
374374
r3514r3515
385385   PORT_DIPSETTING(    0x08, "15000" )
386386   PORT_DIPSETTING(    0x00, "20000" )
387387   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_COCKTAIL
388   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_COCKTAIL
388   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_COCKTAIL
389389   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_COCKTAIL
390390
391391   PORT_START("IN2")
r3514r3515
398398   PORT_DIPSETTING(    0xff, DEF_STR( Cocktail ) )
399399INPUT_PORTS_END
400400
401
402401static INPUT_PORTS_START( astinvad )
403402   PORT_INCLUDE(kamikaze)
404403
405404   PORT_MODIFY("IN1")
406   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Lives ) )      PORT_DIPLOCATION("SW:2")
405   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Lives ) )            PORT_DIPLOCATION("SW:2")
407406   PORT_DIPSETTING(    0x00, "3" )
408407   PORT_DIPSETTING(    0x01, "4" )
409   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Bonus_Life ) )   PORT_DIPLOCATION("SW:1")
408   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Bonus_Life ) )       PORT_DIPLOCATION("SW:1")
410409   PORT_DIPSETTING(    0x02, "10000" )
411410   PORT_DIPSETTING(    0x00, "20000" )
412   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
413   PORT_DIPNAME( 0x88, 0x00, DEF_STR( Coinage ) )      PORT_DIPLOCATION("SW:3,4")
411   PORT_DIPNAME( 0x88, 0x00, DEF_STR( Coinage ) )          PORT_DIPLOCATION("SW:3,4")
414412   PORT_DIPSETTING(    0x88, DEF_STR( 3C_1C ) )
415413   PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) )
416414   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
r3514r3515
441439   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_START1 )
442440   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_START2 )
443441   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY
444   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY
442   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY
445443   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 )
446444   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_COCKTAIL
447   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_COCKTAIL
445   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_COCKTAIL
448446   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_COCKTAIL
449447
450448   PORT_START("IN1")
451   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unused ) )
452   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
453   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
454   PORT_DIPNAME( 0x06, 0x00, DEF_STR( Lives ) )
449   PORT_DIPUNUSED( 0x01, IP_ACTIVE_HIGH )
450   PORT_DIPNAME( 0x06, 0x00, DEF_STR( Lives ) )            /* code at 0x0d4a */
455451   PORT_DIPSETTING(    0x00, "3" )
456452   PORT_DIPSETTING(    0x04, "4" )
457453   PORT_DIPSETTING(    0x02, "5" )
454//  PORT_DIPSETTING(    0x06, "5" )                         /* duplicate settings */
458455   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Coinage ) )
459456   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
460457   PORT_DIPSETTING(    0x08, DEF_STR( 1C_2C ) )
r3514r3515
468465   PORT_DIPSETTING(    0xff, DEF_STR( Cocktail ) )
469466INPUT_PORTS_END
470467
468static INPUT_PORTS_START( spaceinj )
469   PORT_INCLUDE( spaceint )
471470
471   PORT_MODIFY("IN1")
472   PORT_DIPNAME( 0x06, 0x00, DEF_STR( Lives ) )            /* code at 0x0d37 */
473   PORT_DIPSETTING(    0x00, "3" )
474   PORT_DIPSETTING(    0x02, "5" )
475//  PORT_DIPSETTING(    0x04, "5" )                         /* duplicate settings */
476//  PORT_DIPSETTING(    0x06, "5" )                         /* duplicate settings */
477INPUT_PORTS_END
472478
479
480
473481/*************************************
474482 *
475483 *  Sound definitions
r3514r3515
686694GAME( 19??, kosmokil, kamikaze, kamikaze, kamikaze, kamikaze, ROT270, "bootleg",            "Kosmo Killer", 0 ) // says >BEM< Mi Italy but it looks hacked in, dif revision of game tho.
687695GAME( 1979, spcking2, 0,        spcking2, spcking2, spcking2, ROT270, "Konami",             "Space King 2", 0 )
688696GAME( 1980, spaceint, 0,        spaceint, spaceint, 0,        ROT90,  "Shoei",              "Space Intruder", GAME_WRONG_COLORS )
689GAME( 1980, spaceinj, spaceint, spaceint, spaceint, 0,        ROT90,  "Shoei",              "Space Intruder (Japan)", GAME_WRONG_COLORS )
697GAME( 1980, spaceinj, spaceint, spaceint, spaceinj, 0,        ROT90,  "Shoei",              "Space Intruder (Japan)", GAME_WRONG_COLORS )
src/mame/drivers/neodrvr.c
r3514r3515
458458   ROM_REGION( 0x20000, "zoomy", 0 )                                          \
459459   ROM_LOAD( "000-lo.lo", 0x00000, 0x20000, CRC(5a86cff2) SHA1(5992277debadeb64d1c1c64b0a92d9293eaf7e4a) )
460460
461
461462/***************************************************************************
462463
463464    Neo-Geo game pcb infos:
r3514r3515
517518
518519    MVS PROG:
519520    -- SNK --
521    . NEO-MVS PROG-NAM
520522    . NEO-MVS PROG-HERO
521523    . NEO-MVS PROG-EP
524    . NEO-MVS PROG-8MB
522525    . NEO-MVS PROG8M42
523526    . NEO-MVS PROG16
524527    . NEO-MVS PROG42G
528    . NEO-MVS PROG42G-COM
525529    . NEO-MVS PROG42G-1
526530    . NEO-MVS PROG-G2
527531    . NEO-MVS PROG 4096
r3514r3515
541545    . NEO-MVS PROGBK2R (2003.8.26) - NEO-HYCS (2003.9.29)
542546    . NEO-MVS PROGBK3R (2003.9.2) - NEO-HYCS (2003.9.29)
543547    . NEO-MVS PROGBK3S (2003.10.1)
544    . NEO-MVS PROGBK2S (2003.10.xx)
548    . NEO-MVS PROGBK2S (2003.10.18)
545549
546550
547551    AES CHA:
r3514r3515
643647    . Power Spikes II (early revisions) ?
644648    . Metal Slug 3 (rev. Mar/17/2000 1:36)
645649    . Metal Slug 4 (AES)
650    . Metal Slug 4 (MVS, 1st revision)
646651    . Metal Slug 5 (PCB)
647652    . 98 Best 44
648653
r3514r3515
745750   ROM_REGION( 0x100000, "main", 0 )
746751   ROM_LOAD16_WORD_SWAP( "004-p1.bin", 0x000000, 0x080000, CRC(fc6f53db) SHA1(64a62ca4c8fb68954e06121399c9402278bd0467) )
747752
748   NEO_SFIX_64K( "004-s1.bin", BAD_DUMP CRC(b0d16529) SHA1(1483a3459309596ee3ecff68bdbde0809d82dd7a) )
753   NEO_SFIX_128K( "004-s1.bin", CRC(4e310702) SHA1(edb0a27fe51d5e7f5739715b7c8872b6d4459b06) )
749754
750   NEO_BIOS_AUDIO_64K( "004-m1.bin", BAD_DUMP CRC(37965a73) SHA1(61ad03c74169f9f50a37048fb74300ee926ee766) )
755   NEO_BIOS_AUDIO_128K( "004-m1.bin", CRC(c71fbb3b) SHA1(59c58665b53da61352359d191a0569de5dd1f4b3) )
751756
752757   ROM_REGION( 0x100000, "ym", 0 )
753   ROM_LOAD( "004-v1.bin", 0x000000, 0x080000, CRC(b2fb2153) SHA1(36e0cc8927b11105de40188af46f6cf532794c10) )
754   ROM_LOAD( "004-v2.bin", 0x080000, 0x080000, CRC(8503317b) SHA1(ab22f1aba1e977ab234a4f1d73dc6ed789dbeb85) )
758   ROM_LOAD( "004-v11.bin", 0x000000, 0x080000, CRC(b2fb2153) SHA1(36e0cc8927b11105de40188af46f6cf532794c10) )
759   ROM_LOAD( "004-v12.bin", 0x080000, 0x080000, CRC(8503317b) SHA1(ab22f1aba1e977ab234a4f1d73dc6ed789dbeb85) )
755760
756761   ROM_REGION( 0x180000, "ym.deltat", 0 )
757   ROM_LOAD( "004-v3.bin", 0x000000, 0x080000, CRC(4999fb27) SHA1(2d4926a220ea21bdd5e816bb16f985fff089500a) )
758   ROM_LOAD( "004-v4.bin", 0x080000, 0x080000, CRC(776fa2a2) SHA1(e7d5a362ab7806b7b009700a435c815a20e8ec68) )
759   ROM_LOAD( "004-v5.bin", 0x100000, 0x080000, CRC(b3e7eeea) SHA1(4d1e97f380702a3a06e7f954b4caddd9c4119d8f) )
762   ROM_LOAD( "004-v21.bin", 0x000000, 0x080000, CRC(4999fb27) SHA1(2d4926a220ea21bdd5e816bb16f985fff089500a) )
763   ROM_LOAD( "004-v22.bin", 0x080000, 0x080000, CRC(776fa2a2) SHA1(e7d5a362ab7806b7b009700a435c815a20e8ec68) )
764   ROM_LOAD( "004-v23.bin", 0x100000, 0x080000, CRC(b3e7eeea) SHA1(4d1e97f380702a3a06e7f954b4caddd9c4119d8f) )
760765
761766   ROM_REGION( 0x200000, "sprites", ROMREGION_DISPOSE )
762767   ROM_LOAD16_BYTE( "004-c1.bin", 0x000000, 0x80000, CRC(f1ae16bc) SHA1(df68feed4dcba1e1566032b01ebb7b478a1792bf) ) /* Plane 0,1 */
r3514r3515
914919   ROM_LOAD16_BYTE( "009-c6.bin", 0x200001, 0x80000, CRC(2eca8b19) SHA1(16764ef10e404325ba0a1a2ad3a4c0af287be21f) ) /* Plane 2,3 */
915920ROM_END
916921
917ROM_START( ncombath ) /* AES VERSION */
922ROM_START( ncombath ) /* MBS AND AES VERSION */
918923   ROM_REGION( 0x100000, "main", 0 )
919924   ROM_LOAD16_WORD_SWAP( "009-pg1.bin", 0x000000, 0x080000, CRC(8e9f0add) SHA1(d0b908a86a58f2537eea73a431038f1cd74a5a2f) )
920925
r3514r3515
965970   ROM_LOAD16_BYTE( "010-c6.bin", 0x200001, 0x80000, CRC(c495c567) SHA1(2f58475fbb5f1adafce027d396fb05dd71e8fb55) ) /* Plane 2,3 */
966971ROM_END
967972
968ROM_START( superspy )
973ROM_START( superspy ) /* MVS AND AES VERSION */
969974   ROM_REGION( 0x100000, "main", 0 )
970975   ROM_LOAD16_WORD_SWAP( "011-p1.bin",  0x000000, 0x080000, CRC(c7f944b5) SHA1(da7560e09187c68f1d9f7656218497b4464c56c9) )
971976   ROM_LOAD16_WORD_SWAP( "011-sp2.bin", 0x080000, 0x020000, CRC(811a4faf) SHA1(8169dfaf79f52d80ecec402ce1b1ab9cafb7ebdd) )
r3514r3515
989994   ROM_LOAD16_BYTE( "011-c4.bin", 0x200001, 0x100000, CRC(b7f63162) SHA1(077a81b2bb0a8f17c9df6945078608f74432877a) ) /* Plane 2,3 */
990995ROM_END
991996
992ROM_START( mutnat )
997ROM_START( mutnat ) /* MVS AND AES VERSION */
993998   ROM_REGION( 0x100000, "main", 0 )
994999   ROM_LOAD16_WORD_SWAP( "014-p1.bin", 0x000000, 0x080000, CRC(6f1699c8) SHA1(87206f67a619dede7959230f9ff3701b8b78957a) )
9951000
r3514r3515
10571062   ROM_LOAD16_BYTE( "016-c4.bin", 0x200001, 0x100000, CRC(070506e2) SHA1(3a2ec365e1d87a9c5ce1ee9bea88402a8eef4ed7) ) /* Plane 2,3 */
10581063ROM_END
10591064
1060ROM_START( sengoku )
1065ROM_START( sengoku ) /* MVS VERSION */
10611066   ROM_REGION( 0x100000, "main", 0 )
10621067   ROM_LOAD16_WORD_SWAP( "017-p1.bin", 0x000000, 0x080000, CRC(f8a63983) SHA1(7a10ecb2f0fd8315641374c065d2602107b09e72) )
10631068   ROM_LOAD16_WORD_SWAP( "017-p2.bin", 0x080000, 0x020000, CRC(3024bbb3) SHA1(88892e1292dd60f35a76f9a22e623d4f0f9693cc) )
r3514r3515
15951600   ROM_LOAD16_BYTE( "037-c4.bin", 0x200001, 0x100000, CRC(4a24395d) SHA1(943f911f40985db901eaef4c28dfcda299fca73e) ) /* Plane 2,3 */
15961601ROM_END
15971602
1598ROM_START( trally )
1603ROM_START( trally ) /* MVS AND AES VERSION */
15991604   ROM_REGION( 0x100000, "main", 0 )
16001605   ROM_LOAD16_WORD_SWAP( "038-p1.bin", 0x000000, 0x080000, CRC(1e52a576) SHA1(a1cb56354c3378e955b0cd482c3c41ae15add952) )
16011606   ROM_LOAD16_WORD_SWAP( "038-p2.bin", 0x080000, 0x080000, CRC(a5193e2f) SHA1(96803480439e90da23cdca70d59ff519ee85beeb) )
r3514r3515
44024407
44034408   NO_DELTAT_REGION
44044409
4405   ROM_REGION( 0x1400000, "sprites", ROMREGION_DISPOSE )
4406   ROM_LOAD16_BYTE( "230-c1.bin", 0x0000000, 0x400000, CRC(68d4ae76) SHA1(2e820067f6963669f104bebf19e865fe4127b4dd) ) /* Plane 0,1 */
4407   ROM_LOAD16_BYTE( "230-c2.bin", 0x0000001, 0x400000, CRC(fdee05cd) SHA1(efc4ffd790953ac7c25d5f045c64a9b49d24b096) ) /* Plane 2,3 */
4408   ROM_LOAD16_BYTE( "230-c3.bin", 0x0800000, 0x400000, CRC(645077f3) SHA1(0ae74f3b4b3b88f128c6d8c0f35ffa53f5d67ef2) ) /* Plane 0,1 */
4409   ROM_LOAD16_BYTE( "230-c4.bin", 0x0800001, 0x400000, CRC(63aeb74c) SHA1(9ff6930c0c3d79b46b86356e8565ce4fcd69ac38) ) /* Plane 2,3 */
4410   ROM_LOAD16_BYTE( "245-c5.bin", 0x1000000, 0x200000, CRC(28ff1792) SHA1(0cc5c16ac42f52cee74f88235aef0671bee33b4c) ) /* Plane 0,1 */
4411   ROM_LOAD16_BYTE( "245-c6.bin", 0x1000001, 0x200000, CRC(23c65644) SHA1(9dc74c3075cf0f738b6b41e5e8d89a74a6c9ef07) ) /* Plane 2,3 */
4410   ROM_REGION( 0x1800000, "sprites", ROMREGION_DISPOSE )
4411   /* The chip labels and sizes are correct */
4412   ROM_LOAD16_BYTE( "245-c1.bin", 0x0000000, 0x400000, CRC(68d4ae76) SHA1(2e820067f6963669f104bebf19e865fe4127b4dd) ) /* Plane 0,1 */
4413   ROM_LOAD16_BYTE( "245-c2.bin", 0x0000001, 0x400000, CRC(fdee05cd) SHA1(efc4ffd790953ac7c25d5f045c64a9b49d24b096) ) /* Plane 2,3 */
4414   ROM_LOAD16_BYTE( "245-c3.bin", 0x0800000, 0x400000, CRC(645077f3) SHA1(0ae74f3b4b3b88f128c6d8c0f35ffa53f5d67ef2) ) /* Plane 0,1 */
4415   ROM_LOAD16_BYTE( "245-c4.bin", 0x0800001, 0x400000, CRC(63aeb74c) SHA1(9ff6930c0c3d79b46b86356e8565ce4fcd69ac38) ) /* Plane 2,3 */
4416   ROM_LOAD16_BYTE( "245-c5.bin", 0x1000000, 0x400000, CRC(b5f40e7f) SHA1(b332bac64dbb9a9dd66c5315f47ea08634d36f45) ) /* Plane 0,1 */
4417   ROM_LOAD16_BYTE( "245-c6.bin", 0x1000001, 0x400000, CRC(d0337328) SHA1(dff86b75dc283bd4512557a5c64f16e6be6c16e4) ) /* Plane 2,3 */
44124418ROM_END
44134419
44144420ROM_START( shocktr2 )
r3514r3515
49264932   ROM_LOAD16_BYTE( "256-c8.bin", 0x3000001, 0x800000, CRC(4d9be34c) SHA1(a737bdfa2b815aea7067e7af2636e83a9409c414) ) /* Plane 2,3 */
49274933ROM_END
49284934
4929ROM_START( mslug3h ) /* Original Version - Encrypted GFX */ /* AES VERSION */
4935ROM_START( mslug3h ) /* Original Version - Encrypted GFX */ /* MVS AND AES VERSION */
49304936   ROM_REGION( 0x500000, "main", 0 )
49314937   ROM_LOAD16_WORD_SWAP( "256-ph1.bin", 0x000000, 0x100000, CRC(9c42ca85) SHA1(7a8f77a89867b889295ae9b9dfd4ba28f02d234d) )
49324938   ROM_LOAD16_WORD_SWAP( "256-ph2.bin", 0x100000, 0x400000, CRC(1f3d8ce8) SHA1(08b05a8abfb86ec09a5e758d6273acf1489961f9) )
r3514r3515
49995005
50005006ROM_START( kof2000n ) /* Original Version, Encrypted Sound + GFX Roms */
50015007   ROM_REGION( 0x500000, "main", 0 )
5002   ROM_LOAD16_WORD_SWAP( "257-p1n.bin", 0x000000, 0x100000, CRC(5f809dbe) SHA1(2bc233dcff5622de86d01e3b74b840c7caf12982) )
5003   ROM_LOAD16_WORD_SWAP( "257-p2n.bin", 0x100000, 0x400000, CRC(693c2c5e) SHA1(dc9121b7369ef46596343cac055a00aec81704d4) )
5008   ROM_LOAD16_WORD_SWAP( "257-pg1.bin", 0x000000, 0x100000, CRC(5f809dbe) SHA1(2bc233dcff5622de86d01e3b74b840c7caf12982) )
5009   ROM_LOAD16_WORD_SWAP( "257-pg2.bin", 0x100000, 0x400000, CRC(693c2c5e) SHA1(dc9121b7369ef46596343cac055a00aec81704d4) )
50045010
50055011   ROM_Y_ZOOM
50065012
r3514r3515
52145220   ROM_LOAD16_BYTE( "262-c8-08-e0.bin", 0x3000001, 0x800000, CRC(59289a6b) SHA1(ddfce7c85b2a144975db5bb14b4b51aaf881880e) ) /* Plane 2,3 */
52155221ROM_END
52165222
5217ROM_START( mslug4 ) /* Original Version - Encrypted GFX */ /* MVS VERSION */
5223ROM_START( mslug4 ) /* Original Version - Encrypted GFX */ /* MVS VERSION */ /* 2nd revision */
52185224   ROM_REGION( 0x500000, "main", 0 )
52195225   ROM_LOAD16_WORD_SWAP( "263-pg1.bin", 0x000000, 0x100000, CRC(27e4def3) SHA1(a08785e8145981bb6b5332a3b2df7eb321253cca) )
52205226   ROM_LOAD16_WORD_SWAP( "263-p2.bin",  0x100000, 0x400000, CRC(fdb7aed8) SHA1(dbeaec38f44e58ffedba99e70fa1439c2bf0dfa3) )
src/mame/drivers/cardline.c
r3514r3515
1717
1818
1919#include "driver.h"
20#include "cpu/i8051/i8051.h"
20#include "cpu/mcs51/mcs51.h"
2121#include "sound/okim6295.h"
2222
2323#include "cardline.lh"
src/mame/drivers/peplus.c
r3514r3515
159159
160160#include "driver.h"
161161#include "sound/ay8910.h"
162#include "cpu/i8051/i8051.h"
162#include "cpu/mcs51/mcs51.h"
163163#include "machine/i2cmem.h"
164164
165165#include "peplus.lh"
r3514r3515
313313
314314static WRITE8_HANDLER( peplus_io_w )
315315{
316   if (offset == 2)
317      cputag_set_input_line(machine, "main", 0, CLEAR_LINE);
318
316319   io_port[offset] = data;
317320}
318321
r3514r3515
9971000   MDRV_CPU_PROGRAM_MAP(peplus_map, 0)
9981001   //MDRV_CPU_DATA_MAP(peplus_datamap, 0)
9991002   MDRV_CPU_IO_MAP(peplus_iomap, 0)
1000   MDRV_CPU_VBLANK_INT("main", irq0_line_hold)
1003   MDRV_CPU_VBLANK_INT("main", irq0_line_assert)
10011004
10021005   MDRV_MACHINE_RESET(peplus)
10031006   MDRV_NVRAM_HANDLER(peplus)
src/mame/drivers/snookr10.c
r3514r3515
375375VIDEO_START( apple10 );
376376VIDEO_UPDATE( snookr10 );
377377
378int outportl, outporth;
379int bit0, bit1, bit2, bit3, bit4, bit5;
378static int outportl, outporth;
379static int bit0, bit1, bit2, bit3, bit4, bit5;
380380
381381/**********************
382382* Read/Write Handlers *
src/mame/drivers/ttchamp.c
r3514r3515
5454{
5555   int y,x,count;
5656//  int i;
57   static int xxx=320,yyy=204;
57   static const int xxx=320,yyy=204;
5858
5959   fillbitmap(bitmap, get_black_pen(screen->machine), 0);
6060
src/mame/drivers/segac2.c
r3514r3515
247247   return paletteram16[offset + palbank * 0x200];
248248}
249249
250extern UINT16* megadrive_vdp_palette_lookup;
251extern UINT16* megadrive_vdp_palette_lookup_sprite; // for C2
252extern UINT16* megadrive_vdp_palette_lookup_shadow;
253extern UINT16* megadrive_vdp_palette_lookup_highlight;
254
255
256250UINT16* megadrive_vdp_palette_lookup_segac2;
257251UINT16* megadrive_vdp_palette_lookup_sprite_segac2;
258252UINT16* megadrive_vdp_palette_lookup_shadow_segac2;
r3514r3515
326320
327321******************************************************************************/
328322
329extern int segac2_bg_pal_lookup[4];
330extern int segac2_sp_pal_lookup[4];
331
332323static void recompute_palette_tables(void)
333324{
334325   int i;
r3514r3515
18681859
18691860******************************************************************************/
18701861
1871extern int genvdp_use_cram;
1872extern int genesis_has_z80;
1873extern int genesis_always_irq6;
1874extern int genesis_other_hacks;
1875extern DRIVER_INIT( megadriv_c2 );
1876
18771862static void segac2_common_init(running_machine* machine, int (*func)(int in))
18781863{
18791864   DRIVER_INIT_CALL( megadriv_c2 );
src/mame/drivers/taito_f2.c
r3514r3515
34993499   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
35003500INPUT_PORTS_END
35013501
3502INPUT_PORTS_START( yesnoj )
3502static INPUT_PORTS_START( yesnoj )
35033503   /* 0xb00000 -> 0x20c0e0.b ($40e0,A5) */
35043504   PORT_START("DSWA")
35053505   PORT_DIPNAME( 0x01, 0x00, "Print Results" )
src/mame/drivers/acommand.c
r3514r3515
44
55driver by Angelo Salese
66
7seems like a particular version of the NMK16 board.
7Similar (same?) to the Cisco Heat board type.
88
99TODO:
10-Understand what "devices" area needs to make this working...
10-Understand what "devices" area needs to make this working.It's likely that the upper switches
11controls the UFO's and the lower switches the astronauts.
12-Back tilemap paging is likely to be incorrect.
13-3D Artworks for the UFO's,Astronauts etc.
14-Merge to the Cisco Heat driver.
1115
12-Complete sound
16Notes:
17-The real HW is a redemption machine with two guns,similar to the "Cosmo Gang the Video"
18(Namco) bonus games.
1319
14-Back tilemap paging is likely to be incorrect...
15
16
1720m68k irq table vectors
1821lev 1 : 0x64 : 0000 04f0 - rte
1922lev 2 : 0x68 : 0000 044a - vblank
r3514r3515
157160}
158161
159162
160/*copied from drivers/gticlub.c,to be completed*/
161163#define LED_ON      0x01c00
162#define SHOW_LEDS   0
164#define LED_OFF      0x00000
165/*
166     a
167    ---
168f   | | b
169    -g-
170e   | | c
171    ---
172     d
173a & 1
174b & 2
175c & 4
176d & 8
177e & 10
178f & 20
179g & 40
1807f
181*/
182/*                                    0    1    2    3    4    5    6    7    8    9    a    b    c    d    e    f*/
183static const UINT8 led_fill[0x10] = { 0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x00,0x00,0x00,0x00,0x00,0x00};
163184
164#if SHOW_LEDS
165185static void draw_led(bitmap_t *bitmap, int x, int y,UINT8 value)
166186{
167   plot_box(bitmap, x, y, 5, 9, 0x00000000);
187   plot_box(bitmap, x, y, 6, 10, 0x00000000);
168188
169   /* Top */
170   if( (value & 0x40) == 0 ) {
171      *BITMAP_ADDR16(bitmap, y+0, x+1) = LED_ON;
172      *BITMAP_ADDR16(bitmap, y+0, x+2) = LED_ON;
173      *BITMAP_ADDR16(bitmap, y+0, x+3) = LED_ON;
174   }
175   /* Middle */
176   if( (value & 0x01) == 0 ) {
177      *BITMAP_ADDR16(bitmap, y+4, x+1) = LED_ON;
178      *BITMAP_ADDR16(bitmap, y+4, x+2) = LED_ON;
179      *BITMAP_ADDR16(bitmap, y+4, x+3) = LED_ON;
180   }
181   /* Bottom */
182   if( (value & 0x08) == 0 ) {
183      *BITMAP_ADDR16(bitmap, y+8, x+1) = LED_ON;
184      *BITMAP_ADDR16(bitmap, y+8, x+2) = LED_ON;
185      *BITMAP_ADDR16(bitmap, y+8, x+3) = LED_ON;
186   }
187   /* Top Left */
188   if( (value & 0x02) == 0 ) {
189      *BITMAP_ADDR16(bitmap, y+1, x+0) = LED_ON;
190      *BITMAP_ADDR16(bitmap, y+2, x+0) = LED_ON;
191      *BITMAP_ADDR16(bitmap, y+3, x+0) = LED_ON;
192   }
193   /* Top Right */
194   if( (value & 0x20) == 0 ) {
195      *BITMAP_ADDR16(bitmap, y+1, x+4) = LED_ON;
196      *BITMAP_ADDR16(bitmap, y+2, x+4) = LED_ON;
197      *BITMAP_ADDR16(bitmap, y+3, x+4) = LED_ON;
198   }
199   /* Bottom Left */
200   if( (value & 0x04) == 0 ) {
201      *BITMAP_ADDR16(bitmap, y+5, x+0) = LED_ON;
202      *BITMAP_ADDR16(bitmap, y+6, x+0) = LED_ON;
203      *BITMAP_ADDR16(bitmap, y+7, x+0) = LED_ON;
204   }
205   /* Bottom Right */
206   if( (value & 0x10) == 0 ) {
207      *BITMAP_ADDR16(bitmap, y+5, x+4) = LED_ON;
208      *BITMAP_ADDR16(bitmap, y+6, x+4) = LED_ON;
209      *BITMAP_ADDR16(bitmap, y+7, x+4) = LED_ON;
210   }
189   /*a*/
190   *BITMAP_ADDR16(bitmap, y+0, x+1) = ((led_fill[value] & 0x0001) ? LED_ON : LED_OFF);
191   *BITMAP_ADDR16(bitmap, y+0, x+2) = ((led_fill[value] & 0x0001) ? LED_ON : LED_OFF);
192   *BITMAP_ADDR16(bitmap, y+0, x+3) = ((led_fill[value] & 0x0001) ? LED_ON : LED_OFF);
193   /*b*/
194   *BITMAP_ADDR16(bitmap, y+1, x+4) = ((led_fill[value] & 0x0002) ? LED_ON : LED_OFF);
195   *BITMAP_ADDR16(bitmap, y+2, x+4) = ((led_fill[value] & 0x0002) ? LED_ON : LED_OFF);
196   *BITMAP_ADDR16(bitmap, y+3, x+4) = ((led_fill[value] & 0x0002) ? LED_ON : LED_OFF);
197   /*c*/
198   *BITMAP_ADDR16(bitmap, y+5, x+4) = ((led_fill[value] & 0x0004) ? LED_ON : LED_OFF);
199   *BITMAP_ADDR16(bitmap, y+6, x+4) = ((led_fill[value] & 0x0004) ? LED_ON : LED_OFF);
200   *BITMAP_ADDR16(bitmap, y+7, x+4) = ((led_fill[value] & 0x0004) ? LED_ON : LED_OFF);
201   /*d*/
202   *BITMAP_ADDR16(bitmap, y+8, x+1) = ((led_fill[value] & 0x0008) ? LED_ON : LED_OFF);
203   *BITMAP_ADDR16(bitmap, y+8, x+2) = ((led_fill[value] & 0x0008) ? LED_ON : LED_OFF);
204   *BITMAP_ADDR16(bitmap, y+8, x+3) = ((led_fill[value] & 0x0008) ? LED_ON : LED_OFF);
205   /*e*/
206   *BITMAP_ADDR16(bitmap, y+5, x+0) = ((led_fill[value] & 0x0010) ? LED_ON : LED_OFF);
207   *BITMAP_ADDR16(bitmap, y+6, x+0) = ((led_fill[value] & 0x0010) ? LED_ON : LED_OFF);
208   *BITMAP_ADDR16(bitmap, y+7, x+0) = ((led_fill[value] & 0x0010) ? LED_ON : LED_OFF);
209   /*f*/
210   *BITMAP_ADDR16(bitmap, y+1, x+0) = ((led_fill[value] & 0x0020) ? LED_ON : LED_OFF);
211   *BITMAP_ADDR16(bitmap, y+2, x+0) = ((led_fill[value] & 0x0020) ? LED_ON : LED_OFF);
212   *BITMAP_ADDR16(bitmap, y+3, x+0) = ((led_fill[value] & 0x0020) ? LED_ON : LED_OFF);
213   /*g*/
214   *BITMAP_ADDR16(bitmap, y+4, x+1) = ((led_fill[value] & 0x0040) ? LED_ON : LED_OFF);
215   *BITMAP_ADDR16(bitmap, y+4, x+2) = ((led_fill[value] & 0x0040) ? LED_ON : LED_OFF);
216   *BITMAP_ADDR16(bitmap, y+4, x+3) = ((led_fill[value] & 0x0040) ? LED_ON : LED_OFF);
211217}
212#endif
213static UINT16 led0;
214218
219static UINT16 led0,led1;
220
215221static VIDEO_UPDATE( acommand )
216222{
217223   tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
218224   draw_sprites(screen->machine,bitmap,cliprect,0,0);
219225   tilemap_draw(bitmap,cliprect,tx_tilemap,0,0);
220226
221   #if SHOW_LEDS
222      draw_led(bitmap, 3, 53, (led0 & 0xff00) >> 8);
223      popmessage("%04x",led0);
224   #endif
227   /*Order might be wrong,but these for sure are the led numbers tested*/
228   draw_led(bitmap,  0, 20, (led0 & 0x0f00) >> 8);
229   draw_led(bitmap,  6, 20, (led0 & 0x00f0) >> 4);
230   draw_led(bitmap, 12, 20, (led0 & 0x000f));
231
232   draw_led(bitmap, 256-18,20,(led0 & 0xf000) >> 12);
233   draw_led(bitmap, 256-12,20,(led1 & 0xf0) >> 4);
234   draw_led(bitmap, 256-6,20, (led1 & 0xf));
225235   return 0;
226236}
227237
r3514r3515
262272
263273static UINT16 *ac_devram;
264274
265
266275static READ16_HANDLER(ac_devices_r)
267276{
268//  popmessage("(PC=%06x) read at %04x",activecpu_get_pc(),offset*2);
277     logerror("(PC=%06x) read at %04x\n",activecpu_get_pc(),offset*2);
278
269279   switch(offset)
270280   {
271281      case 0x0008/2:
r3514r3515
283293            */
284294         return input_port_read(machine, "IN0");
285295      case 0x0014/2:
286         /*
287                write 0x40,read (~0x08)
288                write 0x08,read (~0x01)
289
290                ---- ---- ---- ---x Boss Door - limit switch
291            */
292         return (ac_devram[offset]);
293296      case 0x0016/2:
294297         return okim6295_status_0_r(machine,0);
295298      case 0x0018/2:
296         /*
297                ---- ---- ---- x--- Astronaut - switch
298            */
299         return ac_devram[offset];
300299      case 0x001a/2:
301300         return okim6295_status_1_r(machine,0);
302301      case 0x0040/2:
303302         /*
304                x-x- x-x- x-x- xx-- (ACTIVE HIGH?) [eori #$aaac, D0]
303                "Upper switch / Under Switch"
304                xx-x ---- xx-x xx-x
305                -x-- ---- ---- ---- Catch Switch - 3
306                --x- ---- ---- ---- Lower Switch - 3
307                ---x ---- ---- ---- Upper Switch - 3
308                ---- -x-- ---- ---- Catch Switch - 2
309                ---- --x- ---- ---- Lower Switch - 2
310                ---- ---x ---- ---- Upper Switch - 2
311                ---- ---- -x-- ---- Catch Switch - 1
312                ---- ---- --x- ---- Lower Switch - 1 (active high)
313                ---- ---- ---x ---- Upper Switch - 1 (active low)
305314                ---- ---- ---- --xx Boss Door - Motor
306315            */
307         return ac_devram[offset];
316        //22dc8
317      {
318         static UINT16 ufo_sw1;
319         ufo_sw1 = ac_devram[offset] & 3;
320         if(ac_devram[offset] & 0x10)
321            ufo_sw1|= 0x10;
322         if(ac_devram[offset] & 0x40)
323            ufo_sw1|= 0x20;
324         if(ac_devram[offset] & 0x100)
325            ufo_sw1|=0x100;
326         if(ac_devram[offset] & 0x400)
327            ufo_sw1|=0x200;
328         if(ac_devram[offset] & 0x1000)
329            ufo_sw1|=0x1000;
330         if(ac_devram[offset] & 0x4000)
331            ufo_sw1|=0x2000;
332//          if(ac_devram[0x0048/2] & 0x0001)
333//              ufo_sw1|=0x0040;
334//          if(ac_devram[0x0048/2] & 0x0004)
335//              ufo_sw1|=0x0400;
336//          if(ac_devram[0x0048/2] & 0x0100)
337//              ufo_sw1|=0x4000;
338         return ufo_sw1;
339      }
308340      case 0x0044/2:
309341         /*
310                xxxx xxxx x-x- x-x- (ACTIVE HIGH?) [eori #$ffaa, D0]
342                ---- ---- --x- ---- Lower Switch - 5
343                ---- ---- ---x ---- Upper Switch - 5
344                ---- ---- ---- --x- Lower Switch - 4 (active high)
345                ---- ---- ---- ---x Upper Switch - 4 (active low)
311346            */
347      {
348         static UINT16 ufo_sw2;
349         ufo_sw2 = 0;
350         if(ac_devram[offset] & 0x01)
351            ufo_sw2|= 1;
352         if(ac_devram[offset] & 0x04)
353            ufo_sw2|= 2;
354         if(ac_devram[offset] & 0x10)
355            ufo_sw2|=0x10;
356         if(ac_devram[offset] & 0x40)
357            ufo_sw2|=0x20;
358         return ufo_sw2;
359      }
360      case 0x0048/2:
312361         return ac_devram[offset];
313362      case 0x005c/2:
314363         /*
r3514r3515
325374   COMBINE_DATA(&ac_devram[offset]);
326375   switch(offset)
327376   {
377      case 0x00/2:
378         if (ACCESSING_BITS_0_7)
379         {
380            okim6295_set_bank_base(0, 0x40000 * (data & 0x3));
381            okim6295_set_bank_base(1, 0x40000 * (data & 0x30) >> 4);
382         }
383         break;
384      case 0x14/2:
328385      case 0x16/2:
329386         if(ACCESSING_BITS_0_7)
330         {
331            logerror("Request to play sample %02x with rom 2\n",data);
332387            okim6295_data_0_w(machine,0,data);
333         }
334388         break;
389      case 0x18/2:
335390      case 0x1a/2:
336391         if(ACCESSING_BITS_0_7)
337         {
338            logerror("Request to play sample %02x with rom 1\n",data);
339392            okim6295_data_1_w(machine,0,data);
340         }
341393         break;
342394      case 0x1c/2:
343395         /*IRQ mask?*/
r3514r3515
347399      case 0x44/2:
348400         break;
349401      case 0x48/2:
402         break;
403      case 0x50/2:
350404         led0 = ac_devram[offset];
405         //popmessage("%04x",led0);
351406         break;
407      case 0x54/2:
408         led1 = ac_devram[offset];
409         //popmessage("%04x",led0);
410         break;
352411   }
353   logerror("%04x %04x\n",offset*2,data);
354412}
355413
356414/*This is always zero ATM*/
r3514r3515
360418      popmessage("UNK-2 enabled %04x",data);
361419}
362420
363static ADDRESS_MAP_START( acommand, ADDRESS_SPACE_PROGRAM, 16 )
421static ADDRESS_MAP_START( acommand_map, ADDRESS_SPACE_PROGRAM, 16 )
364422   AM_RANGE(0x000000, 0x03ffff) AM_ROM
365423   AM_RANGE(0x082000, 0x082005) AM_WRITE(ac_bgscroll_w)
366424   AM_RANGE(0x082100, 0x082105) AM_WRITE(ac_txscroll_w)
r3514r3515
376434
377435static INPUT_PORTS_START( acommand )
378436   PORT_START("IN0")
379   PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Unknown ) )
380   PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
381   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
382   PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) )
383   PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
384   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
385   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) )
386   PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
387   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
388   PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) )
389   PORT_DIPSETTING(      0x0008, DEF_STR( Off ) )
390   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
391   PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) )
392   PORT_DIPSETTING(      0x0010, DEF_STR( Off ) )
393   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
394   PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) )
395   PORT_DIPSETTING(      0x0020, DEF_STR( Off ) )
396   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
397   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) )
437    PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_START1 )
438    PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_START2 )
439    PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_COIN1 )
440    PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_COIN2 )
441    PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_SERVICE1 )
442   PORT_SERVICE_NO_TOGGLE( 0x0020, IP_ACTIVE_LOW )
443   PORT_DIPNAME( 0x0040, 0x0040, "IN0" )
398444   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
399445   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
400446   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) )
401447   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
402448   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
403   PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Unknown ) )
404   PORT_DIPSETTING(      0x0100, DEF_STR( Off ) )
405   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
449    PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON1 )
406450   PORT_DIPNAME( 0x0200, 0x0200, DEF_STR( Unknown ) )
407451   PORT_DIPSETTING(      0x0200, DEF_STR( Off ) )
408452   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
409   PORT_DIPNAME( 0x0400, 0x0400, DEF_STR( Unknown ) )
410   PORT_DIPSETTING(      0x0400, DEF_STR( Off ) )
411   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
453    PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
412454   PORT_DIPNAME( 0x0800, 0x0800, DEF_STR( Unknown ) )
413455   PORT_DIPSETTING(      0x0800, DEF_STR( Off ) )
414456   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
415   PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) )
457   PORT_DIPNAME( 0x1000, 0x1000, "Ticket Dispenser - 1" )
416458   PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
417459   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
418   PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) )
460   PORT_DIPNAME( 0x2000, 0x2000, "Ticket Dispenser - 2")
419461   PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
420462   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
421463   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) )
r3514r3515
426468   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
427469
428470   PORT_START("IN1")
429   PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Unknown ) )
471   PORT_DIPNAME( 0x0001, 0x0001, "IN2" )
430472   PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
431473   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
432474   PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) )
r3514r3515
508550
509551static INTERRUPT_GEN( acommand_irq )
510552{
511   if (cpu_getiloops() == 0)
512      cpunum_set_input_line(machine, 0, 2, HOLD_LINE);
513   else if (cpu_getiloops() == 1)
514      cpunum_set_input_line(machine, 0, 3, HOLD_LINE);
553   switch ( cpu_getiloops() )
554   {
555      case 0:      cpunum_set_input_line(machine, 0, 3, HOLD_LINE);
556      case 1:      cpunum_set_input_line(machine, 0, 2, HOLD_LINE);
557   }
515558}
516559
517560static MACHINE_DRIVER_START( acommand )
518561
519562   /* basic machine hardware */
520563   MDRV_CPU_ADD("main",M68000,12000000)
521   MDRV_CPU_PROGRAM_MAP(acommand,0)
564   MDRV_CPU_PROGRAM_MAP(acommand_map,0)
522565   MDRV_CPU_VBLANK_INT_HACK(acommand_irq,2)
523566
524567   /* video hardware */
r3514r3515
535578   MDRV_VIDEO_UPDATE(acommand)
536579
537580   /* sound hardware */
538   MDRV_SPEAKER_STANDARD_MONO("mono")
581   MDRV_SPEAKER_STANDARD_STEREO("left", "right")
539582
540   MDRV_SOUND_ADD("oki1", OKIM6295, 2400000)
541   MDRV_SOUND_CONFIG(okim6295_interface_pin7low)
542   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
583   MDRV_SOUND_ADD("oki1", OKIM6295, 2112000)
584   MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified
585   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 1.0)
586   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 1.0)
543587
544   MDRV_SOUND_ADD("oki2", OKIM6295, 2400000)
545   MDRV_SOUND_CONFIG(okim6295_interface_pin7low)
546   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
588   MDRV_SOUND_ADD("oki2", OKIM6295, 2112000)
589   MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified
590   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 1.0)
591   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 1.0)
547592MACHINE_DRIVER_END
548593
549594/***************************************************************************
r3514r3515
573618   ROM_LOAD16_BYTE( "jalgp7.bin",   0x300000, 0x080000, CRC(44b71098) SHA1(a6ec2573f9a266d4f8f315f6e99b12525011f512) )
574619   ROM_LOAD16_BYTE( "jalgp8.bin",   0x300001, 0x080000, CRC(ce0b7838) SHA1(46e34971cb62565a3948d8c0a18086648c32e13b) )
575620
576   ROM_REGION( 0x100000, "oki2", 0 )
621   ROM_REGION( 0x100000, "oki1", 0 )   /* M6295 samples */
622   ROM_LOAD( "jalcf2.bin",   0x000000, 0x100000, CRC(b982fd97) SHA1(35ee5b1b9be762ccfefda24d73e329ceea876deb) )
623
624   ROM_REGION( 0x100000, "oki2", 0 )   /* M6295 samples */
577625   ROM_LOAD( "jalcf1.bin",   0x000000, 0x100000, CRC(24af21d3) SHA1(f68ab81a6c833b57ae9eef916a1c8578f3d893dd) )
578626
579   ROM_REGION( 0x100000, "oki1", 0 )
580   ROM_LOAD( "jalcf2.bin",   0x000000, 0x100000, CRC(b982fd97) SHA1(35ee5b1b9be762ccfefda24d73e329ceea876deb) )
581
582627   ROM_REGION( 0x100000, "user1", 0 ) /* ? these two below are identical*/
583628   ROM_LOAD( "jalmr14.bin",   0x000000, 0x080000, CRC(9d428fb7) SHA1(02f72938d73db932bd217620a175a05215f6016a) )
584629   ROM_LOAD( "jalmr17.bin",   0x080000, 0x080000, CRC(9d428fb7) SHA1(02f72938d73db932bd217620a175a05215f6016a) )
585630ROM_END
586631
587GAME( 1990, acommand,  0,       acommand,  acommand,  0, ROT0, "Jaleco", "Alien Command" , GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
632GAME( 1994, acommand,  0,       acommand,  acommand,  0, ROT0, "Jaleco", "Alien Command" , GAME_NOT_WORKING )
src/mame/drivers/jokrwild.c
r0r3515
1/******************************************************************************
2
3    JOKER'S WILD - SIGMA
4    --------------------
5
6    Preliminary driver by Roberto Fresca.
7
8
9    Games running on this hardware:
10
11    * Joker's Wild (encrypted).   1988, Sigma.
12
13
14*******************************************************************************
15
16
17    Hardware Notes (guessed):
18    ------------------------
19
20    CPU:    1x M6809
21    Video:  1x M6845 CRTC or similar.
22    I/O:    2x PIAs ?? (there is code to initialize PIAs at $8033)
23
24
25*******************************************************************************
26
27
28    *** Game Notes ***
29
30    Game is trying to boot, and after approx. 90 seconds an error message appear
31    on screen: "Random number generator is defective", then stuck here.
32
33    See code at $9859
34
35    PIAs are commented out just to see the R/W on error log.
36
37
38*******************************************************************************
39
40    --------------------
41    ***  Memory Map  ***
42    --------------------
43
44    0x0000 - 0x07FF    ; Video RAM.
45    0x2000 - 0x27FF    ; Color RAM.
46    0x4004 - 0x4007    ; PIA?.
47    0x4008 - 0x400B    ; PIA?.
48    0x6000 - 0x6001    ; M6845 CRTC.
49    0x8000 - 0xFFFF    ; ROM space.
50
51
52    *** MC6545 Initialization ***
53    ----------------------------------------------------------------------------------------------------------------------
54    register:  R00   R01   R02   R03   R04   R05   R06   R07   R08   R09   R10   R11   R12   R13   R14   R15   R16   R17
55    ----------------------------------------------------------------------------------------------------------------------
56    value:     0x20  0x18  0x1B  0x64  0x20  0x07  0x1A  0x1D  0x00  0x07  0x00  0x00  0x00  0x00  0x00  0x00  0x00  0x00.
57
58
59*******************************************************************************
60
61
62    DRIVER UPDATES:
63
64
65    [2008-10-30]
66
67    - Fixed graphics to 2 bits per pixel.
68
69
70    [2008-10-25]
71
72    - Initial release.
73    - ROMs load OK.
74    - Proper ROMs decryption.
75    - Added MC6845 CRTC.
76    - Video RAM OK.
77    - Added technical notes.
78
79
80    TODO:
81
82    - RND number generator.
83    - Inputs
84    - Sound.
85    - A lot of work.
86
87
88*******************************************************************************/
89
90
91#define MASTER_CLOCK   XTAL_8MHz   /* guess */
92
93#include "driver.h"
94#include "video/mc6845.h"
95#include "machine/6821pia.h"
96
97
98/*************************
99*     Video Hardware     *
100*************************/
101
102static tilemap *bg_tilemap;
103
104
105static WRITE8_HANDLER( jokrwild_videoram_w )
106{
107   videoram[offset] = data;
108   tilemap_mark_tile_dirty(bg_tilemap, offset);
109}
110
111
112static WRITE8_HANDLER( jokrwild_colorram_w )
113{
114   colorram[offset] = data;
115   tilemap_mark_tile_dirty(bg_tilemap, offset);
116}
117
118
119static TILE_GET_INFO( get_bg_tile_info )
120{
121/*  - bits -
122    7654 3210
123    ---- ----   bank select.
124    ---- ----   color code.
125    ---- ----   seems unused.
126*/
127//  int attr = colorram[tile_index];
128   int code = videoram[tile_index];
129//  int bank = (attr & 0x08) >> 3;
130//  int color = (attr & 0x03);
131
132   SET_TILE_INFO( 0 /* bank */, code, 0 /* color */, 0);
133}
134
135
136static VIDEO_START( jokrwild )
137{
138   bg_tilemap = tilemap_create(get_bg_tile_info, tilemap_scan_rows, 8, 8, 24, 26);
139}
140
141
142static VIDEO_UPDATE( jokrwild )
143{
144   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
145   return 0;
146}
147
148
149static PALETTE_INIT( jokrwild )
150{
151
152}
153
154
155/*************************
156*      Machine Init      *
157*************************/
158
159
160/*****************************
161*    Read/Write  Handlers    *
162*****************************/
163
164//static READ8_HANDLER( random_gen_r )
165//{
166//  return mame_rand(machine) & 0xff;
167//}
168
169
170/*************************
171* Memory Map Information *
172*************************/
173
174static ADDRESS_MAP_START( jokrwild_map, ADDRESS_SPACE_PROGRAM, 8 )
175   AM_RANGE(0x0000, 0x07ff) AM_RAM AM_WRITE(jokrwild_videoram_w) AM_BASE(&videoram)
176   AM_RANGE(0x2000, 0x27ff) AM_RAM AM_WRITE(jokrwild_colorram_w) AM_BASE(&colorram)
177//  AM_RANGE(0x0010, 0x0010) AM_READ(random_gen_r)
178//  AM_RANGE(0x4004, 0x4007) AM_READWRITE(pia_0_r, pia_0_w)
179//  AM_RANGE(0x4008, 0x400b) AM_READWRITE(pia_1_r, pia_1_w)
180//  AM_RANGE(0x4010, 0x4010) AM_READNOP /* R ???? */
181   AM_RANGE(0x6000, 0x6000) AM_DEVWRITE(MC6845, "crtc", mc6845_address_w)
182   AM_RANGE(0x6001, 0x6001) AM_DEVREADWRITE(MC6845, "crtc", mc6845_register_r, mc6845_register_w)
183//  AM_RANGE(0x6100, 0x6100) AM_READWRITENOP    /* R/W ???? */
184//  AM_RANGE(0x6200, 0x6203) another PIA?
185//  AM_RANGE(0x6300, 0x6300) unknown
186   AM_RANGE(0x8000, 0xffff) AM_ROM
187ADDRESS_MAP_END
188
189
190/* I/O byte R/W
191
192
193   -----------------
194
195   unknown writes:
196
197  4004-400b R/W  ; 2x PIAs?
198  4010      R    ; unknown.
199
200  6100      R/W  ; unknown.
201  6200-6203 R/W  ; extra PIA?
202  6300      R    ; unknown.
203
204
205*/
206
207/*************************
208*      Input Ports       *
209*************************/
210
211static INPUT_PORTS_START( jokrwild )
212   PORT_START("IN0")
213   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("0-1") PORT_CODE(KEYCODE_1)
214   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("0-2") PORT_CODE(KEYCODE_2)
215   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("0-3") PORT_CODE(KEYCODE_3)
216   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("0-4") PORT_CODE(KEYCODE_4)
217   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("0-5") PORT_CODE(KEYCODE_5)
218   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("0-6") PORT_CODE(KEYCODE_6)
219   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("0-7") PORT_CODE(KEYCODE_7)
220   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("0-8") PORT_CODE(KEYCODE_8)
221
222   PORT_START("IN1")
223   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("1-1") PORT_CODE(KEYCODE_Q)
224   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("1-2") PORT_CODE(KEYCODE_W)
225   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("1-3") PORT_CODE(KEYCODE_E)
226   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("1-4") PORT_CODE(KEYCODE_R)
227   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("1-5") PORT_CODE(KEYCODE_T)
228   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("1-6") PORT_CODE(KEYCODE_Y)
229   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("1-7") PORT_CODE(KEYCODE_U)
230   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("1-8") PORT_CODE(KEYCODE_I)
231
232   PORT_START("IN2")
233   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("2-1") PORT_CODE(KEYCODE_A)
234   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("2-2") PORT_CODE(KEYCODE_S)
235   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("2-3") PORT_CODE(KEYCODE_D)
236   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("2-4") PORT_CODE(KEYCODE_F)
237   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("2-5") PORT_CODE(KEYCODE_G)
238   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("2-6") PORT_CODE(KEYCODE_H)
239   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("2-7") PORT_CODE(KEYCODE_J)
240   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("2-8") PORT_CODE(KEYCODE_K)
241
242   PORT_START("IN3")
243   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("3-1") PORT_CODE(KEYCODE_Z)
244   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("3-2") PORT_CODE(KEYCODE_X)
245   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("3-3") PORT_CODE(KEYCODE_C)
246   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("3-4") PORT_CODE(KEYCODE_V)
247   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("3-5") PORT_CODE(KEYCODE_B)
248   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("3-6") PORT_CODE(KEYCODE_N)
249   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("3-7") PORT_CODE(KEYCODE_M)
250   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("3-8") PORT_CODE(KEYCODE_L)
251
252   PORT_START("SW1")
253   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
254   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
255   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
256   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
257   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
258   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
259   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
260   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
261   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
262   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
263   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
264   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
265   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
266   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
267   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
268   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
269   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
270   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
271   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
272   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
273   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
274   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
275   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
276   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
277INPUT_PORTS_END
278
279
280/*************************
281*    Graphics Layouts    *
282*************************/
283
284static const gfx_layout charlayout =
285{
286   8, 8,
287   0x400,   /* tiles */
288   2,      /* 2 bpp */
289   { RGN_FRAC(0,2), RGN_FRAC(1,2) },
290   { 0, 1, 2, 3, 4, 5, 6, 7 },
291   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
292   8*8   /* every char takes 8 consecutive bytes */
293};
294
295
296/******************************
297* Graphics Decode Information *
298******************************/
299
300static GFXDECODE_START( jokrwild )
301   GFXDECODE_ENTRY( "gfx1", 0, charlayout, 0, 16 )
302GFXDECODE_END
303
304
305/***********************
306*    PIA Interfaces    *
307***********************/
308
309static const pia6821_interface pia0_intf =
310{
311   /* PIA inputs: A, B, CA1, CB1, CA2, CB2 */
312   input_port_0_r, input_port_1_r, 0, 0, 0, 0,
313
314   /* PIA outputs: A, B, CA2, CB2 */
315   0, 0, 0, 0,
316
317   /* PIA IRQs: A, B */
318   0, 0
319};
320
321static const pia6821_interface pia1_intf =
322{
323   /* PIA inputs: A, B, CA1, CB1, CA2, CB2 */
324   input_port_2_r, input_port_3_r, 0, 0, 0, 0,
325
326   /* PIA outputs: A, B, CA2, CB2 */
327   0, 0, 0, 0,
328
329   /* PIA IRQs: A, B */
330   0, 0
331};
332
333/*************************
334*    Machine Drivers     *
335*************************/
336
337static MACHINE_DRIVER_START( jokrwild )
338
339   /* basic machine hardware */
340   MDRV_CPU_ADD("main", M6809, MASTER_CLOCK/8)   /* guess */
341   MDRV_CPU_PROGRAM_MAP(jokrwild_map, 0)
342   MDRV_CPU_VBLANK_INT("main", nmi_line_pulse)
343
344//  MDRV_NVRAM_HANDLER(generic_0fill)
345
346   /* video hardware */
347   MDRV_SCREEN_ADD("main", RASTER)
348   MDRV_SCREEN_REFRESH_RATE(60)
349   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
350   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
351   MDRV_SCREEN_SIZE((32+1)*8, (32+1)*8)                  /* From MC6845, registers 00 & 04. (value-1) */
352   MDRV_SCREEN_VISIBLE_AREA(0*8, 24*8-1, 0*8, 26*8-1)    /* From MC6845, registers 01 & 06 */
353
354   MDRV_GFXDECODE(jokrwild)
355   MDRV_PALETTE_INIT(jokrwild)
356   MDRV_PALETTE_LENGTH(512)
357   MDRV_VIDEO_START(jokrwild)
358   MDRV_VIDEO_UPDATE(jokrwild)
359
360   MDRV_DEVICE_ADD("crtc", MC6845)
361
362MACHINE_DRIVER_END
363
364
365/*************************
366*        Rom Load        *
367*************************/
368/*
369    One day I will write about HOW I got this dump... :)
370
371   "Only two things are infinite: The universe and human stupidity...
372    and I'm not sure about the universe."  (Albert Einstein)
373
374*/
375ROM_START( jokrwild )
376   ROM_REGION( 0x10000, "main", 0 )
377   ROM_LOAD( "jwild.7b",   0x8000, 0x4000, CRC(744cd029) SHA1(766faea330836344ffc6a1b4e1a64a679b9bf579) )
378   ROM_LOAD( "jwild.7a",   0xc000, 0x4000, CRC(ca8e4f58) SHA1(a4f682980fe562dcd8743890ce94619719cd1153) )
379
380   ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE )
381   ROM_LOAD( "jwild.2h",   0x0000, 0x0800, CRC(aed38e00) SHA1(9530078f6c22d67594606476c3698a75e052d1d6) )
382   ROM_LOAD( "jwild.2g",   0x0800, 0x0800, CRC(d635f025) SHA1(f70d5a837797e2250a7e581b96e60a704da25511) )
383   ROM_LOAD( "jwild.2f",   0x1000, 0x0800, CRC(9c1e057c) SHA1(23fd630aa20a4ffa5179d4a4fa32c6ee4b3f9c1b) )
384   ROM_LOAD( "jwild.2e",   0x1800, 0x0800, CRC(a66ae0a1) SHA1(8e6bfcb169148fdbcc36f4f35747c4805762ddd7) )
385   ROM_LOAD( "jwild.2d",   0x2000, 0x0800, CRC(76a0bcb4) SHA1(34c24ad63b1182166209074259e8f0aabe1ad331) )
386   ROM_LOAD( "jwild.2c",   0x2800, 0x0800, CRC(8d5e0b8f) SHA1(da6692d0c2074427f801b3f1861e3d03075963a2) )
387   ROM_LOAD( "jwild.2b",   0x3000, 0x0800, CRC(a264b0be) SHA1(a935dd3df8bbae9b7788d6c2a8c378fad07d2b43) )
388   ROM_LOAD( "jwild.2a",   0x3800, 0x0800, CRC(8084d0c2) SHA1(370f30f0138e2f7743a97df92379c7b879d90aed) )
389ROM_END
390
391
392/**************************
393*  Driver Initialization  *
394**************************/
395
396static DRIVER_INIT( jokrwild )
397/*****************************************************************************
398
399    Encryption was made by pages of 256 bytes.
400
401    For each page, the value is XORed with a fixed value (0xCC),
402    then XORed again with the offset of the original value inside its own page.
403
404    Example:
405
406    For encrypted value at offset 0x123A (0x89)...
407
408    0x89 XOR 0xCC XOR 0x3A = 0x7F
409
410
411*****************************************************************************/
412{
413   int i, offs;
414   UINT8 *srcp = memory_region( machine, "main" );
415
416   for (i = 0x8000; i < 0x10000; i++)
417   {
418      offs = i & 0xff;
419      srcp[i] = srcp[i] ^ 0xcc ^ offs;
420   }
421
422   /* Initializing PIAs... */
423//  pia_config(0, &pia0_intf);
424//  pia_config(1, &pia1_intf);
425}
426
427
428/*************************
429*      Game Drivers      *
430*************************/
431
432/*    YEAR  NAME      PARENT  MACHINE   INPUT     INIT      ROT    COMPANY  FULLNAME                   FLAGS */
433GAME( 1988, jokrwild, 0,      jokrwild, jokrwild, jokrwild, ROT0, "Sigma", "Joker's Wild (encrypted)", GAME_NO_SOUND | GAME_NOT_WORKING )
src/mame/drivers/macrossp.c
r3514r3515
1515- Priorities (Sprites & Backgrounds) - see quizmoon attract mode
1616- sprite/tilemap priorities might not be 100% correct
1717- Sound
18- palette fade on macrossp Banpresto logo screen (and black on some screen
19  transitions). quizmoon doesn't use that register.
18- optimize palette fading in macrossp.quizmoon doesn't use that register.
2019- All Other Unused Reads / Writes
2120- Correct unknown ports if/as needed
2221- Clean Up
r3514r3515
369368   return soundlatch_word_r(machine,offset,mem_mask);
370369}
371370
371static INT32 fade_effect,old_fade;
372372
373static void update_colors(running_machine *machine)
374{
375   static int i,r,g,b;
376
377   for(i=0;i<0x1000;i++)
378   {
379      b = ((paletteram32[i] & 0x0000ff00) >> 8);
380      if(fade_effect > b) { b = 0; }
381      else            { b-=fade_effect; }
382      g = ((paletteram32[i] & 0x00ff0000) >>16);
383      if(fade_effect > g) { g = 0; }
384      else             { g-=fade_effect; }
385      r = ((paletteram32[i] & 0xff000000) >>24);
386      if(fade_effect > r) { r = 0; }
387      else            { r-=fade_effect; }
388
389      palette_set_color(machine,i,MAKE_RGB(r,g,b));
390   }
391}
392
393static WRITE32_HANDLER( macrossp_palette_fade_w )
394{
395   fade_effect = ((data & 0xff00) >> 8) - 0x28;//it writes two times,first with a -0x28 then with the proper data
396//  popmessage("%02x",fade_effect);
397   if(old_fade != fade_effect)
398   {
399      old_fade = fade_effect;
400      update_colors(machine);
401   }
402}
403
373404/*** MEMORY MAPS *************************************************************/
374405
375406static ADDRESS_MAP_START( readmem, ADDRESS_SPACE_PROGRAM, 32 )
r3514r3515
416447
417448   AM_RANGE(0xa00000, 0xa03fff) AM_WRITE(paletteram32_macrossp_w) AM_BASE(&paletteram32)
418449
419   AM_RANGE(0xb00004, 0xb00007) AM_WRITE(SMH_NOP)   // ????
420   AM_RANGE(0xb00008, 0xb0000b) AM_WRITE(SMH_NOP)   // ????
421//  AM_RANGE(0xb0000c, 0xb0000f) AM_WRITE(SMH_NOP)
422   AM_RANGE(0xb00010, 0xb00013) AM_WRITE(SMH_RAM)   // macrossp palette fade
423//  AM_RANGE(0xb00020, 0xb00023) AM_WRITE(SMH_NOP)
450   AM_RANGE(0xb00004, 0xb00007) AM_WRITE(SMH_NOP)   // irq related?
451   AM_RANGE(0xb00008, 0xb0000b) AM_WRITE(SMH_NOP)   // irq related?
452   AM_RANGE(0xb0000c, 0xb0000f) AM_WRITE(SMH_NOP)
453   AM_RANGE(0xb00010, 0xb00013) AM_WRITE(macrossp_palette_fade_w)   // macrossp palette fade
454     AM_RANGE(0xb00020, 0xb00023) AM_WRITE(SMH_NOP)
424455
425456   AM_RANGE(0xc00000, 0xc00003) AM_WRITE(macrossp_soundcmd_w)
426457
r3514r3515
750781   if (activecpu_get_pc()==0x001810A) cpu_spinuntil_int();
751782}
752783
784#ifdef UNUSED_FUNCTION
785static WRITE32_HANDLER( quizmoon_speedup_w )
786{
787   COMBINE_DATA(&macrossp_mainram[0x00020/4]);
788   if (activecpu_get_pc()==0x1cc) cpu_spinuntil_int();
789}
790#endif
791
753792static DRIVER_INIT( macrossp )
754793{
755794   memory_install_write32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xf10158, 0xf1015b, 0, 0, macrossp_speedup_w );
r3514r3515
757796
758797static DRIVER_INIT( quizmoon )
759798{
799#ifdef UNUSED_FUNCTION
800   memory_install_write32_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xf00020, 0xf00023, 0, 0, quizmoon_speedup_w );
801#endif
760802}
761803
762804GAME( 1996, macrossp, 0, macrossp, macrossp, macrossp, ROT270, "Banpresto", "Macross Plus", GAME_IMPERFECT_GRAPHICS )
src/mame/drivers/gyruss.c
r3514r3515
1313memory mapped ports:
1414
1515read:
16c080      IN0
16c080      IN0  (system inputs)
1717c0a0      IN1
1818c0c0      IN2
19c0e0      DSW0
20c000      DSW1
21c100      DSW2
19c0e0      DSW1
20c000      DSW2
21c100      DSW3
2222
2323write:
2424a000-a1ff  Odd frame spriteram
r3514r3515
221221   PORT_BIT( 0xe0, IP_ACTIVE_LOW, IPT_UNUSED )
222222
223223   PORT_START("P1")
224   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY
224   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY
225225   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_2WAY
226   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_2WAY
227   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_2WAY
226   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )    PORT_2WAY
227   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )  PORT_2WAY
228228   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
229229   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* 1p shoot 2 - unused */
230   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* 2p shoot 3 - unused */
230   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
231231   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
232232
233233   PORT_START("P2")
234   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_COCKTAIL
234   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_COCKTAIL
235235   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_COCKTAIL
236   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_2WAY PORT_COCKTAIL
237   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_2WAY PORT_COCKTAIL
236   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )    PORT_2WAY PORT_COCKTAIL
237   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )  PORT_2WAY PORT_COCKTAIL
238238   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
239239   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* 2p shoot 2 - unused */
240   PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
240   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
241241
242   PORT_START("DSW1")
242   PORT_START("DSW1")   /* 8P Dip Switch */
243243   PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) )
244244   PORT_DIPSETTING(    0x20, DEF_STR( 4C_1C ) )
245245   PORT_DIPSETTING(    0x50, DEF_STR( 3C_1C ) )
r3514r3515
275275   PORT_DIPSETTING(    0x09, DEF_STR( 1C_7C ) )
276276   PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )
277277
278   PORT_START("DSW2")
278   PORT_START("DSW2")   /* 8P Dip Switch */
279279   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )
280280   PORT_DIPSETTING(    0x03, "3" )
281281   PORT_DIPSETTING(    0x02, "4" )
r3514r3515
284284   PORT_DIPNAME( 0x04, 0x00, DEF_STR( Cabinet ) )
285285   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
286286   PORT_DIPSETTING(    0x04, DEF_STR( Cocktail ) )
287   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Bonus_Life ) )
288   PORT_DIPSETTING(    0x08, "30000 60000" )
289   PORT_DIPSETTING(    0x00, "40000 70000" )
290   PORT_DIPNAME( 0x70, 0x70, DEF_STR( Difficulty ) )
287   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Bonus_Life ) )       /* tables at 0x1653 (15 bytes) or 0x4bf3 (13 bytes) */
288   PORT_DIPSETTING(    0x08, "30k 90k 60k+" )              /* last bonus life at 810k : max. 14 bonus lives */
289   PORT_DIPSETTING(    0x00, "40k 110k 70k+" )             /* last bonus life at 810k : max. 12 bonus lives */
290   PORT_DIPNAME( 0x70, 0x30, DEF_STR( Difficulty ) )
291291   PORT_DIPSETTING(    0x70, "1 (Easiest)" )
292292   PORT_DIPSETTING(    0x60, "2" )
293293   PORT_DIPSETTING(    0x50, "3" )
r3514r3515
300300   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
301301   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
302302
303   PORT_START("DSW3")
303   PORT_START("DSW3")   /* 1P Dip Switch */
304304   PORT_DIPNAME( 0x01, 0x00, "Demo Music" )
305305   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
306306   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
307   /* other bits probably unused */
308307INPUT_PORTS_END
309308
310/* This is identical to gyruss except for the bonus that has different
311   values */
312309static INPUT_PORTS_START( gyrussce )
313310   PORT_INCLUDE( gyruss )
314311
315   PORT_MODIFY("DSW1")
316   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Bonus_Life ) )
317   PORT_DIPSETTING(    0x08, "50000 70000" )
318   PORT_DIPSETTING(    0x00, "60000 80000" )
312   PORT_MODIFY("DSW2")
313   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Bonus_Life ) )       /* tables at 0x1653 (15 bytes) or 0x4bf3 (13 bytes) */
314   PORT_DIPSETTING(    0x08, "50k 120k 70k+" )             /* last bonus life at 960k : max. 14 bonus lives */
315   PORT_DIPSETTING(    0x00, "60k 140k 80k+" )             /* last bonus life at 940k : max. 12 bonus lives */
316   PORT_DIPNAME( 0x70, 0x20, DEF_STR( Difficulty ) )       /* "Difficult" default setting according to Centuri manual */
317   PORT_DIPSETTING(    0x70, "1 (Easiest)" )
318   PORT_DIPSETTING(    0x60, "2" )
319   PORT_DIPSETTING(    0x50, "3" )
320   PORT_DIPSETTING(    0x40, "4" )
321   PORT_DIPSETTING(    0x30, "5 (Average)" )
322   PORT_DIPSETTING(    0x20, "6" )
323   PORT_DIPSETTING(    0x10, "7" )
324   PORT_DIPSETTING(    0x00, "8 (Hardest)" )
319325INPUT_PORTS_END
320326
321327
r3514r3515
682688}
683689
684690
685GAME( 1983, gyruss,   0,      gyruss, gyruss,   gyruss, ROT90, "Konami", "Gyruss (Konami)", GAME_SUPPORTS_SAVE )
686GAME( 1983, gyrussce, gyruss, gyruss, gyrussce, gyruss, ROT90, "Konami (Centuri license)", "Gyruss (Centuri)", GAME_SUPPORTS_SAVE )
687GAME( 1983, venus,    gyruss, gyruss, gyrussce, gyruss, ROT90, "bootleg", "Venus", GAME_SUPPORTS_SAVE )
691GAME( 1983, gyruss,   0,        gyruss,   gyruss,   gyruss, ROT90, "Konami", "Gyruss (Konami)", GAME_SUPPORTS_SAVE )
692GAME( 1983, gyrussce, gyruss,   gyruss,   gyrussce, gyruss, ROT90, "Konami (Centuri license)", "Gyruss (Centuri)", GAME_SUPPORTS_SAVE )
693GAME( 1983, venus,    gyruss,   gyruss,   gyruss,   gyruss, ROT90, "bootleg", "Venus", GAME_SUPPORTS_SAVE )
src/mame/drivers/hotblock.c
r3514r3515
124124
125125   int y,x,count;
126126   int i;
127   static int xxx=320,yyy=204;
127   static const int xxx=320,yyy=204;
128128
129129   fillbitmap(bitmap, get_black_pen(screen->machine), 0);
130130
src/mame/drivers/twin16.c
r3514r3515
1818
1919Known Issues:
2020    - some rogue sprites in Devil World
21    - sprite-background priority isn't correct (see intro screen of Devil World)
21    - sprite-background priority is guessed
2222
232368000 Memory Map for Konami Twin System
2424
r3514r3515
6868extern VIDEO_START( fround );
6969extern VIDEO_UPDATE( twin16 );
7070extern VIDEO_EOF( twin16 );
71extern VIDEO_UPDATE( vulcan );
7271
7372
7473extern void twin16_spriteram_process( void );
r3514r3515
9897
9998enum
10099{
101   CPU_SOUND,
100   CPU_A,
102101   CPU_B,
103   CPU_A
102   CPU_SOUND
104103};
105104
106105
r3514r3515
210209   if( twin16_CPUA_register!=old )
211210   {
212211      if( (old&0x08)==0 && (twin16_CPUA_register&0x08) )
213         cpunum_set_input_line_and_vector(machine, CPU_SOUND, 0, HOLD_LINE, 0xff ); // trigger IRQ on sound CPU
212         cpunum_set_input_line_and_vector(machine, 1, 0, HOLD_LINE, 0xff ); // trigger IRQ on sound CPU
214213   }
215214}
216215
r3514r3515
907906
908907static MACHINE_DRIVER_START( twin16 )
909908   // basic machine hardware
910   MDRV_CPU_ADD("audio", Z80, 3579545)
911   MDRV_CPU_PROGRAM_MAP(sound_map,0)
909   MDRV_CPU_ADD("main", M68000, XTAL_18_432MHz/2)
910   MDRV_CPU_PROGRAM_MAP(main_map,0)
911   MDRV_CPU_VBLANK_INT("main", CPUA_interrupt)
912912
913913   MDRV_CPU_ADD("sub", M68000, XTAL_18_432MHz/2)
914914   MDRV_CPU_PROGRAM_MAP(sub_map,0)
915915   MDRV_CPU_VBLANK_INT("main", CPUB_interrupt)
916916
917   MDRV_CPU_ADD("main", M68000, XTAL_18_432MHz/2)
918   MDRV_CPU_PROGRAM_MAP(main_map,0)
919   MDRV_CPU_VBLANK_INT("main", CPUA_interrupt)
917   MDRV_CPU_ADD("audio", Z80, 3579545)
918   MDRV_CPU_PROGRAM_MAP(sound_map,0)
920919
921920   MDRV_INTERLEAVE(100)
922921
r3514r3515
956955   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 0.20)
957956MACHINE_DRIVER_END
958957
959static MACHINE_DRIVER_START( heavysync )
958static MACHINE_DRIVER_START( devilw )
960959   MDRV_IMPORT_FROM(twin16)
961960   MDRV_INTERLEAVE(1000)
962961MACHINE_DRIVER_END
963962
964963static MACHINE_DRIVER_START( fround )
965964   /* basic machine hardware */
966   MDRV_CPU_ADD("audio", Z80, 3579545)
967   MDRV_CPU_PROGRAM_MAP(sound_map,0)
968
969965   MDRV_CPU_ADD("main", M68000, 10000000)
970966   MDRV_CPU_PROGRAM_MAP(fround_map,0)
971967   MDRV_CPU_VBLANK_INT("main", CPUA_interrupt)
972968
969   MDRV_CPU_ADD("audio", Z80, 3579545)
970   MDRV_CPU_PROGRAM_MAP(sound_map,0)
971
973972   MDRV_INTERLEAVE(100)
974973
975974   /* video hardware */
r3514r3515
10131012   MDRV_VIDEO_START(fround)
10141013MACHINE_DRIVER_END
10151014
1016static MACHINE_DRIVER_START( mia )
1015static MACHINE_DRIVER_START( miaj )
10171016   MDRV_IMPORT_FROM(twin16)
10181017   MDRV_SCREEN_MODIFY("main")
10191018   MDRV_SCREEN_VISIBLE_AREA(1*8, 39*8-1, 2*8, 30*8-1)
10201019   MDRV_VIDEO_START(fround)
1021
10221020MACHINE_DRIVER_END
10231021
1024static MACHINE_DRIVER_START( vulcan )
1025   MDRV_IMPORT_FROM(twin16)
1026   MDRV_VIDEO_UPDATE(vulcan )
1027MACHINE_DRIVER_END
1028
10291022static MACHINE_DRIVER_START( cuebrckj )
10301023   MDRV_IMPORT_FROM(twin16)
10311024   MDRV_SCREEN_MODIFY("main")
r3514r3515
10371030/* ROMs */
10381031
10391032ROM_START( devilw )
1040   ROM_REGION( 0x10000, "audio", 0 )   // Z80 code (sound CPU)
1041   ROM_LOAD( "687_l03.10a",      0x00000,  0x8000, CRC(7201983c) SHA1(06d089406d2f702e8d51ffdfbf34e4727a28d506) )
1033   ROM_REGION( 0x40000, "main", 0 )   // 68000 code (CPU A)
1034   ROM_LOAD16_BYTE( "687_t05.6n",   0x00000, 0x10000, CRC(8ab7dc61) SHA1(de8e93f04f22fa07ea6c379eeae12f8fcb48f751) )
1035   ROM_LOAD16_BYTE( "687_t04.4n",   0x00001, 0x10000, CRC(c69924da) SHA1(9b7220eac95fd92f32fec92b21f4f02f871c5d43) )
1036   ROM_LOAD16_BYTE( "687_t09.6r",   0x20000, 0x10000, CRC(fae97de0) SHA1(25b085c9de0943a0112d76447ca0504ed57cad85) )
1037   ROM_LOAD16_BYTE( "687_t08.4r",   0x20001, 0x10000, CRC(8c898d67) SHA1(0dd1a4467f97c993ea8d40398f46c3fc88c889bd) )
10421038
10431039   ROM_REGION( 0x40000, "sub", 0 )   // 68000 code (CPU B)
10441040   ROM_LOAD16_BYTE( "687_q07.10n",   0x00000, 0x10000, CRC(53110c0b) SHA1(a473486f7c99ab758187376d5bd89581e0b7cbdf) )
r3514r3515
10461042   ROM_LOAD16_BYTE( "687_q13.10s",   0x20000, 0x10000, CRC(36ae6014) SHA1(102d4c3215fb5f199ce6f93ce92725b5cce0b01d) )
10471043   ROM_LOAD16_BYTE( "687_q12.8s",   0x20001, 0x10000, CRC(6d012167) SHA1(d608e29e0b2e834c099386b6ebb667e4bfc40ce7) )
10481044
1049   ROM_REGION( 0x40000, "main", 0 )   // 68000 code (CPU A)
1050   ROM_LOAD16_BYTE( "687_t05.6n",   0x00000, 0x10000, CRC(8ab7dc61) SHA1(de8e93f04f22fa07ea6c379eeae12f8fcb48f751) )
1051   ROM_LOAD16_BYTE( "687_t04.4n",   0x00001, 0x10000, CRC(c69924da) SHA1(9b7220eac95fd92f32fec92b21f4f02f871c5d43) )
1052   ROM_LOAD16_BYTE( "687_t09.6r",   0x20000, 0x10000, CRC(fae97de0) SHA1(25b085c9de0943a0112d76447ca0504ed57cad85) )
1053   ROM_LOAD16_BYTE( "687_t08.4r",   0x20001, 0x10000, CRC(8c898d67) SHA1(0dd1a4467f97c993ea8d40398f46c3fc88c889bd) )
1045   ROM_REGION( 0x10000, "audio", 0 )   // Z80 code (sound CPU)
1046   ROM_LOAD( "687_l03.10a",      0x00000,  0x8000, CRC(7201983c) SHA1(06d089406d2f702e8d51ffdfbf34e4727a28d506) )
10541047
10551048   ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE )
10561049   ROM_LOAD( "687_m14.d8",         0x00000,  0x4000, CRC(d7338557) SHA1(9b384baafabaab3888a0139674f0b530303684ca) ) // characters
r3514r3515
10651058   ROM_LOAD16_BYTE( "687_l11.10r",   0x00000, 0x10000, CRC(399deee8) SHA1(dcc65e95f28ae4e9b671e70ce0bd5ba0fe178506) )
10661059   ROM_LOAD16_BYTE( "687_l10.8r",   0x00001, 0x10000, CRC(117c91ee) SHA1(dcf8efb25fc73cff916b66b7bcfd3c1fb2556a53) )
10671060
1068   ROM_REGION( 0x20000, "konami", 0 ) // samples
1061   ROM_REGION( 0x20000, "konami", 0 )    // samples
10691062   ROM_LOAD( "687_i01.5a",         0x00000, 0x20000, CRC(d4992dfb) SHA1(c65bef07b6adb9ab6328d679595450945dbf6a88) )
10701063
1071   ROM_REGION( 0x20000, "upd", 0 ) // samples
1064   ROM_REGION( 0x20000, "upd", 0 )    // samples
10721065   ROM_LOAD( "687_i02.7c",         0x00000, 0x20000, CRC(e5947501) SHA1(9ec7319bd97711981db60af6f477c2ba2ec7e6b8) )
10731066ROM_END
10741067
10751068ROM_START( majuu )
1076   ROM_REGION( 0x10000, "audio", 0 )   // Z80 code (sound CPU)
1077   ROM_LOAD( "687_l03.10a",      0x00000,  0x8000, CRC(7201983c) SHA1(06d089406d2f702e8d51ffdfbf34e4727a28d506) )
1069   ROM_REGION( 0x40000, "main", 0 )   // 68000 code (CPU A)
1070   ROM_LOAD16_BYTE( "687_s05.6n",   0x00000, 0x10000, CRC(bd99b434) SHA1(4dbcf3a57ff0b4c3a160e2a60c2ee3fd38f5a95d) )
1071   ROM_LOAD16_BYTE( "687_s04.4n",   0x00001, 0x10000, CRC(3df732e2) SHA1(32e42edbc6f9dfba6ff881c72b8b014b6905e7f3) )
1072   ROM_LOAD16_BYTE( "687_s09.6r",   0x20000, 0x10000, CRC(1f6efec3) SHA1(4177d300877e3ffcb481f534ef7b3e4bdc160be0) )
1073   ROM_LOAD16_BYTE( "687_s08.4r",   0x20001, 0x10000, CRC(8a16c8c6) SHA1(df3af1c137632eab98b1eea538cc4ef5b134f44f) )
10781074
10791075   ROM_REGION( 0x40000, "sub", 0 )   // 68000 code (CPU B)
10801076   ROM_LOAD16_BYTE( "687_q07.10n",   0x00000, 0x10000, CRC(53110c0b) SHA1(a473486f7c99ab758187376d5bd89581e0b7cbdf) )
r3514r3515
10821078   ROM_LOAD16_BYTE( "687_q13.10s",   0x20000, 0x10000, CRC(36ae6014) SHA1(102d4c3215fb5f199ce6f93ce92725b5cce0b01d) )
10831079   ROM_LOAD16_BYTE( "687_q12.8s",   0x20001, 0x10000, CRC(6d012167) SHA1(d608e29e0b2e834c099386b6ebb667e4bfc40ce7) )
10841080
1085   ROM_REGION( 0x40000, "main", 0 )   // 68000 code (CPU A)
1086   ROM_LOAD16_BYTE( "687_s05.6n",   0x00000, 0x10000, CRC(bd99b434) SHA1(4dbcf3a57ff0b4c3a160e2a60c2ee3fd38f5a95d) )
1087   ROM_LOAD16_BYTE( "687_s04.4n",   0x00001, 0x10000, CRC(3df732e2) SHA1(32e42edbc6f9dfba6ff881c72b8b014b6905e7f3) )
1088   ROM_LOAD16_BYTE( "687_s09.6r",   0x20000, 0x10000, CRC(1f6efec3) SHA1(4177d300877e3ffcb481f534ef7b3e4bdc160be0) )
1089   ROM_LOAD16_BYTE( "687_s08.4r",   0x20001, 0x10000, CRC(8a16c8c6) SHA1(df3af1c137632eab98b1eea538cc4ef5b134f44f) )
1081   ROM_REGION( 0x10000, "audio", 0 )   // Z80 code (sound CPU)
1082   ROM_LOAD( "687_l03.10a",      0x00000,  0x8000, CRC(7201983c) SHA1(06d089406d2f702e8d51ffdfbf34e4727a28d506) )
10901083
10911084   ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE )
10921085   ROM_LOAD( "687_l14.d8",         0x00000,  0x4000, CRC(20ecccd6) SHA1(b8ac3186de5ea81ae1c64b9511b7a0718aabab48) ) // characters
r3514r3515
11011094   ROM_LOAD16_BYTE( "687_l11.10r",   0x00000, 0x10000, CRC(399deee8) SHA1(dcc65e95f28ae4e9b671e70ce0bd5ba0fe178506) )
11021095   ROM_LOAD16_BYTE( "687_l10.8r",   0x00001, 0x10000, CRC(117c91ee) SHA1(dcf8efb25fc73cff916b66b7bcfd3c1fb2556a53) )
11031096
1104   ROM_REGION( 0x20000, "konami", 0 ) // samples
1097   ROM_REGION( 0x20000, "konami", 0 )    // samples
11051098   ROM_LOAD( "687_i01.5a",         0x00000, 0x20000, CRC(d4992dfb) SHA1(c65bef07b6adb9ab6328d679595450945dbf6a88) )
11061099
1107   ROM_REGION( 0x20000, "upd", 0 ) // samples
1100   ROM_REGION( 0x20000, "upd", 0 )    // samples
11081101   ROM_LOAD( "687_i02.7c",         0x00000, 0x20000, CRC(e5947501) SHA1(9ec7319bd97711981db60af6f477c2ba2ec7e6b8) )
11091102ROM_END
11101103
11111104ROM_START( darkadv )
1112   ROM_REGION( 0x10000, "audio", 0 )   // Z80 code (sound CPU)
1113   ROM_LOAD( "687_n03.10a",      0x00000,  0x8000, CRC(a24c682f) SHA1(cf053270d3f77448ff802db832598ae3cf7dae6c) )
1105   ROM_REGION( 0x40000, "main", 0 )   // 68000 code (CPU A)
1106   ROM_LOAD16_BYTE( "687_n05.6n",   0x00000, 0x10000, CRC(a9195b0b) SHA1(a5b30c93dc962b5aef33bab7e257ed606f00c9f2) )
1107   ROM_LOAD16_BYTE( "687_n04.4n",   0x00001, 0x10000, CRC(65b55105) SHA1(ef102eebf34cceebafb55b04003ab9173af43458) )
1108   ROM_LOAD16_BYTE( "687_n09.6r",   0x20000, 0x10000, CRC(1c6b594c) SHA1(06e4eab7f544170ac40e8c77b9ebb236a6094367) )
1109   ROM_LOAD16_BYTE( "687_n08.4r",   0x20001, 0x10000, CRC(a9603196) SHA1(a3ab00a446531d370809d8e405cabe2d74cb612b) )
11141110
11151111   ROM_REGION( 0x40000, "sub", 0 )   // 68000 code (CPU B)
11161112   ROM_LOAD16_BYTE( "687_n07.10n",   0x00000, 0x10000, CRC(6154322a) SHA1(e84c75b4d346ade2cfb5d56454282fafb04c2d77) )
r3514r3515
11181114   ROM_LOAD16_BYTE( "687_n13.10s",   0x20000, 0x10000, CRC(f1c252af) SHA1(dbe78352ae5b284870becc92139773f66c52ed7d) )
11191115   ROM_LOAD16_BYTE( "687_n12.8s",   0x20001, 0x10000, CRC(da221944) SHA1(c288ee583414a077f0d8b815b8e01b7f19a5fafe) )
11201116
1121   ROM_REGION( 0x40000, "main", 0 )   // 68000 code (CPU A)
1122   ROM_LOAD16_BYTE( "687_n05.6n",   0x00000, 0x10000, CRC(a9195b0b) SHA1(a5b30c93dc962b5aef33bab7e257ed606f00c9f2) )
1123   ROM_LOAD16_BYTE( "687_n04.4n",   0x00001, 0x10000, CRC(65b55105) SHA1(ef102eebf34cceebafb55b04003ab9173af43458) )
1124   ROM_LOAD16_BYTE( "687_n09.6r",   0x20000, 0x10000, CRC(1c6b594c) SHA1(06e4eab7f544170ac40e8c77b9ebb236a6094367) )
1125   ROM_LOAD16_BYTE( "687_n08.4r",   0x20001, 0x10000, CRC(a9603196) SHA1(a3ab00a446531d370809d8e405cabe2d74cb612b) )
1117   ROM_REGION( 0x10000, "audio", 0 )   // Z80 code (sound CPU)
1118   ROM_LOAD( "687_n03.10a",      0x00000,  0x8000, CRC(a24c682f) SHA1(cf053270d3f77448ff802db832598ae3cf7dae6c) )
11261119
11271120   ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE )
11281121   ROM_LOAD( "687_n14.d8",   0x0000,  0x4000, CRC(c76ac6d2) SHA1(d8fec255f1f7177a3716a5894fb679cbe172b6ea) ) // characters
r3514r3515
11371130   ROM_LOAD16_BYTE( "687_l11.10r",   0x00000, 0x10000, CRC(399deee8) SHA1(dcc65e95f28ae4e9b671e70ce0bd5ba0fe178506) )
11381131   ROM_LOAD16_BYTE( "687_l10.8r",   0x00001, 0x10000, CRC(117c91ee) SHA1(dcf8efb25fc73cff916b66b7bcfd3c1fb2556a53) )
11391132
1140   ROM_REGION( 0x20000, "konami", 0 ) // samples
1133   ROM_REGION( 0x20000, "konami", 0 )    // samples
11411134   ROM_LOAD( "687_i01.5a",         0x00000, 0x20000, CRC(d4992dfb) SHA1(c65bef07b6adb9ab6328d679595450945dbf6a88) )
11421135
1143   ROM_REGION( 0x20000, "upd", 0 ) // samples
1136   ROM_REGION( 0x20000, "upd", 0 )    // samples
11441137   ROM_LOAD( "687_i02.7c",         0x00000, 0x20000, CRC(e5947501) SHA1(9ec7319bd97711981db60af6f477c2ba2ec7e6b8) )
11451138ROM_END
11461139
11471140ROM_START( vulcan )
1148   ROM_REGION( 0x10000, "audio", 0 )   // Z80 code (sound CPU)
1149   ROM_LOAD( "785_g03.10a",      0x00000,  0x8000, CRC(67a3b50d) SHA1(3c83f3b0df73d9361ec3cda26a6c4c603a088419) )
1141   ROM_REGION( 0x40000, "main", 0 )   // 68000 code (CPU A)
1142   ROM_LOAD16_BYTE( "785_w05.6n",   0x00000, 0x10000, CRC(6e0e99cd) SHA1(f9f4ef617aee83397b0ac98a5cc92f60d3a3d5ed) )
1143   ROM_LOAD16_BYTE( "785_w04.4n",   0x00001, 0x10000, CRC(23ec74ca) SHA1(901c7c798b113232f20e24f61940ed6ef5148599) )
1144   ROM_LOAD16_BYTE( "785_w09.6r",   0x20000, 0x10000, CRC(377e4f28) SHA1(d3af2e52c38b5d618cac2e66df99ab7950638fbc) )
1145   ROM_LOAD16_BYTE( "785_w08.4r",   0x20001, 0x10000, CRC(813d41ea) SHA1(58ba0e4b1afec3e5674286c44da14244591f1312) )
11501146
11511147   ROM_REGION( 0x40000, "sub", 0 )   // 68000 code (CPU B)
11521148   ROM_LOAD16_BYTE( "785_p07.10n",   0x00000, 0x10000, CRC(686d549d) SHA1(9687be801c4fb963bf6b0199e2ae9f5051213f7a) )
r3514r3515
11541150   ROM_LOAD16_BYTE( "785_p13.10s",   0x20000, 0x10000, CRC(478fdb0a) SHA1(2e285ad6dcfc67f3e24d231e0e1be19036ce64d2) )
11551151   ROM_LOAD16_BYTE( "785_p12.8s",   0x20001, 0x10000, CRC(38ea402a) SHA1(90ff2bd71435988cde967704ce3b1401de206683) )
11561152
1157   ROM_REGION( 0x40000, "main", 0 )   // 68000 code (CPU A)
1158   ROM_LOAD16_BYTE( "785_w05.6n",   0x00000, 0x10000, CRC(6e0e99cd) SHA1(f9f4ef617aee83397b0ac98a5cc92f60d3a3d5ed) )
1159   ROM_LOAD16_BYTE( "785_w04.4n",   0x00001, 0x10000, CRC(23ec74ca) SHA1(901c7c798b113232f20e24f61940ed6ef5148599) )
1160   ROM_LOAD16_BYTE( "785_w09.6r",   0x20000, 0x10000, CRC(377e4f28) SHA1(d3af2e52c38b5d618cac2e66df99ab7950638fbc) )
1161   ROM_LOAD16_BYTE( "785_w08.4r",   0x20001, 0x10000, CRC(813d41ea) SHA1(58ba0e4b1afec3e5674286c44da14244591f1312) )
1153   ROM_REGION( 0x10000, "audio", 0 )   // Z80 code (sound CPU)
1154   ROM_LOAD( "785_g03.10a",      0x00000,  0x8000, CRC(67a3b50d) SHA1(3c83f3b0df73d9361ec3cda26a6c4c603a088419) )
11621155
11631156   ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE )
11641157   ROM_LOAD( "785_h14.d8",         0x0000,   0x4000, CRC(02f4b16f) SHA1(45addc99f520770f38c6aa69aef9af59cfc410b5) ) // characters
r3514r3515
11711164
11721165   ROM_REGION( 0x20000, "gfx3", ROMREGION_ERASE00 )   // tile data; mapped at 0x80000 on CPUB
11731166
1174   ROM_REGION( 0x20000, "konami", 0 ) // samples
1167   ROM_REGION( 0x20000, "konami", 0 )    // samples
11751168   ROM_LOAD( "785_f01.5a",         0x00000, 0x20000, CRC(a0d8d69e) SHA1(2994e5740b7c099d55fb162a363a26ef1995c756) )
11761169
1177   ROM_REGION( 0x20000, "upd", 0 ) // samples
1170   ROM_REGION( 0x20000, "upd", 0 )    // samples
11781171   ROM_LOAD( "785_f02.7c",         0x00000, 0x20000, CRC(c39f5ca4) SHA1(92ebea11b7d3a72d0f58c456f16a6ff36d6b3062) )
11791172ROM_END
11801173
11811174ROM_START( gradius2 )
1182   ROM_REGION( 0x10000, "audio", 0 )   // Z80 code (sound CPU)
1183   ROM_LOAD( "785_g03.10a",      0x00000,  0x8000, CRC(67a3b50d) SHA1(3c83f3b0df73d9361ec3cda26a6c4c603a088419) )
1175   ROM_REGION( 0x40000, "main", 0 )   // 68000 code (CPU A)
1176   ROM_LOAD16_BYTE( "785_x05.6n",   0x00000, 0x10000, CRC(8a23a7b8) SHA1(9846272c011715b17f146d5265a09e790d6e37cd) )
1177   ROM_LOAD16_BYTE( "785_x04.4n",   0x00001, 0x10000, CRC(88e466ce) SHA1(3a7d098b851bcf6dc8e7ff601d11563406c56666) )
1178   ROM_LOAD16_BYTE( "785_x09.6r",   0x20000, 0x10000, CRC(3f3d7d7a) SHA1(8e3acf980179e749ec642b6ff211c4ba57c6c592) )
1179   ROM_LOAD16_BYTE( "785_x08.4r",   0x20001, 0x10000, CRC(c39c8efd) SHA1(372dbb254525a7334fe79a42ba9851eafa856847) )
11841180
11851181   ROM_REGION( 0x40000, "sub", 0 )   // 68000 code (CPU B)
11861182   ROM_LOAD16_BYTE( "785_p07.10n",   0x00000, 0x10000, CRC(686d549d) SHA1(9687be801c4fb963bf6b0199e2ae9f5051213f7a) )
r3514r3515
11881184   ROM_LOAD16_BYTE( "785_p13.10s",   0x20000, 0x10000, CRC(478fdb0a) SHA1(2e285ad6dcfc67f3e24d231e0e1be19036ce64d2) )
11891185   ROM_LOAD16_BYTE( "785_p12.8s",   0x20001, 0x10000, CRC(38ea402a) SHA1(90ff2bd71435988cde967704ce3b1401de206683) )
11901186
1191   ROM_REGION( 0x40000, "main", 0 )   // 68000 code (CPU A)
1192   ROM_LOAD16_BYTE( "785_x05.6n",   0x00000, 0x10000, CRC(8a23a7b8) SHA1(9846272c011715b17f146d5265a09e790d6e37cd) )
1193   ROM_LOAD16_BYTE( "785_x04.4n",   0x00001, 0x10000, CRC(88e466ce) SHA1(3a7d098b851bcf6dc8e7ff601d11563406c56666) )
1194   ROM_LOAD16_BYTE( "785_x09.6r",   0x20000, 0x10000, CRC(3f3d7d7a) SHA1(8e3acf980179e749ec642b6ff211c4ba57c6c592) )
1195   ROM_LOAD16_BYTE( "785_x08.4r",   0x20001, 0x10000, CRC(c39c8efd) SHA1(372dbb254525a7334fe79a42ba9851eafa856847) )
1187   ROM_REGION( 0x10000, "audio", 0 )   // Z80 code (sound CPU)
1188   ROM_LOAD( "785_g03.10a",      0x00000,  0x8000, CRC(67a3b50d) SHA1(3c83f3b0df73d9361ec3cda26a6c4c603a088419) )
11961189
11971190   ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE )
11981191   ROM_LOAD( "785_g14.d8",         0x0000, 0x4000, CRC(9dcdad9d) SHA1(22f457408b453a71b7e91974aee1b1e735ff887f) ) // characters
r3514r3515
12051198
12061199   ROM_REGION( 0x20000, "gfx3", ROMREGION_ERASE00 )   // tile data; mapped at 0x80000 on CPUB
12071200
1208   ROM_REGION( 0x20000, "konami", 0 ) // samples
1201   ROM_REGION( 0x20000, "konami", 0 )    // samples
12091202   ROM_LOAD( "785_f01.5a",         0x00000, 0x20000, CRC(a0d8d69e) SHA1(2994e5740b7c099d55fb162a363a26ef1995c756) )
12101203
1211   ROM_REGION( 0x20000, "upd", 0 ) // samples
1204   ROM_REGION( 0x20000, "upd", 0 )    // samples
12121205   ROM_LOAD( "785_f02.7c",         0x00000, 0x20000, CRC(c39f5ca4) SHA1(92ebea11b7d3a72d0f58c456f16a6ff36d6b3062) )
12131206ROM_END
12141207
12151208ROM_START( grdius2a )
1216   ROM_REGION( 0x10000, "audio", 0 )   // Z80 code (sound CPU)
1217   ROM_LOAD( "785_g03.10a",      0x00000,  0x8000, CRC(67a3b50d) SHA1(3c83f3b0df73d9361ec3cda26a6c4c603a088419) )
1209   ROM_REGION( 0x40000, "main", 0 )   // 68000 code (CPU A)
1210   ROM_LOAD16_BYTE( "785_p05.6n",   0x00000, 0x10000, CRC(4db0e736) SHA1(45edf094da448d039af18a7b47a592a3de02f17b) )
1211   ROM_LOAD16_BYTE( "785_p04.4n",   0x00001, 0x10000, CRC(765b99e6) SHA1(4acae0cf2bf23f8a1cf7b650b018d22a9ae947c9) )
1212   ROM_LOAD16_BYTE( "785_t09.6r",   0x20000, 0x10000, CRC(4e3f4965) SHA1(130da6db0590779948a29fd5010f0e628e4f2ee6) )
1213   ROM_LOAD16_BYTE( "785_j08.4r",   0x20001, 0x10000, CRC(2b1c9108) SHA1(3d367a1b60f95798b478dc4a84daa9b362271d4d) )
12181214
12191215   ROM_REGION( 0x40000, "sub", 0 )   // 68000 code (CPU B)
12201216   ROM_LOAD16_BYTE( "785_p07.10n",   0x00000, 0x10000, CRC(686d549d) SHA1(9687be801c4fb963bf6b0199e2ae9f5051213f7a) )
r3514r3515
12221218   ROM_LOAD16_BYTE( "785_p13.10s",   0x20000, 0x10000, CRC(478fdb0a) SHA1(2e285ad6dcfc67f3e24d231e0e1be19036ce64d2) )
12231219   ROM_LOAD16_BYTE( "785_p12.8s",   0x20001, 0x10000, CRC(38ea402a) SHA1(90ff2bd71435988cde967704ce3b1401de206683) )
12241220
1225   ROM_REGION( 0x40000, "main", 0 )   // 68000 code (CPU A)
1226   ROM_LOAD16_BYTE( "785_p05.6n",   0x00000, 0x10000, CRC(4db0e736) SHA1(45edf094da448d039af18a7b47a592a3de02f17b) )
1227   ROM_LOAD16_BYTE( "785_p04.4n",   0x00001, 0x10000, CRC(765b99e6) SHA1(4acae0cf2bf23f8a1cf7b650b018d22a9ae947c9) )
1228   ROM_LOAD16_BYTE( "785_t09.6r",   0x20000, 0x10000, CRC(4e3f4965) SHA1(130da6db0590779948a29fd5010f0e628e4f2ee6) )
1229   ROM_LOAD16_BYTE( "785_j08.4r",   0x20001, 0x10000, CRC(2b1c9108) SHA1(3d367a1b60f95798b478dc4a84daa9b362271d4d) )
1221   ROM_REGION( 0x10000, "audio", 0 )   // Z80 code (sound CPU)
1222   ROM_LOAD( "785_g03.10a",      0x00000,  0x8000, CRC(67a3b50d) SHA1(3c83f3b0df73d9361ec3cda26a6c4c603a088419) )
12301223
12311224   ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE )
12321225   ROM_LOAD( "785_g14.d8",         0x0000, 0x4000, CRC(9dcdad9d) SHA1(22f457408b453a71b7e91974aee1b1e735ff887f) ) // characters
r3514r3515
12391232
12401233   ROM_REGION( 0x20000, "gfx3", ROMREGION_ERASE00 )   // tile data; mapped at 0x80000 on CPUB
12411234
1242   ROM_REGION( 0x20000, "konami", 0 ) // samples
1235   ROM_REGION( 0x20000, "konami", 0 )    // samples
12431236   ROM_LOAD( "785_f01.5a",         0x00000, 0x20000, CRC(a0d8d69e) SHA1(2994e5740b7c099d55fb162a363a26ef1995c756) )
12441237
1245   ROM_REGION( 0x20000, "upd", 0 ) // samples
1238   ROM_REGION( 0x20000, "upd", 0 )    // samples
12461239   ROM_LOAD( "785_f02.7c",         0x00000, 0x20000, CRC(c39f5ca4) SHA1(92ebea11b7d3a72d0f58c456f16a6ff36d6b3062) )
12471240ROM_END
12481241
12491242ROM_START( grdius2b )
1250   ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU)
1251   ROM_LOAD( "785_g03.10a",      0x00000,  0x8000, CRC(67a3b50d) SHA1(3c83f3b0df73d9361ec3cda26a6c4c603a088419) )
1243   ROM_REGION( 0x40000, "main", 0 )    // 68000 code (CPU A)
1244   ROM_LOAD16_BYTE( "785_p05.6n",   0x00000, 0x10000, CRC(4db0e736) SHA1(45edf094da448d039af18a7b47a592a3de02f17b) )
1245   ROM_LOAD16_BYTE( "785_p04.4n",   0x00001, 0x10000, CRC(765b99e6) SHA1(4acae0cf2bf23f8a1cf7b650b018d22a9ae947c9) )
1246   ROM_LOAD16_BYTE( "785_j09.6r",   0x20000, 0x10000, CRC(6d96a7e3) SHA1(cc1362f5922cf1e348a58d54d03320f394a2aeab) )
1247   ROM_LOAD16_BYTE( "785_j08.4r",   0x20001, 0x10000, CRC(2b1c9108) SHA1(3d367a1b60f95798b478dc4a84daa9b362271d4d) )
12521248
1253   ROM_REGION( 0x40000, "sub", 0 ) // 68000 code (CPU B)
1249   ROM_REGION( 0x40000, "sub", 0 )    // 68000 code (CPU B)
12541250   ROM_LOAD16_BYTE( "785_p07.10n",   0x00000, 0x10000, CRC(686d549d) SHA1(9687be801c4fb963bf6b0199e2ae9f5051213f7a) )
12551251   ROM_LOAD16_BYTE( "785_p06.8n" ,   0x00001, 0x10000, CRC(70c94bee) SHA1(951e00ca4d3a47a21b4db05bcdc8ead45b42c3f1) )
12561252   ROM_LOAD16_BYTE( "785_p13.10s",   0x20000, 0x10000, CRC(478fdb0a) SHA1(2e285ad6dcfc67f3e24d231e0e1be19036ce64d2) )
12571253   ROM_LOAD16_BYTE( "785_p12.8s",   0x20001, 0x10000, CRC(38ea402a) SHA1(90ff2bd71435988cde967704ce3b1401de206683) )
12581254
1259   ROM_REGION( 0x40000, "main", 0 ) // 68000 code (CPU A)
1260   ROM_LOAD16_BYTE( "785_p05.6n",   0x00000, 0x10000, CRC(4db0e736) SHA1(45edf094da448d039af18a7b47a592a3de02f17b) )
1261   ROM_LOAD16_BYTE( "785_p04.4n",   0x00001, 0x10000, CRC(765b99e6) SHA1(4acae0cf2bf23f8a1cf7b650b018d22a9ae947c9) )
1262   ROM_LOAD16_BYTE( "785_j09.6r",   0x20000, 0x10000, CRC(6d96a7e3) SHA1(cc1362f5922cf1e348a58d54d03320f394a2aeab) )
1263   ROM_LOAD16_BYTE( "785_j08.4r",   0x20001, 0x10000, CRC(2b1c9108) SHA1(3d367a1b60f95798b478dc4a84daa9b362271d4d) )
1255   ROM_REGION( 0x10000, "audio", 0 )    // Z80 code (sound CPU)
1256   ROM_LOAD( "785_g03.10a",      0x00000,  0x8000, CRC(67a3b50d) SHA1(3c83f3b0df73d9361ec3cda26a6c4c603a088419) )
12641257
12651258   ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE )
12661259   ROM_LOAD( "785_g14.d8",         0x0000, 0x4000, CRC(9dcdad9d) SHA1(22f457408b453a71b7e91974aee1b1e735ff887f) ) // characters
r3514r3515
12731266
12741267   ROM_REGION( 0x20000, "gfx3", ROMREGION_ERASE00 )   // tile data; mapped at 0x80000 on CPUB
12751268
1276   ROM_REGION( 0x20000, "konami", 0 ) // samples
1269   ROM_REGION( 0x20000, "konami", 0 )    // samples
12771270   ROM_LOAD( "785_f01.5a",         0x00000, 0x20000, CRC(a0d8d69e) SHA1(2994e5740b7c099d55fb162a363a26ef1995c756) )
12781271
1279   ROM_REGION( 0x20000, "upd", 0 ) // samples
1272   ROM_REGION( 0x20000, "upd", 0 )    // samples
12801273   ROM_LOAD( "785_f02.7c",         0x00000, 0x20000, CRC(c39f5ca4) SHA1(92ebea11b7d3a72d0f58c456f16a6ff36d6b3062) )
12811274ROM_END
12821275
12831276ROM_START( fround )
1284   ROM_REGION( 0x10000, "audio", 0 )   // Z80 code (sound CPU)
1285   ROM_LOAD( "870_f03.10a",      0x00000,  0x8000, CRC(a645c727) SHA1(e173e79130f187d090766664f1c478d47062749c) )
1286
12871277   ROM_REGION( 0x40000, "main", 0 )   // 68000 code (CPU A)
12881278   ROM_LOAD16_BYTE( "870_m21.bin",   0x00000, 0x20000, CRC(436dbffb) SHA1(be8c8544f4d8ae86f216095753c6178a3cbf0e8d) )
12891279   ROM_LOAD16_BYTE( "870_m20.bin",   0x00001, 0x20000, CRC(b1c79d6a) SHA1(76e95e87eaa96ba694675fde7706540c584a36fb) )
12901280
1281   ROM_REGION( 0x10000, "audio", 0 )   // Z80 code (sound CPU)
1282   ROM_LOAD( "870_f03.10a",      0x00000,  0x8000, CRC(a645c727) SHA1(e173e79130f187d090766664f1c478d47062749c) )
1283
12911284   ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE )
12921285   ROM_LOAD( "870_f14.d8",         0x0000, 0x4000, CRC(c9b46615) SHA1(c0cddb1af47b8e0865055624cf4e89a111ac1b0f) ) // characters
12931286
12941287   ROM_REGION16_LE( 0x200000, "gfx2", 0 )   // gfx data used at runtime
1295   ROM_LOAD16_WORD("870c18.p18",   0x000000, 0x80000, CRC(07927fe8) SHA1(0ab5e0e785347fbed5c4b930a32876d6ce2bef4a) )
1296   ROM_LOAD16_WORD("870c17.p16",   0x080000, 0x80000, CRC(2bc99ff8) SHA1(9a06502317a71ca5662b79aedf47379b8e5434a9) )
1297   ROM_LOAD16_WORD("870c16.p15",   0x100000, 0x80000, CRC(41df6a1b) SHA1(32e0fdeb53628d18adde851e4496dd01ac6ec68f) )
1298   ROM_LOAD16_WORD("870c15.p13",   0x180000, 0x80000, CRC(8c9281df) SHA1(5e3d80be414db108d5363d0ea1b74021ba942c33) )
1288   ROM_LOAD16_WORD("870c18.p18",      0x000000, 0x80000, CRC(07927fe8) SHA1(0ab5e0e785347fbed5c4b930a32876d6ce2bef4a) )
1289   ROM_LOAD16_WORD("870c17.p16",      0x080000, 0x80000, CRC(2bc99ff8) SHA1(9a06502317a71ca5662b79aedf47379b8e5434a9) )
1290   ROM_LOAD16_WORD("870c16.p15",      0x100000, 0x80000, CRC(41df6a1b) SHA1(32e0fdeb53628d18adde851e4496dd01ac6ec68f) )
1291   ROM_LOAD16_WORD("870c15.p13",      0x180000, 0x80000, CRC(8c9281df) SHA1(5e3d80be414db108d5363d0ea1b74021ba942c33) )
12991292
1300   ROM_REGION( 0x20000, "konami", 0 ) // samples
1293   ROM_REGION( 0x20000, "konami", 0 )    // samples
13011294   ROM_LOAD( "870_c01.5a",         0x00000, 0x20000, CRC(6af96546) SHA1(63b49b28c0f2ef8f52bc4c5955ad6a633dd553cf) )
13021295
1303   ROM_REGION( 0x20000, "upd", 0 ) // samples
1296   ROM_REGION( 0x20000, "upd", 0 )    // samples
13041297   ROM_LOAD( "870_c02.7c",         0x00000, 0x20000, CRC(54e12c6d) SHA1(8171441aeb1a1dc4d65fae59c7c217f992f70cbc) )
13051298ROM_END
13061299
13071300ROM_START( froundl )
1308   ROM_REGION( 0x10000, "audio", 0 )   // Z80 code (sound CPU)
1309   ROM_LOAD( "870_f03.10a",      0x00000,  0x8000, CRC(a645c727) SHA1(e173e79130f187d090766664f1c478d47062749c) )
1310
13111301   ROM_REGION( 0x40000, "main", 0 )   // 68000 code (CPU A)
13121302   ROM_LOAD16_BYTE( "870_l21.bin",   0x00000, 0x20000, CRC(e21a3a19) SHA1(5f5793c88093bc8632eab673f5e0d954ac9b9177) )
13131303   ROM_LOAD16_BYTE( "870_l20.bin",   0x00001, 0x20000, CRC(0ce9786f) SHA1(0fb0eef999ed09dd50eed403255887103fc35461) )
13141304
1305   ROM_REGION( 0x10000, "audio", 0 )   // Z80 code (sound CPU)
1306   ROM_LOAD( "870_f03.10a",      0x00000,  0x8000, CRC(a645c727) SHA1(e173e79130f187d090766664f1c478d47062749c) )
1307
13151308   ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE )
13161309   ROM_LOAD( "870_f14.d8",         0x0000, 0x4000, CRC(c9b46615) SHA1(c0cddb1af47b8e0865055624cf4e89a111ac1b0f) ) // characters
13171310
13181311   ROM_REGION16_LE( 0x200000, "gfx2", 0 )   // gfx data used at runtime
1319   ROM_LOAD16_WORD("870c18.p18",   0x000000, 0x80000, CRC(07927fe8) SHA1(0ab5e0e785347fbed5c4b930a32876d6ce2bef4a) )
1320   ROM_LOAD16_WORD("870c17.p16",   0x080000, 0x80000, CRC(2bc99ff8) SHA1(9a06502317a71ca5662b79aedf47379b8e5434a9) )
1321   ROM_LOAD16_WORD("870c16.p15",   0x100000, 0x80000, CRC(41df6a1b) SHA1(32e0fdeb53628d18adde851e4496dd01ac6ec68f) )
1322   ROM_LOAD16_WORD("870c15.p13",   0x180000, 0x80000, CRC(8c9281df) SHA1(5e3d80be414db108d5363d0ea1b74021ba942c33) )
1312   ROM_LOAD16_WORD("870c18.p18",      0x000000, 0x80000, CRC(07927fe8) SHA1(0ab5e0e785347fbed5c4b930a32876d6ce2bef4a) )
1313   ROM_LOAD16_WORD("870c17.p16",      0x080000, 0x80000, CRC(2bc99ff8) SHA1(9a06502317a71ca5662b79aedf47379b8e5434a9) )
1314   ROM_LOAD16_WORD("870c16.p15",      0x100000, 0x80000, CRC(41df6a1b) SHA1(32e0fdeb53628d18adde851e4496dd01ac6ec68f) )
1315   ROM_LOAD16_WORD("870c15.p13",      0x180000, 0x80000, CRC(8c9281df) SHA1(5e3d80be414db108d5363d0ea1b74021ba942c33) )
13231316
1324   ROM_REGION( 0x20000, "konami", 0 ) // samples
1317   ROM_REGION( 0x20000, "konami", 0 )    // samples
13251318   ROM_LOAD( "870_c01.5a",         0x00000, 0x20000, CRC(6af96546) SHA1(63b49b28c0f2ef8f52bc4c5955ad6a633dd553cf) )
13261319
13271320   ROM_REGION( 0x20000, "upd", 0 )   // samples
r3514r3515
13291322ROM_END
13301323
13311324ROM_START( hpuncher )
1332   ROM_REGION( 0x10000, "audio", 0 )   // Z80 code (sound CPU)
1333   ROM_LOAD( "870_g03.10a",      0x00000,  0x8000, CRC(db9c10c8) SHA1(b2ec4d6800a4ab00dfcc8d3cd4abf9b9d7c5544a) )
1334
1335   ROM_REGION( 0x40000, "sub", 0 )   // 68000 code (CPU B)
1336   ROM_LOAD16_BYTE( "870_h07.10n",   0x00000, 0x10000, CRC(b4dda612) SHA1(e9612af11a151de1f0236629c84679f80936cae9) )
1337   ROM_LOAD16_BYTE( "870_h06.8n",   0x00001, 0x10000, CRC(696ba702) SHA1(e35c9aeab4305d828a347eaddf4abc806a889fa3) )
1338
13391325   ROM_REGION( 0x40000, "main", 0 )   // 68000 code (CPU A)
13401326   ROM_LOAD16_BYTE( "870_h05.6n",   0x00000, 0x10000, CRC(2bcfeef3) SHA1(8843e795a310e1a79b7b65226d9526197c2144ef) )
13411327   ROM_LOAD16_BYTE( "870_h04.4n",   0x00001, 0x10000, CRC(b9f97fd3) SHA1(d15a659f753f9f475dfd4f7e96789bacc54cb1f9) )
13421328   ROM_LOAD16_BYTE( "870_h09.6r",   0x20000, 0x10000, CRC(96a4f8b1) SHA1(2709f5236235b1b69c3367054fb998c1beb35625) )
13431329   ROM_LOAD16_BYTE( "870_h08.4r",   0x20001, 0x10000, CRC(46d65156) SHA1(6dd9d97a8e3394db668da1fc6a46c166bca1f456) )
13441330
1331   ROM_REGION( 0x40000, "sub", 0 )   // 68000 code (CPU B)
1332   ROM_LOAD16_BYTE( "870_h07.10n",   0x00000, 0x10000, CRC(b4dda612) SHA1(e9612af11a151de1f0236629c84679f80936cae9) )
1333   ROM_LOAD16_BYTE( "870_h06.8n",   0x00001, 0x10000, CRC(696ba702) SHA1(e35c9aeab4305d828a347eaddf4abc806a889fa3) )
1334
1335   ROM_REGION( 0x10000, "audio", 0 )   // Z80 code (sound CPU)
1336   ROM_LOAD( "870_g03.10a",      0x00000,  0x8000, CRC(db9c10c8) SHA1(b2ec4d6800a4ab00dfcc8d3cd4abf9b9d7c5544a) )
1337
13451338   ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE )
13461339   ROM_LOAD( "870_f14.d8",         0x0000, 0x4000, CRC(c9b46615) SHA1(c0cddb1af47b8e0865055624cf4e89a111ac1b0f) ) // characters
13471340
13481341   ROM_REGION16_LE( 0x200000, "gfx2", 0 )   // gfx data used at runtime
1349   ROM_LOAD16_WORD("870c17.p16",   0x000000, 0x80000, CRC(2bc99ff8) SHA1(9a06502317a71ca5662b79aedf47379b8e5434a9) )
1350   ROM_LOAD16_WORD("870c18.p18",   0x080000, 0x80000, CRC(07927fe8) SHA1(0ab5e0e785347fbed5c4b930a32876d6ce2bef4a) )
1351   ROM_LOAD16_WORD("870c15.p13",   0x100000, 0x80000, CRC(8c9281df) SHA1(5e3d80be414db108d5363d0ea1b74021ba942c33) )
1352   ROM_LOAD16_WORD("870c16.p15",   0x180000, 0x80000, CRC(41df6a1b) SHA1(32e0fdeb53628d18adde851e4496dd01ac6ec68f) )
1342   ROM_LOAD16_WORD("870c17.p16",      0x000000, 0x80000, CRC(2bc99ff8) SHA1(9a06502317a71ca5662b79aedf47379b8e5434a9) )
1343   ROM_LOAD16_WORD("870c18.p18",      0x080000, 0x80000, CRC(07927fe8) SHA1(0ab5e0e785347fbed5c4b930a32876d6ce2bef4a) )
1344   ROM_LOAD16_WORD("870c15.p13",      0x100000, 0x80000, CRC(8c9281df) SHA1(5e3d80be414db108d5363d0ea1b74021ba942c33) )
1345   ROM_LOAD16_WORD("870c16.p15",      0x180000, 0x80000, CRC(41df6a1b) SHA1(32e0fdeb53628d18adde851e4496dd01ac6ec68f) )
13531346
13541347   ROM_REGION( 0x20000, "konami", 0 )   // samples
13551348   ROM_LOAD( "870_c01.5a",         0x00000, 0x20000, CRC(6af96546) SHA1(63b49b28c0f2ef8f52bc4c5955ad6a633dd553cf) )
13561349
1357   ROM_REGION( 0x20000, "upd", 0 ) // samples
1350   ROM_REGION( 0x20000, "upd", 0 )    // samples
13581351   ROM_LOAD( "870_c02.7c",         0x00000, 0x20000, CRC(54e12c6d) SHA1(8171441aeb1a1dc4d65fae59c7c217f992f70cbc) )
13591352ROM_END
13601353
13611354ROM_START( miaj )
1362   ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU)
1363   ROM_LOAD( "808_e03.10a",      0x00000,  0x8000, CRC(3d93a7cd) SHA1(dcdd327e78f32436b276d0666f62a5b733b296e8) )
1355   ROM_REGION( 0x40000, "main", 0 )    // 68000 code (CPU A)
1356   ROM_LOAD16_BYTE("808_r05.6n",      0x00000, 0x10000, CRC(91fd83f4) SHA1(12cba5828d1d752efe4fc1972bed0205ac277850) )
1357   ROM_LOAD16_BYTE("808_r04.4n",      0x00001, 0x10000, CRC(f1c8c597) SHA1(4e8e87aedc9dac4ed05816989210de49f4dd60d2) )
1358   ROM_LOAD16_BYTE("808_r09.6r",      0x20000, 0x10000, CRC(f74d4467) SHA1(2b2491ee7ece979f2ec849075b0c30b6c1ed6bae) )
1359   ROM_LOAD16_BYTE("808_r08.4r",      0x20001, 0x10000, CRC(26f21704) SHA1(123cb2e4bcb25d82faa75e4505f9859c10bca754) )
13641360
1365   ROM_REGION( 0x40000, "sub", 0 ) // 68000 code (CPU B)
1361   ROM_REGION( 0x40000, "sub", 0 )    // 68000 code (CPU B)
13661362   ROM_LOAD16_BYTE("808_e07.10n",   0x00000, 0x10000, CRC(297bdcea) SHA1(41ed650cbc4f56777fa352812e9a560554459f90) )
1367   ROM_LOAD16_BYTE("808_e06.8n",   0x00001, 0x10000, CRC(8f576b33) SHA1(cd8c9a45626c30571ca12d0241cccc092c0903a0) )
1363   ROM_LOAD16_BYTE("808_e06.8n",      0x00001, 0x10000, CRC(8f576b33) SHA1(cd8c9a45626c30571ca12d0241cccc092c0903a0) )
13681364   ROM_LOAD16_BYTE("808_e13.10s",   0x20000, 0x10000, CRC(1fa708f4) SHA1(9511a19f50fb61571c2986c72d1a85e87b8d0495) )
1369   ROM_LOAD16_BYTE("808_e12.8s",   0x20001, 0x10000, CRC(d62f1fde) SHA1(1e55084f1294b6ac7c152fcd1800511fcab5d360) )
1365   ROM_LOAD16_BYTE("808_e12.8s",      0x20001, 0x10000, CRC(d62f1fde) SHA1(1e55084f1294b6ac7c152fcd1800511fcab5d360) )
13701366
1371   ROM_REGION( 0x40000, "main", 0 ) // 68000 code (CPU A)
1372   ROM_LOAD16_BYTE("808_r05.6n",   0x00000, 0x10000, CRC(91fd83f4) SHA1(12cba5828d1d752efe4fc1972bed0205ac277850) )
1373   ROM_LOAD16_BYTE("808_r04.4n",   0x00001, 0x10000, CRC(f1c8c597) SHA1(4e8e87aedc9dac4ed05816989210de49f4dd60d2) )
1374   ROM_LOAD16_BYTE("808_r09.6r",   0x20000, 0x10000, CRC(f74d4467) SHA1(2b2491ee7ece979f2ec849075b0c30b6c1ed6bae) )
1375   ROM_LOAD16_BYTE("808_r08.4r",   0x20001, 0x10000, CRC(26f21704) SHA1(123cb2e4bcb25d82faa75e4505f9859c10bca754) )
1367   ROM_REGION( 0x10000, "audio", 0 )    // Z80 code (sound CPU)
1368   ROM_LOAD( "808_e03.10a",      0x00000,  0x8000, CRC(3d93a7cd) SHA1(dcdd327e78f32436b276d0666f62a5b733b296e8) )
13761369
13771370   ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE )
13781371   ROM_LOAD("808_e14.d8",         0x0000, 0x4000, CRC(b9d36525) SHA1(53291c4911d7e1a5110539e4c57a11d0d530dc6f) ) // characters
13791372
13801373   ROM_REGION16_LE( 0x200000, "gfx2", 0 )   // gfx data used at runtime
1381   ROM_LOAD16_WORD("808d17.p16",   0x000000, 0x80000, CRC(d1299082) SHA1(c3c07b0517e7428ccd1cdf9e15aaf16d98e7c4cd) )
1382   ROM_LOAD16_WORD("808d15.p13",   0x100000, 0x80000, CRC(2b22a6b6) SHA1(8e1af0627a4eac045128c4096e2cfb59c3d2f5ef) )
1374   ROM_LOAD16_WORD("808d17.p16",      0x000000, 0x80000, CRC(d1299082) SHA1(c3c07b0517e7428ccd1cdf9e15aaf16d98e7c4cd) )
1375   ROM_LOAD16_WORD("808d15.p13",      0x100000, 0x80000, CRC(2b22a6b6) SHA1(8e1af0627a4eac045128c4096e2cfb59c3d2f5ef) )
13831376
1384   ROM_REGION( 0x20000, "gfx3", ROMREGION_ERASE00 ) // tile data; mapped at 0x80000 on CPUB
1377   ROM_REGION( 0x20000, "gfx3", ROMREGION_ERASE00 )    // tile data; mapped at 0x80000 on CPUB
13851378
1386   ROM_REGION( 0x20000, "konami", 0 ) // samples
1379   ROM_REGION( 0x20000, "konami", 0 )    // samples
13871380   ROM_LOAD("808_d01.5a",         0x00000, 0x20000, CRC(fd4d37c0) SHA1(ef91c6e7bb57c27a9a51729fffd1bfe3e806fb61) )
13881381
1389   ROM_REGION( 0x20000, "upd", ROMREGION_ERASE00 ) // samples
1382   ROM_REGION( 0x20000, "upd", ROMREGION_ERASE00 )    // samples
13901383ROM_END
13911384
13921385ROM_START( cuebrckj )
1393   ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU)
1394   ROM_LOAD( "903_d03.10a",      0x00000,  0x8000, CRC(455e855a) SHA1(cfdd54a5071862653ee94c0455301f4a7245fbd8) )
1386   ROM_REGION( 0x40000, "main", 0 )    // 68000 code (CPU A)
1387   ROM_LOAD16_BYTE( "903_e05.6n",   0x00000, 0x10000, CRC(8b556220) SHA1(dbe24133e74018c4fe9332519394cbb882c4ed5a) )
1388   ROM_LOAD16_BYTE( "903_e04.4n",   0x00001, 0x10000, CRC(bf9c7927) SHA1(3a594b8846f7e6074ca54f8cd5fe2ba3b64ba740) )
1389   ROM_LOAD16_BYTE( "903_e09.6r",   0x20000, 0x10000, CRC(2a77554d) SHA1(53eee99737333c8c4bbb9c757fd12488b6c4d3d8) )
1390   ROM_LOAD16_BYTE( "903_e08.4r",   0x20001, 0x10000, CRC(c0a430c1) SHA1(bef737f12e9a79781a4cd795ffc108899757901d) )
13951391
1396   ROM_REGION( 0x40000, "sub", 0 ) // 68000 code (CPU B)
1392   ROM_REGION( 0x40000, "sub", 0 )    // 68000 code (CPU B)
13971393   ROM_LOAD16_BYTE( "903_d07.10n",   0x00000, 0x10000, CRC(fc0edce7) SHA1(57e969a42c48a9464ec370d4605eaecb690d58ab) )
13981394   ROM_LOAD16_BYTE( "903_d06.8n",   0x00001, 0x10000, CRC(b2cef6fe) SHA1(27d1d15f3a408e6166745cb6a159704a8cbb4584) )
13991395   ROM_LOAD16_BYTE( "903_e13.10s",   0x20000, 0x10000, CRC(4fb5fb80) SHA1(3a59dae3846341289c31aa106684ebc45488ca45) )
14001396   ROM_LOAD16_BYTE( "903_e12.8s",   0x20001, 0x10000, CRC(883e3097) SHA1(fe0fa1a2881a67223d741c400bb8c1a0c67946c1) )
14011397
1402   ROM_REGION( 0x40000, "main", 0 ) // 68000 code (CPU A)
1403   ROM_LOAD16_BYTE( "903_e05.6n",   0x00000, 0x10000, CRC(8b556220) SHA1(dbe24133e74018c4fe9332519394cbb882c4ed5a) )
1404   ROM_LOAD16_BYTE( "903_e04.4n",   0x00001, 0x10000, CRC(bf9c7927) SHA1(3a594b8846f7e6074ca54f8cd5fe2ba3b64ba740) )
1405   ROM_LOAD16_BYTE( "903_e09.6r",   0x20000, 0x10000, CRC(2a77554d) SHA1(53eee99737333c8c4bbb9c757fd12488b6c4d3d8) )
1406   ROM_LOAD16_BYTE( "903_e08.4r",   0x20001, 0x10000, CRC(c0a430c1) SHA1(bef737f12e9a79781a4cd795ffc108899757901d) )
1398   ROM_REGION( 0x10000, "audio", 0 )    // Z80 code (sound CPU)
1399   ROM_LOAD( "903_d03.10a",      0x00000,  0x8000, CRC(455e855a) SHA1(cfdd54a5071862653ee94c0455301f4a7245fbd8) )
14071400
14081401   ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE )
14091402   ROM_LOAD( "903_e14.d8",         0x0000, 0x4000, CRC(ddbebbd5) SHA1(df532f19a08cabb28d693e4cd445c47c9e35e5ff) ) // characters
r3514r3515
14111404   ROM_REGION( 0x200000, "gfx2", ROMREGION_ERASE00 )   // gfx data used at runtime
14121405   // unpopulated
14131406
1414   ROM_REGION16_BE( 0x20000, "gfx3", 0 ) // tile data; mapped at 0x80000 on CPUB
1407   ROM_REGION16_BE( 0x20000, "gfx3", 0 )    // tile data; mapped at 0x80000 on CPUB
14151408   ROM_LOAD16_BYTE( "903_e11.10r",   0x00000, 0x10000, CRC(5c41faf8) SHA1(f9eee6a7b92d3b3aa4320747da6390310522a2cf) )
14161409   ROM_LOAD16_BYTE( "903_e10.8r",   0x00001, 0x10000, CRC(417576d4) SHA1(e84762743e3a1117b6ef7ea0b304877e4a719f75) )
14171410
1418   ROM_REGION( 0x20000, "konami", ROMREGION_ERASE00 ) // samples
1411   ROM_REGION( 0x20000, "konami", ROMREGION_ERASE00 )    // samples
14191412   // unpopulated
14201413
1421   ROM_REGION( 0x20000, "upd", ROMREGION_ERASE00 ) // samples
1414   ROM_REGION( 0x20000, "upd", ROMREGION_ERASE00 )    // samples
14221415   // unpopulated
14231416ROM_END
14241417
r3514r3515
14711464
14721465/* Game Drivers */
14731466
1474GAME( 1987, devilw,   0,        heavysync, devilw,   twin16,   ROT0, "Konami", "Devil World", 0 )
1475GAME( 1987, majuu,    devilw,   heavysync, devilw,   twin16,   ROT0, "Konami", "Majuu no Ohkoku", 0 )
1476GAME( 1987, darkadv,  devilw,   heavysync, darkadv,  twin16,   ROT0, "Konami", "Dark Adventure", 0 )
1477GAME( 1988, vulcan,   0,        vulcan,    vulcan,   twin16,   ROT0, "Konami", "Vulcan Venture", 0 )
1478GAME( 1988, gradius2, vulcan,   vulcan,    gradius2, twin16,   ROT0, "Konami", "Gradius II - GOFER no Yabou (Japan New Ver.)", 0 )
1479GAME( 1988, grdius2a, vulcan,   vulcan,    vulcan,   twin16,   ROT0, "Konami", "Gradius II - GOFER no Yabou (Japan Old Ver.)", 0 )
1480GAME( 1988, grdius2b, vulcan,   vulcan,    vulcan,   twin16,   ROT0, "Konami", "Gradius II - GOFER no Yabou (Japan Older Ver.)", 0 )
1467GAME( 1987, devilw,   0,        devilw,     devilw,   twin16,   ROT0, "Konami", "Devil World", 0 )
1468GAME( 1987, majuu,    devilw,   devilw,     devilw,   twin16,   ROT0, "Konami", "Majuu no Ohkoku", 0 )
1469GAME( 1987, darkadv,  devilw,   devilw,     darkadv,  twin16,   ROT0, "Konami", "Dark Adventure", 0 )
1470GAME( 1988, vulcan,   0,        twin16,    vulcan,   twin16,   ROT0, "Konami", "Vulcan Venture", 0 )
1471GAME( 1988, gradius2, vulcan,   twin16,    gradius2, twin16,   ROT0, "Konami", "Gradius II - GOFER no Yabou (Japan New Ver.)", 0 )
1472GAME( 1988, grdius2a, vulcan,   twin16,    vulcan,   twin16,   ROT0, "Konami", "Gradius II - GOFER no Yabou (Japan Old Ver.)", 0 )
1473GAME( 1988, grdius2b, vulcan,   twin16,    vulcan,   twin16,   ROT0, "Konami", "Gradius II - GOFER no Yabou (Japan Older Ver.)", 0 )
14811474
14821475GAME( 1988, fround,   0,        fround,    fround,   fround,   ROT0, "Konami", "The Final Round (version M)", 0 )
14831476GAME( 1988, froundl,  fround,   fround,    fround,   fround,   ROT0, "Konami", "The Final Round (version L)", 0 )
14841477GAME( 1988, hpuncher, fround,   hpuncher,  fround,   hpuncher, ROT0, "Konami", "Hard Puncher (Japan)", 0 )
1485GAME( 1989, miaj,     mia,      mia,       miaj,     hpuncher, ROT0, "Konami", "M.I.A. - Missing in Action (Japan)", 0 )
1478GAME( 1989, miaj,     mia,      miaj,      miaj,     hpuncher, ROT0, "Konami", "M.I.A. - Missing in Action (Japan)", 0 )
14861479GAME( 1989, cuebrckj, cuebrick, cuebrckj,  cuebrckj, cuebrckj, ROT0, "Konami", "Cue Brick (Japan)", 0 )
src/mame/drivers/cave.c
r3514r3515
7878#include "sound/okim6295.h"
7979#include "sound/ymz280b.h"
8080
81extern UINT16 *cave_spriteram16_2;
82
8381/***************************************************************************
8482
8583
src/mame/drivers/nmk16.c
r3514r3515
337337      return ~input_port_read(machine, "IN1");
338338}
339339
340static WRITE16_HANDLER( macross2_sound_reset_w )
341{
342   /* PCB behaviour verified by Corrado Tomaselli at MAME Italia Forum:
343       every time music changes Z80 is resetted */
344   cpunum_set_input_line(machine, 1, INPUT_LINE_RESET, data ? CLEAR_LINE : ASSERT_LINE);
345}
346
340347static WRITE16_HANDLER( macross2_sound_command_w )
341348{
342349   if (ACCESSING_BITS_0_7)
343350      soundlatch_w(machine,0,data & 0xff);
344351}
345352
346static READ16_HANDLER( macross2_sound_result_r )
347{
348   return soundlatch2_r(machine,0);
349}
350
351353static WRITE8_HANDLER( macross2_sound_bank_w )
352354{
353355   UINT8 *rom = memory_region(machine, "audio") + 0x10000;
r3514r3515
10051007   AM_RANGE(0x100002, 0x100003) AM_READ_PORT("IN1")
10061008   AM_RANGE(0x100008, 0x100009) AM_READ_PORT("DSW1")
10071009   AM_RANGE(0x10000a, 0x10000b) AM_READ_PORT("DSW2")
1008   AM_RANGE(0x10000e, 0x10000f) AM_READ(macross2_sound_result_r)   /* from Z80 */
1010   AM_RANGE(0x10000e, 0x10000f) AM_READ(soundlatch2_word_r)   /* from Z80 */
10091011   AM_RANGE(0x120000, 0x1207ff) AM_READ(SMH_RAM)
10101012   AM_RANGE(0x140000, 0x14ffff) AM_READ(nmk_bgvideoram_r)
10111013   AM_RANGE(0x170000, 0x170fff) AM_READ(nmk_txvideoram_r)
r3514r3515
10161018static ADDRESS_MAP_START( macross2_writemem, ADDRESS_SPACE_PROGRAM, 16 )
10171019   AM_RANGE(0x000000, 0x07ffff) AM_WRITE(SMH_ROM)
10181020   AM_RANGE(0x100014, 0x100015) AM_WRITE(nmk_flipscreen_w)
1019   AM_RANGE(0x100016, 0x100017) AM_WRITE(SMH_NOP)   /* IRQ eanble? */
1021   AM_RANGE(0x100016, 0x100017) AM_WRITE(macross2_sound_reset_w)   /* Z80 reset */
10201022   AM_RANGE(0x100018, 0x100019) AM_WRITE(nmk_tilebank_w)
10211023   AM_RANGE(0x10001e, 0x10001f) AM_WRITE(macross2_sound_command_w)   /* to Z80 */
10221024   AM_RANGE(0x120000, 0x1207ff) AM_WRITE(paletteram16_RRRRGGGGBBBBRGBx_word_w) AM_BASE(&paletteram16)
src/tools/src2html.c
r3514r3515
55    Copyright Nicola Salmoria and the MAME Team.
66    Visit http://mamedev.org for licensing and usage restrictions.
77
8****************************************************************************
9
10    Template file format:
11
12    <html header>
13    <!--PATH--> = insert path
14    <!--CONTENT--> = insert content
15    <html footer>
16
817***************************************************************************/
918
1019#include <stdio.h>
r3514r3515
2029    CONSTANTS & DEFINES
2130***************************************************************************/
2231
23#define COMMENT_STYLE      "color:#b30000"
24#define STRING_STYLE      "color:#666"
25#define PREPROCESSOR_STYLE   "color:#0000b3"
26#define KEYWORD_STYLE      "color:#0000b3"
27#define MAMEWORD_STYLE      "color:#7f007f"
28#define LINENUM_STYLE      "color:#999"
32#define PREPROC_CLASS      "preproc"
33#define KEYWORD_CLASS      "keyword"
34#define CUSTOM_CLASS      "custom"
2935
3036
3137
r3514r3515
97103
98104static const token_entry dummy_token_table[] =
99105{
100   { NULL, KEYWORD_STYLE }
106   { NULL, KEYWORD_CLASS }
101107};
102108
103109
104110static const token_entry c_token_table[] =
105111{
106   { "#define", PREPROCESSOR_STYLE },
107   { "#elif", PREPROCESSOR_STYLE },
108   { "#else", PREPROCESSOR_STYLE },
109   { "#endif", PREPROCESSOR_STYLE },
110   { "#error", PREPROCESSOR_STYLE },
111   { "#if", PREPROCESSOR_STYLE },
112   { "#ifdef", PREPROCESSOR_STYLE },
113   { "#ifndef", PREPROCESSOR_STYLE },
114   { "#include", PREPROCESSOR_STYLE },
115   { "#line", PREPROCESSOR_STYLE },
116   { "#pragma", PREPROCESSOR_STYLE },
117   { "#undef", PREPROCESSOR_STYLE },
112   { "#define", PREPROC_CLASS },
113   { "#elif", PREPROC_CLASS },
114   { "#else", PREPROC_CLASS },
115   { "#endif", PREPROC_CLASS },
116   { "#error", PREPROC_CLASS },
117   { "#if", PREPROC_CLASS },
118   { "#ifdef", PREPROC_CLASS },
119   { "#ifndef", PREPROC_CLASS },
120   { "#include", PREPROC_CLASS },
121   { "#line", PREPROC_CLASS },
122   { "#pragma", PREPROC_CLASS },
123   { "#undef", PREPROC_CLASS },
118124
119   { "auto", KEYWORD_STYLE },
120   { "break", KEYWORD_STYLE },
121   { "case", KEYWORD_STYLE },
122   { "char", KEYWORD_STYLE },
123   { "const", KEYWORD_STYLE },
124   { "continue", KEYWORD_STYLE },
125   { "default", KEYWORD_STYLE },
126   { "do", KEYWORD_STYLE },
127   { "double", KEYWORD_STYLE },
128   { "else", KEYWORD_STYLE },
129   { "enum", KEYWORD_STYLE },
130   { "extern", KEYWORD_STYLE },
131   { "float", KEYWORD_STYLE },
132   { "for", KEYWORD_STYLE },
133   { "goto", KEYWORD_STYLE },
134   { "if", KEYWORD_STYLE },
135   { "int", KEYWORD_STYLE },
136   { "long", KEYWORD_STYLE },
137   { "register", KEYWORD_STYLE },
138   { "return", KEYWORD_STYLE },
139   { "short", KEYWORD_STYLE },
140   { "signed", KEYWORD_STYLE },
141   { "sizeof", KEYWORD_STYLE },
142   { "static", KEYWORD_STYLE },
143   { "struct", KEYWORD_STYLE },
144   { "switch", KEYWORD_STYLE },
145   { "typedef", KEYWORD_STYLE },
146   { "union", KEYWORD_STYLE },
147   { "unsigned", KEYWORD_STYLE },
148   { "void", KEYWORD_STYLE },
149   { "volatile", KEYWORD_STYLE },
150   { "while", KEYWORD_STYLE },
125   { "auto", KEYWORD_CLASS },
126   { "break", KEYWORD_CLASS },
127   { "case", KEYWORD_CLASS },
128   { "char", KEYWORD_CLASS },
129   { "const", KEYWORD_CLASS },
130   { "continue", KEYWORD_CLASS },
131   { "default", KEYWORD_CLASS },
132   { "do", KEYWORD_CLASS },
133   { "double", KEYWORD_CLASS },
134   { "else", KEYWORD_CLASS },
135   { "enum", KEYWORD_CLASS },
136   { "extern", KEYWORD_CLASS },
137   { "float", KEYWORD_CLASS },
138   { "for", KEYWORD_CLASS },
139   { "goto", KEYWORD_CLASS },
140   { "if", KEYWORD_CLASS },
141   { "int", KEYWORD_CLASS },
142   { "long", KEYWORD_CLASS },
143   { "register", KEYWORD_CLASS },
144   { "return", KEYWORD_CLASS },
145   { "short", KEYWORD_CLASS },
146   { "signed", KEYWORD_CLASS },
147   { "sizeof", KEYWORD_CLASS },
148   { "static", KEYWORD_CLASS },
149   { "struct", KEYWORD_CLASS },
150   { "switch", KEYWORD_CLASS },
151   { "typedef", KEYWORD_CLASS },
152   { "union", KEYWORD_CLASS },
153   { "unsigned", KEYWORD_CLASS },
154   { "void", KEYWORD_CLASS },
155   { "volatile", KEYWORD_CLASS },
156   { "while", KEYWORD_CLASS },
151157
152158/*
153    { "INLINE", MAMEWORD_STYLE },
154    { "INT8", MAMEWORD_STYLE },
155    { "UINT8", MAMEWORD_STYLE },
156    { "INT16", MAMEWORD_STYLE },
157    { "UINT16", MAMEWORD_STYLE },
158    { "INT32", MAMEWORD_STYLE },
159    { "UINT32", MAMEWORD_STYLE },
160    { "INT64", MAMEWORD_STYLE },
161    { "UINT64", MAMEWORD_STYLE },
162    { "ARRAY_LENGTH", MAMEWORD_STYLE },
159    { "INLINE", CUSTOM_CLASS },
160    { "INT8", CUSTOM_CLASS },
161    { "UINT8", CUSTOM_CLASS },
162    { "INT16", CUSTOM_CLASS },
163    { "UINT16", CUSTOM_CLASS },
164    { "INT32", CUSTOM_CLASS },
165    { "UINT32", CUSTOM_CLASS },
166    { "INT64", CUSTOM_CLASS },
167    { "UINT64", CUSTOM_CLASS },
168    { "ARRAY_LENGTH", CUSTOM_CLASS },
163169*/
164   { NULL, KEYWORD_STYLE }
170   { NULL, KEYWORD_CLASS }
165171};
166172
167173
r3514r3515
171177***************************************************************************/
172178
173179/* core output functions */
174static int recurse_dir(int srcrootlen, int dstrootlen, const astring *srcdir, const astring *dstdir);
175static int output_file(file_type type, int srcrootlen, int dstrootlen, const astring *srcfile, const astring *dstfile, int link_to_file);
180static int recurse_dir(int srcrootlen, int dstrootlen, const astring *srcdir, const astring *dstdir, const astring *tempheader, const astring *tempfooter);
181static int output_file(file_type type, int srcrootlen, int dstrootlen, const astring *srcfile, const astring *dstfile, int link_to_file, const astring *tempheader, const astring *tempfooter);
176182
177183/* HTML helpers */
178static core_file *create_file_and_output_header(const astring *filename, const char *title, const char *subtitle);
179static void output_footer_and_close_file(core_file *file);
184static core_file *create_file_and_output_header(const astring *filename, const astring *template, const astring *path);
185static void output_footer_and_close_file(core_file *file, const astring *template, const astring *path);
180186
181187/* path helpers */
182188static const astring *normalized_subpath(const astring *path, int start);
r3514r3515
195201
196202int main(int argc, char *argv[])
197203{
198   astring *srcdir = NULL, *dstdir = NULL;
204   astring *srcdir = NULL, *dstdir = NULL, *tempfilename = NULL, *tempheader = NULL, *tempfooter = NULL;
205   core_file *tempfile;
199206   int unadorned = 0;
200207   int result;
201208   int argnum;
r3514r3515
228235         dstdir = astring_dupc(arg);
229236         unadorned++;
230237      }
238      else if (arg[0] != '-' && unadorned == 2)
239      {
240         tempfilename = astring_dupc(arg);
241         unadorned++;
242      }
231243      else
232244         goto usage;
233245   }
234246
235   /* make sure we got 2 parameters */
236   if (srcdir == NULL || dstdir == NULL)
247   /* make sure we got 3 parameters */
248   if (srcdir == NULL || dstdir == NULL || tempfilename == NULL)
237249      goto usage;
238250
251   /* read the template file into an astring */
252   if (core_fopen(astring_c(tempfilename), OPEN_FLAG_READ, &tempfile) == FILERR_NONE)
253   {
254      UINT64 filesize = core_fsize(tempfile);
255      void *buffer = malloc(filesize);
256      if (buffer != NULL)
257      {
258         core_fread(tempfile, buffer, filesize);
259         tempheader = astring_dupch(buffer, filesize);
260         free(buffer);
261      }
262      core_fclose(tempfile);
263   }
264
265   /* verify the template */
266   if (tempheader == NULL)
267   {
268      fprintf(stderr, "Unable to read template file\n");
269      return 1;
270   }
271   result = astring_findc(tempheader, 0, "<!--CONTENT-->");
272   if (result == -1)
273   {
274      fprintf(stderr, "Template is missing a <!--CONTENT--> marker\n");
275      return 1;
276   }
277   tempfooter = astring_substr(astring_dup(tempheader), result + 14, -1);
278   tempheader = astring_substr(tempheader, 0, result);
279
239280   /* recurse over subdirectories */
240   result = recurse_dir(astring_len(srcdir), astring_len(dstdir), srcdir, dstdir);
281   result = recurse_dir(astring_len(srcdir), astring_len(dstdir), srcdir, dstdir, tempheader, tempfooter);
241282
242283   /* free source and destination directories */
243284   astring_free(srcdir);
244285   astring_free(dstdir);
286   astring_free(tempfilename);
287   astring_free(tempheader);
288   astring_free(tempfooter);
245289   return result;
246290
247291usage:
248   fprintf(stderr, "Usage:\n%s <srcroot> <destroot> [-Iincpath [-Iincpath [...]]]\n", argv[0]);
292   fprintf(stderr, "Usage:\n%s <srcroot> <destroot> <template.html> [-Iincpath [-Iincpath [...]]]\n", argv[0]);
249293   return 1;
250294}
251295
r3514r3515
267311    recurse_dir - recurse through a directory
268312-------------------------------------------------*/
269313
270static int recurse_dir(int srcrootlen, int dstrootlen, const astring *srcdir, const astring *dstdir)
314static int recurse_dir(int srcrootlen, int dstrootlen, const astring *srcdir, const astring *dstdir, const astring *tempheader, const astring *tempfooter)
271315{
272316   static const osd_dir_entry_type typelist[] = { ENTTYPE_DIR, ENTTYPE_FILE };
273317   const astring *srcdir_subpath;
r3514r3515
284328   /* create an index file */
285329   indexname = astring_alloc();
286330   astring_printf(indexname, "%s%c%s", astring_c(dstdir), PATH_SEPARATOR[0], "index.html");
287   indexfile = create_file_and_output_header(indexname, "MAME Source Code", astring_c(srcdir_subpath));
331   indexfile = create_file_and_output_header(indexname, tempheader, srcdir_subpath);
288332   astring_free(indexname);
289333
290334   /* output the directory navigation */
291335   core_fprintf(indexfile, "<h3>Viewing Directory: ");
292336   output_path_as_links(indexfile, srcdir_subpath, TRUE, FALSE);
293337   core_fprintf(indexfile, "</h3>");
294   astring_free((astring *)srcdir_subpath);
295338
296339   /* iterate first over directories, then over files */
297340   for (entindex = 0; entindex < ARRAY_LENGTH(typelist) && result == 0; entindex++)
298341   {
299342      osd_dir_entry_type entry_type = typelist[entindex];
300343      const osd_directory_entry *entry;
344      list_entry **listarray = NULL;
301345      list_entry *list = NULL;
302      list_entry **listarray;
303346      list_entry *curlist;
304347      osd_directory *dir;
305348      int found = 0;
r3514r3515
346389         listarray[found]->next = list;
347390         list = listarray[found];
348391      }
392      free(listarray);
349393
350394      /* iterate through each file */
351395      for (curlist = list; curlist != NULL && result == 0; curlist = curlist->next)
r3514r3515
381425               astring_printf(dstfile, "%s%c%s.html", astring_c(dstdir), PATH_SEPARATOR[0], astring_c(curlist->name));
382426               if (indexfile != NULL)
383427                  core_fprintf(indexfile, "\t<li><a href=\"%s.html\">%s</a></li>\n", astring_c(curlist->name), astring_c(curlist->name));
384               result = output_file(type, srcrootlen, dstrootlen, srcfile, dstfile, astring_cmp(srcdir, dstdir) == 0);
428               result = output_file(type, srcrootlen, dstrootlen, srcfile, dstfile, astring_cmp(srcdir, dstdir) == 0, tempheader, tempfooter);
385429            }
386430         }
387431
r3514r3515
391435            astring_printf(dstfile, "%s%c%s", astring_c(dstdir), PATH_SEPARATOR[0], astring_c(curlist->name));
392436            if (indexfile != NULL)
393437               core_fprintf(indexfile, "\t<li><a href=\"%s/index.html\">%s/</a></li>\n", astring_c(curlist->name), astring_c(curlist->name));
394            result = recurse_dir(srcrootlen, dstrootlen, srcfile, dstfile);
438            result = recurse_dir(srcrootlen, dstrootlen, srcfile, dstfile, tempheader, tempfooter);
395439         }
396440
397441         /* free memory for the names */
r3514r3515
415459
416460error:
417461   if (indexfile != NULL)
418      output_footer_and_close_file(indexfile);
462      output_footer_and_close_file(indexfile, tempfooter, srcdir_subpath);
463   astring_free((astring *)srcdir_subpath);
419464   return result;
420465}
421466
r3514r3515
425470    HTML
426471-------------------------------------------------*/
427472
428static int output_file(file_type type, int srcrootlen, int dstrootlen, const astring *srcfile, const astring *dstfile, int link_to_file)
473static int output_file(file_type type, int srcrootlen, int dstrootlen, const astring *srcfile, const astring *dstfile, int link_to_file, const astring *tempheader, const astring *tempfooter)
429474{
430475   const char *comment_start, *comment_end, *comment_inline, *token_chars;
431476   const char *comment_start_esc, *comment_end_esc, *comment_inline_esc;
r3514r3515
497542   }
498543
499544   /* open the output file */
500   dst = create_file_and_output_header(dstfile, "MAME Source Code", astring_c(srcfile_subpath));
545   dst = create_file_and_output_header(dstfile, tempheader, srcfile_subpath);
501546   if (dst == NULL)
502547   {
503548      fprintf(stderr, "Unable to write file '%s'\n", astring_c(dstfile));
r3514r3515
509554   core_fprintf(dst, "<h3>Viewing File: ");
510555   output_path_as_links(dst, srcfile_subpath, FALSE, link_to_file);
511556   core_fprintf(dst, "</h3>");
512   astring_free((astring *)srcfile_subpath);
513557
514558   /* start with some tags */
515   core_fprintf(dst, "\t<pre style=\"font-family:'Courier New','Courier',monospace; font-size:12px;\">\n");
559   core_fprintf(dst, "\t<pre class=\"source\">\n");
516560
517561   /* iterate over lines in the source file */
518562   while (core_fgets(srcline, ARRAY_LENGTH(srcline), src) != NULL)
r3514r3515
526570      int curcol = 0;
527571
528572      /* start with the line number */
529      dstptr += sprintf(dstptr, "<span style=\"" LINENUM_STYLE "\">%5d</span>&nbsp;&nbsp;", linenum++);
573      dstptr += sprintf(dstptr, "<span class=\"linenum\">%5d</span>&nbsp;&nbsp;", linenum++);
530574
531575      /* iterate over characters in the source line */
532576      for (srcptr = srcline; *srcptr != 0; )
r3514r3515
538582         {
539583            if (!in_comment && ch == comment_start[0] && strncmp(srcptr - 1, comment_start, strlen(comment_start)) == 0)
540584            {
541               dstptr += sprintf(dstptr, "<span style=\"" COMMENT_STYLE "\">%s", comment_start_esc);
585               dstptr += sprintf(dstptr, "<span class=\"comment\">%s", comment_start_esc);
542586               curcol += strlen(comment_start);
543587               srcptr += strlen(comment_start) - 1;
544588               ch = 0;
r3514r3515
557601         /* track whether or not we are within an inline (C++-style) comment */
558602         if (!in_quotes && !in_comment && !in_inline_comment && ch == comment_inline[0] && strncmp(srcptr - 1, comment_inline, strlen(comment_inline)) == 0)
559603         {
560            dstptr += sprintf(dstptr, "<span style=\"" COMMENT_STYLE "\">%s", comment_inline_esc);
604            dstptr += sprintf(dstptr, "<span class=\"comment\">%s", comment_inline_esc);
561605            curcol += strlen(comment_inline);
562606            srcptr += strlen(comment_inline) - 1;
563607            ch = 0;
r3514r3515
581625            for (curtoken = token_table; curtoken->token != NULL; curtoken++)
582626               if (strncmp(srcptr - 1, curtoken->token, toklength) == 0 && strlen(curtoken->token) == toklength)
583627               {
584                  dstptr += sprintf(dstptr, "<span style=\"%s\">%s</span>", curtoken->color, curtoken->token);
628                  dstptr += sprintf(dstptr, "<span class=\"%s\">%s</span>", curtoken->color, curtoken->token);
585629                  curcol += strlen(curtoken->token);
586630                  srcptr += strlen(curtoken->token) - 1;
587631                  ch = 0;
r3514r3515
613657            if (!in_comment && !in_inline_comment && !in_quotes && (ch == '"' || ch == '\''))
614658            {
615659               if (color_quotes)
616                  dstptr += sprintf(dstptr, "<span style=\"" STRING_STYLE "\">%c", ch);
660                  dstptr += sprintf(dstptr, "<span class=\"string\">%c", ch);
617661               else
618662                  *dstptr++ = ch;
619663               in_quotes = ch;
r3514r3515
679723   core_fprintf(dst, "\t</pre>\n");
680724
681725   /* close the file */
682   output_footer_and_close_file(dst);
726   output_footer_and_close_file(dst, tempfooter, srcfile_subpath);
727   astring_free((astring *)srcfile_subpath);
683728   core_fclose(src);
684729   return 0;
685730}
r3514r3515
695740    HTML file with a standard header
696741-------------------------------------------------*/
697742
698static core_file *create_file_and_output_header(const astring *filename, const char *title, const char *subtitle)
743static core_file *create_file_and_output_header(const astring *filename, const astring *template, const astring *path)
699744{
745   astring *modified;
700746   core_file *file;
701747
702748   /* create the indexfile */
r3514r3515
704750      return NULL;
705751
706752   /* print a header */
707   core_fprintf(file,
708      "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
709      "\n"
710      "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
711      "<head>\n"
712      "\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n"
713      "\t<title>%s</title>\n"
714      "\t<link rel=\"stylesheet\" href=\"http://mamedev.org/styles-site.css\" type=\"text/css\" />\n"
715      "</head>\n"
716      "\n"
717      "<body>\n"
718      "\t<div id=\"outer\">\n"
719      "\n"
720      "\t<div id=\"banner\">\n"
721      "\t<h1>%s</h1>\n"
722      "\t<h2>%s</h2>\n"
723      "\t</div>\n"
724      "\n"
725      "\t<div id=\"left\">\n"
726      "\t<div class=\"sidebar\">\n"
727      "\t<!--#include virtual=\"/links.txt\" -->\n"
728      "\t</div>\n"
729      "\t</div>\n"
730      "\n"
731      "\t<div id=\"center\">\n"
732      "\t<div class=\"content\">\n"
733      "\n",
734      title, title, (subtitle == NULL) ? "&nbsp;" : subtitle
735   );
753   modified = astring_dup(template);
754   astring_replacec(modified, 0, "<!--PATH-->", astring_c(path));
755   core_fwrite(file, astring_c(modified), astring_len(modified));
736756
737757   /* return the file */
758   astring_free(modified);
738759   return file;
739760}
740761
r3514r3515
744765    standard footer to an HTML file and close it
745766-------------------------------------------------*/
746767
747static void output_footer_and_close_file(core_file *file)
768static void output_footer_and_close_file(core_file *file, const astring *template, const astring *path)
748769{
749   core_fprintf(file,
750      "\n"
751      "\t</div>\n"
752      "\t</div>\n"
753      "\t</div>\n"
754      "</body>"
755      "\n"
756      "</html>\n"
757   );
770   astring *modified;
771
772   modified = astring_dup(template);
773   astring_replacec(modified, 0, "<!--PATH-->", astring_c(path));
774   core_fwrite(file, astring_c(modified), astring_len(modified));
775   astring_free(modified);
758776   core_fclose(file);
759777}
760778
src/emu/cpu/cpu.mak
r3514r3515
665665CPUDEFS += -DHAS_AT89C4051=$(if $(filter AT89C4051,$(CPUS)),1,0)
666666
667667ifneq ($(filter I8031 I8032 I8051 I8052 I8751 I8752 I80C31 I80C32 I80C51 I80C52 I87C51 I87C52 AT89C4051,$(CPUS)),)
668OBJDIRS += $(CPUOBJ)/i8051
669CPUOBJS += $(CPUOBJ)/i8051/i8051.o
670DBGOBJS += $(CPUOBJ)/i8051/8051dasm.o
668OBJDIRS += $(CPUOBJ)/mcs51
669CPUOBJS += $(CPUOBJ)/mcs51/mcs51.o
670DBGOBJS += $(CPUOBJ)/mcs51/mcs51dasm.o
671671endif
672672
673$(CPUOBJ)/i8051/i8051.o:   $(CPUSRC)/i8051/i8051.c \
674                     $(CPUSRC)/i8051/i8051.h \
675                     $(CPUSRC)/i8051/i8051ops.c
673$(CPUOBJ)/mcs51/mcs51.o:   $(CPUSRC)/mcs51/mcs51.c \
674                     $(CPUSRC)/mcs51/mcs51.h \
675                     $(CPUSRC)/mcs51/mcs51ops.c
676676
677677
678678
src/emu/cpu/dsp56k/dsp56ops.c
r3514r3515
9595static size_t dsp56k_op_bra       (const UINT16 op, const UINT16 op2, UINT8* cycles);
9696static size_t dsp56k_op_bra_1    (const UINT16 op, UINT8* cycles);
9797static size_t dsp56k_op_bra_2    (const UINT16 op, UINT8* cycles);
98static size_t dsp56k_op_brkc    (const UINT16 op, UINT8* cycles);
98static size_t dsp56k_op_brkcc    (const UINT16 op, UINT8* cycles);
9999static size_t dsp56k_op_bscc    (const UINT16 op, const UINT16 op2, UINT8* cycles);
100100static size_t dsp56k_op_bscc_1    (const UINT16 op, UINT8* cycles);
101101static size_t dsp56k_op_bsr       (const UINT16 op, const UINT16 op2, UINT8* cycles);
r3514r3515
164164
165165
166166static void execute_register_to_register_data_move(const UINT16 op, typed_pointer* d_register, UINT64* prev_accum_value);
167static void execute_address_register_update(const UINT16 op, typed_pointer* d_register, UINT64* prev_accum_value);
167168static void execute_x_memory_data_move (const UINT16 op, typed_pointer* d_register, UINT64* prev_accum_value);
168169static void execute_x_memory_data_move2(const UINT16 op, typed_pointer* d_register);
169170
170171
171static UINT16 decode_BBB_bitmask(UINT16 BBB, UINT16 *iVal);
172static int decode_cccc_table(UINT16 cccc);
173static void decode_DDDDD_table(UINT16 DDDDD, typed_pointer* ret);
174static void decode_DD_table(UINT16 DD, typed_pointer* ret);
175static void decode_F_table(UINT16 F, typed_pointer* ret);
176static void decode_h0hF_table(UINT16 h0h, UINT16 F, typed_pointer* src_ret, typed_pointer* dst_ret);
177static void decode_HH_table(UINT16 HH, typed_pointer* ret);
178static void decode_HHH_table(UINT16 HHH, typed_pointer* ret);
179static void decode_IIII_table(UINT16 IIII, typed_pointer* src_ret, typed_pointer* dst_ret, void *working);
180static void decode_JJJF_table(UINT16 JJJ, UINT16 F, typed_pointer* src_ret, typed_pointer* dst_ret);
181static void decode_JJF_table(UINT16 JJ, UINT16 F, typed_pointer* src_ret, typed_pointer* dst_ret);
182static void decode_QQF_special_table(UINT16 QQ, UINT16 F, void **S1, void **S2, void **D);
183static void decode_RR_table(UINT16 RR, typed_pointer* ret);
184static void decode_Z_table(UINT16 Z, typed_pointer* ret);
185static void execute_m_table(int x, UINT16 m);
186static void execute_MM_table(UINT16 rnum, UINT16 MM);
187static UINT16 execute_q_table(int x, UINT16 q);
188#ifdef UNUSED_FUNCTION
189static void execute_z_table(int x, UINT16 z);
190#endif
191static UINT16 assemble_address_from_Pppppp_table(UINT16 P, UINT16 ppppp);
192static UINT16 assemble_address_from_IO_short_address(UINT16 pp);
193static UINT16 assemble_address_from_6bit_signed_relative_short_address(UINT16 srs);
172static UINT16   decode_BBB_bitmask(UINT16 BBB, UINT16 *iVal);
173static int      decode_cccc_table(UINT16 cccc);
174static void      decode_DDDDD_table(UINT16 DDDDD, typed_pointer* ret);
175static void      decode_DD_table(UINT16 DD, typed_pointer* ret);
176static void      decode_F_table(UINT16 F, typed_pointer* ret);
177static void      decode_h0hF_table(UINT16 h0h, UINT16 F, typed_pointer* src_ret, typed_pointer* dst_ret);
178static void      decode_HH_table(UINT16 HH, typed_pointer* ret);
179static void      decode_HHH_table(UINT16 HHH, typed_pointer* ret);
180static void      decode_IIII_table(UINT16 IIII, typed_pointer* src_ret, typed_pointer* dst_ret, void *working);
181static void      decode_JJJF_table(UINT16 JJJ, UINT16 F, typed_pointer* src_ret, typed_pointer* dst_ret);
182static void      decode_JJF_table(UINT16 JJ, UINT16 F, typed_pointer* src_ret, typed_pointer* dst_ret);
183static void      decode_QQF_special_table(UINT16 QQ, UINT16 F, void **S1, void **S2, void **D);
184static void      decode_QQQF_special_table(UINT16 QQQ, UINT16 F, void **S1, void **S2, void **D);
185static void      decode_RR_table(UINT16 RR, typed_pointer* ret);
186static void      decode_Z_table(UINT16 Z, typed_pointer* ret);
194187
188static void      execute_m_table(int x, UINT16 m);
189static void      execute_MM_table(UINT16 rnum, UINT16 MM);
190static UINT16   execute_q_table(int RR, UINT16 q);
191static void      execute_z_table(int RR, UINT16 z);
192
193static UINT16   assemble_address_from_Pppppp_table(UINT16 P, UINT16 ppppp);
194static UINT16   assemble_address_from_IO_short_address(UINT16 pp);
195static UINT16   assemble_address_from_6bit_signed_relative_short_address(UINT16 srs);
196
195197static void dsp56k_process_loop(void);
196198static void dsp56k_process_rep(size_t repSize);
197199
r3514r3515
280282
281283      /* Now evaluate the parallel data move */
282284      // TODO // decode_dual_x_memory_data_read(op, parallel_move_str, parallel_move_str2);
285      logerror("DSP56k: Unemulated Dual X Memory Data Move @ 0x%x\n", PC);
283286   }
284287   /* X Memory Data Write and Register Data Move : 0001 011k RRDD ---- : A-140 */
285288   else if ((op & 0xfe00) == 0x1600)
r3514r3515
300303
301304      /* Now evaluate the parallel data move */
302305      // TODO // decode_x_memory_data_write_and_register_data_move(op, parallel_move_str, parallel_move_str2);
306      logerror("DSP56k: Unemulated Dual X Memory Data And Register Data Move @ 0x%x\n", PC);
303307   }
304308
305309   /* Handle Other parallel types */
r3514r3515
555559            execute_register_to_register_data_move(op, &d_register, &prev_accum_value);
556560            break;
557561         case kAddressRegister:
558            // TODO // decode_address_register_update(op, parallel_move_str);
562            execute_address_register_update(op, &d_register, &prev_accum_value);
559563            break;
560564         case kXMemoryDataMove:
561565            execute_x_memory_data_move(op, &d_register, &prev_accum_value);
r3514r3515
565569            break;
566570         case kXMemoryDataMoveWithDisp:
567571            // TODO // decode_x_memory_data_move_with_short_displacement(op, op2, parallel_move_str);
572            logerror("DSP56k: Unemulated Memory Data Move With Disp Parallel move @ 0x%x\n", PC);
568573            break;
569574         }
570575      }
r3514r3515
722727   /* BRKc : 0000 0001 0001 cccc : A-52 */
723728   else if ((op & 0xfff0) == 0x0110)
724729   {
725      size = dsp56k_op_brkc(op, &cycle_count);
730      size = dsp56k_op_brkcc(op, &cycle_count);
726731   }
727732   /* BScc : 0000 0111 --01 cccc xxxx xxxx xxxx xxxx : A-54 */
728733   else if (((op & 0xff30) == 0x0710) && ((op2 & 0x0000) == 0x0000))
r3514r3515
12321237/* MOVE : .... .... 0001 0001 : A-128 */
12331238static size_t dsp56k_op_move(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
12341239{
1240   /* Equivalent to a nop with a parallel move */
1241   /* These can't be used later.  Hopefully compilers would pick this up. */
1242   *p_accum = 0;
1243   d_register->addr = NULL;
1244   d_register->data_type = DT_BYTE;
1245
12351246   /* S L E U N Z V C */
12361247   /* * * - - - - - - */
1237   return 0;
1248   /* TODO: S, L */
1249   cycles += 2;   /* TODO: + mv oscillator cycles */
1250   return 1;
12381251}
12391252
12401253/* TFR : .... .... 0001 FJJJ : A-212 */
12411254static size_t dsp56k_op_tfr(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
12421255{
1256   typed_pointer S = {NULL, DT_BYTE};
1257   typed_pointer D = {NULL, DT_BYTE};
1258
1259   decode_JJJF_table(BITS(op_byte,0x0007),BITS(op_byte,0x0008), &S, &D);
1260
1261   *p_accum = *((UINT64*)D.addr);
1262
1263   SetDestinationValue(S, D);
1264
1265   d_register->addr = D.addr;
1266   d_register->data_type = D.data_type;
1267
12431268   /* S L E U N Z V C */
1244   /* - - - - - - - - */
1245   return 0;
1269   /* * * - - - - - - */
1270   /* TODO: S, L */
1271   cycles += 2;      /* TODO: + mv oscillator cycles */
1272   return 1;
12461273}
12471274
12481275/* RND : .... .... 0010 F000 : A-188 */
r3514r3515
12881315/* INC24 : .... .... 0010 F011 : A-106 */
12891316static size_t dsp56k_op_inc24(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
12901317{
1318   UINT32 workBits24;
1319
1320   typed_pointer D = {NULL, DT_BYTE};
1321   decode_F_table(BITS(op_byte,0x0008), &D);
1322
1323   /* Save some data for the parallel move */
1324   *p_accum = *((UINT64*)D.addr);
1325
1326   /* TODO: I wonder if workBits24 should be signed? */
1327   workBits24 = ((*((UINT64*)D.addr)) & U64(0x000000ffffff0000)) >> 16;
1328   workBits24++;
1329   workBits24 &= 0x00ffffff;      /* Solves -x issues */
1330
1331   /* Set the D bits with the dec result */
1332   *((UINT64*)D.addr) &= U64(0x000000000000ffff);
1333   *((UINT64*)D.addr) |= (((UINT64)(workBits24)) << 16);
1334
1335   d_register->addr = D.addr;
1336   d_register->data_type = D.data_type;
1337
12911338   /* S L E U N Z V C */
12921339   /* * * * * * ? * * */
1293   /* Z - Set if the 24 most significant bits of the destination result are all zeroes. */
1294   return 0;
1340   /* TODO: S, L, E, U, V, C */
1341   if ( *((UINT64*)D.addr) & U64(0x0000008000000000))       N_bit_set(1);
1342   if ((*((UINT64*)D.addr) & U64(0x000000ffffff0000)) == 0) Z_bit_set(1);
1343
1344   cycles += 2;      /* TODO: + mv oscillator clock cycles */
1345   return 1;
12951346}
12961347
12971348/* OR : .... .... 0010 F1JJ : A-176 */
r3514r3515
16281679/* MPY : .... .... 1k00 FQQQ : A-160    -- CONFIRMED TYPO IN DOCS (HHHH vs HHHW) */
16291680static size_t dsp56k_op_mpy(const UINT16 op_byte, typed_pointer* d_register, UINT64* p_accum, UINT8* cycles)
16301681{
1682   UINT16 k = 0;
1683   INT64 result = 0;
1684
1685   INT32 s1 = 0;
1686   INT32 s2 = 0;
1687
1688   void* D = NULL;
1689   void* S1 = NULL;
1690   void* S2 = NULL;
1691
1692   decode_QQQF_special_table(BITS(op_byte,0x0007), BITS(op_byte,0x0008), &S1, &S2, &D);
1693
1694   k = BITS(op_byte,0x0040);
1695
1696   /* Negative sign */
1697   if (!k)
1698      s1 = *((INT16*)S1);
1699   else
1700      s1 = (*((INT16*)S1)) * -1;
1701
1702   s2 = *((INT16*)S2);
1703
1704   /* Fixed-point 2's complement multiplication requires a shift */
1705   result = ( s1 * s2 ) << 1;
1706
1707   (*((UINT64*)D)) = result & U64(0x000000ffffffffff);
1708
16311709   /* S L E U N Z V C */
16321710   /* * * * * * * * - */
1633   return 0;
1711   /* TODO: S, L, E, V */
1712   if ( *((UINT64*)D) & U64(0x0000008000000000))      N_bit_set(1);
1713   if ((*((UINT64*)D) & U64(0x000000ffffffffff)) == 0) Z_bit_set(1);
1714
1715   cycles += 2;      /* TODO: +mv oscillator cycles */
1716   return 1;
16341717}
16351718
16361719/* MPYR : .... .... 1k01 FQQQ : A-162 */
r3514r3515
17051788/* ASL4 : 0001 0101 0011 F001 : A-30 */
17061789static size_t dsp56k_op_asl4(const UINT16 op, UINT8* cycles)
17071790{
1791   UINT64 p_accum = 0;
1792   typed_pointer D = {NULL, DT_BYTE};
1793   decode_F_table(BITS(op,0x0008), &D);
1794
1795   p_accum = *((UINT64*)D.addr);
1796
1797   *((UINT64*)D.addr) = (*((UINT64*)D.addr)) << 4;
1798   *((UINT64*)D.addr) = (*((UINT64*)D.addr)) & U64(0x000000ffffffffff);
1799
17081800   /* S L E U N Z V C */
17091801   /* - ? * * * * ? ? */
1710   /* V - Set if an arithmetic overflow occurs in the 40 bit result. Also set if bit 5 through 39 are
1802   /* TODO: L, E, U  */
1803   /* V - Set if an arithmetic overflow occurs in the 40 bit result. Also set if bit 35 through 39 are
17111804           not the same. */
17121805   /* C - Set if bit 36 of source operand is set. Cleared otherwise. */
1713   return 0;
1806   if (*((UINT64*)D.addr) & U64(0x0000008000000000)) N_bit_set(1); else N_bit_set(0);
1807   if (*((UINT64*)D.addr) == 0) Z_bit_set(1); else Z_bit_set(0);
1808   if ( (*((UINT64*)D.addr) & U64(0x000000ff00000000)) != (p_accum & U64(0x000000ff00000000)) ) V_bit_set(1); else V_bit_set(0);
1809   if (p_accum & U64(0x0000001000000000)) C_bit_set(1); else C_bit_set(0);
1810
1811   cycles += 2;
1812   return 1;
17141813}
17151814
17161815/* ASR4 : 0001 0101 0011 F000 : A-34 */
17171816static size_t dsp56k_op_asr4(const UINT16 op, UINT8* cycles)
17181817{
1818   UINT64 p_accum = 0;
1819   typed_pointer D = {NULL, DT_BYTE};
1820   decode_F_table(BITS(op,0x0008), &D);
1821
1822   p_accum = *((UINT64*)D.addr);
1823
1824   *((UINT64*)D.addr) = (*((UINT64*)D.addr)) >> 4;
1825   *((UINT64*)D.addr) = (*((UINT64*)D.addr)) & U64(0x000000ffffffffff);
1826
1827   /* The top 4 bits become the old bit 39 */
1828   if (p_accum & U64(0x0000008000000000))
1829      *((UINT64*)D.addr) |= U64(0x000000f000000000);
1830   else
1831      *((UINT64*)D.addr) &= (~U64(0x000000f000000000));
1832
17191833   /* S L E U N Z V C */
17201834   /* - * * * * * 0 ? */
1835   /* TODO: E, U  */
17211836   /* C - Set if bit 3 of source operand is set. Cleared otherwise. */
1722   return 0;
1837   if (*((UINT64*)D.addr) & U64(0x0000008000000000)) N_bit_set(1); else N_bit_set(0);
1838   if (*((UINT64*)D.addr) == 0) Z_bit_set(1); else Z_bit_set(0);
1839   V_bit_set(0);
1840   if (p_accum & U64(0x0000000000000008)) C_bit_set(1); else C_bit_set(0);
1841
1842   cycles += 2;
1843   return 1;
17231844}
17241845
17251846/* ASR16 : 0001 0101 0111 F000 : A-36 */
r3514r3515
19332054/* Bcc : 0000 0111 --11 cccc xxxx xxxx xxxx xxxx : A-48 */
19342055static size_t dsp56k_op_bcc(const UINT16 op, const UINT16 op2, UINT8* cycles)
19352056{
2057   int shouldBranch = decode_cccc_table(BITS(op,0x000f));
2058
2059   if (shouldBranch)
2060   {
2061      INT16 offset = (INT16)op2;
2062
2063      PC += 2;
2064
2065      core.ppc = PC;
2066      PC += offset;
2067      change_pc(PC);
2068
2069      cycles += 4;
2070      return 0;
2071   }
2072   else
2073   {
2074      cycles += 4;
2075      return 2;
2076   }
2077
19362078   /* S L E U N Z V C */
19372079   /* - - - - - - - - */
19382080   return 0;
r3514r3515
20112153   return 0;
20122154}
20132155
2014/* BRKc : 0000 0001 0001 cccc : A-52 */
2015static size_t dsp56k_op_brkc(const UINT16 op, UINT8* cycles)
2156/* BRKcc : 0000 0001 0001 cccc : A-52 */
2157static size_t dsp56k_op_brkcc(const UINT16 op, UINT8* cycles)
20162158{
2159   int shouldBreak = decode_cccc_table(BITS(op,0x000f));
2160
2161   if (shouldBreak)
2162   {
2163      /* TODO: I think this PC = LA thing is off-by-1, but it's working this way because its consistently so */
2164      core.ppc = PC;
2165      PC = LA;
2166      change_pc(PC);
2167
2168      SR = SSL;   /* TODO: A-83.  I believe only the Loop Flag and Forever Flag come back here. */
2169      SP--;
2170
2171      LA = SSH;
2172      LC = SSL;
2173      SP--;
2174
2175      cycles += 8;
2176      return 0;
2177   }
2178   else
2179   {
2180      cycles += 2;
2181      return 1;
2182   }
2183
20172184   /* S L E U N Z V C */
20182185   /* - - - - - - - - */
20192186   return 0;
r3514r3515
22382405/* DO FOREVER : 0000 0000 0000 0010 xxxx xxxx xxxx xxxx : A-88 */
22392406static size_t dsp56k_op_doforever(const UINT16 op, const UINT16 op2, UINT8* cycles)
22402407{
2408   /* First instruction cycle */
2409   SP++;
2410   SSH = LA;
2411   SSL = LC;
2412
2413   /* Second instruction cycle */
2414   SP++;
2415   SSH = PC + 2;
2416   SSL = SR;
2417   LA = PC + 2 + op2;
2418
2419   /* Third instruction cycle */
2420   LF_bit_set(1);
2421   FV_bit_set(1);
2422
22412423   /* S L E U N Z V C */
22422424   /* - - - - - - - - */
2243   return 0;
2425   cycles += 6;
2426   return 2;
22442427}
22452428
22462429/* ENDDO : 0000 0000 0000 1001 : A-92 */
r3514r3515
24322615   else
24332616   {
24342617      /* Signed * Unsigned */
2618      /* TODO: THERE IS A HUGE CHANCE THIS DOESN'T WORK RIGHT */
24352619      UINT32 s1 = (UINT32)((INT32)(*((UINT16*)S1)));
24362620      UINT32 s2 = (UINT32)(*((UINT16*)S2));
24372621      result = ( s1 * s2 ) << 1;
r3514r3515
33443528   }
33453529}
33463530
3531static void decode_QQQF_special_table(UINT16 QQQ, UINT16 F, void **S1, void **S2, void **D)
3532{
3533   UINT16 switchVal = (QQQ << 1) | F;
3534
3535   switch(switchVal)
3536   {
3537      case 0x0: *S1 = &X0;  *S2 = &X0;  *D = &A;  break;
3538      case 0x1: *S1 = &X0;  *S2 = &X0;  *D = &B;  break;
3539      case 0x2: *S1 = &X1;  *S2 = &X0;  *D = &A;  break;
3540      case 0x3: *S1 = &X1;  *S2 = &X0;  *D = &B;  break;
3541      case 0x4: *S1 = &A1;  *S2 = &Y0;  *D = &A;  break;
3542      case 0x5: *S1 = &A1;  *S2 = &Y0;  *D = &B;  break;
3543      case 0x6: *S1 = &B1;  *S2 = &X0;  *D = &A;  break;
3544      case 0x7: *S1 = &B1;  *S2 = &X0;  *D = &B;  break;
3545      case 0x8: *S1 = &Y0;  *S2 = &X0;  *D = &A;  break;
3546      case 0x9: *S1 = &Y0;  *S2 = &X0;  *D = &B;  break;
3547      case 0xa: *S1 = &Y1;  *S2 = &X0;  *D = &A;  break;
3548      case 0xb: *S1 = &Y1;  *S2 = &X0;  *D = &B;  break;
3549      case 0xc: *S1 = &Y0;  *S2 = &X1;  *D = &A;  break;
3550      case 0xd: *S1 = &Y0;  *S2 = &X1;  *D = &B;  break;
3551      case 0xe: *S1 = &Y1;  *S2 = &X1;  *D = &A;  break;
3552      case 0xf: *S1 = &Y1;  *S2 = &X1;  *D = &B;  break;
3553   }
3554}
3555
33473556static void decode_RR_table(UINT16 RR, typed_pointer* ret)
33483557{
33493558   switch(RR)
r3514r3515
34083617}
34093618
34103619/* Returns R value */
3411static UINT16 execute_q_table(int x, UINT16 q)
3620static UINT16 execute_q_table(int RR, UINT16 q)
34123621{
34133622   UINT16 *rX = 0x0000;
34143623   UINT16 *nX = 0x0000;
34153624
3416   switch(x)
3625   switch(RR)
34173626   {
34183627      case 0x0: rX = &R0;  nX = &N0;  break;
34193628      case 0x1: rX = &R1;  nX = &N1;  break;
r3514r3515
34323641   return 0x00;
34333642}
34343643
3435#ifdef UNUSED_FUNCTION
3436static void execute_z_table(int x, UINT16 z)
3644static void execute_z_table(int RR, UINT16 z)
34373645{
3438   UINT16 *rX = 0x00 ;
3439   UINT16 *nX = 0x00 ;
3646   UINT16 *rX = 0x00;
3647   UINT16 *nX = 0x00;
34403648
3441   switch(x)
3649   switch(RR)
34423650   {
3443      case 0x0: rX = &R0 ; nX = &N0 ; break ;
3444      case 0x1: rX = &R1 ; nX = &N1 ; break ;
3445      case 0x2: rX = &R2 ; nX = &N2 ; break ;
3446      case 0x3: rX = &R3 ; nX = &N3 ; break ;
3651      case 0x0: rX = &R0;  nX = &N0;  break;
3652      case 0x1: rX = &R1;  nX = &N1;  break;
3653      case 0x2: rX = &R2;  nX = &N2;  break;
3654      case 0x3: rX = &R3;  nX = &N3;  break;
34473655   }
34483656
3449   if (!z)
3657   switch(z)
34503658   {
3451      (*rX)-- ;
3659      case 0x0: (*rX)--;             break;
3660      case 0x1: (*rX) = (*rX) + (*nX); break;
34523661   }
3453   else
3454   {
3455      (*rX) = (*rX)+(*nX) ;
3456   }
34573662}
3458#endif
3663
34593664static UINT16 assemble_address_from_Pppppp_table(UINT16 P, UINT16 ppppp)
34603665{
34613666   UINT16 destAddr = 0x00 ;
r3514r3515
34873692
34883693static void dsp56k_process_loop(void)
34893694{
3490   if (LF_bit())
3695   /* TODO: This might not work for dos nested in doForevers */
3696   if (LF_bit() && FV_bit())
34913697   {
3698      /* Do Forever*/
34923699      if (PC == LA)
34933700      {
3701         LC--;
3702
3703         core.ppc = PC;
3704         PC = SSH;
3705         change_pc(PC);
3706      }
3707   }
3708   else if (LF_bit())
3709   {
3710      /* Do */
3711      if (PC == LA)
3712      {
34943713         if (LC == 1)
34953714         {
34963715            /* End of loop processing */
r3514r3515
35383757/***************************************************************************
35393758    Parallel Memory Ops
35403759***************************************************************************/
3541/* Register to Register Data Move : 0100 IIII ---- ---- */
3760/* Register to Register Data Move : 0100 IIII ---- ---- : A-132 */
35423761static void execute_register_to_register_data_move(const UINT16 op, typed_pointer* d_register, UINT64* prev_accum_value)
35433762{
35443763   typed_pointer S = {NULL, DT_BYTE};
r3514r3515
35603779   }
35613780}
35623781
3782/* Address Register Update : 0011 0zRR ---- ---- : A-135 */
3783static void execute_address_register_update(const UINT16 op, typed_pointer* d_register, UINT64* prev_accum_value)
3784{
3785   execute_z_table(BITS(op,0x0300), BITS(op,0x0400));
3786}
3787
35633788/* X Memory Data Move : 1mRR HHHW ---- ---- : A-137 */
35643789static void execute_x_memory_data_move(const UINT16 op, typed_pointer* d_register, UINT64* prev_accum_value)
35653790{
src/emu/cpu/dsp56k/dsp56dsm.c
r3514r3515
8080static size_t dsp56k_dasm_bra      (const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str, const offs_t pc);
8181static size_t dsp56k_dasm_bra_1      (const UINT16 op, char* opcode_str, char* arg_str, const offs_t pc);
8282static size_t dsp56k_dasm_bra_2      (const UINT16 op, char* opcode_str, char* arg_str);
83static size_t dsp56k_dasm_brkc      (const UINT16 op, char* opcode_str, char* arg_str);
83static size_t dsp56k_dasm_brkcc      (const UINT16 op, char* opcode_str, char* arg_str);
8484static size_t dsp56k_dasm_bscc      (const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str, const offs_t pc);
8585static size_t dsp56k_dasm_bscc_1   (const UINT16 op, char* opcode_str, char* arg_str);
8686static size_t dsp56k_dasm_bsr      (const UINT16 op, const UINT16 op2, char* opcode_str, char* arg_str, const offs_t pc);
r3514r3515
732732   /* BRKc : 0000 0001 0001 cccc : A-52 */
733733   else if ((op & 0xfff0) == 0x0110)
734734   {
735      size = dsp56k_dasm_brkc(op, opcode_str, arg_str);
735      size = dsp56k_dasm_brkcc(op, opcode_str, arg_str);
736736   }
737737   /* BScc : 0000 0111 --01 cccc xxxx xxxx xxxx xxxx : A-54 */
738738   else if (((op & 0xff30) == 0x0710) && ((op2 & 0x0000) == 0x0000))
r3514r3515
17851785}
17861786
17871787/* BRKc : 0000 0001 0001 cccc : A-52 */
1788static size_t dsp56k_dasm_brkc(const UINT16 op, char* opcode_str, char* arg_str)
1788static size_t dsp56k_dasm_brkcc(const UINT16 op, char* opcode_str, char* arg_str)
17891789{
17901790   char M[32];
17911791   decode_cccc_table(BITS(op,0x000f), M);
src/emu/cpu/mcs51/mcs51.c
r0r3515
1/*****************************************************************************
2 *
3 *   i8051.c
4 *   Portable MCS-51 Family Emulator
5 *
6 *   Chips in the family:
7 *   8051 Product Line (8031,8051,8751)
8 *   8052 Product Line (8032,8052,8752)
9 *   8054 Product Line (8054)
10 *   8058 Product Line (8058)
11 *
12 *   Copyright Steve Ellenoff, all rights reserved.
13 *
14 *   - This source code is released as freeware for non-commercial purposes.
15 *   - You are free to use and redistribute this code in modified or
16 *     unmodified form, provided you list me in the credits.
17 *   - If you modify this source code, you must add a notice to each modified
18 *     source file that it has been changed.  If you're a nice person, you
19 *     will clearly mark each change too.  :)
20 *   - If you wish to use this for commercial purposes, please contact me at
21 *     sellenoff@hotmail.com
22 *   - The author of this copywritten work reserves the right to change the
23 *     terms of its usage and license at any time, including retroactively
24 *   - This entire notice must remain in the source code.
25 *
26 *  This work is based on:
27 *  #1) 'Intel(tm) MC51 Microcontroller Family Users Manual' and
28 *  #2) 8051 simulator by Travis Marlatte
29 *  #3) Portable UPI-41/8041/8741/8042/8742 emulator V0.1 by Juergen Buchmueller (MAME CORE)
30 *
31 *****************************************************************************/
32
33/******************************************************************************
34 *  Notes:
35 *        *Important*: Internal ROM needs to be treated the same as external rom by the programmer
36 *                     creating the driver (ie, use standard cpu rom region)
37 *
38 *        The term cycles is used here to really refer to clock oscilations, because 1 machine cycle
39 *        actually takes 12 oscilations.
40 *
41 *        Read/Write/Modify Instruction -
42 *          Data is read from the Port Latch (not the Port Pin!), possibly modified, and
43 *          written back to (the pin? and) the latch!
44 *
45 *          The following all perform this on a port address..
46 *          (anl, orl, xrl, jbc, cpl, inc, dec, djnz, mov px.y,c, clr px.y, setb px.y)
47 *
48 *        Serial UART emulation is not really accurate, but faked enough to work as far as i can tell
49 *
50 *        August 27,2003: Currently support for only 8031/8051/8751 chips (ie 128 RAM)
51 *        October 14,2003: Added initial support for the 8752 (ie 256 RAM)
52 *        October 22,2003: Full support for the 8752 (ie 256 RAM)
53 *        July 28,2004: Fixed MOVX command and added External Ram Paging Support
54 *        July 31,2004: Added Serial Mode 0 Support & Fixed Interrupt Flags for Serial Port
55 *
56 *        NOW Implemented: RAM paging using hardware configured addressing...
57 *        (July 28,2004)   the "MOVX a,@R0/R1" and "MOVX @R0/R1,a" commands can use any of the other ports
58 *                 to output a page offset into external ram, but it is totally based on the hardware setup.
59 *
60 *        Timing needs to be implemented via MAME timers perhaps?
61 *
62 *        October, 2008, Couriersud - Major rewrite
63 *
64 *****************************************************************************/
65
66/* TODO: Varios
67 *  - EA pin - defined by architecture, must implement:
68 *    1 means external access, bypassing internal ROM
69 *  - T0 output clock ?
70 *
71 * - Implement 80C52 extended serial capabilities
72 * - Full Timer support (all modes)
73 * - Fix serial communication - This is a big hack (but working) right now.
74 * - Implement 83C751 in sslam.c
75 * - Fix cardline.c
76 * - Fix sslam.c and cardline.c
77 *      most likely due to different behaviour of I/O pins. The boards
78 *      actually use 80CXX, i.e. CMOS versions.
79 *      "Normal" 805X will return a 0 if reading from a output port which has
80 *      a 0 written to it's latch. At least cardline expects a 1 here.
81 *
82 * Done:
83 * - Implemented cmos features
84 * - Implemented 80C52 interrupt handling
85 * - Fix segas18.c (segaic16.c) memory handling.
86 * - Fix sslam.c
87 * - Fix limenko.c videopkr.c : Issue with core allocation of ram (duplicate savestate)
88 * - Handle internal ram better (debugger visible)
89 *  - Fixed port reading
90 *  - Rewrote Macros for better readibility
91 *  - Fixed and rewrote Interrupt handling
92 *  - Now returns INTERNAL_DIVIDER, adjusted cycle counts
93 *  - Remove unnecessary and duplicated code
94 * - Remove unnecessary functions
95 * - Rewrite to have sfr-registers stored in int_ram.
96 * - Debugger may now watch sfr-registers as well.
97 * - implemented interrupt callbacks (HOLD_LINE now supported)
98 * - Runtime switch for processor type - remove ifdefs
99 * - internal memory maps for internal rom versions (internal ram now displayed in debugger)
100 * - more timer cleanups from manual
101 */
102
103#include "debugger.h"
104#include "deprecat.h"
105#include "mcs51.h"
106
107#define VERBOSE 1
108
109#define LOG(x)   do { if (VERBOSE) logerror x; } while (0)
110
111/***************************************************************************
112    CONSTANTS
113***************************************************************************/
114
115enum
116{
117   FEATURE_NONE         = 0x00,
118   FEATURE_I8052         = 0x01,
119   FEATURE_CMOS         = 0x02,
120   FEATURE_I80C52         = 0x04,
121   FEATURE_DS5002FP      = 0x08,
122};
123
124/* Internal address in SFR of registers */
125enum
126{
127   ADDR_PSW   = 0xd0,
128   ADDR_ACC   = 0xe0,
129   ADDR_B      = 0xf0,
130
131   ADDR_P0      = 0x80,
132   ADDR_SP      = 0x81,
133   ADDR_DPL   = 0x82,
134   ADDR_DPH   = 0x83,
135   ADDR_PCON   = 0x87,
136   ADDR_TCON   = 0x88,
137   ADDR_TMOD   = 0x89,
138   ADDR_TL0   = 0x8a,
139   ADDR_TL1   = 0x8b,
140   ADDR_TH0   = 0x8c,
141   ADDR_TH1   = 0x8d,
142   ADDR_P1      = 0x90,
143   ADDR_SCON   = 0x98,
144   ADDR_SBUF   = 0x99,
145   ADDR_P2      = 0xa0,
146   ADDR_IE      = 0xa8,
147   ADDR_P3      = 0xb0,
148   ADDR_IP      = 0xb8,
149
150   /* 8052 Only registers */
151    ADDR_T2CON   = 0xc8,
152    ADDR_RCAP2L   = 0xca,
153    ADDR_RCAP2H   = 0xcb,
154    ADDR_TL2   = 0xcc,
155    ADDR_TH2   = 0xcd,
156
157    /* 80C52 Only registers */
158    ADDR_IPH   = 0xb7,
159    ADDR_SADDR   = 0xa9,
160    ADDR_SADEN   = 0xb9,
161
162    /* Philips 80C52 */
163    ADDR_AUXR   = 0x8e,
164    ADDR_AUXR1   = 0xa2,
165
166    /* DS5002FP */
167   ADDR_CRCR   = 0xc1,
168   ADDR_CRCL   = 0xc2,
169   ADDR_CRCH   = 0xc3,
170   ADDR_MCON   = 0xc6,
171   ADDR_TA      = 0xc7,
172   ADDR_RNR   = 0xcf,
173   ADDR_RPCTL   = 0xd8,
174   ADDR_RPS   = 0xda,
175
176};
177
178/* PC vectors */
179
180enum
181{
182   V_RESET = 0x000,   /* power on address */
183   V_IE0   = 0x003,   /* External Interrupt 0 */
184   V_TF0   = 0x00b,   /* Timer 0 Overflow */
185   V_IE1   = 0x013,   /* External Interrupt 1 */
186   V_TF1   = 0x01b,   /* Timer 1 Overflow */
187   V_RITI   = 0x023,   /* Serial Receive/Transmit */
188
189   /* 8052 Only Vectors */
190   V_TF2   = 0x02b,   /* Timer 2 Overflow */
191
192   /* DS5002FP */
193   V_PFI   = 0x02b,   /* Power Failure Interrupt */
194};
195
196/***************************************************************************
197    TYPE DEFINITIONS
198***************************************************************************/
199
200typedef struct _mcs51_uart mcs51_uart;
201struct _mcs51_uart
202{
203   UINT8   data_out;      //Data to send out
204   UINT8   bits_to_send;   //How many bits left to send when transmitting out the serial port
205
206   int      smod_div;      /* signal divided by 2^SMOD */
207   int      rx_clk;         /* rx clock */
208   int      tx_clk;         /* tx clock */
209   UINT8   delay_cycles;   //Gross Hack;
210};
211
212typedef struct _mcs51_regs mcs51_regs;
213struct _mcs51_regs
214{
215   //Internal stuff
216   UINT16   ppc;         //previous pc
217   UINT16   pc;            //current pc
218   UINT16   features;      //features of this cpu
219   UINT8   rwm;         //Signals that the current instruction is a read/write/modify instruction
220
221   int      inst_cycles;      /* cycles for the current instruction */
222   int      ram_mask;           /* second ram bank for indirect access available ? */
223   int      num_interrupts;      /* number of interrupts supported */
224   int      recalc_parity;      /* recalculate parity before next instruction */
225   UINT32   last_line_state;   /* last state of input lines line */
226   int      t0_cnt;            /* number of 0->1 transistions on T0 line */
227   int      t1_cnt;            /* number of 0->1 transistions on T1 line */
228   int      t2_cnt;            /* number of 0->1 transistions on T2 line */
229   int      t2ex_cnt;         /* number of 0->1 transistions on T2EX line */
230   int      cur_irq_prio;      /* Holds value of the current IRQ Priority Level; -1 if no irq */
231   UINT8   irq_active;         /* mask which irq levels are serviced */
232   UINT8   irq_prio[8];      /* interrupt priority */
233
234   mcs51_uart uart;         /* internal uart */
235
236   /* Internal Ram */
237   UINT8   *internal_ram;      /* 128 RAM (8031/51) + 128 RAM in second bank (8032/52) */
238   UINT8   *sfr_ram;         /* 128 SFR - these are in 0x80 - 0xFF */
239
240   /* SFR Callbacks */
241   void    (*sfr_write)(size_t offset, UINT8 data);
242   UINT8   (*sfr_read)(size_t offset);
243
244   /* Interrupt Callback */
245   int    (*irq_callback)(int irqline);
246
247   /* Serial Port TX/RX Callbacks */
248   // TODO: Move to special port r/w
249   void    (*serial_tx_callback)(int data);   //Call back funciton when sending data out of serial port
250   int      (*serial_rx_callback)(void);      //Call back function to retrieve data when receiving serial port data
251
252   /* DS5002FP */
253   struct {
254      UINT8   previous_ta;      /* Previous Timed Access value */
255      UINT8   ta_window;         /* Limed Access window */
256      UINT8   range;            /* Memory Range */
257      const ds5002fp_config *config;   /* Bootstrap Configuration */
258   } ds5002fp;
259
260
261};
262
263/***************************************************************************
264    MACROS
265***************************************************************************/
266
267#undef change_pc
268#define change_pc(x)
269
270/* Read Opcode/Opcode Arguments from Program Code */
271#define ROP(pc)         cpu_readop(pc)
272#define ROP_ARG(pc)      cpu_readop_arg(pc)
273
274/* Read a byte from External Code Memory (Usually Program Rom(s) Space) */
275#define CODEMEM_R(a)   (UINT8)program_read_byte_8le(a)
276
277/* Read/Write a byte from/to External Data Memory (Usually RAM or other I/O) */
278#define DATAMEM_R(a)   (UINT8)io_read_byte_8le(a)
279#define DATAMEM_W(a,v)   io_write_byte_8le(a,v)
280//#define DATAMEM_R(a)  (UINT8)data_read_byte_8le(a)
281//#define DATAMEM_W(a,v)    data_write_byte_8le(a,v)
282
283/* Read/Write a byte from/to the Internal RAM */
284
285#define IRAM_R(a)      iram_read(a)
286#define IRAM_W(a, d)   iram_write(a, d)
287
288/* Read/Write a byte from/to the Internal RAM indirectly */
289/* (called from indirect addressing)                     */
290#define IRAM_IR(a)       data_read_byte_8le((a) & mcs51.ram_mask)
291#define IRAM_IW(a, d)    data_write_byte_8le((a) & mcs51.ram_mask, d)
292
293/* Form an Address to Read/Write to External RAM indirectly */
294/* (called from indirect addressing)                        */
295#define ERAM_ADDR(a,m)   external_ram_iaddr(a,m)
296
297/* Read/Write a bit from Bit Addressable Memory */
298#define BIT_R(a)      bit_address_r(a)
299#define BIT_W(a,v)      bit_address_w(a,v)
300
301/* Input/Output a byte from given I/O port */
302#define IN(port)      ((UINT8)io_read_byte(port))
303#define OUT(port,value) io_write_byte(port,value)
304
305
306/***************************************************************************
307    SHORTCUTS
308***************************************************************************/
309
310#define PPC    mcs51.ppc
311#define PC      mcs51.pc
312#define RWM      mcs51.rwm
313
314/* SFR Registers - These are accessed directly for speed on read */
315/* Read accessors                                                */
316
317#define SFR_A(a)      mcs51.sfr_ram[(a)]
318#define SET_SFR_A(a,v)   do { SFR_A(a) = (v); } while (0)
319
320#define ACC         ((const UINT8) SFR_A(ADDR_ACC))
321#define PSW         ((const UINT8) SFR_A(ADDR_PSW))
322
323#define P0         ((const UINT8) SFR_A(ADDR_P0))
324#define P1         ((const UINT8) SFR_A(ADDR_P1))
325#define P2         ((const UINT8) SFR_A(ADDR_P2))
326#define P3         ((const UINT8) SFR_A(ADDR_P3))
327
328#define SP         SFR_A(ADDR_SP)
329#define DPL         SFR_A(ADDR_DPL)
330#define DPH         SFR_A(ADDR_DPH)
331#define PCON      SFR_A(ADDR_PCON)
332#define TCON      SFR_A(ADDR_TCON)
333#define TMOD      SFR_A(ADDR_TMOD)
334#define TL0         SFR_A(ADDR_TL0)
335#define TL1         SFR_A(ADDR_TL1)
336#define TH0         SFR_A(ADDR_TH0)
337#define TH1         SFR_A(ADDR_TH1)
338#define SCON      SFR_A(ADDR_SCON)
339#define IE         SFR_A(ADDR_IE)
340#define IP         SFR_A(ADDR_IP)
341#define B         SFR_A(ADDR_B)
342#define SBUF      SFR_A(ADDR_SBUF)
343
344#define R_REG(r)   mcs51.internal_ram[(r) | (PSW & 0x18)]
345#define DPTR      ((DPH<<8) | DPL)
346
347/* 8052 Only registers */
348#define T2CON      SFR_A(ADDR_T2CON)
349#define RCAP2L      SFR_A(ADDR_RCAP2L)
350#define RCAP2H      SFR_A(ADDR_RCAP2H)
351#define TL2         SFR_A(ADDR_TL2)
352#define TH2         SFR_A(ADDR_TH2)
353
354/* 80C52 Only registers */
355#define IPH         SFR_A(ADDR_IPH)
356#define SADDR      SFR_A(ADDR_SADDR)
357#define SADEN      SFR_A(ADDR_SADEN)
358
359/* Philips 80C52 */
360/* ============= */
361/* Reduced EMI Mode
362 * The AO bit (AUXR.0) in the AUXR register when set disables the
363 * ALE output.
364 */
365#define AUXR      SFR_A(ADDR_AUXR)
366
367/* The dual DPTR structure (see Figure 12) is a way by which the
368 * 80C52/54/58 will specify the address of an external data memory
369 * location. There are two 16-bit DPTR registers that address the
370 * external memory, and a single bit called DPS = AUXR1/bit0 that
371 * allows the program code to switch between them.
372 */
373#define AUXR1      SFR_A(ADDR_AUXR1)
374
375/* DS5002FP only registers */
376#define CRCR      SFR_A(ADDR_CRCR)
377#define CRCL      SFR_A(ADDR_CRCL)
378#define CRCH      SFR_A(ADDR_CRCH)
379#define MCON      SFR_A(ADDR_MCON)
380#define TA         SFR_A(ADDR_TA)
381#define RNR         SFR_A(ADDR_RNR)
382#define RPCTL      SFR_A(ADDR_RPCTL)
383#define RPS         SFR_A(ADDR_RPS)
384
385
386/* WRITE accessors */
387
388/* Shortcuts */
389
390#define SET_PSW(v)   do { SFR_A(ADDR_PSW) = (v); SET_PARITY(); } while (0)
391#define SET_ACC(v)   do { SFR_A(ADDR_ACC) = (v); SET_PARITY(); } while (0)
392
393/* These trigger actions on modification and have to be written through SFR_W */
394#define SET_P0(v)   IRAM_W(ADDR_P0, v)
395#define SET_P1(v)   IRAM_W(ADDR_P1, v)
396#define SET_P2(v)   IRAM_W(ADDR_P2, v)
397#define SET_P3(v)   IRAM_W(ADDR_P3, v)
398
399/* Within the cpu core, do not trigger a send */
400#define SET_SBUF(v)   SET_SFR_A(ADDR_SBUF, v)
401
402/* No actions triggered on write */
403#define SET_REG(r, v)   do { mcs51.internal_ram[(r) | (PSW & 0x18)] = (v); } while (0)
404
405#define SET_DPTR(n)      do { DPH = ((n) >> 8) & 0xff; DPL = (n) & 0xff; } while (0)
406
407/* Macros for Setting Flags */
408#define SET_X(R, v) do { R = (v);} while (0)
409
410#define SET_CY(n)      SET_PSW((PSW & 0x7f) | (n<<7))   //Carry Flag
411#define SET_AC(n)      SET_PSW((PSW & 0xbf) | (n<<6))   //Aux.Carry Flag
412#define SET_FO(n)      SET_PSW((PSW & 0xdf) | (n<<5))   //User Flag
413#define SET_RS(n)      SET_PSW((PSW & 0xe7) | (n<<3))   //R Bank Select
414#define SET_OV(n)      SET_PSW((PSW & 0xfb) | (n<<2))   //Overflow Flag
415#define SET_P(n)      SET_PSW((PSW & 0xfe) | (n<<0))   //Parity Flag
416
417#define SET_BIT(R, n, v) do { R = (R & ~(1<<(n))) | ((v) << (n));} while (0)
418#define GET_BIT(R, n) (((R)>>(n)) & 0x01)
419
420#define SET_EA(n)      SET_BIT(IE, 7, n)      //Global Interrupt Enable/Disable
421#define SET_ES(n)      SET_BIT(IE, 4, v)      //Serial Interrupt Enable/Disable
422#define SET_ET1(n)      SET_BIT(IE, 3, n)      //Timer 1 Interrupt Enable/Disable
423#define SET_EX1(n)      SET_BIT(IE, 2, n)      //External Int 1 Interrupt Enable/Disable
424#define SET_ET0(n)      SET_BIT(IE, 1, n)      //Timer 0 Interrupt Enable/Disable
425#define SET_EX0(n)      SET_BIT(IE, 0, n)      //External Int 0 Interrupt Enable/Disable
426/* 8052 Only flags */
427#define SET_ET2(n)      SET_BIT(IE, 5, n)      //Timer 2 Interrupt Enable/Disable
428
429/* 8052 Only flags */
430#define SET_PT2(n)      SET_BIT(IP, 5, n);   //Set Timer 2 Priority Level
431
432#define SET_PS0(n)      SET_BIT(IP, 4, n)      //Set Serial Priority Level
433#define SET_PT1(n)      SET_BIT(IP, 3, n)      //Set Timer 1 Priority Level
434#define SET_PX1(n)      SET_BIT(IP, 2, n)      //Set External Int 1 Priority Level
435#define SET_PT0(n)      SET_BIT(IP, 1, n)      //Set Timer 0 Priority Level
436#define SET_PX0(n)      SET_BIT(IP, 0, n)      //Set External Int 0 Priority Level
437
438#define SET_TF1(n)      SET_BIT(TCON, 7, n)   //Indicated Timer 1 Overflow Int Triggered
439#define SET_TR1(n)      SET_BIT(TCON, 6, n)  //IndicateS Timer 1 is running
440#define SET_TF0(n)      SET_BIT(TCON, 5, n)   //Indicated Timer 0 Overflow Int Triggered
441#define SET_TR0(n)      SET_BIT(TCON, 4, n)  //IndicateS Timer 0 is running
442#define SET_IE1(n)      SET_BIT(TCON, 3, n)  //Indicated External Int 1 Triggered
443#define SET_IT1(n)      SET_BIT(TCON, 2, n)  //Indicates how External Int 1 is Triggered
444#define SET_IE0(n)      SET_BIT(TCON, 1, n)  //Indicated External Int 0 Triggered
445#define SET_IT0(n)      SET_BIT(TCON, 0, n)  //Indicates how External Int 0 is Triggered
446
447#define SET_SM0(n)      SET_BIT(SCON, 7, n)   //Sets Serial Port Mode
448#define SET_SM1(n)      SET_BIT(SCON, 6, n)  //Sets Serial Port Mode
449#define SET_SM2(n)      SET_BIT(SCON, 5, n)   //Sets Serial Port Mode (Multiprocesser mode)
450#define SET_REN(n)      SET_BIT(SCON, 4, n)  //Sets Serial Port Receive Enable
451#define SET_TB8(n)      SET_BIT(SCON, 3, n)  //Transmit 8th Bit
452#define SET_RB8(n)      SET_BIT(SCON, 2, n)  //Receive 8th Bit
453#define SET_TI(n)      SET_BIT(SCON, 1, n)  //Indicates Transmit Interrupt Occurred
454#define SET_RI(n)      SET_BIT(SCON, 0, n)  //Indicates Receive Interrupt Occurred
455
456#define SET_GATE1(n)   SET_BIT(TMOD, 7, n)   //Timer 1 Gate Mode
457#define SET_CT1(n)      SET_BIT(TMOD, 6, n)  //Timer 1 Counter Mode
458#define SET_M1_1(n)      SET_BIT(TMOD, 5, n)   //Timer 1 Timer Mode Bit 1
459#define SET_M1_0(n)      SET_BIT(TMOD, 4, n)  //Timer 1 Timer Mode Bit 0
460#define SET_GATE0(n)   SET_BIT(TMOD, 3, n)  //Timer 0 Gate Mode
461#define SET_CT0(n)      SET_BIT(TMOD, 2, n)  //Timer 0 Counter Mode
462#define SET_M0_1(n)      SET_BIT(TMOD, 1, n)  //Timer 0 Timer Mode Bit 1
463#define SET_M0_0(n)      SET_BIT(TMOD, 0, n)  //Timer 0 Timer Mode Bit 0
464
465
466
467/* 8052 Only flags - T2CON Flags */
468#define SET_TF2(n)      SET_BIT(T2CON, 7, n)   //Indicated Timer 2 Overflow Int Triggered
469#define SET_EXF2(n)      SET_BIT(T2CON, 6, n)   //Indicates Timer 2 External Flag
470#define SET_RCLK(n)      SET_BIT(T2CON, 5, n)   //Receive Clock
471#define SET_TCLK(n)      SET_BIT(T2CON, 4, n)   //Transmit Clock
472#define SET_EXEN2(n)   SET_BIT(T2CON, 3, n)   //Timer 2 External Interrupt Enable
473#define SET_TR2(n)      SET_BIT(T2CON, 2, n)   //Indicates Timer 2 is running
474#define SET_CT2(n)      SET_BIT(T2CON, 1, n)   //Sets Timer 2 Counter/Timer Mode
475#define SET_CP(n)      SET_BIT(T2CON, 0, n)   //Sets Timer 2 Capture/Reload Mode
476
477#define SET_GF1(n)      SET_BIT(PCON, 3, n)
478#define SET_GF0(n)      SET_BIT(PCON, 2, n)
479#define SET_PD(n)      SET_BIT(PCON, 1, n)
480#define SET_IDL(n)      SET_BIT(PCON, 0, n)
481
482/* Macros for accessing flags */
483
484#define GET_CY         GET_BIT(PSW, 7)
485#define GET_AC         GET_BIT(PSW, 6)
486#define GET_FO         GET_BIT(PSW, 5)
487#define GET_RS         GET_BIT(PSW, 3)
488#define GET_OV         GET_BIT(PSW, 2)
489#define GET_P         GET_BIT(PSW, 0)
490
491#define GET_EA         GET_BIT(IE, 7)
492#define GET_ET2         GET_BIT(IE, 5)
493#define GET_ES         GET_BIT(IE, 4)
494#define GET_ET1         GET_BIT(IE, 3)
495#define GET_EX1         GET_BIT(IE, 2)
496#define GET_ET0         GET_BIT(IE, 1)
497#define GET_EX0         GET_BIT(IE, 0)
498
499/* 8052 Only flags */
500#define GET_PT2         GET_BIT(IP, 5)
501
502#define GET_PS         GET_BIT(IP, 4)
503#define GET_PT1         GET_BIT(IP, 3)
504#define GET_PX1         GET_BIT(IP, 2)
505#define GET_PT0         GET_BIT(IP, 1)
506#define GET_PX0         GET_BIT(IP, 0)
507
508#define GET_TF1         GET_BIT(TCON, 7)
509#define GET_TR1         GET_BIT(TCON, 6)
510#define GET_TF0         GET_BIT(TCON, 5)
511#define GET_TR0         GET_BIT(TCON, 4)
512#define GET_IE1         GET_BIT(TCON, 3)
513#define GET_IT1         GET_BIT(TCON, 2)
514#define GET_IE0         GET_BIT(TCON, 1)
515#define GET_IT0         GET_BIT(TCON, 0)
516
517#define GET_SM0         GET_BIT(SCON, 7)
518#define GET_SM1         GET_BIT(SCON, 6)
519#define GET_SM2         GET_BIT(SCON, 5)
520#define GET_REN         GET_BIT(SCON, 4)
521#define GET_TB8         GET_BIT(SCON, 3)
522#define GET_RB8         GET_BIT(SCON, 2)
523#define GET_TI         GET_BIT(SCON, 1)
524#define GET_RI         GET_BIT(SCON, 0)
525
526#define GET_GATE1      GET_BIT(TMOD, 7)
527#define GET_CT1         GET_BIT(TMOD, 6)
528#define GET_M1_1      GET_BIT(TMOD, 5)
529#define GET_M1_0      GET_BIT(TMOD, 4)
530#define GET_GATE0      GET_BIT(TMOD, 3)
531#define GET_CT0         GET_BIT(TMOD, 2)
532#define GET_M0_1      GET_BIT(TMOD, 1)
533#define GET_M0_0      GET_BIT(TMOD, 0)
534
535#define GET_SMOD      GET_BIT(PCON, 7)
536
537/* Only in 80C51BH & other cmos */
538
539#define GET_GF1         GET_BIT(PCON, 3)
540#define GET_GF0         GET_BIT(PCON, 2)
541#define GET_PD         GET_BIT(PCON, 1)
542#define GET_IDL         (GET_BIT(PCON, 0) & ~(GET_PD))   /* PD takes precedence! */
543
544/* 8052 Only flags */
545#define GET_TF2         GET_BIT(T2CON, 7)
546#define GET_EXF2      GET_BIT(T2CON, 6)
547#define GET_RCLK      GET_BIT(T2CON, 5)
548#define GET_TCLK      GET_BIT(T2CON, 4)
549#define GET_EXEN2      GET_BIT(T2CON, 3)
550#define GET_TR2         GET_BIT(T2CON, 2)
551#define GET_CT2         GET_BIT(T2CON, 1)
552#define GET_CP         GET_BIT(T2CON, 0)
553
554/* DS5002FP Only flags */
555
556/* PCON Flags - DS5002FP */
557
558#define GET_POR         GET_BIT(PCON, 6)
559#define GET_PFW         GET_BIT(PCON, 5)
560#define GET_WTR         GET_BIT(PCON, 4)
561#define GET_EPFW      GET_BIT(PCON, 3)
562#define GET_EWT         GET_BIT(PCON, 2)
563
564#define   SET_PFW(n)      SET_BIT(PCON, 5, n)
565
566/* MCON Flags - DS5002FP */
567
568#define GET_PA         ((MCON & 0xf0)>>4)
569#define GET_RG1         GET_BIT(MCON, 3)
570#define GET_PES         GET_BIT(MCON, 2)
571#define GET_PM         GET_BIT(MCON, 1)
572#define GET_SL         GET_BIT(MCON, 0)
573
574/* RPCTL Flags - DS5002FP */
575#define GET_RNR         GET_BIT(RPCTL, 7) /* Bit 6 ?? */
576#define GET_EXBS      GET_BIT(RPCTL, 5)
577#define GET_AE         GET_BIT(RPCTL, 4)
578#define GET_IBI         GET_BIT(RPCTL, 3)
579#define GET_DMA         GET_BIT(RPCTL, 2)
580#define GET_RPCON      GET_BIT(RPCTL, 1)
581#define GET_RG0         GET_BIT(RPCTL, 0)
582
583
584/*Add and Subtract Flag settings*/
585#define DO_ADD_FLAGS(a,d,c)   do_add_flags(a,d,c)
586#define DO_SUB_FLAGS(a,d,c)   do_sub_flags(a,d,c)
587
588#define SET_PARITY()   do {mcs51.recalc_parity |= 1;} while (0)
589#define PUSH_PC()      push_pc()
590#define POP_PC()      pop_pc()
591
592#if 0
593/* Any pending IRQ */
594#define SERIALPORT_IRQ    ((R_SCON & 0x03) && GET_ES)
595#define TIMERS_IRQ        ((GET_TF0 && GET_ET0) || (GET_TF1 && GET_ET1))
596#define EXTERNAL_IRQ      ((GET_IE0 && GET_EX0) || (GET_IE1 && GET_EX1))
597
598#if (HAS_I8052 || HAS_I8752)
599#define NO_PENDING_IRQ  !(TIMERS_IRQ) && !(EXTERNAL_IRQ) && !(SERIALPORT_IRQ) && !(GET_ET2 && (GET_TF2 || GET_EXF2))
600#else
601#define NO_PENDING_IRQ  !(TIMERS_IRQ) && !(EXTERNAL_IRQ) && !(SERIALPORT_IRQ)
602#endif
603#endif
604
605/* Clear Current IRQ  */
606#define CLEAR_CURRENT_IRQ() clear_current_irq()
607
608/***************************************************************************
609    GLOBAL VARIABLES
610***************************************************************************/
611
612static int mcs51_icount;
613
614static mcs51_regs mcs51;
615
616
617/***************************************************************************
618    FUNCTION PROTOTYPES
619***************************************************************************/
620
621static void check_irqs(void);
622INLINE void serial_transmit(UINT8 data);
623
624/* Hold callback functions so they can be set by caller (before the cpu reset) */
625
626static void (*hold_serial_tx_callback)(int data);
627static int (*hold_serial_rx_callback)(void);
628
629/***************************************************************************
630    INLINE FUNCTIONS
631***************************************************************************/
632
633INLINE void clear_current_irq(void)
634{
635   //printf("reti cip %d, act %02x\n",mcs51.cur_irq_prio,  mcs51.irq_active);
636   //assert(mcs51.cur_irq_prio >= 0 && mcs51.irq_active);
637
638   if (mcs51.cur_irq_prio >= 0)
639      mcs51.irq_active &= ~(1 << mcs51.cur_irq_prio);
640   if (mcs51.irq_active & 4)
641      mcs51.cur_irq_prio = 2;
642   else if (mcs51.irq_active & 2)
643      mcs51.cur_irq_prio = 1;
644   else if (mcs51.irq_active & 1)
645      mcs51.cur_irq_prio = 0;
646   else
647      mcs51.cur_irq_prio = -1;
648   LOG(("New: %d %02x\n", mcs51.cur_irq_prio, mcs51.irq_active));
649}
650
651INLINE UINT8 r_acc(void) { return SFR_A(ADDR_ACC); }
652
653INLINE UINT8 r_psw(void) { return SFR_A(ADDR_PSW); }
654
655INLINE void update_ptrs(void)
656{
657   mcs51.internal_ram = memory_get_write_ptr(cpu_getactivecpu(), ADDRESS_SPACE_DATA, 0x00);
658   mcs51.sfr_ram = memory_get_write_ptr(cpu_getactivecpu(), ADDRESS_SPACE_DATA, 0x100);
659}
660
661
662/* Generate an external ram address for read/writing using indirect addressing mode */
663/*The lowest 8 bits of the address are passed in (from the R0/R1 register), however
664  the hardware can be configured to set the rest of the address lines to any available output port pins, which
665  means the only way we can implement this is to allow the driver to setup a callback to generate the
666  address as defined by the specific hardware setup. We'll assume the address won't be bigger than 32 bits
667
668  Couriersud, October 2008:
669  There is no way external hardware can distinguish between 8bit access and 16 bit access.
670  During 16bit access the high order byte of the address is output on port 2. We therefore
671  assume that most hardware will use port 2 for 8bit access as well.
672
673  On configurations where 8 bit access in conjunction with other ports is used,
674  it is up to the driver to use AM_MIRROR to mask out the high level address and
675  provide it's own mapping.
676*/
677
678INLINE offs_t external_ram_iaddr(offs_t offset, offs_t mem_mask)
679{
680   if (mem_mask == 0x00ff)
681      return (offset & mem_mask) | (P2 << 8);
682#if 0
683    if(mcs51.eram_iaddr_callback)
684        return mcs51.eram_iaddr_callback(machine,offset,mem_mask);
685    else
686        if (mem_mask <= 0x100) LOG(("mcs51 #%d: external ram address requested (8 bit offset=%02x), but no callback available! at PC:%04x\n", cpu_getactivecpu(), offset, PC));
687#endif
688   return offset;
689}
690
691/* Internal ram read/write */
692
693INLINE UINT8 iram_read(size_t offset)
694{
695   return (((offset) < 0x80) ? data_read_byte_8le(offset) : mcs51.sfr_read(offset));
696}
697
698INLINE void iram_write(size_t offset, UINT8 data)
699{
700   if ((offset) < 0x80)
701      data_write_byte_8le(offset, data);
702   else
703      mcs51.sfr_write(offset, data);
704}
705
706/*Push the current PC to the stack*/
707INLINE void push_pc(void)
708{
709   UINT8 tmpSP = SP+1;                  //Grab and Increment Stack Pointer
710   IRAM_IW(tmpSP, (PC & 0xff));            //Store low byte of PC to Internal Ram (Use IRAM_IW to store stack above 128 bytes)
711   tmpSP++;                           // ""
712   SP = tmpSP;                        // ""
713   IRAM_IW(tmpSP, ( (PC & 0xff00) >> 8));      //Store hi byte of PC to next address in Internal Ram (Use IRAM_IW to store stack above 128 bytes)
714}
715
716/*Pop the current PC off the stack and into the pc*/
717INLINE void pop_pc(void)
718{
719   UINT8 tmpSP = SP;                     //Grab Stack Pointer
720   PC = (IRAM_IR(tmpSP--) & 0xff) << 8;      //Store hi byte to PC (must use IRAM_IR to access stack pointing above 128 bytes)
721   PC = PC | IRAM_IR(tmpSP--);               //Store lo byte to PC (must use IRAM_IR to access stack pointing above 128 bytes)
722   SP = tmpSP;                        //Decrement Stack Pointer
723   change_pc(PC);
724}
725
726//Set the PSW Parity Flag
727INLINE void set_parity(void)
728{
729   //This flag will be set when the accumulator contains an odd # of bits set..
730   UINT8 p = 0;
731   int i;
732   UINT8 a = ACC;
733
734   for (i=0; i<8; i++) {      //Test for each of the 8 bits in the ACC!
735      p ^= (a & 1);
736      a = (a >> 1);
737   }
738
739   SET_P(p & 1);
740}
741
742INLINE UINT8 bit_address_r(UINT8 offset)
743{
744   UINT8   word;
745   UINT8   mask;
746   int   bit_pos;
747   int   distance;   /* distance between bit addressable words */
748               /* 1 for normal bits, 8 for sfr bit addresses */
749
750   //User defined bit addresses 0x20-0x2f (values are 0x0-0x7f)
751   if (offset < 0x80) {
752      distance = 1;
753      word = ( (offset & 0x78) >> 3) * distance + 0x20;
754      bit_pos = offset & 0x7;
755      mask = (0x1 << bit_pos);
756      return((IRAM_R(word) & mask) >> bit_pos);
757   }
758   //SFR bit addressable registers
759   else {
760      distance = 8;
761      word = ( (offset & 0x78) >> 3) * distance + 0x80;
762      bit_pos = offset & 0x7;
763      mask = (0x1 << bit_pos);
764      return ((IRAM_R(word) & mask) >> bit_pos);
765   }
766}
767
768
769INLINE void bit_address_w(UINT8 offset, UINT8 bit)
770{
771   int   word;
772   UINT8   mask;
773   int   bit_pos;
774   UINT8   result;
775   int   distance;
776
777   /* User defined bit addresses 0x20-0x2f (values are 0x0-0x7f) */
778   if (offset < 0x80) {
779      distance = 1;
780      word = ((offset & 0x78) >> 3) * distance + 0x20;
781      bit_pos = offset & 0x7;
782      bit = (bit & 0x1) << bit_pos;
783      mask = ~(1 << bit_pos) & 0xff;
784      result = IRAM_R(word) & mask;
785      result = result | bit;
786      IRAM_W(word, result);
787   }
788   /* SFR bit addressable registers */
789   else {
790      distance = 8;
791      word = ((offset & 0x78) >> 3) * distance + 0x80;
792      bit_pos = offset & 0x7;
793      bit = (bit & 0x1) << bit_pos;
794      mask = ~(1 << bit_pos) & 0xff;
795      result = IRAM_R(word) & mask;
796      result = result | bit;
797      IRAM_W(word, result);
798   }
799}
800
801INLINE void do_add_flags(UINT8 a, UINT8 data, UINT8 c)
802{
803   UINT16 result = a+data+c;
804   INT16 result1 = (INT8)a+(INT8)data+c;
805
806   SET_CY((result & 0x100) >> 8);
807   result = (a&0x0f)+(data&0x0f)+c;
808   SET_AC((result & 0x10) >> 4);
809   SET_OV(result1 < -128 || result1 > 127);
810}
811
812INLINE void do_sub_flags(UINT8 a, UINT8 data, UINT8 c)
813{
814   UINT16 result = a-(data+c);
815   INT16 result1 = (INT8)a-(INT8)(data+c);
816
817   SET_CY((result & 0x100) >> 8);
818   result = (a&0x0f)-((data&0x0f)+c);
819   SET_AC((result & 0x10) >> 4);
820   SET_OV((result1 < -128 || result1 > 127));
821}
822
823INLINE void transmit_receive(int source)
824{
825   int mode = (GET_SM0<<1) | GET_SM1;
826
827   if (source == 1) /* timer1 */
828      mcs51.uart.smod_div = (mcs51.uart.smod_div + 1) & (2-GET_SMOD);
829
830   switch(mode) {
831      //8 bit shifter ( + start,stop bit ) - baud set by clock freq / 12
832      case 0:
833         mcs51.uart.rx_clk += (source == 0) ? 16 : 0; /* clock / 12 */
834         mcs51.uart.tx_clk += (source == 0) ? 16 : 0; /* clock / 12 */
835         break;
836      //8 bit uart ( + start,stop bit ) - baud set by timer1 or timer2
837      case 1:
838      case 3:
839         if (source == 1)
840         {
841            mcs51.uart.tx_clk += (GET_TCLK ? 0 : !mcs51.uart.smod_div);
842            mcs51.uart.rx_clk += (GET_RCLK ? 0 : !mcs51.uart.smod_div);
843         }
844         if (source == 2)
845         {
846            mcs51.uart.tx_clk += (GET_TCLK ? 1 : 0);
847            mcs51.uart.rx_clk += (GET_RCLK ? 1 : 0);
848         }
849         break;
850      //9 bit uart
851      case 2:
852         mcs51.uart.rx_clk += (source == 0) ? (GET_SMOD ? 6 : 3) : 0; /* clock / 12 * 3 / 8 (16) = clock / 32 (64)*/
853         mcs51.uart.tx_clk += (source == 0) ? (GET_SMOD ? 6 : 3) : 0; /* clock / 12 */
854         break;
855   }
856   /* transmit ? */
857   if (mcs51.uart.tx_clk >= 16)
858   {
859      mcs51.uart.tx_clk &= 0x0f;
860      if(mcs51.uart.bits_to_send)
861      {
862         mcs51.uart.bits_to_send--;
863         if(mcs51.uart.bits_to_send == 0) {
864            //printf("Here1 %d\n",  mcs51.uart.bits_to_send);
865            //Call the callback function
866            if(mcs51.serial_tx_callback)
867               mcs51.serial_tx_callback(mcs51.uart.data_out);
868            //Set Interrupt Flag
869            SET_TI(1);
870            //Note: we'll let the main loop catch the interrupt
871         }
872      }
873
874   }
875   /* receive */
876   if (mcs51.uart.rx_clk >= 16)
877   {
878      mcs51.uart.rx_clk &= 0x0f;
879      if (mcs51.uart.delay_cycles>0)
880      {
881         mcs51.uart.delay_cycles--;
882         if (mcs51.uart.delay_cycles == 0)
883         {
884            int data = 0;
885            //Call our callball function to retrieve the data
886            if(mcs51.serial_rx_callback)
887               data = mcs51.serial_rx_callback();
888            //printf("RX Deliver %d\n", data);
889            SET_SBUF(data);
890            //Flag the IRQ
891            SET_RI(1);
892         }
893      }
894   }
895}
896
897
898INLINE void update_timer_t0(int cycles)
899{
900   int mode = (GET_M0_1<<1) | GET_M0_0;
901   UINT32 count = 0;
902
903   if (GET_TR0)
904   {
905      UINT32 delta;
906
907      /* counter / external input */
908      delta = GET_CT0 ? mcs51.t0_cnt : cycles;
909      /* taken, reset */
910      mcs51.t0_cnt = 0;
911      /* TODO: Not sure about IE0. The manual specifies INT0=high,
912         * which in turn means CLEAR_LINE.
913         * IE0 may be edge triggered depending on IT0 */
914      if (GET_GATE0 && !GET_IE0)
915         delta = 0;
916
917      switch(mode) {
918         case 0:         /* 13 Bit Timer Mode */
919            count = ((TH0<<5) | ( TL0 & 0x1f ) );
920            count += delta;
921            if ( count & 0xffffe000 ) /* Check for overflow */
922               SET_TF0(1);
923            TH0 = (count>>5) & 0xff;
924            TL0 =  count & 0x1f ;
925            break;
926         case 1:         /* 16 Bit Timer Mode */
927            count = ((TH0<<8) | TL0);
928            count += delta;
929            if ( count & 0xffff0000 ) /* Check for overflow */
930               SET_TF0(1);
931            TH0 = (count>>8) & 0xff;
932            TL0 = count & 0xff;
933            break;
934         case 2:         /* 8 Bit Autoreload */
935            count = ((UINT32) TL0) + delta;
936            if ( count & 0xffffff00 )             /* Check for overflow */
937            {
938               SET_TF0(1);
939               count += TH0;                   /* Reload timer */
940            }
941            /* Update new values of the counter */
942            TL0 =  count & 0xff;
943            break;
944         case 3:
945            /* Split Timer 1 */
946            count = ((UINT32) TL0) + delta;
947            if ( count & 0xffffff00 )             /* Check for overflow */
948               SET_TF0(1);
949            TL0 = count & 0xff;                /* Update new values of the counter */
950            break;
951      }
952   }
953   if (GET_TR1)
954   {
955      switch(mode)
956      {
957      case 3:
958         /* Split Timer 2 */
959         count = ((UINT32) TH0) + cycles;         /* No gate control or counting !*/
960         if ( count & 0xffffff00 )             /* Check for overflow */
961            SET_TF1(1);
962         TH0 = count & 0xff;                  /* Update new values of the counter */
963         break;
964      }
965   }
966}
967
968/* From the DS5002FP User Manual
969When Timer 1 is selected for operation in Mode 3, it stops counting and holds its current value. This
970action is the same as setting TR1 = 0. When Timer 0 is selected in Mode 3, Timer 1???s control bits are
971stolen as described above. As a result, Timer 1???s functions are limited in this MODE. It is forced to
972operate as a timer whose clock in-put is 12 tCLK and it cannot generate an interrupt on overflow. In
973addition, it also cannot be used with the GATE function. However, it can be started and stopped by
974switching it into or out of Mode 3 or it can be assigned as a baud rate generator for the serial port.
975*/
976
977/* Intel documentation:
978 *  Timer 1 may still be used in modes 0, 1, and 2, while timer 0
979 * is in mode 3. With one important exception:  No interrupts
980 * will be generated by timer 1 while timer 0 is using the TF1
981 * overflow flag
982 */
983
984INLINE void update_timer_t1(int cycles)
985{
986   UINT8 mode = (GET_M1_1<<1) | GET_M1_0;
987   UINT8 mode_0 = (GET_M0_1<<1) | GET_M0_0;
988   UINT32 count = 0;
989
990   if (mode_0 != 3)
991   {
992      if (GET_TR1)
993      {
994         UINT32 delta;
995         UINT32 overflow = 0;
996
997         /* counter / external input */
998         delta = GET_CT1 ? mcs51.t1_cnt : cycles;
999         /* taken, reset */
1000         mcs51.t1_cnt = 0;
1001         /* TODO: Not sure about IE0. The manual specifies INT0=high,
1002             * which in turn means CLEAR_LINE. Change to access last_state?
1003             * IE0 may be edge triggered depending on IT0 */
1004         if (GET_GATE1 && !GET_IE1)
1005            delta = 0;
1006
1007         //printf("mode: %d\n", mode);
1008         switch(mode) {
1009            case 0:         /* 13 Bit Timer Mode */
1010               count = ((TH1<<5) | ( TL1 & 0x1f ) );
1011               count += delta;
1012               overflow = count & 0xffffe000; /* Check for overflow */
1013               TH1 = (count>>5) & 0xff;
1014               TL1 =  count & 0x1f ;
1015               break;
1016            case 1:         /* 16 Bit Timer Mode */
1017               count = ((TH1<<8) | TL1);
1018               count += delta;
1019               overflow = count & 0xffff0000; /* Check for overflow */
1020               TH1 = (count>>8) & 0xff;
1021               TL1 = count & 0xff;
1022               break;
1023            case 2:         /* 8 Bit Autoreload */
1024               count = ((UINT32) TL1) + delta;
1025               overflow = count & 0xffffff00; /* Check for overflow */
1026               if ( overflow )
1027               {
1028                  count += TH1;                   /* Reload timer */
1029               }
1030               /* Update new values of the counter */
1031               TL1 =  count & 0xff;
1032               break;
1033            case 3:
1034               /* do nothing */
1035               break;
1036         }
1037         if (overflow)
1038         {
1039            SET_TF1(1);
1040            transmit_receive(1);
1041         }
1042      }
1043   }
1044   else
1045   {
1046      UINT32 delta;
1047      UINT32 overflow = 0;
1048
1049      delta =  cycles;
1050      /* taken, reset */
1051      mcs51.t1_cnt = 0;
1052      switch(mode) {
1053         case 0:         /* 13 Bit Timer Mode */
1054            count = ((TH1<<5) | ( TL1 & 0x1f ) );
1055            count += delta;
1056            overflow = count & 0xffffe000; /* Check for overflow */
1057            TH1 = (count>>5) & 0xff;
1058            TL1 =  count & 0x1f ;
1059            break;
1060         case 1:         /* 16 Bit Timer Mode */
1061            count = ((TH1<<8) | TL1);
1062            count += delta;
1063            overflow = count & 0xffff0000; /* Check for overflow */
1064            TH1 = (count>>8) & 0xff;
1065            TL1 = count & 0xff;
1066            break;
1067         case 2:         /* 8 Bit Autoreload */
1068            count = ((UINT32) TL1) + delta;
1069            overflow = count & 0xffffff00; /* Check for overflow */
1070            if ( overflow )
1071            {
1072               count += TH1;                   /* Reload timer */
1073            }
1074            /* Update new values of the counter */
1075            TL1 =  count & 0xff;
1076            break;
1077         case 3:
1078            /* do nothing */
1079            break;
1080      }
1081      if (overflow)
1082      {
1083         transmit_receive(1);
1084      }
1085   }
1086}
1087
1088INLINE void update_timer_t2(int cycles)
1089{
1090   /* Update Timer 2 */
1091   if(GET_TR2) {
1092      int mode = ((GET_TCLK | GET_RCLK) << 1) | GET_CP;
1093      int delta = GET_CT2 ? mcs51.t2_cnt : (mode & 2) ? cycles * (12/2) : cycles;
1094
1095      UINT32 count = ((TH2<<8) | TL2) + delta;
1096      mcs51.t2_cnt = 0;
1097
1098      switch (mode)
1099      {
1100         case 0:   /* 16 Bit Auto Reload */
1101            if ( count & 0xffff0000 )
1102            {
1103               SET_TF2(1);
1104               count += ((RCAP2H<<8) | RCAP2L);
1105            }
1106            else if (GET_EXEN2 && mcs51.t2ex_cnt>0)
1107            {
1108               count += ((RCAP2H<<8) | RCAP2L);
1109               mcs51.t2ex_cnt = 0;
1110            }
1111            TH2 = (count>>8) & 0xff;
1112            TL2 =  count & 0xff;
1113            break;
1114         case 1: /* 16 Bit Capture */
1115            if ( count & 0xffff0000 )
1116               SET_TF2(1);
1117            TH2 = (count>>8) & 0xff;
1118            TL2 =  count & 0xff;
1119
1120            if (GET_EXEN2 && mcs51.t2ex_cnt>0)
1121            {
1122               RCAP2H = TH2;
1123               RCAP2L = TL2;
1124               mcs51.t2ex_cnt = 0;
1125            }
1126            break;
1127         case 2:
1128         case 3:   /* Baud rate */
1129            if ( count & 0xffff0000 )
1130            {
1131               count += ((RCAP2H<<8) | RCAP2L);
1132               transmit_receive(2);
1133            }
1134            TH2 = (count>>8) & 0xff;
1135            TL2 =  count & 0xff;
1136            break;
1137      }
1138   }
1139}
1140
1141INLINE void update_timers(int cycles)
1142{
1143   /* Update Timer 0 */
1144   update_timer_t0(cycles);
1145   update_timer_t1(cycles);
1146
1147   if (mcs51.features & FEATURE_I8052)
1148   {
1149      update_timer_t2(cycles);
1150   }
1151}
1152
1153//Set up to transmit data out of serial port
1154//NOTE: Enable Serial Port Interrupt bit is NOT required to send/receive data!
1155
1156INLINE void serial_transmit(UINT8 data)
1157{
1158   int mode = (GET_SM0<<1) | GET_SM1;
1159
1160   //Flag that we're sending data
1161   mcs51.uart.data_out = data;
1162   //printf("serial_tansmit: %x %x\n", mode, data);
1163   switch(mode) {
1164      //8 bit shifter ( + start,stop bit ) - baud set by clock freq / 12
1165      case 0:
1166         mcs51.uart.bits_to_send = 8+2;
1167         break;
1168      //8 bit uart ( + start,stop bit ) - baud set by timer1 or timer2
1169      case 1:
1170         mcs51.uart.bits_to_send = 8+2;
1171         break;
1172      //9 bit uart
1173      case 2:
1174      case 3:
1175         LOG(("Serial mode %d not supported in mcs51!\n", mode));
1176         break;
1177   }
1178}
1179
1180INLINE void serial_receive(void)
1181{
1182   int mode = (GET_SM0<<1) | GET_SM1;
1183
1184   if(GET_ES && GET_REN) {
1185      switch(mode) {
1186         //8 bit shifter ( + start,stop bit ) - baud set by clock freq / 12
1187         case 0:
1188            mcs51.uart.delay_cycles = 8+2;
1189            break;
1190         //8 bit uart ( + start,stop bit ) - baud set by timer1 or timer2
1191         case 1:
1192            mcs51.uart.delay_cycles = 8+2;
1193            break;
1194         //9 bit uart
1195         case 2:
1196         case 3:
1197            LOG(("Serial mode %d not supported in mcs51!\n", mode));
1198            break;
1199      }
1200   }
1201}
1202
1203/* Check and update status of serial port */
1204INLINE void   update_serial(int cycles)
1205{
1206   while (--cycles>=0)
1207      transmit_receive(0);
1208}
1209
1210/* Check and update status of serial port */
1211INLINE void   update_irq_prio(UINT8 ipl, UINT8 iph)
1212{
1213   int i;
1214   for (i=0; i<8; i++)
1215      mcs51.irq_prio[i] = ((ipl >> i) & 1) | (((iph >>i ) & 1) << 1);
1216}
1217
1218/***************************************************************************
1219    CALLBACKS - TODO: Remove
1220***************************************************************************/
1221
1222
1223void i8051_set_serial_tx_callback(void (*callback)(int data))
1224{
1225   //Hold in static variable since this function can get called before reset has run, which wipes i8051 memory clean
1226   hold_serial_tx_callback = callback;
1227}
1228
1229void i8051_set_serial_rx_callback(int (*callback)(void))
1230{
1231   //Hold in static variable since this function can get called before reset has run, which wipes i8051 memory clean
1232   hold_serial_rx_callback = callback;
1233}
1234
1235/***************************************************************************
1236    OPCODES
1237***************************************************************************/
1238
1239#include "mcs51ops.c"
1240
1241
1242static void execute_op(UINT8 op)
1243{
1244   if (mcs51.recalc_parity)
1245   {
1246      set_parity();
1247      mcs51.recalc_parity = 0;
1248   }
1249
1250   switch( op )
1251   {
1252
1253      case 0x00:   nop();                     break;   //NOP
1254      case 0x01:   ajmp(op);                  break;   //AJMP code addr
1255      case 0x02:   ljmp();                     break;   //LJMP code addr
1256      case 0x03:   rr_a();                     break;   //RR A
1257      case 0x04:   inc_a();                  break;   //INC A
1258      case 0x05:   RWM=1; inc_mem(); RWM=0;      break;   //INC data addr
1259
1260      case 0x06:
1261      case 0x07:   inc_ir(op&1);               break;   //INC @R0/@R1
1262
1263      case 0x08:
1264      case 0x09:
1265      case 0x0a:
1266      case 0x0b:
1267      case 0x0c:
1268      case 0x0d:
1269      case 0x0e:
1270      case 0x0f:   inc_r(op&7);               break;   //INC R0 to R7
1271
1272      case 0x10:   RWM=1; jbc(); RWM=0;          break;    //JBC bit addr, code addr
1273      case 0x11:    acall(op);                  break;   //ACALL code addr
1274      case 0x12:   lcall();                   break;   //LCALL code addr
1275      case 0x13:   rrc_a();                  break;   //RRC A
1276      case 0x14:   dec_a();                  break;   //DEC A
1277      case 0x15:   RWM=1; dec_mem(); RWM=0;      break;   //DEC data addr
1278
1279      case 0x16:
1280      case 0x17:   dec_ir(op&1);                break;   //DEC @R0/@R1
1281
1282      case 0x18:
1283      case 0x19:
1284      case 0x1a:
1285      case 0x1b:
1286      case 0x1c:
1287      case 0x1d:
1288      case 0x1e:
1289      case 0x1f:   dec_r(op&7);                break;   //DEC R0 to R7
1290
1291      case 0x20:   jb();                     break;   //JB  bit addr, code addr
1292      case 0x21:   ajmp(op);                  break;   //AJMP code addr
1293      case 0x22:   ret();                     break;   //RET
1294      case 0x23:   rl_a();                     break;   //RL A
1295      case 0x24:   add_a_byte();               break;   //ADD A, #data
1296      case 0x25:   add_a_mem();               break;   //ADD A, data addr
1297
1298      case 0x26:
1299      case 0x27:   add_a_ir(op&1);               break;   //ADD A, @R0/@R1
1300
1301      case 0x28:
1302      case 0x29:
1303      case 0x2a:
1304      case 0x2b:
1305      case 0x2c:
1306      case 0x2d:
1307      case 0x2e:
1308      case 0x2f:   add_a_r(op&7);               break;   //ADD A, R0 to R7
1309
1310      case 0x30:   jnb();                     break;   //JNB bit addr, code addr
1311      case 0x31:   acall(op);                  break;   //ACALL code addr
1312      case 0x32:   reti();                     break;   //RETI
1313      case 0x33:   rlc_a();                  break;   //RLC A
1314      case 0x34:   addc_a_byte();               break;   //ADDC A, #data
1315      case 0x35:   addc_a_mem();               break;   //ADDC A, data addr
1316
1317      case 0x36:
1318      case 0x37:  addc_a_ir(op&1);            break;   //ADDC A, @R0/@R1
1319
1320      case 0x38:
1321      case 0x39:
1322      case 0x3a:
1323      case 0x3b:
1324      case 0x3c:
1325      case 0x3d:
1326      case 0x3e:
1327      case 0x3f:   addc_a_r(op&7);               break;   //ADDC A, R0 to R7
1328
1329      case 0x40:   jc();                     break;   //JC code addr
1330      case 0x41:   ajmp(op);                  break;   //AJMP code addr
1331      case 0x42:   RWM=1; orl_mem_a();   RWM=0;      break;   //ORL data addr, A
1332      case 0x43:   RWM=1; orl_mem_byte(); RWM=0;   break;   //ORL data addr, #data
1333      case 0x44:   orl_a_byte();               break;
1334      case 0x45:   orl_a_mem();               break;   //ORL A, data addr
1335
1336      case 0x46:
1337      case 0x47:   orl_a_ir(op&1);             break;   //ORL A, @RO/@R1
1338
1339      case 0x48:
1340      case 0x49:
1341      case 0x4a:
1342      case 0x4b:
1343      case 0x4c:
1344      case 0x4d:
1345      case 0x4e:
1346      case 0x4f:    orl_a_r(op&7);                break;   //ORL A, RO to R7
1347
1348      case 0x50:   jnc();                      break;   //JNC code addr
1349      case 0x51:  acall(op);                  break;   //ACALL code addr
1350      case 0x52:   RWM=1; anl_mem_a(); RWM=0;      break;   //ANL data addr, A
1351      case 0x53:   RWM=1; anl_mem_byte(); RWM=0;   break;   //ANL data addr, #data
1352      case 0x54:   anl_a_byte();               break;   //ANL A, #data
1353      case 0x55:   anl_a_mem();               break;   //ANL A, data addr
1354
1355      case 0x56:
1356      case 0x57:   anl_a_ir(op&1);               break;   //ANL A, @RO/@R1
1357
1358      case 0x58:
1359      case 0x59:
1360      case 0x5a:
1361      case 0x5b:
1362      case 0x5c:
1363      case 0x5d:
1364      case 0x5e:
1365      case 0x5f:   anl_a_r(op&7);               break;   //ANL A, RO to R7
1366
1367      case 0x60:   jz();                     break;   //JZ code addr
1368      case 0x61:   ajmp(op);                   break;   //AJMP code addr
1369      case 0x62:   RWM=1; xrl_mem_a(); RWM=0;      break;   //XRL data addr, A
1370      case 0x63:   RWM=1; xrl_mem_byte(); RWM=0;   break;   //XRL data addr, #data
1371      case 0x64:   xrl_a_byte();               break;   //XRL A, #data
1372      case 0x65:   xrl_a_mem();               break;   //XRL A, data addr
1373
1374      case 0x66:
1375      case 0x67:   xrl_a_ir(op&1);               break;   //XRL A, @R0/@R1
1376
1377      case 0x68:
1378      case 0x69:
1379      case 0x6a:
1380      case 0x6b:
1381      case 0x6c:
1382      case 0x6d:
1383      case 0x6e:
1384      case 0x6f:   xrl_a_r(op&7);               break;   //XRL A, R0 to R7
1385
1386      case 0x70:   jnz();                     break;   //JNZ code addr
1387      case 0x71:   acall(op);                  break;   //ACALL code addr
1388      case 0x72:   orl_c_bitaddr();            break;   //ORL C, bit addr
1389      case 0x73:   jmp_iadptr();               break;   //JMP @A+DPTR
1390      case 0x74:   mov_a_byte();               break;   //MOV A, #data
1391      case 0x75:   mov_mem_byte();               break;   //MOV data addr, #data
1392
1393      case 0x76:
1394      case 0x77:   mov_ir_byte(op&1);            break;   //MOV @R0/@R1, #data
1395
1396      case 0x78:
1397      case 0x79:
1398      case 0x7a:
1399      case 0x7b:
1400      case 0x7c:
1401      case 0x7d:
1402      case 0x7e:
1403      case 0x7f:   mov_r_byte(op&7);            break;   //MOV R0 to R7, #data
1404
1405      case 0x80:   sjmp();                     break;   //SJMP code addr
1406      case 0x81:   ajmp(op);                  break;   //AJMP code addr
1407      case 0x82:   anl_c_bitaddr();            break;   //ANL C, bit addr
1408      case 0x83:   movc_a_iapc();               break;   //MOVC A, @A + PC
1409      case 0x84:   div_ab();                  break;   //DIV AB
1410      case 0x85:   mov_mem_mem();               break;   //MOV data addr, data addr
1411
1412      case 0x86:
1413      case 0x87:   mov_mem_ir(op&1);            break;   //MOV data addr, @R0/@R1
1414
1415      case 0x88:
1416      case 0x89:
1417      case 0x8a:
1418      case 0x8b:
1419      case 0x8c:
1420      case 0x8d:
1421      case 0x8e:
1422      case 0x8f:   mov_mem_r(op&7);            break;   //MOV data addr,R0 to R7
1423
1424      case 0x90:   mov_dptr_byte();            break;   //MOV DPTR, #data
1425      case 0x91:   acall(op);                  break;   //ACALL code addr
1426      case 0x92:   RWM = 1; mov_bitaddr_c(); RWM = 0; break;   //MOV bit addr, C
1427      case 0x93:   movc_a_iadptr();            break;   //MOVC A, @A + DPTR
1428      case 0x94:   subb_a_byte();               break;   //SUBB A, #data
1429      case 0x95:   subb_a_mem();               break;   //SUBB A, data addr
1430
1431      case 0x96:
1432      case 0x97:   subb_a_ir(op&1);            break;   //SUBB A, @R0/@R1
1433
1434      case 0x98:
1435      case 0x99:
1436      case 0x9a:
1437      case 0x9b:
1438      case 0x9c:
1439      case 0x9d:
1440      case 0x9e:
1441      case 0x9f:   subb_a_r(op&7);               break;   //SUBB A, R0 to R7
1442
1443      case 0xa0:   orl_c_nbitaddr();            break;   //ORL C, /bit addr
1444      case 0xa1:   ajmp(op);                  break;   //AJMP code addr
1445      case 0xa2:   mov_c_bitaddr();            break;   //MOV C, bit addr
1446      case 0xa3:   inc_dptr();                  break;   //INC DPTR
1447      case 0xa4:   mul_ab();                  break;   //MUL AB
1448      case 0xa5:   illegal(op);               break;   //reserved
1449
1450      case 0xa6:
1451      case 0xa7:   mov_ir_mem(op&1);            break;   //MOV @R0/@R1, data addr
1452
1453      case 0xa8:
1454      case 0xa9:
1455      case 0xaa:
1456      case 0xab:
1457      case 0xac:
1458      case 0xad:
1459      case 0xae:
1460      case 0xaf:   mov_r_mem(op&7);            break;   //MOV R0 to R7, data addr
1461
1462      case 0xb0:   anl_c_nbitaddr();            break;   //ANL C,/bit addr
1463      case 0xb1:   acall(op);                  break;   //ACALL code addr
1464      case 0xb2:   RWM=1; cpl_bitaddr(); RWM=0;    break;   //CPL bit addr
1465      case 0xb3:   cpl_c();                  break;   //CPL C
1466      case 0xb4:   cjne_a_byte();               break;   //CJNE A, #data, code addr
1467      case 0xb5:   cjne_a_mem();               break;   //CJNE A, data addr, code addr
1468
1469      case 0xb6:
1470      case 0xb7:   cjne_ir_byte(op&1);          break;   //CJNE @R0/@R1, #data, code addr
1471
1472      case 0xb8:
1473      case 0xb9:
1474      case 0xba:
1475      case 0xbb:
1476      case 0xbc:
1477      case 0xbd:
1478      case 0xbe:
1479      case 0xbf:   cjne_r_byte(op&7);             break;   //CJNE R0 to R7, #data, code addr
1480
1481      case 0xc0:   push();                     break;   //PUSH data addr
1482      case 0xc1:   ajmp(op);                  break;   //AJMP code addr
1483      case 0xc2:   RWM=1; clr_bitaddr(); RWM=0;   break;   //CLR bit addr
1484      case 0xc3:   clr_c();                   break;   //CLR C
1485      case 0xc4:   swap_a();                  break;   //SWAP A
1486      case 0xc5:   xch_a_mem();               break;   //XCH A, data addr
1487
1488      case 0xc6:
1489      case 0xc7:  xch_a_ir(op&1);               break;   //XCH A, @RO/@R1
1490
1491      case 0xc8:
1492      case 0xc9:
1493      case 0xca:
1494      case 0xcb:
1495      case 0xcc:
1496      case 0xcd:
1497      case 0xce:
1498      case 0xcf:   xch_a_r(op&7);               break;   //XCH A, RO to R7
1499
1500      case 0xd0:   pop();                     break;   //POP data addr
1501      case 0xd1:   acall(op);                  break;   //ACALL code addr
1502      case 0xd2:   RWM=1; setb_bitaddr(); RWM=0;   break;   //SETB bit addr
1503      case 0xd3:   setb_c();                  break;   //SETB C
1504      case 0xd4:   da_a();                   break;   //DA A
1505      case 0xd5:   RWM=1; djnz_mem(); RWM=0;      break;   //DJNZ data addr, code addr
1506
1507      case 0xd6:
1508      case 0xd7:  xchd_a_ir(op&1);            break;   //XCHD A, @R0/@R1
1509
1510      case 0xd8:
1511      case 0xd9:
1512      case 0xda:
1513      case 0xdb:
1514      case 0xdc:
1515      case 0xdd:
1516      case 0xde:
1517      case 0xdf:   djnz_r(op&7);               break;   //DJNZ R0 to R7,code addr
1518
1519      case 0xe0:   movx_a_idptr();               break;   //MOVX A,@DPTR
1520      case 0xe1:   ajmp(op);                  break;   //AJMP code addr
1521
1522      case 0xe2:
1523      case 0xe3:   movx_a_ir(op&1);            break;   //MOVX A, @R0/@R1
1524
1525      case 0xe4:   clr_a();                  break;   //CLR A
1526      case 0xe5:   mov_a_mem();               break;   //MOV A, data addr
1527      case 0xe6:
1528      case 0xe7:   mov_a_ir(op&1);               break;   //MOV A,@RO/@R1
1529
1530      case 0xe8:
1531      case 0xe9:
1532      case 0xea:
1533      case 0xeb:
1534      case 0xec:
1535      case 0xed:
1536      case 0xee:
1537      case 0xef:   mov_a_r(op&7);               break;   //MOV A,R0 to R7
1538
1539      case 0xf0:   movx_idptr_a();               break;   //MOVX @DPTR,A
1540      case 0xf1:   acall(op);                  break;   //ACALL code addr
1541
1542      case 0xf2:
1543      case 0xf3:   movx_ir_a(op&1);            break;   //MOVX @R0/@R1,A
1544
1545      case 0xf4:   cpl_a();                  break;   //CPL A
1546      case 0xf5:   mov_mem_a();               break;   //MOV data addr, A
1547
1548      case 0xf6:
1549      case 0xf7:   mov_ir_a(op&1);               break;   //MOV @R0/@R1, A
1550
1551      case 0xf8:
1552      case 0xf9:
1553      case 0xfa:
1554      case 0xfb:
1555      case 0xfc:
1556      case 0xfd:
1557      case 0xfe:
1558      case 0xff:   mov_r_a(op&7);               break;   //MOV R0 to R7, A
1559      default:
1560         illegal(op);
1561   }
1562}
1563
1564/***************************************************************************
1565    OPCODE CYCLES
1566***************************************************************************/
1567
1568/* # of oscilations each opcode requires*/
1569static const UINT8 mcs51_cycles[] = {
1570   1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,
1571   2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,
1572   2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,
1573   2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,
1574   2,2,1,2,1,1,1,1,1,1,1,1,1,1,1,1,
1575   2,2,1,2,1,1,1,1,1,1,1,1,1,1,1,1,
1576   2,2,1,2,1,1,1,1,1,1,1,1,1,1,1,1,
1577   2,2,2,2,1,2,1,1,1,1,1,1,1,1,1,1,
1578   2,2,2,2,4,2,2,2,2,2,2,2,2,2,2,2,
1579   2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,
1580   2,2,1,2,4,1,2,2,2,2,2,2,2,2,2,2,
1581   2,2,1,1,2,2,2,2,2,2,2,2,2,2,2,2,
1582   2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1583   2,2,1,1,1,2,1,1,2,2,2,2,2,2,2,2,
1584   2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,
1585   2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1
1586};
1587
1588/***********************************************************************************
1589 Check for pending Interrupts and process - returns # of cycles used for the int
1590
1591 Note about priority & interrupting interrupts..
1592 1) A high priority interrupt cannot be interrupted by anything!
1593 2) A low priority interrupt can ONLY be interrupted by a high priority interrupt
1594 3) If more than 1 Interrupt Flag is set (ie, 2 simultaneous requests occur),
1595    the following logic works as follows:
1596    1) If two requests come in of different priority levels, the higher one is selected..
1597    2) If the requests are of the same level, an internal order is used:
1598        a) IEO
1599        b) TFO
1600        c) IE1
1601        d) TF1
1602        e) RI+TI
1603        f) TF2+EXF2
1604 **********************************************************************************/
1605static void check_irqs(void)
1606{
1607   UINT8 ints = (GET_IE0 | (GET_TF0<<1) | (GET_IE1<<2) | (GET_TF1<<3)
1608         | ((GET_RI|GET_TI)<<4));
1609   UINT8 int_vec = 0;
1610   UINT8 int_mask = 0;
1611   int priority_request = -1;
1612   int i;
1613
1614   //If All Inerrupts Disabled or no pending abort..
1615   int_mask = (GET_EA ? IE : 0x00);
1616
1617   if (mcs51.features & FEATURE_I8052)
1618      ints |= ((GET_TF2|GET_EXF2)<<5);
1619
1620   if (mcs51.features & FEATURE_DS5002FP)
1621   {
1622      printf("Here\n");
1623      ints |= ((GET_PFW)<<5);
1624      mcs51.irq_prio[6] = 3;   /* force highest priority */
1625      /* mask out interrupts not enabled */
1626      ints &= ((int_mask & 0x1f) | ((GET_EPFW)<<5));
1627   }
1628   else
1629   {
1630      /* mask out interrupts not enabled */
1631      ints &= int_mask;
1632   }
1633
1634   if (!ints)   return;
1635
1636   /* CLear IDL - got enabled interrupt */
1637   if (mcs51.features & FEATURE_CMOS)
1638   {
1639      /* any interrupt terminates idle mode */
1640      SET_IDL(0);
1641      /* external interrupt wakes up */
1642      if (ints & (GET_IE0 | GET_IE1))
1643         /* but not the DS5002FP */
1644         if (!(mcs51.features & FEATURE_DS5002FP))
1645            SET_PD(0);
1646   }
1647
1648   for (i=0; i<mcs51.num_interrupts; i++)
1649   {
1650      if (ints & (1<<i))
1651      {
1652         if (mcs51.irq_prio[i] > priority_request)
1653         {
1654            priority_request = mcs51.irq_prio[i];
1655            int_vec = (i<<3) | 3;
1656         }
1657      }
1658   }
1659
1660   /* Skip the interrupt request if currently processing interrupt
1661     * and the new request does not have a higher priority
1662     */
1663
1664   LOG(("Request: %d\n", priority_request));
1665   if (mcs51.irq_active && (priority_request <= mcs51.cur_irq_prio))
1666   {
1667      LOG(("higher or equal priority irq in progress already, skipping ...\n"));
1668      return;
1669   }
1670
1671    //Save current pc to stack, set pc to new interrupt vector
1672   push_pc();
1673   PC = int_vec;
1674   change_pc(PC);
1675
1676   /* interrupts take 24 cycles */
1677   mcs51.inst_cycles += 2;
1678
1679   //Set current Irq & Priority being serviced
1680   mcs51.cur_irq_prio = priority_request;
1681   mcs51.irq_active |= (1 << priority_request);
1682
1683   LOG(("Take: %d %02x\n", mcs51.cur_irq_prio, mcs51.irq_active));
1684
1685   //printf("irq cip %d, act %02x\n",mcs51.cur_irq_prio,  mcs51.irq_active);
1686
1687   //Clear any interrupt flags that should be cleared since we're servicing the irq!
1688   switch(int_vec) {
1689      case V_IE0:
1690         //External Int Flag only cleared when configured as Edge Triggered..
1691         if(GET_IT0)  /* for some reason having this, breaks alving dmd games */
1692            SET_IE0(0);
1693
1694         /* indicate we took the external IRQ */
1695         if (mcs51.irq_callback != NULL)
1696            (*mcs51.irq_callback)(0);
1697
1698         break;
1699      case V_TF0:
1700         //Timer 0 - Always clear Flag
1701         SET_TF0(0);
1702         break;
1703      case V_IE1:
1704         //External Int Flag only cleared when configured as Edge Triggered..
1705         if(GET_IT1)  /* for some reason having this, breaks alving dmd games */
1706            SET_IE1(0);
1707         /* indicate we took the external IRQ */
1708         if (mcs51.irq_callback != NULL)
1709            (*mcs51.irq_callback)(1);
1710
1711         break;
1712      case V_TF1:
1713         //Timer 1 - Always clear Flag
1714         SET_TF1(0);
1715         break;
1716      case V_RITI:
1717         /* no flags are cleared, TI and RI remain set until reset by software */
1718         break;
1719      /* I8052 specific */
1720      case V_TF2:
1721         /* no flags are cleared according to manual */
1722         break;
1723      /* DS5002FP specific */
1724      /* case V_PFI:
1725         *  no flags are cleared, PFW is reset by software
1726         *  This has the same vector as V_TF2.
1727         */
1728
1729   }
1730}
1731
1732INLINE void burn_cycles(int cycles)
1733{
1734   /* Update Timer (if any timers are running) */
1735   update_timers(cycles);
1736
1737   /* Update Serial (only for mode 0) */
1738   update_serial(cycles);
1739
1740   /* check_irqs */
1741   check_irqs();
1742}
1743
1744static void mcs51_set_irq_line(int irqline, int state)
1745{
1746   /* From the manual:
1747     *
1748     * <cite>In operatiom all the interrupt tlags are latched into the
1749     * interrupt control system during State 5 of every ma-
1750     * chine cycle. The samples are polled during the follow-
1751     * ing machine cycle.</cite>
1752     *
1753     * ==> Since we do not emulate substates, this assumes that the signal is present
1754     * for at least one cycle (12 states)
1755     *
1756     */
1757   UINT32 new_state = (mcs51.last_line_state & ~(1 << irqline)) | ((state != CLEAR_LINE) << irqline);
1758   /* detect 0->1 transistions */
1759   UINT32 tr_state = (~mcs51.last_line_state) & new_state;
1760
1761   switch( irqline )
1762   {
1763      //External Interrupt 0
1764      case MCS51_INT0_LINE:
1765         //Line Asserted?
1766         if (state != CLEAR_LINE) {
1767            //Need cleared->active line transition? (Logical 1-0 Pulse on the line) - CLEAR->ASSERT Transition since INT0 active lo!
1768            if (GET_IT0) {
1769               if (GET_BIT(tr_state, MCS51_INT0_LINE))
1770                  SET_IE0(1);
1771            }
1772            else
1773               SET_IE0(1);      //Nope, just set it..
1774         }
1775         else
1776         {
1777            if (!GET_IT0) /* clear if level triggered */
1778               SET_IE0(0);
1779         }
1780
1781         break;
1782
1783      //External Interrupt 1
1784      case MCS51_INT1_LINE:
1785
1786         //Line Asserted?
1787         if (state != CLEAR_LINE) {
1788            //Need cleared->active line transition? (Logical 1-0 Pulse on the line) - CLEAR->ASSERT Transition since INT1 active lo!
1789            if(GET_IT1){
1790               if (GET_BIT(tr_state, MCS51_INT1_LINE))
1791                  SET_IE1(1);
1792            }
1793            else
1794               SET_IE1(1);      //Nope, just set it..
1795         }
1796         else
1797         {
1798            if (!GET_IT1) /* clear if level triggered */
1799               SET_IE1(0);
1800         }
1801         break;
1802
1803      case MCS51_T0_LINE:
1804         if (GET_BIT(tr_state, MCS51_T0_LINE))
1805            mcs51.t0_cnt++;
1806         break;
1807
1808      case MCS51_T1_LINE:
1809         if (GET_BIT(tr_state, MCS51_T1_LINE))
1810            mcs51.t1_cnt++;
1811         break;
1812
1813      case MCS51_T2_LINE:
1814         if (mcs51.features & FEATURE_I8052)
1815         {
1816            if (GET_BIT(tr_state, MCS51_T2_LINE))
1817               mcs51.t2_cnt++;
1818         }
1819         else
1820            fatalerror("mcs51: Trying to set T2_LINE on a non I8052 type cpu.\n");
1821         break;
1822
1823      case MCS51_T2EX_LINE:
1824         if (mcs51.features & FEATURE_I8052)
1825         {
1826            if (GET_BIT(tr_state, MCS51_T2EX_LINE))
1827            {
1828               SET_EXF2(1);
1829               mcs51.t2ex_cnt++;
1830            }
1831         }
1832         else
1833            fatalerror("mcs51: Trying to set T2EX_LINE on a non I8052 type cpu.\n");
1834         break;
1835
1836      case MCS51_RX_LINE: /* Serial Port Receive */
1837         /* Is the enable flags for this interrupt set? */
1838         if (state != CLEAR_LINE)
1839         {
1840            serial_receive();
1841         }
1842         break;
1843
1844      /* Power Fail Interrupt */
1845      case DS5002FP_PFI_LINE:
1846         if (mcs51.features & FEATURE_DS5002FP)
1847         {
1848            /* Need cleared->active line transition? (Logical 1-0 Pulse on the line) - CLEAR->ASSERT Transition since INT1 active lo! */
1849            if (GET_BIT(tr_state, MCS51_INT1_LINE))
1850               SET_PFW(1);
1851         }
1852         else
1853            fatalerror("mcs51: Trying to set DS5002FP_PFI_LINE on a non DS5002FP type cpu.\n");
1854         break;
1855   }
1856   mcs51.last_line_state = new_state;
1857}
1858
1859/* Execute cycles - returns number of cycles actually run */
1860static int mcs51_execute(int cycles)
1861{
1862   UINT8 op;
1863
1864   mcs51_icount = cycles;
1865
1866   /* external interrupts may have been set since we last checked */
1867   mcs51.inst_cycles = 0;
1868   check_irqs();
1869
1870   /* if in powerdown, just return */
1871   if ((mcs51.features & FEATURE_CMOS) && GET_PD)
1872   {
1873      mcs51_icount = 0;
1874      return cycles;
1875   }
1876
1877   mcs51_icount -= mcs51.inst_cycles;
1878   burn_cycles(mcs51.inst_cycles);
1879
1880   if ((mcs51.features & FEATURE_CMOS) && GET_IDL)
1881   {
1882      do
1883      {
1884         /* burn the cycles */
1885         mcs51_icount--;
1886         burn_cycles(1);
1887      } while( mcs51_icount > 0 );
1888      return cycles - mcs51_icount;
1889   }
1890
1891   do
1892   {
1893      /* Read next opcode */
1894      PPC = PC;
1895      debugger_instruction_hook(Machine, PC);
1896      op = cpu_readop(PC++);
1897
1898      /* process opcode and count cycles */
1899      mcs51.inst_cycles = mcs51_cycles[op];
1900      execute_op(op);
1901
1902      /* burn the cycles */
1903      mcs51_icount -= mcs51.inst_cycles;
1904
1905      /* if in powerdown, just return */
1906      if ((mcs51.features & FEATURE_CMOS) && GET_PD)
1907         return cycles - mcs51_icount;
1908
1909      burn_cycles(mcs51.inst_cycles);
1910
1911      /* decrement the timed access window */
1912      if (mcs51.features & FEATURE_DS5002FP)
1913         mcs51.ds5002fp.ta_window = (mcs51.ds5002fp.ta_window ? mcs51.ds5002fp.ta_window-- : 0x00);
1914
1915      /* If the chip entered in idle mode, end the loop */
1916      if ((mcs51.features & FEATURE_CMOS) && GET_IDL)
1917         return cycles - mcs51_icount;
1918
1919   } while( mcs51_icount > 0 );
1920
1921   return cycles - mcs51_icount;
1922}
1923
1924
1925/****************************************************************************
1926 * MCS51/8051 Section
1927 ****************************************************************************/
1928
1929static void mcs51_sfr_write(size_t offset, UINT8 data)
1930{
1931   /* update register */
1932   assert(offset >= 0x80 && offset <= 0xff);
1933
1934   /* TODO: Move to memory map */
1935   switch (offset)
1936   {
1937      case ADDR_P0:   OUT(MCS51_PORT_P0,data);   break;
1938      case ADDR_P1:   OUT(MCS51_PORT_P1,data);   break;
1939      case ADDR_P2:   OUT(MCS51_PORT_P2,data);   break;
1940      case ADDR_P3:   OUT(MCS51_PORT_P3,data);   break;
1941      case ADDR_SBUF:   serial_transmit(data);      break;
1942      case ADDR_PSW:   SET_PARITY();            break;
1943      case ADDR_ACC:   SET_PARITY();            break;
1944      case ADDR_IP:   update_irq_prio(data, 0);   break;
1945      /* R_SBUF = data;        //This register is used only for "Receiving data coming in!" */
1946
1947      case ADDR_B:
1948      case ADDR_SP:
1949      case ADDR_DPL:
1950      case ADDR_DPH:
1951      case ADDR_PCON:
1952      case ADDR_TCON:
1953      case ADDR_TMOD:
1954      case ADDR_IE:
1955      case ADDR_TL0:
1956      case ADDR_TL1:
1957      case ADDR_TH0:
1958      case ADDR_TH1:
1959      case ADDR_SCON:
1960         break;
1961      default:
1962         LOG(("mcs51 #%d: attemping to write to an invalid/non-implemented SFR address: %zx at 0x%04x, data=%x\n", cpu_getactivecpu(), offset,PC,data));
1963         /* no write in this case according to manual */
1964         return;
1965   }
1966   data_write_byte_8le((size_t)offset | 0x100, data);
1967}
1968
1969static UINT8 mcs51_sfr_read(size_t offset)
1970{
1971   assert(offset >= 0x80 && offset <= 0xff);
1972
1973   switch (offset)
1974   {
1975      /* Read/Write/Modify operations read the port latch ! */
1976      /* Move to memory map */
1977      case ADDR_P0:    return RWM ? P0 : P0 & IN(MCS51_PORT_P0);
1978      case ADDR_P1:    return RWM ? P1 : P1 & IN(MCS51_PORT_P1);
1979      case ADDR_P2:    return RWM ? P2 : P2 & IN(MCS51_PORT_P2);
1980      case ADDR_P3:    return RWM ? P3 : P3 & IN(MCS51_PORT_P3);
1981
1982      case ADDR_PSW:
1983      case ADDR_ACC:
1984      case ADDR_B:
1985      case ADDR_SP:
1986      case ADDR_DPL:
1987      case ADDR_DPH:
1988      case ADDR_PCON:
1989      case ADDR_TCON:
1990      case ADDR_TMOD:
1991      case ADDR_TL0:
1992      case ADDR_TL1:
1993      case ADDR_TH0:
1994      case ADDR_TH1:
1995      case ADDR_SCON:
1996      case ADDR_SBUF:
1997      case ADDR_IE:
1998      case ADDR_IP:
1999         return data_read_byte_8le((size_t) offset | 0x100);
2000      /* Illegal or non-implemented sfr */
2001      default:
2002         LOG(("mcs51 #%d: attemping to read an invalid/non-implemented SFR address: %zx at 0x%04x\n", cpu_getactivecpu(), offset,PC));
2003         /* according to the manual, the read may return random bits */
2004         return 0xff;
2005   }
2006}
2007
2008
2009static void mcs51_init(int index, int clock, const void *config, int (*irqcallback)(int))
2010{
2011   mcs51.irq_callback = irqcallback;
2012
2013   mcs51.features = FEATURE_NONE;
2014   mcs51.ram_mask = 0x7F;           /* 128 bytes of ram */
2015   mcs51.num_interrupts = 5;         /* 5 interrupts */
2016   mcs51.sfr_read = mcs51_sfr_read;
2017   mcs51.sfr_write = mcs51_sfr_write;
2018
2019   /* Save states */
2020   state_save_register_item("mcs51", index, mcs51.ppc);
2021   state_save_register_item("mcs51", index, mcs51.pc);
2022   state_save_register_item("mcs51", index, mcs51.rwm );
2023   state_save_register_item("mcs51", index, mcs51.cur_irq_prio );
2024   state_save_register_item("mcs51", index, mcs51.last_line_state );
2025   state_save_register_item("mcs51", index, mcs51.t0_cnt );
2026   state_save_register_item("mcs51", index, mcs51.t1_cnt );
2027   state_save_register_item("mcs51", index, mcs51.t2_cnt );
2028   state_save_register_item("mcs51", index, mcs51.t2ex_cnt );
2029   state_save_register_item("mcs51", index, mcs51.recalc_parity );
2030   state_save_register_item_array("mcs51", index, mcs51.irq_prio );
2031   state_save_register_item("mcs51", index, mcs51.irq_active );
2032}
2033
2034static void i80c51_init(int index, int clock, const void *config, int (*irqcallback)(int))
2035{
2036   mcs51_init(index, clock, config, irqcallback);
2037
2038   mcs51.features |= FEATURE_CMOS;
2039}
2040
2041/* Reset registers to the initial values */
2042static void mcs51_reset(void)
2043{
2044   update_ptrs();
2045   //Set up serial call back handlers
2046   mcs51.serial_tx_callback = hold_serial_tx_callback;
2047   hold_serial_tx_callback = NULL;
2048   mcs51.serial_rx_callback = hold_serial_rx_callback;
2049   hold_serial_rx_callback = NULL;
2050
2051   mcs51.last_line_state = 0;
2052   mcs51.t0_cnt = 0;
2053   mcs51.t1_cnt = 0;
2054   mcs51.t2_cnt = 0;
2055   mcs51.t2ex_cnt = 0;
2056   /* Flag as NO IRQ in Progress */
2057   mcs51.irq_active = 0;
2058   mcs51.cur_irq_prio = -1;
2059
2060   /* these are all defined reset states */
2061   PC = 0;
2062   SP = 0x7;
2063   SET_PSW(0);
2064   SET_ACC(0);
2065   DPH = 0;
2066   DPL = 0;
2067   B = 0;
2068   IP = 0;
2069   update_irq_prio(IP, 0);
2070   IE = 0;
2071   SCON = 0;
2072   TCON = 0;
2073   TMOD = 0;
2074   PCON = 0;
2075   TH1 = 0;
2076   TH0 = 0;
2077   TL1 = 0;
2078   TL0 = 0;
2079   /* set the port configurations to all 1's */
2080   SET_P3(0xff);
2081   SET_P2(0xff);
2082   SET_P1(0xff);
2083   SET_P0(0xff);
2084
2085   /* 8052 Only registers */
2086   if (mcs51.features & FEATURE_I8052)
2087   {
2088      T2CON = 0;
2089      RCAP2L = 0;
2090      RCAP2H = 0;
2091      TL2 = 0;
2092      TH2 = 0;
2093   }
2094
2095   /* 80C52 Only registers */
2096   if (mcs51.features & FEATURE_I80C52)
2097   {
2098      IPH = 0;
2099      update_irq_prio(IP, IPH);
2100      SADDR = 0;
2101      SADEN = 0;
2102   }
2103
2104   /* DS5002FP Only registers */
2105   if (mcs51.features & FEATURE_DS5002FP)
2106   {
2107      // set initial values (some of them are set using the bootstrap loader)
2108      PCON = 0;
2109      MCON = mcs51.ds5002fp.config->mcon & 0xfb;
2110      RPCTL = mcs51.ds5002fp.config->rpctl & 0x01;
2111      RPS = 0;
2112      RNR = 0;
2113      CRCR = mcs51.ds5002fp.config->crc & 0xf0;
2114      CRCL = 0;
2115      CRCH = 0;
2116      TA = 0;
2117
2118      // set internal CPU state
2119      mcs51.ds5002fp.previous_ta = 0;
2120      mcs51.ds5002fp.ta_window = 0;
2121      mcs51.ds5002fp.range = (GET_RG1 << 1) | GET_RG0;
2122   }
2123
2124}
2125
2126/* Shut down CPU core */
2127static void mcs51_exit(void)
2128{
2129   /* nothing to do */
2130}
2131
2132/****************************************************************************
2133 * 8052 Section
2134 ****************************************************************************/
2135
2136static void i8052_sfr_write(size_t offset, UINT8 data)
2137{
2138   switch (offset)
2139   {
2140      /* 8052 family specific */
2141      case ADDR_T2CON:
2142      case ADDR_RCAP2L:
2143      case ADDR_RCAP2H:
2144      case ADDR_TL2:
2145      case ADDR_TH2:
2146         data_write_byte_8le((size_t) offset | 0x100, data);
2147         break;
2148
2149      default:
2150         mcs51_sfr_write(offset, data);
2151   }
2152}
2153
2154static UINT8 i8052_sfr_read(size_t offset)
2155{
2156   switch (offset)
2157   {
2158      /* 8052 family specific */
2159      case ADDR_T2CON:
2160      case ADDR_RCAP2L:
2161      case ADDR_RCAP2H:
2162      case ADDR_TL2:
2163      case ADDR_TH2:
2164         return data_read_byte_8le((size_t) offset | 0x100);
2165      default:
2166         return mcs51_sfr_read(offset);
2167   }
2168}
2169
2170static void i8052_init (int index, int clock, const void *config, int (*irqcallback)(int))
2171{
2172   mcs51_init(index, clock, config, irqcallback);
2173
2174   mcs51.ram_mask = 0xFF;           /* 256 bytes of ram */
2175   mcs51.num_interrupts = 6;         /* 6 interrupts */
2176
2177   mcs51.features |= FEATURE_I8052;
2178   mcs51.sfr_read = i8052_sfr_read;
2179   mcs51.sfr_write = i8052_sfr_write;
2180}
2181
2182/****************************************************************************
2183 * 80C52 Section
2184 ****************************************************************************/
2185
2186static void i80c52_sfr_write(size_t offset, UINT8 data)
2187{
2188   switch (offset)
2189   {
2190      /* 80c52 family specific */
2191      case ADDR_IP:
2192         update_irq_prio(data, IPH);
2193         break;
2194      case ADDR_IPH:
2195         update_irq_prio(IP, data);
2196         break;
2197      case ADDR_SADDR:
2198      case ADDR_SADEN:
2199         break;
2200
2201      default:
2202         i8052_sfr_write(offset, data);
2203         return;
2204   }
2205   data_write_byte_8le((size_t) offset | 0x100, data);
2206}
2207
2208static UINT8 i80c52_sfr_read(size_t offset)
2209{
2210   switch (offset)
2211   {
2212      /* 80c52 family specific */
2213      case ADDR_IPH:
2214      case ADDR_SADDR:
2215      case ADDR_SADEN:
2216         return data_read_byte_8le((size_t) offset | 0x100);
2217      default:
2218         return i8052_sfr_read(offset);
2219   }
2220}
2221
2222static void i80c52_init(int index, int clock, const void *config, int (*irqcallback)(int))
2223{
2224   i8052_init(index, clock, config, irqcallback);
2225
2226   mcs51.features |= (FEATURE_I80C52 | FEATURE_CMOS);
2227   mcs51.sfr_read = i80c52_sfr_read;
2228   mcs51.sfr_write = i80c52_sfr_write;
2229}
2230
2231static void i80c31_init(int index, int clock, const void *config, int (*irqcallback)(int))
2232{
2233   i80c52_init(index, clock, config, irqcallback);
2234
2235   mcs51.ram_mask = 0x7F;           /* 128 bytes of ram */
2236}
2237
2238/****************************************************************************
2239 * DS5002FP Section
2240 ****************************************************************************/
2241#if 0
2242
2243#define DS5_LOGW(a, d)    LOG(("ds5002fp #%d: write to  " # a " register at 0x%04x, data=%x\n", cpu_getactivecpu(), PC, d))
2244#define DS5_LOGR(a, d)    LOG(("ds5002fp #%d: read from " # a " register at 0x%04x\n", cpu_getactivecpu(), PC))
2245
2246INLINE UINT8 ds5002fp_protected(size_t offset, UINT8 data, UINT8 ta_mask, UINT8 mask)
2247{
2248   UINT8 is_timed_access;
2249
2250   is_timed_access = (mcs51.ds5002fp.ta_window > 0) && (TA == 0x55);
2251   if (is_timed_access)
2252   {
2253      ta_mask = 0xff;
2254   }
2255   data = (mcs51.sfr_ram[offset] & (~ta_mask)) | (data & ta_mask);
2256   return (mcs51.sfr_ram[offset] & (~mask)) | (data & mask);
2257}
2258
2259static void ds5002fp_sfr_write(size_t offset, UINT8 data)
2260{
2261   switch (offset)
2262   {
2263
2264      case ADDR_TA:
2265         mcs51.ds5002fp.previous_ta = TA;
2266         /*  init the time window after having wrote 0xaa */
2267         if ((data == 0xaa) && (mcs51.ds5002fp.ta_window == 0))
2268         {
2269            mcs51.ds5002fp.ta_window = 6; /* 4*12 + 2*12 */
2270            LOG(("ds5002fp #%d: TA window initiated at 0x%04x\n", cpu_getactivecpu(), PC));
2271         }
2272         break;
2273      case ADDR_MCON:    data = ds5002fp_protected(ADDR_MCON, data, 0x0f, 0xf7);   DS5_LOGW(MCON, data); break;
2274      case ADDR_RPCTL:   data = ds5002fp_protected(ADDR_RPCTL, data, 0xef, 0xfe); DS5_LOGW(RPCTL, data); break;
2275      case ADDR_CRCR:      data = ds5002fp_protected(ADDR_CRCR, data, 0xff, 0x0f);   DS5_LOGW(CRCR, data);   break;
2276      case ADDR_PCON:      data = ds5002fp_protected(ADDR_PCON, data, 0xb9, 0xff); break;
2277      case ADDR_IP:       data = ds5002fp_protected(ADDR_IP, data, 0x7f, 0xff);   break;
2278      case ADDR_CRCL:      DS5_LOGW(CRCL, data);                            break;
2279      case ADDR_CRCH:      DS5_LOGW(CRCH, data);                            break;
2280      case ADDR_RNR:      DS5_LOGW(RNR, data);                            break;
2281      case ADDR_RPS:      DS5_LOGW(RPS, data);                           break;
2282      default:
2283         mcs51_sfr_write(offset, data);
2284         return;
2285   }
2286   data_write_byte_8le((size_t) offset | 0x100, data);
2287}
2288
2289static UINT8 ds5002fp_sfr_read(size_t offset)
2290{
2291   switch (offset)
2292   {
2293      case ADDR_CRCR:    DS5_LOGR(CRCR, data);    break;
2294      case ADDR_CRCL:    DS5_LOGR(CRCL, data);      break;
2295      case ADDR_CRCH:    DS5_LOGR(CRCH, data);    break;
2296      case ADDR_MCON:    DS5_LOGR(MCON, data);      break;
2297      case ADDR_TA:       DS5_LOGR(TA, data);      break;
2298      case ADDR_RNR:       DS5_LOGR(RNR, data);      break;
2299      case ADDR_RPCTL:    DS5_LOGR(RPCTL, data);   break;
2300      case ADDR_RPS:       DS5_LOGR(RPS, data);      break;
2301      case ADDR_PCON:
2302         SET_PFW(0);      /* reset PFW flag */
2303         return mcs51_sfr_read(offset); /* FIXME: cmos features ??? */
2304      default:
2305         return mcs51_sfr_read(offset); /* FIXME: cmos features ??? */
2306   }
2307   return data_read_byte_8le((size_t) offset | 0x100);
2308}
2309
2310static void ds5002fp_init(int index, int clock, const void *config, int (*irqcallback)(int))
2311{
2312   /* default configuration */
2313   static const ds5002fp_config default_config = { 0x00, 0x00, 0x00 };
2314   const ds5002fp_config *sconfig = config ? config : &default_config;
2315
2316   mcs51_init(index, clock, config, irqcallback);
2317
2318   mcs51.ds5002fp.config = sconfig;
2319   mcs51.features |= (FEATURE_DS5002FP | FEATURE_CMOS);
2320   mcs51.sfr_read = ds5002fp_sfr_read;
2321   mcs51.sfr_write = ds5002fp_sfr_write;
2322
2323   state_save_register_item("mcs51", index, mcs51.ds5002fp.previous_ta );
2324   state_save_register_item("mcs51", index, mcs51.ds5002fp.ta_window );
2325   state_save_register_item("mcs51", index, mcs51.ds5002fp.range );
2326
2327}
2328#endif
2329
2330/***************************************************************************
2331    ADDRESS MAPS
2332***************************************************************************/
2333
2334
2335/* FIXME: the memory maps should probably support rom banking for EA */
2336static ADDRESS_MAP_START(program_12bit, ADDRESS_SPACE_PROGRAM, 8)
2337   AM_RANGE(0x00, 0x0fff) AM_ROM
2338ADDRESS_MAP_END
2339
2340static ADDRESS_MAP_START(program_13bit, ADDRESS_SPACE_PROGRAM, 8)
2341   AM_RANGE(0x00, 0x1fff) AM_ROM
2342ADDRESS_MAP_END
2343
2344static ADDRESS_MAP_START(data_7bit, ADDRESS_SPACE_DATA, 8)
2345   AM_RANGE(0x0000, 0x007f) AM_RAM
2346   AM_RANGE(0x0100, 0x01ff) AM_RAM /* SFR */
2347ADDRESS_MAP_END
2348
2349static ADDRESS_MAP_START(data_8bit, ADDRESS_SPACE_DATA, 8)
2350   AM_RANGE(0x0000, 0x00ff) AM_RAM
2351   AM_RANGE(0x0100, 0x01ff) AM_RAM /* SFR */
2352ADDRESS_MAP_END
2353
2354
2355/***************************************************************************
2356    GENERAL CONTEXT ACCESS
2357***************************************************************************/
2358
2359static void mcs51_get_context(void *dst)
2360{
2361   if( dst )
2362      memcpy(dst, &mcs51, sizeof(mcs51_regs));
2363}
2364
2365static void mcs51_set_context(void *src)
2366{
2367   if( src )
2368      memcpy(&mcs51, src, sizeof(mcs51_regs));
2369      change_pc(PC);
2370      update_ptrs();
2371}
2372
2373/**************************************************************************
2374 * Generic set_info
2375 **************************************************************************/
2376
2377static void mcs51_set_info(UINT32 state, cpuinfo *info)
2378{
2379   switch (state)
2380   {
2381      /* --- the following bits of info are set as 64-bit signed integers --- */
2382      case CPUINFO_INT_PC:                     PC = info->i;                     break;
2383      case CPUINFO_INT_SP:                     SP = info->i;                       break;
2384
2385      case CPUINFO_INT_INPUT_STATE + MCS51_INT0_LINE:   mcs51_set_irq_line(MCS51_INT0_LINE, info->i); break;
2386      case CPUINFO_INT_INPUT_STATE + MCS51_INT1_LINE:   mcs51_set_irq_line(MCS51_INT1_LINE, info->i); break;
2387      case CPUINFO_INT_INPUT_STATE + MCS51_T0_LINE:   mcs51_set_irq_line(MCS51_T0_LINE, info->i); break;
2388      case CPUINFO_INT_INPUT_STATE + MCS51_T1_LINE:   mcs51_set_irq_line(MCS51_T1_LINE, info->i); break;
2389      case CPUINFO_INT_INPUT_STATE + MCS51_RX_LINE:   mcs51_set_irq_line(MCS51_RX_LINE, info->i); break;
2390
2391      case CPUINFO_INT_REGISTER + MCS51_PC:          PC = info->i;                        break;
2392      case CPUINFO_INT_REGISTER + MCS51_SP:          SP = info->i;                     break;
2393      case CPUINFO_INT_REGISTER + MCS51_PSW:         SET_PSW(info->i);                     break;
2394      case CPUINFO_INT_REGISTER + MCS51_ACC:         SET_ACC(info->i);                     break;
2395      case CPUINFO_INT_REGISTER + MCS51_B:           B = info->i;                        break;
2396      case CPUINFO_INT_REGISTER + MCS51_DPH:         DPH = info->i;                     break;
2397      case CPUINFO_INT_REGISTER + MCS51_DPL:         DPL = info->i;                     break;
2398      case CPUINFO_INT_REGISTER + MCS51_IE:          IE = info->i;                     break;
2399      case CPUINFO_INT_REGISTER + MCS51_R0:          SET_REG(0, info->i); break;
2400      case CPUINFO_INT_REGISTER + MCS51_R1:          SET_REG(1, info->i); break;
2401      case CPUINFO_INT_REGISTER + MCS51_R2:          SET_REG(2, info->i); break;
2402      case CPUINFO_INT_REGISTER + MCS51_R3:          SET_REG(3, info->i); break;
2403      case CPUINFO_INT_REGISTER + MCS51_R4:          SET_REG(4, info->i); break;
2404      case CPUINFO_INT_REGISTER + MCS51_R5:          SET_REG(5, info->i); break;
2405      case CPUINFO_INT_REGISTER + MCS51_R6:          SET_REG(6, info->i); break;
2406      case CPUINFO_INT_REGISTER + MCS51_R7:          SET_REG(7, info->i); break;
2407      case CPUINFO_INT_REGISTER + MCS51_RB:          SET_RS(info->i); break;
2408   }
2409}
2410
2411
2412
2413/**************************************************************************
2414 * Generic get_info
2415 **************************************************************************/
2416
2417static void mcs51_get_info(UINT32 state, cpuinfo *info)
2418{
2419   mcs51_regs *r = &mcs51;
2420
2421   switch (state)
2422   {
2423      /* --- the following bits of info are returned as 64-bit signed integers --- */
2424      case CPUINFO_INT_CONTEXT_SIZE:               info->i = sizeof(mcs51);            break;
2425      case CPUINFO_INT_DEFAULT_IRQ_VECTOR:         info->i = 0;                     break;
2426      case CPUINFO_INT_ENDIANNESS:               info->i = CPU_IS_LE;               break;
2427      case CPUINFO_INT_CLOCK_MULTIPLIER:            info->i = 1;                     break;
2428      case CPUINFO_INT_CLOCK_DIVIDER:               info->i = 12;                     break;
2429      case CPUINFO_INT_MIN_INSTRUCTION_BYTES:         info->i = 1;                     break;
2430      case CPUINFO_INT_MAX_INSTRUCTION_BYTES:         info->i = 5;                     break;
2431      case CPUINFO_INT_MIN_CYCLES:               info->i = 1;                     break;
2432      case CPUINFO_INT_MAX_CYCLES:               info->i = 20; /* rough guess */         break;
2433      case CPUINFO_INT_INPUT_LINES:                 info->i = 3;                     break;
2434
2435      case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_PROGRAM:   info->i = 8;               break;
2436      case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 16;               break;
2437      case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_PROGRAM: info->i = 0;               break;
2438      case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_DATA:   info->i = 8;               break;
2439      case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_DATA:    info->i = 9; /* due to sfr mapping */               break;
2440      case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_DATA:    info->i = 0;               break;
2441      case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_IO:   info->i = 8;                  break;
2442      case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_IO:    info->i = 17;                  break;
2443      case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_IO:    info->i = 0;                  break;
2444
2445      case CPUINFO_INT_PREVIOUSPC:               info->i = PPC;                     break;
2446      case CPUINFO_INT_PC:                      info->i = PC;                     break;
2447      case CPUINFO_INT_SP:                     info->i = SP;                     break;
2448
2449      case CPUINFO_INT_REGISTER + MCS51_PC:          info->i = PC;                     break;
2450      case CPUINFO_INT_REGISTER + MCS51_SP:          info->i = SP;                     break;
2451      case CPUINFO_INT_REGISTER + MCS51_PSW:         info->i = PSW;                     break;
2452      case CPUINFO_INT_REGISTER + MCS51_ACC:         info->i = ACC;                     break;
2453      case CPUINFO_INT_REGISTER + MCS51_B:           info->i = B;                     break;
2454      case CPUINFO_INT_REGISTER + MCS51_DPH:         info->i = DPH;                     break;
2455      case CPUINFO_INT_REGISTER + MCS51_DPL:         info->i = DPL;                     break;
2456      case CPUINFO_INT_REGISTER + MCS51_IE:          info->i = IE;                     break;
2457      case CPUINFO_INT_REGISTER + MCS51_R0:          info->i = R_REG(0);                   break;
2458      case CPUINFO_INT_REGISTER + MCS51_R1:          info->i = R_REG(1);                break;
2459      case CPUINFO_INT_REGISTER + MCS51_R2:          info->i = R_REG(2);                break;
2460      case CPUINFO_INT_REGISTER + MCS51_R3:          info->i = R_REG(3);                break;
2461      case CPUINFO_INT_REGISTER + MCS51_R4:          info->i = R_REG(4);                break;
2462      case CPUINFO_INT_REGISTER + MCS51_R5:          info->i = R_REG(5);                break;
2463      case CPUINFO_INT_REGISTER + MCS51_R6:          info->i = R_REG(6);                break;
2464      case CPUINFO_INT_REGISTER + MCS51_R7:          info->i = R_REG(7);                break;
2465      case CPUINFO_INT_REGISTER + MCS51_RB:          info->i = R_REG(8);                break;
2466
2467      /* --- the following bits of info are returned as pointers to data or functions --- */
2468      case CPUINFO_PTR_SET_INFO:                  info->setinfo = mcs51_set_info;         break;
2469      case CPUINFO_PTR_GET_CONTEXT:               info->getcontext = mcs51_get_context;   break;
2470      case CPUINFO_PTR_SET_CONTEXT:               info->setcontext = mcs51_set_context;   break;
2471      case CPUINFO_PTR_INIT:                     info->init = mcs51_init;            break;
2472      case CPUINFO_PTR_RESET:                     info->reset = mcs51_reset;            break;
2473      case CPUINFO_PTR_EXIT:                     info->exit = mcs51_exit;            break;
2474      case CPUINFO_PTR_EXECUTE:                  info->execute = mcs51_execute;         break;
2475      case CPUINFO_PTR_BURN:                     info->burn = NULL;                  break;
2476      case CPUINFO_PTR_DISASSEMBLE:               info->disassemble = i8051_dasm;         break;
2477      case CPUINFO_PTR_INSTRUCTION_COUNTER:         info->icount = &mcs51_icount;         break;
2478
2479      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map8 = NULL;   break;
2480      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA:    info->internal_map8 = NULL;   break;
2481      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_IO:      info->internal_map8 = NULL;   break;
2482
2483      case CPUINFO_STR_NAME:                     strcpy(info->s, "I8051");            break;
2484      case CPUINFO_STR_CORE_FAMILY:               strcpy(info->s, "MCS-51");            break;
2485      case CPUINFO_STR_CORE_VERSION:               strcpy(info->s, "1.0");               break;
2486      case CPUINFO_STR_CORE_FILE:                  strcpy(info->s, __FILE__);            break;
2487      case CPUINFO_STR_CORE_CREDITS:               strcpy(info->s, "Copyright Steve Ellenoff"); break;
2488
2489      case CPUINFO_STR_FLAGS:
2490         sprintf(info->s, "%c%c%c%c%c%c%c%c",
2491            PSW & 0x80 ? 'C':'.',
2492            PSW & 0x40 ? 'A':'.',
2493            PSW & 0x20 ? 'F':'.',
2494            PSW & 0x10 ? '0':'.',
2495            PSW & 0x08 ? '1':'.',
2496            PSW & 0x04 ? 'V':'.',
2497            PSW & 0x02 ? '?':'.',
2498            PSW & 0x01 ? 'P':'.');
2499         break;
2500
2501      case CPUINFO_STR_REGISTER + MCS51_PC:           sprintf(info->s, "PC:%04X", r->pc);      break;
2502      case CPUINFO_STR_REGISTER + MCS51_SP:           sprintf(info->s, "SP:%02X", SP);      break;
2503      case CPUINFO_STR_REGISTER + MCS51_PSW:          sprintf(info->s, "PSW:%02X", PSW);      break;
2504      case CPUINFO_STR_REGISTER + MCS51_ACC:          sprintf(info->s, "A:%02X", ACC);      break;
2505      case CPUINFO_STR_REGISTER + MCS51_B:            sprintf(info->s, "B:%02X", B);         break;
2506      case CPUINFO_STR_REGISTER + MCS51_DPH:          sprintf(info->s, "DPH:%02X", DPH);      break;
2507      case CPUINFO_STR_REGISTER + MCS51_DPL:          sprintf(info->s, "DPL:%02X", DPL);      break;
2508      case CPUINFO_STR_REGISTER + MCS51_IE:           sprintf(info->s, "IE:%02X", IE);      break;
2509      case CPUINFO_STR_REGISTER + MCS51_R0:           sprintf(info->s, "R0:%02X", R_REG(0));    break;
2510      case CPUINFO_STR_REGISTER + MCS51_R1:           sprintf(info->s, "R1:%02X", R_REG(1));    break;
2511      case CPUINFO_STR_REGISTER + MCS51_R2:           sprintf(info->s, "R2:%02X", R_REG(2));    break;
2512      case CPUINFO_STR_REGISTER + MCS51_R3:         sprintf(info->s, "R3:%02X", R_REG(3));    break;
2513      case CPUINFO_STR_REGISTER + MCS51_R4:          sprintf(info->s, "R4:%02X", R_REG(4));    break;
2514      case CPUINFO_STR_REGISTER + MCS51_R5:          sprintf(info->s, "R5:%02X", R_REG(5));    break;
2515      case CPUINFO_STR_REGISTER + MCS51_R6:          sprintf(info->s, "R6:%02X", R_REG(6));    break;
2516      case CPUINFO_STR_REGISTER + MCS51_R7:          sprintf(info->s, "R7:%02X", R_REG(7));    break;
2517      case CPUINFO_STR_REGISTER + MCS51_RB:          sprintf(info->s, "RB:%02X", ((PSW & 0x18)>>3)); break;
2518   }
2519}
2520
2521/**************************************************************************
2522 * Specific get_info
2523 **************************************************************************/
2524
2525void i8031_get_info(UINT32 state, cpuinfo *info)
2526{
2527   switch (state)
2528   {
2529      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA:    info->internal_map8 = address_map_data_7bit;   break;
2530
2531      case CPUINFO_STR_NAME:                     strcpy(info->s, "I8031");            break;
2532      default:                              mcs51_get_info(state, info);         break;
2533   }
2534   /* --- the following bits of info are returned as NULL-terminated strings --- */
2535}
2536
2537void i8051_get_info(UINT32 state, cpuinfo *info)
2538{
2539   switch (state)
2540   {
2541      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map8 = address_map_program_12bit;   break;
2542      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA:    info->internal_map8 = address_map_data_7bit;   break;
2543
2544      case CPUINFO_STR_NAME:                     strcpy(info->s, "I8051");            break;
2545      default:                              mcs51_get_info(state, info);         break;
2546   }
2547   /* --- the following bits of info are returned as NULL-terminated strings --- */
2548}
2549
2550void i8032_get_info(UINT32 state, cpuinfo *info)
2551{
2552   switch (state)
2553   {
2554      case CPUINFO_PTR_INIT:                     info->init = i8052_init;            break;
2555
2556      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA:    info->internal_map8 = address_map_data_8bit;   break;
2557
2558      case CPUINFO_STR_NAME:                     strcpy(info->s, "I8032");            break;
2559
2560      default:                              mcs51_get_info(state, info);         break;
2561   }
2562}
2563
2564void i8052_get_info(UINT32 state, cpuinfo *info)
2565{
2566   switch (state)
2567   {
2568      case CPUINFO_PTR_INIT:                     info->init = i8052_init;            break;
2569
2570      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map8 = address_map_program_13bit;   break;
2571      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA:    info->internal_map8 = address_map_data_8bit;   break;
2572
2573      case CPUINFO_STR_NAME:                     strcpy(info->s, "I8052");            break;
2574
2575      default:                              mcs51_get_info(state, info);         break;
2576   }
2577}
2578
2579void i8751_get_info(UINT32 state, cpuinfo *info)
2580{
2581   switch (state)
2582   {
2583      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map8 = address_map_program_12bit;   break;
2584      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA:    info->internal_map8 = address_map_data_7bit;   break;
2585
2586      case CPUINFO_STR_NAME:                     strcpy(info->s, "I8751");            break;
2587
2588      default:                              mcs51_get_info(state, info);         break;
2589   }
2590}
2591
2592void i8752_get_info(UINT32 state, cpuinfo *info)
2593{
2594   switch (state)
2595   {
2596      case CPUINFO_PTR_INIT:                     info->init = i8052_init;            break;
2597
2598      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map8 = address_map_program_13bit;   break;
2599      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA:    info->internal_map8 = address_map_data_8bit;   break;
2600
2601      case CPUINFO_STR_NAME:                     strcpy(info->s, "I8752");            break;
2602
2603      default:                              mcs51_get_info(state, info);         break;
2604   }
2605}
2606
2607/**************************************************************************
2608 * CMOS get_info
2609 **************************************************************************/
2610
2611void i80c31_get_info(UINT32 state, cpuinfo *info)
2612{
2613   /* according to PHILIPS datasheet this is a stripped down version
2614     * of i80c52 with 128 bytes internal ram */
2615   switch (state)
2616   {
2617      case CPUINFO_PTR_INIT:                     info->init = i80c31_init;            break;
2618
2619      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map8 = NULL;   break;
2620      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA:    info->internal_map8 = address_map_data_7bit;   break;
2621
2622      case CPUINFO_STR_NAME:                     strcpy(info->s, "I80C31");            break;
2623      default:                              i8031_get_info(state, info);         break;
2624   }
2625}
2626
2627void i80c51_get_info(UINT32 state, cpuinfo *info)
2628{
2629   switch (state)
2630   {
2631      case CPUINFO_PTR_INIT:                     info->init = i80c51_init;            break;
2632      case CPUINFO_STR_NAME:                     strcpy(info->s, "I80C51");            break;
2633      default:                              i8051_get_info(state, info);         break;
2634   }
2635}
2636
2637void i80c32_get_info(UINT32 state, cpuinfo *info)
2638{
2639   switch (state)
2640   {
2641      case CPUINFO_PTR_INIT:                     info->init = i80c52_init;            break;
2642      case CPUINFO_STR_NAME:                     strcpy(info->s, "I80C32");            break;
2643      default:                              i8032_get_info(state, info);         break;
2644   }
2645}
2646
2647void i80c52_get_info(UINT32 state, cpuinfo *info)
2648{
2649   switch (state)
2650   {
2651      case CPUINFO_PTR_INIT:                     info->init = i80c52_init;            break;
2652      case CPUINFO_STR_NAME:                     strcpy(info->s, "I80C52");            break;
2653      default:                              i8052_get_info(state, info);         break;
2654   }
2655}
2656
2657void i87c51_get_info(UINT32 state, cpuinfo *info)
2658{
2659   switch (state)
2660   {
2661      case CPUINFO_PTR_INIT:                     info->init = i80c51_init;            break;
2662      case CPUINFO_STR_NAME:                     strcpy(info->s, "I87C51");            break;
2663      default:                              i8751_get_info(state, info);         break;
2664   }
2665}
2666
2667void i87c52_get_info(UINT32 state, cpuinfo *info)
2668{
2669   switch (state)
2670   {
2671      case CPUINFO_PTR_INIT:                     info->init = i80c52_init;            break;
2672      case CPUINFO_STR_NAME:                     strcpy(info->s, "I87C52");            break;
2673      default:                              i8752_get_info(state, info);         break;
2674   }
2675}
2676
2677/**************************************************************************
2678 * Other variants get_info
2679 **************************************************************************/
2680
2681void at89c4051_get_info(UINT32 state, cpuinfo *info)
2682{
2683   switch (state)
2684   {
2685      case CPUINFO_PTR_INIT:                     info->init = i80c51_init;            break;
2686      case CPUINFO_STR_NAME:                     strcpy(info->s, "AT89C4051");            break;
2687      default:                              i8051_get_info(state, info);         break;
2688   }
2689}
src/emu/cpu/mcs51/mcs51ops.c
r0r3515
1/*******************************************************************************************
2 NOTE: All registers are accessed directly, instead of using the SFR_R() function for speed
3 Direct register access is availabe from the R_(register name) macros.. ex: ACC for the ACC
4 with the exception of the PC
5********************************************************************************************/
6
7//ACALL code addr                           /* 1: aaa1 0001 */
8INLINE void acall(UINT8 op)
9{
10   UINT8 addr = ROP_ARG(PC++);            //Grab code address byte
11   PUSH_PC();                        //Save PC to the stack
12   //Thanks Gerrit for help with this! :)
13   PC = (PC & 0xf800) | ((op & 0xe0) << 3) | addr;
14   change_pc(PC);
15}
16
17//ADD A, #data                              /* 1: 0010 0100 */
18INLINE void add_a_byte(void)
19{
20   UINT8 data = ROP_ARG(PC++);            //Grab data
21   UINT8 result = ACC + data;         //Add data to accumulator
22   DO_ADD_FLAGS(ACC,data,0);            //Set Flags
23   SET_ACC(result);                  //Store 8 bit result of addtion in ACC
24}
25
26//ADD A, data addr                          /* 1: 0010 0101 */
27INLINE void add_a_mem(void)
28{
29   UINT8 addr = ROP_ARG(PC++);            //Grab data address
30   UINT8 data = IRAM_R(addr);            //Grab data from data address
31   UINT8 result = ACC + data;         //Add data to accumulator
32   DO_ADD_FLAGS(ACC,data,0);            //Set Flags
33   SET_ACC(result);                  //Store 8 bit result of addtion in ACC
34}
35
36//ADD A, @R0/@R1                            /* 1: 0010 011i */
37INLINE void add_a_ir(int r)
38{
39   UINT8 data = IRAM_IR(R_REG(r));         //Grab data from memory pointed to by R0 or R1
40   UINT8 result = ACC + data;         //Add data to accumulator
41   DO_ADD_FLAGS(ACC,data,0);            //Set Flags
42   SET_ACC(result);                  //Store 8 bit result of addtion in ACC
43}
44
45//ADD A, R0 to R7                           /* 1: 0010 1rrr */
46INLINE void add_a_r(int r)
47{
48   UINT8 data = R_REG(r);               //Grab data from R0 - R7
49   UINT8 result = ACC + data;         //Add data to accumulator
50   DO_ADD_FLAGS(ACC,data,0);            //Set Flags
51   SET_ACC(result);                  //Store 8 bit result of addtion in ACC
52}
53
54//ADDC A, #data                             /* 1: 0011 0100 */
55INLINE void addc_a_byte(void)
56{
57   UINT8 data = ROP_ARG(PC++);            //Grab data
58   UINT8 result = ACC + data + GET_CY;   //Add data + carry flag to accumulator
59   DO_ADD_FLAGS(ACC,data,GET_CY);      //Set Flags
60   SET_ACC(result);                  //Store 8 bit result of addtion in ACC
61}
62
63//ADDC A, data addr                         /* 1: 0011 0101 */
64INLINE void addc_a_mem(void)
65{
66   UINT8 addr = ROP_ARG(PC++);            //Grab data address
67   UINT8 data = IRAM_R(addr);            //Grab data from data address
68   UINT8 result = ACC + data + GET_CY;   //Add data + carry flag to accumulator
69   DO_ADD_FLAGS(ACC,data,GET_CY);      //Set Flags
70   SET_ACC(result);                  //Store 8 bit result of addtion in ACC
71}
72
73//ADDC A, @R0/@R1                           /* 1: 0011 011i */
74INLINE void addc_a_ir(int r)
75{
76   UINT8 data = IRAM_IR(R_REG(r));         //Grab data from memory pointed to by R0 or R1
77   UINT8 result = ACC + data + GET_CY;   //Add data + carry flag to accumulator
78   DO_ADD_FLAGS(ACC,data,GET_CY);      //Set Flags
79   SET_ACC(result);                  //Store 8 bit result of addtion in ACC
80}
81
82//ADDC A, R0 to R7                          /* 1: 0011 1rrr */
83INLINE void addc_a_r(int r)
84{
85   UINT8 data = R_REG(r);               //Grab data from R0 - R7
86   UINT8 result = ACC + data + GET_CY;   //Add data + carry flag to accumulator
87   DO_ADD_FLAGS(ACC,data,GET_CY);      //Set Flags
88   SET_ACC(result);                  //Store 8 bit result of addtion in ACC
89}
90
91//AJMP code addr                            /* 1: aaa0 0001 */
92INLINE void ajmp(UINT8 op)
93{
94   UINT8 addr = ROP_ARG(PC++);            //Grab code address byte
95   //Thanks Gerrit for help with this! :)
96   PC = (PC & 0xf800) | ((op & 0xe0) << 3) | addr;
97   change_pc(PC);
98}
99
100//ANL data addr, A                          /* 1: 0101 0010 */
101INLINE void anl_mem_a(void)
102{
103   UINT8 addr = ROP_ARG(PC++);            //Grab data address
104   UINT8 data = IRAM_R(addr);            //Grab data from data address
105   IRAM_W(addr,data & ACC);            //Set data address value to it's value Logical AND with ACC
106}
107
108//ANL data addr, #data                      /* 1: 0101 0011 */
109INLINE void anl_mem_byte(void)
110{
111   UINT8 addr = ROP_ARG(PC++);            //Grab data address
112   UINT8 data = ROP_ARG(PC++);            //Grab data
113   UINT8 srcdata = IRAM_R(addr);         //Grab data from data address
114   IRAM_W(addr,srcdata & data);         //Set data address value to it's value Logical AND with Data
115}
116
117//ANL A, #data                              /* 1: 0101 0100 */
118INLINE void anl_a_byte(void)
119{
120   UINT8 data = ROP_ARG(PC++);            //Grab data
121   SET_ACC(ACC & data);            //Set ACC to value of ACC Logical AND with Data
122}
123
124//ANL A, data addr                          /* 1: 0101 0101 */
125INLINE void anl_a_mem(void)
126{
127   UINT8 addr = ROP_ARG(PC++);            //Grab data address
128   UINT8 data = IRAM_R(addr);            //Grab data from data address
129   SET_ACC(ACC & data);            //Set ACC to value of ACC Logical AND with Data
130}
131
132//ANL A, @RO/@R1                            /* 1: 0101 011i */
133INLINE void anl_a_ir(int r)
134{
135   UINT8 data = IRAM_IR(R_REG(r));         //Grab data from address R0 or R1 points to
136   SET_ACC(ACC & data);            //Set ACC to value of ACC Logical AND with Data
137}
138
139//ANL A, RO to R7                           /* 1: 0101 1rrr */
140INLINE void anl_a_r(int r)
141{
142   UINT8 data = R_REG(r);               //Grab data from R0 - R7
143   SET_ACC(ACC & data);            //Set ACC to value of ACC Logical AND with Data
144}
145
146//ANL C, bit addr                           /* 1: 1000 0010 */
147INLINE void anl_c_bitaddr(void)
148{
149   int cy = GET_CY;
150   UINT8 addr = ROP_ARG(PC++);            //Grab bit address
151   UINT8 bit = BIT_R(addr);            //Grab bit data from bit address
152   SET_CY( (cy & bit) );               //Set Carry flag to Carry Flag Value Logical AND with Bit
153}
154
155//ANL C,/bit addr                           /* 1: 1011 0000 */
156INLINE void anl_c_nbitaddr(void)
157{
158   int cy = GET_CY;
159   UINT8 addr = ROP_ARG(PC++);            //Grab bit address
160   UINT8 bit = BIT_R(addr);            //Grab bit data from bit address
161   bit = ((~bit)&1);                  //Complement bit
162   SET_CY( (cy & bit) );               //Set Carry flag to Carry Flag Value Logical AND with Complemented Bit
163}
164
165//CJNE A, #data, code addr                  /* 1: 1011 0100 */
166INLINE void cjne_a_byte(void)
167{
168   UINT8 data = ROP_ARG(PC++);            //Grab data
169   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
170
171   if(ACC != data)                  //Jump if values are not equal
172   {
173      PC = PC + rel_addr;
174      change_pc(PC);
175   }
176
177   //Set carry flag to 1 if 1st compare value is < 2nd compare value
178   SET_CY( (ACC < data) );
179}
180
181//CJNE A, data addr, code addr              /* 1: 1011 0101 */
182INLINE void cjne_a_mem(void)
183{
184   UINT8 addr = ROP_ARG(PC++);            //Grab data address
185   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
186   UINT8 data = IRAM_R(addr);            //Pull value from data address
187
188   if(ACC != data)                  //Jump if values are not equal
189   {
190      PC = PC + rel_addr;
191      change_pc(PC);
192   }
193
194   //Set carry flag to 1 if 1st compare value is < 2nd compare value
195   SET_CY( (ACC < data) );
196}
197
198//CJNE @R0/@R1, #data, code addr            /* 1: 1011 011i */
199INLINE void cjne_ir_byte(int r)
200{
201   UINT8 data = ROP_ARG(PC++);            //Grab data
202   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
203   UINT8 srcdata = IRAM_IR(R_REG(r));      //Grab value pointed to by R0 or R1
204
205   if(srcdata != data)                  //Jump if values are not equal
206   {
207      PC = PC + rel_addr;
208      change_pc(PC);
209   }
210
211   //Set carry flag to 1 if 1st compare value is < 2nd compare value
212   SET_CY( (srcdata < data) );
213}
214
215//CJNE R0 to R7, #data, code addr           /* 1: 1011 1rrr */
216INLINE void cjne_r_byte(int r)
217{
218   UINT8 data = ROP_ARG(PC++);            //Grab data
219   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
220   UINT8 srcdata = R_REG(r);               //Grab value of R0 - R7
221
222   if(srcdata != data)                  //Jump if values are not equal
223   {
224      PC = PC + rel_addr;
225      change_pc(PC);
226   }
227
228   //Set carry flag to 1 if 1st compare value is < 2nd compare value
229   SET_CY( (srcdata < data) );
230}
231
232//CLR bit addr                              /* 1: 1100 0010 */
233INLINE void clr_bitaddr(void)
234{
235   UINT8 addr = ROP_ARG(PC++);            //Grab bit address
236   BIT_W(addr,0);                     //Clear bit at specified bit address
237}
238
239//CLR C                                     /* 1: 1100 0011 */
240INLINE void clr_c(void)
241{
242   SET_CY(0);                        //Clear Carry Flag
243}
244
245//CLR A                                     /* 1: 1110 0100 */
246INLINE void clr_a(void)
247{
248   SET_ACC(0);                     //Clear Accumulator
249}
250
251//CPL bit addr                              /* 1: 1011 0010 */
252INLINE void cpl_bitaddr(void)
253{
254   UINT8 addr = ROP_ARG(PC++);            //Grab bit address
255   UINT8 data = (~BIT_R(addr))&1;
256   BIT_W(addr,data);                  //Complement bit at specified bit address
257}
258
259//CPL C                                     /* 1: 1011 0011 */
260INLINE void cpl_c(void)
261{
262   UINT8 bit = (~GET_CY)&1;            //Complement Carry Flag
263   SET_CY(bit);
264}
265
266//CPL A                                     /* 1: 1111 0100 */
267INLINE void cpl_a(void)
268{
269   UINT8 data = ((~ACC)&0xff);
270   SET_ACC(data);                  //Complement Accumulator
271}
272
273//DA A                                      /* 1: 1101 0100 */
274INLINE void da_a(void)
275{
276/*From several sources, since none said the same thing:
277 The decimal adjust instruction is associated with the use of the ADD and ADDC instructions.
278 The eight-bit value in the accumulator is adjusted to form two BCD digits of four bits each.
279 If the accumulator contents bits 0-3 are greater than 9, OR the AC flag is set, then six is added to
280 produce a proper BCD digit.
281 If the carry is set, OR the four high bits 4-7 exceed nine, six is added to the value of these bits.
282 The carry flag will be set if the result is > 0x99, but not cleared otherwise */
283
284 UINT16 new_acc = ACC & 0xff;
285 if(GET_AC || (new_acc & 0x0f) > 0x09)
286    new_acc += 0x06;
287 if(GET_CY || ((new_acc & 0xf0) > 0x90) || (new_acc & ~0xff))
288    new_acc += 0x60;
289 SET_ACC(new_acc&0xff);
290 if(new_acc & ~0xff)
291   SET_CY(1);
292}
293
294//DEC A                                     /* 1: 0001 0100 */
295INLINE void dec_a(void)
296{
297   SET_ACC(ACC-1);
298}
299
300//DEC data addr                             /* 1: 0001 0101 */
301INLINE void dec_mem(void)
302{
303   UINT8 addr = ROP_ARG(PC++);            //Grab data address
304   UINT8 data = IRAM_R(addr);
305   IRAM_W(addr,data-1);
306}
307
308//DEC @R0/@R1                               /* 1: 0001 011i */
309INLINE void dec_ir(int r)
310{
311   UINT8 data = IRAM_IR(R_REG(r));
312   IRAM_W(R_REG(r),data-1);
313}
314
315//DEC R0 to R7                              /* 1: 0001 1rrr */
316INLINE void dec_r(int r)
317{
318   SET_REG(r, R_REG(r) - 1);
319}
320
321//DIV AB                                    /* 1: 1000 0100 */
322INLINE void div_ab(void)
323{
324   if( B == 0 ) {
325      //Overflow flag is set!
326      SET_OV(1);
327      //Really the values are undefined according to the manual, but we'll just leave them as is..
328      //SET_ACC(0xff);
329      //SFR_W(B,0xff);
330   }
331   else {
332      int a = (int)ACC / B;
333      int b = (int)ACC % B;
334      //A gets quotient byte, B gets remainder byte
335      SET_ACC(a);
336      B = b;
337      //Overflow flag is cleared
338      SET_OV(0);
339   }
340   //Carry Flag is always cleared
341   SET_CY(0);
342}
343
344//DJNZ data addr, code addr                 /* 1: 1101 0101 */
345INLINE void djnz_mem(void)
346{
347   UINT8 addr = ROP_ARG(PC++);            //Grab data address
348   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
349   IRAM_W(addr,IRAM_R(addr) - 1);         //Decrement value contained at data address
350   if(IRAM_R(addr) != 0)               //Branch if contents of data address is not 0
351   {
352      PC = PC + rel_addr;
353      change_pc(PC);
354   }
355}
356
357//DJNZ R0 to R7,code addr                   /* 1: 1101 1rrr */
358INLINE void djnz_r(int r)
359{
360   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
361   SET_REG(r ,R_REG(r) - 1);               //Decrement value
362   if(R_REG(r) != 0)                     //Branch if contents of R0 - R7 is not 0
363   {
364      PC = PC + rel_addr;
365      change_pc(PC);
366   }
367}
368
369//INC A                                     /* 1: 0000 0100 */
370INLINE void inc_a(void)
371{
372   SET_ACC(ACC+1);
373}
374
375//INC data addr                             /* 1: 0000 0101 */
376INLINE void inc_mem(void)
377{
378   UINT8 addr = ROP_ARG(PC++);            //Grab data address
379   UINT8 data = IRAM_R(addr);
380   IRAM_W(addr,data+1);
381}
382
383//INC @R0/@R1                               /* 1: 0000 011i */
384INLINE void inc_ir(int r)
385{
386   UINT8 data = IRAM_IR(R_REG(r));
387   IRAM_W(R_REG(r),data+1);
388}
389
390//INC R0 to R7                              /* 1: 0000 1rrr */
391INLINE void inc_r(int r)
392{
393   UINT8 data = R_REG(r);
394   SET_REG(r, data + 1);
395}
396
397//INC DPTR                                  /* 1: 1010 0011 */
398INLINE void inc_dptr(void)
399{
400   UINT16 dptr = (DPTR)+1;
401   SET_DPTR(dptr);
402}
403
404//JB  bit addr, code addr                   /* 1: 0010 0000 */
405INLINE void jb(void)
406{
407   UINT8 addr = ROP_ARG(PC++);            //Grab bit address
408   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
409   if(BIT_R(addr))                     //If bit set at specified bit address, jump
410   {
411      PC = PC + rel_addr;
412      change_pc(PC);
413   }
414}
415
416//JBC bit addr, code addr                   /* 1: 0001 0000 */
417INLINE void jbc(void)
418{
419   UINT8 addr = ROP_ARG(PC++);            //Grab bit address
420   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
421   if(BIT_R(addr))   {                  //If bit set at specified bit address, jump
422      PC = PC + rel_addr;
423      BIT_W(addr,0);                  //Clear Bit also
424      change_pc(PC);
425   }
426}
427
428//JC code addr                              /* 1: 0100 0000 */
429INLINE void jc(void)
430{
431   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
432   if(GET_CY)                        //Jump if Carry Flag Set
433   {
434      PC = PC + rel_addr;
435      change_pc(PC);
436   }
437}
438
439//JMP @A+DPTR                               /* 1: 0111 0011 */
440INLINE void jmp_iadptr(void)
441{
442   PC = ACC + DPTR;
443   change_pc(PC);
444}
445
446//JNB bit addr, code addr                   /* 1: 0011 0000 */
447INLINE void jnb(void)
448{
449   UINT8 addr = ROP_ARG(PC++);            //Grab bit address
450   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
451   if(!BIT_R(addr))                  //If bit NOT set at specified bit address, jump
452   {
453      PC = PC + rel_addr;
454      change_pc(PC);
455   }
456}
457
458//JNC code addr                             /* 1: 0101 0000 */
459INLINE void jnc(void)
460{
461   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
462   if(!GET_CY)                        //Jump if Carry Flag not set
463   {
464      PC = PC + rel_addr;
465      change_pc(PC);
466   }
467}
468
469//JNZ code addr                             /* 1: 0111 0000 */
470INLINE void jnz(void)
471{
472   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
473   if(ACC != 0)                     //Branch if ACC is not 0
474   {
475      PC = PC+rel_addr;
476      change_pc(PC);
477   }
478}
479
480//JZ code addr                              /* 1: 0110 0000 */
481INLINE void jz(void)
482{
483   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
484   if(ACC == 0)                     //Branch if ACC is 0
485   {
486      PC = PC+rel_addr;
487      change_pc(PC);
488   }
489}
490
491//LCALL code addr                           /* 1: 0001 0010 */
492INLINE void lcall(void)
493{
494   UINT8 addr_hi, addr_lo;
495   addr_hi = ROP_ARG(PC++);
496   addr_lo = ROP_ARG(PC++);
497   PUSH_PC();
498   PC = (UINT16)((addr_hi<<8) | addr_lo);
499   change_pc(PC);
500}
501
502//LJMP code addr                            /* 1: 0000 0010 */
503INLINE void ljmp(void)
504{
505   UINT8 addr_hi, addr_lo;
506   addr_hi = ROP_ARG(PC++);
507   addr_lo = ROP_ARG(PC++);
508   PC = (UINT16)((addr_hi<<8) | addr_lo);
509   change_pc(PC);
510}
511
512//MOV A, #data                              /* 1: 0111 0100 */
513INLINE void mov_a_byte(void)
514{
515   UINT8 data = ROP_ARG(PC++);            //Grab data
516   SET_ACC(data);                  //Store data to ACC
517}
518
519//MOV A, data addr                          /* 1: 1110 0101 */
520INLINE void mov_a_mem(void)
521{
522   UINT8 addr = ROP_ARG(PC++);            //Grab data address
523   SET_ACC(IRAM_R(addr));            //Store contents of data address to ACC
524}
525
526//MOV A,@RO/@R1                             /* 1: 1110 011i */
527INLINE void mov_a_ir(int r)
528{
529   SET_ACC(IRAM_IR(R_REG(r)));            //Store contents of address pointed by R0 or R1 to ACC
530}
531
532//MOV A,R0 to R7                            /* 1: 1110 1rrr */
533INLINE void mov_a_r(int r)
534{
535   SET_ACC(R_REG(r));                  //Store contents of R0 - R7 to ACC
536}
537
538//MOV data addr, #data                      /* 1: 0111 0101 */
539INLINE void mov_mem_byte(void)
540{
541   UINT8 addr = ROP_ARG(PC++);            //Grab data address
542   UINT8 data = ROP_ARG(PC++);            //Grab data
543   IRAM_W(addr,data);                  //Store data to data address location
544}
545
546//MOV data addr, data addr                  /* 1: 1000 0101 */
547INLINE void mov_mem_mem(void)
548{
549   //1st address is src, 2nd is dst, but the mov command works as mov dst,src)
550   UINT8 src,dst;
551   src = ROP_ARG(PC++);               //Grab source data address
552   dst = ROP_ARG(PC++);               //Grab destination data address
553   IRAM_W(dst,IRAM_R(src));            //Read source address contents and store to destination address
554}
555
556//MOV @R0/@R1, #data                        /* 1: 0111 011i */
557INLINE void mov_ir_byte(int r)
558{
559   UINT8 data = ROP_ARG(PC++);            //Grab data
560   IRAM_IW(R_REG(r),data);               //Store data to address pointed by R0 or R1
561}
562
563//MOV R0 to R7, #data                       /* 1: 0111 1rrr */
564INLINE void mov_r_byte(int r)
565{
566   UINT8 data = ROP_ARG(PC++);            //Grab data
567   SET_REG(r, data);                     //Store to R0 - R7
568}
569
570//MOV data addr, @R0/@R1                    /* 1: 1000 011i */
571INLINE void mov_mem_ir(int r)
572{
573   UINT8 addr = ROP_ARG(PC++);            //Grab data address
574   IRAM_W(addr,IRAM_IR(R_REG(r)));         //Store contents pointed to by R0 or R1 to data address
575}
576
577//MOV data addr,R0 to R7                    /* 1: 1000 1rrr */
578INLINE void mov_mem_r(int r)
579{
580   UINT8 addr = ROP_ARG(PC++);            //Grab data address
581   IRAM_W(addr,R_REG(r));               //Store contents of R0 - R7 to data address
582}
583
584//MOV DPTR, #data16                         /* 1: 1001 0000 */
585INLINE void mov_dptr_byte(void)
586{
587   UINT8 data_hi, data_lo;
588   data_hi = ROP_ARG(PC++);            //Grab hi byte
589   data_lo = ROP_ARG(PC++);            //Grab lo byte
590   SET_DPTR((UINT16)((data_hi<<8)|data_lo));   //Store to DPTR
591}
592
593//MOV bit addr, C                           /* 1: 1001 0010 */
594INLINE void mov_bitaddr_c(void)
595{
596   UINT8 addr = ROP_ARG(PC++);            //Grab bit address
597   BIT_W(addr,GET_CY);                  //Store Carry Flag to Bit Address
598}
599
600//MOV @R0/@R1, data addr                    /* 1: 1010 011i */
601INLINE void mov_ir_mem(int r)
602{
603   UINT8 addr = ROP_ARG(PC++);            //Grab data address
604   IRAM_IW(R_REG(r),IRAM_R(addr));         //Store data from data address to address pointed to by R0 or R1
605}
606
607//MOV R0 to R7, data addr                   /* 1: 1010 1rrr */
608INLINE void mov_r_mem(int r)
609{
610   UINT8 addr = ROP_ARG(PC++);            //Grab data address
611   SET_REG(r, IRAM_R(addr));            //Store to R0 - R7
612}
613
614//MOV data addr, A                          /* 1: 1111 0101 */
615INLINE void mov_mem_a(void)
616{
617   UINT8 addr = ROP_ARG(PC++);            //Grab data address
618   IRAM_W(addr,ACC);                  //Store A to data address
619}
620
621//MOV @R0/@R1, A                            /* 1: 1111 011i */
622INLINE void mov_ir_a(int r)
623{
624   IRAM_IW(R_REG(r),ACC);               //Store A to location pointed to by R0 or R1
625}
626
627//MOV R0 to R7, A                           /* 1: 1111 1rrr */
628INLINE void mov_r_a(int r)
629{
630   SET_REG(r, ACC);                  //Store A to R0-R7
631}
632
633//MOVC A, @A + PC                           /* 1: 1000 0011 */
634INLINE void movc_a_iapc(void)
635{
636   UINT8 data;
637   data = CODEMEM_R(ACC+PC);            //Move a byte from CODE(Program) Memory and store to ACC
638   SET_ACC(data);
639}
640
641//MOV C, bit addr                           /* 1: 1010 0010 */
642INLINE void mov_c_bitaddr(void)
643{
644   UINT8 addr = ROP_ARG(PC++);            //Grab bit address
645   SET_CY( (BIT_R(addr)) );            //Store Bit from Bit Address to Carry Flag
646}
647
648//MOVC A, @A + DPTR                         /* 1: 1001 0011 */
649INLINE void movc_a_iadptr(void)
650{
651   UINT8 data;
652   data = CODEMEM_R(ACC + DPTR);         //Move a byte from CODE(Program) Memory and store to ACC
653   SET_ACC(data);
654}
655
656//MOVX A,@DPTR                              /* 1: 1110 0000 */
657//(Move External Ram 16 bit address to A)
658INLINE void movx_a_idptr(void)
659{
660//  UINT8 byte = DATAMEM_R(R_DPTR);         //Grab 1 byte from External DATA memory pointed to by dptr
661   UINT32 addr = ERAM_ADDR(DPTR, 0xFFFF);
662   UINT8 byte = DATAMEM_R(addr);         //Grab 1 byte from External DATA memory pointed to by dptr
663   SET_ACC(byte);                  //Store to ACC
664}
665
666//MOVX A, @R0/@R1                           /* 1: 1110 001i */
667//(Move External Ram 8 bit address to A)
668INLINE void movx_a_ir(int r)
669{
670   UINT32 addr = ERAM_ADDR(R_REG(r),0xFF);   //Grab address by reading location pointed to by R0 or R1
671   UINT8 byte = DATAMEM_R(addr);         //Grab 1 byte from External DATA memory pointed to by address
672   SET_ACC(byte);                  //Store to ACC
673}
674
675//MOVX @DPTR,A                              /* 1: 1111 0000 */
676//(Move A to External Ram 16 bit address)
677INLINE void movx_idptr_a(void)
678{
679//  DATAMEM_W(R_DPTR, ACC);               //Store ACC to External DATA memory address pointed to by DPTR
680   UINT32 addr = ERAM_ADDR(DPTR, 0xFFFF);
681   DATAMEM_W(addr, ACC);            //Store ACC to External DATA memory address pointed to by DPTR
682}
683
684//MOVX @R0/@R1,A                            /* 1: 1111 001i */
685//(Move A to External Ram 8 bit address)
686INLINE void movx_ir_a(int r)
687{
688   UINT32 addr = ERAM_ADDR(R_REG(r),0xFF);   //Grab address by reading location pointed to by R0 or R1
689   DATAMEM_W(addr, ACC);               //Store ACC to External DATA memory address
690}
691
692//MUL AB                                    /* 1: 1010 0100 */
693INLINE void mul_ab(void)
694{
695   UINT16 result = ACC * B;
696   //A gets lo bits, B gets hi bits of result
697   B = (UINT8) ((result & 0xFF00) >> 8);
698   SET_ACC((UINT8)(result & 0x00FF));
699   //Set flags
700   SET_OV( ((result & 0x100) >> 8) );      //Set/Clear Overflow Flag if result > 255
701   SET_CY(0);                        //Carry Flag always cleared
702}
703
704//NOP                                       /* 1: 0000 0000 */
705INLINE void nop(void)
706{
707}
708
709//ORL data addr, A                          /* 1: 0100 0010 */
710INLINE void orl_mem_a(void)
711{
712   UINT8 addr = ROP_ARG(PC++);            //Grab data address
713   UINT8 data = IRAM_R(addr);            //Grab data from data address
714   IRAM_W(addr,data | ACC);            //Set data address value to it's value Logical OR with ACC
715}
716
717//ORL data addr, #data                      /* 1: 0100 0011 */
718INLINE void orl_mem_byte(void)
719{
720   UINT8 addr = ROP_ARG(PC++);            //Grab data address
721   UINT8 data = ROP_ARG(PC++);            //Grab data
722   UINT8 srcdata = IRAM_R(addr);         //Grab data from data address
723   IRAM_W(addr,srcdata | data);         //Set data address value to it's value Logical OR with Data
724}
725
726//ORL A, #data                              /* 1: 0100 0100 */
727INLINE void orl_a_byte(void)
728{
729   UINT8 data = ROP_ARG(PC++);            //Grab data
730   SET_ACC(ACC | data);            //Set ACC to value of ACC Logical OR with Data
731}
732
733//ORL A, data addr                          /* 1: 0100 0101 */
734INLINE void orl_a_mem(void)
735{
736   UINT8 addr = ROP_ARG(PC++);            //Grab data address
737   UINT8 data = IRAM_R(addr);            //Grab data from data address
738   SET_ACC(ACC | data);            //Set ACC to value of ACC Logical OR with Data
739}
740
741//ORL A, @RO/@R1                            /* 1: 0100 011i */
742INLINE void orl_a_ir(int r)
743{
744   UINT8 data = IRAM_IR(R_REG(r));         //Grab data from address R0 or R1 points to
745   SET_ACC(ACC | data);            //Set ACC to value of ACC Logical OR with Data
746}
747
748//ORL A, RO to R7                           /* 1: 0100 1rrr */
749INLINE void orl_a_r(int r)
750{
751   UINT8 data = R_REG(r);               //Grab data from R0 - R7
752   SET_ACC(ACC | data);            //Set ACC to value of ACC Logical OR with Data
753}
754
755//ORL C, bit addr                           /* 1: 0111 0010 */
756INLINE void orl_c_bitaddr(void)
757{
758   int cy = GET_CY;
759   UINT8 addr = ROP_ARG(PC++);            //Grab bit address
760   UINT8 bit = BIT_R(addr);            //Grab bit data from bit address
761   SET_CY( (cy | bit) );               //Set Carry flag to Carry Flag Value Logical OR with Bit
762}
763
764//ORL C, /bit addr                          /* 1: 1010 0000 */
765INLINE void orl_c_nbitaddr(void)
766{
767   int cy = GET_CY;
768   UINT8 addr = ROP_ARG(PC++);            //Grab bit address
769   UINT8 bit = BIT_R(addr);            //Grab bit data from bit address
770   bit = ((~bit)&1);                  //Complement bit
771   SET_CY( (cy | bit) );               //Set Carry flag to Carry Flag Value Logical OR with Complemented Bit
772}
773
774//POP data addr                             /* 1: 1101 0000 */
775INLINE void pop(void)
776{
777   UINT8 addr = ROP_ARG(PC++);            //Grab data address
778   IRAM_W(addr, IRAM_IR(SP));            //Store to contents of data addr, data pointed to by Stack - IRAM_IR needed to access upper 128 bytes of stack
779   //IRAM_IW(addr, IRAM_IR(R_SP));         //Store to contents of data addr, data pointed to by Stack - doesn't work, sfr's are not restored this way and it's not an indirect access anyway
780   SP = SP-1;                        //Decrement SP
781}
782
783//PUSH data addr                            /* 1: 1100 0000 */
784INLINE void push(void)
785{
786   UINT8 addr = ROP_ARG(PC++);            //Grab data address
787   UINT8 tmpSP = SP+1;               //Grab and Increment Stack Pointer
788   SP = tmpSP;                     // ""
789   IRAM_IW(tmpSP, IRAM_R(addr));         //Store to stack contents of data address - IRAM_IW needed to store to upper 128 bytes of stack, however, can't use IRAM_IR because that won't store the sfrs and it's not an indirect access anyway
790}
791
792//RET                                       /* 1: 0010 0010 */
793INLINE void ret(void)
794{
795   POP_PC();
796}
797
798//RETI                                      /* 1: 0011 0010 */
799INLINE void reti(void)
800{
801   POP_PC();
802   CLEAR_CURRENT_IRQ();
803}
804
805//RL A                                      /* 1: 0010 0011 */
806INLINE void rl_a(void)
807{
808   //Left Shift A, Bit 7 carries to Bit 0
809   int carry = ((ACC & 0x80) >> 7);
810   int data = (ACC<<1) & 0xfe;
811   SET_ACC( data | carry);
812}
813
814//RLC A                                     /* 1: 0011 0011 */
815INLINE void rlc_a(void)
816{
817   //Left Shift A, Bit 7 goes to Carry Flag, Original Carry Flag goes to Bit 0 of ACC
818   int carry = ((ACC & 0x80) >> 7);
819   int data = ((ACC<<1) & 0xfe) | GET_CY;
820   SET_ACC( data);
821   SET_CY(carry);
822}
823
824//RR A                                      /* 1: 0000 0011 */
825INLINE void rr_a(void)
826{
827   //Right Shift A, Bit 0 carries to Bit 7
828   int carry = ((ACC & 1) << 7);
829   int data = (ACC>>1) & 0x7f;
830   SET_ACC( data | carry);
831}
832
833//RRC A                                     /* 1: 0001 0011 */
834INLINE void rrc_a(void)
835{
836   //Right Shift A, Bit 0 goes to Carry Flag, Bit 7 of ACC gets set to original Carry Flag
837   int carry = (ACC & 1);
838   int data = ((ACC>>1) & 0x7f) | (GET_CY<<7);
839   SET_ACC( data);
840   SET_CY(carry);
841}
842
843//SETB C                                    /* 1: 1101 0011 */
844INLINE void setb_c(void)
845{
846   SET_CY(1);      //Set Carry Flag
847}
848
849//SETB bit addr                             /* 1: 1101 0010 */
850INLINE void setb_bitaddr(void)
851{
852   UINT8 addr = ROP_ARG(PC++);            //Grab bit address
853   BIT_W(addr,1);                     //Set Bit at Bit Address
854}
855
856//SJMP code addr                            /* 1: 1000 0000 */
857INLINE void sjmp(void)
858{
859   INT8 rel_addr = ROP_ARG(PC++);         //Grab relative code address
860   PC = PC + rel_addr;                  //Update PC
861   change_pc(PC);
862}
863
864//SUBB A, #data                             /* 1: 1001 0100 */
865INLINE void subb_a_byte(void)
866{
867   UINT8 data = ROP_ARG(PC++);            //Grab data
868   UINT8 result = ACC - data - GET_CY;   //Subtract data & carry flag from accumulator
869   DO_SUB_FLAGS(ACC,data,GET_CY);      //Set Flags
870   SET_ACC(result);                  //Store 8 bit result of addtion in ACC
871
872}
873
874//SUBB A, data addr                         /* 1: 1001 0101 */
875INLINE void subb_a_mem(void)
876{
877   UINT8 addr = ROP_ARG(PC++);            //Grab data address
878   UINT8 data = IRAM_R(addr);            //Grab data from data address
879   UINT8 result = ACC - data - GET_CY;   //Subtract data & carry flag from accumulator
880   DO_SUB_FLAGS(ACC,data,GET_CY);      //Set Flags
881   SET_ACC(result);                  //Store 8 bit result of addtion in ACC
882}
883
884//SUBB A, @R0/@R1                           /* 1: 1001 011i */
885INLINE void subb_a_ir(int r)
886{
887   UINT8 data = IRAM_IR(R_REG(r));         //Grab data from memory pointed to by R0 or R1
888   UINT8 result = ACC - data - GET_CY;   //Subtract data & carry flag from accumulator
889   DO_SUB_FLAGS(ACC,data,GET_CY);      //Set Flags
890   SET_ACC(result);                  //Store 8 bit result of addtion in ACC
891}
892
893//SUBB A, R0 to R7                          /* 1: 1001 1rrr */
894INLINE void subb_a_r(int r)
895{
896   UINT8 data = R_REG(r);               //Grab data from R0 - R7
897   UINT8 result = ACC - data - GET_CY;   //Subtract data & carry flag from accumulator
898   DO_SUB_FLAGS(ACC,data,GET_CY);      //Set Flags
899   SET_ACC(result);                  //Store 8 bit result of addtion in ACC
900}
901
902//SWAP A                                    /* 1: 1100 0100 */
903INLINE void swap_a(void)
904{
905   UINT8 a_nib_lo, a_nib_hi;
906   a_nib_hi = (ACC & 0x0f) << 4;         //Grab lo byte of ACC and move to hi
907   a_nib_lo = (ACC & 0xf0) >> 4;         //Grab hi byte of ACC and move to lo
908   SET_ACC( a_nib_hi | a_nib_lo);
909}
910
911//XCH A, data addr                          /* 1: 1100 0101 */
912INLINE void xch_a_mem(void)
913{
914   UINT8 addr = ROP_ARG(PC++);            //Grab data address
915   UINT8 data = IRAM_R(addr);            //Grab data
916   UINT8 oldACC = ACC;               //Hold value of ACC
917   SET_ACC(data);                  //Sets ACC to data
918   IRAM_W(addr,oldACC);               //Sets data address to old value of ACC
919}
920
921//XCH A, @RO/@R1                            /* 1: 1100 011i */
922INLINE void xch_a_ir(int r)
923{
924   UINT8 data = IRAM_IR(R_REG(r));         //Grab data pointed to by R0 or R1
925   UINT8 oldACC = ACC;               //Hold value of ACC
926   SET_ACC(data);                  //Sets ACC to data
927   IRAM_W(R_REG(r),oldACC);               //Sets data address to old value of ACC
928}
929
930//XCH A, RO to R7                           /* 1: 1100 1rrr */
931INLINE void xch_a_r(int r)
932{
933   UINT8 data = R_REG(r);               //Grab data from R0-R7
934   UINT8 oldACC = ACC;               //Hold value of ACC
935   SET_ACC(data);                  //Sets ACC to data
936   SET_REG(r, oldACC);                  //Sets data address to old value of ACC
937}
938
939//XCHD A, @R0/@R1                           /* 1: 1101 011i */
940INLINE void xchd_a_ir(int r)
941{
942   UINT8 acc, ir_data;
943   ir_data = IRAM_IR(R_REG(r));            //Grab data pointed to by R0 or R1
944   acc = ACC;                     //Grab ACC value
945   SET_ACC( (acc & 0xf0) | (ir_data & 0x0f) );      //Set ACC to lower nibble of data pointed to by R0 or R1
946   IRAM_W(R_REG(r), (ir_data & 0xf0) | (acc & 0x0f) );   //Set data pointed to by R0 or R1 to lower nibble of ACC
947}
948
949//XRL data addr, A                          /* 1: 0110 0010 */
950INLINE void xrl_mem_a(void)
951{
952   UINT8 addr = ROP_ARG(PC++);            //Grab data address
953   UINT8 data = IRAM_R(addr);            //Grab data from data address
954   IRAM_W(addr,data ^ ACC);            //Set data address value to it's value Logical XOR with ACC
955}
956
957//XRL data addr, #data                      /* 1: 0110 0011 */
958INLINE void xrl_mem_byte(void)
959{
960   UINT8 addr = ROP_ARG(PC++);            //Grab data address
961   UINT8 data = ROP_ARG(PC++);            //Grab data
962   UINT8 srcdata = IRAM_R(addr);         //Grab data from data address
963   IRAM_W(addr,srcdata ^ data);         //Set data address value to it's value Logical XOR with Data
964}
965
966//XRL A, #data                              /* 1: 0110 0100 */
967INLINE void xrl_a_byte(void)
968{
969   UINT8 data = ROP_ARG(PC++);            //Grab data
970   SET_ACC(ACC ^ data);            //Set ACC to value of ACC Logical XOR with Data
971}
972
973//XRL A, data addr                          /* 1: 0110 0101 */
974INLINE void xrl_a_mem(void)
975{
976   UINT8 addr = ROP_ARG(PC++);            //Grab data address
977   UINT8 data = IRAM_R(addr);            //Grab data from data address
978   SET_ACC(ACC ^ data);            //Set ACC to value of ACC Logical XOR with Data
979}
980
981//XRL A, @R0/@R1                            /* 1: 0110 011i */
982INLINE void xrl_a_ir(int r)
983{
984   UINT8 data = IRAM_IR(R_REG(r));         //Grab data from address R0 or R1 points to
985   SET_ACC(ACC ^ data);            //Set ACC to value of ACC Logical XOR with Data
986}
987
988//XRL A, R0 to R7                           /* 1: 0110 1rrr */
989INLINE void xrl_a_r(int r)
990{
991   UINT8 data = R_REG(r);               //Grab data from R0 - R7
992   SET_ACC(ACC ^ data);            //Set ACC to value of ACC Logical XOR with Data
993}
994
995//illegal opcodes
996INLINE void illegal(UINT8 op)
997{
998   LOG(("i8051 #%d: illegal opcode at 0x%03x: %02x\n", cpu_getactivecpu(), PC-1, op));
999}
src/emu/cpu/mcs51/mcs51.h
r0r3515
1/*****************************************************************************
2 *
3 *   mcs51.h
4 *   Portable MCS-51 Family Emulator
5 *
6 *   Chips in the family:
7 *   8051 Product Line (8031,8051,8751)
8 *   8052 Product Line (8032,8052,8752)
9 *   8054 Product Line (8054)
10 *   8058 Product Line (8058)
11 *
12 *   Copyright Steve Ellenoff, all rights reserved.
13 *
14 *   - This source code is released as freeware for non-commercial purposes.
15 *   - You are free to use and redistribute this code in modified or
16 *     unmodified form, provided you list me in the credits.
17 *   - If you modify this source code, you must add a notice to each modified
18 *     source file that it has been changed.  If you're a nice person, you
19 *     will clearly mark each change too.  :)
20 *   - If you wish to use this for commercial purposes, please contact me at
21 *     sellenoff@hotmail.com
22 *   - The author of this copywritten work reserves the right to change the
23 *     terms of its usage and license at any time, including retroactively
24 *   - This entire notice must remain in the source code.
25 *
26 *  This work is based on:
27 *  #1) 'Intel(tm) MC51 Microcontroller Family Users Manual' and
28 *  #2) 8051 simulator by Travis Marlatte
29 *  #3) Portable UPI-41/8041/8741/8042/8742 emulator V0.1 by Juergen Buchmueller (MAME CORE)
30 *
31 * 2008, October, Couriersud
32 * - Rewrite of timer, interrupt and serial code
33 * - addition of CMOS features
34 * - internal memory maps
35 * - addition of new processor types
36 * - full emulation of 8xCx2 processors
37 *****************************************************************************/
38
39#pragma once
40
41#ifndef __MCS51_H__
42#define __MCS51_H__
43
44#include "cpuintrf.h"
45
46enum
47{
48   MCS51_PC=1, MCS51_SP, MCS51_PSW, MCS51_ACC, MCS51_B, MCS51_DPH, MCS51_DPL, MCS51_IE,
49   MCS51_R0, MCS51_R1, MCS51_R2, MCS51_R3, MCS51_R4, MCS51_R5, MCS51_R6, MCS51_R7, MCS51_RB
50};
51
52enum
53{
54   MCS51_INT0_LINE = 0,    /* P3.2: External Interrupt 0 */
55   MCS51_INT1_LINE,      /* P3.3: External Interrupt 1 */
56   MCS51_RX_LINE,         /* P3.0: Serial Port Receive Line */
57   MCS51_T0_LINE,         /* P3,4: Timer 0 External Input */
58   MCS51_T1_LINE,         /* P3.5: Timer 1 External Input */
59   MCS51_T2_LINE,         /* P1.0: Timer 2 External Input */
60   MCS51_T2EX_LINE,      /* P1.1: Timer 2 Capture Reload Trigger */
61
62   DS5002FP_PFI_LINE,      /* DS5002FP Power fail interrupt */
63};
64
65/* special I/O space ports */
66
67enum
68{
69   MCS51_PORT_P0   = 0x10000,
70   MCS51_PORT_P1   = 0x10001,
71   MCS51_PORT_P2   = 0x10002,
72   MCS51_PORT_P3   = 0x10003,
73   MCS51_PORT_TX   = 0x10004,   /* P3.1 */
74};
75
76/***************************************************************************
77    CONFIGURATION
78***************************************************************************/
79
80/* configuration of the DS5002FP */
81typedef struct _ds5002fp_config ds5002fp_config;
82struct _ds5002fp_config
83{
84   UINT8   mcon;               /* bootstrap loader MCON register */
85   UINT8   rpctl;               /* bootstrap loader RPCTL register */
86   UINT8   crc;               /* bootstrap loader CRC register */
87};
88
89/***************************************************************************
90    FUNCTION PROTOTYPES
91***************************************************************************/
92
93extern void i8051_set_serial_tx_callback(void (*callback)(int data));
94extern void i8051_set_serial_rx_callback(int (*callback)(void));
95
96/* variants with no internal rom and 128 byte internal memory */
97void i8031_get_info(UINT32 state, cpuinfo *info);
98
99/* variants with no internal rom and 256 byte internal memory */
100void i8032_get_info(UINT32 state, cpuinfo *info);
101
102/* variants 4k internal rom and 128 byte internal memory */
103void i8051_get_info(UINT32 state, cpuinfo *info);
104void i8751_get_info(UINT32 state, cpuinfo *info);
105
106/* variants 8k internal rom and 256 byte internal memory and more registers */
107void i8052_get_info(UINT32 state, cpuinfo *info);
108void i8752_get_info(UINT32 state, cpuinfo *info);
109
110/* cmos variants */
111void i80c31_get_info(UINT32 state, cpuinfo *info);
112void i80c51_get_info(UINT32 state, cpuinfo *info);
113void i87c51_get_info(UINT32 state, cpuinfo *info);
114
115void i80c32_get_info(UINT32 state, cpuinfo *info);
116void i80c52_get_info(UINT32 state, cpuinfo *info);
117void i87c52_get_info(UINT32 state, cpuinfo *info);
118
119/* 4k internal perom and 128 internal ram and 2 analog comparators */
120void at89c4051_get_info(UINT32 state, cpuinfo *info);
121
122/****************************************************************************
123 * Disassembler
124 ****************************************************************************/
125
126offs_t i8051_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram);
127
128#endif /* __MCS51_H__ */
src/emu/cpu/mcs51/mcs51dasm.c
r0r3515
1/*****************************************************************************
2 *
3 *   i8051dasm.c
4 *   Portable MCS-51 Family Emulator
5 *
6 *   Chips in the family:
7 *   8051 Product Line (8031,8051,8751)
8 *   8052 Product Line (8032,8052,8752)
9 *   8054 Product Line (8054)
10 *   8058 Product Line (8058)
11 *
12 *   Copyright Steve Ellenoff, all rights reserved.
13 *
14 *   - This source code is released as freeware for non-commercial purposes.
15 *   - You are free to use and redistribute this code in modified or
16 *     unmodified form, provided you list me in the credits.
17 *   - If you modify this source code, you must add a notice to each modified
18 *     source file that it has been changed.  If you're a nice person, you
19 *     will clearly mark each change too.  :)
20 *   - If you wish to use this for commercial purposes, please contact me at
21 *     sellenoff@hotmail.com
22 *   - The author of this copywritten work reserves the right to change the
23 *     terms of its usage and license at any time, including retroactively
24 *   - This entire notice must remain in the source code.
25 *
26 *  This work is based on:
27 *  #1) 'Intel(tm) MC51 Microcontroller Family Users Manual' and
28 *  #2) 8051 simulator by Travis Marlatte
29 *  #3) Portable UPI-41/8041/8741/8042/8742 emulator V0.1 by Juergen Buchmueller (MAME CORE)
30 *
31 *****************************************************************************
32 * Symbol Memory Name Tables borrowed from:
33 * D52 8052 Disassembler - Copyright Jeffery L. Post
34 *****************************************************************************/
35
36#include "debugger.h"
37#include "mcs51.h"
38
39#define SHOW_MEMORY_NAMES   1
40
41#ifdef SHOW_MEMORY_NAMES
42
43/*Display the memory address names for data & bit address access*/
44
45//SFR Names
46static const char sfr[128][7] = {
47    "p0",     "sp",     "dpl",    "dph",    /* 80 - 83 */
48    "adat",   "85h",    "86h",    "pcon",   /* 84 - 87 */
49    "tcon",   "tmod",   "tl0",    "tl1",    /* 88 - 8b */
50    "th0",    "th1",    "pwcm",   "pwmp",   /* 8a - 8f */
51    "p1",     "91h",    "92h",    "93h",    /* 90 - 93 */
52    "94h",    "95h",    "96h",    "97h",    /* 94 - 97 */
53    "scon",   "sbuf",   "9ah",    "9bh",    /* 98 - 9b */
54    "9ch",    "9dh",    "9eh",    "9fh",    /* 9c - 9f */
55    "p2",     "0a1h",   "0a2h",   "0a3h",   /* a0 - a3 */
56    "0a4h",   "0a5h",   "0a6h",   "0a7h",   /* a4 - a7 */
57    "ie",     "cml0",   "cml1",   "cml2",   /* a8 - ab */
58    "ctl0",   "ctl1",   "ctl2",   "ctl3",   /* ac - af */
59    "p3",     "0b1h",   "0b2h",   "0b3h",   /* b0 - b3 */
60    "0b4h",   "0b5h",   "0b6h",   "0b7h",   /* b4 - b7 */
61    "ip",     "0b9h",   "0bah",   "0bbh",   /* b8 - bb */
62    "0bch",   "0bdh",   "0beh",   "0bfh",   /* bc - bf */
63    "p4",     "0c1h",   "0c2h",   "0c3h",   /* c0 - c3 */
64    "p5",     "adcon",  "adch",   "0c7h",   /* c4 - c7 */
65    "t2con",  "cmh0",   "rcap2l", "rcap2h", /* c8 - cb */
66    "tl2",    "th2",    "cth2",   "cth3",   /* cc - cf */
67    "psw",    "0d1h",   "0d2h",   "0d3h",   /* d0 - d3 */
68    "0d4h",   "0d5h",   "0d6h",   "0d7h",   /* d4 - d7 */
69    "i2cfg",  "s1sta",  "s1dat",  "s1adr",  /* d8 - db */
70    "0dch",   "0ddh",   "0deh",   "0dfh",   /* dc - df */
71    "acc",    "0e1h",   "0e2h",   "0e3h",   /* e0 - e3 */
72    "0e4h",   "0e5h",   "0e6h",   "0e7h",   /* e4 - e7 */
73    "csr",    "0e9h",   "tm2con", "ctcon",  /* e8 - eb */
74    "tml2",   "tmh2",   "ste",    "rte",    /* ec - ef */
75    "b",      "0f1h",   "0f2h",   "0f3h",   /* f0 - f3 */
76    "0f4h",   "0f5h",   "0f6h",   "0f7h",   /* f4 - f7 */
77    "i2sta",  "0f9h",   "0fah",   "0fbh",   /* f8 - fb */
78    "pwm0",   "pwm1",   "pwena",  "t3"      /* fc - ff */
79};
80
81//SFR Addressable bits
82static const char sfrbits[128][8] = {
83    "p0.0",   "p0.1",   "p0.2",   "p0.3",   /* 80 - 83 */
84    "p0.4",   "p0.5",   "p0.6",   "p0.7",   /* 84 - 87 */
85    "it0",    "ie0",    "it1",    "ie1",    /* 88 - 8b */
86    "tr0",    "tf0",    "tr1",    "tf1",    /* 8c - 8f */
87    "p1.0",   "p1.1",   "p1.2",   "p1.3",   /* 90 - 93 */
88    "p1.4",   "p1.5",   "p1.6",   "p1.7",   /* 94 - 97 */
89    "ri",     "ti",     "rb8",    "tb8",    /* 98 - 9b */
90    "ren",    "sm2",    "sm1",    "sm0",    /* 9c - 9f */
91    "p2.0",   "p2.1",   "p2.2",   "p2.3",   /* a0 - a3 */
92    "p2.4",   "p2.5",   "p2.6",   "p2.7",   /* a4 - a7 */
93    "ex0",    "et0",    "ex1",    "et1",    /* a8 - ab */
94    "es",     "ie.5",   "ie.6",   "ea",     /* ac - af */
95    "rxd",    "txd",    "int0",   "int1",   /* b0 - b3 */
96    "t0",     "t1",     "wr",     "rd",     /* b4 - b7 */
97    "px0",    "pt0",    "px1",    "pt1",    /* b8 - bb */
98    "ps",     "ip.5",   "ip.6",   "ip.7",   /* bc - bf */
99    "0c0h.0", "0c0h.1", "0c0h.2", "0c0h.3", /* c0 - c3 */
100    "0c0h.4", "0c0h.5", "0c0h.6", "0c0h.7", /* c4 - c7 */
101    "cprl2",  "ct2",    "tr2",    "exen2",  /* c8 - cb */
102    "tclk",   "rclk",   "exf2",   "tf2",    /* cc - cf */
103    "p",      "psw.1",  "ov",     "rs0",    /* d0 - d3 */
104    "rs1",    "f0",     "ac",     "cy",     /* d4 - d7 */
105    "ct0",    "ct1",    "i2cfg.2","i2cfg.3",/* d8 - db */
106    "tirun",  "clrti",  "mastrq", "slaven", /* dc - df */
107    "acc.0",  "acc.1",  "acc.2",  "acc.3",  /* e0 - e3 */
108    "acc.4",  "acc.5",  "acc.6",  "acc.7",  /* e4 - e7 */
109    "ibf",    "obf",    "idsm",   "obfc",   /* e8 - eb */
110    "ma0",    "ma1",    "mb0",    "mb1",    /* ec - ef */
111    "b.0",    "b.1",    "b.2",    "b.3",    /* f0 - f3 */
112    "b.4",    "b.5",    "b.6",    "b.7",    /* f4 - f7 */
113    "xstp",   "xstr",   "makstp", "makstr", /* f8 - fb */
114    "xactv",  "xdata",  "idle",   "i2sta.7" /* fc - ff */
115} ;
116
117//Names for bit addressable memory
118static const char membits[128][6] = {
119    "20h.0",  "20h.1",  "20h.2",  "20h.3",
120    "20h.4",  "20h.5",  "20h.6",  "20h.7",
121    "21h.0",  "21h.1",  "21h.2",  "21h.3",
122    "21h.4",  "21h.5",  "21h.6",  "21h.7",
123    "22h.0",  "22h.1",  "22h.2",  "22h.3",
124    "22h.4",  "22h.5",  "22h.6",  "22h.7",
125    "23h.0",  "23h.1",  "23h.2",  "23h.3",
126    "23h.4",  "23h.5",  "23h.6",  "23h.7",
127    "24h.0",  "24h.1",  "24h.2",  "24h.3",
128    "24h.4",  "24h.5",  "24h.6",  "24h.7",
129    "25h.0",  "25h.1",  "25h.2",  "25h.3",
130    "25h.4",  "25h.5",  "25h.6",  "25h.7",
131    "26h.0",  "26h.1",  "26h.2",  "26h.3",
132    "26h.4",  "26h.5",  "26h.6",  "26h.7",
133    "27h.0",  "27h.1",  "27h.2",  "27h.3",
134    "27h.4",  "27h.5",  "27h.6",  "27h.7",
135    "28h.0",  "28h.1",  "28h.2",  "28h.3",
136    "28h.4",  "28h.5",  "28h.6",  "28h.7",
137    "29h.0",  "29h.1",  "29h.2",  "29h.3",
138    "29h.4",  "29h.5",  "29h.6",  "29h.7",
139    "2ah.0",  "2ah.1",  "2ah.2",  "2ah.3",
140    "2ah.4",  "2ah.5",  "2ah.6",  "2ah.7",
141    "2bh.0",  "2bh.1",  "2bh.2",  "2bh.3",
142    "2bh.4",  "2bh.5",  "2bh.6",  "2bh.7",
143    "2ch.0",  "2ch.1",  "2ch.2",  "2ch.3",
144    "2ch.4",  "2ch.5",  "2ch.6",  "2ch.7",
145    "2dh.0",  "2dh.1",  "2dh.2",  "2dh.3",
146    "2dh.4",  "2dh.5",  "2dh.6",  "2dh.7",
147    "2eh.0",  "2eh.1",  "2eh.2",  "2eh.3",
148    "2eh.4",  "2eh.5",  "2eh.6",  "2eh.7",
149    "2fh.0",  "2fh.1",  "2fh.2",  "2fh.3",
150    "2fh.4",  "2fh.5",  "2fh.6",  "2fh.7"
151};
152
153//Regiser Bank memory names
154static const char regbank[][6] = {
155    "rb0r0",  "rb0r1",  "rb0r2",  "rb0r3",
156    "rb0r4",  "rb0r5",  "rb0r6",  "rb0r7",
157    "rb1r0",  "rb1r1",  "rb1r2",  "rb1r3",
158    "rb1r4",  "rb1r5",  "rb1r6",  "rb1r7",
159    "rb2r0",  "rb2r1",  "rb2r2",  "rb2r3",
160    "rb2r4",  "rb2r5",  "rb2r6",  "rb2r7",
161    "rb3r0",  "rb3r1",  "rb3r2",  "rb3r3",
162    "rb3r4",  "rb3r5",  "rb3r6",  "rb3r7"
163};
164
165static const char *get_data_address( UINT8 arg )
166{
167   char *buffer = cpuintrf_temp_str();
168
169   if(arg < 0x80)
170   {
171      //Ram locations 0-0x1F are considered register access in 3 banks
172      if(arg < 0x1f)
173         sprintf(buffer,"%s",regbank[arg]);
174      else
175         sprintf(buffer,"$%02X",arg);
176   }
177   else
178      sprintf(buffer,"%s",sfr[arg-0x80]);
179   return buffer;
180}
181
182static const char *get_bit_address( UINT8 arg )
183{
184   char *buffer = cpuintrf_temp_str();
185
186   if(arg < 0x80)
187   {
188      //Bit address 0-7F can be referred to as 20.0, 20.1, to 20.7 for address 0, and 2f.0,2f.1 to 2f.7 for address 7f
189      if(arg < 0x7f)
190         sprintf(buffer,"%s",membits[arg]);
191      else
192         sprintf(buffer,"$%02X",arg);
193   }
194   else
195      sprintf(buffer,"%s",sfrbits[arg-0x80]);
196   return buffer;
197}
198
199#else
200
201/*Just display the actual memory address for data & bit address access*/
202
203static const char *get_data_address( UINT8 arg )
204{
205   char *buffer = cpuintrf_temp_str();
206   sprintf(buffer,"$%02X",arg);
207   return buffer;
208}
209
210static const char *get_bit_address( UINT8 arg )
211{
212   char *buffer = cpuintrf_temp_str();
213   sprintf(buffer,"$%02X",arg);
214   return buffer;
215}
216
217#endif
218
219
220unsigned i8051_dasm(char *dst, unsigned pc, const UINT8 *oprom, const UINT8 *opram)
221{
222   UINT32 flags = 0;
223   unsigned PC = pc;
224   const char *sym, *sym2;
225    UINT8 op, data;
226   UINT16 addr;
227   INT8 rel;
228
229   op = oprom[PC++ - pc];
230   switch( op )
231   {
232      //NOP
233      case 0x00:            /* 1: 0000 0000 */
234         sprintf(dst, "nop");
235         break;
236
237      //AJMP code addr        /* 1: aaa0 0001 */
238      case 0x01:
239      case 0x21:
240      case 0x41:
241      case 0x61:
242      case 0x81:
243      case 0xa1:
244      case 0xc1:
245      case 0xe1:
246         addr = opram[PC++ - pc];
247         addr|= (PC & 0xf800) | ((op & 0xe0) << 3);
248         sprintf(dst, "ajmp  $%04X", addr);
249         break;
250
251      //LJMP code addr
252      case 0x02:            /* 1: 0000 0010 */
253         addr = (opram[PC++ - pc]<<8) & 0xff00;
254         addr|= opram[PC++ - pc];
255         sprintf(dst, "ljmp  $%04X", addr);
256         break;
257
258      //RR A
259      case 0x03:            /* 1: 0000 0011 */
260         sprintf(dst, "rr    a");
261         break;
262
263      //INC A
264      case 0x04:            /* 1: 0000 0100 */
265         sprintf(dst, "inc   a");
266         break;
267
268      //INC data addr
269      case 0x05:            /* 1: 0000 0101 */
270         sym = get_data_address(opram[PC++ - pc]);
271         sprintf(dst, "inc   %s", sym);
272         break;
273
274      //INC @R0/@R1           /* 1: 0000 011i */
275      case 0x06:
276      case 0x07:
277         sprintf(dst, "inc   @r%d", op&1);
278         break;
279
280      //INC R0 to R7          /* 1: 0000 1rrr */
281      case 0x08:
282      case 0x09:
283      case 0x0a:
284      case 0x0b:
285      case 0x0c:
286      case 0x0d:
287      case 0x0e:
288      case 0x0f:
289         sprintf(dst, "inc   r%d", op&7);
290         break;
291
292      //JBC bit addr, code addr
293      case 0x10:            /* 1: 0001 0000 */
294         sym = get_bit_address(opram[PC++ - pc]);
295         rel  = opram[PC++ - pc];
296         sprintf(dst, "jbc   %s,$%04X", sym, PC + rel);
297         break;
298
299      //ACALL code addr       /* 1: aaa1 0001 */
300      case 0x11:
301      case 0x31:
302      case 0x51:
303      case 0x71:
304      case 0x91:
305      case 0xb1:
306      case 0xd1:
307      case 0xf1:
308         sprintf(dst, "acall $%04X", (PC & 0xf800) | ((op & 0xe0) << 3) | opram[PC - pc]);
309         PC++;
310         flags = DASMFLAG_STEP_OVER;
311         break;
312
313      //LCALL code addr
314      case 0x12:            /* 1: 0001 0010 */
315         addr = (opram[PC++ - pc]<<8) & 0xff00;
316         addr|= opram[PC++ - pc];
317         sprintf(dst, "lcall $%04X", addr);
318         flags = DASMFLAG_STEP_OVER;
319         break;
320
321      //RRC A
322      case 0x13:            /* 1: 0001 0011 */
323         sprintf(dst, "rrc   a");
324         break;
325
326      //DEC A
327      case 0x14:            /* 1: 0001 0100 */
328         sprintf(dst, "dec   a");
329         break;
330
331      //DEC data addr
332      case 0x15:            /* 1: 0001 0101 */
333         sym = get_data_address(opram[PC++ - pc]);
334         sprintf(dst, "dec   %s", sym);
335         break;
336
337      //Unable to test
338      //DEC @R0/@R1           /* 1: 0001 011i */
339      case 0x16:
340      case 0x17:
341         sprintf(dst, "dec   @r%d", op&1);
342         break;
343
344      //DEC R0 to R7          /* 1: 0001 1rrr */
345      case 0x18:
346      case 0x19:
347      case 0x1a:
348      case 0x1b:
349      case 0x1c:
350      case 0x1d:
351      case 0x1e:
352      case 0x1f:
353         sprintf(dst, "dec   r%d", op&7);
354         break;
355
356      //JB  bit addr, code addr
357      case 0x20:            /* 1: 0010 0000 */
358         sym = get_bit_address(opram[PC++ - pc]);
359         rel  = opram[PC++ - pc];
360         sprintf(dst, "jb    %s,$%04X", sym, (PC + rel));
361         break;
362
363      //RET
364      case 0x22:            /* 1: 0010 0010 */
365         sprintf(dst, "ret");
366         flags = DASMFLAG_STEP_OUT;
367         break;
368
369      //RL A
370      case 0x23:            /* 1: 0010 0011 */
371         sprintf(dst, "rl    a");
372         break;
373
374      //ADD A, #data
375      case 0x24:            /* 1: 0010 0100 */
376         sprintf(dst, "add   a,#$%02X", opram[PC++ - pc]);
377         break;
378
379      //ADD A, data addr
380      case 0x25:            /* 1: 0010 0101 */
381         sym = get_data_address(opram[PC++ - pc]);
382         sprintf(dst, "add   a,%s", sym);
383         break;
384
385      //Unable to Test
386      //ADD A, @R0/@R1        /* 1: 0010 011i */
387      case 0x26:
388      case 0x27:
389         sprintf(dst, "add   a,@r%d", op&1);
390         break;
391
392      //ADD A, R0 to R7       /* 1: 0010 1rrr */
393      case 0x28:
394      case 0x29:
395      case 0x2a:
396      case 0x2b:
397      case 0x2c:
398      case 0x2d:
399      case 0x2e:
400      case 0x2f:
401         sprintf(dst, "add   a,r%d", op&7);
402         break;
403
404      //JNB bit addr, code addr
405      case 0x30:            /* 1: 0011 0000 */
406         sym = get_bit_address(opram[PC++ - pc]);
407         rel  = opram[PC++ - pc];
408         sprintf(dst, "jnb   %s,$%04X", sym, (PC + rel));
409         break;
410
411      //RETI
412      case 0x32:            /* 1: 0011 0010 */
413         sprintf(dst, "reti");
414         flags = DASMFLAG_STEP_OUT;
415         break;
416
417      //RLC A
418      case 0x33:            /* 1: 0011 0011 */
419         sprintf(dst, "rlc   a");
420         break;
421
422      //ADDC A, #data
423      case 0x34:            /* 1: 0011 0100 */
424         sprintf(dst, "addc  a,#$%02X", opram[PC++ - pc]);
425         break;
426
427      //ADDC A, data addr
428      case 0x35:            /* 1: 0011 0101 */
429         sym = get_data_address(opram[PC++ - pc]);
430         sprintf(dst, "addc  a,%s", sym);
431         break;
432
433      //ADDC A, @R0/@R1       /* 1: 0011 011i */
434      case 0x36:
435      case 0x37:
436         sprintf(dst, "addc  a,@r%d", op&1);
437         break;
438
439      //ADDC A, R0 to R7      /* 1: 0011 1rrr */
440      case 0x38:
441      case 0x39:
442      case 0x3a:
443      case 0x3b:
444      case 0x3c:
445      case 0x3d:
446      case 0x3e:
447      case 0x3f:
448         sprintf(dst, "addc  a,r%d", op&7);
449         break;
450
451      //JC code addr
452      case 0x40:            /* 1: 0100 0000 */
453         rel = opram[PC++ - pc];
454         sprintf(dst, "jc    $%04X", PC + rel);
455         break;
456
457      //ORL data addr, A
458      case 0x42:            /* 1: 0100 0010 */
459         sym = get_data_address(opram[PC++ - pc]);
460         sprintf(dst, "orl   %s,a", sym);
461         break;
462
463      //ORL data addr, #data
464      case 0x43:            /* 1: 0100 0011 */
465         sym = get_data_address(opram[PC++ - pc]);
466         sprintf(dst, "orl   %s,#$%02X", sym, opram[PC++ - pc]);
467         break;
468
469      //Unable to Test
470      //ORL A, #data
471      case 0x44:            /* 1: 0100 0100 */
472         sprintf(dst, "orl   a,#$%02X", opram[PC++ - pc]);
473         break;
474
475      //ORL A, data addr
476      case 0x45:            /* 1: 0100 0101 */
477         sym = get_data_address(opram[PC++ - pc]);
478         sprintf(dst, "orl   a,%s", sym);
479         break;
480
481      //ORL A, @RO/@R1        /* 1: 0100 011i */
482      case 0x46:
483      case 0x47:
484         sprintf(dst, "orl   a,@r%d", op&1);
485         break;
486
487      //ORL A, RO to R7       /* 1: 0100 1rrr */
488      case 0x48:
489      case 0x49:
490      case 0x4a:
491      case 0x4b:
492      case 0x4c:
493      case 0x4d:
494      case 0x4e:
495      case 0x4f:
496         sprintf(dst, "orl   a,r%d", op&7);
497         break;
498
499      //JNC code addr
500      case 0x50:            /* 1: 0101 0000 */
501         rel = opram[PC++ - pc];
502         sprintf(dst, "jnc   $%04X", PC + rel);
503         break;
504
505      //Unable to test
506      //ANL data addr, A
507      case 0x52:            /* 1: 0101 0010 */
508         sym = get_data_address(opram[PC++ - pc]);
509         sprintf(dst, "anl   %s,a", sym);
510         break;
511
512      //Unable to test
513      //ANL data addr, #data
514      case 0x53:            /* 1: 0101 0011 */
515         sym = get_data_address(opram[PC++ - pc]);
516         sprintf(dst, "anl   %s,#$%02X", sym, opram[PC++ - pc]);
517         break;
518
519      //ANL A, #data
520      case 0x54:            /* 1: 0101 0100 */
521         sprintf(dst, "anl   a,#$%02X", opram[PC++ - pc]);
522         break;
523
524      //ANL A, data addr
525      case 0x55:            /* 1: 0101 0101 */
526         sym = get_data_address(opram[PC++ - pc]);
527         sprintf(dst, "anl   a,%s", sym);
528         break;
529
530      //Unable to test
531      //ANL A, @RO/@R1        /* 1: 0101 011i */
532      case 0x56:
533      case 0x57:
534         sprintf(dst, "anl   a,@r%d", op&1);
535         break;
536
537      //ANL A, RO to R7       /* 1: 0101 1rrr */
538      case 0x58:
539      case 0x59:
540      case 0x5a:
541      case 0x5b:
542      case 0x5c:
543      case 0x5d:
544      case 0x5e:
545      case 0x5f:
546         sprintf(dst, "anl   a,r%d", op&7);
547         break;
548
549      //JZ code addr
550      case 0x60:            /* 1: 0110 0000 */
551         rel = opram[PC++ - pc];
552         sprintf(dst, "jz    $%04X", PC + rel);
553         break;
554
555      //Unable to test
556      //XRL data addr, A
557      case 0x62:            /* 1: 0110 0010 */
558         sym = get_data_address(opram[PC++ - pc]);
559         sprintf(dst, "xrl   %s,a", sym);
560         break;
561
562      //XRL data addr, #data
563      case 0x63:            /* 1: 0110 0011 */
564         sym = get_data_address(opram[PC++ - pc]);
565         sprintf(dst, "xrl   %s,#$%02X", sym, opram[PC++ - pc]);
566         break;
567
568      //XRL A, #data
569      case 0x64:            /* 1: 0110 0100 */
570         sprintf(dst, "xrl   a,#$%02X", opram[PC++ - pc]);
571         break;
572
573      //XRL A, data addr
574      case 0x65:            /* 1: 0110 0101 */
575         sym = get_data_address(opram[PC++ - pc]);
576         sprintf(dst, "xrl   a,%s", sym);
577         break;
578
579      //Unable to test
580      //XRL A, @R0/@R1        /* 1: 0110 011i */
581      case 0x66:
582      case 0x67:
583         sprintf(dst, "xrl   a,@r%d", op&1);
584         break;
585
586      //XRL A, R0 to R7       /* 1: 0110 1rrr */
587      case 0x68:
588      case 0x69:
589      case 0x6a:
590      case 0x6b:
591      case 0x6c:
592      case 0x6d:
593      case 0x6e:
594      case 0x6f:
595         sprintf(dst, "xrl   a,r%d", op&7);
596         break;
597
598      //JNZ code addr
599      case 0x70:            /* 1: 0111 0000 */
600         rel = opram[PC++ - pc];
601         sprintf(dst, "jnz   $%04X", PC + rel);
602         break;
603
604      //Unable to test
605      //ORL C, bit addr
606      case 0x72:            /* 1: 0111 0010 */
607         sym = get_bit_address(opram[PC++ - pc]);
608         sprintf(dst, "orl   c,%s", sym);
609         break;
610
611      //Unable to test
612      //JMP @A+DPTR
613      case 0x73:            /* 1: 0111 0011 */
614         sprintf(dst, "jmp   @a+dptr");
615         break;
616
617      //MOV A, #data
618      case 0x74:            /* 1: 0111 0100 */
619         sprintf(dst, "mov   a,#$%02X", opram[PC++ - pc]);
620         break;
621
622      //MOV data addr, #data
623      case 0x75:            /* 1: 0111 0101 */
624         sym = get_data_address(opram[PC++ - pc]);
625         sprintf(dst, "mov   %s,#$%02X", sym, opram[PC++ - pc]);
626         break;
627
628      //Unable to test
629      //MOV @R0/@R1, #data    /* 1: 0111 011i */
630      case 0x76:
631      case 0x77:
632         sprintf(dst, "mov   @r%d,#$%02X", op&1, opram[PC++ - pc]);
633         break;
634
635      //MOV R0 to R7, #data   /* 1: 0111 1rrr */
636      case 0x78:
637      case 0x79:
638      case 0x7a:
639      case 0x7b:
640      case 0x7c:
641      case 0x7d:
642      case 0x7e:
643      case 0x7f:
644         sprintf(dst, "mov   r%d,#$%02X", (op & 7), opram[PC++ - pc]);
645         break;
646
647      //SJMP code addr
648      case 0x80:            /* 1: 1000 0000 */
649         rel = opram[PC++ - pc];
650         sprintf(dst, "sjmp  $%04X", PC + rel);
651         break;
652
653      //ANL C, bit addr
654      case 0x82:            /* 1: 1000 0010 */
655         sym = get_bit_address(opram[PC++ - pc]);
656         sprintf(dst, "anl   c,%s", sym);
657         break;
658
659      //MOVC A, @A + PC
660      case 0x83:            /* 1: 1000 0011 */
661         sprintf(dst, "movc  a,@a+pc");
662         break;
663
664      //DIV AB
665      case 0x84:            /* 1: 1000 0100 */
666         sprintf(dst, "div   ab");
667         break;
668
669      //MOV data addr, data addr  (Note: 1st address is src, 2nd is dst, but the mov command works as mov dst,src)
670      case 0x85:            /* 1: 1000 0101 */
671         sym  = get_data_address(opram[PC++ - pc]);
672         sym2 = get_data_address(opram[PC++ - pc]);
673         sprintf(dst, "mov   %s,%s", sym2, sym);
674         break;
675
676      //Unable to test
677      //MOV data addr, @R0/@R1/* 1: 1000 011i */
678      case 0x86:
679      case 0x87:
680         sym = get_data_address(opram[PC++ - pc]);
681         sprintf(dst, "mov   %s,@r%d", sym, op&1);
682         break;
683
684      //MOV data addr,R0 to R7/* 1: 1000 1rrr */
685      case 0x88:
686      case 0x89:
687      case 0x8a:
688      case 0x8b:
689      case 0x8c:
690      case 0x8d:
691      case 0x8e:
692      case 0x8f:
693         sym = get_data_address(opram[PC++ - pc]);
694         sprintf(dst, "mov   %s,r%d", sym, op&7);
695         break;
696
697      //MOV DPTR, #data16
698      case 0x90:            /* 1: 1001 0000 */
699         addr = (opram[PC++ - pc]<<8) & 0xff00;
700         addr|= opram[PC++ - pc];
701         sprintf(dst, "mov   dptr,#$%04X", addr);
702         break;
703
704      //MOV bit addr, C
705      case 0x92:            /* 1: 1001 0010 */
706         sym = get_bit_address(opram[PC++ - pc]);
707         sprintf(dst, "mov   %s,c", sym);
708         break;
709
710      //MOVC A, @A + DPTR
711      case 0x93:            /* 1: 1001 0011 */
712         sprintf(dst, "movc  a,@a+dptr");
713         break;
714
715      //SUBB A, #data
716      case 0x94:            /* 1: 1001 0100 */
717         sprintf(dst, "subb  a,#$%02X", opram[PC++ - pc]);
718         break;
719
720      //SUBB A, data addr
721      case 0x95:            /* 1: 1001 0101 */
722         sym = get_data_address(opram[PC++ - pc]);
723         sprintf(dst, "subb  a,%s", sym);
724         break;
725
726      //Unable to test
727      //SUBB A, @R0/@R1       /* 1: 1001 011i */
728      case 0x96:
729      case 0x97:
730         sprintf(dst, "subb  a,@r%d", op&1);
731         break;
732
733      //SUBB A, R0 to R7      /* 1: 1001 1rrr */
734      case 0x98:
735      case 0x99:
736      case 0x9a:
737      case 0x9b:
738      case 0x9c:
739      case 0x9d:
740      case 0x9e:
741      case 0x9f:
742         sprintf(dst, "subb  a,r%d", op&7);
743         break;
744
745      //Unable to test
746      //ORL C, /bit addr
747      case 0xa0:              /* 1: 1010 0000 */
748         sym = get_bit_address(opram[PC++ - pc]);
749         sprintf(dst, "orl   c,/%s", sym);
750         break;
751
752      //MOV C, bit addr
753      case 0xa2:              /* 1: 1010 0010 */
754         sym = get_bit_address(opram[PC++ - pc]);
755         sprintf(dst, "mov   c,%s", sym);
756         break;
757
758      //INC DPTR
759      case 0xa3:              /* 1: 1010 0011 */
760         sprintf(dst, "inc   dptr");
761         break;
762
763      //MUL AB
764      case 0xa4:              /* 1: 1010 0100 */
765         sprintf(dst, "mul   ab");
766         break;
767
768      //reserved
769      case 0xa5:              /* 1: 1010 0101 */
770         sprintf(dst, "ill/rsv");
771         break;
772
773      //Unable to test
774      //MOV @R0/@R1, data addr  /* 1: 1010 011i */
775      case 0xa6:
776      case 0xa7:
777         sym = get_data_address(opram[PC++ - pc]);
778         sprintf(dst, "mov   @r%d,%s", op&1, sym);
779         break;
780
781      //MOV R0 to R7, data addr /* 1: 1010 1rrr */
782      case 0xa8:
783      case 0xa9:
784      case 0xaa:
785      case 0xab:
786      case 0xac:
787      case 0xad:
788      case 0xae:
789      case 0xaf:
790         sym = get_data_address(opram[PC++ - pc]);
791         sprintf(dst, "mov   r%d,%s", op&7, sym);
792         break;
793
794      //ANL C,/bit addr
795      case 0xb0:                   /* 1: 1011 0000 */
796         sym = get_bit_address(opram[PC++ - pc]);
797         sprintf(dst, "anl   c,/%s", sym);
798         break;
799
800      //CPL bit addr
801      case 0xb2:                   /* 1: 1011 0010 */
802         sym = get_bit_address(opram[PC++ - pc]);
803         sprintf(dst, "cpl   %s", sym);
804         break;
805
806      //Unable to test
807      //CPL C
808      case 0xb3:                   /* 1: 1011 0011 */
809         sprintf(dst, "cpl   c");
810         break;
811
812      //CJNE A, #data, code addr
813      case 0xb4:                   /* 1: 1011 0100 */
814         data = opram[PC++ - pc];
815         rel  = opram[PC++ - pc];
816         sprintf(dst, "cjne  a,#$%02X,$%04X", data, PC + rel);
817         break;
818
819      //CJNE A, data addr, code addr
820      case 0xb5:                   /* 1: 1011 0101 */
821         sym = get_data_address(opram[PC++ - pc]);
822         rel  = opram[PC++ - pc];
823         sprintf(dst, "cjne  a,%s,$%04X", sym, PC + rel);
824         break;
825
826      //Unable to test
827      //CJNE @R0/@R1, #data, code addr /* 1: 1011 011i */
828      case 0xb6:
829      case 0xb7:
830         data = opram[PC++ - pc];
831         rel  = opram[PC++ - pc];
832         sprintf(dst, "cjne  @r%d,#$%02X,$%04X", op&1, data, PC + rel);
833         break;
834
835      //CJNE R0 to R7, #data, code addr/* 1: 1011 1rrr */
836      case 0xb8:
837      case 0xb9:
838      case 0xba:
839      case 0xbb:
840      case 0xbc:
841      case 0xbd:
842      case 0xbe:
843      case 0xbf:
844         data = opram[PC++ - pc];
845         rel  = opram[PC++ - pc];
846         sprintf(dst, "cjne  r%d,#$%02X,$%04X", op&7, data, PC + rel);
847         break;
848
849      //PUSH data addr
850      case 0xc0:                  /* 1: 1100 0000 */
851         sym = get_data_address(opram[PC++ - pc]);
852         sprintf(dst, "push  %s", sym);
853         break;
854
855      //CLR bit addr
856      case 0xc2:                  /* 1: 1100 0010 */
857         sym = get_bit_address(opram[PC++ - pc]);
858         sprintf(dst, "clr   %s", sym);
859         break;
860
861      //CLR C
862      case 0xc3:                  /* 1: 1100 0011 */
863         sprintf(dst, "clr   c");
864         break;
865
866      //SWAP A
867      case 0xc4:                  /* 1: 1100 0100 */
868         sprintf(dst, "swap  a");
869         break;
870
871      //XCH A, data addr
872      case 0xc5:                  /* 1: 1100 0101 */
873         sym = get_data_address(opram[PC++ - pc]);
874         sprintf(dst, "xch   a,%s", sym);
875         break;
876
877      //XCH A, @RO/@R1                /* 1: 1100 011i */
878      case 0xc6:
879      case 0xc7:
880         sprintf(dst, "xch   a,@r%d", op&1);
881         break;
882
883      //XCH A, RO to R7               /* 1: 1100 1rrr */
884      case 0xc8:
885      case 0xc9:
886      case 0xca:
887      case 0xcb:
888      case 0xcc:
889      case 0xcd:
890      case 0xce:
891      case 0xcf:
892         sprintf(dst, "xch   a,r%d", op&7);
893         break;
894
895      //POP data addr
896      case 0xd0:                  /* 1: 1101 0000 */
897         sym = get_data_address(opram[PC++ - pc]);
898         sprintf(dst, "pop   %s", sym);
899         break;
900
901      //SETB bit addr
902      case 0xd2:                  /* 1: 1101 0010 */
903         sym = get_bit_address(opram[PC++ - pc]);
904         sprintf(dst, "setb  %s", sym);
905         break;
906
907      //SETB C
908      case 0xd3:                  /* 1: 1101 0011 */
909         sprintf(dst, "setb  c");
910         break;
911
912      //Unable to test
913      //DA A
914      case 0xd4:                  /* 1: 1101 0100 */
915         sprintf(dst, "da   a");
916         break;
917
918      //DJNZ data addr, code addr
919      case 0xd5:                  /* 1: 1101 0101 */
920         sym = get_data_address(opram[PC++ - pc]);
921         rel  = opram[PC++ - pc];
922         sprintf(dst, "djnz  %s,$%04X", sym, PC + rel);
923         flags = DASMFLAG_STEP_OVER;
924         break;
925
926      //XCHD A, @R0/@R1               /* 1: 1101 011i */
927      case 0xd6:
928      case 0xd7:
929         sprintf(dst, "xchd  a,@r%d", op&1);
930         break;
931
932      //DJNZ R0 to R7,code addr       /* 1: 1101 1rrr */
933      case 0xd8:
934      case 0xd9:
935      case 0xda:
936      case 0xdb:
937      case 0xdc:
938      case 0xdd:
939      case 0xde:
940      case 0xdf:
941         rel = opram[PC++ - pc];
942         sprintf(dst, "djnz  r%d,$%04X", op&7, (PC + rel));
943         flags = DASMFLAG_STEP_OVER;
944         break;
945
946      //MOVX A,@DPTR
947      case 0xe0:                  /* 1: 1110 0000 */
948         sprintf(dst, "movx  a,@dptr");
949         break;
950
951      //Unable to test
952      //MOVX A, @R0/@R1               /* 1: 1110 001i */
953      case 0xe2:
954      case 0xe3:
955         sprintf(dst, "movx  a,@r%d", op&1);
956         break;
957
958      //CLR A
959      case 0xe4:                  /* 1: 1110 0100 */
960         sprintf(dst, "clr   a");
961         break;
962
963      //MOV A, data addr
964      case 0xe5:                  /* 1: 1110 0101 */
965         sym = get_data_address(opram[PC++ - pc]);
966         sprintf(dst, "mov   a,%s", sym);
967         break;
968
969      //Unable to test
970      //MOV A,@RO/@R1                 /* 1: 1110 011i */
971      case 0xe6:
972      case 0xe7:
973         sprintf(dst, "mov   a,@r%d", op&1);
974         break;
975
976      //MOV A,R0 to R7                /* 1: 1110 1rrr */
977      case 0xe8:
978      case 0xe9:
979      case 0xea:
980      case 0xeb:
981      case 0xec:
982      case 0xed:
983      case 0xee:
984      case 0xef:
985         sprintf(dst, "mov   a,r%d", op&7);
986         break;
987
988      //MOVX @DPTR,A
989      case 0xf0:                  /* 1: 1111 0000 */
990         sprintf(dst, "movx  @dptr,a");
991         break;
992
993      //Unable to test
994      //MOVX @R0/@R1,A                /* 1: 1111 001i */
995      case 0xf2:
996      case 0xf3:
997         sprintf(dst, "movx  @r%d,a", op&1);
998         break;
999
1000      //CPL A
1001      case 0xf4:                  /* 1: 1111 0100 */
1002         sprintf(dst, "cpl   a");
1003         break;
1004
1005      //MOV data addr, A
1006      case 0xf5:                  /* 1: 1111 0101 */
1007         sym = get_data_address(opram[PC++ - pc]);
1008         sprintf(dst, "mov   %s,a", sym);
1009         break;
1010
1011      //MOV @R0/@R1, A                /* 1: 1111 011i */
1012      case 0xf6:
1013      case 0xf7:
1014         sprintf(dst, "mov   @r%d,a", op&1);
1015         break;
1016
1017      //MOV R0 to R7, A               /* 1: 1111 1rrr */
1018      case 0xf8:
1019      case 0xf9:
1020      case 0xfa:
1021      case 0xfb:
1022      case 0xfc:
1023      case 0xfd:
1024      case 0xfe:
1025      case 0xff:
1026         sprintf(dst, "mov   r%d,a", op&7);
1027         break;
1028
1029      default:
1030         sprintf(dst, "illegal");
1031    }
1032   return (PC - pc) | flags | DASMFLAG_SUPPORTED;
1033}
src/emu/cpu/m6502/6502dasm.c
r3514r3515
8080   bsr,
8181/* 6510 + 65c02 mnemonics */
8282   anc,  asr, ast,  arr,  asx,  axa,  dcp,  dea,
83   dop,  ina, isc,  lax,  phx,  phy,  plx,  ply,
83   dop,  ina, isb,  lax,  phx,  phy,  plx,  ply,
8484   rla,  rra, sax,  slo,  sre,  sah,  say,  ssh,
8585   sxh,  syh, top,  oal,  kil,
8686/* 65ce02 mnemonics */
r3514r3515
115115   "bsr",
116116/* 6510 mnemonics */
117117   "anc", "asr", "ast", "arr", "asx", "axa", "dcp", "dea",
118   "dop", "ina", "isc", "lax", "phx", "phy", "plx", "ply",
118   "dop", "ina", "isb", "lax", "phx", "phy", "plx", "ply",
119119   "rla", "rra", "sax", "slo", "sre", "sah", "say", "ssh",
120120   "sxh", "syh", "top", "oal", "kil",
121121/* 65ce02 mnemonics */
r3514r3515
141141
142142static const struct op6502_info op6502[256] = {
143143   {m6502_brk,imm},{ora,idx},{kil,non},{slo,idx},/* 00 */
144   {dop,imm},{ora,zpg},{asl,zpg},{slo,zpg},
144   {nop,zpg},{ora,zpg},{asl,zpg},{slo,zpg},
145145   {php,imp},{ora,imm},{asl,acc},{anc,imm},
146   {top,iw2},{ora,aba},{asl,aba},{slo,aba},
147   {bpl,rel},{ora,idy},{nop,imp},{slo,idy},/* 10 */
148   {dop,imm},{ora,zpx},{asl,zpx},{slo,zpx},
149   {clc,imp},{ora,aby},{kil,non},{slo,aby},
150   {top,iw2},{ora,abx},{asl,abx},{slo,abx},
146   {nop,aba},{ora,aba},{asl,aba},{slo,aba},
147   {bpl,rel},{ora,idy},{kil,non},{slo,idy},/* 10 */
148   {nop,zpx},{ora,zpx},{asl,zpx},{slo,zpx},
149   {clc,imp},{ora,aby},{nop,imp},{slo,aby},
150   {nop,abx},{ora,abx},{asl,abx},{slo,abx},
151151   {jsr,adr},{and,idx},{kil,non},{rla,idx},/* 20 */
152152   {bit,zpg},{and,zpg},{rol,zpg},{rla,zpg},
153153   {plp,imp},{and,imm},{rol,acc},{anc,imm},
154154   {bit,aba},{and,aba},{rol,aba},{rla,aba},
155155   {bmi,rel},{and,idy},{kil,non},{rla,idy},/* 30 */
156   {dop,imm},{and,zpx},{rol,zpx},{rla,zpx},
156   {nop,zpx},{and,zpx},{rol,zpx},{rla,zpx},
157157   {sec,imp},{and,aby},{nop,imp},{rla,aby},
158   {top,iw2},{and,abx},{rol,abx},{rla,abx},
158   {nop,abx},{and,abx},{rol,abx},{rla,abx},
159159   {rti,imp},{eor,idx},{kil,non},{sre,idx},/* 40 */
160   {dop,imm},{eor,zpg},{lsr,zpg},{sre,zpg},
160   {nop,zpg},{eor,zpg},{lsr,zpg},{sre,zpg},
161161   {pha,imp},{eor,imm},{lsr,acc},{asr,imm},
162162   {jmp,adr},{eor,aba},{lsr,aba},{sre,aba},
163163   {bvc,rel},{eor,idy},{kil,non},{sre,idy},/* 50 */
164   {dop,imm},{eor,zpx},{lsr,zpx},{sre,zpx},
164   {nop,zpx},{eor,zpx},{lsr,zpx},{sre,zpx},
165165   {cli,imp},{eor,aby},{nop,imp},{sre,aby},
166   {top,iw2},{eor,abx},{lsr,abx},{sre,abx},
166   {nop,abx},{eor,abx},{lsr,abx},{sre,abx},
167167   {rts,imp},{adc,idx},{kil,non},{rra,idx},/* 60 */
168   {dop,imm},{adc,zpg},{ror,zpg},{rra,zpg},
168   {nop,zpg},{adc,zpg},{ror,zpg},{rra,zpg},
169169   {pla,imp},{adc,imm},{ror,acc},{arr,imm},
170170   {jmp,ind},{adc,aba},{ror,aba},{rra,aba},
171171   {bvs,rel},{adc,idy},{kil,non},{rra,idy},/* 70 */
172   {dop,imm},{adc,zpx},{ror,zpx},{rra,zpx},
172   {nop,zpx},{adc,zpx},{ror,zpx},{rra,zpx},
173173   {sei,imp},{adc,aby},{nop,imp},{rra,aby},
174   {top,iw2},{adc,abx},{ror,abx},{rra,abx},
175   {dop,imm},{sta,idx},{dop,imm},{sax,idx},/* 80 */
174   {nop,abx},{adc,abx},{ror,abx},{rra,abx},
175   {nop,imm},{sta,idx},{nop,imm},{sax,idx},/* 80 */
176176   {sty,zpg},{sta,zpg},{stx,zpg},{sax,zpg},
177   {dey,imp},{dop,imm},{txa,imp},{axa,imm},
177   {dey,imp},{nop,imm},{txa,imp},{axa,imm},
178178   {sty,aba},{sta,aba},{stx,aba},{sax,aba},
179179   {bcc,rel},{sta,idy},{kil,non},{say,idy},/* 90 */
180   {sty,zpx},{sta,zpx},{stx,zpy},{sax,zpx},
180   {sty,zpx},{sta,zpx},{stx,zpy},{sax,zpy},
181181   {tya,imp},{sta,aby},{txs,imp},{ssh,aby},
182182   {syh,abx},{sta,abx},{sxh,aby},{sah,aby},
183183   {ldy,imm},{lda,idx},{ldx,imm},{lax,idx},/* a0 */
r3514r3515
185185   {tay,imp},{lda,imm},{tax,imp},{oal,imm},
186186   {ldy,aba},{lda,aba},{ldx,aba},{lax,aba},
187187   {bcs,rel},{lda,idy},{kil,non},{lax,idy},/* b0 */
188   {ldy,zpx},{lda,zpx},{ldx,zpy},{lax,zpx},
188   {ldy,zpx},{lda,zpx},{ldx,zpy},{lax,zpy},
189189   {clv,imp},{lda,aby},{tsx,imp},{ast,aby},
190   {ldy,abx},{lda,abx},{ldx,aby},{lax,abx},
191   {cpy,imm},{cmp,idx},{dop,imm},{dcp,idx},/* c0 */
190   {ldy,abx},{lda,abx},{ldx,aby},{lax,aby},
191   {cpy,imm},{cmp,idx},{nop,imm},{dcp,idx},/* c0 */
192192   {cpy,zpg},{cmp,zpg},{dec,zpg},{dcp,zpg},
193193   {iny,imp},{cmp,imm},{dex,imp},{asx,imm},
194194   {cpy,aba},{cmp,aba},{dec,aba},{dcp,aba},
195195   {bne,rel},{cmp,idy},{kil,non},{dcp,idy},/* d0 */
196   {dop,imm},{cmp,zpx},{dec,zpx},{dcp,zpx},
196   {nop,zpx},{cmp,zpx},{dec,zpx},{dcp,zpx},
197197   {cld,imp},{cmp,aby},{nop,imp},{dcp,aby},
198   {top,iw2},{cmp,abx},{dec,abx},{dcp,abx},
199   {cpx,imm},{sbc,idx},{dop,imm},{isc,idx},/* e0 */
200   {cpx,zpg},{sbc,zpg},{inc,zpg},{isc,zpg},
198   {nop,abx},{cmp,abx},{dec,abx},{dcp,abx},
199   {cpx,imm},{sbc,idx},{nop,imm},{isb,idx},/* e0 */
200   {cpx,zpg},{sbc,zpg},{inc,zpg},{isb,zpg},
201201   {inx,imp},{sbc,imm},{nop,imp},{sbc,imm},
202   {cpx,aba},{sbc,aba},{inc,aba},{isc,aba},
203   {beq,rel},{sbc,idy},{kil,non},{isc,idy},/* f0 */
204   {dop,imm},{sbc,zpx},{inc,zpx},{isc,zpx},
205   {sed,imp},{sbc,aby},{nop,imp},{isc,aby},
206   {top,iw2},{sbc,abx},{inc,abx},{isc,abx}
202   {cpx,aba},{sbc,aba},{inc,aba},{isb,aba},
203   {beq,rel},{sbc,idy},{kil,non},{isb,idy},/* f0 */
204   {nop,zpx},{sbc,zpx},{inc,zpx},{isb,zpx},
205   {sed,imp},{sbc,aby},{nop,imp},{isb,aby},
206   {nop,abx},{sbc,abx},{inc,abx},{isb,abx}
207207};
208208
209209static const struct op6502_info op65c02[256] = {
src/emu/cpu/powerpc/ppccom.h
r3514r3515
575575
576576void ppccom_reset(powerpc_state *ppc);
577577offs_t ppccom_dasm(powerpc_state *ppc, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram);
578void ppccom_update_cycle_counting(powerpc_state *ppc);
579578
580579int ppccom_translate_address(powerpc_state *ppc, int space, int intention, offs_t *address);
581580
src/emu/cpu/nec/necea.h
r3514r3515
99static unsigned EA_003(void) { EO=I.regs.w[BP]+I.regs.w[IY]; EA=DefaultBase(SS)+EO; return EA; }
1010static unsigned EA_004(void) { EO=I.regs.w[IX]; EA=DefaultBase(DS0)+EO; return EA; }
1111static unsigned EA_005(void) { EO=I.regs.w[IY]; EA=DefaultBase(DS0)+EO; return EA; }
12static unsigned EA_006(void) { EO=FETCH; EO+=FETCH<<8; EA=DefaultBase(DS0)+EO; return EA; }
12static unsigned EA_006(void) { EO=FETCH(); EO+=FETCH()<<8; EA=DefaultBase(DS0)+EO; return EA; }
1313static unsigned EA_007(void) { EO=I.regs.w[BW]; EA=DefaultBase(DS0)+EO; return EA; }
1414
15static unsigned EA_100(void) { EO=(I.regs.w[BW]+I.regs.w[IX]+(INT8)FETCH); EA=DefaultBase(DS0)+EO; return EA; }
16static unsigned EA_101(void) { EO=(I.regs.w[BW]+I.regs.w[IY]+(INT8)FETCH); EA=DefaultBase(DS0)+EO; return EA; }
17static unsigned EA_102(void) { EO=(I.regs.w[BP]+I.regs.w[IX]+(INT8)FETCH); EA=DefaultBase(SS)+EO; return EA; }
18static unsigned EA_103(void) { EO=(I.regs.w[BP]+I.regs.w[IY]+(INT8)FETCH); EA=DefaultBase(SS)+EO; return EA; }
19static unsigned EA_104(void) { EO=(I.regs.w[IX]+(INT8)FETCH); EA=DefaultBase(DS0)+EO; return EA; }
20static unsigned EA_105(void) { EO=(I.regs.w[IY]+(INT8)FETCH); EA=DefaultBase(DS0)+EO; return EA; }
21static unsigned EA_106(void) { EO=(I.regs.w[BP]+(INT8)FETCH); EA=DefaultBase(SS)+EO; return EA; }
22static unsigned EA_107(void) { EO=(I.regs.w[BW]+(INT8)FETCH); EA=DefaultBase(DS0)+EO; return EA; }
15static unsigned EA_100(void) { EO=(I.regs.w[BW]+I.regs.w[IX]+(INT8)FETCH()); EA=DefaultBase(DS0)+EO; return EA; }
16static unsigned EA_101(void) { EO=(I.regs.w[BW]+I.regs.w[IY]+(INT8)FETCH()); EA=DefaultBase(DS0)+EO; return EA; }
17static unsigned EA_102(void) { EO=(I.regs.w[BP]+I.regs.w[IX]+(INT8)FETCH()); EA=DefaultBase(SS)+EO; return EA; }
18static unsigned EA_103(void) { EO=(I.regs.w[BP]+I.regs.w[IY]+(INT8)FETCH()); EA=DefaultBase(SS)+EO; return EA; }
19static unsigned EA_104(void) { EO=(I.regs.w[IX]+(INT8)FETCH()); EA=DefaultBase(DS0)+EO; return EA; }
20static unsigned EA_105(void) { EO=(I.regs.w[IY]+(INT8)FETCH()); EA=DefaultBase(DS0)+EO; return EA; }
21static unsigned EA_106(void) { EO=(I.regs.w[BP]+(INT8)FETCH()); EA=DefaultBase(SS)+EO; return EA; }
22static unsigned EA_107(void) { EO=(I.regs.w[BW]+(INT8)FETCH()); EA=DefaultBase(DS0)+EO; return EA; }
2323
24static unsigned EA_200(void) { E16=FETCH; E16+=FETCH<<8; EO=I.regs.w[BW]+I.regs.w[IX]+(INT16)E16; EA=DefaultBase(DS0)+EO; return EA; }
25static unsigned EA_201(void) { E16=FETCH; E16+=FETCH<<8; EO=I.regs.w[BW]+I.regs.w[IY]+(INT16)E16; EA=DefaultBase(DS0)+EO; return EA; }
26static unsigned EA_202(void) { E16=FETCH; E16+=FETCH<<8; EO=I.regs.w[BP]+I.regs.w[IX]+(INT16)E16; EA=DefaultBase(SS)+EO; return EA; }
27static unsigned EA_203(void) { E16=FETCH; E16+=FETCH<<8; EO=I.regs.w[BP]+I.regs.w[IY]+(INT16)E16; EA=DefaultBase(SS)+EO; return EA; }
28static unsigned EA_204(void) { E16=FETCH; E16+=FETCH<<8; EO=I.regs.w[IX]+(INT16)E16; EA=DefaultBase(DS0)+EO; return EA; }
29static unsigned EA_205(void) { E16=FETCH; E16+=FETCH<<8; EO=I.regs.w[IY]+(INT16)E16; EA=DefaultBase(DS0)+EO; return EA; }
30static unsigned EA_206(void) { E16=FETCH; E16+=FETCH<<8; EO=I.regs.w[BP]+(INT16)E16; EA=DefaultBase(SS)+EO; return EA; }
31static unsigned EA_207(void) { E16=FETCH; E16+=FETCH<<8; EO=I.regs.w[BW]+(INT16)E16; EA=DefaultBase(DS0)+EO; return EA; }
24static unsigned EA_200(void) { E16=FETCH(); E16+=FETCH()<<8; EO=I.regs.w[BW]+I.regs.w[IX]+(INT16)E16; EA=DefaultBase(DS0)+EO; return EA; }
25static unsigned EA_201(void) { E16=FETCH(); E16+=FETCH()<<8; EO=I.regs.w[BW]+I.regs.w[IY]+(INT16)E16; EA=DefaultBase(DS0)+EO; return EA; }
26static unsigned EA_202(void) { E16=FETCH(); E16+=FETCH()<<8; EO=I.regs.w[BP]+I.regs.w[IX]+(INT16)E16; EA=DefaultBase(SS)+EO; return EA; }
27static unsigned EA_203(void) { E16=FETCH(); E16+=FETCH()<<8; EO=I.regs.w[BP]+I.regs.w[IY]+(INT16)E16; EA=DefaultBase(SS)+EO; return EA; }
28static unsigned EA_204(void) { E16=FETCH(); E16+=FETCH()<<8; EO=I.regs.w[IX]+(INT16)E16; EA=DefaultBase(DS0)+EO; return EA; }
29static unsigned EA_205(void) { E16=FETCH(); E16+=FETCH()<<8; EO=I.regs.w[IY]+(INT16)E16; EA=DefaultBase(DS0)+EO; return EA; }
30static unsigned EA_206(void) { E16=FETCH(); E16+=FETCH()<<8; EO=I.regs.w[BP]+(INT16)E16; EA=DefaultBase(SS)+EO; return EA; }
31static unsigned EA_207(void) { E16=FETCH(); E16+=FETCH()<<8; EO=I.regs.w[BW]+(INT16)E16; EA=DefaultBase(DS0)+EO; return EA; }
3232
3333static unsigned (*const GetEA[192])(void)={
3434   EA_000, EA_001, EA_002, EA_003, EA_004, EA_005, EA_006, EA_007,
src/emu/cpu/nec/nec.c
r3514r3515
167167
168168   const nec_config *config;
169169
170   UINT8   prefetch_size;
171   UINT8   prefetch_cycles;
172   INT8   prefetch_count;
173   UINT8   prefetch_reset;
174   UINT32   chip_type;
170175
176   UINT32   prefix_base;   /* base address of the latest prefix segment */
177   UINT8   seg_prefix;      /* prefix segment indicator */
178
171179} nec_Regs;
172180
173181/***************************************************************************/
r3514r3515
178186
179187static nec_Regs I;
180188
181static UINT32 chip_type;
182static UINT32 prefix_base;   /* base address of the latest prefix segment */
183static char seg_prefix;      /* prefix segment indicator */
184189
185190
186191/* The interrupt number of a pending external interrupt pending NMI is 2.   */
r3514r3515
189194#define INT_IRQ 0x01
190195#define NMI_IRQ 0x02
191196
197INLINE void prefetch(void)
198{
199   I.prefetch_count--;
200}
201
202static void do_prefetch(int previous_ICount)
203{
204   int diff = previous_ICount - (int) nec_ICount;
205
206   /* The implementation is not accurate, but comes close.
207     * It does not respect that the V30 will fetch two bytes
208     * at once directly, but instead uses only 2 cycles instead
209     * of 4. There are however only very few sources publicy
210     * available and they are vague.
211     */
212   while (I.prefetch_count<0)
213   {
214      I.prefetch_count++;
215      if (diff>I.prefetch_cycles)
216         diff -= I.prefetch_cycles;
217      else
218         nec_ICount -= I.prefetch_cycles;
219   }
220
221   if (I.prefetch_reset)
222   {
223      I.prefetch_count = 0;
224      I.prefetch_reset = 0;
225      return;
226   }
227
228   while (diff>=I.prefetch_cycles && I.prefetch_count < I.prefetch_size)
229   {
230      diff -= I.prefetch_cycles;
231      I.prefetch_count++;
232   }
233
234}
235
236INLINE UINT8 fetch(void)
237{
238   prefetch();
239   return cpu_readop_arg(FETCH_XOR((I.sregs[PS]<<4)+I.ip++));
240}
241
242INLINE UINT16 fetchword(void)
243{
244   UINT16 r = FETCH();
245   r |= (FETCH()<<8);
246   return r;
247}
248
192249#include "necinstr.h"
193250#include "necea.h"
194251#include "necmodrm.h"
r3514r3515
199256
200257static UINT8 fetchop(void)
201258{
202   UINT8 ret = cpu_readop( FETCH_XOR( ( I.sregs[PS]<<4)+I.ip++));
259   UINT8 ret;
203260
261   prefetch();
262   ret = cpu_readop( FETCH_XOR( ( I.sregs[PS]<<4)+I.ip++));
263
204264   if (I.MF == 1)
205265      if (I.config->v25v35_decryptiontable)
206266      {
r3514r3515
210270}
211271
212272
273
213274/***************************************************************************/
214275
215276static void nec_reset (void)
216277{
217   const nec_config *config;
218278    unsigned int i,j,c;
219279    static const BREGS reg_name[8]={ AL, CL, DL, BL, AH, CH, DH, BH };
220    int (*save_irqcallback)(int);
221    memory_interface save_mem;
222280
223   save_irqcallback = I.irq_callback;
224   save_mem = I.mem;
225   config = I.config;
226   memset( &I, 0, sizeof(I) );
227   I.irq_callback = save_irqcallback;
228   I.mem = save_mem;
229   I.config = config;
281   memset( &I.regs.w, 0, sizeof(I.regs.w));
282   memset( &I.sregs, 0, sizeof(I.sregs));
230283
284   I.ip = 0;
285   I.TF = 0;
286   I.IF = 0;
287   I.DF = 0;
288   I.MF = 0;
289   I.SignVal = 0;
290   I.int_vector = 0;
291   I.pending_irq = 0;
292   I.nmi_state = 0;
293   I.irq_state = 0;
294   I.poll_state = 0;
295   I.AuxVal = 0;
296   I.OverVal = 0;
297   I.ZeroVal = 0;
298   I.CarryVal = 0;
299   I.ParityVal = 0;
231300
301
232302   I.sregs[PS] = 0xffff;
233303
234304   CHANGE_PC;
r3514r3515
336406OP( 0x0d, i_or_axd16 ) { DEF_axd16;   ORW;   I.regs.w[AW]=dst;         CLKS(4,4,2);            }
337407OP( 0x0e, i_push_cs  ) { PUSH(I.sregs[PS]);   CLKS(12,8,3);   }
338408OP( 0x0f, i_pre_nec  ) { UINT32 ModRM, tmp, tmp2;
339   switch (FETCH) {
409   switch (FETCH()) {
340410      case 0x10 : BITOP_BYTE;   CLKS(3,3,4); tmp2 = I.regs.b[CL] & 0x7;   I.ZeroVal = (tmp & (1<<tmp2)) ? 1 : 0;   I.CarryVal=I.OverVal=0; break; /* Test */
341411      case 0x11 : BITOP_WORD;   CLKS(3,3,4); tmp2 = I.regs.b[CL] & 0xf;   I.ZeroVal = (tmp & (1<<tmp2)) ? 1 : 0;   I.CarryVal=I.OverVal=0; break; /* Test */
342412      case 0x12 : BITOP_BYTE;   CLKS(5,5,4); tmp2 = I.regs.b[CL] & 0x7;   tmp &= ~(1<<tmp2);   PutbackRMByte(ModRM,tmp);   break; /* Clr */
r3514r3515
346416      case 0x16 : BITOP_BYTE;   CLKS(4,4,4); tmp2 = I.regs.b[CL] & 0x7;   BIT_NOT;         PutbackRMByte(ModRM,tmp);   break; /* Not */
347417      case 0x17 : BITOP_WORD;   CLKS(4,4,4); tmp2 = I.regs.b[CL] & 0xf;   BIT_NOT;         PutbackRMWord(ModRM,tmp);   break; /* Not */
348418
349      case 0x18 : BITOP_BYTE;   CLKS(4,4,4); tmp2 = (FETCH) & 0x7;   I.ZeroVal = (tmp & (1<<tmp2)) ? 1 : 0;   I.CarryVal=I.OverVal=0; break; /* Test */
350      case 0x19 : BITOP_WORD;   CLKS(4,4,4); tmp2 = (FETCH) & 0xf;   I.ZeroVal = (tmp & (1<<tmp2)) ? 1 : 0;   I.CarryVal=I.OverVal=0; break; /* Test */
351      case 0x1a : BITOP_BYTE;   CLKS(6,6,4); tmp2 = (FETCH) & 0x7;   tmp &= ~(1<<tmp2);      PutbackRMByte(ModRM,tmp);   break; /* Clr */
352      case 0x1b : BITOP_WORD;   CLKS(6,6,4); tmp2 = (FETCH) & 0xf;   tmp &= ~(1<<tmp2);      PutbackRMWord(ModRM,tmp);   break; /* Clr */
353      case 0x1c : BITOP_BYTE;   CLKS(5,5,4); tmp2 = (FETCH) & 0x7;   tmp |= (1<<tmp2);      PutbackRMByte(ModRM,tmp);   break; /* Set */
354      case 0x1d : BITOP_WORD;   CLKS(5,5,4); tmp2 = (FETCH) & 0xf;   tmp |= (1<<tmp2);      PutbackRMWord(ModRM,tmp);   break; /* Set */
355      case 0x1e : BITOP_BYTE;   CLKS(5,5,4); tmp2 = (FETCH) & 0x7;   BIT_NOT;            PutbackRMByte(ModRM,tmp);   break; /* Not */
356      case 0x1f : BITOP_WORD;   CLKS(5,5,4); tmp2 = (FETCH) & 0xf;   BIT_NOT;            PutbackRMWord(ModRM,tmp);   break; /* Not */
419      case 0x18 : BITOP_BYTE;   CLKS(4,4,4); tmp2 = (FETCH()) & 0x7;   I.ZeroVal = (tmp & (1<<tmp2)) ? 1 : 0;   I.CarryVal=I.OverVal=0; break; /* Test */
420      case 0x19 : BITOP_WORD;   CLKS(4,4,4); tmp2 = (FETCH()) & 0xf;   I.ZeroVal = (tmp & (1<<tmp2)) ? 1 : 0;   I.CarryVal=I.OverVal=0; break; /* Test */
421      case 0x1a : BITOP_BYTE;   CLKS(6,6,4); tmp2 = (FETCH()) & 0x7;   tmp &= ~(1<<tmp2);      PutbackRMByte(ModRM,tmp);   break; /* Clr */
422      case 0x1b : BITOP_WORD;   CLKS(6,6,4); tmp2 = (FETCH()) & 0xf;   tmp &= ~(1<<tmp2);      PutbackRMWord(ModRM,tmp);   break; /* Clr */
423      case 0x1c : BITOP_BYTE;   CLKS(5,5,4); tmp2 = (FETCH()) & 0x7;   tmp |= (1<<tmp2);      PutbackRMByte(ModRM,tmp);   break; /* Set */
424      case 0x1d : BITOP_WORD;   CLKS(5,5,4); tmp2 = (FETCH()) & 0xf;   tmp |= (1<<tmp2);      PutbackRMWord(ModRM,tmp);   break; /* Set */
425      case 0x1e : BITOP_BYTE;   CLKS(5,5,4); tmp2 = (FETCH()) & 0x7;   BIT_NOT;            PutbackRMByte(ModRM,tmp);   break; /* Not */
426      case 0x1f : BITOP_WORD;   CLKS(5,5,4); tmp2 = (FETCH()) & 0xf;   BIT_NOT;            PutbackRMWord(ModRM,tmp);   break; /* Not */
357427
358428      case 0x20 :   ADD4S; CLKS(7,7,2); break;
359429      case 0x22 :   SUB4S; CLKS(7,7,2); break;
360430      case 0x26 :   CMP4S; CLKS(7,7,2); break;
361      case 0x28 : ModRM = FETCH; tmp = GetRMByte(ModRM); tmp <<= 4; tmp |= I.regs.b[AL] & 0xf; I.regs.b[AL] = (I.regs.b[AL] & 0xf0) | ((tmp>>8)&0xf); tmp &= 0xff; PutbackRMByte(ModRM,tmp); CLKM(13,13,9,28,28,15); break;
362      case 0x2a : ModRM = FETCH; tmp = GetRMByte(ModRM); tmp2 = (I.regs.b[AL] & 0xf)<<4; I.regs.b[AL] = (I.regs.b[AL] & 0xf0) | (tmp&0xf); tmp = tmp2 | (tmp>>4);   PutbackRMByte(ModRM,tmp); CLKM(17,17,13,32,32,19); break;
363      case 0x31 : ModRM = FETCH; ModRM=0; logerror("%06x: Unimplemented bitfield INS\n",activecpu_get_pc()); break;
364      case 0x33 : ModRM = FETCH; ModRM=0; logerror("%06x: Unimplemented bitfield EXT\n",activecpu_get_pc()); break;
431      case 0x28 : ModRM = FETCH(); tmp = GetRMByte(ModRM); tmp <<= 4; tmp |= I.regs.b[AL] & 0xf; I.regs.b[AL] = (I.regs.b[AL] & 0xf0) | ((tmp>>8)&0xf); tmp &= 0xff; PutbackRMByte(ModRM,tmp); CLKM(13,13,9,28,28,15); break;
432      case 0x2a : ModRM = FETCH(); tmp = GetRMByte(ModRM); tmp2 = (I.regs.b[AL] & 0xf)<<4; I.regs.b[AL] = (I.regs.b[AL] & 0xf0) | (tmp&0xf); tmp = tmp2 | (tmp>>4);   PutbackRMByte(ModRM,tmp); CLKM(17,17,13,32,32,19); break;
433      case 0x31 : ModRM = FETCH(); ModRM=0; logerror("%06x: Unimplemented bitfield INS\n",activecpu_get_pc()); break;
434      case 0x33 : ModRM = FETCH(); ModRM=0; logerror("%06x: Unimplemented bitfield EXT\n",activecpu_get_pc()); break;
365435      case 0x92 : CLK(2); break; /* V25/35 FINT */
366      case 0xe0 : ModRM = FETCH; ModRM=0; logerror("%06x: V33 unimplemented BRKXA (break to expansion address)\n",activecpu_get_pc()); break;
367      case 0xf0 : ModRM = FETCH; ModRM=0; logerror("%06x: V33 unimplemented RETXA (return from expansion address)\n",activecpu_get_pc()); break;
368      case 0xff : ModRM = FETCH; ModRM=0; logerror("%06x: unimplemented BRKEM (break to 8080 emulation mode)\n",activecpu_get_pc()); break;
436      case 0xe0 : ModRM = FETCH(); ModRM=0; logerror("%06x: V33 unimplemented BRKXA (break to expansion address)\n",activecpu_get_pc()); break;
437      case 0xf0 : ModRM = FETCH(); ModRM=0; logerror("%06x: V33 unimplemented RETXA (return from expansion address)\n",activecpu_get_pc()); break;
438      case 0xff : ModRM = FETCH(); ModRM=0; logerror("%06x: unimplemented BRKEM (break to 8080 emulation mode)\n",activecpu_get_pc()); break;
369439      default:    logerror("%06x: Unknown V20 instruction\n",activecpu_get_pc()); break;
370440   }
371441}
r3514r3515
394464OP( 0x23, i_and_r16w ) { DEF_r16w;   ANDW;   RegWord(ModRM)=dst;         CLKR(15,15,8,15,11,6,2,EA);   }
395465OP( 0x24, i_and_ald8 ) { DEF_ald8;   ANDB;   I.regs.b[AL]=dst;         CLKS(4,4,2);            }
396466OP( 0x25, i_and_axd16) { DEF_axd16;   ANDW;   I.regs.w[AW]=dst;         CLKS(4,4,2);   }
397OP( 0x26, i_es       ) { seg_prefix=TRUE;   prefix_base=I.sregs[DS1]<<4;   CLK(2);      nec_instruction[fetchop()]();   seg_prefix=FALSE; }
467OP( 0x26, i_es       ) { I.seg_prefix=TRUE;   I.prefix_base=I.sregs[DS1]<<4;   CLK(2);      nec_instruction[fetchop()]();   I.seg_prefix=FALSE; }
398468OP( 0x27, i_daa      ) { ADJ4(6,0x60);                           CLKS(3,3,2);   }
399469
400470OP( 0x28, i_sub_br8  ) { DEF_br8;   SUBB;   PutbackRMByte(ModRM,dst);   CLKM(2,2,2,16,16,7);       }
r3514r3515
403473OP( 0x2b, i_sub_r16w ) { DEF_r16w;   SUBW;   RegWord(ModRM)=dst;         CLKR(15,15,8,15,11,6,2,EA);   }
404474OP( 0x2c, i_sub_ald8 ) { DEF_ald8;   SUBB;   I.regs.b[AL]=dst;         CLKS(4,4,2);             }
405475OP( 0x2d, i_sub_axd16) { DEF_axd16;   SUBW;   I.regs.w[AW]=dst;         CLKS(4,4,2);   }
406OP( 0x2e, i_cs       ) { seg_prefix=TRUE;   prefix_base=I.sregs[PS]<<4;   CLK(2);      nec_instruction[fetchop()]();   seg_prefix=FALSE; }
476OP( 0x2e, i_cs       ) { I.seg_prefix=TRUE;   I.prefix_base=I.sregs[PS]<<4;   CLK(2);      nec_instruction[fetchop()]();   I.seg_prefix=FALSE; }
407477OP( 0x2f, i_das      ) { ADJ4(-6,-0x60);                        CLKS(3,3,2);   }
408478
409479OP( 0x30, i_xor_br8  ) { DEF_br8;   XORB;   PutbackRMByte(ModRM,dst);   CLKM(2,2,2,16,16,7);      }
r3514r3515
412482OP( 0x33, i_xor_r16w ) { DEF_r16w;   XORW;   RegWord(ModRM)=dst;         CLKR(15,15,8,15,11,6,2,EA);   }
413483OP( 0x34, i_xor_ald8 ) { DEF_ald8;   XORB;   I.regs.b[AL]=dst;         CLKS(4,4,2);             }
414484OP( 0x35, i_xor_axd16) { DEF_axd16;   XORW;   I.regs.w[AW]=dst;         CLKS(4,4,2);   }
415OP( 0x36, i_ss       ) { seg_prefix=TRUE;   prefix_base=I.sregs[SS]<<4;   CLK(2);      nec_instruction[fetchop()]();   seg_prefix=FALSE; }
485OP( 0x36, i_ss       ) { I.seg_prefix=TRUE;   I.prefix_base=I.sregs[SS]<<4;   CLK(2);      nec_instruction[fetchop()]();   I.seg_prefix=FALSE; }
416486OP( 0x37, i_aaa      ) { ADJB(6, (I.regs.b[AL] > 0xf9) ? 2 : 1);      CLKS(7,7,4);    }
417487
418488OP( 0x38, i_cmp_br8  ) { DEF_br8;   SUBB;               CLKM(2,2,2,11,11,6); }
r3514r3515
421491OP( 0x3b, i_cmp_r16w ) { DEF_r16w;   SUBW;               CLKR(15,15,8,15,11,6,2,EA);   }
422492OP( 0x3c, i_cmp_ald8 ) { DEF_ald8;   SUBB;               CLKS(4,4,2); }
423493OP( 0x3d, i_cmp_axd16) { DEF_axd16;   SUBW;               CLKS(4,4,2);   }
424OP( 0x3e, i_ds       ) { seg_prefix=TRUE;   prefix_base=I.sregs[DS0]<<4;   CLK(2);      nec_instruction[fetchop()]();   seg_prefix=FALSE; }
494OP( 0x3e, i_ds       ) { I.seg_prefix=TRUE;   I.prefix_base=I.sregs[DS0]<<4;   CLK(2);      nec_instruction[fetchop()]();   I.seg_prefix=FALSE; }
425495OP( 0x3f, i_aas      ) { ADJB(-6, (I.regs.b[AL] < 6) ? -2 : -1);      CLKS(7,7,4);   }
426496
427497OP( 0x40, i_inc_ax  ) { IncWordReg(AW);                  CLK(2);   }
r3514r3515
496566    nec_ICount-=20;
497567   logerror("%06x: bound %04x high %04x low %04x tmp\n",activecpu_get_pc(),high,low,tmp);
498568}
499OP( 0x63, i_brkn   ) { nec_interrupt(FETCH,1); CLKS(50,50,24); } // timing not verified, used by riskchal / gussun
569OP( 0x63, i_brkn   ) { nec_interrupt(FETCH(),1); CLKS(50,50,24); } // timing not verified, used by riskchal / gussun
500570OP( 0x64, i_repnc  ) {    UINT32 next = fetchop();   UINT16 c = I.regs.w[CW];
501571    switch(next) { /* Segments */
502       case 0x26:   seg_prefix=TRUE;   prefix_base=I.sregs[DS1]<<4;   next = fetchop();   CLK(2); break;
503       case 0x2e:   seg_prefix=TRUE;   prefix_base=I.sregs[PS]<<4;   next = fetchop();   CLK(2); break;
504       case 0x36:   seg_prefix=TRUE;   prefix_base=I.sregs[SS]<<4;   next = fetchop();   CLK(2); break;
505       case 0x3e:   seg_prefix=TRUE;   prefix_base=I.sregs[DS0]<<4;   next = fetchop();   CLK(2); break;
572       case 0x26:   I.seg_prefix=TRUE;   I.prefix_base=I.sregs[DS1]<<4;   next = fetchop();   CLK(2); break;
573       case 0x2e:   I.seg_prefix=TRUE;   I.prefix_base=I.sregs[PS]<<4;   next = fetchop();   CLK(2); break;
574       case 0x36:   I.seg_prefix=TRUE;   I.prefix_base=I.sregs[SS]<<4;   next = fetchop();   CLK(2); break;
575       case 0x3e:   I.seg_prefix=TRUE;   I.prefix_base=I.sregs[DS0]<<4;   next = fetchop();   CLK(2); break;
506576   }
507577
508578    switch(next) {
r3514r3515
522592       case 0xaf:   CLK(2); if (c) do { i_scasw(); c--; } while (c>0 && !CF); I.regs.w[CW]=c; break;
523593      default:   logerror("%06x: REPNC invalid\n",activecpu_get_pc());   nec_instruction[next]();
524594    }
525   seg_prefix=FALSE;
595   I.seg_prefix=FALSE;
526596}
527597
528598OP( 0x65, i_repc  ) {    UINT32 next = fetchop();   UINT16 c = I.regs.w[CW];
529599    switch(next) { /* Segments */
530       case 0x26:   seg_prefix=TRUE;   prefix_base=I.sregs[DS1]<<4;   next = fetchop();   CLK(2); break;
531       case 0x2e:   seg_prefix=TRUE;   prefix_base=I.sregs[PS]<<4;   next = fetchop();   CLK(2); break;
532       case 0x36:   seg_prefix=TRUE;   prefix_base=I.sregs[SS]<<4;   next = fetchop();   CLK(2); break;
533       case 0x3e:   seg_prefix=TRUE;   prefix_base=I.sregs[DS0]<<4;   next = fetchop();   CLK(2); break;
600       case 0x26:   I.seg_prefix=TRUE;   I.prefix_base=I.sregs[DS1]<<4;   next = fetchop();   CLK(2); break;
601       case 0x2e:   I.seg_prefix=TRUE;   I.prefix_base=I.sregs[PS]<<4;   next = fetchop();   CLK(2); break;
602       case 0x36:   I.seg_prefix=TRUE;   I.prefix_base=I.sregs[SS]<<4;   next = fetchop();   CLK(2); break;
603       case 0x3e:   I.seg_prefix=TRUE;   I.prefix_base=I.sregs[DS0]<<4;   next = fetchop();   CLK(2); break;
534604   }
535605
536606    switch(next) {
r3514r3515
550620       case 0xaf:   CLK(2); if (c) do { i_scasw(); c--; } while (c>0 && CF);   I.regs.w[CW]=c; break;
551621      default:   logerror("%06x: REPC invalid\n",activecpu_get_pc());   nec_instruction[next]();
552622    }
553   seg_prefix=FALSE;
623   I.seg_prefix=FALSE;
554624}
555625
556OP( 0x68, i_push_d16 ) { UINT32 tmp;   FETCHWORD(tmp); PUSH(tmp);   CLKW(12,12,5,12,8,5,I.regs.w[SP]);   }
557OP( 0x69, i_imul_d16 ) { UINT32 tmp;   DEF_r16w;    FETCHWORD(tmp); dst = (INT32)((INT16)src)*(INT32)((INT16)tmp); I.CarryVal = I.OverVal = (((INT32)dst) >> 15 != 0) && (((INT32)dst) >> 15 != -1);     RegWord(ModRM)=(WORD)dst;     nec_ICount-=(ModRM >=0xc0 )?38:47;}
558OP( 0x6a, i_push_d8  ) { UINT32 tmp = (WORD)((INT16)((INT8)FETCH));    PUSH(tmp);   CLKW(11,11,5,11,7,3,I.regs.w[SP]);   }
559OP( 0x6b, i_imul_d8  ) { UINT32 src2; DEF_r16w; src2= (WORD)((INT16)((INT8)FETCH)); dst = (INT32)((INT16)src)*(INT32)((INT16)src2); I.CarryVal = I.OverVal = (((INT32)dst) >> 15 != 0) && (((INT32)dst) >> 15 != -1); RegWord(ModRM)=(WORD)dst; nec_ICount-=(ModRM >=0xc0 )?31:39; }
626OP( 0x68, i_push_d16 ) { UINT32 tmp;   tmp = FETCHWORD(); PUSH(tmp);   CLKW(12,12,5,12,8,5,I.regs.w[SP]);   }
627OP( 0x69, i_imul_d16 ) { UINT32 tmp;   DEF_r16w;    tmp = FETCHWORD(); dst = (INT32)((INT16)src)*(INT32)((INT16)tmp); I.CarryVal = I.OverVal = (((INT32)dst) >> 15 != 0) && (((INT32)dst) >> 15 != -1);     RegWord(ModRM)=(WORD)dst;     nec_ICount-=(ModRM >=0xc0 )?38:47;}
628OP( 0x6a, i_push_d8  ) { UINT32 tmp = (WORD)((INT16)((INT8)FETCH()));    PUSH(tmp);   CLKW(11,11,5,11,7,3,I.regs.w[SP]);   }
629OP( 0x6b, i_imul_d8  ) { UINT32 src2; DEF_r16w; src2= (WORD)((INT16)((INT8)FETCH())); dst = (INT32)((INT16)src)*(INT32)((INT16)src2); I.CarryVal = I.OverVal = (((INT32)dst) >> 15 != 0) && (((INT32)dst) >> 15 != -1); RegWord(ModRM)=(WORD)dst; nec_ICount-=(ModRM >=0xc0 )?31:39; }
560630OP( 0x6c, i_insb     ) { PutMemB(DS1,I.regs.w[IY],read_port_byte(I.regs.w[DW])); I.regs.w[IY]+= -2 * I.DF + 1; CLK(8); }
561631OP( 0x6d, i_insw     ) { PutMemW(DS1,I.regs.w[IY],read_port_word(I.regs.w[DW])); I.regs.w[IY]+= -4 * I.DF + 2; CLKS(18,10,8); }
562632OP( 0x6e, i_outsb    ) { write_port_byte(I.regs.w[DW],GetMemB(DS0,I.regs.w[IX])); I.regs.w[IX]+= -2 * I.DF + 1; CLK(8); }
r3514r3515
579649OP( 0x7e, i_jle     ) { JMP((ZF)||(SF!=OF));    CLKS(4,4,3); }
580650OP( 0x7f, i_jnle    ) { JMP((SF==OF)&&(!ZF));   CLKS(4,4,3); }
581651
582OP( 0x80, i_80pre   ) { UINT32 dst, src; GetModRM; dst = GetRMByte(ModRM); src = FETCH;
652OP( 0x80, i_80pre   ) { UINT32 dst, src; GetModRM; dst = GetRMByte(ModRM); src = FETCH();
583653   if (ModRM >=0xc0 ) CLKS(4,4,2) else if ((ModRM & 0x38)==0x38) CLKS(13,13,6) else CLKS(18,18,7)
584654   switch (ModRM & 0x38) {
585655       case 0x00: ADDB;         PutbackRMByte(ModRM,dst);   break;
r3514r3515
593663    }
594664}
595665
596OP( 0x81, i_81pre   ) { UINT32 dst, src; GetModRM; dst = GetRMWord(ModRM); src = FETCH; src+= (FETCH << 8);
666OP( 0x81, i_81pre   ) { UINT32 dst, src; GetModRM; dst = GetRMWord(ModRM); src = FETCH(); src+= (FETCH() << 8);
597667   if (ModRM >=0xc0 ) CLKS(4,4,2) else if ((ModRM & 0x38)==0x38) CLKW(17,17,8,17,13,6,EA) else CLKW(26,26,11,26,18,7,EA)
598668    switch (ModRM & 0x38) {
599669       case 0x00: ADDW;         PutbackRMWord(ModRM,dst);   break;
r3514r3515
607677    }
608678}
609679
610OP( 0x82, i_82pre   ) { UINT32 dst, src; GetModRM; dst = GetRMByte(ModRM); src = (BYTE)((INT8)FETCH);
680OP( 0x82, i_82pre   ) { UINT32 dst, src; GetModRM; dst = GetRMByte(ModRM); src = (BYTE)((INT8)FETCH());
611681   if (ModRM >=0xc0 ) CLKS(4,4,2) else if ((ModRM & 0x38)==0x38) CLKS(13,13,6) else CLKS(18,18,7)
612682   switch (ModRM & 0x38) {
613683       case 0x00: ADDB;         PutbackRMByte(ModRM,dst);   break;
r3514r3515
621691    }
622692}
623693
624OP( 0x83, i_83pre   ) { UINT32 dst, src; GetModRM; dst = GetRMWord(ModRM); src = (WORD)((INT16)((INT8)FETCH));
694OP( 0x83, i_83pre   ) { UINT32 dst, src; GetModRM; dst = GetRMWord(ModRM); src = (WORD)((INT16)((INT8)FETCH()));
625695   if (ModRM >=0xc0 ) CLKS(4,4,2) else if ((ModRM & 0x38)==0x38) CLKW(17,17,8,17,13,6,EA) else CLKW(26,26,11,26,18,7,EA)
626696    switch (ModRM & 0x38) {
627697       case 0x00: ADDW;         PutbackRMWord(ModRM,dst);   break;
r3514r3515
645715OP( 0x8a, i_mov_r8b   ) { UINT8  src; GetModRM; src = GetRMByte(ModRM);   RegByte(ModRM)=src;      CLKM(2,2,2,11,11,5);       }
646716OP( 0x8b, i_mov_r16w  ) { UINT16 src; GetModRM; src = GetRMWord(ModRM);   RegWord(ModRM)=src;    CLKR(15,15,7,15,11,5,2,EA);    }
647717OP( 0x8c, i_mov_wsreg ) { GetModRM; PutRMWord(ModRM,I.sregs[(ModRM & 0x38) >> 3]);            CLKR(14,14,5,14,10,3,2,EA); }
648OP( 0x8d, i_lea       ) { UINT16 ModRM = FETCH; (void)(*GetEA[ModRM])(); RegWord(ModRM)=EO;    CLKS(4,4,2); }
718OP( 0x8d, i_lea       ) { UINT16 ModRM = FETCH(); (void)(*GetEA[ModRM])(); RegWord(ModRM)=EO;    CLKS(4,4,2); }
649719OP( 0x8e, i_mov_sregw ) { UINT16 src; GetModRM; src = GetRMWord(ModRM); CLKR(15,15,7,15,11,5,2,EA);
650720    switch (ModRM & 0x38) {
651721       case 0x00: I.sregs[DS1] = src; break; /* mov es,ew */
r3514r3515
657727   I.no_interrupt=1;
658728}
659729OP( 0x8f, i_popw ) { UINT16 tmp; GetModRM; POP(tmp); PutRMWord(ModRM,tmp); nec_ICount-=21; }
660OP( 0x90, i_nop  ) { CLK(3);
661   /* Cycle skip for idle loops (0: NOP  1:  JMP 0) */
662   if (I.no_interrupt==0 && nec_ICount>0 && (I.pending_irq==0) && (PEEKOP((I.sregs[PS]<<4)+I.ip))==0xeb && (PEEK((I.sregs[PS]<<4)+I.ip+1))==0xfd)
663      nec_ICount%=15;
664}
730OP( 0x90, i_nop  ) { CLK(3); }
665731OP( 0x91, i_xchg_axcx ) { XchgAWReg(CW); CLK(3); }
666732OP( 0x92, i_xchg_axdx ) { XchgAWReg(DW); CLK(3); }
667733OP( 0x93, i_xchg_axbx ) { XchgAWReg(BW); CLK(3); }
r3514r3515
672738
673739OP( 0x98, i_cbw       ) { I.regs.b[AH] = (I.regs.b[AL] & 0x80) ? 0xff : 0;      CLK(2);   }
674740OP( 0x99, i_cwd       ) { I.regs.w[DW] = (I.regs.b[AH] & 0x80) ? 0xffff : 0;   CLK(4);   }
675OP( 0x9a, i_call_far  ) { UINT32 tmp, tmp2;   FETCHWORD(tmp); FETCHWORD(tmp2); PUSH(I.sregs[PS]); PUSH(I.ip); I.ip = (WORD)tmp; I.sregs[PS] = (WORD)tmp2; CHANGE_PC; CLKW(29,29,13,29,21,9,I.regs.w[SP]); }
741OP( 0x9a, i_call_far  ) { UINT32 tmp, tmp2;   tmp = FETCHWORD(); tmp2 = FETCHWORD(); PUSH(I.sregs[PS]); PUSH(I.ip); I.ip = (WORD)tmp; I.sregs[PS] = (WORD)tmp2; CHANGE_PC; CLKW(29,29,13,29,21,9,I.regs.w[SP]); }
676742OP( 0x9b, i_wait      ) { if (!I.poll_state) I.ip--; CLK(5); }
677743OP( 0x9c, i_pushf     ) { UINT16 tmp = CompressFlags(); PUSH( tmp ); CLKS(12,8,3); }
678744OP( 0x9d, i_popf      ) { UINT32 tmp; POP(tmp); ExpandFlags(tmp); CLKS(12,8,5); if (I.TF) nec_trap(); }
679745OP( 0x9e, i_sahf      ) { UINT32 tmp = (CompressFlags() & 0xff00) | (I.regs.b[AH] & 0xd5); ExpandFlags(tmp); CLKS(3,3,2); }
680746OP( 0x9f, i_lahf      ) { I.regs.b[AH] = CompressFlags() & 0xff; CLKS(3,3,2); }
681747
682OP( 0xa0, i_mov_aldisp ) { UINT32 addr; FETCHWORD(addr); I.regs.b[AL] = GetMemB(DS0, addr); CLKS(10,10,5); }
683OP( 0xa1, i_mov_axdisp ) { UINT32 addr; FETCHWORD(addr); I.regs.w[AW] = GetMemW(DS0, addr); CLKW(14,14,7,14,10,5,addr); }
684OP( 0xa2, i_mov_dispal ) { UINT32 addr; FETCHWORD(addr); PutMemB(DS0, addr, I.regs.b[AL]);  CLKS(9,9,3); }
685OP( 0xa3, i_mov_dispax ) { UINT32 addr; FETCHWORD(addr); PutMemW(DS0, addr, I.regs.w[AW]);  CLKW(13,13,5,13,9,3,addr); }
748OP( 0xa0, i_mov_aldisp ) { UINT32 addr; addr = FETCHWORD(); I.regs.b[AL] = GetMemB(DS0, addr); CLKS(10,10,5); }
749OP( 0xa1, i_mov_axdisp ) { UINT32 addr; addr = FETCHWORD(); I.regs.w[AW] = GetMemW(DS0, addr); CLKW(14,14,7,14,10,5,addr); }
750OP( 0xa2, i_mov_dispal ) { UINT32 addr; addr = FETCHWORD(); PutMemB(DS0, addr, I.regs.b[AL]);  CLKS(9,9,3); }
751OP( 0xa3, i_mov_dispax ) { UINT32 addr; addr = FETCHWORD(); PutMemW(DS0, addr, I.regs.w[AW]);  CLKW(13,13,5,13,9,3,addr); }
686752OP( 0xa4, i_movsb      ) { UINT32 tmp = GetMemB(DS0,I.regs.w[IX]); PutMemB(DS1,I.regs.w[IY], tmp); I.regs.w[IY] += -2 * I.DF + 1; I.regs.w[IX] += -2 * I.DF + 1; CLKS(8,8,6); }
687753OP( 0xa5, i_movsw      ) { UINT32 tmp = GetMemW(DS0,I.regs.w[IX]); PutMemW(DS1,I.regs.w[IY], tmp); I.regs.w[IY] += -4 * I.DF + 2; I.regs.w[IX] += -4 * I.DF + 2; CLKS(16,16,10); }
688754OP( 0xa6, i_cmpsb      ) { UINT32 src = GetMemB(DS1, I.regs.w[IY]); UINT32 dst = GetMemB(DS0, I.regs.w[IX]); SUBB; I.regs.w[IY] += -2 * I.DF + 1; I.regs.w[IX] += -2 * I.DF + 1; CLKS(14,14,14); }
r3514r3515
697763OP( 0xae, i_scasb      ) { UINT32 src = GetMemB(DS1, I.regs.w[IY]);    UINT32 dst = I.regs.b[AL]; SUBB; I.regs.w[IY] += -2 * I.DF + 1; CLKS(4,4,3);  }
698764OP( 0xaf, i_scasw      ) { UINT32 src = GetMemW(DS1, I.regs.w[IY]);    UINT32 dst = I.regs.w[AW]; SUBW; I.regs.w[IY] += -4 * I.DF + 2; CLKW(8,8,5,8,4,3,I.regs.w[IY]); }
699765
700OP( 0xb0, i_mov_ald8  ) { I.regs.b[AL] = FETCH;   CLKS(4,4,2); }
701OP( 0xb1, i_mov_cld8  ) { I.regs.b[CL] = FETCH; CLKS(4,4,2); }
702OP( 0xb2, i_mov_dld8  ) { I.regs.b[DL] = FETCH; CLKS(4,4,2); }
703OP( 0xb3, i_mov_bld8  ) { I.regs.b[BL] = FETCH; CLKS(4,4,2); }
704OP( 0xb4, i_mov_ahd8  ) { I.regs.b[AH] = FETCH; CLKS(4,4,2); }
705OP( 0xb5, i_mov_chd8  ) { I.regs.b[CH] = FETCH; CLKS(4,4,2); }
706OP( 0xb6, i_mov_dhd8  ) { I.regs.b[DH] = FETCH; CLKS(4,4,2); }
707OP( 0xb7, i_mov_bhd8  ) { I.regs.b[BH] = FETCH;   CLKS(4,4,2); }
766OP( 0xb0, i_mov_ald8  ) { I.regs.b[AL] = FETCH();   CLKS(4,4,2); }
767OP( 0xb1, i_mov_cld8  ) { I.regs.b[CL] = FETCH(); CLKS(4,4,2); }
768OP( 0xb2, i_mov_dld8  ) { I.regs.b[DL] = FETCH(); CLKS(4,4,2); }
769OP( 0xb3, i_mov_bld8  ) { I.regs.b[BL] = FETCH(); CLKS(4,4,2); }
770OP( 0xb4, i_mov_ahd8  ) { I.regs.b[AH] = FETCH(); CLKS(4,4,2); }
771OP( 0xb5, i_mov_chd8  ) { I.regs.b[CH] = FETCH(); CLKS(4,4,2); }
772OP( 0xb6, i_mov_dhd8  ) { I.regs.b[DH] = FETCH(); CLKS(4,4,2); }
773OP( 0xb7, i_mov_bhd8  ) { I.regs.b[BH] = FETCH();   CLKS(4,4,2); }
708774
709OP( 0xb8, i_mov_axd16 ) { I.regs.b[AL] = FETCH;    I.regs.b[AH] = FETCH;   CLKS(4,4,2); }
710OP( 0xb9, i_mov_cxd16 ) { I.regs.b[CL] = FETCH;    I.regs.b[CH] = FETCH;   CLKS(4,4,2); }
711OP( 0xba, i_mov_dxd16 ) { I.regs.b[DL] = FETCH;    I.regs.b[DH] = FETCH;   CLKS(4,4,2); }
712OP( 0xbb, i_mov_bxd16 ) { I.regs.b[BL] = FETCH;    I.regs.b[BH] = FETCH;   CLKS(4,4,2); }
713OP( 0xbc, i_mov_spd16 ) { I.regs.b[SPL] = FETCH; I.regs.b[SPH] = FETCH;   CLKS(4,4,2); }
714OP( 0xbd, i_mov_bpd16 ) { I.regs.b[BPL] = FETCH; I.regs.b[BPH] = FETCH; CLKS(4,4,2); }
715OP( 0xbe, i_mov_sid16 ) { I.regs.b[IXL] = FETCH; I.regs.b[IXH] = FETCH;   CLKS(4,4,2); }
716OP( 0xbf, i_mov_did16 ) { I.regs.b[IYL] = FETCH; I.regs.b[IYH] = FETCH;   CLKS(4,4,2); }
775OP( 0xb8, i_mov_axd16 ) { I.regs.b[AL] = FETCH();    I.regs.b[AH] = FETCH();   CLKS(4,4,2); }
776OP( 0xb9, i_mov_cxd16 ) { I.regs.b[CL] = FETCH();    I.regs.b[CH] = FETCH();   CLKS(4,4,2); }
777OP( 0xba, i_mov_dxd16 ) { I.regs.b[DL] = FETCH();    I.regs.b[DH] = FETCH();   CLKS(4,4,2); }
778OP( 0xbb, i_mov_bxd16 ) { I.regs.b[BL] = FETCH();    I.regs.b[BH] = FETCH();   CLKS(4,4,2); }
779OP( 0xbc, i_mov_spd16 ) { I.regs.b[SPL] = FETCH(); I.regs.b[SPH] = FETCH();   CLKS(4,4,2); }
780OP( 0xbd, i_mov_bpd16 ) { I.regs.b[BPL] = FETCH(); I.regs.b[BPH] = FETCH(); CLKS(4,4,2); }
781OP( 0xbe, i_mov_sid16 ) { I.regs.b[IXL] = FETCH(); I.regs.b[IXH] = FETCH();   CLKS(4,4,2); }
782OP( 0xbf, i_mov_did16 ) { I.regs.b[IYL] = FETCH(); I.regs.b[IYH] = FETCH();   CLKS(4,4,2); }
717783
718784OP( 0xc0, i_rotshft_bd8 ) {
719785   UINT32 src, dst; UINT8 c;
720786   GetModRM; src = (unsigned)GetRMByte(ModRM); dst=src;
721   c=FETCH;
787   c=FETCH();
722788   CLKM(7,7,2,19,19,6);
723789   if (c) switch (ModRM & 0x38) {
724790      case 0x00: do { ROL_BYTE;  c--; CLK(1); } while (c>0); PutbackRMByte(ModRM,(BYTE)dst); break;
r3514r3515
735801OP( 0xc1, i_rotshft_wd8 ) {
736802   UINT32 src, dst;  UINT8 c;
737803   GetModRM; src = (unsigned)GetRMWord(ModRM); dst=src;
738   c=FETCH;
804   c=FETCH();
739805   CLKM(7,7,2,27,19,6);
740806    if (c) switch (ModRM & 0x38) {
741807      case 0x00: do { ROL_WORD;  c--; CLK(1); } while (c>0); PutbackRMWord(ModRM,(WORD)dst); break;
r3514r3515
749815   }
750816}
751817
752OP( 0xc2, i_ret_d16  ) { UINT32 count = FETCH; count += FETCH << 8; POP(I.ip); I.regs.w[SP]+=count; CHANGE_PC; CLKS(24,24,10); }
818OP( 0xc2, i_ret_d16  ) { UINT32 count = FETCH(); count += FETCH() << 8; POP(I.ip); I.regs.w[SP]+=count; CHANGE_PC; CLKS(24,24,10); }
753819OP( 0xc3, i_ret      ) { POP(I.ip); CHANGE_PC; CLKS(19,19,10); }
754820OP( 0xc4, i_les_dw   ) { GetModRM; WORD tmp = GetRMWord(ModRM); RegWord(ModRM)=tmp; I.sregs[DS1] = GetnextRMWord; CLKW(26,26,14,26,18,10,EA); }
755821OP( 0xc5, i_lds_dw   ) { GetModRM; WORD tmp = GetRMWord(ModRM); RegWord(ModRM)=tmp; I.sregs[DS0] = GetnextRMWord; CLKW(26,26,14,26,18,10,EA); }
r3514r3515
757823OP( 0xc7, i_mov_wd16 ) { GetModRM; PutImmRMWord(ModRM); nec_ICount-=(ModRM >=0xc0 )?4:15; }
758824
759825OP( 0xc8, i_enter ) {
760    UINT32 nb = FETCH;
826    UINT32 nb = FETCH();
761827    UINT32 i,level;
762828
763829    nec_ICount-=23;
764    nb += FETCH << 8;
765    level = FETCH;
830    nb += FETCH() << 8;
831    level = FETCH();
766832    PUSH(I.regs.w[BP]);
767833    I.regs.w[BP]=I.regs.w[SP];
768834    I.regs.w[SP] -= nb;
r3514r3515
777843   POP(I.regs.w[BP]);
778844   nec_ICount-=8;
779845}
780OP( 0xca, i_retf_d16  ) { UINT32 count = FETCH; count += FETCH << 8; POP(I.ip); POP(I.sregs[PS]); I.regs.w[SP]+=count; CHANGE_PC; CLKS(32,32,16); }
846OP( 0xca, i_retf_d16  ) { UINT32 count = FETCH(); count += FETCH() << 8; POP(I.ip); POP(I.sregs[PS]); I.regs.w[SP]+=count; CHANGE_PC; CLKS(32,32,16); }
781847OP( 0xcb, i_retf      ) { POP(I.ip); POP(I.sregs[PS]); CHANGE_PC; CLKS(29,29,16); }
782848OP( 0xcc, i_int3      ) { nec_interrupt(3,0); CLKS(50,50,24); }
783OP( 0xcd, i_int       ) { nec_interrupt(FETCH,0); CLKS(50,50,24); }
849OP( 0xcd, i_int       ) { nec_interrupt(FETCH(),0); CLKS(50,50,24); }
784850OP( 0xce, i_into      ) { if (OF) { nec_interrupt(4,0); CLKS(52,52,26); } else CLK(3); }
785851OP( 0xcf, i_iret      ) { POP(I.ip); POP(I.sregs[PS]); i_popf(); SetMD(1); CHANGE_PC; CLKS(39,39,19); }
786852
r3514r3515
846912   }
847913}
848914
849OP( 0xd4, i_aam    ) { UINT32 mult=FETCH; mult=0; I.regs.b[AH] = I.regs.b[AL] / 10; I.regs.b[AL] %= 10; SetSZPF_Word(I.regs.w[AW]); CLKS(15,15,12); }
850OP( 0xd5, i_aad    ) { UINT32 mult=FETCH; mult=0; I.regs.b[AL] = I.regs.b[AH] * 10 + I.regs.b[AL]; I.regs.b[AH] = 0; SetSZPF_Byte(I.regs.b[AL]); CLKS(7,7,8); }
915OP( 0xd4, i_aam    ) { UINT32 mult=FETCH(); mult=0; I.regs.b[AH] = I.regs.b[AL] / 10; I.regs.b[AL] %= 10; SetSZPF_Word(I.regs.w[AW]); CLKS(15,15,12); }
916OP( 0xd5, i_aad    ) { UINT32 mult=FETCH(); mult=0; I.regs.b[AL] = I.regs.b[AH] * 10 + I.regs.b[AL]; I.regs.b[AH] = 0; SetSZPF_Byte(I.regs.b[AL]); CLKS(7,7,8); }
851917OP( 0xd6, i_setalc ) { I.regs.b[AL] = (CF)?0xff:0x00; nec_ICount-=3; logerror("%06x: Undefined opcode (SETALC)\n",activecpu_get_pc()); }
852918OP( 0xd7, i_trans  ) { UINT32 dest = (I.regs.w[BW]+I.regs.b[AL])&0xffff; I.regs.b[AL] = GetMemB(DS0, dest); CLKS(9,9,5); }
853919OP( 0xd8, i_fpo    ) { GetModRM; nec_ICount-=2;   logerror("%06x: Unimplemented floating point control %04x\n",activecpu_get_pc(),ModRM); }
854920
855OP( 0xe0, i_loopne ) { INT8 disp = (INT8)FETCH; I.regs.w[CW]--; if (!ZF && I.regs.w[CW]) { I.ip = (WORD)(I.ip+disp); /*CHANGE_PC;*/ CLKS(14,14,6); } else CLKS(5,5,3); }
856OP( 0xe1, i_loope  ) { INT8 disp = (INT8)FETCH; I.regs.w[CW]--; if ( ZF && I.regs.w[CW]) { I.ip = (WORD)(I.ip+disp); /*CHANGE_PC;*/ CLKS(14,14,6); } else CLKS(5,5,3); }
857OP( 0xe2, i_loop   ) { INT8 disp = (INT8)FETCH; I.regs.w[CW]--; if (I.regs.w[CW]) { I.ip = (WORD)(I.ip+disp); /*CHANGE_PC;*/ CLKS(13,13,6); } else CLKS(5,5,3); }
858OP( 0xe3, i_jcxz   ) { INT8 disp = (INT8)FETCH; if (I.regs.w[CW] == 0) { I.ip = (WORD)(I.ip+disp); /*CHANGE_PC;*/ CLKS(13,13,6); } else CLKS(5,5,3); }
859OP( 0xe4, i_inal   ) { UINT8 port = FETCH; I.regs.b[AL] = read_port_byte(port); CLKS(9,9,5);   }
860OP( 0xe5, i_inax   ) { UINT8 port = FETCH; I.regs.w[AW] = read_port_word(port); CLKW(13,13,7,13,9,5,port); }
861OP( 0xe6, i_outal  ) { UINT8 port = FETCH; write_port_byte(port, I.regs.b[AL]); CLKS(8,8,3);   }
862OP( 0xe7, i_outax  ) { UINT8 port = FETCH; write_port_word(port, I.regs.w[AW]); CLKW(12,12,5,12,8,3,port);   }
921OP( 0xe0, i_loopne ) { INT8 disp = (INT8)FETCH(); I.regs.w[CW]--; if (!ZF && I.regs.w[CW]) { I.ip = (WORD)(I.ip+disp); /*CHANGE_PC;*/ CLKS(14,14,6); } else CLKS(5,5,3); }
922OP( 0xe1, i_loope  ) { INT8 disp = (INT8)FETCH(); I.regs.w[CW]--; if ( ZF && I.regs.w[CW]) { I.ip = (WORD)(I.ip+disp); /*CHANGE_PC;*/ CLKS(14,14,6); } else CLKS(5,5,3); }
923OP( 0xe2, i_loop   ) { INT8 disp = (INT8)FETCH(); I.regs.w[CW]--; if (I.regs.w[CW]) { I.ip = (WORD)(I.ip+disp); /*CHANGE_PC;*/ CLKS(13,13,6); } else CLKS(5,5,3); }
924OP( 0xe3, i_jcxz   ) { INT8 disp = (INT8)FETCH(); if (I.regs.w[CW] == 0) { I.ip = (WORD)(I.ip+disp); /*CHANGE_PC;*/ CLKS(13,13,6); } else CLKS(5,5,3); }
925OP( 0xe4, i_inal   ) { UINT8 port = FETCH(); I.regs.b[AL] = read_port_byte(port); CLKS(9,9,5);   }
926OP( 0xe5, i_inax   ) { UINT8 port = FETCH(); I.regs.w[AW] = read_port_word(port); CLKW(13,13,7,13,9,5,port); }
927OP( 0xe6, i_outal  ) { UINT8 port = FETCH(); write_port_byte(port, I.regs.b[AL]); CLKS(8,8,3);   }
928OP( 0xe7, i_outax  ) { UINT8 port = FETCH(); write_port_word(port, I.regs.w[AW]); CLKW(12,12,5,12,8,3,port);   }
863929
864OP( 0xe8, i_call_d16 ) { UINT32 tmp; FETCHWORD(tmp); PUSH(I.ip); I.ip = (WORD)(I.ip+(INT16)tmp); CHANGE_PC; nec_ICount-=24; }
865OP( 0xe9, i_jmp_d16  ) { UINT32 tmp; FETCHWORD(tmp); I.ip = (WORD)(I.ip+(INT16)tmp); CHANGE_PC; nec_ICount-=15; }
866OP( 0xea, i_jmp_far  ) { UINT32 tmp,tmp1; FETCHWORD(tmp); FETCHWORD(tmp1); I.sregs[PS] = (WORD)tmp1;    I.ip = (WORD)tmp; CHANGE_PC; nec_ICount-=27;  }
867OP( 0xeb, i_jmp_d8   ) { int tmp = (int)((INT8)FETCH); nec_ICount-=12; I.ip = (WORD)(I.ip+tmp); }
930OP( 0xe8, i_call_d16 ) { UINT32 tmp; tmp = FETCHWORD(); PUSH(I.ip); I.ip = (WORD)(I.ip+(INT16)tmp); CHANGE_PC; nec_ICount-=24; }
931OP( 0xe9, i_jmp_d16  ) { UINT32 tmp; tmp = FETCHWORD(); I.ip = (WORD)(I.ip+(INT16)tmp); CHANGE_PC; nec_ICount-=15; }
932OP( 0xea, i_jmp_far  ) { UINT32 tmp,tmp1; tmp = FETCHWORD(); tmp1 = FETCHWORD(); I.sregs[PS] = (WORD)tmp1;    I.ip = (WORD)tmp; CHANGE_PC; nec_ICount-=27;  }
933OP( 0xeb, i_jmp_d8   ) { int tmp = (int)((INT8)FETCH()); nec_ICount-=12; I.ip = (WORD)(I.ip+tmp); }
868934OP( 0xec, i_inaldx   ) { I.regs.b[AL] = read_port_byte(I.regs.w[DW]); CLKS(8,8,5);}
869935OP( 0xed, i_inaxdx   ) { I.regs.w[AW] = read_port_word(I.regs.w[DW]); CLKW(12,12,7,12,8,5,I.regs.w[DW]); }
870936OP( 0xee, i_outdxal  ) { write_port_byte(I.regs.w[DW], I.regs.b[AL]); CLKS(8,8,3);   }
r3514r3515
873939OP( 0xf0, i_lock     ) { logerror("%06x: Warning - BUSLOCK\n",activecpu_get_pc()); I.no_interrupt=1; CLK(2); }
874940OP( 0xf2, i_repne    ) { UINT32 next = fetchop(); UINT16 c = I.regs.w[CW];
875941    switch(next) { /* Segments */
876       case 0x26:   seg_prefix=TRUE;   prefix_base=I.sregs[DS1]<<4;   next = fetchop();   CLK(2); break;
877       case 0x2e:   seg_prefix=TRUE;   prefix_base=I.sregs[PS]<<4;   next = fetchop();   CLK(2); break;
878       case 0x36:   seg_prefix=TRUE;   prefix_base=I.sregs[SS]<<4;   next = fetchop();   CLK(2); break;
879       case 0x3e:   seg_prefix=TRUE;   prefix_base=I.sregs[DS0]<<4;   next = fetchop();   CLK(2); break;
942       case 0x26:   I.seg_prefix=TRUE;   I.prefix_base=I.sregs[DS1]<<4;   next = fetchop();   CLK(2); break;
943       case 0x2e:   I.seg_prefix=TRUE;   I.prefix_base=I.sregs[PS]<<4;   next = fetchop();   CLK(2); break;
944       case 0x36:   I.seg_prefix=TRUE;   I.prefix_base=I.sregs[SS]<<4;   next = fetchop();   CLK(2); break;
945       case 0x3e:   I.seg_prefix=TRUE;   I.prefix_base=I.sregs[DS0]<<4;   next = fetchop();   CLK(2); break;
880946   }
881947
882948    switch(next) {
r3514r3515
896962       case 0xaf:   CLK(2); if (c) do { i_scasw(); c--; } while (c>0 && ZF==0);   I.regs.w[CW]=c; break;
897963      default:   logerror("%06x: REPNE invalid\n",activecpu_get_pc());   nec_instruction[next]();
898964    }
899   seg_prefix=FALSE;
965   I.seg_prefix=FALSE;
900966}
901967OP( 0xf3, i_repe     ) { UINT32 next = fetchop(); UINT16 c = I.regs.w[CW];
902968    switch(next) { /* Segments */
903       case 0x26:   seg_prefix=TRUE;   prefix_base=I.sregs[DS1]<<4;   next = fetchop();   CLK(2); break;
904       case 0x2e:   seg_prefix=TRUE;   prefix_base=I.sregs[PS]<<4;   next = fetchop();   CLK(2); break;
905       case 0x36:   seg_prefix=TRUE;   prefix_base=I.sregs[SS]<<4;   next = fetchop();   CLK(2); break;
906       case 0x3e:   seg_prefix=TRUE;   prefix_base=I.sregs[DS0]<<4;   next = fetchop();   CLK(2); break;
969       case 0x26:   I.seg_prefix=TRUE;   I.prefix_base=I.sregs[DS1]<<4;   next = fetchop();   CLK(2); break;
970       case 0x2e:   I.seg_prefix=TRUE;   I.prefix_base=I.sregs[PS]<<4;   next = fetchop();   CLK(2); break;
971       case 0x36:   I.seg_prefix=TRUE;   I.prefix_base=I.sregs[SS]<<4;   next = fetchop();   CLK(2); break;
972       case 0x3e:   I.seg_prefix=TRUE;   I.prefix_base=I.sregs[DS0]<<4;   next = fetchop();   CLK(2); break;
907973   }
908974
909975    switch(next) {
r3514r3515
923989       case 0xaf:   CLK(2); if (c) do { i_scasw(); c--; } while (c>0 && ZF==1);   I.regs.w[CW]=c; break;
924990      default:   logerror("%06x: REPE invalid\n",activecpu_get_pc()); nec_instruction[next]();
925991    }
926   seg_prefix=FALSE;
992   I.seg_prefix=FALSE;
927993}
928994OP( 0xf4, i_hlt ) { logerror("%06x: HALT\n",activecpu_get_pc()); nec_ICount=0; }
929995OP( 0xf5, i_cmc ) { I.CarryVal = !CF; CLK(2); }
930996OP( 0xf6, i_f6pre ) { UINT32 tmp; UINT32 uresult,uresult2; INT32 result,result2;
931997   GetModRM; tmp = GetRMByte(ModRM);
932998    switch (ModRM & 0x38) {
933      case 0x00: tmp &= FETCH; I.CarryVal = I.OverVal = 0; SetSZPF_Byte(tmp); nec_ICount-=(ModRM >=0xc0 )?4:11; break; /* TEST */
999      case 0x00: tmp &= FETCH(); I.CarryVal = I.OverVal = 0; SetSZPF_Byte(tmp); nec_ICount-=(ModRM >=0xc0 )?4:11; break; /* TEST */
9341000      case 0x08: logerror("%06x: Undefined opcode 0xf6 0x08\n",activecpu_get_pc()); break;
9351001       case 0x10: PutbackRMByte(ModRM,~tmp); nec_ICount-=(ModRM >=0xc0 )?2:16; break; /* NOT */
9361002      case 0x18: I.CarryVal=(tmp!=0); tmp=(~tmp)+1; SetSZPF_Byte(tmp); PutbackRMByte(ModRM,tmp&0xff); nec_ICount-=(ModRM >=0xc0 )?2:16; break; /* NEG */
r3514r3515
9441010OP( 0xf7, i_f7pre   ) { UINT32 tmp,tmp2; UINT32 uresult,uresult2; INT32 result,result2;
9451011   GetModRM; tmp = GetRMWord(ModRM);
9461012    switch (ModRM & 0x38) {
947      case 0x00: FETCHWORD(tmp2); tmp &= tmp2; I.CarryVal = I.OverVal = 0; SetSZPF_Word(tmp); nec_ICount-=(ModRM >=0xc0 )?4:11; break; /* TEST */
1013      case 0x00: tmp2 = FETCHWORD(); tmp &= tmp2; I.CarryVal = I.OverVal = 0; SetSZPF_Word(tmp); nec_ICount-=(ModRM >=0xc0 )?4:11; break; /* TEST */
9481014      case 0x08: logerror("%06x: Undefined opcode 0xf7 0x08\n",activecpu_get_pc()); break;
9491015       case 0x10: PutbackRMWord(ModRM,~tmp); nec_ICount-=(ModRM >=0xc0 )?2:16; break; /* NOT */
9501016      case 0x18: I.CarryVal=(tmp!=0); tmp=(~tmp)+1; SetSZPF_Word(tmp); PutbackRMWord(ModRM,tmp&0xffff); nec_ICount-=(ModRM >=0xc0 )?2:16; break; /* NEG */
r3514r3515
11621228}
11631229#endif
11641230
1231static int necv_execute(int cycles)
1232{
1233   int prev_ICount;
11651234
1166/* Wrappers for the different CPU types */
1167#if (HAS_V20||HAS_V25)
1168static void v20_init(int index, int clock, const void *config, int (*irqcallback)(int))
1169{
1170   nec_init(index, clock, config, irqcallback, 0);
1171   configure_memory_8bit();
1172}
1173static int v20_execute(int cycles)
1174{
11751235   nec_ICount=cycles;
1176   chip_type=V20;
11771236
11781237   while(nec_ICount>0) {
11791238      /* Dispatch IRQ */
r3514r3515
11901249         I.no_interrupt--;
11911250
11921251      debugger_instruction_hook(Machine, (I.sregs[PS]<<4) + I.ip);
1252      prev_ICount = nec_ICount;
11931253      nec_instruction[fetchop()]();
1254      do_prefetch(prev_ICount);
11941255    }
11951256   return cycles - nec_ICount;
11961257}
1258
1259/* Wrappers for the different CPU types */
1260#if (HAS_V20||HAS_V25)
1261static void v20_init(int index, int clock, const void *config, int (*irqcallback)(int))
1262{
1263   nec_init(index, clock, config, irqcallback, 0);
1264   configure_memory_8bit();
1265   I.chip_type=V20;
1266   I.prefetch_size = 4;      /* 3 words */
1267   I.prefetch_cycles = 4;      /* four cycles per byte */
1268}
11971269#endif
11981270
11991271#if (HAS_V30||HAS_V35)
r3514r3515
12011273{
12021274   nec_init(index, clock, config, irqcallback, 1);
12031275   configure_memory_16bit();
1204}
1205static int v30_execute(int cycles) {
1206   nec_ICount=cycles;
1207   chip_type=V30;
1276   I.chip_type=V30;
1277   I.prefetch_size = 6;      /* 3 words */
1278   I.prefetch_cycles = 2;      /* two cycles per byte / four per word */
12081279
1209   while(nec_ICount>0) {
1210      /* Dispatch IRQ */
1211      if (I.pending_irq && I.no_interrupt==0)
1212      {
1213         if (I.pending_irq & NMI_IRQ)
1214            external_int();
1215         else if (I.IF)
1216            external_int();
1217      }
1218
1219      /* No interrupt allowed between last instruction and this one */
1220      if (I.no_interrupt)
1221         I.no_interrupt--;
1222
1223      debugger_instruction_hook(Machine, (I.sregs[PS]<<4) + I.ip);
1224      nec_instruction[fetchop()]();
1225    }
1226   return cycles - nec_ICount;
12271280}
12281281#endif
12291282
r3514r3515
12311284static void v33_init(int index, int clock, const void *config, int (*irqcallback)(int))
12321285{
12331286   nec_init(index, clock, config, irqcallback, 2);
1287   I.chip_type=V33;
1288   I.prefetch_size = 6;      /* ???? */
1289   I.prefetch_cycles = 2;      /* two cycles per byte / four per word */
1290
12341291   configure_memory_16bit();
12351292}
1236static int v33_execute(int cycles)
1237{
1238   nec_ICount=cycles;
1239   chip_type=V33;
1240
1241   while(nec_ICount>0) {
1242      /* Dispatch IRQ */
1243      if (I.pending_irq && I.no_interrupt==0)
1244      {
1245         if (I.pending_irq & NMI_IRQ)
1246            external_int();
1247         else if (I.IF)
1248            external_int();
1249      }
1250
1251      /* No interrupt allowed between last instruction and this one */
1252      if (I.no_interrupt)
1253         I.no_interrupt--;
1254
1255      debugger_instruction_hook(Machine, (I.sregs[PS]<<4) + I.ip);
1256      nec_instruction[fetchop()]();
1257    }
1258
1259   return cycles - nec_ICount;
1260}
12611293#endif
12621294
12631295
r3514r3515
13831415      case CPUINFO_PTR_INIT:                     /* set per-CPU */                  break;
13841416      case CPUINFO_PTR_RESET:                     info->reset = nec_reset;            break;
13851417      case CPUINFO_PTR_EXIT:                     info->exit = nec_exit;               break;
1386      case CPUINFO_PTR_EXECUTE:                  /* set per-CPU */                  break;
1418      case CPUINFO_PTR_EXECUTE:                  info->execute = necv_execute;         break;
13871419      case CPUINFO_PTR_BURN:                     info->burn = NULL;                  break;
13881420      case CPUINFO_PTR_DISASSEMBLE:               info->disassemble = nec_dasm;         break;
13891421      case CPUINFO_PTR_INSTRUCTION_COUNTER:         info->icount = &nec_ICount;            break;
r3514r3515
14511483
14521484      /* --- the following bits of info are returned as pointers to data or functions --- */
14531485      case CPUINFO_PTR_INIT:                     info->init = v20_init;               break;
1454      case CPUINFO_PTR_EXECUTE:                  info->execute = v20_execute;         break;
14551486
14561487      /* --- the following bits of info are returned as NULL-terminated strings --- */
14571488      case CPUINFO_STR_NAME:                     strcpy(info->s, "V20");               break;
r3514r3515
14771508
14781509      /* --- the following bits of info are returned as pointers to data or functions --- */
14791510      case CPUINFO_PTR_INIT:                     info->init = v20_init;               break;
1480      case CPUINFO_PTR_EXECUTE:                  info->execute = v20_execute;         break;
14811511
14821512      /* --- the following bits of info are returned as NULL-terminated strings --- */
14831513      case CPUINFO_STR_NAME:                     strcpy(info->s, "V25");               break;
r3514r3515
14991529   {
15001530      /* --- the following bits of info are returned as pointers to data or functions --- */
15011531      case CPUINFO_PTR_INIT:                     info->init = v30_init;               break;
1502      case CPUINFO_PTR_EXECUTE:                  info->execute = v30_execute;         break;
15031532
15041533      /* --- the following bits of info are returned as NULL-terminated strings --- */
15051534      case CPUINFO_STR_NAME:                     strcpy(info->s, "V30");               break;
r3514r3515
15211550   {
15221551      /* --- the following bits of info are returned as pointers to data or functions --- */
15231552      case CPUINFO_PTR_INIT:                     info->init = v33_init;               break;
1524      case CPUINFO_PTR_EXECUTE:                  info->execute = v33_execute;         break;
15251553
15261554      /* --- the following bits of info are returned as NULL-terminated strings --- */
15271555      case CPUINFO_STR_NAME:                     strcpy(info->s, "V33");               break;
r3514r3515
15431571   {
15441572      /* --- the following bits of info are returned as pointers to data or functions --- */
15451573      case CPUINFO_PTR_INIT:                     info->init = v30_init;               break;
1546      case CPUINFO_PTR_EXECUTE:                  info->execute = v30_execute;         break;
15471574
15481575      /* --- the following bits of info are returned as NULL-terminated strings --- */
15491576      case CPUINFO_STR_NAME:                     strcpy(info->s, "V35");               break;
src/emu/cpu/nec/necmodrm.h
r3514r3515
3737{                     \
3838   WORD val;               \
3939   if (ModRM >= 0xc0)            \
40      FETCHWORD(I.regs.w[Mod_RM.RM.w[ModRM]]) \
40      I.regs.w[Mod_RM.RM.w[ModRM]] = FETCHWORD(); \
4141   else {                  \
4242      (*GetEA[ModRM])();         \
43      FETCHWORD(val)            \
43      val = FETCHWORD();            \
4444      write_word( EA , val);         \
4545   }                  \
4646}
r3514r3515
5959#define PutImmRMByte(ModRM)             \
6060{                     \
6161   if (ModRM >= 0xc0)            \
62      I.regs.b[Mod_RM.RM.b[ModRM]]=FETCH;    \
62      I.regs.b[Mod_RM.RM.b[ModRM]]=FETCH();    \
6363   else {                  \
6464      (*GetEA[ModRM])();         \
65      write_byte( EA , FETCH );      \
65      write_byte( EA , FETCH() );      \
6666   }                  \
6767}
6868
r3514r3515
7575}
7676
7777#define DEF_br8                     \
78   UINT32 ModRM = FETCH,src,dst;      \
78   UINT32 ModRM = FETCH(),src,dst;      \
7979   src = RegByte(ModRM);            \
8080    dst = GetRMByte(ModRM)
8181
8282#define DEF_wr16                  \
83   UINT32 ModRM = FETCH,src,dst;      \
83   UINT32 ModRM = FETCH(),src,dst;      \
8484   src = RegWord(ModRM);            \
8585    dst = GetRMWord(ModRM)
8686
8787#define DEF_r8b                     \
88   UINT32 ModRM = FETCH,src,dst;      \
88   UINT32 ModRM = FETCH(),src,dst;      \
8989   dst = RegByte(ModRM);            \
9090    src = GetRMByte(ModRM)
9191
9292#define DEF_r16w                  \
93   UINT32 ModRM = FETCH,src,dst;      \
93   UINT32 ModRM = FETCH(),src,dst;      \
9494   dst = RegWord(ModRM);            \
9595    src = GetRMWord(ModRM)
9696
9797#define DEF_ald8                  \
98   UINT32 src = FETCH;               \
98   UINT32 src = FETCH();               \
9999   UINT32 dst = I.regs.b[AL]
100100
101101#define DEF_axd16                  \
102   UINT32 src = FETCH;             \
102   UINT32 src = FETCH();             \
103103   UINT32 dst = I.regs.w[AW];         \
104    src += (FETCH << 8)
104    src += (FETCH() << 8)
src/emu/cpu/nec/nec.h
r3514r3515
8888
8989/************************************************************************/
9090
91#define CHANGE_PC change_pc((I.sregs[PS]<<4) + I.ip)
91#define CHANGE_PC do { EMPTY_PREFETCH(); change_pc((I.sregs[PS]<<4) + I.ip); } while (0)
9292
9393#define SegBase(Seg) (I.sregs[Seg] << 4)
9494
95#define DefaultBase(Seg) ((seg_prefix && (Seg==DS0 || Seg==SS)) ? prefix_base : I.sregs[Seg] << 4)
95#define DefaultBase(Seg) ((I.seg_prefix && (Seg==DS0 || Seg==SS)) ? I.prefix_base : I.sregs[Seg] << 4)
9696
9797#define GetMemB(Seg,Off) (read_byte(DefaultBase(Seg) + (Off)))
9898#define GetMemW(Seg,Off) (read_word(DefaultBase(Seg) + (Off)))
r3514r3515
100100#define PutMemB(Seg,Off,x) { write_byte(DefaultBase(Seg) + (Off), (x)); }
101101#define PutMemW(Seg,Off,x) { write_word(DefaultBase(Seg) + (Off), (x)); }
102102
103/* prefetch timing */
104
105#define FETCH()          fetch()
103106#define FETCH_XOR(a)      ((a) ^ I.mem.fetch_xor)
104#define FETCH (cpu_readop_arg(FETCH_XOR((I.sregs[PS]<<4)+I.ip++)))
107#define FETCHWORD()         fetchword()
108#define EMPTY_PREFETCH()   I.prefetch_reset = 1
105109
106110
107#define FETCHOP ()
108#define FETCHWORD(var) { var=cpu_readop_arg(FETCH_XOR((I.sregs[PS]<<4)+I.ip))+(cpu_readop_arg(FETCH_XOR((I.sregs[PS]<<4)+I.ip+1))<<8); I.ip+=2; }
109111#define PUSH(val) { I.regs.w[SP]-=2; write_word((((I.sregs[SS]<<4)+I.regs.w[SP])),val); }
110112#define POP(var) { var = read_word((((I.sregs[SS]<<4)+I.regs.w[SP]))); I.regs.w[SP]+=2; }
111#define PEEK(addr) ((BYTE)cpu_readop_arg(FETCH_XOR(addr)))
112#define PEEKOP(addr) ((BYTE)cpu_readop(FETCH_XOR(addr)))
113113
114#define GetModRM UINT32 ModRM=cpu_readop_arg(FETCH_XOR((I.sregs[PS]<<4)+I.ip++))
114#define GetModRM UINT32 ModRM=FETCH()
115115
116116/* Cycle count macros:
117117    CLK  - cycle count is the same on all processors
r3514r3515
126126*/
127127
128128#define CLK(all) nec_ICount-=all
129#define CLKS(v20,v30,v33) { const UINT32 ccount=(v20<<16)|(v30<<8)|v33; nec_ICount-=(ccount>>chip_type)&0x7f; }
130#define CLKW(v20o,v30o,v33o,v20e,v30e,v33e,addr) { const UINT32 ocount=(v20o<<16)|(v30o<<8)|v33o, ecount=(v20e<<16)|(v30e<<8)|v33e; nec_ICount-=(addr&1)?((ocount>>chip_type)&0x7f):((ecount>>chip_type)&0x7f); }
131#define CLKM(v20,v30,v33,v20m,v30m,v33m) { const UINT32 ccount=(v20<<16)|(v30<<8)|v33, mcount=(v20m<<16)|(v30m<<8)|v33m; nec_ICount-=( ModRM >=0xc0 )?((ccount>>chip_type)&0x7f):((mcount>>chip_type)&0x7f); }
132#define CLKR(v20o,v30o,v33o,v20e,v30e,v33e,vall,addr) { const UINT32 ocount=(v20o<<16)|(v30o<<8)|v33o, ecount=(v20e<<16)|(v30e<<8)|v33e; if (ModRM >=0xc0) nec_ICount-=vall; else nec_ICount-=(addr&1)?((ocount>>chip_type)&0x7f):((ecount>>chip_type)&0x7f); }
129#define CLKS(v20,v30,v33) { const UINT32 ccount=(v20<<16)|(v30<<8)|v33; nec_ICount-=(ccount>>I.chip_type)&0x7f; }
130#define CLKW(v20o,v30o,v33o,v20e,v30e,v33e,addr) { const UINT32 ocount=(v20o<<16)|(v30o<<8)|v33o, ecount=(v20e<<16)|(v30e<<8)|v33e; nec_ICount-=(addr&1)?((ocount>>I.chip_type)&0x7f):((ecount>>I.chip_type)&0x7f); }
131#define CLKM(v20,v30,v33,v20m,v30m,v33m) { const UINT32 ccount=(v20<<16)|(v30<<8)|v33, mcount=(v20m<<16)|(v30m<<8)|v33m; nec_ICount-=( ModRM >=0xc0 )?((ccount>>I.chip_type)&0x7f):((mcount>>I.chip_type)&0x7f); }
132#define CLKR(v20o,v30o,v33o,v20e,v30e,v33e,vall,addr) { const UINT32 ocount=(v20o<<16)|(v30o<<8)|v33o, ecount=(v20e<<16)|(v30e<<8)|v33e; if (ModRM >=0xc0) nec_ICount-=vall; else nec_ICount-=(addr&1)?((ocount>>I.chip_type)&0x7f):((ecount>>I.chip_type)&0x7f); }
133133
134134/************************************************************************/
135135#define CompressFlags() (WORD)(CF | (PF << 2) | (AF << 4) | (ZF << 6) \
r3514r3515
167167   I.regs.w[Reg]=tmp1
168168
169169#define JMP(flag)                     \
170   int tmp = (int)((INT8)FETCH);         \
170   int tmp;                        \
171   EMPTY_PREFETCH();                  \
172   tmp = (int)((INT8)FETCH());            \
171173   if (flag)                        \
172174   {                              \
173175      static const UINT8 table[3]={3,10,10};    \
174176      I.ip = (WORD)(I.ip+tmp);         \
175      nec_ICount-=table[chip_type/8];      \
177      nec_ICount-=table[I.chip_type/8];   \
176178      CHANGE_PC;                     \
177179      return;                        \
178180   }
r3514r3515
209211   I.regs.b[AL] &= 0x0F
210212
211213#define BITOP_BYTE                     \
212   ModRM = FETCH;                     \
214   ModRM = FETCH();                     \
213215   if (ModRM >= 0xc0) {               \
214216      tmp=I.regs.b[Mod_RM.RM.b[ModRM]];   \
215217   }                              \
r3514r3515
219221    }
220222
221223#define BITOP_WORD                     \
222   ModRM = FETCH;                     \
224   ModRM = FETCH();                     \
223225   if (ModRM >= 0xc0) {               \
224226      tmp=I.regs.w[Mod_RM.RM.w[ModRM]];   \
225227   }                              \
r3514r3515
300302   int count = (I.regs.b[CL]+1)/2;                     \
301303   unsigned di = I.regs.w[IY];                        \
302304   unsigned si = I.regs.w[IX];                        \
303   static const UINT8 table[3]={18,19,19};                   \
304   if (seg_prefix) logerror("%06x: Warning: seg_prefix defined for add4s\n",activecpu_get_pc());   \
305   static const UINT8 table[3]={18,19,19};                \
306   if (I.seg_prefix) logerror("%06x: Warning: seg_prefix defined for add4s\n",activecpu_get_pc());   \
305307   I.ZeroVal = I.CarryVal = 0;                        \
306308   for (i=0;i<count;i++) {                           \
307      nec_ICount-=table[chip_type/8];                  \
309      nec_ICount-=table[I.chip_type/8];               \
308310      tmp = GetMemB(DS0, si);                        \
309      tmp2 = GetMemB(DS1, di);                        \
311      tmp2 = GetMemB(DS1, di);                     \
310312      v1 = (tmp>>4)*10 + (tmp&0xf);                  \
311313      v2 = (tmp2>>4)*10 + (tmp2&0xf);                  \
312314      result = v1+v2+I.CarryVal;                     \
313315      I.CarryVal = result > 99 ? 1 : 0;               \
314316      result = result % 100;                        \
315317      v1 = ((result/10)<<4) | (result % 10);            \
316      PutMemB(DS1, di,v1);                           \
318      PutMemB(DS1, di,v1);                        \
317319      if (v1) I.ZeroVal = 1;                        \
318320      si++;                                    \
319321      di++;                                    \
r3514r3515
325327   int i,v1,v2,result;                              \
326328    unsigned di = I.regs.w[IY];                        \
327329   unsigned si = I.regs.w[IX];                        \
328   static const UINT8 table[3]={18,19,19};                   \
329   if (seg_prefix) logerror("%06x: Warning: seg_prefix defined for sub4s\n",activecpu_get_pc());   \
330   static const UINT8 table[3]={18,19,19};               \
331   if (I.seg_prefix) logerror("%06x: Warning: seg_prefix defined for sub4s\n",activecpu_get_pc());   \
330332   I.ZeroVal = I.CarryVal = 0;                        \
331333   for (i=0;i<count;i++) {                           \
332      nec_ICount-=table[chip_type/8];                  \
334      nec_ICount-=table[I.chip_type/8];               \
333335      tmp = GetMemB(DS1, di);                        \
334      tmp2 = GetMemB(DS0, si);                        \
336      tmp2 = GetMemB(DS0, si);                     \
335337      v1 = (tmp>>4)*10 + (tmp&0xf);                  \
336338      v2 = (tmp2>>4)*10 + (tmp2&0xf);                  \
337339      if (v1 < (v2+I.CarryVal)) {                     \
r3514r3515
343345         I.CarryVal = 0;                           \
344346      }                                       \
345347      v1 = ((result/10)<<4) | (result % 10);            \
346      PutMemB(DS1, di,v1);                           \
348      PutMemB(DS1, di,v1);                        \
347349      if (v1) I.ZeroVal = 1;                        \
348350      si++;                                    \
349351      di++;                                    \
r3514r3515
355357   int i,v1,v2,result;                              \
356358    unsigned di = I.regs.w[IY];                        \
357359   unsigned si = I.regs.w[IX];                        \
358   static const UINT8 table[3]={14,19,19};                  \
359   if (seg_prefix) logerror("%06x: Warning: seg_prefix defined for cmp4s\n",activecpu_get_pc());   \
360   static const UINT8 table[3]={14,19,19};               \
361   if (I.seg_prefix) logerror("%06x: Warning: seg_prefix defined for cmp4s\n",activecpu_get_pc());   \
360362   I.ZeroVal = I.CarryVal = 0;                        \
361363   for (i=0;i<count;i++) {                           \
362      nec_ICount-=table[chip_type/8];                  \
364      nec_ICount-=table[I.chip_type/8];               \
363365      tmp = GetMemB(DS1, di);                        \
364      tmp2 = GetMemB(DS0, si);                        \
366      tmp2 = GetMemB(DS0, si);                     \
365367      v1 = (tmp>>4)*10 + (tmp&0xf);                  \
366368      v2 = (tmp2>>4)*10 + (tmp2&0xf);                  \
367369      if (v1 < (v2+I.CarryVal)) {                     \
src/emu/cpu/mips/mips3com.h
r3514r3515
229229offs_t mips3com_dasm(mips3_state *mips, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram);
230230void mips3com_update_cycle_counting(mips3_state *mips);
231231
232void mips3com_map_tlb_entry(mips3_state *mips, int tlbindex);
233void mips3com_map_tlb_entries(mips3_state *mips);
234232void mips3com_asid_changed(mips3_state *mips);
235233int mips3com_translate_address(mips3_state *mips, int space, int intention, offs_t *address);
236234void mips3com_tlbr(mips3_state *mips);
src/emu/uimenu.c
r3514r3515
217217
218218static render_texture *arrow_texture;
219219
220static const char *priortext = "Return to Prior Menu";
221static const char *backtext = "Return to " CAPSTARTGAMENOUN;
222static const char *exittext = "Exit";
220static const char priortext[] = "Return to Prior Menu";
221static const char backtext[] = "Return to " CAPSTARTGAMENOUN;
222static const char exittext[] = "Exit";
223223
224224static const rgb_t text_fgcolor = MAKE_ARGB(0xff,0xff,0xff,0xff);
225225static const rgb_t text_bgcolor = MAKE_ARGB(0xe0,0x80,0x80,0x80);
src/emu/machine/pd4990a.c
r3514r3515
3636
3737/* Set the data in the chip to Monday 09/09/73 00:00:00     */
3838/* If you ever read this Leejanne, you know what I mean :-) */
39struct pd4990a_s pd4990a =
39static const struct pd4990a_s pd4990a_initval =
4040{
4141   0x00,   /* seconds BCD */
4242   0x00,   /* minutes BCD */
r3514r3515
4747   1      /* weekday BCD */
4848};
4949
50struct pd4990a_s pd4990a;
51
5052static UINT32 shiftlo,shifthi;
5153
5254static int retraces = 0;   /* Assumes 60 retraces a second */
5355static int testwaits= 0;
54static int maxwaits= 1;   /*switch test every frame*/
56static int maxwaits= 0;   /*switch test every frame*/
5557static int testbit = 0;   /* Pulses a bit in order to simulate */
5658               /* test output */
5759static int outputbit=0;
r3514r3515
326328
327329void pd4990a_init(void)
328330{
331   pd4990a = pd4990a_initval;
332   shiftlo = 0;
333   shifthi = 0;
334   retraces = 0;
335   testwaits = 0;
336   maxwaits = 1;
337   testbit = 0;
338   outputbit = 0;
339   bitno = 0;
340   reading = 0;
341   writting = 0;
342   clock_line = 0;
343   command_line =0;
344
329345   state_save_register_item("pd4990a", 0, pd4990a.seconds);
330346   state_save_register_item("pd4990a", 0, pd4990a.minutes);
331347   state_save_register_item("pd4990a", 0, pd4990a.hours);
src/emu/machine/ldcore.c
r3514r3515
156156    GLOBAL VARIABLES
157157***************************************************************************/
158158
159static const ldplayer_interface *player_interfaces[] =
159static const ldplayer_interface *const player_interfaces[] =
160160{
161161//  &pr7820_interface,
162162   &pr8210_interface,
src/emu/machine/z80ctc.h
r3514r3515
5757    INITIALIZATION/CONFIGURATION
5858***************************************************************************/
5959
60void z80ctc_reset(const device_config *device);
6160attotime z80ctc_getperiod(const device_config *device, int ch);
6261
6362
src/emu/sound/disc_mth.c
r3514r3515
4343
4444#include <float.h>
4545
46struct dst_comp_adder_context
47{
48   double   total[256];
49};
50
4651struct dst_dac_r1_context
4752{
4853   double   i_bias;      /* current of the bias circuit */
r3514r3515
5156   int      last_data;
5257};
5358
59struct dst_diode_mix__context
60{
61   int      size;
62   double   v_junction[8];
63};
64
5465struct dst_flipflop_context
5566{
5667   int last_clk;
r3514r3515
7182   int      type;
7283   int      size;
7384   int      r_node_bit_flag;
85   int      c_bit_flag;
7486   double   r_total;
7587   double *r_node[DISC_MIXER_MAX_INPS];      /* Either pointer to resistance node output OR NULL */
88   double   r_last[DISC_MIXER_MAX_INPS];
7689   double   exponent_rc[DISC_MIXER_MAX_INPS];   /* For high pass filtering cause by cIn */
7790   double   v_cap[DISC_MIXER_MAX_INPS];         /* cap voltage of each input */
7891   double   exponent_c_f;         /* Low pass on mixed inputs */
r3514r3515
182195 *
183196 * DST_COMP_ADDER  - Selectable parallel component adder
184197 *
185 * input[0]    - Enable input value
186 * input[1]    - Bit Select
198 * input[0]    - Bit Select
187199 *
188200 * Also passed discrete_comp_adder_table structure
189201 *
190202 * Mar 2004, D Renaud.
191203 ************************************************************************/
192#define DST_COMP_ADDER__ENABLE   (*(node->input[0]))
193#define DST_COMP_ADDER__SELECT   (int)(*(node->input[1]))
204#define DST_COMP_ADDER__SELECT   (*(node->input[0]))
194205
195206static void dst_comp_adder_step(node_description *node)
196207{
197   const discrete_comp_adder_table *info = node->custom;
198   int bit;
208   struct dst_comp_adder_context    *context = node->context;
209   int select;
199210
200   if(DST_COMP_ADDER__ENABLE)
211   select = (int)DST_COMP_ADDER__SELECT;
212   assert(select < 256);
213   node->output[0] = context->total[select];
214}
215
216static void dst_comp_adder_reset(node_description *node)
217{
218   const  discrete_comp_adder_table *info = node->custom;
219   struct dst_comp_adder_context    *context = node->context;
220
221   int i, bit;
222   int length = 1 << info->length;
223
224   assert(length <= 256);
225
226   /* pre-calculate all possible values to speed up step rooutine */
227   for(i = 0; i < length; i++)
201228   {
202229      switch (info->type)
203230      {
204231         case DISC_COMP_P_CAPACITOR:
205            node->output[0] = info->cDefault;
206            for(bit=0; bit < info->length; bit++)
232            context->total[i] = info->cDefault;
233            for(bit = 0; bit < info->length; bit++)
207234            {
208               if (DST_COMP_ADDER__SELECT & (1 << bit)) node->output[0] += info->c[bit];
235               if (i & (1 << bit)) context->total[i] += info->c[bit];
209236            }
210237            break;
211238         case DISC_COMP_P_RESISTOR:
212            node->output[0] = info->cDefault ? 1.0 / info->cDefault : 0;
213            for(bit=0; bit < info->length; bit++)
239            context->total[i] = (info->cDefault != 0) ? 1.0 / info->cDefault : 0;
240            for(bit = 0; bit < info->length; bit++)
214241            {
215               if (DST_COMP_ADDER__SELECT & (1 << bit)) node->output[0] += 1.0 / info->c[bit];
242               if ((i & (1 << bit)) && (info->c[bit] != 0)) context->total[i] += 1.0 / info->c[bit];
216243            }
217            if (node->output[0] != 0) node->output[0] = 1.0 / node->output[0];
244            if (context->total[i] != 0) context->total[i] = 1.0 / context->total[i];
218245            break;
219246      }
220247   }
221   else
222   {
223      node->output[0] = 0;
224   }
248   node->output[0] = context->total[0];
225249}
226250
227
228251/************************************************************************
229252 *
230253 * DST_CLAMP - Simple signal clamping circuit
r3514r3515
378401   if (info->cFilter)
379402   {
380403      /* Setup filter constants */
381      context->exponent = -1.0 / (context->r_total * info->cFilter  * discrete_current_context->sample_rate);
382      context->exponent =  1.0 - exp(context->exponent);
404      context->exponent = RC_CHARGE_EXP(context->r_total * info->cFilter);
383405   }
384406}
385407
r3514r3515
388410*
389411 * DST_DIODE_MIX  - Diode Mixer
390412 *
391 * input[0]    - Enable input value
392 * input[1]    - Diode junction voltage drop
393 * input[2]    - Input 0
413 * input[0]    - Input 0
394414 * .....
395415 *
396416 * Dec 2004, D Renaud.
397417 ************************************************************************/
398#define DST_DIODE_MIX__VJUNC      (*(node->input[0]))
399#define DST_DIODE_MIX_INP_OFFSET   1
418#define DST_DIODE_MIX_INP_OFFSET   0
400419#define DST_DIODE_MIX__INP(addr)   (*(node->input[DST_DIODE_MIX_INP_OFFSET + addr]))
401420
402421static void dst_diode_mix_step(node_description *node)
403422{
404   struct   dst_size_context *context = node->context;
423   struct   dst_diode_mix__context *context = node->context;
405424
406   double   max = 0;
425   double   val, max = 0;
407426   int      addr;
408427
409428   for (addr = 0; addr < context->size; addr++)
410429   {
411      if (DST_DIODE_MIX__INP(addr) > max) max = DST_DIODE_MIX__INP(addr);
430      val = DST_DIODE_MIX__INP(addr) - context->v_junction[addr];
431      if (val > max) max = val;
412432   }
413   node->output[0] = max - DST_DIODE_MIX__VJUNC;
414   if (node->output[0] < 0) node->output[0] = 0;
433   if (max < 0) max = 0;
434   node->output[0] = max;
415435}
416436
417437static void dst_diode_mix_reset(node_description *node)
418438{
419   struct dst_size_context *context = node->context;
439   const  double *info = node->custom;
440   struct dst_diode_mix__context *context = node->context;
420441
442   int      addr;
443
421444   context->size = node->active_inputs - DST_DIODE_MIX_INP_OFFSET;
445   assert(context->size <= 8);
422446
447   for (addr = 0; addr < context->size; addr++)
448   {
449      if (info == NULL)
450      {
451         /* setup default junction voltage */
452         context->v_junction[addr] = 0.5;
453      }
454      else
455      {
456         /* use supplied junction voltage */
457         context->v_junction[addr] = *info++;
458      }
459   }
423460   dst_diode_mix_step(node);
424461}
425462
r3514r3515
932969      node->output[0] = table[addr];
933970}
934971
972
935973/************************************************************************
936974 *
937975 * DST_MIXER  - Mixer/Gain stage
r3514r3515
9951033   int      bit, connected;
9961034
9971035   /* put commonly used stuff in local variables for speed */
998   double   value;
999   double   dt = discrete_current_context->sample_rate;
10001036   int      r_node_bit_flag = context->r_node_bit_flag;
1037   int      c_bit_flag = context->c_bit_flag;
1038   int      bit_mask = 1;
10011039   int      has_rF = (info->rF != 0);
10021040   int      type = context->type;
10031041   double   v_ref = info->vRef;
r3514r3515
10181056            connected = 1;
10191057            vTemp     = DST_MIXER__IN(bit);
10201058
1021            if (r_node_bit_flag & (1 << bit))
1059            /* is there a resistor? */
1060            if (r_node_bit_flag & bit_mask)
10221061            {
10231062               /* a node has the possibility of being disconnected from the circuit. */
1024               value = *context->r_node[bit];
1025               if (value == 0)
1063               if (*context->r_node[bit] == 0)
10261064                  connected = 0;
10271065               else
10281066               {
10291067                  /* value currently holds resistance */
1030                  rTemp   += value;
1068                  rTemp   += *context->r_node[bit];
10311069                  r_total += 1.0 / rTemp;
1032                  value = info->c[bit];
1033                  if (value != 0)
1070                  /* is there a capacitor? */
1071                  if (c_bit_flag & bit_mask)
10341072                  {
10351073                     switch (type)
10361074                     {
r3514r3515
10491087                           rTemp2 = rTemp + rI;
10501088                           break;
10511089                     }
1052                     /* Re-calculate exponent if resistor is a node */
1053                     /* value currently holds capacitance */
1054                     context->exponent_rc[bit] =  1.0 - exp(-1.0 / (rTemp2 * value * dt));
1090                     /* Re-calculate exponent if resistor is a node and has changed value */
1091                     if (*context->r_node[bit] != context->r_last[bit])
1092                     {
1093                        context->exponent_rc[bit] =  RC_CHARGE_EXP(rTemp2 * info->c[bit]);
1094                        context->r_last[bit] = *context->r_node[bit];
1095                     }
10551096                  }
10561097               }
10571098            }
10581099
10591100            if (connected)
10601101            {
1061               if (info->c[bit] != 0)
1102               /* is there a capacitor? */
1103               if (c_bit_flag & bit_mask)
10621104               {
10631105                  /* do input high pass filtering if needed. */
10641106                  context->v_cap[bit] += (vTemp - v_ref - context->v_cap[bit]) * context->exponent_rc[bit];
r3514r3515
10661108               }
10671109               i += ((type == DISC_MIXER_IS_OP_AMP) ? v_ref - vTemp : vTemp) / rTemp;
10681110            }
1111         bit_mask = bit_mask << 1;
10691112         }
10701113      }
10711114      else
r3514r3515
10751118         {
10761119            vTemp = DST_MIXER__IN(bit);
10771120
1078            if (info->c[bit] != 0)
1121            if (c_bit_flag & (1 << bit))
10791122            {
10801123               /* do input high pass filtering if needed. */
10811124               context->v_cap[bit] += (vTemp - v_ref - context->v_cap[bit]) * context->exponent_rc[bit];
r3514r3515
11031146         if (r_node_bit_flag != 0)
11041147         {
11051148            /* Re-calculate exponent if resistor nodes are used */
1106            context->exponent_c_f =  1.0 - exp(-1.0 / (r_total * info->cF  * dt));
1149            context->exponent_c_f =  RC_CHARGE_EXP(r_total * info->cF);
11071150         }
11081151         context->v_cap_f += (v - v_ref - context->v_cap_f) * context->exponent_c_f;
11091152         v = context->v_cap_f;
r3514r3515
11441187      }
11451188      else
11461189         context->r_node[bit] = NULL;
1190
1191      /* flag any caps */
1192      if (info->c[bit] != 0)
1193         context->c_bit_flag |= 1 << bit;
11471194   }
11481195
11491196   context->size = node->active_inputs - 1;
r3514r3515
11931240               break;
11941241         }
11951242         /* Setup filter constants */
1196         context->exponent_rc[bit] = -1.0 / (rTemp * info->c[bit]  * discrete_current_context->sample_rate);
1197         context->exponent_rc[bit] =  1.0 - exp(context->exponent_rc[bit]);
1243         context->exponent_rc[bit] = RC_CHARGE_EXP(rTemp * info->c[bit]);
11981244      }
11991245   }
12001246
r3514r3515
12091255   if (info->cF != 0)
12101256   {
12111257      /* Setup filter constants */
1212      context->exponent_c_f = -1.0 / (((info->type == DISC_MIXER_IS_OP_AMP) ? info->rF : (1.0 / context->r_total))* info->cF  * discrete_current_context->sample_rate);
1213      context->exponent_c_f =  1.0 - exp(context->exponent_c_f);
1258      context->exponent_c_f = RC_CHARGE_EXP(((info->type == DISC_MIXER_IS_OP_AMP) ? info->rF : (1.0 / context->r_total)) * info->cF);
12141259   }
12151260
12161261   context->v_cap_amp      = 0;
r3514r3515
12181263   if (info->cAmp != 0)
12191264   {
12201265      /* Setup filter constants */
1221      /* We will use 100000 ohms as an average final stage impedance. */
1266      /* We will use 100k ohms as an average final stage impedance. */
12221267      /* Your amp/speaker system will have more effect on incorrect filtering then any value used here. */
1223      context->exponent_c_amp = -1.0 / (100000 * info->cAmp  * discrete_current_context->sample_rate);
1224      context->exponent_c_amp =  1.0 - exp(context->exponent_c_amp);
1268      context->exponent_c_amp = RC_CHARGE_EXP(RES_K(100) * info->cAmp);
12251269   }
12261270
12271271   if (context->type == DISC_MIXER_IS_OP_AMP_WITH_RI) context->gain = info->rF / info->rI;
r3514r3515
17701814      if (context->has_r4)
17711815      {
17721816         /* exponential charge */
1773         context->exponent = -1.0 / (info->r4 * info->c  * discrete_current_context->sample_rate);
1774         context->exponent =  1.0 - exp(context->exponent);
1817         context->exponent = RC_CHARGE_EXP(info->r4 * info->c);
17751818      }
17761819      else
17771820         /* linear charge */
r3514r3515
18401883   const  discrete_op_amp_1sht_info *info    = node->custom;
18411884   struct dst_op_amp_1sht_context   *context = node->context;
18421885
1843   context->exponent1c = -1.0 / ((1.0 / (1.0 / info->r3 + 1.0 / info->r4)) * info->c1  * discrete_current_context->sample_rate);
1844   context->exponent1c =  1.0 - exp(context->exponent1c);
1845   context->exponent1d = -1.0 / (info->r4 * info->c1  * discrete_current_context->sample_rate);
1846   context->exponent1d =  1.0 - exp(context->exponent1d);
1847   context->exponent2  = -1.0 / (info->r2 * info->c2  * discrete_current_context->sample_rate);
1848   context->exponent2  =  1.0 - exp(context->exponent2);
1886   context->exponent1c = RC_CHARGE_EXP(RES_2_PARALLEL(info->r3, info->r4) * info->c1);
1887   context->exponent1d = RC_CHARGE_EXP(info->r4 * info->c1);
1888   context->exponent2  = RC_CHARGE_EXP(info->r2 * info->c2);
18491889   context->i_fixed  = (info->vP - OP_AMP_NORTON_VBE) / info->r1;
18501890   context->v_cap1   = context->v_cap2 = 0;
18511891   context->v_max    = info->vP - OP_AMP_NORTON_VBE;
r3514r3515
19632003   context->v_out_max = info->vP - OP_AMP_NORTON_VBE;
19642004   /* This is probably overkill because R5 is usually much lower then r6 or r7,
19652005     * but it is better to play it safe. */
1966   context->v_trig[0] = (info->v1 - 0.6) * (info->r6 / (info->r6 + info->r5));
1967   context->v_trig[1] = (info->v1 - 0.6 - OP_AMP_NORTON_VBE) * (context->r67 / (context->r67 + info->r5)) + OP_AMP_NORTON_VBE;
2006   context->v_trig[0] = (info->v1 - 0.6) * RES_VOLTAGE_DIVIDER(info->r5, info->r6);
2007   context->v_trig[1] = (info->v1 - 0.6 - OP_AMP_NORTON_VBE) * RES_VOLTAGE_DIVIDER(info->r5, context->r67) + OP_AMP_NORTON_VBE;
19682008   context->i_fixed   = context->v_out_max / info->r1;
19692009
19702010   context->v_cap1 = 0;
19712011   /* Charge rate thru r5 */
19722012   /* There can be a different charge rates depending on function F3. */
1973   context->exponent_c[0] = -1.0 / ((1.0 / (1.0 / info->r5 + 1.0 / info->r6)) * info->c1 * discrete_current_context->sample_rate);
1974   context->exponent_c[0] =  1.0 - exp(context->exponent_c[0]);
1975   context->exponent_c[1] = -1.0 / ((1.0 / (1.0 / info->r5 + 1.0 / context->r67)) * info->c1 * discrete_current_context->sample_rate);
1976   context->exponent_c[1] =  1.0 - exp(context->exponent_c[1]);
2013   context->exponent_c[0] = RC_CHARGE_EXP(RES_2_PARALLEL(info->r5, info->r6) * info->c1);
2014   context->exponent_c[1] = RC_CHARGE_EXP(RES_2_PARALLEL(info->r5, context->r67) * info->c1);
19772015   /* Discharge rate thru r6 + r7 */
1978   context->exponent_d[1] = -1.0 / (context->r67 * info->c1 * discrete_current_context->sample_rate);
1979   context->exponent_d[1] =  1.0 - exp(context->exponent_d[1]);
2016   context->exponent_d[1] = RC_CHARGE_EXP(context->r67 * info->c1);
19802017   /* Discharge rate thru r6 */
19812018   if (info->r6 != 0)
19822019   {
1983      context->exponent_d[0] = -1.0 / (info->r6 * info->c1 * discrete_current_context->sample_rate);
1984      context->exponent_d[0] =  1.0 - exp(context->exponent_d[0]);
2020      context->exponent_d[0] = RC_CHARGE_EXP(info->r6 * info->c1);
19852021   }
19862022   context->v_cap2       = 0;
1987   context->v_trig2      = (info->v2 - 0.6 - OP_AMP_NORTON_VBE) * (info->r9 / (info->r8 + info->r9));
1988   context->exponent2[0] = -1.0 / (info->r9 * info->c2 * discrete_current_context->sample_rate);
1989   context->exponent2[0] =  1.0 - exp(context->exponent2[0]);
1990   context->exponent2[1] = -1.0 / ((1.0 / (1.0 / info->r8 + 1.0 / info->r9)) * info->c2 * discrete_current_context->sample_rate);
1991   context->exponent2[1] =  1.0 - exp(context->exponent2[1]);
2023   context->v_trig2      = (info->v2 - 0.6 - OP_AMP_NORTON_VBE) * RES_VOLTAGE_DIVIDER(info->r8, info->r9);
2024   context->exponent2[0] = RC_CHARGE_EXP(info->r9 * info->c2);
2025   context->exponent2[1] = RC_CHARGE_EXP(RES_2_PARALLEL(info->r8, info->r9) * info->c2);
19922026   context->v_cap3  = 0;
1993   context->v_trig3 = (info->v3 - 0.6 - OP_AMP_NORTON_VBE) * (info->r11 / (info->r10 + info->r11));
1994   context->exponent3[0] = -1.0 / (info->r11 * info->c3 * discrete_current_context->sample_rate);
1995   context->exponent3[0] =  1.0 - exp(context->exponent3[0]);
1996   context->exponent3[1] = -1.0 / ((1.0 / (1.0 / info->r10 + 1.0 / info->r11)) * info->c3 * discrete_current_context->sample_rate);
1997   context->exponent3[1] =  1.0 - exp(context->exponent3[1]);
2027   context->v_trig3 = (info->v3 - 0.6 - OP_AMP_NORTON_VBE) * RES_VOLTAGE_DIVIDER(info->r10, info->r11);
2028   context->exponent3[0] = RC_CHARGE_EXP(info->r11 * info->c3);
2029   context->exponent3[1] = RC_CHARGE_EXP(RES_2_PARALLEL(info->r10, info->r11) * info->c3);
19982030
19992031   dst_tvca_op_amp_step(node);
20002032}
src/emu/sound/discrete.c
r3514r3515
5757 *
5858 *************************************/
5959
60struct _discrete_info
61{
62   /* emulation info */
63   int      sndindex;
64   int      sample_rate;
65   double   sample_time;
60discrete_info *discrete_current_context = NULL;
6661
67   /* internal node tracking */
68   int node_count;
69   node_description **running_order;
70   node_description **indexed_node;
71   node_description *node_list;
7262
73   /* the input streams */
74   int discrete_input_streams;
75   stream_sample_t *input_stream_data[DISCRETE_MAX_OUTPUTS];
7663
77   /* output node tracking */
78   int discrete_outputs;
79   node_description *output_node[DISCRETE_MAX_OUTPUTS];
80
81   /* the output stream */
82   sound_stream *discrete_stream;
83
84   /* debugging statics */
85   FILE *disclogfile;
86
87   /* csvlog tracking */
88   int num_csvlogs;
89   FILE *disc_csv_file[DISCRETE_MAX_CSVLOGS];
90   node_description *csvlog_node[DISCRETE_MAX_CSVLOGS];
91   INT64 sample_num;
92
93   /* wavelog tracking */
94   int num_wavelogs;
95   wav_file *disc_wav_file[DISCRETE_MAX_WAVELOGS];
96   node_description *wavelog_node[DISCRETE_MAX_WAVELOGS];
97};
98typedef struct _discrete_info discrete_info;
99
100static discrete_info *discrete_current_context;
101
102
103
10464/*************************************
10565 *
10666 *  Prototypes
r3514r3515
218178   { DST_ASWITCH     ,"DST_ASWITCH"     , 1 ,0                                      ,NULL                  ,dst_aswitch_step     },
219179   { DST_TRANSFORM   ,"DST_TRANSFORM"   , 1 ,0                                      ,NULL                  ,dst_transform_step   },
220180   /* Component specific */
221   { DST_COMP_ADDER  ,"DST_COMP_ADDER"  , 1 ,0                                      ,NULL                  ,dst_comp_adder_step  },
181   { DST_COMP_ADDER  ,"DST_COMP_ADDER"  , 1 ,sizeof(struct dst_comp_adder_context)  ,dst_comp_adder_reset  ,dst_comp_adder_step  },
222182   { DST_DAC_R1      ,"DST_DAC_R1"      , 1 ,sizeof(struct dst_dac_r1_context)      ,dst_dac_r1_reset      ,dst_dac_r1_step      },
223   { DST_DIODE_MIX   ,"DST_DIODE_MIX"   , 1 ,sizeof(struct dst_size_context)        ,dst_diode_mix_reset   ,dst_diode_mix_step   },
183   { DST_DIODE_MIX   ,"DST_DIODE_MIX"   , 1 ,sizeof(struct dst_diode_mix__context)  ,dst_diode_mix_reset   ,dst_diode_mix_step   },
224184   { DST_INTEGRATE   ,"DST_INTEGRATE"   , 1 ,sizeof(struct dst_integrate_context)   ,dst_integrate_reset   ,dst_integrate_step   },
225185   { DST_MIXER       ,"DST_MIXER"       , 1 ,sizeof(struct dst_mixer_context)       ,dst_mixer_reset       ,dst_mixer_step       },
226186   { DST_OP_AMP      ,"DST_OP_AMP"      , 1 ,sizeof(struct dst_op_amp_context)      ,dst_op_amp_reset      ,dst_op_amp_step      },
r3514r3515
304264   else
305265      info->sample_rate = Machine->sample_rate;
306266   info->sample_time = 1.0 / info->sample_rate;
267   info->neg_sample_time = - info->sample_time;
307268
308269   /* create the logfile */
309270   sprintf(name, "discrete%d.log", info->sndindex);
src/emu/sound/discrete.h
r3514r3515
238238 * DISCRETE_TRANSFORM4(NODE,INP0,INP1,INP2,INP3,FUNCT)
239239 * DISCRETE_TRANSFORM5(NODE,INP0,INP1,INP2,INP3,INP4,FUNCT)
240240 *
241 * DISCRETE_COMP_ADDER(NODE,ENAB,DATA,TABLE)
241 * DISCRETE_COMP_ADDER(NODE,DATA,TABLE)
242242 * DISCRETE_DAC_R1(NODE,ENAB,DATA,VDATA,LADDER)
243 * DISCRETE_DIODE_MIXER2(NODE,VJUNC,IN0,IN1)
244 * DISCRETE_DIODE_MIXER3(NODE,VJUNC,IN0,IN1,IN2)
245 * DISCRETE_DIODE_MIXER4(NODE,VJUNC,IN0,IN1,IN2,IN3)
243 * DISCRETE_DIODE_MIXER2(NODE,IN0,IN1,TABLE)
244 * DISCRETE_DIODE_MIXER3(NODE,IN0,IN1,IN2,TABLE)
245 * DISCRETE_DIODE_MIXER4(NODE,IN0,IN1,IN2,IN3,TABLE)
246246 * DISCRETE_INTEGRATE(NODE,TRG0,TRG1,INFO)
247247 * DISCRETE_MIXER2(NODE,ENAB,IN0,IN1,INFO)
248248 * DISCRETE_MIXER3(NODE,ENAB,IN0,IN1,IN2,INFO)
r3514r3515
300300 * DISCRETE_555_VCO1_CV(NODE,RESET,VIN,CTRLV,OPTIONS)
301301 * DISCRETE_566(NODE,ENAB,VMOD,R,C,OPTIONS)
302302 *
303 * DISCRETE_CUSTOM1(NODE,ENAB,IN0,INFO)
304 * DISCRETE_CUSTOM2(NODE,ENAB,IN0,IN1,INFO)
305 * DISCRETE_CUSTOM3(NODE,ENAB,IN0,IN1,IN2,INFO)
306 * DISCRETE_CUSTOM4(NODE,ENAB,IN0,IN1,IN2,IN3,INFO)
307 * DISCRETE_CUSTOM5(NODE,ENAB,IN0,IN1,IN2,IN3,IN4,INFO)
303 * DISCRETE_CUSTOM1(NODE,IN0,INFO)
304 * DISCRETE_CUSTOM2(NODE,IN0,IN1,INFO)
305 * DISCRETE_CUSTOM3(NODE,IN0,IN1,IN2,INFO)
306 * DISCRETE_CUSTOM4(NODE,IN0,IN1,IN2,IN3,INFO)
307 * DISCRETE_CUSTOM5(NODE,IN0,IN1,IN2,IN3,IN4,INFO)
308 * DISCRETE_CUSTOM6(NODE,IN0,IN1,IN2,IN3,IN4,IN5,INFO)
309 * DISCRETE_CUSTOM7(NODE,IN0,IN1,IN2,IN3,IN4,IN5,IN6,INFO)
310 * DISCRETE_CUSTOM8(NODE,IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7,INFO)
311 * DISCRETE_CUSTOM9(NODE,IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7,IN8,INFO)
308312 *
309313 * DISCRETE_CSVLOG1(NODE1)
310314 * DISCRETE_CSVLOG2(NODE1,NODE2)
r3514r3515
16831687 *  Declaration syntax
16841688 *
16851689 *     DISCRETE_COMP_ADDER(name of node,
1686 *                         enable node or static value,
16871690 *                         data node (static value is useless),
16881691 *                         address of discrete_comp_adder_table structure)
16891692 *
16901693 *     discrete_comp_adder_table = {type, cDefault, length, c{}}
1694 *          note: length can be a maximum of 8
16911695 *
16921696 *  Circuit Types:
16931697 *     DISC_COMP_P_CAPACITOR - parallel capacitors
r3514r3515
17601764 *  Declaration syntax
17611765 *
17621766 *     DISCRETE_DIODE_MIXERx(name of node,
1763 *         (x = 2/3/4)       voltage drop of the diode junction (static value),
1764 *                           input 0 node,
1767 *         (x = 2/3/4)       input 0 node,
17651768 *                           input 1 node,
1766 *                           ...)
1769 *                           ...,
1770 *                           address of v_junction table)
17671771 *
1772 *    v_junction table can be set to NULL if you want all diodes to
1773 *                     default to a 0.5V drop.  Otherwise use a
1774 *                     table of doubles to specify juntion voltages.
1775 *
17681776 * EXAMPLES: see dkong
17691777 *
17701778 ***********************************************************************
r3514r3515
26812689 *                          enable,
26822690 *                          input node (or value),
26832691 *                          switch node (or value),
2684 *                          R in Ohms,
2685 *                          C1 in Farads,
2686 *                          C2 in Farads,
2687 *                          C3 in Farads,
2688 *                          C4 in Farads)
2692 *                          R in Ohms (static value),
2693 *                          C1 in Farads (static value),
2694 *                          C2 in Farads (static value),
2695 *                          C3 in Farads (static value),
2696 *                          C4 in Farads (static value))
26892697 *
26902698 *     This is a typical filter circuit in circusc or scramble.
26912699 *     Switches are usually CD4066 with a "open" resistance of
r3514r3515
30953103 *     DISC_566_OUT_TRIANGLE - Pin 4 Triangle Wave Output
30963104 *     DISC_566_OUT_LOGIC    - Internal Flip/Flop Output
30973105 *
3106 * EXAMPLES: see Starship 1
3107 *
30983108 ***********************************************************************
30993109 *
31003110 * DISCRETE_74LS624 - VCO.
r3514r3515
31423152 ***********************************************************************
31433153 *
31443154 * DISCRETE_CUSTOMx - Link to custom code
3145 *     where x = 1 to 5
3155 *     where x = 1 to 9
31463156 *
31473157 *  Declaration syntax
31483158 *
31493159 *     DISCRETE_CUSTOMx(name of node,
3150 *                      enable node or static value,
31513160 *                      input 0 node or static value, ...)
31523161 *
31533162 *     discrete_custom_info = {reset, step, contextsize, custom}
31543163 *                             reset  = address called to reset a node after creation or system reset
31553164 *                             step   = address called to execute one time delta of output update
31563165 *                             contextsize = size of context to create
3157 *                             custom = address of specific initialisation data
3166 *                             custom = address of specific initialization data
31583167 *
3168 * EXAMPLES: see Donkey Kong
3169 *
31593170 ***********************************************************************
31603171 =======================================================================
31613172 * Debugging modules.
r3514r3515
32363247 *
32373248 ************************************************************************/
32383249
3250#include "streams.h"
3251#include "wavwrite.h"
32393252
3253
3254
32403255/*************************************
32413256 *
3257 *  macros
3258 *  see also: emu\machine\rescap.h
3259 *
3260 *************************************/
3261
3262/* calculate charge exponent using discrete sample time */
3263#define RC_CHARGE_EXP(rc)            (1.0 - exp(discrete_current_context->neg_sample_time / (rc)))
3264/* calculate charge exponent using given sample time */
3265#define RC_CHARGE_EXP_DT(rc, dt)      (1.0 - exp(-(dt) / (rc)))
3266#define RC_CHARGE_NEG_EXP_DT(rc, dt)   (1.0 - exp((dt) / (rc)))
3267
3268/* calculate discharge exponent using discrete sample time */
3269#define RC_DISCHARGE_EXP(rc)         (exp(discrete_current_context->neg_sample_time / (rc)))
3270/* calculate discharge exponent using given sample time */
3271#define RC_DISCHARGE_EXP_DT(rc, dt)      (exp(-(dt) / (rc)))
3272#define RC_DISCHARGE_NEG_EXP_DT(rc, dt)   (exp((dt) / (rc)))
3273
3274
3275/*************************************
3276 *
32423277 *  Profiling Nodes
32433278 *
32443279 *************************************/
r3514r3515
35213556};
35223557
35233558
3559/*************************************
3560 *
3561 *  Core runtime info
3562 *
3563 *  this structure is exposed mainly
3564 *  to read the sample rate info
3565 *  and possibly context info
3566 *
3567 *************************************/
35243568
3569typedef struct _discrete_info discrete_info;
3570struct _discrete_info
3571{
3572   /* emulation info */
3573   int      sndindex;
3574   int      sample_rate;
3575   double   sample_time;
3576   double   neg_sample_time;
3577
3578   /* internal node tracking */
3579   int node_count;
3580   node_description **running_order;
3581   node_description **indexed_node;
3582   node_description *node_list;
3583
3584   /* the input streams */
3585   int discrete_input_streams;
3586   stream_sample_t *input_stream_data[DISCRETE_MAX_OUTPUTS];
3587
3588   /* output node tracking */
3589   int discrete_outputs;
3590   node_description *output_node[DISCRETE_MAX_OUTPUTS];
3591
3592   /* the output stream */
3593   sound_stream *discrete_stream;
3594
3595   /* debugging statics */
3596   FILE *disclogfile;
3597
3598   /* csvlog tracking */
3599   int num_csvlogs;
3600   FILE *disc_csv_file[DISCRETE_MAX_CSVLOGS];
3601   node_description *csvlog_node[DISCRETE_MAX_CSVLOGS];
3602   INT64 sample_num;
3603
3604   /* wavelog tracking */
3605   int num_wavelogs;
3606   wav_file *disc_wav_file[DISCRETE_MAX_WAVELOGS];
3607   node_description *wavelog_node[DISCRETE_MAX_WAVELOGS];
3608};
3609
3610
35253611/*************************************
35263612 *
35273613 *  Node-specific struct types
r3514r3515
41024188#define DISCRETE_TRANSFORM4(NODE,INP0,INP1,INP2,INP3,FUNCT)             { NODE, DST_TRANSFORM   , 4, { INP0,INP1,INP2,INP3 }, { INP0,INP1,INP2,INP3 }, FUNCT, "DISCRETE_TRANSFORM4" },
41034189#define DISCRETE_TRANSFORM5(NODE,INP0,INP1,INP2,INP3,INP4,FUNCT)        { NODE, DST_TRANSFORM   , 5, { INP0,INP1,INP2,INP3,INP4 }, { INP0,INP1,INP2,INP3,INP4 }, FUNCT, "DISCRETE_TRANSFORM5" },
41044190/* Component specific */
4105#define DISCRETE_COMP_ADDER(NODE,ENAB,DATA,TABLE)                       { NODE, DST_COMP_ADDER  , 2, { ENAB,DATA }, { ENAB,DATA }, TABLE, "DISCRETE_COMP_ADDER" },
4191#define DISCRETE_COMP_ADDER(NODE,DATA,TABLE)                            { NODE, DST_COMP_ADDER  , 1, { DATA }, { DATA }, TABLE, "DISCRETE_COMP_ADDER" },
41064192#define DISCRETE_DAC_R1(NODE,ENAB,DATA,VDATA,LADDER)                    { NODE, DST_DAC_R1      , 3, { ENAB,DATA,VDATA }, { ENAB,DATA,VDATA }, LADDER, "DISCRETE_DAC_R1" },
4107#define DISCRETE_DIODE_MIXER2(NODE,VJUNC,IN0,IN1)                       { NODE, DST_DIODE_MIX   , 3, { NODE_NC,IN0,IN1 }, { VJUNC,IN0,IN1 }, NULL, "DISCRETE_DIODE_MIXER2" },
4108#define DISCRETE_DIODE_MIXER3(NODE,VJUNC,IN0,IN1,IN2)                   { NODE, DST_DIODE_MIX   , 4, { NODE_NC,IN0,IN1,IN2 }, { VJUNC,IN0,IN1,IN2 }, INFO, "DISCRETE_DIODE_MIXER3" },
4109#define DISCRETE_DIODE_MIXER4(NODE,VJUNC,IN0,IN1,IN2,IN3)               { NODE, DST_DIODE_MIX   , 5, { NODE_NC,IN0,IN1,IN2,IN3 }, { VJUNC,IN0,IN1,IN2,IN3 }, INFO, "DISCRETE_DIODE_MIXER4" },
4193#define DISCRETE_DIODE_MIXER2(NODE,IN0,IN1,TABLE)                       { NODE, DST_DIODE_MIX   , 3, { IN0,IN1 }, { IN0,IN1 }, TABLE, "DISCRETE_DIODE_MIXER2" },
4194#define DISCRETE_DIODE_MIXER3(NODE,IN0,IN1,IN2,TABLE)                   { NODE, DST_DIODE_MIX   , 4, { IN0,IN1,IN2 }, { IN0,IN1,IN2 }, TABLE, "DISCRETE_DIODE_MIXER3" },
4195#define DISCRETE_DIODE_MIXER4(NODE,IN0,IN1,IN2,IN3,TABLE)               { NODE, DST_DIODE_MIX   , 5, { IN0,IN1,IN2,IN3 }, { IN0,IN1,IN2,IN3 }, TABLE, "DISCRETE_DIODE_MIXER4" },
41104196#define DISCRETE_INTEGRATE(NODE,TRG0,TRG1,INFO)                         { NODE, DST_INTEGRATE   , 2, { TRG0,TRG1 }, { TRG0,TRG1 }, INFO, "DISCRETE_INTEGRATE" },
41114197#define DISCRETE_MIXER2(NODE,ENAB,IN0,IN1,INFO)                         { NODE, DST_MIXER       , 3, { ENAB,IN0,IN1 }, { ENAB,IN0,IN1 }, INFO, "DISCRETE_MIXER2" },
41124198#define DISCRETE_MIXER3(NODE,ENAB,IN0,IN1,IN2,INFO)                     { NODE, DST_MIXER       , 4, { ENAB,IN0,IN1,IN2 }, { ENAB,IN0,IN1,IN2 }, INFO, "DISCRETE_MIXER3" },
r3514r3515
41364222#define DISCRETE_RCDISC5(NODE,ENAB,INP0,RVAL,CVAL)                      { NODE, DST_RCDISC5     , 4, { ENAB,INP0,NODE_NC,NODE_NC }, { ENAB,INP0,RVAL,CVAL }, NULL, "DISCRETE_RCDISC5" },
41374223#define DISCRETE_RCDISC_MODULATED(NODE,INP0,INP1,RVAL0,RVAL1,RVAL2,RVAL3,CVAL,VP)   { NODE, DST_RCDISC_MOD, 8, { INP0,INP1,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC }, { INP0,INP1,RVAL0,RVAL1,RVAL2,RVAL3,CVAL,VP }, NULL, "DISCRETE_RCDISC_MODULATED" },
41384224#define DISCRETE_RCFILTER(NODE,ENAB,INP0,RVAL,CVAL)                     { NODE, DST_RCFILTER    , 4, { ENAB,INP0,NODE_NC,NODE_NC }, { ENAB,INP0,RVAL,CVAL }, NULL, "DISCRETE_RCFILTER" },
4139#define DISCRETE_RCFILTER_SW(NODE,ENAB,INP0,SW,RVAL,CVAL1,CVAL2,CVAL3,CVAL4) { NODE, DST_RCFILTER_SW, 8, { ENAB,INP0,SW,RVAL,CVAL1,CVAL2,CVAL3,CVAL4 }, { ENAB,INP0,SW,RVAL,CVAL1,CVAL2,CVAL3,CVAL4 }, NULL, "DISCRETE_RCFILTER_SW" },
4225#define DISCRETE_RCFILTER_SW(NODE,ENAB,INP0,SW,RVAL,CVAL1,CVAL2,CVAL3,CVAL4) { NODE, DST_RCFILTER_SW, 8, { ENAB,INP0,SW,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC }, { ENAB,INP0,SW,RVAL,CVAL1,CVAL2,CVAL3,CVAL4 }, NULL, "DISCRETE_RCFILTER_SW" },
41404226#define DISCRETE_RCFILTER_VREF(NODE,ENAB,INP0,RVAL,CVAL,VREF)           { NODE, DST_RCFILTER    , 5, { ENAB,INP0,NODE_NC,NODE_NC,NODE_NC }, { ENAB,INP0,RVAL,CVAL,VREF }, NULL, "DISCRETE_RCFILTER_VREF" },
41414227#define DISCRETE_RCINTEGRATE(NODE,INP0,RVAL0,RVAL1,RVAL2,CVAL,vP,TYPE)  { NODE, DST_RCINTEGRATE , 7, { INP0,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC }, { INP0,RVAL0,RVAL1,RVAL2,CVAL,vP,TYPE }, NULL, "DISCRETE_RCINTEGRATE" },
41424228/* For testing - seem to be buggered.  Use versions not ending in N. */
r3514r3515
41464232
41474233/* from disc_dev.c */
41484234/* generic modules */
4149#define DISCRETE_CUSTOM1(NODE,ENAB,IN0,INFO)                            { NODE, DST_CUSTOM      , 2, { ENAB,IN0 }, { ENAB,IN0 }, INFO, "DISCRETE_CUSTOM1" },
4150#define DISCRETE_CUSTOM2(NODE,ENAB,IN0,IN1,INFO)                        { NODE, DST_CUSTOM      , 3, { ENAB,IN0,IN1 }, { ENAB,IN0,IN1 }, INFO, "DISCRETE_CUSTOM2" },
4151#define DISCRETE_CUSTOM3(NODE,ENAB,IN0,IN1,IN2,INFO)                    { NODE, DST_CUSTOM      , 4, { ENAB,IN0,IN1,IN2 }, { ENAB,IN0,IN1,IN2 }, INFO, "DISCRETE_CUSTOM3" },
4152#define DISCRETE_CUSTOM4(NODE,ENAB,IN0,IN1,IN2,IN3,INFO)                { NODE, DST_CUSTOM      , 5, { ENAB,IN0,IN1,IN2,IN3 }, { ENAB,IN0,IN1,IN2,IN3 }, INFO, "DISCRETE_CUSTOM4" },
4153#define DISCRETE_CUSTOM5(NODE,ENAB,IN0,IN1,IN2,IN3,IN4,INFO)            { NODE, DST_CUSTOM      , 6, { ENAB,IN0,IN1,IN2,IN3,IN4 }, { ENAB,IN0,IN1,IN2,IN3,IN4 }, INFO, "DISCRETE_CUSTOM5" },
4235#define DISCRETE_CUSTOM1(NODE,IN0,INFO)                                 { NODE, DST_CUSTOM      , 1, { IN0 }, { IN0 }, INFO, "DISCRETE_CUSTOM1" },
4236#define DISCRETE_CUSTOM2(NODE,IN0,IN1,INFO)                             { NODE, DST_CUSTOM      , 2, { IN0,IN1 }, { IN0,IN1 }, INFO, "DISCRETE_CUSTOM2" },
4237#define DISCRETE_CUSTOM3(NODE,IN0,IN1,IN2,INFO)                         { NODE, DST_CUSTOM      , 3, { IN0,IN1,IN2 }, { IN0,IN1,IN2 }, INFO, "DISCRETE_CUSTOM3" },
4238#define DISCRETE_CUSTOM4(NODE,IN0,IN1,IN2,IN3,INFO)                     { NODE, DST_CUSTOM      , 4, { IN0,IN1,IN2,IN3 }, { IN0,IN1,IN2,IN3 }, INFO, "DISCRETE_CUSTOM4" },
4239#define DISCRETE_CUSTOM5(NODE,IN0,IN1,IN2,IN3,IN4,INFO)                 { NODE, DST_CUSTOM      , 5, { IN0,IN1,IN2,IN3,IN4 }, { IN0,IN1,IN2,IN3,IN4 }, INFO, "DISCRETE_CUSTOM5" },
4240#define DISCRETE_CUSTOM6(NODE,IN0,IN1,IN2,IN3,IN4,IN5,INFO)             { NODE, DST_CUSTOM      , 6, { IN0,IN1,IN2,IN3,IN4,IN5 }, { IN0,IN1,IN2,IN3,IN4,IN5 }, INFO, "DISCRETE_CUSTOM6" },
4241#define DISCRETE_CUSTOM7(NODE,IN0,IN1,IN2,IN3,IN4,IN5,IN6,INFO)         { NODE, DST_CUSTOM      , 7, { IN0,IN1,IN2,IN3,IN4,IN5,IN6 }, { IN0,IN1,IN2,IN3,IN4,IN5,IN6 }, INFO, "DISCRETE_CUSTOM7" },
4242#define DISCRETE_CUSTOM8(NODE,IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7,INFO)     { NODE, DST_CUSTOM      , 8, { IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7 }, { IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7 }, INFO, "DISCRETE_CUSTOM8" },
4243#define DISCRETE_CUSTOM9(NODE,IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7,IN8,INFO) { NODE, DST_CUSTOM      , 9, { IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7,IN8 }, { IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7,IN8 }, INFO, "DISCRETE_CUSTOM9" },
41544244/* Component specific */
41554245#define DISCRETE_555_ASTABLE(NODE,RESET,R1,R2,C,OPTIONS)                { NODE, DSD_555_ASTBL   , 5, { RESET,R1,R2,C,NODE_NC }, { RESET,R1,R2,C,-1 }, OPTIONS, "DISCRETE_555_ASTABLE" },
41564246#define DISCRETE_555_ASTABLE_CV(NODE,RESET,R1,R2,C,CTRLV,OPTIONS)       { NODE, DSD_555_ASTBL   , 5, { RESET,R1,R2,C,CTRLV }, { RESET,R1,R2,C,CTRLV }, OPTIONS, "DISCRETE_555_ASTABLE_CV" },
r3514r3515
41824272 *
41834273 *************************************/
41844274
4275extern discrete_info *discrete_current_context;
4276
41854277node_description *discrete_find_node(void *chip, int node);
41864278
41874279WRITE8_HANDLER(discrete_sound_w);
4188READ8_HANDLER(discrete_sound_r);
4280READ8_HANDLER( discrete_sound_r);
41894281
41904282#endif /* __DISCRETE_H__ */
src/emu/sound/fm.c
r3514r3515
77** Copyright Jarek Burczynski (bujar at mame dot net)
88** Copyright Tatsuyuki Satoh , MultiArcadeMachineEmulator development
99**
10** Version 1.4 (final beta)
10** Version 1.4.2 (final beta)
1111**
1212*/
1313
1414/*
1515** History:
1616**
17** 2006-2008 Eke-Eke (Genesis Plus port), MAME backport by R. Belmont
17** 2006-2008 Eke-Eke (Genesis Plus GX), MAME backport by R. Belmont.
1818**  - implemented PG overflow, aka "detune bug" (Ariel, Comix Zone, Shaq Fu, Spiderman,...), credits to Nemesis
1919**  - fixed SSG-EG support, credits to Nemesis and additional fixes from Alone Coder
2020**  - modified EG rates and frequency, tested by Nemesis on real hardware
21**  - fixed EG attenuation level on KEY ON (Ecco 2 splash sound)
22**  - fixed LFO phase update for CH3 special mode (Warlock, Alladin), thanks to AamirM
21**  - implemented LFO phase update for CH3 special mode (Warlock birds, Alladin bug sound)
22**  - fixed Attack Rate update (Batman & Robin intro)
23**  - fixed attenuation level at the start of Substain (Gynoug explosions)
24**  - fixed EG decay->substain transition to handle special cases, like SL=0 and Decay rate is very slow (Mega Turrican tracks 03,09...)
2325**
2426** 06-23-2007 Zsolt Vasvari:
2527**  - changed the timing not to require the use of floating point calculations
r3514r3515
701703        but LFO works with one more bit of a precision so we really need 4096 elements */
702704
703705   UINT32   fn_table[4096];   /* fnumber->increment counter */
706   UINT32 fn_max;    /* maximal phase increment (used for phase overflow) */
704707
705
706708   /* LFO */
707709   UINT32   lfo_cnt;
708710   UINT32   lfo_inc;
r3514r3515
726728static UINT32   LFO_AM;         /* runtime LFO calculations helper */
727729static INT32   LFO_PM;         /* runtime LFO calculations helper */
728730
729static int fn_max;    /* maximal phase increment (used for phase overflow) */
730
731731/* log output level */
732732#define LOG_ERR  3      /* ERROR       */
733733#define LOG_WAR  2      /* WARNING     */
r3514r3515
922922   {
923923      SLOT->key = 1;
924924      SLOT->phase = 0;      /* restart Phase Generator */
925      SLOT->ssgn = (SLOT->ssg & 0x04) >> 1;
925926
926927      if ((type == TYPE_YM2612) || (type == TYPE_YM2608))
927928      {
928929              if( (SLOT->ar + SLOT->ksr) < 32+62 )
929930              {
930931                 SLOT->state = EG_ATT;    /* phase -> Attack */
931                 SLOT->volume = MAX_ATT_INDEX;    /* fix Ecco 2 splash sound */
932932         }
933933         else
934934         {
935935                 /* directly switch to Decay */
936                 SLOT->volume = MIN_ATT_INDEX;
936937                 SLOT->state = EG_DEC;
937                 SLOT->volume = MIN_ATT_INDEX;
938938         }
939939      }
940940      else
r3514r3515
10751075      SLOT->eg_sh_ar  = eg_rate_shift [SLOT->ar  + SLOT->ksr ];
10761076      if ((type == TYPE_YM2612) || (type == TYPE_YM2608))
10771077      {
1078                   SLOT->eg_sh_ar  = eg_rate_shift [SLOT->ar  + SLOT->ksr ];
10781079         SLOT->eg_sel_ar = eg_rate_select2612[SLOT->ar  + SLOT->ksr ];
10791080      }
10801081      else
r3514r3515
11681169INLINE void advance_lfo(FM_OPN *OPN)
11691170{
11701171   UINT8 pos;
1171   UINT8 prev_pos;
11721172
11731173   if (OPN->lfo_inc)   /* LFO enabled ? */
11741174   {
1175      prev_pos = OPN->lfo_cnt>>LFO_SH & 127;
1176
11771175      OPN->lfo_cnt += OPN->lfo_inc;
11781176
11791177      pos = (OPN->lfo_cnt >> LFO_SH) & 127;
r3514r3515
11811179
11821180      /* update AM when LFO output changes */
11831181
1184      /*if (prev_pos != pos)*/
11851182      /* actually I can't optimize is this way without rewritting chan_calc()
11861183        to use chip->lfo_am instead of global lfo_am */
11871184      {
r3514r3515
11951192      }
11961193
11971194      /* PM works with 4 times slower clock */
1198      prev_pos >>= 2;
11991195      pos >>= 2;
12001196      /* update PM when LFO output changes */
12011197      /*if (prev_pos != pos)*/ /* can't use global lfo_pm for this optimization, must be chip->lfo_pm instead*/
r3514r3515
12221218   i = 4; /* four operators per channel */
12231219   do
12241220   {
1221      /* reset SSG-EG swap flag */
1222      swap_flag = 0;
1223
12251224      switch(SLOT->state)
12261225      {
12271226      case EG_ATT:      /* attack phase */
r3514r3515
12401239      break;
12411240
12421241      case EG_DEC:   /* decay phase */
1243         if (SLOT->ssg&0x08)   /* SSG EG type envelope selected */
1242         if ((OPN->type == TYPE_YM2612) || (OPN->type == TYPE_YM2608))
12441243         {
1245            if ( !(OPN->eg_cnt & ((1<<SLOT->eg_sh_d1r)-1) ) )
1244                                if ( !(OPN->eg_cnt & ((1<<SLOT->eg_sh_d1r)-1) ) )
1245                                {
1246               if (SLOT->ssg&0x08)   /* SSG EG type envelope selected */
1247               {
1248                         SLOT->volume += 6 * eg_inc[SLOT->eg_sel_d1r + ((OPN->eg_cnt>>SLOT->eg_sh_d1r)&7)];
1249               }
1250               else
1251               {
1252                                                SLOT->volume += eg_inc[SLOT->eg_sel_d1r + ((OPN->eg_cnt>>SLOT->eg_sh_d1r)&7)];
1253               }
1254                 }
1255
1256            /* check transition even if no volume update: this fixes the case when SL = MIN_ATT_INDEX */
1257            if ( SLOT->volume >= (INT32)(SLOT->sl) )
12461258            {
1247               SLOT->volume += 4 * eg_inc[SLOT->eg_sel_d1r + ((OPN->eg_cnt>>SLOT->eg_sh_d1r)&7)];
1248
1249               if ( SLOT->volume >= (INT32)(SLOT->sl) )
1250                  SLOT->state = EG_SUS;
1259               SLOT->volume = (INT32)(SLOT->sl);
1260               SLOT->state = EG_SUS;
12511261            }
12521262         }
12531263         else
12541264         {
1255            if ( !(OPN->eg_cnt & ((1<<SLOT->eg_sh_d1r)-1) ) )
1265            if (SLOT->ssg&0x08)   /* SSG EG type envelope selected */
12561266            {
1257               SLOT->volume += eg_inc[SLOT->eg_sel_d1r + ((OPN->eg_cnt>>SLOT->eg_sh_d1r)&7)];
1267               if ( !(OPN->eg_cnt & ((1<<SLOT->eg_sh_d1r)-1) ) )
1268               {
1269                  SLOT->volume += 4 * eg_inc[SLOT->eg_sel_d1r + ((OPN->eg_cnt>>SLOT->eg_sh_d1r)&7)];
12581270
1259               if ( SLOT->volume >= (INT32)(SLOT->sl) )
1260                  SLOT->state = EG_SUS;
1271                  if ( SLOT->volume >= (INT32)(SLOT->sl) )
1272                     SLOT->state = EG_SUS;
1273               }
12611274            }
1275            else
1276            {
1277               if ( !(OPN->eg_cnt & ((1<<SLOT->eg_sh_d1r)-1) ) )
1278               {
1279                  SLOT->volume += eg_inc[SLOT->eg_sel_d1r + ((OPN->eg_cnt>>SLOT->eg_sh_d1r)&7)];
1280
1281                  if ( SLOT->volume >= (INT32)(SLOT->sl) )
1282                     SLOT->state = EG_SUS;
1283               }
1284            }
12621285         }
12631286      break;
12641287
r3514r3515
12671290         {
12681291            if ( !(OPN->eg_cnt & ((1<<SLOT->eg_sh_d2r)-1) ) )
12691292            {
1270               SLOT->volume += 4 * eg_inc[SLOT->eg_sel_d2r + ((OPN->eg_cnt>>SLOT->eg_sh_d2r)&7)];
12711293
1272               if ( SLOT->volume >= 512 )
1294               if ((OPN->type == TYPE_YM2612) || (OPN->type == TYPE_YM2608))
12731295               {
1274                  SLOT->volume = MAX_ATT_INDEX;
1296                  SLOT->volume += 6 * eg_inc[SLOT->eg_sel_d2r + ((OPN->eg_cnt>>SLOT->eg_sh_d2r)&7)];
1297               }
1298               else
1299               {
1300                  SLOT->volume += 4 * eg_inc[SLOT->eg_sel_d2r + ((OPN->eg_cnt>>SLOT->eg_sh_d2r)&7)];
1301               }
12751302
1303               if ( SLOT->volume >= ENV_QUIET )
1304               {
1305                  if ((OPN->type != TYPE_YM2612) && (OPN->type != TYPE_YM2608))
1306                  {
1307                     SLOT->volume = MAX_ATT_INDEX;
1308                  }
1309
12761310                  if (SLOT->ssg&0x01)   /* bit 0 = hold */
12771311                  {
12781312                     if (SLOT->ssgn&1)   /* have we swapped once ??? */
r3514r3515
12871321                  {
12881322                     /* same as KEY-ON operation */
12891323
1290                     /* restart of the Phase Generator should be here,
1291                                only if AR is not maximum ??? */
1324                     /* restart of the Phase Generator should be here */
12921325                     SLOT->phase = 0;
12931326
1294                     /* phase -> Attack */
1295                     SLOT->volume = 511;
1296                     SLOT->state = EG_ATT;
1327                     if ((OPN->type == TYPE_YM2612) || (OPN->type == TYPE_YM2608))
1328                     {
1329                        if ((SLOT->ar + SLOT->ksr) < 94 /*32+62*/)
1330                        {
1331                           SLOT->state = EG_ATT; /* phase -> Attack */
1332                        }
1333                        else
1334                        {
1335                           /* Attack Rate is maximal: directly switch to Decay (or Substain) */
1336                           SLOT->volume = MIN_ATT_INDEX;
1337                           SLOT->state = (SLOT->sl == MIN_ATT_INDEX) ? EG_SUS : EG_DEC;
1338                        }
1339                     }
1340                     else
1341                     {
1342                        /* phase -> Attack */
1343                        SLOT->volume = 511;
1344                        SLOT->state = EG_ATT;
1345                     }
12971346
12981347                     swap_flag = (SLOT->ssg&0x02); /* bit 1 = alternate */
12991348                  }
r3514r3515
13191368      case EG_REL:   /* release phase */
13201369            if ( !(OPN->eg_cnt & ((1<<SLOT->eg_sh_rr)-1) ) )
13211370            {
1322               SLOT->volume += eg_inc[SLOT->eg_sel_rr + ((OPN->eg_cnt>>SLOT->eg_sh_rr)&7)];
1371               /* SSG-EG affects Release phase also (Nemesis) */
1372               if ((SLOT->ssg&0x08) && ((OPN->type = TYPE_YM2612) || (OPN->type = TYPE_YM2608)))
1373               {
1374                  SLOT->volume += 6 * eg_inc[SLOT->eg_sel_rr + ((OPN->eg_cnt>>SLOT->eg_sh_rr)&7)];
1375               }
1376               else
1377               {
1378                  SLOT->volume += eg_inc[SLOT->eg_sel_rr + ((OPN->eg_cnt>>SLOT->eg_sh_rr)&7)];
1379               }
13231380
13241381               if ( SLOT->volume >= MAX_ATT_INDEX )
13251382               {
r3514r3515
13311388
13321389      }
13331390
1334      out = SLOT->tl + ((UINT32)SLOT->volume);
13351391
1336      if ((SLOT->ssg&0x08) && (SLOT->ssgn&2) && (SLOT->state != EG_OFF))   /* negate output (changes come from alternate bit, init comes from attack bit) */
1337         out ^= 511; // was ((1<<ENV_BITS)-1); /* 1023 */
1392      out = ((UINT32)SLOT->volume);
13381393
1394                /* negate output (changes come from alternate bit, init comes from attack bit) */
1395      if ((SLOT->ssg&0x08) && (SLOT->ssgn&2) && (SLOT->state > EG_REL))
1396         out ^= MAX_ATT_INDEX;
1397
13391398      /* we need to store the result here because we are going to change ssgn
13401399            in next instruction */
1341      SLOT->vol_out = out;
1400      SLOT->vol_out = out + SLOT->tl;
13421401
1402                /* reverse SLOT inversion flag */
13431403      SLOT->ssgn ^= swap_flag;
13441404
13451405      SLOT++;
r3514r3515
13751435      fc = (OPN->fn_table[fn]>>(7-blk)) + SLOT->DT[kc];
13761436
13771437      /* detects frequency overflow (credits to Nemesis) */
1378      if (fc < 0) fc += fn_max;
1438      if (fc < 0) fc += OPN->fn_max;
13791439
13801440      /* update phase */
13811441      SLOT->phase += (fc * SLOT->mul) >> 1;
r3514r3515
14131473      /* detects frequency overflow (credits to Nemesis) */
14141474      finc = fc + CH->SLOT[SLOT1].DT[kc];
14151475
1416      if (finc < 0) finc += fn_max;
1476      if (finc < 0) finc += OPN->fn_max;
14171477      CH->SLOT[SLOT1].phase += (finc*CH->SLOT[SLOT1].mul) >> 1;
14181478
14191479      finc = fc + CH->SLOT[SLOT2].DT[kc];
1420      if (finc < 0) finc += fn_max;
1480      if (finc < 0) finc += OPN->fn_max;
14211481      CH->SLOT[SLOT2].phase += (finc*CH->SLOT[SLOT2].mul) >> 1;
14221482
14231483      finc = fc + CH->SLOT[SLOT3].DT[kc];
1424      if (finc < 0) finc += fn_max;
1484      if (finc < 0) finc += OPN->fn_max;
14251485      CH->SLOT[SLOT3].phase += (finc*CH->SLOT[SLOT3].mul) >> 1;
14261486
14271487      finc = fc + CH->SLOT[SLOT4].DT[kc];
1428      if (finc < 0) finc += fn_max;
1488      if (finc < 0) finc += OPN->fn_max;
14291489      CH->SLOT[SLOT4].phase += (finc*CH->SLOT[SLOT4].mul) >> 1;
14301490   }
14311491   else    /* LFO phase modulation  = zero */
r3514r3515
15121572}
15131573
15141574/* update phase increment and envelope generator */
1515INLINE void refresh_fc_eg_slot(UINT8 type, FM_SLOT *SLOT , int fc , int kc )
1575INLINE void refresh_fc_eg_slot(FM_OPN *OPN, FM_SLOT *SLOT , int fc , int kc )
15161576{
15171577   int ksr = kc >> SLOT->KSR;
15181578
15191579   fc += SLOT->DT[kc];
15201580
15211581   /* detects frequency overflow (credits to Nemesis) */
1522   if (fc < 0) fc += fn_max;
1582   if (fc < 0) fc += OPN->fn_max;
15231583
15241584   /* (frequency) phase increment counter */
15251585   SLOT->Incr = (fc * SLOT->mul) >> 1;
r3514r3515
15321592      if ((SLOT->ar + SLOT->ksr) < 32+62)
15331593      {
15341594         SLOT->eg_sh_ar  = eg_rate_shift [SLOT->ar  + SLOT->ksr ];
1535         if ((type == TYPE_YM2612) || (type == TYPE_YM2608))
1595         if ((OPN->type == TYPE_YM2612) || (OPN->type == TYPE_YM2608))
15361596         {
15371597            SLOT->eg_sel_ar = eg_rate_select2612[SLOT->ar  + SLOT->ksr ];
15381598         }
r3514r3515
15511611      SLOT->eg_sh_d2r = eg_rate_shift [SLOT->d2r + SLOT->ksr];
15521612      SLOT->eg_sh_rr  = eg_rate_shift [SLOT->rr  + SLOT->ksr];
15531613
1554      if ((type == TYPE_YM2612) || (type == TYPE_YM2608))
1614      if ((OPN->type == TYPE_YM2612) || (OPN->type == TYPE_YM2608))
15551615      {
15561616         SLOT->eg_sel_d1r= eg_rate_select2612[SLOT->d1r + SLOT->ksr];
15571617         SLOT->eg_sel_d2r= eg_rate_select2612[SLOT->d2r + SLOT->ksr];
r3514r3515
15681628
15691629/* update phase increment counters */
15701630/* Changed from INLINE to static to work around gcc 4.2.1 codegen bug */
1571static void refresh_fc_eg_chan(UINT8 type, FM_CH *CH )
1631static void refresh_fc_eg_chan(FM_OPN *OPN, FM_CH *CH )
15721632{
15731633   if( CH->SLOT[SLOT1].Incr==-1){
15741634      int fc = CH->fc;
15751635      int kc = CH->kcode;
1576      refresh_fc_eg_slot(type, &CH->SLOT[SLOT1] , fc , kc );
1577      refresh_fc_eg_slot(type, &CH->SLOT[SLOT2] , fc , kc );
1578      refresh_fc_eg_slot(type, &CH->SLOT[SLOT3] , fc , kc );
1579      refresh_fc_eg_slot(type, &CH->SLOT[SLOT4] , fc , kc );
1636      refresh_fc_eg_slot(OPN, &CH->SLOT[SLOT1] , fc , kc );
1637      refresh_fc_eg_slot(OPN, &CH->SLOT[SLOT2] , fc , kc );
1638      refresh_fc_eg_slot(OPN, &CH->SLOT[SLOT3] , fc , kc );
1639      refresh_fc_eg_slot(OPN, &CH->SLOT[SLOT4] , fc , kc );
15801640   }
15811641}
15821642
r3514r3515
17611821/* CSM Key Controll */
17621822INLINE void CSMKeyControll(UINT8 type, FM_CH *CH)
17631823{
1764   /* this is wrong, atm */
1765
1766   /* all key on */
1767   FM_KEYON(type, CH,SLOT1);
1768   FM_KEYON(type, CH,SLOT2);
1769   FM_KEYON(type, CH,SLOT3);
1770   FM_KEYON(type, CH,SLOT4);
1824   /* all key on then off (only for operators which were OFF!) */
1825   if (!CH->SLOT[SLOT1].key)
1826   {
1827      FM_KEYON(type, CH,SLOT1);
1828      FM_KEYOFF(CH, SLOT1);
1829   }
1830   if (!CH->SLOT[SLOT2].key)
1831   {
1832      FM_KEYON(type, CH,SLOT2);
1833      FM_KEYOFF(CH, SLOT2);
1834   }
1835   if (!CH->SLOT[SLOT3].key)
1836   {
1837      FM_KEYON(type, CH,SLOT3);
1838      FM_KEYOFF(CH, SLOT3);
1839   }
1840   if (!CH->SLOT[SLOT4].key)
1841   {
1842      FM_KEYON(type, CH,SLOT4);
1843      FM_KEYOFF(CH, SLOT4);
1844   }
17711845}
17721846
17731847#ifdef __STATE_H__
r3514r3515
18611935#endif
18621936   }
18631937
1864   /* maximal frequency, used for overflow, best setting with BLOCK=5 (notaz) */
1865   fn_max = ((UINT32)((double)OPN->fn_table[0x7ff*2] / OPN->ST.freqbase) >> 2);
1938   /* maximal frequency is required for Phase overflow calculation, register size is 17 bits (Nemesis) */
1939   OPN->fn_max = (UINT32)( (double)0x20000 * OPN->ST.freqbase * (1<<(FREQ_SH-10)) );
18661940
18671941   /* LFO freq. table */
18681942   for(i = 0; i < 8; i++)
r3514r3515
22042278
22052279
22062280   /* refresh PG and EG */
2207   refresh_fc_eg_chan( OPN->type, cch[0] );
2208   refresh_fc_eg_chan( OPN->type, cch[1] );
2281   refresh_fc_eg_chan( OPN, cch[0] );
2282   refresh_fc_eg_chan( OPN, cch[1] );
22092283   if( (F2203->OPN.ST.mode & 0xc0) )
22102284   {
22112285      /* 3SLOT MODE */
22122286      if( cch[2]->SLOT[SLOT1].Incr==-1)
22132287      {
2214         refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT1] , OPN->SL3.fc[1] , OPN->SL3.kcode[1] );
2215         refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT2] , OPN->SL3.fc[2] , OPN->SL3.kcode[2] );
2216         refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT3] , OPN->SL3.fc[0] , OPN->SL3.kcode[0] );
2217         refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT4] , cch[2]->fc , cch[2]->kcode );
2288         refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT1] , OPN->SL3.fc[1] , OPN->SL3.kcode[1] );
2289         refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT2] , OPN->SL3.fc[2] , OPN->SL3.kcode[2] );
2290         refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT3] , OPN->SL3.fc[0] , OPN->SL3.kcode[0] );
2291         refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT4] , cch[2]->fc , cch[2]->kcode );
22182292      }
2219   }else refresh_fc_eg_chan( OPN->type, cch[2] );
2293   }else refresh_fc_eg_chan( OPN, cch[2] );
22202294
22212295
22222296   /* YM2203 doesn't have LFO so we must keep these globals at 0 level */
r3514r3515
33863460   pcmsizeA = F2608->pcm_size;
33873461
33883462   /* refresh PG and EG */
3389   refresh_fc_eg_chan( OPN->type, cch[0] );
3390   refresh_fc_eg_chan( OPN->type, cch[1] );
3463   refresh_fc_eg_chan( OPN, cch[0] );
3464   refresh_fc_eg_chan( OPN, cch[1] );
33913465   if( (OPN->ST.mode & 0xc0) )
33923466   {
33933467      /* 3SLOT MODE */
33943468      if( cch[2]->SLOT[SLOT1].Incr==-1)
33953469      {
3396         refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT1] , OPN->SL3.fc[1] , OPN->SL3.kcode[1] );
3397         refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT2] , OPN->SL3.fc[2] , OPN->SL3.kcode[2] );
3398         refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT3] , OPN->SL3.fc[0] , OPN->SL3.kcode[0] );
3399         refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT4] , cch[2]->fc , cch[2]->kcode );
3470         refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT1] , OPN->SL3.fc[1] , OPN->SL3.kcode[1] );
3471         refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT2] , OPN->SL3.fc[2] , OPN->SL3.kcode[2] );
3472         refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT3] , OPN->SL3.fc[0] , OPN->SL3.kcode[0] );
3473         refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT4] , cch[2]->fc , cch[2]->kcode );
34003474      }
3401   }else refresh_fc_eg_chan( OPN->type, cch[2] );
3402   refresh_fc_eg_chan( OPN->type, cch[3] );
3403   refresh_fc_eg_chan( OPN->type, cch[4] );
3404   refresh_fc_eg_chan( OPN->type, cch[5] );
3475   }else refresh_fc_eg_chan( OPN, cch[2] );
3476   refresh_fc_eg_chan( OPN, cch[3] );
3477   refresh_fc_eg_chan( OPN, cch[4] );
3478   refresh_fc_eg_chan( OPN, cch[5] );
34053479
34063480
34073481   /* buffering */
r3514r3515
34213495      out_fm[4] = 0;
34223496      out_fm[5] = 0;
34233497
3424      /* advance envelope generator */
3425      OPN->eg_timer += OPN->eg_timer_add;
3426      while (OPN->eg_timer >= OPN->eg_timer_overflow)
3427      {
3428         OPN->eg_timer -= OPN->eg_timer_overflow;
3429         OPN->eg_cnt++;
3430
3431         advance_eg_channel(OPN, &cch[0]->SLOT[SLOT1]);
3432         advance_eg_channel(OPN, &cch[1]->SLOT[SLOT1]);
3433         advance_eg_channel(OPN, &cch[2]->SLOT[SLOT1]);
3434         advance_eg_channel(OPN, &cch[3]->SLOT[SLOT1]);
3435         advance_eg_channel(OPN, &cch[4]->SLOT[SLOT1]);
3436         advance_eg_channel(OPN, &cch[5]->SLOT[SLOT1]);
3437      }
3438
34393498      /* calculate FM */
34403499      chan_calc(OPN, cch[0], 0 );
34413500      chan_calc(OPN, cch[1], 1 );
r3514r3515
34553514            ADPCMA_calc_chan( F2608, &F2608->adpcm[j]);
34563515      }
34573516
3517      /* advance envelope generator */
3518      OPN->eg_timer += OPN->eg_timer_add;
3519      while (OPN->eg_timer >= OPN->eg_timer_overflow)
3520      {
3521         OPN->eg_timer -= OPN->eg_timer_overflow;
3522         OPN->eg_cnt++;
3523
3524         advance_eg_channel(OPN, &cch[0]->SLOT[SLOT1]);
3525         advance_eg_channel(OPN, &cch[1]->SLOT[SLOT1]);
3526         advance_eg_channel(OPN, &cch[2]->SLOT[SLOT1]);
3527         advance_eg_channel(OPN, &cch[3]->SLOT[SLOT1]);
3528         advance_eg_channel(OPN, &cch[4]->SLOT[SLOT1]);
3529         advance_eg_channel(OPN, &cch[5]->SLOT[SLOT1]);
3530      }
3531
34583532      /* buffering */
34593533      {
34603534         int lt,rt;
r3514r3515
39404014#endif
39414015
39424016   /* refresh PG and EG */
3943   refresh_fc_eg_chan( OPN->type, cch[0] );
4017   refresh_fc_eg_chan( OPN, cch[0] );
39444018   if( (OPN->ST.mode & 0xc0) )
39454019   {
39464020      /* 3SLOT MODE */
39474021      if( cch[1]->SLOT[SLOT1].Incr==-1)
39484022      {
3949         refresh_fc_eg_slot(OPN->type, &cch[1]->SLOT[SLOT1] , OPN->SL3.fc[1] , OPN->SL3.kcode[1] );
3950         refresh_fc_eg_slot(OPN->type, &cch[1]->SLOT[SLOT2] , OPN->SL3.fc[2] , OPN->SL3.kcode[2] );
3951         refresh_fc_eg_slot(OPN->type, &cch[1]->SLOT[SLOT3] , OPN->SL3.fc[0] , OPN->SL3.kcode[0] );
3952         refresh_fc_eg_slot(OPN->type, &cch[1]->SLOT[SLOT4] , cch[1]->fc , cch[1]->kcode );
4023         refresh_fc_eg_slot(OPN, &cch[1]->SLOT[SLOT1] , OPN->SL3.fc[1] , OPN->SL3.kcode[1] );
4024         refresh_fc_eg_slot(OPN, &cch[1]->SLOT[SLOT2] , OPN->SL3.fc[2] , OPN->SL3.kcode[2] );
4025         refresh_fc_eg_slot(OPN, &cch[1]->SLOT[SLOT3] , OPN->SL3.fc[0] , OPN->SL3.kcode[0] );
4026         refresh_fc_eg_slot(OPN, &cch[1]->SLOT[SLOT4] , cch[1]->fc , cch[1]->kcode );
39534027      }
3954   }else refresh_fc_eg_chan( OPN->type, cch[1] );
3955   refresh_fc_eg_chan( OPN->type, cch[2] );
3956   refresh_fc_eg_chan( OPN->type, cch[3] );
4028   }else refresh_fc_eg_chan( OPN, cch[1] );
4029   refresh_fc_eg_chan( OPN, cch[2] );
4030   refresh_fc_eg_chan( OPN, cch[3] );
39574031
39584032   /* buffering */
39594033   for(i=0; i < length ; i++)
r3514r3515
40694143   pcmsizeA = F2610->pcm_size;
40704144
40714145   /* refresh PG and EG */
4072   refresh_fc_eg_chan( OPN->type, cch[0] );
4073   refresh_fc_eg_chan( OPN->type, cch[1] );
4146   refresh_fc_eg_chan( OPN, cch[0] );
4147   refresh_fc_eg_chan( OPN, cch[1] );
40744148   if( (OPN->ST.mode & 0xc0) )
40754149   {
40764150      /* 3SLOT MODE */
40774151      if( cch[2]->SLOT[SLOT1].Incr==-1)
40784152      {
4079         refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT1] , OPN->SL3.fc[1] , OPN->SL3.kcode[1] );
4080         refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT2] , OPN->SL3.fc[2] , OPN->SL3.kcode[2] );
4081         refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT3] , OPN->SL3.fc[0] , OPN->SL3.kcode[0] );
4082         refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT4] , cch[2]->fc , cch[2]->kcode );
4153         refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT1] , OPN->SL3.fc[1] , OPN->SL3.kcode[1] );
4154         refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT2] , OPN->SL3.fc[2] , OPN->SL3.kcode[2] );
4155         refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT3] , OPN->SL3.fc[0] , OPN->SL3.kcode[0] );
4156         refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT4] , cch[2]->fc , cch[2]->kcode );
40834157      }
4084   }else refresh_fc_eg_chan( OPN->type, cch[2] );
4085   refresh_fc_eg_chan( OPN->type, cch[3] );
4086   refresh_fc_eg_chan( OPN->type, cch[4] );
4087   refresh_fc_eg_chan( OPN->type, cch[5] );
4158   }else refresh_fc_eg_chan( OPN, cch[2] );
4159   refresh_fc_eg_chan( OPN, cch[3] );
4160   refresh_fc_eg_chan( OPN, cch[4] );
4161   refresh_fc_eg_chan( OPN, cch[5] );
40884162
40894163   /* buffering */
40904164   for(i=0; i < length ; i++)
r3514r3515
45904664   dacen = F2612->dacen;
45914665
45924666   /* refresh PG and EG */
4593   refresh_fc_eg_chan( OPN->type, cch[0] );
4594   refresh_fc_eg_chan( OPN->type, cch[1] );
4667   refresh_fc_eg_chan( OPN, cch[0] );
4668   refresh_fc_eg_chan( OPN, cch[1] );
45954669   if( (OPN->ST.mode & 0xc0) )
45964670   {
45974671      /* 3SLOT MODE */
45984672      if( cch[2]->SLOT[SLOT1].Incr==-1)
45994673      {
4600         refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT1] , OPN->SL3.fc[1] , OPN->SL3.kcode[1] );
4601         refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT2] , OPN->SL3.fc[2] , OPN->SL3.kcode[2] );
4602         refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT3] , OPN->SL3.fc[0] , OPN->SL3.kcode[0] );
4603         refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT4] , cch[2]->fc , cch[2]->kcode );
4674         refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT1] , OPN->SL3.fc[1] , OPN->SL3.kcode[1] );
4675         refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT2] , OPN->SL3.fc[2] , OPN->SL3.kcode[2] );
4676         refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT3] , OPN->SL3.fc[0] , OPN->SL3.kcode[0] );
4677         refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT4] , cch[2]->fc , cch[2]->kcode );
46044678      }
4605   }else refresh_fc_eg_chan( OPN->type, cch[2] );
4606   refresh_fc_eg_chan( OPN->type, cch[3] );
4607   refresh_fc_eg_chan( OPN->type, cch[4] );
4608   refresh_fc_eg_chan( OPN->type, cch[5] );
4679   }else refresh_fc_eg_chan( OPN, cch[2] );
4680   refresh_fc_eg_chan( OPN, cch[3] );
4681   refresh_fc_eg_chan( OPN, cch[4] );
4682   refresh_fc_eg_chan( OPN, cch[5] );
46094683
46104684   /* buffering */
46114685   for(i=0; i < length ; i++)
r3514r3515
46214695      out_fm[4] = 0;
46224696      out_fm[5] = 0;
46234697
4698      /* calculate FM */
4699      chan_calc(OPN, cch[0], 0 );
4700      chan_calc(OPN, cch[1], 1 );
4701      chan_calc(OPN, cch[2], 2 );
4702      chan_calc(OPN, cch[3], 3 );
4703      chan_calc(OPN, cch[4], 4 );
4704      if( dacen )
4705         *cch[5]->connect4 += dacout;
4706      else
4707         chan_calc(OPN, cch[5], 5 );
4708
46244709      /* advance envelope generator */
46254710      OPN->eg_timer += OPN->eg_timer_add;
46264711      while (OPN->eg_timer >= OPN->eg_timer_overflow)
r3514r3515
46364721         advance_eg_channel(OPN, &cch[5]->SLOT[SLOT1]);
46374722      }
46384723
4639      /* calculate FM */
4640      chan_calc(OPN, cch[0], 0 );
4641      chan_calc(OPN, cch[1], 1 );
4642      chan_calc(OPN, cch[2], 2 );
4643      chan_calc(OPN, cch[3], 3 );
4644      chan_calc(OPN, cch[4], 4 );
4645      if( dacen )
4646         *cch[5]->connect4 += dacout;
4647      else
4648         chan_calc(OPN, cch[5], 5 );
4649
46504724      {
46514725         int lt,rt;
46524726
src/emu/sound/disc_dev.c
r3514r3515
2323 *
2424 ************************************************************************/
2525
26#define DEFAULT_555_CAP_BLEED   RES_M(10)
26#define DEFAULT_555_BLEED_R   RES_M(10)
2727
2828struct dsd_555_astbl_context
2929{
r3514r3515
4242   double   exp_bleed;
4343   double   exp_charge;
4444   double   exp_discharge;
45   double   t_rc_bleed;
4546   double   t_rc_charge;
4647   double   t_rc_discharge;
48   double   last_r1;
49   double   last_r2;
50   double   last_c;
4751};
4852
4953struct dsd_555_mstbl_context
r3514r3515
147151#define DSD_555_ASTBL_RC_MASK   0x0e
148152
149153/* charge/discharge constants */
150#define DSD_555_ASTBL_T_RC_BLEED      (DEFAULT_555_CAP_BLEED * DSD_555_ASTBL__C)
154#define DSD_555_ASTBL_T_RC_BLEED      (DEFAULT_555_BLEED_R * DSD_555_ASTBL__C)
151155/* Use quick charge if specified. */
152156#define DSD_555_ASTBL_T_RC_CHARGE      ((DSD_555_ASTBL__R1 + ((info->options & DISC_555_ASTABLE_HAS_FAST_CHARGE_DIODE) ? 0 : DSD_555_ASTBL__R2)) * DSD_555_ASTBL__C)
153157#define DSD_555_ASTBL_T_RC_DISCHARGE   (DSD_555_ASTBL__R2 * DSD_555_ASTBL__C)
r3514r3515
161165   int      count_r = 0;
162166   double   dt;                        /* change in time */
163167   double   x_time  = 0;               /* time since change happened */
164   double   t_rc    = 0;               /* RC time constant */
165168   double   v_cap   = context->cap_voltage;   /* Current voltage on capacitor, before dt */
166169   double   v_cap_next = 0;               /* Voltage on capacitor, after dt */
167   double   v_charge, exponent;
168   int      update_exponent, update_t_rc;
170   double   v_charge, exponent = 0;
171   int      update_exponent = 0;
169172
170173   /* put commonly used stuff in local variables for speed */
171174   double   threshold = context->threshold;
r3514r3515
246249   }
247250   else
248251   {
252      /* Update charge contstants and exponents if nodes changed */
253      if (context->has_rc_nodes && (DSD_555_ASTBL__R1 != context->last_r1 || DSD_555_ASTBL__C != context->last_c || DSD_555_ASTBL__R2 != context->last_r2))
254      {
255         context->t_rc_bleed  = DSD_555_ASTBL_T_RC_BLEED;
256         context->t_rc_charge = DSD_555_ASTBL_T_RC_CHARGE;
257         context->t_rc_discharge = DSD_555_ASTBL_T_RC_DISCHARGE;
258         context->exp_bleed  = RC_CHARGE_EXP(context->t_rc_bleed);
259         context->exp_charge = RC_CHARGE_EXP(context->t_rc_charge);
260         context->exp_discharge = RC_CHARGE_EXP(context->t_rc_discharge);
261         context->last_r1 = DSD_555_ASTBL__R1;
262         context->last_r2 = DSD_555_ASTBL__R2;
263         context->last_c  = DSD_555_ASTBL__C;
264      }
249265      /* Keep looping until all toggling in time sample is used up. */
250      update_t_rc = context->has_rc_nodes;
251      update_exponent = update_t_rc;
252266      do
253267      {
254268         if (context->flip_flop)
r3514r3515
258272               /* Oscillation disabled because there is no longer any charge resistor. */
259273               /* Bleed the cap due to circuit losses. */
260274               if (update_exponent)
261               {
262                  t_rc     = DSD_555_ASTBL_T_RC_BLEED;
263                  exponent = 1.0 - exp(-(dt / t_rc));
264               }
275                  exponent = RC_CHARGE_EXP_DT(context->t_rc_bleed, dt);
265276               else
266277                  exponent = context->exp_bleed;
267278               v_cap_next = v_cap - (v_cap * exponent);
r3514r3515
270281            else
271282            {
272283               /* Charging */
273               if (update_t_rc)
274                  t_rc = DSD_555_ASTBL_T_RC_CHARGE;
275               else
276                  t_rc = context->t_rc_charge;
277284               if (update_exponent)
278                  exponent = 1.0 - exp(-(dt / t_rc ));
285                  exponent = RC_CHARGE_EXP_DT(context->t_rc_charge, dt);
279286               else
280287                  exponent = context->exp_charge;
281288               v_cap_next = v_cap + ((v_charge - v_cap) * exponent);
r3514r3515
285292               if (v_cap_next >= threshold)
286293               {
287294                  /* calculate the overshoot time */
288                  dt     = t_rc  * log(1.0 / (1.0 - ((v_cap_next - threshold) / (v_charge - v_cap))));
295                  dt     = context->t_rc_charge  * log(1.0 / (1.0 - ((v_cap_next - threshold) / (v_charge - v_cap))));
289296                  x_time = dt;
290297                  v_cap  = threshold;
291298                  context->flip_flop = 0;
r3514r3515
299306            /* Discharging */
300307            if(DSD_555_ASTBL__R2 != 0)
301308            {
302               if (update_t_rc)
303                  t_rc = DSD_555_ASTBL_T_RC_DISCHARGE;
304               else
305                  t_rc = context->t_rc_discharge;
306309               if (update_exponent)
307                  exponent = 1.0 - exp(-(dt / t_rc ));
310                  exponent = RC_CHARGE_EXP_DT(context->t_rc_discharge, dt);
308311               else
309312                  exponent = context->exp_discharge;
310313               v_cap_next = v_cap - (v_cap * exponent);
r3514r3515
320323            if (v_cap_next <= trigger)
321324            {
322325               /* calculate the overshoot time */
323               dt = t_rc  * log(1.0 / (1.0 - ((trigger - v_cap_next) / v_cap)));
326               if (v_cap_next < trigger)
327                  dt = context->t_rc_discharge  * log(1.0 / (1.0 - ((trigger - v_cap_next) / v_cap)));
324328               x_time = dt;
325329               v_cap  = trigger;
326330               context->flip_flop = 1;
r3514r3515
376380   struct dsd_555_astbl_context *context = node->context;
377381   node_description *v_charge_node;
378382
379   double   neg_dt = 0.0 - discrete_current_context->sample_time;
380   double   t_rc;
381
382383   context->use_ctrlv   = (node->input_is_node >> 4) & 1;
383384   context->output_type = info->options & DISC_555_OUT_MASK;
384385
r3514r3515
416417      context->has_rc_nodes = 1;
417418   else
418419   {
419      t_rc = DSD_555_ASTBL_T_RC_BLEED;
420      context->exp_bleed  = 1.0 - exp(neg_dt / t_rc);
421      t_rc = DSD_555_ASTBL_T_RC_CHARGE;
422      context->exp_charge  = 1.0 - exp(neg_dt / t_rc);
423      context->t_rc_charge = t_rc;
424      t_rc = DSD_555_ASTBL_T_RC_DISCHARGE;
425      context->exp_discharge  = 1.0 - exp(neg_dt / t_rc);
426      context->t_rc_discharge = t_rc;
420      context->t_rc_bleed  = DSD_555_ASTBL_T_RC_BLEED;
421      context->exp_bleed   = RC_CHARGE_EXP(context->t_rc_bleed);
422      context->t_rc_charge = DSD_555_ASTBL_T_RC_CHARGE;
423      context->exp_charge  = RC_CHARGE_EXP(context->t_rc_charge);
424      context->t_rc_discharge = DSD_555_ASTBL_T_RC_DISCHARGE;
425      context->exp_discharge  = RC_CHARGE_EXP(context->t_rc_discharge);
427426   }
428427
429428   context->output_is_ac = info->options & DISC_555_OUT_AC;
r3514r3515
507506         else
508507         {
509508            /* Charging */
510            v_cap_next = v_cap + ((info->v_pos - v_cap) * (1.0 - exp(-(discrete_current_context->sample_time / (DSD_555_MSTBL__R * DSD_555_MSTBL__C)))));
509            v_cap_next = v_cap + ((info->v_pos - v_cap) * RC_CHARGE_EXP(DSD_555_MSTBL__R * DSD_555_MSTBL__C));
511510
512511            /* Has it charged past upper limit? */
513512            /* If trigger is still enabled, then we keep charging,
r3514r3515
603602#define DSD_555_CC_RC_MASK   0x78
604603
605604/* charge/discharge constants */
606#define DSD_555_CC_T_RC_BLEED         (DEFAULT_555_CAP_BLEED * DSD_555_CC__C)
605#define DSD_555_CC_T_RC_BLEED         (DEFAULT_555_BLEED_R * DSD_555_CC__C)
607606#define DSD_555_CC_T_RC_DISCHARGE_01   (DSD_555_CC__RDIS * DSD_555_CC__C)
608607#define DSD_555_CC_T_RC_DISCHARGE_NO_I   (DSD_555_CC__RGND * DSD_555_CC__C)
609608#define DSD_555_CC_T_RC_CHARGE         (r_charge * DSD_555_CC__C)
r3514r3515
714713               if (update_exponent)
715714               {
716715                  t_rc     = DSD_555_CC_T_RC_BLEED;
717                  exponent = 1.0 - exp(-(dt / t_rc));
716                  exponent = RC_CHARGE_EXP_DT(t_rc, dt);
718717               }
719718               else
720719                  exponent = context->exp_bleed;
r3514r3515
755754            else
756755               t_rc = context->t_rc_discharge_01;
757756            if (update_exponent)
758               exponent = 1.0 - exp(-(dt / t_rc));
757               exponent = RC_CHARGE_EXP_DT(t_rc, dt);
759758            else
760759               exponent = context->exp_discharge_01;
761760
r3514r3515
808807               else
809808                  t_rc = context->t_rc_discharge_no_i;
810809               if (update_exponent)
811                  exponent = 1.0 - exp(-(dt / t_rc));
810                  exponent = RC_CHARGE_EXP_DT(t_rc, dt);
812811               else
813812                  exponent = context->exp_discharge_no_i;
814813
r3514r3515
829828               else
830829                  t_rc = context->t_rc_charge;
831830               if (update_exponent)
832                  exponent = 1.0 - exp(-(dt / t_rc));
831                  exponent = RC_CHARGE_EXP_DT(t_rc, dt);
833832               else
834833                  exponent = context->exp_charge;
835834
r3514r3515
857856            else
858857               t_rc = context->t_rc_discharge;
859858            if (update_exponent)
860               exponent = 1.0 - exp(-(dt / t_rc));
859               exponent = RC_CHARGE_EXP_DT(t_rc, dt);
861860            else
862861               exponent = context->exp_discharge;
863862
r3514r3515
935934   const  discrete_555_cc_desc *info    = node->custom;
936935   struct dsd_555_cc_context   *context = node->context;
937936
938   double   neg_dt = 0.0 - discrete_current_context->sample_time;
939   double   r_temp, r_discharge = 0, r_charge = 0, t_rc;
937   double   r_temp, r_discharge = 0, r_charge = 0;
940938
941939   context->flip_flop   = 1;
942940   context->cap_voltage = 0;
r3514r3515
996994            break;
997995      }
998996
999      t_rc = DSD_555_CC_T_RC_BLEED;
1000      context->exp_bleed  = 1.0 - exp(neg_dt / t_rc);
1001      t_rc = DSD_555_CC_T_RC_DISCHARGE_01;
1002      context->exp_discharge_01  = 1.0 - exp(neg_dt / t_rc);
1003      context->t_rc_discharge_01 = t_rc;
1004      t_rc = DSD_555_CC_T_RC_DISCHARGE_NO_I;
1005      context->exp_discharge_no_i  = 1.0 - exp(neg_dt / t_rc);
1006      context->t_rc_discharge_no_i = t_rc;
1007      t_rc = DSD_555_CC_T_RC_CHARGE;
1008      context->exp_charge  = 1.0 - exp(neg_dt / t_rc);
1009      context->t_rc_charge = t_rc;
1010      t_rc = DSD_555_CC_T_RC_DISCHARGE;
1011      context->exp_discharge  = 1.0 - exp(neg_dt / t_rc);
1012      context->t_rc_discharge = t_rc;
997      context->exp_bleed  = RC_CHARGE_EXP(DSD_555_CC_T_RC_BLEED);
998      context->t_rc_discharge_01 = DSD_555_CC_T_RC_DISCHARGE_01;
999      context->exp_discharge_01  = RC_CHARGE_EXP(context->t_rc_discharge_01);
1000      context->t_rc_discharge_no_i = DSD_555_CC_T_RC_DISCHARGE_NO_I;
1001      context->exp_discharge_no_i  = RC_CHARGE_EXP(context->t_rc_discharge_no_i);
1002      context->t_rc_charge = DSD_555_CC_T_RC_CHARGE;
1003      context->exp_charge  = RC_CHARGE_EXP(context->t_rc_charge);
1004      context->t_rc_discharge = DSD_555_CC_T_RC_DISCHARGE;
1005      context->exp_discharge  = RC_CHARGE_EXP(context->t_rc_discharge);
10131006   }
10141007
10151008   /* Step to set the output */
r3514r3515
16061599      double   dt;   /* change in time */
16071600      double   sample_t;
16081601      double   t;
1609      int      lst, cntf=0, cntr=0;
1602      int      lst, cntf = 0, cntr = 0;
16101603
16111604      sample_t = discrete_current_context->sample_time;   /* Change in time */
16121605      dt  = LS624_T(DSD_LS624__C, DSD_LS624__VRNG, DSD_LS624__VMOD);
r3514r3515
16151608      lst = context->state;
16161609      while (t + dt < sample_t)
16171610      {
1618         context->state = (1-context->state);
1611         context->state = (1 - context->state);
16191612         if (context->state)
16201613            cntr++;
16211614         else
r3514r3515
16271620      switch (context->out_type)
16281621      {
16291622         case DISC_LS624_OUT_ENERGY:
1630            node->output[0] = ((double) lst) * (1.0+context->remain/sample_t) - ((double) context->state) * context->remain/sample_t;
1623            node->output[0] = ((double)lst) * (1.0 + context->remain / sample_t) - ((double)context->state) * context->remain / sample_t;
16311624            break;
16321625         case DISC_LS624_OUT_LOGIC:
16331626            node->output[0] = context->state;
src/emu/sound/disc_wav.c
r3514r3515
3939   double   t_left;      /* time unused during last sample in seconds */
4040};
4141
42#define DSS_INV_TAB_SIZE   500
43
44struct dss_inverter_osc_context
45{
46   double   w;
47   double  wc;
48   double   v_cap;
49   double  v_g2_old;
50   double   rp;
51   double  r1;
52   double  r2;
53   double  c;
54   double   tf_a;
55   double   tf_b;
56   double  tf_tab[DSS_INV_TAB_SIZE];
57};
58
4259struct dss_lfsr_context
4360{
4461   unsigned int   lfsr_reg;
r3514r3515
138155   double phase;
139156};
140157
141#define DSS_INV_TAB_SIZE   500
142158
143struct dss_inverter_osc_context
144{
145   double   w;
146   double  wc;
147   double   v_cap;
148   double  v_g2_old;
149   double   rp;
150   double  r1;
151   double  r2;
152   double  c;
153   double   tf_a;
154   double   tf_b;
155   double  tf_tab[DSS_INV_TAB_SIZE];
156};
157
158
159159/************************************************************************
160160 *
161161 * DSS_COUNTER - External clock Binary Counter
r3514r3515
11391139            /* calculate the overshoot time */
11401140            t = context->rc * log(1.0 / (1.0 - ((new_vCap - info->trshRise) / (info->vGate - v_cap))));
11411141            /* calculate new exponent because of reduced time */
1142            exponent = 1.0 - exp(-t / context->rc);
1142            exponent = RC_CHARGE_EXP_DT(context->rc, t);
11431143            v_cap    = new_vCap = info->trshRise;
11441144            context->state = 0;
11451145         }
r3514r3515
11531153            /* calculate the overshoot time */
11541154            t = context->rc * log(1.0 / (1.0 - ((info->trshFall - new_vCap) / v_cap)));
11551155            /* calculate new exponent because of reduced time */
1156            exponent = 1.0 - exp(-t / context->rc);
1156            exponent = RC_CHARGE_EXP_DT(context->rc, t);
11571157            v_cap    = new_vCap = info->trshFall;
11581158            context->state = 1;
11591159         }
r3514r3515
11981198     * So use this for the RC charge constant. */
11991199   rSource     = 1.0 / ((1.0 / info->rIn) + (1.0 / info->rFeedback));
12001200   context->rc = rSource * info->c;
1201   context->exponent = -1.0 / (context->rc  * discrete_current_context->sample_rate);
1202   context->exponent = 1.0 - exp(context->exponent);
1201   context->exponent = RC_CHARGE_EXP(context->rc);
12031202
12041203   /* Cap is at 0V on power up.  Causing output to be high. */
12051204   context->v_cap = 0;
src/emu/sound/disc_flt.c
r3514r3515
1919 * DST_RCDISC5           - Diode in series with R//C
2020 * DST_RCDISC_MOD        - RC triggered by logic and modulated
2121 * DST_RCFILTER          - Simple RC filter & also lowpass filter
22 * DST_RCFILTER_SW       - Usage of node_description values for switchable RC filter
2223 * DST_RCINTEGRATE       - Two diode inputs, transistor and a R/C charge
2324 *                         discharge network
25 * DST_SALLEN_KEY        - Sallen-Key filter circuit
2426 *
2527 ************************************************************************/
2628
r3514r3515
99101struct dst_rcfilter_sw_context
100102{
101103   double   vCap[4];
104   double   exp[4];
102105};
103106
104107struct dst_rcintegrate_context
r3514r3515
152155{
153156   struct dst_rcfilter_context *context = node->context;
154157
155   context->exponent = -1.0 / (DST_CRFILTER__R * DST_CRFILTER__C * discrete_current_context->sample_rate);
156   context->exponent =  1.0 - exp(context->exponent);
158   context->exponent = RC_CHARGE_EXP(DST_CRFILTER__R * DST_CRFILTER__C);
157159   context->vCap   = 0;
158160   node->output[0] = DST_CRFILTER__IN;
159161}
r3514r3515
316318   node->output[0] = 0;
317319}
318320
319/************************************************************************
320 *
321 * DST_SALLEN_KEY - Sallen-Key filter circuit
322 *
323 * input[0]    - Enable input value
324 * input[1]    - IN0 node
325 * input[3]    - Filter Type
326 *
327 * also passed discrete_op_amp_filt_info structure
328 *
329 * 2008, couriersud
330 ************************************************************************/
331#define DST_SALLEN_KEY__ENABLE   (*(node->input[0]))
332#define DST_SALLEN_KEY__INP0   (*(node->input[1]))
333#define DST_SALLEN_KEY__TYPE   (*(node->input[2]))
334321
335static void dst_sallen_key_step(node_description *node)
336{
337   struct dss_filter2_context *context = node->context;
338
339   double gain = 1.0;
340
341   if (DST_SALLEN_KEY__ENABLE == 0.0)
342   {
343      gain = 0.0;
344   }
345
346   node->output[0] = -context->a1 * context->y1 - context->a2 * context->y2 +
347               context->b0 * gain * DST_SALLEN_KEY__INP0 + context->b1 * context->x1 + context->b2 * context->x2;
348
349   context->x2 = context->x1;
350   context->x1 = gain * DST_SALLEN_KEY__INP0;
351   context->y2 = context->y1;
352   context->y1 = node->output[0];
353}
354
355static void dst_sallen_key_reset(node_description *node)
356{
357   struct dss_filter2_context       *context = node->context;
358   const  discrete_op_amp_filt_info *info    = node->custom;
359
360   double freq, q;
361
362   switch ((int) DST_SALLEN_KEY__TYPE)
363   {
364      case DISC_SALLEN_KEY_LOW_PASS:
365          freq = 1.0 / ( 2.0 * M_PI * sqrt(info->c1 * info->c2 * info->r1 * info->r2));
366          q = sqrt(info->c1 * info->c2 * info->r1 * info->r2) / (info->c2 * (info->r1 + info->r2));
367          break;
368      default:
369         fatalerror("Unknown sallen key filter type");
370   }
371
372   calculate_filter2_coefficients(freq, 1.0 / q, DISC_FILTER_LOWPASS,
373                           &context->a1, &context->a2,
374                           &context->b0, &context->b1, &context->b2);
375   node->output[0] = 0;
376}
377
378322/************************************************************************
379323 *
380324 * DST_OP_AMP_FILT - Op Amp filter circuit RC filter
r3514r3515
521465   switch (context->type)
522466   {
523467      case DISC_OP_AMP_FILTER_IS_LOW_PASS_1:
524         context->exponentC1 = -1.0 / (info->rF * info->c1 * discrete_current_context->sample_rate);
525         context->exponentC1 =  1.0 - exp(context->exponentC1);
468         context->exponentC1 = RC_CHARGE_EXP(info->rF * info->c1);
526469         context->exponentC2 =  0;
527470         break;
528471      case DISC_OP_AMP_FILTER_IS_HIGH_PASS_1:
529         context->exponentC1 = -1.0 / (context->rTotal * info->c1 * discrete_current_context->sample_rate);
530         context->exponentC1 =  1.0 - exp(context->exponentC1);
472         context->exponentC1 = RC_CHARGE_EXP(context->rTotal * info->c1);
531473         context->exponentC2 =  0;
532474         break;
533475      case DISC_OP_AMP_FILTER_IS_BAND_PASS_1:
534         context->exponentC1 = -1.0 / (info->rF * info->c1 * discrete_current_context->sample_rate);
535         context->exponentC1 =  1.0 - exp(context->exponentC1);
536         context->exponentC2 = -1.0 / (context->rTotal * info->c2 * discrete_current_context->sample_rate);
537         context->exponentC2 =  1.0 - exp(context->exponentC2);
476         context->exponentC1 = RC_CHARGE_EXP(info->rF * info->c1);
477         context->exponentC2 = RC_CHARGE_EXP(context->rTotal * info->c2);
538478         break;
539479      case DISC_OP_AMP_FILTER_IS_BAND_PASS_1M | DISC_OP_AMP_IS_NORTON:
540480         context->rTotal = 1.0 / (1.0 / info->r1 + 1.0 / info->r2);
r3514r3515
559499         break;
560500      }
561501      case DISC_OP_AMP_FILTER_IS_BAND_PASS_0 | DISC_OP_AMP_IS_NORTON:
562         context->exponentC1 = -1.0 / ((1.0 / (1.0 / info->r1 + 1.0 / (info->r2 + info->r3 + info->r4))) * info->c1 * discrete_current_context->sample_rate);
563         context->exponentC1 =  1.0 - exp(context->exponentC1);
564         context->exponentC2 = -1.0 / ((1.0 / (1.0 / (info->r1 + info->r2) + 1.0 / (info->r3 + info->r4))) * info->c2 * discrete_current_context->sample_rate);
565         context->exponentC2 =  1.0 - exp(context->exponentC2);
566         context->exponentC3 = -1.0 / ((info->r1 + info->r2 + info->r3 + info->r4) * info->c3 * discrete_current_context->sample_rate);
567         context->exponentC3 =  1.0 - exp(context->exponentC3);
502         context->exponentC1 = RC_CHARGE_EXP(RES_2_PARALLEL(info->r1, info->r2 + info->r3 + info->r4) * info->c1);
503         context->exponentC2 = RC_CHARGE_EXP(RES_2_PARALLEL(info->r1 + info->r2, info->r3 + info->r4) * info->c2);
504         context->exponentC3 = RC_CHARGE_EXP((info->r1 + info->r2 + info->r3 + info->r4) * info->c3);
568505         break;
569506      case DISC_OP_AMP_FILTER_IS_HIGH_PASS_0 | DISC_OP_AMP_IS_NORTON:
570         context->exponentC1 = -1.0 / (info->r1 * info->c1 * discrete_current_context->sample_rate);
571         context->exponentC1 =  1.0 - exp(context->exponentC1);
507         context->exponentC1 = RC_CHARGE_EXP(info->r1 * info->c1);
572508         break;
573509   }
574510
r3514r3515
679615
680616   context->state = 0;
681617   context->t = 0;
682   context->exponent0 = -1.0 * DST_RCDISC2__R0 * DST_RCDISC2__C;
683   context->exponent1 = -1.0 * DST_RCDISC2__R1 * DST_RCDISC2__C;
684   context->exponent0 = exp(discrete_current_context->sample_time/context->exponent0);
685   context->exponent1 = exp(discrete_current_context->sample_time/context->exponent1);
618   context->exponent0 = RC_DISCHARGE_EXP(DST_RCDISC2__R0 * DST_RCDISC2__C);
619   context->exponent1 = RC_DISCHARGE_EXP(DST_RCDISC2__R1 * DST_RCDISC2__C);
686620}
687621
688622/************************************************************************
r3514r3515
716650      diff = DST_RCDISC3__IN - node->output[0];
717651      if( diff > 0 )
718652      {
719         diff = diff - (diff * exp(discrete_current_context->sample_time / context->exponent0));
653         diff = diff - (diff * context->exponent0);
720654      } else if( diff < 0)
721655      {
722656         if(diff < -0.5)
723            diff = diff - (diff * exp(discrete_current_context->sample_time / context->exponent1));
657            diff = diff - (diff * context->exponent1);
724658         else
725            diff = diff - (diff * exp(discrete_current_context->sample_time / context->exponent0));
659            diff = diff - (diff * context->exponent0);
726660      }
727661      node->output[0] += diff;
728662   }
r3514r3515
740674
741675   context->state = 0;
742676   context->t = 0;
743   context->exponent0 = -1.0 * DST_RCDISC3__R1 * DST_RCDISC3__C;
744   context->exponent1 = -1.0 *(DST_RCDISC3__R1 * DST_RCDISC3__R2)/( DST_RCDISC3__R1 + DST_RCDISC3__R2)* DST_RCDISC3__C;
677   context->exponent0 = RC_CHARGE_EXP(DST_RCDISC3__R1 * DST_RCDISC3__C);
678   context->exponent1 = RC_CHARGE_EXP(RES_2_PARALLEL(DST_RCDISC3__R1, DST_RCDISC3__R2) * DST_RCDISC3__C);
745679}
746680
747681
r3514r3515
832766         v = DST_RCDISC4__VP - .5;   /* diode drop */
833767
834768         /* When the input is 1, both R1 & R3 are basically in parallel. */
835         r  = 1.0 / (1.0 / DST_RCDISC4__R1 + 1.0 / DST_RCDISC4__R3);
769         r  = RES_2_PARALLEL(DST_RCDISC4__R1, DST_RCDISC4__R3);
836770         rT = DST_RCDISC4__R2 + r;
837771         i  = v / rT;
838772         context->v[1] = i * r + .5;
839         rT = 1.0 / (1.0 / DST_RCDISC4__R2 + 1.0 / r);
840         context->exp[1] = -1.0 / (rT * DST_RCDISC4__C1 * discrete_current_context->sample_rate);
841         context->exp[1] =  1.0 - exp(context->exp[1]);
773         rT = RES_2_PARALLEL(DST_RCDISC4__R2, r);
774         context->exp[1] = RC_CHARGE_EXP(rT * DST_RCDISC4__C1);
842775
843776         /* When the input is 0, R1 is out of circuit. */
844777         rT = DST_RCDISC4__R2 + DST_RCDISC4__R3;
845778         i  = v / rT;
846779         context->v[0] = i * DST_RCDISC4__R3 + .5;
847         rT = 1.0 / (1.0 / DST_RCDISC4__R2 + 1.0 / DST_RCDISC4__R3);
848         context->exp[0] = -1.0 / (rT * DST_RCDISC4__C1 * discrete_current_context->sample_rate);
849         context->exp[0] =  1.0 - exp(context->exp[0]);
780         rT = RES_2_PARALLEL(DST_RCDISC4__R2, DST_RCDISC4__R3);
781         context->exp[0] = RC_CHARGE_EXP(rT * DST_RCDISC4__C1);
850782         break;
851783
852784      case 3:
r3514r3515
855787             * resistance, so we will just use .5k in series with R1.
856788             */
857789         r = 500.0 + DST_RCDISC4__R1;
858         context->v[1] = DST_RCDISC4__R2 / (r + DST_RCDISC4__R2) * (5.0 - 0.5);
859         rT = 1.0 / ( 1.0 / r + 1.0 / DST_RCDISC4__R2);
860         context->exp[1] = -1.0 / (rT * DST_RCDISC4__C1 * discrete_current_context->sample_rate);
861         context->exp[1] =  1.0 - exp(context->exp[1]);
790         context->v[1] = RES_VOLTAGE_DIVIDER(r, DST_RCDISC4__R2) * (5.0 - 0.5);
791         rT = RES_2_PARALLEL(r, DST_RCDISC4__R2);
792         context->exp[1] = RC_CHARGE_EXP(rT * DST_RCDISC4__C1);
862793
863794         /* When the input is 0, R1 is out of circuit. */
864795         context->v[0] = 0;
865         context->exp[0] = -1.0 / (DST_RCDISC4__R2 * DST_RCDISC4__C1 * discrete_current_context->sample_rate);
866         context->exp[0] =  1.0 - exp(context->exp[0]);
796         context->exp[0] = RC_CHARGE_EXP(DST_RCDISC4__R2 * DST_RCDISC4__C1);
867797         break;
868798   }
869799}
r3514r3515
901831
902832      if(diff < 0)
903833         //diff = diff - (diff * exp(discrete_current_context->sample_time / context->exponent0));
904         diff = -node->output[0] + (node->output[0] * exp(discrete_current_context->sample_time / context->exponent0));
834         diff = -node->output[0] + (node->output[0] * context->exponent0);
905835      node->output[0] += diff;
906836   }
907837   else
r3514r3515
918848
919849   context->state = 0;
920850   context->t = 0;
921   context->exponent0 = -1.0 * DST_RCDISC5__R * DST_RCDISC5__C;
851   context->exponent0 = RC_CHARGE_EXP(DST_RCDISC5__R * DST_RCDISC5__C);
922852}
923853
924854
r3514r3515
986916   struct dst_rcdisc_mod_context *context = node->context;
987917
988918   double   rc[2], rc2[2];
989   double   neg_dt = 0.0 - discrete_current_context->sample_time;
990919
991920   /* pre-calculate fixed values */
992921   /* DST_RCDISC_MOD__IN1 <= 0.5 */
993922   rc[0] = DST_RCDISC_MOD__R1 + DST_RCDISC_MOD__R2;
994923   if (rc[0] < 1) rc[0] = 1;
995   context->exp_low[0]  = exp(neg_dt / (DST_RCDISC_MOD__C * rc[0]));
924   context->exp_low[0]  = RC_DISCHARGE_EXP(DST_RCDISC_MOD__C * rc[0]);
996925   context->gain[0]     = RES_VOLTAGE_DIVIDER(rc[0], DST_RCDISC_MOD__R4);
997926   /* DST_RCDISC_MOD__IN1 > 0.5 */
998927   rc[1] = DST_RCDISC_MOD__R2;
999928   if (rc[1] < 1) rc[1] = 1;
1000   context->exp_low[1]  = exp(neg_dt / (DST_RCDISC_MOD__C * rc[1]));
929   context->exp_low[1]  = RC_DISCHARGE_EXP(DST_RCDISC_MOD__C * rc[1]);
1001930   context->gain[1]     = RES_VOLTAGE_DIVIDER(rc[1], DST_RCDISC_MOD__R4);
1002931   /* DST_RCDISC_MOD__IN2 <= 0.6 */
1003932   rc2[0] = DST_RCDISC_MOD__R4;
1004933   /* DST_RCDISC_MOD__IN2 > 0.6 */
1005   rc2[1] = DST_RCDISC_MOD__R3 * DST_RCDISC_MOD__R4 / (DST_RCDISC_MOD__R3 + DST_RCDISC_MOD__R4);
934   rc2[1] = RES_2_PARALLEL(DST_RCDISC_MOD__R3, DST_RCDISC_MOD__R4);
1006935   /* DST_RCDISC_MOD__IN1 <= 0.5 && DST_RCDISC_MOD__IN2 <= 0.6 */
1007   context->exp_high[0] = exp(neg_dt / (DST_RCDISC_MOD__C * (rc[0] + rc2[0])));
936   context->exp_high[0] = RC_DISCHARGE_EXP(DST_RCDISC_MOD__C * (rc[0] + rc2[0]));
1008937   context->vd_gain[0]  = RES_VOLTAGE_DIVIDER(rc[0], rc2[0]);
1009938   /* DST_RCDISC_MOD__IN1 > 0.5  && DST_RCDISC_MOD__IN2 <= 0.6 */
1010   context->exp_high[1] = exp(neg_dt / (DST_RCDISC_MOD__C * (rc[1] + rc2[0])));
939   context->exp_high[1] = RC_DISCHARGE_EXP(DST_RCDISC_MOD__C * (rc[1] + rc2[0]));
1011940   context->vd_gain[1]  = RES_VOLTAGE_DIVIDER(rc[1], rc2[0]);
1012941   /* DST_RCDISC_MOD__IN1 <= 0.5 && DST_RCDISC_MOD__IN2 > 0.6 */
1013   context->exp_high[2] = exp(neg_dt / (DST_RCDISC_MOD__C * (rc[0] + rc2[1])));
942   context->exp_high[2] = RC_DISCHARGE_EXP(DST_RCDISC_MOD__C * (rc[0] + rc2[1]));
1014943   context->vd_gain[2]  = RES_VOLTAGE_DIVIDER(rc[0], rc2[1]);
1015944   /* DST_RCDISC_MOD__IN1 > 0.5  && DST_RCDISC_MOD__IN2 > 0.6 */
1016   context->exp_high[3] = exp(neg_dt / (DST_RCDISC_MOD__C * (rc[1] + rc2[1])));
945   context->exp_high[3] = RC_DISCHARGE_EXP(DST_RCDISC_MOD__C * (rc[1] + rc2[1]));
1017946   context->vd_gain[3]  = RES_VOLTAGE_DIVIDER(rc[1], rc2[1]);
1018947
1019948   context->v_cap  = 0;
r3514r3515
1060989{
1061990   struct dst_rcfilter_context *context = node->context;
1062991
1063   context->exponent = -1.0 / (DST_RCFILTER__R * DST_RCFILTER__C * discrete_current_context->sample_rate);
1064   context->exponent = 1.0 - exp(context->exponent);
992   context->exponent = RC_CHARGE_EXP(DST_RCFILTER__R * DST_RCFILTER__C);
1065993   context->vCap   = 0;
1066994   node->output[0] = 0;
1067995}
r3514r3515
10901018   struct dst_rcfilter_sw_context *context = node->context;
10911019
10921020   int i;
1093   double rcexp;
10941021   int bits = (int)DST_RCFILTER_SW__SWITCH;
10951022   double us = 0, rs = 0;
10961023
r3514r3515
11041031            rs += DST_RCFILTER_SW__R;
11051032         }
11061033      }
1107      node->output[0] = CD4066_ON_RES / ( CD4066_ON_RES + rs) * DST_RCFILTER_SW__VIN + DST_RCFILTER_SW__R / (CD4066_ON_RES + rs)  * us;
1034      node->output[0] = RES_VOLTAGE_DIVIDER(rs, CD4066_ON_RES) * DST_RCFILTER_SW__VIN + DST_RCFILTER_SW__R / (CD4066_ON_RES + rs)  * us;
11081035      for (i = 0; i < 4; i++)
11091036      {
11101037         if (( bits & (1 << i)) != 0)
11111038         {
1112            rcexp = 1.0 - exp(-1.0 / ( CD4066_ON_RES * DST_RCFILTER_SW__C(i)) * discrete_current_context->sample_rate);
1113            context->vCap[i] += ((node->output[0] - context->vCap[i]) * rcexp);
1039            context->vCap[i] += (node->output[0] - context->vCap[i]) * context->exp[i];
11141040         }
11151041      }
11161042   }
r3514r3515
11271053   int i;
11281054
11291055   for (i = 0; i < 4; i++)
1056   {
11301057      context->vCap[i] = 0;
1058      context->exp[i] = RC_CHARGE_EXP(CD4066_ON_RES * DST_RCFILTER_SW__C(i));
1059   }
11311060   node->output[0] = 0;
11321061}
11331062
r3514r3515
11831112   {
11841113      /* discharge .... */
11851114      diff  = 0.0 - context->vCap;
1186      iC    = 0.0 - context->c_exp1 * diff; /* iC */
1115      iC    = context->c_exp1 * diff; /* iC */
11871116      diff -= diff * context->exp_exponent1;
11881117      context->vCap += diff;
11891118      iQ = 0;
11901119      vE = context->vCap * context->gain_r1_r2;
1191      RG = vE / (-iC);
1120      RG = vE / iC;
11921121   }
11931122   else
11941123   {
r3514r3515
12581187   node->output[0] = 0;
12591188}
12601189
1190/************************************************************************
1191 *
1192 * DST_SALLEN_KEY - Sallen-Key filter circuit
1193 *
1194 * input[0]    - Enable input value
1195 * input[1]    - IN0 node
1196 * input[3]    - Filter Type
1197 *
1198 * also passed discrete_op_amp_filt_info structure
1199 *
1200 * 2008, couriersud
1201 ************************************************************************/
1202#define DST_SALLEN_KEY__ENABLE   (*(node->input[0]))
1203#define DST_SALLEN_KEY__INP0   (*(node->input[1]))
1204#define DST_SALLEN_KEY__TYPE   (*(node->input[2]))
12611205
1206static void dst_sallen_key_step(node_description *node)
1207{
1208   struct dss_filter2_context *context = node->context;
1209
1210   double gain = 1.0;
1211
1212   if (DST_SALLEN_KEY__ENABLE == 0.0)
1213   {
1214      gain = 0.0;
1215   }
1216
1217   node->output[0] = -context->a1 * context->y1 - context->a2 * context->y2 +
1218               context->b0 * gain * DST_SALLEN_KEY__INP0 + context->b1 * context->x1 + context->b2 * context->x2;
1219
1220   context->x2 = context->x1;
1221   context->x1 = gain * DST_SALLEN_KEY__INP0;
1222   context->y2 = context->y1;
1223   context->y1 = node->output[0];
1224}
1225
1226static void dst_sallen_key_reset(node_description *node)
1227{
1228   struct dss_filter2_context       *context = node->context;
1229   const  discrete_op_amp_filt_info *info    = node->custom;
1230
1231   double freq, q;
1232
1233   switch ((int) DST_SALLEN_KEY__TYPE)
1234   {
1235      case DISC_SALLEN_KEY_LOW_PASS:
1236          freq = 1.0 / ( 2.0 * M_PI * sqrt(info->c1 * info->c2 * info->r1 * info->r2));
1237          q = sqrt(info->c1 * info->c2 * info->r1 * info->r2) / (info->c2 * (info->r1 + info->r2));
1238          break;
1239      default:
1240         fatalerror("Unknown sallen key filter type");
1241   }
1242
1243   calculate_filter2_coefficients(freq, 1.0 / q, DISC_FILTER_LOWPASS,
1244                           &context->a1, &context->a2,
1245                           &context->b0, &context->b1, &context->b2);
1246   node->output[0] = 0;
1247}
1248
1249
12621250/* !!!!!!!!!!! NEW FILTERS for testing !!!!!!!!!!!!!!!!!!!!! */
12631251
12641252
src/emu/sound/nes_apu.c
r3514r3515
476476      ** dereferences and load up the other triregs
477477      */
478478
479      info->APU.tri.write_latency = 3;
479   /* used to be 3, but now we run the clock faster, so base it on samples/sync */
480      info->APU.tri.write_latency = (info->samps_per_sync + 239) / 240;
480481
481482      if (info->APU.tri.enabled)
482483      {
src/emu/render.h
r3514r3515
324324/* allocate base structures for the rendering system */
325325void render_init(running_machine *machine);
326326
327/* set a notifier that we call before doing long scaling operations */
328void render_set_rescale_notify(running_machine *machine, int (*notifier)(running_machine *, int, int));
329
330327/* return a boolean indicating if the screen is live */
331328int render_is_live_screen(const device_config *screen);
332329
r3514r3515
342339/* return the aspect ratio for UI fonts */
343340float render_get_ui_aspect(void);
344341
345/* performs an input hit test */
346int render_input_hit_test(render_target *target, INT32 target_x, INT32 target_y, const char *input_tag, UINT32 input_mask);
347342
348343
349
350344/* ----- render target management ----- */
351345
352346/* allocate a new render target */
src/emu/drivers/xtal.h
r3514r3515
7272   XTAL_9_987MHz      = 9987000,      /* Crazy Balloon */
7373   XTAL_10MHz         = 10000000,
7474   XTAL_10_595MHz     = 10595000,      /* Mad Alien */
75   XTAL_10_730MHz      = 10730000,      /* Ruleta RE-900 VDP Clock */
7576   XTAL_10_733MHz      = 10733000,      /* The Fairyland Story */
7677   XTAL_10_738635MHz   = 10738635,      /* TMS9918 family */
7778   XTAL_11MHz         = 11000000,      /* Mario I8039 sound */
78   XTAL_11_0592MHz     = 11059200,      /* Lethal Justice */
79   XTAL_11_0592MHz     = 11059200,      /* Lethal Justice, Ruleta RE-900 */
7980   XTAL_11_2MHz        = 11200000,      /* New York, New York */
8081   XTAL_11_289MHz     = 11289000,      /* Vanguard */
8182   XTAL_11_6688MHz     = 11668800,      /* Gameplan pixel clock */
src/lib/util/cdrom.c
r3514r3515
221221   }
222222   else
223223   {
224      /* return 2048 bytes of mode1 data from a 2336 byte mode 1 or 2 raw sector */
224      /* return 2048 bytes of mode 1 data from a 2352 byte mode 1 or 2 raw sector */
225225      if ((datatype == CD_TRACK_MODE1) && ((tracktype == CD_TRACK_MODE1_RAW) || (tracktype == CD_TRACK_MODE2_RAW)))
226226      {
227227         memcpy(buffer, &file->cache[(sectoroffs * CD_FRAME_SIZE) + 16], 2048);
228228         return 1;
229229      }
230230
231      /* return 2048 bytes of mode1 data from a mode2 form1 sector */
231      /* return 2048 bytes of mode 1 data from a mode2 form1 sector */
232232      if ((datatype == CD_TRACK_MODE1) && (tracktype == CD_TRACK_MODE2_FORM1))
233233      {
234234         memcpy(buffer, &file->cache[(sectoroffs * CD_FRAME_SIZE) + 24], 2048);
235235         return 1;
236236      }
237237
238      /* return mode 2 2336 byte data from a RAW sector */
238      /* return mode 2 2336 byte data from a 2352 byte mode 1 or 2 raw sector (skip the header) */
239239      if ((datatype == CD_TRACK_MODE2) && ((tracktype == CD_TRACK_MODE1_RAW) || (tracktype == CD_TRACK_MODE2_RAW)))
240240      {
241         memcpy(buffer, &file->cache[(sectoroffs * CD_FRAME_SIZE) + 16], 2048);
241         memcpy(buffer, &file->cache[(sectoroffs * CD_FRAME_SIZE) + 16], 2336);
242242         return 1;
243243      }
244244
src/mess/mess.mak
r3514r3515
8686#CPUS += N7751
8787#CPUS += M58715
8888CPUS += I8X41
89#CPUS += I8031
90#CPUS += I8032
8991CPUS += I8051
9092#CPUS += I8052
9193#CPUS += I8751
9294#CPUS += I8752
95#CPUS += I80C31
96#CPUS += I80C32
97#CPUS += I80C51
98#CPUS += I80C52
99#CPUS += I87C51
100#CPUS += I87C52
101#CPUS += AT89C4051
93102#CPUS += DS5002FP
94103CPUS += M6800
95104#CPUS += M6801
docs/messnew.txt
r3514r3515
3333- [NES] Fixed bug #1672.  [Wilbert Pol]
3434
3535
36
3637User Interface Changes:
3738-----------------------
3839(none)
r3514r3515
4748
4849Source Changes:
4950----------------
50- The core is based on MAME 0.128u1.  This incorporates all features of the
51- The core is based on MAME 0.128u2.  This incorporates all features of the
5152  update to this core.  [MAME team]
5253
5354

Previous 15994 Revisions Next


© 1998-2018 The MESS Team