Previous 15994 Revisions Next

r5535 Sunday 30th August, 2009 at 04:59:32 UTC by Nathan Woods
Updated to MAME 0.133u4 core
[ROOT]makefile
[docs]messnew.txt
[src/emu]emu.mak inptport.h inpttype.h
[src/emu/cpu]cpu.mak x86log.c
[src/emu/cpu/arm]arm.c armdasm.c
[src/emu/cpu/arm7]arm7.c arm7dasm.c
[src/emu/cpu/cubeqcpu]cubedasm.c* cubeqcpu.c
[src/emu/cpu/dsp32]dsp32.c dsp32dis.c
[src/emu/cpu/e132xs]32xsdasm.c
[src/emu/cpu/esrip]esrip.c esripdsm.c*
[src/emu/cpu/g65816]g65816ds.c
[src/emu/cpu/h83002]h8_16.c h8_8.c h8disasm.c
[src/emu/cpu/i386]i386dasm.c
[src/emu/cpu/i8085]i8085.c
[src/emu/cpu/i960]i960.c i960dis.c
[src/emu/cpu/jaguar]jagdasm.c jaguar.c
[src/emu/cpu/m37710]m7700ds.c
[src/emu/cpu/m68000]m68kdasm.c
[src/emu/cpu/mb86233]mb86233.c mb86233d.c
[src/emu/cpu/mips]mips3dsm.c psxdasm.c r3000.c r3kdasm.c
[src/emu/cpu/nec]necdasm.c
[src/emu/cpu/powerpc]ppc_dasm.c
[src/emu/cpu/rsp]rsp.c rsp_dasm.c
[src/emu/cpu/sh2]sh2.c sh2dasm.c sh2drc.c
[src/emu/cpu/sh4]sh4.c sh4dasm.c
[src/emu/cpu/sharc]sharc.c sharcdsm.c
[src/emu/cpu/ssem]ssem.c ssemdasm.c
[src/emu/cpu/ssp1601]ssp1601.c ssp1601d.c
[src/emu/cpu/superfx]sfx_dasm.c* superfx.c* superfx.h*
[src/emu/cpu/tms32031]dis32031.c tms32031.c
[src/emu/cpu/tms57002]57002dsm.c* tms57002.c
[src/emu/cpu/v60]v60.c v60d.c
[src/emu/cpu/z80]z80.c
[src/emu/cpu/z8000]8000dasm.c
[src/emu/sound]disc_dev.c disc_flt.c disc_inp.c disc_mth.c disc_wav.c discrete.c discrete.h
[src/emu/video]mc6845.c
[src/mame]mame.mak mamedriv.c
[src/mame/audio]bzone.c dkong.c galaxian.c mario.c redalert.c tank8.c
[src/mame/drivers]ampoker2.c bzone.c dwarfd.c goindol.c hyhoo.c kaneko16.c m79amb.c megatech.c meritm.c midtunit.c midwunit.c n8080.c namcos22.c nbmj9195.c niyanpai.c norautp.c pgm.c phoenix.c sauro.c taito_f2.c taitogn.c tiamc1.c tmaster.c toypop.c
[src/mame/includes]bzone.h kaneko16.h midtunit.h phoenix.h snes.h taito_f2.h
[src/mame/layout]noraut11.lay* noraut12.lay*
[src/mame/machine]archimds.c kaneko16.c leland.c midtunit.c
[src/mame/video]jagobj.c jaguar.c kaneko16.c leland.c phoenix.c snes.c taito_f2.c thepit.c
[src/mess]mess.mak
[src/mess/osd/windows]windows.mak
[src/mess/tools/messtest]messtest.mak
[src/osd]osdcore.h
[src/osd/osdmini]minimisc.c
[src/osd/windows]winmisc.c
[src/tools]tools.mak unidasm.c*

src/mame/audio/galaxian.c
r5534r5535
3535#define SOUND_CLOCK          (XTAL/6/2)         /* 1.536 MHz */
3636#define RNG_RATE            (XTAL/3*2)         /* RNG clock is XTAL/3*2 see Aaron's note in video/galaxian.c */
3737
38//#define DISCRETE_BITSET(_N, _N1, _B, _OV) DISCRETE_TRANSFORM4(_N, _N1, (1 << ((_B)-1)), 0, _OV, "01&2>3*")
39
4038/* 74LS259 */
4139#define GAL_INP_BG_DAC         NODE_10      /* at 9M Q4 to Q7 in schematics */
4240
r5534r5535
270268   /* Pitch */
271269   DISCRETE_INPUT_DATA(GAL_INP_PITCH)
272270
273   /************************************************/
274   /* Background                                   */
275   /************************************************/
271   /* Group Background and pitch */
272   DISCRETE_TASK_START()
273   
274      /************************************************/
275      /* Background                                   */
276      /************************************************/
277   
278      DISCRETE_DAC_R1(NODE_100, 1, GAL_INP_BG_DAC, TTL_OUT, &galaxian_bck_dac)
279      DISCRETE_555_CC(NODE_105, 1, NODE_100, GAL_R21, GAL_C15, 0, 0, 0, &galaxian_bck_vco)
280      // Next is mult/add opamp circuit
281      DISCRETE_MULTADD(NODE_110, 1, NODE_105, GAL_R33/RES_3_PARALLEL(GAL_R31,GAL_R32,GAL_R33),
282            -5.0*GAL_R33/GAL_R31)
283      DISCRETE_CLAMP(NODE_111,1,NODE_110,0.0,5.0,0.0)
284      // The three 555
285      DISCRETE_555_ASTABLE_CV(NODE_115, GAL_INP_FS1, GAL_R22, GAL_R23, GAL_C17, NODE_111, &galaxian_555_vco_desc)
286      DISCRETE_555_ASTABLE_CV(NODE_116, GAL_INP_FS2, GAL_R25, GAL_R26, GAL_C18, NODE_111, &galaxian_555_vco_desc)
287      DISCRETE_555_ASTABLE_CV(NODE_117, GAL_INP_FS3, GAL_R28, GAL_R29, GAL_C19, NODE_111, &galaxian_555_vco_desc)
288   
289      DISCRETE_MIXER3(NODE_120, 1, NODE_115, NODE_116, NODE_117, &galaxian_bck_mixer_desc)
290     
291      /************************************************/
292      /* PITCH                                        */
293      /************************************************/
294   
295      /* two cascaded LS164 which are reset to pitch latch value,
296        * thus generating SOUND_CLOCK / (256 - pitch_clock) signal
297        *
298        * One possibility to implement this is
299        * DISCRETE_TRANSFORM3(NODE_130, SOUND_CLOCK, 256, GAL_INP_PITCH, "012-/")
300        * DISCRETE_COUNTER(NODE_132, 1, 0, NODE_130, 15, DISC_COUNT_UP, 0, DISC_CLK_IS_FREQ)
301        * but there is a native choice:
302        */
303       DISCRETE_NOTE(NODE_132, 1, SOUND_CLOCK, GAL_INP_PITCH, 255, 15,  DISC_CLK_IS_FREQ)
304   
305       /* from the 74393 (counter 2 above) only QA, QC, QD are used.
306        * We decode three here and use SUB_NODE(133,x) below to access.
307        */
308       DISCRETE_BITS_DECODE(NODE_133, NODE_132, 0, 3, TTL_OUT)      /* QA-QD 74393 */
276309
277   DISCRETE_DAC_R1(NODE_100, 1, GAL_INP_BG_DAC, TTL_OUT, &galaxian_bck_dac)
278   DISCRETE_555_CC(NODE_105, 1, NODE_100, GAL_R21, GAL_C15, 0, 0, 0, &galaxian_bck_vco)
279   // Next is mult/add opamp circuit
280   DISCRETE_MULTADD(NODE_110, 1, NODE_105, GAL_R33/RES_3_PARALLEL(GAL_R31,GAL_R32,GAL_R33),
281         -5.0*GAL_R33/GAL_R31)
282   DISCRETE_CLAMP(NODE_111,1,NODE_110,0.0,5.0,0.0)
283   // The three 555
284   DISCRETE_555_ASTABLE_CV(NODE_115, GAL_INP_FS1, GAL_R22, GAL_R23, GAL_C17, NODE_111, &galaxian_555_vco_desc)
285   DISCRETE_555_ASTABLE_CV(NODE_116, GAL_INP_FS2, GAL_R25, GAL_R26, GAL_C18, NODE_111, &galaxian_555_vco_desc)
286   DISCRETE_555_ASTABLE_CV(NODE_117, GAL_INP_FS3, GAL_R28, GAL_R29, GAL_C19, NODE_111, &galaxian_555_vco_desc)
310    /* End of this task */
311    DISCRETE_TASK_END5(NODE_120, NODE_SUB(133,0),NODE_SUB(133,1),NODE_SUB(133,2),NODE_SUB(133,3))
312   
313    /* Group Hit and Fire */
287314
288   DISCRETE_MIXER3(NODE_120, 1, NODE_115, NODE_116, NODE_117, &galaxian_bck_mixer_desc)
315    DISCRETE_TASK_START()
289316
290   /************************************************/
291   /* PITCH                                        */
292   /************************************************/
317       /************************************************/
318      /* HIT                                          */
319      /************************************************/
293320
294   /* two cascaded LS164 which are reset to pitch latch value,
295     * thus generating SOUND_CLOCK / (256 - pitch_clock) signal
296     *
297     * One possibility to implement this is
298     * DISCRETE_TRANSFORM3(NODE_130, SOUND_CLOCK, 256, GAL_INP_PITCH, "012-/")
299     * DISCRETE_COUNTER(NODE_132, 1, 0, NODE_130, 15, DISC_COUNT_UP, 0, DISC_CLK_IS_FREQ)
300     * but there is a native choice:
301     */
302    DISCRETE_NOTE(NODE_132, 1, SOUND_CLOCK, GAL_INP_PITCH, 255, 15,  DISC_CLK_IS_FREQ)
321       /* NOISE */
322       /* since only a sample of the LFSR is latched @V2 we let the lfsr
323        * run at a lower speed
324        */
325       DISCRETE_LFSR_NOISE(NODE_150, 1, 1, RNG_RATE/100, 1.0, 0, 0.5, &galaxian_lfsr)
326      DISCRETE_SQUAREWFIX(NODE_151,1,60*264/2,1.0,50,0.5,0)  /* 2V signal */
327      DISCRETE_LOGIC_DFLIPFLOP(NODE_152,1,1,1,NODE_151,NODE_150)
303328
304    /* from the 74393 (counter 2 above) only QA, QC, QD are used.
305     * We decode three here and use SUB_NODE(133,x) below to access.
306     */
307    DISCRETE_BITS_DECODE(NODE_133, NODE_132, 0, 3, TTL_OUT)      /* QA-QD 74393 */
329   
330      /* Not 100% correct - switching causes high impedance input for node_157
331        * this is not emulated */
332      DISCRETE_RCDISC5(NODE_155, NODE_152, GAL_INP_HIT, (GAL_R35 + GAL_R36), GAL_C21)
333      DISCRETE_OP_AMP_FILTER(NODE_157, 1, NODE_155, 0, DISC_OP_AMP_FILTER_IS_BAND_PASS_1M, &galaxian_bandpass_desc)
334     
335      /************************************************/
336      /* FIRE                                         */
337      /************************************************/
338     
339      DISCRETE_LOGIC_INVERT(NODE_170, 1, GAL_INP_FIRE)
340      DISCRETE_MULTIPLY(NODE_171, 1, TTL_OUT, GAL_INP_FIRE)
341      DISCRETE_MULTIPLY(NODE_172, 1, TTL_OUT, NODE_170) // inverted
342      DISCRETE_RCFILTER(NODE_173, 1, NODE_172, GAL_R47, GAL_C28)
343      /* Mix noise and 163 */
344      DISCRETE_TRANSFORM5(NODE_177, NODE_152, TTL_OUT, 1.0/GAL_R46, NODE_173, 1.0/GAL_R48,
345            "01*2*34*+" )
346      //DISCRETE_MULTIPLY(NODE_174, 1, TTL_OUT, NODE_152)
347      //DISCRETE_MULTIPLY(NODE_175, 1, 1.0/GAL_R46, NODE_174)
348      //DISCRETE_MULTIPLY(NODE_176, 1, 1.0/GAL_R48, NODE_173)
349      //DISCRETE_ADDER2(NODE_177, 1, NODE_175, NODE_176)
350      DISCRETE_MULTIPLY(NODE_178, 1, RES_2_PARALLEL(GAL_R46, GAL_R48), NODE_177)
351   
352      DISCRETE_555_ASTABLE_CV(NODE_181, 1, GAL_R44, GAL_R45, GAL_C27, NODE_178, &galaxian_555_fire_vco_desc)
353   
354      /* 555 toggles discharge on rc discharge module */
355      DISCRETE_RCDISC5(NODE_182, NODE_181, NODE_171, (GAL_R41), GAL_C25)
308356
309   /************************************************/
310   /* HIT                                          */
311   /************************************************/
357   /* End of task */
358   DISCRETE_TASK_END2(NODE_157, NODE_182)
312359
313    /* NOISE */
314    /* since only a sample of the LFSR is latched @V2 we let the lfsr
315     * run at a lower speed
316     */
317   DISCRETE_LFSR_NOISE(NODE_150, 1, 1, RNG_RATE/100, 1.0, 0, 0.5, &galaxian_lfsr)
318   DISCRETE_SQUAREWFIX(NODE_151,1,60*264/2,1.0,50,0.5,0)  /* 2V signal */
319   DISCRETE_LOGIC_DFLIPFLOP(NODE_152,1,1,1,NODE_151,NODE_150)
320
321
322   /* Not 100% correct - switching causes high impedance input for node_157
323     * this is not emulated */
324   DISCRETE_RCDISC5(NODE_155, NODE_152, GAL_INP_HIT, (GAL_R35 + GAL_R36), GAL_C21)
325   DISCRETE_OP_AMP_FILTER(NODE_157, 1, NODE_155, 0, DISC_OP_AMP_FILTER_IS_BAND_PASS_1M, &galaxian_bandpass_desc)
326
327360   /************************************************/
328   /* FIRE                                         */
329   /************************************************/
330   DISCRETE_LOGIC_INVERT(NODE_160, 1, GAL_INP_FIRE)
331   DISCRETE_MULTIPLY(NODE_161, 1, TTL_OUT, GAL_INP_FIRE)
332   DISCRETE_MULTIPLY(NODE_162, 1, TTL_OUT, NODE_160) // inverted
333   DISCRETE_RCFILTER(NODE_163, 1, NODE_162, GAL_R47, GAL_C28)
334   /* Mix noise and 163 */
335   DISCRETE_TRANSFORM5(NODE_167, NODE_152, TTL_OUT, 1.0/GAL_R46, NODE_163, 1.0/GAL_R48,
336         "01*2*34*+" )
337   //DISCRETE_MULTIPLY(NODE_164, 1, TTL_OUT, NODE_152)
338   //DISCRETE_MULTIPLY(NODE_165, 1, 1.0/GAL_R46, NODE_164)
339   //DISCRETE_MULTIPLY(NODE_166, 1, 1.0/GAL_R48, NODE_163)
340   //DISCRETE_ADDER2(NODE_167, 1, NODE_165, NODE_166)
341   DISCRETE_MULTIPLY(NODE_168, 1, RES_2_PARALLEL(GAL_R46, GAL_R48), NODE_167)
342
343   DISCRETE_555_ASTABLE_CV(NODE_171, 1, GAL_R44, GAL_R45, GAL_C27, NODE_168, &galaxian_555_fire_vco_desc)
344
345   /* 555 toggles discharge on rc discharge module */
346   DISCRETE_RCDISC5(NODE_172, NODE_171, NODE_161, (GAL_R41), GAL_C25)
347
348   /************************************************/
349361   /* FINAL MIX                                    */
350362   /************************************************/
351363
352364   DISCRETE_MIXER5(NODE_279, 1, NODE_SUB(133,0), NODE_SUB(133,2), NODE_SUB(133,2), NODE_SUB(133,3), NODE_120, &galaxian_mixerpre_desc)
353   DISCRETE_MIXER3(NODE_280, 1, NODE_279, NODE_157, NODE_172, &galaxian_mixer_desc)
365   DISCRETE_MIXER3(NODE_280, 1, NODE_279, NODE_157, NODE_182, &galaxian_mixer_desc)
354366   DISCRETE_OUTPUT(NODE_280, 32767.0/5.0*5)
355367
356368DISCRETE_SOUND_END
r5534r5535
364376   /************************************************/
365377   DISCRETE_DELETE(NODE_279, NODE_279)
366378   DISCRETE_REPLACE
367   DISCRETE_MIXER7(NODE_280, 1, NODE_SUB(133,0), NODE_SUB(133,2), NODE_SUB(133,2), NODE_SUB(133,3), NODE_120, NODE_157, NODE_172, &mooncrst_mixer_desc)
379   DISCRETE_MIXER7(NODE_280, 1, NODE_SUB(133,0), NODE_SUB(133,2), NODE_SUB(133,2), NODE_SUB(133,3), NODE_120, NODE_157, NODE_182, &mooncrst_mixer_desc)
368380DISCRETE_SOUND_END
369381
370382/*************************************
src/mame/audio/bzone.c
r5534r5535
2222#include "streams.h"
2323#include "bzone.h"
2424
25#if !BZONE_DISCRETE
2526#define OUTPUT_RATE (6000*4)
2627
2728
r5534r5535
295296   }
296297}
297298
299#else
298300
301#include "sound/discrete.h"
302#include "sound/pokey.h"
303
304#define BZ_NOISE_CLOCK      12000      /* FIXME */
305
306/*************************************
307 *
308 *  Discrete Sound Defines
309 *
310 *************************************/
311
312#define BZ_INPUT         NODE_01      /* at M2 LS273 */
313#define BZ_INP_EXPLO      NODE_SUB(10, 0)
314#define BZ_INP_EXPLOLS      NODE_SUB(10, 1)
315#define BZ_INP_SHELL      NODE_SUB(10, 2)
316#define BZ_INP_SHELLLS      NODE_SUB(10, 3)
317#define BZ_INP_ENGREV      NODE_SUB(10, 4)
318#define BZ_INP_SOUNDEN      NODE_SUB(10, 5)
319#define BZ_INP_STARTLED      NODE_SUB(10, 6)
320#define BZ_INP_MOTEN      NODE_SUB(10, 7)
321
322#define TTL_OUT 5
323
324#define BZ_R5         RES_K(1)
325#define BZ_R6         RES_K(4.7)
326#define BZ_R7         RES_K(1)
327#define BZ_R8         RES_K(100)
328#define BZ_R9         RES_K(22)
329
330//#define RT            (1.0/BZ_R5 + 1.0/BZ_R6 * 1.0/BZ_R7)
331
332#define BZ_R10         RES_K(100)
333#define BZ_R11         RES_K(250)
334#define BZ_R12         RES_K(33)
335#define BZ_R13         RES_K(10)
336#define BZ_R14         RES_K(22)
337#define BZ_R15         RES_K(1)
338#define BZ_R16         RES_K(1)
339#define BZ_R17         RES_K(22)
340#define BZ_R18         RES_K(10)
341#define BZ_R19         RES_K(33)
342
343#define BZ_R20         RES_K(33)
344#define BZ_R21         RES_K(33)
345#define BZ_R25         RES_K(100)
346#define BZ_R26         RES_K(33)
347#define BZ_R27         RES_K(330)
348#define BZ_R28         RES_K(100)
349#define BZ_R29         RES_K(22)
350
351#define BZ_R32         RES_K(330)
352#define BZ_R33         RES_K(330)
353#define BZ_R34         RES_K(33)
354#define BZ_R35         RES_K(33)
355
356#define BZ_C9         CAP_U(4.7)
357
358#define BZ_C11         CAP_U(0.015)
359#define BZ_C13         CAP_U(10)
360#define BZ_C14         CAP_U(10)
361
362#define BZ_C21         CAP_U(0.0047)
363#define BZ_C22         CAP_U(0.0047)
364#define BZ_C29         CAP_U(0.47)
365
366/*************************************
367 *
368 *  Discrete Sound static structs
369 *
370 *************************************/
371
372
373static const discrete_lfsr_desc bzone_lfsr =
374{
375   DISC_CLK_IS_FREQ,
376   16,                      /* Bit Length */
377   0,                      /* Reset Value */
378   3,                      /* Use Bit 10 (QC of second LS164) as F0 input 0 */
379   14,                      /* Use Bit 23 (QH of third LS164) as F0 input 1 */
380   DISC_LFSR_XOR,         /* F0 is XOR */
381   DISC_LFSR_NOT_IN0,       /* F1 is inverted F0*/
382   DISC_LFSR_REPLACE,        /* F2 replaces the shifted register contents */
383   0x000001,               /* Everything is shifted into the first bit only */
384   DISC_LFSR_FLAG_OUTPUT_SR_SN1, /* output the complete shift register to sub node 1*/
385   15                   /* Output bit */
386};
387
388static const discrete_op_amp_filt_info bzone_explo_0 =
389{
390      BZ_R18 + BZ_R19, 0, 0, 0,       /* r1, r2, r3, r4 */
391      BZ_R33,                     /* rF */
392      BZ_C22, 0, 0,               /* c1, c2, c3 */
393      0,                        /* vRef - not used */
394      22, 0                     /* vP, vN */
395};
396
397static const discrete_op_amp_filt_info bzone_explo_1 =
398{
399      BZ_R18, 0, 0, 0,             /* r1, r2, r3, r4 */
400      BZ_R33,                     /* rF */
401      BZ_C22, 0, 0,               /* c1, c2, c3 */
402      0,                        /* vRef - not used */
403      22, 0                     /* vP, vN */
404};
405
406static const discrete_op_amp_filt_info bzone_shell_0 =
407{
408      BZ_R13 + BZ_R12, 0, 0, 0,       /* r1, r2, r3, r4 */
409      BZ_R32,                     /* rF */
410      BZ_C21, 0, 0,               /* c1, c2, c3 */
411      0,                        /* vRef - not used */
412      22, 0                     /* vP, vN */
413};
414
415static const discrete_op_amp_filt_info bzone_shell_1 =
416{
417      BZ_R13, 0, 0, 0,             /* r1, r2, r3, r4 */
418      BZ_R32,                     /* rF */
419      BZ_C21, 0, 0,               /* c1, c2, c3 */
420      0,                        /* vRef - not used */
421      22, 0                     /* vP, vN */
422};
423
424static const discrete_555_desc bzone_vco_desc =
425{
426   DISC_555_OUT_DC,
427   5.0,
428   DEFAULT_555_CHARGE,
429   1.0 // Logic output
430};
431
432static const discrete_mixer_desc bzone_eng_mixer_desc =
433{
434   DISC_MIXER_IS_RESISTOR,
435   {BZ_R20, BZ_R21, BZ_R34, BZ_R35},
436   {0, 0, 0, 0},
437   {0, 0, 0, 0},
438   0, 0,
439   BZ_C29,
440   0, /* no out cap */
441   0, TTL_OUT      /* inputs are logic */
442};
443
444static const discrete_mixer_desc bzone_final_mixer_desc =
445{
446   DISC_MIXER_IS_RESISTOR,
447   {BZ_R28, BZ_R25, BZ_R26, BZ_R27},
448   {0, 0, 0, 0},
449   {0, 0, 0, 0},
450   0, BZ_R29,
451   0,
452   0, /* no out cap */
453   0, 1
454};
455
456/*************************************
457 *
458 *  Discrete Sound Blocks
459 *
460 *************************************/
461
462static DISCRETE_SOUND_START(bzone)
463
464   /************************************************/
465   /* Input register mapping for galaxian          */
466   /************************************************/
467   DISCRETE_INPUT_DATA(BZ_INPUT)
468
469   /* decode the bits */
470   DISCRETE_BITS_DECODE(NODE_10, BZ_INPUT, 0, 7, 5.7)// TTL_OUT)       /* QA-QD 74393 */
471   DISCRETE_ADJUSTMENT_TAG(NODE_11, 0, RES_K(250), DISC_LINADJ, "R11")
472
473
474   /************************************************/
475   /* NOISE                                        */
476   /************************************************/
477
478   /* 12Khz clock is divided by two by B4 74LS109 */
479   DISCRETE_LFSR_NOISE(NODE_30, 1, 1, BZ_NOISE_CLOCK / 2, 1.0, 0, 0.5, &bzone_lfsr)
480
481   /* divide by 2 */
482   DISCRETE_COUNTER(NODE_31, 1, 0, NODE_30, 1, DISC_COUNT_UP, 0, DISC_CLK_ON_R_EDGE)
483
484   DISCRETE_BITS_DECODE(NODE_32, NODE_SUB(30,1), 11, 14, 1)      /* to NAND LS20, J4 */
485   /* 11-14 */
486   DISCRETE_LOGIC_NAND4(NODE_33,1,NODE_SUB(32,0),NODE_SUB(32,1),NODE_SUB(32,2),NODE_SUB(32,3))
487   /* divide by 2 */
488   DISCRETE_COUNTER(NODE_34, 1, 0, NODE_33, 1, DISC_COUNT_UP, 0, DISC_CLK_ON_R_EDGE)
489
490   /************************************************/
491   /* Explosion                                    */
492   /************************************************/
493
494   /* FIXME: +0.7 for diode */
495   DISCRETE_RCDISC5(NODE_40, NODE_34, BZ_INP_EXPLO, BZ_R17 + BZ_R16, BZ_C14)
496   DISCRETE_MULTIPLY(NODE_41, 1, BZ_R16 / (BZ_R17 + BZ_R16), NODE_40)
497
498   /* one of two filter configurations active */
499   DISCRETE_LOGIC_INVERT(NODE_42, 1, BZ_INP_EXPLOLS)
500   DISCRETE_OP_AMP_FILTER(NODE_43, BZ_INP_EXPLOLS,  0, NODE_41,
501         DISC_OP_AMP_FILTER_IS_LOW_PASS_1M, &bzone_explo_1)
502   DISCRETE_OP_AMP_FILTER(NODE_44, NODE_42,  0, NODE_41,
503      DISC_OP_AMP_FILTER_IS_LOW_PASS_1M, &bzone_explo_0)
504   DISCRETE_ADDER2(NODE_45, 1, NODE_43, NODE_44)
505
506   /************************************************/
507   /* Shell                                        */
508   /************************************************/
509   /* FIXME: +0.7 for diode */
510   DISCRETE_RCDISC5(NODE_50, NODE_31, BZ_INP_SHELL, BZ_R14 + BZ_R15, BZ_C9)
511   DISCRETE_MULTIPLY(NODE_51, 1, BZ_R15 / (BZ_R14 + BZ_R15), NODE_50)
512
513   /* one of two filter configurations active */
514   DISCRETE_LOGIC_INVERT(NODE_52, 1, BZ_INP_SHELLLS)
515   DISCRETE_OP_AMP_FILTER(NODE_53, BZ_INP_SHELLLS,  0, NODE_51,
516         DISC_OP_AMP_FILTER_IS_LOW_PASS_1M, &bzone_shell_1)
517   DISCRETE_OP_AMP_FILTER(NODE_54, NODE_52,  0, NODE_51,
518      DISC_OP_AMP_FILTER_IS_LOW_PASS_1M, &bzone_shell_0)
519   DISCRETE_ADDER2(NODE_55, 1, NODE_53, NODE_54)
520
521   /************************************************/
522   /* Engine                                       */
523   /************************************************/
524
525
526   DISCRETE_TRANSFORM2(NODE_60, BZ_INP_ENGREV, 0.0, "01=")
527   // FIXME: from R5 .. R7
528   DISCRETE_MULTIPLEX2(NODE_61, 1, NODE_60, 2.5, 4.2)
529   DISCRETE_RCDISC3(NODE_62, 1, NODE_61, BZ_R8, BZ_R9, BZ_C13, -0.5)
530
531   /* R11 taken from adjuster port */
532   DISCRETE_555_ASTABLE_CV(NODE_63, 1, BZ_R10, NODE_11, BZ_C11, NODE_62, &bzone_vco_desc)
533
534   /* two LS161, reset to 4 resp 6 counting up to 15, QD and ripple carry mixed */
535   DISCRETE_COUNTER(NODE_65, BZ_INP_MOTEN, 0, NODE_63, 11, DISC_COUNT_UP, 0, DISC_CLK_ON_R_EDGE)
536   DISCRETE_TRANSFORM2(NODE_66, NODE_65, 3, "01>") /* QD */
537   DISCRETE_TRANSFORM2(NODE_67, NODE_65, 11, "01=") /* Ripple */
538
539   DISCRETE_COUNTER(NODE_68, BZ_INP_MOTEN, 0, NODE_63, 9, DISC_COUNT_UP, 0, DISC_CLK_ON_R_EDGE)
540   DISCRETE_TRANSFORM2(NODE_69, NODE_68, 1, "01>") /* QD */
541   DISCRETE_TRANSFORM2(NODE_70, NODE_68, 9, "01=") /* Ripple */
542
543   DISCRETE_MIXER4(NODE_75, 1, NODE_66, NODE_67, NODE_69, NODE_70, &bzone_eng_mixer_desc)
544
545   /************************************************/
546   /* FINAL MIX                                    */
547   /************************************************/
548
549   /* not sure about pokey output levels - bleow is just a estimate */
550   DISCRETE_INPUTX_STREAM(NODE_85, 0, 5.0/32767.0 * 4, 0)
551
552   DISCRETE_MIXER4(NODE_280, 1, NODE_45, NODE_55, NODE_75, NODE_85, &bzone_final_mixer_desc)
553   DISCRETE_OUTPUT(NODE_280, 32767.0/5.0 * 2)
554   //DISCRETE_WAVELOG1(NODE_55, 32767.0/22)
555   //DISCRETE_WAVELOG2(NODE_30, 32767.0/5.0, NODE_31, 32767.0/5.0)
556
557DISCRETE_SOUND_END
558
559static const pokey_interface bzone_pokey_interface =
560{
561   { DEVCB_NULL },
562   DEVCB_INPUT_PORT("IN3")
563};
564
565WRITE8_DEVICE_HANDLER( bzone_sounds_w )
566{
567   discrete_sound_w(device, BZ_INPUT, data);
568
569   output_set_value("startled", (data >> 6) & 1);
570    sound_global_enable(data & 0x20);
571}
572
573
574MACHINE_DRIVER_START( bzone_audio )
575
576   MDRV_SPEAKER_STANDARD_MONO("mono")
577
578   MDRV_SOUND_ADD("pokey",  POKEY, BZONE_MASTER_CLOCK / 8)
579   MDRV_SOUND_CONFIG(bzone_pokey_interface)
580   MDRV_SOUND_ROUTE_EX(0, "discrete", 1.0, 0)
581
582   MDRV_SOUND_ADD("discrete", DISCRETE, 0)
583   MDRV_SOUND_CONFIG_DISCRETE(bzone)
584
585   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
586MACHINE_DRIVER_END
587
588#endif
src/mame/audio/dkong.c
r5534r5535
284284 *                                        Gnd         Gnd
285285 *
286286 ************************************************************************/
287#define DKONG_CUSTOM_IN1      (*(node->input[0]))
288#define DKONG_CUSTOM_IN2      (*(node->input[1]))
289#define DKONG_CUSTOM_R1         (*(node->input[2]))
290#define DKONG_CUSTOM_R2         (*(node->input[3]))
291#define DKONG_CUSTOM_R3         (*(node->input[4]))
292#define DKONG_CUSTOM_R4         (*(node->input[5]))
293#define DKONG_CUSTOM_C         (*(node->input[6]))
294#define DKONG_CUSTOM_V         (*(node->input[7]))
287#define DKONG_CUSTOM_IN1      DISCRETE_INPUT(0)
288#define DKONG_CUSTOM_IN2      DISCRETE_INPUT(1)
289#define DKONG_CUSTOM_R1         DISCRETE_INPUT(2)
290#define DKONG_CUSTOM_R2         DISCRETE_INPUT(3)
291#define DKONG_CUSTOM_R3         DISCRETE_INPUT(4)
292#define DKONG_CUSTOM_R4         DISCRETE_INPUT(5)
293#define DKONG_CUSTOM_C         DISCRETE_INPUT(6)
294#define DKONG_CUSTOM_V         DISCRETE_INPUT(7)
295295
296296struct dkong_custom_mixer_context
297297{
r5534r5535
343343
344344static const discrete_custom_info dkong_custom_mixer_info =
345345{
346   DISCRETE_RESET_NAME( dkong_custom_mixer ),
347   DISCRETE_STEP_NAME( dkong_custom_mixer ),
348   sizeof(struct dkong_custom_mixer_context),
346   DISCRETE_CUSTOM_MODULE( dkong_custom_mixer, struct dkong_custom_mixer_context),
349347   NULL
350348};
351349#endif
352350
351
352static DISCRETE_SOUND_START(dkong2b_dac)
353   DISCRETE_INPUT_DATA(DS_DAC)
354   DISCRETE_OUTPUT(DS_DAC, 1)
355DISCRETE_SOUND_END
356
353357static DISCRETE_SOUND_START(dkong2b)
354358
355359   /************************************************/
r5534r5535
361365   DISCRETE_INPUT_NOT(DS_SOUND1_INV)   /* IC 6J, pin 12 */
362366   DISCRETE_INPUT_NOT(DS_SOUND0_INV)   /* IC 6J, pin 2 */
363367   DISCRETE_INPUT_NOT(DS_DISCHARGE_INV)
364   DISCRETE_INPUT_DATA(DS_DAC)
368   //DISCRETE_INPUT_DATA(DS_DAC)
369
365370   /* Mixing - DAC */
366371   DISCRETE_ADJUSTMENT_TAG(DS_ADJ_DAC, 0, 1, DISC_LINADJ, "VR2")
367372
r5534r5535
369374   /* Stomp                                        */
370375   /************************************************/
371376   /* Noise */
377   DISCRETE_TASK_START()
372378   DISCRETE_LFSR_NOISE(NODE_11, 1, 1, CLOCK_2VF, 1.0, 0, 0.5, &dkong_lfsr)
373379   DISCRETE_COUNTER(NODE_12, 1, 0, NODE_11, 7, DISC_COUNT_UP, 0, DISC_CLK_ON_R_EDGE)   /* LS161, IC 3J */
374380   DISCRETE_TRANSFORM3(NODE_13,NODE_12,3,DK_SUP_V,"01>2*")
r5534r5535
384390
385391   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)
386392   DISCRETE_MULTIPLY(DS_OUT_SOUND0,1,NODE_22,DK_R3/R_SERIES(DK_R3,DK_R4))
393   DISCRETE_TASK_END(DS_OUT_SOUND0)
387394
388395   /************************************************/
389396   /* Jump                                         */
390397   /************************************************/
391/*  tt */
398   /*  tt */
392399   /* 4049B Inverter Oscillator build from 3 inverters */
400   DISCRETE_TASK_START()
393401   DISCRETE_INVERTER_OSC(NODE_25,1,0,DK_R38,DK_R39,DK_C26,0,&dkong_inverter_osc_desc_jump)
394402
395403#if DK_USE_CUSTOM
r5534r5535
416424
417425   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)
418426   DISCRETE_MULTIPLY(DS_OUT_SOUND1,1,NODE_39,DK_R25/(DK_R26+DK_R25))
427   DISCRETE_TASK_END(DS_OUT_SOUND1)
419428
420429   /************************************************/
421430   /* Walk                                         */
422431   /************************************************/
432   DISCRETE_TASK_START()
423433   DISCRETE_INVERTER_OSC(NODE_51,1,0,DK_R47,DK_R48,DK_C30,0,&dkong_inverter_osc_desc_walk)
424434
425435#if DK_USE_CUSTOM
r5534r5535
440450   /* Filter and divide - omitted C22 */
441451   DISCRETE_CRFILTER(NODE_61, 1, NODE_60, DK_R15+DK_R16, DK_C23)
442452   DISCRETE_MULTIPLY(DS_OUT_SOUND2, 1, NODE_61, DK_R15/(DK_R15+DK_R16))
453   DISCRETE_TASK_END(DS_OUT_SOUND2)
443454
444455   /************************************************/
445456   /* DAC                                          */
446457   /************************************************/
447458
459   DISCRETE_TASK_START()
460   DISCRETE_INPUTX_STREAM(DS_DAC, 0, 1.0, 0)
448461   /* Signal decay circuit Q7, R20, C32 */
449462   DISCRETE_RCDISC(NODE_70, DS_DISCHARGE_INV, 1, DK_R20, DK_C32)
450463   DISCRETE_TRANSFORM4(NODE_71, DS_DAC,  DK_SUP_V/256.0, NODE_70, DS_DISCHARGE_INV, "01*3!2+*")
r5534r5535
465478#else
466479   DISCRETE_MULTIPLY(DS_OUT_DAC, 1, NODE_73, DS_ADJ_DAC)
467480#endif
481   DISCRETE_TASK_END(DS_OUT_DAC)
468482
469483   /************************************************/
470484   /* Amplifier                                    */
r5534r5535
623637   DISCRETE_INPUT_NOT(DS_SOUND6_INV)
624638   DISCRETE_INPUT_NOT(DS_SOUND7_INV)
625639   DISCRETE_INPUT_NOT(DS_DISCHARGE_INV)
626   DISCRETE_INPUT_DATA(DS_DAC)
627640
641   /* Must be in task if tasks added */
642   DISCRETE_INPUTX_STREAM(DS_DAC, 0, 1.0, 0)
643   //DISCRETE_INPUT_DATA(DS_DAC)
644
628645   /* Mixing - DAC */
629646   DISCRETE_ADJUSTMENT_TAG(DS_ADJ_DAC, 0, 1, DISC_LINADJ, "VR2")
630647
r5534r5535
11541171                   AM_WRITE(dkong_voice_w)
11551172   AM_RANGE(MCS48_PORT_BUS, MCS48_PORT_BUS) AM_DEVREAD("ls175.3d", dkong_tune_r)
11561173                           AM_WRITE(dkong_voice_w)
1157   AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_DEVWRITE("discrete", dkong_p1_w) /* only write to dac */
1174   AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_DEVWRITE("discdac", dkong_p1_w) /* only write to dac */
11581175   AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_LATCH8_READWRITE("virtual_p2")
11591176   AM_RANGE(MCS48_PORT_T0, MCS48_PORT_T0) AM_LATCH8_READBIT("ls259.6h", 5)
11601177   AM_RANGE(MCS48_PORT_T1, MCS48_PORT_T1) AM_LATCH8_READBIT("ls259.6h", 4)
r5534r5535
11701187
11711188static ADDRESS_MAP_START( radarsc1_sound_io_map, ADDRESS_SPACE_IO, 8 )
11721189   AM_RANGE(0x00, 0x00) AM_MIRROR(0xff) AM_DEVREAD("ls175.3d", latch8_r)
1173   AM_RANGE(0x00, 0xff) AM_DEVWRITE("discrete", dkong_p1_w) /* DAC here */
1190   AM_RANGE(0x00, 0xff) AM_DEVWRITE("discdac", dkong_p1_w) /* DAC here */
11741191   AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_LATCH8_READ("virtual_p1")
11751192                         AM_DEVWRITE("tms", M58817_command_w)
11761193   AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_LATCH8_WRITE("virtual_p2")
r5534r5535
12451262   MDRV_CPU_IO_MAP(dkong_sound_io_map)
12461263
12471264   MDRV_SPEAKER_STANDARD_MONO("mono")
1265
1266   MDRV_SOUND_ADD("discdac", DISCRETE, 0)
1267   MDRV_SOUND_CONFIG_DISCRETE(dkong2b_dac)
1268   MDRV_SOUND_ROUTE_EX(0, "discrete", 1.0, 0)
1269
12481270   MDRV_SOUND_ADD("discrete", DISCRETE, 0)
12491271   MDRV_SOUND_CONFIG_DISCRETE(dkong2b)
12501272   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
src/mame/audio/redalert.c
r5534r5535
168168}
169169
170170
171static void sod_callback(const device_config *device, int data)
171static WRITE_LINE_DEVICE_HANDLER( sod_callback )
172172{
173   hc55516_digit_w(devtag_get_device(device->machine, "cvsd"), data);
173   hc55516_digit_w(devtag_get_device(device->machine, "cvsd"), state);
174174}
175175
176176
177static int sid_callback(const device_config *device)
177static READ_LINE_DEVICE_HANDLER( sid_callback )
178178{
179179   return hc55516_clock_state_r(devtag_get_device(device->machine, "cvsd"));
180180}
181181
182182
183static const i8085_config redalert_voice_i8085_config =
183static I8085_CONFIG( redalert_voice_i8085_config )
184184{
185   NULL,            /* INTE changed callback */
186   NULL,            /* STATUS changed callback */
187   sod_callback,      /* SOD changed callback (8085A only) */
188   sid_callback      /* SID changed callback (8085A only) */
185   DEVCB_NULL,               /* STATUS changed callback */
186   DEVCB_NULL,               /* INTE changed callback */
187   DEVCB_LINE(sid_callback),   /* SID changed callback (8085A only) */
188   DEVCB_LINE(sod_callback)   /* SOD changed callback (8085A only) */
189189};
190190
191191
src/mame/audio/mario.c
r5534r5535
169169 *            -||-
170170 *             C2
171171 ************************************************************************/
172#define MARIO_CUSTOM_VOUT      (*(node->input[0]))
173#define MARIO_CUSTOM_IN1      (*(node->input[1]))
174#define MARIO_CUSTOM_IN2      (*(node->input[2]))
175#define MARIO_CUSTOM_C1         (*(node->input[3]))
176#define MARIO_CUSTOM_C2         (*(node->input[4]))
177#define MARIO_CUSTOM_R1         (*(node->input[5]))
178#define MARIO_CUSTOM_C3         (*(node->input[6]))
172#define MARIO_CUSTOM_VOUT      DISCRETE_INPUT(0)
173#define MARIO_CUSTOM_IN1      DISCRETE_INPUT(1)
174#define MARIO_CUSTOM_IN2      DISCRETE_INPUT(2)
175#define MARIO_CUSTOM_C1         DISCRETE_INPUT(3)
176#define MARIO_CUSTOM_C2         DISCRETE_INPUT(4)
177#define MARIO_CUSTOM_R1         DISCRETE_INPUT(5)
178#define MARIO_CUSTOM_C3         DISCRETE_INPUT(6)
179179
180180struct mario_custom_run_context
181181{
r5534r5535
192192
193193   double   t1   = 0.5 / LS624_F(MARIO_CUSTOM_C1, MARIO_CUSTOM_IN1, RUN_VCO_VOLTAGE);
194194   double   t2   = 0.5 / LS624_F(MARIO_CUSTOM_C2, MARIO_CUSTOM_IN2, RUN_VCO_VOLTAGE);
195   double  sample_t = disc_info->sample_time;
195   double  sample_t = node->info->sample_time;
196196   double  vn, t;
197197
198198   //if (MARIO_CUSTOM_VOUT)
r5534r5535
258258
259259static const discrete_custom_info mario_custom_run_info =
260260{
261   DISCRETE_RESET_NAME( mario_custom_run ),
262   DISCRETE_STEP_NAME( mario_custom_run ),
263   sizeof(struct mario_custom_run_context),
261   DISCRETE_CUSTOM_MODULE( mario_custom_run, struct mario_custom_run_context),
264262   NULL
265263};
266264
src/mame/audio/tank8.c
r5534r5535
212212   DISCRETE_DIVIDE(NODE_110,1,TANK8_BUGLE_DATA1,7875.0)
213213   DISCRETE_DIVIDE(NODE_111,1,TANK8_BUGLE_DATA2,7875.0)
214214   DISCRETE_SQUAREWAVE2(NODE_112,TANK8_BUGLE_EN,3.4, NODE_110, NODE_111,1.7,0)
215   DISCRETE_RCDISC3(NODE_113,1, NODE_112, RES_K(10),RES_K(1),CAP_U(0.1))
215   DISCRETE_RCDISC3(NODE_113,1, NODE_112, RES_K(10),RES_K(1),CAP_U(0.1), 0.5)
216216   DISCRETE_CRFILTER(TANK8_BUGLE, 1, NODE_113, RES_K(47), CAP_U(.01))
217217
218218   /************************************************/
src/mame/machine/leland.c
r5534r5535
13801380
13811381   /* set the new value */
13821382    leland_gfx_control = data;
1383   leland_dac_control &= data & 3;
1383   leland_dac_control = data & 3;
13841384
13851385    /* some bankswitching occurs here */
13861386   if (LOG_BANKSWITCHING_M)
src/mame/machine/midtunit.c
r5534r5535
174174
175175/*************************************
176176 *
177 *  MK Turbo Ninja protection
178 *
179 *************************************/
180
181static READ16_HANDLER( mkturbo_prot_r )
182{
183   /* the security GAL overlays a counter of some sort at 0xfffff400 in ROM space.
184     * A startup protection check expects to read back two different values in succession */
185   return mame_rand(space->machine);
186}
187
188
189
190/*************************************
191 *
177192 *  Mortal Kombat 2 protection
178193 *
179194 *************************************/
r5534r5535
454469   memory_set_bankptr(machine, 9, auto_alloc_array(machine, UINT8, 0x80));
455470}
456471
472DRIVER_INIT( mkturbo )
473{
474   /* protection */
475   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xfffff400, 0xfffff40f, 0, 0, mkturbo_prot_r);
476
477   DRIVER_INIT_CALL(mktunit);
478}
479
480
457481static void init_nbajam_common(running_machine *machine, int te_protection)
458482{
459483   /* common init */
src/mame/machine/archimds.c
r5534r5535
115115{
116116   double freq;
117117
118   if((double)ioc_timercnt[tmr] != 0) // FIXME: dmdtouch does a divide by zero?
118   if(ioc_timercnt[tmr] != 0) // FIXME: dmdtouch does a divide by zero?
119119   {
120120      freq = 2000000.0 / (double)ioc_timercnt[tmr];
121121   //  logerror("IOC: starting timer %d, %d ticks, freq %f Hz\n", tmr, ioc_timercnt[tmr], freq);
src/mame/machine/kaneko16.c
r5534r5535
1616#include "includes/kaneko16.h"
1717
1818#include "kanekotb.h"   // TOYBOX MCU trojaning results
19#include "machine/eeprom.h"
1920
21
22#define CALC3_VERBOSE_OUTPUT 0
23
2024#define MCU_RESPONSE(d) memcpy(&kaneko16_mcu_ram[mcu_offset], d, sizeof(d))
2125
2226UINT16 *kaneko16_mcu_ram;
r5534r5535
3438    - bonkadv only uses Random Number, XY Overlap Collision bit and register '0x02'
3539*/
3640
41
3742static struct {
3843   UINT16 x1p, y1p, x1s, y1s;
3944   UINT16 x2p, y2p, x2s, y2s;
r5534r5535
147152  rect2       <----->       |     <----------->  |             <--->
148153  result      <---------->  |     <-------->     |       <---->
149154*/
155
150156static INT16 calc_compute_x(void)
151157{
152158   INT16 x_coll;
r5534r5535
161167
162168   return x_coll;
163169}
170
164171static INT16 calc_compute_y(void)
165172{
166173   INT16 y_coll;
r5534r5535
236243   return 0;
237244}
238245
246/*
247    B Rap Boys
248    Shogun Warriors
249
250*/
251
252
253static struct {
254   int x1p, y1p, z1p, x1s, y1s, z1s;
255   int x2p, y2p, z2p, x2s, y2s, z2s;
256
257   int x1po, y1po, z1po, x1so, y1so, z1so;
258   int x2po, y2po, z2po, x2so, y2so, z2so;
259
260   int x12, y12, z12, x21, y21, z21;
261
262   int x_coll, y_coll, z_coll;
263
264   int x1tox2, y1toy2, z1toz2;
265
266   UINT16 mult_a, mult_b;
267
268   UINT16 flags;
269   UINT16 mode;
270
271} shogwarr_hit;
272
273
274//calculate simple intersection of two segments
275
276static int shogwarr_calc_compute(int x1, int w1, int x2, int w2)
277{
278   int dist;
279
280   if(x2>=x1 && x2+w2<=(x1+w1))
281   {
282      //x2 inside x1
283      dist=w2;
284   }
285   else
286   {
287      if(x1>=x2 && x1+w1<=(x2+w2))
288      {
289         //x1 inside x2
290         dist=w1;
291      }
292      else
293      {
294         if(x2<x1)
295         {
296            //swap
297            int tmp=x1;
298            x1=x2;
299            x2=tmp;
300            tmp=w1;
301            w1=w2;
302            w2=tmp;
303         }
304         dist=x1+w1-x2;
305      }
306   }
307   return dist;
308}
309
310//calc segment coordinates
311
312static void shogwarr_calc_org(int mode, int x0, int s0,  int* x1, int* s1)
313{
314   switch(mode)
315   {
316      case 0: *x1=x0; *s1=s0; break;
317      case 1: *x1=x0-s0/2; *s1=s0; break;
318      case 2: *x1=x0-s0; *s1=s0; break;
319      case 3:   *x1=x0-s0; *s1=2*s0; break;
320   }
321   //x1 is the left most coord, s1 = width
322}
323
324static void shogwarr_recalc_collisions(void)
325{
326   //calculate positions and sizes
327
328   int mode=shogwarr_hit.mode;
329
330   shogwarr_hit.flags=0;
331
332   shogwarr_calc_org(mode&3, shogwarr_hit.x1po, shogwarr_hit.x1so, &shogwarr_hit.x1p, &shogwarr_hit.x1s);
333   mode>>=2;
334   shogwarr_calc_org(mode&3, shogwarr_hit.y1po, shogwarr_hit.y1so, &shogwarr_hit.y1p, &shogwarr_hit.y1s);
335   mode>>=2;
336   shogwarr_calc_org(mode&3, shogwarr_hit.z1po, shogwarr_hit.z1so, &shogwarr_hit.z1p, &shogwarr_hit.z1s);
337
338   mode>>=4;
339
340   shogwarr_calc_org(mode&3, shogwarr_hit.x2po, shogwarr_hit.x2so, &shogwarr_hit.x2p, &shogwarr_hit.x2s);
341   mode>>=2;
342   shogwarr_calc_org(mode&3, shogwarr_hit.y2po, shogwarr_hit.y2so, &shogwarr_hit.y2p, &shogwarr_hit.y2s);
343   mode>>=2;
344   shogwarr_calc_org(mode&3, shogwarr_hit.z2po, shogwarr_hit.z2so, &shogwarr_hit.z2p, &shogwarr_hit.z2s);
345
346
347   shogwarr_hit.x1tox2=abs(shogwarr_hit.x2po-shogwarr_hit.x1po);
348   shogwarr_hit.y1toy2=abs(shogwarr_hit.y2po-shogwarr_hit.y1po);
349   shogwarr_hit.z1toz2=abs(shogwarr_hit.z2po-shogwarr_hit.z1po);
350
351
352   shogwarr_hit.x_coll = shogwarr_calc_compute(shogwarr_hit.x1p, shogwarr_hit.x1s, shogwarr_hit.x2p, shogwarr_hit.x2s);
353   shogwarr_hit.y_coll = shogwarr_calc_compute(shogwarr_hit.y1p, shogwarr_hit.y1s, shogwarr_hit.y2p, shogwarr_hit.y2s);
354   shogwarr_hit.z_coll = shogwarr_calc_compute(shogwarr_hit.z1p, shogwarr_hit.z1s, shogwarr_hit.z2p, shogwarr_hit.z2s);
355
356
357   // 4th nibble: Y Absolute Collision -> possible values = 9,8,4,3,2
358   if      (shogwarr_hit.y1p >  shogwarr_hit.y2p)   shogwarr_hit.flags |= 0x2000;
359   else if (shogwarr_hit.y1p == shogwarr_hit.y2p)   shogwarr_hit.flags |= 0x4000;
360   else if (shogwarr_hit.y1p <  shogwarr_hit.y2p)   shogwarr_hit.flags |= 0x8000;
361   if (shogwarr_hit.y_coll<0) shogwarr_hit.flags |= 0x1000;
362
363   // 3rd nibble: X Absolute Collision -> possible values = 9,8,4,3,2
364   if      (shogwarr_hit.x1p >  shogwarr_hit.x2p)   shogwarr_hit.flags |= 0x0200;
365   else if (shogwarr_hit.x1p == shogwarr_hit.x2p)   shogwarr_hit.flags |= 0x0400;
366   else if (shogwarr_hit.x1p <  shogwarr_hit.x2p)   shogwarr_hit.flags |= 0x0800;
367   if (shogwarr_hit.x_coll<0) shogwarr_hit.flags |= 0x0100;
368
369   // 2nd nibble: Z Absolute Collision -> possible values = 9,8,4,3,2
370   if      (shogwarr_hit.z1p >  shogwarr_hit.z2p)   shogwarr_hit.flags |= 0x0020;
371   else if (shogwarr_hit.z1p == shogwarr_hit.z2p)   shogwarr_hit.flags |= 0x0040;
372   else if (shogwarr_hit.z1p <  shogwarr_hit.z2p)   shogwarr_hit.flags |= 0x0080;
373   if (shogwarr_hit.z_coll<0) shogwarr_hit.flags |= 0x0010;
374
375   // 1st nibble: XYZ Overlap Collision
376   if ((shogwarr_hit.x_coll>=0)&&(shogwarr_hit.y_coll>=0)&&(shogwarr_hit.z_coll>=0)) shogwarr_hit.flags |= 0x0008;
377   if ((shogwarr_hit.x_coll>=0)&&(shogwarr_hit.z_coll>=0)) shogwarr_hit.flags |= 0x0004;
378   if ((shogwarr_hit.y_coll>=0)&&(shogwarr_hit.z_coll>=0)) shogwarr_hit.flags |= 0x0002;
379   if ((shogwarr_hit.x_coll>=0)&&(shogwarr_hit.y_coll>=0)) shogwarr_hit.flags |= 0x0001;
380}
381
382
383WRITE16_HANDLER(shogwarr_calc_w)
384{
385   int idx=offset*4;
386   switch (idx)
387   {
388      // p is position, s is size
389      case 0x00:
390      case 0x28:
391
392               shogwarr_hit.x1po = data; break;
393
394      case 0x04:
395      case 0x2c:
396               shogwarr_hit.x1so = data; break;
397
398      case 0x08:
399      case 0x30:
400               shogwarr_hit.y1po = data; break;
401
402      case 0x0c:
403      case 0x34:
404               shogwarr_hit.y1so = data; break;
405
406      case 0x10:
407      case 0x58:
408               shogwarr_hit.x2po = data; break;
409
410      case 0x14:
411      case 0x5c:
412               shogwarr_hit.x2so = data; break;
413
414      case 0x18:
415      case 0x60:
416               shogwarr_hit.y2po = data; break;
417
418      case 0x1c:
419      case 0x64:
420               shogwarr_hit.y2so = data; break;
421
422      case 0x38:
423      case 0x50:
424               shogwarr_hit.z1po = data; break;
425      case 0x3c:
426      case 0x54:
427               shogwarr_hit.z1so = data; break;
428
429      case 0x20:
430      case 0x68:
431               shogwarr_hit.z2po = data; break;
432
433      case 0x24:
434      case 0x6c:
435               shogwarr_hit.z2so = data; break;
436
437      case 0x70:
438               shogwarr_hit.mode=data;break;
439
440      default:
441         logerror("CPU #0 PC %06x: warning - write unmapped hit address %06x [ %06x] = %06x\n",cpu_get_pc(space->cpu),offset<<1, idx, data);
442   }
443
444   shogwarr_recalc_collisions();
445}
446
447
448READ16_HANDLER(shogwarr_calc_r)
449{
450
451   int idx=offset*4;
452
453   switch (idx)
454   {
455      case 0x00: // X distance
456      case 0x10:
457         return shogwarr_hit.x_coll;
458
459      case 0x04: // Y distance
460      case 0x14:
461         return shogwarr_hit.y_coll;
462
463      case 0x18: // Z distance
464         return shogwarr_hit.z_coll;
465
466      case 0x08:
467      case 0x1c:
468
469         return shogwarr_hit.flags;
470
471      case 0x28:
472         return (mame_rand(space->machine) & 0xffff);
473
474      case 0x40: return shogwarr_hit.x1po;
475      case 0x44: return shogwarr_hit.x1so;
476      case 0x48: return shogwarr_hit.y1po;
477      case 0x4c: return shogwarr_hit.y1so;
478      case 0x50: return shogwarr_hit.z1po;
479      case 0x54: return shogwarr_hit.z1so;
480
481      case 0x58: return shogwarr_hit.x2po;
482      case 0x5c: return shogwarr_hit.x2so;
483      case 0x60: return shogwarr_hit.y2po;
484      case 0x64: return shogwarr_hit.y2so;
485      case 0x68: return shogwarr_hit.z2po;
486      case 0x6c: return shogwarr_hit.z2so;
487
488      case 0x80: return shogwarr_hit.x1tox2;
489      case 0x84: return shogwarr_hit.y1toy2;
490      case 0x88: return shogwarr_hit.z1toz2;
491
492      default:
493         logerror("CPU #0 PC %06x: warning - read unmapped calc address %06x [ %06x]\n",cpu_get_pc(space->cpu),offset<<1, idx);
494   }
495
496   return 0;
497}
498
239499/***************************************************************************
240500                                CALC3 MCU:
241501
r5534r5535
26952900207FE0 : base of 'stack' used when transfering tables out of MCU
270530*/
271531
272static void calc3_mcu_run(running_machine *machine);
273532
274533static int calc3_mcu_status, calc3_mcu_command_offset;
275534
r5534r5535
280539   calc3_mcu_command_offset = 0;
281540}
282541
542void calc3_mcu_run(running_machine *machine);
543
283544WRITE16_HANDLER( calc3_mcu_ram_w )
284545{
285546   COMBINE_DATA(&kaneko16_mcu_ram[offset]);
286   calc3_mcu_run(space->machine);
547   //calc3_mcu_run(space->machine);
287548}
288549
289550#define CALC3_MCU_COM_W(_n_)            \
r5534r5535
291552{                                 \
292553   logerror("calc3w %d %04x %04x\n",_n_, data,mem_mask); \
293554   calc3_mcu_status |= (1 << _n_);         \
294   calc3_mcu_run(space->machine);               \
295555}
296556
297557CALC3_MCU_COM_W(0)
r5534r5535
299559CALC3_MCU_COM_W(2)
300560CALC3_MCU_COM_W(3)
301561
562
302563/***************************************************************************
303564                                Shogun Warriors
304565***************************************************************************/
r5534r5535
356617Status
357618
358619Blocks marked ** are decrypted and verified
359              ~~ means I have the data to study
620              .. means I have the data to study
360621
361622(Shogun Warriors)
362623
r5534r5535
409670** Block 15 Found Base 250f - Mode? 02 Unknown 3f Key 24 Length 03b8                                           | shift 3 places + table, contains GAME OVER, CONTINUE
410671** Block 16 Found Base 28cd - Mode? 01 Unknown 03 Key 80 Length 018a
411672** Block 17 Found Base 2a5d - Mode? 01 Unknown 1f Key 15 Length 018a
412-- Block 18 Found Base 2bed - Mode? 01 Unknown 44 Key 00 Length 0184
673** Block 18 Found Base 2bed - Mode? 01 Unknown 44 Key 00 Length 0184                                           | 4 place shift
413674** Block 19 Found Base 2d77 - Mode? 01 Unknown 03 Key 19 Length 0184                                           | just a table
414   Block 1a Found Base 2f01 - Inline Encryption (size 21) - Mode? 02 Unknown 3f Key (unused?) 61 Length 0a24
415   Block 1b Found Base 394c - Mode? 01 Unknown 5f Key 22 Length 0e02
416   Block 1c Found Base 4754 - Mode? 01 Unknown 1f Key 3f Length 0e02
417   Block 1d Found Base 555c - Mode? 01 Unknown 03 Key bf Length 0e02
418   Block 1e Found Base 6364 - Mode? 01 Unknown 01 Key 24 Length 0e02
675** Block 1a Found Base 2f01 - Inline Encryption (size 21) - Mode? 02 Unknown 3f Key (unused?) 61 Length 0a24
676** Block 1b Found Base 394c - Mode? 01 Unknown 5f Key 22 Length 0e02
677** Block 1c Found Base 4754 - Mode? 01 Unknown 1f Key 3f Length 0e02
678** Block 1d Found Base 555c - Mode? 01 Unknown 03 Key bf Length 0e02
679** Block 1e Found Base 6364 - Mode? 01 Unknown 01 Key 24 Length 0e02
419680** Block 1f Found Base 716c - Mode? 02 Unknown 1f Key 39 Length 02ac                                           | 1 place shift + table
420   Block 20 Found Base 741e - Mode? 03 Unknown 03 Key af Length 01a4
421   Block 21 Found Base 75c8 - Inline Encryption (size 3d) - Mode? 03 Unknown 2f Key (unused?) 7d Length 01fa
681** Block 20 Found Base 741e - Mode? 03 Unknown 03 Key af Length 01a4
682** Block 21 Found Base 75c8 - Inline Encryption (size 3d) - Mode? 03 Unknown 2f Key (unused?) 7d Length 01fa
422683** Block 22 Found Base 7805 - Mode? 03 Unknown 1f Key 17 Length 010c                                           | 1 place shift + table
423684** Block 23 Found Base 7917 - Mode? 03 Unknown 03 Key 89 Length 018c                                           | just a table
424~~ Block 24 Found Base 7aa9 - Inline Encryption (size 03) - Mode? 03 Unknown 5f Key (unused?) 43 Length 0214
425   Block 25 Found Base 7cc6 - Inline Encryption (size 1d) - Mode? 03 Unknown 02 Key (unused?) 5d Length 0178
426   Block 26 Found Base 7e61 - Mode? 03 Unknown 03 Key 05 Length 04e2
427   Block 27 Found Base 8349 - Mode? 03 Unknown 3f Key a7 Length 00fa
428   Block 28 Found Base 8449 - Inline Encryption (size 23) - Mode? 03 Unknown 1f Key (unused?) 63 Length 015a
429   Block 29 Found Base 85cc - Mode? 03 Unknown 03 Key 15 Length 00d6
430   Block 2a Found Base 86a8 - Mode? 03 Unknown 3f Key a1 Length 00aa
431   Block 2b Found Base 8758 - Mode? 03 Unknown 2f Key 04 Length 01a2
432   Block 2c Found Base 8900 - Mode? 03 Unknown 2f Key 04 Length 04cc
433   Block 2d Found Base 8dd2 - Mode? 03 Unknown 03 Key 15 Length 0486
685** Block 24 Found Base 7aa9 - Inline Encryption (size 03) - Mode? 03 Unknown 5f Key (unused?) 43 Length 0214
686** Block 25 Found Base 7cc6 - Inline Encryption (size 1d) - Mode? 03 Unknown 02 Key (unused?) 5d Length 0178
687** Block 26 Found Base 7e61 - Mode? 03 Unknown 03 Key 05 Length 04e2
688** Block 27 Found Base 8349 - Mode? 03 Unknown 3f Key a7 Length 00fa
689** Block 28 Found Base 8449 - Inline Encryption (size 23) - Mode? 03 Unknown 1f Key (unused?) 63 Length 015a
690** Block 29 Found Base 85cc - Mode? 03 Unknown 03 Key 15 Length 00d6
691** Block 2a Found Base 86a8 - Mode? 03 Unknown 3f Key a1 Length 00aa
692** Block 2b Found Base 8758 - Mode? 03 Unknown 2f Key 04 Length 01a2
693** Block 2c Found Base 8900 - Mode? 03 Unknown 2f Key 04 Length 04cc
694** Block 2d Found Base 8dd2 - Mode? 03 Unknown 03 Key 15 Length 0486
434695
696
435697*/
436698
437699UINT16 calc3_mcu_crc;
r5534r5535
454716   0xda,0x89,0x08,0x77,0xb1,0x81,0x6b,0x2d,0xb6,0xbc,0x99,0xc9,0x35,0x0a,0x0f,0x01
455717};
456718
457/* ok - shogwarr */
458static UINT8 calc3_key15[64] = {
459   0x0C,0xEB,0x30,0x25,0xA8,0xED,0xE3,0x23,0xAC,0x2B,0x8D,0x34,0x88,0x9F,0x55,0xB5,
460   0xBF,0x15,0xE3,0x7C,0x54,0xD4,0x72,0xA9,0x7E,0x80,0x27,0x9F,0xA3,0x3F,0xA1,0x4D,
461   0x84,0x1B,0xD1,0xB2,0xB5,0xA7,0x0C,0xA0,0x51,0xE6,0x5E,0xC0,0xEB,0x68,0x22,0xD6,
462   0xC8,0xB6,0xCF,0x46,0x4B,0xF0,0x15,0xD7,0xB0,0xB5,0x29,0xB8,0xFD,0x43,0x5C,0xC0
463};
464719
465
466720/* ok - brapboys initial transfer */
467721static UINT8 calc3_key04[64] = {
468722    0xff,0x4a,0x62,0xa3,0xf4,0xb4,0x8c,0x2d,0x84,0xbd,0x87,0x3a,0x9e,0xe9,0xd7,0x12,
r5534r5535
471725   0x43,0xbe,0x47,0x32,0x8f,0x0e,0xfd,0x64,0x42,0x59,0x2b,0xe5,0xde,0x6d,0x80,0x7a,
472726 };
473727
728 static UINT8 calc3_key05[64] = {
729    0x5e,0xd8,0xa6,0xd7,0x00,0x94,0x23,0x66,0xaf,0xea,0xbe,0x45,0x38,0x90,0x8e,0x8d,
730   0x5b,0x14,0x2c,0xda,0x55,0x7e,0x9d,0x08,0x2d,0x31,0xfd,0x3a,0xbe,0x13,0xeb,0x21,
731   0x87,0xee,0xb7,0x7b,0x34,0x15,0x4d,0xd9,0xeb,0x4a,0xde,0xa6,0x57,0xdf,0x53,0x65,
732   0x75,0x1c,0x72,0x3a,0x20,0xe1,0xcd,0xac,0x5d,0x8c,0x6d,0xa9,0x66,0x1d,0x41,0xca,
733};
734
735/* ok - shogwarr */
736static UINT8 calc3_key15[64] = {
737   0x0C,0xEB,0x30,0x25,0xA8,0xED,0xE3,0x23,0xAC,0x2B,0x8D,0x34,0x88,0x9F,0x55,0xB5,
738   0xBF,0x15,0xE3,0x7C,0x54,0xD4,0x72,0xA9,0x7E,0x80,0x27,0x9F,0xA3,0x3F,0xA1,0x4D,
739   0x84,0x1B,0xD1,0xB2,0xB5,0xA7,0x0C,0xA0,0x51,0xE6,0x5E,0xC0,0xEB,0x68,0x22,0xD6,
740   0xC8,0xB6,0xCF,0x46,0x4B,0xF0,0x15,0xD7,0xB0,0xB5,0x29,0xB8,0xFD,0x43,0x5C,0xC0
741};
742
474743  static UINT8 calc3_key17[64] = {
475744    0x1b,0x48,0xa4,0xdd,0x2e,0x7a,0xe3,0xd1,0x6d,0x9e,0x49,0x31,0xdb,0x13,0xe6,0x00,
476745   0xf1,0x8f,0xcb,0x3f,0x23,0xc1,0xf3,0xb4,0x30,0x35,0xf4,0xea,0x2c,0x77,0x65,0x79,
r5534r5535
485754   0x7f,0x5f,0xa6,0x1b,0x90,0x96,0x19,0x14,0x22,0x81,0x38,0xcd,0x20,0x2f,0x22,0x70,
486755};
487756
757  static UINT8 calc3_key22[64] = {
758    0xfe,0xf7,0xc7,0x85,0xe4,0xd3,0x93,0xd0,0x36,0x61,0xc8,0x4d,0x0c,0x3e,0x2a,0x1c,
759   0x32,0x1a,0xbf,0x1a,0xb0,0x60,0xb5,0xa8,0x1a,0x19,0x16,0xaf,0x96,0x0d,0x2d,0xe0,
760   0xb1,0x2c,0xb6,0x41,0xe1,0x2d,0xc8,0xe5,0xd9,0x75,0x82,0xfa,0x90,0x3a,0x77,0x09,
761   0x0e,0xe8,0xda,0x7a,0xfb,0xc4,0x68,0x57,0xe8,0xcf,0x18,0x51,0x5b,0xed,0x83,0x08,
762};
763
488764  static UINT8 calc3_key24[64] = {
489765    0x75,0x49,0x7a,0xd6,0x84,0xbd,0x70,0xbe,0x10,0x19,0x6c,0xb2,0xa9,0x5f,0x6b,0x78,
490766   0x14,0x29,0x2a,0x15,0xd0,0x4a,0x10,0x93,0x69,0xb2,0xdf,0x02,0x7f,0x92,0x19,0xbd,
r5534r5535
506782   0x26,0xf3,0x44,0x94,0xdb,0x15,0x76,0xcc,0x28,0x33,0x2d,0x4b,0x79,0xdb,0x06,0xbc
507783};
508784
785static UINT8 calc3_key3f[64] = {
786   0x27,0xb4,0xc1,0xba,0x5f,0xd4,0x47,0x04,0x1f,0xfe,0x42,0xa5,0xce,0xb5,0x23,0xbe,
787   0x42,0xcc,0x59,0x71,0x51,0x13,0x41,0xa4,0x18,0x35,0xcf,0x02,0x0d,0xe1,0xfb,0x43,
788   0xc5,0x28,0xed,0xae,0x84,0x27,0xe8,0xdc,0x89,0xe5,0xf6,0xbe,0x16,0x7e,0x57,0xe1,
789   0x41,0x82,0xa9,0xf1,0x7c,0x98,0xd7,0x7c,0xe5,0x67,0xc2,0xf9,0x4d,0xb6,0xb0,0x09,
790};
791
509792 static UINT8 calc3_key80[64] = {
510793    0x33,0x8e,0x6f,0x22,0xac,0x01,0x9f,0x7a,0xc7,0xca,0x23,0xc4,0xa4,0x9c,0x07,0xf8,
511794   0x98,0xc1,0x17,0x4a,0xb2,0xbc,0xcc,0xf4,0x0e,0x2e,0xf6,0x35,0xdd,0xf6,0x29,0x9a,
r5534r5535
520803   0x67,0x47,0xee,0xa2,0x35,0xb3,0xff,0x76,0x57,0x4f,0x30,0x66,0xf8,0xe9,0xe0,0x5b,
521804};
522805
806 static UINT8 calc3_keya1[64] = {
807    0x0f,0x35,0xa3,0x7c,0xf1,0x75,0xea,0x27,0x36,0x4d,0x4b,0x1a,0x3b,0x24,0xef,0x9d,
808   0x4e,0x39,0x7e,0x7b,0x3d,0x42,0x0d,0xc2,0x9f,0x53,0xc7,0xc4,0xdf,0x02,0x5d,0x61,
809   0x0c,0xc9,0x2d,0x89,0x63,0xab,0x34,0xfc,0x97,0x1b,0xb5,0x54,0xe6,0x19,0xa5,0x46,
810   0xdc,0x9e,0xdc,0x25,0xe4,0x3a,0xfc,0xa7,0x93,0xfc,0x1f,0xec,0xb3,0x92,0x43,0xbc,
811};
812
813 static UINT8 calc3_keya7[64] = {
814    0x5d,0xdd,0xd4,0xbe,0xc0,0xff,0xe1,0x1b,0x3a,0xd6,0x61,0xc8,0x90,0x02,0x23,0x08,
815   0xfa,0x7a,0xfa,0x1d,0xab,0x2b,0xa0,0x0b,0x24,0xe1,0x6b,0x9e,0x38,0x6b,0xb2,0xae,
816   0xdd,0xfa,0xfc,0xa2,0xb8,0xcb,0xed,0x33,0x66,0x06,0xef,0x72,0x8b,0xe5,0xa3,0x0d,
817   0x9b,0x18,0x05,0xce,0x6a,0x69,0x61,0x64,0x74,0x9c,0xf9,0x66,0xec,0x99,0x72,0x95,
818};
819
820 static UINT8 calc3_keyaf[64] = {
821    0x2c,0xf3,0x0d,0x50,0x30,0x77,0xc2,0x25,0x91,0x83,0x5f,0xac,0xf4,0x56,0x96,0xc8,
822   0x70,0x86,0x16,0x5a,0x1b,0xa1,0x7d,0x08,0x53,0x15,0xfd,0x3c,0xcb,0x4d,0xd0,0x70,
823   0x5c,0x1d,0x5c,0xaa,0x87,0x60,0x24,0x42,0xcc,0xe0,0x75,0xeb,0xae,0x75,0xcc,0xf1,
824   0x81,0x71,0x09,0xc0,0xf8,0x3c,0x55,0xa6,0x71,0x3c,0xd2,0xda,0xfe,0xf8,0x07,0xbc,
825};
826
523827static UINT8 calc3_keybc[64] = {
524828    0xb8,0x8a,0xa5,0x8f,0x58,0x30,0xb0,0x38,0xa6,0x53,0x84,0x33,0xd4,0xd7,0xbd,0x26,
525829   0x45,0x35,0xb7,0xf6,0x1a,0x20,0x7b,0x8d,0x7e,0x68,0x69,0xdb,0xb1,0x1e,0xa5,0x1a,
r5534r5535
527831   0xfa,0x8e,0x71,0x32,0xfa,0x42,0x69,0xec,0x5d,0x50,0x02,0x42,0xc2,0xe4,0xae,0x5a,
528832 };
529833
834 static UINT8 calc3_keybf[64] = {
835   0x9a,0x8e,0xcf,0x66,0xe0,0xd8,0xd4,0x2a,0x0f,0x4d,0xad,0x64,0x8c,0x6d,0xcb,0x37,
836   0x2e,0x0e,0x9f,0xc4,0xca,0xff,0x85,0xf1,0x7f,0xec,0x71,0x69,0xc2,0x81,0x5c,0xe4,
837   0x28,0xd2,0x6b,0xa9,0xf6,0xfb,0xe4,0x51,0x68,0x03,0xd0,0xcd,0xc3,0x07,0x6f,0xab,
838   0x1c,0x94,0x5f,0x94,0xe6,0x54,0x8b,0x1a,0x3c,0xed,0xd4,0xb0,0xf3,0x26,0x81,0xfa,
839};
840
530841// global so we can use them in the filename when we save out the data (debug..)
531842static UINT8 calc3_decryption_key_byte;
532843static UINT8 calc3_unknown;
844static UINT8 calc3_shift;
533845static UINT8 calc3_mode;
534846static UINT8 calc3_blocksize_offset;
535847static UINT16 calc3_dataend;
536848static UINT16 calc3_database;
537849
850static int data_header[2];
851
852UINT32 calc3_writeaddress;
853UINT32 calc3_writeaddress_current;
854UINT16 calc3_dsw_addr = 0x00;
855UINT16 calc3_eeprom_addr;
856UINT16 calc3_poll_addr;
857UINT16 cakc3_checkumaddress;
858
859static UINT8 shift_bits(UINT8 dat, int bits)
860{
861   bits &=0x7;
862
863   if (bits==0) return BITSWAP8(dat, 7,6,5,4,3,2,1,0);
864   if (bits==1) return BITSWAP8(dat, 6,5,4,3,2,1,0,7);
865   if (bits==2) return BITSWAP8(dat, 5,4,3,2,1,0,7,6);
866   if (bits==3) return BITSWAP8(dat, 4,3,2,1,0,7,6,5);
867   if (bits==4) return BITSWAP8(dat, 3,2,1,0,7,6,5,4);
868   if (bits==5) return BITSWAP8(dat, 2,1,0,7,6,5,4,3);
869   if (bits==6) return BITSWAP8(dat, 1,0,7,6,5,4,3,2);
870   if (bits==7) return BITSWAP8(dat, 0,7,6,5,4,3,2,1);
871
872   return dat;
873}
874
538875// endian safe? you're having a laugh
539876int calc3_decompress_table(running_machine* machine, int tabnum, UINT8* dstram, int dstoffset)
540877{
878   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
541879   UINT8* rom = memory_region(machine,"cpu1");
542880   UINT8 numregions;
543881   UINT16 length;
882   int local_counter=0;
544883   int x;
545884   int offset = 0;
546885   int isbrap = ( !strcmp(machine->gamedrv->name,"brapboysj") || !strcmp(machine->gamedrv->name,"brapboys"));
r5534r5535
572911      calc3_blocksize_offset =    rom[offset+0]; // location of the 'block length'
573912      calc3_mode =                rom[offset+1];
574913      calc3_unknown =             rom[offset+2];
914      calc3_shift = (calc3_unknown &0xf0)>>4;
915      calc3_unknown &= 0x0f;
575916      calc3_decryption_key_byte = rom[offset+3];
576917
577918
r5534r5535
587928      length = rom[offset+0] | (rom[offset+1]<<8);
588929      offset+=2;
589930
931#if CALC3_VERBOSE_OUTPUT
590932      if (inline_table_size)
591933      {
592         printf("Block %02x Found Base %04x - Inline Encryption (size %02x) - Mode? %02x Unknown %02x Key (unused?) %02x Length %04x\n", tabnum, calc3_database, inline_table_size, calc3_mode, calc3_unknown, calc3_decryption_key_byte, length);
934         printf("Block %02x Found Base %04x - Inline Encryption (size %02x) - Mode? %02x Shift %01x Unk %01x Key (unused?) %02x Length %04x\n", tabnum, calc3_database, inline_table_size, calc3_shift, calc3_mode, calc3_unknown, calc3_decryption_key_byte, length);
593935      }
594936      else
595937      {
596         printf("Block %02x Found Base %04x - Mode? %02x Unknown %02x Key %02x Length %04x\n", tabnum, calc3_database, calc3_mode, calc3_unknown, calc3_decryption_key_byte, length);
938         printf("Block %02x Found Base %04x - Mode? %02x Shift %01x Unk %01x Key %02x Length %04x\n", tabnum, calc3_database, calc3_mode, calc3_shift, calc3_unknown, calc3_decryption_key_byte, length);
597939      }
598
599
940#endif
600941      // copy + decrypt the table to the specified memory area
601      if (dstram)
942      //if (dstram)
602943      {
603944         int i;
604945
r5534r5535
607948            // shogwarr does this with 'mode' as 0x08, which probably has some special meaning
608949            //printf("CALC3: requested 0 length table!\n");
609950            // -- seems to be 'reset stack' to default for the protection table writes
951
952            // except this will break shogun going into game, must be specific conditions for
953            // this, or it can remember addresses and restore those
954
955            // hack, set it to a known address instead of trying to restore to anywhere specific..
956            // might break at some point tho, eg if it doesn't write command 06 often enough because it trys to use another one like 07...
957            // need to understand the meaning of this (test hw?)
958
959            // !dstram is used because we don't want to process these during our initial table scan, only when the game asks!
960
961            if (calc3_mode==0x06)
962            {
963               calc3_writeaddress_current = 0x202000;
964            }
965            else if (calc3_mode==0x07)
966            {
967               // also calls empty table with Mode? 07
968               // maybe they reset to different points?
969            }
970            else if (calc3_mode==0x08 && !dstram)
971            {
972               //printf("save to eeprom\n");
973
974               {
975                  UINT32 length, size;
976                  UINT8 *dat;
977
978                  dat = (UINT8 *)eeprom_get_data_pointer(&length, &size);
979
980                  for (i=0;i<0x80;i++)
981                  {
982                     dat[i] = memory_read_byte(space, calc3_eeprom_addr+0x200000+i);
983                  }
984
985               }
986
987            }
988            else if (!dstram)
989            {
990               printf("unknown blank table command\n");
991            }
992
993            return 0;
610994         }
611995
612996         if (inline_table_size)
613997         {
998         // these should be derived from the inline table somehow, probably just a +/- swap like the normal stuff.. maybe
999            UINT8 extra[]  = { 0x14,0xf0,0xf8,0xd2,0xbe,0xfc,0xac,0x86,0x64,0x08,0x0c,0x74,0xd6,0x6a,0x24,0x12,0x1a,0x72,0xba,0x48,0x76,0x66,0x4a,0x7c,0x5c,0x82,0x0a,0x86,0x82,0x02,0xe6 };
1000            UINT8 extra2[] = { 0x2f,0x04,0xd1,0x69,0xad,0xeb,0x10,0x95,0xb0,0x2f,0x0a,0x83,0x7d,0x4e,0x2a,0x07,0x89,0x52,0xca,0x41,0xf1,0x4f,0xaf,0x1c,0x01,0xe9,0x89,0xd2,0xaf,0xcd };
1001
1002
6141003            for (i=0;i<length;i++)
6151004            {
6161005               UINT8 dat=0;
1006               int extrasign = -1;
6171007
618               if (tabnum==0x11 && isbrap )
619               {
6201008
621                  // typed data.. to verify results, out decrypt works!
622                  unsigned char rawData[252+2] = {
623                     0x00,0x00,  0x42, 0x79, 0x00, 0x20, 0x08, 0x2E, 0x10, 0x39, 0x00, 0x20, 0x00, 0xC2,
624                     0x02, 0x40, 0x00, 0x30, 0xE4, 0x48, 0x33, 0xFB, 0x00, 0x3C, 0x00, 0x10,
625                     0x22, 0x42, 0x30, 0x3B, 0x00, 0x32, 0x43, 0xEE, 0x00, 0x0A, 0x41, 0xF9,
626                     0x00, 0x20, 0x08, 0x30, 0x4A, 0x50, 0x67, 0x00, 0x00, 0x04, 0x4E, 0x75,
627                     0x11, 0x40, 0x00, 0x02, 0x11, 0x7C, 0x00, 0xFC, 0x00, 0x03, 0x31, 0x49,
628                     0x00, 0x04, 0x30, 0xBC, 0x00, 0x01, 0x42, 0x6E, 0xFF, 0xB0, 0x41, 0xFA,
629                     0x00, 0x16, 0x2C, 0x88, 0x4E, 0x75, 0x00, 0x16, 0x00, 0x00, 0x00, 0x17,
630                     0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00, 0x19, 0x00, 0x01, 0x33, 0xC0,
631                     0x00, 0x2C, 0x00, 0x00, 0x30, 0x3C, 0x00, 0x14, 0x51, 0xC8, 0xFF, 0xFE,
632                     0x33, 0xC0, 0x00, 0x2D, 0x00, 0x00, 0x42, 0x79, 0x00, 0x20, 0x08, 0x2E,
633                     0x41, 0xF9, 0x00, 0x10, 0x78, 0xB6, 0x70, 0x07, 0x0C, 0x10, 0x00, 0x03,
634                     0x66, 0x00, 0x00, 0x0E, 0x53, 0x68, 0x00, 0x0E, 0x66, 0x00, 0x00, 0x06,
635                     0x10, 0xBC, 0x00, 0x04, 0x41, 0xE8, 0x00, 0x12, 0x51, 0xC8, 0xFF, 0xE6,
636                     0x32, 0x39, 0x00, 0x10, 0x22, 0x46, 0x02, 0x41, 0xFF, 0xFC, 0x10, 0x39,
637                     0x00, 0x20, 0x00, 0xC2, 0x02, 0x40, 0x00, 0x01, 0x82, 0x40, 0xE3, 0x48,
638                     0x82, 0x40, 0x33, 0xC1, 0x00, 0x90, 0x00, 0x00, 0x33, 0xFB, 0x00, 0x2A,
639                     0x00, 0x10, 0x20, 0x26, 0xE5, 0x48, 0x23, 0xFB, 0x00, 0x24, 0x00, 0x10,
640                     0x20, 0x22, 0x33, 0xFB, 0x00, 0x20, 0x00, 0x90, 0x00, 0x02, 0x32, 0x39,
641                     0x00, 0x10, 0x22, 0x48, 0x82, 0x7B, 0x00, 0x14, 0x33, 0xC1, 0x00, 0x80,
642                     0x00, 0x08, 0x4E, 0x75, 0xFF, 0xFF, 0x00, 0x3F, 0xE8, 0xC0, 0x42, 0x00,
643                     0x03, 0xC0, 0x00, 0x00, 0x57, 0x00, 0x7E, 0x00, 0xFC, 0x00, 0x03, 0x03
644                  };
1009               if (
1010                   (tabnum==0x11 && isbrap) ||
1011                     (tabnum==0x1a && isbrap) ||
1012                   (tabnum==0x21 && isbrap) ||
1013                   (tabnum==0x24 && isbrap) ||
1014                   (tabnum==0x28 && isbrap)
1015                  /*(tabnum==0x40 && !isbrap)*/
1016                  )
1017                     extrasign = 0;
6451018
646                  if ( ((i / 19)&1)==0)
1019               if ((tabnum==0x25 && isbrap))
1020                  extrasign = 1;
1021
1022
1023
1024               if (extrasign !=-1)
1025               {
1026                  if ( ((i / inline_table_size)&1)==0)
6471027                  {
6481028                     if (((i%inline_table_size)&1)==1)
6491029                     {
6501030                        UINT8 inlinet = rom[inline_table_base + (i%inline_table_size)];
6511031                        dat = rom[offset+i];
652                        //printf("%02x, ",inlinet);
6531032                        dat -= inlinet;
654
655                        dat = BITSWAP8(dat, 4,3,2,1,0,7,6,5);
656                        if (dat != rawData[i]) printf("ERROR %d x %02x %02x\n", (i / 19)&1, dat, rawData[i]);
1033                        dat = shift_bits(dat, calc3_shift);
6571034                     }
6581035                     else
6591036                     {
660                        UINT8 extra[] = { 0x14,0xf0,0xf8,0xd2,0xbe,0xfc,0xac,0x86,0x64,0x08,0x0c/*,0x74,0xd6,0x6a,0x24,0x12,0x1a */};
1037
6611038                        UINT8 inlinet = rom[inline_table_base + (i%inline_table_size)];
6621039                        dat = rom[offset+i];
663                        dat -= inlinet;
664                        dat -= extra[(i%inline_table_size)>>1];
665                        dat = BITSWAP8(dat, 2,1,0,7,6,5,4,3);
6661040
667                        if (dat != rawData[i]) printf("ERROR %d y %02x %02x\n", (i / 19)&1, dat, rawData[i]);
1041                        if (extrasign==0)
1042                        {
1043                           dat -= inlinet;
1044                           dat -= extra[(i%inline_table_size)>>1];
1045                        }
1046                        else
1047                        {
1048                           dat += inlinet;
1049                           dat += extra[(i%inline_table_size)>>1];
1050                        }
6681051
669                        //dat = rawData[i];
670
1052                        dat = shift_bits(dat, 8-calc3_shift);
6711053                     }
6721054                  }
6731055                  else
r5534r5535
6771059                        UINT8 inlinet = rom[inline_table_base + (i%inline_table_size)];
6781060                        dat = rom[offset+i];
6791061                        dat -= inlinet;
680
681                        dat = BITSWAP8(dat, 4,3,2,1,0,7,6,5);
682                        if (dat != rawData[i]) printf("ERROR %d x %02x %02x\n", (i / 19)&1, dat, rawData[i]);
1062                        dat = shift_bits(dat, calc3_shift);
6831063                     }
6841064                     else
6851065                     {
686                        // shhould probably use the inline table somehow?
687
688                        UINT8 extra[] = { 0x2f, 0x04, 0xd1, 0x69, 0xad, 0xeb, 0x10, 0x95,0xb0 };;
6891066                        dat = rom[offset+i];
6901067
691                        dat -= extra[(i%inline_table_size)>>1];
692                        dat = BITSWAP8(dat, 2,1,0,7,6,5,4,3);
693
694                        if (dat != rawData[i]) printf("ERROR %d y %02x %02x\n", (i / 19)&1, dat, rawData[i]);
1068                        if (extrasign==0)
1069                        {
1070                           dat -= extra2[(i%inline_table_size)>>1];
1071                        }
1072                        else
1073                        {
1074                           dat += extra2[(i%inline_table_size)>>1];
1075                        }
1076                        dat = shift_bits(dat, 8-calc3_shift);
6951077                     }
6961078                  }
6971079               }
698               else if (tabnum==0x40) // fjbuster / shogun warriors japanese character select (what enables this extra?)
1080               // the above rule doesn't work for this case... hmm ..
1081               else if (tabnum==0x40 && !isbrap) // fjbuster / shogun warriors japanese character select (what enables this extra?)
6991082               {
7001083                  UINT8 inlinet = rom[inline_table_base + (i%inline_table_size)];
7011084                  dat = rom[offset+i];
r5534r5535
7061089                  // is relative to the start of the original table, and has a size of 0x11 (17) bytes which loop.
7071090                  if (((i%inline_table_size)&1)==0)
7081091                  {
709                     // thie gets mapped over half the inline table?!..  (inline length is 0x22, this changes odd bytes)
710                     // what specifies the additional overlay here?
711                     UINT8 extra[0x11] = { 0x14,0xf0,0xf8,0xd2,0xbe,0xfc,0xac,0x86,0x64,0x08,0x0c,0x74,0xd6,0x6a,0x24,0x12,0x1a };
7121092                     dat -= extra[(i%inline_table_size)>>1];
1093                  }
1094               }
1095               else
1096               {
1097                  if (i==1)
1098                     printf("unhandled inline case\n");
7131099
1100               }
1101
1102               if(local_counter>1)
1103               {
1104                  if (space)
1105                  {
1106                     memory_write_byte(space, dstoffset+i, dat);
7141107                  }
7151108
716
1109                  // debug, used to output tables at the start
1110                  if (dstram)
1111                  {
1112                     dstram[(dstoffset+i)^1] = dat;
1113                  }
7171114               }
1115               else
1116                  data_header[local_counter]=dat;
7181117
719               dstram[(dstoffset+i)^1] = dat;
1118               ++local_counter;
7201119            }
7211120         }
7221121         else
r5534r5535
7291128            // each key seems to relate directly to a 0x40 byte decryption table, only these ones handled so far
7301129            if (calc3_decryption_key_byte == 0x01) key = calc3_key01;
7311130            if (calc3_decryption_key_byte == 0x04) key = calc3_key04;
1131            if (calc3_decryption_key_byte == 0x05) key = calc3_key05;
7321132            if (calc3_decryption_key_byte == 0x15) key = calc3_key15;
7331133            if (calc3_decryption_key_byte == 0x17) key = calc3_key17;
7341134            if (calc3_decryption_key_byte == 0x19) key = calc3_key19;
1135            if (calc3_decryption_key_byte == 0x22) key = calc3_key22;
7351136            if (calc3_decryption_key_byte == 0x24) key = calc3_key24;
7361137            if (calc3_decryption_key_byte == 0x31) key = calc3_key31;
7371138            if (calc3_decryption_key_byte == 0x39) key = calc3_key39;
1139            if (calc3_decryption_key_byte == 0x3f) key = calc3_key3f;
7381140            if (calc3_decryption_key_byte == 0x80) key = calc3_key80;
7391141            if (calc3_decryption_key_byte == 0x89) key = calc3_key89;
1142            if (calc3_decryption_key_byte == 0xa1) key = calc3_keya1;
1143            if (calc3_decryption_key_byte == 0xa7) key = calc3_keya7;
1144            if (calc3_decryption_key_byte == 0xaf) key = calc3_keyaf;
7401145            if (calc3_decryption_key_byte == 0xbc) key = calc3_keybc;
1146            if (calc3_decryption_key_byte == 0xbf) key = calc3_keybf;
7411147
742
7431148            for (i=0;i<length;i++)
7441149            {
7451150
7461151
7471152               UINT8 dat = rom[offset+i];
7481153
749               if (tabnum==0x12 && isbrap)
1154               if ((tabnum==0x10 && isbrap) ||
1155                   (tabnum==0x13 && isbrap) ||
1156                   (tabnum==0x14 && isbrap) ||
1157                   (tabnum==0x15 && isbrap) ||
1158                   (tabnum==0x16 && isbrap) ||
1159                   (tabnum==0x18 && isbrap) ||
1160                   (tabnum==0x19 && isbrap) ||
1161                   (tabnum==0x1b && isbrap) ||
1162                   (tabnum==0x1c && isbrap) ||
1163                   (tabnum==0x1d && isbrap) ||
1164                   (tabnum==0x1f && isbrap) ||
1165                   (tabnum==0x20 && isbrap) ||
1166                   (tabnum==0x22 && isbrap) ||
1167                   (tabnum==0x23 && isbrap) ||
1168                   (tabnum==0x26 && isbrap) ||
1169                   (tabnum==0x27 && isbrap) ||
1170                   (tabnum==0x2a && isbrap) ||
1171                  (tabnum==0x41 && !isbrap))
7501172               {
751                  dat = BITSWAP8(dat, 4,3,2,1,0,7,6,5);
752               }
753               else if (tabnum==0x13 && isbrap)
754               {
7551173                  dat -= key[i&0x3f];
7561174
757                  if ((i&1)==0) dat = BITSWAP8(dat, 5,4,3,2,1,0,7,6);
758                  else          dat = BITSWAP8(dat, 1,0,7,6,5,4,3,2);
1175                  if ((i&1)==0) dat = shift_bits(dat, 8-calc3_shift);
1176                  else          dat = shift_bits(dat, calc3_shift);
7591177
7601178               }
761               else if (tabnum==0x14 && isbrap)
1179               else if ((tabnum==0x17 && isbrap) ||
1180                        (tabnum==0x29 && isbrap) ||
1181                      (tabnum==0x2b && isbrap) ||
1182                      (tabnum==0x2c && isbrap) ||
1183                      (tabnum==0x2d && isbrap))
7621184               {
763                  dat -= key[i&0x3f];
764               }
765               else if (tabnum==0x15 && isbrap)
766               {
767                  dat -= key[i&0x3f];
1185                  if ((i&1)==0) dat += key[i&0x3f];
1186                  else dat -= key[i&0x3f];
7681187
769                  if ((i&1)==0) dat = BITSWAP8(dat, 2,1,0,7,6,5,4,3);
770                  else          dat = BITSWAP8(dat, 4,3,2,1,0,7,6,5);
771
772                  //error 264 35 36  (typo, ignore)
1188                  if ((i&1)==0) dat = shift_bits(dat, 8-calc3_shift);
1189                  else          dat = shift_bits(dat, calc3_shift);
7731190               }
774               else if (tabnum==0x16 && isbrap)
1191               else if ((tabnum==0x1e && isbrap) ||
1192                        (tabnum==0x80 && !isbrap))
7751193               {
776                  dat -= key[i&0x3f];
777                  // error 1 02 should be 00 (the usual)
778               }
779               else if (tabnum==0x17 && isbrap)
780               {
781                  // note we've seen this key (0x15) before, but again, here we have to add sometimes.. obviously a bit to control this..
782                  if ((i&1)==0) dat += key[i&0x3f];
1194                  // note we've already seen this table, but like many others, it's + instead of - on some bytes..
1195                  if ((i&1)==1) dat += key[i&0x3f];
7831196                  else dat -= key[i&0x3f];
7841197
785                  if ((i&1)==0) dat = BITSWAP8(dat, 0,7,6,5,4,3,2,1);
786                  else          dat = BITSWAP8(dat, 6,5,4,3,2,1,0,7);
787
788                  //error 1 02 should be 00 (the usual)
789                  //error 390 02 should be 00 (typo, ignore)
790                  //error 391 c6 should be 2c (typo, ignore)
791                  //error 392 03 should be 60 (typo, ignore)
792                  //error 393 60 should be 36 (typo, ignore)
1198                  if ((i&1)==0) dat = shift_bits(dat, 8-calc3_shift);
1199                  else          dat = shift_bits(dat, calc3_shift);
7931200               }
794               else if (tabnum==0x19 && isbrap)
1201               else if (tabnum==0x12 && isbrap)
7951202               {
796                  dat -= key[i&0x3f];
797                  // first 2 bytes were 00 in the returned data..
798                  //if (i==1) dat=0x00;
1203                  // this one doesn't alternate the shifts...  'unknown' is 8
1204                  dat = BITSWAP8(dat, 4,3,2,1,0,7,6,5);
7991205               }
800               else if (tabnum==0x1f && isbrap)
1206               else
8011207               {
1208                  if (i==1) printf("unhandled non-inline case!\n");
1209                  // plain table case
8021210                  dat -= key[i&0x3f];
1211               }
8031212
804                  if ((i&1)==0) dat = BITSWAP8(dat, 0,7,6,5,4,3,2,1);
805                  else          dat = BITSWAP8(dat, 6,5,4,3,2,1,0,7);
806               }
807               else if (tabnum==0x22 && isbrap)
1213               if(local_counter>1)
8081214               {
809
810                  #if 0
1215                  if (space)
8111216                  {
812                     UINT8 test;
813                     UINT8 xxx;
814
815                     if ((i&1)==1) xxx = BITSWAP8(rawData[i], 0,7,6,5,4,3,2,1);
816                     else          xxx = BITSWAP8(rawData[i], 6,5,4,3,2,1,0,7);
817
818                     test= dat-xxx;
819
820                     printf("%02x,%02x,%02x  ",dat, rawData[i], test);
821
822                     if ((i%0x40)==0x3f)
823                        printf("\n");
824
825                     //if (dat!=rawData[i]) printf("error %d %02x should be %02x\n",i, dat, rawData[i]);
1217                     memory_write_byte(space, dstoffset+i, dat);
8261218                  }
827                  #endif
828                  {
829                     dat -= key[i&0x3f];
8301219
831                     if ((i&1)==0) dat = BITSWAP8(dat, 0,7,6,5,4,3,2,1);
832                     else          dat = BITSWAP8(dat, 6,5,4,3,2,1,0,7);
833                     // first 2 bytes were 00 in the returned data..
834                     //if (i==1) dat=0x00;
835                  }
836
837
838               }
839               else if (tabnum==0x23 && isbrap)
840               {
841                  dat -= key[i&0x3f];
842                  // error 1 18 should be 00 (usual byte 1 'issue)
843                  // error 384 98 should be 38 (typo, ignore)
844
845               }
846               else if (tabnum==0x80 && !isbrap) // shogwarr table 80 (irq code)
847               {
848                  if ((i&1)==0)
1220                  // debug, used to output tables at the start
1221                  if (dstram)
8491222                  {
850                     dat -= key[i&0x3f];
851                     dat = BITSWAP8(dat,2,1,0,7,6,5,4,3);
1223                     dstram[(dstoffset+i)^1] = dat;
8521224                  }
853                  else
854                  {
855                     // note + , not -  (!!)
856                     dat += key[i&0x3f];
857                     dat = BITSWAP8(dat,4,3,2,1,0,7,6,5);
858                  }
8591225               }
860               else if (tabnum==0x41 && !isbrap) // shogwarr table 41  -- note fjbuster uses table 40, which looks like (almost) the same data but with better encryption...
861               {
862                  // simple shifts...  different direction for each alternating byte..
863                  dat -= key[i&0x3f];
864
865                  if ((i&1)==1) dat = BITSWAP8(dat,0,7,6,5,4,3,2,1);
866                  else dat = BITSWAP8(dat,6,5,4,3,2,1,0,7);
867               }
8681226               else
869               {
870                  // plain table case
871                  dat -= key[i&0x3f];
872               }
1227                  data_header[local_counter]=dat;
8731228
1229               ++local_counter;
8741230
875               dstram[(dstoffset+i)^1] = dat;
1231               //dstram[(dstoffset+i)^1] = dat;
8761232            }
8771233         }
8781234      }
r5534r5535
8861242
8871243}
8881244
1245
1246
8891247DRIVER_INIT(calc3_scantables)
8901248{
8911249   UINT8* rom = memory_region(machine,"cpu1");
r5534r5535
8981256   {
8991257      calc3_mcu_crc+=rom[x];
9001258   }
901   printf("crc %04x\n",calc3_mcu_crc);
1259   //printf("crc %04x\n",calc3_mcu_crc);
9021260   numregions = rom[0];
9031261
9041262   for (x=0;x<numregions;x++)
r5534r5535
9081266      memset(tmpdstram, 0x00,0x2000);
9091267      length = calc3_decompress_table(machine, x, tmpdstram, 0);
9101268
1269#if CALC3_VERBOSE_OUTPUT
9111270      // dump to file
9121271      if (length)
9131272      {
r5534r5535
9341293            fclose(fp);
9351294         }
9361295      }
937
1296#endif
9381297      free(tmpdstram);
9391298   }
9401299
r5534r5535
9431302   // to that extra block of data
9441303
9451304   // dump out the 0x1000 sized block at the end
1305#if CALC3_VERBOSE_OUTPUT
9461306   {
9471307      FILE *fp;
9481308      char filename[256];
r5534r5535
9571317         fclose(fp);
9581318      }
9591319   }
1320#endif
9601321}
9611322
962UINT32 calc3_writeaddress;
963UINT16 calc3_dsw_addr;
964UINT16 calc3_eeprom_addr;
965UINT16 calc3_poll_addr;
966UINT16 cakc3_checkumaddress;
9671323
1324
9681325extern UINT16 calc3_mcu_crc;
969extern UINT16* kaneko16_calc3_fakeram;
970// from brap boys, might be polluted with shogun warriors values tho as was running shogun code at the time
971static UINT16 kaneko16_eeprom_data[0x40] =
972{
973   0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,   0x0000, 0x0000,
974   0x0000, 0x0003, 0x0002, 0x1020, 0x0002, 0x6010, 0x0101, 0x0101,
975   0x0101, 0x0001,   0x0003, 0x0008, 0x4B41, 0x4E45, 0x4B4F, 0x2020,
976   0x4265, 0x2052, 0x6170, 0x2042, 0x6F79, 0x7300,   0x3030, 0x302E,
977   0x3038, 0x7FFF, 0xFFFF, 0xFFFF,   0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
978   0xFFFF, 0xFFFF,   0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,
979   0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,   0xFFFF, 0xFFFF,
980   0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF,   0x003B, 0xFFFF, 0xFFFF, 0xFFFF
981};
9821326
983static void calc3_mcu_run(running_machine *machine)
1327void calc3_mcu_run(running_machine *machine)
9841328{
9851329   UINT16 mcu_command;
9861330   int i;
1331   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
9871332
9881333   if ( calc3_mcu_status != (1|2|4|8) )   return;
9891334
1335   if (calc3_dsw_addr) memory_write_byte(space, calc3_dsw_addr+0x200000, ( ~input_port_read(machine, "DSW1"))&0xff); // // DSW // dsw actually updates in realtime - mcu reads+writes it every frame
1336
1337
9901338   //calc3_mcu_status = 0;
9911339
9921340   mcu_command = kaneko16_mcu_ram[calc3_mcu_command_offset/2 + 0];
r5534r5535
10021350      /* 0xff is a special 'init' command */
10031351      if (mcu_command == 0xff)
10041352      {
1353
10051354         // clear old command (handshake to main cpu)
10061355         kaneko16_mcu_ram[(calc3_mcu_command_offset>>1)+0] = 0x0000;
10071356
r5534r5535
10141363         calc3_writeaddress =      (kaneko16_mcu_ram[(0>>1) + 6] << 16) |
10151364                                   (kaneko16_mcu_ram[(0>>1) + 7]);
10161365
1366         // set our current write / stack pointer to the address specified
1367         calc3_writeaddress_current = calc3_writeaddress;
1368#if CALC3_VERBOSE_OUTPUT
10171369         printf("Calc 3 Init Command - %04x DSW addr\n",  calc3_dsw_addr);
10181370         printf("Calc 3 Init Command - %04x Eeprom Address\n",  calc3_eeprom_addr);
10191371         printf("Calc 3 Init Command - %04x Future Commands Base\n",  calc3_mcu_command_offset);
10201372         printf("Calc 3 Init Command - %04x Poll / Busy Address\n",  calc3_poll_addr);
10211373         printf("Calc 3 Init Command - %04x ROM Checksum Address\n",  cakc3_checkumaddress);
10221374         printf("Calc 3 Init Command - %08x Data Write Address\n",  calc3_writeaddress);
1375#endif
1376   //      memory_write_byte(space, calc3_dsw_addr+0x200000, ( ~input_port_read(machine, "DSW1"))&0xff); // // DSW // dsw actually updates in realtime - mcu reads+writes it every frame
10231377
1024         kaneko16_mcu_ram[calc3_dsw_addr/2] = ~input_port_read(machine, "DSW1");   // DSW // dsw actually updates in realtime - mcu reads+writes it every frame
10251378         kaneko16_mcu_ram[cakc3_checkumaddress / 2] = calc3_mcu_crc;            // MCU Rom Checksum!
10261379
1027         for (i=0;i<0x40;i++)
1380         /*
1381            for (i=0;i<0x40;i++)
1382            {
1383                kaneko16_mcu_ram[(calc3_eeprom_addr / 2)+i] = kaneko16_eeprom_data[i];//((eepromData[i]&0xff00)>>8) |  ((eepromData[i]&0x00ff)<<8);
1384            }
1385            */
1386
10281387         {
1029            kaneko16_mcu_ram[(calc3_eeprom_addr / 2)+i] = kaneko16_eeprom_data[i];//((eepromData[i]&0xff00)>>8) |  ((eepromData[i]&0x00ff)<<8);
1388            UINT32 length, size;
1389            UINT8 *dat;
1390
1391            dat = (UINT8 *)eeprom_get_data_pointer(&length, &size);
1392
1393            for (i=0;i<0x80;i++)
1394            {
1395               memory_write_byte(space, calc3_eeprom_addr+0x200000+i, dat[i]);
1396            }
1397
10301398         }
10311399
10321400      }
r5534r5535
10461414            int param1 = kaneko16_mcu_ram[(calc3_mcu_command_offset>>1) + 1 + (2*i)];
10471415            int param2 = kaneko16_mcu_ram[(calc3_mcu_command_offset>>1) + 2 + (2*i)];
10481416            UINT8  commandtabl = (param1&0xff00) >> 8;
1049            UINT16 commandaddr = (param1&0x00ff) | (param2&0xff00);
1050            UINT8  commandunk =  (param2&0x00ff); // brap boys sets.. seems to cause further writebasck address displacement??
1051
1052            UINT32 fakeoffs;
1053
1417            UINT16 commandaddr =param2;// (param1&0x00ff) | (param2&0xff00);
1418            UINT8  commandunk =  (param1&0x00ff); // brap boys sets.. seems to cause further writebasck address displacement?? (when tested on hw it looked like a simple +, but that doesn't work for brapboys...)
1419#if CALC3_VERBOSE_OUTPUT
10541420            printf("transfer %d table %02x writeback address %04x unknown %02x\n", i, commandtabl, commandaddr, commandunk);
1055
1056            // the data SHOULD be written somewhere to main ram, probably related to the calc3_writeaddress set in command 0xff
1057            // but I'm not sure how, for now write it back to a FAKE region instead
1058            fakeoffs = 0x1e00*commandtabl;
1059            fakeoffs+=0xf00000;
1060
1061            // HACK HACK HACK, I don't know what commandunk does, but Brap Boys polls a table of addresses and doesn't do anything
1062            // more unless they change.  The usual writeback address doesn't touch this table, so I think this unknown value must
1063            // cause an additional displacement to cause the writeback address to populate that table.. maybe
1064            if (commandunk == 0x30)
1421#endif
10651422            {
10661423               int length;
1067               commandaddr -= 0x60;
1068               length = calc3_decompress_table(machine, commandtabl, (UINT8*)kaneko16_mcu_ram, (calc3_writeaddress&0xffff)-2);
10691424
1070               printf("writing back address %08x to %08x\n", calc3_writeaddress, commandaddr);
1071               kaneko16_mcu_ram[(commandaddr>>1)+0] = (calc3_writeaddress>>16)&0xffff;
1072               kaneko16_mcu_ram[(commandaddr>>1)+1] = (calc3_writeaddress&0xffff);
1073               calc3_writeaddress += length;
1425               length = calc3_decompress_table(machine, commandtabl, 0, calc3_writeaddress_current-2);
10741426
1075            }
1076            else if (commandunk == 0xa0)
1077            {
1078               int length;
1079               commandaddr -= 0x6d;
1080               length = calc3_decompress_table(machine, commandtabl, (UINT8*)kaneko16_mcu_ram, (calc3_writeaddress&0xffff)-2);
1427               if (length)
1428               {
1429                  int write=commandaddr;
1430#if CALC3_VERBOSE_OUTPUT
1431                  printf("writing back address %08x to %08x %08x\n", calc3_writeaddress_current, commandaddr,write);
1432#endif
10811433
1082               printf("writing back address %08x to %08x\n", calc3_writeaddress, commandaddr);
1083               kaneko16_mcu_ram[(commandaddr>>1)+0] = (calc3_writeaddress>>16)&0xffff;
1084               kaneko16_mcu_ram[(commandaddr>>1)+1] = (calc3_writeaddress&0xffff);
1085               calc3_writeaddress += length;
1086            }
1087            else if (commandunk == 0x98)
1088            {
1089               int length;
1090               commandaddr -= (0x6d+0xd);
1091               length = calc3_decompress_table(machine, commandtabl, (UINT8*)kaneko16_mcu_ram, (calc3_writeaddress&0xffff)-2);
1434                  //memory_write_byte(space,write+0x200001, data_header[0]); // maybe not.. check first boss brapboysj
1435                  memory_write_byte(space,write+0x200001, data_header[1]);
10921436
1093               printf("writing back address %08x to %08x\n", calc3_writeaddress, commandaddr);
1094               kaneko16_mcu_ram[(commandaddr>>1)+0] = (calc3_writeaddress>>16)&0xffff;
1095               kaneko16_mcu_ram[(commandaddr>>1)+1] = (calc3_writeaddress&0xffff);
1096               calc3_writeaddress += length;
1097            }
1437                  write=commandaddr+(char)commandunk;
1438                  memory_write_word(space,write+0x200000, (calc3_writeaddress_current>>16)&0xffff);
1439                  memory_write_word(space,write+0x200002,  (calc3_writeaddress_current&0xffff));
1440                 
1441                  calc3_writeaddress_current += ((length+3)&(~1));
1442               }
10981443
1099
1100            else
1101            {
1102               calc3_decompress_table(machine, commandtabl, (UINT8*)kaneko16_calc3_fakeram, fakeoffs&0xfffff);
1103
1104               // write back WHERE we wrote the data to the address specified so that the code can jump to it etc.
1105               fakeoffs+=2;// the first 2 bytes don't seem to be the offset it expects to jump to..
1106
1107               printf("writing back fake address %08x to %08x\n", fakeoffs, commandaddr);
1108               kaneko16_mcu_ram[(commandaddr>>1)+0] = (fakeoffs>>16)&0xffff;
1109               kaneko16_mcu_ram[(commandaddr>>1)+1] = (fakeoffs&0xffff);
11101444            }
11111445         }
1112
1113
11141446      }
11151447   }
11161448}
src/mame/mamedriv.c
r5534r5535
30263026   DRIVER( shangtou )   /* 2002.02 Shanghai Sangokuhaitougi */
30273027   DRIVER( xiistag )   /* 2002.07 XII Stag (V2.01J) */
30283028   DRIVER( sianniv )   /* 2003.10 Space Invaders Anniversary (V2.02J) */
3029   DRIVER( kollon )   /* 2003.11 Kollon */
3029   DRIVER( kollon )   /* 2003.11 Kollon (V2.04J) */
3030   DRIVER( kollonc )   /* 2003.11 Kollon (V2.04JC, Compact Flash version) */
30303031   DRIVER( zooo )      /* 2004.05 Zooo */
30313032
30323033   /* Namco System 11 */
r5534r5535
42634264                  /* 16 */
42644265                  /* 17 */
42654266                  /* 18 */
4266                  /* 19 */
4267   DRIVER( mt_gfoot )   /* 19 */
42674268   DRIVER( mt_lastb )   /* 20 */
42684269   DRIVER( mt_wcsoc )   /* 21 */
42694270   DRIVER( mt_tetri )   /* 22 */
r5534r5535
67336734   DRIVER( strkforc )   /* (c) 1991 Midway */
67346735   DRIVER( mk )      /* (c) 1992 Midway */
67356736   DRIVER( mkr4 )      /* (c) 1992 Midway */
6737   DRIVER( mkturbo )   /* bootleg */
67366738   DRIVER( mkprot8 )   /* (c) 1992 Midway */
67376739   DRIVER( mkprot9 )   /* (c) 1992 Midway */
67386740   DRIVER( mkla1 )      /* (c) 1992 Midway */
r5534r5535
68496851   DRIVER( tm7ka )      /* (c) 1999 Midway Games */
68506852   DRIVER( tm7keval )   /* (c) 1999 Midway Games */
68516853   DRIVER( tm8k )      /* (c) 2000 Midway Games */
6852   DRIVER( galgbios )   /* (c) 1998 Creative Electonics & Software (CES) */
6854   DRIVER( galgbios )   /* (c) 1998 Creative Electronics & Software (CES) */
6855   DRIVER( galgame2 )   /* (c) 1998 Creative Electronics & Software (CES) / Namco */
68536856
68546857   /* Cinematronics raster games */
68556858   DRIVER( embargo )
r5534r5535
69186921   /* TIA-MC1 hardware games */
69196922   DRIVER( konek )      /* (c) 1988 Terminal */
69206923   DRIVER( sosterm )   /* (c) 1988 Terminal */
6924   DRIVER( bilyard )   /* (c) 1988 Terminal */
69216925
69226926   /* Photon hardware games */
69236927   DRIVER( phtetris )
r5534r5535
87378741   DRIVER( spitboss )   /* (c) 1988 Merit */
87388742   DRIVER( pitbosss )   /* (c) 1990 Merit */
87398743   DRIVER( pitbossm )   /* (c) 1994 Merit */
8744   DRIVER( pitbossma )   /* (c) 1994 Merit */
87408745   DRIVER( pbst30 )   /* (c) 1994 Merit */
87418746   DRIVER( pbst30b )   /* (c) 1993 Merit */
87428747   DRIVER( megat3 )   /* (c) 1996 Merit */
r5534r5535
94949499
94959500   /* Hi-Lo Poker-based */
94969501   DRIVER( gtipoker )   /* (c) 1983 GTI Inc */
9497   DRIVER( norautp )   /* (c) 1988? Noraut */
9498   DRIVER( norautjp )   /* (c) 1988? Noraut */
9502   DRIVER( norautp )   /* (c) 1988? Noraut Ltd */
9503   DRIVER( norautjp )   /* (c) 1988? Noraut Ltd */
9504   DRIVER( norautrh )   /* (c) 1988? Noraut Ltd */
9505   DRIVER( norautu )   /* (c) 1988? Noraut Ltd */
9506   DRIVER( norautv3 )   /* (c) 1988? Noraut Ltd */
94999507   DRIVER( norautpn )   /* (c) 1990? unknown */
95009508
95019509   /* Sanki Denshi Kogyo */
src/mame/includes/bzone.h
r5534r5535
44
55*************************************************************************/
66
7#define BZONE_DISCRETE      (1)
78
9#define BZONE_MASTER_CLOCK (XTAL_12_096MHz)
10#define BZONE_CLOCK_3KHZ  (MASTER_CLOCK / 4096)
11
812/*----------- defined in drivers/bzone.c -----------*/
913
1014extern UINT8 rb_input_select;
r5534r5535
1216
1317/*----------- defined in audio/bzone.c -----------*/
1418
19#if BZONE_DISCRETE
20
21WRITE8_DEVICE_HANDLER( bzone_sounds_w );
22
23MACHINE_DRIVER_EXTERN( bzone_audio );
24#else
1525WRITE8_HANDLER( bzone_sounds_w );
1626
1727DEVICE_GET_INFO( bzone_sound );
1828#define SOUND_BZONE DEVICE_GET_INFO_NAME(bzone_sound)
29#endif
1930
20
2131/*----------- defined in audio/redbaron.c -----------*/
2232
2333WRITE8_HANDLER( redbaron_sounds_w );
src/mame/includes/midtunit.h
r5534r5535
1515READ16_HANDLER( midtunit_input_r );
1616
1717DRIVER_INIT( mktunit );
18DRIVER_INIT( mkturbo );
1819DRIVER_INIT( jdreddp );
1920DRIVER_INIT( nbajam );
2021DRIVER_INIT( nbajamte );
src/mame/includes/kaneko16.h
r5534r5535
6363/* Sprites: */
6464
6565extern int kaneko16_sprite_type;
66extern int kaneko16_sprite_fliptype;
6667extern UINT16 kaneko16_sprite_xoffs, kaneko16_sprite_flipx;
6768extern UINT16 kaneko16_sprite_yoffs, kaneko16_sprite_flipy;
6869extern UINT16 *kaneko16_sprites_regs;
src/mame/includes/phoenix.h
r5534r5535
1#include "devcb.h"
12#include "sound/discrete.h"
23
34
r5534r5535
7374READ8_HANDLER( survival_input_port_0_r );
7475READ8_DEVICE_HANDLER( survival_protection_r );
7576
76int survival_sid_callback( const device_config *device );
77READ_LINE_DEVICE_HANDLER( survival_sid_callback );
7778
src/mame/includes/taito_f2.h
r5534r5535
3636VIDEO_UPDATE( taitof2 );
3737VIDEO_UPDATE( taitof2_pri );
3838VIDEO_UPDATE( taitof2_pri_roz );
39VIDEO_UPDATE( ssi );
40VIDEO_UPDATE( thundfox );
41VIDEO_UPDATE( deadconx );
42VIDEO_UPDATE( metalb );
43VIDEO_UPDATE( yesnoj );
39VIDEO_UPDATE( taitof2_driftout );
40VIDEO_UPDATE( taitof2_ssi );
41VIDEO_UPDATE( taitof2_thundfox );
42VIDEO_UPDATE( taitof2_deadconx );
43VIDEO_UPDATE( taitof2_metalb );
44VIDEO_UPDATE( taitof2_yesnoj );
4445
4546WRITE16_HANDLER( taitof2_spritebank_w );
4647READ16_HANDLER ( koshien_spritebank_r );
4748WRITE16_HANDLER( koshien_spritebank_w );
4849WRITE16_HANDLER( taitof2_sprite_extension_w );
50WRITE16_HANDLER( taitof2_palette_w );
src/mame/includes/snes.h
r5534r5535
371371HAS_ST018,
372372HAS_SPC7110,
373373HAS_SPC7110_RTC,
374HAS_CX4,
374375HAS_UNK
375376};
376377
src/mame/mame.mak
r5534r5535
114114CPUS += AVR8
115115CPUS += TMS0980
116116CPUS += I4004
117CPUS += SUPERFX
117118
118119
119120#-------------------------------------------------
r5534r5535
17491750
17501751$(DRIVERS)/neogeo.o:   $(LAYOUT)/neogeo.lh
17511752
1753$(DRIVERS)/norautp.o:   $(LAYOUT)/noraut11.lh \
1754                  $(LAYOUT)/noraut12.lh
1755
17521756$(DRIVERS)/overdriv.o:   $(LAYOUT)/overdriv.lh
17531757
17541758$(DRIVERS)/peplus.o:   $(LAYOUT)/peplus.lh \
r5534r5535
18411845$(DRIVERS)/galaxian.o:   $(MAMESRC)/drivers/galdrvr.c
18421846$(DRIVERS)/mpu4.o:      $(MAMESRC)/drivers/mpu4drvr.c
18431847$(DRIVERS)/neogeo.o:   $(MAMESRC)/drivers/neodrvr.c
1848$(MACHINE)/snes.o:       $(MAMESRC)/machine/snesdsp1.c \
1849                  $(MAMESRC)/machine/snesdsp2.c \
1850                  $(MAMESRC)/machine/snesobc1.c
src/mame/video/kaneko16.c
r5534r5535
4949UINT16* galsnew_fg_pixram;
5050
5151int kaneko16_sprite_type;
52int kaneko16_sprite_fliptype;
5253static int kaneko16_keep_sprites = 0; // default disabled for games not using it
5354UINT16 kaneko16_sprite_xoffs, kaneko16_sprite_flipx;
5455UINT16 kaneko16_sprite_yoffs, kaneko16_sprite_flipy;
r5534r5535
579580      else
580581         code = s->code;      // .. or latch this value
581582
583
582584      if (flags & USE_LATCHED_COLOR)
583585      {
584586         s->color      =   color;
585587         s->priority      =   priority;
586588         s->xoffs      =   xoffs;
587589         s->yoffs      =   yoffs;
588         s->flipx      =   flipx;
589         s->flipy      =   flipy;
590
591         if (kaneko16_sprite_fliptype==0)
592         {
593            s->flipx      =   flipx;
594            s->flipy      =   flipy;
595         }
590596      }
591597      else
592598      {
r5534r5535
594600         priority   =   s->priority;
595601         xoffs      =   s->xoffs;
596602         yoffs      =   s->yoffs;
603
604         if (kaneko16_sprite_fliptype==0)
605         {
606            flipx = s->flipx;
607            flipy = s->flipy;
608         }
609      }
610
611      // brap boys explicitly doesn't want the flip to be latched, maybe there is a different bit to enable that behavior?
612      if (kaneko16_sprite_fliptype==1)
613      {
597614         flipx      =   s->flipx;
598615         flipy      =   s->flipy;
599616      }
src/mame/video/leland.c
r5534r5535
5555   int scanline = param;
5656
5757   /* update the DACs */
58
5958   if (!(leland_dac_control & 0x01))
6059      leland_dac_update(0, leland_video_ram[(last_scanline) * 256 + 160]);
6160
r5534r5535
6665
6766   scanline = (scanline+1) % 256;
6867
69   if (scanline == 0)
70   {
71      /* turn off the DACs at the start of the frame */
72      leland_dac_control = 3;
73   }
74
7568   /* come back at the next appropriate scanline */
7669   timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline);
7770}
src/mame/video/jagobj.c
r5534r5535
8080{
8181   if (firstpix & 7)
8282   {
83      UINT32 pixsrc = src[firstpix >> 3];
83      UINT32 pixsrc = src[firstpix / 8];
8484      while (firstpix & 7)
8585      {
86         int pix = (pixsrc >> ((~firstpix & 7) << 2)) & 0x0f;
86         int pix = (pixsrc >> (4 * (~firstpix & 7))) & 0x0f;
8787         if ((!(flags & 4) || pix) && (UINT32)xpos < 760)
8888         {
8989            if (!(flags & 2))
r5534r5535
9696      }
9797   }
9898
99   firstpix >>= 3;
100   iwidth >>= 3;
99   firstpix /= 8;
100   iwidth /= 8;
101101   iwidth -= firstpix;
102102
103103   while (iwidth-- > 0)
r5534r5535
178178         xpos += dxpos;
179179      }
180180      else
181         xpos += dxpos << 3;
181         xpos += 8 * dxpos;
182182   }
183183}
184184
r5534r5535
246246{
247247   if (firstpix & 3)
248248   {
249      UINT32 pixsrc = src[firstpix >> 2];
249      UINT32 pixsrc = src[firstpix / 4];
250250      while (firstpix & 3)
251251      {
252         UINT8 pix = pixsrc >> ((~firstpix & 3) << 3);
252         UINT8 pix = pixsrc >> (8 * (~firstpix & 3));
253253         if ((!(flags & 4) || pix) && (UINT32)xpos < 760)
254254         {
255255            if (!(flags & 2))
r5534r5535
262262      }
263263   }
264264
265   firstpix >>= 2;
266   iwidth >>= 2;
265   firstpix /= 4;
266   iwidth /= 4;
267267   iwidth -= firstpix;
268268
269269   while (iwidth-- > 0)
r5534r5535
308308         xpos += dxpos;
309309      }
310310      else
311         xpos += dxpos << 2;
311         xpos += 4 * dxpos;
312312   }
313313}
314314
r5534r5535
376376{
377377   if (firstpix & 1)
378378   {
379      UINT16 pix = src[firstpix >> 1];
379      UINT16 pix = src[firstpix / 2];
380380      if ((!(flags & 4) || pix) && (UINT32)xpos < 760)
381381      {
382382         if (!(flags & 2))
r5534r5535
387387      xpos += dxpos;
388388   }
389389
390   firstpix >>= 1;
391   iwidth >>= 1;
390   firstpix /= 2;
391   iwidth /= 2;
392392   iwidth -= firstpix;
393393
394394   while (iwidth-- > 0)
r5534r5535
415415         xpos += dxpos;
416416      }
417417      else
418         xpos += dxpos << 1;
418         xpos += 2 * dxpos;
419419   }
420420}
421421
r5534r5535
473473
474474
475475
476
477
478/*************************************
479 *
480 *  32bpp bitmap renderers - needs to be verified
481 *
482 *************************************/
483
484INLINE void bitmap_32_draw(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos, UINT8 flags, INT32 dxpos)
485{
486   iwidth -= firstpix;
487
488   while (iwidth-- > 0)
489   {
490      UINT32 pix = src[firstpix++];
491
492      if (xpos < 760)
493      {
494         scanline[xpos++] = (pix&0xffff0000)>>16;
495         scanline[xpos++] = pix&0xffff;
496      }
497   }
498}
499
500static void bitmap_32_0(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
501{
502   bitmap_32_draw(firstpix, iwidth, src, xpos, 0, 1);
503}
504
505static void bitmap_32_1(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
506{
507   bitmap_32_draw(firstpix, iwidth, src, xpos, 1, -1);
508}
509
510static void bitmap_32_2(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
511{
512   bitmap_32_draw(firstpix, iwidth, src, xpos, 2, 1);
513}
514
515static void bitmap_32_3(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
516{
517   bitmap_32_draw(firstpix, iwidth, src, xpos, 3, -1);
518}
519
520static void bitmap_32_4(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
521{
522   bitmap_32_draw(firstpix, iwidth, src, xpos, 4, 1);
523}
524
525static void bitmap_32_5(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
526{
527   bitmap_32_draw(firstpix, iwidth, src, xpos, 5, -1);
528}
529
530static void bitmap_32_6(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
531{
532   bitmap_32_draw(firstpix, iwidth, src, xpos, 6, 1);
533}
534
535static void bitmap_32_7(INT32 firstpix, INT32 iwidth, UINT32 *src, INT32 xpos)
536{
537   bitmap_32_draw(firstpix, iwidth, src, xpos, 7, -1);
538}
539
540static void (*const bitmap32[8])(INT32, INT32, UINT32 *, INT32) =
541{
542   bitmap_32_0,
543   bitmap_32_1,
544   bitmap_32_2,
545   bitmap_32_3,
546   bitmap_32_4,
547   bitmap_32_5,
548   bitmap_32_6,
549   bitmap_32_7
550};
551
552
553
554476INLINE UINT8 lookup_pixel(const UINT32 *src, int i, int pitch, int depth)
555477{
556   int ppl      = 32 / depth;
557   UINT32 data   = src[((i & ppl) / ppl) + ((i / (ppl<<1)) * (pitch<<1))];
558   UINT8 pix   = (data >> ((~i & (ppl-1)) * depth)) & ((1 << depth) - 1);
478   int ppl         = 32 / depth;
479   UINT32 data   = src[((i & ppl) / ppl) + ((i / (ppl*2)) * 2 * pitch)];
480   UINT8 pix      = (data >> ((~i & (ppl-1)) * depth)) & ((1 << depth) - 1);
559481   return pix;
560482}
561483
r5534r5535
612534      UINT32 dwidth = (lower2 >> 18) & 0x3ff;
613535      UINT32 iwidth = ((lower2 >> 28) | ((upper2 & 0x3f) << 4)) << (6 - depthlog);
614536      UINT8 _index = (upper2 >> 5) & 0xfe;
615      UINT8 flags = (upper2 >> 13) & 0x07;
616      UINT8 firstpix = ((upper2 >> 17) & 0x3f) >> depthlog;
537      UINT8 flags = (upper2 >> 13) & 0x0f;
538      UINT8 firstpix = ((upper2 >> 17) & 0x1f) >> depthlog;
617539      int i, dxpos = (flags & 1) ? -1 : 1;
618540
619541      /* preadjust for firstpix */
r5534r5535
625547         /* 1bpp case */
626548         case 0:
627549         {
628            UINT16 *clut = (UINT16 *)jaguar_gpu_clut + _index;
550            UINT16 *clut = (UINT16 *)jaguar_gpu_clut;
551            clut += _index & 0xfe;
629552
630553            /* non-blending */
631554            if (!(flags & 2))
r5534r5535
658581         /* 2bpp case */
659582         case 1:
660583         {
661            UINT16 *clut = (UINT16 *)jaguar_gpu_clut + (_index & 0xfc);
584            UINT16 *clut = (UINT16 *)jaguar_gpu_clut;
585            clut += _index & 0xfc;
662586
663587            /* non-blending */
664588            if (!(flags & 2))
r5534r5535
694618            if (pitch != 1)
695619               logerror("Unhandled pitch = %d\n", pitch);
696620
697            clutbase = (UINT16 *)jaguar_gpu_clut + (_index & 0xf8);
698            (*bitmap4[flags])(firstpix, iwidth, src, xpos);
621            clutbase = (UINT16 *)jaguar_gpu_clut + (_index & 0xf0);
622            (*bitmap4[flags & 7])(firstpix, iwidth, src, xpos);
699623            break;
700624
701625         /* 8bpp case */
r5534r5535
705629               logerror("Unhandled pitch = %d\n", pitch);
706630
707631            clutbase = (UINT16 *)jaguar_gpu_clut;
708            (*bitmap8[flags])(firstpix, iwidth, src, xpos);
632            (*bitmap8[flags & 7])(firstpix, iwidth, src, xpos);
709633            break;
710634
711635         /* 16bpp case */
r5534r5535
714638            if (pitch != 1)
715639               logerror("Unhandled pitch = %d\n", pitch);
716640
717            (*bitmap16[flags])(firstpix, iwidth, src, xpos);
641            (*bitmap16[flags & 7])(firstpix, iwidth, src, xpos);
718642            break;
719643
720         /* 32bpp case */
721         case 5:
722            /* only handle pitch=1 for now */
723            if (pitch != 1)
724               logerror("Unhandled pitch = %d\n", pitch);
725
726            (*bitmap32[flags])(firstpix, iwidth, src, xpos);
727            break;
728
729644         default:
730645            fprintf(stderr, "Unhandled bitmap source depth = %d\n", depthlog);
731646            break;
r5534r5535
800715      UINT32 dwidth = (lower2 >> 18) & 0x3ff;
801716      INT32 iwidth = ((lower2 >> 28) | ((upper2 & 0x3f) << 4)) << (6 - depthlog);
802717      UINT8 _index = (upper2 >> 5) & 0xfe;
803      UINT8 flags = (upper2 >> 13) & 0x07;
804      UINT8 firstpix = ((upper2 >> 17) & 0x3f) >> depthlog;
718      UINT8 flags = (upper2 >> 13) & 0x0f;
719      UINT8 firstpix = ((upper2 >> 17) & 0x1f) >> depthlog;
805720
806721      INT32 hscale = lower3 & 0xff;
807722      INT32 vscale = (lower3 >> 8) & 0xff;
r5534r5535
809724      int dxpos = (flags & 1) ? -1 : 1;
810725      int xpix = firstpix, yinc;
811726
812      /* only handle pitch=1 (sequential data) for now */
727      /* only handle pitch=0 for now */
813728      if (pitch != 1)
814729         logerror("Unhandled pitch = %d\n", pitch);
815730      if (flags & 2)
r5534r5535
827742         /* switch off the depth */
828743         switch (depthlog)
829744         {
830            case 0:
831            {
832               UINT16 *clut = (UINT16 *)jaguar_gpu_clut + _index;
833
834               /* render in phrases */
835               while (xpix < iwidth)
836               {
837                  UINT16 pix = (src[xpix >> 5] >> (~xpix & 31)) & 0x01;
838
839                  while (xleft > 0)
840                  {
841                     if (xpos >= 0 && xpos < 760 && (pix || !(flags & 4)))
842                        scanline[xpos] = clut[BYTE_XOR_BE(pix)];
843                     xpos += dxpos;
844                     xleft -= 0x20;
845                  }
846                  while (xleft <= 0)
847                     xleft += hscale, xpix++;
848               }
849               break;
850            }
851
852            case 1:
853            {
854               UINT16 *clut = (UINT16 *)jaguar_gpu_clut + (_index & 0xfc);
855
856               /* render in phrases */
857               while (xpix < iwidth)
858               {
859                  UINT16 pix = (src[xpix >> 4] >> ((~xpix & 15) << 1)) & 0x03;
860
861                  while (xleft > 0)
862                  {
863                     if (xpos >= 0 && xpos < 760 && (pix || !(flags & 4)))
864                        scanline[xpos] = clut[BYTE_XOR_BE(pix)];
865                     xpos += dxpos;
866                     xleft -= 0x20;
867                  }
868                  while (xleft <= 0)
869                     xleft += hscale, xpix++;
870               }
871               break;
872            }
873
874745            case 2:
875746            {
876               UINT16 *clut = (UINT16 *)jaguar_gpu_clut + (_index & 0xf8);
747               UINT16 *clut = (UINT16 *)jaguar_gpu_clut;
748               clut += _index & 0xf0;
877749
878750               /* render in phrases */
879751               while (xpix < iwidth)
880752               {
881                  UINT16 pix = (src[xpix >> 3] >> ((~xpix & 7) << 2)) & 0x0f;
753                  UINT16 pix = (src[xpix / 8] >> ((~xpix & 7) * 4)) & 0x0f;
882754
883755                  while (xleft > 0)
884756                  {
r5534r5535
900772               /* render in phrases */
901773               while (xpix < iwidth)
902774               {
903                  UINT16 pix = (src[xpix >> 2] >> ((~xpix & 3) << 3)) & 0xff;
775                  UINT16 pix = (src[xpix / 4] >> ((~xpix & 3) * 8)) & 0xff;
904776
905777                  while (xleft > 0)
906778                  {
r5534r5535
918790            case 4:
919791               while (xpix < iwidth)
920792               {
921                  UINT16 pix = src[xpix >> 1] >> ((~xpix & 1) << 4);
793                  UINT16 pix = src[xpix / 2] >> ((~xpix & 1) * 16);
922794
923795                  while (xleft > 0)
924796                  {
r5534r5535
1065937
1066938         /* GPU interrupt */
1067939         case 2:
1068            gpu_regs[OB_HH]=(objdata[1]&0xffff0000)>>16;
1069            gpu_regs[OB_HL]=objdata[1]&0xffff;
1070            gpu_regs[OB_LH]=(objdata[0]&0xffff0000)>>16;
1071            gpu_regs[OB_LL]=objdata[0]&0xffff;
940            gpu_regs[OB_HH]=objdata[1];
941            gpu_regs[OB_HL]=objdata[2];
942            gpu_regs[OB_LH]=objdata[3];
943            gpu_regs[OB_LL]=objdata[4];
1072944            cpu_irq_state |= 2;
1073945            update_cpu_irq(machine);
1074946            done=1;
src/mame/video/snes.c
r5534r5535
167167            b = ((*colour & 0x7c00) >> 10) + ((scanlines[SUBSCREEN].buffer[offset] & 0x7c00) >> 10);
168168
169169            /* don't halve for the back colour */
170            if( (snes_ram[CGADSUB] & 0x40) && (scanlines[SUBSCREEN].zbuf[offset] || scanlines[SUBSCREEN].buffer[offset]) )
170            if( (snes_ram[CGADSUB] & 0x40) && (scanlines[SUBSCREEN].zbuf[offset] || scanlines[SUBSCREEN].buffer[offset] != snes_cgram[FIXED_COLOUR]) )
171171            {
172172               r >>= 1;
173173               g >>= 1;
r5534r5535
181181            b = ((*colour & 0x7c00) >> 10) + ((snes_cgram[FIXED_COLOUR] & 0x7c00) >> 10);
182182
183183            /* don't halve for the back colour */
184            if( (snes_ram[CGADSUB] & 0x40) && (scanlines[SUBSCREEN].zbuf[offset] || scanlines[SUBSCREEN].buffer[offset]) )
184            if( (snes_ram[CGADSUB] & 0x40) && (scanlines[SUBSCREEN].zbuf[offset] || scanlines[SUBSCREEN].buffer[offset] != snes_cgram[FIXED_COLOUR]) )
185185            {
186186               r >>= 1;
187187               g >>= 1;
r5534r5535
205205            if( b > 0x1f ) b = 0;
206206
207207            /* don't halve for the back colour */
208            if( (snes_ram[CGADSUB] & 0x40) && (scanlines[SUBSCREEN].zbuf[offset] || scanlines[SUBSCREEN].buffer[offset]) )
208            if( (snes_ram[CGADSUB] & 0x40) && (scanlines[SUBSCREEN].zbuf[offset] || scanlines[SUBSCREEN].buffer[offset] != snes_cgram[FIXED_COLOUR]) )
209209            {
210210               r >>= 1;
211211               g >>= 1;
r5534r5535
222222            if( b > 0x1f ) b = 0;
223223
224224            /* don't halve for the back colour */
225            if( (snes_ram[CGADSUB] & 0x40) && (scanlines[SUBSCREEN].zbuf[offset] || scanlines[SUBSCREEN].buffer[offset]) )
225            if( (snes_ram[CGADSUB] & 0x40) && (scanlines[SUBSCREEN].zbuf[offset] || scanlines[SUBSCREEN].buffer[offset] != snes_cgram[FIXED_COLOUR]) )
226226            {
227227               r >>= 1;
228228               g >>= 1;
src/mame/video/jaguar.c
r5534r5535
424424   {
425425      /* YCC full */
426426      case 0x000:
427      /* RGB24 */
428      case 0x002:
429427         for (i = 0; i < 65536; i++)
430428         {
431429            UINT8 r = (red_lookup[i >> 8] * (i & 0xff)) >> 8;
r5534r5535
467465      /* others */
468466      default:
469467         logerror("Can't handle mode %X\n", vmode);
470         fprintf(stderr, "Can't handle mode %X\n", vmode);
471468         break;
472469   }
473470}
r5534r5535
598595   switch (offset)
599596   {
600597      case B_CMD:   /* B_CMD */
601         return 1;
598         return 0x00000001;
602599
603600      default:
604601         logerror("%08X:Blitter read register @ F022%02X\n", cpu_get_previouspc(space->cpu), offset * 4);
r5534r5535
646643   return gpu_regs[offset];
647644}
648645
649static TIMER_CALLBACK( jaguar_pit )
650{
651   attotime sample_period;
652   cpu_irq_state |= 8;
653   update_cpu_irq(machine);
654646
655   if (gpu_regs[PIT0])
656   {
657      sample_period = ATTOTIME_IN_NSEC(cpu_get_clock(cputag_get_cpu(machine,"gpu")) / (1+gpu_regs[PIT0]) / (1+gpu_regs[PIT1]));
658//      timer_set(machine, sample_period, NULL, 0, jaguar_pit);
659   }
660}
661   
662647WRITE16_HANDLER( jaguar_tom_regs_w )
663648{
664649   UINT32 reg_store = gpu_regs[offset];
665   attotime sample_period;
650
666651   if (offset < GPU_REGS)
667652   {
668653      COMBINE_DATA(&gpu_regs[offset]);
669654
670655      switch (offset)
671656      {
672         case PIT1:
673            if (gpu_regs[PIT0])
674            {
675               sample_period = ATTOTIME_IN_NSEC(cpu_get_clock(cputag_get_cpu(space->machine,"gpu")) / (1+gpu_regs[PIT0]) / (1+gpu_regs[PIT1]));
676               timer_set(space->machine, sample_period, NULL, 0, jaguar_pit);
677            }
678            break;
679657         case INT1:
680658            cpu_irq_state &= ~(gpu_regs[INT1] >> 8);
681659            update_cpu_irq(space->machine);
r5534r5535
709687               int hbend = effective_hvalue(ENABLE_BORDERS ? gpu_regs[HBE] : MIN(gpu_regs[HDB1], gpu_regs[HDB2]));
710688               int hbstart = effective_hvalue(gpu_regs[ENABLE_BORDERS ? HBB : HDE]);
711689               int vperiod = (gpu_regs[VP] & 0x7ff) + 1;
712               int vbend = MAX(gpu_regs[VBE],gpu_regs[VDB]) & 0x7ff;
690               int vbend = gpu_regs[VBE] & 0x7ff;
713691               int vbstart = gpu_regs[VBB] & 0x7ff;
714692
715693               /* adjust for the half-lines */
r5534r5535
796774   /* only run if video is enabled and we are past the "display begin" */
797775   if ((gpu_regs[VMODE] & 1) && vc >= (gpu_regs[VDB] & 0x7ff))
798776   {
799      UINT32 *dest = BITMAP_ADDR32(screen_bitmap, vc >> 1, 0);
777      UINT32 *dest = BITMAP_ADDR32(screen_bitmap, vc / 2, 0);
800778      int maxx = visarea->max_x;
801      int hde = effective_hvalue(gpu_regs[HDE]) >> 1;
779      int hde = effective_hvalue(gpu_regs[HDE]) / 2;
802780      UINT16 x,scanline[760];
803781      UINT8 y,pixel_width = ((gpu_regs[VMODE]>>10)&3)+1;
804782
r5534r5535
814792      process_object_list(machine, vc, scanline);
815793
816794      /* copy the data to the target, clipping */
817      if ((gpu_regs[VMODE] & 0x106) == 0x002)   /* RGB24 */
818      {
819         for (x = 0; x < 760 && hdb <= maxx && hdb < hde; x+=2)
820            for (y = 0; y < pixel_width; y++)
821            {
822               UINT8 r = pen_table[(scanline[x]&0xff)|256];
823               UINT8 g = pen_table[(scanline[x]>>8)|512];
824               UINT8 b = pen_table[scanline[x+1]&0xff];               
825               dest[hdb++] = MAKE_RGB(r, g, b);
826            }
827      }
828      else
829      {
830         for (x = 0; x < 760 && hdb <= maxx && hdb < hde; x++)
831            for (y = 0; y < pixel_width; y++)
832               dest[hdb++] = pen_table[scanline[x]];
833      }
795      for (x = 0; x < 760 && hdb <= maxx && hdb < hde; x++)
796         for (y = 0; y < pixel_width; y++)
797            dest[hdb++] = pen_table[scanline[x]];
834798   }
835799
836800   /* adjust the timer in a loop, to handle missed cases */
src/mame/video/phoenix.c
r5534r5535
435435   return survival_protection_value;
436436}
437437
438int survival_sid_callback( const device_config *device )
438READ_LINE_DEVICE_HANDLER( survival_sid_callback )
439439{
440440   return survival_sid_value;
441441}
src/mame/video/taito_f2.c
r5534r5535
7373static UINT8 f2_spritepri[6]; // todo - move into taitoic.c
7474static UINT8 f2_spriteblendmode; // todo - move into taitoic.c
7575
76static UINT16 *paletteram_buffer;
77
7678enum
7779{
7880   FOOTCHMP = 1
r5534r5535
295297   f2_pivot_xdisp = -16;
296298   f2_pivot_ydisp = 16;
297299   taitof2_core_vh_start(machine, 0,3,3,0,0,0,0,0,0);
300
301   paletteram_buffer = auto_alloc_array(machine, UINT16, 4096);
302   memset(paletteram_buffer, 0, 4096*sizeof(UINT16));
303   state_save_register_global_pointer(machine, paletteram_buffer, 4096);
298304}
299305
306WRITE16_HANDLER( taitof2_palette_w )
307{
308   COMBINE_DATA(&paletteram_buffer[offset]);
309}
300310
311
301312/********************************************************
302313          SPRITE READ AND WRITE HANDLERS
303314
r5534r5535
964975   }
965976}
966977
978
967979VIDEO_EOF( taitof2_no_buffer )
968980{
969981   taitof2_update_sprites_active_area();
r5534r5535
10391051
10401052
10411053/* SSI */
1042VIDEO_UPDATE( ssi )
1054VIDEO_UPDATE( taitof2_ssi )
10431055{
10441056   taitof2_handle_sprite_buffering();
10451057
r5534r5535
10521064}
10531065
10541066
1055VIDEO_UPDATE( yesnoj )
1067VIDEO_UPDATE( taitof2_yesnoj )
10561068{
10571069   taitof2_handle_sprite_buffering();
10581070
r5534r5535
11931205   return 0;
11941206}
11951207
1208VIDEO_UPDATE( taitof2_driftout )
1209{
1210   UINT16 pen;
11961211
1212   /* send palette, workaround for bug http://www.mametesters.org/view.php?id=3356 (just for this game)
1213     driftout writes twice per frame to the palette, this causes glitches on some setups due to
1214     VIDEO_UPDATE not being synced to renderer update when multithreading is on. */
1215   for (pen=0;pen<4096;pen++)
1216      palette_set_color_rgb(screen->machine, pen, pal5bit(paletteram_buffer[pen] >> 10), pal5bit(paletteram_buffer[pen] >> 5), pal5bit(paletteram_buffer[pen] >> 0));
11971217
1218   return VIDEO_UPDATE_CALL( taitof2_pri_roz );
1219}
1220
1221
1222
11981223/* Thunderfox */
1199VIDEO_UPDATE( thundfox )
1224VIDEO_UPDATE( taitof2_thundfox )
12001225{
12011226   int tilepri[2][3];
12021227   int spritepri[4];
r5534r5535
13261351
13271352********************************************************************/
13281353
1329VIDEO_UPDATE( metalb )
1354VIDEO_UPDATE( taitof2_metalb )
13301355{
13311356   UINT8 layer[5], invlayer[4];
13321357   UINT16 priority;
r5534r5535
13761401
13771402
13781403/* Deadconx, Footchmp */
1379VIDEO_UPDATE( deadconx )
1404VIDEO_UPDATE( taitof2_deadconx )
13801405{
13811406   UINT8 layer[5];
13821407   UINT8 tilepri[5];
src/mame/video/thepit.c
r5534r5535
9999
100100   for (i = 0; i < 32; i++)
101101   {
102      UINT8 r = ((color_prom[i + 0x20] >> 6) | (color_prom[i + 0x00] << 2)) & 0x1f;
103      UINT8 g = BITSWAP8(color_prom[i + 0x20], 7, 6, 0, 1, 2, 3, 4, 5) & 0x1f;
104      UINT8 b = BITSWAP8(color_prom[i + 0x00], 0, 1, 2, 3, 4, 5, 6, 7) & 0x1f;
102      UINT8 b = BITSWAP8(color_prom[i + 0x00], 0, 1, 2, 3, 4, 5, 6, 7);
103      UINT8 g = BITSWAP8(color_prom[i + 0x20], 0, 1, 2, 3, 4, 5, 6, 7);
104      UINT8 r = (b>>5&7)<<2 | (g>>6&3);
105105
106      palette_set_color_rgb(machine, i, pal5bit(r), pal5bit(g), pal5bit(b));
106      palette_set_color_rgb(machine, i, pal5bit(r), pal5bit(g), pal4bit(b));
107107   }
108108
109109   /* allocate primary colors for the background and foreground
src/mame/layout/noraut11.lay
r0r5535
1<?xml version="1.0"?>
2<mamelayout version="2">
3   <element name="L0" defstate="1">
4      <rect state="1">
5         <color red="1.0" green="0.5" blue="0.0" />
6      </rect>
7      <rect state="0">
8         <color red="0.35" green="0.2" blue="0.0" />
9      </rect>
10      <text string="CHANGE">
11         <color red="0.0" green="0.0" blue="0.0" />
12         <bounds x="0" y="0.1" width="1" height="0.4" />
13      </text>
14      <text string="CARD">
15         <color red="0.0" green="0.0" blue="0.0" />
16         <bounds x="0" y="0.5" width="1" height="0.4" />
17      </text>
18   </element>
19
20   <element name="L1" defstate="1">
21      <rect state="1">
22         <color red="1.0" green="0.5" blue="0.0" />
23      </rect>
24      <rect state="0">
25         <color red="0.35" green="0.2" blue="0.0" />
26      </rect>
27      <text string="HALF">
28         <color red="0.0" green="0.0" blue="0.0" />
29         <bounds x="0" y="0.1" width="1" height="0.4" />
30      </text>
31      <text string="GAMBLE">
32         <color red="0.0" green="0.0" blue="0.0" />
33         <bounds x="0" y="0.5" width="1" height="0.4" />
34      </text>
35   </element>
36
37   <element name="L2" defstate="1">
38      <rect state="1">
39         <color red="1.0" green="0.0" blue="0.0" />
40      </rect>
41      <rect state="0">
42         <color red="0.4" green="0.0" blue="0.0" />
43      </rect>
44      <text string="HOLD 1">
45         <color red="0.0" green="0.0" blue="0.0" />
46         <bounds x="0" y="0.3" width="1" height="0.2" />
47      </text>
48      <text string="CANCEL">
49         <color red="0.0" green="0.0" blue="0.0" />
50         <bounds x="0" y="0.5" width="1" height="0.2" />
51      </text>
52   </element>
53
54   <element name="L3" defstate="1">
55      <rect state="1">
56         <color red="1.0" green="0.0" blue="0.0" />
57      </rect>
58      <rect state="0">
59         <color red="0.4" green="0.0" blue="0.0" />
60      </rect>
61      <text string="HOLD 2">
62         <color red="0.0" green="0.0" blue="0.0" />
63         <bounds x="0" y="0.3" width="1" height="0.2" />
64      </text>
65      <text string="CANCEL">
66         <color red="0.0" green="0.0" blue="0.0" />
67         <bounds x="0" y="0.5" width="1" height="0.2" />
68      </text>
69   </element>
70
71   <element name="L4" defstate="1">
72      <rect state="1">
73         <color red="1.0" green="0.0" blue="0.0" />
74      </rect>
75      <rect state="0">
76         <color red="0.4" green="0.0" blue="0.0" />
77      </rect>
78      <text string="HOLD 3">
79         <color red="0.0" green="0.0" blue="0.0" />
80         <bounds x="0" y="0.3" width="1" height="0.2" />
81      </text>
82      <text string="CANCEL">
83         <color red="0.0" green="0.0" blue="0.0" />
84         <bounds x="0" y="0.5" width="1" height="0.2" />
85      </text>
86   </element>
87
88   <element name="L5" defstate="1">
89      <rect state="1">
90         <color red="1.0" green="0.0" blue="0.0" />
91      </rect>
92      <rect state="0">
93         <color red="0.4" green="0.0" blue="0.0" />
94      </rect>
95      <text string="HOLD 4">
96         <color red="0.0" green="0.0" blue="0.0" />
97         <bounds x="0" y="0.3" width="1" height="0.2" />
98      </text>
99      <text string="CANCEL">
100         <color red="0.0" green="0.0" blue="0.0" />
101         <bounds x="0" y="0.5" width="1" height="0.2" />
102      </text>
103   </element>
104
105   <element name="L6" defstate="1">
106      <rect state="1">
107         <color red="1.0" green="0.0" blue="0.0" />
108      </rect>
109      <rect state="0">
110         <color red="0.4" green="0.0" blue="0.0" />
111      </rect>
112      <text string="HOLD 5">
113         <color red="0.0" green="0.0" blue="0.0" />
114         <bounds x="0" y="0.3" width="1" height="0.2" />
115      </text>
116      <text string="CANCEL">
117         <color red="0.0" green="0.0" blue="0.0" />
118         <bounds x="0" y="0.5" width="1" height="0.2" />
119      </text>
120   </element>
121
122
123   <element name="L8" defstate="1">
124      <rect state="1">
125         <color red="1.0" green="1.0" blue="0.0" />
126      </rect>
127      <rect state="0">
128         <color red="0.3" green="0.3" blue="0.0" />
129      </rect>
130      <text string="DEAL">
131         <color red="0.0" green="0.0" blue="0.0" />
132         <bounds x="0" y="0.1" width="1" height="0.4" />
133      </text>
134      <text string="DRAW">
135         <color red="0.0" green="0.0" blue="0.0" />
136         <bounds x="0" y="0.5" width="1" height="0.4" />
137      </text>
138   </element>
139
140   <element name="L9" defstate="1">
141      <rect state="1">
142         <color red="1.0" green="1.0" blue="0.0" />
143      </rect>
144      <rect state="0">
145         <color red="0.3" green="0.3" blue="0.0" />
146      </rect>
147      <text string="BET">
148         <color red="0.0" green="0.0" blue="0.0" />
149         <bounds x="0" y="0.1" width="1" height="0.4" />
150      </text>
151      <text string="COLLECT">
152         <color red="0.0" green="0.0" blue="0.0" />
153         <bounds x="0" y="0.5" width="1" height="0.4" />
154      </text>
155   </element>
156
157   <element name="L10" defstate="1">
158      <rect state="1">
159         <color red="1.0" green="1.0" blue="0.0" />
160      </rect>
161      <rect state="0">
162         <color red="0.3" green="0.3" blue="0.0" />
163      </rect>
164      <text string="HI">
165         <color red="0.0" green="0.0" blue="0.0" />
166         <bounds x="0" y="0.25" width="1" height="0.5" />
167      </text>
168   </element>
169
170   <element name="L11" defstate="1">
171      <rect state="1">
172         <color red="1.0" green="1.0" blue="0.0" />
173      </rect>
174      <rect state="0">
175         <color red="0.3" green="0.3" blue="0.0" />
176      </rect>
177      <text string="LO">
178         <color red="0.0" green="0.0" blue="0.0" />
179         <bounds x="0" y="0.25" width="1" height="0.5" />
180      </text>
181   </element>
182
183
184
185   <view name="Button Lamps">
186      <screen index="0">
187         <bounds left="0" top="0" right="4" bottom="3" />
188      </screen>
189
190      <bezel name="lamp0" element="L0">
191         <bounds x="3.05" y="3.28" width="0.40" height="0.20" />
192      </bezel>
193      <bezel name="lamp1" element="L1">
194         <bounds x="3.05" y="3.03" width="0.40" height="0.20" />
195      </bezel>
196
197      <bezel name="lamp2" element="L2">
198         <bounds x="0.05" y="3.05" width="0.40" height="0.40" />
199      </bezel>
200      <bezel name="lamp3" element="L3">
201         <bounds x="0.55" y="3.05" width="0.40" height="0.40" />
202      </bezel>
203      <bezel name="lamp4" element="L4">
204         <bounds x="1.05" y="3.05" width="0.40" height="0.40" />
205      </bezel>
206      <bezel name="lamp5" element="L5">
207         <bounds x="1.55" y="3.05" width="0.40" height="0.40" />
208      </bezel>
209      <bezel name="lamp6" element="L6">
210         <bounds x="2.05" y="3.05" width="0.40" height="0.40" />
211      </bezel>
212
213
214      <bezel name="lamp8" element="L8">
215         <bounds x="2.55" y="3.28" width="0.40" height="0.20" />
216      </bezel>
217      <bezel name="lamp9" element="L9">
218         <bounds x="2.55" y="3.03" width="0.40" height="0.20" />
219      </bezel>
220
221      <bezel name="lamp10" element="L10">
222         <bounds x="3.55" y="3.03" width="0.40" height="0.20" />
223      </bezel>
224      <bezel name="lamp11" element="L11">
225         <bounds x="3.55" y="3.28" width="0.40" height="0.20" />
226      </bezel>
227
228   </view>
229</mamelayout>
src/mame/layout/noraut12.lay
r0r5535
1<?xml version="1.0"?>
2<mamelayout version="2">
3   <element name="L0" defstate="1">
4      <disk state="1">
5         <color red="1.0" green="0.5" blue="0.0" />
6      </disk>
7      <disk state="0">
8         <color red="0.35" green="0.2" blue="0.0" />
9      </disk>
10      <text string="STAND">
11         <color red="0.0" green="0.0" blue="0.0" />
12         <bounds x="0" y="0.3" width="1" height="0.4" />
13      </text>
14   </element>
15
16   <element name="L1" defstate="1">
17      <disk state="1">
18         <color red="0.0" green="1.0" blue="0.5" />
19      </disk>
20      <disk state="0">
21         <color red="0.0" green="0.3" blue="0.15" />
22      </disk>
23      <text string="SAVE">
24         <color red="0.0" green="0.0" blue="0.0" />
25         <bounds x="0" y="0.3" width="1" height="0.4" />
26      </text>
27   </element>
28
29   <element name="L2" defstate="1">
30      <disk state = "1">
31         <color red="1.0" green="1.0" blue="0.0" />
32      </disk>
33      <disk state="0">
34         <color red="0.3" green="0.3" blue="0.0" />
35      </disk>
36      <text string="HOLD1">
37         <color red="0.0" green="0.0" blue="0.0" />
38         <bounds x="0" y="0.3" width="1" height="0.4" />
39      </text>
40   </element>
41
42   <element name="L3" defstate="1">
43      <disk state = "1">
44         <color red="1.0" green="1.0" blue="0.0" />
45      </disk>
46      <disk state="0">
47         <color red="0.3" green="0.3" blue="0.0" />
48      </disk>
49      <text string="HOLD2">
50         <color red="0.0" green="0.0" blue="0.0" />
51         <bounds x="0" y="0.3" width="1" height="0.4" />
52      </text>
53   </element>
54
55   <element name="L4" defstate="1">
56      <disk state = "1">
57         <color red="1.0" green="1.0" blue="0.0" />
58      </disk>
59      <disk state="0">
60         <color red="0.3" green="0.3" blue="0.0" />
61      </disk>
62      <text string="HOLD3">
63         <color red="0.0" green="0.0" blue="0.0" />
64         <bounds x="0" y="0.3" width="1" height="0.4" />
65      </text>
66   </element>
67
68   <element name="L5" defstate="1">
69      <disk state = "1">
70         <color red="1.0" green="1.0" blue="0.0" />
71      </disk>
72      <disk state="0">
73         <color red="0.3" green="0.3" blue="0.0" />
74      </disk>
75      <text string="HOLD4">
76         <color red="0.0" green="0.0" blue="0.0" />
77         <bounds x="0" y="0.3" width="1" height="0.4" />
78      </text>
79   </element>
80
81   <element name="L6" defstate="1">
82      <disk state = "1">
83         <color red="1.0" green="1.0" blue="0.0" />
84      </disk>
85      <disk state="0">
86         <color red="0.3" green="0.3" blue="0.0" />
87      </disk>
88      <text string="HOLD5">
89         <color red="0.0" green="0.0" blue="0.0" />
90         <bounds x="0" y="0.3" width="1" height="0.4" />
91      </text>
92   </element>
93
94   <element name="L7" defstate="1">
95      <disk state="1">
96         <color red="1.0" green="1.0" blue="0.0" />
97      </disk>
98      <disk state="0">
99         <color red="0.3" green="0.3" blue="0.0" />
100      </disk>
101      <text string="CANCEL">
102         <color red="0.0" green="0.0" blue="0.0" />
103         <bounds x="0" y="0.3" width="1" height="0.4" />
104      </text>
105   </element>
106
107
108   <element name="L8" defstate="1">
109      <disk state="1">
110         <color red="1.0" green="0.5" blue="0.0" />
111      </disk>
112      <disk state="0">
113         <color red="0.35" green="0.2" blue="0.0" />
114      </disk>
115      <text string="DEAL">
116         <color red="0.0" green="0.0" blue="0.0" />
117         <bounds x="0" y="0.3" width="1" height="0.4" />
118      </text>
119   </element>
120
121   <element name="L9" defstate="1">
122      <disk state="1">
123         <color red="1.0" green="0.0" blue="0.0" />
124      </disk>
125      <disk state="0">
126         <color red="0.4" green="0.0" blue="0.0" />
127      </disk>
128      <text string="BET">
129         <color red="0.0" green="0.0" blue="0.0" />
130         <bounds x="0" y="0.3" width="1" height="0.4" />
131      </text>
132   </element>
133
134   <element name="L10" defstate="1">
135      <rect state="1">
136         <color red="1.0" green="1.0" blue="0.0" />
137      </rect>
138      <rect state="0">
139         <color red="0.3" green="0.3" blue="0.0" />
140      </rect>
141      <text string="HIGH">
142         <color red="0.0" green="0.0" blue="0.0" />
143         <bounds x="0" y="0.25" width="1" height="0.5" />
144      </text>
145   </element>
146
147   <element name="L11" defstate="1">
148      <rect state="1">
149         <color red="1.0" green="1.0" blue="0.0" />
150      </rect>
151      <rect state="0">
152         <color red="0.3" green="0.3" blue="0.0" />
153      </rect>
154      <text string="LOW">
155         <color red="0.0" green="0.0" blue="0.0" />
156         <bounds x="0" y="0.25" width="1" height="0.5" />
157      </text>
158   </element>
159
160
161
162   <view name="Button Lamps">
163      <screen index="0">
164         <bounds left="0" top="0" right="4" bottom="3" />
165      </screen>
166
167      <bezel name="lamp2" element="L2">
168         <bounds x="0.55" y="3.03" width="0.20" height="0.20" />
169      </bezel>
170      <bezel name="lamp3" element="L3">
171         <bounds x="1.05" y="3.03" width="0.20" height="0.20" />
172      </bezel>
173      <bezel name="lamp4" element="L4">
174         <bounds x="1.55" y="3.03" width="0.20" height="0.20" />
175      </bezel>
176      <bezel name="lamp5" element="L5">
177         <bounds x="2.05" y="3.03" width="0.20" height="0.20" />
178      </bezel>
179      <bezel name="lamp6" element="L6">
180         <bounds x="2.55" y="3.03" width="0.20" height="0.20" />
181      </bezel>
182
183      <bezel name="lamp7" element="L7">
184         <bounds x="0.55" y="3.28" width="0.20" height="0.20" />
185      </bezel>
186      <bezel name="lamp0" element="L0">
187         <bounds x="1.05" y="3.28" width="0.20" height="0.20" />
188      </bezel>
189      <bezel name="lamp1" element="L1">
190         <bounds x="1.55" y="3.28" width="0.20" height="0.20" />
191      </bezel>
192      <bezel name="lamp8" element="L8">
193         <bounds x="2.05" y="3.28" width="0.20" height="0.20" />
194      </bezel>
195      <bezel name="lamp9" element="L9">
196         <bounds x="2.55" y="3.28" width="0.20" height="0.20" />
197      </bezel>
198
199      <bezel name="lamp10" element="L10">
200         <bounds x="3.05" y="3.03" width="0.40" height="0.20" />
201      </bezel>
202      <bezel name="lamp11" element="L11">
203         <bounds x="3.05" y="3.28" width="0.40" height="0.20" />
204      </bezel>
205
206   </view>
207</mamelayout>
src/mame/drivers/nbmj9195.c
r5534r5535
29312931   MDRV_CPU_IO_MAP(sailorws_io_map)
29322932   MDRV_CPU_VBLANK_INT("screen", ctc0_trg1)            /* vblank is connect to ctc triggfer */
29332933
2934   MDRV_CPU_ADD("audiocpu", Z80, 8000000/1)               /* TMPZ84C011, 8.00 MHz */
2934   MDRV_CPU_ADD("audiocpu", Z80, 8000000)               /* TMPZ84C011, 8.00 MHz */
29352935   MDRV_CPU_CONFIG(daisy_chain_sound)
29362936   MDRV_CPU_PROGRAM_MAP(sailorws_sound_map)
29372937   MDRV_CPU_IO_MAP(sailorws_sound_io_map)
29382938
29392939   MDRV_Z80CTC_ADD("main_ctc", 12000000/2 /* same as "maincpu" */, ctc_intf_main)
2940   MDRV_Z80CTC_ADD("audio_ctc", 8000000/1 /* same as "audiocpu" */, ctc_intf_audio)
2940   MDRV_Z80CTC_ADD("audio_ctc", 8000000 /* same as "audiocpu" */, ctc_intf_audio)
29412941
29422942   MDRV_MACHINE_RESET(sailorws)
29432943
src/mame/drivers/norautp.c
r5534r5535
11/******************************************************************************
22
3     - NORAUT POKER -
4    ------------------
3   - NORAUT POKER -
4  ------------------
55
6    Driver by Roberto Fresca & Angelo Salese.
6  Driver by Roberto Fresca & Angelo Salese.
77
88
9    Games running on this hardware:
9  Games running on this hardware:
1010
11    * Noraut Poker,      1988,  Noraut Ltd.
12    * Noraut Joker Poker 1988,  Noraut Ltd.
13    * GTI Poker          1983,  GTI Inc.
14    * Poker,             198?,  Unknown.
11   * Noraut Poker,                 1988,  Noraut Ltd.
12   * Noraut Joker Poker,           1988,  Noraut Ltd.
13   * Noraut Red Hot Joker Poker,   1988,  Noraut Ltd.
14   * Noraut Poker (NTX10A),        1988,  Noraut Ltd.
15   * Noraut Joker Poker (V3.010a), 1988,  Noraut Ltd.
16   * GTI Poker,                    1983,  GTI Inc.
17   * Noraut Poker (bootleg),       198?,  Unknown.
1518
1619
1720*******************************************************************************
1821
1922
20    Hardware Notes:
21    ---------------
23  HARDWARE NOTES:
24  ---------------
2225
23    1x Z80
24    3x PPI 8255
25    2x 6116 SRAM
26    1x 3.6 Vcc Battery.
27    1x 18.432 MHz. Xtal.
26  Hardware Layout (norautp):
2827
29    1x 555 + unknown yellow resonator, near the edge connector.
30    1x 555 + resnet, near the battery.
28  1x Z80
29  3x PPI 8255
30  2x 6116 SRAM
31  1x 3.6 Vcc Battery.
32  1x 18.432 MHz. Xtal.
3133
32    2x 3pins jumpers (between the Z80 and ROM)
34  1x 555 + unknown yellow resonator, near the edge connector.
35  1x 555 + resnet, near the battery.
3336
34       JP1 (ABC);  JP2 (DEF)
37  1x 10 DIP switches bank.
38  2x 3pins jumpers (between the Z80 and ROM)
3539
36    PCB silksceened:  AB+DE=512  BC+DE=256
37                      (CUT BC)   EF=64/128
40     JP1 (ABC);  JP2 (DEF)
3841
42  PCB silksceened:  AB+DE=512  BC+DE=256
43                    (CUT BC)   EF=64/128
3944
40  1x 10 DIP switches bank.
45  PCB silksceened: SMART-BOARD 131191 ISS.E (Made in USA)
4146
47  -------------------------------------------------------------
4248
43    PCB silksceened:  SMART-BOARD 131191 ISS.E (Made in USA)
4449
50  Hardware Layout (norautjp):
4551
52  - CPU:             1x TMPZ84C00AP-8
53  - RAM:             2x HM6116LP-4 CMOS Static Ram
54  - I/O:             3x D8255AC-2 Peripeheral Interface Adapter
55  - Prg ROMs:        1x 2764 Eprom
56  - Gfx ROMs:        1x 2732 Eprom
57  - Sound:           Discrete
58  - Battery:         1x 3.6v Ni-cd 65Mah
59  - Crystal:         1x 18.432Mhz
60  - Resistor Array:  4x 9 Pin SIP 472G
61
62
63  PCB Layout (norautjp):                                                       Edge Connector 36x2
64   ______________________________________________________________________________________________
65  |  _____                  _________    _________    _____         .........    _________       |
66  | |D5555|                |74LS174N |  |74LS153N |  |D5555|        .........   |ULN2003A |      |
67  | |_____|                |_________|  |_________|  |_____|    Resistor Array  |_________|      |
68  |                                                               ___                            |
69  |                                                              |VR1|                           |
70  |              DIP SW x4                                       |___|                           |
71  |  ________     _______                                                                        |
72  | |Battery |   |1|2|3|4|  _________    _________    _________    _________     _________       |
73  | |  3.6v  |   |_|_|_|_| |74LS157N |  |74LS153N |  |74LS161AP|  |74LS86AN |   |ULN2003A |      |
74  | |________|             |_________|  |_________|  |_________|  |_________|   |_________|      |
75  |                                                                                              |
76  |                                                                                              |
77  |                                                                                              | 36
78  |  _________              _________                 _________    _________     _________       |___
79  | |HD74LS04P|            |74LS166AP|               |74LS161AN|  |74LS153N |   |ULN2003A |       ___|
80  | |_________|            |_________|               |_________|  |_________|   |_________|       ___|
81  |                                                                                               ___|
82  |                                   DIP SW x 8                               ________________   ___|
83  |               _____________    _______________    _________    _________  |                |  ___|
84  |              |             |  |1|2|3|4|5|6|7|8|  |74LS161AN|  |74LS157N | |    D8255AC-2   |  ___|
85  |              |    2732     |  |_|_|_|_|_|_|_|_|  |_________|  |_________| |________________|  ___|
86  |              |_____________|                                                                  ___|
87  |                                                                                               ___|
88  |                                                                            ________________   ___|
89  |                                                                           |                |  ___|
90  |  _____________        _____________                                       |    D8255AC-2   |  ___|
91  | |             |      |             |                                      |________________|  ___|
92  | |    6116     |      |    6116     |                                                          ___|
93  | |_____________|      |_____________|              _________    _________                      ___|
94  |                                                  |74LS161AN|  |74LS157N |                     ___|
95  |                                                  |_________|  |_________|                     ___|
96  |                                                                                               ___|
97  |  ______________       ________________                                                        ___|
98  | |              |     |                |           _________    _________                      ___|
99  | |     2764     |     |    D8255AC-2   |          |74LS161AN|  |74LS157N |     .........       ___|
100  | |______________|     |________________|          |_________|  |_________|     .........       ___|
101  |                                                                              Resistor Array   ___|
102  |                                                                                               |
103  |                                                                                               | 1
104  |                      _________                    _________    _________    _________         |
105  |                     | 74LS32N |                  |74LS161AN|  | 74LS86P |  | 74LS04N |        |
106  |                     |_________|                  |_________|  |_________|  |_________|        |
107  |                                                                                               |
108  |                                             XTAL                                              |
109  |                                            .----.                                             |
110  |  ____________________     __________      _________    _________    _________    _________    |
111  | |                    |   |PALce16v8H|    | 74LS04N |  |74LS157N |  | 74LS11N |  |74LS74AN |   |
112  | |   TMPZ84C00AP-8    |   |__________|    |_________|  |_________|  |_________|  |_________|   |
113  | |____________________|                                                                        |
114  |                                                                                               |
115  |_______________________________________________________________________________________________|
116
117
118
46119*******************************************************************************
47120
48121
49    Noraut Edge Connector (pinouts)
50    --------------------------------
51    Component     PN   Solder Side
52    --------------------------------
53    GND           01   GND
54    5v DC         02   5v DC
55                  03
56    12v DC        04   12v DC
57                  05
58                  06
59                  07
60    0v            08   Readout Switch
61    0v            09   Low level hopper
62    0v            10   50p in
63    0v            11   pound in
64    0v            12   Bet switch
65    0v            13   Deal switch
66    0v            14   Hold 1 switch
67    0v            15   Half Gamble switch
68    0v            16   Change Card switch
69    Refil         17   Coin count/sense from hopper
70    Low Switch    18   High swicth
71    Hold 3 Switch 19   Hold 2 switch
72    Hold 5 Switch 20   Hold 4 switch
73    10p coin      21   Deflect
74                  22   50p in meter
75                  23   Hopper Motor Drive (low volt switch line NOT 24v)
76                  24
77                  25   spk+
78                  26   Panel lamps clock
79    Monitor sync  27   Hold 1 lamp
80    Bet lamp      28   Deal lamp
81    Change lamp   29   Hold 4 lamp
82    Hold 5 lamp   30   Panel lights reset
83    High lamp     31   Half Gamble lamp
84    Hold 2 lamp   32   Low lamp
85    10p Meter out 33   Meter refil
86    Video Green   34   Hold 3 lamp
87    Video Blue    35   10p in Meter
88    Video Red     36   Spark Detect (Not on all boards)
122  Noraut Edge Connector (pinouts)
123  --------------------------------
124  Component     PN   Solder Side
125  --------------------------------
126  GND           01   GND
127  5v DC         02   5v DC
128                03
129  12v DC        04   12v DC
130                05
131                06
132                07
133  0v            08   Readout Switch
134  0v            09   Low level hopper
135  0v            10   50p in
136  0v            11   pound in
137  0v            12   Bet switch
138  0v            13   Deal switch
139  0v            14   Hold 1 switch
140  0v            15   Half Gamble switch
141  0v            16   Change Card switch
142  Refil         17   Coin count/sense from hopper
143  Low Switch    18   High swicth
144  Hold 3 Switch 19   Hold 2 switch
145  Hold 5 Switch 20   Hold 4 switch
146  10p coin      21   Deflect
147                22   50p in meter
148                23   Hopper Motor Drive (low volt switch line NOT 24v)
149                24
150                25   spk+
151                26   Panel lamps clock
152  Monitor sync  27   Hold 1 lamp
153  Bet lamp      28   Deal lamp
154  Change lamp   29   Hold 4 lamp
155  Hold 5 lamp   30   Panel lights reset
156  High lamp     31   Half Gamble lamp
157  Hold 2 lamp   32   Low lamp
158  10p Meter out 33   Meter refil
159  Video Green   34   Hold 3 lamp
160  Video Blue    35   10p in Meter
161  Video Red     36   Spark Detect (Not on all boards)
89162
163*******************************************************************************
90164
165  Control Panel
166  -------------
167
168  There are 2 control panel schemes:
169
170  * The default one (11 button-lamps) for systems without CANCEL button.
171
172  .--------------------------------------------------------------------------.
173  |                                              .-------. .------. .------. |
174  | .------. .------. .------. .------. .------. |  BET  | | HALF | |  HI  | |
175  | |      | |      | |      | |      | |      | |COLLECT| |GAMBLE| |      | |
176  | | HOLD | | HOLD | | HOLD | | HOLD | | HOLD | '-------' '------' '------' |
177  | |CANCEL| |CANCEL| |CANCEL| |CANCEL| |CANCEL| .-------. .------. .------. |
178  | |      | |      | |      | |      | |      | | DEAL  | |CHANGE| |  LO  | |
179  | '------' '------' '------' '------' '------' | DRAW  | | CARD | |      | |
180  |                                              '-------' '------' '------' |
181  '--------------------------------------------------------------------------'
182
183   HOLD buttons              = red.
184   BET, DEAL, HI & LO        = yellow.
185   HALF GAMBLE & CHANGE CARD = orange.
186
187
188  * The alternate one (12 button-lamps) for systems with CANCEL button.
189
190  .-------------------------------------------------------------.
191  | .------. .------. .------. .------. .------.   .----------. |
192  | | HOLD | | HOLD | | HOLD | | HOLD | | HOLD |   |   HIGH   | |
193  | '------' '------' '------' '------' '------'   '----------' |
194  | .------. .------. .------. .------. .------.   .----------. |
195  | |CANCEL| |STAND | | SAVE | | DEAL | | BET  |   |   LOW    | |
196  | '------' '------' '------' '------' '------'   '----------' |
197  '-------------------------------------------------------------'
198
199   HOLD & CANCEL buttons     = yellow (1).
200   STAND & DEAL buttons      = orange (1).
201   SAVE (HALF GAMBLE) button = blued-green (1).
202   BET button                = red (1).
203   HIGH & LOW buttons        = yellow.
204
205   (1) Circular-shaped buttons.
206
207  Some lamps are wired in different way in this scheme.
208
209
91210*******************************************************************************
92211
93212
94    *** Game Notes ***
213  Noraut Poker discrete audio circuitry
214  -------------------------------------
95215
96    Nothing, yet...
216  3x ULN2003A (Darlington transistor array)
217  1x D5555C   (CMOS timer)
218  1x KN2222A  (Epitaxial planar general purpose NPN transistor)
219  1x VR/POT
97220
221  .------.                              .------------.               .-------.
222  |      |                              |   D5555C   |               |KN2222A|
223  |      |                             4|            |3     R3       |       |      -->
224  |   PC7|------------------------------|RST      OUT|-----ZZZZ------|B     E|>----ZZZZZ-----> Audio Out.
225  |   PC6|----------.                  6|            |8              |   C   |      VR1
226  |   PC5|-----.    |2-in         .-----|THR      VCC|-----------.   '---+---'          .----> Audio Out.
227  |   PC4|--.  |  .-+------.      |    5|            |7          |       |              |
228  |      |  |  |  |ULN2003A|      |  .--|CVOLT   DISC|--.        |       |              |
229  |      |  |  |  '-+------'      |  |  |            |  |        +-------'            --+--
230  |      |  |  |    |2-out   C1   |  |  |    GND     |  |        |                     GND
231  | 8255 |  |  |    '--------||---+  |  '-----+------'  |        |                      -
232  |  AP  |  |  '--.               |  |        |1        |        |                      '
233  |      |  |     |3-in           |  |        |         |        |
234  '------'  |  .--+-----.         |  |   C5   |         |        |
235            |  |ULN2003A|         |  '---||---+         |        |    +5V
236            |  '--+-----'         |           |         |        |    -+-
237            |     |3-out     C2   |      C4   |         |    C6  |     |
238            |     '----------||---+------||---+-------. | .--||--+-----'
239            |2-in                 |           |       | | |      |
240          .-+------.              |         --+--      '-'       |
241          |ULN2003A|              |          GND        |        |
242          '-+------'              |           -         |        |
243            |2-out           C3   |     R1    '         |   R2   |
244            '----------------||---+----ZZZZ-------------+--ZZZZ--'
98245
246  VR1 = 100 ohms
247
248  R1 = 120 K ; Tolerance +/- 5%
249  R2 = 2.2 K ; Tolerance +/- 5%
250  R3 = 1 K   ; Tolerance +/- 5%
251
252  C1 = 223J = 22000 pF  =  22 nF = 0.022 uF ; Tolerance +/- 5%
253  C2 = 103J = 10000 pF  =  10 nF = 0.01 uF  ; Tolerance +/- 5%
254  C3 = 473J = 47000 pF  =  47 nF = 0.047 uF ; Tolerance +/- 5%
255  C4 = 103J = 10000 pF  =  10 nF = 0.01 uF  ; Tolerance +/- 5%
256
257  C5 = 103  = 10000 pF  =  10 nF = 0.01 uF
258  C6 = 104  = 100000 pF = 100 nF = 0.1 uF
259
260  - C1, C2, C3 & C4 are polyester film / mylar capacitors.
261  - C5 & C6 are ceramic capacitors.
262  - All Capacitors are non-polarised.
263
264
99265*******************************************************************************
100266
101    --------------------
102    ***  Memory Map  ***
103    --------------------
104267
105    0x0000 - 0x1FFF    ; ROM space.
106    0x6000 - 0x63FF    ; NVRAM.
268  Narout System Ports Map
269  -----------------------
107270
108    0x60 - 0x63        ; PPI 8255 0 - DIP Switches.
109    0xA0 - 0xA3        ; PPI 8255 1 - Regular Inputs.
110    0xC0 - 0xC3        ; PPI 8255 2 - Video RAM.
271  (*) Confirmed lines.
111272
112273
274  PPI-0 (60h-63h); PortA IN.
275  DIP Switches bank:
276
277  7654 3210
278  ---- ---x  * DIP switch 8
279  ---- --x-  * DIP switch 7
280  ---- -x--  * DIP switch 6
281  ---- x---  * DIP switch 5
282  ---x ----  * DIP switch 4
283  --x- ----  * DIP switch 3
284  -x-- ----  * DIP switch 2
285  x--- ----  * DIP switch 1
286
287
288  PPI-0 (60h-63h); PortB OUT.
289  Lamps:
290
291  7654 3210
292  ---- ---x  * CHANGE CARD lamp.
293  ---- --x-  * SAVE / HALF GAMBLE lamp.
294  ---- -x--  * HOLD 1 lamp.
295  ---- x---  * HOLD 2 lamp.
296  ---x ----  * HOLD 3 lamp.
297  --x- ----  * HOLD 4 lamp.
298  -x-- ----  * HOLD 5 lamp.
299  x--- ----  * CANCEL lamp.
300
301
302  PPI-0 (60h-63h); PortC OUT.
303  Lamps & Coin Counters:
304
305  7654 3210
306  ---- ---x  * HI lamp.
307  ---- --x-  * LO lamp.
308  ---- -x--  unknown.
309  ---- x---  * Payout pulse.
310  ---x ----  * Coin 2 counter.
311  --x- ----  * Coin 1 counter.
312  -x-- ----  unknown.
313  x--- ----  unknown (always activated).
314
315
316-----------------------------------------------------------
317
318  PPI-1 (a0h-a3h); PortA IN.
319  Regular Inputs:
320
321  7654 3210
322  ---- ---x  * DEAL / DRAW button.
323  ---- --x-  * BET / CHANGE CARD button.
324  ---- -x--  * COIN 1 mech.
325  ---- x---  * COIN 2 mech.
326  ---x ----  * READOUT button.
327  --x- ----  * HI button.
328  -x-- ----  * LO button.
329  x--- ----  * PAYOUT button.
330
331
332  PPI-1 (a0h-a3h); PortB IN.
333  Regular Inputs:
334
335  7654 3210
336  ---- ---x  * STAND / TAKE button.
337  ---- --x-  * SAVE / HALF GAMBLE button.
338  ---- -x--  * HOLD 1 button.
339  ---- x---  * HOLD 2 button.
340  ---x ----  * HOLD 3 button.
341  --x- ----  * HOLD 4 button.
342  -x-- ----  * HOLD 5 button.
343  x--- ----  * CANCEL button.
344
345
346  PPI-1 (a0h-a3h); PortC OUT.
347  Sound & Lamps:
348
349  7654 3210
350  ---- ---x  * DEAL / DRAW Lamp.
351  ---- --x-  * BET / COLLECT Lamp.
352  ---- -x--  unknown (always activated after initalize).
353  ---- x---  unknown.
354  xxxx ----  * Discrete Sound Lines.
355
356
357-----------------------------------------------------------
358
359  PPI-2 (a0h-a3h); PortA IN/OUT
360  VRAM Handlers:
361
362  7654 3210
363  xxxx xxxx  VRAM DATA.
364
365
366  PPI-2 (a0h-a3h); PortB IN? (should be OUT)
367  VRAM Handlers:
368
369  7654 3210
370  xxxx xxxx  VRAM ADDRESSING.
371
372
373  PPI-2 (a0h-a3h); PortC (PortA handshake lines)
374  VRAM Handlers:
375
376  7654 3210
377  xxxx xxxx  HANDSHAKE LINES.
378
379
113380*******************************************************************************
114381
115382
116  DRIVER UPDATES:
383  *** Game Notes ***
117384
118385
119    [2009-01-27]
386  - norautjp:
387 
388   At the first start-up, the game will give you a very clever
389    "FU" screen. Press the following buttons *together* on different times
390    to get rid of it (and actually initialize the machine):
120391
121    - Initial release.
122    - Defined ROM, RAM.
123    - Added 2x PPI 8255 for regular I/O.
124    - Added complete inputs and hooked DIP switches.
125    - Added video RAM support.
126    - Added NVRAM.
127    - Added lamps support.
128    - Added coin counters.
129    - Identified the sound writes.
130    - Added hardware description.
131    - Added pinout scheme.
132    - Added technical notes.
392    * start + bet buttons (1+2);
393    * Hold 3 + Hold 2 + Save (Half Gamble) + Change Card (C+X+F+D)
133394
134    [2009-01-28]
395    Also notice that you actually need to map the last four buttons on the
396    same button / on a joypad since MAME's steady key doesn't seem to work on
397    my end...
135398
136    - Merged GTI Poker (gtipoker.c) with this driver.
137    - Added new memory map and machine driver for gtipoker.
138    - Hooked 2x PPI 8255 to gtipoker.
139    - Hooked the video RAM access ports to gtipoker.
140    - Changed norautpn description from Noraut Poker (No Payout),
141      to Noraut Poker (bootleg), since the game has payout system.
142    - Some clean-ups.
143399
144    Notes:
145    - norautjp: at the first start-up, the game will give you a very clever
146      "FU" screen. Press the following buttons *together* on different times
147      to get rid of it (and actually initialize the machine):
148      * start + bet buttons (1+2);
149      * Hold 3 + Hold 2 + Save (Half Gamble) + Change Card (C+X+F+D)
150      Also notice that you actually need to map the last four buttons on the
151      same button / on a joypad since MAME's steady key doesn't seem to work on
152      my end...
400*******************************************************************************
153401
402  --------------------
403  ***  Memory Map  ***
404  --------------------
154405
155    TODO:
406  0x0000 - 0x1FFF    ; ROM space.
407  0x6000 - 0x63FF    ; NVRAM.
156408
157    - Analize the extra 8255 at 0xc0-0xc3 (full bidirectional port w/hshk)
158    - Video RAM (through 3rd PPI?).
159    - Find if wide chars are hardcoded or tied to a bit.
160    - Proper colors (missing PROM?)
161    - Lamps layout.
162    - Discrete sound.
409  0x60 - 0x63        ; PPI 8255 0 - DIP Switches, lamps & counters.
410  0xA0 - 0xA3        ; PPI 8255 1 - Regular Inputs, sound lines & remaining lamps.
411  0xC0 - 0xC3        ; PPI 8255 2 - Video RAM access.
163412
164413
414*******************************************************************************
415
416
417  DRIVER UPDATES:
418
419
420  [2009-01-27]
421
422  - Initial release.
423  - Defined ROM, RAM.
424  - Added 2x PPI 8255 for regular I/O.
425  - Added complete inputs and hooked DIP switches.
426  - Added video RAM support.
427  - Added NVRAM.
428  - Added lamps support.
429  - Added coin counters.
430  - Identified the sound writes.
431  - Added hardware description.
432  - Added pinout scheme.
433  - Added technical notes.
434
435
436  [2009-01-28]
437
438  - Merged GTI Poker (gtipoker.c) with this driver.
439  - Added new memory map and machine driver for gtipoker.
440  - Hooked 2x PPI 8255 to gtipoker.
441  - Hooked the video RAM access ports to gtipoker.
442  - Changed norautpn description from Noraut Poker (No Payout),
443    to Noraut Poker (bootleg), since the game has payout system.
444  - Some clean-ups.
445
446
447  [2009-08-21]
448
449  - Switched to pre-defined Xtal clock.
450  - Changed the way how graphics are banked/accessed.
451  - Fixed the graphics offset and number of tiles per bank.
452  - Added new set: Noraut Red Hot Joker Poker.
453  - Added new set: Noraut Poker (NTX10A).
454  - Added new set: Noraut Joker Poker (V3.010a).
455  - Fixed the tile size/decode for the first GFX bank.
456  - Added proper norautrh inputs, including the readout button.
457  - Added partial DIP switches to norautrh.
458  - Added more technical notes.
459
460
461  [2009-08-23/26]
462
463  - Added a default NVRAM to Noraut Joker Poker to bypass the 'F U' screen.
464    This is due to the phisical keyboard limitation when needs to enter
465    4 simultaneous inputs.
466  - Executed a trojan on 2 noraut systems to confirm the way 16x32 tiles are decoded.
467  - Fixed the x-offset for 32x32 tiles lines.
468  - Fixed the screen aspect and visible area.
469  - Confirmed correct colors. No bipolar PROM involved.
470  - Added Noraut Joker Poker hardware and PCB layouts.
471  - Documented the discrete audio circuitery. Added a full diagram.
472
473
474  [2009-08-29]
475
476  - Fixed the coin counters.
477  - Documented all the output ports.
478  - Added a scheme with descriptions for every existent port.
479  - Added full lamps support to naroutp, naroutjp, naroutrh and naroutpn.
480  - Created lamps layouts for 11 and 12-lamps scheme.
481  - Rerouted some inputs to mantain the inputs layout.
482  - Renamed some inputs to match the text with the real cab buttons.
483  - Removed the imperfect colors flag from the existent sets.
484  - Added 2 different control panel layouts to the source.
485  - Updated technical notes.
486
487
488  TODO:
489
490  - Analize the third 8255 at 0xc0-0xc3 (full bidirectional port w/hshk lines)
491  - Video RAM (through 3rd PPI?).
492  - Find if wide chars are hardcoded or tied to a bit.
493  - Discrete sound.
494  - Save support.
495
496
165497*******************************************************************************/
166498
167499
r5534r5535
172504#include "machine/8255ppi.h"
173505#include "sound/dac.h"
174506
507#include "noraut11.lh"
508#include "noraut12.lh"
509
175510static UINT16 *np_vram;
176511static UINT16 np_addr;
177512
r5534r5535
196531
197532   for(y = 0; y < 8; y++)
198533   {
199      /*Double width*/
534      /* Double width, displaced 8 pixels in X */
200535      if(y == 2 || (y >= 4 && y < 6))
201536      {
202537         for(x = 0; x < 16; x++)
r5534r5535
204539            int tile = np_vram[count] & 0x3f;
205540            int colour = (np_vram[count] & 0xc0) >> 6;
206541
207            drawgfx_opaque(bitmap,cliprect, screen->machine->gfx[1], tile, colour, 0, 0, x * 32, y * 32);
542            drawgfx_opaque(bitmap,cliprect, screen->machine->gfx[1], tile, colour, 0, 0, (x * 32) + 8, y * 32);
208543
209544            count+=2;
210545         }
r5534r5535
245580*      R/W Handlers      *
246581*************************/
247582
248static WRITE8_DEVICE_HANDLER( lamps_w )
583static WRITE8_DEVICE_HANDLER( mainlamps_w )
249584{
250/*  LAMPS:
585/*  PPI-0 (60h-63h); PortB OUT.
586    Lamps:
251587
252588    7654 3210
253    ---- ---x  Change Card / (Save?)
254    ---- --x-  Hi/Lo
255    ---- -x--  Hold 1
256    ---- x---  Hold 2
257    ---x ----  Hold 3
258    --x- ----  Hold 4
259    -x-- ----  Hold 5
260    x--- ----  Start (poker)
589    ---- ---x  * CHANGE CARD lamp.
590    ---- --x-  * SAVE / HALF GAMBLE lamp.
591    ---- -x--  * HOLD 1 lamp.
592    ---- x---  * HOLD 2 lamp.
593    ---x ----  * HOLD 3 lamp.
594    --x- ----  * HOLD 4 lamp.
595    -x-- ----  * HOLD 5 lamp.
596    x--- ----  * CANCEL lamp.
261597*/
262
263   output_set_lamp_value(0, (data >> 0) & 1);      /* Change */
264   output_set_lamp_value(1, (data >> 1) & 1);      /* Hi/Lo  */
265   output_set_lamp_value(2, (data >> 2) & 1);      /* Hold 1 */
266   output_set_lamp_value(3, (data >> 3) & 1);      /* Hold 2 */
267   output_set_lamp_value(4, (data >> 4) & 1);      /* Hold 3 */
268   output_set_lamp_value(5, (data >> 5) & 1);      /* Hold 4 */
269   output_set_lamp_value(6, (data >> 6) & 1);      /* Hold 5 */
270   output_set_lamp_value(7, (data >> 7) & 1);      /* Start  */
598   output_set_lamp_value(0, (data >> 0) & 1);   /* CHANGE CARD lamp */
599   output_set_lamp_value(1, (data >> 1) & 1);   /* SAVE / HALF GAMBLE lamp */
600   output_set_lamp_value(2, (data >> 2) & 1);   /* HOLD 1 lamp */
601   output_set_lamp_value(3, (data >> 3) & 1);   /* HOLD 2 lamp */
602   output_set_lamp_value(4, (data >> 4) & 1);   /* HOLD 3 lamp */
603   output_set_lamp_value(5, (data >> 5) & 1);   /* HOLD 4 lamp */
604   output_set_lamp_value(6, (data >> 6) & 1);   /* HOLD 5 lamp */
605   output_set_lamp_value(7, (data >> 7) & 1);   /* CANCEL lamp */
271606}
272607
273static WRITE8_DEVICE_HANDLER( ccounter_w )
608static WRITE8_DEVICE_HANDLER( soundlamps_w )
274609{
275   coin_counter_w(0, data & 0x20);   /* Coin1 */
276   coin_counter_w(1, data & 0x10);   /* Coin2 */
277   coin_counter_w(2, data & 0x08);   /* Payout */
610/*  PPI-1 (a0h-a3h); PortC OUT.
611    Sound & Lamps:
612
613    7654 3210
614    ---- ---x  * DEAL / DRAW Lamp.
615    ---- --x-  * BET / COLLECT Lamp.
616    ---- -x--  unknown (always activated after initalize).
617    ---- x---  unknown.
618    xxxx ----  * Discrete Sound Lines.
619*/
620   output_set_lamp_value(8, (data >> 0) & 1);   /* DEAL / DRAW lamp */
621   output_set_lamp_value(9, (data >> 1) & 1);   /* BET / COLLECT lamp */
622
623   /* the 4 MSB are for discrete sound */
624   dac_data_w(devtag_get_device(device->machine, "dac"), (data & 0xf0));   /* Discrete Sound */
278625}
279626
280static WRITE8_DEVICE_HANDLER( sndlamp_w )
627static WRITE8_DEVICE_HANDLER( counterlamps_w )
281628{
282   output_set_lamp_value(8, (data >> 0) & 1);      /* Start? */
283   output_set_lamp_value(9, (data >> 1) & 1);      /* Bet */
629/*  PPI-0 (60h-63h); PortC OUT.
630    Lamps & Coin Counters:
284631
285   /* the 4 MSB are for discrete (or DAC) sound */
286   dac_data_w(devtag_get_device(device->machine, "dac"), (data & 0xf0));      /* Sound DAC? */
632    7654 3210
633    ---- ---x  * HI lamp.
634    ---- --x-  * LO lamp.
635    ---- -x--  unknown.
636    ---- x---  * Payout pulse.
637    ---x ----  * Coin 2 counter.
638    --x- ----  * Coin 1 counter.
639    -x-- ----  unknown.
640    x--- ----  unknown (always activated).
641*/
642   output_set_lamp_value(10, (data >> 0) & 1);   /* HI lamp */
643   output_set_lamp_value(11, (data >> 1) & 1);   /* LO lamp */
644
645   coin_counter_w(0, data & 0x10);   /* Coin1/3 counter */
646   coin_counter_w(1, data & 0x20);   /* Coin2 counter */
647   coin_counter_w(2, data & 0x08);   /* Payout pulse */
287648}
288649
289/*game waits for bit 7 (0x80) to be set.*/
650
651/* game waits for bit 7 (0x80) to be set.*/
290652static READ8_HANDLER( test_r )
291653{
292654   return 0xff;
293655}
294656
657/* game waits for bit 4 (0x10) to be reset.*/
658static READ8_HANDLER( test2_r )
659{
660   return 0x00;
661}
662
295663static WRITE8_HANDLER( vram_data_w )
296664{
297665   np_vram[np_addr] = data & 0xff;
r5534r5535
330698  c2 --> R  ; status?
331699  c3 --> W  ; alternate 00 & 01 (in case of PPI, setting resetting bit 0 of handshaked port)
332700
701  The strange issue is that some sets just configure the PPI to mixed mode2 and mode0 input.
702  it means that port A should be bidirectional and port B just as input. (port C as hshk regs).
703  So... it doesn't match the addressing through c1.
333704*/
334705
335706static ADDRESS_MAP_START( gtipoker_map, ADDRESS_SPACE_PROGRAM, 8 )
r5534r5535
345716   AM_RANGE(0xdd, 0xdd) AM_WRITE(vram_addr_w)
346717   AM_RANGE(0xde, 0xde) AM_READ(test_r)
347718//  AM_RANGE(0xdc, 0xdf) AM_DEVREADWRITE("ppi8255_2", ppi8255_r, ppi8255_w)
348   AM_RANGE(0xef, 0xef) AM_READ(test_r)
719   AM_RANGE(0xef, 0xef) AM_READ(test2_r)
349720ADDRESS_MAP_END
350721
351722
r5534r5535
355726
356727static INPUT_PORTS_START( norautp )
357728   PORT_START("IN0")
358   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_GAMBLE_DEAL ) PORT_NAME("Deal / Start")
359   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_GAMBLE_BET ) PORT_NAME("Bet / Take")
729   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_GAMBLE_DEAL ) PORT_NAME("Deal / Draw")
730   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_POKER_BET )   PORT_NAME("Bet / Collect")
360731   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(2)   /* Coin A */
361732   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_IMPULSE(2)   /* Coin B */
362   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
733   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE )     PORT_NAME("Readout") PORT_CODE(KEYCODE_9)
363734   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_GAMBLE_HIGH ) PORT_NAME("Hi")
364   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_GAMBLE_LOW ) PORT_NAME("Lo")
735   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_GAMBLE_LOW ) PORT_NAME("Lo")
365736   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_GAMBLE_PAYOUT )
366737
367738   PORT_START("IN1")
368   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Change Card")
369   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_GAMBLE_HALF ) PORT_NAME("Save (Half Gamble)")
739   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 )     PORT_CODE(KEYCODE_F) PORT_NAME("Change Card")
740   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_GAMBLE_HALF ) PORT_NAME("Half Gamble / Save")
370741   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_POKER_HOLD1 )
371742   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_POKER_HOLD2 )
372743   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_POKER_HOLD3 )
r5534r5535
401772   PORT_DIPSETTING(    0x00, "10 Pence" )
402773INPUT_PORTS_END
403774
404static INPUT_PORTS_START( poker )
775static INPUT_PORTS_START( norautrh )
405776   PORT_START("IN0")
777   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_GAMBLE_DEAL ) PORT_NAME("Deal / Draw")
778   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_POKER_BET )   PORT_NAME("Bet / Change Card")
779   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(2)   /* Coin A */
780   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_IMPULSE(2)   /* Coin B */
781   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE )     PORT_NAME("Readout") PORT_CODE(KEYCODE_9)
782   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_GAMBLE_HIGH ) PORT_NAME("Hi")
783   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_GAMBLE_LOW )  PORT_NAME("Lo")
784   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_GAMBLE_PAYOUT )
785
786   PORT_START("IN1")
787   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_GAMBLE_TAKE ) PORT_NAME("Stand / Take")
788   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_GAMBLE_HALF ) PORT_NAME("Save / Half Gamble")
789   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_POKER_HOLD1 )
790   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_POKER_HOLD2 )
791   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_POKER_HOLD3 )
792   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_POKER_HOLD4 )
793   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_POKER_HOLD5 )
794   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_POKER_CANCEL )   /* Coin C for other games */
795
796   PORT_START("DSW1")
797   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )   PORT_DIPLOCATION("DSW1:8")
798   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
799   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
800   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )   PORT_DIPLOCATION("DSW1:7")
801   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
802   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
803   PORT_DIPNAME( 0x04, 0x04, "Bet Max" )         PORT_DIPLOCATION("DSW1:6")
804   PORT_DIPSETTING(    0x04, "5" )
805   PORT_DIPSETTING(    0x00, "25" )
806   PORT_DIPNAME( 0x08, 0x08, "Raise Ante" )      PORT_DIPLOCATION("DSW1:5")
807   PORT_DIPSETTING(    0x08, "Random" )
808   PORT_DIPSETTING(    0x00, "Always" )
809   PORT_DIPNAME( 0x10, 0x10, "Type of Game" )      PORT_DIPLOCATION("DSW1:4")
810   PORT_DIPSETTING(    0x10, "Jacks Plus" )
811   PORT_DIPSETTING(    0x00, "Joker Poker" )
812   PORT_DIPNAME( 0xa0, 0x20, DEF_STR( Coinage ) )   PORT_DIPLOCATION("DSW1:3,1")
813   PORT_DIPSETTING(    0x00, "A=1; B=5" )
814   PORT_DIPSETTING(    0xa0, "A=5; B=25" )
815   PORT_DIPSETTING(    0x20, "A=10; B=5" )
816   PORT_DIPSETTING(    0x80, "A=50; B=25" )
817   PORT_DIPNAME( 0x40, 0x00, "Show Bet")         PORT_DIPLOCATION("DSW1:2")
818   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
819   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
820INPUT_PORTS_END
821
822static INPUT_PORTS_START( naroutpn )
823   PORT_START("IN0")
406824   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_GAMBLE_DEAL ) PORT_NAME("Deal / Start")
407   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_GAMBLE_BET ) PORT_NAME("Bet / Change Card")
825   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_POKER_BET )  PORT_NAME("Bet / Change Card")
408826   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(2)   /* Coin A */
409827   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_IMPULSE(2)   /* Coin B */
410   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
828   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE )     PORT_NAME("Readout") PORT_CODE(KEYCODE_9)
411829   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_GAMBLE_HIGH ) PORT_NAME("Hi")
412   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_GAMBLE_LOW ) PORT_NAME("Lo")
830   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_GAMBLE_LOW ) PORT_NAME("Lo")
413831   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_GAMBLE_PAYOUT )
414832
415833   PORT_START("IN1")
416   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_GAMBLE_TAKE ) PORT_NAME("Stand (Take)")
417   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_GAMBLE_HALF ) PORT_NAME("Save (Half Gamble)")
834   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_GAMBLE_TAKE ) PORT_NAME("Stand / Take")
835   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_GAMBLE_HALF ) PORT_NAME("Save / Half Gamble")
418836   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_POKER_HOLD1 )
419837   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_POKER_HOLD2 )
420838   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_POKER_HOLD3 )
r5534r5535
449867   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
450868INPUT_PORTS_END
451869
870
452871/*************************
453872*    Graphics Layouts    *
454873*************************/
455874
456875static const gfx_layout charlayout =
876/*
877  Trojanned 2 Narout Poker PCBs to see how the hardware decodes
878  the 16x32 tiles. The following GFX layout is 100% accurate.
879*/
457880{
458   16,32,
459   RGN_FRAC(1,1),
881   16, 32,
882   RGN_FRAC(1,2),
460883   1,
461884   { 0 },
462885   { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
463   { 0*16, 0*16, 1*16, 1*16, 2*16, 2*16, 3*16, 3*16, 4*16, 4*16, 5*16, 5*16, 6*16, 6*16, 7*16, 7*16,
464     8*16, 8*16, 9*16, 9*16, 10*16,10*16,11*16,11*16,12*16,12*16,13*16,13*16,14*16,14*16,15*16,15*16 },
886   { 0*16, 0*16, 0*16, 0*16, 0*16, 0*16, 0*16, 0*16, 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
887     8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16, 0*16, 0*16, 0*16, 0*16, 0*16, 0*16, 0*16, 0*16, },
465888   16*16
466889};
467890
468891static const gfx_layout charlayout32x32 =
469892{
470893   32,32,
471   RGN_FRAC(1,1),
894   RGN_FRAC(1,2),
472895   1,
473896   { 0 },
474897   { 0,0, 1,1, 2,2, 3,3, 4,4, 5,5, 6,6, 7,7, 8,8, 9,9, 10,10, 11,11, 12,12, 13,13, 14,14, 15,15 },
r5534r5535
482905* Graphics Decode Information *
483906******************************/
484907
908/* GFX are stored in the 2nd half... Maybe the HW could handle 2 bitplanes? */
485909static GFXDECODE_START( norautp )
486   GFXDECODE_ENTRY( "gfx", 0, charlayout,      0, 4 )
487   GFXDECODE_ENTRY( "gfx", 0, charlayout32x32, 0, 4 )
910   GFXDECODE_ENTRY( "gfx", 0x800, charlayout,      0, 4 )
911   GFXDECODE_ENTRY( "gfx", 0x800, charlayout32x32, 0, 4 )
488912GFXDECODE_END
489913
490914
r5534r5535
495919static const ppi8255_interface ppi8255_intf[3] =
496920{
497921   {   /* (60-63) Mode 0 - Port A set as input */
498      DEVCB_INPUT_PORT("DSW1"),   /* Port A read */
499      DEVCB_NULL,               /* Port B read */
500      DEVCB_NULL,               /* Port C read */
501      DEVCB_NULL,               /* Port A write */
502      DEVCB_HANDLER(lamps_w),       /* Port B write */
503      DEVCB_HANDLER(ccounter_w)   /* Port C write */
922      DEVCB_INPUT_PORT("DSW1"),      /* Port A read */
923      DEVCB_NULL,                  /* Port B read */
924      DEVCB_NULL,                  /* Port C read */
925      DEVCB_NULL,                  /* Port A write */
926      DEVCB_HANDLER(mainlamps_w),      /* Port B write */
927      DEVCB_HANDLER(counterlamps_w)   /* Port C write */
504928   },
505929   {   /* (a0-a3) Mode 0 - Ports A & B set as input */
506      DEVCB_INPUT_PORT("IN0"),    /* Port A read */
507      DEVCB_INPUT_PORT("IN1"),   /* Port B read */
508      DEVCB_NULL,                /* Port C read */
509      DEVCB_NULL,                /* Port A write */
510      DEVCB_NULL,                /* Port B write */
511      DEVCB_HANDLER(sndlamp_w)    /* Port C write */
930      DEVCB_INPUT_PORT("IN0"),      /* Port A read */
931      DEVCB_INPUT_PORT("IN1"),      /* Port B read */
932      DEVCB_NULL,                  /* Port C read */
933      DEVCB_NULL,                  /* Port A write */
934      DEVCB_NULL,                  /* Port B write */
935      DEVCB_HANDLER(soundlamps_w)      /* Port C write */
512936   },
513937   {   /* (c0-c3) Group A Mode 2 (5-handshacked bidirectional port) */
514      DEVCB_NULL,                /* Port A read */
515      DEVCB_NULL,                /* Port B read */
516      DEVCB_NULL,                /* Port C read */
517      DEVCB_NULL,                /* Port A write */
518      DEVCB_NULL,                /* Port B write */
519      DEVCB_NULL                /* Port C write */
938      DEVCB_NULL,                  /* Port A read */
939      DEVCB_NULL,                  /* Port B read */
940      DEVCB_NULL,                  /* Port C read  (should has test_r tied) */
941      DEVCB_NULL,                  /* Port A write (should has vram_data_w tied) */
942      DEVCB_NULL,                  /* Port B write (should has vram_addr_w tied) */
943      DEVCB_NULL                  /* Port C write */
520944   }
521945};
522946
r5534r5535
546970   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
547971   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
548972   MDRV_SCREEN_SIZE(32*16, 32*16)
549   MDRV_SCREEN_VISIBLE_AREA(2*16, 31*16-1, 0*16, 16*16-1)
973   MDRV_SCREEN_VISIBLE_AREA(3*16, 31*16-1, (0*16) + 8, 16*16-1)   /* the hardware clips the top 8 pixels */
550974
551975   MDRV_GFXDECODE(norautp)
552976
r5534r5535
6161040   ROM_LOAD( "char.bin",   0x0000, 0x1000, CRC(955eac6f) SHA1(470d8bad1a5d2a0a08dd129e6393c3c3a4ef2159) )
6171041ROM_END
6181042
1043/*
1044Noraut Joker Poker
6191045
1046Program:27C64
1047Marked:
1048"MX10A JOKER G.L
1049 N.C.R  C.C  M.S"
1050
1051Char:2732
1052Marked:
1053"N1-057-5"
1054
1055CPU: TMPZ84C00AP-8
1056*/
1057
6201058ROM_START( norautjp )
6211059   ROM_REGION( 0x10000, "maincpu", 0 )
6221060   ROM_LOAD( "2764-1prog.bin",   0x0000, 0x2000, CRC(5f776ce1) SHA1(673b8c67ebd5c1334187a9407b86a43150cbe67b) )
6231061
624   ROM_REGION( 0x800,  "gfx", 0 )
625   ROM_LOAD( "2732-1char.bin",   0x0000, 0x0800, CRC(d94be899) SHA1(b7212162324fa2d67383a475052e3b351bb1af5f) )    /* first half 0xff filled */
626   ROM_CONTINUE(                 0x0000, 0x0800 )
1062   ROM_REGION( 0x1000,   "gfx", 0 )
1063   ROM_FILL(                     0x0000, 0x0800, 0xff )
1064   ROM_LOAD( "2732-1char.bin",   0x0800, 0x0800, CRC(d94be899) SHA1(b7212162324fa2d67383a475052e3b351bb1af5f) )    /* first half 0xff filled */
1065   ROM_CONTINUE(                 0x0800, 0x0800 )
1066
1067   ROM_REGION( 0x400,   "nvram", 0 )
1068   ROM_LOAD( "norautjp_nv.bin",  0x0000, 0x0400, CRC(0a0614b2) SHA1(eb21b2723b41743daf787cfc379bc67cce2b8538) )   /* default NVRAM */
1069
6271070ROM_END
6281071
1072/*
1073Noraut Red Hot Joker Poker
1074Red hot joker poker scrolls across screen
1075and eprom has Red Hot on sticker
1076Char:
1077Handwritten sticker with "Club250 grapics" on it
1078
1079Pressing the readout button brings you to a menu with RESET / READOUT
1080pressing on Readout brings you to "coins in" and "coins out" and "balance".
1081
1082No date info on board or found in rom
1083*/
1084
1085ROM_START( norautrh )
1086   ROM_REGION( 0x10000, "maincpu", 0 )
1087   ROM_LOAD( "norautrh.bin",  0x0000, 0x2000, CRC(f5447d1a) SHA1(75d6439481e469e82e5561146966c9c7b44f34fe) )
1088
1089   ROM_REGION( 0x1000,  "gfx", 0 )
1090   ROM_LOAD( "club250.bin",   0x0000, 0x1000, CRC(d94be899) SHA1(b7212162324fa2d67383a475052e3b351bb1af5f) )
1091ROM_END
1092
1093/*
1094Unknown Noraut: "NTX10A  V6"
1095None working old noraut board with daughter card upgrade
1096daughter card looks like an old upgrade PCB marked:
1097"Noraut LTD Game Module"
1098half of which is incased in epoxy resin.
1099only thing not visble on this board compared to others i have is the cpu
1100with is under the epoxy not sure what else is their.
1101
1102D Card contains:
1103Backup Battery
1104
1105Program Eprom:27C256
1106Marked: "NTX10A  V6"
1107           "C201"
1108
1109CPU:
1110Unknown Incased in epoxy
1111
1112NVRAM: HY6264A
1113
1114PAL:
1115PAL16L8ACN
1116
1117Charcter Eprom is mounted on main board
1118CHAR Eprom:2732
1119Marked: "GU27"
1120
1121daughter card is connected on to another card containing only pcb tracks no components
1122This second board connects to main board with ribbon cable to the 40pin socket where
1123the original cpu would of been.
1124
1125No date info on board or found in rom.
1126*/
1127
1128ROM_START( norautu )
1129   ROM_REGION( 0x10000, "maincpu", 0 )
1130   ROM_LOAD( "2563.bin",    0x0000, 0x8000, CRC(6cbe68bd) SHA1(93201baaf03a9bba6c52c64cc26e8e445aa6454e) )
1131
1132   ROM_REGION( 0x1000,  "gfx", 0 )
1133   ROM_LOAD( "club250.bin", 0x0000, 0x1000, CRC(d94be899) SHA1(b7212162324fa2d67383a475052e3b351bb1af5f) )
1134ROM_END
1135
1136
1137/*NORAUT V3.010a:
1138Board upgraded with daughter card.
1139daughter card looks modern and is marked
1140"memory expansion module"
1141"Unique Ireland"
1142
1143D Card contains:
1144Backup Battery
1145
1146Program Eprom:27C512
1147Marked:
1148"G45P A V3.010a GU27
1149 Euro 27C512 20MAR02"
1150
1151
1152PAL:PAL16l8ANC
1153Marked VER.2
1154
1155CPU:
1156Zilog
1157Z8400APS
1158Z80 CPU
1159
1160NVRAM: 6116
1161
1162Two jumpers on card , game will not boot if these are removed or placed on other pins
1163cabinet beeps and shows grapics on screen. Removing while game is on cause game to freeze.
1164Unknown what their for.
1165
1166Charcter Eprom is mounted on main board
1167CHAR Eprom:2716
1168Marked "GU27"
1169
1170No date info found in rom,  program eprom sticker "Euro 27C512 20MAR02"
1171This version contains a hidden menu with lots of differnt options
1172to access this menu you must hold the HI and LOW button and press the readout/test switch
1173the screen will go blank then you release the 3 buttons and the menu appears.
1174
1175Pressing the readout button brings you to a menu with RESET / READOUT
1176pressing on Readout brings you to "coins in" and "coins out" and "balance".
1177
1178The daughter card connects direct to main pcb through 40 pins into original cpu socket
1179and 12 pins to one side of original program eprom.
1180*/
1181
1182ROM_START( norautv3 )
1183   ROM_REGION( 0x10000, "maincpu", 0 )
1184   ROM_LOAD( "g45pa.bin", 0x0000, 0x10000, CRC(f966f4d2) SHA1(99c21ceb59664f32fd1269351fa976370d486f2e) )
1185
1186   ROM_REGION( 0x1000,  "gfx", 0 )
1187   ROM_FILL(              0x0000, 0x0800, 0xff )
1188   ROM_LOAD( "gu27.bin",  0x0800, 0x0800, CRC(174a5eec) SHA1(44d84a0cf29a0bf99674d95084c905d3bb0445ad) )
1189ROM_END
1190
1191
6291192/*************************
6301193*      Game Drivers      *
6311194*************************/
6321195
633/*    YEAR  NAME      PARENT   MACHINE   INPUT    INIT  ROT    COMPANY        FULLNAME                 FLAGS */
634GAME( 1988, norautp,  0,       norautp,  norautp, 0,    ROT0, "Noraut Ltd.", "Noraut Poker",           GAME_NO_SOUND | GAME_IMPERFECT_COLORS )
635GAME( 1988, norautjp, norautp, norautp,  norautp, 0,    ROT0, "Noraut Ltd.", "Noraut Joker Poker",     GAME_NO_SOUND | GAME_IMPERFECT_COLORS )
636GAME( 1983, gtipoker, 0,       gtipoker, norautp, 0,    ROT0, "GTI Inc",     "GTI Poker",              GAME_NO_SOUND | GAME_IMPERFECT_COLORS | GAME_NOT_WORKING )
1196/*     YEAR  NAME      PARENT   MACHINE   INPUT     INIT  ROT    COMPANY        FULLNAME                       FLAGS                              LAYOUT */
1197GAMEL( 1988, norautp,  0,       norautp,  norautp,  0,    ROT0, "Noraut Ltd.", "Noraut Poker",                 GAME_NO_SOUND,                     layout_noraut11 )
1198GAMEL( 1988, norautjp, norautp, norautp,  norautp,  0,    ROT0, "Noraut Ltd.", "Noraut Joker Poker",           GAME_NO_SOUND,                     layout_noraut11 )
1199GAMEL( 1988, norautrh, 0,       norautp,  norautrh, 0,    ROT0, "Noraut Ltd.", "Noraut Red Hot Joker Poker",   GAME_NO_SOUND,                     layout_noraut12 )
1200GAME(  1988, norautu,  0,       norautp,  norautp,  0,    ROT0, "Noraut Ltd.", "Noraut Poker (NTX10A)",        GAME_NO_SOUND | GAME_NOT_WORKING )
1201GAME(  1988, norautv3, 0,       norautp,  norautp,  0,    ROT0, "Noraut Ltd.", "Noraut Joker Poker (V3.010a)", GAME_NO_SOUND | GAME_NOT_WORKING )
1202GAME(  1983, gtipoker, 0,       gtipoker, norautp,  0,    ROT0, "GTI Inc",     "GTI Poker",                    GAME_NO_SOUND | GAME_NOT_WORKING )
6371203
6381204/*The following has everything uncertain, seems a bootleg/hack and doesn't have any identification strings in program rom. */
639GAME( 198?, norautpn, norautp, norautp,  poker,   0,    ROT0, "bootleg?",    "Noraut Poker (bootleg)", GAME_NO_SOUND | GAME_IMPERFECT_COLORS )
1205GAMEL( 198?, norautpn, norautp, norautp,  naroutpn, 0,    ROT0, "bootleg?",    "Noraut Poker (bootleg)",       GAME_NO_SOUND,                    layout_noraut12 )
src/mame/drivers/kaneko16.c
r5534r5535
5757- Finish the Inputs (different wheels and pedals)
5858- Find infos about the communication stuff (even if it won't be supported)
5959
60[brapboys / shogwarr]
61
62- Verify collision protection on real hardware
63- Figure out how MCU resets writeback address (currently hacked)
64- Find relationship between Key tables and final datablock
65- Clean up debug code file writes etc. (when above are done only!)
66- Interrupt timing? (some sprites flicker)
67- Sprite buffering (2 frames?, or related to above)
68
6069Dip locations verified from manual for:
6170
6271- berlwall
r5534r5535
6877- gtmr2
6978- shogwarr
7079
80
81
7182***************************************************************************/
7283
7384#include "driver.h"
r5534r5535
8091#include "sound/2151intf.h"
8192#include "sound/okim6295.h"
8293
83UINT16* kaneko16_calc3_fakeram;
8494static UINT16* kaneko16_mainram;
8595
8696/***************************************************************************
r5534r5535
98108   kaneko16_sprite_xoffs = 0;
99109   kaneko16_sprite_yoffs = 0;
100110
111   kaneko16_sprite_fliptype = 0;
112
101113/*
102114    Sx = Sprites with priority x, x = tiles with priority x,
103115    Sprites - Tiles Order (bottom -> top):
r5534r5535
231243
232244   kaneko16_sprite_xoffs = 0xa00;
233245
234   kaneko16_sprite_yoffs = 0x200;
246   kaneko16_sprite_yoffs = -0x40;
235247
248   kaneko16_sprite_type = 0;
249   kaneko16_sprite_fliptype = 1;
236250
237   kaneko16_priority.sprite[0] = 2;   // below all
251   kaneko16_priority.sprite[0] = 1;   // below all
238252   kaneko16_priority.sprite[1] = 3;   // above tile[0], below the others
239253   kaneko16_priority.sprite[2] = 5;   // above all
240254   kaneko16_priority.sprite[3] = 7;   // ""
r5534r5535
791805                                Shogun Warriors
792806***************************************************************************/
793807
794/* Untested */
808/* Works for B-Rap Boys - untested with Shogun Warriors */
795809static WRITE16_HANDLER( shogwarr_oki_bank_w )
796810{
797811   if (ACCESSING_BITS_0_7)
798812   {
799      okim6295_set_bank_base(devtag_get_device(space->machine, "oki1"), 0x10000 * ((data >> 0) & 0x3) );
800      okim6295_set_bank_base(devtag_get_device(space->machine, "oki2"), 0x10000 * ((data >> 4) & 0x3) );
813      okim6295_set_bank_base(devtag_get_device(space->machine, "oki1"), 0x40000 * ((data >> 4) & 0xf));
814      okim6295_set_bank_base(devtag_get_device(space->machine, "oki2"), 0x40000 * (data & 0xf));
801815   }
802816}
803817
818extern void calc3_mcu_run(running_machine *machine);
819
820WRITE16_HANDLER(shogwarr_calc_w);
821READ16_HANDLER(shogwarr_calc_r);
822
823
804824static ADDRESS_MAP_START( shogwarr, ADDRESS_SPACE_PROGRAM, 16 )
805825   AM_RANGE(0x000000, 0x03ffff) AM_ROM      // ROM
806826   AM_RANGE(0x100000, 0x10ffff) AM_RAM AM_BASE(&kaneko16_mainram)      // Work RAM
r5534r5535
808828   AM_RANGE(0x280000, 0x280001) AM_WRITE(calc3_mcu_com0_w)
809829   AM_RANGE(0x290000, 0x290001) AM_WRITE(calc3_mcu_com1_w)
810830   AM_RANGE(0x2b0000, 0x2b0001) AM_WRITE(calc3_mcu_com2_w)
831   //AM_RANGE(0x2c0000, 0x2c0001) AM_WRITE(calc3_run) // guess, might be irqack
811832   AM_RANGE(0x2d0000, 0x2d0001) AM_WRITE(calc3_mcu_com3_w)
812833   AM_RANGE(0x380000, 0x380fff) AM_RAM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE(&paletteram16)   // Palette
813834   AM_RANGE(0x400000, 0x400001) AM_DEVREADWRITE8("oki1", okim6295_r, okim6295_w, 0x00ff)   // Samples
r5534r5535
819840   AM_RANGE(0x603000, 0x603fff) AM_RAM AM_BASE(&kaneko16_vscroll_0)
820841   AM_RANGE(0x800000, 0x80000f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE(&kaneko16_layers_0_regs)   // Layers 0 Regs
821842   AM_RANGE(0x900000, 0x90001f) AM_RAM_WRITE(kaneko16_sprites_regs_w) AM_BASE(&kaneko16_sprites_regs)   // Sprites Regs
822   AM_RANGE(0xa00014, 0xa00015) AM_READ(kaneko16_rnd_r)      // Random Number ?
843   AM_RANGE(0xa00000, 0xa0007f) AM_READWRITE(shogwarr_calc_r, shogwarr_calc_w)      // Random Number ?
823844   AM_RANGE(0xa80000, 0xa80001) AM_READWRITE(watchdog_reset16_r, watchdog_reset16_w)   // Watchdog
824845   AM_RANGE(0xb80000, 0xb80001) AM_READ_PORT("P1")
825846   AM_RANGE(0xb80002, 0xb80003) AM_READ_PORT("P2")
r5534r5535
827848   AM_RANGE(0xb80006, 0xb80007) AM_READ_PORT("UNK")
828849   AM_RANGE(0xd00000, 0xd00001) AM_NOP                     // ? (bit 0)
829850   AM_RANGE(0xe00000, 0xe00001) AM_WRITE(shogwarr_oki_bank_w)   // Samples Bankswitching
830
831   AM_RANGE(0xf00000, 0xffffff) AM_RAM AM_BASE(&kaneko16_calc3_fakeram) // I copy protection data tables here because I don't know where they really go.  NOT ON PCB
832851ADDRESS_MAP_END
833852
834853
r5534r5535
15661585INPUT_PORTS_END
15671586
15681587
1588static INPUT_PORTS_START( brapboys )
1589   PORT_START("P1")      /* b80000.w */
1590   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
1591   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
1592   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
1593   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
1594   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
1595   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
1596   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_START1 )
1597   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_COIN1 )
15691598
1599   PORT_START("P2")      /* b80002.w */
1600   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
1601   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
1602   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
1603   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
1604   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
1605   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
1606   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_START2 )
1607   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_COIN2 )
1608
1609   PORT_START("SYSTEM")   /* b80004.w */
1610   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(3)
1611   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(3)
1612   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(3)
1613   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(3)
1614   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(3)
1615   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(3)
1616   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_START3 )
1617   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_COIN3 )
1618
1619   PORT_START("UNK")      /* ? - b80006.w */
1620   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_UNKNOWN )
1621   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_UNKNOWN )
1622   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_UNKNOWN )
1623   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_UNKNOWN )
1624   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_UNKNOWN )
1625   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN )
1626   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
1627   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
1628
1629   PORT_START("DSW1")
1630   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Flip_Screen ) )   PORT_DIPLOCATION("SW1:1")
1631   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
1632   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1633   PORT_SERVICE_DIPLOC(0x02, IP_ACTIVE_LOW, "SW1:2" )
1634   PORT_DIPNAME( 0x04, 0x04, "Switch Test" )      PORT_DIPLOCATION("SW1:3")
1635   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
1636   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1637   PORT_DIPUNUSED_DIPLOC(0x08, 0x08, "SW1:4" )
1638   PORT_DIPNAME( 0x10, 0x10, "Coin Slots" )      PORT_DIPLOCATION("SW1:5")
1639   PORT_DIPSETTING(    0x10, "Separate Coins" )
1640   PORT_DIPSETTING(    0x00, "Shared Coins" )
1641   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Players ) )      PORT_DIPLOCATION("SW1:6")
1642   PORT_DIPSETTING(    0x20, "3" )
1643   PORT_DIPSETTING(    0x00, "2" )
1644   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Difficulty ) )   PORT_DIPLOCATION("SW1:7,8")
1645   PORT_DIPSETTING(    0x80, DEF_STR( Easy ) )
1646   PORT_DIPSETTING(    0xc0, DEF_STR( Normal ) )
1647   PORT_DIPSETTING(    0x40, DEF_STR( Hard ) )
1648   PORT_DIPSETTING(    0x00, DEF_STR( Very_Hard) )
1649
1650/*****************************************************
1651Difficulty    Lives      Bonus Players    Play Level
1652  Easy          3      every 1000 / 2000   Level 2
1653  Normal        2      every 2000 / 3000   Level 3
1654  Hard          2      every 3000 / 4000   Level 4
1655  Very Hard     1       --- NONE ---       Level 6
1656******************************************************/
1657
1658INPUT_PORTS_END
1659
1660
15701661/***************************************************************************
15711662
15721663
r5534r5535
19832074
19842075    other: busy loop
19852076*/
2077
19862078#define SHOGWARR_INTERRUPTS_NUM   3
19872079static INTERRUPT_GEN( shogwarr_interrupt )
19882080{
r5534r5535
19922084      case 1:  cpu_set_input_line(device, 3, HOLD_LINE); break;
19932085
19942086      // the code for this interupt is provided by the MCU..
1995      case 0:  cpu_set_input_line(device, 4, HOLD_LINE); break;
2087      case 0:  cpu_set_input_line(device, 4, HOLD_LINE);
2088
2089            calc3_mcu_run(device->machine);
2090      break;
19962091      /*case 0:
19972092        {
19982093            // hack, clear this ram address to get into test mode (interrupt would clear it)
r5534r5535
20052100   }
20062101}
20072102
2103/*
2104unsigned char shogwarr_default_eeprom[128] = {
2105    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2106    0x4B, 0x41, 0x4E, 0x45, 0x4B, 0x4F, 0x2F, 0x41, 0x54, 0x4F, 0x50, 0x20, 0x31, 0x39, 0x39, 0x32,
2107    0x46, 0x55, 0x4A, 0x49, 0xFF, 0xFF, 0x4D, 0x41, 0x20, 0x42, 0x55, 0x53, 0x54, 0x45, 0x52, 0x20,
2108    0x20, 0x53, 0x48, 0x4F, 0xFF, 0xFF, 0x4E, 0x20, 0x57, 0x41, 0x52, 0x52, 0x49, 0x4F, 0x52, 0x53,
2109    0xFF, 0xFF, 0x70, 0x79, 0x72, 0x69, 0xFF, 0xFF, 0x74, 0x20, 0x4B, 0x41, 0x4E, 0x45, 0x4B, 0x4F,
2110    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2111    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
2112    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF
2113};
2114*/
2115// the above eeprom looks corrupt, some of the text is wrong, the game never writes this text tho.. maybe it should be as below
2116// leaving both here incase they relate to which tables get 'locked out' by the MCU somehow
2117UINT8 shogwarr_default_eeprom[128] = {
2118   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2119   0x4B, 0x41, 0x4E, 0x45, 0x4B, 0x4F, 0x2F, 0x41, 0x54, 0x4F, 0x50, 0x20, 0x31, 0x39, 0x39, 0x32,
2120   0x46, 0x55, 0x4A, 0x49, 0x59, 0x41, 0x4D, 0x41, 0x20, 0x42, 0x55, 0x53, 0x54, 0x45, 0x52, 0x20,
2121   0x20, 0x53, 0x48, 0x4F, 0x47, 0x55, 0x4E, 0x20, 0x57, 0x41, 0x52, 0x52, 0x49, 0x4F, 0x52, 0x53,
2122   0x63, 0x6F, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0x4B, 0x41, 0x4E, 0x45, 0x4B, 0x4F,
2123   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2124   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
2125   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF
2126};
2127
2128UINT8 brapboys_default_eeprom[128] = {
2129   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2130   0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x20, 0x30, 0x00, 0x03, 0x68, 0x18, 0x01, 0x01, 0x01, 0x01,
2131   0x01, 0x01, 0x00, 0x01, 0x00, 0x04, 0x00, 0x08, 0x4B, 0x41, 0x4E, 0x45, 0x4B, 0x4F, 0x20, 0x20,
2132   0x42, 0x65, 0x20, 0x52, 0x61, 0x70, 0x20, 0x42, 0x6F, 0x79, 0x73, 0x00, 0x30, 0x30, 0x30, 0x2E,
2133   0x30, 0x38, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
2134   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
2135   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
2136   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x35, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
2137};
2138
2139static NVRAM_HANDLER( shogwarr )
2140{
2141   int isbrap = ( !strcmp(machine->gamedrv->name,"brapboysj") || !strcmp(machine->gamedrv->name,"brapboys"));
2142
2143   if (read_or_write)
2144      eeprom_save(file);
2145   else
2146   {
2147      eeprom_init(machine, &eeprom_interface_93C46);
2148
2149      if (file) eeprom_load(file);
2150      else
2151      {
2152         if (isbrap)
2153            eeprom_set_data(brapboys_default_eeprom,128);
2154         else
2155            eeprom_set_data(shogwarr_default_eeprom,128);
2156      }
2157   }
2158}
2159
20082160static MACHINE_DRIVER_START( shogwarr )
20092161
20102162   /* basic machine hardware */
r5534r5535
20202172   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
20212173   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
20222174   MDRV_SCREEN_SIZE(320, 240)
2023   MDRV_SCREEN_VISIBLE_AREA(40, 296-1, 0, 240-1)
2175   MDRV_SCREEN_VISIBLE_AREA(40, 296-1, 16, 240-1)
20242176
20252177   MDRV_GFXDECODE(1x4bit_1x4bit)
20262178   MDRV_PALETTE_LENGTH(2048)
r5534r5535
20282180   MDRV_VIDEO_START(kaneko16_1xVIEW2)
20292181   MDRV_VIDEO_UPDATE(kaneko16)
20302182
2183   MDRV_NVRAM_HANDLER(shogwarr)
2184
20312185   /* sound hardware */
20322186   MDRV_SPEAKER_STANDARD_MONO("mono")
20332187
r5534r5535
34703624    ROM_REGION( 0x020000, "cpu1", 0 )         /* MCU Code */
34713625   ROM_LOAD( "rb-040.u33",  0x000000, 0x020000, CRC(757c6e19) SHA1(0f1c37b1b1eb6b230c593e4648c4302f413a61f5) )
34723626
3473   ROM_REGION( 0x400000, "gfx1", 0 )   /* Sprites */
3474   /* order is probably wrong, but until it does more we can't tell */
3475   ROM_LOAD( "rb-020.u2",  0x000000, 0x080000, CRC(b038440e) SHA1(9e32cb62358ab846470d9a75d4dab771d608a3cf) )
3476   ROM_LOAD( "rb-025.u80", 0x080000, 0x040000, CRC(36cd6b90) SHA1(45c50f2652726ded67c9c24185a71a6367e09270) ) // Correct size for this set
3477//  ROM_LOAD( "rb-026.u5",  0x100000, 0x080000, CRC(bb7604d4) SHA1(57d51ce4ea2000f9a50bae326cfcb66ec494249f) ) // Not in World set
3627   ROM_REGION( 0x800000, "gfx1", 0 )   /* Sprites */
3628   ROM_LOAD( "rb-020.c2",  0x000000, 0x100000, CRC(ce220d38) SHA1(b88d7c89a3e1a826bf19a1fa692ec77c944596d9) )
3629   ROM_LOAD( "rb-021.u76", 0x100000, 0x100000, CRC(74001407) SHA1(90002056ceb4e0401246950b8c3f996af0a2463c) )
3630   ROM_LOAD( "rb-022.u77", 0x200000, 0x100000, CRC(cb3f42dc) SHA1(5415f15621924dd263b8fe7daaf3dc25d470b814) )
3631   ROM_LOAD( "rb-023.u78", 0x300000, 0x100000, CRC(0e6530c5) SHA1(72bff46f0672927e540f4f3546ae533dd0a231e0) )
3632   ROM_LOAD( "rb-024.u79", 0x400000, 0x080000, CRC(65fa6447) SHA1(551e540d7bf412753b4a7098e25e6f9d8774bcf4) ) // correct, both halves identical when dumped as larger
3633   ROM_LOAD( "rb-025.u80", 0x500000, 0x040000, CRC(36cd6b90) SHA1(45c50f2652726ded67c9c24185a71a6367e09270) ) // eprom, contains title logo for this version
34783634
3479   ROM_LOAD( "rb-021.u76", 0x200000, 0x080000, CRC(b7e2d362) SHA1(7e98e5b3d1ee972fc4cf9bebd33a3ca96a77357c) )
3480   ROM_LOAD( "rb-022.u77", 0x280000, 0x080000, CRC(8d40c97a) SHA1(353b0a4a508f2fff8eeed680b1f685c7fdc29a7d) ) // right pos. (text)
3481   ROM_LOAD( "rb-023.u78", 0x300000, 0x080000, CRC(dcf11c8d) SHA1(eed801f7cca3d3a941b1a4e4815cac9d20d970f7) )
3482   ROM_LOAD( "rb-024.u79", 0x380000, 0x080000, CRC(65fa6447) SHA1(551e540d7bf412753b4a7098e25e6f9d8774bcf4) )
3483
34843635   ROM_REGION( 0x400000, "gfx2", 0 )   /* Tiles (scrambled) */
34853636   ROM_LOAD( "rb-010.u65",  0x000000, 0x100000, CRC(ffd73f87) SHA1(1a661f71976be61c22d9b962850e738ba17f1d45) )
34863637   ROM_LOAD( "rb-011.u66",  0x100000, 0x100000, CRC(d9325f78) SHA1(346832608664aa8f3ac9260a549903386b4125a8) )
34873638   ROM_LOAD( "rb-012.u67",  0x200000, 0x100000, CRC(bfdbe0d1) SHA1(3abc5398ee8ee1871b4d081f9b748539d69bcdba) )
34883639   ROM_LOAD( "rb-013.u68",  0x300000, 0x100000, CRC(28c37fe8) SHA1(e10dd1a810983077328b44e6e33ce2e899c506d2) )
34893640
3490   ROM_REGION( 0x100000, "oki1", 0 )   /* Samples */
3491   /* Upper 128kB of M6295 address region is bank-switched? */
3641   ROM_REGION( 0x300000, "samples", 0 )
3642   /* OKI 1 */
34923643   ROM_LOAD( "rb-000.u43",  0x000000, 0x080000, CRC(58ad1a62) SHA1(1d2643b5f6eac22682972a88d284e00de3e3b223) )
34933644   ROM_LOAD( "rb-003.101",  0x080000, 0x080000, CRC(2cac25d7) SHA1(0412c317bf650a93051b9304d23035efde0c026a) )
34943645
3495   ROM_REGION( 0x200000, "oki2", 0 )   /* Samples */
3496   /* Upper 128kB of M6295 address region is bank-switched? */
3497   ROM_LOAD( "rb-001.u44",   0x000000, 0x100000, CRC(7cf774b3) SHA1(3fb0a5096ce9480f97e311439042eb8cbc26efb4) )
3498   ROM_LOAD( "rb-002.u45",   0x100000, 0x100000, CRC(e4b30444) SHA1(be6756dce3721226e0b7f5d4d168008c31aeea8e) )
3646   /* OKI 2 */
3647   ROM_LOAD( "rb-001.u44",  0x100000, 0x100000, CRC(7cf774b3) SHA1(3fb0a5096ce9480f97e311439042eb8cbc26efb4) )
3648   ROM_LOAD( "rb-002.u45",  0x200000, 0x100000, CRC(e4b30444) SHA1(be6756dce3721226e0b7f5d4d168008c31aeea8e) )
3649
3650   /* Sound data is copied here during driver init */
3651   ROM_REGION( 0x400000*16, "oki1", 0 )
3652   ROM_FILL(                0x00000, 0x400000*16, 0x00 )
3653
3654   ROM_REGION( 0x400000*16, "oki2", 0 )
3655   ROM_FILL(                0x00000, 0x400000*16, 0x00 )
34993656ROM_END
35003657
3658
35013659ROM_START( brapboysj ) /* The Japanese version has an extra rom??? and used a rom sub board */
35023660    ROM_REGION( 0x040000, "maincpu", 0 )         /* 68000 Code */
35033661   ROM_LOAD16_BYTE( "rb-004.u61", 0x000000, 0x020000, CRC(5432442c) SHA1(f0f7328ece96ef25e6d4fd1958d734f64a9ef371) )
r5534r5535
35063664    ROM_REGION( 0x020000, "cpu1", 0 )         /* MCU Code */
35073665   ROM_LOAD( "rb-006.u33",  0x000000, 0x020000, CRC(f1d76b20) SHA1(c571b5f28e529589ee2d7697ef5d4b60ccb66e7a) )
35083666
3509   ROM_REGION( 0x400000, "gfx1", 0 )   /* Sprites */
3510   /* order is probably wrong, but until it does more we can't tell */
3511   ROM_LOAD( "rb-020.u2",  0x000000, 0x080000, CRC(b038440e) SHA1(9e32cb62358ab846470d9a75d4dab771d608a3cf) )
3512   ROM_LOAD( "rb-025.u4",  0x080000, 0x080000, CRC(aa795ba5) SHA1(c5256dcceded2e76f548b60c18e51d0dd0209d81) )
3513   ROM_LOAD( "rb-026.u5",  0x100000, 0x080000, CRC(bb7604d4) SHA1(57d51ce4ea2000f9a50bae326cfcb66ec494249f) )
3667   ROM_REGION( 0x1000000, "gfx1", 0 )   /* Sprites */
3668   /* prety sure all these are at least half size */
3669   ROM_LOAD( "rb-020.c2",  0x000000, 0x100000, CRC(ce220d38) SHA1(b88d7c89a3e1a826bf19a1fa692ec77c944596d9) )
3670   ROM_LOAD( "rb-021.u76", 0x100000, 0x100000, CRC(74001407) SHA1(90002056ceb4e0401246950b8c3f996af0a2463c) )
3671   ROM_LOAD( "rb-022.u77", 0x200000, 0x100000, CRC(cb3f42dc) SHA1(5415f15621924dd263b8fe7daaf3dc25d470b814) )
3672   ROM_LOAD( "rb-023.u78", 0x300000, 0x100000, CRC(0e6530c5) SHA1(72bff46f0672927e540f4f3546ae533dd0a231e0) )
3673   ROM_LOAD( "rb-024.u79", 0x400000, 0x080000, CRC(65fa6447) SHA1(551e540d7bf412753b4a7098e25e6f9d8774bcf4) ) // correct, both halves identical when dumped as larger
3674   ROM_LOAD( "rb-025.u4",  0x500000, 0x080000, CRC(aa795ba5) SHA1(c5256dcceded2e76f548b60c18e51d0dd0209d81) ) // eprom, special title screen
3675   ROM_LOAD( "rb-026.u5",  0x580000, 0x080000, CRC(bb7604d4) SHA1(57d51ce4ea2000f9a50bae326cfcb66ec494249f) ) // eprom, logs that bounce past
35143676
3515   ROM_LOAD( "rb-021.u76", 0x200000, 0x080000, CRC(b7e2d362) SHA1(7e98e5b3d1ee972fc4cf9bebd33a3ca96a77357c) )
3516   ROM_LOAD( "rb-022.u77", 0x280000, 0x080000, CRC(8d40c97a) SHA1(353b0a4a508f2fff8eeed680b1f685c7fdc29a7d) ) // right pos. (text)
3517   ROM_LOAD( "rb-023.u78", 0x300000, 0x080000, CRC(dcf11c8d) SHA1(eed801f7cca3d3a941b1a4e4815cac9d20d970f7) )
3518   ROM_LOAD( "rb-024.u79", 0x380000, 0x080000, CRC(65fa6447) SHA1(551e540d7bf412753b4a7098e25e6f9d8774bcf4) )
35193677
35203678   ROM_REGION( 0x400000, "gfx2", 0 )   /* Tiles (scrambled) */
35213679   ROM_LOAD( "rb-010.u65",  0x000000, 0x100000, CRC(ffd73f87) SHA1(1a661f71976be61c22d9b962850e738ba17f1d45) )
r5534r5535
35233681   ROM_LOAD( "rb-012.u67",  0x200000, 0x100000, CRC(bfdbe0d1) SHA1(3abc5398ee8ee1871b4d081f9b748539d69bcdba) )
35243682   ROM_LOAD( "rb-013.u68",  0x300000, 0x100000, CRC(28c37fe8) SHA1(e10dd1a810983077328b44e6e33ce2e899c506d2) )
35253683
3526   ROM_REGION( 0x100000, "oki1", 0 )   /* Samples */
3527   /* Upper 128kB of M6295 address region is bank-switched? */
3684   ROM_REGION( 0x300000, "samples", 0 )
3685   /* OKI 1 */
35283686   ROM_LOAD( "rb-000.u43",  0x000000, 0x080000, CRC(58ad1a62) SHA1(1d2643b5f6eac22682972a88d284e00de3e3b223) )
35293687   ROM_LOAD( "rb-003.101",  0x080000, 0x080000, CRC(2cac25d7) SHA1(0412c317bf650a93051b9304d23035efde0c026a) )
35303688
3531   ROM_REGION( 0x200000, "oki2", 0 )   /* Samples */
3532   /* Upper 128kB of M6295 address region is bank-switched? */
3533   ROM_LOAD( "rb-001.u44",   0x000000, 0x100000, CRC(7cf774b3) SHA1(3fb0a5096ce9480f97e311439042eb8cbc26efb4) )
3534   ROM_LOAD( "rb-002.u45",   0x100000, 0x100000, CRC(e4b30444) SHA1(be6756dce3721226e0b7f5d4d168008c31aeea8e) )
3689   /* OKI 2 */
3690   ROM_LOAD( "rb-001.u44",  0x100000, 0x100000, CRC(7cf774b3) SHA1(3fb0a5096ce9480f97e311439042eb8cbc26efb4) )
3691   ROM_LOAD( "rb-002.u45",  0x200000, 0x100000, CRC(e4b30444) SHA1(be6756dce3721226e0b7f5d4d168008c31aeea8e) )
3692
3693   /* Sound data is copied here during driver init */
3694   ROM_REGION( 0x400000*16, "oki1", 0 )
3695   ROM_FILL(                0x00000, 0x400000*16, 0x00 )
3696
3697   ROM_REGION( 0x400000*16, "oki2", 0 )
3698   ROM_FILL(                0x00000, 0x400000*16, 0x00 )
35353699ROM_END
35363700
35373701/**********************************************************************
r5534r5535
36363800    //  MCU is a 78K series III type CPU
36373801}
36383802
3803static DRIVER_INIT( brapboys )
3804{
3805   /*
3806        Expand the OKI sample data
3807
3808        OKI 1:
3809        Address space 0x00000-0x2ffff is fixed
3810        Address space 0x30000-0x3ffff is banked (13 banks)
3811
3812        OKI 2:
3813        Address space 0x00000-0x1ffff is fixed
3814        Address space 0x20000-0x3ffff is banked (15 banks)
3815
3816        The current sound device implementation can't handle
3817        the banking dynamically so we have to expand all the bank
3818        combinations here and use use okim6295_set_bank_base().
3819    */
3820   int bank;
3821   UINT8 *src = memory_region(machine, "samples");
3822   UINT8 *dst1 = memory_region(machine, "oki1");
3823   UINT8 *dst2 = memory_region(machine, "oki2");
3824
3825   /* OKI 1 */
3826   for (bank = 0; bank < 13; ++bank)
3827   {
3828      UINT8 *dst;
3829      UINT8 *srcn;
3830
3831      dst = dst1 + 0x40000 * bank;
3832      srcn = src + 0x30000 + (0x10000 * bank);
3833      memcpy(dst, src, 0x30000);
3834      memcpy(dst + 0x30000, srcn, 0x10000);
3835   }
3836
3837   /* OKI 2 */
3838   for (bank = 0; bank < 15; ++bank)
3839   {
3840      UINT8 *dst;
3841      UINT8 *srcn;
3842      dst = dst2 + 0x40000 * bank;
3843      srcn = src + 0x120000 + (0x20000 * bank);
3844      memcpy(dst, src + 0x100000, 0x20000);
3845      memcpy(dst + 0x20000, srcn, 0x20000);
3846   }
3847
3848   DRIVER_INIT_CALL(calc3);
3849}
3850
3851
36393852/***************************************************************************
36403853
36413854
r5534r5535
36623875GAME( 1995, gtmr2,    0,        gtmr2,    gtmr2,    gtmr2, ROT0,  "Kaneko", "Mille Miglia 2: Great 1000 Miles Rally (95/05/24)", 0 )
36633876GAME( 1995, gtmr2a,   gtmr2,    gtmr2,    gtmr2,    gtmr2, ROT0,  "Kaneko", "Mille Miglia 2: Great 1000 Miles Rally (95/04/04)", 0 )
36643877GAME( 1995, gtmr2u,   gtmr2,    gtmr2,    gtmr2,    gtmr2, ROT0,  "Kaneko", "Great 1000 Miles Rally 2 USA (95/05/18)", 0 )
3878// some functionality of the protection chip still needs investigating on these, but they seem to be playable
3879GAME( 1992, brapboys, 0,        shogwarr, brapboys, brapboys,          ROT0,  "Kaneko", "B.Rap Boys (World)",      0 )
3880GAME( 1992, brapboysj,brapboys, shogwarr, brapboys, brapboys,          ROT0,  "Kaneko", "B.Rap Boys Special (Japan)",      0 )
36653881
36663882/* Non-working games (mainly due to protection) */
36673883
36683884GAME( 1992, shogwarr, 0,        shogwarr, shogwarr, calc3,   ROT0,  "Kaneko", "Shogun Warriors",         GAME_NOT_WORKING )
36693885GAME( 1992, shogwarre,shogwarr, shogwarr, shogwarr, calc3,   ROT0,  "Kaneko", "Shogun Warriors (Euro)",  GAME_NOT_WORKING )
36703886GAME( 1992, fjbuster, shogwarr, shogwarr, shogwarr, calc3,   ROT0,  "Kaneko", "Fujiyama Buster (Japan)", GAME_NOT_WORKING )
3671GAME( 1992, brapboys, 0,        shogwarr, shogwarr, calc3,          ROT0,  "Kaneko", "B.Rap Boys (World)",      GAME_NOT_WORKING )
3672GAME( 1992, brapboysj,brapboys, shogwarr, shogwarr, calc3,          ROT0,  "Kaneko", "B.Rap Boys Special (Japan)",      GAME_NOT_WORKING )
3887
src/mame/drivers/ampoker2.c
r5534r5535
876876   PORT_DIPNAME( 0x08, 0x08, "Rate Table SW1" ) PORT_DIPLOCATION("SW1:3") /* DSW3 (should be arranged with DSW4) */
877877   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
878878   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
879   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_POKER_HOLD2 )
879   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_POKER_HOLD3 )
880880
881881   PORT_START("IN6")
882882   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
src/mame/drivers/pgm.c
r5534r5535
4444120x  - 2001  - Knights of Valor 2 Plus (9 Dragons?)
4545130x  - 2001  - DoDonpachi II
4646
470450x - 2002  - Demon Front
470450x - 2002  - Demon Front (also known to be produced / sold in a single PCB version)
4848
4949---
5050
src/mame/drivers/megatech.c
r5534r5535
6565Out Run                    171-5783    837-6963-06       610-0239-06         MPR-11078      (Mask)        EPR-12368-06   (27256)   n/a
6666Alien Syndrome             171-5783    837-6963-07       610-0239-07         MPR-11194      (232011)      EPR-12368-07   (27256)   n/a
6767Afterburner                171-5784    837-6963-10       610-0239-10         315-5235       (custom)      MPR-11271-T    (834000)  EPR-12368-10 (27256)
68Great Football             171-5783    837-6963-19       610-0239-19         MPR-10576F     (831000)      EPR-12368-19   (27256)   n/a
69World Championship Soccer  171-5782    837-6963-21       610-0239-21         MPR-126078     (uPD23C4000)  EPR-12607B     (27256)   n/a
6870Tetris                     171-5834    837-6963-22       610-0239-22         MPR-12356F     (831000)      MPR-12357F     (831000)  EPR-12368-22 (27256)
69World Championship Soccer  171-5782    837-6963-21       610-0239-21         MPR-126078     (uPD23C4000)  EPR-12607B     (27256)   n/a
7071Ghouls & Ghosts            171-5869A   -                 610-0239-23         MPR-12605      (40 pins)     MPR-12606      (40 pins) EPR-12368-23 (27256)
7172Super Hang On              171-5782    837-6963-24       610-0239-24         MPR-12640      (234000)      EPR-12368-24   (27256)   n/a
7273Forgotten Worlds           171-5782    837-6963-26       610-0239-26         MPR-12672-H    (Mask)        EPR-12368-26   (27256)   n/a
r5534r5535
684685   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
685686   ROM_LOAD16_WORD_SWAP( "mp12538.ic1", 0x000000, 0x080000, CRC(3bea3dce) SHA1(ec72e4fde191dedeb3f148f132603ed3c23f0f86) ) \
686687    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
687    ROM_LOAD( "12368-01.ic2", 0x000000, 0x08000, CRC(40cb0088) SHA1(e1711532c29f395a35a1cb34d789015881b5a1ed) ) \
688    ROM_LOAD( "epr-12368-01.ic2", 0x000000, 0x08000, CRC(40cb0088) SHA1(e1711532c29f395a35a1cb34d789015881b5a1ed) ) \
688689
689690ROM_START( mt_beast ) /* Altered Beast */
690691   MEGATECH_BIOS
r5534r5535
696697   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
697698   ROM_LOAD16_WORD_SWAP( "mp11934.ic1", 0x000000, 0x080000, CRC(932daa09) SHA1(a2d7a76f3604c6227d43229908bfbd02b0ef5fd9) ) \
698699    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
699   ROM_LOAD( "12368-02.ic2", 0x000000, 0x08000, CRC(c129c66c) SHA1(e7c0c97db9df9eb04e2f9ff561b64305219b8f1f) ) \
700   ROM_LOAD( "epr-12368-02.ic2", 0x000000, 0x08000, CRC(c129c66c) SHA1(e7c0c97db9df9eb04e2f9ff561b64305219b8f1f) ) \
700701
701702ROM_START( mt_shar2 ) /* Space Harrier 2 */
702703   MEGATECH_BIOS
r5534r5535
708709   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
709710   ROM_LOAD16_WORD_SWAP( "mp11996f.ic1", 0x000000, 0x080000,  CRC(9355c34e) SHA1(26ff91c2921408673c644b0b1c8931d98524bf63) ) \
710711    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
711   ROM_LOAD( "12368-03.ic2", 0x000000, 0x08000,  CRC(1ba4ac5d) SHA1(9bde57d70189d159ebdc537a9026001abfd0deae) ) \
712   ROM_LOAD( "epr-12368-03.ic2", 0x000000, 0x08000,  CRC(1ba4ac5d) SHA1(9bde57d70189d159ebdc537a9026001abfd0deae) ) \
712713
713714ROM_START( mt_stbld ) /* Super Thunder Blade */
714715   MEGATECH_BIOS
r5534r5535
720721   ROM_REGION( 0x300000, GAME_REGION, 0 ) \
721722   ROM_LOAD( "mp11129f.ic1", 0x000000, 0x020000, CRC(c6611c84) SHA1(eab0eed872dd26b13bcf0b2dd74fcbbc078812c9) ) \
722723    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_SMS ) \
723   ROM_LOAD( "12368-04.ic2", 0x000000, 0x08000, CRC(62e5579b) SHA1(e1f531be5c40a1216d4192baeda9352384444410) ) \
724   ROM_LOAD( "epr-12368-04.ic2", 0x000000, 0x08000, CRC(62e5579b) SHA1(e1f531be5c40a1216d4192baeda9352384444410) ) \
724725   /* Also known to have the ID# MPR-11128 instead of MPR-11129F, same contents */
725726
726727ROM_START( mt_ggolf ) /* Great Golf */
r5534r5535
733734   ROM_REGION( 0x300000, GAME_REGION, 0 ) \
734735   ROM_LOAD( "mp10747f.ic1", 0x000000, 0x020000, BAD_DUMP CRC(9cf53703) SHA1(c6b4d1de56bd5bf067ec7fc80449c07686d01337) ) \
735736    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_SMS ) \
736   ROM_LOAD( "12368-05.ic2", 0x000000, 0x08000, CRC(bab91fcc) SHA1(a160c9d34b253e93ac54fdcef33f95f44d8fa90c) ) \
737   ROM_LOAD( "epr-12368-05.ic2", 0x000000, 0x08000, CRC(bab91fcc) SHA1(a160c9d34b253e93ac54fdcef33f95f44d8fa90c) ) \
737738
738739ROM_START( mt_gsocr ) /* Great Soccer */
739740   MEGATECH_BIOS
r5534r5535
769770   ROM_REGION( 0x300000, GAME_REGION, 0 ) \
770771   ROM_LOAD( "mp11706.ic1", 0x000000, 0x040000, CRC(0C6FAC4E) SHA1(7C0778C055DC9C2B0AAE1D166DBDB4734E55B9D1) ) \
771772    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_SMS ) \
772   ROM_LOAD( "12368-08.ic2", 0x000000, 0x08000, CRC(103A0459) SHA1(D803DDF7926B83785E8503C985B8C78E7CCB5DAC) ) \
773   ROM_LOAD( "epr-12368-08.ic2", 0x000000, 0x08000, CRC(103A0459) SHA1(D803DDF7926B83785E8503C985B8C78E7CCB5DAC) ) \
773774
774775ROM_START( mt_shnbi ) /* Shinobi */
775776   MEGATECH_BIOS
r5534r5535
781782   ROM_REGION( 0x300000, GAME_REGION, 0 ) \
782783   ROM_LOAD( "mp11271.ic1", 0x000000, 0x080000, CRC(1C951F8E) SHA1(51531DF038783C84640A0CAB93122E0B59E3B69A) ) \
783784    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_SMS ) \
784   ROM_LOAD( "12368-10.ic2", 0x000000, 0x08000, CRC(2A7CB590) SHA1(2236963BDDC89CA9045B530259CC7B5CCF889EAF) ) \
785   ROM_LOAD( "epr-12368-10.ic2", 0x000000, 0x08000, CRC(2A7CB590) SHA1(2236963BDDC89CA9045B530259CC7B5CCF889EAF) ) \
785786
786787ROM_START( mt_aftrb ) /* Afterburner */
787788   MEGATECH_BIOS
r5534r5535
793794   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
794795   ROM_LOAD16_WORD_SWAP( "mp12559.ic1", 0x000000, 0x080000, CRC(b093bee3) SHA1(0bf6194c3d228425f8cf1903ed70d8da1b027b6a) ) \
795796    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
796   ROM_LOAD( "12368-11.ic2", 0x000000, 0x08000, CRC(f4f27e8d) SHA1(ae1a2823deb416c53838115966f1833d5dac72d4) ) \
797   ROM_LOAD( "epr-12368-11.ic2", 0x000000, 0x08000, CRC(f4f27e8d) SHA1(ae1a2823deb416c53838115966f1833d5dac72d4) ) \
797798
798799ROM_START( mt_tfor2 ) /* Thunder Force 2 */
799800   MEGATECH_BIOS
r5534r5535
805806   ROM_REGION( 0x300000, GAME_REGION, 0 ) \
806807   ROM_LOAD( "ep13817.ic2", 0x000000, 0x20000, CRC(299cbb74) SHA1(901697a3535ad70190647f34ad5b30b695d54542) ) \
807808    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_SMS ) \
808   ROM_LOAD( "12368-13.ic1", 0x000000, 0x08000,  CRC(4038cbd1) SHA1(696bc1efce45d9f0052b2cf0332a232687c8d6ab) ) \
809   ROM_LOAD( "epr-12368-13.ic1", 0x000000, 0x08000,  CRC(4038cbd1) SHA1(696bc1efce45d9f0052b2cf0332a232687c8d6ab) ) \
809810
810811ROM_START( mt_astro ) /* Astro Warrior */
811812   MEGATECH_BIOS
812813   MEGATECH_GAME13("game0", "inst0")
813814ROM_END
814815
816/* Game 19 - Great Football (SMS) */
817#define MEGATECH_GAME19(GAME_REGION, INSTRUCTION_REGION) \
818   ROM_REGION( 0x300000, GAME_REGION, 0 ) \
819   ROM_LOAD( "mpr-10576f.ic1", 0x000000, 0x020000, CRC(2055825f) SHA1(a768f44ce7e50083ffe8c4b5e3ac93ceb7bd3266) ) \
820    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_SMS ) \
821   ROM_LOAD( "epr-12368-19.ic2", 0x000000, 0x08000, CRC(e27cb37a) SHA1(2b6259957e86d033a5689fd716a9efcfeff7d5ba) ) \
822
823ROM_START( mt_gfoot ) /* Great Football */
824   MEGATECH_BIOS
825   MEGATECH_GAME19("game0", "inst0")
826ROM_END
827
815828/* Game 20 - Last Battle */
816829#define MEGATECH_GAME20(GAME_REGION, INSTRUCTION_REGION) \
817830   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
818831   ROM_LOAD16_WORD_SWAP( "mp12578f.ic1", 0x000000, 0x080000, CRC(531191a0) SHA1(f6bc26e975c01a3e10ab4033e4c5f494627a1e2f) ) \
819832    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
820   ROM_LOAD( "12368-20.ic2", 0x000000, 0x08000, CRC(e1a71c91) SHA1(c250da18660d8aea86eb2abace41ba46130dabc8) ) \
833   ROM_LOAD( "epr-12368-20.ic2", 0x000000, 0x08000, CRC(e1a71c91) SHA1(c250da18660d8aea86eb2abace41ba46130dabc8) ) \
821834
822835ROM_START( mt_lastb ) /* Last Battle */
823836   MEGATECH_BIOS
r5534r5535
829842   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
830843   ROM_LOAD16_WORD_SWAP( "mp12607b.ic1", 0x000000, 0x080000, CRC(bc591b30) SHA1(55e8577171c0933eee53af1dabd0f4c6462d5fc8) ) \
831844    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
832   ROM_LOAD( "12368-21.ic2", 0x000000, 0x08000, CRC(028ee46b) SHA1(cd8f81d66e5ae62107eb20e0ca5db4b66d4b2987) ) \
845   ROM_LOAD( "epr-12368-21.ic2", 0x000000, 0x08000, CRC(028ee46b) SHA1(cd8f81d66e5ae62107eb20e0ca5db4b66d4b2987) ) \
833846
834847ROM_START( mt_wcsoc ) /* World Championship Soccer */
835848   MEGATECH_BIOS
r5534r5535
842855   ROM_LOAD16_BYTE( "mpr-12356f.ic1", 0x000001, 0x020000, CRC(1e71c1a0) SHA1(44b2312792e49d46d71e0417a7f022e5ffddbbfe) ) \
843856   ROM_LOAD16_BYTE( "mpr-12357f.ic2", 0x000000, 0x020000, CRC(d52ca49c) SHA1(a9159892eee2c0cf28ebfcfa99f81f80781851c6) ) \
844857    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
845   ROM_LOAD( "12368-22.ic3", 0x000000, 0x08000, CRC(1c1b6468) SHA1(568a38f4186167486e39ab4aa2c1ceffd0b81156) ) \
858   ROM_LOAD( "epr-12368-22.ic3", 0x000000, 0x08000, CRC(1c1b6468) SHA1(568a38f4186167486e39ab4aa2c1ceffd0b81156) ) \
846859
847860ROM_START( mt_tetri ) /* Tetris */
848861   MEGATECH_BIOS
r5534r5535
856869   ROM_LOAD16_WORD_SWAP( "mpr12606.ic2", 0x080000, 0x020000, CRC(D0BE7777) SHA1(A44B2A3D427F6973B5C1A3DCD8D1776366ACB9F7) ) \
857870   ROM_CONTINUE(0x020000,0x60000) \
858871    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
859   ROM_LOAD( "12368-23.ic3", 0x000000, 0x08000, CRC(7ee58546) SHA1(ad5bb0934475eacdc5e354f67c96fe0d2512d33b) ) \
872   ROM_LOAD( "epr-12368-23.ic3", 0x000000, 0x08000, CRC(7ee58546) SHA1(ad5bb0934475eacdc5e354f67c96fe0d2512d33b) ) \
860873
861874ROM_START( mt_gng ) /* Ghouls and Ghosts */
862875   MEGATECH_BIOS
r5534r5535
880893   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
881894   ROM_LOAD16_WORD_SWAP( "12806.ic1", 0x000000, 0x080000, CRC(43456820) SHA1(2f7f1fcd979969ac99426f11ab99999a5494a121) ) \
882895    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
883   ROM_LOAD( "12368-25.ic2", 0x000000, 0x08000, CRC(1f07ed28) SHA1(9d54192f4c6c1f8a51c38a835c1dd1e4e3e8279e) ) \
896   ROM_LOAD( "epr-12368-25.ic2", 0x000000, 0x08000, CRC(1f07ed28) SHA1(9d54192f4c6c1f8a51c38a835c1dd1e4e3e8279e) ) \
884897
885898ROM_START( mt_gaxe ) /* Golden Axe */
886899   MEGATECH_BIOS
r5534r5535
905918   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
906919   ROM_LOAD16_WORD_SWAP( "mp12707.1", 0x000000, 0x080000, CRC(4f2c513d) SHA1(f9bb548b3688170fe18bb3f1b5b54182354143cf) ) \
907920    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
908   ROM_LOAD( "12368-27.ic2", 0x000000, 0x08000, CRC(caf46f78) SHA1(a9659e86a6a223646338cd8f29c346866e4406c7) ) \
921   ROM_LOAD( "epr-12368-27.ic2", 0x000000, 0x08000, CRC(caf46f78) SHA1(a9659e86a6a223646338cd8f29c346866e4406c7) ) \
909922
910923ROM_START( mt_mystd ) /* Mystic Defender */
911924   MEGATECH_BIOS
r5534r5535
917930   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
918931   ROM_LOAD16_WORD_SWAP( "mp12675.ic1", 0x000000, 0x080000, CRC(672A1D4D) SHA1(5FD0AF14C8F2CF8CEAB1AE61A5A19276D861289A) ) \
919932    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
920   ROM_LOAD( "12368-28.ic2", 0x000000, 0x08000, CRC(0D30BEDE) SHA1(73A090D84B78A570E02FB54A33666DCADA52849B) ) \
933   ROM_LOAD( "epr-12368-28.ic2", 0x000000, 0x08000, CRC(0D30BEDE) SHA1(73A090D84B78A570E02FB54A33666DCADA52849B) ) \
921934
922935ROM_START( mt_revsh ) /* The Revenge Of Shinobi */
923936   MEGATECH_BIOS
r5534r5535
929942   ROM_REGION( 0x300000, GAME_REGION, 0 ) \
930943   ROM_LOAD( "mp11404.ic1", 0x000000, 0x020000, CRC(E030E66C) SHA1(06664DAF208F07CB00B603B12ECCFC3F01213A17) ) \
931944    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_SMS ) \
932   ROM_LOAD( "12368-29.ic2", 0x000000, 0x08000, CRC(534151e8) SHA1(219238d90c1d3ac07ff64c9a2098b490fff68f04) ) \
945   ROM_LOAD( "epr-12368-29.ic2", 0x000000, 0x08000, CRC(534151e8) SHA1(219238d90c1d3ac07ff64c9a2098b490fff68f04) ) \
933946
934947ROM_START( mt_parlg ) /* Parlour Games */
935948   MEGATECH_BIOS
r5534r5535
941954   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
942955   ROM_LOAD16_WORD_SWAP( "mp12645f.ic1", 0x000000, 0x080000, CRC(c07ef8d2) SHA1(9d111fdc7bb92d52bfa048cd134aa488b4f475ef) ) \
943956    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
944   ROM_LOAD( "12368-31.ic2", 0x000000, 0x08000, CRC(30af7e4a) SHA1(baf91d527393dc90aba9371abcb1e690bcc83c7e) ) \
957   ROM_LOAD( "epr-12368-31.ic2", 0x000000, 0x08000, CRC(30af7e4a) SHA1(baf91d527393dc90aba9371abcb1e690bcc83c7e) ) \
945958
946959ROM_START( mt_tgolf ) /* Arnold Palmer Tournament Golf */
947960   MEGATECH_BIOS
r5534r5535
966979   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
967980   ROM_LOAD16_WORD_SWAP( "mp12706.ic1", 0x000000, 0x080000, CRC(8901214f) SHA1(f5ec166be1cf9b86623b9d7a78ec903b899da32a) ) \
968981    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
969   ROM_LOAD( "12368-35.ic2", 0x000000, 0x08000, CRC(67bbe482) SHA1(6fc283b22e68befabb44b2cc61a7f82a71d6f029) ) \
982   ROM_LOAD( "epr-12368-35.ic2", 0x000000, 0x08000, CRC(67bbe482) SHA1(6fc283b22e68befabb44b2cc61a7f82a71d6f029) ) \
970983
971984ROM_START( mt_tlbba ) /* Tommy Lasorda Baseball */
972985   MEGATECH_BIOS
r5534r5535
978991   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
979992   ROM_LOAD16_WORD_SWAP( "mp13193-t.ic1", 0x000000, 0x080000, CRC(8c770e2f) SHA1(02a3626025c511250a3f8fb3176eebccc646cda9) ) \
980993    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
981   ROM_LOAD( "ep12368-36.ic3", 0x000000, 0x08000,  CRC(a4b29bac) SHA1(c9be866ac96243897d09612fe17562e0481f66e3) ) \
994   ROM_LOAD( "epr-12368-36.ic3", 0x000000, 0x08000,  CRC(a4b29bac) SHA1(c9be866ac96243897d09612fe17562e0481f66e3) ) \
982995
983996ROM_START( mt_cols ) /* Columns */
984997   MEGATECH_BIOS
r5534r5535
9901003   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
9911004   ROM_LOAD16_WORD_SWAP( "mp13192-h.ic1", 0x000000, 0x080000, CRC(82f458ef) SHA1(58444b783312def71ecffc4ad021b72a609685cb) ) \
9921005    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
993   ROM_LOAD( "12368-38.ic2", 0x000000, 0x08000, CRC(43c5529b) SHA1(104f85adea6da1612c0aa96d553efcaa387d7aaf) ) \
1006   ROM_LOAD( "epr-12368-38.ic2", 0x000000, 0x08000, CRC(43c5529b) SHA1(104f85adea6da1612c0aa96d553efcaa387d7aaf) ) \
9941007
9951008ROM_START( mt_eswat ) /* ESWAT */
9961009   MEGATECH_BIOS
r5534r5535
10021015   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
10031016   ROM_LOAD16_WORD_SWAP( "13250.ic1", 0x000000, 0x080000, CRC(189b885f) SHA1(31c06ffcb48b1604989a94e584261457de4f1f46) ) \
10041017    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
1005   ROM_LOAD( "12368-39.ic2", 0x000000, 0x08000, CRC(64b3ce25) SHA1(83a9f2432d146a712b037f96f261742f7dc810bb) ) \
1018   ROM_LOAD( "epr-12368-39.ic2", 0x000000, 0x08000, CRC(64b3ce25) SHA1(83a9f2432d146a712b037f96f261742f7dc810bb) ) \
10061019
10071020ROM_START( mt_smgp ) /* Super Monaco Grand Prix */
10081021   MEGATECH_BIOS
r5534r5535
10141027   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
10151028   ROM_LOAD16_WORD_SWAP( "mp13285a.ic1", 0x000000, 0x080000, CRC(189516e4) SHA1(2a79e07da2e831832b8d448cae87a833c85e67c9) ) \
10161029    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
1017   ROM_LOAD( "12368-40.ic2", 0x000000, 0x08000, CRC(0482378c) SHA1(734772f3ddb5ff82b76c3514d18a464b2bce8381) ) \
1030   ROM_LOAD( "epr-12368-40.ic2", 0x000000, 0x08000, CRC(0482378c) SHA1(734772f3ddb5ff82b76c3514d18a464b2bce8381) ) \
10181031
10191032ROM_START( mt_mwalk ) /* Moon Walker */
10201033   MEGATECH_BIOS
r5534r5535
10261039   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
10271040   ROM_LOAD16_WORD_SWAP( "mp13578a-s.ic1", 0x000000, 0x080000, CRC(23f19893) SHA1(09aca793871e2246af4dc24925bc1eda8ff34446) ) \
10281041    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
1029   ROM_LOAD( "ep12368-41.ic2", 0x000000, 0x08000, CRC(3014acec) SHA1(07953e9ae5c23fc7e7d08993b215f4dfa88aa5d7) ) \
1042   ROM_LOAD( "epr-12368-41.ic2", 0x000000, 0x08000, CRC(3014acec) SHA1(07953e9ae5c23fc7e7d08993b215f4dfa88aa5d7) ) \
10301043
10311044ROM_START( mt_crack ) /* Crackdown */
10321045   MEGATECH_BIOS
r5534r5535
10501063   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
10511064   ROM_LOAD16_WORD_SWAP( "mpr13396h.ic1", 0x000000, 0x080000, CRC(091226e3) SHA1(cb15c6277314f3c4a86b5ae5823f72811d5d269d) ) \
10521065    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
1053   ROM_LOAD( "epr12368-44.ic2", 0x000000, 0x08000, CRC(e653065d) SHA1(96b014fc4df8eb2188ac94ed0a778d974fe6dcad) ) \
1066   ROM_LOAD( "epr-12368-44.ic2", 0x000000, 0x08000, CRC(e653065d) SHA1(96b014fc4df8eb2188ac94ed0a778d974fe6dcad) ) \
10541067
10551068ROM_START( mt_arrow ) /* Arrow Flash */
10561069   MEGATECH_BIOS
r5534r5535
10621075   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
10631076   ROM_LOAD16_WORD_SWAP( "mp13941.ic1", 0x000000, 0x080000, CRC(D71B3EE6) SHA1(05F272DAD243D132D517C303388248DC4C0482ED) ) \
10641077    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
1065   ROM_LOAD( "12368-47.ic2", 0x000000, 0x08000, CRC(31FB683D) SHA1(E356DA020BBF817B97FB10C27F75CF5931EDF4FC) ) \
1078   ROM_LOAD( "epr-12368-47.ic2", 0x000000, 0x08000, CRC(31FB683D) SHA1(E356DA020BBF817B97FB10C27F75CF5931EDF4FC) ) \
10661079
10671080ROM_START( mt_astrm ) /* Alien Storm */
10681081   MEGATECH_BIOS
r5534r5535
10741087   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
10751088   ROM_LOAD16_WORD_SWAP( "mpr-14025-f.ic1", 0x000000, 0x080000, CRC(26e899fe) SHA1(6d28e154ae2e4196097a2aa96c5acd5dfe7e3d2b) ) \
10761089    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
1077   ROM_LOAD( "12368-48.ic2", 0x000000, 0x08000, CRC(25817bc2) SHA1(ba1bbb952aff12fb4d3ecfb10d82c54128439395) ) \
1090   ROM_LOAD( "epr-12368-48.ic2", 0x000000, 0x08000, CRC(25817bc2) SHA1(ba1bbb952aff12fb4d3ecfb10d82c54128439395) ) \
10781091
10791092ROM_START( mt_wwar ) /* Wrestle War */
10801093   MEGATECH_BIOS
r5534r5535
10861099   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
10871100   ROM_LOAD16_WORD_SWAP( "mp13905a.ic1", 0x000000, 0x100000, CRC(68a88d60) SHA1(2f56e8a2b0999de4fa0d14a1527f4e1df0f9c7a2) ) \
10881101    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
1089   ROM_LOAD( "12368-49.ic2", 0x000000, 0x08000, CRC(c5101da2) SHA1(636f30043e2e9291e193ef9a2ead2e97a0bf7380) ) \
1102   ROM_LOAD( "epr-12368-49.ic2", 0x000000, 0x08000, CRC(c5101da2) SHA1(636f30043e2e9291e193ef9a2ead2e97a0bf7380) ) \
10901103
10911104ROM_START( mt_bbros ) /* Bonanza Bros. */
10921105   MEGATECH_BIOS
r5534r5535
11101123   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
11111124   ROM_LOAD16_WORD_SWAP( "mp13913.ic1", 0x000000, 0x080000, CRC(480b4b5c) SHA1(ab1dc1f738e3b2d0898a314b123fa71182bf572e) ) \
11121125    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
1113   ROM_LOAD( "12368-52.ic2", 0x0000, 0x8000,  CRC(6a69d20c) SHA1(e483b39ff6eca37dc192dc296d004049e220554a) ) \
1126   ROM_LOAD( "epr-12368-52.ic2", 0x0000, 0x8000,  CRC(6a69d20c) SHA1(e483b39ff6eca37dc192dc296d004049e220554a) ) \
11141127
11151128ROM_START( mt_sonic ) /* Sonic The Hedgehog */
11161129   MEGATECH_BIOS
r5534r5535
11211134   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
11221135   ROM_LOAD16_WORD_SWAP( "mp13933.ic1", 0x000000, 0x080000, CRC(13775004) SHA1(5decfd35944a2d0e7b996b9a4a12b616a309fd5e) ) \
11231136    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
1124   ROM_LOAD( "12368-52.ic2", 0x0000, 0x8000,  CRC(6a69d20c) SHA1(e483b39ff6eca37dc192dc296d004049e220554a) ) \
1137   ROM_LOAD( "epr-12368-52.ic2", 0x0000, 0x8000,  CRC(6a69d20c) SHA1(e483b39ff6eca37dc192dc296d004049e220554a) ) \
11251138
11261139ROM_START( mt_sonia ) /* Sonic (alt)*/
11271140   MEGATECH_BIOS
r5534r5535
11331146   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
11341147   ROM_LOAD16_WORD_SWAP( "mp14341.ic1", 0x000000, 0x080000, CRC(04d65ebc) SHA1(24338aecdc52b6f416548be722ca475c83dbae96) ) \
11351148    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
1136   ROM_LOAD( "12368-53.ic2", 0x000000, 0x08000,  CRC(4fa61044) SHA1(7810deea221c10b0b2f5233443d81f4f1998ee58) ) \
1149   ROM_LOAD( "epr-12368-53.ic2", 0x000000, 0x08000,  CRC(4fa61044) SHA1(7810deea221c10b0b2f5233443d81f4f1998ee58) ) \
11371150
11381151   /* alt version with these roms exists, but the content is the same */
11391152   /* (6a221fd6) ep14706.ic1             mp14341.ic1  [even]     IDENTICAL */
r5534r5535
11491162   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
11501163   ROM_LOAD16_WORD_SWAP( "mp14272.ic1", 0x000000, 0x080000, CRC(d4784cae) SHA1(b6c286027d06fd850016a2a1ee1f1aeea080c3bb) ) \
11511164    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
1152   ROM_LOAD( "12368-57.ic2", 0x000000, 0x08000, CRC(dc9b4433) SHA1(efd3a598569010cdc4bf38ecbf9ed1b4e14ffe36) ) \
1165   ROM_LOAD( "epr-12368-57.ic2", 0x000000, 0x08000, CRC(dc9b4433) SHA1(efd3a598569010cdc4bf38ecbf9ed1b4e14ffe36) ) \
11531166
11541167ROM_START( mt_gaxe2 ) /* Golden Axe 2 */
11551168   MEGATECH_BIOS
r5534r5535
11611174   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
11621175   ROM_LOAD16_WORD_SWAP( "mp14356a-f.ic1", 0x000000, 0x100000, CRC(20cf32f6) SHA1(752314346a7a98b3808b3814609e024dc0a4108c) ) \
11631176    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
1164   ROM_LOAD( "ep12368-58.ic2", 0x000000, 0x08000, CRC(dce2708e) SHA1(fcebb1899ee11468f6bda705899f074e7de9d723) ) \
1177   ROM_LOAD( "epr-12368-58.ic2", 0x000000, 0x08000, CRC(dce2708e) SHA1(fcebb1899ee11468f6bda705899f074e7de9d723) ) \
11651178
11661179ROM_START( mt_stf ) /* Sports Talk Football */
11671180   MEGATECH_BIOS
r5534r5535
11851198   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
11861199   ROM_LOAD16_WORD_SWAP( "mp14557.ic1", 0x000000, 0x100000, CRC(e1a889a4) SHA1(a2768eacafc47d371e5276f0cce4b12b6041337a) ) \
11871200    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
1188   ROM_LOAD( "12368-60.ic2", 0x000000, 0x08000, CRC(a8e4af18) SHA1(dfa49f6ec4047718f33dba1180f6204dbaff884c) ) \
1201   ROM_LOAD( "epr-12368-60.ic2", 0x000000, 0x08000, CRC(a8e4af18) SHA1(dfa49f6ec4047718f33dba1180f6204dbaff884c) ) \
11891202
11901203ROM_START( mt_kcham ) /* Kid Chameleon */
11911204   MEGATECH_BIOS
r5534r5535
11971210   ROM_REGION16_BE( 0x300000, GAME_REGION, 0 ) \
11981211   ROM_LOAD16_WORD_SWAP( "mp15000a-f.ic1", 0x000000, 0x100000, CRC(679ebb49) SHA1(557482064677702454562f753460993067ef9e16) ) \
11991212    MEGATECH_INSTRUCTION_REGION( INSTRUCTION_REGION, MEGATECH_GAME_IS_GEN ) \
1200   ROM_LOAD( "ep12368-62.ic2", 0x000000, 0x08000, CRC(14a8566f) SHA1(d1d14162144bf068ddd19e9736477ff98fb43f9e) ) \
1213   ROM_LOAD( "epr-12368-62.ic2", 0x000000, 0x08000, CRC(14a8566f) SHA1(d1d14162144bf068ddd19e9736477ff98fb43f9e) ) \
12011214
12021215ROM_START( mt_soni2 ) /* Sonic The Hedgehog 2 */
12031216   MEGATECH_BIOS
r5534r5535
12521265/* 16 */ // unknown
12531266/* 17 */ // unknown
12541267/* 18 */ // unknown
1255/* 19 */ // unknown
1268/* 19 */ GAME( 1987, mt_gfoot, megatech, megatech, megatech, mtnew, ROT0, "Sega",                  "Great Football (Mega-Tech, SMS based)", GAME_NOT_WORKING ) /* sms! */
12561269/* 20 */ GAME( 1989, mt_lastb, megatech, megatech, megatech, mtnew, ROT0, "Sega",                  "Last Battle (Mega-Tech)", GAME_NOT_WORKING )
12571270/* 21 */ GAME( 1989, mt_wcsoc, megatech, megatech, megatech, mtnew, ROT0, "Sega",                  "World Championship Soccer (Mega-Tech)", GAME_NOT_WORKING )
12581271/* 22 */ GAME( 1989, mt_tetri, megatech, megatech, megatech, mtnew, ROT0, "Sega",                  "Tetris (Mega-Tech)", GAME_NOT_WORKING )
r5534r5535
12951308/* 58 */ GAME( 1991, mt_stf,   megatech, megatech, megatech, mtnew, ROT0, "Sega",                  "Joe Montana II: Sports Talk Football (Mega-Tech)", GAME_NOT_WORKING )
12961309/* 59 */ GAME( 1991, mt_mlh,   megatech, megatech, megatech, mtnew, ROT0, "Sega",                  "Mario Lemieux Hockey (Mega-Tech)", GAME_NOT_WORKING )
12971310/* 60 */ GAME( 1992, mt_kcham, megatech, megatech, megatech, mtnew, ROT0, "Sega",                  "Kid Chameleon (Mega-Tech)", GAME_NOT_WORKING )
1298/* 61 */ // unknown
1311/* 61 */ // Turbo Outrun
12991312/* 62 */ GAME( 1992, mt_soni2, megatech, megatech, megatech, mtnew, ROT0, "Sega",                  "Sonic The Hedgehog 2 (Mega-Tech)", GAME_NOT_WORKING )
13001313
13011314/* more? */
src/mame/drivers/dwarfd.c
r5534r5535
529529   return 0;
530530}
531531
532static void dwarfd_sod_callback(const device_config *device, int nSO)
532static WRITE_LINE_DEVICE_HANDLER( dwarfd_sod_callback )
533533{
534   crt_access=nSO;
534   crt_access = state;
535535}
536536
537537
538static const i8085_config dwarfd_i8085_config =
538static I8085_CONFIG( dwarfd_i8085_config )
539539{
540   NULL,               /* INTE changed callback */
541   NULL,               /* STATUS changed callback */
542   dwarfd_sod_callback,   /* SOD changed callback (8085A only) */
543   NULL               /* SID changed callback (8085A only) */
540   DEVCB_NULL,                  /* STATUS changed callback */
541   DEVCB_NULL,                  /* INTE changed callback */
542   DEVCB_NULL,                  /* SID changed callback (8085A only) */
543   DEVCB_LINE(dwarfd_sod_callback)   /* SOD changed callback (8085A only) */
544544};
545545
546546
src/mame/drivers/m79amb.c
r5534r5535
4848  8002 Sound Control (According to Manual)
4949  8003 D0=SelfTest LED
5050
51
52The cabinet has backdrop artwork, a lightbulb for explosions,
53and two large (paddles pretending to be) guns.
54
5155*/
5256
5357#include "driver.h"
r5534r5535
8993}
9094
9195
92static const int ControllerTable[32] = {
93    0  , 1  , 3  , 2  , 6  , 7  , 5  , 4  ,
94    12 , 13 , 15 , 14 , 10 , 11 , 9  , 8  ,
95    24 , 25 , 27 , 26 , 30 , 31 , 29 , 28 ,
96    20 , 21 , 23 , 22 , 18 , 19 , 17 , 16
96/* grenade trajectory per gun position is inconsistent and sloppy in the game:
97     0,     1,     3,     2,     6,     7,     5,     4     - gun position
98    90.00, 90.00, 90.00, 90.00, 86.42, 86.42, 86.42, 86.42  - grenade trajectory (angle, est)
99     18.0,  18.0,  18.0,  18.0,  27.2,  27.2,  27.2,  31.2  - crosses with y=28 (x, est)
100
101    12,    13,    15,    14,    10,    11,     9,     8,
102    84.39, 84.39, 84.39, 80.87, 79.00, 80.87, 79.00, 79.00
103     41.9,  48.9,  56.8,  75.8,  87.2,  88.8, 101.6, 107.6
104
105    24,    25,    27,    26,    30,    31,    29,    28,
106    79.00, 79.00, 75.59, 75.59, 75.59, 73.72, 73.72, 73.72
107    114.1, 121.5, 138.8, 146.0, 152.7, 162.6, 167.6, 172.7
108
109    20,    21,    23,    22,    18,    19,    17,    16
110    73.72, 70.08, 70.08, 70.08, 67.97, 67.97, 64.34, 64.34
111    181.6, 199.9, 205.4, 211.9, 223.5, 232.4, 254.0, 254.0
112*/
113static const UINT8 lut_cross[0x20] = {
114     19,    20,    21,    23,    25,    27,    29,    37,
115     45,    53,    66,    82,    88,    95,   105,   111,
116    118,   130,   142,   149,   158,   165,   170,   177,
117    191,   203,   209,   218,   228,   243,   249,   255,
97118};
119static const UINT8 lut_pos[0x20] = {
120    0x1f,  0x1e,  0x1c,  0x1d,  0x19,  0x18,  0x1a,  0x1b,
121    0x13,  0x12,  0x10,  0x11,  0x15,  0x14,  0x16,  0x17,
122    0x07,  0x06,  0x04,  0x05,  0x01,  0x00,  0x02,  0x03,
123    0x0b,  0x0a,  0x08,  0x09,  0x0d,  0x0c,  0x0e,  0x0f
124};
98125
126static UINT8 lut_gun1[0x100];
127static UINT8 lut_gun2[0x100];
128
99129static READ8_HANDLER( gray5bit_controller0_r )
100130{
101    int port_data = input_port_read(space->machine, "8004");
102    return (port_data & 0xe0) | (~ControllerTable[port_data & 0x1f] & 0x1f);
131    UINT8 port_data = input_port_read(space->machine, "8004");
132    UINT8 gun_pos = input_port_read(space->machine, "GUN1");
133    return (port_data & 0xe0) | lut_gun1[gun_pos];
103134}
104135
105136static READ8_HANDLER( gray5bit_controller1_r )
106137{
107    int port_data = input_port_read(space->machine, "8005");
108    return (port_data & 0xe0) | (~ControllerTable[port_data & 0x1f] & 0x1f);
138    UINT8 port_data = input_port_read(space->machine, "8005");
139    UINT8 gun_pos = input_port_read(space->machine, "GUN2");
140    return (port_data & 0xe0) | lut_gun2[gun_pos];
109141}
110142
111143static WRITE8_HANDLER( m79amb_8002_w )
r5534r5535
118150static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
119151   AM_RANGE(0x0000, 0x1fff) AM_ROM
120152   AM_RANGE(0x4000, 0x5fff) AM_RAM_WRITE(ramtek_videoram_w) AM_BASE(&ramtek_videoram)
121   AM_RANGE(0x6000, 0x63ff) AM_RAM      /* ?? */
153   AM_RANGE(0x6000, 0x63ff) AM_RAM               /* ?? */
122154   AM_RANGE(0x8000, 0x8000) AM_READ_PORT("8000") AM_DEVWRITE("discrete", m79amb_8000_w)
123155   AM_RANGE(0x8001, 0x8001) AM_WRITE(SMH_RAM) AM_BASE(&mask)
124156   AM_RANGE(0x8002, 0x8002) AM_READ_PORT("8002") AM_WRITE(m79amb_8002_w)
r5534r5535
161193   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
162194
163195   PORT_START("8004")
164   PORT_BIT( 0x1f, 0x10, IPT_PADDLE ) PORT_MINMAX(0,0x1f) PORT_SENSITIVITY(25) PORT_KEYDELTA(10) PORT_CENTERDELTA(0)
196   PORT_BIT( 0x1f, IP_ACTIVE_LOW, IPT_UNUSED ) // gun 1 here
165197   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 )
166198   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
167199   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
168200
169201   PORT_START("8005")
170   PORT_BIT( 0x1f, 0x10, IPT_PADDLE ) PORT_MINMAX(0,0x1f) PORT_SENSITIVITY(25) PORT_KEYDELTA(10) PORT_CENTERDELTA(0) PORT_PLAYER(2)
202   PORT_BIT( 0x1f, IP_ACTIVE_LOW, IPT_UNUSED ) // gun 2 here
171203   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
172204   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
173205   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
206
207   // fake ports for the guns
208   PORT_START("GUN1")
209   PORT_BIT( 0xff, 0x80, IPT_PADDLE ) PORT_CROSSHAIR(X, (1.0-(19.0/256.0)), 19.0/256.0, 30.0/224.0) PORT_MINMAX(19,255) PORT_SENSITIVITY(50) PORT_KEYDELTA(5) PORT_CENTERDELTA(0) PORT_PLAYER(1)
210
211   PORT_START("GUN2")
212   PORT_BIT( 0xff, 0x80, IPT_PADDLE ) PORT_CROSSHAIR(X, (1.0-(22.0/256.0)), 0.0, 30.0/224.0) PORT_MINMAX(0,234) PORT_SENSITIVITY(50) PORT_KEYDELTA(5) PORT_CENTERDELTA(0) PORT_PLAYER(2)
174213INPUT_PORTS_END
175214
176215
r5534r5535
182221static DRIVER_INIT( m79amb )
183222{
184223   UINT8 *rom = memory_region(machine, "maincpu");
185   int i;
224   int i,j;
186225
187226   /* PROM data is active low */
188227    for (i = 0;i < 0x2000;i++)
189228      rom[i] = ~rom[i];
229
230   /* gun positions */
231   for (i=0;i<0x100;i++) {
232      /* gun 1, start at left 18 */
233      for (j=0;j<0x20;j++) {
234         if (i<=lut_cross[j]) {
235            lut_gun1[i]=lut_pos[j];
236            break;
237         }
238      }
239
240      /* gun 2, start at right 235 */
241      for (j=0;j<0x20;j++) {
242         if (i>=(253-lut_cross[j])) {
243            lut_gun2[i]=lut_pos[j];
244            break;
245         }
246      }
247   }
190248}
191249
192250static MACHINE_DRIVER_START( m79amb )
src/mame/drivers/meritm.c
r5534r5535
1010      Other: 2 Z80APIO (I/O and interrupt controllers)
1111             1 8255 (I/O)
1212
13  CRT 252: addon board for CRT 250, stores question roms
13  CRT 256: addon board for CRT 250, stores question roms (aka Memory Expansion board)
1414
1515  CRT 258: addon board for CRT 250, contains UART and Microtouch touch screen controller
1616
r5534r5535
3434  Pit Boss Superstar (c)1990
3535  *Pit Boss Superstar 30 (c)1993
3636  Pit Boss Megastar (c)1994
37  *Pit Boss Supertouch 30 (c)1993/4
37  Pit Boss Supertouch 30 (c)1993/4
3838
3939  CRT 260:
4040  *Megatouch Video (c)1994?
r5534r5535
694694   PORT_INCLUDE(meritm_crt250)
695695
696696   PORT_MODIFY("DSW")
697   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) )
697   PORT_DIPUNUSED_DIPLOC( 0x01, 0x00, "SW1:1" )            /* Unused */
698   PORT_DIPNAME( 0x02, 0x02, "Solitaire Timer Mode" ) PORT_DIPLOCATION("SW1:2")
698699   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
699   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
700   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unknown ) )
701   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
702700   PORT_DIPSETTING(    0x02, DEF_STR( On ) )
703   PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unknown ) )
701   PORT_DIPNAME( 0x04, 0x04, "Sex Trivia" ) PORT_DIPLOCATION("SW1:3")
704702   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
705703   PORT_DIPSETTING(    0x04, DEF_STR( On ) )
706   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unknown ) )
707   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
708   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
709   PORT_DIPNAME( 0x10, 0x10, "Run 21 and Trivia Whiz 2000: Coins to start" )
704   PORT_DIPNAME( 0x08, 0x00, "Coin Limit" ) PORT_DIPLOCATION("SW1:4")
705   PORT_DIPSETTING(    0x00, "No Coin Limit" )
706   PORT_DIPSETTING(    0x08, "4 Coin Limit" )   /* With Lockout coil */
707   PORT_DIPNAME( 0x10, 0x10, "Run 21 and Trivia Whiz 2000: Coins to start" ) PORT_DIPLOCATION("SW1:5")
710708   PORT_DIPSETTING(    0x00, "2 Coins" )
711709   PORT_DIPSETTING(    0x10, "1 Coin" )
712   PORT_DIPNAME( 0x20, 0x20, "Great Solitaire: Coins to start" )
713   PORT_DIPSETTING(    0x00, "4 Coins" )
714   PORT_DIPSETTING(    0x20, "2 Coins" )
715   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
710   PORT_DIPNAME( 0x20, 0x20, "Great Solitaire: Coins to start" ) PORT_DIPLOCATION("SW1:6")
711   PORT_DIPSETTING(    0x00, "2 Coins" )
712   PORT_DIPSETTING(    0x20, "1 Coin" )
713   PORT_DIPNAME( 0x40, 0x00, "Sync Adjustment (Set by factory)" ) PORT_DIPLOCATION("SW1:7")   /* Sync Adjustment (Set by factory) */
716714   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
717715   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
718   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
716   PORT_DIPNAME( 0x80, 0x00, "Sync Adjustment (Set by factory)" ) PORT_DIPLOCATION("SW1:8")   /* Sync Adjustment (Set by factory) */
719717   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
720718   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
721719INPUT_PORTS_END
722720
721static INPUT_PORTS_START(pitbossa)
722   PORT_INCLUDE(pitbossm)
723
724   PORT_MODIFY("DSW")
725   PORT_DIPNAME( 0x20, 0x20, "Great Solitaire: Coins to start" ) PORT_DIPLOCATION("SW1:6")
726   PORT_DIPSETTING(    0x00, "4 Coins" )
727   PORT_DIPSETTING(    0x20, "2 Coins" )
728INPUT_PORTS_END
729
723730static INPUT_PORTS_START(pbst30)
724731   PORT_INCLUDE(meritm_crt260)
725732
726733   PORT_MODIFY("DSW")
727   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) )
734   PORT_DIPNAME( 0x01, 0x00, "Invert Touch Screen Coordinates" ) PORT_DIPLOCATION("SW1:1") /* In case you installed the touch screen upside down??? */
728735   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
729   PORT_DIPSETTING(    0x01, DEF_STR( On ) ) // when on, touch screen coordinates are mirrored?
730   PORT_DIPNAME( 0x02, 0x02, "Enable casino games" )
736   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
737   PORT_DIPNAME( 0x02, 0x02, "Enable Casino Games" ) PORT_DIPLOCATION("SW1:2")
731738   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
732739   PORT_DIPSETTING(    0x02, DEF_STR( Yes ) )
733   PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unknown ) )
740   PORT_DIPNAME( 0x04, 0x04, "Sexy Trivia Catagory" ) PORT_DIPLOCATION("SW1:3")
734741   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
735742   PORT_DIPSETTING(    0x04, DEF_STR( On ) )
736   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unknown ) )
743   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW1:4") /* Likely Coin limit */
737744   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
738745   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
739   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) ) // off 1 coin 0.5 credit, on 1 coin 1 credit
746   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW1:5")
747   PORT_DIPSETTING(    0x00, DEF_STR( 2C_1C ) )
748   PORT_DIPSETTING(    0x10, DEF_STR( 1C_1C ) )
749   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW1:6")
740750   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
741   PORT_DIPSETTING(    0x10, DEF_STR( On ) )
742   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
743   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
744751   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
745   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
752   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW1:7")
746753   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
747754   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
748   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
755   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW1:8")
749756   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
750757   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
751758INPUT_PORTS_END
r5534r5535
10981105/*
10991106    Pit Boss Megastar - Merit Industries Inc. 1994
11001107
1101    Games are: Great Solitaire, Run 21 and Trivia Whiz 2000.
1102    -------------------------------------------------------
1103    Some of the pinouts probably flash lighted buttons as
1104    most Merit games have this feature.
1105    -------------------------------------------------------
1108 Runs on standard Merit CRT-250 PCB with the following additions:
1109  CRT-256 Memory Expansion board
1110  CRT-254 Module (to connect the DS1204 to main board via connector J2)
1111  CRT-243 Video Billboard board (Optional) with optional Video Billboard Keyboard
11061112
1107    EPROMS 1,2, and 3 are 27C2001's
1108    EPROMS 4 through 9 are 27C512's
1113From the "PIT BOSS MEGASTAR CHIP SET UPGRADE KIT" Program No. 9243-XX PM8938 Owner's Manual:
11091114
1110    One 8 bank dip switch.
1115  This kit updates the Superstar 30 program (9233-xx) to the Megastar program. The new EPROM set consists of 3
1116  EPROMS: 9243-xx-xx U9, U11, U15. EPROMs U10, U12 and U13 are unchanged and do not need to be replaced in a
1117  field upgrade. U14 will be removed as it is no longer used.
11111118
1112    Two YAMAHA V9938 Video Processors.
1119Custom Program Versions:
11131120
1114    21.47727 MHz Crystal tied into pin 63 on both the V9938's
1121Program #      Description                  Differences
11229243-00-01     Standard Megastar            Includes all Options / No Restrictions
11239243-00-06     California Megastar          Excludes Free Play Feature
11249243-00-07     New Jersey Megastar          Excludes Set Trivia and includes 4-coin limit with lockout coil
11151125
1116    CPU Z80B
1126From ADDENDUM:
11171127
1118    Audio YM2149F
1119    Two Z80A-PIO
1128MANUAL: Megastar Owners Game Manual PM8939
1129DATE: 8/23/94
11309244-00-01, 06, 07
11201131
1121    One Goldstar GM76C88L-15 (6264) SRAM
1122    Eight V53C464AP80 (41464) RAMS
1132Description of Changes:
11231133
1124    One PALCE16V8H-25PC/4
1125    One GAL22V10B
11341- Great Draw Poker and 7 Stud Poker have been added to the program set
11352- On page 3-1 legend artwork has changed. PASS has been replaced with
1136   PASS/PLAY and COLLECT/QUIT has been replaced with COLLECT/QUIT/RAISE
11373- An additional Solitaire Instruction decal has beed added to the kit.
1138   This new Instruction decal is to be mounted in a visivle loction for
1139   players use.
11261140
1127    chaneman Sept.23 2004
11281141*/
11291142
1130ROM_START( pitbossm )
1143ROM_START( pitbossm ) /* Dallas DS1204V security key attached to CRT-254 connected to J2 connector labeled 9244-00 U1-RO1 C1994 MII */
11311144   ROM_REGION( 0x80000, "maincpu", 0 )
1132   ROM_LOAD( "4",  0x00000, 0x10000, CRC(55e14fb1) SHA1(ec29764d1b63360f64b82452e0db8054b99fcca0) )
1133   ROM_LOAD( "5",  0x10000, 0x10000, CRC(853a1a99) SHA1(45e33442aa7e51c05c9ac8b8458937ee3ff4c21d) )
1134   ROM_LOAD( "6",  0x20000, 0x10000, CRC(47a9dfc7) SHA1(eca100003f5605bcf405f610a0458ccb67894d35) )
1135   ROM_LOAD( "7",  0x30000, 0x10000, CRC(b9fb4203) SHA1(84b514d9739d9c2ab1081cfc7cdedb41155ee038) )
1136   ROM_LOAD( "8",  0x40000, 0x10000, CRC(574fb3c7) SHA1(213741df3055b97ddd9889c2aa3d3e863e2c86d3) ) // == u16 on pitboss2/spitboss
1137   ROM_RELOAD(     0x50000, 0x10000)
1138   ROM_LOAD( "9",  0x60000, 0x10000, CRC(27034061) SHA1(cff6be592a4a3ab01c204b081470f224e6186c4d) )
1145   ROM_LOAD( "9244-00-01_u9-r0",  0x00000, 0x10000, CRC(8317fea1) SHA1(eb84fdca7cd51883153561785571790d12d0d612) )
1146   ROM_LOAD( "9244-00-01_u10-r0", 0x10000, 0x10000, CRC(853a1a99) SHA1(45e33442aa7e51c05c9ac8b8458937ee3ff4c21d) ) /* Could also be labeled 9234-00-01 U10-R0 */
1147   ROM_LOAD( "9244-00-01_u11-r0", 0x20000, 0x10000, CRC(45223e0d) SHA1(45070e85d87aa67ecd6a1355212f1d24142fcbd0) )
1148   ROM_LOAD( "9244-00-01_u12-r0", 0x30000, 0x10000, CRC(b9fb4203) SHA1(84b514d9739d9c2ab1081cfc7cdedb41155ee038) ) /* Could also be labeled 9234-00-01 U12-R0 */
1149   ROM_LOAD( "9244-00-01_u13-r0", 0x40000, 0x10000, CRC(574fb3c7) SHA1(213741df3055b97ddd9889c2aa3d3e863e2c86d3) ) /* Could also be labeled 9234-00-01 U13-R0 */
1150   ROM_LOAD( "9244-00-01_u14-r0", 0x50000, 0x10000, CRC(c0d18911) SHA1(def939c6bac1e3124197f3f783d06f3bef3d03e9) )
1151   ROM_LOAD( "9244-00-01_u15-r0", 0x60000, 0x10000, CRC(740e3734) SHA1(6440d258af114f3820683b4e6fba5db6aea02231) )
11391152   ROM_RELOAD(     0x70000, 0x10000)
11401153
11411154
11421155   ROM_REGION( 0xc0000, "user1", 0 ) // extra data / extra banks?
1143   ROM_LOAD( "3",  0x00000, 0x40000, CRC(35f4ca46) SHA1(87917b3017f505fae65d6bfa2c7d6fb503c2da6a) )
1144   ROM_LOAD( "2",  0x40000, 0x40000, CRC(606f1656) SHA1(7f1e3a698a34d3c3b8f9f2cd8d5224b6c096e941) )
1145   ROM_LOAD( "1",  0x80000, 0x40000, CRC(590a1565) SHA1(b80ea967b6153847b2594e9c59bfe87559022b6c) )
1156   ROM_LOAD( "qs9243-00-01_u7-r0",  0x00000, 0x40000, CRC(35f4ca46) SHA1(87917b3017f505fae65d6bfa2c7d6fb503c2da6a) ) /* These 3 roms are on CRT-256 sattalite PCB */
1157   ROM_LOAD( "qs9243-00-01_u6-r0",  0x40000, 0x40000, CRC(606f1656) SHA1(7f1e3a698a34d3c3b8f9f2cd8d5224b6c096e941) )
1158   ROM_LOAD( "qs9243-00-01_u5-r0",  0x80000, 0x40000, CRC(590a1565) SHA1(b80ea967b6153847b2594e9c59bfe87559022b6c) )
11461159ROM_END
11471160
1161ROM_START( pitbossma ) /* Unprotected or patched??  The manual shows a DS1204 key for this set */
1162   ROM_REGION( 0x80000, "maincpu", 0 )
1163   ROM_LOAD( "9243-00-01_u9-r0",  0x00000, 0x10000, CRC(55e14fb1) SHA1(ec29764d1b63360f64b82452e0db8054b99fcca0) )
1164   ROM_LOAD( "9243-00-01_u10-r0", 0x10000, 0x10000, CRC(853a1a99) SHA1(45e33442aa7e51c05c9ac8b8458937ee3ff4c21d) ) /* Could also be labeled 9234-00-01 U10-R0 */
1165   ROM_LOAD( "9243-00-01_u11-r0", 0x20000, 0x10000, CRC(47a9dfc7) SHA1(eca100003f5605bcf405f610a0458ccb67894d35) )
1166   ROM_LOAD( "9243-00-01_u12-r0", 0x30000, 0x10000, CRC(b9fb4203) SHA1(84b514d9739d9c2ab1081cfc7cdedb41155ee038) ) /* Could also be labeled 9234-00-01 U12-R0 */
1167   ROM_LOAD( "9243-00-01_u13-r0", 0x40000, 0x10000, CRC(574fb3c7) SHA1(213741df3055b97ddd9889c2aa3d3e863e2c86d3) ) /* Could also be labeled 9234-00-01 U13-R0 */
1168   ROM_RELOAD(     0x50000, 0x10000) /* U14 is unused for this set */
1169   ROM_LOAD( "9243-00-01_u15-r0", 0x60000, 0x10000, CRC(27034061) SHA1(cff6be592a4a3ab01c204b081470f224e6186c4d) )
1170   ROM_RELOAD(     0x70000, 0x10000)
11481171
1149ROM_START( pbst30 ) /* Dallas DS1204V security key at U1 labeled 9234-10 U1-RO1 C1994 MII */
1172
1173   ROM_REGION( 0xc0000, "user1", 0 ) // extra data / extra banks?
1174   ROM_LOAD( "qs9243-00-01_u7-r0",  0x00000, 0x40000, CRC(35f4ca46) SHA1(87917b3017f505fae65d6bfa2c7d6fb503c2da6a) ) /* These 3 roms are on CRT-256 sattalite PCB */
1175   ROM_LOAD( "qs9243-00-01_u6-r0",  0x40000, 0x40000, CRC(606f1656) SHA1(7f1e3a698a34d3c3b8f9f2cd8d5224b6c096e941) )
1176   ROM_LOAD( "qs9243-00-01_u5-r0",  0x80000, 0x40000, CRC(590a1565) SHA1(b80ea967b6153847b2594e9c59bfe87559022b6c) )
1177ROM_END
1178
1179ROM_START( pbst30 ) /* Dallas DS1204V security key attached to CRT-254 connected to J2 connector labeled 9234-10 U1-RO1 C1994 MII */
11501180   ROM_REGION( 0x80000, "maincpu", 0 )
11511181   ROM_LOAD( "9234-10-01_u9-r0",  0x00000, 0x10000, CRC(96f39c9a) SHA1(df698e94a5204cf050ceadc5c257ca5f68171114) )
1152   ROM_LOAD( "5",  0x10000, 0x10000, BAD_DUMP CRC(853a1a99) SHA1(45e33442aa7e51c05c9ac8b8458937ee3ff4c21d) ) // taken from pitbossm
1153   ROM_LOAD( "9234-10-01_u11-r0",  0x20000, 0x10000, CRC(835fa041) SHA1(2ae754c5fcf50548eb214902409217d1643c6eaa) )
1154   ROM_LOAD( "7",  0x30000, 0x10000, BAD_DUMP CRC(b9fb4203) SHA1(84b514d9739d9c2ab1081cfc7cdedb41155ee038) ) // taken from pitbossm
1155   ROM_LOAD( "9234-10-01_u14-r0",  0x50000, 0x10000, CRC(9b0873a4) SHA1(7362c6220aa4bf1a9ab7c11cb8a51587a2a0a992) )
1156   ROM_LOAD( "9234-10-01_u15-r0",  0x60000, 0x10000, CRC(9fbd8582) SHA1(c0f68c8a7cdca34c8736cefc71767c421bcaba8a) )
1182   ROM_LOAD( "9234-00-01_u10-r0", 0x10000, 0x10000, CRC(853a1a99) SHA1(45e33442aa7e51c05c9ac8b8458937ee3ff4c21d) )
1183   ROM_LOAD( "9234-10-01_u11-r0", 0x20000, 0x10000, CRC(835fa041) SHA1(2ae754c5fcf50548eb214902409217d1643c6eaa) )
1184   ROM_LOAD( "9234-00-01_u12-r0", 0x30000, 0x10000, CRC(b9fb4203) SHA1(84b514d9739d9c2ab1081cfc7cdedb41155ee038) )
1185   ROM_LOAD( "9234-00-01_u13-r0", 0x40000, 0x10000, CRC(574fb3c7) SHA1(213741df3055b97ddd9889c2aa3d3e863e2c86d3) )
1186   ROM_LOAD( "9234-10-01_u14-r0", 0x50000, 0x10000, CRC(9b0873a4) SHA1(7362c6220aa4bf1a9ab7c11cb8a51587a2a0a992) )
1187   ROM_LOAD( "9234-10-01_u15-r0", 0x60000, 0x10000, CRC(9fbd8582) SHA1(c0f68c8a7cdca34c8736cefc71767c421bcaba8a) )
11571188
11581189
11591190   ROM_REGION( 0xc0000, "user1", 0 ) // extra data / extra banks?
1160   ROM_LOAD( "qs9234-01_u7-r0",  0x00000, 0x40000, CRC(c0534aaa) SHA1(4b3cbf03f29fd5b4b8fd423e73c0c8147692fa75) )
1191   ROM_LOAD( "qs9234-01_u7-r0",  0x00000, 0x40000, CRC(c0534aaa) SHA1(4b3cbf03f29fd5b4b8fd423e73c0c8147692fa75) ) /* These 3 roms are on CRT-256 sattalite PCB */
11611192   ROM_LOAD( "qs9234-01_u6-r0",  0x40000, 0x40000, CRC(fe2cd934) SHA1(623011dc53ed6eefefa0725dba6fd1efee2077c1) )
11621193   ROM_LOAD( "qs9234-01_u5-r0",  0x80000, 0x40000, CRC(293fe305) SHA1(8a551ae8fb4fa4bf329128be1bfd6f1c3ff5a366) )
11631194ROM_END
11641195
1165ROM_START( pbst30b ) /* Dallas DS1204V security key at U1 labeled 9234-01 U1-RO1 C1993 MII */
1196ROM_START( pbst30b ) /* Dallas DS1204V security key attached to CRT-254 connected to J2 connector labeled 9234-01 U1-RO1 C1993 MII */
11661197   ROM_REGION( 0x80000, "maincpu", 0 )
11671198   ROM_LOAD( "9234-00-01_u9-r0a",  0x00000, 0x10000, CRC(5f058f95) SHA1(98382935340a076bdb1b20c7f16c25b6084599fe) )
1168   ROM_LOAD( "5",  0x10000, 0x10000, BAD_DUMP CRC(853a1a99) SHA1(45e33442aa7e51c05c9ac8b8458937ee3ff4c21d) ) // taken from pitbossm
1169   ROM_LOAD( "9234-00-01_u11-r0a",  0x20000, 0x10000, CRC(79125fb5) SHA1(6ca4f33c363cfb6f5c0f23b8fcc8cfcc076f68b1) )
1170   ROM_LOAD( "7",  0x30000, 0x10000, BAD_DUMP CRC(b9fb4203) SHA1(84b514d9739d9c2ab1081cfc7cdedb41155ee038) ) // taken from pitbossm
1171   ROM_LOAD( "9234-00-01_u14-r0a",  0x50000, 0x10000, CRC(e83f91d5) SHA1(1d64c943787b239763f44be412ee7f5ad13eb37d) )
1172   ROM_LOAD( "9234-00-01_u15-r0a",  0x60000, 0x10000, CRC(f10f0d39) SHA1(2b5d5a93adb5251e09160b10c067b6e70289f608) )
1199   ROM_LOAD( "9234-00-01_u10-r0",  0x10000, 0x10000, CRC(853a1a99) SHA1(45e33442aa7e51c05c9ac8b8458937ee3ff4c21d) )
1200   ROM_LOAD( "9234-00-01_u11-r0a", 0x20000, 0x10000, CRC(79125fb5) SHA1(6ca4f33c363cfb6f5c0f23b8fcc8cfcc076f68b1) )
1201   ROM_LOAD( "9234-00-01_u12-r0",  0x30000, 0x10000, CRC(b9fb4203) SHA1(84b514d9739d9c2ab1081cfc7cdedb41155ee038) )
1202   ROM_LOAD( "9234-00-01_u13-r0",  0x40000, 0x10000, CRC(574fb3c7) SHA1(213741df3055b97ddd9889c2aa3d3e863e2c86d3) )
1203   ROM_LOAD( "9234-00-01_u14-r0a", 0x50000, 0x10000, CRC(e83f91d5) SHA1(1d64c943787b239763f44be412ee7f5ad13eb37d) )
1204   ROM_LOAD( "9234-00-01_u15-r0a", 0x60000, 0x10000, CRC(f10f0d39) SHA1(2b5d5a93adb5251e09160b10c067b6e70289f608) )
11731205
11741206
11751207   ROM_REGION( 0xc0000, "user1", 0 ) // extra data / extra banks?
1176   ROM_LOAD( "qs9234-01_u7-r0",  0x00000, 0x40000, CRC(c0534aaa) SHA1(4b3cbf03f29fd5b4b8fd423e73c0c8147692fa75) )
1208   ROM_LOAD( "qs9234-01_u7-r0",  0x00000, 0x40000, CRC(c0534aaa) SHA1(4b3cbf03f29fd5b4b8fd423e73c0c8147692fa75) ) /* These 3 roms are on CRT-256 sattalite PCB */
11771209   ROM_LOAD( "qs9234-01_u6-r0",  0x40000, 0x40000, CRC(fe2cd934) SHA1(623011dc53ed6eefefa0725dba6fd1efee2077c1) )
11781210   ROM_LOAD( "qs9234-01_u5-r0",  0x80000, 0x40000, CRC(293fe305) SHA1(8a551ae8fb4fa4bf329128be1bfd6f1c3ff5a366) )
11791211ROM_END
r5534r5535
14881520
14891521ROM_START( megat6 ) /* Dallas DS1204V security key at U5 labeled 9255-80 U5-B-RO1 C1998 MII */
14901522   ROM_REGION( 0x400000, "maincpu", 0 )
1491   ROM_LOAD( "9255-80-01_u32-r0",  0x000000, 0x100000, CRC(f8f7f48e) SHA1(1bebe1f8898c60b795a0f794ca9b79e03d2744e4) ) /* Location U32 */
1523   ROM_LOAD( "9255-60-01_u32-r0",  0x000000, 0x100000, CRC(f8f7f48e) SHA1(1bebe1f8898c60b795a0f794ca9b79e03d2744e4) ) /* Location U32 */
14921524   ROM_LOAD( "qs9255-08_u36-r0",   0x100000, 0x080000, CRC(800f5a1f) SHA1(4d3ee6fb896d6452aab1f279a3ee878284bd1acc) ) /* Location U36 */
14931525   ROM_RELOAD(                     0x180000, 0x080000 )
14941526   ROM_LOAD( "qs9255-08_u37-r0",   0x200000, 0x100000, CRC(5ba01949) SHA1(1598949ea18d07bbc78af0ddd279a687173c1229) ) /* Location U37 */
r5534r5535
15041536   ROM_LOAD( "sc3981-0a.u51",  0x000, 0x117, CRC(4fc750d0) SHA1(d09ff7a8c66aeb5c49e9fec84bd1521e3f5d8d0a) )
15051537ROM_END
15061538
1539static DRIVER_INIT(pitbossm)
1540{
1541   static const UINT8 pitbossm_ds1204_key[8] =
1542      { 0xf0, 0xaa, 0x0f, 0x0f, 0x55, 0x55, 0xff, 0xab };
1543
1544   static const UINT8 pitbossm_ds1204_nvram[16] =
1545      { 0x16, 0x90, 0xa0, 0x52, 0xd8, 0x6c, 0x12, 0xaf, 0x36, 0x22, 0x61, 0x35, 0x0d, 0x58, 0x0c, 0x00 };
1546
1547   ds1204_init(machine, pitbossm_ds1204_key, pitbossm_ds1204_nvram);
1548
1549};
1550
15071551static DRIVER_INIT(pbst30)
15081552{
15091553   static const UINT8 pbst30b_ds1204_key[8] =
r5534r5535
16071651GAME( 1988, spitboss,  0,      meritm_crt250, meritm_crt250, 0, ROT0, "Merit", "Super Pit Boss", GAME_IMPERFECT_GRAPHICS )
16081652GAME( 1990, pitbosss,  0,      meritm_crt250, meritm_crt250, 0, ROT0, "Merit", "Pit Boss Superstar", GAME_IMPERFECT_GRAPHICS )
16091653
1610/* CRT 250 + question roms */
1611GAME( 1994, pitbossm,  0,      meritm_crt250_questions, pitbossm, 0, ROT0, "Merit", "Pit Boss Megastar", GAME_IMPERFECT_GRAPHICS )
1654/* CRT 250 + CRT 254 + CRT 256 */
1655GAME( 1994, pbst30,    0,      meritm_crt250_crt252_crt258, pbst30, pbst30,  ROT0, "Merit", "Pit Boss Supertouch 30 (9234-10-01)", GAME_IMPERFECT_GRAPHICS )
1656GAME( 1993, pbst30b,   pbst30, meritm_crt250_crt252_crt258, pbst30, pbst30b, ROT0, "Merit", "Pit Boss Supertouch 30 (9234-00-01)", GAME_IMPERFECT_GRAPHICS )
16121657
1613/* CRT 250 + CRT 252 + CRT 258 */
1614GAME( 1994, pbst30,    0,      meritm_crt250_crt252_crt258, pbst30, pbst30,  ROT0, "Merit", "Pit Boss Supertouch 30", GAME_IMPERFECT_GRAPHICS )
1615GAME( 1993, pbst30b,   0,      meritm_crt250_crt252_crt258, pbst30, pbst30b, ROT0, "Merit", "Pit Boss Supertouch 30 (set 2)", GAME_IMPERFECT_GRAPHICS )
1658/* CRT 250 + CRT 254 + CRT 256 */
1659GAME( 1994, pitbossm,  0,         meritm_crt250_questions, pitbossm, pitbossm, ROT0, "Merit", "Pit Boss Megastar (9244-00-01)", GAME_IMPERFECT_GRAPHICS )
1660GAME( 1994, pitbossma, pitbossm,  meritm_crt250_questions, pitbossa, 0,        ROT0, "Merit", "Pit Boss Megastar (9243-00-01)", GAME_IMPERFECT_GRAPHICS )
16161661
16171662/* CRT 260 */
16181663GAME( 1996, megat3,    0,      meritm_crt260, meritm_crt260, megat3,   ROT0, "Merit", "Megatouch III (9255-20-01 RON, Standard version)", GAME_IMPERFECT_GRAPHICS )
src/mame/drivers/midwunit.c
r5534r5535
664664
665665ROM_START( mk3 )
666666   ROM_REGION16_LE( 0x800000, "dcs", ROMREGION_ERASEFF )   /* sound data */
667   ROM_LOAD16_BYTE( "mk3-u2.bin", 0x000000, 0x100000, BAD_DUMP CRC(3838cfe5) SHA1(e3d2901f3bae1362742fc6ee0aa31c9f63b4dfa3) )
667   ROM_LOAD16_BYTE( "mk3-u2.bin", 0x000000, 0x100000, CRC(5273436f) SHA1(e1735842a0159eafe79d878d44e3828df9bfa5bb) )
668668   ROM_LOAD16_BYTE( "mk3-u3.bin", 0x200000, 0x100000, CRC(856fe411) SHA1(6165ebecfce7500e948d84492ffa19eed7f47091) )
669669   ROM_LOAD16_BYTE( "mk3-u4.bin", 0x400000, 0x100000, CRC(428a406f) SHA1(e70ec83cd054de0da1e178720ed0035b8887f797) )
670670   ROM_LOAD16_BYTE( "mk3-u5.bin", 0x600000, 0x100000, CRC(3b98a09f) SHA1(edf1d02a56dcf3349e6b4bb4097acfe7592305f4) )
r5534r5535
703703
704704ROM_START( mk3r20 )
705705   ROM_REGION16_LE( 0x800000, "dcs", ROMREGION_ERASEFF )   /* sound data */
706   ROM_LOAD16_BYTE( "mk3-u2.bin", 0x000000, 0x100000, BAD_DUMP CRC(3838cfe5) SHA1(e3d2901f3bae1362742fc6ee0aa31c9f63b4dfa3) )
706   ROM_LOAD16_BYTE( "mk3-u2.bin", 0x000000, 0x100000, CRC(5273436f) SHA1(e1735842a0159eafe79d878d44e3828df9bfa5bb) )
707707   ROM_LOAD16_BYTE( "mk3-u3.bin", 0x200000, 0x100000, CRC(856fe411) SHA1(6165ebecfce7500e948d84492ffa19eed7f47091) )
708708   ROM_LOAD16_BYTE( "mk3-u4.bin", 0x400000, 0x100000, CRC(428a406f) SHA1(e70ec83cd054de0da1e178720ed0035b8887f797) )
709709   ROM_LOAD16_BYTE( "mk3-u5.bin", 0x600000, 0x100000, CRC(3b98a09f) SHA1(edf1d02a56dcf3349e6b4bb4097acfe7592305f4) )
r5534r5535
742742
743743ROM_START( mk3r10 )
744744   ROM_REGION16_LE( 0x800000, "dcs", ROMREGION_ERASEFF )   /* sound data */
745   ROM_LOAD16_BYTE( "mk3-u2.bin", 0x000000, 0x100000, BAD_DUMP CRC(3838cfe5) SHA1(e3d2901f3bae1362742fc6ee0aa31c9f63b4dfa3) )
745   ROM_LOAD16_BYTE( "mk3-u2.bin", 0x000000, 0x100000, CRC(5273436f) SHA1(e1735842a0159eafe79d878d44e3828df9bfa5bb) )
746746   ROM_LOAD16_BYTE( "mk3-u3.bin", 0x200000, 0x100000, CRC(856fe411) SHA1(6165ebecfce7500e948d84492ffa19eed7f47091) )
747747   ROM_LOAD16_BYTE( "mk3-u4.bin", 0x400000, 0x100000, CRC(428a406f) SHA1(e70ec83cd054de0da1e178720ed0035b8887f797) )
748748   ROM_LOAD16_BYTE( "mk3-u5.bin", 0x600000, 0x100000, CRC(3b98a09f) SHA1(edf1d02a56dcf3349e6b4bb4097acfe7592305f4) )
r5534r5535
781781
782782ROM_START( mk3p40 )
783783   ROM_REGION16_LE( 0x800000, "dcs", ROMREGION_ERASEFF )   /* sound data */
784   ROM_LOAD16_BYTE( "mk3-u2.bin", 0x000000, 0x100000, BAD_DUMP CRC(3838cfe5) SHA1(e3d2901f3bae1362742fc6ee0aa31c9f63b4dfa3) )
784   ROM_LOAD16_BYTE( "mk3-u2.bin", 0x000000, 0x100000, CRC(5273436f) SHA1(e1735842a0159eafe79d878d44e3828df9bfa5bb) )
785785   ROM_LOAD16_BYTE( "mk3-u3.bin", 0x200000, 0x100000, CRC(856fe411) SHA1(6165ebecfce7500e948d84492ffa19eed7f47091) )
786786   ROM_LOAD16_BYTE( "mk3-u4.bin", 0x400000, 0x100000, CRC(428a406f) SHA1(e70ec83cd054de0da1e178720ed0035b8887f797) )
787787   ROM_LOAD16_BYTE( "mk3-u5.bin", 0x600000, 0x100000, CRC(3b98a09f) SHA1(edf1d02a56dcf3349e6b4bb4097acfe7592305f4) )
src/mame/drivers/toypop.c
r5534r5535
663663   ROM_LOAD( "tp1-5.2p", 0x0400, 0x0200, CRC(4d77fa5a) SHA1(2438910314b23ecafb553230244f3931861ad2da) )   /* sprites */
664664
665665   ROM_REGION( 0x0100, "namco", 0 )   /* sound prom */
666   ROM_LOAD( "lr1-4.3d", 0x0000, 0x0100, CRC(16a9166a) SHA1(847cbaf7c88616576c410177e066ae1d792ac0ba) )
666   ROM_LOAD( "tp1-6.3d", 0x0000, 0x0100, CRC(16a9166a) SHA1(847cbaf7c88616576c410177e066ae1d792ac0ba) )
667667ROM_END
668668
669669
src/mame/drivers/phoenix.c
r5534r5535
513513
514514/* Same as Phoenix, but uses an AY8910 and an extra visible line (column) */
515515
516static const i8085_config survival_i8085_config =
516static I8085_CONFIG( survival_i8085_config )
517517{
518   NULL,               /* INTE changed callback */
519   NULL,               /* STATUS changed callback */
520   NULL,               /* SOD changed callback (8085A only) */
521   survival_sid_callback   /* SID changed callback (8085A only) */
518   DEVCB_NULL,                     /* STATUS changed callback */
519   DEVCB_NULL,                     /* INTE changed callback */
520   DEVCB_LINE(survival_sid_callback),   /* SID changed callback (8085A only) */
521   DEVCB_NULL                     /* SOD changed callback (8085A only) */
522522};
523523
524524static MACHINE_DRIVER_START( survival )
src/mame/drivers/taito_f2.c
r5534r5535
11321132   AM_RANGE(0x300000, 0x30ffff) AM_RAM
11331133   AM_RANGE(0x400000, 0x401fff) AM_READWRITE(TC0430GRW_word_r, TC0430GRW_word_w)   /* ROZ tilemap */
11341134   AM_RANGE(0x402000, 0x40200f) AM_WRITE(TC0430GRW_ctrl_word_w)
1135   AM_RANGE(0x700000, 0x701fff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE(&paletteram16)
1135   AM_RANGE(0x700000, 0x701fff) AM_RAM_WRITE(taitof2_palette_w)
11361136   AM_RANGE(0x800000, 0x80ffff) AM_READWRITE(TC0100SCN_word_0_r, TC0100SCN_word_0_w)   /* tilemaps */
11371137   AM_RANGE(0x820000, 0x82000f) AM_READWRITE(TC0100SCN_ctrl_word_0_r, TC0100SCN_ctrl_word_0_w)
11381138   AM_RANGE(0x900000, 0x90ffff) AM_RAM AM_BASE(&spriteram16) AM_SIZE(&spriteram_size)
r5534r5535
32583258   MDRV_GFXDECODE(thundfox)
32593259   MDRV_VIDEO_START(taitof2_thundfox)
32603260   MDRV_VIDEO_EOF(taitof2_partial_buffer_delayed_thundfox)
3261   MDRV_VIDEO_UPDATE(thundfox)
3261   MDRV_VIDEO_UPDATE(taitof2_thundfox)
32623262MACHINE_DRIVER_END
32633263
32643264
r5534r5535
33263326   /* video hardware */
33273327   MDRV_VIDEO_START(taitof2_ssi)
33283328   MDRV_VIDEO_EOF(taitof2_partial_buffer_delayed_thundfox)   // buffer_delayed_thundfox instead of buffer_delayed fixes the butterfly powerup
3329   MDRV_VIDEO_UPDATE(ssi)
3329   MDRV_VIDEO_UPDATE(taitof2_ssi)
33303330MACHINE_DRIVER_END
33313331
33323332
r5534r5535
33793379   MDRV_GFXDECODE(deadconx)
33803380   MDRV_VIDEO_START(taitof2_footchmp)
33813381   MDRV_VIDEO_EOF(taitof2_full_buffer_delayed)
3382   MDRV_VIDEO_UPDATE(deadconx)
3382   MDRV_VIDEO_UPDATE(taitof2_deadconx)
33833383MACHINE_DRIVER_END
33843384
33853385
r5534r5535
33943394   MDRV_GFXDECODE(deadconx)
33953395   MDRV_VIDEO_START(taitof2_hthero)
33963396   MDRV_VIDEO_EOF(taitof2_full_buffer_delayed)
3397   MDRV_VIDEO_UPDATE(deadconx)
3397   MDRV_VIDEO_UPDATE(taitof2_deadconx)
33983398MACHINE_DRIVER_END
33993399
34003400
r5534r5535
34213421   /* video hardware */
34223422   MDRV_GFXDECODE(yuyugogo)
34233423   MDRV_VIDEO_START(taitof2_yuyugogo)
3424   MDRV_VIDEO_UPDATE(yesnoj)
3424   MDRV_VIDEO_UPDATE(taitof2_yesnoj)
34253425MACHINE_DRIVER_END
34263426
34273427
r5534r5535
34883488   MDRV_GFXDECODE(deadconx)
34893489   MDRV_PALETTE_LENGTH(8192)
34903490   MDRV_VIDEO_START(taitof2_metalb)
3491   MDRV_VIDEO_UPDATE(metalb)
3491   MDRV_VIDEO_UPDATE(taitof2_metalb)
34923492MACHINE_DRIVER_END
34933493
34943494
r5534r5535
35153515   /* video hardware */
35163516   MDRV_GFXDECODE(yuyugogo)
35173517   MDRV_VIDEO_START(taitof2_yesnoj)
3518   MDRV_VIDEO_UPDATE(yesnoj)
3518   MDRV_VIDEO_UPDATE(taitof2_yesnoj)
35193519MACHINE_DRIVER_END
35203520
35213521
r5534r5535
35293529   /* video hardware */
35303530   MDRV_GFXDECODE(deadconx)
35313531   MDRV_VIDEO_START(taitof2_deadconx)
3532   MDRV_VIDEO_UPDATE(deadconx)
3532   MDRV_VIDEO_UPDATE(taitof2_deadconx)
35333533MACHINE_DRIVER_END
35343534
35353535
r5534r5535
35433543   /* video hardware */
35443544   MDRV_GFXDECODE(deadconx)
35453545   MDRV_VIDEO_START(taitof2_deadconxj)
3546   MDRV_VIDEO_UPDATE(deadconx)
3546   MDRV_VIDEO_UPDATE(taitof2_deadconx)
35473547MACHINE_DRIVER_END
35483548
35493549
r5534r5535
36093609   /* video hardware */
36103610   MDRV_GFXDECODE(pivot)
36113611   MDRV_VIDEO_START(taitof2_driftout)
3612   MDRV_VIDEO_UPDATE(taitof2_pri_roz)
3612   MDRV_VIDEO_UPDATE(taitof2_driftout)
36133613MACHINE_DRIVER_END
36143614
36153615
src/mame/drivers/hyhoo.c
r5534r5535
255255static MACHINE_DRIVER_START( hyhoo )
256256
257257   /* basic machine hardware */
258   MDRV_CPU_ADD("maincpu", Z80, 5000000/1)   /* 5.00 MHz ?? */
258   MDRV_CPU_ADD("maincpu", Z80, 5000000)   /* 5.00 MHz ?? */
259259   MDRV_CPU_PROGRAM_MAP(hyhoo_map)
260260   MDRV_CPU_IO_MAP(hyhoo_io_map)
261261   MDRV_CPU_VBLANK_INT("screen", nb1413m3_interrupt)
src/mame/drivers/bzone.c
r5534r5535
206206#include "video/avgdvg.h"
207207#include "machine/mathbox.h"
208208#include "machine/atari_vg.h"
209#include "sound/pokey.h"
210209#include "rendlay.h"
211210#include "bzone.h"
212211
212#include "sound/pokey.h"
213
213214#include "bzone.lh"
214215
215#define MASTER_CLOCK (XTAL_12_096MHz)
216#define CLOCK_3KHZ  (MASTER_CLOCK / 4096)
217216
218
219217static UINT8 analog_data;
220218
221219UINT8 rb_input_select;
r5534r5535
308306   AM_RANGE(0x1810, 0x1810) AM_DEVREAD("mathbox", mathbox_lo_r)
309307   AM_RANGE(0x1818, 0x1818) AM_DEVREAD("mathbox", mathbox_hi_r)
310308   AM_RANGE(0x1820, 0x182f) AM_DEVREADWRITE("pokey", pokey_r, pokey_w)
309#if BZONE_DISCRETE
310   AM_RANGE(0x1840, 0x1840) AM_DEVWRITE("discrete", bzone_sounds_w)
311#else
311312   AM_RANGE(0x1840, 0x1840) AM_WRITE(bzone_sounds_w)
313#endif
312314   AM_RANGE(0x1860, 0x187f) AM_DEVWRITE("mathbox", mathbox_go_w)
313315   AM_RANGE(0x2000, 0x2fff) AM_RAM AM_BASE(&vectorram) AM_SIZE(&vectorram_size) AM_REGION("maincpu", 0x2000)
314316   AM_RANGE(0x3000, 0x7fff) AM_ROM
r5534r5535
419421   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START1 )
420422   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 )
421423   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )
424
425#if BZONE_DISCRETE
426   PORT_START("R11")
427   PORT_ADJUSTER( 50, "Engine Frequency" )
428#endif
422429INPUT_PORTS_END
423430
424431
r5534r5535
543550 *
544551 *************************************/
545552
546static MACHINE_DRIVER_START( bzone )
553static MACHINE_DRIVER_START( bzone_base )
547554
548555   /* basic machine hardware */
549   MDRV_CPU_ADD("maincpu", M6502, MASTER_CLOCK / 8)
556   MDRV_CPU_ADD("maincpu", M6502, BZONE_MASTER_CLOCK / 8)
550557   MDRV_CPU_PROGRAM_MAP(bzone_map)
551   MDRV_CPU_PERIODIC_INT(bzone_interrupt, (double)MASTER_CLOCK / 4096 / 12)
558   MDRV_CPU_PERIODIC_INT(bzone_interrupt, (double)BZONE_MASTER_CLOCK / 4096 / 12)
552559
553560   MDRV_MACHINE_START(bzone)
554561
r5534r5535
564571   /* Drivers */
565572   MDRV_MATHBOX_ADD("mathbox")
566573
574MACHINE_DRIVER_END
575
576static MACHINE_DRIVER_START( bzone )
577
578   MDRV_IMPORT_FROM(bzone_base)
579
567580   /* sound hardware */
581#if BZONE_DISCRETE
582   MDRV_IMPORT_FROM(bzone_audio)
583#else
568584   MDRV_SPEAKER_STANDARD_MONO("mono")
569585
570586   MDRV_SOUND_ADD("pokey",  POKEY, MASTER_CLOCK / 8)
r5534r5535
573589
574590   MDRV_SOUND_ADD("custom", BZONE, 0)
575591   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
592#endif
576593MACHINE_DRIVER_END
577594
578595
r5534r5535
582599   MDRV_IMPORT_FROM(bzone)
583600
584601   /* sound hardware */
585   MDRV_SOUND_REPLACE("pokey", POKEY,  MASTER_CLOCK / 8)
602   MDRV_SOUND_REPLACE("pokey", POKEY,  BZONE_MASTER_CLOCK / 8)
586603   MDRV_SOUND_CONFIG(bzone_pokey_interface)
587604   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
588605MACHINE_DRIVER_END
r5534r5535
591608static MACHINE_DRIVER_START( redbaron )
592609
593610   /* basic machine hardware */
594   MDRV_IMPORT_FROM(bzone)
611   MDRV_IMPORT_FROM(bzone_base)
595612   MDRV_CPU_MODIFY("maincpu")
596613   MDRV_CPU_PROGRAM_MAP(redbaron_map)
597   MDRV_CPU_PERIODIC_INT(bzone_interrupt, (double)MASTER_CLOCK / 4096 / 12)
614   MDRV_CPU_PERIODIC_INT(bzone_interrupt, (double)BZONE_MASTER_CLOCK / 4096 / 12)
598615
599616   MDRV_MACHINE_START(redbaron)
600617
r5534r5535
608625   MDRV_VIDEO_START(avg_bzone)
609626
610627   /* sound hardware */
611   MDRV_SOUND_REPLACE("pokey", POKEY, 1500000)
628   MDRV_SPEAKER_STANDARD_MONO("mono")
629
630   MDRV_SOUND_ADD("pokey", POKEY, 1500000)
612631   MDRV_SOUND_CONFIG(redbaron_pokey_interface)
613632   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
614633
615   MDRV_SOUND_REPLACE("custom", REDBARON, 0)
634   MDRV_SOUND_ADD("custom", REDBARON, 0)
635
616636   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
617637MACHINE_DRIVER_END
618638
src/mame/drivers/sauro.c
r5534r5535
1111Memory mapped:
1212
13130000-dfff   ROM
14e000-e7ff   RAM
14e000-e7ff   RAM, battery backed
1515e800-ebff   Sprite RAM
1616f000-fbff   Background Video RAM
1717f400-ffff   Background Color RAM
r5534r5535
136136
137137static ADDRESS_MAP_START( sauro_map, ADDRESS_SPACE_PROGRAM, 8 )
138138   AM_RANGE(0x0000, 0xdfff) AM_ROM
139   AM_RANGE(0xe000, 0xe7ff) AM_RAM
139   AM_RANGE(0xe000, 0xe7ff) AM_RAM AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size)
140140   AM_RANGE(0xe800, 0xebff) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
141141   AM_RANGE(0xf000, 0xf3ff) AM_RAM_WRITE(tecfri_videoram_w) AM_BASE(&tecfri_videoram)
142142   AM_RANGE(0xf400, 0xf7ff) AM_RAM_WRITE(tecfri_colorram_w) AM_BASE(&tecfri_colorram)
r5534r5535
182182
183183static ADDRESS_MAP_START( trckydoc_map, ADDRESS_SPACE_PROGRAM, 8 )
184184   AM_RANGE(0x0000, 0xdfff) AM_ROM
185   AM_RANGE(0xe000, 0xe7ff) AM_RAM
185   AM_RANGE(0xe000, 0xe7ff) AM_RAM AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size)
186186   AM_RANGE(0xe800, 0xebff) AM_RAM AM_MIRROR(0x400) AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
187187   AM_RANGE(0xf000, 0xf3ff) AM_RAM_WRITE(tecfri_videoram_w) AM_BASE(&tecfri_videoram)
188188   AM_RANGE(0xf400, 0xf7ff) AM_RAM_WRITE(tecfri_colorram_w) AM_BASE(&tecfri_colorram)
r5534r5535
337337   MDRV_CPU_ADD("maincpu", Z80, XTAL_20MHz/4)       /* verified on pcb */
338338   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
339339
340   MDRV_NVRAM_HANDLER(generic_1fill)
341
340342   /* video hardware */
341343   MDRV_SCREEN_ADD("screen", RASTER)
342344   MDRV_SCREEN_REFRESH_RATE(55.72)   /* verified on pcb */
src/mame/drivers/midtunit.c
r5534r5535
711711ROM_END
712712
713713
714ROM_START( mkturbo )
715   ROM_REGION( 0x50000, "adpcm", 0 )    /* sound CPU */
716   ROM_LOAD( "mks-u3.rom", 0x10000, 0x40000, CRC(c615844c) SHA1(5732f9053a5f73b0cc3b0166d7dc4430829d5bc7) )
717
718   ROM_REGION( 0x200000, "oki", 0 )   /* ADPCM */
719   ROM_LOAD( "mks-u12.rom", 0x00000, 0x40000, CRC(258bd7f9) SHA1(463890b23f17350fb9b8a85897b0777c45bc2d54) )
720   ROM_RELOAD(              0x40000, 0x40000 )
721   ROM_LOAD( "mks-u13.rom", 0x80000, 0x40000, CRC(7b7ec3b6) SHA1(6eec1b90d4a4855f34a7ebfbf93f3358d5627db4) )
722   ROM_RELOAD(              0xc0000, 0x40000 )
723
724   /* A 'KOMBO BOARD' daughtercard holding a GAL16V8A-2SP, 27C040 EPROM and a 9.8304MHz XTAL plugs into the UG12 socket */
725   ROM_REGION16_LE( 0x100000, "user1", 0 )   /* 34010 code */
726   ROM_LOAD16_BYTE( "kombo-rom-uj-12.bin", 0x00000, 0x80000, CRC(7a441f2d) SHA1(3b731bcbd73721ea0cc20157ec5181d25922523c) )
727   ROM_LOAD16_BYTE( "kombo-rom-ug-12.bin", 0x00001, 0x80000, CRC(45bed5a1) SHA1(dba2c21878925afdcaf61520c18ebefd5e9617db) )
728
729   ROM_REGION( 0xc00000, "gfx1", 0 )
730   ROM_LOAD( "mkt-ug14.bin", 0x000000, 0x80000, CRC(9e00834e) SHA1(2b97b63f52ba1dba6af6ae56c223519a52b2ab9d) )
731   ROM_LOAD( "mkt-ug16.bin", 0x080000, 0x80000, CRC(52c9d1e5) SHA1(7b1880fca0a11544782b70365c7dd96381ac48e7) )
732   ROM_LOAD( "mkt-ug17.bin", 0x100000, 0x80000, CRC(e34fe253) SHA1(6b010bee795c1770297c9557ded1fe83425857f2) )
733
734   ROM_LOAD( "mkt-uj14.bin", 0x300000, 0x80000, CRC(f4b0aaa7) SHA1(4cc6ee34c89e3cde325ad24b29511f70ae6a5a72) )
735   ROM_LOAD( "mkt-uj16.bin", 0x380000, 0x80000, CRC(c94c58cf) SHA1(974d75667eee779497325d5be8df937f15417edf) )
736   ROM_LOAD( "mkt-uj17.bin", 0x400000, 0x80000, CRC(a56e12f5) SHA1(5db637c4710990cd06bb0069714b19621532e431) )
737
738   ROM_LOAD( "mkt-ug19.bin", 0x600000, 0x80000, CRC(2d8c7ba1) SHA1(f891d6eb618dbf3e77f02e0f93da216e20571905) )
739   ROM_LOAD( "mkt-ug20.bin", 0x680000, 0x80000, CRC(2f7e55d3) SHA1(bda6892ee6fcb46959e4d0892bbe7d9fc6072dd3) )
740   ROM_LOAD( "mkt-ug22.bin", 0x700000, 0x80000, CRC(b537bb4e) SHA1(05a447deee2e89b49bdb3ca2161a021d7ec5f11e) )
741
742   ROM_LOAD( "mkt-uj19.bin", 0x900000, 0x80000, CRC(33b9b7a4) SHA1(e8ceca4c049e1f55d480a03ff793b595bd04d344) )
743   ROM_LOAD( "mkt-uj20.bin", 0x980000, 0x80000, CRC(eae96df0) SHA1(b40532312ba61e4065abfd733dd0c93eecad48e9) )
744   ROM_LOAD( "mkt-uj22.bin", 0xa00000, 0x80000, CRC(5e12523b) SHA1(468f93ef9bb6addb45c1c939d24b6511f255426a) )
745ROM_END
746
747
714748ROM_START( mk2 )
715749   ROM_REGION16_LE( 0xc00000, "dcs", ROMREGION_ERASEFF )   /* sound data */
716750   ROM_LOAD16_BYTE( "su2.l1", 0x000000, 0x80000, CRC(5f23d71d) SHA1(54c2afef243759e0f3dbe2907edbc4302f5c8bad) )
r5534r5535
12781312
12791313GAME( 1992, mk,       0,       tunit_adpcm, mk,       mktunit,  ROT0, "Midway",   "Mortal Kombat (rev 5.0 T-Unit 03/19/93)", GAME_SUPPORTS_SAVE )
12801314GAME( 1992, mkr4,     mk,      tunit_adpcm, mk,       mktunit,  ROT0, "Midway",   "Mortal Kombat (rev 4.0 T-Unit 02/11/93)", GAME_SUPPORTS_SAVE )
1315GAME( 1992, mkturbo,  mk,      tunit_adpcm, mk,       mkturbo,  ROT0, "Midway",   "Mortal Kombat Turbo Ninja (rev 3.1 T-Unit 03/19/93, hack)", GAME_SUPPORTS_SAVE )
12811316
12821317GAME( 1993, mk2,      0,       tunit_dcs,   mk2,      mk2,      ROT0, "Midway",   "Mortal Kombat II (rev L3.1)", GAME_SUPPORTS_SAVE )
12831318GAME( 1993, mk2r32,   mk2,     tunit_dcs,   mk2,      mk2,      ROT0, "Midway",   "Mortal Kombat II (rev L3.2 (European))", GAME_SUPPORTS_SAVE )
src/mame/drivers/niyanpai.c
r5534r5535
783783   MDRV_CPU_PROGRAM_MAP(niyanpai_map)
784784   MDRV_CPU_VBLANK_INT("screen", niyanpai_interrupt)
785785
786   MDRV_CPU_ADD("audiocpu", Z80, 8000000/1)               /* TMPZ84C011, 8.00 MHz */
786   MDRV_CPU_ADD("audiocpu", Z80, 8000000)               /* TMPZ84C011, 8.00 MHz */
787787   MDRV_CPU_CONFIG(daisy_chain_sound)
788788   MDRV_CPU_PROGRAM_MAP(niyanpai_sound_map)
789789   MDRV_CPU_IO_MAP(niyanpai_sound_io_map)
790790
791   MDRV_Z80CTC_ADD("ctc", 8000000/1 /* same as "audiocpu" */, ctc_intf)
791   MDRV_Z80CTC_ADD("ctc", 8000000 /* same as "audiocpu" */, ctc_intf)
792792
793793   MDRV_MACHINE_RESET(niyanpai)
794794   MDRV_NVRAM_HANDLER(generic_0fill)
src/mame/drivers/tiamc1.c
r5534r5535
66  special thanks to Shiru for his standalone emulator and documentation
77
88  Games supported:
9      * Billiard
910      * Konek-Gorbunok
11      * Snezhnaja Koroleva
1012      * S.O.S.
1113
1214  Other games known to exist on this hardware (interchangeable by the ROM swap):
1315      * Avtogonki
14      * Billiard
1516      * Istrebitel'
1617      * Kot-Rybolov
1718      * Kotigoroshko
1819      * Ostrov Drakona
1920      * Ostrov Sokrovisch
2021      * Perehvatchik
21      * Snezhnaja Koroleva
2222      * Zvezdnyj Rycar'
2323
2424 ***************************************************************
r5534r5535
312312
313313ROM_END
314314
315ROM_START( bilyard )
316   ROM_REGION( 0x10000, "maincpu", 0 )
317   ROM_LOAD( "04.1g", 0x00000, 0x2000, CRC(a44f913d) SHA1(f01a0e931fb0f719bc7b3f1ca7802dd747c8a56f) )
318   ROM_LOAD( "05.2g", 0x02000, 0x2000, CRC(6e41219f) SHA1(b09a16c9bd48b503ec0f2c636f021199d7ac7924) )
319   ROM_FILL( 0x04000, 0x2000, 0x00 ) /* 06.3g is unpopulated */
320   ROM_FILL( 0x06000, 0x2000, 0x00 ) /* 07.4g is unpopulated */
321   ROM_FILL( 0x08000, 0x2000, 0x00 ) /* 08.5g is unpopulated */
322   ROM_FILL( 0x0a000, 0x2000, 0x00 ) /* 09.6g is unpopulated */
323   ROM_LOAD( "10.7g", 0x0c000, 0x2000, CRC(173adb85) SHA1(53f27b45e61365907e8996c283ae70ca5b498129) )
324
325   ROM_REGION( 0x8000, "gfx1", 0 )
326   ROM_LOAD( "00.2a", 0x00000, 0x2000, CRC(6f72e043) SHA1(a60f66326ff0a55e2624231efcbceff700d9ceee) )
327   ROM_LOAD( "01.3a", 0x02000, 0x2000, CRC(daddbbb5) SHA1(1460aebcbb57180e05930845703ff6325d85702a) )
328   ROM_LOAD( "02.5a", 0x04000, 0x2000, CRC(3d744d33) SHA1(f1375098e81986715d0497b09df0c6622bd75b9a) )
329   ROM_LOAD( "03.6a", 0x06000, 0x2000, CRC(8bfc0b15) SHA1(221efdce516274d3b1d9009d11dc9ed6cd67ef12) )
330ROM_END
331
315332GAME( 1988, konek, 0, tiamc1, tiamc1, 0, ROT0, "Terminal", "Konek-Gorbunok", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
316333GAME( 1988, sosterm, 0, tiamc1, tiamc1, 0, ROT0, "Terminal", "S.O.S.", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
317334GAME( 1988, koroleva, 0, tiamc1, tiamc1, 0, ROT0, "Terminal", "Snezhnaja Koroleva", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
335GAME( 1988, bilyard, 0, tiamc1, tiamc1, 0, ROT0, "Terminal", "Billiard", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
src/mame/drivers/tmaster.c
r5534r5535
105105#include "cpu/m68000/m68000.h"
106106#include "deprecat.h"
107107#include "sound/okim6295.h"
108#include "machine/eeprom.h"
108#include "machine/eepromdev.h"
109109#include "machine/microtch.h"
110110#include "machine/68681.h"
111111
r5534r5535
212212                                Video & Blitter
213213
214214
215    Offset:     Bits:           Value:
215    Offset:     Bits:                     Value:
216216
217        02
218                fedc ba-- ---- ----
217        00
218
219        02      fedc ba-- ---- ----
219220                ---- --9- ---- ----       Layer 1 Buffer To Display
220221                ---- ---8 ---- ----       Layer 0 Buffer To Display
221222                ---- ---- 7654 3210
r5534r5535
239240                ---- ---- ---- --1-       Flip Y
240241                ---- ---- ---- ---0       Flip X
241242
242        12      fedc ba98 ---- ----       Solid Fill Pen
243    Addr Register:
244
245                fedc ba98 ---- ----       Solid Fill Pen
243246                ---- ---- 7654 3210       Source Address (high)
244247
245    A write to the source address (high) triggers the blit.
248    Color Register:
249
250                fedc ba98 ---- ----       Source Pen (Pen Replacement Mode)
251                ---- ---- 7654 3210       Palette (0-f) / Destination Pen (Pen Replacement Mode)
252
253    A write to the source address (mid) triggers the blit.
246254    A the end of the blit, a level 2 IRQ is issued.
247255
248256***************************************************************************/
r5534r5535
251259static UINT16 *tmaster_regs;
252260static UINT16 tmaster_color;
253261static UINT16 tmaster_addr;
262static UINT32 tmaster_gfx_offs, tmaster_gfx_size;
254263static int (*compute_addr) (UINT16 reg_low, UINT16 reg_mid, UINT16 reg_high);
255264
256265static int tmaster_compute_addr(UINT16 reg_low, UINT16 reg_mid, UINT16 reg_high)
r5534r5535
299308#endif
300309
301310
302   if (layers_ctrl & 1)   copybitmap         (bitmap,tmaster_bitmap[0][(tmaster_regs[0x02/2]>>8)&1],0,0,0,0,cliprect);
303   else               bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
311   bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
304312
305   if (layers_ctrl & 2)   copybitmap_trans   (bitmap,tmaster_bitmap[1][(tmaster_regs[0x02/2]>>9)&1],0,0,0,0,cliprect,0xff);
313   if (layers_ctrl & 1)   copybitmap_trans(bitmap, tmaster_bitmap[0][(tmaster_regs[0x02/2]>>8)&1], 0,0,0,0, cliprect, 0xff);
314   if (layers_ctrl & 2)   copybitmap_trans(bitmap, tmaster_bitmap[1][(tmaster_regs[0x02/2]>>9)&1], 0,0,0,0, cliprect, 0xff);
306315
307316   return 0;
308317}
r5534r5535
310319static WRITE16_HANDLER( tmaster_color_w )
311320{
312321   COMBINE_DATA( &tmaster_color );
313#if 0
314   if (tmaster_color & ~7)
315      logerror("%06x: color %04x\n", cpu_get_pc(space->cpu), tmaster_color);
316#endif
317322}
318323
319324static WRITE16_HANDLER( tmaster_addr_w )
r5534r5535
325330{
326331   int x,y,x0,x1,y0,y1,dx,dy,flipx,flipy,sx,sy,sw,sh, addr, mode, layer,buffer, color;
327332
328   UINT8 *gfxdata   =   memory_region( machine, "gfx1" );
329   size_t size      =   memory_region_length( machine, "gfx1" );
333   UINT8 *gfxdata   =   memory_region( machine, "blitter" ) + tmaster_gfx_offs;
330334
331   UINT16 data;
335   UINT16 pen;
332336
333337   bitmap_t *bitmap;
334338
r5534r5535
348352
349353   addr <<= 1;
350354
355#ifdef MAME_DEBUG
351356#if 0
352   logerror("%s: blit w %03x, h %02x, x %03x, y %02x, addr %06x, mode %02x\n", cpuexec_describe_context(machine),
353         sw,sh,sx,sy, addr, mode
357   logerror("%s: blit w %03x, h %02x, x %03x, y %02x, src %06x, fill/addr %04x, repl/color %04x, mode %02x\n", cpuexec_describe_context(machine),
358         sw,sh,sx,sy, addr, tmaster_addr, tmaster_color, mode
354359   );
355360#endif
361#endif
356362
357363   flipx = mode & 1;
358364   flipy = mode & 2;
r5534r5535
366372   sx = (sx & 0x7fff) - (sx & 0x8000);
367373   sy = (sy & 0x7fff) - (sy & 0x8000);
368374
369   color = (tmaster_color & 7) << 8;
375   color = (tmaster_color & 0x0f) << 8;
370376
371377   switch (mode & 0x20)
372378   {
373379      case 0x00:                     // blit with transparency
374         if (addr > size - sw*sh)
380         if (addr > tmaster_gfx_size - sw*sh)
375381         {
376382            logerror("%s: blit error, addr %06x out of bounds\n", cpuexec_describe_context(machine),addr);
377            addr = size - sw*sh;
383            addr = tmaster_gfx_size - sw*sh;
378384         }
379385
380         for (y = y0; y != y1; y += dy)
386         if ( mode & 0x200 )
381387         {
382            for (x = x0; x != x1; x += dx)
388            // copy from ROM, replacing occurrences of src pen with dst pen
389
390            UINT8 dst_pen = (tmaster_color >> 8) & 0xff;
391            UINT8 src_pen = (tmaster_color >> 0) & 0xff;
392
393            for (y = y0; y != y1; y += dy)
383394            {
384               data = gfxdata[addr++];
395               for (x = x0; x != x1; x += dx)
396               {
397                  pen = gfxdata[addr++];
385398
386               if ((data != 0xff) && (sx + x >= 0) && (sx + x < 400) && (sy + y >= 0) && (sy + y < 256))
387                  *BITMAP_ADDR16(bitmap, sy + y, sx + x) = data + color;
399                  if (pen == src_pen)
400                     pen = dst_pen;
401
402                  if ((pen != 0xff) && (sx + x >= 0) && (sx + x < 400) && (sy + y >= 0) && (sy + y < 256))
403                     *BITMAP_ADDR16(bitmap, sy + y, sx + x) = pen + color;
404               }
388405            }
389406         }
407         else
408         {
409            // copy from ROM as is
410
411            for (y = y0; y != y1; y += dy)
412            {
413               for (x = x0; x != x1; x += dx)
414               {
415                  pen = gfxdata[addr++];
416
417                  if ((pen != 0xff) && (sx + x >= 0) && (sx + x < 400) && (sy + y >= 0) && (sy + y < 256))
418                     *BITMAP_ADDR16(bitmap, sy + y, sx + x) = pen + color;
419               }
420            }
421         }
390422         break;
391423
392424      case 0x20:                     // solid fill
393         data = ((tmaster_addr >> 8) & 0xff) + color;
425         pen = ((tmaster_addr >> 8) & 0xff) + color;
426
427         if ((pen & 0xff) == 0xff)
428            pen = 0xff;
429
394430         for (y = y0; y != y1; y += dy)
395431         {
396432            for (x = x0; x != x1; x += dx)
397433            {
398434               if ((sx + x >= 0) && (sx + x < 400) && (sy + y >= 0) && (sy + y < 256))
399                  *BITMAP_ADDR16(bitmap, sy + y, sx + x) = data;
435                  *BITMAP_ADDR16(bitmap, sy + y, sx + x) = pen;
400436            }
401437         }
402438         break;
r5534r5535
455491
456492   AM_RANGE( 0x580000, 0x580001 ) AM_WRITENOP // often
457493
458   AM_RANGE( 0x600000, 0x600fff ) AM_READWRITE( SMH_RAM, paletteram16_xBBBBBGGGGGRRRRR_word_w ) AM_BASE(&paletteram16) // looks like palettes, maybe
494   AM_RANGE( 0x600000, 0x601fff ) AM_READWRITE( SMH_RAM, paletteram16_xBBBBBGGGGGRRRRR_word_w ) AM_BASE(&paletteram16)
459495
460496   AM_RANGE( 0x800000, 0x800001 ) AM_DEVREADWRITE8( "oki", okim6295_r, okim6295_w, 0x00ff )
461497
r5534r5535
467503                                Galaxy Games
468504***************************************************************************/
469505
470// NVRAM
506// ROM/RAM Banking
471507
508#define GALGAMES_BANK_000000_R   1
509#define GALGAMES_BANK_000000_W   2
510#define GALGAMES_BANK_200000_R   3
511#define GALGAMES_BANK_200000_W   4
512#define GALGAMES_BANK_240000_R   5
513
514#define GALGAMES_RAM   0
515#define GALGAMES_ROM0   1
516#define GALGAMES_ROM1   2
517#define GALGAMES_ROM2   3
518#define GALGAMES_ROM3   4
519
520static UINT16 *galgames_ram;
521static UINT16 galgames_cart;
522
523// NVRAM (5 x EEPROM)
524
472525static const eeprom_interface galgames_eeprom_interface =
473526{
474527   10,               // address bits 10
r5534r5535
482535   1               // reset_delay
483536};
484537
538#define GALGAMES_EEPROM_BIOS  "eeprom_bios"
539#define GALGAMES_EEPROM_CART1 "eeprom_cart1"
540#define GALGAMES_EEPROM_CART2 "eeprom_cart2"
541#define GALGAMES_EEPROM_CART3 "eeprom_cart3"
542#define GALGAMES_EEPROM_CART4 "eeprom_cart4"
543
544const char const *galgames_eeprom_names[5] = { GALGAMES_EEPROM_BIOS, GALGAMES_EEPROM_CART1, GALGAMES_EEPROM_CART2, GALGAMES_EEPROM_CART3, GALGAMES_EEPROM_CART4 };
545
485546static READ16_HANDLER( galgames_eeprom_r )
486547{
487   return eeprom_read_bit() ? 0x80 : 0x00;
548   const device_config *eeprom = devtag_get_device(space->machine, galgames_eeprom_names[galgames_cart]);
549
550   return eepromdev_read_bit(eeprom) ? 0x80 : 0x00;
488551}
489552
490553static WRITE16_HANDLER( galgames_eeprom_w )
r5534r5535
494557
495558   if ( ACCESSING_BITS_0_7 )
496559   {
560      const device_config *eeprom = devtag_get_device(space->machine, galgames_eeprom_names[galgames_cart]);
561
497562      // latch the bit
498      eeprom_write_bit(data & 0x0001);
563      eepromdev_write_bit(eeprom, data & 0x0001);
499564
500565      // clock line asserted: write latch or select next bit to read
501      eeprom_set_clock_line((data & 0x0002) ? ASSERT_LINE : CLEAR_LINE );
566      eepromdev_set_clock_line(eeprom, (data & 0x0002) ? ASSERT_LINE : CLEAR_LINE );
502567   }
503568}
504569
505static NVRAM_HANDLER( galgames )
506{
507   if (read_or_write)
508      eeprom_save(file);
509   else
510   {
511      eeprom_init(machine, &galgames_eeprom_interface);
512      if (file)   eeprom_load(file);
513   }
514}
515
516570// BT481A Palette RAMDAC
517571static UINT32 palette_offset;
518572static UINT8 palette_index;
r5534r5535
533587      palette_data[palette_index] = data & 0xff;
534588      if (++palette_index == 3)
535589      {
536         palette_set_color(space->machine, palette_offset, MAKE_RGB(palette_data[0], palette_data[1], palette_data[2]));
590         int palette_base;
591         for (palette_base = 0; palette_base < 0x1000; palette_base += 0x100)
592            palette_set_color(space->machine, palette_offset + palette_base, MAKE_RGB(palette_data[0], palette_data[1], palette_data[2]));
537593         palette_index = 0;
538594         palette_offset++;
539595      }
r5534r5535
551607      memory_region(space->machine, "oki")[offset] = data & 0xff;
552608}
553609
610// Carts (preliminary, PIC communication is not implemented)
554611
555// Carts communication (preliminary, no cart is dumped yet)
612static void galgames_update_rombank(running_machine *machine, UINT32 cart)
613{
614   galgames_cart = cart;
556615
616   tmaster_gfx_offs = 0x200000 * cart;
617
618   if (memory_get_bank(machine, GALGAMES_BANK_000000_R) == GALGAMES_RAM)
619      memory_set_bank(machine, GALGAMES_BANK_200000_R, GALGAMES_ROM0 + galgames_cart);   // rom
620
621   memory_set_bank(machine, GALGAMES_BANK_240000_R, GALGAMES_ROM0 + galgames_cart);   // rom
622}
623
557624static WRITE16_HANDLER( galgames_cart_sel_w )
558625{
559626   // cart selection (0 1 2 3 4 7)
560627
561   // 7 resets the eeprom
562628   if (ACCESSING_BITS_0_7)
563      eeprom_set_cs_line(((data&0xff) == 0x07) ? ASSERT_LINE : CLEAR_LINE);
629   {
630      int i;
631
632      switch( data & 0xff )
633      {
634         case 0x07:      // 7 resets the eeprom
635            for (i = 0; i < 5; i++)
636               eepromdev_set_cs_line(devtag_get_device(space->machine, galgames_eeprom_names[i]), ASSERT_LINE);
637            break;
638
639         case 0x00:
640         case 0x01:
641         case 0x02:
642         case 0x03:
643         case 0x04:
644            eepromdev_set_cs_line(devtag_get_device(space->machine, galgames_eeprom_names[data & 0xff]), CLEAR_LINE);
645            galgames_update_rombank(space->machine, data & 0xff);
646            break;
647
648         default:
649            eepromdev_set_cs_line(devtag_get_device(space->machine, galgames_eeprom_names[0]), CLEAR_LINE);
650            galgames_update_rombank(space->machine, 0);
651            logerror("%06x: unknown cart sel = %04x\n", cpu_get_pc(space->cpu), data);
652            break;
653      }
654   }
564655}
565656
566657static READ16_HANDLER( galgames_cart_clock_r )
r5534r5535
577668      // ROM/RAM banking
578669      if ((data & 0xf7) == 0x05)
579670      {
580         memory_set_bank(space->machine, 1, 1);   // ram
581         memory_set_bank(space->machine, 3, 0);   // rom
671         memory_set_bank(space->machine, GALGAMES_BANK_000000_R, GALGAMES_RAM);   // ram
672         galgames_update_rombank(space->machine, galgames_cart);
582673         logerror("%06x: romram bank = %04x\n", cpu_get_pc(space->cpu), data);
583674      }
584675      else
585676      {
586         memory_set_bank(space->machine, 1, 0);   // rom
677         memory_set_bank(space->machine, GALGAMES_BANK_000000_R, GALGAMES_ROM0);   // rom
678         memory_set_bank(space->machine, GALGAMES_BANK_200000_R, GALGAMES_RAM);   // ram
587679         logerror("%06x: unknown romram bank = %04x\n", cpu_get_pc(space->cpu), data);
588680      }
589681   }
r5534r5535
605697
606698static ADDRESS_MAP_START( galgames_map, ADDRESS_SPACE_PROGRAM, 16 )
607699
608   AM_RANGE( 0x000000, 0x03ffff ) AM_READWRITE(SMH_BANK(1), SMH_BANK(2))
609   AM_RANGE( 0x040000, 0x1fffff ) AM_ROM AM_REGION( "maincpu", 0 )
610   AM_RANGE( 0x200000, 0x23ffff ) AM_READWRITE(SMH_BANK(3), SMH_BANK(4))
611   AM_RANGE( 0x240000, 0x3fffff ) AM_ROM AM_REGION( "maincpu", 0 )
700   AM_RANGE( 0x000000, 0x03ffff ) AM_READWRITE(SMH_BANK(GALGAMES_BANK_000000_R), SMH_BANK(GALGAMES_BANK_000000_W)) AM_BASE( &galgames_ram )
701   AM_RANGE( 0x040000, 0x1fffff ) AM_ROM AM_REGION( "maincpu", 0x40000 )
702   AM_RANGE( 0x200000, 0x23ffff ) AM_READWRITE(SMH_BANK(GALGAMES_BANK_200000_R), SMH_BANK(GALGAMES_BANK_200000_W))
703   AM_RANGE( 0x240000, 0x3fffff ) AM_READ(SMH_BANK(GALGAMES_BANK_240000_R))
612704
613705   AM_RANGE( 0x400000, 0x400011 ) AM_WRITE( tmaster_blitter_w ) AM_BASE( &tmaster_regs )
614706   AM_RANGE( 0x400012, 0x400013 ) AM_WRITE( tmaster_addr_w )
r5534r5535
753845
754846static MACHINE_RESET( tmaster )
755847{
848   tmaster_gfx_offs = 0;
849   tmaster_gfx_size = memory_region_length(machine, "blitter");
850
756851   tmaster_devices.duart68681 = devtag_get_device( machine, "duart68681" );
757852}
758853
r5534r5535
787882
788883   MDRV_NVRAM_HANDLER(generic_0fill)
789884
790
791885   MDRV_SCREEN_ADD("screen", RASTER)
792886   MDRV_SCREEN_REFRESH_RATE(60)
793887   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
r5534r5535
795889   MDRV_SCREEN_SIZE(400, 256)
796890   MDRV_SCREEN_VISIBLE_AREA(0, 400-1, 0, 256-1)
797891
798   MDRV_PALETTE_LENGTH(0x800)
892   MDRV_PALETTE_LENGTH(0x1000)
799893
800894   MDRV_VIDEO_START(tmaster)
801895   MDRV_VIDEO_UPDATE(tmaster)
r5534r5535
829923
830924static MACHINE_RESET( galgames )
831925{
832   memory_set_bank(machine, 1, 0);   // rom
833   memory_set_bank(machine, 3, 1);   // ram
926   tmaster_gfx_offs = 0;
927   tmaster_gfx_size = 0x200000;
834928
835   memory_set_bank(machine, 2, 0);   // ram
836   memory_set_bank(machine, 4, 0);   // ram
929   memory_set_bank(machine, GALGAMES_BANK_000000_R, GALGAMES_ROM0);   // rom
930   memory_set_bank(machine, GALGAMES_BANK_000000_W, GALGAMES_RAM);      // ram
837931
932   memory_set_bank(machine, GALGAMES_BANK_200000_R, GALGAMES_RAM);      // ram
933   memory_set_bank(machine, GALGAMES_BANK_200000_W, GALGAMES_RAM);      // ram
934
935   memory_set_bank(machine, GALGAMES_BANK_240000_R, GALGAMES_ROM0);   // rom
936
937   galgames_update_rombank(machine, 0);
938
838939   device_reset(cputag_get_cpu(machine, "maincpu"));
839940}
840941
942UINT8 *galgames_eeprom_data = NULL;
943
841944static MACHINE_DRIVER_START( galgames )
842945   MDRV_CPU_ADD("maincpu", M68000, XTAL_24MHz / 2)
843946   MDRV_CPU_PROGRAM_MAP(galgames_map)
844947   MDRV_CPU_VBLANK_INT_HACK(galgames_interrupt, 1+20)   // ??
845948
846   MDRV_NVRAM_HANDLER( galgames )
949   // 5 EEPROMs on the motherboard (for BIOS + 4 Carts)
950   MDRV_EEPROM_ADD(GALGAMES_EEPROM_BIOS,  galgames_eeprom_interface, 0, galgames_eeprom_data)
951   MDRV_EEPROM_ADD(GALGAMES_EEPROM_CART1, galgames_eeprom_interface, 0, galgames_eeprom_data)
952   MDRV_EEPROM_ADD(GALGAMES_EEPROM_CART2, galgames_eeprom_interface, 0, galgames_eeprom_data)
953   MDRV_EEPROM_ADD(GALGAMES_EEPROM_CART3, galgames_eeprom_interface, 0, galgames_eeprom_data)
954   MDRV_EEPROM_ADD(GALGAMES_EEPROM_CART4, galgames_eeprom_interface, 0, galgames_eeprom_data)
955
847956   MDRV_MACHINE_RESET( galgames )
848957
849958   /* video hardware */
r5534r5535
854963   MDRV_SCREEN_SIZE(400, 256)
855964   MDRV_SCREEN_VISIBLE_AREA(0, 400-1, 0, 256-1)
856965
857   MDRV_PALETTE_LENGTH(0x800)   // only 0x100 used
966   MDRV_PALETTE_LENGTH(0x1000)   // only 0x100 used
858967
859968   MDRV_VIDEO_START(galgames)
860969   MDRV_VIDEO_UPDATE(tmaster)
r5534r5535
867976   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
868977MACHINE_DRIVER_END
869978
979/*
980    Each cartridge contains a PIC, that should provide, among other things, the following header:
981
982    4345 5331 3939 3700 0c10 ffb3 3c00 0000       "CES1997"
983    fffe f2f7 8557 c119 0000 0000 2340 188e
984*/
985static MACHINE_DRIVER_START( galgame2 )
986   MDRV_IMPORT_FROM(galgames)
987//  MDRV_CPU_ADD("pic", PIC12C508, XTAL_24MHz / 2)
988MACHINE_DRIVER_END
989
990
870991/***************************************************************************
871992
872993                               ROMs Loading
r5534r5535
8941015   ROM_LOAD16_BYTE( "tmaster.u51", 0x000000, 0x080000, CRC(edaa5874) SHA1(48b99bc7f5a6453def265967ca7d8eefdf9dc97b) ) /* Ver: 3.00 Euro 11-25-96 */
8951016   ROM_LOAD16_BYTE( "tmaster.u52", 0x000001, 0x080000, CRC(e9fd30fc) SHA1(d91ea05d5f574603883336729fb9df705688945d) ) /* Ver: 3.00 Euro 11-25-96 */
8961017
897   ROM_REGION( 0x400000, "gfx1", ROMREGION_ERASE )   // Blitter gfx
1018   ROM_REGION( 0x400000, "blitter", ROMREGION_ERASE )   // Blitter gfx
8981019   ROM_LOAD16_BYTE( "tmaster.u38", 0x100000, 0x080000, CRC(68885ef6) SHA1(010602b59c33c3e490491a296ddaf8952e315b83) )
8991020   ROM_LOAD16_BYTE( "tmaster.u36", 0x100001, 0x080000, CRC(204096ec) SHA1(9239923b7eedb6003c63ef2e8ff224edee657bbc) )
9001021   // unused gap
r5534r5535
9331054   ROM_LOAD16_BYTE( "tm2k_v402.u51", 0x000000, 0x100000, CRC(fa6d168c) SHA1(c458d1114c658ac963a22cdb74ee5ea489ddcbba) ) /* Ver: 4.02 Standard 5-30-97 */
9341055   ROM_LOAD16_BYTE( "tm2k_v402.u52", 0x000001, 0x100000, CRC(4e9c2d42) SHA1(67e34778f21010c43c1247179faa3f7ede5ad8d0) ) /* Ver: 4.02 Standard 5-30-97 */
9351056
936   ROM_REGION( 0x400000, "gfx1", ROMREGION_ERASE )   // Blitter gfx
1057   ROM_REGION( 0x400000, "blitter", ROMREGION_ERASE )   // Blitter gfx
9371058   ROM_LOAD16_BYTE( "tm2k_graphic.u38", 0x100000, 0x080000, CRC(22bb6cc5) SHA1(fc6cfd4e1e6e1455d648a7b63f2c8e37cdfe86d6) )
9381059   ROM_LOAD16_BYTE( "tm2k_graphic.u36", 0x100001, 0x080000, CRC(7f0840ac) SHA1(1c3af419d571579a3f2c561617d55914d28ef22b) )
9391060   ROM_LOAD16_BYTE( "tm2k_graphic.u39", 0x300000, 0x080000, CRC(059e1bd8) SHA1(7451c1cfa0d090b0566e353738a1ffba732a8ad2) )
r5534r5535
9891110   ROM_LOAD16_BYTE( "tm3k_v502.u51", 0x000000, 0x100000, CRC(6267e2bd) SHA1(c81e5cd059a9ad2f6a36261738e39740a1a3a03f) ) /* TOUCHMASTER 3000 U51 DOMESTIC 5.02 (Standard 11-17-97) (yellow label) */
9901111   ROM_LOAD16_BYTE( "tm3k_v502.u52", 0x000001, 0x100000, CRC(836fdf1e) SHA1(2ee9c0929950afb72f172b253d6c392e9a698037) ) /* TOUCHMASTER 3000 U52 DOMESTIC 5.02 (Standard 11-17-97) (yellow label) */
9911112
992   ROM_REGION( 0x600000, "gfx1", 0 )   // Blitter gfx
1113   ROM_REGION( 0x600000, "blitter", 0 )   // Blitter gfx
9931114   ROM_LOAD16_BYTE( "tm3k_graphic.u38", 0x000000, 0x100000, CRC(a6683899) SHA1(d05024390917cdb1871d030996da8e1eb6460918) ) /* Labeled TOUCHMASTER U38 STANDARD 5.0 (pink label) */
9941115   ROM_LOAD16_BYTE( "tm3k_graphic.u36", 0x000001, 0x100000, CRC(7bde520d) SHA1(77750b689e2f0d47804042456e54bbd9c28deeac) ) /* Labeled TOUCHMASTER U36 STANDARD 5.0 (pink label) */
9951116   ROM_LOAD16_BYTE( "tm3k_graphic.u39", 0x200000, 0x100000, CRC(206b56a6) SHA1(09e5e05bffd0a09abd24d668e2c59b56f2c79134) ) /* Labeled TOUCHMASTER U39 STANDARD 5.0 (pink label) */
r5534r5535
10061127   ROM_LOAD16_BYTE( "tm3k_v501.u51", 0x000000, 0x100000, CRC(c9522279) SHA1(e613b791f831271722f05b7e96c35519fa9fc174) ) /* TOUCHMASTER 3000 U51 DOMESTIC 5.01 (Standard 11-4-97) (yellow label) */
10071128   ROM_LOAD16_BYTE( "tm3k_v501.u52", 0x000001, 0x100000, CRC(8c6a0db7) SHA1(6b0eae60ea471cd8c4001749ac2677d8d4532567) ) /* TOUCHMASTER 3000 U52 DOMESTIC 5.01 (Standard 11-4-97) (yellow label) */
10081129
1009   ROM_REGION( 0x600000, "gfx1", 0 )   // Blitter gfx
1130   ROM_REGION( 0x600000, "blitter", 0 )   // Blitter gfx
10101131   ROM_LOAD16_BYTE( "tm3k_graphic.u38", 0x000000, 0x100000, CRC(a6683899) SHA1(d05024390917cdb1871d030996da8e1eb6460918) ) /* Labeled TOUCHMASTER U38 STANDARD 5.0 (pink label) */
10111132   ROM_LOAD16_BYTE( "tm3k_graphic.u36", 0x000001, 0x100000, CRC(7bde520d) SHA1(77750b689e2f0d47804042456e54bbd9c28deeac) ) /* Labeled TOUCHMASTER U36 STANDARD 5.0 (pink label) */
10121133   ROM_LOAD16_BYTE( "tm3k_graphic.u39", 0x200000, 0x100000, CRC(206b56a6) SHA1(09e5e05bffd0a09abd24d668e2c59b56f2c79134) ) /* Labeled TOUCHMASTER U39 STANDARD 5.0 (pink label) */
r5534r5535
10521173   ROM_LOAD16_BYTE( "tm4k_v602.u51", 0x000000, 0x100000, CRC(3d8d7848) SHA1(31638f23cdd5e6cfbb2270e953f84fe1bd437950) ) /* TOUCHMASTER 4000 U51 DOMESTIC  6.02 (Standard 4-14-98) */
10531174   ROM_LOAD16_BYTE( "tm4k_v602.u52", 0x000001, 0x100000, CRC(6d412871) SHA1(ae27c7723b292daf6682c53bafac22e4a3cd1ece) ) /* TOUCHMASTER 4000 U52 DOMESTIC  6.02 (Standard 4-14-98) */
10541175
1055   ROM_REGION( 0x600000, "gfx1", 0 )   // Blitter gfx
1176   ROM_REGION( 0x600000, "blitter", 0 )   // Blitter gfx
10561177   ROM_LOAD16_BYTE( "tm4k_graphic.u38", 0x000000, 0x100000, CRC(a6683899) SHA1(d05024390917cdb1871d030996da8e1eb6460918) ) /* Mask rom labeled 5341-15746-03 U38 VIDEO IMAGE */
10571178   ROM_LOAD16_BYTE( "tm4k_graphic.u36", 0x000001, 0x100000, CRC(7bde520d) SHA1(77750b689e2f0d47804042456e54bbd9c28deeac) ) /* Mask rom labeled 5341-15746-01 U36 VIDEO IMAGE */
10581179   ROM_LOAD16_BYTE( "tm4k_graphic.u39", 0x200000, 0x100000, CRC(bac88cfb) SHA1(26ed169296b890c5f5b50c418c15299355a6592f) ) /* Mask rom labeled 5341-15746-04 U39 VIDEO IMAGE */
r5534r5535
10971218   ROM_LOAD16_BYTE( "tm5k_v7_10.u51", 0x000000, 0x100000, CRC(df0bd25e) SHA1(db1a197ed4c868743397f3823f3f1d42b9329f80) ) /* TOUCHMASTER 5000 U51 DOMESTIC 7.10 (Standard 10-9-98) (tan label) */
10981219   ROM_LOAD16_BYTE( "tm5k_v7_10.u52", 0x000001, 0x100000, CRC(ddf9e8dc) SHA1(3228f2eba067bdf1bd639116bffc589585ea3e72) ) /* TOUCHMASTER 5000 U52 DOMESTIC 7.10 (Standard 10-9-98) (tan label) */
10991220
1100   ROM_REGION( 0x600000, "gfx1", 0 )   // Blitter gfx
1221   ROM_REGION( 0x600000, "blitter", 0 )   // Blitter gfx
11011222   ROM_LOAD16_BYTE( "tm5k_graphic.u38", 0x000000, 0x100000, CRC(93038e7c) SHA1(448f69bf51ac992f6b35b471cba9675c67984cd7) ) /* Mask rom labeled 5341-15951-07 U38 VIDEO IMAGE */
11021223   ROM_LOAD16_BYTE( "tm5k_graphic.u36", 0x000001, 0x100000, CRC(5453a44a) SHA1(094439a56336ca933b0b7ede8c057546d1d490b2) ) /* Mask rom labeled 5341-15951-06 U36 VIDEO IMAGE */
11031224   ROM_LOAD16_BYTE( "tm5k_graphic.u39", 0x200000, 0x100000, CRC(1349fdc7) SHA1(5118983be584455320f0d6006133f38e6a8ee0d8) ) /* Mask rom labeled 5341-15951-05 U39 VIDEO IMAGE */
r5534r5535
11141235   ROM_LOAD16_BYTE( "tm5kca_v7_10.u51", 0x000000, 0x100000, CRC(7c03708f) SHA1(e1f8198bc03c1f9d2a00662b589fd66fdcc7a2de) ) /* TOUCHMASTER 5000 U51 CALIFORNIA 7.10 (CA. 10-9-98) (tan label) */
11151236   ROM_LOAD16_BYTE( "tm5kca_v7_10.u52", 0x000001, 0x100000, CRC(f1413295) SHA1(ad6b57c590bdae063b0e4a1abcb3b13ee52cd6db) ) /* TOUCHMASTER 5000 U52 CALIFORNIA 7.10 (CA. 10-9-98) (tan label) */
11161237
1117   ROM_REGION( 0x600000, "gfx1", 0 )   // Blitter gfx
1238   ROM_REGION( 0x600000, "blitter", 0 )   // Blitter gfx
11181239   ROM_LOAD16_BYTE( "tm5k_graphic.u38", 0x000000, 0x100000, CRC(93038e7c) SHA1(448f69bf51ac992f6b35b471cba9675c67984cd7) ) /* Mask rom labeled 5341-15951-07 U38 VIDEO IMAGE */
11191240   ROM_LOAD16_BYTE( "tm5k_graphic.u36", 0x000001, 0x100000, CRC(5453a44a) SHA1(094439a56336ca933b0b7ede8c057546d1d490b2) ) /* Mask rom labeled 5341-15951-06 U36 VIDEO IMAGE */
11201241   ROM_LOAD16_BYTE( "tm5k_graphic.u39", 0x200000, 0x100000, CRC(1349fdc7) SHA1(5118983be584455320f0d6006133f38e6a8ee0d8) ) /* Mask rom labeled 5341-15951-05 U39 VIDEO IMAGE */
r5534r5535
11311252   ROM_LOAD16_BYTE( "tm5k_v7_01.u51", 0x000000, 0x100000, CRC(3ff68213) SHA1(ec4939899a69f56d2437c806fdd0a5b50e58ec6a) ) /* TOUCHMASTER 5000 U51 DOMESTIC 7.01 (Standard 8-21-98) (pink label) */
11321253   ROM_LOAD16_BYTE( "tm5k_v7_01.u52", 0x000001, 0x100000, CRC(b3de607c) SHA1(4ede5b8c50177d1934a3b93d311a240ef354c450) ) /* TOUCHMASTER 5000 U52 DOMESTIC 7.01 (Standard 8-21-98) (pink label) */
11331254
1134   ROM_REGION( 0x600000, "gfx1", 0 )   // Blitter gfx
1255   ROM_REGION( 0x600000, "blitter", 0 )   // Blitter gfx
11351256   ROM_LOAD16_BYTE( "tm5k_graphic.u38", 0x000000, 0x100000, CRC(93038e7c) SHA1(448f69bf51ac992f6b35b471cba9675c67984cd7) ) /* Mask rom labeled 5341-15951-07 U38 VIDEO IMAGE */
11361257   ROM_LOAD16_BYTE( "tm5k_graphic.u36", 0x000001, 0x100000, CRC(5453a44a) SHA1(094439a56336ca933b0b7ede8c057546d1d490b2) ) /* Mask rom labeled 5341-15951-06 U36 VIDEO IMAGE */
11371258   ROM_LOAD16_BYTE( "tm5k_graphic.u39", 0x200000, 0x100000, CRC(1349fdc7) SHA1(5118983be584455320f0d6006133f38e6a8ee0d8) ) /* Mask rom labeled 5341-15951-05 U39 VIDEO IMAGE */
r5534r5535
11791300   ROM_LOAD16_BYTE( "tm7k_v804.u51", 0x000000, 0x100000, CRC(2461af04) SHA1(9cf37c04db0297ff8f9f316fd476d6d5d1c39acf) ) /* TOUCHMASTER 7000 U51 DOMESTIC 8.04 (Standard 06/02/99) (orange label) */
11801301   ROM_LOAD16_BYTE( "tm7k_v804.u52", 0x000001, 0x100000, CRC(5d39fad2) SHA1(85e8d110b88e1099117ab7963eaee47dc86ec7c5) ) /* TOUCHMASTER 7000 U52 DOMESTIC 8.04 (Standard 06/02/99) (orange label) */
11811302
1182   ROM_REGION( 0x600000, "gfx1", 0 )   // Blitter gfx
1303   ROM_REGION( 0x600000, "blitter", 0 )   // Blitter gfx
11831304   ROM_LOAD16_BYTE( "tm7k_graphic.u38", 0x000000, 0x100000, CRC(93038e7c) SHA1(448f69bf51ac992f6b35b471cba9675c67984cd7) ) /* Mask rom labeled 5341-16262-07 U38 VIDEO IMAGE */
11841305   ROM_LOAD16_BYTE( "tm7k_graphic.u36", 0x000001, 0x100000, CRC(5453a44a) SHA1(094439a56336ca933b0b7ede8c057546d1d490b2) ) /* Mask rom labeled 5341-16262-06 U36 VIDEO IMAGE */
11851306   ROM_LOAD16_BYTE( "tm7k_graphic.u39", 0x200000, 0x100000, CRC(26af8da8) SHA1(02555b1597a4962f1fd0c3ffc89e5c8338aa3085) ) /* Mask rom labeled 5341-16262-05 U39 VIDEO IMAGE */
r5534r5535
11961317   ROM_LOAD16_BYTE( "tm7k_v800.u51", 0x000000, 0x100000, CRC(83ec3da7) SHA1(37fa7183e7acc2eab35ac431d99cbbfe4862979e) ) /* TOUCHMASTER 7000 U51 DOMESTIC 8.00 (Standard 03/26/99) (orange label) */
11971318   ROM_LOAD16_BYTE( "tm7k_v800.u52", 0x000001, 0x100000, CRC(e2004282) SHA1(aa73029f31e2062cabedfcd778db97b314624ae8) ) /* TOUCHMASTER 7000 U52 DOMESTIC 8.00 (Standard 03/26/99) (orange label) */
11981319
1199   ROM_REGION( 0x600000, "gfx1", 0 )   // Blitter gfx
1320   ROM_REGION( 0x600000, "blitter", 0 )   // Blitter gfx
12001321   ROM_LOAD16_BYTE( "tm7k_graphic.u38", 0x000000, 0x100000, CRC(93038e7c) SHA1(448f69bf51ac992f6b35b471cba9675c67984cd7) ) /* Labeled GRAPHIC U38  8.0 (orange label) */
12011322   ROM_LOAD16_BYTE( "tm7k_graphic.u36", 0x000001, 0x100000, CRC(5453a44a) SHA1(094439a56336ca933b0b7ede8c057546d1d490b2) ) /* Labeled GRAPHIC U36  8.0 (orange label) */
12021323   ROM_LOAD16_BYTE( "tm7k_graphic.u39", 0x200000, 0x100000, CRC(26af8da8) SHA1(02555b1597a4962f1fd0c3ffc89e5c8338aa3085) ) /* Labeled GRAPHIC U39  8.0 (orange label) */
r5534r5535
12131334   ROM_LOAD16_BYTE( "tm7k_v81x.u51", 0x000000, 0x100000, CRC(57c88287) SHA1(1008bbcd137ede321be4cc2ad22e3982d880471b) ) /* TOUCHMASTER 7000 U51 8.1X (ASI Standard 03/08/99) (white label) */
12141335   ROM_LOAD16_BYTE( "tm7k_v81x.u52", 0x000001, 0x100000, CRC(e45d69bb) SHA1(9e8a42924a9cd573cbd2f3164d0fb468eee7ff51) ) /* TOUCHMASTER 7000 U52 8.1X (ASI Standard 03/08/99) (white label) */
12151336
1216   ROM_REGION( 0x600000, "gfx1", 0 )   // Blitter gfx
1337   ROM_REGION( 0x600000, "blitter", 0 )   // Blitter gfx
12171338   ROM_LOAD16_BYTE( "tm7k_graphic.u38", 0x000000, 0x100000, CRC(93038e7c) SHA1(448f69bf51ac992f6b35b471cba9675c67984cd7) ) /* TOUCHMASTER EDCE V8.X U38 (white label) */
12181339   ROM_LOAD16_BYTE( "tm7k_graphic.u36", 0x000001, 0x100000, CRC(5453a44a) SHA1(094439a56336ca933b0b7ede8c057546d1d490b2) ) /* TOUCHMASTER DB7F V8.X U36 (white label) */
12191340   ROM_LOAD16_BYTE( "tm7k_graphic.u39", 0x200000, 0x100000, CRC(26af8da8) SHA1(02555b1597a4962f1fd0c3ffc89e5c8338aa3085) ) /* TOUCHMASTER 2BB6 V8.X U39 (white label) */
r5534r5535
12581379   ROM_LOAD16_BYTE( "tm8k_v904.u51", 0x000000, 0x100000, CRC(28864ec8) SHA1(e703f9ee350dd915102e784bbd04445a95b7d0a5) ) /* TOUCHMASTER 8000 U51 DOMESTIC 9.04 (Standard 04/25/00) */
12591380   ROM_LOAD16_BYTE( "tm8k_v904.u52", 0x000001, 0x100000, CRC(c123eec2) SHA1(3e9c84755b18a4fd900068f385ee47107771391d) ) /* TOUCHMASTER 8000 U52 DOMESTIC 9.04 (Standard 04/25/00) */
12601381
1261   ROM_REGION( 0x600000, "gfx1", 0 )   // Blitter gfx
1382   ROM_REGION( 0x600000, "blitter", 0 )   // Blitter gfx
12621383   ROM_LOAD16_BYTE( "tm8k_graphic.u38", 0x000000, 0x100000, CRC(2a971d46) SHA1(6ca4067e9fa40053df415e670b2e853915319dbb) ) /* Mask rom labeled 5341-16513-07 U38 VIDEO IMAGE */
12631384   ROM_LOAD16_BYTE( "tm8k_graphic.u36", 0x000001, 0x100000, CRC(3bde285e) SHA1(87bf60034665542fb0240b7479adfffb7ba9fad7) ) /* Mask rom labeled 5341-16513-06 U36 VIDEO IMAGE */
12641385   ROM_LOAD16_BYTE( "tm8k_graphic.u39", 0x200000, 0x100000, CRC(58c6c1d8) SHA1(cc11863c4ea46bde7ea4775075f4328be6d6c6d1) ) /* Mask rom labeled 5341-16513-05 U39 VIDEO IMAGE */
r5534r5535
12831404
12841405----
12851406
1286Board silkscreend  237-0211-00
1287                   REV.-D
1407Board silkscreened  237-0211-00
1408                    REV.-D
12881409
12891410Cartridge based mother board
12901411Holds up to 4 cartridges
r5534r5535
12921413    GALAXY U1 V1.90 12/1/98
12931414    GALAXY U2 V1.90 12/1/98
12941415
1295NAMCO 307 Cartridge has surface mount Flash chips in it (not dumped).
1296
12971416Motorola MC68HC000FN12
1298141724 MHz oscillator
12991418Xilinx XC5206
r5534r5535
13101429
13111430***************************************************************************/
13121431
1432#define GALGAMES_BIOS_ROMS \
1433   ROM_SYSTEM_BIOS( 0, "0",   "v1.90" ) \
1434   ROMX_LOAD( "galaxy.u2", 0x000000, 0x100000, CRC(e51ff184) SHA1(aaa795f2c15ec29b3ceeb5c917b643db0dbb7083), ROM_SKIP(1) | ROM_BIOS(1) ) \
1435   ROMX_LOAD( "galaxy.u1", 0x000001, 0x100000, CRC(c6d7bc6d) SHA1(93c032f9aa38cbbdda59a8a25ff9f38f7ad9c760), ROM_SKIP(1) | ROM_BIOS(1) )
1436
1437#define GALGAMES_MB_PALS \
1438   ROM_REGION( 0xa00, "pals", 0) \
1439   ROM_LOAD( "16v8h-blue.u24",    0x000, 0x117, NO_DUMP ) \
1440   ROM_LOAD( "16v8h-yellow.u25",  0x200, 0x117, NO_DUMP ) \
1441   ROM_LOAD( "16v8h-magenta.u26", 0x400, 0x117, NO_DUMP ) \
1442   ROM_LOAD( "16v8h-green.u27",   0x600, 0x117, NO_DUMP ) \
1443   ROM_LOAD( "16v8h-red.u45",     0x800, 0x117, NO_DUMP )
1444
13131445ROM_START( galgbios )
1314   ROM_REGION( 0x200000 + 0x40000, "maincpu", 0 )
1315   ROM_LOAD16_BYTE( "galaxy.u2", 0x1c0000, 0x020000, CRC(e51ff184) SHA1(aaa795f2c15ec29b3ceeb5c917b643db0dbb7083) )
1316   ROM_CONTINUE(                 0x000000, 0x0e0000 )
1317   ROM_LOAD16_BYTE( "galaxy.u1", 0x1c0001, 0x020000, CRC(c6d7bc6d) SHA1(93c032f9aa38cbbdda59a8a25ff9f38f7ad9c760) )
1318   ROM_CONTINUE(                 0x000001, 0x0e0000 )
1319   ROM_FILL(                     0x200000, 0x040000, 0)   // RAM
1446   ROM_REGION( 0x200000, "maincpu", 0 )
1447   GALGAMES_BIOS_ROMS
13201448
1321   ROM_REGION( 0x200000, "gfx1", 0 )
1322   ROM_LOAD16_BYTE( "galaxy.u2", 0x000000, 0x100000, CRC(e51ff184) SHA1(aaa795f2c15ec29b3ceeb5c917b643db0dbb7083) )
1323   ROM_LOAD16_BYTE( "galaxy.u1", 0x000001, 0x100000, CRC(c6d7bc6d) SHA1(93c032f9aa38cbbdda59a8a25ff9f38f7ad9c760) )
1449   ROM_REGION( 0x200000, "blitter", 0 )
1450   ROM_COPY( "maincpu", 0, 0, 0x200000 )
13241451
13251452   ROM_REGION( 0x40000, "oki", ROMREGION_ERASE )
13261453   // RAM, filled by the 68000 and fed to the OKI
1454
1455   GALGAMES_MB_PALS
13271456ROM_END
13281457
1458/***************************************************************************
13291459
1460Galaxy Games StarPak 2
1461
1462NAMCO 307 Cartridge, has surface mount Flash chips in it:
1463
1464.u1 am29f800BB
1465.u2 am29f800BB
1466.u4 pic 12c508
1467
1468Board silkscreened  237-0209-00
1469                    REV.-C
1470
1471***************************************************************************/
1472
1473ROM_START( galgame2 )
1474   ROM_REGION( 0x200000 * 2, "maincpu", 0 )
1475   GALGAMES_BIOS_ROMS
1476   ROM_LOAD16_BYTE( "namco.u2",  0x200000, 0x100000, CRC(f43c0c54) SHA1(4a13946c3d173b0e4ab25b01849574fa3302b417) )
1477   ROM_LOAD16_BYTE( "namco.u1",  0x200001, 0x100000, CRC(b8c34a8b) SHA1(40d3b35f573d2bd2ae1c7d876c55fc436864fa3f) )
1478
1479   ROM_REGION( 0x9db, "pic", 0 )
1480   ROM_LOAD( "namco.u4", 0x000, 0x9db, CRC(63ec1224) SHA1(2966b2aa431e6b8d46cbba18a6fc4de7395caa04) )
1481
1482   ROM_REGION( 0x200000 * 2, "blitter", 0 )
1483   ROM_COPY( "maincpu", 0, 0, 0x200000 * 2 )
1484
1485   ROM_REGION( 0x40000, "oki", ROMREGION_ERASE )
1486   // RAM, filled by the 68000 and fed to the OKI
1487
1488   GALGAMES_MB_PALS
1489ROM_END
1490
1491
13301492static DRIVER_INIT( tm4k )
13311493{
13321494   UINT16 *ROM = (UINT16 *)memory_region( machine, "maincpu" );
r5534r5535
14981660
14991661static DRIVER_INIT( galgames )
15001662{
1501   UINT8 *ROM = memory_region(machine, "maincpu");
1502   // configure memory banks
1503   memory_configure_bank(machine, 1, 0, 2, ROM+0x1c0000, 0x40000);
1504   memory_configure_bank(machine, 3, 0, 2, ROM+0x1c0000, 0x40000);
1663   UINT8 *ROM   =   memory_region(machine, "maincpu");
1664   int cart;
15051665
1506   memory_configure_bank(machine, 2, 0, 1, ROM+0x200000, 0x40000);
1507   memory_configure_bank(machine, 4, 0, 1, ROM+0x200000, 0x40000);
1666   // RAM bank at 0x000000-0x03ffff and 0x200000-0x23ffff
1667   // ROM bank at 0x000000-0x1fffff and 0x200000-0x3fffff (bios)
1668
1669   memory_configure_bank(machine, GALGAMES_BANK_000000_R, GALGAMES_RAM,  1, galgames_ram, 0x40000);
1670   memory_configure_bank(machine, GALGAMES_BANK_000000_R, GALGAMES_ROM0, 1, ROM+0x000000, 0x40000);
1671
1672   memory_configure_bank(machine, GALGAMES_BANK_000000_W, GALGAMES_RAM,  1, galgames_ram, 0x40000);
1673
1674   memory_configure_bank(machine, GALGAMES_BANK_200000_R, GALGAMES_RAM,  1, galgames_ram, 0x40000);
1675   memory_configure_bank(machine, GALGAMES_BANK_200000_R, GALGAMES_ROM0, 1, ROM+0x000000, 0x40000);
1676
1677   memory_configure_bank(machine, GALGAMES_BANK_200000_W, GALGAMES_RAM,  1, galgames_ram, 0x40000);
1678
1679   memory_configure_bank(machine, GALGAMES_BANK_240000_R, GALGAMES_ROM0, 1, ROM+0x040000, 0x1c0000);
1680
1681   // More ROM banks at 0x200000-0x3fffff (carts)
1682
1683   for (cart = 1; cart <= 4; cart++)
1684   {
1685      UINT8 *CART = memory_region(machine, "maincpu");
1686
1687      if  (0x200000 * (cart+1) <= memory_region_length(machine, "maincpu"))
1688         CART += 0x200000 * cart;
1689
1690      memory_configure_bank(machine, GALGAMES_BANK_200000_R, GALGAMES_ROM0+cart, 1, CART,          0x40000);
1691      memory_configure_bank(machine, GALGAMES_BANK_240000_R, GALGAMES_ROM0+cart, 1, CART+0x040000, 0x1c0000);
1692   }
15081693}
15091694
1510GAME( 1996, tm,       0,    tm,       tm,       0,        ROT0, "Midway",                         "Touchmaster (v3.00 Euro)",           0 )
1511GAME( 1996, tm2k,     0,    tm3k,     tmaster,  0,        ROT0, "Midway",                         "Touchmaster 2000 (v4.02 Standard)",  0 )
1512GAME( 1997, tm3k,     0,    tm3k,     tmaster,  0,        ROT0, "Midway",                         "Touchmaster 3000 (v5.02 Standard)",  0 )
1513GAME( 1997, tm3ka,    tm3k, tm3k,     tmaster,  0,        ROT0, "Midway",                         "Touchmaster 3000 (v5.01 Standard)",  0 )
1514GAME( 1998, tm4k,     0,    tm3k,     tmaster,  tm4k,     ROT0, "Midway",                         "Touchmaster 4000 (v6.02 Standard)",  0 )
1515GAME( 1998, tm5k,     0,    tm3k,     tmaster,  tm5k,     ROT0, "Midway",                         "Touchmaster 5000 (v7.10 Standard)",  0 )
1516GAME( 1998, tm5kca,   tm5k, tm3k,     tmaster,  tm5kca,   ROT0, "Midway",                         "Touchmaster 5000 (v7.10 California)",  0 )
1517GAME( 1998, tm5ka,    tm5k, tm3k,     tmaster,  tm5ka,    ROT0, "Midway",                         "Touchmaster 5000 (v7.01 Standard)",  0 )
1518GAME( 1999, tm7k,     0,    tm3k,     tmaster,  tm7k,     ROT0, "Midway",                         "Touchmaster 7000 (v8.04 Standard)",  0 )
1519GAME( 1999, tm7ka,    tm7k, tm3k,     tmaster,  tm7ka,    ROT0, "Midway",                         "Touchmaster 7000 (v8.00 Standard)",  0 )
1520GAME( 1999, tm7keval, tm7k, tm3k,     tmaster,  tm7keval, ROT0, "Midway",                         "Touchmaster 7000 (v8.1X Evaluation)",  0 )
1521GAME( 2000, tm8k,     0,    tm3k,     tmaster,  tm8k,     ROT0, "Midway",                         "Touchmaster 8000 (v9.04 Standard)",  0 )
1522GAME( 1998, galgbios, 0,    galgames, galgames, galgames, ROT0, "Creative Electonics & Software", "Galaxy Games (BIOS v1.90)", GAME_IS_BIOS_ROOT )
1695static DRIVER_INIT( galgame2 )
1696{
1697   UINT16 *ROM = (UINT16 *)memory_region( machine, "maincpu" );
1698
1699   // Patch BIOS to see the game code as first cartridge (until the PIC therein is emulated)
1700   ROM[0x118da/2] = 0x4a06;
1701   ROM[0x118dc/2] = 0x6704;
1702   ROM[0x118de/2] = 0x7000;
1703   ROM[0x118e0/2] = 0x6002;
1704   ROM[0x118e2/2] = 0x7001;
1705   ROM[0x118e4/2] = 0x4e71;
1706   ROM[0x118e6/2] = 0x4e71;
1707   ROM[0x118e8/2] = 0x4e71;
1708
1709   // Cartdridge check on game selection screen
1710   ROM[0x12da0/2] = 0x4e71;
1711
1712   DRIVER_INIT_CALL( galgames );
1713}
1714
1715
1716GAME( 1996, tm,       0,        tm,       tm,       0,        ROT0, "Midway",                                  "Touchmaster (v3.00 Euro)",            0 )
1717GAME( 1996, tm2k,     0,        tm3k,     tmaster,  0,        ROT0, "Midway",                                  "Touchmaster 2000 (v4.02 Standard)",   0 )
1718GAME( 1997, tm3k,     0,        tm3k,     tmaster,  0,        ROT0, "Midway",                                  "Touchmaster 3000 (v5.02 Standard)",   0 )
1719GAME( 1997, tm3ka,    tm3k,     tm3k,     tmaster,  0,        ROT0, "Midway",                                  "Touchmaster 3000 (v5.01 Standard)",   0 )
1720GAME( 1998, tm4k,     0,        tm3k,     tmaster,  tm4k,     ROT0, "Midway",                                  "Touchmaster 4000 (v6.02 Standard)",   0 )
1721GAME( 1998, tm5k,     0,        tm3k,     tmaster,  tm5k,     ROT0, "Midway",                                  "Touchmaster 5000 (v7.10 Standard)",   0 )
1722GAME( 1998, tm5kca,   tm5k,     tm3k,     tmaster,  tm5kca,   ROT0, "Midway",                                  "Touchmaster 5000 (v7.10 California)", 0 )
1723GAME( 1998, tm5ka,    tm5k,     tm3k,     tmaster,  tm5ka,    ROT0, "Midway",                                  "Touchmaster 5000 (v7.01 Standard)",   0 )
1724GAME( 1999, tm7k,     0,        tm3k,     tmaster,  tm7k,     ROT0, "Midway",                                  "Touchmaster 7000 (v8.04 Standard)",   0 )
1725GAME( 1999, tm7ka,    tm7k,     tm3k,     tmaster,  tm7ka,    ROT0, "Midway",                                  "Touchmaster 7000 (v8.00 Standard)",   0 )
1726GAME( 1999, tm7keval, tm7k,     tm3k,     tmaster,  tm7keval, ROT0, "Midway",                                  "Touchmaster 7000 (v8.1X Evaluation)", 0 )
1727GAME( 2000, tm8k,     0,        tm3k,     tmaster,  tm8k,     ROT0, "Midway",                                  "Touchmaster 8000 (v9.04 Standard)",   0 )
1728GAME( 1998, galgbios, 0,        galgames, galgames, galgames, ROT0, "Creative Electronics & Software",         "Galaxy Games (BIOS v1.90)",           GAME_IS_BIOS_ROOT )
1729GAME( 1998, galgame2, galgbios, galgame2, galgames, galgame2, ROT0, "Creative Electronics & Software / Namco", "Galaxy Games StarPak 2",              0 )
src/mame/drivers/namcos22.c
r5534r5535
46844684        ROM_LOAD( "dt1ptru2.15f", 0x400000, 0x080000, CRC(1171eaf5) SHA1(168365ea619386f218585c49025cdd7fd1224082) )
46854685
46864686   ROM_REGION( 0x1000000, "c352", 0 ) /* sound samples */
4687        ROM_LOAD( "dt1wavea.2l",  0x000000, 0x400000, CRC(14352455) SHA1(1965ea6e5ce1b2187ecb64bd40ff044f4b2ba5f6) )
4688        ROM_LOAD( "dt1waveb.1l",  0x400000, 0x400000, CRC(16a4dd8a) SHA1(4883b7ba3ee08a2893d4b2918640ba44e7147164) )
4687        ROM_LOAD( "dt1wavea.2l",  0x000000, 0x400000, CRC(cbd52e40) SHA1(dc995dd919548c96a90efb0375e5b5f1055e05cb) )
4688        ROM_LOAD( "dt1waveb.1l",  0x400000, 0x400000, CRC(6b736f94) SHA1(ac3715480aa9a9c2dec099607f89859bb3b73a6a) )
46894689ROM_END
46904690
46914691ROM_START( aquajet )
src/mame/drivers/n8080.c
r5534r5535
8181   cputag_set_input_line_and_vector(timer->machine, "maincpu", INPUT_LINE_IRQ0, state, 0xd7);
8282}
8383
84static void n8080_inte_callback(const device_config *device, int state)
84static WRITE_LINE_DEVICE_HANDLER( n8080_inte_callback )
8585{
8686   inte = state;
8787}
8888
89static void n8080_status_callback(const device_config *device, UINT8 status)
89static WRITE8_DEVICE_HANDLER( n8080_status_callback )
9090{
91   if (BIT(status, 0))
91   if (data & I8085_STATUS_INTA)
9292   {
9393      /* interrupt acknowledge */
9494      cpu_set_input_line(device, INPUT_LINE_IRQ0, CLEAR_LINE);
9595   }
9696}
9797
98static const i8085_config n8080_cpu_config =
98static I8085_CONFIG( n8080_cpu_config )
9999{
100   n8080_inte_callback,   /* INTE changed callback */
101   n8080_status_callback,   /* STATUS changed callback */
102   NULL,               /* SOD changed callback (8085A only) */
103   NULL,               /* SID changed callback (8085A only) */
100   DEVCB_HANDLER(n8080_status_callback),   /* STATUS changed callback */
101   DEVCB_LINE(n8080_inte_callback),      /* INTE changed callback */
102   DEVCB_NULL,                        /* SID changed callback (8085A only) */
103   DEVCB_NULL                        /* SOD changed callback (8085A only) */
104104};
105105
106106static MACHINE_DRIVER_START( spacefev )
src/mame/drivers/taitogn.c
r5534r5535
11731173   DISK_IMAGE( "kollon", 0, SHA1(d8ea5b5b0ee99004b16ef89883e23de6c7ddd7ce))
11741174ROM_END
11751175
1176ROM_START(kollonc)
1177   TAITOGNET_BIOS
1178   ROM_DEFAULT_BIOS( "v2" )
1179
1180   DISK_REGION( "card" )
1181   DISK_IMAGE( "kollonc", 0, SHA1(ce62181659701cfb8f7c564870ab902be4d8e060)) /* Original Taito Compact Flash version */
1182ROM_END
1183
11761184ROM_START(shikigam)
11771185   TAITOGNET_BIOS
11781186
r5534r5535
12241232   ROM_DEFAULT_BIOS( "v2" )
12251233
12261234   DISK_REGION( "card" )
1227   DISK_IMAGE( "otenamhf", 0, SHA1(5b15c33bf401e5546d78e905f538513d6ffcf562))
1235   DISK_IMAGE( "otenamhf", 0, SHA1(5b15c33bf401e5546d78e905f538513d6ffcf562)) /* Original Taito Compact Flash version */
12281236ROM_END
12291237
12301238
r5534r5535
12961304GAME( 2001, shikigam, taitogn,  coh3002t, coh3002t, coh3002t, ROT270, "Taito/Alfa System", "Shikigami no Shiro (V2.03J)", GAME_IMPERFECT_SOUND )
12971305GAME( 2003, sianniv,  taitogn,  coh3002t, coh3002t, coh3002t, ROT270, "Taito", "Space Invaders Anniversary (V2.02J)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND ) // IRQ at the wrong time
12981306GAME( 2003, kollon,   taitogn,  coh3002t, coh3002t, coh3002t, ROT0,   "Taito", "Kollon (V2.04J)", GAME_IMPERFECT_SOUND )
1307GAME( 2003, kollonc,  kollon,   coh3002t, coh3002t, coh3002t, ROT0,   "Taito", "Kollon (V2.04JC)", GAME_IMPERFECT_SOUND )
12991308
13001309GAME( 1999, otenamih, taitogn,  coh3002t, coh3002t, coh3002t, ROT0,   "Success", "Otenami Haiken (V2.04J)", GAME_IMPERFECT_SOUND )
13011310GAME( 2005, otenamhf, taitogn,  coh3002t, coh3002t, coh3002t, ROT0,   "Success/Warashi", "Otenami Haiken Final (V2.07JC)", GAME_IMPERFECT_SOUND )
src/mame/drivers/goindol.c
r5534r5535
102102   AM_RANGE(0xc000, 0xc7ff) AM_RAM AM_BASE(&ram)
103103   AM_RANGE(0xc800, 0xc800) AM_READNOP AM_WRITE(soundlatch_w) // watchdog?
104104   AM_RANGE(0xc810, 0xc810) AM_WRITE(goindol_bankswitch_w)
105   AM_RANGE(0xc820, 0xd820) AM_READ_PORT("DIAL") AM_WRITE(SMH_RAM) AM_BASE(&goindol_fg_scrolly)
106   AM_RANGE(0xc830, 0xd830) AM_READ_PORT("P1") AM_WRITE(SMH_RAM) AM_BASE(&goindol_fg_scrollx)
105   AM_RANGE(0xc820, 0xc820) AM_READ_PORT("DIAL")
106   AM_RANGE(0xc820, 0xd820) AM_WRITE(SMH_RAM) AM_BASE(&goindol_fg_scrolly)
107   AM_RANGE(0xc830, 0xc830) AM_READ_PORT("P1")
108   AM_RANGE(0xc830, 0xd830) AM_WRITE(SMH_RAM) AM_BASE(&goindol_fg_scrollx)
107109   AM_RANGE(0xc834, 0xc834) AM_READ_PORT("P2")
108110   AM_RANGE(0xd000, 0xd03f) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
109111   AM_RANGE(0xd040, 0xd7ff) AM_RAM
src/tools/unidasm.c
r0r5535
1/***************************************************************************
2
3    mamedasm.c
4
5    Generic MAME disassembler.
6
7    Copyright Nicola Salmoria and the MAME Team.
8    Visit http://mamedev.org for licensing and usage restrictions.
9
10***************************************************************************/
11
12#include "cpuintrf.h"
13#include <ctype.h>
14
15
16enum _display_type
17{
18   _8bit,
19   _8bitx,
20   _16be,
21   _16le,
22   _24be,
23   _24le,
24   _32be,
25   _32le,
26   _40be,
27   _40le,
28   _48be,
29   _48le,
30   _56be,
31   _56le,
32   _64be,
33   _64le
34};
35typedef enum _display_type display_type;
36
37
38typedef struct _dasm_table_entry dasm_table_entry;
39struct _dasm_table_entry
40{
41   const char *         name;
42   display_type         display;
43   INT8               pcshift;
44   cpu_disassemble_func   func;
45};
46
47
48typedef struct _options options;
49struct _options
50{
51   const char *         filename;
52   offs_t               basepc;
53   UINT8               norawbytes;
54   UINT8               lower;
55   UINT8               upper;
56   const dasm_table_entry *dasm;
57};
58
59
60CPU_DISASSEMBLE( adsp21xx );
61CPU_DISASSEMBLE( alpha8201 );
62CPU_DISASSEMBLE( arm );
63CPU_DISASSEMBLE( arm7arm );
64CPU_DISASSEMBLE( arm7thumb );
65CPU_DISASSEMBLE( asap );
66CPU_DISASSEMBLE( avr8 );
67CPU_DISASSEMBLE( ccpu );
68CPU_DISASSEMBLE( cdp1802 );
69CPU_DISASSEMBLE( cop410 );
70CPU_DISASSEMBLE( cop420 );
71CPU_DISASSEMBLE( cop444 );
72CPU_DISASSEMBLE( cp1610 );
73CPU_DISASSEMBLE( cquestsnd );
74CPU_DISASSEMBLE( cquestrot );
75CPU_DISASSEMBLE( cquestlin );
76CPU_DISASSEMBLE( dsp32c );
77CPU_DISASSEMBLE( dsp56k );
78CPU_DISASSEMBLE( hyperstone_generic );
79CPU_DISASSEMBLE( esrip );
80CPU_DISASSEMBLE( f8 );
81CPU_DISASSEMBLE( g65816_generic );
82CPU_DISASSEMBLE( h6280 );
83CPU_DISASSEMBLE( h8 );
84CPU_DISASSEMBLE( hd6309 );
85CPU_DISASSEMBLE( i4004 );
86CPU_DISASSEMBLE( i8085 );
87CPU_DISASSEMBLE( x86_16 );
88CPU_DISASSEMBLE( x86_32 );
89CPU_DISASSEMBLE( x86_64 );
90CPU_DISASSEMBLE( i860 );
91CPU_DISASSEMBLE( i960 );
92CPU_DISASSEMBLE( jaguargpu );
93CPU_DISASSEMBLE( jaguardsp );
94CPU_DISASSEMBLE( konami );
95CPU_DISASSEMBLE( lh5801 );
96CPU_DISASSEMBLE( lr35902 );
97CPU_DISASSEMBLE( m37710_generic );
98CPU_DISASSEMBLE( m6502 );
99CPU_DISASSEMBLE( m65sc02 );
100CPU_DISASSEMBLE( m65c02 );
101CPU_DISASSEMBLE( m65ce02 );
102CPU_DISASSEMBLE( m6510 );
103CPU_DISASSEMBLE( deco16 );
104CPU_DISASSEMBLE( m4510 );
105CPU_DISASSEMBLE( m6800 );
106CPU_DISASSEMBLE( m6801 );
107CPU_DISASSEMBLE( m6802 );
108CPU_DISASSEMBLE( m6803 );
109CPU_DISASSEMBLE( hd63701 );
110CPU_DISASSEMBLE( nsc8105 );
111CPU_DISASSEMBLE( m68000 );
112CPU_DISASSEMBLE( m68008 );
113CPU_DISASSEMBLE( m68010 );
114CPU_DISASSEMBLE( m68020 );
115CPU_DISASSEMBLE( m68030 );
116CPU_DISASSEMBLE( m68040 );
117CPU_DISASSEMBLE( m6805 );
118CPU_DISASSEMBLE( m6809 );
119CPU_DISASSEMBLE( mb86233 );
120CPU_DISASSEMBLE( mb88 );
121CPU_DISASSEMBLE( mcs48 );
122CPU_DISASSEMBLE( upi41 );
123CPU_DISASSEMBLE( i8051 );
124CPU_DISASSEMBLE( i8052 );
125CPU_DISASSEMBLE( i80c51 );
126CPU_DISASSEMBLE( i80c52 );
127CPU_DISASSEMBLE( ds5002fp );
128CPU_DISASSEMBLE( minx );
129CPU_DISASSEMBLE( mips3be );
130CPU_DISASSEMBLE( mips3le );
131CPU_DISASSEMBLE( psxcpu_generic );
132CPU_DISASSEMBLE( r3000be );
133CPU_DISASSEMBLE( r3000le );
134CPU_DISASSEMBLE( nec_generic );
135CPU_DISASSEMBLE( pdp1 );
136CPU_DISASSEMBLE( tx0_64kw );
137CPU_DISASSEMBLE( tx0_8kw );
138CPU_DISASSEMBLE( pic16c5x );
139CPU_DISASSEMBLE( powerpc );
140CPU_DISASSEMBLE( rsp );
141CPU_DISASSEMBLE( s2650 );
142CPU_DISASSEMBLE( saturn );
143CPU_DISASSEMBLE( sc61860 );
144CPU_DISASSEMBLE( se3208 );
145CPU_DISASSEMBLE( sh2 );
146CPU_DISASSEMBLE( sh4 );
147CPU_DISASSEMBLE( sharc );
148CPU_DISASSEMBLE( sm8500 );
149CPU_DISASSEMBLE( spc700 );
150CPU_DISASSEMBLE( ssem );
151CPU_DISASSEMBLE( ssp1601 );
152CPU_DISASSEMBLE( t11 );
153CPU_DISASSEMBLE( t90 );
154CPU_DISASSEMBLE( tlcs900 );
155CPU_DISASSEMBLE( tms0980 );
156CPU_DISASSEMBLE( tms1000 );
157CPU_DISASSEMBLE( tms1100 );
158CPU_DISASSEMBLE( tms32010 );
159CPU_DISASSEMBLE( tms32025 );
160CPU_DISASSEMBLE( tms32031 );
161CPU_DISASSEMBLE( tms32051 );
162CPU_DISASSEMBLE( tms34010 );
163CPU_DISASSEMBLE( tms34020 );
164CPU_DISASSEMBLE( tms57002 );
165CPU_DISASSEMBLE( tms7000 );
166CPU_DISASSEMBLE( upd7810 );
167CPU_DISASSEMBLE( upd7807 );
168CPU_DISASSEMBLE( upd7801 );
169CPU_DISASSEMBLE( upd78c05 );
170CPU_DISASSEMBLE( v60 );
171CPU_DISASSEMBLE( v70 );
172CPU_DISASSEMBLE( v810 );
173CPU_DISASSEMBLE( z180 );
174CPU_DISASSEMBLE( z8000 );
175CPU_DISASSEMBLE( z80 );
176
177
178static const dasm_table_entry dasm_table[] =
179{
180   { "adsp21xx",   _24le, -2, CPU_DISASSEMBLE_NAME(adsp21xx) },
181   { "alpha8201",   _8bit,  0, CPU_DISASSEMBLE_NAME(alpha8201) },
182   { "arm",      _32le,  0, CPU_DISASSEMBLE_NAME(arm) },
183   { "arm7",      _32le,  0, CPU_DISASSEMBLE_NAME(arm7arm) },
184   { "arm7thumb",   _16le,  0, CPU_DISASSEMBLE_NAME(arm7thumb) },
185   { "asap",      _32le,  0, CPU_DISASSEMBLE_NAME(asap) },
186   { "avr8",      _16le,  0, CPU_DISASSEMBLE_NAME(avr8) },
187   { "ccpu",      _8bit,  0, CPU_DISASSEMBLE_NAME(ccpu) },
188   { "cdp1802",   _8bit,  0, CPU_DISASSEMBLE_NAME(cdp1802) },
189   { "cop410",      _8bit,  0, CPU_DISASSEMBLE_NAME(cop410) },
190   { "cop420",      _8bit,  0, CPU_DISASSEMBLE_NAME(cop420) },
191   { "cop444",      _8bit,  0, CPU_DISASSEMBLE_NAME(cop444) },
192   { "cp1610",      _16be, -1, CPU_DISASSEMBLE_NAME(cp1610) },
193   { "cquestsnd",   _64be, -3, CPU_DISASSEMBLE_NAME(cquestsnd) },
194   { "cquestrot",   _64be, -3, CPU_DISASSEMBLE_NAME(cquestrot) },
195   { "cquestlin",   _64be, -3, CPU_DISASSEMBLE_NAME(cquestlin) },
196   { "dsp32c",      _32le,  0, CPU_DISASSEMBLE_NAME(dsp32c) },
197   { "dsp56k",      _16le, -1, CPU_DISASSEMBLE_NAME(dsp56k) },
198   { "hyperstone",   _16be,  0, CPU_DISASSEMBLE_NAME(hyperstone_generic) },
199   { "esrip",      _64be,  0, CPU_DISASSEMBLE_NAME(esrip) },
200   { "f8",         _8bit,  0, CPU_DISASSEMBLE_NAME(f8) },
201   { "g65816",      _8bit,  0, CPU_DISASSEMBLE_NAME(g65816_generic) },
202   { "h6280",      _8bit,  0, CPU_DISASSEMBLE_NAME(h6280) },
203   { "h8",         _16be,  0, CPU_DISASSEMBLE_NAME(h8) },
204   { "hd6309",      _8bit,  0, CPU_DISASSEMBLE_NAME(hd6309) },
205   { "i386",      _8bit,  0, CPU_DISASSEMBLE_NAME(x86_32) },
206   { "i4004",      _8bit,  0, CPU_DISASSEMBLE_NAME(i4004) },
207   { "i8085",      _8bit,  0, CPU_DISASSEMBLE_NAME(i8085) },
208   { "i80286",      _8bit,  0, CPU_DISASSEMBLE_NAME(x86_16) },
209   { "i8086",      _8bit,  0, CPU_DISASSEMBLE_NAME(x86_16) },
210   { "i960",      _32le,  0, CPU_DISASSEMBLE_NAME(i960) },
211   { "jaguargpu",   _16be,  0, CPU_DISASSEMBLE_NAME(jaguargpu) },
212   { "jaguardsp",   _16be,  0, CPU_DISASSEMBLE_NAME(jaguardsp) },
213   { "x86_16",      _8bit,  0, CPU_DISASSEMBLE_NAME(x86_16) },
214   { "x86_32",      _8bit,  0, CPU_DISASSEMBLE_NAME(x86_32) },
215   { "x86_64",      _8bit,  0, CPU_DISASSEMBLE_NAME(x86_64) },
216   { "konami",     _8bit,  0, CPU_DISASSEMBLE_NAME(konami) },
217   { "lh5801",     _8bit,  0, CPU_DISASSEMBLE_NAME(lh5801) },
218   { "lr35902",    _8bit,  0, CPU_DISASSEMBLE_NAME(lr35902) },
219   { "m37710",     _8bit,  0, CPU_DISASSEMBLE_NAME(m37710_generic) },
220   { "m6502",      _8bit,  0, CPU_DISASSEMBLE_NAME(m6502) },
221   { "m65sc02",    _8bit,  0, CPU_DISASSEMBLE_NAME(m65sc02) },
222   { "m65c02",     _8bit,  0, CPU_DISASSEMBLE_NAME(m65c02) },
223   { "m65ce02",    _8bit,  0, CPU_DISASSEMBLE_NAME(m65ce02) },
224   { "m6510",      _8bit,  0, CPU_DISASSEMBLE_NAME(m6510) },
225   { "deco16",     _8bit,  0, CPU_DISASSEMBLE_NAME(deco16) },
226   { "m4510",      _8bit,  0, CPU_DISASSEMBLE_NAME(m4510) },
227   { "m6800",      _8bit,  0, CPU_DISASSEMBLE_NAME(m6800) },
228   { "m6801",      _8bit,  0, CPU_DISASSEMBLE_NAME(m6801) },
229   { "m6802",      _8bit,  0, CPU_DISASSEMBLE_NAME(m6802) },
230   { "m6803",      _8bit,  0, CPU_DISASSEMBLE_NAME(m6803) },
231   { "hd63701",    _8bit,  0, CPU_DISASSEMBLE_NAME(hd63701) },
232   { "nsc8105",    _8bit,  0, CPU_DISASSEMBLE_NAME(nsc8105) },
233   { "m68000",     _16be,  0, CPU_DISASSEMBLE_NAME(m68000) },
234   { "m68008",     _16be,  0, CPU_DISASSEMBLE_NAME(m68008) },
235   { "m68010",     _16be,  0, CPU_DISASSEMBLE_NAME(m68010) },
236   { "m68020",     _16be,  0, CPU_DISASSEMBLE_NAME(m68020) },
237   { "m68030",     _16be,  0, CPU_DISASSEMBLE_NAME(m68030) },
238   { "m68040",     _16be,  0, CPU_DISASSEMBLE_NAME(m68040) },
239   { "m6805",      _8bit,  0, CPU_DISASSEMBLE_NAME(m6805) },
240   { "m6809",      _8bit,  0, CPU_DISASSEMBLE_NAME(m6809) },
241   { "mb86233",    _32le, -2, CPU_DISASSEMBLE_NAME(mb86233) },
242   { "mb88xx",     _8bit,  0, CPU_DISASSEMBLE_NAME(mb88) },
243   { "mcs48",      _8bit,  0, CPU_DISASSEMBLE_NAME(mcs48) },
244   { "upi41",      _8bit,  0, CPU_DISASSEMBLE_NAME(upi41) },
245   { "i8051",      _8bit,  0, CPU_DISASSEMBLE_NAME(i8051) },
246   { "i8052",      _8bit,  0, CPU_DISASSEMBLE_NAME(i8052) },
247   { "i80c51",     _8bit,  0, CPU_DISASSEMBLE_NAME(i80c51) },
248   { "i80c52",     _8bit,  0, CPU_DISASSEMBLE_NAME(i80c52) },
249   { "ds5002fp",   _8bit,  0, CPU_DISASSEMBLE_NAME(ds5002fp) },
250   { "minx",       _8bit,  0, CPU_DISASSEMBLE_NAME(minx) },
251   { "mips3be",    _32be,  0, CPU_DISASSEMBLE_NAME(mips3be) },
252   { "mips3le",    _32le,  0, CPU_DISASSEMBLE_NAME(mips3le) },
253   { "psxcpu",     _32le,  0, CPU_DISASSEMBLE_NAME(psxcpu_generic) },
254   { "r3000be",    _32be,  0, CPU_DISASSEMBLE_NAME(r3000be) },
255   { "r3000le",    _32le,  0, CPU_DISASSEMBLE_NAME(r3000le) },
256   { "nec",        _8bit,  0, CPU_DISASSEMBLE_NAME(nec_generic) },
257   { "pdp1",       _32be,  0, CPU_DISASSEMBLE_NAME(pdp1) },
258   { "tx0_64kw",   _32be, -2, CPU_DISASSEMBLE_NAME(tx0_64kw) },
259   { "tx0_8kw",    _32be, -2, CPU_DISASSEMBLE_NAME(tx0_8kw) },
260   { "pic16c5x",   _16le, -1, CPU_DISASSEMBLE_NAME(pic16c5x) },
261   { "powerpc",    _32be,  0, CPU_DISASSEMBLE_NAME(powerpc) },
262   { "rsp",        _32le,  0, CPU_DISASSEMBLE_NAME(rsp) },
263   { "s2650",      _8bit,  0, CPU_DISASSEMBLE_NAME(s2650) },
264   { "saturn",     _8bit,  0, CPU_DISASSEMBLE_NAME(saturn) },
265   { "sc61860",    _8bit,  0, CPU_DISASSEMBLE_NAME(sc61860) },
266   { "se3208",     _16le,  0, CPU_DISASSEMBLE_NAME(se3208) },
267   { "sh2",        _16be,  0, CPU_DISASSEMBLE_NAME(sh2) },
268   { "sh4",        _16le,  0, CPU_DISASSEMBLE_NAME(sh4) },
269   { "sharc",      _64le, -3, CPU_DISASSEMBLE_NAME(sharc) },
270   { "sm8500",     _8bit,  0, CPU_DISASSEMBLE_NAME(sm8500) },
271   { "spc700",     _8bit,  0, CPU_DISASSEMBLE_NAME(spc700) },
272   { "ssem",       _32le,  0, CPU_DISASSEMBLE_NAME(ssem) },
273   { "ssp1601",    _16be, -1, CPU_DISASSEMBLE_NAME(ssp1601) },
274   { "t11",        _16le,  0, CPU_DISASSEMBLE_NAME(t11) },
275//  { "t90",        _8bit,  0, CPU_DISASSEMBLE_NAME(t90) },
276   { "tlcs900",    _8bit,  0, CPU_DISASSEMBLE_NAME(tlcs900) },
277   { "tms0980",    _16be,  0, CPU_DISASSEMBLE_NAME(tms0980) },
278   { "tms1000",    _8bit,  0, CPU_DISASSEMBLE_NAME(tms1000) },
279   { "tms1100",    _8bit,  0, CPU_DISASSEMBLE_NAME(tms1100) },
280   { "tms32010",   _16be, -1, CPU_DISASSEMBLE_NAME(tms32010) },
281   { "tms32025",   _16be, -1, CPU_DISASSEMBLE_NAME(tms32025) },
282   { "tms32031",   _32le, -2, CPU_DISASSEMBLE_NAME(tms32031) },
283   { "tms32051",   _16le, -1, CPU_DISASSEMBLE_NAME(tms32051) },
284   { "tms34010",   _8bit,  3, CPU_DISASSEMBLE_NAME(tms34010) },
285   { "tms34020",   _8bit,  3, CPU_DISASSEMBLE_NAME(tms34020) },
286   { "tms57002",   _32le, -2, CPU_DISASSEMBLE_NAME(tms57002) },
287   { "tms7000",    _8bit,  0, CPU_DISASSEMBLE_NAME(tms7000) },
288   { "upd7810",    _8bit,  0, CPU_DISASSEMBLE_NAME(upd7810) },
289   { "upd7807",    _8bit,  0, CPU_DISASSEMBLE_NAME(upd7807) },
290   { "upd7801",    _8bit,  0, CPU_DISASSEMBLE_NAME(upd7801) },
291   { "upd78c05",   _8bit,  0, CPU_DISASSEMBLE_NAME(upd78c05) },
292   { "v60",        _8bit,  0, CPU_DISASSEMBLE_NAME(v60) },
293   { "v70",        _8bit,  0, CPU_DISASSEMBLE_NAME(v70) },
294   { "v810",       _16le,  0, CPU_DISASSEMBLE_NAME(v810) },
295   { "z180",       _8bit,  0, CPU_DISASSEMBLE_NAME(z180) },
296//  { "z8000",      _16be,  0, CPU_DISASSEMBLE_NAME(z8000) },
297   { "z80",      _8bit,  0, CPU_DISASSEMBLE_NAME(z80) },
298};
299
300
301void CLIB_DECL fatalerror(const char *text, ...)
302{
303   va_list arg;
304
305   /* dump to the buffer; assume no one writes >2k lines this way */
306   va_start(arg, text);
307   vfprintf(stderr, text, arg);
308   va_end(arg);
309
310   exit(1);
311}
312
313
314void CLIB_DECL logerror(const char *format, ...)
315{
316   /* silent logerrors are allowed in disassemblers */
317}
318
319
320void CLIB_DECL mame_printf_debug(const char *format, ...)
321{
322   /* silent mame_printf_debugs are allowed in disassemblers */
323}
324
325
326int parse_options(int argc, char *argv[], options *opts)
327{
328   int pending_base = FALSE;
329   int pending_arch = FALSE;
330   int curarch;
331   int numrows;
332   int arg;
333
334   memset(opts, 0, sizeof(*opts));
335
336   // loop through arguments
337   for (arg = 1; arg < argc; arg++)
338   {
339      char *curarg = argv[arg];
340
341      // is it a switch?
342      if (curarg[0] == '-')
343      {
344         if (pending_base || pending_arch)
345            goto usage;
346
347         if (tolower(curarg[1]) == 'a')
348            pending_arch = TRUE;
349         else if (tolower(curarg[1]) == 'b')
350            pending_base = TRUE;
351         else if (tolower(curarg[1]) == 'l')
352            opts->lower = TRUE;
353         else if (tolower(curarg[1]) == 'n')
354            opts->norawbytes = TRUE;
355         else if (tolower(curarg[1]) == 'u')
356            opts->upper = TRUE;
357         else
358            goto usage;
359      }
360
361      // base PC
362      else if (pending_base)
363      {
364         if (curarg[0] == '0' && curarg[1] == 'x')
365            sscanf(&curarg[2], "%x", &opts->basepc);
366         else if (curarg[0] == '$')
367            sscanf(&curarg[1], "%x", &opts->basepc);
368         else
369            sscanf(&curarg[0], "%x", &opts->basepc);
370         pending_base = FALSE;
371      }
372
373      // architecture
374      else if (pending_arch)
375      {
376         for (curarch = 0; curarch < ARRAY_LENGTH(dasm_table); curarch++)
377            if (core_stricmp(curarg, dasm_table[curarch].name) == 0)
378               break;
379         if (curarch == ARRAY_LENGTH(dasm_table))
380            goto usage;
381         opts->dasm = &dasm_table[curarch];
382         pending_arch = FALSE;
383      }
384
385      // filename
386      else if (opts->filename == NULL)
387         opts->filename = curarg;
388
389      // fail
390      else
391         goto usage;
392   }
393
394   // if no file or no architecture, fail
395   if (opts->filename == NULL || opts->dasm == NULL)
396      goto usage;
397   return 0;
398
399usage:
400   printf("Usage: %s <filename> -arch <architecture> [-basepc <pc>] [-norawbytes] [-upper] [-lower]\n", argv[0]);
401   printf("\n");
402   printf("Supported architectures:");
403   numrows = (ARRAY_LENGTH(dasm_table) + 6) / 7;
404   for (curarch = 0; curarch < numrows * 7; curarch++)
405   {
406      int row = curarch / 7;
407      int col = curarch % 7;
408      int index = col * numrows + row;
409      if (col == 0)
410         printf("\n  ");
411      printf("%-11s", (index < ARRAY_LENGTH(dasm_table)) ? dasm_table[index].name : "");
412   }
413   printf("\n");
414   return 1;
415};
416
417
418int main(int argc, char *argv[])
419{
420   file_error filerr;
421   int displayendian;
422   int displaychunk;
423   UINT32 curbyte;
424   UINT32 length;
425   int maxchunks;
426   UINT32 curpc;
427   options opts;
428   int numbytes;
429   void *data;
430   char *p;
431
432   // parse options first
433   if (parse_options(argc, argv, &opts))
434      return 1;
435
436   // load the file
437   filerr = core_fload(opts.filename, &data, &length);
438   if (filerr != FILERR_NONE)
439   {
440      fprintf(stderr, "Error opening file '%s'\n", opts.filename);
441      return 1;
442   }
443
444   // precompute parameters
445   displaychunk = (opts.dasm->display / 2) + 1;
446   displayendian = opts.dasm->display % 2;
447   switch (displaychunk)
448   {
449      case 1:      maxchunks = 6;   break;
450      case 2:      maxchunks = 3;   break;
451      default:   maxchunks = 1;   break;
452   }
453
454   // run it
455   curpc = opts.basepc;
456   for (curbyte = 0; curbyte < length; curbyte += numbytes)
457   {
458      UINT8 *oprom = (UINT8 *)data + curbyte;
459      char buffer[1024];
460      UINT32 pcdelta;
461      int numchunks;
462
463      // disassemble
464      pcdelta = (*opts.dasm->func)(NULL, buffer, curpc, oprom, oprom) & DASMFLAG_LENGTHMASK;
465      if (opts.dasm->pcshift < 0)
466         numbytes = pcdelta << -opts.dasm->pcshift;
467      else
468         numbytes = pcdelta >> opts.dasm->pcshift;
469
470      // round to the nearest display chunk
471      numbytes = ((numbytes + displaychunk - 1) / displaychunk) * displaychunk;
472      if (numbytes == 0)
473         numbytes = displaychunk;
474      numchunks = numbytes / displaychunk;
475
476      // output the address
477      printf("%08X: ", curpc);
478
479      // output the raw bytes
480      if (!opts.norawbytes)
481      {
482         int firstchunks = (numchunks < maxchunks) ? numchunks : maxchunks;
483         int chunknum, bytenum;
484         for (chunknum = 0; chunknum < firstchunks; chunknum++)
485         {
486            for (bytenum = 0; bytenum < displaychunk; bytenum++)
487               printf("%02X", oprom[displayendian ? (displaychunk - 1 - bytenum) : bytenum]);
488            printf(" ");
489            oprom += displaychunk;
490         }
491         for ( ; chunknum < maxchunks; chunknum++)
492            printf("%*s ", displaychunk * 2, "");
493         printf(" ");
494      }
495
496      // output the disassembly
497      if (opts.lower)
498      {
499         for (p = buffer; *p != 0; p++)
500            *p = tolower(*p);
501      } else if (opts.upper)
502      {
503         for (p = buffer; *p != 0; p++)
504            *p = toupper(*p);
505      }
506      printf("%s\n", buffer);
507
508      // output additional raw bytes
509      if (!opts.norawbytes && numchunks > maxchunks)
510      {
511         for (numchunks -= maxchunks; numchunks > 0; numchunks -= maxchunks)
512         {
513            int firstchunks = (numchunks < maxchunks) ? numchunks : maxchunks;
514            int chunknum, bytenum;
515            printf("          ");
516            for (chunknum = 0; chunknum < firstchunks; chunknum++)
517            {
518               for (bytenum = 0; bytenum < displaychunk; bytenum++)
519                  printf("%02X", oprom[displayendian ? (displaychunk - 1 - bytenum) : bytenum]);
520               printf(" ");
521               oprom += displaychunk;
522            }
523            printf("\n");
524         }
525      }
526
527      // advance
528      curpc += pcdelta;
529      curbyte += numbytes;
530   }
531
532   return 0;
533}
src/tools/tools.mak
r5534r5535
2626   romcmp$(EXE) \
2727   chdman$(EXE) \
2828   jedutil$(EXE) \
29   unidasm$(EXE) \
2930   ldresample$(EXE) \
3031   ldverify$(EXE) \
3132   regrep$(EXE) \
r5534r5535
7677
7778
7879#-------------------------------------------------
80# unidasm
81#-------------------------------------------------
82
83UNIDASMOBJS = \
84   $(TOOLSOBJ)/unidasm.o \
85
86unidasm$(EXE): $(UNIDASMOBJS) $(LIBUTIL) $(LIBOCORE) $(LIBDASM) $(ZLIB) $(EXPAT)
87   @echo Linking $@...
88   $(LD) $(LDFLAGS) $^ $(LIBS) -o $@
89
90
91
92#-------------------------------------------------
7993# ldresample
8094#-------------------------------------------------
8195
src/osd/osdmini/minimisc.c
r5534r5535
3333
3434
3535//============================================================
36//  osd_is_bad_read_ptr
37//============================================================
38
39int osd_is_bad_read_ptr(const void *ptr, size_t size)
40{
41   // there is no standard way to do this, so just say no
42   return FALSE;
43}
44
45
46//============================================================
4736//  osd_break_into_debugger
4837//============================================================
4938
src/osd/osdcore.h
r5534r5535
758758
759759
760760/*-----------------------------------------------------------------------------
761    osd_is_bad_read_ptr: attempt to determine if the given pointer will
762        generate an access violation if accessed for read
763
764    Parameters:
765
766        ptr - the pointer to examine
767
768        size - the number of bytes to reference
769
770    Return value:
771
772        TRUE if an access to the referenced memory will generate an access
773        violation on a read; FALSE otherwise.
774
775    Notes:
776
777        This function will eventually be deprecated.
778-----------------------------------------------------------------------------*/
779int osd_is_bad_read_ptr(const void *ptr, size_t size);
780
781
782/*-----------------------------------------------------------------------------
783761    osd_break_into_debugger: break into the hosting system's debugger if one
784762        is attached
785763
src/osd/windows/winmisc.c
r5534r5535
4141
4242
4343//============================================================
44//  osd_is_bad_read_ptr
45//============================================================
46
47int osd_is_bad_read_ptr(const void *ptr, size_t size)
48{
49   return IsBadReadPtr(ptr, size);
50}
51
52
53//============================================================
5444//  osd_break_into_debugger
5545//============================================================
5646
src/emu/cpu/h83002/h8disasm.c
r5534r5535
12741274   return size;
12751275}
12761276
1277CPU_DISASSEMBLE(h8)
1278{
1279   return h8_disasm(buffer, pc, oprom, opram, 0xffff);
1280}
12771281
1282// disassembly hook for varients with 24-bit address bus (e.g. H8/3044)
1283CPU_DISASSEMBLE(h8_24)
1284{
1285   return h8_disasm(buffer, pc, oprom, opram, 0xffffff);
1286}
1287
1288// disassembly hook for full 32-bit address bus
1289CPU_DISASSEMBLE(h8_32)
1290{
1291   return h8_disasm(buffer, pc, oprom, opram, 0xffffffff);
1292}
1293
src/emu/cpu/h83002/h8_16.c
r5534r5535
1717#include "h8.h"
1818#include "h8priv.h"
1919
20CPU_DISASSEMBLE(h8_24);
21CPU_DISASSEMBLE(h8_32);
22
2023#define H8_SP   (7)
2124
2225#define h8_mem_read8(x) memory_read_byte(h8->program, x)
r5534r5535
5356
5457extern offs_t h8_disasm(char *output, offs_t address, const UINT8 *oprom, const UINT8 *opram, UINT32 addr_mask);
5558
56// disassembly hook for varients with 24-bit address bus (e.g. H8/3044)
57static CPU_DISASSEMBLE(h8_24)
58{
59   return h8_disasm(buffer, pc, oprom, opram, 0xffffff);
60}
61
62// disassembly hook for full 32-bit address bus
63static CPU_DISASSEMBLE(h8_32)
64{
65   return h8_disasm(buffer, pc, oprom, opram, 0xffffffff);
66}
67
6859void h8_3002_InterruptRequest(h83xx_state *h8, UINT8 source, UINT8 state)
6960{
7061   // don't allow clear on external interrupts
src/emu/cpu/h83002/h8_8.c
r5534r5535
1313#include "h8.h"
1414#include "h8priv.h"
1515
16CPU_DISASSEMBLE(h8);
17
1618#define H8_SP   (7)
1719
1820#define h8_mem_read8(x)      memory_read_byte(h8->program, x)
r5534r5535
7173
7274/* implementation */
7375
74extern offs_t h8_disasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 addrmask);
75
76static CPU_DISASSEMBLE(h8)
77{
78   return h8_disasm(buffer, pc, oprom, opram, 0xffff);
79}
80
8176static void h8_300_InterruptRequest(h83xx_state *h8, UINT8 source, UINT8 mode)
8277{
8378   if (source>31)
src/emu/cpu/m68000/m68kdasm.c
r5534r5535
37153715}
37163716#endif
37173717
3718CPU_DISASSEMBLE( m68000 )
3719{
3720   return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68000);
3721}
37183722
3723CPU_DISASSEMBLE( m68008 )
3724{
3725   return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68008);
3726}
3727
3728CPU_DISASSEMBLE( m68010 )
3729{
3730   return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68010);
3731}
3732
3733CPU_DISASSEMBLE( m68020 )
3734{
3735   return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68020);
3736}
3737
3738CPU_DISASSEMBLE( m68030 )
3739{
3740   return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68030);
3741}
3742
3743CPU_DISASSEMBLE( m68040 )
3744{
3745   return m68k_disassemble_raw(buffer, pc, oprom, opram, M68K_CPU_TYPE_68040);
3746}
3747
3748
3749
37193750/* ======================================================================== */
37203751/* ============================== END OF FILE ============================= */
37213752/* ======================================================================== */
src/emu/cpu/tms32031/dis32031.c
r5534r5535
731731
732732   return 1 | flags | DASMFLAG_SUPPORTED;
733733}
734
735
736CPU_DISASSEMBLE( tms32031 )
737{
738   UINT32 op = oprom[0] | (oprom[1] << 8) | (oprom[2] << 16) | (oprom[3] << 24);
739    return dasm_tms32031(buffer, pc, op);
740}
src/emu/cpu/tms32031/tms32031.c
r5534r5535
1010#include "tms32031.h"
1111#include "eminline.h"
1212
13CPU_DISASSEMBLE( tms32031 );
1314
1415#define LOG_OPCODE_USAGE   (0)
1516
r5534r5535
536537
537538
538539/***************************************************************************
539    DISASSEMBLY HOOK
540***************************************************************************/
541
542static CPU_DISASSEMBLE( tms32031 )
543{
544   UINT32 op = oprom[0] | (oprom[1] << 8) | (oprom[2] << 16) | (oprom[3] << 24);
545   extern unsigned dasm_tms32031(char *, unsigned, UINT32);
546    return dasm_tms32031(buffer, pc, op);
547}
548
549
550
551/***************************************************************************
552540    BOOT LOADER
553541***************************************************************************/
554542
src/emu/cpu/superfx/superfx.h
r0r5535
1#ifndef __SUPERFX_H__
2#define __SUPERFX_H__
3
4enum
5{
6   SUPERFX_PC = 1,
7
8   SUPERFX_DREG,
9   SUPERFX_SREG,
10
11   SUPERFX_R0,
12   SUPERFX_R1,
13   SUPERFX_R2,
14   SUPERFX_R3,
15   SUPERFX_R4,
16   SUPERFX_R5,
17   SUPERFX_R6,
18   SUPERFX_R7,
19   SUPERFX_R8,
20   SUPERFX_R9,
21   SUPERFX_R10,
22   SUPERFX_R11,
23   SUPERFX_R12,
24   SUPERFX_R13,
25   SUPERFX_R14,
26   SUPERFX_R15,
27
28    SUPERFX_PBR,
29    SUPERFX_SFR,
30    SUPERFX_ROMBR,
31    SUPERFX_RAMBR,
32    SUPERFX_CBR,
33    SUPERFX_SCBR,
34    SUPERFX_SCMR,
35    SUPERFX_COLR,
36    SUPERFX_POR,
37    SUPERFX_BRAMR,
38    SUPERFX_VCR,
39    SUPERFX_CFGR,
40    SUPERFX_CLSR,
41
42    SUPERFX_ROMCL,
43    SUPERFX_ROMDR,
44
45    SUPERFX_RAMCL,
46    SUPERFX_RAMAR,
47    SUPERFX_RAMDR,
48    SUPERFX_RAMADDR,
49};
50
51#define SUPERFX_SFR_IRQ      0x8000   // Interrupt Flag
52#define SUPERFX_SFR_B      0x1000   // WITH Flag
53#define SUPERFX_SFR_IH      0x0800   // Immediate Higher 8-bit Flag
54#define SUPERFX_SFR_IL      0x0400   // Immediate Lower 8-bit Flag
55#define SUPERFX_SFR_ALT      0x0300   // ALT Mode, both bits
56#define SUPERFX_SFR_ALT0   0x0000   // ALT Mode, no bits
57#define SUPERFX_SFR_ALT1   0x0100   // ALT Mode, bit 0
58#define SUPERFX_SFR_ALT2   0x0200   // ALT Mode, bit 1
59#define SUPERFX_SFR_ALT3   0x0300   // ALT Mode, both bits (convenience dupe)
60#define SUPERFX_SFR_R      0x0040   // ROM R14 Read Flag
61#define SUPERFX_SFR_G      0x0020   // GO Flag
62#define SUPERFX_SFR_OV      0x0010   // Overflow Flag
63#define SUPERFX_SFR_S      0x0008   // Sign Flag
64#define SUPERFX_SFR_CY      0x0004   // Carry Flag
65#define SUPERFX_SFR_Z      0x0002   // Zero Flag
66
67#define SUPERFX_POR_OBJ         0x10
68#define SUPERFX_POR_FREEZEHIGH   0x08
69#define SUPERFX_POR_HIGHNIBBLE   0x04
70#define SUPERFX_POR_DITHER      0x02
71#define SUPERFX_POR_TRANSPARENT   0x01
72
73#define SUPERFX_SCMR_HT_MASK   0x24
74#define SUPERFX_SCMR_HT0      0x00
75#define SUPERFX_SCMR_HT1      0x04
76#define SUPERFX_SCMR_HT2      0x20
77#define SUPERFX_SCMR_HT3      0x24
78#define SUPERFX_SCMR_RON      0x10
79#define SUPERFX_SCMR_RAN      0x08
80#define SUPERFX_SCMR_MD         0x03
81
82#define SUPERFX_CFGR_IRQ   0x80   // IRQ
83#define SUPERFX_CFGR_MS0   0x20   // MS0
84
85CPU_GET_INFO( superfx );
86#define CPU_SUPERFX CPU_GET_INFO_NAME( superfx )
87
88CPU_DISASSEMBLE( superfx );
89extern offs_t superfx_dasm_one(char *buffer, offs_t pc, UINT8 op, UINT8 param0, UINT8 param1, UINT16 alt);
90
91UINT8 superfx_mmio_read(const device_config *cpu, UINT32 addr);
92void superfx_mmio_write(const device_config *cpu, UINT32 addr, UINT8 data);
93void superfx_add_clocks(const device_config *cpu, INT32 clocks);
94
95#endif /* __SUPERFX_H__ */
src/emu/cpu/superfx/sfx_dasm.c
r0r5535
1#include "cpuintrf.h"
2#include "superfx.h"
3#include <stdarg.h>
4
5static char *output;
6
7static void ATTR_PRINTF(1,2) print(const char *fmt, ...)
8{
9    va_list vl;
10
11    va_start(vl, fmt);
12    output += vsprintf(output, fmt, vl);
13    va_end(vl);
14}
15
16offs_t superfx_dasm_one(char *buffer, offs_t pc, UINT8 op, UINT8 param0, UINT8 param1, UINT16 alt)
17{
18   UINT8 bytes_consumed = 1;
19    output = buffer;
20
21   switch(op)
22   {
23      case 0x00: // STOP
24         print("STOP");
25         break;
26      case 0x01: // NOP
27         print("NOP");
28         break;
29      case 0x02: // CACHE
30         print("CACHE");
31         break;
32      case 0x03: // LSR
33         print("LSR");
34         break;
35      case 0x04: // ROL
36         print("ROL");
37         break;
38      case 0x05: // BRA
39         print("BRA     %d", (INT8)param0);
40         bytes_consumed = 2;
41         break;
42      case 0x06: // BLT
43         print("BLT     %d", (INT8)param0);
44         bytes_consumed = 2;
45         break;
46      case 0x07: // BGE
47         print("BGE     %d", (INT8)param0);
48         bytes_consumed = 2;
49         break;
50      case 0x08: // BNE
51         print("BNE     %d", (INT8)param0);
52         bytes_consumed = 2;
53         break;
54      case 0x09: // BEQ
55         print("BEQ     %d", (INT8)param0);
56         bytes_consumed = 2;
57         break;
58      case 0x0a: // BPL
59         print("BPL     %d", (INT8)param0);
60         bytes_consumed = 2;
61         break;
62      case 0x0b: // BMI
63         print("BMI     %d", (INT8)param0);
64         bytes_consumed = 2;
65         break;
66      case 0x0c: // BCC
67         print("BCC     %d", (INT8)param0);
68         bytes_consumed = 2;
69         break;
70      case 0x0d: // BCS
71         print("BCS     %d", (INT8)param0);
72         bytes_consumed = 2;
73         break;
74      case 0x0e: // BVC
75         print("BVC     %d", (INT8)param0);
76         bytes_consumed = 2;
77         break;
78      case 0x0f: // BVS
79         print("BVS     %d", (INT8)param0);
80         bytes_consumed = 2;
81         break;
82
83      case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17:
84      case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f:   // TO
85         print("TO      R%d", op & 0xf);
86         break;
87
88      case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27:
89      case 0x28: case 0x29: case 0x2a: case 0x2b: case 0x2c: case 0x2d: case 0x2e: case 0x2f: // WITH
90         print("WITH    R%d", op & 0xf);
91         break;
92
93      case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35:
94      case 0x36: case 0x37: case 0x38: case 0x39: case 0x3a: case 0x3b:   // STW_IR / STB_IR
95         switch(alt)
96         {
97            case SUPERFX_SFR_ALT0:
98            case SUPERFX_SFR_ALT2:
99               print("STW     (R%d)", op & 0xf);
100               break;
101            case SUPERFX_SFR_ALT1:
102            case SUPERFX_SFR_ALT3:
103               print("STB     (R%d)", op & 0xf);
104               break;
105         }
106         break;
107
108      case 0x3c: // LOOP
109         print("LOOP");
110         break;
111      case 0x3d: // ALT1
112         print("ALT1");
113         break;
114      case 0x3e: // ALT2
115         print("ALT2");
116         break;
117      case 0x3f: // ALT3
118         print("ALT3");
119         break;
120
121      case 0x40: case 0x41: case 0x42: case 0x43: case 0x44: case 0x45:
122      case 0x46: case 0x47: case 0x48: case 0x49: case 0x4a: case 0x4b:   // LDW_IR / LDB_IR
123         switch(alt)
124         {
125            case SUPERFX_SFR_ALT0:
126            case SUPERFX_SFR_ALT2:
127               print("LDW     (R%d)", op & 0xf);
128               break;
129            case SUPERFX_SFR_ALT1:
130            case SUPERFX_SFR_ALT3:
131               print("LDB     (R%d)", op & 0xf);
132               break;
133         }
134         break;
135
136      case 0x4c: // PLOT / RPIX
137         switch(alt)
138         {
139            case SUPERFX_SFR_ALT0:
140            case SUPERFX_SFR_ALT2:
141               print("PLOT");
142               break;
143            case SUPERFX_SFR_ALT1:
144            case SUPERFX_SFR_ALT3:
145               print("RPIX");
146               break;
147         }
148         break;
149
150      case 0x4d: // SWAP
151         print("SWAP");
152         break;
153
154      case 0x4e: // COLOR / CMODE
155         switch(alt)
156         {
157            case SUPERFX_SFR_ALT0:
158            case SUPERFX_SFR_ALT2:
159               print("COLOR");
160               break;
161            case SUPERFX_SFR_ALT1:
162            case SUPERFX_SFR_ALT3:
163               print("CMODE");
164               break;
165         }
166         break;
167
168      case 0x4f: // NOT
169         print("NOT");
170         break;
171
172      case 0x50: case 0x51: case 0x52: case 0x53: case 0x54: case 0x55: case 0x56: case 0x57:
173      case 0x58: case 0x59: case 0x5a: case 0x5b: case 0x5c: case 0x5d: case 0x5e: case 0x5f: // ADD / ADC / ADDI / ADCI
174         switch(alt)
175         {
176            case SUPERFX_SFR_ALT0:
177               print("ADD     R%d", op &0xf);
178               break;
179            case SUPERFX_SFR_ALT1:
180               print("ADC     R%d", op &0xf);
181               break;
182            case SUPERFX_SFR_ALT2:
183               print("ADDI    R%d", op &0xf);
184               break;
185            case SUPERFX_SFR_ALT3:
186               print("ADCI    R%d", op &0xf);
187               break;
188         }
189         break;
190
191      case 0x60: case 0x61: case 0x62: case 0x63: case 0x64: case 0x65: case 0x66: case 0x67:
192      case 0x68: case 0x69: case 0x6a: case 0x6b: case 0x6c: case 0x6d: case 0x6e: case 0x6f: // SUB / SBC / SUBI / CMP
193         switch(alt)
194         {
195            case SUPERFX_SFR_ALT0:
196               print("SUB     R%d", op &0xf);
197               break;
198            case SUPERFX_SFR_ALT1:
199               print("SBC     R%d", op &0xf);
200               break;
201            case SUPERFX_SFR_ALT2:
202               print("SUBI    R%d", op &0xf);
203               break;
204            case SUPERFX_SFR_ALT3:
205               print("CMP     R%d", op &0xf);
206               break;
207         }
208         break;
209
210      case 0x70: // MERGE
211         print("MERGE");
212         break;
213
214               case 0x71: case 0x72: case 0x73: case 0x74: case 0x75: case 0x76: case 0x77:
215      case 0x78: case 0x79: case 0x7a: case 0x7b: case 0x7c: case 0x7d: case 0x7e: case 0x7f: // AND / BIC / ANDI / BICI
216         switch(alt)
217         {
218            case SUPERFX_SFR_ALT0:
219               print("AND     R%d", op &0xf);
220               break;
221            case SUPERFX_SFR_ALT1:
222               print("BIC     R%d", op &0xf);
223               break;
224            case SUPERFX_SFR_ALT2:
225               print("ANDI    R%d", op &0xf);
226               break;
227            case SUPERFX_SFR_ALT3:
228               print("BICI    R%d", op &0xf);
229               break;
230         }
231         break;
232
233      case 0x80: case 0x81: case 0x82: case 0x83: case 0x84: case 0x85: case 0x86: case 0x87:
234      case 0x88: case 0x89: case 0x8a: case 0x8b: case 0x8c: case 0x8d: case 0x8e: case 0x8f: // MULT / UMULT / MULTI / UMULTI
235         switch(alt)
236         {
237            case SUPERFX_SFR_ALT0:
238               print("MULT    R%d", op &0xf);
239               break;
240            case SUPERFX_SFR_ALT1:
241               print("UMULT   R%d", op &0xf);
242               break;
243            case SUPERFX_SFR_ALT2:
244               print("MULTI   R%d", op &0xf);
245               break;
246            case SUPERFX_SFR_ALT3:
247               print("UMULTI  R%d", op &0xf);
248               break;
249         }
250         break;
251
252      case 0x90: // SBK
253         print("SBK");
254         break;
255
256      case 0x91: case 0x92: case 0x93: case 0x94: // LINK
257         print("LINK    %d", op & 0xf);
258         break;
259
260      case 0x95: // SEX
261         print("SEX");
262         break;
263
264      case 0x96: // ASR / DIV2
265         switch(alt)
266         {
267            case SUPERFX_SFR_ALT0:
268            case SUPERFX_SFR_ALT2:
269               print("ASR");
270               break;
271            case SUPERFX_SFR_ALT1:
272            case SUPERFX_SFR_ALT3:
273               print("DIV2");
274               break;
275         }
276         break;
277
278      case 0x97: // ROR
279         print("ROR");
280         break;
281
282      case 0x98: case 0x99: case 0x9a: case 0x9b: case 0x9c: case 0x9d: // JMP / LJMP
283         switch(alt)
284         {
285            case SUPERFX_SFR_ALT0:
286            case SUPERFX_SFR_ALT2:
287               print("JMP     R%d", op & 0xf);
288               break;
289            case SUPERFX_SFR_ALT1:
290            case SUPERFX_SFR_ALT3:
291               print("LJMP    R%d", op & 0xf);
292               break;
293         }
294         break;
295
296      case 0x9e: // LOB
297         print("LOB");
298         break;
299
300      case 0x9f: // FMULT / LMULT
301         switch(alt)
302         {
303            case SUPERFX_SFR_ALT0:
304            case SUPERFX_SFR_ALT2:
305               print("FMULT   R%d", op & 0xf);
306               break;
307            case SUPERFX_SFR_ALT1:
308            case SUPERFX_SFR_ALT3:
309               print("LMULT   R%d", op & 0xf);
310               break;
311         }
312         break;
313
314      case 0xa0: case 0xa1: case 0xa2: case 0xa3: case 0xa4: case 0xa5: case 0xa6: case 0xa7:
315      case 0xa8: case 0xa9: case 0xaa: case 0xab: case 0xac: case 0xad: case 0xae: case 0xaf: // IBT / LMS / SMS / LML
316         switch(alt)
317         {
318            case SUPERFX_SFR_ALT0:
319               print("IBT     R%d,0x%02x", op & 0xf, param0);
320               break;
321            case SUPERFX_SFR_ALT2:
322               print("SMS     R%d,(0x%04x)", op & 0xf, param0 << 1);
323               break;
324            case SUPERFX_SFR_ALT1:
325            case SUPERFX_SFR_ALT3:
326               print("LMS     R%d,(0x%04x)", op & 0xf, param0 << 1);
327               break;
328         }
329         bytes_consumed = 2;
330         break;
331
332      case 0xb0: case 0xb1: case 0xb2: case 0xb3: case 0xb4: case 0xb5: case 0xb6: case 0xb7:
333      case 0xb8: case 0xb9: case 0xba: case 0xbb: case 0xbc: case 0xbd: case 0xbe: case 0xbf: // FROM
334         print("FROM    R%d", op & 0xf);
335         break;
336
337      case 0xc0: // HIB
338         print("HIB");
339         break;
340
341               case 0xc1: case 0xc2: case 0xc3: case 0xc4: case 0xc5: case 0xc6: case 0xc7:
342      case 0xc8: case 0xc9: case 0xca: case 0xcb: case 0xcc: case 0xcd: case 0xce: case 0xcf: // OR / XOR / ORI / XORI
343         switch(alt)
344         {
345            case SUPERFX_SFR_ALT0:
346               print("OR      R%d", op &0xf);
347               break;
348            case SUPERFX_SFR_ALT1:
349               print("XOR     R%d", op &0xf);
350               break;
351            case SUPERFX_SFR_ALT2:
352               print("ORI     R%d", op &0xf);
353               break;
354            case SUPERFX_SFR_ALT3:
355               print("XORI    R%d", op &0xf);
356               break;
357         }
358         break;
359
360      case 0xd0: case 0xd1: case 0xd2: case 0xd3: case 0xd4: case 0xd5: case 0xd6: case 0xd7:
361      case 0xd8: case 0xd9: case 0xda: case 0xdb: case 0xdc: case 0xdd: case 0xde:            // INC
362         print("INC     R%d", op & 0xf);
363         break;
364
365      case 0xdf: // GETC / RAMB / ROMB
366         switch(alt)
367         {
368            case SUPERFX_SFR_ALT0:
369            case SUPERFX_SFR_ALT1:
370               print("GETC");
371               break;
372            case SUPERFX_SFR_ALT2:
373               print("RAMB");
374               break;
375            case SUPERFX_SFR_ALT3:
376               print("ROMB");
377               break;
378         }
379         break;
380
381      case 0xe0: case 0xe1: case 0xe2: case 0xe3: case 0xe4: case 0xe5: case 0xe6: case 0xe7:
382      case 0xe8: case 0xe9: case 0xea: case 0xeb: case 0xec: case 0xed: case 0xee:            // DEC
383         print("DEC     R%d", op & 0xf);
384         break;
385
386      case 0xef: // GETB / GETBH / GETBL / GETBS
387         switch(alt)
388         {
389            case SUPERFX_SFR_ALT0:
390               print("GETB");
391               break;
392            case SUPERFX_SFR_ALT1:
393               print("GETBH");
394               break;
395            case SUPERFX_SFR_ALT2:
396               print("GETBL");
397               break;
398            case SUPERFX_SFR_ALT3:
399               print("GETBS");
400               break;
401         }
402         break;
403
404      case 0xf0: case 0xf1: case 0xf2: case 0xf3: case 0xf4: case 0xf5: case 0xf6: case 0xf7:
405      case 0xf8: case 0xf9: case 0xfa: case 0xfb: case 0xfc: case 0xfd: case 0xfe: case 0xff: // IWT / LM / SM / LM
406         switch(alt)
407         {
408            case SUPERFX_SFR_ALT0:
409               print("IWT     R%d,#%02x%02x", op & 0xf, param1, param0);
410               bytes_consumed = 3;
411               break;
412            case SUPERFX_SFR_ALT2:
413               print("SM      R%d", op & 0xf);
414               break;
415            case SUPERFX_SFR_ALT1:
416            case SUPERFX_SFR_ALT3:
417               print("LM      R%d", op & 0xf);
418               break;
419         }
420         break;
421   }
422
423    return bytes_consumed | DASMFLAG_SUPPORTED;
424}
src/emu/cpu/superfx/superfx.c
r0r5535
1#include "cpuintrf.h"
2#include "debugger.h"
3#include "superfx.h"
4
5typedef struct
6{
7   UINT16 offset;
8   UINT8 bitpend;
9   UINT8 data[8];
10} pixelcache_t;
11
12typedef struct
13{
14   UINT8 buffer[0x200];
15   UINT8 valid[0x20];
16} cache_t;
17
18typedef struct _superfx_state superfx_state;
19struct _superfx_state
20{
21   UINT8  pipeline;
22
23   UINT16 r[16];   // GPRs
24   UINT16 sfr;      // Status Flag Register
25   UINT8  pbr;      // Program Bank Register
26   UINT8  rombr;   // Game Pack ROM Bank Register
27   UINT8  rambr;   // Game Pack RAM Bank Register
28   UINT16 cbr;      // Cache Base Register
29   UINT8  scbr;   // Screen Base Register
30   UINT8  scmr;   // Screen Mode Register
31   UINT8  colr;   // Color Register
32   UINT8  por;      // Plot Option Register
33   UINT8  bramr;   // Back-Up RAM Register
34   UINT8  vcr;      // Version Code Register
35   UINT8  cfgr;   // Config Register
36   UINT8  clsr;   // Clock Select Register
37
38   UINT32 romcl;   // Clock ticks until ROMDR is valid
39   UINT8  romdr;   // ROM Buffer Data Register
40
41   UINT32 ramcl;   // Clock ticks until RAMDR is valid;
42   UINT16 ramar;   // RAM Buffer Address Register
43   UINT8  ramdr;   // RAM Buffer Data Register
44   UINT16 ramaddr;   // RAM Address
45
46   UINT16 *sreg;   // Source Register (From)
47   UINT8  sreg_idx;// Source Register (To), index
48   UINT16 *dreg;   // Destination Register (To)
49   UINT8  dreg_idx;// Destination Register (To), index
50   UINT8  r15_modified;
51
52   UINT8  irq;      // IRQ Pending
53
54   UINT32 cache_access_speed;
55   UINT32 memory_access_speed;
56
57   cache_t cache;
58   pixelcache_t pixelcache[2];
59
60    const device_config *device;
61    const address_space *program;
62    int icount;
63};
64
65INLINE superfx_state *get_safe_token(const device_config *device)
66{
67    assert(device != NULL);
68    assert(device->token != NULL);
69    assert(device->type == CPU);
70    assert(cpu_get_type(device) == CPU_SUPERFX);
71    return (superfx_state *)device->token;
72}
73
74/*****************************************************************************/
75
76static void superfx_regs_reset(superfx_state *cpustate);
77static void superfx_update_speed(superfx_state *cpustate);
78static void superfx_cache_flush(superfx_state *cpustate);
79static UINT8 superfx_cache_mmio_read(superfx_state *cpustate, UINT16 addr);
80static void superfx_cache_mmio_write(superfx_state *cpustate, UINT32 addr, UINT8 data);
81static void superfx_memory_reset(superfx_state *cpustate);
82static UINT8 superfx_bus_read(superfx_state *cpustate, UINT32 addr);
83static void superfx_bus_write(superfx_state *cpustate, UINT32 addr, UINT8 data);
84static void superfx_pixelcache_flush(superfx_state *cpustate, INT32 line);
85static void superfx_plot(superfx_state *cpustate, UINT8 x, UINT8 y);
86static UINT8 superfx_rpix(superfx_state *cpustate, UINT16 r1, UINT16 r2);
87static UINT8 superfx_color(superfx_state *cpustate, UINT8 source);
88static UINT8 superfx_rambuffer_sync(superfx_state *cpustate);
89static UINT8 superfx_rambuffer_read(superfx_state *cpustate, UINT16 addr);
90static void superfx_rambuffer_write(superfx_state *cpustate, UINT16 addr, UINT8 val);
91static void superfx_rombuffer_sync(superfx_state *cpustate);
92static void superfx_rombuffer_update(superfx_state *cpustate);
93static UINT8 superfx_rombuffer_read(superfx_state *cpustate);
94static void superfx_gpr_write(superfx_state *cpustate, UINT8 r, UINT16 data);
95INLINE UINT8 superfx_op_read(superfx_state *cpustate, UINT16 addr);
96INLINE UINT8 superfx_peekpipe(superfx_state *cpustate);
97INLINE UINT8 superfx_pipe(superfx_state *cpustate);
98static void superfx_add_clocks_internal(superfx_state *cpustate, INT32 clocks);
99static void superfx_timing_reset(superfx_state *cpustate);
100
101/*****************************************************************************/
102
103#define SUPERFX_SFR_OV_SET      ((cpustate->sfr & SUPERFX_SFR_OV) ? 1 : 0)
104#define SUPERFX_SFR_OV_CLEAR   ((cpustate->sfr & SUPERFX_SFR_OV) ? 0 : 1)
105#define SUPERFX_SFR_S_SET      ((cpustate->sfr & SUPERFX_SFR_S) ? 1 : 0)
106#define SUPERFX_SFR_S_CLEAR      ((cpustate->sfr & SUPERFX_SFR_S) ? 0 : 1)
107#define SUPERFX_SFR_CY_SET      ((cpustate->sfr & SUPERFX_SFR_CY) ? 1 : 0)
108#define SUPERFX_SFR_CY_CLEAR   ((cpustate->sfr & SUPERFX_SFR_CY) ? 0 : 1)
109#define SUPERFX_SFR_Z_SET      ((cpustate->sfr & SUPERFX_SFR_Z) ? 1 : 0)
110#define SUPERFX_SFR_Z_CLEAR      ((cpustate->sfr & SUPERFX_SFR_Z) ? 0 : 1)
111
112static void superfx_regs_reset(superfx_state *cpustate)
113{
114   cpustate->sfr &= ~(SUPERFX_SFR_B | SUPERFX_SFR_ALT3);
115
116   cpustate->sreg = &cpustate->r[0];
117   cpustate->dreg = &cpustate->r[0];
118   cpustate->dreg_idx = 0;
119   cpustate->sreg_idx = 0;
120}
121
122static void superfx_update_speed(superfx_state *cpustate)
123{
124   cpustate->cache_access_speed = (cpustate->clsr ? 1 : 2);
125   cpustate->memory_access_speed = (cpustate->clsr ? 5 : 6);
126   if(cpustate->clsr)
127   {
128      cpustate->cfgr &= ~SUPERFX_CFGR_MS0; // Cannot use high-speed multiplication in 21MHz mode
129   }
130}
131
132static void superfx_cache_flush(superfx_state *cpustate)
133{
134   UINT32 n = 0;
135   for(n = 0; n < 32; n++)
136   {
137      cpustate->cache.valid[n] = 0;
138   }
139}
140
141static UINT8 superfx_cache_mmio_read(superfx_state *cpustate, UINT16 addr)
142{
143   addr = (addr + cpustate->cbr) & 0x1ff;
144   return cpustate->cache.buffer[addr];
145}
146
147static void superfx_cache_mmio_write(superfx_state *cpustate, UINT32 addr, UINT8 data)
148{
149   addr = (addr + cpustate->cbr) & 0x1ff;
150   cpustate->cache.buffer[addr] = data;
151   if((addr & 15) == 15)
152   {
153      cpustate->cache.valid[addr >> 4] = 1;
154   }
155}
156
157static void superfx_memory_reset(superfx_state *cpustate)
158{
159   UINT32 n = 0;
160   for(n = 0; n < 0x200; n++)
161   {
162      cpustate->cache.buffer[n] = 0x00;
163   }
164   for(n = 0; n < 0x20; n++)
165   {
166      cpustate->cache.valid[n] = 0;
167   }
168   for(n = 0; n < 2; n++)
169   {
170      cpustate->pixelcache[n].offset = ~0;
171      cpustate->pixelcache[n].bitpend = 0x00;
172   }
173}
174
175static UINT8 superfx_bus_read(superfx_state *cpustate, UINT32 addr)
176{
177   //printf( "superfx_bus_read: %08x\n", addr );
178   return memory_read_byte(cpustate->program, addr);
179}
180
181static void superfx_bus_write(superfx_state *cpustate, UINT32 addr, UINT8 data)
182{
183   memory_write_byte(cpustate->program, addr, data);
184   //printf( "superfx_bus_write: %08x = %02x\n", addr, data );
185   // TODO: Hook up to the same memory map as the main 65C816 CPU.  See src/chip/superfx/bus/bus.cpp in the bsnes source code.
186}
187
188static void superfx_pixelcache_flush(superfx_state *cpustate, INT32 line)
189{
190   UINT8 x = cpustate->pixelcache[line].offset << 3;
191   UINT8 y = cpustate->pixelcache[line].offset >> 5;
192   UINT32 cn = 0;
193   UINT32 bpp = 2 << ((cpustate->scmr & SUPERFX_SCMR_MD) - ((cpustate->scmr & SUPERFX_SCMR_MD) >> 1)); // = [regs.scmr.md]{ 2, 4, 4, 8 };
194   UINT32 addr = 0;
195   UINT32 n = 0;
196
197   if(cpustate->pixelcache[line].bitpend == 0x00)
198   {
199      return;
200   }
201
202   switch((cpustate->por & SUPERFX_POR_OBJ) ? SUPERFX_SCMR_HT3 : (cpustate->scmr & SUPERFX_SCMR_HT_MASK))
203   {
204      case SUPERFX_SCMR_HT0:
205         cn = ((x & 0xf8) << 1) + ((y & 0xf8) >> 3);
206         break;
207      case SUPERFX_SCMR_HT1:
208         cn = ((x & 0xf8) << 1) + ((y & 0xf8) >> 1) + ((y & 0xf8) >> 3);
209         break;
210      case SUPERFX_SCMR_HT2:
211         cn = ((x & 0xf8) << 1) + ((y & 0xf8) >> 0) + ((y & 0xf8) >> 3);
212         break;
213      case SUPERFX_SCMR_HT3:
214         cn = ((y & 0x80) << 2) + ((x & 0x80) << 1) + ((y & 0x78) << 1) + ((x & 0x78) >> 2);
215         break;
216   }
217
218   addr = 0x700000 + (cn * (bpp << 3)) + (cpustate->scbr << 10) + ((y & 0x07) * 2);
219
220   for(n = 0; n < bpp; n++)
221   {
222      UINT8 byte = ((n >> 1) << 4) + (n & 1);  // = [n]{ 0, 1, 16, 17, 32, 33, 48, 49 };
223      UINT8 data = 0x00;
224      UINT32 x = 0;
225      for(x = 0; x < 8; x++)
226      {
227         data |= ((cpustate->pixelcache[line].data[x] >> n) & 1) << x;
228      }
229      if(cpustate->pixelcache[line].bitpend != 0xff)
230      {
231         superfx_add_clocks_internal(cpustate, cpustate->memory_access_speed);
232         data &= cpustate->pixelcache[line].bitpend;
233         //printf( "superfx_pixelcache_flush: calling superfx_bus_read\n" );
234         data |= superfx_bus_read(cpustate, addr + byte) & ~cpustate->pixelcache[line].bitpend;
235      }
236      superfx_add_clocks_internal(cpustate, cpustate->memory_access_speed);
237      superfx_bus_write(cpustate, addr + byte, data);
238   }
239
240   cpustate->pixelcache[line].bitpend = 0x00;
241}
242
243static void superfx_plot(superfx_state *cpustate, UINT8 x, UINT8 y)
244{
245   UINT8 color = cpustate->colr;
246   UINT16 offset = (y << 5) + (x >> 3);
247
248   printf( "plot: %02x at %d, %d\n", color, x, y );
249
250   if((cpustate->por & SUPERFX_POR_DITHER) && ((cpustate->scmr & SUPERFX_SCMR_MD) != 3))
251   {
252      if((x ^ y) & 1)
253      {
254         color >>= 4;
255      }
256      color &= 0x0f;
257   }
258
259   if(!(cpustate->por & SUPERFX_POR_TRANSPARENT))
260   {
261      if((cpustate->scmr & SUPERFX_SCMR_MD) == 3)
262      {
263         if(cpustate->por & SUPERFX_POR_FREEZEHIGH)
264         {
265            if((color & 0x0f) == 0)
266            {
267               return;
268            }
269         }
270         else
271         {
272            if(color == 0)
273            {
274               return;
275            }
276         }
277      }
278      else
279      {
280         if((color & 0x0f) == 0)
281         {
282            return;
283         }
284      }
285   }
286
287   if(offset != cpustate->pixelcache[0].offset)
288   {
289      superfx_pixelcache_flush(cpustate, 1);
290      cpustate->pixelcache[1] = cpustate->pixelcache[0];
291      cpustate->pixelcache[0].bitpend = 0x00;
292      cpustate->pixelcache[0].offset = offset;
293   }
294
295   x = (x & 7) ^ 7;
296   cpustate->pixelcache[0].data[x] = color;
297   cpustate->pixelcache[0].bitpend |= 1 << x;
298   if(cpustate->pixelcache[0].bitpend == 0xff)
299   {
300      superfx_pixelcache_flush(cpustate, 1);
301      cpustate->pixelcache[1] = cpustate->pixelcache[0];
302      cpustate->pixelcache[0].bitpend = 0x00;
303   }
304}
305
306static UINT8 superfx_rpix(superfx_state *cpustate, UINT16 x, UINT16 y)
307{
308   UINT32 cn = 0;
309   UINT32 bpp = 2 << ((cpustate->scmr & SUPERFX_SCMR_MD) - ((cpustate->scmr & SUPERFX_SCMR_MD) >> 1)); // = [regs.scmr.md]{ 2, 4, 4, 8 };
310   UINT32 addr = 0;
311   UINT8 data = 0x00;
312   UINT32 n = 0;
313
314   superfx_pixelcache_flush(cpustate, 1);
315   superfx_pixelcache_flush(cpustate, 0);
316
317   switch((cpustate->por & SUPERFX_POR_OBJ) ? SUPERFX_SCMR_HT3 : (cpustate->scmr & SUPERFX_SCMR_HT_MASK))
318   {
319      case SUPERFX_SCMR_HT0:
320         cn = ((x & 0xf8) << 1) + ((y & 0xf8) >> 3);
321         break;
322      case SUPERFX_SCMR_HT1:
323         cn = ((x & 0xf8) << 1) + ((y & 0xf8) >> 1) + ((y & 0xf8) >> 3);
324         break;
325      case SUPERFX_SCMR_HT2:
326         cn = ((x & 0xf8) << 1) + ((y & 0xf8) >> 0) + ((y & 0xf8) >> 3);
327         break;
328      case SUPERFX_SCMR_HT3:
329         cn = ((y & 0x80) << 2) + ((x & 0x80) << 1) + ((y & 0x78) << 1) + ((x & 0x78) >> 2);
330         break;
331   }
332
333   addr = 0x700000 + (cn * (bpp << 3)) + (cpustate->scbr << 10) + ((y & 0x07) * 2);
334   x = (x & 7) ^ 7;
335
336   for(n = 0; n < bpp; n++)
337   {
338      UINT8 byte = ((n >> 1) << 4) + (n & 1);  // = [n]{ 0, 1, 16, 17, 32, 33, 48, 49 };
339      superfx_add_clocks_internal(cpustate, cpustate->memory_access_speed);
340      //printf( "superfx_rpix: calling superfx_bus_read\n" );
341      data |= ((superfx_bus_read(cpustate, addr + byte) >> x) & 1) << n;
342   }
343
344   return data;
345}
346
347static UINT8 superfx_color(superfx_state *cpustate, UINT8 source)
348{
349   if(cpustate->por & SUPERFX_POR_HIGHNIBBLE)
350   {
351      return (cpustate->colr & 0xf0) | (source >> 4);
352   }
353   if(cpustate->por & SUPERFX_POR_FREEZEHIGH)
354   {
355      return (cpustate->colr & 0xf0) | (source & 0x0f);
356   }
357   return source;
358}
359
360static UINT8 superfx_rambuffer_sync(superfx_state *cpustate)
361{
362   if(cpustate->ramcl)
363   {
364      superfx_add_clocks_internal(cpustate, cpustate->ramcl);
365   }
366   return 0;
367}
368
369static UINT8 superfx_rambuffer_read(superfx_state *cpustate, UINT16 addr)
370{
371   //superfx_rambuffer_sync(cpustate);
372   //printf( "superfx_rambuffer_read: calling superfx_bus_read\n" );
373   return superfx_bus_read(cpustate, 0x700000 + (cpustate->rambr << 16) + addr);
374}
375
376static void superfx_rambuffer_write(superfx_state *cpustate, UINT16 addr, UINT8 data)
377{
378   superfx_bus_write(cpustate, 0x700000 + (cpustate->rambr << 16) + cpustate->ramar, cpustate->ramdr);
379   //superfx_rambuffer_sync(cpustate);
380   //cpustate->ramcl = cpustate->memory_access_speed;
381   //cpustate->ramar = addr;
382   //cpustate->ramdr = data;
383}
384
385static void superfx_rombuffer_sync(superfx_state *cpustate)
386{
387   //printf( "superfx_rombuffer_sync\n" );
388   if(cpustate->romcl)
389   {
390      printf( "calling add_clocks_internal\n" );
391      superfx_add_clocks_internal(cpustate, cpustate->romcl);
392   }
393}
394
395static void superfx_rombuffer_update(superfx_state *cpustate)
396{
397   cpustate->sfr |= SUPERFX_SFR_R;
398   //printf( "superfx_rombuffer_update: setting romcl\n" );
399   cpustate->romcl = cpustate->memory_access_speed;
400}
401
402static UINT8 superfx_rombuffer_read(superfx_state *cpustate)
403{
404   superfx_rombuffer_sync(cpustate);
405   printf( "superfx_rombuffer_read: %02x\n", cpustate->romdr);
406   return cpustate->romdr;
407}
408
409static void superfx_gpr_write(superfx_state *cpustate, UINT8 r, UINT16 data)
410{
411   cpustate->r[r] = data;
412   if(r == 14)
413   {
414      superfx_rombuffer_update(cpustate);
415   }
416   else if(r == 15)
417   {
418      cpustate->r15_modified = 1;
419   }
420}
421
422INLINE UINT8 superfx_op_read(superfx_state *cpustate, UINT16 addr)
423{
424   UINT16 offset = addr - cpustate->cbr;
425   if(offset < 512)
426   {
427      if(!cpustate->cache.valid[offset >> 4])
428      {
429         UINT32 dp = offset & 0xfff0;
430         UINT32 sp = (cpustate->pbr << 16) + ((cpustate->cbr + dp) & 0xfff0);
431         UINT32 n = 0;
432         for(n = 0; n < 16; n++)
433         {
434            superfx_add_clocks_internal(cpustate, cpustate->memory_access_speed);
435            //printf( "superfx_op_read: caching superfx_bus_read value\n" );
436            cpustate->cache.buffer[dp++] = superfx_bus_read(cpustate, sp++);
437         }
438         cpustate->cache.valid[offset >> 4] = 1;
439      }
440      else
441      {
442         superfx_add_clocks_internal(cpustate, cpustate->memory_access_speed);
443      }
444      return cpustate->cache.buffer[offset];
445   }
446
447   if(cpustate->pbr <= 0x5f)
448   {
449      //$[00-5f]:[0000-ffff] ROM
450      superfx_rombuffer_sync(cpustate);
451      superfx_add_clocks_internal(cpustate, cpustate->memory_access_speed);
452      //printf( "superfx_op_read: reading from rom, calling superfx_bus_read\n" );
453      return superfx_bus_read(cpustate, (cpustate->pbr << 16) + addr);
454   }
455   else
456   {
457      //$[60-7f]:[0000-ffff] RAM
458      superfx_rambuffer_sync(cpustate);
459      superfx_add_clocks_internal(cpustate, cpustate->memory_access_speed);
460      //printf( "superfx_op_read: reading from ram, calling superfx_bus_read\n" );
461      return superfx_bus_read(cpustate, (cpustate->pbr << 16) + addr);
462   }
463}
464
465INLINE UINT8 superfx_peekpipe(superfx_state *cpustate)
466{
467   UINT8 result = cpustate->pipeline;
468   cpustate->pipeline = superfx_op_read(cpustate, cpustate->r[15]);
469   cpustate->r15_modified = 0;
470   return result;
471}
472
473INLINE UINT8 superfx_pipe(superfx_state *cpustate)
474{
475   UINT8 result = cpustate->pipeline;
476   cpustate->pipeline = superfx_op_read(cpustate, ++cpustate->r[15]);
477   cpustate->r15_modified = 0;
478   return result;
479}
480
481/*****************************************************************************/
482
483UINT8 superfx_mmio_read(const device_config *cpu, UINT32 addr)
484{
485   superfx_state *cpustate = get_safe_token(cpu);
486
487   addr &= 0xffff;
488
489   if(addr != 0x3030)
490   {
491      //printf( "superfx_mmio_read: %08x\n", addr );
492   }
493
494   if(addr >= 0x3100 && addr <= 0x32ff)
495   {
496      return superfx_cache_mmio_read(cpustate, addr - 0x3100);
497   }
498
499   if(addr >= 0x3000 && addr <= 0x301f)
500   {
501      return cpustate->r[(addr >> 1) & 0xf] >> ((addr & 1) << 3);
502   }
503
504   switch(addr)
505   {
506      case 0x3030:
507         return cpustate->sfr >> 0;
508
509      case 0x3031:
510      {
511         UINT8 r = cpustate->sfr >> 8;
512         cpustate->sfr &= ~SUPERFX_SFR_IRQ;
513         cpustate->irq = 0;
514         return r;
515      }
516
517      case 0x3034:
518         return cpustate->pbr;
519
520      case 0x3036:
521         return cpustate->rombr;
522
523      case 0x303b:
524         return cpustate->vcr;
525
526      case 0x303c:
527         return cpustate->rambr;
528
529      case 0x303e:
530         return cpustate->cbr >> 0;
531
532      case 0x303f:
533         return cpustate->cbr >> 8;
534   }
535
536   return 0;
537}
538
539void superfx_mmio_write(const device_config *cpu, UINT32 addr, UINT8 data)
540{
541   superfx_state *cpustate = get_safe_token(cpu);
542
543   //printf( "superfx_mmio_write: %08x = %02x\n", addr, data );
544
545   addr &= 0xffff;
546
547   if(addr >= 0x3100 && addr <= 0x32ff)
548   {
549      return superfx_cache_mmio_write(cpustate, addr - 0x3100, data);
550   }
551
552   if(addr >= 0x3000 && addr <= 0x301f)
553   {
554      UINT32 n = (addr >> 1) & 0xf;
555      if((addr & 1) == 0)
556      {
557         cpustate->r[n] = (cpustate->r[n] & 0xff00) | data;
558      }
559      else
560      {
561         cpustate->r[n] = (data << 8) | (cpustate->r[n] & 0xff);
562      }
563
564      if(addr == 0x301f)
565      {
566         cpustate->sfr |= SUPERFX_SFR_G;
567      }
568      return;
569   }
570
571   switch(addr)
572   {
573      case 0x3030:
574      {
575         UINT8 g = (cpustate->sfr & SUPERFX_SFR_G) ? 1 : 0;
576         cpustate->sfr = (cpustate->sfr & 0xff00) | (data << 0);
577         if(g == 1 && !(cpustate->sfr & SUPERFX_SFR_G))
578         {
579            cpustate->cbr = 0x0000;
580            superfx_cache_flush(cpustate);
581         }
582         break;
583      }
584
585      case 0x3031:
586         cpustate->sfr = (data << 8) | (cpustate->sfr & 0x00ff);
587         break;
588
589      case 0x3033:
590         cpustate->bramr = data;
591         break;
592
593      case 0x3034:
594         cpustate->pbr = data;
595         superfx_cache_flush(cpustate);
596         break;
597
598      case 0x3037:
599         cpustate->cfgr = data;
600         superfx_update_speed(cpustate);
601         break;
602
603      case 0x3038:
604         cpustate->scbr = data;
605         break;
606
607      case 0x3039:
608         cpustate->clsr = data;
609         superfx_update_speed(cpustate);
610         break;
611
612      case 0x303a:
613         cpustate->scmr = data;
614         break;
615   }
616}
617
618static void superfx_add_clocks_internal(superfx_state *cpustate, INT32 clocks)
619{
620   //printf( "superfx_add_clocks: %d\n", clocks);
621   /*
622    if(cpustate->romcl)
623    {
624        printf( "ROM is accessing\n" );
625        printf( "romcl = %d, -= MIN(%d, %d) (= %d)\n", cpustate->romcl, clocks, cpustate->romcl, MIN(clocks, cpustate->romcl));
626        cpustate->romcl -= MIN(clocks, cpustate->romcl);
627        if(cpustate->romcl == 0)
628        {
629            cpustate->sfr &= ~SUPERFX_SFR_R;
630            printf( "superfx_op_read: reading from rom, calling superfx_bus_read: %08x\n", (cpustate->rombr << 16) + cpustate->r[14] );
631            cpustate->romdr = superfx_bus_read(cpustate, (cpustate->rombr << 16) + cpustate->r[14]);
632        }
633    }
634    */
635
636   if(cpustate->ramcl)
637   {
638      cpustate->ramcl -= MIN(clocks, cpustate->ramcl);
639      if(cpustate->ramcl == 0)
640      {
641         printf( "Writing %02x to %08x\n", cpustate->ramdr, 0x700000 + (cpustate->rambr << 16) + cpustate->ramar );
642         superfx_bus_write(cpustate, 0x700000 + (cpustate->rambr << 16) + cpustate->ramar, cpustate->ramdr);
643      }
644   }
645}
646
647static void superfx_timing_reset(superfx_state *cpustate)
648{
649   superfx_update_speed(cpustate);
650   cpustate->r15_modified = 0;
651
652   cpustate->romcl = 0;
653   cpustate->romdr = 0;
654
655   cpustate->ramcl = 0;
656   cpustate->ramar = 0;
657   cpustate->ramdr = 0;
658}
659
660void superfx_add_clocks(const device_config *cpu, INT32 clocks)
661{
662   superfx_state *cpustate = get_safe_token(cpu);
663
664   superfx_add_clocks_internal(cpustate, clocks);
665}
666
667/*****************************************************************************/
668
669static CPU_INIT( superfx )
670{
671   int i;
672    superfx_state *cpustate = get_safe_token(device);
673
674   for(i = 0; i < 16; i++)
675   {
676      cpustate->r[i] = 0;
677   }
678
679   cpustate->sfr = 0;
680   cpustate->pbr = 0;
681   cpustate->rombr = 0;
682   cpustate->rambr = 0;
683   cpustate->cbr = 0;
684   cpustate->scbr = 0;
685   cpustate->scmr = 0;
686   cpustate->colr = 0;
687   cpustate->por = 0;
688   cpustate->bramr = 0;
689   cpustate->vcr = 0x04;
690   cpustate->cfgr = 0;
691   cpustate->clsr = 0;
692   cpustate->pipeline = 0x01; // nop
693   cpustate->ramaddr = 0;
694   cpustate->r15_modified = 0;
695
696   superfx_regs_reset(cpustate);
697   superfx_memory_reset(cpustate);
698   superfx_update_speed(cpustate);
699
700    cpustate->device = device;
701    cpustate->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
702}
703
704static CPU_EXIT( superfx )
705{
706}
707
708static CPU_RESET( superfx )
709{
710   int i;
711
712    superfx_state *cpustate = get_safe_token(device);
713
714   for(i = 0; i < 16; i++)
715   {
716      cpustate->r[i] = 0;
717   }
718
719   cpustate->sfr = 0;
720   cpustate->pbr = 0;
721   cpustate->rombr = 0;
722   cpustate->rambr = 0;
723   cpustate->cbr = 0;
724   cpustate->scbr = 0;
725   cpustate->scmr = 0;
726   cpustate->colr = 0;
727   cpustate->por = 0;
728   cpustate->bramr = 0;
729   cpustate->vcr = 0x04;
730   cpustate->cfgr = 0;
731   cpustate->clsr = 0;
732   cpustate->pipeline = 0x01; // nop
733   cpustate->ramaddr = 0;
734
735   superfx_regs_reset(cpustate);
736   superfx_timing_reset(cpustate);
737}
738
739INLINE void superfx_dreg_sfr_sz_update(superfx_state *cpustate)
740{
741   cpustate->sfr &= ~(SUPERFX_SFR_S | SUPERFX_SFR_Z);
742   cpustate->sfr |= (*(cpustate->dreg) & 0x8000) ? SUPERFX_SFR_S : 0;
743   cpustate->sfr |= (*(cpustate->dreg) == 0) ? SUPERFX_SFR_Z : 0;
744}
745
746static CPU_EXECUTE( superfx )
747{
748   superfx_state *cpustate = get_safe_token(device);
749   UINT8 op;
750
751   cpustate->icount = cycles;
752
753   if(!(cpustate->sfr & SUPERFX_SFR_G))
754   {
755      superfx_add_clocks_internal(cpustate, 6);
756      cpustate->icount = MIN(cpustate->icount, 0);
757   }
758
759   while (cpustate->icount > 0 && (cpustate->sfr & SUPERFX_SFR_G))
760   {
761      if(!(cpustate->sfr & SUPERFX_SFR_G))
762      {
763         superfx_add_clocks_internal(cpustate, 6);
764         cpustate->icount = MIN(cpustate->icount, 0);
765         break;
766      }
767
768      debugger_instruction_hook(device, (cpustate->pbr << 16) | cpustate->r[15]);
769
770        op = superfx_peekpipe(cpustate);
771
772      printf( "Executing op at %06x: %02x\n", (cpustate->pbr << 16) | cpustate->r[15], op );
773      switch(op)
774      {
775         case 0x00: // STOP
776            if(!(cpustate->cfgr & SUPERFX_CFGR_IRQ))
777            {
778               cpustate->sfr |= SUPERFX_SFR_IRQ;
779               cpustate->irq = 1;
780            }
781            cpustate->sfr &= ~SUPERFX_SFR_G;
782            cpustate->pipeline = 0x01;
783            superfx_regs_reset(cpustate);
784            break;
785         case 0x01: // NOP
786            superfx_regs_reset(cpustate);
787            break;
788         case 0x02: // CACHE
789            if(cpustate->cbr != (cpustate->r[15] & 0xfff0))
790            {
791               cpustate->cbr = cpustate->r[15] & 0xfff0;
792               superfx_cache_flush(cpustate);
793            }
794            superfx_regs_reset(cpustate);
795            break;
796         case 0x03: // LSR
797            cpustate->sfr &= ~SUPERFX_SFR_CY;
798            cpustate->sfr |= (*(cpustate->sreg) & 1) ? SUPERFX_SFR_CY : 0;
799            superfx_gpr_write(cpustate, cpustate->dreg_idx, *(cpustate->sreg) >> 1);
800            superfx_dreg_sfr_sz_update(cpustate);
801            superfx_regs_reset(cpustate);
802            break;
803         case 0x04: // ROL
804         {
805            UINT16 carry = *(cpustate->sreg) & 0x8000;
806            superfx_gpr_write(cpustate, cpustate->dreg_idx, (*(cpustate->sreg) << 1) | (SUPERFX_SFR_CY_SET ? 1 : 0));
807            cpustate->sfr &= ~SUPERFX_SFR_CY;
808            cpustate->sfr |= carry ? SUPERFX_SFR_CY : 0;
809            superfx_dreg_sfr_sz_update(cpustate);
810            superfx_regs_reset(cpustate);
811            break;
812         }
813         case 0x05: // BRA
814         {
815            INT32 e = (INT8)superfx_pipe(cpustate);
816            superfx_gpr_write(cpustate, 15, cpustate->r[15] + e);
817            break;
818         }
819         case 0x06: // BLT
820         {
821            INT32 e = (INT8)superfx_pipe(cpustate);
822            if((SUPERFX_SFR_S_SET ^ SUPERFX_SFR_OV_SET) == 0)
823            {
824               superfx_gpr_write(cpustate, 15, cpustate->r[15] + e);
825            }
826            break;
827         }
828         case 0x07: // BGE
829         {
830            INT32 e = (INT8)superfx_pipe(cpustate);
831            if((SUPERFX_SFR_S_SET ^ SUPERFX_SFR_OV_SET) == 1)
832            {
833               superfx_gpr_write(cpustate, 15, cpustate->r[15] + e);
834            }
835            break;
836         }
837         case 0x08: // BNE
838         {
839            INT32 e = (INT8)superfx_pipe(cpustate);
840            if(SUPERFX_SFR_Z_SET == 0)
841            {
842               superfx_gpr_write(cpustate, 15, cpustate->r[15] + e);
843            }
844            break;
845         }
846         case 0x09: // BEQ
847         {
848            INT32 e = (INT8)superfx_pipe(cpustate);
849            if(SUPERFX_SFR_Z_SET == 1)
850            {
851               superfx_gpr_write(cpustate, 15, cpustate->r[15] + e);
852            }
853            break;
854         }
855         case 0x0a: // BPL
856         {
857            INT32 e = (INT8)superfx_pipe(cpustate);
858            if(SUPERFX_SFR_S_SET == 0)
859            {
860               superfx_gpr_write(cpustate, 15, cpustate->r[15] + e);
861            }
862            break;
863         }
864         case 0x0b: // BMI
865         {
866            INT32 e = (INT8)superfx_pipe(cpustate);
867            if(SUPERFX_SFR_S_SET == 1)
868            {
869               superfx_gpr_write(cpustate, 15, cpustate->r[15] + e);
870            }
871            break;
872         }
873         case 0x0c: // BCC
874         {
875            INT32 e = (INT8)superfx_pipe(cpustate);
876            if(SUPERFX_SFR_CY_SET == 0)
877            {
878               superfx_gpr_write(cpustate, 15, cpustate->r[15] + e);
879            }
880            break;
881         }
882         case 0x0d: // BCS
883         {
884            INT32 e = (INT8)superfx_pipe(cpustate);
885            if(SUPERFX_SFR_CY_SET == 1)
886            {
887               superfx_gpr_write(cpustate, 15, cpustate->r[15] + e);
888            }
889            break;
890         }
891         case 0x0e: // BVC
892         {
893            INT32 e = (INT8)superfx_pipe(cpustate);
894            if(SUPERFX_SFR_OV_SET == 0)
895            {
896               superfx_gpr_write(cpustate, 15, cpustate->r[15] + e);
897            }
898            break;
899         }
900         case 0x0f: // BVS
901         {
902            INT32 e = (INT8)superfx_pipe(cpustate);
903            if(SUPERFX_SFR_OV_SET == 1)
904            {
905               superfx_gpr_write(cpustate, 15, cpustate->r[15] + e);
906            }
907            break;
908         }
909
910         case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17:
911         case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f:   // TO
912            if(!(cpustate->sfr & SUPERFX_SFR_B))
913            {
914               cpustate->dreg = &cpustate->r[op & 0xf];
915               cpustate->dreg_idx = op & 0xf;
916            }
917            else
918            {
919               superfx_gpr_write(cpustate, op & 0xf, *(cpustate->sreg));
920               superfx_regs_reset(cpustate);
921            }
922            break;
923
924         case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27:
925         case 0x28: case 0x29: case 0x2a: case 0x2b: case 0x2c: case 0x2d: case 0x2e: case 0x2f: // WITH
926            cpustate->sreg = &cpustate->r[op & 0xf];
927            cpustate->sreg_idx = op & 0xf;
928            cpustate->dreg = &cpustate->r[op & 0xf];
929            cpustate->dreg_idx = op & 0xf;
930            cpustate->sfr |= SUPERFX_SFR_B;
931            break;
932
933         case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35:
934         case 0x36: case 0x37: case 0x38: case 0x39: case 0x3a: case 0x3b:   // STW_IR / STB_IR
935            if((cpustate->sfr & SUPERFX_SFR_ALT1) == 0)
936            { // STW_IR
937               cpustate->ramaddr = cpustate->r[op & 0xf];
938               superfx_rambuffer_write(cpustate, cpustate->ramaddr ^ 0, (*(cpustate->sreg)) >> 0);
939               superfx_rambuffer_write(cpustate, cpustate->ramaddr ^ 1, (*(cpustate->sreg)) >> 8);
940               superfx_regs_reset(cpustate);
941            }
942            else
943            { // STB_IR
944               cpustate->ramaddr = cpustate->r[op & 0xf];
945               superfx_rambuffer_write(cpustate, cpustate->ramaddr, *(cpustate->sreg));
946               superfx_regs_reset(cpustate);
947            }
948            break;
949
950         case 0x3c: // LOOP
951            superfx_gpr_write(cpustate, 12, cpustate->r[12] - 1);
952            cpustate->sfr &= ~(SUPERFX_SFR_S | SUPERFX_SFR_Z);
953            cpustate->sfr |= (cpustate->r[12] & 0x8000) ? SUPERFX_SFR_S : 0;
954            cpustate->sfr |= (cpustate->r[12] == 0) ? SUPERFX_SFR_Z : 0;
955            if(!(cpustate->sfr & SUPERFX_SFR_Z))
956            {
957               superfx_gpr_write(cpustate, 15, cpustate->r[13]);
958            }
959            superfx_regs_reset(cpustate);
960            break;
961         case 0x3d: // ALT1
962            cpustate->sfr &= ~SUPERFX_SFR_B;
963            cpustate->sfr |= SUPERFX_SFR_ALT1;
964            break;
965         case 0x3e: // ALT2
966            cpustate->sfr &= ~SUPERFX_SFR_B;
967            cpustate->sfr |= SUPERFX_SFR_ALT2;
968            break;
969         case 0x3f: // ALT3
970            cpustate->sfr &= ~SUPERFX_SFR_B;
971            cpustate->sfr |= SUPERFX_SFR_ALT1;
972            cpustate->sfr |= SUPERFX_SFR_ALT2;
973            break;
974
975         case 0x40: case 0x41: case 0x42: case 0x43: case 0x44: case 0x45:
976         case 0x46: case 0x47: case 0x48: case 0x49: case 0x4a: case 0x4b:   // LDW_IR / LDB_IR
977            if((cpustate->sfr & SUPERFX_SFR_ALT1) == 0)
978            { // LDW_IR
979               UINT16 data = 0;
980               cpustate->ramaddr = cpustate->r[op & 0xf];
981               data  = superfx_rambuffer_read(cpustate, (cpustate->ramaddr ^ 0) << 0);
982               data |= superfx_rambuffer_read(cpustate, (cpustate->ramaddr ^ 1) << 8);
983               superfx_gpr_write(cpustate, cpustate->dreg_idx, data);
984               superfx_regs_reset(cpustate);
985            }
986            else
987            { // LDB_IR
988               cpustate->ramaddr = cpustate->r[op & 0xf];
989               superfx_gpr_write(cpustate, cpustate->dreg_idx, superfx_rambuffer_read(cpustate, cpustate->ramaddr));
990               superfx_regs_reset(cpustate);
991            }
992            break;
993
994         case 0x4c: // PLOT / RPIX
995            if((cpustate->sfr & SUPERFX_SFR_ALT1) == 0)
996            { // PLOT
997               superfx_plot(cpustate, cpustate->r[1], cpustate->r[2]);
998               superfx_gpr_write(cpustate, 1, cpustate->r[1] + 1);
999               superfx_regs_reset(cpustate);
1000            }
1001            else
1002            { // RPIX
1003               superfx_gpr_write(cpustate, cpustate->dreg_idx, superfx_rpix(cpustate, cpustate->r[1], cpustate->r[2]));
1004               superfx_dreg_sfr_sz_update(cpustate);
1005               superfx_regs_reset(cpustate);
1006            }
1007            break;
1008
1009         case 0x4d: // SWAP
1010            superfx_gpr_write(cpustate, cpustate->dreg_idx, (*(cpustate->sreg) >> 8) | (*(cpustate->sreg) << 8));
1011            superfx_dreg_sfr_sz_update(cpustate);
1012            superfx_regs_reset(cpustate);
1013            break;
1014
1015         case 0x4e: // COLOR / CMODE
1016            if((cpustate->sfr & SUPERFX_SFR_ALT1) == 0)
1017            { // COLOR
1018               cpustate->colr = superfx_color(cpustate, *(cpustate->sreg));
1019               superfx_regs_reset(cpustate);
1020            }
1021            else
1022            { // CMODE
1023               cpustate->por = *(cpustate->sreg);
1024               superfx_regs_reset(cpustate);
1025            }
1026            break;
1027
1028         case 0x4f: // NOT
1029            superfx_gpr_write(cpustate, cpustate->dreg_idx, ~(*(cpustate->sreg)));
1030            superfx_dreg_sfr_sz_update(cpustate);
1031            superfx_regs_reset(cpustate);
1032            break;
1033
1034         case 0x50: case 0x51: case 0x52: case 0x53: case 0x54: case 0x55: case 0x56: case 0x57:
1035         case 0x58: case 0x59: case 0x5a: case 0x5b: case 0x5c: case 0x5d: case 0x5e: case 0x5f: // ADD / ADC / ADDI / ADCI
1036         {
1037            INT32 r = *(cpustate->sreg);
1038            cpustate->sfr &= ~(SUPERFX_SFR_OV | SUPERFX_SFR_S | SUPERFX_SFR_CY | SUPERFX_SFR_Z);
1039            switch(cpustate->sfr & SUPERFX_SFR_ALT)
1040            {
1041               case SUPERFX_SFR_ALT0: // ADD
1042                  r += cpustate->r[op & 0xf];
1043                  cpustate->sfr |= (~(*(cpustate->sreg) ^ cpustate->r[op & 0xf]) & (cpustate->r[op & 0xf] ^ r) & 0x8000) ? SUPERFX_SFR_OV : 0;
1044                  break;
1045               case SUPERFX_SFR_ALT1: // ADC
1046                  r += cpustate->r[op & 0xf] + ((cpustate->sfr & SUPERFX_SFR_CY) ? 1 : 0);
1047                  cpustate->sfr |= (~(*(cpustate->sreg) ^ cpustate->r[op & 0xf]) & (cpustate->r[op & 0xf] ^ r) & 0x8000) ? SUPERFX_SFR_OV : 0;
1048                  break;
1049               case SUPERFX_SFR_ALT2: // ADDI
1050                  r += op & 0xf;
1051                  cpustate->sfr |= (~(*(cpustate->sreg) ^ (op & 0xf)) & ((op & 0xf) ^ r) & 0x8000) ? SUPERFX_SFR_OV : 0;
1052                  break;
1053               case SUPERFX_SFR_ALT3: // ADCI
1054                  r += (op & 0xf) + ((cpustate->sfr & SUPERFX_SFR_CY) ? 1 : 0);
1055                  cpustate->sfr |= (~(*(cpustate->sreg) ^ (op & 0xf)) & ((op & 0xf) ^ r) & 0x8000) ? SUPERFX_SFR_OV : 0;
1056                  break;
1057            }
1058            cpustate->sfr |= (r & 0x8000) ? SUPERFX_SFR_S : 0;
1059            cpustate->sfr |= (r >= 0x10000) ? SUPERFX_SFR_CY : 0;
1060            cpustate->sfr |= ((UINT16)r == 0) ? SUPERFX_SFR_Z : 0;
1061            superfx_gpr_write(cpustate, cpustate->dreg_idx, r);
1062            superfx_regs_reset(cpustate);
1063            break;
1064         }
1065
1066         case 0x60: case 0x61: case 0x62: case 0x63: case 0x64: case 0x65: case 0x66: case 0x67:
1067         case 0x68: case 0x69: case 0x6a: case 0x6b: case 0x6c: case 0x6d: case 0x6e: case 0x6f: // SUB / SBC / SUBI / CMP
1068         {
1069            INT32 r = *(cpustate->sreg);
1070            cpustate->sfr &= ~(SUPERFX_SFR_OV | SUPERFX_SFR_S | SUPERFX_SFR_CY | SUPERFX_SFR_Z);
1071            switch(cpustate->sfr & SUPERFX_SFR_ALT)
1072            {
1073               case SUPERFX_SFR_ALT0: // SUB
1074                  r -= cpustate->r[op & 0xf];
1075                  cpustate->sfr |= ((*(cpustate->sreg) ^ cpustate->r[op & 0xf]) & (*(cpustate->sreg) ^ r) & 0x8000) ? SUPERFX_SFR_OV : 0;
1076                  superfx_gpr_write(cpustate, cpustate->dreg_idx, r);
1077                  break;
1078               case SUPERFX_SFR_ALT1: // SBC
1079                  r -= cpustate->r[op & 0xf] - ((cpustate->sfr & SUPERFX_SFR_CY) ? 0 : 1);
1080                  cpustate->sfr |= ((*(cpustate->sreg) ^ cpustate->r[op & 0xf]) & (*(cpustate->sreg) ^ r) & 0x8000) ? SUPERFX_SFR_OV : 0;
1081                  superfx_gpr_write(cpustate, cpustate->dreg_idx, r);
1082                  break;
1083               case SUPERFX_SFR_ALT2: // SUBI
1084                  r -= op & 0xf;
1085                  cpustate->sfr |= ((*(cpustate->sreg) ^ (op & 0xf)) & (*(cpustate->sreg) ^ r) & 0x8000) ? SUPERFX_SFR_OV : 0;
1086                  superfx_gpr_write(cpustate, cpustate->dreg_idx, r);
1087                  break;
1088               case SUPERFX_SFR_ALT3: // CMP
1089                  r -= cpustate->r[op & 0xf];
1090                  cpustate->sfr |= ((*(cpustate->sreg) ^ cpustate->r[op & 0xf]) & (*(cpustate->sreg) ^ r) & 0x8000) ? SUPERFX_SFR_OV : 0;
1091                  break;
1092            }
1093            cpustate->sfr |= (r & 0x8000) ? SUPERFX_SFR_S : 0;
1094            cpustate->sfr |= (r >= 0x10000) ? SUPERFX_SFR_CY : 0;
1095            cpustate->sfr |= ((UINT16)r == 0) ? SUPERFX_SFR_Z : 0;
1096            superfx_regs_reset(cpustate);
1097            break;
1098         }
1099
1100         case 0x70: // MERGE
1101            superfx_gpr_write(cpustate, cpustate->dreg_idx, (cpustate->r[7] & 0xff00) | (cpustate->r[8] >> 8));
1102            cpustate->sfr &= ~(SUPERFX_SFR_OV | SUPERFX_SFR_S | SUPERFX_SFR_CY | SUPERFX_SFR_Z);
1103            cpustate->sfr |= (*(cpustate->dreg) & 0xc0c0) ? SUPERFX_SFR_OV : 0;
1104            cpustate->sfr |= (*(cpustate->dreg) & 0x8080) ? SUPERFX_SFR_S : 0;
1105            cpustate->sfr |= (*(cpustate->dreg) & 0xe0e0) ? SUPERFX_SFR_CY : 0;
1106            cpustate->sfr |= (*(cpustate->dreg) & 0xf0f0) ? SUPERFX_SFR_Z : 0;
1107            superfx_regs_reset(cpustate);
1108            break;
1109
1110                    case 0x71: case 0x72: case 0x73: case 0x74: case 0x75: case 0x76: case 0x77:
1111         case 0x78: case 0x79: case 0x7a: case 0x7b: case 0x7c: case 0x7d: case 0x7e: case 0x7f: // AND / BIC / ANDI / BICI
1112            switch(cpustate->sfr & SUPERFX_SFR_ALT)
1113            {
1114               case SUPERFX_SFR_ALT0: // AND
1115                  superfx_gpr_write(cpustate, cpustate->dreg_idx, *(cpustate->sreg) & cpustate->r[op & 0xf]);
1116                  break;
1117               case SUPERFX_SFR_ALT1: // BIC
1118                  superfx_gpr_write(cpustate, cpustate->dreg_idx, *(cpustate->sreg) & ~cpustate->r[op & 0xf]);
1119                  break;
1120               case SUPERFX_SFR_ALT2: // ANDI
1121                  superfx_gpr_write(cpustate, cpustate->dreg_idx, *(cpustate->sreg) & (op & 0xf));
1122                  break;
1123               case SUPERFX_SFR_ALT3: // BICI
1124                  superfx_gpr_write(cpustate, cpustate->dreg_idx, *(cpustate->sreg) & ~(op & 0xf));
1125                  break;
1126            }
1127            superfx_dreg_sfr_sz_update(cpustate);
1128            superfx_regs_reset(cpustate);
1129            break;
1130
1131         case 0x80: case 0x81: case 0x82: case 0x83: case 0x84: case 0x85: case 0x86: case 0x87:
1132         case 0x88: case 0x89: case 0x8a: case 0x8b: case 0x8c: case 0x8d: case 0x8e: case 0x8f: // MULT / UMULT / MULTI / UMULTI
1133            switch(cpustate->sfr & SUPERFX_SFR_ALT)
1134            {
1135               case SUPERFX_SFR_ALT0: // MULT
1136                  superfx_gpr_write(cpustate, cpustate->dreg_idx, (INT8)(*(cpustate->sreg)) * (INT8)(cpustate->r[op & 0xf]));
1137                  break;
1138               case SUPERFX_SFR_ALT1: // UMULT
1139                  superfx_gpr_write(cpustate, cpustate->dreg_idx, (UINT8)(*(cpustate->sreg)) * (UINT8)(cpustate->r[op & 0xf]));
1140                  break;
1141               case SUPERFX_SFR_ALT2: // MULTI
1142                  superfx_gpr_write(cpustate, cpustate->dreg_idx, (INT8)(*(cpustate->sreg)) * (INT8)(op & 0xf));
1143                  break;
1144               case SUPERFX_SFR_ALT3: // UMULTI
1145                  superfx_gpr_write(cpustate, cpustate->dreg_idx, (UINT8)(*(cpustate->sreg)) * (UINT8)(op & 0xf));
1146                  break;
1147            }
1148            superfx_dreg_sfr_sz_update(cpustate);
1149            superfx_regs_reset(cpustate);
1150            if(!(cpustate->cfgr & SUPERFX_CFGR_MS0))
1151            {
1152               superfx_add_clocks_internal(cpustate, 2);
1153            }
1154            break;
1155
1156         case 0x90: // SBK
1157            superfx_rambuffer_write(cpustate, cpustate->ramaddr ^ 0, *(cpustate->sreg) >> 0);
1158            superfx_rambuffer_write(cpustate, cpustate->ramaddr ^ 1, *(cpustate->sreg) >> 8);
1159            superfx_regs_reset(cpustate);
1160            break;
1161
1162         case 0x91: case 0x92: case 0x93: case 0x94: // LINK
1163            superfx_gpr_write(cpustate, 11, cpustate->r[15] + (op & 0xf));
1164            superfx_regs_reset(cpustate);
1165            break;
1166
1167         case 0x95: // SEX
1168            superfx_gpr_write(cpustate, cpustate->dreg_idx, (INT8)(*(cpustate->sreg)));
1169            superfx_dreg_sfr_sz_update(cpustate);
1170            superfx_regs_reset(cpustate);
1171            break;
1172
1173         case 0x96: // ASR / DIV2
1174            if((cpustate->sfr & SUPERFX_SFR_ALT1) == 0)
1175            { // ASR
1176               cpustate->sfr &= ~SUPERFX_SFR_CY;
1177               cpustate->sfr |= (*(cpustate->sreg) & 1) ? SUPERFX_SFR_CY : 0;
1178               superfx_gpr_write(cpustate, cpustate->dreg_idx, (INT16)(*(cpustate->sreg) >> 1));
1179               superfx_dreg_sfr_sz_update(cpustate);
1180               superfx_regs_reset(cpustate);
1181            }
1182            else
1183            { // DIV2
1184               cpustate->sfr &= ~SUPERFX_SFR_CY;
1185               cpustate->sfr |= (*(cpustate->sreg) & 1) ? SUPERFX_SFR_CY : 0;
1186               superfx_gpr_write(cpustate, cpustate->dreg_idx, ((INT16)(*(cpustate->sreg) >> 1)) + ((*(cpustate->sreg) + 1) >> 16));
1187               superfx_dreg_sfr_sz_update(cpustate);
1188               superfx_regs_reset(cpustate);
1189            }
1190            break;
1191
1192         case 0x97: // ROR
1193         {
1194            UINT16 carry = *(cpustate->sreg) & 1;
1195            superfx_gpr_write(cpustate, cpustate->dreg_idx, (((cpustate->sfr & SUPERFX_SFR_CY) ? 1 : 0) << 15) | (*(cpustate->sreg) >> 1));
1196            cpustate->sfr &= ~SUPERFX_SFR_CY;
1197            cpustate->sfr |= carry ? SUPERFX_SFR_CY : 0;
1198            superfx_dreg_sfr_sz_update(cpustate);
1199            superfx_regs_reset(cpustate);
1200            break;
1201         }
1202
1203         case 0x98: case 0x99: case 0x9a: case 0x9b: case 0x9c: case 0x9d: // JMP / LJMP
1204            if((cpustate->sfr & SUPERFX_SFR_ALT1) == 0)
1205            { // JMP
1206               superfx_gpr_write(cpustate, 15, cpustate->r[op & 0xf]);
1207               superfx_regs_reset(cpustate);
1208            }
1209            else
1210            { // LJMP
1211               cpustate->pbr = cpustate->r[op & 0xf];
1212               superfx_gpr_write(cpustate, 15, *(cpustate->sreg));
1213               cpustate->cbr = cpustate->r[15] & 0xfff0;
1214               superfx_cache_flush(cpustate);
1215               superfx_regs_reset(cpustate);
1216            }
1217            break;
1218
1219         case 0x9e: // LOB
1220            superfx_gpr_write(cpustate, cpustate->dreg_idx, *(cpustate->sreg) & 0xff);
1221            cpustate->sfr &= ~(SUPERFX_SFR_S | SUPERFX_SFR_Z);
1222            cpustate->sfr |= (*(cpustate->dreg) & 0x80) ? SUPERFX_SFR_S : 0;
1223            cpustate->sfr |= (*(cpustate->dreg) == 0) ? SUPERFX_SFR_Z : 0;
1224            superfx_regs_reset(cpustate);
1225            break;
1226
1227         case 0x9f: // FMULT / LMULT
1228         {
1229            UINT32 result = (INT16)(*(cpustate->sreg)) * (INT16)cpustate->r[6];
1230            if(cpustate->sfr & SUPERFX_SFR_ALT1)
1231            { // LMULT
1232               superfx_gpr_write(cpustate, 4, result);
1233            }
1234            superfx_gpr_write(cpustate, cpustate->dreg_idx, result >> 16);
1235            cpustate->sfr &= ~SUPERFX_SFR_CY;
1236            cpustate->sfr |= (result & 0x8000) ? SUPERFX_SFR_CY : 0;
1237            superfx_dreg_sfr_sz_update(cpustate);
1238            superfx_regs_reset(cpustate);
1239            superfx_add_clocks_internal(cpustate, 4 + ((cpustate->cfgr & SUPERFX_CFGR_MS0) ? 4 : 0));
1240            break;
1241         }
1242
1243         case 0xa0: case 0xa1: case 0xa2: case 0xa3: case 0xa4: case 0xa5: case 0xa6: case 0xa7:
1244         case 0xa8: case 0xa9: case 0xaa: case 0xab: case 0xac: case 0xad: case 0xae: case 0xaf: // IBT / LMS / SMS / LMS
1245            switch(cpustate->sfr & SUPERFX_SFR_ALT)
1246            {
1247               case SUPERFX_SFR_ALT0: // IBT
1248                  superfx_gpr_write(cpustate, op & 0xf, (INT8)superfx_pipe(cpustate));
1249                  superfx_regs_reset(cpustate);
1250                  break;
1251               case SUPERFX_SFR_ALT2: // SMS
1252                  cpustate->ramaddr = superfx_pipe(cpustate) << 1;
1253                  superfx_rambuffer_write(cpustate, cpustate->ramaddr ^ 0, cpustate->r[op & 0xf] >> 0);
1254                  superfx_rambuffer_write(cpustate, cpustate->ramaddr ^ 1, cpustate->r[op & 0xf] >> 8);
1255                  superfx_regs_reset(cpustate);
1256                  break;
1257               case SUPERFX_SFR_ALT1: // LMS
1258               case SUPERFX_SFR_ALT3: // LMS
1259               {
1260                  UINT16 data = 0;
1261                  cpustate->ramaddr = superfx_pipe(cpustate) << 1;
1262                  data  = superfx_rambuffer_read(cpustate, cpustate->ramaddr ^ 0) << 0;
1263                  data |= superfx_rambuffer_read(cpustate, cpustate->ramaddr ^ 1) << 8;
1264                  superfx_gpr_write(cpustate, op & 0xf, data);
1265                  superfx_regs_reset(cpustate);
1266                  break;
1267               }
1268            }
1269            break;
1270
1271         case 0xb0: case 0xb1: case 0xb2: case 0xb3: case 0xb4: case 0xb5: case 0xb6: case 0xb7:
1272         case 0xb8: case 0xb9: case 0xba: case 0xbb: case 0xbc: case 0xbd: case 0xbe: case 0xbf: // FROM
1273            if(!(cpustate->sfr & SUPERFX_SFR_B))
1274            {
1275               cpustate->sreg = &(cpustate->r[op & 0xf]);
1276               cpustate->sreg_idx = op & 0xf;
1277            }
1278            else
1279            {
1280               superfx_gpr_write(cpustate, cpustate->dreg_idx, cpustate->r[op & 0xf]);
1281               cpustate->sfr &= ~SUPERFX_SFR_OV;
1282               cpustate->sfr |= (*(cpustate->dreg) & 0x80) ? SUPERFX_SFR_OV : 0;
1283               superfx_dreg_sfr_sz_update(cpustate);
1284               superfx_regs_reset(cpustate);
1285            }
1286            break;
1287
1288         case 0xc0: // HIB
1289            superfx_gpr_write(cpustate, cpustate->dreg_idx, *(cpustate->sreg) >> 8);
1290            superfx_dreg_sfr_sz_update(cpustate);
1291            superfx_regs_reset(cpustate);
1292            break;
1293
1294                    case 0xc1: case 0xc2: case 0xc3: case 0xc4: case 0xc5: case 0xc6: case 0xc7:
1295         case 0xc8: case 0xc9: case 0xca: case 0xcb: case 0xcc: case 0xcd: case 0xce: case 0xcf: // OR / XOR / ORI / XORI
1296            switch(cpustate->sfr & SUPERFX_SFR_ALT)
1297            {
1298               case SUPERFX_SFR_ALT0: // OR
1299                  superfx_gpr_write(cpustate, cpustate->dreg_idx, *(cpustate->sreg) | cpustate->r[op & 0xf]);
1300                  break;
1301               case SUPERFX_SFR_ALT1: // XOR
1302                  superfx_gpr_write(cpustate, cpustate->dreg_idx, *(cpustate->sreg) ^ cpustate->r[op & 0xf]);
1303                  break;
1304               case SUPERFX_SFR_ALT2: // ORI
1305                  superfx_gpr_write(cpustate, cpustate->dreg_idx, *(cpustate->sreg) | (op & 0xf));
1306                  break;
1307               case SUPERFX_SFR_ALT3: // XORI
1308                  superfx_gpr_write(cpustate, cpustate->dreg_idx, *(cpustate->sreg) ^ (op & 0xf));
1309                  break;
1310            }
1311            superfx_dreg_sfr_sz_update(cpustate);
1312            superfx_regs_reset(cpustate);
1313            break;
1314
1315         case 0xd0: case 0xd1: case 0xd2: case 0xd3: case 0xd4: case 0xd5: case 0xd6: case 0xd7:
1316         case 0xd8: case 0xd9: case 0xda: case 0xdb: case 0xdc: case 0xdd: case 0xde:            // INC
1317            superfx_gpr_write(cpustate, op & 0xf, cpustate->r[op & 0xf] + 1);
1318            cpustate->sfr &= ~(SUPERFX_SFR_S | SUPERFX_SFR_Z);
1319            cpustate->sfr |= (cpustate->r[op & 0xf] & 0x8000) ? SUPERFX_SFR_S : 0;
1320            cpustate->sfr |= (cpustate->r[op & 0xf] == 0) ? SUPERFX_SFR_Z : 0;
1321            superfx_regs_reset(cpustate);
1322            break;
1323
1324         case 0xdf: // GETC / RAMB / ROMB
1325            switch(cpustate->sfr & SUPERFX_SFR_ALT)
1326            {
1327               case SUPERFX_SFR_ALT0: // GETC
1328               case SUPERFX_SFR_ALT1: // GETC
1329                  cpustate->colr = superfx_color(cpustate, superfx_rombuffer_read(cpustate));
1330                  superfx_regs_reset(cpustate);
1331                  break;
1332               case SUPERFX_SFR_ALT2: // RAMB
1333                  superfx_rambuffer_sync(cpustate);
1334                  cpustate->rambr = *(cpustate->sreg);
1335                  superfx_regs_reset(cpustate);
1336                  break;
1337               case SUPERFX_SFR_ALT3: // ROMB
1338                  superfx_rombuffer_sync(cpustate);
1339                  cpustate->rombr = *(cpustate->sreg);
1340                  superfx_regs_reset(cpustate);
1341                  break;
1342            }
1343            break;
1344
1345         case 0xe0: case 0xe1: case 0xe2: case 0xe3: case 0xe4: case 0xe5: case 0xe6: case 0xe7:
1346         case 0xe8: case 0xe9: case 0xea: case 0xeb: case 0xec: case 0xed: case 0xee:            // DEC
1347            superfx_gpr_write(cpustate, op & 0xf, cpustate->r[op & 0xf] - 1);
1348            cpustate->sfr &= ~(SUPERFX_SFR_S | SUPERFX_SFR_Z);
1349            cpustate->sfr |= (cpustate->r[op & 0xf] & 0x8000) ? SUPERFX_SFR_S : 0;
1350            cpustate->sfr |= (cpustate->r[op & 0xf] == 0) ? SUPERFX_SFR_Z : 0;
1351            superfx_regs_reset(cpustate);
1352            break;
1353
1354         case 0xef: // GETB / GETBH / GETBL / GETBS
1355         {
1356            UINT8 byte = superfx_bus_read(cpustate, (cpustate->rombr << 16) + cpustate->r[14]);
1357            switch(cpustate->sfr & SUPERFX_SFR_ALT)
1358            {
1359               case SUPERFX_SFR_ALT0: // GETB
1360                  superfx_gpr_write(cpustate, cpustate->dreg_idx, byte);
1361                  break;
1362               case SUPERFX_SFR_ALT1: // GETBH
1363                  superfx_gpr_write(cpustate, cpustate->dreg_idx, (byte << 8) | (*(cpustate->sreg) & 0x00ff));
1364                  break;
1365               case SUPERFX_SFR_ALT2: // GETBL
1366                  superfx_gpr_write(cpustate, cpustate->dreg_idx, (*(cpustate->sreg) & 0xff00) | (byte << 0));
1367                  break;
1368               case SUPERFX_SFR_ALT3: // GETBS
1369                  superfx_gpr_write(cpustate, cpustate->dreg_idx, (INT16)((INT8)byte));
1370                  break;
1371            }
1372            superfx_regs_reset(cpustate);
1373            break;
1374         }
1375
1376         case 0xf0: case 0xf1: case 0xf2: case 0xf3: case 0xf4: case 0xf5: case 0xf6: case 0xf7:
1377         case 0xf8: case 0xf9: case 0xfa: case 0xfb: case 0xfc: case 0xfd: case 0xfe: case 0xff: // IWT / LM / SM / LM
1378         {
1379            UINT16 data;
1380            switch(cpustate->sfr & SUPERFX_SFR_ALT)
1381            {
1382               case SUPERFX_SFR_ALT0: // IWT
1383                  data  = superfx_pipe(cpustate) << 0;
1384                  data |= superfx_pipe(cpustate) << 8;
1385                  superfx_gpr_write(cpustate, op & 0xf, data);
1386                  superfx_regs_reset(cpustate);
1387                  break;
1388               case SUPERFX_SFR_ALT2: // SM
1389                  cpustate->ramaddr  = superfx_pipe(cpustate) << 0;
1390                  cpustate->ramaddr |= superfx_pipe(cpustate) << 8;
1391                  superfx_rambuffer_write(cpustate, cpustate->ramaddr ^ 0, cpustate->r[op & 0xf] >> 0);
1392                  superfx_rambuffer_write(cpustate, cpustate->ramaddr ^ 1, cpustate->r[op & 0xf] >> 8);
1393                  superfx_regs_reset(cpustate);
1394                  break;
1395               case SUPERFX_SFR_ALT1:
1396               case SUPERFX_SFR_ALT3: // LM
1397                  cpustate->ramaddr  = superfx_pipe(cpustate) << 0;
1398                  cpustate->ramaddr |= superfx_pipe(cpustate) << 8;
1399                  data  = superfx_rambuffer_read(cpustate, cpustate->ramaddr ^ 0) << 0;
1400                  data |= superfx_rambuffer_read(cpustate, cpustate->ramaddr ^ 1) << 8;
1401                  superfx_gpr_write(cpustate, op & 0xf, data);
1402                  superfx_regs_reset(cpustate);
1403                  break;
1404            }
1405            break;
1406         }
1407      }
1408
1409      if(!cpustate->r15_modified)
1410      {
1411         cpustate->r[15]++;
1412      }
1413
1414        --cpustate->icount;
1415    }
1416
1417    return cycles - cpustate->icount;
1418}
1419
1420/*****************************************************************************/
1421
1422CPU_DISASSEMBLE( superfx )
1423{
1424   superfx_state *cpustate = get_safe_token(device);
1425
1426    UINT8      op = *(UINT8 *)(opram + 0);
1427    UINT8  param0 = *(UINT8 *)(opram + 1);
1428    UINT8  param1 = *(UINT8 *)(opram + 2);
1429   UINT16    alt = cpustate->sfr & SUPERFX_SFR_ALT;
1430
1431    return superfx_dasm_one(buffer, pc, op, param0, param1, alt);
1432}
1433
1434/*****************************************************************************/
1435
1436static CPU_SET_INFO( superfx )
1437{
1438    superfx_state *cpustate = get_safe_token(device);
1439
1440    switch (state)
1441    {
1442        /* --- the following bits of info are set as 64-bit signed integers --- */
1443        case CPUINFO_INT_PC:
1444        case CPUINFO_INT_REGISTER + SUPERFX_PC:           cpustate->r[15] = info->i;      break;
1445       case CPUINFO_INT_REGISTER + SUPERFX_DREG:      info->i = cpustate->dreg_idx;   break;
1446       case CPUINFO_INT_REGISTER + SUPERFX_SREG:      info->i = cpustate->sreg_idx;   break;
1447        case CPUINFO_INT_REGISTER + SUPERFX_R0:         cpustate->r[0] = info->i;      break;
1448        case CPUINFO_INT_REGISTER + SUPERFX_R1:         cpustate->r[1] = info->i;      break;
1449        case CPUINFO_INT_REGISTER + SUPERFX_R2:         cpustate->r[2] = info->i;      break;
1450        case CPUINFO_INT_REGISTER + SUPERFX_R3:         cpustate->r[3] = info->i;      break;
1451        case CPUINFO_INT_REGISTER + SUPERFX_R4:         cpustate->r[4] = info->i;      break;
1452        case CPUINFO_INT_REGISTER + SUPERFX_R5:         cpustate->r[5] = info->i;      break;
1453        case CPUINFO_INT_REGISTER + SUPERFX_R6:         cpustate->r[6] = info->i;      break;
1454        case CPUINFO_INT_REGISTER + SUPERFX_R7:         cpustate->r[7] = info->i;      break;
1455        case CPUINFO_INT_REGISTER + SUPERFX_R8:         cpustate->r[8] = info->i;      break;
1456        case CPUINFO_INT_REGISTER + SUPERFX_R9:         cpustate->r[9] = info->i;      break;
1457        case CPUINFO_INT_REGISTER + SUPERFX_R10:        cpustate->r[10] = info->i;      break;
1458        case CPUINFO_INT_REGISTER + SUPERFX_R11:        cpustate->r[11] = info->i;      break;
1459        case CPUINFO_INT_REGISTER + SUPERFX_R12:        cpustate->r[12] = info->i;      break;
1460        case CPUINFO_INT_REGISTER + SUPERFX_R13:        cpustate->r[13] = info->i;      break;
1461        case CPUINFO_INT_REGISTER + SUPERFX_R14:        cpustate->r[14] = info->i;      break;
1462        case CPUINFO_INT_REGISTER + SUPERFX_R15:        cpustate->r[15] = info->i;      break;
1463        case CPUINFO_INT_REGISTER + SUPERFX_SFR:         cpustate->sfr = info->i;          break;
1464        case CPUINFO_INT_REGISTER + SUPERFX_PBR:          cpustate->pbr = info->i;      break;
1465       case CPUINFO_INT_REGISTER + SUPERFX_ROMBR:      cpustate->rombr = info->i;      break;
1466       case CPUINFO_INT_REGISTER + SUPERFX_RAMBR:      cpustate->rambr = info->i;      break;
1467       case CPUINFO_INT_REGISTER + SUPERFX_CBR:      cpustate->cbr = info->i;      break;
1468       case CPUINFO_INT_REGISTER + SUPERFX_SCBR:      cpustate->scbr = info->i;      break;
1469       case CPUINFO_INT_REGISTER + SUPERFX_SCMR:      cpustate->scmr = info->i;      break;
1470       case CPUINFO_INT_REGISTER + SUPERFX_COLR:      cpustate->colr = info->i;      break;
1471       case CPUINFO_INT_REGISTER + SUPERFX_POR:      cpustate->por = info->i;      break;
1472       case CPUINFO_INT_REGISTER + SUPERFX_BRAMR:      cpustate->bramr = info->i;      break;
1473       case CPUINFO_INT_REGISTER + SUPERFX_VCR:      cpustate->vcr = info->i;      break;
1474       case CPUINFO_INT_REGISTER + SUPERFX_CFGR:      cpustate->cfgr = info->i;      break;
1475       case CPUINFO_INT_REGISTER + SUPERFX_CLSR:      cpustate->clsr = info->i;      break;
1476       case CPUINFO_INT_REGISTER + SUPERFX_ROMCL:      cpustate->romcl = info->i;      break;
1477       case CPUINFO_INT_REGISTER + SUPERFX_ROMDR:      cpustate->romdr = info->i;      break;
1478       case CPUINFO_INT_REGISTER + SUPERFX_RAMCL:      cpustate->ramcl = info->i;      break;
1479       case CPUINFO_INT_REGISTER + SUPERFX_RAMAR:      cpustate->ramar = info->i;      break;
1480       case CPUINFO_INT_REGISTER + SUPERFX_RAMDR:      cpustate->ramdr = info->i;      break;
1481       case CPUINFO_INT_REGISTER + SUPERFX_RAMADDR:   cpustate->ramaddr = info->i;   break;
1482    }
1483}
1484
1485CPU_GET_INFO( superfx )
1486{
1487    superfx_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL;
1488
1489    switch(state)
1490    {
1491        /* --- the following bits of info are returned as 64-bit signed integers --- */
1492        case CPUINFO_INT_CONTEXT_SIZE:             info->i = sizeof(superfx_state);               break;
1493        case CPUINFO_INT_INPUT_LINES:              info->i = 0;                                   break;
1494        case CPUINFO_INT_DEFAULT_IRQ_VECTOR:       info->i = 0;                                   break;
1495        case DEVINFO_INT_ENDIANNESS:               info->i = ENDIANNESS_LITTLE;                   break;
1496        case CPUINFO_INT_CLOCK_MULTIPLIER:         info->i = 1;                                   break;
1497        case CPUINFO_INT_CLOCK_DIVIDER:            info->i = 1;                                   break;
1498        case CPUINFO_INT_MIN_INSTRUCTION_BYTES:    info->i = 1;                                   break;
1499        case CPUINFO_INT_MAX_INSTRUCTION_BYTES:    info->i = 3;                                   break;
1500        case CPUINFO_INT_MIN_CYCLES:               info->i = 1;                                   break;
1501        case CPUINFO_INT_MAX_CYCLES:               info->i = 1;                                   break;
1502
1503        case CPUINFO_INT_DATABUS_WIDTH_PROGRAM:    info->i = 8;                                  break;
1504        case CPUINFO_INT_ADDRBUS_WIDTH_PROGRAM:    info->i = 32;                                 break;
1505        case CPUINFO_INT_ADDRBUS_SHIFT_PROGRAM:    info->i = 0;                                  break;
1506        case CPUINFO_INT_DATABUS_WIDTH_DATA:       info->i = 0;                                  break;
1507        case CPUINFO_INT_ADDRBUS_WIDTH_DATA:       info->i = 0;                                  break;
1508        case CPUINFO_INT_ADDRBUS_SHIFT_DATA:       info->i = 0;                                  break;
1509        case CPUINFO_INT_DATABUS_WIDTH_IO:         info->i = 0;                                  break;
1510        case CPUINFO_INT_ADDRBUS_WIDTH_IO:         info->i = 0;                                  break;
1511        case CPUINFO_INT_ADDRBUS_SHIFT_IO:         info->i = 0;                                  break;
1512
1513        case CPUINFO_INT_PC:    /* intentional fallthrough */
1514        case CPUINFO_INT_REGISTER + SUPERFX_PC:       info->i = ((cpustate->pbr << 16) | cpustate->r[15]) - 1; break;
1515       case CPUINFO_INT_REGISTER + SUPERFX_DREG:      info->i = cpustate->dreg_idx;   break;
1516       case CPUINFO_INT_REGISTER + SUPERFX_SREG:      info->i = cpustate->sreg_idx;   break;
1517        case CPUINFO_INT_REGISTER + SUPERFX_R0:         info->i = cpustate->r[0];      break;
1518        case CPUINFO_INT_REGISTER + SUPERFX_R1:         info->i = cpustate->r[1];      break;
1519        case CPUINFO_INT_REGISTER + SUPERFX_R2:         info->i = cpustate->r[2];      break;
1520        case CPUINFO_INT_REGISTER + SUPERFX_R3:         info->i = cpustate->r[3];      break;
1521        case CPUINFO_INT_REGISTER + SUPERFX_R4:         info->i = cpustate->r[4];      break;
1522        case CPUINFO_INT_REGISTER + SUPERFX_R5:         info->i = cpustate->r[5];      break;
1523        case CPUINFO_INT_REGISTER + SUPERFX_R6:         info->i = cpustate->r[6];      break;
1524        case CPUINFO_INT_REGISTER + SUPERFX_R7:         info->i = cpustate->r[7];      break;
1525        case CPUINFO_INT_REGISTER + SUPERFX_R8:         info->i = cpustate->r[8];      break;
1526        case CPUINFO_INT_REGISTER + SUPERFX_R9:         info->i = cpustate->r[9];      break;
1527        case CPUINFO_INT_REGISTER + SUPERFX_R10:        info->i = cpustate->r[10];      break;
1528        case CPUINFO_INT_REGISTER + SUPERFX_R11:        info->i = cpustate->r[11];      break;
1529        case CPUINFO_INT_REGISTER + SUPERFX_R12:        info->i = cpustate->r[12];      break;
1530        case CPUINFO_INT_REGISTER + SUPERFX_R13:        info->i = cpustate->r[13];      break;
1531        case CPUINFO_INT_REGISTER + SUPERFX_R14:        info->i = cpustate->r[14];      break;
1532        case CPUINFO_INT_REGISTER + SUPERFX_R15:        info->i = cpustate->r[15];      break;
1533        case CPUINFO_INT_REGISTER + SUPERFX_SFR:      info->i = cpustate->sfr;         break;
1534        case CPUINFO_INT_REGISTER + SUPERFX_PBR:          info->i = cpustate->sfr;      break;
1535       case CPUINFO_INT_REGISTER + SUPERFX_ROMBR:      info->i = cpustate->rombr;      break;
1536       case CPUINFO_INT_REGISTER + SUPERFX_RAMBR:      info->i = cpustate->rambr;      break;
1537       case CPUINFO_INT_REGISTER + SUPERFX_CBR:      info->i = cpustate->cbr;      break;
1538       case CPUINFO_INT_REGISTER + SUPERFX_SCBR:      info->i = cpustate->scbr;      break;
1539       case CPUINFO_INT_REGISTER + SUPERFX_SCMR:      info->i = cpustate->scmr;      break;
1540       case CPUINFO_INT_REGISTER + SUPERFX_COLR:      info->i = cpustate->colr;      break;
1541       case CPUINFO_INT_REGISTER + SUPERFX_POR:      info->i = cpustate->por;      break;
1542       case CPUINFO_INT_REGISTER + SUPERFX_BRAMR:      info->i = cpustate->bramr;      break;
1543       case CPUINFO_INT_REGISTER + SUPERFX_VCR:      info->i = cpustate->vcr;      break;
1544       case CPUINFO_INT_REGISTER + SUPERFX_CFGR:      info->i = cpustate->cfgr;      break;
1545       case CPUINFO_INT_REGISTER + SUPERFX_CLSR:      info->i = cpustate->clsr;      break;
1546       case CPUINFO_INT_REGISTER + SUPERFX_ROMCL:      info->i = cpustate->romcl;      break;
1547       case CPUINFO_INT_REGISTER + SUPERFX_ROMDR:      info->i = cpustate->romdr;      break;
1548       case CPUINFO_INT_REGISTER + SUPERFX_RAMCL:      info->i = cpustate->ramcl;      break;
1549       case CPUINFO_INT_REGISTER + SUPERFX_RAMAR:      info->i = cpustate->ramar;      break;
1550       case CPUINFO_INT_REGISTER + SUPERFX_RAMDR:      info->i = cpustate->ramdr;      break;
1551       case CPUINFO_INT_REGISTER + SUPERFX_RAMADDR:   info->i = cpustate->ramaddr;   break;
1552
1553        /* --- the following bits of info are returned as pointers to data or functions --- */
1554        case CPUINFO_FCT_SET_INFO:              info->setinfo = CPU_SET_INFO_NAME(superfx);              break;
1555        case CPUINFO_FCT_INIT:                  info->init = CPU_INIT_NAME(superfx);                     break;
1556        case CPUINFO_FCT_RESET:                 info->reset = CPU_RESET_NAME(superfx);                   break;
1557        case CPUINFO_FCT_EXIT:                  info->exit = CPU_EXIT_NAME(superfx);                     break;
1558        case CPUINFO_FCT_EXECUTE:               info->execute = CPU_EXECUTE_NAME(superfx);               break;
1559        case CPUINFO_FCT_BURN:                  info->burn = NULL;                                    break;
1560        case CPUINFO_FCT_DISASSEMBLE:           info->disassemble = CPU_DISASSEMBLE_NAME(superfx);      break;
1561        case CPUINFO_PTR_INSTRUCTION_COUNTER:   info->icount = &cpustate->icount;                     break;
1562
1563        /* --- the following bits of info are returned as NULL-terminated strings --- */
1564        case DEVINFO_STR_NAME:                          strcpy(info->s, "SuperFX");                  break;
1565        case DEVINFO_STR_FAMILY:                         strcpy(info->s, "SuperFX");                  break;
1566        case DEVINFO_STR_VERSION:                        strcpy(info->s, "1.0");                     break;
1567        case DEVINFO_STR_SOURCE_FILE:                   strcpy(info->s, __FILE__);                  break;
1568        case DEVINFO_STR_CREDITS:                        strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team");   break;
1569
1570        case CPUINFO_STR_FLAGS:                         strcpy(info->s, " ");                     break;
1571
1572        case CPUINFO_STR_REGISTER + SUPERFX_PC:         sprintf(info->s, "PC:      %06X", (cpustate->pbr << 16) | cpustate->r[15]); break;
1573       case CPUINFO_STR_REGISTER + SUPERFX_DREG:      sprintf(info->s, "DREG:    R%d",  cpustate->dreg_idx);   break;
1574       case CPUINFO_STR_REGISTER + SUPERFX_SREG:      sprintf(info->s, "SREG:    R%d",  cpustate->sreg_idx);   break;
1575        case CPUINFO_STR_REGISTER + SUPERFX_R0:         sprintf(info->s, "R0:      %04X", cpustate->r[0]);      break;
1576        case CPUINFO_STR_REGISTER + SUPERFX_R1:         sprintf(info->s, "R1:      %04X", cpustate->r[1]);      break;
1577        case CPUINFO_STR_REGISTER + SUPERFX_R2:         sprintf(info->s, "R2:      %04X", cpustate->r[2]);      break;
1578        case CPUINFO_STR_REGISTER + SUPERFX_R3:         sprintf(info->s, "R3:      %04X", cpustate->r[3]);      break;
1579        case CPUINFO_STR_REGISTER + SUPERFX_R4:         sprintf(info->s, "R4:      %04X", cpustate->r[4]);      break;
1580        case CPUINFO_STR_REGISTER + SUPERFX_R5:         sprintf(info->s, "R5:      %04X", cpustate->r[5]);      break;
1581        case CPUINFO_STR_REGISTER + SUPERFX_R6:         sprintf(info->s, "R6:      %04X", cpustate->r[6]);      break;
1582        case CPUINFO_STR_REGISTER + SUPERFX_R7:         sprintf(info->s, "R7:      %04X", cpustate->r[7]);      break;
1583        case CPUINFO_STR_REGISTER + SUPERFX_R8:         sprintf(info->s, "R8:      %04X", cpustate->r[8]);      break;
1584        case CPUINFO_STR_REGISTER + SUPERFX_R9:         sprintf(info->s, "R9:      %04X", cpustate->r[9]);      break;
1585        case CPUINFO_STR_REGISTER + SUPERFX_R10:        sprintf(info->s, "R10:     %04X", cpustate->r[10]);      break;
1586        case CPUINFO_STR_REGISTER + SUPERFX_R11:        sprintf(info->s, "R11:     %04X", cpustate->r[11]);      break;
1587        case CPUINFO_STR_REGISTER + SUPERFX_R12:        sprintf(info->s, "R12:     %04X", cpustate->r[12]);      break;
1588        case CPUINFO_STR_REGISTER + SUPERFX_R13:        sprintf(info->s, "R13:     %04X", cpustate->r[13]);      break;
1589        case CPUINFO_STR_REGISTER + SUPERFX_R14:        sprintf(info->s, "R14:     %04X", cpustate->r[14]);      break;
1590        case CPUINFO_STR_REGISTER + SUPERFX_R15:        sprintf(info->s, "R15:     %04X", cpustate->r[15]);      break;
1591        case CPUINFO_STR_REGISTER + SUPERFX_SFR:          sprintf(info->s, "SFR:     %04X", cpustate->sfr);      break;
1592        case CPUINFO_STR_REGISTER + SUPERFX_PBR:          sprintf(info->s, "PBR:     %02X", cpustate->sfr);      break;
1593       case CPUINFO_STR_REGISTER + SUPERFX_ROMBR:      sprintf(info->s, "ROMBR:   %02X", cpustate->rombr);      break;
1594       case CPUINFO_STR_REGISTER + SUPERFX_RAMBR:      sprintf(info->s, "RAMBR:   %02X", cpustate->rambr);      break;
1595       case CPUINFO_STR_REGISTER + SUPERFX_CBR:      sprintf(info->s, "CBR:     %04X", cpustate->cbr);      break;
1596       case CPUINFO_STR_REGISTER + SUPERFX_SCBR:      sprintf(info->s, "SCBR:    %02X", cpustate->scbr);      break;
1597       case CPUINFO_STR_REGISTER + SUPERFX_SCMR:      sprintf(info->s, "SCMR:    %02X", cpustate->scmr);      break;
1598       case CPUINFO_STR_REGISTER + SUPERFX_COLR:      sprintf(info->s, "COLR     %02X", cpustate->colr);      break;
1599       case CPUINFO_STR_REGISTER + SUPERFX_POR:      sprintf(info->s, "POR:     %02X", cpustate->por);      break;
1600       case CPUINFO_STR_REGISTER + SUPERFX_BRAMR:      sprintf(info->s, "BRAMR:   %02X", cpustate->bramr);      break;
1601       case CPUINFO_STR_REGISTER + SUPERFX_VCR:      sprintf(info->s, "VCR:     %02X", cpustate->vcr);      break;
1602       case CPUINFO_STR_REGISTER + SUPERFX_CFGR:      sprintf(info->s, "CFGR:    %02X", cpustate->cfgr);      break;
1603       case CPUINFO_STR_REGISTER + SUPERFX_CLSR:      sprintf(info->s, "CLSR:    %02X", cpustate->clsr);      break;
1604       case CPUINFO_STR_REGISTER + SUPERFX_ROMCL:      sprintf(info->s, "ROMCL:   %08X", cpustate->romcl);      break;
1605       case CPUINFO_STR_REGISTER + SUPERFX_ROMDR:      sprintf(info->s, "ROMDR:   %02X", cpustate->romdr);      break;
1606       case CPUINFO_STR_REGISTER + SUPERFX_RAMCL:      sprintf(info->s, "RAMCL:   %08X", cpustate->ramcl);      break;
1607       case CPUINFO_STR_REGISTER + SUPERFX_RAMAR:      sprintf(info->s, "RAMAR:   %04X", cpustate->ramar);      break;
1608       case CPUINFO_STR_REGISTER + SUPERFX_RAMDR:      sprintf(info->s, "RAMDR:   %02X", cpustate->ramdr);      break;
1609       case CPUINFO_STR_REGISTER + SUPERFX_RAMADDR:   sprintf(info->s, "RAMADDR: %04X", cpustate->ramaddr);   break;
1610    }
1611}
src/emu/cpu/cpu.mak
r5534r5535
4848
4949DRCOBJ += \
5050   $(CPUOBJ)/drcbex64.o \
51   $(CPUOBJ)/x86log.o
51   $(CPUOBJ)/x86log.o $(CPUOBJ)/i386/i386dasm.o
5252
5353DRCDEPS += \
5454   $(CPUSRC)/x86emit.h
r5534r5535
5959
6060DRCOBJ += \
6161   $(CPUOBJ)/drcbex86.o \
62   $(CPUOBJ)/x86log.o
62   $(CPUOBJ)/x86log.o $(CPUOBJ)/i386/i386dasm.o
6363
6464DRCDEPS += \
6565   $(CPUSRC)/x86emit.h
r5534r5535
8181ifneq ($(filter ARM,$(CPUS)),)
8282OBJDIRS += $(CPUOBJ)/arm
8383CPUOBJS += $(CPUOBJ)/arm/arm.o
84DBGOBJS += $(CPUOBJ)/arm/armdasm.o
84DASMOBJS += $(CPUOBJ)/arm/armdasm.o
8585endif
8686
8787ifneq ($(filter ARM7,$(CPUS)),)
8888OBJDIRS += $(CPUOBJ)/arm7
8989CPUOBJS += $(CPUOBJ)/arm7/arm7.o
90DBGOBJS += $(CPUOBJ)/arm7/arm7dasm.o
90DASMOBJS += $(CPUOBJ)/arm7/arm7dasm.o
9191endif
9292
9393$(CPUOBJ)/arm/arm.o:    $(CPUSRC)/arm/arm.c \
r5534r5535
107107ifneq ($(filter SE3208,$(CPUS)),)
108108OBJDIRS += $(CPUOBJ)/se3208
109109CPUOBJS += $(CPUOBJ)/se3208/se3208.o
110DBGOBJS += $(CPUOBJ)/se3208/se3208dis.o
110DASMOBJS += $(CPUOBJ)/se3208/se3208dis.o
111111endif
112112
113113$(CPUOBJ)/se3208/se3208.o:    $(CPUSRC)/se3208/se3208.c \
r5534r5535
122122ifneq ($(filter ALPHA8201,$(CPUS)),)
123123OBJDIRS += $(CPUOBJ)/alph8201
124124CPUOBJS += $(CPUOBJ)/alph8201/alph8201.o
125DBGOBJS += $(CPUOBJ)/alph8201/8201dasm.o
125DASMOBJS += $(CPUOBJ)/alph8201/8201dasm.o
126126endif
127127
128128$(CPUOBJ)/alph8201/alph8201.o:   $(CPUSRC)/alph8201/alph8201.c \
r5534r5535
137137ifneq ($(filter ADSP21XX,$(CPUS)),)
138138OBJDIRS += $(CPUOBJ)/adsp2100
139139CPUOBJS += $(CPUOBJ)/adsp2100/adsp2100.o
140DBGOBJS += $(CPUOBJ)/adsp2100/2100dasm.o
140DASMOBJS += $(CPUOBJ)/adsp2100/2100dasm.o
141141endif
142142
143143$(CPUOBJ)/adsp2100/adsp2100.o:   $(CPUSRC)/adsp2100/adsp2100.c \
r5534r5535
153153ifneq ($(filter ADSP21062,$(CPUS)),)
154154OBJDIRS += $(CPUOBJ)/sharc
155155CPUOBJS += $(CPUOBJ)/sharc/sharc.o
156DBGOBJS += $(CPUOBJ)/sharc/sharcdsm.o
156DASMOBJS += $(CPUOBJ)/sharc/sharcdsm.o
157157endif
158158
159159$(CPUOBJ)/sharc/sharc.o:   $(CPUSRC)/sharc/sharc.c \
r5534r5535
175175ifneq ($(filter APEXC,$(CPUS)),)
176176OBJDIRS += $(CPUOBJ)/apexc
177177CPUOBJS += $(CPUOBJ)/apexc/apexc.o
178DBGOBJS += $(CPUOBJ)/apexc/apexcdsm.o
178DASMOBJS += $(CPUOBJ)/apexc/apexcdsm.o
179179endif
180180
181181$(CPUOBJ)/apexc/apexc.o:   $(CPUSRC)/apexc/apexc.c \
r5534r5535
190190ifneq ($(filter DSP32C,$(CPUS)),)
191191OBJDIRS += $(CPUOBJ)/dsp32
192192CPUOBJS += $(CPUOBJ)/dsp32/dsp32.o
193DBGOBJS += $(CPUOBJ)/dsp32/dsp32dis.o
193DASMOBJS += $(CPUOBJ)/dsp32/dsp32dis.o
194194endif
195195
196196$(CPUOBJ)/dsp32/dsp32.o:    $(CPUSRC)/dsp32/dsp32.c \
r5534r5535
205205ifneq ($(filter ASAP,$(CPUS)),)
206206OBJDIRS += $(CPUOBJ)/asap
207207CPUOBJS += $(CPUOBJ)/asap/asap.o
208DBGOBJS += $(CPUOBJ)/asap/asapdasm.o
208DASMOBJS += $(CPUOBJ)/asap/asapdasm.o
209209endif
210210
211211$(CPUOBJ)/asap/asap.o:   $(CPUSRC)/asap/asap.c \
r5534r5535
220220ifneq ($(filter JAGUAR,$(CPUS)),)
221221OBJDIRS += $(CPUOBJ)/jaguar
222222CPUOBJS += $(CPUOBJ)/jaguar/jaguar.o
223DBGOBJS += $(CPUOBJ)/jaguar/jagdasm.o
223DASMOBJS += $(CPUOBJ)/jaguar/jagdasm.o
224224endif
225225
226226$(CPUOBJ)/jaguar/jaguar.o:   $(CPUSRC)/jaguar/jaguar.c \
r5534r5535
229229
230230
231231#-------------------------------------------------
232# Atmel 8-bit AVR
233#-------------------------------------------------
234
235ifneq ($(filter AVR8,$(CPUS)),)
236OBJDIRS += $(CPUOBJ)/avr8
237CPUOBJS += $(CPUOBJ)/avr8/avr8.o
238DBGOBJS += $(CPUOBJ)/avr8/avr8dasm.o
239endif
240
241$(CPUOBJ)/avr8/avr8.o:    $(CPUSRC)/avr8/avr8.c \
242         $(CPUSRC)/avr8/avr8.h
243
244
245
246#-------------------------------------------------
247232# Simutrek Cube Quest bit-sliced CPUs
248233#-------------------------------------------------
249234
250235ifneq ($(filter CUBEQCPU,$(CPUS)),)
251236OBJDIRS += $(CPUOBJ)/cubeqcpu
252237CPUOBJS += $(CPUOBJ)/cubeqcpu/cubeqcpu.o
253#DBGOBJS += $(CPUOBJ)/cubeqcpu/cubedasm.o
238DASMOBJS += $(CPUOBJ)/cubeqcpu/cubedasm.o
254239endif
255240
256241$(CPUOBJ)/cubeqcpu/cubeqcpu.o:   $(CPUSRC)/cubeqcpu/cubeqcpu.c \
r5534r5535
265250ifneq ($(filter ESRIP,$(CPUS)),)
266251OBJDIRS += $(CPUOBJ)/esrip
267252CPUOBJS += $(CPUOBJ)/esrip/esrip.o
268#DBGOBJS += $(CPUOBJ)/esrip/esrip.o
253DASMOBJS += $(CPUOBJ)/esrip/esripdsm.o
269254endif
270255
271256$(CPUOBJ)/esrip/esrip.o:   $(CPUSRC)/esrip/esrip.c \
r5534r5535
280265ifneq ($(filter CDP1802,$(CPUS)),)
281266OBJDIRS += $(CPUOBJ)/cdp1802
282267CPUOBJS += $(CPUOBJ)/cdp1802/cdp1802.o
283DBGOBJS += $(CPUOBJ)/cdp1802/1802dasm.o
268DASMOBJS += $(CPUOBJ)/cdp1802/1802dasm.o
284269endif
285270
286271$(CPUOBJ)/cdp1802/cdp1802.o:   $(CPUSRC)/cdp1802/cdp1802.c \
r5534r5535
295280ifneq ($(filter COP400,$(CPUS)),)
296281OBJDIRS += $(CPUOBJ)/cop400
297282CPUOBJS += $(CPUOBJ)/cop400/cop400.o
298DBGOBJS += $(CPUOBJ)/cop400/cop410ds.o
299DBGOBJS += $(CPUOBJ)/cop400/cop420ds.o
300DBGOBJS += $(CPUOBJ)/cop400/cop440ds.o
283DASMOBJS += $(CPUOBJ)/cop400/cop410ds.o
284DASMOBJS += $(CPUOBJ)/cop400/cop420ds.o
285DASMOBJS += $(CPUOBJ)/cop400/cop440ds.o
301286endif
302287
303288$(CPUOBJ)/cop400/cop400.o:   $(CPUSRC)/cop400/cop400.c \
r5534r5535
313298ifneq ($(filter CP1610,$(CPUS)),)
314299OBJDIRS += $(CPUOBJ)/cp1610
315300CPUOBJS += $(CPUOBJ)/cp1610/cp1610.o
316DBGOBJS += $(CPUOBJ)/cp1610/1610dasm.o
301DASMOBJS += $(CPUOBJ)/cp1610/1610dasm.o
317302endif
318303
319304$(CPUOBJ)/cp1610/cp1610.o:   $(CPUSRC)/cp1610/cp1610.c \
r5534r5535
328313ifneq ($(filter CCPU,$(CPUS)),)
329314OBJDIRS += $(CPUOBJ)/ccpu
330315CPUOBJS += $(CPUOBJ)/ccpu/ccpu.o
331DBGOBJS += $(CPUOBJ)/ccpu/ccpudasm.o
316DASMOBJS += $(CPUOBJ)/ccpu/ccpudasm.o
332317endif
333318
334319$(CPUOBJ)/ccpu/ccpu.o:   $(CPUSRC)/ccpu/ccpu.c \
r5534r5535
343328ifneq ($(filter T11,$(CPUS)),)
344329OBJDIRS += $(CPUOBJ)/t11
345330CPUOBJS += $(CPUOBJ)/t11/t11.o
346DBGOBJS += $(CPUOBJ)/t11/t11dasm.o
331DASMOBJS += $(CPUOBJ)/t11/t11dasm.o
347332endif
348333
349334$(CPUOBJ)/t11/t11.o:   $(CPUSRC)/t11/t11.c \
r5534r5535
360345ifneq ($(filter F8,$(CPUS)),)
361346OBJDIRS += $(CPUOBJ)/f8
362347CPUOBJS += $(CPUOBJ)/f8/f8.o
363DBGOBJS += $(CPUOBJ)/f8/f8dasm.o
348DASMOBJS += $(CPUOBJ)/f8/f8dasm.o
364349endif
365350
366351$(CPUOBJ)/f8/f8.o:   $(CPUSRC)/f8/f8.c \
r5534r5535
381366   $(CPUOBJ)/g65816/g65816o2.o \
382367   $(CPUOBJ)/g65816/g65816o3.o \
383368   $(CPUOBJ)/g65816/g65816o4.o
384DBGOBJS += $(CPUOBJ)/g65816/g65816ds.o
369DASMOBJS += $(CPUOBJ)/g65816/g65816ds.o
385370endif
386371
387372G65816DEPS = \
r5534r5535
416401ifneq ($(filter HD6309,$(CPUS)),)
417402OBJDIRS += $(CPUOBJ)/hd6309
418403CPUOBJS += $(CPUOBJ)/hd6309/hd6309.o
419DBGOBJS += $(CPUOBJ)/hd6309/6309dasm.o
404DASMOBJS += $(CPUOBJ)/hd6309/6309dasm.o
420405endif
421406
422407$(CPUOBJ)/hd6309/hd6309.o:   $(CPUSRC)/hd6309/hd6309.c \
r5534r5535
432417ifneq ($(filter H83002,$(CPUS)),)
433418OBJDIRS += $(CPUOBJ)/h83002
434419CPUOBJS += $(CPUOBJ)/h83002/h8_16.o $(CPUOBJ)/h83002/h8periph.o
435DBGOBJS += $(CPUOBJ)/h83002/h8disasm.o
420DASMOBJS += $(CPUOBJ)/h83002/h8disasm.o
436421endif
437422
438423$(CPUOBJ)/h83002/h8_16.o:      $(CPUSRC)/h83002/h8_16.c \
r5534r5535
453438ifneq ($(filter H83334,$(CPUS)),)
454439OBJDIRS += $(CPUOBJ)/h83002
455440CPUOBJS += $(CPUOBJ)/h83002/h8_8.o $(CPUOBJ)/h83002/h8periph.o
456DBGOBJS += $(CPUOBJ)/h83002/h8disasm.o
441DASMOBJS += $(CPUOBJ)/h83002/h8disasm.o
457442endif
458443
459444$(CPUOBJ)/h83002/h8_8.o:      $(CPUSRC)/h83002/h8_8.c \
r5534r5535
473458ifneq ($(filter SH2,$(CPUS)),)
474459OBJDIRS += $(CPUOBJ)/sh2
475460CPUOBJS += $(CPUOBJ)/sh2/sh2.o $(CPUOBJ)/sh2/sh2comn.o $(CPUOBJ)/sh2/sh2drc.o $(CPUOBJ)/sh2/sh2fe.o $(DRCOBJ)
476DBGOBJS += $(CPUOBJ)/sh2/sh2dasm.o
461DASMOBJS += $(CPUOBJ)/sh2/sh2dasm.o
477462endif
478463
479464$(CPUOBJ)/sh2/sh2.o:   $(CPUSRC)/sh2/sh2.c \
r5534r5535
499484ifneq ($(filter SH4,$(CPUS)),)
500485OBJDIRS += $(CPUOBJ)/sh4
501486CPUOBJS += $(CPUOBJ)/sh4/sh4.o $(CPUOBJ)/sh4/sh4comn.o
502DBGOBJS += $(CPUOBJ)/sh4/sh4dasm.o
487DASMOBJS += $(CPUOBJ)/sh4/sh4dasm.o
503488endif
504489
505490$(CPUOBJ)/sh4/sh4.o:   $(CPUSRC)/sh4/sh4.c \
r5534r5535
519504ifneq ($(filter H6280,$(CPUS)),)
520505OBJDIRS += $(CPUOBJ)/h6280
521506CPUOBJS += $(CPUOBJ)/h6280/h6280.o
522DBGOBJS += $(CPUOBJ)/h6280/6280dasm.o
507DASMOBJS += $(CPUOBJ)/h6280/6280dasm.o
523508endif
524509
525510$(CPUOBJ)/h6280/h6280.o:   $(CPUSRC)/h6280/h6280.c \
r5534r5535
536521ifneq ($(filter E1,$(CPUS)),)
537522OBJDIRS += $(CPUOBJ)/e132xs
538523CPUOBJS += $(CPUOBJ)/e132xs/e132xs.o
539DBGOBJS += $(CPUOBJ)/e132xs/32xsdasm.o
524DASMOBJS += $(CPUOBJ)/e132xs/32xsdasm.o
540525endif
541526
542527$(CPUOBJ)/e132xs/e132xs.o:   $(CPUSRC)/e132xs/e132xs.c \
r5534r5535
552537ifneq ($(filter I4004,$(CPUS)),)
553538OBJDIRS += $(CPUOBJ)/i4004
554539CPUOBJS += $(CPUOBJ)/i4004/i4004.o
555DBGOBJS += $(CPUOBJ)/i4004/4004dasm.o
540DASMOBJS += $(CPUOBJ)/i4004/4004dasm.o
556541endif
557542
558543$(CPUOBJ)/i4004/i4004.o:   $(CPUSRC)/i4004/i4004.c \
r5534r5535
567552ifneq ($(filter I8085,$(CPUS)),)
568553OBJDIRS += $(CPUOBJ)/i8085
569554CPUOBJS += $(CPUOBJ)/i8085/i8085.o
570DBGOBJS += $(CPUOBJ)/i8085/8085dasm.o
555DASMOBJS += $(CPUOBJ)/i8085/8085dasm.o
571556endif
572557
573558$(CPUOBJ)/i8085/i8085.o:   $(CPUSRC)/i8085/i8085.c \
r5534r5535
583568ifneq ($(filter MCS48,$(CPUS)),)
584569OBJDIRS += $(CPUOBJ)/mcs48
585570CPUOBJS += $(CPUOBJ)/mcs48/mcs48.o
586DBGOBJS += $(CPUOBJ)/mcs48/mcs48dsm.o
571DASMOBJS += $(CPUOBJ)/mcs48/mcs48dsm.o
587572endif
588573
589574$(CPUOBJ)/mcs48/mcs48.o:   $(CPUSRC)/mcs48/mcs48.c \
r5534r5535
598583ifneq ($(filter MCS51,$(CPUS)),)
599584OBJDIRS += $(CPUOBJ)/mcs51
600585CPUOBJS += $(CPUOBJ)/mcs51/mcs51.o
601DBGOBJS += $(CPUOBJ)/mcs51/mcs51dasm.o
586DASMOBJS += $(CPUOBJ)/mcs51/mcs51dasm.o
602587endif
603588
604589$(CPUOBJ)/mcs51/mcs51.o:   $(CPUSRC)/mcs51/mcs51.c \
r5534r5535
613598OBJDIRS += $(CPUOBJ)/i86 $(CPUOBJ)/i386
614599CPUOBJS += $(CPUOBJ)/i86/i86.o
615600CPUOBJS += $(CPUOBJ)/i86/i286.o
616DBGOBJS += $(CPUOBJ)/i386/i386dasm.o
601DASMOBJS += $(CPUOBJ)/i386/i386dasm.o
617602endif
618603
619604ifneq ($(filter I386,$(CPUS)),)
620605OBJDIRS += $(CPUOBJ)/i386
621606CPUOBJS += $(CPUOBJ)/i386/i386.o
622DBGOBJS += $(CPUOBJ)/i386/i386dasm.o
607DASMOBJS += $(CPUOBJ)/i386/i386dasm.o
623608endif
624609
625610I86DEPS = \
r5534r5535
662647ifneq ($(filter I860,$(CPUS)),)
663648OBJDIRS += $(CPUOBJ)/i860
664649CPUOBJS += $(CPUOBJ)/i860/i860.o
665DBGOBJS += $(CPUOBJ)/i860/i860dis.o
650DASMOBJS += $(CPUOBJ)/i860/i860dis.o
666651endif
667652
668653$(CPUOBJ)/i860/i860.o:  $(CPUSRC)/i860/i860.c \
r5534r5535
676661ifneq ($(filter I960,$(CPUS)),)
677662OBJDIRS += $(CPUOBJ)/i960
678663CPUOBJS += $(CPUOBJ)/i960/i960.o
679DBGOBJS += $(CPUOBJ)/i960/i960dis.o
664DASMOBJS += $(CPUOBJ)/i960/i960dis.o
680665endif
681666
682667$(CPUOBJ)/i960/i960.o:   $(CPUSRC)/i960/i960.c \
r5534r5535
691676ifneq ($(filter KONAMI,$(CPUS)),)
692677OBJDIRS += $(CPUOBJ)/konami
693678CPUOBJS += $(CPUOBJ)/konami/konami.o
694DBGOBJS += $(CPUOBJ)/konami/knmidasm.o
679DASMOBJS += $(CPUOBJ)/konami/knmidasm.o
695680endif
696681
697682$(CPUOBJ)/konami/konami.o:   $(CPUSRC)/konami/konami.c \
r5534r5535
708693ifneq ($(filter LH5801,$(CPUS)),)
709694OBJDIRS += $(CPUOBJ)/lh5801
710695CPUOBJS += $(CPUOBJ)/lh5801/lh5801.o
711DBGOBJS += $(CPUOBJ)/lh5801/5801dasm.o
696DASMOBJS += $(CPUOBJ)/lh5801/5801dasm.o
712697endif
713698
714699$(CPUOBJ)/lh5801/lh5801.o:   $(CPUSRC)/lh5801/lh5801.c \
r5534r5535
724709ifneq ($(filter SSEM,$(CPUS)),)
725710OBJDIRS += $(CPUOBJ)/ssem
726711CPUOBJS += $(CPUOBJ)/ssem/ssem.o
727DBGOBJS += $(CPUOBJ)/ssem/ssemdasm.o
712DASMOBJS += $(CPUOBJ)/ssem/ssemdasm.o
728713endif
729714
730715$(CPUOBJ)/ssem/ssem.o:   $(CPUSRC)/ssem/ssem.c \
r5534r5535
739724ifneq ($(filter MB88XX,$(CPUS)),)
740725OBJDIRS += $(CPUOBJ)/mb88xx
741726CPUOBJS += $(CPUOBJ)/mb88xx/mb88xx.o
742DBGOBJS += $(CPUOBJ)/mb88xx/mb88dasm.o
727DASMOBJS += $(CPUOBJ)/mb88xx/mb88dasm.o
743728endif
744729
745730$(CPUOBJ)/mb88xx/mb88xx.o:   $(CPUSRC)/mb88xx/mb88xx.c \
r5534r5535
754739ifneq ($(filter MB86233,$(CPUS)),)
755740OBJDIRS += $(CPUOBJ)/mb86233
756741CPUOBJS += $(CPUOBJ)/mb86233/mb86233.o
757DBGOBJS += $(CPUOBJ)/mb86233/mb86233d.o
742DASMOBJS += $(CPUOBJ)/mb86233/mb86233d.o
758743endif
759744
760745$(CPUOBJ)/mb86233/mb86233.o:   $(CPUSRC)/mb86233/mb86233.c \
r5534r5535
769754ifneq ($(filter PIC16C5X,$(CPUS)),)
770755OBJDIRS += $(CPUOBJ)/pic16c5x
771756CPUOBJS += $(CPUOBJ)/pic16c5x/pic16c5x.o
772DBGOBJS += $(CPUOBJ)/pic16c5x/16c5xdsm.o
757DASMOBJS += $(CPUOBJ)/pic16c5x/16c5xdsm.o
773758endif
774759
775760$(CPUOBJ)/pic16c5x/pic16c5x.o:   $(CPUSRC)/pic16c5x/pic16c5x.c \
r5534r5535
788773CPUOBJS += $(CPUOBJ)/mips/r3000.o
789774CPUOBJS += $(CPUOBJ)/mips/mips3com.o $(CPUOBJ)/mips/mips3fe.o $(CPUOBJ)/mips/mips3drc.o $(DRCOBJ)
790775CPUOBJS += $(CPUOBJ)/mips/psx.o
791DBGOBJS += $(CPUOBJ)/mips/r3kdasm.o
792DBGOBJS += $(CPUOBJ)/mips/mips3dsm.o
793DBGOBJS += $(CPUOBJ)/mips/psxdasm.o
776DASMOBJS += $(CPUOBJ)/mips/r3kdasm.o
777DASMOBJS += $(CPUOBJ)/mips/mips3dsm.o
778DASMOBJS += $(CPUOBJ)/mips/psxdasm.o
794779endif
795780
796781$(CPUOBJ)/mips/r3000.o:   $(CPUSRC)/mips/r3000.c \
r5534r5535
826811   $(CPUOBJ)/m37710/m37710o1.o \
827812   $(CPUOBJ)/m37710/m37710o2.o \
828813   $(CPUOBJ)/m37710/m37710o3.o
829DBGOBJS += $(CPUOBJ)/m37710/m7700ds.o
814DASMOBJS += $(CPUOBJ)/m37710/m7700ds.o
830815endif
831816
832817M37710DEPS = \
r5534r5535
864849CPUOBJS += $(CPUOBJ)/m6502/m6509.o
865850CPUOBJS += $(CPUOBJ)/m6502/m65ce02.o
866851CPUOBJS += $(CPUOBJ)/m6502/m4510.o
867DBGOBJS += $(CPUOBJ)/m6502/6502dasm.o
852DASMOBJS += $(CPUOBJ)/m6502/6502dasm.o
868853endif
869854
870855$(CPUOBJ)/m6502/m6502.o:   $(CPUSRC)/m6502/m6502.c \
r5534r5535
895880ifneq ($(filter M6800,$(CPUS)),)
896881OBJDIRS += $(CPUOBJ)/m6800
897882CPUOBJS += $(CPUOBJ)/m6800/m6800.o
898DBGOBJS += $(CPUOBJ)/m6800/6800dasm.o
883DASMOBJS += $(CPUOBJ)/m6800/6800dasm.o
899884endif
900885
901886$(CPUOBJ)/m6800/m6800.o:   $(CPUSRC)/m6800/m6800.c \
r5534r5535
912897ifneq ($(filter M6805,$(CPUS)),)
913898OBJDIRS += $(CPUOBJ)/m6805
914899CPUOBJS += $(CPUOBJ)/m6805/m6805.o
915DBGOBJS += $(CPUOBJ)/m6805/6805dasm.o
900DASMOBJS += $(CPUOBJ)/m6805/6805dasm.o
916901endif
917902
918903$(CPUOBJ)/m6805/m6805.o:   $(CPUSRC)/m6805/m6805.c \
r5534r5535
928913ifneq ($(filter M6809,$(CPUS)),)
929914OBJDIRS += $(CPUOBJ)/m6809
930915CPUOBJS += $(CPUOBJ)/m6809/m6809.o
931DBGOBJS += $(CPUOBJ)/m6809/6809dasm.o
916DASMOBJS += $(CPUOBJ)/m6809/6809dasm.o
932917endif
933918
934919$(CPUOBJ)/m6809/m6809.o:   $(CPUSRC)/m6809/m6809.c \
r5534r5535
945930ifneq ($(filter MC68HC11,$(CPUS)),)
946931OBJDIRS += $(CPUOBJ)/mc68hc11
947932CPUOBJS += $(CPUOBJ)/mc68hc11/mc68hc11.o
948DBGOBJS += $(CPUOBJ)/mc68hc11/hc11dasm.o
933DASMOBJS += $(CPUOBJ)/mc68hc11/hc11dasm.o
949934endif
950935
951936$(CPUOBJ)/mc68hc11/mc68hc11.o:   $(CPUSRC)/mc68hc11/mc68hc11.c \
r5534r5535
960945ifneq ($(filter M680X0,$(CPUS)),)
961946OBJDIRS += $(CPUOBJ)/m68000
962947CPUOBJS += $(CPUOBJ)/m68000/m68kcpu.o $(CPUOBJ)/m68000/m68kops.o
963DBGOBJS += $(CPUOBJ)/m68000/m68kdasm.o
948DASMOBJS += $(CPUOBJ)/m68000/m68kdasm.o
964949M68KMAKE = $(BUILDOUT)/m68kmake$(BUILD_EXE)
965950endif
966951
r5534r5535
1002987ifneq ($(filter DSP56156,$(CPUS)),)
1003988OBJDIRS += $(CPUOBJ)/dsp56k
1004989CPUOBJS += $(CPUOBJ)/dsp56k/dsp56k.o
1005DBGOBJS += $(CPUOBJ)/dsp56k/dsp56dsm.o
990DASMOBJS += $(CPUOBJ)/dsp56k/dsp56dsm.o
1006991endif
1007992
1008993$(CPUOBJ)/dsp56k/dsp56k.o:   $(CPUSRC)/dsp56k/dsp56k.c \
r5534r5535
10201005OBJDIRS += $(CPUOBJ)/pdp1
10211006CPUOBJS += $(CPUOBJ)/pdp1/pdp1.o
10221007CPUOBJS += $(CPUOBJ)/pdp1/tx0.o
1023DBGOBJS += $(CPUOBJ)/pdp1/pdp1dasm.o
1024DBGOBJS += $(CPUOBJ)/pdp1/tx0dasm.o
1008DASMOBJS += $(CPUOBJ)/pdp1/pdp1dasm.o
1009DASMOBJS += $(CPUOBJ)/pdp1/tx0dasm.o
10251010endif
10261011
10271012$(CPUOBJ)/pdp1/pdp1.o:   $(CPUSRC)/pdp1/pdp1.c \
r5534r5535
10411026ifneq ($(filter POWERPC,$(CPUS)),)
10421027OBJDIRS += $(CPUOBJ)/powerpc
10431028CPUOBJS += $(CPUOBJ)/powerpc/ppccom.o $(CPUOBJ)/powerpc/ppcfe.o $(CPUOBJ)/powerpc/ppcdrc.o $(DRCOBJ)
1044DBGOBJS += $(CPUOBJ)/powerpc/ppc_dasm.o
1029DASMOBJS += $(CPUOBJ)/powerpc/ppc_dasm.o
10451030endif
10461031
10471032$(CPUOBJ)/powerpc/ppccom.o:   $(CPUSRC)/powerpc/ppc.h \
r5534r5535
10661051ifneq ($(filter NEC,$(CPUS)),)
10671052OBJDIRS += $(CPUOBJ)/nec
10681053CPUOBJS += $(CPUOBJ)/nec/nec.o
1069DBGOBJS += $(CPUOBJ)/nec/necdasm.o
1054DASMOBJS += $(CPUOBJ)/nec/necdasm.o
10701055endif
10711056
10721057ifneq ($(filter V30MZ,$(CPUS)),)
10731058OBJDIRS += $(CPUOBJ)/v30mz $(CPUOBJ)/nec
10741059CPUOBJS += $(CPUOBJ)/v30mz/v30mz.o
1075DBGOBJS += $(CPUOBJ)/nec/necdasm.o
1060DASMOBJS += $(CPUOBJ)/nec/necdasm.o
10761061endif
10771062
10781063$(CPUOBJ)/nec/nec.o:   $(CPUSRC)/nec/nec.c \
r5534r5535
11001085ifneq ($(filter V60,$(CPUS)),)
11011086OBJDIRS += $(CPUOBJ)/v60
11021087CPUOBJS += $(CPUOBJ)/v60/v60.o
1103DBGOBJS += $(CPUOBJ)/v60/v60d.o
1088DASMOBJS += $(CPUOBJ)/v60/v60d.o
11041089endif
11051090
11061091$(CPUOBJ)/v60/v60.o:   $(CPUSRC)/v60/am.c \
r5534r5535
11281113ifneq ($(filter V810,$(CPUS)),)
11291114OBJDIRS += $(CPUOBJ)/v810
11301115CPUOBJS += $(CPUOBJ)/v810/v810.o
1131DBGOBJS += $(CPUOBJ)/v810/v810dasm.o
1116DASMOBJS += $(CPUOBJ)/v810/v810dasm.o
11321117endif
11331118
11341119$(CPUOBJ)/v810/v810.o:   $(CPUSRC)/v810/v810.c \
r5534r5535
11431128ifneq ($(filter UPD7810,$(CPUS)),)
11441129OBJDIRS += $(CPUOBJ)/upd7810
11451130CPUOBJS += $(CPUOBJ)/upd7810/upd7810.o
1146DBGOBJS += $(CPUOBJ)/upd7810/7810dasm.o
1131DASMOBJS += $(CPUOBJ)/upd7810/7810dasm.o
11471132endif
11481133
11491134$(CPUOBJ)/upd7810/upd7810.o:   $(CPUSRC)/upd7810/upd7810.c \
r5534r5535
11601145ifneq ($(filter MINX,$(CPUS)),)
11611146OBJDIRS += $(CPUOBJ)/minx
11621147CPUOBJS += $(CPUOBJ)/minx/minx.o
1163DBGOBJS += $(CPUOBJ)/minx/minxd.o
1148DASMOBJS += $(CPUOBJ)/minx/minxd.o
11641149endif
11651150
11661151$(CPUOBJ)/minx/minx.o:      $(CPUSRC)/minx/minx.c \
r5534r5535
11721157                     $(CPUSRC)/minx/minxfunc.h
11731158
11741159
1175
11761160#-------------------------------------------------
11771161# Nintendo/SGI RSP (R3000-based + vector processing)
11781162#-------------------------------------------------
r5534r5535
11801164ifneq ($(filter RSP,$(CPUS)),)
11811165OBJDIRS += $(CPUOBJ)/rsp
11821166CPUOBJS += $(CPUOBJ)/rsp/rsp.o
1183DBGOBJS += $(CPUOBJ)/rsp/rsp_dasm.o
1167DASMOBJS += $(CPUOBJ)/rsp/rsp_dasm.o
11841168endif
11851169
11861170$(CPUOBJ)/rsp/rsp.o:   $(CPUSRC)/rsp/rsp.c \
r5534r5535
11951179ifneq ($(filter SATURN,$(CPUS)),)
11961180OBJDIRS += $(CPUOBJ)/saturn
11971181CPUOBJS += $(CPUOBJ)/saturn/saturn.o
1198DBGOBJS += $(CPUOBJ)/saturn/saturnds.o
1182DASMOBJS += $(CPUOBJ)/saturn/saturnds.o
11991183endif
12001184
12011185$(CPUOBJ)/saturn/saturn.o:   $(CPUSRC)/saturn/saturn.c \
r5534r5535
12121196ifneq ($(filter S2650,$(CPUS)),)
12131197OBJDIRS += $(CPUOBJ)/s2650
12141198CPUOBJS += $(CPUOBJ)/s2650/s2650.o
1215DBGOBJS += $(CPUOBJ)/s2650/2650dasm.o
1199DASMOBJS += $(CPUOBJ)/s2650/2650dasm.o
12161200endif
12171201
12181202$(CPUOBJ)/s2650/s2650.o:   $(CPUSRC)/s2650/s2650.c \
r5534r5535
12281212ifneq ($(filter SC61860,$(CPUS)),)
12291213OBJDIRS += $(CPUOBJ)/sc61860
12301214CPUOBJS += $(CPUOBJ)/sc61860/sc61860.o
1231DBGOBJS += $(CPUOBJ)/sc61860/scdasm.o
1215DASMOBJS += $(CPUOBJ)/sc61860/scdasm.o
12321216endif
12331217
12341218$(CPUOBJ)/sc61860/sc61860.o:   $(CPUSRC)/sc61860/sc61860.h \
r5534r5535
12451229ifneq ($(filter SM8500,$(CPUS)),)
12461230OBJDIRS += $(CPUOBJ)/sm8500
12471231CPUOBJS += $(CPUOBJ)/sm8500/sm8500.o
1248DBGOBJS += $(CPUOBJ)/sm8500/sm8500d.o
1232DASMOBJS += $(CPUOBJ)/sm8500/sm8500d.o
12491233endif
12501234
12511235$(CPUOBJ)/sm8500/sm8500.o:   $(CPUSRC)/sm8500/sm8500.c \
r5534r5535
12621246SPCD = cpu/spc700
12631247OBJDIRS += $(CPUOBJ)/spc700
12641248CPUOBJS += $(CPUOBJ)/spc700/spc700.o
1265DBGOBJS += $(CPUOBJ)/spc700/spc700ds.o
1249DASMOBJS += $(CPUOBJ)/spc700/spc700ds.o
12661250endif
12671251
12681252$(CPUOBJ)/spc700/spc700.o:   $(CPUSRC)/spc700/spc700.c \
r5534r5535
12771261ifneq ($(filter SSP1601,$(CPUS)),)
12781262OBJDIRS += $(CPUOBJ)/ssp1601
12791263CPUOBJS += $(CPUOBJ)/ssp1601/ssp1601.o
1280DBGOBJS += $(CPUOBJ)/ssp1601/ssp1601d.o
1264DASMOBJS += $(CPUOBJ)/ssp1601/ssp1601d.o
12811265endif
12821266
12831267$(CPUOBJ)/ssp1610/ssp1601.o:   $(CPUSRC)/ssp1601/ssp1601.c \
r5534r5535
12861270
12871271
12881272#-------------------------------------------------
1273# Atmel 8-bit AVR
1274#-------------------------------------------------
1275
1276ifneq ($(filter AVR8,$(CPUS)),)
1277OBJDIRS += $(CPUOBJ)/avr8
1278CPUOBJS += $(CPUOBJ)/avr8/avr8.o
1279DASMOBJS += $(CPUOBJ)/avr8/avr8dasm.o
1280endif
1281
1282$(CPUOBJ)/avr8/avr8.o:    $(CPUSRC)/avr8/avr8.c \
1283         $(CPUSRC)/avr8/avr8.h
1284
1285
1286
1287#-------------------------------------------------
12891288# Texas Instruments TMS0980
12901289#-------------------------------------------------
12911290
12921291ifneq ($(filter TMS0980,$(CPUS)),)
12931292OBJDIRS += $(CPUOBJ)/tms0980
12941293CPUOBJS += $(CPUOBJ)/tms0980/tms0980.o
1295DBGOBJS += $(CPUOBJ)/tms0980/tms0980d.o
1294DASMOBJS += $(CPUOBJ)/tms0980/tms0980d.o
12961295endif
12971296
12981297$(CPUOBJ)/tms0980/tms0980.o:   $(CPUSRC)/tms0980/tms0980.h \
r5534r5535
13101309ifneq ($(filter TMS7000,$(CPUS)),)
13111310OBJDIRS += $(CPUOBJ)/tms7000
13121311CPUOBJS += $(CPUOBJ)/tms7000/tms7000.o
1313DBGOBJS += $(CPUOBJ)/tms7000/7000dasm.o
1312DASMOBJS += $(CPUOBJ)/tms7000/7000dasm.o
13141313endif
13151314
13161315$(CPUOBJ)/tms7000/tms7000.o:   $(CPUSRC)/tms7000/tms7000.h \
r5534r5535
13311330CPUOBJS += $(CPUOBJ)/tms9900/tms9980a.o
13321331CPUOBJS += $(CPUOBJ)/tms9900/tms9995.o
13331332CPUOBJS += $(CPUOBJ)/tms9900/ti990_10.o
1334DBGOBJS += $(CPUOBJ)/tms9900/9900dasm.o
1333DASMOBJS += $(CPUOBJ)/tms9900/9900dasm.o
13351334endif
13361335
13371336$(CPUOBJ)/tms9900/tms9900.o:   $(CPUSRC)/tms9900/tms9900.c \
r5534r5535
13631362ifneq ($(filter TMS340X0,$(CPUS)),)
13641363OBJDIRS += $(CPUOBJ)/tms34010
13651364CPUOBJS += $(CPUOBJ)/tms34010/tms34010.o
1366DBGOBJS += $(CPUOBJ)/tms34010/34010dsm.o
1365DASMOBJS += $(CPUOBJ)/tms34010/34010dsm.o
13671366endif
13681367
13691368$(CPUOBJ)/tms34010/tms34010.o:   $(CPUSRC)/tms34010/tms34010.c \
r5534r5535
13821381ifneq ($(filter TMS32010,$(CPUS)),)
13831382OBJDIRS += $(CPUOBJ)/tms32010
13841383CPUOBJS += $(CPUOBJ)/tms32010/tms32010.o
1385DBGOBJS += $(CPUOBJ)/tms32010/32010dsm.o
1384DASMOBJS += $(CPUOBJ)/tms32010/32010dsm.o
13861385endif
13871386
13881387$(CPUOBJ)/tms32010/tms32010.o:   $(CPUSRC)/tms32010/tms32010.c \
r5534r5535
13971396ifneq ($(filter TMS32025,$(CPUS)),)
13981397OBJDIRS += $(CPUOBJ)/tms32025
13991398CPUOBJS += $(CPUOBJ)/tms32025/tms32025.o
1400DBGOBJS += $(CPUOBJ)/tms32025/32025dsm.o
1399DASMOBJS += $(CPUOBJ)/tms32025/32025dsm.o
14011400endif
14021401
14031402$(CPUOBJ)/tms32025/tms32025.o:   $(CPUSRC)/tms32025/tms32025.c \
r5534r5535
14121411ifneq ($(filter TMS32031,$(CPUS)),)
14131412OBJDIRS += $(CPUOBJ)/tms32031
14141413CPUOBJS += $(CPUOBJ)/tms32031/tms32031.o
1415DBGOBJS += $(CPUOBJ)/tms32031/dis32031.o
1414DASMOBJS += $(CPUOBJ)/tms32031/dis32031.o
14161415endif
14171416
14181417$(CPUOBJ)/tms32031/tms32031.o:   $(CPUSRC)/tms32031/tms32031.c \
r5534r5535
14281427ifneq ($(filter TMS32051,$(CPUS)),)
14291428OBJDIRS += $(CPUOBJ)/tms32051
14301429CPUOBJS += $(CPUOBJ)/tms32051/tms32051.o
1431DBGOBJS += $(CPUOBJ)/tms32051/dis32051.o
1430DASMOBJS += $(CPUOBJ)/tms32051/dis32051.o
14321431endif
14331432
14341433$(CPUOBJ)/tms32051/tms32051.o:   $(CPUSRC)/tms32051/tms32051.c \
r5534r5535
14431442ifneq ($(filter TMS57002,$(CPUS)),)
14441443OBJDIRS += $(CPUOBJ)/tms57002
14451444CPUOBJS += $(CPUOBJ)/tms57002/tms57002.o
1445DASMOBJS += $(CPUOBJ)/tms57002/57002dsm.o
14461446TMSMAKE += $(BUILDOUT)/tmsmake$(BUILD_EXE)
14471447endif
14481448
r5534r5535
14501450                        $(CPUSRC)/tms57002/tms57002.h \
14511451                        $(CPUOBJ)/tms57002/tms57002.inc
14521452
1453$(CPUOBJ)/tms57002/57002dsm.o:   $(CPUSRC)/tms57002/57002dsm.c \
1454                        $(CPUOBJ)/tms57002/tms57002.inc
1455
14531456# rule to generate the C file
14541457$(CPUOBJ)/tms57002/tms57002.inc: $(TMSMAKE) $(CPUSRC)/tms57002/tmsinstr.lst
14551458   @echo Generating TMS57002 source file...
r5534r5535
14741477ifneq ($(filter TLCS90,$(CPUS)),)
14751478OBJDIRS += $(CPUOBJ)/tlcs90
14761479CPUOBJS += $(CPUOBJ)/tlcs90/tlcs90.o
1477#DBGOBJS += $(CPUOBJ)/tlcs90/tlcs90.o
1480#DASMOBJS += $(CPUOBJ)/tlcs90/tlcs90.o
14781481endif
14791482
14801483$(CPUOBJ)/tlcs90/tlcs90.o:   $(CPUSRC)/tlcs90/tlcs90.c \
r5534r5535
14891492ifneq ($(filter TLCS900,$(CPUS)),)
14901493OBJDIRS += $(CPUOBJ)/tlcs900
14911494CPUOBJS += $(CPUOBJ)/tlcs900/tlcs900.o
1492DBGOBJS += $(CPUOBJ)/tlcs900/dasm900.o
1495DASMOBJS += $(CPUOBJ)/tlcs900/dasm900.o
14931496endif
14941497
14951498$(CPUOBJ)/tlcs900/tlcs900.o:   $(CPUSRC)/tlcs900/tlcs900.c \
r5534r5535
15071510ifneq ($(filter Z80,$(CPUS)),)
15081511OBJDIRS += $(CPUOBJ)/z80
15091512CPUOBJS += $(CPUOBJ)/z80/z80.o $(CPUOBJ)/z80/z80daisy.o
1510DBGOBJS += $(CPUOBJ)/z80/z80dasm.o
1513DASMOBJS += $(CPUOBJ)/z80/z80dasm.o
15111514endif
15121515
15131516$(CPUOBJ)/z80/z80.o:   $(CPUSRC)/z80/z80.c \
r5534r5535
15221525ifneq ($(filter LR35902,$(CPUS)),)
15231526OBJDIRS += $(CPUOBJ)/lr35902
15241527CPUOBJS += $(CPUOBJ)/lr35902/lr35902.o
1525DBGOBJS += $(CPUOBJ)/lr35902/lr35902d.o
1528DASMOBJS += $(CPUOBJ)/lr35902/lr35902d.o
15261529endif
15271530
15281531$(CPUOBJ)/lr35902/lr35902.o:   $(CPUSRC)/lr35902/lr35902.c \
r5534r5535
15391542ifneq ($(filter Z180,$(CPUS)),)
15401543OBJDIRS += $(CPUOBJ)/z180 $(CPUOBJ)/z80
15411544CPUOBJS += $(CPUOBJ)/z180/z180.o $(CPUOBJ)/z80/z80daisy.o
1542DBGOBJS += $(CPUOBJ)/z180/z180dasm.o
1545DASMOBJS += $(CPUOBJ)/z180/z180dasm.o
15431546endif
15441547
15451548$(CPUOBJ)/z180/z180.o:   $(CPUSRC)/z180/z180.c \
r5534r5535
15621565ifneq ($(filter Z8000,$(CPUS)),)
15631566OBJDIRS += $(CPUOBJ)/z8000
15641567CPUOBJS += $(CPUOBJ)/z8000/z8000.o
1565DBGOBJS += $(CPUOBJ)/z8000/8000dasm.o
1568DASMOBJS += $(CPUOBJ)/z8000/8000dasm.o
15661569endif
15671570
15681571$(CPUOBJ)/z8000/z8000.o:   $(CPUSRC)/z8000/z8000.c \
r5534r5535
15711574                     $(CPUSRC)/z8000/z8000dab.h \
15721575                     $(CPUSRC)/z8000/z8000ops.c \
15731576                     $(CPUSRC)/z8000/z8000tbl.c
1577
1578
1579
1580#-------------------------------------------------
1581# Argonaut SuperFX
1582#-------------------------------------------------
1583
1584ifneq ($(filter SUPERFX,$(CPUS)),)
1585OBJDIRS += $(CPUOBJ)/superfx
1586CPUOBJS += $(CPUOBJ)/superfx/superfx.o
1587DASMOBJS += $(CPUOBJ)/superfx/sfx_dasm.o
1588endif
1589
1590$(CPUOBJ)/superfx/superfx.o:$(CPUSRC)/superfx/superfx.c \
1591                     $(CPUSRC)/superfx/superfx.h
src/emu/cpu/m37710/m7700ds.c
r5534r5535
608608
609609   return length | flags | DASMFLAG_SUPPORTED;
610610}
611
612CPU_DISASSEMBLE( m37710_generic )
613{
614   return m7700_disassemble(buffer, (pc&0xffff), pc>>16, oprom, 0, 0);
615}
616
src/emu/cpu/sharc/sharc.c
r5534r5535
66#include "sharc.h"
77#include "debugger.h"
88
9CPU_DISASSEMBLE( sharc );
10
911enum
1012{
1113   SHARC_PC=1,      SHARC_PCSTK,   SHARC_MODE1,   SHARC_MODE2,
r5534r5535
170172};
171173
172174
173static CPU_DISASSEMBLE( sharc );
174
175175static void sharc_dma_exec(SHARC_REGS *cpustate, int channel);
176176static void check_interrupts(SHARC_REGS *cpustate);
177177
r5534r5535
416416   }
417417}
418418
419static CPU_DISASSEMBLE( sharc )
420{
421   UINT64 op = 0;
422   UINT32 flags = 0;
423
424   op = ((UINT64)oprom[0] << 0)  | ((UINT64)oprom[1] << 8) |
425       ((UINT64)oprom[2] << 16) | ((UINT64)oprom[3] << 24) |
426       ((UINT64)oprom[4] << 32) | ((UINT64)oprom[5] << 40);
427
428   flags = sharc_dasm_one(buffer, pc, op);
429   return 1 | flags | DASMFLAG_SUPPORTED;
430}
431
432
433419static CPU_INIT( sharc )
434420{
435421   SHARC_REGS *cpustate = get_safe_token(device);
src/emu/cpu/sharc/sharcdsm.c
r5534r5535
11811181   return flags;
11821182}
11831183
1184
1185CPU_DISASSEMBLE( sharc )
1186{
1187   UINT64 op = 0;
1188   UINT32 flags = 0;
1189
1190   op = ((UINT64)oprom[0] << 0)  | ((UINT64)oprom[1] << 8) |
1191       ((UINT64)oprom[2] << 16) | ((UINT64)oprom[3] << 24) |
1192       ((UINT64)oprom[4] << 32) | ((UINT64)oprom[5] << 40);
1193
1194   flags = sharc_dasm_one(buffer, pc, op);
1195   return 1 | flags | DASMFLAG_SUPPORTED;
1196}
1197
1198
src/emu/cpu/tms57002/57002dsm.c
r0r5535
1#include "tms57002.h"
2#include "debugger.h"
3
4#ifdef __GNUC__
5#define noinline __attribute__((noinline))
6#else
7#define noinline /* */
8#endif
9
10static const char *tms57002_get_memadr(UINT32 opcode, char type)
11{
12   static char buff[2][10];
13   static int index = 0;
14   char *buf;
15
16   index = 1-index;
17   buf = buff[index];
18
19   if(((opcode & 0x400) && (type == 'c')) || (!(opcode & 0x400) && (type == 'd'))) {
20      if(opcode & 0x100)
21         sprintf(buf, "%c(%02x)", type, opcode & 0xff);
22      else if(opcode & 0x80)
23         sprintf(buf, "%c*+", type);
24      else
25         sprintf(buf, "%c*", type);
26   } else if(opcode & 0x200)
27      sprintf(buf, "%c*+", type);
28   else
29      sprintf(buf, "%c*", type);
30   return buf;
31}
32
33
34CPU_DISASSEMBLE(tms57002)
35{
36   UINT32 opcode = opram[0] | (opram[1] << 8) | (opram[2] << 16);
37   UINT8 fa = opcode >> 18;
38   char *buf = buffer;
39   if(fa == 0x3f) {
40      switch((opcode >> 11) & 0x7f) { // category 3
41
42#define DASM3
43#include "cpu/tms57002/tms57002.inc"
44#undef  DASM3
45
46      default:
47         sprintf(buf, "unk c3 %02x", (opcode >> 11) & 0x7f);
48         break;
49      }
50   } else {
51      switch(fa) { // category 1
52      case 0x00:
53         buf[0] = 0;
54         break;
55
56#define DASM1
57#include "cpu/tms57002/tms57002.inc"
58#undef  DASM1
59
60      default:
61         sprintf(buf, "unk c1 %02x", fa);
62         break;
63      }
64
65      buf += strlen(buf);
66      if(buf != buffer) {
67         strcpy(buf, " ; ");
68         buf += 3;
69      }
70
71      switch((opcode >> 11) & 0x7f) { // category 2
72      case 0x00:
73         if(buf != buffer)
74            buf[-3] = 0;
75         else
76            sprintf(buf, "nop");
77         break;
78
79#define DASM2
80#include "cpu/tms57002/tms57002.inc"
81#undef  DASM2
82
83      default:
84         sprintf(buf, "unk c2 %02x", (opcode >> 11) & 0x7f);
85         break;
86      }
87   }
88
89   return 1;
90}
src/emu/cpu/tms57002/tms57002.c
r5534r5535
11#include "tms57002.h"
22#include "debugger.h"
33
4CPU_DISASSEMBLE(tms57002);
5
46#ifdef __GNUC__
57#define noinline __attribute__((noinline))
68#else
r5534r5535
117119
118120static void tms57002_cache_flush(tms57002_t *s);
119121
120static const char *tms57002_get_memadr(UINT32 opcode, char type)
121{
122   static char buff[2][10];
123   static int index = 0;
124   char *buf;
125
126   index = 1-index;
127   buf = buff[index];
128
129   if(((opcode & 0x400) && (type == 'c')) || (!(opcode & 0x400) && (type == 'd'))) {
130      if(opcode & 0x100)
131         sprintf(buf, "%c(%02x)", type, opcode & 0xff);
132      else if(opcode & 0x80)
133         sprintf(buf, "%c*+", type);
134      else
135         sprintf(buf, "%c*", type);
136   } else if(opcode & 0x200)
137      sprintf(buf, "%c*+", type);
138   else
139      sprintf(buf, "%c*", type);
140   return buf;
141}
142
143static CPU_DISASSEMBLE(tms57002)
144{
145   UINT32 opcode = opram[0] | (opram[1] << 8) | (opram[2] << 16);
146   UINT8 fa = opcode >> 18;
147   char *buf = buffer;
148   if(fa == 0x3f) {
149      switch((opcode >> 11) & 0x7f) { // category 3
150
151#define DASM3
152#include "cpu/tms57002/tms57002.inc"
153#undef  DASM3
154
155      default:
156         sprintf(buf, "unk c3 %02x", (opcode >> 11) & 0x7f);
157         break;
158      }
159   } else {
160      switch(fa) { // category 1
161      case 0x00:
162         buf[0] = 0;
163         break;
164
165#define DASM1
166#include "cpu/tms57002/tms57002.inc"
167#undef  DASM1
168
169      default:
170         sprintf(buf, "unk c1 %02x", fa);
171         break;
172      }
173
174      buf += strlen(buf);
175      if(buf != buffer) {
176         strcpy(buf, " ; ");
177         buf += 3;
178      }
179
180      switch((opcode >> 11) & 0x7f) { // category 2
181      case 0x00:
182         if(buf != buffer)
183            buf[-3] = 0;
184         else
185            sprintf(buf, "nop");
186         break;
187
188#define DASM2
189#include "cpu/tms57002/tms57002.inc"
190#undef  DASM2
191
192      default:
193         sprintf(buf, "unk c2 %02x", (opcode >> 11) & 0x7f);
194         break;
195      }
196   }
197
198   return 1;
199}
200
201122WRITE8_DEVICE_HANDLER(tms57002_pload_w)
202123{
203124   tms57002_t *s = get_safe_token(device);
src/emu/cpu/cubeqcpu/cubedasm.c
r0r5535
1/***************************************************************************
2
3    cubedasm.c
4
5    Implementation of the Cube Quest AM2901-based CPUs
6
7***************************************************************************/
8
9#include "debugger.h"
10#include "cubeqcpu.h"
11#include "driver.h"
12
13
14/***************************************************************************
15    CONSTANTS
16***************************************************************************/
17
18/* Am2901 Instruction Fields */
19static const char *const ins[] =
20{
21   "ADD  ",
22   "SUBR ",
23   "SUBS ",
24   "OR   ",
25   "AND  ",
26   "NOTRS",
27   "EXOR ",
28   "EXNOR",
29};
30
31static const char *const src[] =
32{
33   "A,Q",
34   "A,B",
35   "0,Q",
36   "0,B",
37   "0,A",
38   "D,A",
39   "D,Q",
40   "D,0",
41};
42
43static const char *const dst[] =
44{
45   "QREG ",
46   "NOP  ",
47   "RAMA ",
48   "RAMF ",
49   "RAMQD",
50   "RAMD ",
51   "RAMQU",
52   "RAMU ",
53};
54
55
56/***************************************************************************
57    SOUND DISASSEMBLY HOOK
58***************************************************************************/
59
60CPU_DISASSEMBLE( cquestsnd )
61{
62   static const char *const jmps[] =
63   {
64      "JUMP ",
65      "     ",
66      "JMSB ",
67      "JNMSB",
68      "     ",
69      "JZERO",
70      "JOVR ",
71      "JLOOP",
72   };
73
74
75   static const char *const latches[] =
76   {
77      "PLTCH  ",
78      "DAC    ",
79      "ADLATCH",
80      "       ",
81   };
82
83   UINT64 inst = BIG_ENDIANIZE_INT64(*(UINT64 *)oprom);
84   UINT32 inslow = inst & 0xffffffff;
85   UINT32 inshig = inst >> 32;
86
87   int t       = (inshig >> 24) & 0xff;
88   int b       = (inshig >> 20) & 0xf;
89   int a       = (inshig >> 16) & 0xf;
90   int ci      = (inshig >> 15) & 1;
91   int i5_3    = (inshig >> 12) & 7;
92   int _ramen  = (inshig >> 11) & 1;
93   int i2_0    = (inshig >> 8) & 7;
94   int rtnltch = (inshig >> 7) & 1;
95   int jmp     = (inshig >> 4) & 7;
96   int inca    = (inshig >> 3) & 1;
97   int i8_6    = (inshig >> 0) & 7;
98   int _ipram  = (inslow >> 31) & 1;
99   int _ipwrt  = (inslow >> 30) & 1;
100   int latch   = (inslow >> 28) & 3;
101   int rtn     = (inslow >> 27) & 1;
102   int _rin    = (inslow >> 26) & 1;
103
104
105   sprintf(buffer, "%s %s %s %x,%x,%c %.2x %s %s %.2x %s %s %s %c %c %c",
106         ins[i5_3],
107         src[i2_0],
108         dst[i8_6],
109         a,
110         b,
111         ci ? 'C' : ' ',
112         _rin,
113         jmps[jmp],
114         rtn ? "RET" : "   ",
115         t,
116         latches[latch],
117         rtnltch ? "RTLATCH" : "       ",
118         _ramen ? "PROM" : "RAM ",
119         _ipram ? ' ' : 'R',
120         _ipwrt ? ' ' : 'W',
121         inca ? 'I' : ' ');
122
123   return 1 | DASMFLAG_SUPPORTED;
124}
125
126
127/***************************************************************************
128    ROTATE DISASSEMBLY HOOK
129***************************************************************************/
130
131CPU_DISASSEMBLE( cquestrot )
132{
133   static const char *const jmps[] =
134   {
135      "       ",
136      "JSEQ   ",
137      "JC     ",
138      "JSYNC  ",
139      "JLDWAIT",
140      "JMSB   ",
141      "JGEONE ",
142      "JZERO  ",
143
144      "JUMP   ",
145      "JNSEQ  ",
146      "JNC    ",
147      "JNSYNC ",
148      "JNLDWAI",
149      "JNMSB  ",
150      "JLTONE ",
151      "JNZERO ",
152   };
153
154   static const char *const youts[] =
155   {
156      "     ",
157      "     ",
158      "Y2LDA",
159      "Y2LDD",
160      "Y2DAD",
161      "Y2DIN",
162      "Y2R  ",
163      "Y2D  ",
164   };
165
166   static const char *const spfs[] =
167   {
168      "      ",
169      "      ",
170      "OP    ",
171      "RET   ",
172      "SQLTCH",
173      "SWRT  ",
174      "DIV   ",
175      "MULT  ",
176
177      "DRED  ",
178      "DWRT  ",
179      "???   ",
180      "???   ",
181      "???   ",
182      "???   ",
183      "???   ",
184      "???   "
185   };
186
187   UINT64 inst = BIG_ENDIANIZE_INT64(*(UINT64 *)oprom);
188   UINT32 inslow = inst & 0xffffffff;
189   UINT32 inshig = inst >> 32;
190
191   int t       = (inshig >> 20) & 0xfff;
192   int jmp     = (inshig >> 16) & 0xf;
193   int spf      = (inshig >> 12) & 0xf;
194//  int rsrc    = (inshig >> 11) & 0x1;
195   int yout   = (inshig >> 8) & 0x7;
196   int sel      = (inshig >> 6) & 0x3;
197//  int dsrc    = (inshig >> 4) & 0x3;
198   int b      = (inshig >> 0) & 0xf;
199   int a      = (inslow >> 28) & 0xf;
200   int i8_6   = (inslow >> 24) & 0x7;
201   int ci      = (inslow >> 23) & 0x1;
202   int i5_3   = (inslow >> 20) & 0x7;
203//  int _sex    = (inslow >> 19) & 0x1;
204   int i2_0   = (inslow >> 16) & 0x7;
205
206   sprintf(buffer, "%s %s,%s %x,%x,%c %d %s %s %s %.2x",
207         ins[i5_3],
208         src[i2_0],
209         dst[i8_6],
210         a,
211         b,
212         ci ? 'C' : ' ',
213         sel,
214         jmps[jmp],
215         youts[yout],
216         spfs[spf],
217         t);
218
219   return 1 | DASMFLAG_SUPPORTED;
220}
221
222/***************************************************************************
223    LINE DRAWER DISASSEMBLY HOOK
224***************************************************************************/
225
226CPU_DISASSEMBLE( cquestlin )
227{
228   static const char *const jmps[] =
229   {
230      "     ",
231      "JMSB ",
232      "JSEQ ",
233      "JGTZ ",
234      "JC   ",
235      "JZ   ",
236      "?????",
237      "?????",
238
239      "JUMP ",
240      "JNMSB",
241      "JNSEQ",
242      "JLEZ ",
243      "JNC  ",
244      "JNZ  ",
245      "?????",
246      "?????",
247   };
248
249   static const char *const latches[] =
250   {
251      "       ",
252      "SEQLTCH",
253      "XLTCH  ",
254      "YLTCH  ",
255      "BGLTCH ",
256      "FGLTCH ",
257      "CLTCH  ",
258      "ZLTCH  ",
259   };
260
261   static const char *const spfs[] =
262   {
263      "      ",
264      "FSTOP ",
265      "FREG  ",
266      "FSTART",
267      "PWRT  ",
268      "MULT  ",
269      "LSTOP ",
270      "BRES  ",
271   };
272
273   UINT64 inst = BIG_ENDIANIZE_INT64(*(UINT64 *)oprom);
274   UINT32 inslow = inst & 0xffffffff;
275   UINT32 inshig = inst >> 32;
276
277   int t       = (inshig >> 24) & 0xff;
278   int jmp      = (inshig >> 20) & 0xf;
279   int latch   = (inshig >> 16) & 0x7;
280   int op      = (inshig >> 15) & 0x1;
281   int spf      = (inshig >> 12) & 0x7;
282   int b      = (inshig >> 8) & 0xf;
283   int a      = (inshig >> 4) & 0xf;
284   int i8_6   = (inshig >> 0) & 0x7;
285   int ci      = (inslow >> 31) & 0x1;
286   int i5_3   = (inslow >> 28) & 0x7;
287   int _pbcs   = (inslow >> 27) & 0x1;
288   int i2_0   = (inslow >> 24) & 0x7;
289
290   sprintf(buffer, "%s %s,%s %x,%x %c %s %.2x %s %s %s %s",
291         ins[i5_3],
292         src[i2_0],
293         dst[i8_6],
294         a,
295         b,
296         ci ? 'C' : ' ',
297         jmps[jmp],
298         t,
299         latches[latch],
300         op ? "OP" : "  ",
301         _pbcs ? "  " : "PB",
302         spfs[spf]);
303
304   return 1 | DASMFLAG_SUPPORTED;
305}
src/emu/cpu/cubeqcpu/cubeqcpu.c
r5534r5535
1515#include "driver.h"
1616
1717
18CPU_DISASSEMBLE( cquestsnd );
19CPU_DISASSEMBLE( cquestrot );
20CPU_DISASSEMBLE( cquestlin );
21
22
1823/***************************************************************************
1924    CONSTANTS
2025***************************************************************************/
2126
2227/* Am2901 Instruction Fields */
23static const char *const ins[] =
24{
25   "ADD  ",
26   "SUBR ",
27   "SUBS ",
28   "OR   ",
29   "AND  ",
30   "NOTRS",
31   "EXOR ",
32   "EXNOR",
33};
34
35static const char *const src[] =
36{
37   "A,Q",
38   "A,B",
39   "0,Q",
40   "0,B",
41   "0,A",
42   "D,A",
43   "D,Q",
44   "D,0",
45};
46
47static const char *const dst[] =
48{
49   "QREG ",
50   "NOP  ",
51   "RAMA ",
52   "RAMF ",
53   "RAMQD",
54   "RAMD ",
55   "RAMQU",
56   "RAMU ",
57};
58
5928enum alu_src
6029{
6130   AQ = 0,
r5534r5535
737706
738707
739708/***************************************************************************
740    SOUND DISASSEMBLY HOOK
741***************************************************************************/
742
743static CPU_DISASSEMBLE( cquestsnd )
744{
745   static const char *const jmps[] =
746   {
747      "JUMP ",
748      "     ",
749      "JMSB ",
750      "JNMSB",
751      "     ",
752      "JZERO",
753      "JOVR ",
754      "JLOOP",
755   };
756
757
758   static const char *const latches[] =
759   {
760      "PLTCH  ",
761      "DAC    ",
762      "ADLATCH",
763      "       ",
764   };
765
766   UINT64 inst = BIG_ENDIANIZE_INT64(*(UINT64 *)oprom);
767   UINT32 inslow = inst & 0xffffffff;
768   UINT32 inshig = inst >> 32;
769
770   int t       = (inshig >> 24) & 0xff;
771   int b       = (inshig >> 20) & 0xf;
772   int a       = (inshig >> 16) & 0xf;
773   int ci      = (inshig >> 15) & 1;
774   int i5_3    = (inshig >> 12) & 7;
775   int _ramen  = (inshig >> 11) & 1;
776   int i2_0    = (inshig >> 8) & 7;
777   int rtnltch = (inshig >> 7) & 1;
778   int jmp     = (inshig >> 4) & 7;
779   int inca    = (inshig >> 3) & 1;
780   int i8_6    = (inshig >> 0) & 7;
781   int _ipram  = (inslow >> 31) & 1;
782   int _ipwrt  = (inslow >> 30) & 1;
783   int latch   = (inslow >> 28) & 3;
784   int rtn     = (inslow >> 27) & 1;
785   int _rin    = (inslow >> 26) & 1;
786
787
788   sprintf(buffer, "%s %s %s %x,%x,%c %.2x %s %s %.2x %s %s %s %c %c %c\n",
789         ins[i5_3],
790         src[i2_0],
791         dst[i8_6],
792         a,
793         b,
794         ci ? 'C' : ' ',
795         _rin,
796         jmps[jmp],
797         rtn ? "RET" : "   ",
798         t,
799         latches[latch],
800         rtnltch ? "RTLATCH" : "       ",
801         _ramen ? "PROM" : "RAM ",
802         _ipram ? ' ' : 'R',
803         _ipwrt ? ' ' : 'W',
804         inca ? 'I' : ' ');
805
806   return 1 | DASMFLAG_SUPPORTED;
807}
808
809
810/***************************************************************************
811709    ROTATE CORE EXECUTION LOOP
812710***************************************************************************/
813711
r5534r5535
11921090
11931091
11941092/***************************************************************************
1195    ROTATE DISASSEMBLY HOOK
1196***************************************************************************/
1197
1198static CPU_DISASSEMBLE( cquestrot )
1199{
1200   static const char *const jmps[] =
1201   {
1202      "       ",
1203      "JSEQ   ",
1204      "JC     ",
1205      "JSYNC  ",
1206      "JLDWAIT",
1207      "JMSB   ",
1208      "JGEONE ",
1209      "JZERO  ",
1210
1211      "JUMP   ",
1212      "JNSEQ  ",
1213      "JNC    ",
1214      "JNSYNC ",
1215      "JNLDWAI",
1216      "JNMSB  ",
1217      "JLTONE ",
1218      "JNZERO ",
1219   };
1220
1221   static const char *const youts[] =
1222   {
1223      "     ",
1224      "     ",
1225      "Y2LDA",
1226      "Y2LDD",
1227      "Y2DAD",
1228      "Y2DIN",
1229      "Y2R  ",
1230      "Y2D  ",
1231   };
1232
1233   static const char *const spfs[] =
1234   {
1235      "      ",
1236      "      ",
1237      "OP    ",
1238      "RET   ",
1239      "SQLTCH",
1240      "SWRT  ",
1241      "DIV   ",
1242      "MULT  ",
1243
1244      "DRED  ",
1245      "DWRT  ",
1246      "???   ",
1247      "???   ",
1248      "???   ",
1249      "???   ",
1250      "???   ",
1251      "???   "
1252   };
1253
1254   UINT64 inst = BIG_ENDIANIZE_INT64(*(UINT64 *)oprom);
1255   UINT32 inslow = inst & 0xffffffff;
1256   UINT32 inshig = inst >> 32;
1257
1258   int t       = (inshig >> 20) & 0xfff;
1259   int jmp     = (inshig >> 16) & 0xf;
1260   int spf      = (inshig >> 12) & 0xf;
1261//  int rsrc    = (inshig >> 11) & 0x1;
1262   int yout   = (inshig >> 8) & 0x7;
1263   int sel      = (inshig >> 6) & 0x3;
1264//  int dsrc    = (inshig >> 4) & 0x3;
1265   int b      = (inshig >> 0) & 0xf;
1266   int a      = (inslow >> 28) & 0xf;
1267   int i8_6   = (inslow >> 24) & 0x7;
1268   int ci      = (inslow >> 23) & 0x1;
1269   int i5_3   = (inslow >> 20) & 0x7;
1270//  int _sex    = (inslow >> 19) & 0x1;
1271   int i2_0   = (inslow >> 16) & 0x7;
1272
1273   sprintf(buffer, "%s %s,%s %x,%x,%c %d %s %s %s %.2x\n",
1274         ins[i5_3],
1275         src[i2_0],
1276         dst[i8_6],
1277         a,
1278         b,
1279         ci ? 'C' : ' ',
1280         sel,
1281         jmps[jmp],
1282         youts[yout],
1283         spfs[spf],
1284         t);
1285
1286   return 1 | DASMFLAG_SUPPORTED;
1287}
1288
1289/***************************************************************************
12901093    LINE DRAWER CORE EXECUTION LOOP
12911094***************************************************************************/
12921095
r5534r5535
17551558}
17561559
17571560
1758/***************************************************************************
1759    LINE DRAWER DISASSEMBLY HOOK
1760***************************************************************************/
1761
1762static CPU_DISASSEMBLE( cquestlin )
1763{
1764   static const char *const jmps[] =
1765   {
1766      "     ",
1767      "JMSB ",
1768      "JSEQ ",
1769      "JGTZ ",
1770      "JC   ",
1771      "JZ   ",
1772      "?????",
1773      "?????",
1774
1775      "JUMP ",
1776      "JNMSB",
1777      "JNSEQ",
1778      "JLEZ ",
1779      "JNC  ",
1780      "JNZ  ",
1781      "?????",
1782      "?????",
1783   };
1784
1785   static const char *const latches[] =
1786   {
1787      "       ",
1788      "SEQLTCH",
1789      "XLTCH  ",
1790      "YLTCH  ",
1791      "BGLTCH ",
1792      "FGLTCH ",
1793      "CLTCH  ",
1794      "ZLTCH  ",
1795   };
1796
1797   static const char *const spfs[] =
1798   {
1799      "      ",
1800      "FSTOP ",
1801      "FREG  ",
1802      "FSTART",
1803      "PWRT  ",
1804      "MULT  ",
1805      "LSTOP ",
1806      "BRES  ",
1807   };
1808
1809   UINT64 inst = BIG_ENDIANIZE_INT64(*(UINT64 *)oprom);
1810   UINT32 inslow = inst & 0xffffffff;
1811   UINT32 inshig = inst >> 32;
1812
1813   int t       = (inshig >> 24) & 0xff;
1814   int jmp      = (inshig >> 20) & 0xf;
1815   int latch   = (inshig >> 16) & 0x7;
1816   int op      = (inshig >> 15) & 0x1;
1817   int spf      = (inshig >> 12) & 0x7;
1818   int b      = (inshig >> 8) & 0xf;
1819   int a      = (inshig >> 4) & 0xf;
1820   int i8_6   = (inshig >> 0) & 0x7;
1821   int ci      = (inslow >> 31) & 0x1;
1822   int i5_3   = (inslow >> 28) & 0x7;
1823   int _pbcs   = (inslow >> 27) & 0x1;
1824   int i2_0   = (inslow >> 24) & 0x7;
1825
1826   sprintf(buffer, "%s %s,%s %x,%x %c %s %.2x %s %s %s %s\n",
1827         ins[i5_3],
1828         src[i2_0],
1829         dst[i8_6],
1830         a,
1831         b,
1832         ci ? 'C' : ' ',
1833         jmps[jmp],
1834         t,
1835         latches[latch],
1836         op ? "OP" : "  ",
1837         _pbcs ? "  " : "PB",
1838         spfs[spf]);
1839
1840   return 1 | DASMFLAG_SUPPORTED;
1841}
1842
18431561/**************************************************************************
18441562 * Sound set_info
18451563 **************************************************************************/
src/emu/cpu/x86log.c
r5534r5535
7474***************************************************************************/
7575
7676static void reset_log(x86log_context *log);
77static int x86log_i386_dasm_one_ex(char *buffer, UINT64 eip, const UINT8 *oprom, int mode);
77extern int i386_dasm_one(char *buffer, UINT64 eip, const UINT8 *oprom, int mode);
7878
7979
8080
r5534r5535
237237      else
238238      {
239239#ifdef PTR64
240         bytes = x86log_i386_dasm_one_ex(buffer, (FPTR)cur, cur, 64) & DASMFLAG_LENGTHMASK;
240         bytes = i386_dasm_one(buffer, (FPTR)cur, cur, 64) & DASMFLAG_LENGTHMASK;
241241#else
242         bytes = x86log_i386_dasm_one_ex(buffer, (FPTR)cur, cur, 32) & DASMFLAG_LENGTHMASK;
242         bytes = i386_dasm_one(buffer, (FPTR)cur, cur, 32) & DASMFLAG_LENGTHMASK;
243243#endif
244244      }
245245
r5534r5535
305305   log->comment_count = 0;
306306   log->comment_pool_next = log->comment_pool;
307307}
308
309
310
311/***************************************************************************
312    DISASSEMBLERS
313***************************************************************************/
314
315#define i386_dasm_one x86log_i386_dasm_one
316#define i386_dasm_one_ex x86log_i386_dasm_one_ex
317#include "cpu/i386/i386dasm.c"
src/emu/cpu/v60/v60.c
r5534r5535
199199#define ADTMR1   reg[64]
200200//29-31 reserved
201201
202// Register names
203const char *const v60_reg_names[69] = {
204   "R0", "R1", "R2", "R3",
205   "R4", "R5", "R6", "R7",
206   "R8", "R9", "R10", "R11",
207   "R12", "R13", "R14", "R15",
208   "R16", "R17", "R18", "R19",
209   "R20", "R21", "R22", "R23",
210   "R24", "R25", "R26", "R27",
211   "R28", "AP", "FP", "SP",
212   "PC", "PSW","Unk","Unk",
213   "ISP", "L0SP", "L1SP", "L2SP",
214   "L3SP", "SBR","TR","SYCW",
215   "TKCW", "PIR", "Reserved","Reserved",
216   "Reserved","Reserved","Reserved","PSW2",
217   "ATBR0", "ATLR0", "ATBR1", "ATLR1",
218   "ATBR2", "ATLR2", "ATBR3", "ATLR3",
219   "TRMODE", "ADTR0", "ADTR1","ADTMR0",
220   "ADTMR1","Reserved","Reserved","Reserved"
221};
222
223202// Defines...
224203#define NORMALIZEFLAGS(cs) \
225204{ \
src/emu/cpu/v60/v60d.c
r5534r5535
22#include "debugger.h"
33#include "v60.h"
44
5// Register names
6const char *const v60_reg_names[69] = {
7   "R0", "R1", "R2", "R3",
8   "R4", "R5", "R6", "R7",
9   "R8", "R9", "R10", "R11",
10   "R12", "R13", "R14", "R15",
11   "R16", "R17", "R18", "R19",
12   "R20", "R21", "R22", "R23",
13   "R24", "R25", "R26", "R27",
14   "R28", "AP", "FP", "SP",
15   "PC", "PSW","Unk","Unk",
16   "ISP", "L0SP", "L1SP", "L2SP",
17   "L3SP", "SBR","TR","SYCW",
18   "TKCW", "PIR", "Reserved","Reserved",
19   "Reserved","Reserved","Reserved","PSW2",
20   "ATBR0", "ATLR0", "ATBR1", "ATLR1",
21   "ATBR2", "ATLR2", "ATBR3", "ATLR3",
22   "TRMODE", "ADTR0", "ADTR1","ADTMR0",
23   "ADTMR1","Reserved","Reserved","Reserved"
24};
25
526static const UINT8 *rombase;
627static offs_t pcbase;
728
src/emu/cpu/ssp1601/ssp1601d.c
r5534r5535
288288}
289289
290290// vim:ts=4
291
292CPU_DISASSEMBLE( ssp1601 )
293{
294   //ssp1601_state_t *ssp1601_state = get_safe_token(device);
295
296   return dasm_ssp1601(buffer, pc, oprom);
297}
298
299
src/emu/cpu/ssp1601/ssp1601.c
r5534r5535
2020#include "debugger.h"
2121#include "ssp1601.h"
2222
23CPU_DISASSEMBLE( ssp1601 );
2324
2425/* detect ops with unimplemented/invalid fields.
2526 * Useful for homebrew or if a new VR revision pops up. */
r5534r5535
764765 * MAME interface
765766 **************************************************************************/
766767
767static CPU_DISASSEMBLE( ssp1601 )
768{
769   //ssp1601_state_t *ssp1601_state = get_safe_token(device);
770
771   return dasm_ssp1601(buffer, pc, oprom);
772}
773
774
775768static CPU_SET_INFO( ssp1601 )
776769{
777770   ssp1601_state_t *ssp1601_state = get_safe_token(device);
src/emu/cpu/e132xs/32xsdasm.c
r5534r5535
21332133
21342134   return size | flags | DASMFLAG_SUPPORTED;
21352135}
2136
2137CPU_DISASSEMBLE( hyperstone_generic )
2138{
2139   return dasm_hyperstone( buffer, pc, oprom, 0, 0 );
2140}
src/emu/cpu/i386/i386dasm.c
r5534r5535
20552055      case GROUP:
20562056         handle_modrm( modrm_string );
20572057         for( i=0; i < ARRAY_LENGTH(group_op_table); i++ ) {
2058            if( mame_stricmp(op->mnemonic, group_op_table[i].mnemonic) == 0 ) {
2058            if( strcmp(op->mnemonic, group_op_table[i].mnemonic) == 0 ) {
20592059               decode_opcode( s, &group_op_table[i].opcode[MODRM_REG1], op1 );
20602060               return;
20612061            }
r5534r5535
21372137{
21382138   return i386_dasm_one_ex(buffer, eip, oprom, mode);
21392139}
2140
2141CPU_DISASSEMBLE( x86_16 )
2142{
2143   return i386_dasm_one_ex(buffer, pc, oprom, 16);
2144}
2145
2146CPU_DISASSEMBLE( x86_32 )
2147{
2148   return i386_dasm_one_ex(buffer, pc, oprom, 32);
2149}
2150
2151CPU_DISASSEMBLE( x86_64 )
2152{
2153   return i386_dasm_one_ex(buffer, pc, oprom, 64);
2154}
src/emu/cpu/dsp32/dsp32.c
r5534r5535
3030#include "debugger.h"
3131#include "dsp32.h"
3232
33CPU_DISASSEMBLE( dsp32c );
3334
3435
3536/***************************************************************************
r5534r5535
402403
403404
404405/***************************************************************************
405    DISASSEMBLY HOOK
406***************************************************************************/
407
408static CPU_DISASSEMBLE( dsp32c )
409{
410   extern unsigned dasm_dsp32(char *, unsigned, UINT32);
411   return dasm_dsp32(buffer, pc, oprom[0] | (oprom[1] << 8) | (oprom[2] << 16) | (oprom[3] << 24));
412}
413
414
415
416/***************************************************************************
417406    PARALLEL INTERFACE WRITES
418407***************************************************************************/
419408
src/emu/cpu/dsp32/dsp32dis.c
r5534r5535
689689
690690   return 4 | flags | DASMFLAG_SUPPORTED;
691691}
692
693
694/***************************************************************************
695    DISASSEMBLY HOOK
696***************************************************************************/
697
698CPU_DISASSEMBLE( dsp32c )
699{
700   return dasm_dsp32(buffer, pc, oprom[0] | (oprom[1] << 8) | (oprom[2] << 16) | (oprom[3] << 24));
701}
src/emu/cpu/rsp/rsp.c
r5534r5535
88#include "debugger.h"
99#include "rsp.h"
1010
11CPU_DISASSEMBLE( rsp );
12
1113#define LOG_INSTRUCTION_EXECUTION      0
1214#define SAVE_DISASM                  0
1315#define SAVE_DMEM                  0
r5534r5535
28672869
28682870/*****************************************************************************/
28692871
2870static CPU_DISASSEMBLE( rsp )
2871{
2872   UINT32 op = LITTLE_ENDIANIZE_INT32(*(UINT32 *)opram);
2873   return rsp_dasm_one(buffer, pc, op);
2874}
2875
2876/*****************************************************************************/
2877
28782872static CPU_SET_INFO( rsp )
28792873{
28802874   rsp_state *cpustate = get_safe_token(device);
src/emu/cpu/rsp/rsp_dasm.c
r5534r5535
343343
344344   return 4 | flags | DASMFLAG_SUPPORTED;
345345}
346
347/*****************************************************************************/
348
349CPU_DISASSEMBLE( rsp )
350{
351   UINT32 op = LITTLE_ENDIANIZE_INT32(*(UINT32 *)opram);
352   return rsp_dasm_one(buffer, pc, op);
353}
src/emu/cpu/ssem/ssem.c
r5534r5535
88#include "debugger.h"
99#include "ssem.h"
1010
11CPU_DISASSEMBLE( ssem );
12
13
1114#define SSEM_DISASM_ON_UNIMPL           0
1215#define SSEM_DUMP_MEM_ON_UNIMPL         0
1316
r5534r5535
234237    return cycles - cpustate->icount;
235238}
236239
237/*****************************************************************************/
238240
239static CPU_DISASSEMBLE( ssem )
240{
241    UINT32 op = (*(UINT8 *)(opram + 0) << 24) |
242                (*(UINT8 *)(opram + 1) << 16) |
243                (*(UINT8 *)(opram + 2) <<  8) |
244                (*(UINT8 *)(opram + 3) <<  0);
245    return ssem_dasm_one(buffer, pc, op);
246}
247
248241/*****************************************************************************/
249242
250243static CPU_SET_INFO( ssem )
src/emu/cpu/ssem/ssemdasm.c
r5534r5535
7373
7474    return 4 | DASMFLAG_SUPPORTED;
7575}
76
77/*****************************************************************************/
78
79CPU_DISASSEMBLE( ssem )
80{
81    UINT32 op = (*(UINT8 *)(opram + 0) << 24) |
82                (*(UINT8 *)(opram + 1) << 16) |
83                (*(UINT8 *)(opram + 2) <<  8) |
84                (*(UINT8 *)(opram + 3) <<  0);
85    return ssem_dasm_one(buffer, pc, op);
86}
src/emu/cpu/jaguar/jagdasm.c
r5534r5535
180180   }
181181   return size | flags | DASMFLAG_SUPPORTED;
182182}
183
184
185CPU_DISASSEMBLE( jaguargpu )
186{
187    return dasmjag(JAGUAR_VARIANT_GPU, buffer, pc, oprom);
188}
189
190CPU_DISASSEMBLE( jaguardsp )
191{
192    return dasmjag(JAGUAR_VARIANT_DSP, buffer, pc, oprom);
193}
194
195
196
src/emu/cpu/jaguar/jaguar.c
r5534r5535
1010#include "cpuexec.h"
1111#include "jaguar.h"
1212
13CPU_DISASSEMBLE( jaguargpu );
14CPU_DISASSEMBLE( jaguardsp );
15
1316#define LOG_GPU_IO      0
1417#define LOG_DSP_IO      0
1518
r5534r5535
557560
558561
559562/***************************************************************************
560    DISASSEMBLY HOOK
561***************************************************************************/
562
563static CPU_DISASSEMBLE( jaguargpu )
564{
565   extern unsigned dasmjag(int, char *, unsigned, const UINT8 *);
566    return dasmjag(JAGUAR_VARIANT_GPU, buffer, pc, oprom);
567}
568
569static CPU_DISASSEMBLE( jaguardsp )
570{
571   extern unsigned dasmjag(int, char *, unsigned, const UINT8 *);
572    return dasmjag(JAGUAR_VARIANT_DSP, buffer, pc, oprom);
573}
574
575
576
577/***************************************************************************
578563    OPCODES
579564***************************************************************************/
580565
src/emu/cpu/i8085/i8085.c
r5534r5535
11361136      case I8085_SID:
11371137         {
11381138         int sid = devcb_call_read_line(&cpustate->in_sid_func);
1139         
1139
11401140         cpustate->ietemp = ((cpustate->IM & IM_SID) != 0);
11411141         cpustate->ietemp = (sid != 0);
11421142         }
src/emu/cpu/arm/arm.c
r5534r5535
1818#include "arm.h"
1919#include "debugger.h"
2020
21CPU_DISASSEMBLE( arm );
22
2123#define READ8(addr)         cpu_read8(cpustate,addr)
2224#define WRITE8(addr,data)   cpu_write8(cpustate,addr,data)
2325#define READ32(addr)      cpu_read32(cpustate,addr)
r5534r5535
492494   arm_check_irq_state(cpustate);
493495}
494496
495static CPU_DISASSEMBLE( arm )
496{
497   UINT32 opcode = oprom[0] | (oprom[1] << 8) | (oprom[2] << 16) | (oprom[3] << 24);
498   return 4 | arm_disasm(buffer, pc, opcode);
499}
500
501497static CPU_INIT( arm )
502498{
503499   ARM_REGS *cpustate = get_safe_token(device);
src/emu/cpu/arm/armdasm.c
r5534r5535
391391
392392   return dasmflags | DASMFLAG_SUPPORTED;
393393}
394
395CPU_DISASSEMBLE( arm )
396{
397   UINT32 opcode = oprom[0] | (oprom[1] << 8) | (oprom[2] << 16) | (oprom[3] << 24);
398   return 4 | arm_disasm(buffer, pc, opcode);
399}
src/emu/cpu/powerpc/ppc_dasm.c
r5534r5535
11661166   sprintf(buffer, "?");
11671167    return 4 | flags;
11681168}
1169
1170CPU_DISASSEMBLE( powerpc )
1171{
1172   UINT32 op = *(UINT32 *)oprom;
1173   op = BIG_ENDIANIZE_INT32(op);
1174   return ppc_dasm_one(buffer, pc, op);
1175}
src/emu/cpu/z8000/8000dasm.c
r5534r5535
8686   Z8000_exec *o;
8787   UINT32 flags = 0;
8888
89   /* already initialized? */
90   if(z8000_exec == NULL)
91      z8000_init_tables();
92
8993    GET_OP(oprom, 0, new_pc - pc);
9094   new_pc += 2;
9195   switch (pc)
src/emu/cpu/sh2/sh2dasm.c
r5534r5535
600600   }
601601   return 2 | flags | DASMFLAG_SUPPORTED;
602602}
603
604CPU_DISASSEMBLE( sh2 )
605{
606   return DasmSH2( buffer, pc, (oprom[0] << 8) | oprom[1] );
607}
608
src/emu/cpu/sh2/sh2drc.c
r5534r5535
2020#include "sh2comn.h"
2121#include "eminline.h"
2222
23CPU_DISASSEMBLE( sh2 );
24
2325#ifdef USE_SH2DRC
2426
2527/***************************************************************************
r5534r5535
31723174
31733175
31743176/*-------------------------------------------------
3175    sh2_dasm - disassemble an instruction
3176-------------------------------------------------*/
3177
3178static CPU_DISASSEMBLE( sh2 )
3179{
3180   return DasmSH2( buffer, pc, (oprom[0] << 8) | oprom[1] );
3181}
3182
3183/*-------------------------------------------------
31843177    sh2_internal_a5 - read handler for
31853178    SH2 internal map
31863179-------------------------------------------------*/
src/emu/cpu/sh2/sh2.c
r5534r5535
103103#include "sh2.h"
104104#include "sh2comn.h"
105105
106CPU_DISASSEMBLE( sh2 );
107
106108#ifndef USE_SH2DRC
107109
108110/* speed up delay loops, bail out of tight loops */
r5534r5535
22392241   return cycles - sh2_icount;
22402242}
22412243
2242static CPU_DISASSEMBLE( sh2 )
2243{
2244   return DasmSH2( buffer, pc, (oprom[0] << 8) | oprom[1] );
2245}
2246
22472244static CPU_INIT( sh2 )
22482245{
22492246   /* allocate the core memory */
src/emu/cpu/sh4/sh4.c
r5534r5535
2727#include "sh4regs.h"
2828#include "sh4comn.h"
2929
30CPU_DISASSEMBLE( sh4 );
31
3032INLINE SH4 *get_safe_token(const device_config *device)
3133{
3234   assert(device != NULL);
r5534r5535
34193421   return cycles - sh4->sh4_icount;
34203422}
34213423
3422static CPU_DISASSEMBLE( sh4 )
3423{
3424   return DasmSH4( buffer, pc, (oprom[1] << 8) | oprom[0] );
3425}
3426
34273424static CPU_INIT( sh4 )
34283425{
34293426   const struct sh4_config *conf = (const struct sh4_config *)device->static_config;
src/emu/cpu/sh4/sh4dasm.c
r5534r5535
809809   }
810810   return 2 | flags | DASMFLAG_SUPPORTED;
811811}
812
813CPU_DISASSEMBLE( sh4 )
814{
815   return DasmSH4( buffer, pc, (oprom[1] << 8) | oprom[0] );
816}
817
src/emu/cpu/g65816/g65816ds.c
r5534r5535
345345
346346   return length | DASMFLAG_SUPPORTED | dasm_flags;
347347}
348
349CPU_DISASSEMBLE( g65816_generic )
350{
351   return g65816_disassemble(buffer, (pc & 0x00ffff), (pc & 0xff0000) >> 16, oprom, 0, 0);
352}
src/emu/cpu/nec/necdasm.c
r5534r5535
14851485      case GROUP:
14861486         handle_modrm( modrm_string );
14871487         for( i=0; i < ARRAY_LENGTH(group_op_table); i++ ) {
1488            if( mame_stricmp(op->mnemonic, group_op_table[i].mnemonic) == 0 )
1488            if( strcmp(op->mnemonic, group_op_table[i].mnemonic) == 0 )
14891489            {
14901490               decode_opcode( s, &group_op_table[i].opcode[MODRM_REG1], op1 );
14911491               return;
r5534r5535
15431543   decode_opcode( buffer, &necv_opcode_table1[op], op );
15441544   return (pc-eip) | dasm_flags | DASMFLAG_SUPPORTED;
15451545}
1546
1547CPU_DISASSEMBLE( nec_generic )
1548{
1549   return necv_dasm_one(buffer, pc, oprom, NULL);
1550}
1551
src/emu/cpu/mips/mips3dsm.c
r5534r5535
509509   }
510510   return 4 | flags | DASMFLAG_SUPPORTED;
511511}
512
513
514CPU_DISASSEMBLE( mips3be )
515{
516   UINT32 op = *(UINT32 *)oprom;
517   op = BIG_ENDIANIZE_INT32(op);
518   return dasmmips3(buffer, pc, op);
519}
520
521
522CPU_DISASSEMBLE( mips3le )
523{
524   UINT32 op = *(UINT32 *)oprom;
525   op = LITTLE_ENDIANIZE_INT32(op);
526   return dasmmips3(buffer, pc, op);
527}
528
529
src/emu/cpu/mips/r3000.c
r5534r5535
99#include "debugger.h"
1010#include "r3000.h"
1111
12CPU_DISASSEMBLE( r3000be );
13CPU_DISASSEMBLE( r3000le );
1214
1315#define ENABLE_OVERFLOWS   0
1416
r5534r5535
888890    DISASSEMBLY HOOK
889891***************************************************************************/
890892
891static CPU_DISASSEMBLE( r3000be )
892{
893   extern unsigned dasmr3k(char *, unsigned, UINT32);
894   UINT32 op = *(UINT32 *)oprom;
895   op = BIG_ENDIANIZE_INT32(op);
896   return dasmr3k(buffer, pc, op);
897}
898893
899
900static CPU_DISASSEMBLE( r3000le )
901{
902   extern unsigned dasmr3k(char *, unsigned, UINT32);
903   UINT32 op = *(UINT32 *)oprom;
904   op = LITTLE_ENDIANIZE_INT32(op);
905   return dasmr3k(buffer, pc, op);
906}
907
908
909
910894/***************************************************************************
911895    CACHE I/O
912896***************************************************************************/
src/emu/cpu/mips/r3kdasm.c
r5534r5535
369369   }
370370   return 4 | flags | DASMFLAG_SUPPORTED;
371371}
372
373
374CPU_DISASSEMBLE( r3000be )
375{
376   UINT32 op = *(UINT32 *)oprom;
377   op = BIG_ENDIANIZE_INT32(op);
378   return dasmr3k(buffer, pc, op);
379}
380
381
382CPU_DISASSEMBLE( r3000le )
383{
384   UINT32 op = *(UINT32 *)oprom;
385   op = LITTLE_ENDIANIZE_INT32(op);
386   return dasmr3k(buffer, pc, op);
387}
src/emu/cpu/mips/psxdasm.c
r5534r5535
739739   }
740740   return ( opram - oldopram ) | flags | DASMFLAG_SUPPORTED;
741741}
742
743CPU_DISASSEMBLE( psxcpu_generic )
744{
745   DasmPSXCPU_state state = {0};
746   state.pc = pc;
747   return DasmPSXCPU( &state, buffer, pc, opram );
748}
src/emu/cpu/z80/z80.c
r5534r5535
3434 *    - Fixed cycle counts for LD IYL/IXL/IYH/IXH,n [Marshmellow]
3535 *    - Fixed X/Y flags in CCF/SCF/BIT, ZEXALL is happy now [hap]
3636 *    - Simplified DAA, renamed MEMPTR (3.8) to WZ, added TODO [hap]
37 *    - Fixed IM2 interrupt cycles [eke]
3738 *   Changes in 3.8 [Miodrag Milanovic]:
3839 *    - Added MEMPTR register (according to informations provided
3940 *      by Vladimir Kladov
r5534r5535
32963297      PUSH(z80, pc);
32973298      RM16(z80, irq_vector, &z80->pc);
32983299      LOG(("Z80 '%s' IM2 [$%04x] = $%04x\n", z80->device->tag, irq_vector, z80->PCD));
3299      /* CALL opcode timing */
3300      z80->icount -= z80->cc_op[0xcd];
3300      /* CALL opcode timing + 'interrupt latency' cycles */
3301      z80->icount -= z80->cc_op[0xcd] + z80->cc_ex[0xff];
33013302   }
33023303   else
33033304   /* Interrupt mode 1. RST 38h */
src/emu/cpu/esrip/esrip.c
r5534r5535
1111#include "deprecat.h"
1212#include "esrip.h"
1313
14CPU_DISASSEMBLE( esrip );
1415
16
1517/***************************************************************************
1618    CONSTANTS
1719***************************************************************************/
r5534r5535
18641866}
18651867
18661868
1867/***************************************************************************
1868    DISASSEMBLY HOOK (TODO: FINISH)
1869***************************************************************************/
1870
1871static CPU_DISASSEMBLE( esrip )
1872{
1873#if 0
1874   static const char* const jmp_types[] =
1875   {
1876      "JCT",
1877      "JT1",
1878      "JT2",
1879      "JT3",
1880      "JT4",
1881      "JLBRM",
1882      "J#HBLANK",
1883      "JMP",
1884   };
1885
1886   static const char* const njmp_types[] =
1887   {
1888      "JNCT",
1889      "JNT1",
1890      "JNT2",
1891      "JNT3",
1892      "JNT4",
1893      "JNLBRM",
1894      "J#HBLANK",
1895      "  ",
1896   };
1897#endif
1898
1899   UINT64 inst = BIG_ENDIANIZE_INT64(*(UINT64 *)oprom);
1900
1901   UINT32 inst_hi = inst >> 32;
1902   UINT32 inst_lo = inst & 0xffffffff;
1903
1904   UINT16 ins = (inst_hi >> 16) & 0xffff;
1905   UINT8  ctrl = (inst_hi >> 8) & 0xff;
1906   UINT8  jmp_dest = (inst_lo >> 8) & 0xff;
1907
1908   UINT8 jmp_ctrl = (ctrl >> 3) & 0x1f;
1909
1910   UINT8 ctrl1 = (inst_lo >> 16) & 0xff;
1911   UINT8 ctrl2 = (inst_lo >> 24) & 0xff;
1912   UINT8 ctrl3 = (inst_hi) & 0xff;
1913
1914   sprintf(buffer, "%.4x %c%c%c%c %.2x %s%s%s%s%s%s%s%s %c%s%s%s %c%c%c%c%c%c%c%c\n",
1915         ins,
1916         ctrl & 1 ? 'D' : ' ',
1917         ctrl & 2 ? ' ' : 'Y',
1918         ctrl & 4 ? 'S' : ' ',
1919         (~jmp_ctrl & 0x18) ? 'J' : ' ',
1920         jmp_dest,
1921         ctrl1 & 0x01 ? "  " : "I ",
1922         ctrl1 & 0x02 ? "  " : "FL",
1923         ctrl1 & 0x04 ? "FE" : "  ",
1924         ctrl1 & 0x08 ? "  " : "FR",
1925         ctrl1 & 0x10 ? "  " : "IL",
1926         ctrl1 & 0x20 ? "IE" : "  ",
1927         ctrl1 & 0x40 ? "  " : "IR",
1928         ctrl1 & 0x80 ? "  " : "IW",
1929
1930         ctrl2 & 0x80 ? ' ' : 'O',
1931         ctrl2 & 0x40 ? "     " : "IXLLD",
1932         ctrl2 & 0x20 ? "     " : "IADLD",
1933         ctrl2 & 0x10 ? "     " : "SCALD",
1934
1935         ctrl3 & 0x01 ? ' ' : '0',
1936         ctrl3 & 0x02 ? ' ' : '1',
1937         ctrl3 & 0x04 ? ' ' : '2',
1938         ctrl3 & 0x08 ? ' ' : '3',
1939         ctrl3 & 0x10 ? ' ' : '4',
1940         ctrl3 & 0x20 ? ' ' : '5',
1941         ctrl3 & 0x40 ? ' ' : '6',
1942         ctrl3 & 0x80 ? ' ' : '7'
1943         );
1944
1945   return 1 | DASMFLAG_SUPPORTED;
1946}
1947
19481869/**************************************************************************
19491870 * set_info
19501871 **************************************************************************/
src/emu/cpu/esrip/esripdsm.c
r0r5535
1/***************************************************************************
2
3    esripdsm.c
4
5    Implementation of the Entertainment Sciences
6    AM29116-based Real Time Image Processor
7
8***************************************************************************/
9
10#include "debugger.h"
11
12
13/***************************************************************************
14    DISASSEMBLY HOOK (TODO: FINISH)
15***************************************************************************/
16
17CPU_DISASSEMBLE( esrip )
18{
19#if 0
20   static const char* const jmp_types[] =
21   {
22      "JCT",
23      "JT1",
24      "JT2",
25      "JT3",
26      "JT4",
27      "JLBRM",
28      "J#HBLANK",
29      "JMP",
30   };
31
32   static const char* const njmp_types[] =
33   {
34      "JNCT",
35      "JNT1",
36      "JNT2",
37      "JNT3",
38      "JNT4",
39      "JNLBRM",
40      "J#HBLANK",
41      "  ",
42   };
43#endif
44
45   UINT64 inst = BIG_ENDIANIZE_INT64(*(UINT64 *)oprom);
46
47   UINT32 inst_hi = inst >> 32;
48   UINT32 inst_lo = inst & 0xffffffff;
49
50   UINT16 ins = (inst_hi >> 16) & 0xffff;
51   UINT8  ctrl = (inst_hi >> 8) & 0xff;
52   UINT8  jmp_dest = (inst_lo >> 8) & 0xff;
53
54   UINT8 jmp_ctrl = (ctrl >> 3) & 0x1f;
55
56   UINT8 ctrl1 = (inst_lo >> 16) & 0xff;
57   UINT8 ctrl2 = (inst_lo >> 24) & 0xff;
58   UINT8 ctrl3 = (inst_hi) & 0xff;
59
60   sprintf(buffer, "%.4x %c%c%c%c %.2x %s%s%s%s%s%s%s%s %c%s%s%s %c%c%c%c%c%c%c%c",
61         ins,
62         ctrl & 1 ? 'D' : ' ',
63         ctrl & 2 ? ' ' : 'Y',
64         ctrl & 4 ? 'S' : ' ',
65         (~jmp_ctrl & 0x18) ? 'J' : ' ',
66         jmp_dest,
67         ctrl1 & 0x01 ? "  " : "I ",
68         ctrl1 & 0x02 ? "  " : "FL",
69         ctrl1 & 0x04 ? "FE" : "  ",
70         ctrl1 & 0x08 ? "  " : "FR",
71         ctrl1 & 0x10 ? "  " : "IL",
72         ctrl1 & 0x20 ? "IE" : "  ",
73         ctrl1 & 0x40 ? "  " : "IR",
74         ctrl1 & 0x80 ? "  " : "IW",
75
76         ctrl2 & 0x80 ? ' ' : 'O',
77         ctrl2 & 0x40 ? "     " : "IXLLD",
78         ctrl2 & 0x20 ? "     " : "IADLD",
79         ctrl2 & 0x10 ? "     " : "SCALD",
80
81         ctrl3 & 0x01 ? ' ' : '0',
82         ctrl3 & 0x02 ? ' ' : '1',
83         ctrl3 & 0x04 ? ' ' : '2',
84         ctrl3 & 0x08 ? ' ' : '3',
85         ctrl3 & 0x10 ? ' ' : '4',
86         ctrl3 & 0x20 ? ' ' : '5',
87         ctrl3 & 0x40 ? ' ' : '6',
88         ctrl3 & 0x80 ? ' ' : '7'
89         );
90
91   return 1 | DASMFLAG_SUPPORTED;
92}
src/emu/cpu/i960/i960.c
r5534r5535
33#include "i960dis.h"
44#include <math.h>
55
6CPU_DISASSEMBLE( i960  );
7
68#ifdef _MSC_VER
79/* logb prototype is different for MS Visual C */
810#include <float.h>
r5534r5535
20842086   state_save_register_device_item_array(device, 0, i960->rcache_frame_addr);
20852087}
20862088
2087static CPU_DISASSEMBLE( i960  )
2088{
2089   disassemble_t dis;
2090
2091   dis.IP = pc;
2092   dis.buffer = buffer;
2093   dis.oprom = oprom;
2094
2095   i960_disassemble(&dis);
2096
2097   return dis.IPinc | dis.disflags | DASMFLAG_SUPPORTED;
2098}
2099
21002089static CPU_RESET( i960 )
21012090{
21022091   i960_state_t *i960 = get_safe_token(device);
src/emu/cpu/i960/i960dis.c
r5534r5535
289289
290290
291291
292CPU_DISASSEMBLE( i960  )
293{
294   disassemble_t dis;
295
296   dis.IP = pc;
297   dis.buffer = buffer;
298   dis.oprom = oprom;
299
300   i960_disassemble(&dis);
301
302   return dis.IPinc | dis.disflags | DASMFLAG_SUPPORTED;
303}
304
src/emu/cpu/mb86233/mb86233.c
r5534r5535
1616#include "mb86233.h"
1717#include "debugger.h"
1818
19CPU_DISASSEMBLE( mb86233 );
20
1921/***************************************************************************
2022    STRUCTURES & TYPEDEFS
2123***************************************************************************/
r5534r5535
15581560}
15591561
15601562/***************************************************************************
1561    DISASSEMBLY HOOK
1562***************************************************************************/
1563
1564static CPU_DISASSEMBLE( mb86233 )
1565{
1566   extern UINT32 dasm_mb86233(char *, UINT32);
1567
1568   UINT32 op = *(UINT32 *)oprom;
1569   op = LITTLE_ENDIANIZE_INT32(op);
1570   return dasm_mb86233(buffer, op);
1571}
1572
1573
1574/***************************************************************************
15751563    Information Setters
15761564***************************************************************************/
15771565
src/emu/cpu/mb86233/mb86233d.c
r5534r5535
772772
773773   return (1 | DASMFLAG_SUPPORTED);
774774}
775
776CPU_DISASSEMBLE( mb86233 )
777{
778   UINT32 op = *(UINT32 *)oprom;
779   op = LITTLE_ENDIANIZE_INT32(op);
780   return dasm_mb86233(buffer, op);
781}
src/emu/cpu/arm7/arm7.c
r5534r5535
279279
280280static CPU_DISASSEMBLE( arm7 )
281281{
282   CPU_DISASSEMBLE( arm7arm );
283   CPU_DISASSEMBLE( arm7thumb );
284
282285    arm_state *cpustate = get_safe_token(device);
283286
284287    if (T_IS_SET(GET_CPSR))
285    {
286        return thumb_disasm(buffer, pc, oprom[0] | (oprom[1] << 8)) | 2;
287    }
288       return CPU_DISASSEMBLE_CALL(arm7thumb);
288289    else
289    {
290        return arm7_disasm(buffer, pc, oprom[0] | (oprom[1] << 8) | (oprom[2] << 16) | (oprom[3] << 24)) | 4;
291    }
290       return CPU_DISASSEMBLE_CALL(arm7arm);
292291}
293292
294293
src/emu/cpu/arm7/arm7dasm.c
r5534r5535
13051305
13061306   return dasmflags | DASMFLAG_SUPPORTED;
13071307}
1308
1309CPU_DISASSEMBLE( arm7arm )
1310{
1311   return arm7_disasm(buffer, pc, oprom[0] | (oprom[1] << 8) | (oprom[2] << 16) | (oprom[3] << 24)) | 4;
1312}
1313
1314CPU_DISASSEMBLE( arm7thumb )
1315{
1316   return thumb_disasm(buffer, pc, oprom[0] | (oprom[1] << 8)) | 2;
1317}
src/emu/video/mc6845.c
r5534r5535
436436
437437static void update_upd_adr_timer(mc6845_t *mc6845)
438438{
439   if (!is_display_enabled(mc6845))
439   if (!is_display_enabled(mc6845) && supports_transparent[mc6845->device_type])
440440      timer_adjust_oneshot(mc6845->upd_adr_timer,  mc6845->upd_time, 0);
441441}
442442
r5534r5535
466466            if (next_y == mc6845->vert_pix_total)
467467               next_y = -1;
468468         }
469         timer_adjust_oneshot(mc6845->upd_adr_timer,  attotime_never, 0);
469         if (supports_transparent[mc6845->device_type]) timer_adjust_oneshot(mc6845->upd_adr_timer,  attotime_never, 0);
470470      }
471471
472472      /* we are in a blanking region, get the location of the next display start */
src/emu/emu.mak
r5534r5535
202202
203203include $(EMUSRC)/cpu/cpu.mak
204204
205$(LIBCPU): $(CPUOBJS) $(DBGOBJS)
205$(LIBCPU): $(CPUOBJS)
206206
207$(LIBDASM): $(DASMOBJS)
207208
208209
210
209211#-------------------------------------------------
210212# sound core objects
211213#-------------------------------------------------
src/emu/inpttype.h
r5534r5535
113113   INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, POKER_HOLD4,         "Hold 4",                 SEQ_DEF_1(KEYCODE_V) )
114114   INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, POKER_HOLD5,         "Hold 5",                 SEQ_DEF_1(KEYCODE_B) )
115115   INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, POKER_CANCEL,        "Cancel",                 SEQ_DEF_1(KEYCODE_N) )
116   INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, POKER_BET,           "Bet",                    SEQ_DEF_1(KEYCODE_1) )
116117   INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, SLOT_STOP1,          "Stop Reel 1",            SEQ_DEF_1(KEYCODE_X) )
117118   INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, SLOT_STOP2,          "Stop Reel 2",            SEQ_DEF_1(KEYCODE_C) )
118119   INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, SLOT_STOP3,          "Stop Reel 3",            SEQ_DEF_1(KEYCODE_V) )
src/emu/inptport.h
r5534r5535
255255   IPT_POKER_HOLD4,
256256   IPT_POKER_HOLD5,
257257   IPT_POKER_CANCEL,
258   IPT_POKER_BET,
258259
259260   /* slot-specific inputs */
260261   IPT_SLOT_STOP1,
src/emu/sound/disc_inp.c
r5534r5535
1515 *
1616 ************************************************************************/
1717
18#define DSS_INPUT__GAIN      (*(node->input[0]))
19#define DSS_INPUT__OFFSET   (*(node->input[1]))
20#define DSS_INPUT__INIT      (*(node->input[2]))
2118
19#define DSS_INPUT__GAIN      DISCRETE_INPUT(0)
20#define DSS_INPUT__OFFSET   DISCRETE_INPUT(1)
21#define DSS_INPUT__INIT      DISCRETE_INPUT(2)
2222
23
2324struct dss_adjustment_context
2425{
2526   const input_port_config *port;
r5534r5535
3031   double      scale;
3132};
3233
34struct dss_input_context
35{
36   stream_sample_t *ptr;         /* current in ptr for stream */
37   UINT8      data;            /* data written */
38   double       gain;            /* node gain */
39   double      offset;            /* node offset */
40   UINT8      is_stream;
41   UINT8      is_buffered;
42   UINT32      stream_in_number;
43   UINT32      stream_out_number;
44};
45
3346INLINE discrete_info *get_safe_token(const device_config *device)
3447{
3548   assert(device != NULL);
r5534r5535
4962   /* Read the node input value if allowed */
5063   if (node)
5164   {
52      UINT8 *node_data = (UINT8 *)node->context;
65      struct dss_input_context *context = (struct dss_input_context *)node->context;
5366
5467      /* Bring the system up to now */
5568      stream_update(info->discrete_stream);
5669
57      if ((node->module.type >= DSS_INPUT_DATA) && (node->module.type <= DSS_INPUT_PULSE))
70      if ((node->module->type >= DSS_INPUT_DATA) && (node->module->type <= DSS_INPUT_PULSE))
5871      {
59         data = *node_data;
72         data = context->data;
6073      }
6174   }
6275   else
r5534r5535
6578    return data;
6679}
6780
68#if 0
69static STREAM_BACKGROUND_CALLBACK( disc_cb )
70{
71   node_description *node = (node_description *) ptr;
7281
73   node->output[0] = param * DSS_INPUT__GAIN + DSS_INPUT__OFFSET;
74}
75#endif
76
7782WRITE8_DEVICE_HANDLER(discrete_sound_w)
7883{
7984   discrete_info    *info = get_safe_token(device);
r5534r5535
8287   /* Update the node input value if it's a proper input node */
8388   if (node)
8489   {
85      UINT8 *node_data = (UINT8 *)node->context;
86      UINT8 last_data  = *node_data;
90      struct dss_input_context *context = (struct dss_input_context *)node->context;
8791      UINT8 new_data    = 0;
8892
89      switch (node->module.type)
93      switch (node->module->type)
9094      {
9195         case DSS_INPUT_DATA:
9296            new_data = data;
r5534r5535
100104            break;
101105      }
102106
103      if (last_data != new_data)
107      if (context->data != new_data)
104108      {
105#if 1
106109         /* Bring the system up to now */
107110         stream_update(info->discrete_stream);
108111
109         *node_data = new_data;
112         context->data = new_data;
110113
111114         /* Update the node output here so we don't have to do it each step */
112         node->output[0] = *node_data * DSS_INPUT__GAIN + DSS_INPUT__OFFSET;
113#else
114         *node_data = new_data;
115         /* Bring the system up to now */
116         stream_update_background(info->discrete_stream, disc_cb, (void *) node, *node_data);
117
118#endif
115         node->output[0] = new_data * context->gain + context->offset;
119116      }
120117   }
121118   else
r5534r5535
137134 * input[6]    -
138135 *
139136 ************************************************************************/
140#define DSS_ADJUSTMENT__MIN      (*(node->input[0]))
141#define DSS_ADJUSTMENT__MAX      (*(node->input[1]))
142#define DSS_ADJUSTMENT__LOG      (*(node->input[2]))
143#define DSS_ADJUSTMENT__PORT   (*(node->input[3]))
144#define DSS_ADJUSTMENT__PMIN   (*(node->input[4]))
145#define DSS_ADJUSTMENT__PMAX   (*(node->input[5]))
137#define DSS_ADJUSTMENT__MIN      DISCRETE_INPUT(0)
138#define DSS_ADJUSTMENT__MAX      DISCRETE_INPUT(1)
139#define DSS_ADJUSTMENT__LOG      DISCRETE_INPUT(2)
140#define DSS_ADJUSTMENT__PORT   DISCRETE_INPUT(3)
141#define DSS_ADJUSTMENT__PMIN   DISCRETE_INPUT(4)
142#define DSS_ADJUSTMENT__PMAX   DISCRETE_INPUT(5)
146143
147144static DISCRETE_STEP(dss_adjustment)
148145{
r5534r5535
172169
173170   if (node->custom)
174171   {
175      context->port = input_port_by_tag(disc_info->device->machine->portconfig, (const char *)node->custom);
172      context->port = input_port_by_tag(node->info->device->machine->portconfig, (const char *)node->custom);
176173      if (context->port == NULL)
177174         fatalerror("DISCRETE_ADJUSTMENT_TAG - NODE_%d has invalid tag", node->node-NODE_00);
178175   }
179176   else
180      context->port = input_port_by_index(disc_info->device->machine->portconfig, DSS_ADJUSTMENT__PORT);
177      context->port = input_port_by_index(node->info->device->machine->portconfig, DSS_ADJUSTMENT__PORT);
181178
182179   context->lastpval = 0x7fffffff;
183180   context->pmin     = DSS_ADJUSTMENT__PMIN;
r5534r5535
211208 * input[0]    - Constant value
212209 *
213210 ************************************************************************/
214#define DSS_CONSTANT__INIT   (*(node->input[0]))
211#define DSS_CONSTANT__INIT   DISCRETE_INPUT(0)
215212
216213static DISCRETE_RESET(dss_constant)
217214{
r5534r5535
231228 ************************************************************************/
232229static DISCRETE_RESET(dss_input)
233230{
234   UINT8 *node_data = (UINT8 *)node->context;
231   struct dss_input_context *context = (struct dss_input_context *)node->context;
235232
236   switch (node->module.type)
233   context->is_buffered = FALSE;
234   context->is_stream = FALSE;
235   context->gain = DSS_INPUT__GAIN;
236   context->offset = DSS_INPUT__OFFSET;
237
238   switch (node->module->type)
237239   {
238240      case DSS_INPUT_DATA:
239         *node_data = DSS_INPUT__INIT;
241         context->data = DSS_INPUT__INIT;
240242         break;
241243      case DSS_INPUT_LOGIC:
242244      case DSS_INPUT_PULSE:
243         *node_data = (DSS_INPUT__INIT == 0) ? 0 : 1;
245         context->data = (DSS_INPUT__INIT == 0) ? 0 : 1;
244246         break;
245247      case DSS_INPUT_NOT:
246         *node_data = (DSS_INPUT__INIT == 0) ? 1 : 0;
248         context->data = (DSS_INPUT__INIT == 0) ? 1 : 0;
247249         break;
248250   }
249   node->output[0] = *node_data * DSS_INPUT__GAIN + DSS_INPUT__OFFSET;
251   node->output[0] = context->data * context->gain + context->offset;
250252}
251253
252254static DISCRETE_STEP(dss_input_pulse)
253255{
254   UINT8 *node_data = (UINT8 *)node->context;
256   struct dss_input_context *context = (struct dss_input_context *)node->context;
255257
256258   /* Set a valid output */
257   node->output[0] = *node_data;
259   node->output[0] = context->data;
258260   /* Reset the input to default for the next cycle */
259261   /* node order is now important */
260   *node_data = DSS_INPUT__INIT;
262   context->data = DSS_INPUT__INIT;
261263}
262264
263265
r5534r5535
270272 * input[2]    - Offset value
271273 *
272274 ************************************************************************/
273#define DSS_INPUT_STREAM__STREAM   (*(node->input[0]))
274#define DSS_INPUT_STREAM__GAIN      (*(node->input[1]))
275#define DSS_INPUT_STREAM__OFFSET   (*(node->input[2]))
275#define DSS_INPUT_STREAM__STREAM   DISCRETE_INPUT(0)
276#define DSS_INPUT_STREAM__GAIN      DISCRETE_INPUT(1)
277#define DSS_INPUT_STREAM__OFFSET   DISCRETE_INPUT(2)
276278
277279static DISCRETE_STEP(dss_input_stream)
278280{
279281   /* the context pointer is set to point to the current input stream data in discrete_stream_update */
280   stream_sample_t **ptr = (stream_sample_t **)node->context;
281   stream_sample_t *data = *ptr;
282   struct dss_input_context *context = (struct dss_input_context *)node->context;
282283
283   node->output[0] = data ? (*data) * DSS_INPUT_STREAM__GAIN + DSS_INPUT_STREAM__OFFSET : 0;
284   if (context->ptr)
285   {
286      node->output[0] = (*context->ptr) * context->gain + context->offset;
287      context->ptr++;
288   }
289   else
290      node->output[0] = 0;
284291}
285292
286293static DISCRETE_RESET(dss_input_stream)
287294{
288   int istream = DSS_INPUT_STREAM__STREAM;
289   /* we will use the node's context pointer to point to the input stream data */
290   assert(istream < disc_info->discrete_input_streams);
291   node->context = (discrete_info *) &disc_info->input_stream_data[istream];
295   struct dss_input_context *context = (struct dss_input_context *)node->context;
296
297   assert(DSS_INPUT_STREAM__STREAM < linked_list_count(node->info->input_list));
298   context->is_buffered = FALSE;
299   context->is_stream = TRUE;
300   context->stream_in_number = DSS_INPUT_STREAM__STREAM;
301   context->gain = DSS_INPUT_STREAM__GAIN;
302   context->offset = DSS_INPUT_STREAM__OFFSET;
303   context->ptr = NULL;
292304}
src/emu/sound/disc_mth.c
r5534r5535
180180 * input[4]    - Channel3 input value
181181 *
182182 ************************************************************************/
183#define DST_ADDER__ENABLE   (*(node->input[0]))
184#define DST_ADDER__IN0      (*(node->input[1]))
185#define DST_ADDER__IN1      (*(node->input[2]))
186#define DST_ADDER__IN2      (*(node->input[3]))
187#define DST_ADDER__IN3      (*(node->input[4]))
183#define DST_ADDER__ENABLE   DISCRETE_INPUT(0)
184#define DST_ADDER__IN0      DISCRETE_INPUT(1)
185#define DST_ADDER__IN1      DISCRETE_INPUT(2)
186#define DST_ADDER__IN2      DISCRETE_INPUT(3)
187#define DST_ADDER__IN3      DISCRETE_INPUT(4)
188188
189189static DISCRETE_STEP(dst_adder)
190190{
r5534r5535
209209 *
210210 * Mar 2004, D Renaud.
211211 ************************************************************************/
212#define DST_COMP_ADDER__SELECT   (*(node->input[0]))
212#define DST_COMP_ADDER__SELECT   DISCRETE_INPUT(0)
213213
214214static DISCRETE_STEP(dst_comp_adder)
215215{
r5534r5535
267267 * input[4]    - Clamp output when disabled
268268 *
269269 ************************************************************************/
270#define DST_CLAMP__ENABLE   (*(node->input[0]))
271#define DST_CLAMP__IN      (*(node->input[1]))
272#define DST_CLAMP__MIN      (*(node->input[2]))
273#define DST_CLAMP__MAX      (*(node->input[3]))
274#define DST_CLAMP__CLAMP   (*(node->input[4]))
270#define DST_CLAMP__ENABLE   DISCRETE_INPUT(0)
271#define DST_CLAMP__IN      DISCRETE_INPUT(1)
272#define DST_CLAMP__MIN      DISCRETE_INPUT(2)
273#define DST_CLAMP__MAX      DISCRETE_INPUT(3)
274#define DST_CLAMP__CLAMP   DISCRETE_INPUT(4)
275275
276276static DISCRETE_STEP(dst_clamp)
277277{
r5534r5535
300300 *
301301 * Mar 2004, D Renaud.
302302 ************************************************************************/
303#define DST_DAC_R1__ENABLE      (*(node->input[0]))
304#define DST_DAC_R1__DATA      (*(node->input[1]))
305#define DST_DAC_R1__VON         (*(node->input[2]))
303#define DST_DAC_R1__ENABLE      DISCRETE_INPUT(0)
304#define DST_DAC_R1__DATA      DISCRETE_INPUT(1)
305#define DST_DAC_R1__VON         DISCRETE_INPUT(2)
306306
307307static DISCRETE_STEP(dst_dac_r1)
308308{
r5534r5535
384384   if (info->ladderLength < 2)
385385   {
386386      /* You need at least 2 resistors for a ladder */
387      discrete_log(disc_info, "dst_dac_r1_reset - Ladder length too small");
387      discrete_log(node->info, "dst_dac_r1_reset - Ladder length too small");
388388   }
389389   if (info->ladderLength > DISC_LADDER_MAXRES )
390390   {
391      discrete_log(disc_info, "dst_dac_r1_reset - Ladder length exceeds DISC_LADDER_MAXRES");
391      discrete_log(node->info, "dst_dac_r1_reset - Ladder length exceeds DISC_LADDER_MAXRES");
392392   }
393393
394394   /*
r5534r5535
426426 * Dec 2004, D Renaud.
427427 ************************************************************************/
428428#define DST_DIODE_MIX_INP_OFFSET   0
429#define DST_DIODE_MIX__INP(addr)   (*(node->input[DST_DIODE_MIX_INP_OFFSET + addr]))
429#define DST_DIODE_MIX__INP(addr)   DISCRETE_INPUT(DST_DIODE_MIX_INP_OFFSET + addr)
430430
431431static DISCRETE_STEP(dst_diode_mix)
432432{
r5534r5535
480480 * input[2]    - Divisor
481481 *
482482 ************************************************************************/
483#define DST_DIVIDE__ENABLE   (*(node->input[0]))
484#define DST_DIVIDE__IN      (*(node->input[1]))
485#define DST_DIVIDE__DIV      (*(node->input[2]))
483#define DST_DIVIDE__ENABLE   DISCRETE_INPUT(0)
484#define DST_DIVIDE__IN      DISCRETE_INPUT(1)
485#define DST_DIVIDE__DIV      DISCRETE_INPUT(2)
486486
487487static DISCRETE_STEP(dst_divide)
488488{
r5534r5535
491491      if(DST_DIVIDE__DIV == 0)
492492      {
493493         node->output[0 ]= DBL_MAX;   /* Max out but don't break */
494         discrete_log(disc_info, "dst_divider_step() - Divide by Zero attempted in NODE_%02d.\n",NODE_INDEX(node->node));
494         discrete_log(node->info, "dst_divider_step() - Divide by Zero attempted in NODE_%02d.\n",NODE_INDEX(node->node));
495495      }
496496      else
497497      {
r5534r5535
515515 * input[3]    - Final addition offset
516516 *
517517 ************************************************************************/
518#define DST_GAIN__ENABLE   (*(node->input[0]))
519#define DST_GAIN__IN      (*(node->input[1]))
520#define DST_GAIN__GAIN      (*(node->input[2]))
521#define DST_GAIN__OFFSET   (*(node->input[3]))
518#define DST_GAIN__ENABLE   DISCRETE_INPUT(0)
519#define DST_GAIN__IN      DISCRETE_INPUT(1)
520#define DST_GAIN__GAIN      DISCRETE_INPUT(2)
521#define DST_GAIN__OFFSET   DISCRETE_INPUT(3)
522522
523523static DISCRETE_STEP(dst_gain)
524524{
r5534r5535
545545 *
546546 * Mar 2004, D Renaud.
547547 ************************************************************************/
548#define DST_INTEGRATE__TRG0   (*(node->input[0]))
549#define DST_INTEGRATE__TRG1   (*(node->input[1]))
548#define DST_INTEGRATE__TRG0   DISCRETE_INPUT(0)
549#define DST_INTEGRATE__TRG1   DISCRETE_INPUT(1)
550550
551551static int dst_trigger_function(int trig0, int trig1, int trig2, int function)
552552{
r5534r5535
609609         i_neg = context->v_max_in / info->r1;
610610         i_pos = (DST_INTEGRATE__TRG0 - OP_AMP_NORTON_VBE) / info->r2;
611611         if (i_pos < 0) i_pos = 0;
612         node->output[0] += (i_pos - i_neg) / disc_info->sample_rate / info->c;
612         node->output[0] += (i_pos - i_neg) / node->info->sample_rate / info->c;
613613         break;
614614
615615      case DISC_INTEGRATE_OP_AMP_2 | DISC_OP_AMP_IS_NORTON:
r5534r5535
618618         i_neg  = dst_trigger_function(trig0, trig1, 0, info->f0) ? context->v_max_in_d / info->r1 : 0;
619619         i_pos  = dst_trigger_function(trig0, trig1, 0, info->f1) ? context->v_max_in / info->r2 : 0;
620620         i_pos += dst_trigger_function(trig0, trig1, 0, info->f2) ? context->v_max_in_d / info->r3 : 0;
621         node->output[0] += (i_pos - i_neg) / disc_info->sample_rate / info->c;
621         node->output[0] += (i_pos - i_neg) / node->info->sample_rate / info->c;
622622         break;
623623   }
624624
r5534r5535
646646      v = info->v1 * info->r3 / (info->r2 + info->r3);   /* vRef */
647647      v = info->v1 - v;   /* actual charging voltage */
648648      i = v / info->r1;
649      context->change = i / disc_info->sample_rate / info->c;
649      context->change = i / node->info->sample_rate / info->c;
650650   }
651651   node->output[0] = 0;
652652}
r5534r5535
660660 * input[1]    - input[0] value
661661 *
662662 ************************************************************************/
663#define DST_LOGIC_INV__ENABLE   (*(node->input[0]))
664#define DST_LOGIC_INV__IN      (*(node->input[1]))
663#define DST_LOGIC_INV__ENABLE   DISCRETE_INPUT(0)
664#define DST_LOGIC_INV__IN      DISCRETE_INPUT(1)
665665
666666static DISCRETE_STEP(dst_logic_inv)
667667{
r5534r5535
684684 * input[2]    - To bit
685685 *
686686 ************************************************************************/
687#define DST_BITS_DECODE__IN      (*(node->input[0]))
688#define DST_BITS_DECODE__FROM   (*(node->input[1]))
689#define DST_BITS_DECODE__TO      (*(node->input[2]))
690#define DST_BITS_DECODE__VOUT   (*(node->input[3]))
687#define DST_BITS_DECODE__IN      DISCRETE_INPUT(0)
688#define DST_BITS_DECODE__FROM   DISCRETE_INPUT(1)
689#define DST_BITS_DECODE__TO      DISCRETE_INPUT(2)
690#define DST_BITS_DECODE__VOUT   DISCRETE_INPUT(3)
691691
692692static DISCRETE_STEP(dst_bits_decode)
693693{
r5534r5535
724724 * input[4]    - input[3] value
725725 *
726726 ************************************************************************/
727#define DST_LOGIC_AND__ENABLE   (*(node->input[0]))
728#define DST_LOGIC_AND__IN0      (*(node->input[1]))
729#define DST_LOGIC_AND__IN1      (*(node->input[2]))
730#define DST_LOGIC_AND__IN2      (*(node->input[3]))
731#define DST_LOGIC_AND__IN3      (*(node->input[4]))
727#define DST_LOGIC_AND__ENABLE   DISCRETE_INPUT(0)
728#define DST_LOGIC_AND__IN0      DISCRETE_INPUT(1)
729#define DST_LOGIC_AND__IN1      DISCRETE_INPUT(2)
730#define DST_LOGIC_AND__IN2      DISCRETE_INPUT(3)
731#define DST_LOGIC_AND__IN3      DISCRETE_INPUT(4)
732732
733733static DISCRETE_STEP(dst_logic_and)
734734{
r5534r5535
753753 * input[4]    - input[3] value
754754 *
755755 ************************************************************************/
756#define DST_LOGIC_NAND__ENABLE   (*(node->input[0]))
757#define DST_LOGIC_NAND__IN0      (*(node->input[1]))
758#define DST_LOGIC_NAND__IN1      (*(node->input[2]))
759#define DST_LOGIC_NAND__IN2      (*(node->input[3]))
760#define DST_LOGIC_NAND__IN3      (*(node->input[4]))
756#define DST_LOGIC_NAND__ENABLE   DISCRETE_INPUT(0)
757#define DST_LOGIC_NAND__IN0      DISCRETE_INPUT(1)
758#define DST_LOGIC_NAND__IN1      DISCRETE_INPUT(2)
759#define DST_LOGIC_NAND__IN2      DISCRETE_INPUT(3)
760#define DST_LOGIC_NAND__IN3      DISCRETE_INPUT(4)
761761
762762static DISCRETE_STEP(dst_logic_nand)
763763{
r5534r5535
782782 * input[4]    - input[3] value
783783 *
784784 ************************************************************************/
785#define DST_LOGIC_OR__ENABLE   (*(node->input[0]))
786#define DST_LOGIC_OR__IN0      (*(node->input[1]))
787#define DST_LOGIC_OR__IN1      (*(node->input[2]))
788#define DST_LOGIC_OR__IN2      (*(node->input[3]))
789#define DST_LOGIC_OR__IN3      (*(node->input[4]))
785#define DST_LOGIC_OR__ENABLE   DISCRETE_INPUT(0)
786#define DST_LOGIC_OR__IN0      DISCRETE_INPUT(1)
787#define DST_LOGIC_OR__IN1      DISCRETE_INPUT(2)
788#define DST_LOGIC_OR__IN2      DISCRETE_INPUT(3)
789#define DST_LOGIC_OR__IN3      DISCRETE_INPUT(4)
790790
791791static DISCRETE_STEP(dst_logic_or)
792792{
r5534r5535
811811 * input[4]    - input[3] value
812812 *
813813 ************************************************************************/
814#define DST_LOGIC_NOR__ENABLE   (*(node->input[0]))
815#define DST_LOGIC_NOR__IN0      (*(node->input[1]))
816#define DST_LOGIC_NOR__IN1      (*(node->input[2]))
817#define DST_LOGIC_NOR__IN2      (*(node->input[3]))
818#define DST_LOGIC_NOR__IN3      (*(node->input[4]))
814#define DST_LOGIC_NOR__ENABLE   DISCRETE_INPUT(0)
815#define DST_LOGIC_NOR__IN0      DISCRETE_INPUT(1)
816#define DST_LOGIC_NOR__IN1      DISCRETE_INPUT(2)
817#define DST_LOGIC_NOR__IN2      DISCRETE_INPUT(3)
818#define DST_LOGIC_NOR__IN3      DISCRETE_INPUT(4)
819819
820820static DISCRETE_STEP(dst_logic_nor)
821821{
r5534r5535
838838 * input[2]    - input[1] value
839839 *
840840 ************************************************************************/
841#define DST_LOGIC_XOR__ENABLE   (*(node->input[0]))
842#define DST_LOGIC_XOR__IN0      (*(node->input[1]))
843#define DST_LOGIC_XOR__IN1      (*(node->input[2]))
841#define DST_LOGIC_XOR__ENABLE   DISCRETE_INPUT(0)
842#define DST_LOGIC_XOR__IN0      DISCRETE_INPUT(1)
843#define DST_LOGIC_XOR__IN1      DISCRETE_INPUT(2)
844844
845845static DISCRETE_STEP(dst_logic_xor)
846846{
r5534r5535
863863 * input[2]    - input[1] value
864864 *
865865 ************************************************************************/
866#define DST_LOGIC_XNOR__ENABLE   (*(node->input[0]))
867#define DST_LOGIC_XNOR__IN0      (*(node->input[1]))
868#define DST_LOGIC_XNOR__IN1      (*(node->input[2]))
866#define DST_LOGIC_XNOR__ENABLE   DISCRETE_INPUT(0)
867#define DST_LOGIC_XNOR__IN0      DISCRETE_INPUT(1)
868#define DST_LOGIC_XNOR__IN1      DISCRETE_INPUT(2)
869869
870870static DISCRETE_STEP(dst_logic_nxor)
871871{
r5534r5535
891891 * input[4]    - data
892892 *
893893 ************************************************************************/
894#define DST_LOGIC_DFF__ENABLE    (*(node->input[0]))
895#define DST_LOGIC_DFF__RESET   !(*(node->input[1]))
896#define DST_LOGIC_DFF__SET      !(*(node->input[2]))
897#define DST_LOGIC_DFF__CLOCK    (*(node->input[3]))
898#define DST_LOGIC_DFF__DATA     (*(node->input[4]))
894#define DST_LOGIC_DFF__ENABLE    DISCRETE_INPUT(0)
895#define DST_LOGIC_DFF__RESET   !DISCRETE_INPUT(1)
896#define DST_LOGIC_DFF__SET      !DISCRETE_INPUT(2)
897#define DST_LOGIC_DFF__CLOCK    DISCRETE_INPUT(3)
898#define DST_LOGIC_DFF__DATA     DISCRETE_INPUT(4)
899899
900900static DISCRETE_STEP(dst_logic_dff)
901901{
r5534r5535
940940 * input[5]    - K
941941 *
942942 ************************************************************************/
943#define DST_LOGIC_JKFF__ENABLE    (*(node->input[0]))
944#define DST_LOGIC_JKFF__RESET   !(*(node->input[1]))
945#define DST_LOGIC_JKFF__SET      !(*(node->input[2]))
946#define DST_LOGIC_JKFF__CLOCK    (*(node->input[3]))
947#define DST_LOGIC_JKFF__J        (*(node->input[4]))
948#define DST_LOGIC_JKFF__K        (*(node->input[5]))
943#define DST_LOGIC_JKFF__ENABLE    DISCRETE_INPUT(0)
944#define DST_LOGIC_JKFF__RESET   !DISCRETE_INPUT(1)
945#define DST_LOGIC_JKFF__SET      !DISCRETE_INPUT(2)
946#define DST_LOGIC_JKFF__CLOCK    DISCRETE_INPUT(3)
947#define DST_LOGIC_JKFF__J        DISCRETE_INPUT(4)
948#define DST_LOGIC_JKFF__K        DISCRETE_INPUT(5)
949949
950950static DISCRETE_STEP(dst_logic_jkff)
951951{
r5534r5535
10011001 *
10021002 * Feb 2007, D Renaud.
10031003 ************************************************************************/
1004#define DST_LOOKUP_TABLE__ENABLE   (*(node->input[0]))
1005#define DST_LOOKUP_TABLE__IN      (*(node->input[1]))
1006#define DST_LOOKUP_TABLE__SIZE      (*(node->input[2]))
1004#define DST_LOOKUP_TABLE__ENABLE   DISCRETE_INPUT(0)
1005#define DST_LOOKUP_TABLE__IN      DISCRETE_INPUT(1)
1006#define DST_LOOKUP_TABLE__SIZE      DISCRETE_INPUT(2)
10071007
10081008static DISCRETE_STEP(dst_lookup_table)
10091009{
r5534r5535
10681068 * The voltage is then modified by an inverting amp formula.
10691069 * v = vRef + (rF/rI) * (vRef - (i * r))
10701070 */
1071#define DST_MIXER__ENABLE      (*(node->input[0]))
1072#define DST_MIXER__IN(bit)      (*(node->input[bit + 1]))
1071#define DST_MIXER__ENABLE      DISCRETE_INPUT(0)
1072#define DST_MIXER__IN(bit)      DISCRETE_INPUT(bit + 1)
10731073
10741074static DISCRETE_STEP(dst_mixer)
10751075{
r5534r5535
12271227   context->r_node_bit_flag = 0;
12281228   for (bit = 0; bit < 8; bit++)
12291229   {
1230      r_node = discrete_find_node(disc_info, info->r_node[bit]);
1230      r_node = discrete_find_node(node->info, info->r_node[bit]);
12311231      if (r_node != NULL)
12321232      {
12331233         context->r_node[bit] = &(r_node->output[NODE_CHILD_NODE_NUM(info->r_node[bit])]);
r5534r5535
13341334 *
13351335 * Dec 2004, D Renaud.
13361336 ************************************************************************/
1337#define DST_MULTIPLEX__ENABLE      (*(node->input[0]))
1338#define DST_MULTIPLEX__ADDR         (*(node->input[1]))
1339#define DST_MULTIPLEX__INP(addr)   (*(node->input[2 + addr]))
1337#define DST_MULTIPLEX__ENABLE      DISCRETE_INPUT(0)
1338#define DST_MULTIPLEX__ADDR         DISCRETE_INPUT(1)
1339#define DST_MULTIPLEX__INP(addr)   DISCRETE_INPUT(2 + addr)
13401340
13411341static DISCRETE_STEP(dst_multiplex)
13421342{
r5534r5535
13541354      else
13551355      {
13561356         /* Bad address.  We will leave the output alone. */
1357         discrete_log(disc_info, "NODE_%02d - Address = %d. Out of bounds\n", node->node-NODE_00, addr);
1357         discrete_log(node->info, "NODE_%02d - Address = %d. Out of bounds\n", node->node-NODE_00, addr);
13581358      }
13591359   }
13601360   else
r5534r5535
13851385 *
13861386 * Complete re-write Jan 2004, D Renaud.
13871387 ************************************************************************/
1388#define DST_ONESHOT__RESET   (*(node->input[0]))
1389#define DST_ONESHOT__TRIG   (*(node->input[1]))
1390#define DST_ONESHOT__AMP   (*(node->input[2]))
1391#define DST_ONESHOT__WIDTH   (*(node->input[3]))
1392#define DST_ONESHOT__TYPE   (int)(*(node->input[4]))
1388#define DST_ONESHOT__RESET   DISCRETE_INPUT(0)
1389#define DST_ONESHOT__TRIG   DISCRETE_INPUT(1)
1390#define DST_ONESHOT__AMP   DISCRETE_INPUT(2)
1391#define DST_ONESHOT__WIDTH   DISCRETE_INPUT(3)
1392#define DST_ONESHOT__TYPE   (int)DISCRETE_INPUT(4)
13931393
13941394static DISCRETE_STEP(dst_oneshot)
13951395{
r5534r5535
14391439
14401440      if (do_count)
14411441      {
1442         context->countdown -= disc_info->sample_time;
1442         context->countdown -= node->info->sample_time;
14431443         if(context->countdown <= 0.0)
14441444         {
14451445            node->output[0]    = (DST_ONESHOT__TYPE & DISC_OUT_ACTIVE_LOW) ? DST_ONESHOT__AMP : 0;
r5534r5535
14751475 * input[5]    - Clamp value when disabled
14761476 *
14771477 ************************************************************************/
1478#define DST_RAMP__ENABLE   (*(node->input[0]))
1479#define DST_RAMP__DIR      (*(node->input[1]))
1480#define DST_RAMP__GRAD      (*(node->input[2]))
1481#define DST_RAMP__START      (*(node->input[3]))
1482#define DST_RAMP__END      (*(node->input[4]))
1483#define DST_RAMP__CLAMP      (*(node->input[5]))
1478#define DST_RAMP__ENABLE   DISCRETE_INPUT(0)
1479#define DST_RAMP__DIR      DISCRETE_INPUT(1)
1480#define DST_RAMP__GRAD      DISCRETE_INPUT(2)
1481#define DST_RAMP__START      DISCRETE_INPUT(3)
1482#define DST_RAMP__END      DISCRETE_INPUT(4)
1483#define DST_RAMP__CLAMP      DISCRETE_INPUT(5)
14841484
14851485static DISCRETE_STEP(dst_ramp)
14861486{
r5534r5535
15141514   struct dss_ramp_context *context = (struct dss_ramp_context *)node->context;
15151515
15161516   node->output[0]  = DST_RAMP__CLAMP;
1517   context->step    = DST_RAMP__GRAD / disc_info->sample_rate;
1517   context->step    = DST_RAMP__GRAD / node->info->sample_rate;
15181518   context->dir     = ((DST_RAMP__END - DST_RAMP__START) == abs(DST_RAMP__END - DST_RAMP__START));
15191519   context->last_en = 0;
15201520}
r5534r5535
15301530 * input[3]    - clock type
15311531 *
15321532 ************************************************************************/
1533#define DST_SAMPHOLD__ENABLE   (*(node->input[0]))
1534#define DST_SAMPHOLD__IN0      (*(node->input[1]))
1535#define DST_SAMPHOLD__CLOCK      (*(node->input[2]))
1536#define DST_SAMPHOLD__TYPE      (*(node->input[3]))
1533#define DST_SAMPHOLD__ENABLE   DISCRETE_INPUT(0)
1534#define DST_SAMPHOLD__IN0      DISCRETE_INPUT(1)
1535#define DST_SAMPHOLD__CLOCK      DISCRETE_INPUT(2)
1536#define DST_SAMPHOLD__TYPE      DISCRETE_INPUT(3)
15371537
15381538static DISCRETE_STEP(dst_samphold)
15391539{
r5534r5535
15601560            if (DST_SAMPHOLD__CLOCK == 0) node->output[0] = DST_SAMPHOLD__IN0;
15611561            break;
15621562         default:
1563            discrete_log(disc_info, "dst_samphold_step - Invalid clocktype passed");
1563            discrete_log(node->info, "dst_samphold_step - Invalid clocktype passed");
15641564            break;
15651565      }
15661566   }
r5534r5535
15941594 * input[3]    - input[1]
15951595 *
15961596 ************************************************************************/
1597#define DSS_SWITCH__ENABLE   (*(node->input[0]))
1598#define DSS_SWITCH__SWITCH   (*(node->input[1]))
1599#define DSS_SWITCH__IN0      (*(node->input[2]))
1600#define DSS_SWITCH__IN1      (*(node->input[3]))
1597#define DSS_SWITCH__ENABLE   DISCRETE_INPUT(0)
1598#define DSS_SWITCH__SWITCH   DISCRETE_INPUT(1)
1599#define DSS_SWITCH__IN0      DISCRETE_INPUT(2)
1600#define DSS_SWITCH__IN1      DISCRETE_INPUT(3)
16011601
16021602static DISCRETE_STEP(dst_switch)
16031603{
r5534r5535
16211621 * input[3]    - Threshold for enable
16221622 *
16231623 ************************************************************************/
1624#define DSS_ASWITCH__ENABLE      (*(node->input[0]))
1625#define DSS_ASWITCH__CTRL      (*(node->input[1]))
1626#define DSS_ASWITCH__IN         (*(node->input[2]))
1627#define DSS_ASWITCH__THRESHOLD   (*(node->input[3]))
1624#define DSS_ASWITCH__ENABLE      DISCRETE_INPUT(0)
1625#define DSS_ASWITCH__CTRL      DISCRETE_INPUT(1)
1626#define DSS_ASWITCH__IN         DISCRETE_INPUT(2)
1627#define DSS_ASWITCH__THRESHOLD   DISCRETE_INPUT(3)
16281628
16291629
16301630static DISCRETE_STEP(dst_aswitch)
r5534r5535
16511651 * input[5]    - Channel4 input value
16521652 *
16531653 ************************************************************************/
1654#define DST_TRANSFORM__IN0      (*(node->input[0]))
1655#define DST_TRANSFORM__IN1      (*(node->input[1]))
1656#define DST_TRANSFORM__IN2      (*(node->input[2]))
1657#define DST_TRANSFORM__IN3      (*(node->input[3]))
1658#define DST_TRANSFORM__IN4      (*(node->input[4]))
1654#define DST_TRANSFORM__IN0      DISCRETE_INPUT(0)
1655#define DST_TRANSFORM__IN1      DISCRETE_INPUT(1)
1656#define DST_TRANSFORM__IN2      DISCRETE_INPUT(2)
1657#define DST_TRANSFORM__IN3      DISCRETE_INPUT(3)
1658#define DST_TRANSFORM__IN4      DISCRETE_INPUT(4)
16591659
16601660#define MAX_TRANS_STACK   16
16611661
r5534r5535
17621762            top = (int)number1 ^ (int)top;
17631763            break;
17641764         default:
1765            discrete_log(disc_info, "dst_transform_step - Invalid function type/variable passed");
1765            discrete_log(node->info, "dst_transform_step - Invalid function type/variable passed");
17661766            node->output[0] = 0;
17671767            break;
17681768      }
r5534r5535
17831783 *
17841784 * Mar 2007, D Renaud.
17851785 ************************************************************************/
1786#define DST_OP_AMP__ENABLE   (*(node->input[0]))
1787#define DST_OP_AMP__INP0   (*(node->input[1]))
1788#define DST_OP_AMP__INP1   (*(node->input[2]))
1786#define DST_OP_AMP__ENABLE   DISCRETE_INPUT(0)
1787#define DST_OP_AMP__INP0   DISCRETE_INPUT(1)
1788#define DST_OP_AMP__INP1   DISCRETE_INPUT(2)
17891789
17901790static DISCRETE_STEP(dst_op_amp)
17911791{
r5534r5535
18691869      }
18701870      else
18711871         /* linear charge */
1872         context->exponent = disc_info->sample_rate * info->c;
1872         context->exponent = node->info->sample_rate * info->c;
18731873   }
18741874
1875   if (info->r3 >= 0)
1875   if (info->r3 > 0)
18761876      context->i_fixed = (info->vP - OP_AMP_NORTON_VBE) / info->r3;
1877   else
1878      context->i_fixed = 0;
18771879}
18781880
18791881
r5534r5535
18871889 *
18881890 * Mar 2007, D Renaud.
18891891 ************************************************************************/
1890#define DST_OP_AMP_1SHT__TRIGGER   (*(node->input[0]))
1892#define DST_OP_AMP_1SHT__TRIGGER   DISCRETE_INPUT(0)
18911893
18921894static DISCRETE_STEP(dst_op_amp_1sht)
18931895{
r5534r5535
19581960 *
19591961 * Mar 2004, D Renaud.
19601962 ************************************************************************/
1961#define DST_TVCA_OP_AMP__TRG0   (*(node->input[0]))
1962#define DST_TVCA_OP_AMP__TRG1   (*(node->input[1]))
1963#define DST_TVCA_OP_AMP__TRG2   (*(node->input[2]))
1964#define DST_TVCA_OP_AMP__INP0   (*(node->input[3]))
1965#define DST_TVCA_OP_AMP__INP1   (*(node->input[4]))
1963#define DST_TVCA_OP_AMP__TRG0   DISCRETE_INPUT(0)
1964#define DST_TVCA_OP_AMP__TRG1   DISCRETE_INPUT(1)
1965#define DST_TVCA_OP_AMP__TRG2   DISCRETE_INPUT(2)
1966#define DST_TVCA_OP_AMP__INP0   DISCRETE_INPUT(3)
1967#define DST_TVCA_OP_AMP__INP1   DISCRETE_INPUT(4)
19661968
19671969static DISCRETE_STEP(dst_tvca_op_amp)
19681970{
src/emu/sound/discrete.c
r5534r5535
3838#include "inptport.h"
3939#include "wavwrite.h"
4040#include "discrete.h"
41#include "eminline.h"
4142
4243
4344/*************************************
r5534r5535
5758
5859#define DISCRETE_PROFILING         (0)
5960
60
61
6261/*************************************
6362 *
6463 *  Prototypes
6564 *
6665 *************************************/
6766
68static void init_nodes(discrete_info *info, discrete_sound_block *block_list, const device_config *device);
69static void find_input_nodes(discrete_info *info, discrete_sound_block *block_list);
70static void setup_output_nodes(const device_config *device, discrete_info *info);
67static void init_nodes(discrete_info *info, linked_list_entry *block_list, const device_config *device);
68static void find_input_nodes(discrete_info *info);
7169static void setup_disc_logs(discrete_info *info);
7270static node_description *discrete_find_node(const discrete_info *info, int node);
7371static DEVICE_RESET( discrete );
72static STREAM_UPDATE( discrete_stream_update );
7473
7574
76
7775/*************************************
7876 *
7977 *  Debug logging
r5534r5535
9795   }
9896}
9997
98typedef struct _task_info task_info;
10099
100struct _task_info
101{
102   discrete_task_context *context;
103   int samples;
104};
101105
106INLINE void step_nodes_in_list(linked_list_entry **list)
107{
108   linked_list_entry *entry;
109   for (entry = *list; entry != NULL; entry = entry->next)
110   {
111      node_description *node = (node_description *) entry->ptr;
112
113      /* Now step the node */
114      if (DISCRETE_PROFILING)
115         node->run_time -= osd_profiling_ticks();
116
117      (*node->module->step)(node);
118      //bigselect(info->device, node);
119
120      if (DISCRETE_PROFILING)
121         node->run_time += osd_profiling_ticks();
122   }
123}
124
125static void *task_callback(void *param, int threadid)
126{
127   task_info *ti = (task_info *) param;
128   int samples, i;
129
130   /* set up task buffers */
131   for (i = 0; i < ti->context->numbuffered; i++)
132      ti->context->ptr[i] = &ti->context->node_buf[i][0];
133   
134   samples = ti->samples;
135   while (samples-- > 0)
136   {
137      step_nodes_in_list(&ti->context->list);
138   }
139   /* reset ptr */
140   for (i = 0; i < ti->context->numbuffered; i++)
141      ti->context->ptr[i] = &ti->context->node_buf[i][0];
142
143   free(param);
144   return NULL;
145}
146
147static DISCRETE_STEP( dso_task )
148{
149   discrete_task_context *ctx =  (discrete_task_context *) node->context;
150   int i;
151   
152   for (i = 0; i < ctx->numbuffered; i++)
153      *(ctx->ptr[i]++) = (double) DISCRETE_INPUT(i);
154}
155
156static DISCRETE_RESET( dso_task )
157{
158   /* nothing to do - just avoid being stepped */
159}
160
161static DISCRETE_STEP( dso_output )
162{
163   stream_sample_t **output = (stream_sample_t **) &node->context;
164   double val;
165
166   /* Add gain to the output and put into the buffers */
167   /* Clipping will be handled by the main sound system */
168   val = DISCRETE_INPUT(0) * DISCRETE_INPUT(1);
169   **output = val;
170   (*output)++;
171}
172
173static DISCRETE_RESET( dso_output )
174{
175   /* nothing to do - just avoid being stepped */
176}
177
178
102179/*************************************
103180 *
181 *  Add an entry to a list
182 *
183 *************************************/
184
185static void linked_list_add(discrete_info *info, linked_list_entry ***list_tail_ptr, void *ptr)
186{
187   **list_tail_ptr = auto_alloc(info->device->machine, linked_list_entry);
188   (**list_tail_ptr)->ptr = ptr;
189   (**list_tail_ptr)->next = NULL;
190   *list_tail_ptr = &((**list_tail_ptr)->next);
191}
192
193/*************************************
194 *
195 *  Count entries in a list
196 *
197 *************************************/
198
199static int linked_list_count(linked_list_entry *list)
200{
201   int cnt = 0;
202   linked_list_entry *entry;
203
204   for (entry = list; entry != NULL; entry = entry->next)
205      cnt++;
206
207   return cnt;
208}
209
210
211/*************************************
212 *
104213 *  Included simulation objects
105214 *
106215 *************************************/
r5534r5535
121230
122231static const discrete_module module_list[] =
123232{
124   { DSO_OUTPUT      ,"DSO_OUTPUT"      , 0 ,0                                      ,NULL                  ,NULL                 },
233   { DSO_OUTPUT      ,"DSO_OUTPUT"      , 0 ,0                                      ,dso_output_reset      ,dso_output_step      },
125234   { DSO_CSVLOG      ,"DSO_CSVLOG"      , 0 ,0                                      ,NULL                  ,NULL                 },
126235   { DSO_WAVELOG     ,"DSO_WAVELOG"     , 0 ,0                                      ,NULL                  ,NULL                 },
127236   { DSO_IMPORT      ,"DSO_IMPORT"      , 0 ,0                                      ,NULL                  ,NULL                 },
128237
238   /* parallel modules */
239   { DSO_TASK_START  ,"DSO_TASK_START"  , 0 ,0                                      ,NULL                  ,NULL                 },
240   { DSO_TASK_END    ,"DSO_TASK_END"    , 0 ,0                                      ,dso_task_reset        ,dso_task_step        },
241   { DSO_TASK_SYNC   ,"DSO_TASK_SYNC"   , 0 ,0                                      ,NULL                  ,NULL                 },
242
129243   /* nop */
130   { DSS_NOP         ,"DSS_NOP"         , 0 ,0                                      ,NULL                  ,NULL                },
244   { DSS_NOP         ,"DSS_NOP"         , 0 ,0                                      ,NULL                  ,NULL                },
131245
132246   /* from disc_inp.c */
133247   { DSS_ADJUSTMENT  ,"DSS_ADJUSTMENT"  , 1 ,sizeof(struct dss_adjustment_context)  ,dss_adjustment_reset  ,dss_adjustment_step  },
134248   { DSS_CONSTANT    ,"DSS_CONSTANT"    , 1 ,0                                      ,dss_constant_reset    ,NULL                 },
135   { DSS_INPUT_DATA  ,"DSS_INPUT_DATA"  , 1 ,sizeof(UINT8)                          ,dss_input_reset       ,NULL                 },
136   { DSS_INPUT_LOGIC ,"DSS_INPUT_LOGIC" , 1 ,sizeof(UINT8)                          ,dss_input_reset       ,NULL                 },
137   { DSS_INPUT_NOT   ,"DSS_INPUT_NOT"   , 1 ,sizeof(UINT8)                          ,dss_input_reset       ,NULL                 },
138   { DSS_INPUT_PULSE ,"DSS_INPUT_PULSE" , 1 ,sizeof(UINT8)                          ,dss_input_reset       ,dss_input_pulse_step },
139   { DSS_INPUT_STREAM,"DSS_INPUT_STREAM", 1 ,0                                      ,dss_input_stream_reset,dss_input_stream_step},
249   { DSS_INPUT_DATA  ,"DSS_INPUT_DATA"  , 1 ,sizeof(struct dss_input_context)       ,dss_input_reset       ,NULL                 },
250   { DSS_INPUT_LOGIC ,"DSS_INPUT_LOGIC" , 1 ,sizeof(struct dss_input_context)       ,dss_input_reset       ,NULL                 },
251   { DSS_INPUT_NOT   ,"DSS_INPUT_NOT"   , 1 ,sizeof(struct dss_input_context)       ,dss_input_reset       ,NULL                 },
252   { DSS_INPUT_PULSE ,"DSS_INPUT_PULSE" , 1 ,sizeof(struct dss_input_context)       ,dss_input_reset       ,dss_input_pulse_step },
253   { DSS_INPUT_STREAM,"DSS_INPUT_STREAM", 1 ,sizeof(struct dss_input_context)       ,dss_input_stream_reset,dss_input_stream_step},
140254
141255   /* from disc_wav.c */
142256   /* Generic modules */
143257   { DSS_COUNTER     ,"DSS_COUNTER"     , 1 ,sizeof(struct dss_counter_context)     ,dss_counter_reset     ,dss_counter_step     },
144   { DSS_LFSR_NOISE  ,"DSS_LFSR_NOISE"  , 1 ,sizeof(struct dss_lfsr_context)        ,dss_lfsr_reset        ,dss_lfsr_step        },
258   { DSS_LFSR_NOISE  ,"DSS_LFSR_NOISE"  , 2 ,sizeof(struct dss_lfsr_context)        ,dss_lfsr_reset        ,dss_lfsr_step        },
145259   { DSS_NOISE       ,"DSS_NOISE"       , 1 ,sizeof(struct dss_noise_context)       ,dss_noise_reset       ,dss_noise_step       },
146260   { DSS_NOTE        ,"DSS_NOTE"        , 1 ,sizeof(struct dss_note_context)        ,dss_note_reset        ,dss_note_step        },
147261   { DSS_SAWTOOTHWAVE,"DSS_SAWTOOTHWAVE", 1 ,sizeof(struct dss_sawtoothwave_context),dss_sawtoothwave_reset,dss_sawtoothwave_step},
r5534r5535
229343   { DSS_NULL        ,"DSS_NULL"        , 0 ,0                                      ,NULL                  ,NULL                 }
230344};
231345
232
233
234346/*************************************
235347 *
236348 *  Find a given node
r5534r5535
249361 *
250362 *************************************/
251363
252static int discrete_build_list(discrete_info *info, discrete_sound_block *intf, discrete_sound_block *out, int offset)
364static void discrete_build_list(discrete_info *info, discrete_sound_block *intf, linked_list_entry ***current)
253365{
254366   int node_count = 0;
255367
r5534r5535
258370      /* scan imported */
259371      if (intf[node_count].type == DSO_IMPORT)
260372      {
261         offset = discrete_build_list(info, (discrete_sound_block *) intf[node_count].custom, out, offset);
373         discrete_log(info, "discrete_build_list() - DISCRETE_IMPORT @ NODE_%02d", NODE_INDEX(intf[node_count].node) );
374         discrete_build_list(info, (discrete_sound_block *) intf[node_count].custom, current);
262375      }
263376      else if (intf[node_count].type == DSO_REPLACE)
264377      {
265         int i;
378         linked_list_entry *entry;
266379
267380         node_count++;
268381         if (intf[node_count].type == DSS_NULL)
269382            fatalerror("discrete_build_list: DISCRETE_REPLACE at end of node_list");
270383
271         for (i = 0; i < offset; i++)
272            if (out[i].type != NODE_SPECIAL )
273               if (out[i].node == intf[node_count].node)
384         for (entry = info->block_list; entry != NULL; entry = entry->next)
385         {
386            discrete_sound_block *block = (discrete_sound_block *) entry->ptr;
387
388            if (block->type != NODE_SPECIAL )
389               if (block->node == intf[node_count].node)
274390               {
275                  out[i] = intf[node_count];
391                  entry->ptr = (void *) &intf[node_count];
392                  discrete_log(info, "discrete_build_list() - DISCRETE_REPLACE @ NODE_%02d", NODE_INDEX(intf[node_count].node) );
276393                  break;
277394               }
395         }
278396
279         if (i >= offset)
397         if (entry == NULL)
280398            fatalerror("discrete_build_list: DISCRETE_REPLACE did not found node %d", NODE_INDEX(intf[node_count].node));
281399
282400      }
283401      else if (intf[node_count].type == DSO_DELETE)
284402      {
285         int i,p,deleted;
403         linked_list_entry *entry, *last;
286404
287         p = 0;
288         deleted = 0;
289         for (i = 0; i < offset; i++)
405         last = NULL;
406         for (entry = info->block_list; entry != NULL; last = entry, entry = entry->next)
290407         {
291            if ((out[i].node >= intf[node_count].input_node[0]) &&
292                  (out[i].node <= intf[node_count].input_node[1]))
408            discrete_sound_block *block = (discrete_sound_block *) entry->ptr;
409
410            if ((block->node >= intf[node_count].input_node[0]) &&
411                  (block->node <= intf[node_count].input_node[1]))
293412            {
294               discrete_log(info, "discrete_build_list() - DISCRETE_DELETE deleted NODE_%02d", NODE_INDEX(out[i].node) );
295               deleted++;
413               discrete_log(info, "discrete_build_list() - DISCRETE_DELETE deleted NODE_%02d", NODE_INDEX(block->node) );
414               if (last != NULL)
415                  last->next = entry->next;
416               else
417                  info->block_list = entry->next;
296418            }
297            else
298            {
299               out[p++] = out[i];
300            }
301419         }
302         offset -= deleted;
303420      }
304421      else
305         out[offset++] = intf[node_count];
422      {
423         discrete_log(info, "discrete_build_list() - adding node %d (*current %p)\n", node_count, *current);
424         linked_list_add(info, current, &intf[node_count]);
425      }
306426
307427      node_count++;
308428   }
309   out[offset] = intf[node_count];
310   return offset;
311429}
312430
313431/*************************************
314432 *
433 *  Sanity check list
434 *
435 *************************************/
436
437static void discrete_sanity_check(discrete_info *info)
438{
439   linked_list_entry *entry;
440   int node_count = 0;
441
442   discrete_log(info, "discrete_start() - Doing node list sanity check");
443   for (entry = info->block_list; entry != NULL; entry = entry->next)
444   {
445      discrete_sound_block *block = (discrete_sound_block *) entry->ptr;
446
447      /* make sure we don't have too many nodes overall */
448      if (node_count > DISCRETE_MAX_NODES)
449         fatalerror("discrete_start() - Upper limit of %d nodes exceeded, have you terminated the interface block?", DISCRETE_MAX_NODES);
450
451      /* make sure the node number is in range */
452      if (block->node < NODE_START || block->node > NODE_END)
453         fatalerror("discrete_start() - Invalid node number on node %02d descriptor", block->node);
454
455      /* make sure the node type is valid */
456      if (block->type > DSO_OUTPUT)
457         fatalerror("discrete_start() - Invalid function type on NODE_%02d", NODE_INDEX(block->node) );
458
459      /* make sure this is a main node */
460      if (NODE_CHILD_NODE_NUM(block->node) > 0)
461         fatalerror("discrete_start() - Child node number on NODE_%02d", NODE_INDEX(block->node) );
462
463      node_count++;
464   }
465   discrete_log(info, "discrete_start() - Sanity check counted %d nodes", node_count);
466
467}
468
469/*************************************
470 *
315471 *  Master discrete system start
316472 *
317473 *************************************/
318474
319475static DEVICE_START( discrete )
320476{
321   discrete_sound_block *intf;
477   linked_list_entry **intf;
322478   discrete_sound_block *intf_start = (discrete_sound_block *)device->static_config;
323479   discrete_info *info = get_safe_token(device);
324480   char name[32];
r5534r5535
337493
338494   /* create the logfile */
339495   sprintf(name, "discrete%s.log", device->tag);
340   if (DISCRETE_DEBUGLOG && !info->disclogfile)
496   if (DISCRETE_DEBUGLOG)
341497      info->disclogfile = fopen(name, "w");
342498
343499   /* Build the final block list */
344   intf = auto_alloc_array_clear(device->machine, discrete_sound_block, DISCRETE_MAX_NODES);
345   discrete_build_list(info, intf_start, intf, 0);
500   info->block_list = NULL;
501   intf = &info->block_list;
502   discrete_build_list(info, intf_start, &intf);
346503
347504   /* first pass through the nodes: sanity check, fill in the indexed_nodes, and make a total count */
348   discrete_log(info, "discrete_start() - Doing node list sanity check");
349   for (info->node_count = 0; intf[info->node_count].type != DSS_NULL; info->node_count++)
350   {
351      /* make sure we don't have too many nodes overall */
352      if (info->node_count > DISCRETE_MAX_NODES)
353         fatalerror("discrete_start() - Upper limit of %d nodes exceeded, have you terminated the interface block?", DISCRETE_MAX_NODES);
505   discrete_sanity_check(info);
354506
355      /* make sure the node number is in range */
356      if (intf[info->node_count].node < NODE_START || intf[info->node_count].node > NODE_END)
357         fatalerror("discrete_start() - Invalid node number on node %02d descriptor", info->node_count);
507   /* Start with empty lists */
508   info->node_list = NULL;
509   info->step_list = NULL;
510   info->output_list = NULL;
511   info->input_list = NULL;
358512
359      /* make sure the node type is valid */
360      if (intf[info->node_count].type > DSO_OUTPUT)
361         fatalerror("discrete_start() - Invalid function type on NODE_%02d", NODE_INDEX(intf[info->node_count].node) );
362
363      /* make sure this is a main node */
364      if (NODE_CHILD_NODE_NUM(intf[info->node_count].node) > 0)
365         fatalerror("discrete_start() - Child node number on NODE_%02d", NODE_INDEX(intf[info->node_count].node) );
366   }
367   info->node_count++;
368   discrete_log(info, "discrete_start() - Sanity check counted %d nodes", info->node_count);
369
370   /* allocate memory for the array of actual nodes */
371   info->node_list = auto_alloc_array_clear(device->machine, node_description, info->node_count);
372
373   /* allocate memory for the node execution order array */
374   info->running_order = auto_alloc_array_clear(device->machine, node_description *, info->node_count);
375
376513   /* allocate memory to hold pointers to nodes by index */
377514   info->indexed_node = auto_alloc_array_clear(device->machine, node_description *, DISCRETE_MAX_NODES);
378515
379516   /* initialize the node data */
380   init_nodes(info, intf, device);
517   init_nodes(info, info->block_list, device);
381518
382519   /* now go back and find pointers to all input nodes */
383   find_input_nodes(info, intf);
520   find_input_nodes(info);
384521
385522   /* then set up the output nodes */
386   setup_output_nodes(device, info);
523   /* initialize the stream(s) */
524   info->discrete_stream = stream_create(device,linked_list_count(info->input_list), linked_list_count(info->output_list), info->sample_rate, info, discrete_stream_update);
387525
526   /* allocate a queue */
527
528   info->queue = osd_work_queue_alloc(WORK_QUEUE_FLAG_MULTI | WORK_QUEUE_FLAG_HIGH_FREQ);
529
388530   setup_disc_logs(info);
389531}
390532
r5534r5535
401543   discrete_info *info = get_safe_token(device);
402544   int log_num;
403545
546   osd_work_queue_free(info->queue);
547
404548   if (DISCRETE_PROFILING)
405549   {
406      int nodenum;
550      int count = 0;
551      linked_list_entry *entry;
407552      osd_ticks_t total = 0;
408553      osd_ticks_t tresh;
409554
410      printf("Total Samples: %d\n", info->total_samples);
411555      /* calculate total time */
412      for (nodenum = 0; nodenum < info->node_count; nodenum++)
556      for (entry = info->step_list; entry != NULL; entry = entry->next)
413557      {
414         node_description *node = info->running_order[nodenum];
558         node_description *node = (node_description *) entry->ptr;
415559
416560         /* Now step the node */
417561         total += node->run_time;
562         count++;
418563      }
419564      /* print statistics */
420      tresh = total / info->node_count;
421      for (nodenum = 0; nodenum < info->node_count; nodenum++)
565      printf("Total Samples: %d\n", info->total_samples);
566      tresh = total / count;
567      for (entry = info->step_list; entry != NULL; entry = entry->next)
422568      {
423         node_description *node = info->running_order[nodenum];
569         node_description *node = (node_description *) entry->ptr;
424570
425571         if (node->run_time > tresh)
426            printf("%3d: %20s %8.2f %10d\n", NODE_INDEX(node->node), node->module.name, (float) node->run_time / (float) total * 100.0, ((int) node->run_time) / info->total_samples);
572            printf("%3d: %20s %8.2f %10d\n", NODE_INDEX(node->node), node->module->name, (float) node->run_time / (float) total * 100.0, ((int) node->run_time) / info->total_samples);
427573      }
428574   }
429575
r5534r5535
457603static DEVICE_RESET( discrete )
458604{
459605   discrete_info *info = get_safe_token(device);
460   int nodenum;
606   linked_list_entry *entry;
461607
462608   /* loop over all nodes */
463   for (nodenum = 0; nodenum < info->node_count; nodenum++)
609   for (entry = info->node_list; entry != 0; entry = entry->next)
464610   {
465      node_description *node = info->running_order[nodenum];
611      node_description *node = (node_description *) entry->ptr;
466612
467613      node->output[0] = 0;
468614
469615      /* if the node has a reset function, call it */
470      if (node->module.reset)
471         (*node->module.reset)(info, node);
616      if (node->module->reset)
617         (*node->module->reset)(node);
472618
473619      /* otherwise, just step it */
474      else if (node->module.step)
475         (*node->module.step)(info, node);
620      else if (node->module->step)
621         (*node->module->step)(node);
476622   }
477623}
478624
r5534r5535
562708 *
563709 *************************************/
564710
565static STREAM_UPDATE( discrete_stream_update )
711INLINE void discrete_stream_update_csv(discrete_info *info)
566712{
567   discrete_info *info = (discrete_info *)param;
568   int samplenum, nodenum, outputnum;
713   int nodenum, outputnum;
714
715   /* Dump any csv logs */
716   for (outputnum = 0; outputnum < info->num_csvlogs; outputnum++)
717   {
718      fprintf(info->disc_csv_file[outputnum], "%" I64FMT "d", ++info->sample_num);
719      for (nodenum = 0; nodenum < info->csvlog_node[outputnum]->active_inputs; nodenum++)
720      {
721         fprintf(info->disc_csv_file[outputnum], ", %f", *info->csvlog_node[outputnum]->input[nodenum]);
722      }
723      fprintf(info->disc_csv_file[outputnum], "\n");
724   }
725}
726
727INLINE void discrete_stream_update_wave(discrete_info *info)
728{
729   int outputnum;
569730   double val;
570731   INT16 wave_data_l, wave_data_r;
571732
572   /* Setup any input streams */
573   for (nodenum = 0; nodenum < info->discrete_input_streams; nodenum++)
733   /* Dump any wave logs */
734   for (outputnum = 0; outputnum < info->num_wavelogs; outputnum++)
574735   {
575      info->input_stream_data[nodenum] = inputs[nodenum];
736      /* get nodes to be logged and apply gain, then clip to 16 bit */
737      val = (*info->wavelog_node[outputnum]->input[0]) * (*info->wavelog_node[outputnum]->input[1]);
738      val = (val < -32768) ? -32768 : (val > 32767) ? 32767 : val;
739      wave_data_l = (INT16)val;
740      if (info->wavelog_node[outputnum]->active_inputs == 2)
741      {
742         /* DISCRETE_WAVELOG1 */
743         wav_add_data_16(info->disc_wav_file[outputnum], &wave_data_l, 1);
744      }
745      else
746      {
747         /* DISCRETE_WAVELOG2 */
748         val = (*info->wavelog_node[outputnum]->input[2]) * (*info->wavelog_node[outputnum]->input[3]);
749         val = (val < -32768) ? -32768 : (val > 32767) ? 32767 : val;
750         wave_data_r = (INT16)val;
751
752         wav_add_data_16lr(info->disc_wav_file[outputnum], &wave_data_l, &wave_data_r, 1);
753      }
576754   }
755}
577756
578   /* Now we must do samples iterations of the node list, one output for each step */
579   for (samplenum = 0; samplenum < samples; samplenum++)
580   {
757INLINE void discrete_stream_update_nodes(discrete_info *info)
758{
759   linked_list_entry *entry;
760
761   if (DISCRETE_PROFILING)
581762      info->total_samples++;
582      /* loop over all nodes */
583      for (nodenum = 0; nodenum < info->node_count; nodenum++)
584      {
585         node_description *node = info->running_order[nodenum];
586763
587         /* Now step the node */
588         if (DISCRETE_PROFILING)
589            node->run_time -= osd_profiling_ticks();
764   /* update task nodes */
765   for (entry = info->task_list; entry != 0; entry = entry->next)
766   {
767      discrete_task_context *task = (discrete_task_context *) entry->ptr;
768      int i;
769     
770      for (i = 0; i < task->numbuffered; i++)
771         **task->dest[i] = *task->ptr[i]++;
772   }
590773
591         if (node->module.step)
592            (*node->module.step)(info, node);
593            //bigselect(info->device, node);
774   /* loop over all nodes */
775   step_nodes_in_list(&info->step_list);
776}
594777
595         if (DISCRETE_PROFILING)
596            node->run_time += osd_profiling_ticks();
778static STREAM_UPDATE( discrete_stream_update )
779{
780   discrete_info *info = (discrete_info *)param;
781   linked_list_entry *entry;
782   int samplenum, outputnum;
597783
598      }
784   if (samples == 0)
785      return;
599786
600      /* Add gain to the output and put into the buffers */
601      /* Clipping will be handled by the main sound system */
602      for (outputnum = 0; outputnum < info->discrete_outputs; outputnum++)
603      {
604         val = (*info->output_node[outputnum]->input[0]) * (*info->output_node[outputnum]->input[1]);
605         outputs[outputnum][samplenum] = val;
606      }
787   /* Setup any output streams */
788   for (entry = info->output_list, outputnum = 0; entry != NULL; entry = entry->next, outputnum++)
789   {
790      ((node_description *) entry->ptr)->context = (void *) outputs[outputnum];
791   }
607792
608      /* Dump any csv logs */
609      for (outputnum = 0; outputnum < info->num_csvlogs; outputnum++)
610      {
611         fprintf(info->disc_csv_file[outputnum], "%" I64FMT "d", ++info->sample_num);
612         for (nodenum = 0; nodenum < info->csvlog_node[outputnum]->active_inputs; nodenum++)
613         {
614            fprintf(info->disc_csv_file[outputnum], ", %f", *info->csvlog_node[outputnum]->input[nodenum]);
615         }
616         fprintf(info->disc_csv_file[outputnum], "\n");
617      }
793   /* Setup any input streams */
794   for (entry = info->input_list; entry != NULL; entry = entry->next)
795   {
796      struct dss_input_context *context = (struct dss_input_context *) ((node_description *) entry->ptr)->context;
797      context->ptr = (void *) inputs[context->stream_in_number];
798   }
618799
619      /* Dump any wave logs */
620      for (outputnum = 0; outputnum < info->num_wavelogs; outputnum++)
621      {
622         /* get nodes to be logged and apply gain, then clip to 16 bit */
623         val = (*info->wavelog_node[outputnum]->input[0]) * (*info->wavelog_node[outputnum]->input[1]);
624         val = (val < -32768) ? -32768 : (val > 32767) ? 32767 : val;
625         wave_data_l = (INT16)val;
626         if (info->wavelog_node[outputnum]->active_inputs == 2)
627         {
628            /* DISCRETE_WAVELOG1 */
629            wav_add_data_16(info->disc_wav_file[outputnum], &wave_data_l, 1);
630         }
631         else
632         {
633            /* DISCRETE_WAVELOG2 */
634            val = (*info->wavelog_node[outputnum]->input[2]) * (*info->wavelog_node[outputnum]->input[3]);
635            val = (val < -32768) ? -32768 : (val > 32767) ? 32767 : val;
636            wave_data_r = (INT16)val;
800   for (entry = info->task_list; entry != 0; entry = entry->next)
801   {
802      task_info *ti = malloc(sizeof(task_info));
803      discrete_task_context *task = (discrete_task_context *) entry->ptr;
637804
638            wav_add_data_16lr(info->disc_wav_file[outputnum], &wave_data_l, &wave_data_r, 1);
639         }
640      }
805      /* Fire task */
806      ti->context = task;
807      ti->samples = samples;
808      osd_work_item_queue(info->queue, task_callback, (void *) ti, WORK_ITEM_FLAG_AUTO_RELEASE);
809   }
641810
642      /* advance input streams */
643      for (nodenum = 0; nodenum < info->discrete_input_streams; nodenum++)
811   /* and wait for them */
812   osd_work_queue_wait(info->queue, osd_ticks_per_second()*10);
813
814   if ((info->num_csvlogs == 0) && (info->num_wavelogs == 0))
815   {
816      /* Now we must do samples iterations of the node list, one output for each step */
817      for (samplenum = 0; samplenum < samples; samplenum++)
818         discrete_stream_update_nodes(info);
819   }
820   else
821   {
822      /* Now we must do samples iterations of the node list, one output for each step */
823      for (samplenum = 0; samplenum < samples; samplenum++)
644824      {
645         info->input_stream_data[nodenum]++;
825         discrete_stream_update_nodes(info);
826         discrete_stream_update_csv(info);
827         discrete_stream_update_wave(info);
828
646829      }
647830   }
648831
r5534r5535
656839 *
657840 *************************************/
658841
659static void init_nodes(discrete_info *info, discrete_sound_block *block_list, const device_config *device)
842
843static void init_nodes(discrete_info *info, linked_list_entry *block_list, const device_config *device)
660844{
661   int nodenum;
845   linked_list_entry   **cur_task_node = NULL;
846   linked_list_entry   *entry;
847   discrete_task_context *task = NULL;
848   /* list tail pointers */
849   linked_list_entry   **step_list = &info->step_list;
850   linked_list_entry   **node_list = &info->node_list;
851   linked_list_entry   **task_list = &info->task_list;
852   linked_list_entry   **output_list = &info->output_list;
853   linked_list_entry   **input_list = &info->input_list;
662854
663   /* start with no outputs or input streams */
664   info->discrete_outputs = 0;
665   info->discrete_input_streams = 0;
666
667855   /* loop over all nodes */
668   for (nodenum = 0; nodenum < info->node_count; nodenum++)
856   for (entry = block_list; entry != NULL; entry = entry->next)
669857   {
670      discrete_sound_block *block = &block_list[nodenum];
671      node_description *node = &info->node_list[nodenum];
858      discrete_sound_block *block = (discrete_sound_block *) entry->ptr;
859      node_description *node = auto_alloc_clear(info->device->machine, node_description);
672860      int inputnum, modulenum;
673861
674      /* our running order just follows the order specified */
675      info->running_order[nodenum] = node;
862      /* find the requested module */
863      for (modulenum = 0; module_list[modulenum].type != DSS_NULL; modulenum++)
864         if (module_list[modulenum].type == block->type)
865            break;
866      if (module_list[modulenum].type != block->type)
867         fatalerror("init_nodes() - Unable to find discrete module type %d for NODE_%02d", block->type, NODE_INDEX(block->node));
676868
869      /* static inits */
870      node->context = NULL;
871      node->info = info;
872      node->node = block->node;
873      node->module = &module_list[modulenum];
874      node->output[0] = 0.0;
875      node->block = block;
876      node->custom = block->custom;
877      node->active_inputs = block->active_inputs;
878
677879      /* keep track of special nodes */
678880      if (block->node == NODE_SPECIAL)
679881      {
r5534r5535
681883         {
682884            /* Output Node */
683885            case DSO_OUTPUT:
684               if (info->discrete_outputs == DISCRETE_MAX_OUTPUTS)
685                  fatalerror("init_nodes() - There can not be more then %d output nodes", DISCRETE_MAX_OUTPUTS);
686               info->output_node[info->discrete_outputs++] = node;
886               linked_list_add(info, &output_list, node);
687887               break;
688888
689889            /* CSVlog Node for debugging */
r5534r5535
700900               info->wavelog_node[info->num_wavelogs++] = node;
701901               break;
702902
903            /* Task processing */
904            case DSO_TASK_START:
905               if (cur_task_node != NULL)
906                  fatalerror("init_nodes() - Nested DISCRETE_START_TASK.");
907               task = auto_alloc_clear(info->device->machine, discrete_task_context);
908               linked_list_add(info, &task_list, task);
909               cur_task_node = &task->list;
910               break;
911
912            case DSO_TASK_END:
913               if (cur_task_node == NULL)
914                  fatalerror("init_nodes() - NO DISCRETE_START_TASK.");
915               task->numbuffered = node->active_inputs;
916               {
917                  int i;
918                  for (i = 0; i < task->numbuffered; i++)
919                     task->dest[i] = (double **) &node->input[i];
920               }
921               node->context = task;
922               task = NULL;
923               break;
924
703925            default:
704926               fatalerror("init_nodes() - Failed, trying to create unknown special discrete node.");
705927         }
r5534r5535
713935         info->indexed_node[NODE_INDEX(block->node)] = node;
714936      }
715937
716      /* find the requested module */
717      for (modulenum = 0; module_list[modulenum].type != DSS_NULL; modulenum++)
718         if (module_list[modulenum].type == block->type)
719            break;
720      if (module_list[modulenum].type != block->type)
721         fatalerror("init_nodes() - Unable to find discrete module type %d for NODE_%02d", block->type, NODE_INDEX(block->node));
722
723      /* static inits */
724      node->node = block->node;
725      node->module = module_list[modulenum];
726      node->output[0] = 0.0;
727      node->block = block;
728
729      node->active_inputs = block->active_inputs;
730938      for (inputnum = 0; inputnum < DISCRETE_MAX_INPUTS; inputnum++)
731939      {
732940         node->input[inputnum] = &(block->initial[inputnum]);
733941      }
734942
735      node->context = NULL;
736      node->name = block->name;
737      node->custom = block->custom;
738
739943      /* setup module if custom */
740944      if (block->type == DST_CUSTOM)
741945      {
742946         const discrete_custom_info *custom = (const discrete_custom_info *)node->custom;
743         node->module.reset = custom->reset;
744         node->module.step = custom->step;
745         node->module.contextsize = custom->contextsize;
947         node->module = &custom->module;
746948         node->custom = custom->custom;
747949      }
748950
749951      /* allocate memory if necessary */
750      if (node->module.contextsize)
751         node->context = auto_alloc_array_clear(device->machine, UINT8, node->module.contextsize);
952      if (node->module->contextsize)
953         node->context = auto_alloc_array_clear(device->machine, UINT8, node->module->contextsize);
752954
753955      /* if we are an stream input node, track that */
754956      if (block->type == DSS_INPUT_STREAM)
755957      {
756         if (info->discrete_input_streams == DISCRETE_MAX_OUTPUTS)
757            fatalerror("init_nodes() - There can not be more then %d input stream nodes", DISCRETE_MAX_OUTPUTS);
758         /* we will use the node's context pointer to point to the input stream data */
759         //node->context = &info->input_stream_data[info->discrete_input_streams++];
760         node->context = NULL;
761         info->discrete_input_streams++;
958         linked_list_add(info, &input_list, node);
762959      }
763960
961      /* add to node list */
962      linked_list_add(info, &node_list, node);
963
964      /* our running order just follows the order specified */
965      /* does the node step ? */
966      if (node->module->step != NULL)
967      {
968         /* do we belong to a task? */
969         if (cur_task_node == NULL)
970            linked_list_add(info, &step_list, node);
971         else
972            linked_list_add(info, &cur_task_node, node);
973      }
974
975      if (block->type == DSO_TASK_END)
976      {
977         cur_task_node = NULL;
978      }
979
764980      /* and register save state */
765      state_save_register_device_item_array(device, nodenum, node->output);
981      if (node->node != NODE_SPECIAL)
982         state_save_register_device_item_array(device, node->node, node->output);
766983   }
767984
768985   /* if no outputs, give an error */
769   if (info->discrete_outputs == 0)
986   if (linked_list_count(info->output_list) == 0)
770987      fatalerror("init_nodes() - Couldn't find an output node");
771988}
772989
r5534r5535
778995 *
779996 *************************************/
780997
781static void find_input_nodes(discrete_info *info, discrete_sound_block *block_list)
998static void find_input_nodes(discrete_info *info)
782999{
783   int nodenum, inputnum;
1000   int inputnum;
1001   linked_list_entry *entry;
7841002
7851003   /* loop over all nodes */
786   for (nodenum = 0; nodenum < info->node_count; nodenum++)
1004   for (entry = info->node_list; entry != NULL; entry = entry->next)
7871005   {
788      node_description *node = &info->node_list[nodenum];
789      discrete_sound_block *block = &block_list[nodenum];
1006      node_description *node = (node_description *) entry->ptr;
1007      const discrete_sound_block *block = node->block;
7901008
7911009      /* loop over all active inputs */
7921010      for (inputnum = 0; inputnum < node->active_inputs; inputnum++)
r5534r5535
8001018            if (!node_ref)
8011019               fatalerror("discrete_start - NODE_%02d referenced a non existent node NODE_%02d", NODE_INDEX(node->node), NODE_INDEX(inputnode));
8021020
803            if (NODE_CHILD_NODE_NUM(inputnode) >= node_ref->module.num_output)
1021            if (NODE_CHILD_NODE_NUM(inputnode) >= node_ref->module->num_output)
8041022               fatalerror("discrete_start - NODE_%02d referenced non existent output %d on node NODE_%02d", NODE_INDEX(node->node), NODE_CHILD_NODE_NUM(inputnode), NODE_INDEX(inputnode));
8051023
8061024            node->input[inputnum] = &(node_ref->output[NODE_CHILD_NODE_NUM(inputnode)]);   /* Link referenced node out to input */
r5534r5535
8211039}
8221040
8231041
824
8251042/*************************************
8261043 *
827 *  Set up the output nodes
828 *
829 *************************************/
830
831static void setup_output_nodes(const device_config *device, discrete_info *info)
832{
833   /* initialize the stream(s) */
834   info->discrete_stream = stream_create(device, info->discrete_input_streams, info->discrete_outputs, info->sample_rate, info, discrete_stream_update);
835}
836
837
838
839/*************************************
840 *
8411044 *  Set up the logs
8421045 *
8431046 *************************************/
src/emu/sound/discrete.h
r5534r5535
287287 * DISCRETE_OP_AMP_FILTER(NODE,ENAB,INP0,INP1,TYPE,INFO)
288288 * DISCRETE_RCDISC(NODE,ENAB,IN0,RVAL,CVAL)
289289 * DISCRETE_RCDISC2(NODE,SWITCH,INP0,RVAL0,INP1,RVAL1,CVAL)
290 * DISCRETE_RCDISC3(NODE,ENAB,INP0,RVAL0,RVAL1,CVAL)
290 * DISCRETE_RCDISC3(NODE,ENAB,INP0,RVAL0,RVAL1,CVAL, DJV)
291291 * DISCRETE_RCDISC4(NODE,ENAB,INP0,RVAL0,RVAL1,RVAL2,CVAL,VP,TYPE)
292292 * DISCRETE_RCDISC5(NODE,ENAB,IN0,RVAL,CVAL)
293293 * DISCRETE_RCINTEGRATE(NODE,INP0,RVAL0,RVAL1,RVAL2,CVAL,vP,TYPE)
r5534r5535
438438 * Note: The discrete system is floating point based.  So when routing a stream
439439 *       set it's gain to 100% and then use DISCRETE_INPUTX_STREAM to adjust
440440 *       it if needed.
441 *       If you need to access a stream from a discrete task, the stream node
442 *       must be part of that task. If a given stream is used in two tasks or
443 *       a task and the main task, you must declare two stream nodes acccessing the
444 *       same stream input NUM.
441445 *
442 * EXAMPLES: see
446 * EXAMPLES: see scramble, frogger
443447 *
444448 ***********************************************************************
445449 =======================================================================
r5534r5535
22492253 *  vRef >-----------------------'  |/
22502254 *
22512255 *          --------------------------------------------------
2256  *
2257 *     DISC_OP_AMP_FILTER_IS_LOW_PASS_1M
2258 *          First Order Low Pass Filter
22522259 *
2260 *                              c1
2261 *                      .-------||---------.
2262 *                      |                  |
2263 *          r1          |       rF         |
2264 *  IN0 >--ZZZZ--.      +------ZZZZ--------+
2265 *               |      |                  |
2266 *          r2   |      |           |\     |
2267 *  VP  >--ZZZZ--+------+--------+  | \    |
2268 *               |               '--|- \   |
2269 *          r3   |                  |   >--+----------> Netlist Node
2270 *  VN  >--ZZZZ--'               .--|+ /
2271 *                               |  | /
2272 *  IN1 >------------------------'  |/
2273 *
2274 *          --------------------------------------------------
2275 *
22532276 *     DISC_OP_AMP_FILTER_IS_HIGH_PASS_1
22542277 *          First Order High Pass Filter
22552278 *
r5534r5535
24822505 *                        |                 |
24832506 *    ENAB       -0------>|                 |
24842507 *                        |    diode  R2    |
2485 *    INPUT1     -1------>| -+-|<|--ZZZZ-+- |---->   Netlist node
2508 *    JV         -5------>| -+-|>|--ZZZZ-+- |---->   Netlist node (JV < 0)
2509 *                        |                 |
2510 *                        |    diode  R2    |
2511 *    INPUT1     -1------>| -+-|<|--ZZZZ-+- |---->   Netlist node (JV > 0)
24862512 *                        |  |           |  |
24872513 *    RVAL1      -2------>|  '-ZZZZ-+----'  |
24882514 *                        |     R1  |       |
r5534r5535
24992525 *                      input node (or value),
25002526 *                      R1 resistor value in OHMS,
25012527 *                      R2 resistor value in OHMS,
2502 *                      capacitor value in FARADS)
2528 *                      capacitor value in FARADS,
2529 *                      diode junction voltage)
25032530 *
2531 * The polarity of the diode junction voltage determines the polarity of the diode.
2532 *
25042533 *  Example config line
25052534 *
2506 *     DISCRETE_RCDISC3(NODE_11,NODE_10,10,100,220,CAP_U(1))
2535 *     DISCRETE_RCDISC3(NODE_11,NODE_10,10,100,220,CAP_U(1), 0.5)
25072536 *
25082537 *  When enabled by NODE_10, C charges from 10v as indicated by RC
25092538 *  of 100R & 1uF.
25102539 *
2511 * EXAMPLES: see Tank8
2540 * EXAMPLES: see Tank8, bzone
25122541 *
25132542 ***********************************************************************
25142543 *
r5534r5535
32033232 *     DISCRETE_CUSTOMx(name of node,
32043233 *                      input 0 node or static value, ...)
32053234 *
3206 *     discrete_custom_info = {reset, step, contextsize, custom}
3207 *                             reset  = address called to reset a node after creation or system reset
3208 *                             step   = address called to execute one time delta of output update
3209 *                             contextsize = size of context to create
3235 *     discrete_custom_info = {discrete_module, custom}
3236 *                             discrete_module  = discrete module definition
32103237 *                             custom = address of specific initialization data
32113238 *
3212 * EXAMPLES: see Donkey Kong
3239 * In most case, you should be able to use
32133240 *
3241 *     discrete_custom_info = {DISCRETE_CUSTOM_MODULE(basename, context type), custom}
3242 *
3243 * if you have used DISCRETE_STEP(basename) and DISCRETE_RESET(basename) to define
3244 * the step/reset procedures.
3245 *
3246 * EXAMPLES: see Donkey Kong, Mario Bros.
3247 *
32143248 ***********************************************************************
32153249 =======================================================================
32163250 * Debugging modules.
r5534r5535
33043338 *************************************/
33053339
33063340/* calculate charge exponent using discrete sample time */
3307#define RC_CHARGE_EXP(rc)            (1.0 - exp(disc_info->neg_sample_time / (rc)))
3341#define RC_CHARGE_EXP(rc)            (1.0 - exp(node->info->neg_sample_time / (rc)))
33083342/* calculate charge exponent using given sample time */
33093343#define RC_CHARGE_EXP_DT(rc, dt)      (1.0 - exp(-(dt) / (rc)))
33103344#define RC_CHARGE_NEG_EXP_DT(rc, dt)   (1.0 - exp((dt) / (rc)))
33113345
33123346/* calculate discharge exponent using discrete sample time */
3313#define RC_DISCHARGE_EXP(rc)         (exp(disc_info->neg_sample_time / (rc)))
3347#define RC_DISCHARGE_EXP(rc)         (exp(node->info->neg_sample_time / (rc)))
33143348/* calculate discharge exponent using given sample time */
33153349#define RC_DISCHARGE_EXP_DT(rc, dt)      (exp(-(dt) / (rc)))
33163350#define RC_DISCHARGE_NEG_EXP_DT(rc, dt)   (exp((dt) / (rc)))
r5534r5535
33243358#define DISCRETE_STEP_NAME( _func )  _func ## _step
33253359#define DISCRETE_RESET_NAME( _func ) _func ## _reset
33263360
3327#define DISCRETE_STEP(_func) void DISCRETE_STEP_NAME(_func) (const discrete_info *disc_info, node_description *node)
3328#define DISCRETE_RESET(_func) void DISCRETE_RESET_NAME(_func) (const discrete_info *disc_info, node_description *node)
3361#define DISCRETE_STEP(_func) void DISCRETE_STEP_NAME(_func) (node_description *node)
3362#define DISCRETE_RESET(_func) void DISCRETE_RESET_NAME(_func) (node_description *node)
33293363
3330#define DISCRETE_STEP_CALL(_func) DISCRETE_STEP_NAME(_func) (disc_info, node)
3331#define DISCRETE_RESET_CALL(_func) DISCRETE_RESET_NAME(_func) (disc_info, node)
3364#define DISCRETE_STEP_CALL(_func) DISCRETE_STEP_NAME(_func) (node)
3365#define DISCRETE_RESET_CALL(_func) DISCRETE_RESET_NAME(_func) (node)
33323366
3333#if 0
3334#define DISCRETE_STEP(_func) void DISCRETE_STEP_NAME(_func) (const device_config *device, node_description *node)
3335#define DISCRETE_RESET(_func) void DISCRETE_RESET_NAME(_func) (const device_config *device, node_description *node)
3367#define DISCRETE_CUSTOM_MODULE(_basename, _context_type) \
3368   { DST_CUSTOM, "CUSTOM", 1, sizeof(_context_type), DISCRETE_RESET_NAME(_basename), DISCRETE_STEP_NAME(_basename) }
33363369
3337#define DISCRETE_STEP_CALL(_func) DISCRETE_STEP_NAME(_func) (device, node)
3338#define DISCRETE_RESET_CALL(_func) DISCRETE_RESET_NAME(_func) (device, node)
3339#endif
3370#define DISCRETE_INPUT(_num)   (*(node->input[_num]))
33403371
33413372/*************************************
33423373 *
r5534r5535
33463377
33473378#define DISCRETE_MAX_NODES            300
33483379#define DISCRETE_MAX_INPUTS            10
3349#define DISCRETE_MAX_OUTPUTS         16
33503380#define DISCRETE_MAX_WAVELOGS         10
33513381#define DISCRETE_MAX_CSVLOGS         10
3352#define DISCRETE_MAX_NODE_OUTPUTS       8
3382#define DISCRETE_MAX_OUTPUTS          8
33533383
33543384
33553385/*************************************
r5534r5535
34603490#define DISC_OP_AMP_FILTER_IS_BAND_PASS_1M   0x30
34613491#define DISC_OP_AMP_FILTER_IS_HIGH_PASS_0   0x40
34623492#define DISC_OP_AMP_FILTER_IS_BAND_PASS_0   0x50
3493#define DISC_OP_AMP_FILTER_IS_LOW_PASS_1M   0x60
34633494
34643495#define DISC_OP_AMP_FILTER_TYPE_MASK      (0xf0 | DISC_OP_AMP_IS_NORTON)   // Used only internally.
34653496
r5534r5535
35853616   const char *   name;
35863617   int            num_output;            /* Total number of output nodes, i.e. Master node + 1 */
35873618   size_t         contextsize;
3588   void (*reset)(const discrete_info *disc_info, node_description *node);   /* Called to reset a node after creation or system reset */
3589   void (*step)(const discrete_info *disc_info, node_description *node);   /* Called to execute one time delta of output update */
3619   void (*reset)(node_description *node);   /* Called to reset a node after creation or system reset */
3620   void (*step)(node_description *node);   /* Called to execute one time delta of output update */
35903621};
35913622
35923623
r5534r5535
35993630struct _node_description
36003631{
36013632   int            node;                        /* The node's index number in the node list */
3602   double         output[DISCRETE_MAX_NODE_OUTPUTS];   /* The node's last output value */
3633   double         output[DISCRETE_MAX_OUTPUTS];      /* The node's last output value */
36033634
36043635   int            active_inputs;                  /* Number of active inputs on this node type */
36053636   int            input_is_node;                  /* Bit Flags.  1 in bit location means input_is_node */
36063637   const double *   input[DISCRETE_MAX_INPUTS];         /* Addresses of Input values */
36073638
3608   discrete_module module;                        /* Copy of the node's module info */
3609   const discrete_sound_block *block;               /* Points to the node's setup block. */
36103639   void *         context;                     /* Contextual information specific to this node type */
3611   const char *   name;                        /* Text name string for identification/debug */
36123640   const void *   custom;                        /* Custom function specific initialisation data */
3641
3642   const discrete_module *module;                  /* Node's module info */
3643   const discrete_sound_block *block;               /* Points to the node's setup block. */
3644   const discrete_info *info;                     /* Points to the parent */
3645
36133646   osd_ticks_t      run_time;
36143647};
36153648
r5534r5535
36243657 *
36253658 *************************************/
36263659
3660typedef struct _linked_list_entry   linked_list_entry;
3661struct _linked_list_entry
3662{
3663   void *ptr;
3664   linked_list_entry *next;
3665};
3666
3667typedef struct _discrete_task_context discrete_task_context;
3668struct _discrete_task_context
3669{
3670   linked_list_entry *list;
3671
3672   int numbuffered;
3673   double *ptr[5];
3674   double node_buf[5][2048];
3675   double **dest[5];
3676};
3677
36273678struct _discrete_info
36283679{
36293680   const device_config *device;
r5534r5535
36343685   double   neg_sample_time;
36353686
36363687   /* internal node tracking */
3637   int node_count;
3638   node_description **running_order;
36393688   node_description **indexed_node;
3640   node_description *node_list;
36413689
3690   /* list of all nodes */
3691   linked_list_entry    *node_list;      /* node_description * */
3692
3693   /* list of nodes which step */
3694   linked_list_entry    *step_list;      /* node_description * */
3695
3696   /* list of discrete blocks after prescan (IMPORT, DELETE, REPLACE) */
3697   linked_list_entry    *block_list;      /* discrete_sound_block * */
3698
3699   /* tasks */
3700   linked_list_entry    *task_list;      /* discrete_task_context * */
3701
36423702   /* the input streams */
3643   int discrete_input_streams;
3644   stream_sample_t *input_stream_data[DISCRETE_MAX_OUTPUTS];
3703   linked_list_entry     *input_list;
36453704
36463705   /* output node tracking */
3647   int discrete_outputs;
3648   node_description *output_node[DISCRETE_MAX_OUTPUTS];
3706   linked_list_entry     *output_list;
36493707
36503708   /* the output stream */
36513709   sound_stream *discrete_stream;
r5534r5535
36643722   wav_file *disc_wav_file[DISCRETE_MAX_WAVELOGS];
36653723   node_description *wavelog_node[DISCRETE_MAX_WAVELOGS];
36663724
3725   /* parallel tasks */
3726
3727   osd_work_queue *queue;
3728
36673729   /* profiling */
36683730   int total_samples;
36693731};
r5534r5535
39273989typedef struct _discrete_custom_info discrete_custom_info;
39283990struct _discrete_custom_info
39293991{
3930   void (*reset)(const discrete_info *disc_info, node_description *node);   /* Called to reset a node after creation or system reset */
3931   void (*step)(const discrete_info *disc_info, node_description *node);   /* Called to execute one time delta of output update */
3932   size_t contextsize;
3992   const discrete_module module;
39333993   const void *custom;                  /* Custom function specific initialisation data */
39343994};
39353995
r5534r5535
39674027 *
39684028 *************************************/
39694029
3970#define NODE0_DEF(_x) NODE_ ## 0 ## _x = (0x40000000 + (_x) * DISCRETE_MAX_NODE_OUTPUTS), \
4030#define NODE0_DEF(_x) NODE_ ## 0 ## _x = (0x40000000 + (_x) * DISCRETE_MAX_OUTPUTS), \
39714031   NODE_ ## 0 ## _x ## _01, NODE_ ## 0 ## _x ## _02, NODE_ ## 0 ## _x ## _03, NODE_ ## 0 ## _x ## _04, \
39724032   NODE_ ## 0 ## _x ## _05, NODE_ ## 0 ## _x ## _06, NODE_ ## 0 ## _x ## _07
3973#define NODE_DEF(_x) NODE_ ## _x = (0x40000000 + (_x) * DISCRETE_MAX_NODE_OUTPUTS), \
4033#define NODE_DEF(_x) NODE_ ## _x = (0x40000000 + (_x) * DISCRETE_MAX_OUTPUTS), \
39744034   NODE_ ## _x ## _01, NODE_ ## _x ## _02, NODE_ ## _x ## _03, NODE_ ## _x ## _04, \
39754035   NODE_ ## _x ## _05, NODE_ ## _x ## _06, NODE_ ## _x ## _07
39764036
r5534r5535
40094069
40104070/* Some Pre-defined nodes for convenience */
40114071
4012#define NODE(_x)   (NODE_00 + (_x) * DISCRETE_MAX_NODE_OUTPUTS)
4072#define NODE(_x)   (NODE_00 + (_x) * DISCRETE_MAX_OUTPUTS)
40134073#define NODE_SUB(_x, _y) (NODE(_x) + (_y))
40144074
4015#if DISCRETE_MAX_NODE_OUTPUTS == 8
4075#if DISCRETE_MAX_OUTPUTS == 8
40164076#define NODE_CHILD_NODE_NUM(_x)      ((int)(_x) & 7)
40174077#define NODE_DEFAULT_NODE(_x)      ((int)(_x) & ~7)
40184078#define NODE_INDEX(_x)            (((int)(_x) - NODE_START)>>3)
40194079#else
4020#error "DISCRETE_MAX_NODE_OUTPUTS != 8"
4080#error "DISCRETE_MAX_OUTPUTS != 8"
40214081#endif
40224082
40234083#define NODE_RELATIVE(_x, _y) (NODE(NODE_INDEX(_x) + (_y)))
r5534r5535
40284088#define NODE_START   NODE_00
40294089#define NODE_END   NODE_SPECIAL
40304090
4091#define IS_VALUE_A_NODE(val)   (((val) > NODE_START) && ((val) <= NODE_END))
40314092
40324093
40334094/*************************************
r5534r5535
41514212   DSO_CSVLOG,         /* Dump nodes as csv file */
41524213   DSO_WAVELOG,      /* Dump nodes as wav file */
41534214
4215   /* Parallel execution */
4216   DSO_TASK_START,   /* start of parallel task */
4217   DSO_TASK_END,   /* end of parallel task */
4218   DSO_TASK_SYNC,   /* wait for all parallel tasks to finish */
4219
41544220   /* Output Node -- this must be the last entry in this enum! */
41554221   DSO_OUTPUT,         /* The final output node */
41564222
r5534r5535
42924358#define DISCRETE_OP_AMP_FILTER(NODE,ENAB,INP0,INP1,TYPE,INFO)           { NODE, DST_OP_AMP_FILT , 4, { ENAB,INP0,INP1,NODE_NC }, { ENAB,INP0,INP1,TYPE }, INFO, "DISCRETE_OP_AMP_FILTER" },
42934359#define DISCRETE_RCDISC(NODE,ENAB,INP0,RVAL,CVAL)                       { NODE, DST_RCDISC      , 4, { ENAB,INP0,NODE_NC,NODE_NC }, { ENAB,INP0,RVAL,CVAL }, NULL, "DISCRETE_RCDISC" },
42944360#define DISCRETE_RCDISC2(NODE,SWITCH,INP0,RVAL0,INP1,RVAL1,CVAL)        { NODE, DST_RCDISC2     , 6, { SWITCH,INP0,NODE_NC,INP1,NODE_NC,NODE_NC }, { SWITCH,INP0,RVAL0,INP1,RVAL1,CVAL }, NULL, "DISCRETE_RCDISC2" },
4295#define DISCRETE_RCDISC3(NODE,ENAB,INP0,RVAL0,RVAL1,CVAL)               { NODE, DST_RCDISC3     , 5, { ENAB,INP0,NODE_NC,NODE_NC,NODE_NC }, { ENAB,INP0,RVAL0,RVAL1,CVAL }, NULL, "DISCRETE_RCDISC3" },
4361#define DISCRETE_RCDISC3(NODE,ENAB,INP0,RVAL0,RVAL1,CVAL,DJV)           { NODE, DST_RCDISC3     , 6, { ENAB,INP0,NODE_NC,NODE_NC,NODE_NC,NODE_NC }, { ENAB,INP0,RVAL0,RVAL1,CVAL,DJV }, NULL, "DISCRETE_RCDISC3" },
42964362#define DISCRETE_RCDISC4(NODE,ENAB,INP0,RVAL0,RVAL1,RVAL2,CVAL,VP,TYPE) { NODE, DST_RCDISC4     , 8, { ENAB,INP0,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC }, { ENAB,INP0,RVAL0,RVAL1,RVAL2,CVAL,VP,TYPE }, NULL, "DISCRETE_RCDISC4" },
42974363#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" },
42984364#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" },
r5534r5535
43304396#define DISCRETE_NOP(NODE)                                              { NODE, DSS_NOP         , 0, { 0 }, { 0 }, NULL, "DISCRETE_NOP" },
43314397
43324398/* logging */
4333#define DISCRETE_CSVLOG1(NODE1)                                    { NODE_SPECIAL, DSO_CSVLOG   , 1, { NODE1 }, { NODE1 }, NULL, "DISCRETE_CSVLOG1" },
4334#define DISCRETE_CSVLOG2(NODE1,NODE2)                              { NODE_SPECIAL, DSO_CSVLOG   , 2, { NODE1,NODE2 }, { NODE1,NODE2 }, NULL, "DISCRETE_CSVLOG2" },
4335#define DISCRETE_CSVLOG3(NODE1,NODE2,NODE3)                        { NODE_SPECIAL, DSO_CSVLOG   , 3, { NODE1,NODE2,NODE3 }, { NODE1,NODE2,NODE3 }, NULL, "DISCRETE_CSVLOG3" },
4336#define DISCRETE_CSVLOG4(NODE1,NODE2,NODE3,NODE4)                  { NODE_SPECIAL, DSO_CSVLOG   , 4, { NODE1,NODE2,NODE3,NODE4 }, { NODE1,NODE2,NODE3,NODE4 }, NULL, "DISCRETE_CSVLOG4" },
4337#define DISCRETE_CSVLOG5(NODE1,NODE2,NODE3,NODE4,NODE5)            { NODE_SPECIAL, DSO_CSVLOG   , 5, { NODE1,NODE2,NODE3,NODE4,NODE5 }, { NODE1,NODE2,NODE3,NODE4,NODE5 }, NULL, "DISCRETE_CSVLOG5" },
4338#define DISCRETE_WAVELOG1(NODE1,GAIN1)                             { NODE_SPECIAL, DSO_WAVELOG  , 2, { NODE1,NODE_NC }, { NODE1,GAIN1 }, NULL, "DISCRETE_WAVELOG1" },
4339#define DISCRETE_WAVELOG2(NODE1,GAIN1,NODE2,GAIN2)                 { NODE_SPECIAL, DSO_WAVELOG  , 4, { NODE1,NODE_NC,NODE2,NODE_NC }, { NODE1,GAIN1,NODE2,GAIN2 }, NULL, "DISCRETE_WAVELOG2" },
4399#define DISCRETE_CSVLOG1(NODE1)                                         { NODE_SPECIAL, DSO_CSVLOG   , 1, { NODE1 }, { NODE1 }, NULL, "DISCRETE_CSVLOG1" },
4400#define DISCRETE_CSVLOG2(NODE1,NODE2)                                   { NODE_SPECIAL, DSO_CSVLOG   , 2, { NODE1,NODE2 }, { NODE1,NODE2 }, NULL, "DISCRETE_CSVLOG2" },
4401#define DISCRETE_CSVLOG3(NODE1,NODE2,NODE3)                             { NODE_SPECIAL, DSO_CSVLOG   , 3, { NODE1,NODE2,NODE3 }, { NODE1,NODE2,NODE3 }, NULL, "DISCRETE_CSVLOG3" },
4402#define DISCRETE_CSVLOG4(NODE1,NODE2,NODE3,NODE4)                       { NODE_SPECIAL, DSO_CSVLOG   , 4, { NODE1,NODE2,NODE3,NODE4 }, { NODE1,NODE2,NODE3,NODE4 }, NULL, "DISCRETE_CSVLOG4" },
4403#define DISCRETE_CSVLOG5(NODE1,NODE2,NODE3,NODE4,NODE5)                 { NODE_SPECIAL, DSO_CSVLOG   , 5, { NODE1,NODE2,NODE3,NODE4,NODE5 }, { NODE1,NODE2,NODE3,NODE4,NODE5 }, NULL, "DISCRETE_CSVLOG5" },
4404#define DISCRETE_WAVELOG1(NODE1,GAIN1)                                  { NODE_SPECIAL, DSO_WAVELOG  , 2, { NODE1,NODE_NC }, { NODE1,GAIN1 }, NULL, "DISCRETE_WAVELOG1" },
4405#define DISCRETE_WAVELOG2(NODE1,GAIN1,NODE2,GAIN2)                      { NODE_SPECIAL, DSO_WAVELOG  , 4, { NODE1,NODE_NC,NODE2,NODE_NC }, { NODE1,GAIN1,NODE2,GAIN2 }, NULL, "DISCRETE_WAVELOG2" },
43404406
43414407/* import */
4342#define DISCRETE_IMPORT(INFO)                                      { NODE_SPECIAL, DSO_IMPORT   , 0, { 0 }, { 0 }, &(INFO##_discrete_interface), "DISCRETE_IMPORT" },
4343#define DISCRETE_DELETE(NODE_FROM, NODE_TO)                        { NODE_SPECIAL, DSO_DELETE   , 2, { NODE_FROM, NODE_TO }, { NODE_FROM, NODE_TO }, NULL, "DISCRETE_DELETE" },
4344#define DISCRETE_REPLACE                                      { NODE_SPECIAL, DSO_REPLACE  , 0, { 0 }, { 0 }, NULL, "DISCRETE_REPLACE" },
4408#define DISCRETE_IMPORT(INFO)                                           { NODE_SPECIAL, DSO_IMPORT   , 0, { 0 }, { 0 }, &(INFO##_discrete_interface), "DISCRETE_IMPORT" },
4409#define DISCRETE_DELETE(NODE_FROM, NODE_TO)                             { NODE_SPECIAL, DSO_DELETE   , 2, { NODE_FROM, NODE_TO }, { NODE_FROM, NODE_TO }, NULL, "DISCRETE_DELETE" },
4410#define DISCRETE_REPLACE                                           { NODE_SPECIAL, DSO_REPLACE  , 0, { 0 }, { 0 }, NULL, "DISCRETE_REPLACE" },
43454411
4412/* parallel tasks */
43464413
4414#define DISCRETE_TASK_START()                                           { NODE_SPECIAL, DSO_TASK_START, 0, { 0 }, { 0 }, NULL, "DISCRETE_TASK_START" },
4415#define DISCRETE_TASK_END(BNODE1)                                       { NODE_SPECIAL, DSO_TASK_END , 1, { BNODE1 }, { BNODE1 }, NULL, "DISCRETE_TASK_END" },
4416#define DISCRETE_TASK_END2(BNODE1,BNODE2)                               { NODE_SPECIAL, DSO_TASK_END , 2, { BNODE1,BNODE2 }, { BNODE1,BNODE2 }, NULL, "DISCRETE_TASK_END2" },
4417#define DISCRETE_TASK_END3(BNODE1,BNODE2,BNODE3)                        { NODE_SPECIAL, DSO_TASK_END , 3, { BNODE1,BNODE2,BNODE3 }, { BNODE1,BNODE2,BNODE3 }, NULL, "DISCRETE_TASK_END3" },
4418#define DISCRETE_TASK_END4(BNODE1,BNODE2,BNODE3,BNODE4)                 { NODE_SPECIAL, DSO_TASK_END , 4, { BNODE1,BNODE2,BNODE3,BNODE4 }, { BNODE1,BNODE2,BNODE3,BNODE4 }, NULL, "DISCRETE_TASK_END4" },
4419#define DISCRETE_TASK_END5(BNODE1,BNODE2,BNODE3,BNODE4,BNODE5)          { NODE_SPECIAL, DSO_TASK_END , 5, { BNODE1,BNODE2,BNODE3,BNODE4,BNODE5 }, { BNODE1,BNODE2,BNODE3,BNODE4,BNODE5 }, NULL, "DISCRETE_TASK_END5" },
4420//#define DISCRETE_TASK_SYNC()                                          { NODE_SPECIAL, DSO_TASK_SYNC, 0, { 0 }, { 0 }, NULL, "DISCRETE_TASK_SYNC" },
4421
43474422/* output */
43484423#define DISCRETE_OUTPUT(OPNODE,GAIN)                               { NODE_SPECIAL, DSO_OUTPUT   , 2, { OPNODE,NODE_NC }, { 0,GAIN }, NULL, "DISCRETE_OUTPUT" },
43494424
43504425
4351
4352#define IS_VALUE_A_NODE(val)   (((val) > NODE_START) && ((val) <= NODE_END))
4353
43544426/*************************************
43554427 *
43564428 *  Interface to the external world
src/emu/sound/disc_dev.c
r5534r5535
141141 *
142142 * Jan 2004, D Renaud.
143143 ************************************************************************/
144#define DSD_555_ASTBL__RESET   (! *(node->input[0]))
145#define DSD_555_ASTBL__R1      (*(node->input[1]))
146#define DSD_555_ASTBL__R2      (*(node->input[2]))
147#define DSD_555_ASTBL__C      (*(node->input[3]))
148#define DSD_555_ASTBL__CTRLV   (*(node->input[4]))
144#define DSD_555_ASTBL__RESET   (! DISCRETE_INPUT(0))
145#define DSD_555_ASTBL__R1      DISCRETE_INPUT(1)
146#define DSD_555_ASTBL__R2      DISCRETE_INPUT(2)
147#define DSD_555_ASTBL__C      DISCRETE_INPUT(3)
148#define DSD_555_ASTBL__CTRLV   DISCRETE_INPUT(4)
149149
150150/* bit mask of the above RC inputs */
151151#define DSD_555_ASTBL_RC_MASK   0x0e
r5534r5535
234234     * dt = R*C(log(1/(1-(Vc/Vr))))
235235     */
236236
237   dt = disc_info->sample_time;
237   dt = node->info->sample_time;
238238
239239   /* Sometimes a switching network is used to setup the capacitance.
240240     * These may select no capacitor, causing oscillation to stop.
r5534r5535
338338   }
339339
340340   /* Convert last switch time to a ratio */
341   x_time = x_time / disc_info->sample_time;
341   x_time = x_time / node->info->sample_time;
342342
343343   switch (context->output_type)
344344   {
r5534r5535
387387   context->v_out_high = (info->v_out_high == DEFAULT_555_HIGH) ? info->v_pos - 1.2 : info->v_out_high;
388388
389389   /* setup v_charge or node */
390   v_charge_node = discrete_find_node(disc_info, info->v_charge);
390   v_charge_node = discrete_find_node(node->info, info->v_charge);
391391   if (v_charge_node)
392392      context->v_charge_node = &(v_charge_node->output[NODE_CHILD_NODE_NUM(info->v_charge)]);
393393   else
r5534r5535
450450 *
451451 * Oct 2004, D Renaud.
452452 ************************************************************************/
453#define DSD_555_MSTBL__RESET   (! *(node->input[0]))
454#define DSD_555_MSTBL__TRIGGER   (*(node->input[1]))
455#define DSD_555_MSTBL__R      (*(node->input[2]))
456#define DSD_555_MSTBL__C      (*(node->input[3]))
453#define DSD_555_MSTBL__RESET   (! DISCRETE_INPUT(0))
454#define DSD_555_MSTBL__TRIGGER   DISCRETE_INPUT(1)
455#define DSD_555_MSTBL__R      DISCRETE_INPUT(2)
456#define DSD_555_MSTBL__C      DISCRETE_INPUT(3)
457457
458458static DISCRETE_STEP(dsd_555_mstbl)
459459{
r5534r5535
548548   context->output_type = info->options & DISC_555_OUT_MASK;
549549   if ((context->output_type == DISC_555_OUT_COUNT_F) || (context->output_type == DISC_555_OUT_COUNT_R))
550550   {
551      discrete_log(disc_info, "Invalid Output type in NODE_%d.\n", node->node - NODE_00);
551      discrete_log(node->info, "Invalid Output type in NODE_%d.\n", node->node - NODE_00);
552552      context->output_type = DISC_555_OUT_SQW;
553553   }
554554
r5534r5535
590590 *
591591 * Mar 2004, D Renaud.
592592 ************************************************************************/
593#define DSD_555_CC__RESET   (! *(node->input[0]))
594#define DSD_555_CC__VIN      (*(node->input[1]))
595#define DSD_555_CC__R      (*(node->input[2]))
596#define DSD_555_CC__C      (*(node->input[3]))
597#define DSD_555_CC__RBIAS   (*(node->input[4]))
598#define DSD_555_CC__RGND   (*(node->input[5]))
599#define DSD_555_CC__RDIS   (*(node->input[6]))
593#define DSD_555_CC__RESET   (! DISCRETE_INPUT(0))
594#define DSD_555_CC__VIN      DISCRETE_INPUT(1)
595#define DSD_555_CC__R      DISCRETE_INPUT(2)
596#define DSD_555_CC__C      DISCRETE_INPUT(3)
597#define DSD_555_CC__RBIAS   DISCRETE_INPUT(4)
598#define DSD_555_CC__RGND   DISCRETE_INPUT(5)
599#define DSD_555_CC__RDIS   DISCRETE_INPUT(6)
600600
601601/* bit mask of the above RC inputs not including DSD_555_CC__R */
602602#define DSD_555_CC_RC_MASK   0x78
r5534r5535
642642      return;
643643   }
644644
645   dt    = disc_info->sample_time;   /* Change in time */
645   dt    = node->info->sample_time;   /* Change in time */
646646   v_cap = context->cap_voltage;   /* Set to voltage before change */
647647   v_vcharge_limit = DSD_555_CC__VIN + info->v_cc_junction;   /* the max v_cap can be and still be charged by i */
648648   /* Calculate charging current */
r5534r5535
888888   context->cap_voltage = v_cap_next;
889889
890890   /* Convert last switch time to a ratio */
891   x_time = x_time / disc_info->sample_time;
891   x_time = x_time / node->info->sample_time;
892892
893893   switch (context->output_type)
894894   {
r5534r5535
11551155 *
11561156 * Apr 2006, D Renaud.
11571157 ************************************************************************/
1158#define DSD_555_VCO1__RESET   (*(node->input[0]))   /* reset active low */
1159#define DSD_555_VCO1__VIN1   (*(node->input[1]))
1160#define DSD_555_VCO1__VIN2   (*(node->input[2]))
1158#define DSD_555_VCO1__RESET   DISCRETE_INPUT(0)   /* reset active low */
1159#define DSD_555_VCO1__VIN1   DISCRETE_INPUT(1)
1160#define DSD_555_VCO1__VIN2   DISCRETE_INPUT(2)
11611161
11621162static DISCRETE_STEP(dsd_555_vco1)
11631163{
r5534r5535
11711171   double   v_cap;         /* Current voltage on capacitor, before dt */
11721172   double   v_cap_next = 0;   /* Voltage on capacitor, after dt */
11731173
1174   dt    = disc_info->sample_time;   /* Change in time */
1174   dt    = node->info->sample_time;   /* Change in time */
11751175   v_cap = context->cap_voltage;
11761176
11771177   /* Check: if the Control Voltage node is connected. */
r5534r5535
12751275   context->cap_voltage = v_cap_next;
12761276
12771277   /* Convert last switch time to a ratio.  No x_time in reset. */
1278   x_time = x_time / disc_info->sample_time;
1278   x_time = x_time / node->info->sample_time;
12791279   if (!DSD_555_VCO1__RESET) x_time = 0;
12801280
12811281   switch (context->output_type)
r5534r5535
13851385 *
13861386 * Mar 2004, D Renaud.
13871387 ************************************************************************/
1388#define DSD_566__ENABLE   (*(node->input[0]))
1389#define DSD_566__VMOD   (*(node->input[1]))
1390#define DSD_566__R      (*(node->input[2]))
1391#define DSD_566__C      (*(node->input[3]))
1388#define DSD_566__ENABLE   DISCRETE_INPUT(0)
1389#define DSD_566__VMOD   DISCRETE_INPUT(1)
1390#define DSD_566__R      DISCRETE_INPUT(2)
1391#define DSD_566__C      DISCRETE_INPUT(3)
13921392
13931393static DISCRETE_STEP(dsd_566)
13941394{
r5534r5535
14031403
14041404   if (DSD_566__ENABLE && !context->error)
14051405   {
1406      dt    = disc_info->sample_time;   /* Change in time */
1406      dt    = node->info->sample_time;   /* Change in time */
14071407      v_cap = context->cap_voltage;   /* Set to voltage before change */
14081408
14091409      /* get the v_charge and update each step if it is a node */
r5534r5535
15281528   }
15291529
15301530   /* setup v_charge or node */
1531   v_charge_node = discrete_find_node(disc_info, info->v_charge);
1531   v_charge_node = discrete_find_node(node->info, info->v_charge);
15321532   if (v_charge_node)
15331533      context->v_charge_node = &(v_charge_node->output[NODE_CHILD_NODE_NUM(info->v_charge)]);
15341534   else
r5534r5535
15751575 *
15761576 * Dec 2007, Couriersud
15771577 ************************************************************************/
1578#define DSD_LS624__ENABLE   (*(node->input[0]))
1579#define DSD_LS624__VMOD      (*(node->input[1]))
1580#define DSD_LS624__VRNG      (*(node->input[2]))
1581#define DSD_LS624__C      (*(node->input[3]))
1582#define DSD_LS624__OUTTYPE   (*(node->input[4]))
1578#define DSD_LS624__ENABLE   DISCRETE_INPUT(0)
1579#define DSD_LS624__VMOD      DISCRETE_INPUT(1)
1580#define DSD_LS624__VRNG      DISCRETE_INPUT(2)
1581#define DSD_LS624__C      DISCRETE_INPUT(3)
1582#define DSD_LS624__OUTTYPE   DISCRETE_INPUT(4)
15831583
15841584/*
15851585 * The datasheet mentions a 600 ohm discharge. It also gives
r5534r5535
16081608      double  en = 0.0f;
16091609      int      cntf = 0, cntr = 0;
16101610
1611      sample_t = disc_info->sample_time;   /* Change in time */
1611      sample_t = node->info->sample_time;   /* Change in time */
16121612      //dt  = LS624_T(DSD_LS624__C, DSD_LS624__VRNG, DSD_LS624__VMOD) / 2.0;
16131613      dt  = 1.0f / (2.0f * LS624_F(DSD_LS624__C, DSD_LS624__VMOD, DSD_LS624__VRNG));
16141614      t   = context->remain;
src/emu/sound/disc_wav.c
r5534r5535
170170 *
171171 * Jan 2004, D Renaud.
172172 ************************************************************************/
173#define DSS_COUNTER__ENABLE      (*(node->input[0]))
174#define DSS_COUNTER__RESET      (*(node->input[1]))
175#define DSS_COUNTER__CLOCK      (*(node->input[2]))
176#define DSS_COUNTER__MAX      (*(node->input[3]))
177#define DSS_COUNTER__DIR      (*(node->input[4]))
178#define DSS_COUNTER__INIT      (*(node->input[5]))
179#define DSS_COUNTER__CLOCK_TYPE   (*(node->input[6]))
173#define DSS_COUNTER__ENABLE      DISCRETE_INPUT(0)
174#define DSS_COUNTER__RESET      DISCRETE_INPUT(1)
175#define DSS_COUNTER__CLOCK      DISCRETE_INPUT(2)
176#define DSS_COUNTER__MAX      DISCRETE_INPUT(3)
177#define DSS_COUNTER__DIR      DISCRETE_INPUT(4)
178#define DSS_COUNTER__INIT      DISCRETE_INPUT(5)
179#define DSS_COUNTER__CLOCK_TYPE   DISCRETE_INPUT(6)
180180#define DSS_7492__CLOCK_TYPE    DSS_COUNTER__MAX
181181
182182static const int disc_7492_count[6] = {0x00, 0x01, 0x02, 0x04, 0x05, 0x06};
r5534r5535
199199   if (context->clock_type == DISC_CLK_IS_FREQ)
200200   {
201201      /* We need to keep clocking the internal clock even if disabled. */
202      cycles = (context->t_left + disc_info->sample_time) * ds_clock;
202      cycles = (context->t_left + node->info->sample_time) * ds_clock;
203203      inc    = (int)cycles;
204204      context->t_left = (cycles - inc) / ds_clock;
205      if (inc) x_time = context->t_left / disc_info->sample_time;
205      if (inc) x_time = context->t_left / node->info->sample_time;
206206   }
207207   else
208208   {
r5534r5535
318318 * also passed dss_lfsr_context structure
319319 *
320320 ************************************************************************/
321#define DSS_LFSR_NOISE__ENABLE   (*(node->input[0]))
322#define DSS_LFSR_NOISE__RESET   (*(node->input[1]))
323#define DSS_LFSR_NOISE__CLOCK   (*(node->input[2]))
324#define DSS_LFSR_NOISE__AMP      (*(node->input[3]))
325#define DSS_LFSR_NOISE__FEED   (*(node->input[4]))
326#define DSS_LFSR_NOISE__BIAS   (*(node->input[5]))
321#define DSS_LFSR_NOISE__ENABLE   DISCRETE_INPUT(0)
322#define DSS_LFSR_NOISE__RESET   DISCRETE_INPUT(1)
323#define DSS_LFSR_NOISE__CLOCK   DISCRETE_INPUT(2)
324#define DSS_LFSR_NOISE__AMP      DISCRETE_INPUT(3)
325#define DSS_LFSR_NOISE__FEED   DISCRETE_INPUT(4)
326#define DSS_LFSR_NOISE__BIAS   DISCRETE_INPUT(5)
327327
328328INLINE int dss_lfsr_function(const discrete_info *disc_info, int myfunc, int in0, int in1, int bitmask)
329329{
r5534r5535
401401   if (lfsr_desc->clock_type == DISC_CLK_IS_FREQ)
402402   {
403403      /* We need to keep clocking the internal clock even if disabled. */
404      cycles = (context->t_left + disc_info->sample_time) / context->t_clock;
404      cycles = (context->t_left + node->info->sample_time) / context->t_clock;
405405      inc    = (int)cycles;
406406      context->t_left = (cycles - inc) * context->t_clock;
407407   }
r5534r5535
445445         fbresult = (context->lfsr_reg >> lfsr_desc->bitlength) & 0x01;
446446
447447         /* Stage 2 feedback combine fbresultNew with infeed bit */
448         fbresult = dss_lfsr_function(disc_info, lfsr_desc->feedback_function1, fbresult, noise_feed, 0x01);
448         fbresult = dss_lfsr_function(node->info, lfsr_desc->feedback_function1, fbresult, noise_feed, 0x01);
449449
450450         /* Stage 3 first we setup where the bit is going to be shifted into */
451451         fbresult = fbresult * lfsr_desc->feedback_function2_mask;
452452         /* Then we left shift the register, */
453453         context->lfsr_reg = context->lfsr_reg << 1;
454454         /* Now move the fbresult into the shift register and mask it to the bitlength */
455         context->lfsr_reg = dss_lfsr_function(disc_info, lfsr_desc->feedback_function2, fbresult, context->lfsr_reg, (1 << lfsr_desc->bitlength) - 1 );
455         context->lfsr_reg = dss_lfsr_function(node->info, lfsr_desc->feedback_function2, fbresult, context->lfsr_reg, (1 << lfsr_desc->bitlength) - 1 );
456456
457457         /* Now get and store the new feedback result */
458458         /* Fetch the feedback bits */
459459         fb0 = (context->lfsr_reg >> lfsr_desc->feedback_bitsel0) & 0x01;
460460         fb1 = (context->lfsr_reg >> lfsr_desc->feedback_bitsel1) & 0x01;
461461         /* Now do the combo on them */
462         fbresult = dss_lfsr_function(disc_info, lfsr_desc->feedback_function0, fb0, fb1, 0x01);
463         context->lfsr_reg = dss_lfsr_function(disc_info, DISC_LFSR_REPLACE, context->lfsr_reg, fbresult << lfsr_desc->bitlength, (2 << lfsr_desc->bitlength) - 1);
462         fbresult = dss_lfsr_function(node->info, lfsr_desc->feedback_function0, fb0, fb1, 0x01);
463         context->lfsr_reg = dss_lfsr_function(node->info, DISC_LFSR_REPLACE, context->lfsr_reg, fbresult << lfsr_desc->bitlength, (2 << lfsr_desc->bitlength) - 1);
464464
465465      }
466466      /* Now select the output bit */
r5534r5535
479479
480480      /* output the lfsr reg ?*/
481481      if (context->out_lfsr_reg)
482         node->output[1] = context->lfsr_reg;
482         node->output[1] = (double) context->lfsr_reg;
483483
484484   }
485485   if(!DSS_LFSR_NOISE__ENABLE)
r5534r5535
500500   context->out_lfsr_reg = (lfsr_desc->flags & DISC_LFSR_FLAG_OUTPUT_SR_SN1) ? 1 : 0;
501501
502502   if ((lfsr_desc->clock_type < DISC_CLK_ON_F_EDGE) || (lfsr_desc->clock_type > DISC_CLK_IS_FREQ))
503      discrete_log(disc_info, "Invalid clock type passed in NODE_%d\n", NODE_INDEX(node->node));
503      discrete_log(node->info, "Invalid clock type passed in NODE_%d\n", NODE_INDEX(node->node));
504504
505505   context->last = (DSS_COUNTER__CLOCK != 0);
506506   if (lfsr_desc->clock_type == DISC_CLK_IS_FREQ) context->t_clock = 1.0 / DSS_LFSR_NOISE__CLOCK;
r5534r5535
513513   fb0 = (context->lfsr_reg >> lfsr_desc->feedback_bitsel0) & 0x01;
514514   fb1=(context->lfsr_reg >> lfsr_desc->feedback_bitsel1) & 0x01;
515515   /* Now do the combo on them */
516   fbresult = dss_lfsr_function(disc_info, lfsr_desc->feedback_function0, fb0, fb1, 0x01);
517   context->lfsr_reg=dss_lfsr_function(disc_info, DISC_LFSR_REPLACE, context->lfsr_reg, fbresult << lfsr_desc->bitlength, (2<< lfsr_desc->bitlength ) - 1);
516   fbresult = dss_lfsr_function(node->info, lfsr_desc->feedback_function0, fb0, fb1, 0x01);
517   context->lfsr_reg=dss_lfsr_function(node->info, DISC_LFSR_REPLACE, context->lfsr_reg, fbresult << lfsr_desc->bitlength, (2<< lfsr_desc->bitlength ) - 1);
518518
519519   /* Now select and setup the output bit */
520520   node->output[0] = (context->lfsr_reg >> lfsr_desc->output_bit) & 0x01;
r5534r5535
539539 * input3    - DC Bias value
540540 *
541541 ************************************************************************/
542#define DSS_NOISE__ENABLE   (*(node->input[0]))
543#define DSS_NOISE__FREQ      (*(node->input[1]))
544#define DSS_NOISE__AMP      (*(node->input[2]))
545#define DSS_NOISE__BIAS      (*(node->input[3]))
542#define DSS_NOISE__ENABLE   DISCRETE_INPUT(0)
543#define DSS_NOISE__FREQ      DISCRETE_INPUT(1)
544#define DSS_NOISE__AMP      DISCRETE_INPUT(2)
545#define DSS_NOISE__BIAS      DISCRETE_INPUT(3)
546546
547547static DISCRETE_STEP(dss_noise)
548548{
r5534r5535
554554      if(context->phase > (2.0 * M_PI))
555555      {
556556         /* GCC's rand returns a RAND_MAX value of 0x7fff */
557         int newval = (mame_rand(disc_info->device->machine) & 0x7fff) - 16384;
557         int newval = (mame_rand(node->info->device->machine) & 0x7fff) - 16384;
558558
559559         /* make sure the peak to peak values are the amplitude */
560560         node->output[0] = DSS_NOISE__AMP / 2;
r5534r5535
577577
578578   /* The enable input only curtails output, phase rotation still occurs. */
579579   /* We allow the phase to exceed 2Pi here, so we can tell when to sample the noise. */
580   context->phase += ((2.0 * M_PI * DSS_NOISE__FREQ) / disc_info->sample_rate);
580   context->phase += ((2.0 * M_PI * DSS_NOISE__FREQ) / node->info->sample_rate);
581581}
582582
583583
r5534r5535
603603 *
604604 * Mar 2004, D Renaud.
605605 ************************************************************************/
606 #define DSS_NOTE__ENABLE      (*(node->input[0]))
607 #define DSS_NOTE__CLOCK      (*(node->input[1]))
608 #define DSS_NOTE__DATA         (*(node->input[2]))
609 #define DSS_NOTE__MAX1         (*(node->input[3]))
610 #define DSS_NOTE__MAX2         (*(node->input[4]))
611 #define DSS_NOTE__CLOCK_TYPE   (*(node->input[5]))
606 #define DSS_NOTE__ENABLE      DISCRETE_INPUT(0)
607 #define DSS_NOTE__CLOCK      DISCRETE_INPUT(1)
608 #define DSS_NOTE__DATA         DISCRETE_INPUT(2)
609 #define DSS_NOTE__MAX1         DISCRETE_INPUT(3)
610 #define DSS_NOTE__MAX2         DISCRETE_INPUT(4)
611 #define DSS_NOTE__CLOCK_TYPE   DISCRETE_INPUT(5)
612612
613613static DISCRETE_STEP(dss_note)
614614{
r5534r5535
621621   if (context->clock_type == DISC_CLK_IS_FREQ)
622622   {
623623      /* We need to keep clocking the internal clock even if disabled. */
624      cycles = (context->t_left + disc_info->sample_time) / context->t_clock;
624      cycles = (context->t_left + node->info->sample_time) / context->t_clock;
625625      inc    = (int)cycles;
626626      context->t_left = (cycles - inc) * context->t_clock;
627      if (inc) x_time = context->t_left / disc_info->sample_time;
627      if (inc) x_time = context->t_left / node->info->sample_time;
628628   }
629629   else
630630   {
r5534r5535
730730 *
731731 * Mar 2004, D Renaud.
732732 ************************************************************************/
733#define DSS_OP_AMP_OSC__ENABLE   (*(node->input[0]))
734#define DSS_OP_AMP_OSC__VMOD1   (*(node->input[1]))
735#define DSS_OP_AMP_OSC__VMOD2   (*(node->input[2]))
733#define DSS_OP_AMP_OSC__ENABLE   DISCRETE_INPUT(0)
734#define DSS_OP_AMP_OSC__VMOD1   DISCRETE_INPUT(1)
735#define DSS_OP_AMP_OSC__VMOD2   DISCRETE_INPUT(2)
736736
737737/* The inputs on a norton op-amp are (info->vP - OP_AMP_NORTON_VBE) */
738738/* which is the same as the output high voltage.  We will define them */
r5534r5535
754754   UINT8 force_charge = 0;
755755   UINT8 enable = DSS_OP_AMP_OSC__ENABLE;
756756
757   dt = disc_info->sample_time;   /* Change in time */
757   dt = node->info->sample_time;   /* Change in time */
758758   vC = context->v_cap;   /* Set to voltage before change */
759759
760760   /* work out the charge currents for the VCOs. */
r5534r5535
931931   {
932932      if IS_VALUE_A_NODE(*r_info_ptr)
933933      {
934         r_node = discrete_find_node(disc_info, *r_info_ptr);
934         r_node = discrete_find_node(node->info, *r_info_ptr);
935935         *r_context_ptr = &(r_node->output[NODE_CHILD_NODE_NUM((int)*r_info_ptr)]);
936936      }
937937      else
r5534r5535
10481048 * input5    - Initial Phase
10491049 *
10501050 ************************************************************************/
1051#define DSS_SAWTOOTHWAVE__ENABLE   (*(node->input[0]))
1052#define DSS_SAWTOOTHWAVE__FREQ      (*(node->input[1]))
1053#define DSS_SAWTOOTHWAVE__AMP      (*(node->input[2]))
1054#define DSS_SAWTOOTHWAVE__BIAS      (*(node->input[3]))
1055#define DSS_SAWTOOTHWAVE__GRAD      (*(node->input[4]))
1056#define DSS_SAWTOOTHWAVE__PHASE      (*(node->input[5]))
1051#define DSS_SAWTOOTHWAVE__ENABLE   DISCRETE_INPUT(0)
1052#define DSS_SAWTOOTHWAVE__FREQ      DISCRETE_INPUT(1)
1053#define DSS_SAWTOOTHWAVE__AMP      DISCRETE_INPUT(2)
1054#define DSS_SAWTOOTHWAVE__BIAS      DISCRETE_INPUT(3)
1055#define DSS_SAWTOOTHWAVE__GRAD      DISCRETE_INPUT(4)
1056#define DSS_SAWTOOTHWAVE__PHASE      DISCRETE_INPUT(5)
10571057
10581058static DISCRETE_STEP(dss_sawtoothwave)
10591059{
r5534r5535
10781078   /*                    boils out to                           */
10791079   /*     phase step = (2Pi*output freq)/sample freq)           */
10801080   /* Also keep the new phasor in the 2Pi range.                */
1081   context->phase = fmod((context->phase + ((2.0 * M_PI * DSS_SAWTOOTHWAVE__FREQ) / disc_info->sample_rate)), 2.0 * M_PI);
1081   context->phase = fmod((context->phase + ((2.0 * M_PI * DSS_SAWTOOTHWAVE__FREQ) / node->info->sample_rate)), 2.0 * M_PI);
10821082}
10831083
10841084static DISCRETE_RESET(dss_sawtoothwave)
r5534r5535
11111111 *
11121112 * Mar 2004, D Renaud.
11131113 ************************************************************************/
1114#define DSS_SCHMITT_OSC__ENABLE   (int)(*(node->input[0]))
1115#define DSS_SCHMITT_OSC__VIN   (*(node->input[1]))
1116#define DSS_SCHMITT_OSC__AMP   (*(node->input[2]))
1114#define DSS_SCHMITT_OSC__ENABLE   (int)DISCRETE_INPUT(0)
1115#define DSS_SCHMITT_OSC__VIN   DISCRETE_INPUT(1)
1116#define DSS_SCHMITT_OSC__AMP   DISCRETE_INPUT(2)
11171117
11181118static DISCRETE_STEP(dss_schmitt_osc)
11191119{
r5534r5535
12281228 * input4    - Starting phase
12291229 *
12301230 ************************************************************************/
1231#define DSS_SINEWAVE__ENABLE   (*(node->input[0]))
1232#define DSS_SINEWAVE__FREQ      (*(node->input[1]))
1233#define DSS_SINEWAVE__AMPL      (*(node->input[2]))
1234#define DSS_SINEWAVE__BIAS      (*(node->input[3]))
1235#define DSS_SINEWAVE__PHASE      (*(node->input[4]))
1231#define DSS_SINEWAVE__ENABLE   DISCRETE_INPUT(0)
1232#define DSS_SINEWAVE__FREQ      DISCRETE_INPUT(1)
1233#define DSS_SINEWAVE__AMPL      DISCRETE_INPUT(2)
1234#define DSS_SINEWAVE__BIAS      DISCRETE_INPUT(3)
1235#define DSS_SINEWAVE__PHASE      DISCRETE_INPUT(4)
12361236
12371237static DISCRETE_STEP(dss_sinewave)
12381238{
r5534r5535
12571257   /*                    boils out to                           */
12581258   /*     phase step = (2Pi*output freq)/sample freq)           */
12591259   /* Also keep the new phasor in the 2Pi range.                */
1260   context->phase=fmod((context->phase + ((2.0 * M_PI * DSS_SINEWAVE__FREQ) / disc_info->sample_rate)), 2.0 * M_PI);
1260   context->phase=fmod((context->phase + ((2.0 * M_PI * DSS_SINEWAVE__FREQ) / node->info->sample_rate)), 2.0 * M_PI);
12611261}
12621262
12631263static DISCRETE_RESET(dss_sinewave)
r5534r5535
12861286 * input5    - Start Phase
12871287 *
12881288 ************************************************************************/
1289#define DSS_SQUAREWAVE__ENABLE   (*(node->input[0]))
1290#define DSS_SQUAREWAVE__FREQ   (*(node->input[1]))
1291#define DSS_SQUAREWAVE__AMP      (*(node->input[2]))
1292#define DSS_SQUAREWAVE__DUTY   (*(node->input[3]))
1293#define DSS_SQUAREWAVE__BIAS   (*(node->input[4]))
1294#define DSS_SQUAREWAVE__PHASE   (*(node->input[5]))
1289#define DSS_SQUAREWAVE__ENABLE   DISCRETE_INPUT(0)
1290#define DSS_SQUAREWAVE__FREQ   DISCRETE_INPUT(1)
1291#define DSS_SQUAREWAVE__AMP      DISCRETE_INPUT(2)
1292#define DSS_SQUAREWAVE__DUTY   DISCRETE_INPUT(3)
1293#define DSS_SQUAREWAVE__BIAS   DISCRETE_INPUT(4)
1294#define DSS_SQUAREWAVE__PHASE   DISCRETE_INPUT(5)
12951295
12961296static DISCRETE_STEP(dss_squarewave)
12971297{
r5534r5535
13231323   /*                    boils out to                           */
13241324   /*     phase step = (2Pi*output freq)/sample freq)           */
13251325   /* Also keep the new phasor in the 2Pi range.                */
1326   context->phase=fmod(context->phase + ((2.0 * M_PI * DSS_SQUAREWAVE__FREQ) / disc_info->sample_rate), 2.0 * M_PI);
1326   context->phase=fmod(context->phase + ((2.0 * M_PI * DSS_SQUAREWAVE__FREQ) / node->info->sample_rate), 2.0 * M_PI);
13271327}
13281328
13291329static DISCRETE_RESET(dss_squarewave)
r5534r5535
13521352 * input5    - Start Phase
13531353 *
13541354 ************************************************************************/
1355#define DSS_SQUAREWFIX__ENABLE   (*(node->input[0]))
1356#define DSS_SQUAREWFIX__FREQ   (*(node->input[1]))
1357#define DSS_SQUAREWFIX__AMP      (*(node->input[2]))
1358#define DSS_SQUAREWFIX__DUTY   (*(node->input[3]))
1359#define DSS_SQUAREWFIX__BIAS   (*(node->input[4]))
1360#define DSS_SQUAREWFIX__PHASE   (*(node->input[5]))
1355#define DSS_SQUAREWFIX__ENABLE   DISCRETE_INPUT(0)
1356#define DSS_SQUAREWFIX__FREQ   DISCRETE_INPUT(1)
1357#define DSS_SQUAREWFIX__AMP      DISCRETE_INPUT(2)
1358#define DSS_SQUAREWFIX__DUTY   DISCRETE_INPUT(3)
1359#define DSS_SQUAREWFIX__BIAS   DISCRETE_INPUT(4)
1360#define DSS_SQUAREWFIX__PHASE   DISCRETE_INPUT(5)
13611361
13621362static DISCRETE_STEP(dss_squarewfix)
13631363{
r5534r5535
13921392{
13931393   struct dss_squarewfix_context *context = (struct dss_squarewfix_context *)node->context;
13941394
1395   context->sample_step = 1.0 / disc_info->sample_rate;
1395   context->sample_step = 1.0 / node->info->sample_rate;
13961396   context->flip_flop   = 1;
13971397
13981398   /* Do the intial time shift and convert freq to off/on times */
r5534r5535
14301430 * input5    - Initial Time Shift
14311431 *
14321432 ************************************************************************/
1433#define DSS_SQUAREWAVE2__ENABLE   (*(node->input[0]))
1434#define DSS_SQUAREWAVE2__AMP   (*(node->input[1]))
1435#define DSS_SQUAREWAVE2__T_OFF   (*(node->input[2]))
1436#define DSS_SQUAREWAVE2__T_ON   (*(node->input[3]))
1437#define DSS_SQUAREWAVE2__BIAS   (*(node->input[4]))
1438#define DSS_SQUAREWAVE2__SHIFT   (*(node->input[5]))
1433#define DSS_SQUAREWAVE2__ENABLE   DISCRETE_INPUT(0)
1434#define DSS_SQUAREWAVE2__AMP   DISCRETE_INPUT(1)
1435#define DSS_SQUAREWAVE2__T_OFF   DISCRETE_INPUT(2)
1436#define DSS_SQUAREWAVE2__T_ON   DISCRETE_INPUT(3)
1437#define DSS_SQUAREWAVE2__BIAS   DISCRETE_INPUT(4)
1438#define DSS_SQUAREWAVE2__SHIFT   DISCRETE_INPUT(5)
14391439
14401440static DISCRETE_STEP(dss_squarewave2)
14411441{
r5534r5535
14541454      /*     phase step = 2Pi/(output period/sample period)        */
14551455      /*                    boils out to                           */
14561456      /*     phase step = 2Pi/(output period*sample freq)          */
1457      newphase = context->phase + ((2.0 * M_PI) / ((DSS_SQUAREWAVE2__T_OFF + DSS_SQUAREWAVE2__T_ON) * disc_info->sample_rate));
1457      newphase = context->phase + ((2.0 * M_PI) / ((DSS_SQUAREWAVE2__T_OFF + DSS_SQUAREWAVE2__T_ON) * node->info->sample_rate));
14581458      /* Keep the new phasor in the 2Pi range.*/
14591459      context->phase = fmod(newphase, 2.0 * M_PI);
14601460
r5534r5535
15011501 * input4    - Desc
15021502 *
15031503 ************************************************************************/
1504#define DSS_INVERTER_OSC__ENABLE   (*(node->input[0]))
1505#define DSS_INVERTER_OSC__MOD      (*(node->input[1]))
1506#define DSS_INVERTER_OSC__RC      (*(node->input[2]))
1507#define DSS_INVERTER_OSC__RP      (*(node->input[3]))
1508#define DSS_INVERTER_OSC__C         (*(node->input[4]))
1509#define DSS_INVERTER_OSC__R2      (*(node->input[5]))
1504#define DSS_INVERTER_OSC__ENABLE   DISCRETE_INPUT(0)
1505#define DSS_INVERTER_OSC__MOD      DISCRETE_INPUT(1)
1506#define DSS_INVERTER_OSC__RC      DISCRETE_INPUT(2)
1507#define DSS_INVERTER_OSC__RP      DISCRETE_INPUT(3)
1508#define DSS_INVERTER_OSC__C         DISCRETE_INPUT(4)
1509#define DSS_INVERTER_OSC__R2      DISCRETE_INPUT(5)
15101510
15111511INLINE double dss_inverter_tftab(node_description *node, double x)
15121512{
r5534r5535
16071607            vMix = rMix* ( (vG3-vG2) / context->r1 + (DSS_INVERTER_OSC__MOD-vG2) / context->r2 + (vI-0.7-vG2)/context->rp);
16081608         }
16091609         diff = vMix - context->v_cap;
1610         diff = diff - diff * exp(-disc_info->sample_time / (context->c * rMix));
1610         diff = diff - diff * exp(-node->info->sample_time / (context->c * rMix));
16111611         break;
16121612      case DISC_OSC_INVERTER_IS_TYPE5:
16131613         if ((info->clamp >= 0.0) && ((vI< - info->clamp) || (vI> info->vB+info->clamp)))
r5534r5535
16251625            vMix = rMix* ( (vG3 - vG2) / context->r1 + (DSS_INVERTER_OSC__MOD-vG2) / context->r2 + (vI+0.7-vG2)/context->rp);
16261626         }
16271627         diff = vMix - context->v_cap;
1628         diff = diff - diff * exp(-disc_info->sample_time/(context->c * rMix));
1628         diff = diff - diff * exp(-node->info->sample_time/(context->c * rMix));
16291629         break;
16301630      default:
16311631         fatalerror("DISCRETE_INVERTER_OSC - Wrong type on NODE_%02d", node->node - NODE_00);
r5534r5535
16481648   int i;
16491649
16501650   /* exponent */
1651   context->w  = exp(-disc_info->sample_time / (DSS_INVERTER_OSC__RC * DSS_INVERTER_OSC__C));
1652   context->wc = exp(-disc_info->sample_time / ((DSS_INVERTER_OSC__RC * DSS_INVERTER_OSC__RP) / (DSS_INVERTER_OSC__RP + DSS_INVERTER_OSC__RC) * DSS_INVERTER_OSC__C));
1651   context->w  = exp(-node->info->sample_time / (DSS_INVERTER_OSC__RC * DSS_INVERTER_OSC__C));
1652   context->wc = exp(-node->info->sample_time / ((DSS_INVERTER_OSC__RC * DSS_INVERTER_OSC__RP) / (DSS_INVERTER_OSC__RP + DSS_INVERTER_OSC__RC) * DSS_INVERTER_OSC__C));
16531653   node->output[0]   = 0;
16541654   context->v_cap    = 0;
16551655   context->v_g2_old = 0;
r5534r5535
16781678 * input4    - Initial Phase
16791679 *
16801680 ************************************************************************/
1681#define DSS_TRIANGLEWAVE__ENABLE   (*(node->input[0]))
1682#define DSS_TRIANGLEWAVE__FREQ      (*(node->input[1]))
1683#define DSS_TRIANGLEWAVE__AMP      (*(node->input[2]))
1684#define DSS_TRIANGLEWAVE__BIAS      (*(node->input[3]))
1685#define DSS_TRIANGLEWAVE__PHASE      (*(node->input[4]))
1681#define DSS_TRIANGLEWAVE__ENABLE   DISCRETE_INPUT(0)
1682#define DSS_TRIANGLEWAVE__FREQ      DISCRETE_INPUT(1)
1683#define DSS_TRIANGLEWAVE__AMP      DISCRETE_INPUT(2)
1684#define DSS_TRIANGLEWAVE__BIAS      DISCRETE_INPUT(3)
1685#define DSS_TRIANGLEWAVE__PHASE      DISCRETE_INPUT(4)
16861686
16871687static DISCRETE_STEP(dss_trianglewave)
16881688{
r5534r5535
17081708   /*                    boils out to                           */
17091709   /*     phase step = (2Pi*output freq)/sample freq)           */
17101710   /* Also keep the new phasor in the 2Pi range.                */
1711   context->phase=fmod((context->phase + ((2.0 * M_PI * DSS_TRIANGLEWAVE__FREQ) / disc_info->sample_rate)), 2.0 * M_PI);
1711   context->phase=fmod((context->phase + ((2.0 * M_PI * DSS_TRIANGLEWAVE__FREQ) / node->info->sample_rate)), 2.0 * M_PI);
17121712}
17131713
17141714static DISCRETE_RESET(dss_trianglewave)
r5534r5535
17351735 * input2    - gain scaling factor
17361736 *
17371737 ************************************************************************/
1738#define DSS_ADSR__ENABLE   (*(node->input[0]))
1738#define DSS_ADSR__ENABLE   DISCRETE_INPUT(0)
17391739
17401740static DISCRETE_STEP(dss_adsrenv)
17411741{
src/emu/sound/disc_flt.c
r5534r5535
7373   double exponent0;
7474   double exponent1;
7575   double v_cap;      /* rcdisc5 */
76   double v_diode;      /* rcdisc3 */
7677};
7778
7879struct dst_rcdisc_mod_context
r5534r5535
134135 * input[4]    - Voltage reference. Usually 0V.
135136 *
136137 ************************************************************************/
137#define DST_CRFILTER__ENABLE   (*(node->input[0]))
138#define DST_CRFILTER__IN      (*(node->input[1]))
139#define DST_CRFILTER__R         (*(node->input[2]))
140#define DST_CRFILTER__C         (*(node->input[3]))
141#define DST_CRFILTER__VREF      (*(node->input[4]))
138#define DST_CRFILTER__ENABLE   DISCRETE_INPUT(0)
139#define DST_CRFILTER__IN      DISCRETE_INPUT(1)
140#define DST_CRFILTER__R         DISCRETE_INPUT(2)
141#define DST_CRFILTER__C         DISCRETE_INPUT(3)
142#define DST_CRFILTER__VREF      DISCRETE_INPUT(4)
142143
143144static DISCRETE_STEP(dst_crfilter)
144145{
r5534r5535
175176 * input[3]    - Filter type (initialization only)
176177 *
177178 ************************************************************************/
178#define DST_FILTER1__ENABLE   (*(node->input[0]))
179#define DST_FILTER1__IN      (*(node->input[1]))
180#define DST_FILTER1__FREQ   (*(node->input[2]))
181#define DST_FILTER1__TYPE   (*(node->input[3]))
179#define DST_FILTER1__ENABLE   DISCRETE_INPUT(0)
180#define DST_FILTER1__IN      DISCRETE_INPUT(1)
181#define DST_FILTER1__FREQ   DISCRETE_INPUT(2)
182#define DST_FILTER1__TYPE   DISCRETE_INPUT(3)
182183
183184static void calculate_filter1_coefficients(const discrete_info *disc_info, double fc, double type,
184185                                 double *a1, double *b0, double *b1)
r5534r5535
228229{
229230   struct dss_filter1_context *context = (struct dss_filter1_context *)node->context;
230231
231   calculate_filter1_coefficients(disc_info, DST_FILTER1__FREQ, DST_FILTER1__TYPE, &context->a1, &context->b0, &context->b1);
232   calculate_filter1_coefficients(node->info, DST_FILTER1__FREQ, DST_FILTER1__TYPE, &context->a1, &context->b0, &context->b1);
232233   node->output[0] = 0;
233234}
234235
r5534r5535
244245 * input[4]    - Filter type (initialization only)
245246 *
246247 ************************************************************************/
247#define DST_FILTER2__ENABLE   (*(node->input[0]))
248#define DST_FILTER2__IN      (*(node->input[1]))
249#define DST_FILTER2__FREQ   (*(node->input[2]))
250#define DST_FILTER2__DAMP   (*(node->input[3]))
251#define DST_FILTER2__TYPE   (*(node->input[4]))
248#define DST_FILTER2__ENABLE   DISCRETE_INPUT(0)
249#define DST_FILTER2__IN      DISCRETE_INPUT(1)
250#define DST_FILTER2__FREQ   DISCRETE_INPUT(2)
251#define DST_FILTER2__DAMP   DISCRETE_INPUT(3)
252#define DST_FILTER2__TYPE   DISCRETE_INPUT(4)
252253
253254static void calculate_filter2_coefficients(const discrete_info *disc_info,
254255                                         double fc, double d, double type,
r5534r5535
258259   double w;   /* cutoff freq, in radians/sec */
259260   double w_squared;
260261   double den;   /* temp variable */
261   double two_over_T = 2*disc_info->sample_rate;
262   double two_over_T = 2 * disc_info->sample_rate;
262263   double two_over_T_squared = two_over_T * two_over_T;
263264
264265   /* calculate digital filter coefficents */
r5534r5535
317318{
318319   struct dss_filter2_context *context = (struct dss_filter2_context *)node->context;
319320
320   calculate_filter2_coefficients(disc_info, DST_FILTER2__FREQ, DST_FILTER2__DAMP, DST_FILTER2__TYPE,
321   calculate_filter2_coefficients(node->info, DST_FILTER2__FREQ, DST_FILTER2__DAMP, DST_FILTER2__TYPE,
321322                           &context->a1, &context->a2,
322323                           &context->b0, &context->b1, &context->b2);
323324   node->output[0] = 0;
r5534r5535
337338 *
338339 * Mar 2004, D Renaud.
339340 ************************************************************************/
340#define DST_OP_AMP_FILT__ENABLE   (*(node->input[0]))
341#define DST_OP_AMP_FILT__INP1   (*(node->input[1]))
342#define DST_OP_AMP_FILT__INP2   (*(node->input[2]))
343#define DST_OP_AMP_FILT__TYPE   (*(node->input[3]))
341#define DST_OP_AMP_FILT__ENABLE   DISCRETE_INPUT(0)
342#define DST_OP_AMP_FILT__INP1   DISCRETE_INPUT(1)
343#define DST_OP_AMP_FILT__INP2   DISCRETE_INPUT(2)
344#define DST_OP_AMP_FILT__TYPE   DISCRETE_INPUT(3)
344345
345346static DISCRETE_STEP(dst_op_amp_filt)
346347{
r5534r5535
360361      {
361362         /* Millman the input voltages. */
362363         i  = context->iFixed;
363         i += (DST_OP_AMP_FILT__INP1 - context->vRef) / info->r1;
364         if (info->r2 != 0)
365            i += (DST_OP_AMP_FILT__INP2 - context->vRef) / info->r2;
364         switch (context->type)
365         {
366            case DISC_OP_AMP_FILTER_IS_LOW_PASS_1M:
367               i += (DST_OP_AMP_FILT__INP1 - DST_OP_AMP_FILT__INP2) / info->r1;
368               if (info->r2 != 0)
369                  i += (context->vP - DST_OP_AMP_FILT__INP2) / info->r2;
370               if (info->r3 != 0)
371                  i += (context->vN - DST_OP_AMP_FILT__INP2) / info->r3;
372               break;
373            default:
374               i += (DST_OP_AMP_FILT__INP1 - context->vRef) / info->r1;
375               if (info->r2 != 0)
376                  i += (DST_OP_AMP_FILT__INP2 - context->vRef) / info->r2;
377               break;
378         }
366379         v = i * context->rTotal;
367380      }
368381
r5534r5535
373386            node->output[0] = context->vC1 * context->gain + info->vRef;
374387            break;
375388
389         case DISC_OP_AMP_FILTER_IS_LOW_PASS_1M:
390            context->vC1 += (v - context->vC1) * context->exponentC1;
391            node->output[0] = context->vC1 * context->gain + DST_OP_AMP_FILT__INP2;
392            break;
393
376394         case DISC_OP_AMP_FILTER_IS_HIGH_PASS_1:
377395            node->output[0] = (v - context->vC1) * context->gain + info->vRef;
378396            context->vC1 += (v - context->vC1) * context->exponentC1;
r5534r5535
470488   switch (context->type)
471489   {
472490      case DISC_OP_AMP_FILTER_IS_LOW_PASS_1:
491      case DISC_OP_AMP_FILTER_IS_LOW_PASS_1M:
473492         context->exponentC1 = RC_CHARGE_EXP(info->rF * info->c1);
474493         context->exponentC2 =  0;
475494         break;
r5534r5535
489508         double d  = (info->c1 + info->c2) / sqrt(info->rF / context->rTotal * info->c1 * info->c2);
490509         double gain = -info->rF / context->rTotal * info->c2 / (info->c1 + info->c2);
491510
492         calculate_filter2_coefficients(disc_info, fc, d, DISC_FILTER_BANDPASS,
511         calculate_filter2_coefficients(node->info, fc, d, DISC_FILTER_BANDPASS,
493512                                 &context->a1, &context->a2,
494513                                 &context->b0, &context->b1, &context->b2);
495514         context->b0 *= gain;
r5534r5535
534553 * input[3]    - Capacitor Value (initialization only)
535554 *
536555 ************************************************************************/
537#define DST_RCDISC__ENABLE   (*(node->input[0]))
538#define DST_RCDISC__IN      (*(node->input[1]))
539#define DST_RCDISC__R      (*(node->input[2]))
540#define DST_RCDISC__C      (*(node->input[3]))
556#define DST_RCDISC__ENABLE   DISCRETE_INPUT(0)
557#define DST_RCDISC__IN      DISCRETE_INPUT(1)
558#define DST_RCDISC__R      DISCRETE_INPUT(2)
559#define DST_RCDISC__C      DISCRETE_INPUT(3)
541560
542561static DISCRETE_STEP(dst_rcdisc)
543562{
r5534r5535
558577         if (DST_RCDISC__ENABLE)
559578         {
560579            node->output[0] = DST_RCDISC__IN * exp(context->t / context->exponent0);
561            context->t += disc_info->sample_time;
580            context->t += node->info->sample_time;
562581         } else
563582         {
564583            context->state = 0;
r5534r5535
591610 * input[5]    - Capacitor Value (initialization only)
592611 *
593612 ************************************************************************/
594#define DST_RCDISC2__ENABLE   (*(node->input[0]))
595#define DST_RCDISC2__IN0   (*(node->input[1]))
596#define DST_RCDISC2__R0      (*(node->input[2]))
597#define DST_RCDISC2__IN1   (*(node->input[3]))
598#define DST_RCDISC2__R1      (*(node->input[4]))
599#define DST_RCDISC2__C      (*(node->input[5]))
613#define DST_RCDISC2__ENABLE   DISCRETE_INPUT(0)
614#define DST_RCDISC2__IN0   DISCRETE_INPUT(1)
615#define DST_RCDISC2__R0      DISCRETE_INPUT(2)
616#define DST_RCDISC2__IN1   DISCRETE_INPUT(3)
617#define DST_RCDISC2__R1      DISCRETE_INPUT(4)
618#define DST_RCDISC2__C      DISCRETE_INPUT(5)
600619
601620static DISCRETE_STEP(dst_rcdisc2)
602621{
r5534r5535
634653 * input[2]    - Resistor0 value (initialization only)
635654 * input[4]    - Resistor1 value (initialization only)
636655 * input[5]    - Capacitor Value (initialization only)
656 * input[6]    - Diode Junction voltage (initialization only)
637657 *
638658 ************************************************************************/
639#define DST_RCDISC3__ENABLE   (*(node->input[0]))
640#define DST_RCDISC3__IN      (*(node->input[1]))
641#define DST_RCDISC3__R1      (*(node->input[2]))
642#define DST_RCDISC3__R2      (*(node->input[3]))
643#define DST_RCDISC3__C      (*(node->input[4]))
659#define DST_RCDISC3__ENABLE   DISCRETE_INPUT(0)
660#define DST_RCDISC3__IN      DISCRETE_INPUT(1)
661#define DST_RCDISC3__R1      DISCRETE_INPUT(2)
662#define DST_RCDISC3__R2      DISCRETE_INPUT(3)
663#define DST_RCDISC3__C      DISCRETE_INPUT(4)
664#define DST_RCDISC3__DJV   DISCRETE_INPUT(6)
644665
645666static DISCRETE_STEP(dst_rcdisc3)
646667{
r5534r5535
653674   if(DST_RCDISC3__ENABLE)
654675   {
655676      diff = DST_RCDISC3__IN - node->output[0];
656      if( diff > 0 )
677      if (context->v_diode > 0)
657678      {
658         diff = diff - (diff * context->exponent0);
659      } else if( diff < 0)
679         if( diff > 0 )
680         {
681            diff = diff - (diff * context->exponent0);
682         } else if( diff < 0)
683         {
684            if(diff < -context->v_diode)
685               diff = diff - (diff * context->exponent1);
686            else
687               diff = diff - (diff * context->exponent0);
688         }
689      }
690      else
660691      {
661         if(diff < -0.5)
662            diff = diff - (diff * context->exponent1);
663         else
692         if( diff < 0 )
693         {
664694            diff = diff - (diff * context->exponent0);
695         } else if( diff > 0)
696         {
697            if(diff > -context->v_diode)
698               diff = diff - (diff * context->exponent1);
699            else
700               diff = diff - (diff * context->exponent0);
701         }
665702      }
666703      node->output[0] += diff;
667704   }
r5534r5535
679716
680717   context->state = 0;
681718   context->t = 0;
719   context->v_diode = DST_RCDISC3__DJV;
682720   context->exponent0 = RC_CHARGE_EXP(DST_RCDISC3__R1 * DST_RCDISC3__C);
683721   context->exponent1 = RC_CHARGE_EXP(RES_2_PARALLEL(DST_RCDISC3__R1, DST_RCDISC3__R2) * DST_RCDISC3__C);
684722}
r5534r5535
697735 * input[4]    - circuit type (initialization only)
698736 *
699737 ************************************************************************/
700#define DST_RCDISC4__ENABLE   (*(node->input[0]))
701#define DST_RCDISC4__IN      (*(node->input[1]))
702#define DST_RCDISC4__R1      (*(node->input[2]))
703#define DST_RCDISC4__R2      (*(node->input[3]))
704#define DST_RCDISC4__R3      (*(node->input[4]))
705#define DST_RCDISC4__C1      (*(node->input[5]))
706#define DST_RCDISC4__VP      (*(node->input[6]))
707#define DST_RCDISC4__TYPE   (*(node->input[7]))
738#define DST_RCDISC4__ENABLE   DISCRETE_INPUT(0)
739#define DST_RCDISC4__IN      DISCRETE_INPUT(1)
740#define DST_RCDISC4__R1      DISCRETE_INPUT(2)
741#define DST_RCDISC4__R2      DISCRETE_INPUT(3)
742#define DST_RCDISC4__R3      DISCRETE_INPUT(4)
743#define DST_RCDISC4__C1      DISCRETE_INPUT(5)
744#define DST_RCDISC4__VP      DISCRETE_INPUT(6)
745#define DST_RCDISC4__TYPE   DISCRETE_INPUT(7)
708746
709747static DISCRETE_STEP(dst_rcdisc4)
710748{
r5534r5535
742780   /* some error checking. */
743781   if (DST_RCDISC4__R1 <= 0 || DST_RCDISC4__R2 <= 0 || DST_RCDISC4__C1 <= 0 || (DST_RCDISC4__R3 <= 0 &&  context->type == 1))
744782   {
745      discrete_log(disc_info, "Invalid component values in NODE_%d.\n", node->node - NODE_00);
783      discrete_log(node->info, "Invalid component values in NODE_%d.\n", node->node - NODE_00);
746784      return;
747785   }
748786   if (DST_RCDISC4__VP < 3)
749787   {
750      discrete_log(disc_info, "vP must be >= 3V in NODE_%d.\n", node->node - NODE_00);
788      discrete_log(node->info, "vP must be >= 3V in NODE_%d.\n", node->node - NODE_00);
751789      return;
752790   }
753791   if (DST_RCDISC4__TYPE < 1 || DST_RCDISC4__TYPE > 3)
754792   {
755      discrete_log(disc_info, "Invalid circuit type in NODE_%d.\n", node->node - NODE_00);
793      discrete_log(node->info, "Invalid circuit type in NODE_%d.\n", node->node - NODE_00);
756794      return;
757795   }
758796
r5534r5535
813851 * input[3]    - Capacitor Value (initialization only)
814852 *
815853 ************************************************************************/
816#define DST_RCDISC5__ENABLE   (*(node->input[0]))
817#define DST_RCDISC5__IN      (*(node->input[1]))
818#define DST_RCDISC5__R      (*(node->input[2]))
819#define DST_RCDISC5__C      (*(node->input[3]))
854#define DST_RCDISC5__ENABLE   DISCRETE_INPUT(0)
855#define DST_RCDISC5__IN      DISCRETE_INPUT(1)
856#define DST_RCDISC5__R      DISCRETE_INPUT(2)
857#define DST_RCDISC5__C      DISCRETE_INPUT(3)
820858
821859static DISCRETE_STEP( dst_rcdisc5)
822860{
r5534r5535
877915 * input[8]    - Voltage Value (initialization only)
878916 *
879917 ************************************************************************/
880#define DST_RCDISC_MOD__IN1      (*(node->input[0]))
881#define DST_RCDISC_MOD__IN2      (*(node->input[1]))
882#define DST_RCDISC_MOD__R1      (*(node->input[2]))
883#define DST_RCDISC_MOD__R2      (*(node->input[3]))
884#define DST_RCDISC_MOD__R3      (*(node->input[4]))
885#define DST_RCDISC_MOD__R4      (*(node->input[5]))
886#define DST_RCDISC_MOD__C      (*(node->input[6]))
887#define DST_RCDISC_MOD__VP      (*(node->input[7]))
918#define DST_RCDISC_MOD__IN1      DISCRETE_INPUT(0)
919#define DST_RCDISC_MOD__IN2      DISCRETE_INPUT(1)
920#define DST_RCDISC_MOD__R1      DISCRETE_INPUT(2)
921#define DST_RCDISC_MOD__R2      DISCRETE_INPUT(3)
922#define DST_RCDISC_MOD__R3      DISCRETE_INPUT(4)
923#define DST_RCDISC_MOD__R4      DISCRETE_INPUT(5)
924#define DST_RCDISC_MOD__C      DISCRETE_INPUT(6)
925#define DST_RCDISC_MOD__VP      DISCRETE_INPUT(7)
888926
889927static DISCRETE_STEP(dst_rcdisc_mod)
890928{
r5534r5535
9701008 * input[4]    - Voltage reference. Usually 0V.
9711009 *
9721010 ************************************************************************/
973#define DST_RCFILTER__ENABLE      (*(node->input[0]))
974#define DST_RCFILTER__VIN      (*(node->input[1]))
975#define DST_RCFILTER__R         (*(node->input[2]))
976#define DST_RCFILTER__C         (*(node->input[3]))
977#define DST_RCFILTER__VREF      (*(node->input[4]))
1011#define DST_RCFILTER__ENABLE      DISCRETE_INPUT(0)
1012#define DST_RCFILTER__VIN      DISCRETE_INPUT(1)
1013#define DST_RCFILTER__R         DISCRETE_INPUT(2)
1014#define DST_RCFILTER__C         DISCRETE_INPUT(3)
1015#define DST_RCFILTER__VREF      DISCRETE_INPUT(4)
9781016
9791017static DISCRETE_STEP(dst_rcfilter)
9801018{
r5534r5535
10151053 * input[4]    - Voltage reference. Usually 0V.
10161054 *
10171055 ************************************************************************/
1018#define DST_RCFILTER_SW__ENABLE      (*(node->input[0]))
1019#define DST_RCFILTER_SW__VIN      (*(node->input[1]))
1020#define DST_RCFILTER_SW__SWITCH      (*(node->input[2]))
1021#define DST_RCFILTER_SW__R         (*(node->input[3]))
1022#define DST_RCFILTER_SW__C(x)      (*(node->input[4+x]))
1056#define DST_RCFILTER_SW__ENABLE      DISCRETE_INPUT(0)
1057#define DST_RCFILTER_SW__VIN      DISCRETE_INPUT(1)
1058#define DST_RCFILTER_SW__SWITCH      DISCRETE_INPUT(2)
1059#define DST_RCFILTER_SW__R         DISCRETE_INPUT(3)
1060#define DST_RCFILTER_SW__C(x)      DISCRETE_INPUT(4+x)
10231061
10241062#define CD4066_ON_RES  270
10251063#define DST_RCFILTER_SW_ITERATIONS   (10)
r5534r5535
10321070   int i,j ;
10331071   int bits = (int)DST_RCFILTER_SW__SWITCH;
10341072   double us = 0, rs = 0;
1073   double vd;
1074   double rt;
10351075
10361076   if (DST_RCFILTER_SW__ENABLE)
10371077   {
r5534r5535
10481088         context->vCap[1] += (DST_RCFILTER_SW__VIN - context->vCap[1]) * context->exp1;
10491089         node->output[0] = context->vCap[1] + (DST_RCFILTER_SW__VIN - context->vCap[1]) * context->factor;
10501090         break;
1091      case 3:
1092         rs = 2 * DST_RCFILTER_SW__R;
1093         vd = RES_VOLTAGE_DIVIDER(rs, CD4066_ON_RES) * DST_RCFILTER_SW__VIN;
1094         rt = DST_RCFILTER_SW__R / (CD4066_ON_RES + rs);
1095
1096         for (j = 0; j < DST_RCFILTER_SW_ITERATIONS; j++)
1097         {
1098            node->output[0] = vd + rt  * (context->vCap[0] + context->vCap[1]);
1099            context->vCap[0] += (node->output[0] - context->vCap[0]) * context->exp[0];
1100            context->vCap[1] += (node->output[0] - context->vCap[1]) * context->exp[1];
1101         }
1102         break;
10511103      default:
1104         rs = 0;
1105
1106         for (i = 0; i < 4; i++)
1107         {
1108            if (( bits & (1 << i)) != 0)
1109            {
1110               rs += DST_RCFILTER_SW__R;
1111            }
1112         }
1113
1114         vd = RES_VOLTAGE_DIVIDER(rs, CD4066_ON_RES) * DST_RCFILTER_SW__VIN;
1115         rt = DST_RCFILTER_SW__R / (CD4066_ON_RES + rs);
1116
10521117         for (j = 0; j < DST_RCFILTER_SW_ITERATIONS; j++)
10531118         {
1119            us = 0;
10541120            for (i = 0; i < 4; i++)
10551121            {
10561122               if (( bits & (1 << i)) != 0)
10571123               {
10581124                  us += context->vCap[i];
1059                  rs += DST_RCFILTER_SW__R;
10601125               }
10611126            }
1062            node->output[0] = RES_VOLTAGE_DIVIDER(rs, CD4066_ON_RES) * DST_RCFILTER_SW__VIN + DST_RCFILTER_SW__R / (CD4066_ON_RES + rs)  * us;
1127            node->output[0] = vd + rt  * us;
10631128            for (i = 0; i < 4; i++)
10641129            {
10651130               if (( bits & (1 << i)) != 0)
r5534r5535
11081173 * input[5]    - Capacitor Value (initialization only)
11091174 *
11101175 ************************************************************************/
1111#define DST_RCINTEGRATE__IN1   (*(node->input[0]))
1112#define DST_RCINTEGRATE__R1      (*(node->input[1]))
1113#define DST_RCINTEGRATE__R2      (*(node->input[2]))
1114#define DST_RCINTEGRATE__R3      (*(node->input[3]))
1115#define DST_RCINTEGRATE__C      (*(node->input[4]))
1116#define DST_RCINTEGRATE__VP      (*(node->input[5]))
1117#define DST_RCINTEGRATE__TYPE   (*(node->input[6]))
1176#define DST_RCINTEGRATE__IN1   DISCRETE_INPUT(0)
1177#define DST_RCINTEGRATE__R1      DISCRETE_INPUT(1)
1178#define DST_RCINTEGRATE__R2      DISCRETE_INPUT(2)
1179#define DST_RCINTEGRATE__R3      DISCRETE_INPUT(3)
1180#define DST_RCINTEGRATE__C      DISCRETE_INPUT(4)
1181#define DST_RCINTEGRATE__VP      DISCRETE_INPUT(5)
1182#define DST_RCINTEGRATE__TYPE   DISCRETE_INPUT(6)
11181183
11191184/* Ebers-Moll large signal model
11201185 * Couriersud:
r5534r5535
11981263   struct dst_rcintegrate_context *context = (struct dst_rcintegrate_context *)node->context;
11991264
12001265   double r;
1201   double dt = disc_info->sample_time;
1266   double dt = node->info->sample_time;
12021267
12031268   context->type = DST_RCINTEGRATE__TYPE;
12041269
r5534r5535
12331298 *
12341299 * 2008, couriersud
12351300 ************************************************************************/
1236#define DST_SALLEN_KEY__ENABLE   (*(node->input[0]))
1237#define DST_SALLEN_KEY__INP0   (*(node->input[1]))
1238#define DST_SALLEN_KEY__TYPE   (*(node->input[2]))
1301#define DST_SALLEN_KEY__ENABLE   DISCRETE_INPUT(0)
1302#define DST_SALLEN_KEY__INP0   DISCRETE_INPUT(1)
1303#define DST_SALLEN_KEY__TYPE   DISCRETE_INPUT(2)
12391304
12401305static DISCRETE_STEP(dst_sallen_key)
12411306{
r5534r5535
12741339         fatalerror("Unknown sallen key filter type");
12751340   }
12761341
1277   calculate_filter2_coefficients(disc_info, freq, 1.0 / q, DISC_FILTER_LOWPASS,
1342   calculate_filter2_coefficients(node->info, freq, 1.0 / q, DISC_FILTER_LOWPASS,
12781343                           &context->a1, &context->a2,
12791344                           &context->b0, &context->b1, &context->b2);
12801345   node->output[0] = 0;
r5534r5535
12941359 * input[3]    - Capacitor Value (initialization only)
12951360 *
12961361 ************************************************************************/
1297#define DST_RCFILTERN__ENABLE      (*(node->input[0]))
1298#define DST_RCFILTERN__IN      (*(node->input[1]))
1299#define DST_RCFILTERN__R      (*(node->input[2]))
1300#define DST_RCFILTERN__C      (*(node->input[3]))
1362#define DST_RCFILTERN__ENABLE      DISCRETE_INPUT(0)
1363#define DST_RCFILTERN__IN      DISCRETE_INPUT(1)
1364#define DST_RCFILTERN__R      DISCRETE_INPUT(2)
1365#define DST_RCFILTERN__C      DISCRETE_INPUT(3)
13011366
13021367static DISCRETE_RESET(dst_rcfilterN)
13031368{
r5534r5535
13271392 * input[3]    - Capacitor Value (initialization only)
13281393 *
13291394 ************************************************************************/
1330#define DST_RCDISCN__ENABLE   (*(node->input[0]))
1331#define DST_RCDISCN__IN      (*(node->input[1]))
1332#define DST_RCDISCN__R      (*(node->input[2]))
1333#define DST_RCDISCN__C      (*(node->input[3]))
1395#define DST_RCDISCN__ENABLE   DISCRETE_INPUT(0)
1396#define DST_RCDISCN__IN      DISCRETE_INPUT(1)
1397#define DST_RCDISCN__R      DISCRETE_INPUT(2)
1398#define DST_RCDISCN__C      DISCRETE_INPUT(3)
13341399
13351400static DISCRETE_RESET(dst_rcdiscN)
13361401{
r5534r5535
13841449 * input[5]    - Capacitor Value (initialization only)
13851450 *
13861451 ************************************************************************/
1387#define DST_RCDISC2N__ENABLE      (*(node->input[0]))
1388#define DST_RCDISC2N__IN0      (*(node->input[1]))
1389#define DST_RCDISC2N__R0      (*(node->input[2]))
1390#define DST_RCDISC2N__IN1      (*(node->input[3]))
1391#define DST_RCDISC2N__R1      (*(node->input[4]))
1392#define DST_RCDISC2N__C         (*(node->input[5]))
1452#define DST_RCDISC2N__ENABLE      DISCRETE_INPUT(0)
1453#define DST_RCDISC2N__IN0      DISCRETE_INPUT(1)
1454#define DST_RCDISC2N__R0      DISCRETE_INPUT(2)
1455#define DST_RCDISC2N__IN1      DISCRETE_INPUT(3)
1456#define DST_RCDISC2N__R1      DISCRETE_INPUT(4)
1457#define DST_RCDISC2N__C         DISCRETE_INPUT(5)
13931458
13941459struct dss_rcdisc2_context
13951460{
r5534r5535
14221487   f1 = 1.0 / (2 * M_PI * DST_RCDISC2N__R0 * DST_RCDISC2N__C);
14231488   f2 = 1.0 / (2 * M_PI * DST_RCDISC2N__R1 * DST_RCDISC2N__C);
14241489
1425   calculate_filter1_coefficients(disc_info, f1, DISC_FILTER_LOWPASS, &context->a1_0, &context->b0_0, &context->b1_0);
1426   calculate_filter1_coefficients(disc_info, f2, DISC_FILTER_LOWPASS, &context->a1_1, &context->b0_1, &context->b1_1);
1490   calculate_filter1_coefficients(node->info, f1, DISC_FILTER_LOWPASS, &context->a1_0, &context->b0_0, &context->b1_0);
1491   calculate_filter1_coefficients(node->info, f2, DISC_FILTER_LOWPASS, &context->a1_1, &context->b0_1, &context->b1_1);
14271492
14281493   /* Initialize the object */
14291494   node->output[0] = 0;
src/mess/tools/messtest/messtest.mak
r5534r5535
3737
3838#$(MESSTEST_OBJS): maketree
3939
40$(MESSTEST): $(VERSIONOBJ) $(MESSTEST_OBJS) $(LIBIMGTOOL) $(DRVLIBS) $(LIBEMU) $(LIBCPU) $(LIBSOUND) $(LIBUTIL) $(EXPAT) $(ZLIB) $(LIBOCORE)
40$(MESSTEST): $(VERSIONOBJ) $(MESSTEST_OBJS) $(LIBIMGTOOL) $(DRVLIBS) $(LIBEMU) $(LIBCPU) $(LIBDASM) $(LIBSOUND) $(LIBUTIL) $(EXPAT) $(ZLIB) $(LIBOCORE)
4141   @echo Linking $@...
4242   $(LD) $(LDFLAGS) $^ $(LIBS) $(EXPAT) -o $@
src/mess/mess.mak
r5534r5535
4444#-------------------------------------------------
4545
4646CPUS += Z80
47#CPUS += Z180
47CPUS += Z180
4848CPUS += I8085
4949CPUS += M6502
5050CPUS += H6280
r5534r5535
5252CPUS += I386
5353CPUS += NEC
5454CPUS += V30MZ
55#CPUS += V60
55CPUS += V60
5656CPUS += MCS48
5757CPUS += MCS51
5858CPUS += M6800
5959CPUS += M6805
6060CPUS += HD6309
6161CPUS += M6809
62#CPUS += KONAMI
62CPUS += KONAMI
6363CPUS += M680X0
6464CPUS += T11
6565CPUS += S2650
66#CPUS += TMS340X0
66CPUS += TMS340X0
6767CPUS += TMS9900
6868CPUS += Z8000
6969CPUS += TMS32010
70#CPUS += TMS32025
71#CPUS += TMS32031
72#CPUS += TMS32051
73#CPUS += TMS57002
74#CPUS += CCPU
75#CPUS += ADSP21XX
76#CPUS += ASAP
70CPUS += TMS32025
71CPUS += TMS32031
72CPUS += TMS32051
73CPUS += TMS57002
74CPUS += CCPU
75CPUS += ADSP21XX
76CPUS += ASAP
7777CPUS += UPD7810
7878CPUS += ARM
7979CPUS += ARM7
8080CPUS += JAGUAR
81#CPUS += CUBEQCPU
82#CPUS += ESRIP
81CPUS += CUBEQCPU
82CPUS += ESRIP
8383CPUS += MIPS
8484CPUS += SH2
8585CPUS += SH4
86#CPUS += DSP32C
87#CPUS += PIC16C5X
86CPUS += DSP32C
87CPUS += PIC16C5X
8888CPUS += G65816
8989CPUS += SPC700
90#CPUS += E1
91#CPUS += I860
92#CPUS += I960
90CPUS += E1
91CPUS += I860
92CPUS += I960
9393CPUS += H83002
9494CPUS += H83334
9595CPUS += V810
96#CPUS += M37710
96CPUS += M37710
9797CPUS += POWERPC
98#CPUS += SE3208
99#CPUS += MC68HC11
100#CPUS += ADSP21062
101#CPUS += DSP56156
98CPUS += SE3208
99CPUS += MC68HC11
100CPUS += ADSP21062
101CPUS += DSP56156
102102CPUS += RSP
103#CPUS += ALPHA8201
103CPUS += ALPHA8201
104104CPUS += CDP1802
105105CPUS += COP400
106#CPUS += TLCS90
106CPUS += TLCS90
107107CPUS += TLCS900
108#CPUS += MB88XX
109#CPUS += MB86233
108CPUS += MB88XX
109CPUS += MB86233
110110CPUS += SSP1601
111111CPUS += APEXC
112112CPUS += CP1610
113113CPUS += F8
114#CPUS += LH5801
114CPUS += LH5801
115115CPUS += PDP1
116116CPUS += SATURN
117117CPUS += SC61860
r5534r5535
123123CPUS += AVR8
124124CPUS += TMS0980
125125CPUS += I4004
126CPUS += SUPERFX
126127
127128
128129
src/mess/osd/windows/windows.mak
r5534r5535
7878
7979EXECUTABLE_DEFINED = 1
8080
81$(EMULATORDLL): $(VERSIONOBJ) $(OBJ)/mess/osd/windows/messlib.o $(DRVLIBS) $(LIBOSD) $(LIBEMU) $(LIBCPU) $(LIBSOUND) $(LIBUTIL) $(EXPAT) $(ZLIB) $(LIBOCORE) $(MESS_WINOBJ)/mess.res
81$(EMULATORDLL): $(VERSIONOBJ) $(OBJ)/mess/osd/windows/messlib.o $(DRVLIBS) $(LIBOSD) $(LIBEMU) $(LIBCPU) $(LIBDASM) $(LIBSOUND) $(LIBUTIL) $(EXPAT) $(ZLIB) $(LIBOCORE) $(MESS_WINOBJ)/mess.res
8282# always recompile the version string
8383   $(CC) $(CDEFS) $(CFLAGS) -c $(SRC)/version.c -o $(VERSIONOBJ)
8484   @echo Linking $@...
docs/messnew.txt
r5534r5535
5959
6060Source Changes:
6161----------------
62- The core is based on MAME 0.133u3.  This incorporates all features of the
62- The core is based on MAME 0.133u4.  This incorporates all features of the
6363  update to this core.  [MAME team]
6464
6565
makefile
r5534r5535
420420
421421LIBEMU = $(OBJ)/libemu.a
422422LIBCPU = $(OBJ)/libcpu.a
423LIBDASM = $(OBJ)/libdasm.a
423424LIBSOUND = $(OBJ)/libsound.a
424425LIBUTIL = $(OBJ)/libutil.a
425426LIBOCORE = $(OBJ)/libocore.a
r5534r5535
537538
538539ifndef EXECUTABLE_DEFINED
539540
540$(EMULATOR): $(VERSIONOBJ) $(DRVLIBS) $(LIBOSD) $(LIBEMU) $(LIBCPU) $(LIBSOUND) $(LIBUTIL) $(EXPAT) $(ZLIB) $(LIBOCORE) $(RESFILE)
541$(EMULATOR): $(VERSIONOBJ) $(DRVLIBS) $(LIBOSD) $(LIBEMU) $(LIBCPU) $(LIBDASM) $(LIBSOUND) $(LIBUTIL) $(EXPAT) $(ZLIB) $(LIBOCORE) $(RESFILE)
541542# always recompile the version string
542543   $(CC) $(CDEFS) $(CFLAGS) -c $(SRC)/version.c -o $(VERSIONOBJ)
543544   @echo Linking $@...

Previous 15994 Revisions Next


© 1998-2018 The MESS Team