Previous 15994 Revisions Next

r1071 Friday 5th October, 2007 at 12:52:48 UTC by Nathan Woods
Updated to MAME 0.119u3 core
[docs]messnew.txt
[src/emu]cheat.c mamecore.h memory.c memory.h uigfx.c
[src/emu/cpu]cpu.mak drcfe.c drcfe.h
[src/emu/cpu/arm7]arm7core.h
[src/emu/cpu/i86]i286intf.h instr86.c
[src/emu/cpu/m6502]m6502.h
[src/emu/cpu/m68000]m68kcpu.h
[src/emu/cpu/minx]minxfunc.h
[src/emu/cpu/mips]mdrc64.c mdrcold.c mips3.c mips3com.c mips3drc.c mips3fe.c mips3fe.h
[src/emu/cpu/nec]nec.c
[src/emu/cpu/powerpc]ppc.h
[src/emu/cpu/spc700]spc700ds.h
[src/emu/cpu/v60]v60.h
[src/emu/debug]debugvw.h
[src/emu/sound]s14001a.h scspdsp.c speaker.c wave.c
[src/emu/video]generic.c resnet.h vector.c
[src/lib/util]options.c
[src/mame]mame.mak mamedriv.c
[src/mame/audio]atarijsa.c atarijsa.h harddriv.c
[src/mame/drivers]2mindril.c bnstars.c* cabal.c cps3.c cultures.c cvs.c ddenlovr.c ddragon.c djboy.c dynduke.c expro02.c firebeat.c galaga.c gstream.c hornet.c igs_180.c jongkyo.c* looping.c m72.c macrossp.c megadriv.h megaplay.c megatech.c mitchell.c model2.c mpu4.c ms32.c pacman.c polepos.c seattle.c segac2.c segae.c segae.h segas16a.c sliver.c snowbros.c spdodgeb.c srmp6.c starfire.c superqix.c system16.c system24.c tehkanwc.c vegas.c
[src/mame/includes]amiga.h cubocd32.h dc.h genesis.h m107.h m92.h megasys1.h nam_cust.h* namcos21.h
[src/mame/machine]6526cia.h 6532riot.h 8237dma.c 8237dma.h at28c16.h atarigen.h harddriv.c irem_cpu.c laserdsc.h mb3773.c mb3773.h mb87078.c mc146818.c mc146818.h msm6242.c msm6242.h pci.c pci.h pgmy2ks.c pic8259.c pic8259.h rtc65271.c rtc65271.h segacrpt.c segacrpt.h timekpr.h tmp68301.h wd33c93.h znsec.c znsec.h
[src/mame/video]bfm_adr2.h changela.c dynduke.c grchamp.c kaneko16.c m92.c mitchell.c model2.c model2rd.c* pastelg.c poly.c poly.h ppu2c0x.c ppu2c0x.h realbrk.c spdodgeb.c st0016.c system1.c system1.h turbo.c vooddefs.h voodoo.c voodoo.h
[src/mess/machine]i82439tx.c mpc105.c
[src/mess/tools/messtest]tststubs.c
[src/osd]osdcore.h
[src/osd/windows]sound.c video.h window.h winsync.c winwork.c
[src/tools]chdcd.c runtest.cmd

src/mame/audio/atarijsa.c
r1070r1071
3030
3131****************************************************************************/
3232
33#include "machine/atarigen.h"
34#include "audio/atarijsa.h"
33#include "driver.h"
3534#include "cpu/m6502/m6502.h"
3635#include "sound/5220intf.h"
3736#include "sound/2151intf.h"
3837#include "sound/okim6295.h"
3938#include "sound/pokey.h"
39#include "machine/atarigen.h"
40#include "audio/atarijsa.h"
4041
4142static UINT8 *bank_base;
4243static UINT8 *bank_source_data;
src/mame/audio/atarijsa.h
r1070r1071
44
55****************************************************************************/
66
7#include "driver.h"
8#include "machine/atarigen.h"
97
108
119#define ATARI_CLOCK_3MHz      3579000
src/mame/audio/harddriv.c
r1070r1071
44
55****************************************************************************/
66
7#include "driver.h"
78#include "cpu/tms32010/tms32010.h"
9#include "sound/dac.h"
810#include "machine/atarigen.h"
911#include "harddriv.h"
10#include "sound/dac.h"
1112
1213
1314#define BIO_FREQUENCY      (1000000 / 50)
src/mame/machine/mc146818.h
r1070r1071
1414#ifndef MC146818_H
1515#define MC146818_H
1616
17#include "driver.h"
18
1917typedef enum
2018{
2119   MC146818_STANDARD,
src/mame/machine/irem_cpu.c
r1070r1071
302302const UINT8 gussun_decryption_table[256] = {
303303   0xcd,xxxx,xxxx,0x36,xxxx,0x52,0xb1,0x5b, 0x68,0xcd,xxxx,xxxx,xxxx,0xa8,xxxx,xxxx, /* 00 */
304304//      !!!!                                     ^^^^ !!!!                !!!!
305   xxxx,xxxx,0x75,0x24,0x09,0x83,0x32,0xe9, xxxx,0x79,xxxx,0x01,0x22,xxxx,0xac,xxxx, /* 10 */
305   xxxx,xxxx,0x75,0x24,0x01,0x83,0x32,0xe9, xxxx,0x78,xxxx,0x19,0x22,xxxx,0xac,xxxx, /* 10 */
306306//                     !!!! ????      ^^^^            ????      ???? !!!!      ^^^^
307   0x5d,0xa5,0x1a,0x51,0x0a,xxxx,0x19,xxxx ,0xf8,0x48,0x91,0x40,0x28,0x19,0x03,0x5f, /* 20 */
307   0x5d,0xa5,0x10,0x51,0x0a,xxxx,0x19,xxxx ,0xf8,0x90,0x91,0x40,0x28,0x22,0x03,0x5f, /* 20 */
308308//                ????      !!!!      ????       ^^^^ ???? ^^^^ gggg gggg ????
309   0x26,xxxx,xxxx,0x8b,0x2f,0x02,xxxx,xxxx, 0x8e,0xab,xxxx,xxxx,0xbc,0xf1,0xb3,xxxx, /* 30 */
309   0x26,xxxx,xxxx,0x8b,xxxx,0x02,xxxx,xxxx, 0x8e,0xab,xxxx,xxxx,0xbc,0xf1,0xb3,xxxx, /* 30 */
310310//
311   xxxx,xxxx,0xc6,xxxx,0x8c,0x3a,0x19,xxxx, xxxx,0x74,0x61,xxxx,0x33,xxxx,0x19,xxxx, /* 40 */
312//           ????           ????      ????                 !!!!                ????
313   xxxx,0x53,0xa0,0xc0,0xc3,0x41,0xfc,0xe7, xxxx,0x1c,0x76,0x2b,xxxx,xxxx,0xba,0x2a, /* 50 */
314//                !!!! ^^^^      ^^^^                 ???? ???? !!!!                !!!!
315   0xb0,xxxx,xxxx,0x7c,xxxx,xxxx,0xb5,0x07, 0xb9,xxxx,0x27,0x46,0xf9,xxxx,xxxx,xxxx, /* 60 */
316//                     ????                                !!!! ^^^^
311   xxxx,0x19,0xc6,xxxx,xxxx,0x3a,0x10,xxxx, xxxx,0x74,0x61,xxxx,0x33,xxxx,0x19,xxxx, /* 40 */
312//           ????                     ????                 !!!!                ????
313   xxxx,0x53,0xa0,0xc0,0xc3,0x41,0xfc,0xe7, xxxx,0x2c,0x7f,0x2b,xxxx,xxxx,0xba,0x2a, /* 50 */
314//                !!!! ^^^^      ^^^^                 gggg ???? !!!!                !!!!
315   0xb0,xxxx,0x28,0x7e,xxxx,xxxx,0xb5,0x07, 0xb9,xxxx,0x27,0x46,0xf9,xxxx,xxxx,xxxx, /* 60 */
316//                ???? gggg                                !!!! ^^^^
317317   xxxx,0xea,0x72,0x73,0xad,0xd1,0x3b,0x5e, 0xe5,0x57,xxxx,0x0d,xxxx,xxxx,xxxx,0x3c, /* 70 */
318318//                          ^^^^
319   xxxx,0x86,xxxx,0x19,0x28,0x25,0x2d,xxxx, 0x9a,0xeb,0x04,0x0b,0xa2,0xb8,0xf6,xxxx, /* 80 */
319   xxxx,0x86,xxxx,0xb7,0x30,0x25,0x2d,xxxx, 0x9a,0xeb,0x04,0x0b,0xa2,0xb8,0xf6,xxxx, /* 80 */
320320//                     ???? ????                           ^^^^      !!!!      !!!!
321321   xxxx,xxxx,0x9d,xxxx,0xbb,xxxx,xxxx,0xcb, 0xa9,0xcf,xxxx,0x60,0x43,0x56,xxxx,0x19, /* 90 */
322322//                ^^^^                     ^^^^  !!!! ^^^^      !!!!                ????
323   xxxx,0xa3,xxxx,xxxx,xxxx,xxxx,0xfa,0xb4, xxxx,0x81,0xe6,xxxx,0x80,0x8c,0xd4,xxxx, /* a0 */
324//                                         gggg                           gggg !!!!
325   xxxx,0x19,0x19,xxxx,0x7d,0x3d,0x3e,xxxx, xxxx,xxxx,0x4b,xxxx,xxxx,xxxx,xxxx,xxxx, /* b0 */
326//           ???? ???? ???? ^^^^                           ????
323   xxxx,0xa3,xxxx,xxxx,xxxx,xxxx,0xfa,0xb4, xxxx,0x81,0xe6,0x42,0x80,0x8c,0xd4,xxxx, /* a0 */
324//                                         gggg                 ????      gggg !!!!
325   xxxx,0x11,0x11,0x11,0x77,0x3d,0x3e,xxxx, xxxx,xxxx,0x4b,xxxx,xxxx,xxxx,xxxx,xxxx, /* b0 */
326//           ???? ???? ???? gggg                           ????
327327   xxxx,0xff,0x47,xxxx,0x55,0x1e,xxxx,0x59, 0x93,xxxx,xxxx,xxxx,0x88,0xc1,0x11,0xb2, /* c0 */
328328//                ^^^^                           ^^^^                     ^^^^ ????
329329   xxxx,0x2e,0x06,0xc7,0x05,xxxx,0x8a,0x5a, 0x58,0xbe,xxxx,xxxx,xxxx,0x1f,0x23,xxxx, /* d0 */
330//           ^^^^
330//           ^^^^                                               ????
331331   0xe8,xxxx,0x89,0xa1,0xd0,xxxx,0x19,0xe2, 0x38,0xfe,0x50,0x9c,xxxx,xxxx,xxxx,0x49, /* e0 */
332332//                                    ????                      ^^^^                !!!!
333   0xfb,xxxx,0xf3,xxxx,xxxx,0x0f,xxxx,xxxx, xxxx,xxxx,0xf7,0xbd,0x39,0x7d,0xbf,xxxx, /* f0 */
334//      !!!!                                                    !!!!      ????
333   0xfb,xxxx,0xf3,xxxx,xxxx,0x0f,xxxx,xxxx, xxxx,0x70,0xf7,0xbd,0x39,0x7f,0xbf,xxxx, /* f0 */
334//      !!!!                                          ????      !!!!      gggg
335335};
336
337
336338/*
337339missing opcode:
338340
339***14 -> ??  (2097b - 20980 (01 09 11 31
340+++19 -> 78? (2282f - routine from 2281f to 22871) (78, 79, 7a, 7b)
341+++1b -> 01? (1d8f9 - routine from 1d8c7 to 1d8fc) - three bytes (09,11,21,29,31 - 01,19)
342+++22 -> 00? (1deff - routine from 1dee8 to 1df26) (01,09,10,11,18,19,1a,1b,20,21,28,29,30,31 - 00,08,13 - 12
343+++26 -> ??  (14ed_ , 198e_
344*+*29 -> 48? (1df22 - routine from 1df1d to
345+++2d -> 1a? (1df1d - routine from 1dee8 to 1df26) (00,01,10,11,12,13,20,21,28,29,30,31 - 08,09,18,19
346---41 -> ??
347///46 -> ??  (1461b
348---4e -> ??  (208ac -
349///5a -> ??  (222fc - routine from 222ed to ) (7x j...)
350///63 -> ??  (1df7f, 1df8c, 1df95,21f08 - routine from 1df1d to ) - two bytes j..
351---83 -> ??  (
352***84 -> 18? (1d8f1 - routine from 1d8c7 to 1d8fc) - three bytes (00,08,10,18,20,28,30)
353---9f -> ??  (
354---b1 -> ??
355---b2 -> ??  (20a8c - 20acd
356///b3 -> ??  (216b6 - 216cf
357///ba -> ??  (1094d, 10b28 - routine from 10948 to 10b73) one byte (4b
358+++ce -> 21? (10236 - routine from 1017e to 10254) (01, 09, 11, 19, 21, 29, 31)
359---e6 -> ??  (1d8f7 -
360+++fd -> 79? (1d659 - routine from 1d63c to 1d65e) (78,7a - 79,7b - 7d)
3411**14 -> 09? (2097b - 20980 (01 09 11 31
342+++19 -> 79? (2282f - routine from 2281f to 22871) (78, 79, 7a, 7b)
3430++1b -> 19? (1d8f9 - routine from 1d8c7 to 1d8fc) - three bytes (09,11,21,29,31 - 01,19)
34401+22 -> 00? (1deff - routine from 1dee8 to 1df26) no 08,18,20,30 - ok 00,10
3450++26 -> 29? (14ed_ , 198e_
34601*29 -> 48? (1df22 - routine from 1df1d to
34701+2d -> 1a? (1df1d - routine from 1dee8 to 1df26) (00,01,10,11,12,13,20,21,28,29,30,31 - 08,09,18,19
348---41 -> 19?
349///46 -> 10? (1461b
350---4e -> 19? (208ac -
3511//5a -> 76? (222fc - routine from 222ed to ) (7x j...) 70 76 78 7a 7c
3521//62 -> 28? (1cf86 1cfa3 - routine from 1cf61 to 1cff4)  (water in level 1)
3531--83 -> b7? (194cd - routine from
3540**84 -> 18? (1d8f1 - routine from 1d8c7 to 1d8fc) - three bytes (00,08,10,18,20,28,30)
355---9f -> 19? (
356///ab -> 42?
357---b1 -> 19?
358---b2 -> 19? (20a8c - 20acd
359///b3 -> 19? (216b6 - 216cf
360///ba -> 4b? (1094d, 10b28 - routine from 10948 to 10b73) one byte (4b
36101+ce -> 11? (10236 - routine from 1017e to 10254) (01, 09, 11, 19, 21, 29, 31)
362///db ->     (16992
363///f9 -> 71? (16598 - 165a1 - 18de7 - routine from 18dc4 to ) 70,71
361364
365
362366rz guess:
3633672b -> 40 (1d4d2 1db81 1dba9 - routine from 1d4b2 to 1d4de) (ok 40,48,96) -> 40
364368         (no 0e,16,17,27,2f,37,3f,41,42,44,45,4a,4b,4c,4d,4e,4f,54,5c,6c,6d,92,94,95,97)
3653692c -> 28 (20333 - routine from 2032a to 20366)
36659 -> 1c (220cf - 2037f - routine from 2202f to ) 2bytes (1c,
37059 -> 2c (220cf - 2037f - routine from 2202f to ) 2bytes (2c,
37163 -> 7d (1df7f, 1df8c, 1df95,21f08 - routine from 1df1d to ) - two bytes j..
367372a7 -> b4 (2029a - routine from 20290 to
368373ad -> 8c (1d559, 1d8d4 - routine from 1d547 - ; routine from 1d8b8 to 1d8fc)
369     (00,01,08,09,0c,10,11,12,13,14,18,19,1a,1b,1c,20,21,28,29,2c,30,31,34,87,b4,b6,b7)
374b4 -> 77 (1d03a, 1d57a - routine from 1d4df ) 7f,7d,7b  -  79 - "77"
375fd -> 7f (1d659 - routine from 1d63c to 1d65e) 77,7f
370376
371377missing V35+ core:
37237800    -> 63    not supported (229e2 - routine from 229da to 229ec) (for now we use cd instruction + hack)
src/mame/machine/timekpr.h
r1070r1071
88#if !defined( TIMEKPR_H )
99#define TIMEKPR_H ( 1 )
1010
11#include "driver.h"
12
1311extern void timekeeper_init( int chip, int type, UINT8 *data );
1412
1513#define MAX_TIMEKEEPER_CHIPS ( 1 )
src/mame/machine/pgmy2ks.c
r1070r1071
1717// Following table gives the decrypted sprite offset given the sprite number.
1818// The actual decryption algorithm is unknown.
1919
20#include "osdcore.h"
20#include "driver.h"
2121
2222const UINT32 pgmy2ks[0x3c00] = {
2323   0x000000, 0x00007c, 0x0000f8, 0x000174, 0x0001f0, 0x00026c, 0x0002e8, 0x000364,
src/mame/machine/msm6242.c
r1070r1071
44
55***************************************************************************/
66
7#include "driver.h"
78#include "machine/msm6242.h"
89
910static UINT8 msm6264_reg[3] = { 0, 0, 0 };
src/mame/machine/msm6242.h
r1070r1071
11#ifndef MSM6242_INCLUDE
22#define MSM6242_INCLUDE
33
4#include "driver.h"
5
64READ8_HANDLER( msm6242_r );
75WRITE8_HANDLER( msm6242_w );
86
src/mame/machine/pic8259.c
r1070r1071
1111
1212**********************************************************************/
1313
14#include "driver.h"
15#include "memconv.h"
1416#include "machine/pic8259.h"
15#include "memconv.h"
1617
1718#define IRQ_COUNT   8
1819
src/mame/machine/wd33c93.h
r1070r1071
1818extern void wd33c93_get_dma_data(int bytes, UINT8 *pData);
1919extern void wd33c93_write_data(int bytes, UINT8 *pData);
2020extern void *wd33c93_get_device(int id);
21extern void wd33c93_set_device(int id, void *);
2221extern void wd33c93_clear_dma(void);
2322extern int wd33c93_get_dma_count(void);
2423extern READ8_HANDLER(wd33c93_r);
src/mame/machine/pic8259.h
r1070r1071
77#ifndef PIC8259_H
88#define PIC8259_H
99
10#include "driver.h"
11
12
1310int pic8259_init(int count, void (*set_int_line)(int which, int interrupt));
1411int pic8259_acknowledge(int which);
1512void pic8259_set_irq_line(int which, int irq, int state);
src/mame/machine/at28c16.h
r1070r1071
88#if !defined( AT28C16_H )
99#define AT28C16_H ( 1 )
1010
11#include "driver.h"
12
1311#define MAX_AT28C16_CHIPS ( 4 )
1412
1513extern void at28c16_a9_12v( int chip, int a9_12v );
src/mame/machine/harddriv.c
r1070r1071
44
55****************************************************************************/
66
7#include "machine/atarigen.h"
7#include "driver.h"
88#include "cpu/tms34010/tms34010.h"
99#include "cpu/tms34010/34010ops.h"
1010#include "cpu/adsp2100/adsp2100.h"
1111#include "cpu/m68000/m68000.h"
1212#include "cpu/dsp32/dsp32.h"
13#include "machine/atarigen.h"
1314#include "machine/asic65.h"
1415#include "audio/atarijsa.h"
1516#include "harddriv.h"
src/mame/machine/segacrpt.c
r1070r1071
111111  ???-????      Top Roller             same key as Yamato
112112  315-5028      Sindbad Mystery
113113  315-5030      Up'n Down &            unencrypted version available
114          M120 Razzmatazz
114  ???-???? M120 Razzmatazz
115115  315-5033      Regulus                unencrypted version available
116116  315-5041 M140 Mister Viking
117117  315-5048      SWAT                   used Bull Fight for k.p.a.
r1070r1071
123123  315-5069      Star Force             game by Tehkan; same key as Super Locomotive
124124  ???-????      Pinball Action         game by Tehkan; also has a simple bitswap on top
125125  ???-????      Spatter
126  315-5084      Jongkyo                TABLE INCOMPLETE game by Kiwako; also has a simple bitswap on top
126127  315-5093      Pitfall II
127128  315-5098      Ninja Princess         unencrypted version available; same key as Up'n Down
128129  315-5102      Sega Ninja             unencrypted version available
r1070r1071
230231{
231232   lfkp(0x57);
232233}
233
234static void read_table_from_disk(UINT8 *xortable)
235{
236   FILE *f;
237
238
239   f = fopen("table","rb");
240
241   if (f) fread(xortable,1,128,f);
242
243   fclose(f);
244}
245234#endif
246235
247236static void sega_decode(const UINT8 convtable[32][4])
r1070r1071
280269      rom[A] = (src & ~0xa8) | (convtable[2*row+1][col] ^ xor);
281270
282271      if (convtable[2*row][col] == 0xff)   /* table incomplete! (for development) */
283         decrypted[A] = 0x00;
272         decrypted[A] = 0xee;
284273      if (convtable[2*row+1][col] == 0xff)   /* table incomplete! (for development) */
285274         rom[A] = 0xee;
286275   }
r1070r1071
797786}
798787
799788
789void jongkyo_decode(void)
790{
791   /* encrypted ROM is banked */
792   UINT8 *decrypted;
793
794   static const UINT8 convtable[32][4] =
795   {
796      /*       opcode                   data                     address      */
797      /*  A    B    C    D         A    B    C    D                           */
798      { 0x28,0x08,0xa8,0x88 }, { 0xa0,0xa8,0x20,0x28 },   /* ...0...0...0...0 */
799      { 0x80,0x88,0xa0,0xa8 }, { 0xa0,0xa8,0x20,0x28 },   /* ...0...0...0...1 */
800      { 0xa0,0xa8,0x20,0x28 }, { 0x20,0xa0,0x00,0x80 },   /* ...0...0...1...0 */
801      { 0xa0,0xa8,0x20,0x28 }, { 0x80,0x88,0xa0,0xa8 },   /* ...0...0...1...1 */
802      { 0x08,0x88,0x00,0x80 }, { 0x08,0x88,0x00,0x80 },   /* ...0...1...0...0 */
803      { 0x88,0xa8,0x80,0xa0 }, { 0x08,0x88,0x00,0x80 },   /* ...0...1...0...1 */
804      { 0x20,0xa0,0x00,0x80 }, { 0x20,0xa0,0x00,0x80 },   /* ...0...1...1...0 */
805      { 0x08,0x88,0x00,0x80 }, { 0x08,0x88,0x00,0x80 },   /* ...0...1...1...1 */
806      { 0x88,0xa8,0x80,0xa0 }, { 0xa0,0xa8,0x20,0x28 },   /* ...1...0...0...0 */
807      { 0x80,0x88,0xa0,0xa8 }, { 0x80,0x88,0xa0,0xa8 },   /* ...1...0...0...1 */
808      { 0xa0,0xa8,0x20,0x28 }, { 0x20,0xa0,0x00,0x80 },   /* ...1...0...1...0 */
809      { 0xa0,0xa8,0x20,0x28 }, { 0x80,0x88,0xa0,0xa8 },   /* ...1...0...1...1 */
810      { 0x08,0x88,0x00,0x80 }, { 0x28,0x08,0xa8,0x88 },   /* ...1...1...0...0 */
811      { 0x08,0x88,0x00,0x80 }, { 0x80,0x88,0xa0,0xa8 },   /* ...1...1...0...1 */
812      { 0x28,0x08,0xa8,0x88 }, { 0x20,0xa0,0x00,0x80 },   /* ...1...1...1...0 */
813      { 0x80,0x88,0xa0,0xa8 }, { 0x08,0x88,0x00,0x80 }   /* ...1...1...1...1 */
814   };
815
816   int A;
817
818   UINT8 *rom = memory_region(REGION_CPU1);
819   decrypted = auto_malloc(0x9000);
820
821   for (A = 0x0000;A < 0x9000;A++)
822   {
823      int xor = 0;
824
825      UINT8 src = rom[A];
826
827      /* pick the translation table from bits 0, 4, 8 and 12 of the address */
828      int row = (A & 1) + (((A >> 4) & 1) << 1) + (((A >> 8) & 1) << 2) + (((A >> 12) & 1) << 3);
829
830      /* pick the offset in the table from bits 3 and 5 of the source data */
831      int col = ((src >> 3) & 1) + (((src >> 5) & 1) << 1);
832      /* the bottom half of the translation table is the mirror image of the top */
833      if (src & 0x80)
834      {
835         col = 3 - col;
836         xor = 0xa8;
837      }
838
839      /* special handling for banked area */
840      if (A >= 0x7000)
841         row = (A & 1) + (((A >> 4) & 1) << 1) + (((A >> 8) & 1) << 2);
842
843      /* decode the opcodes */
844      decrypted[A] = (src & ~0xa8) | (convtable[2*row][col] ^ xor);
845
846      /* decode the data */
847      rom[A] = (src & ~0xa8) | (convtable[2*row+1][col] ^ xor);
848   }
849
850   memory_configure_bank(1,0,8, memory_region(REGION_CPU1)+0x7000,0x0400);
851   memory_configure_bank_decrypted(1,0,8,decrypted+0x7000,0x0400);
852   memory_set_decrypted_region(0, 0x0000, 0x6bff, decrypted);
853   memory_set_bank(1, 0);
854}
855
856
800857void pitfall2_decode(void)
801858{
802859   static const UINT8 convtable[32][4] =
src/mame/machine/segacrpt.h
r1070r1071
1414void bullfgtj_decode(void);
1515void pbaction_decode(void);
1616void spatter_decode(void);
17void jongkyo_decode(void);
1718void pitfall2_decode(void);
1819void nprinces_decode(void);
1920void seganinj_decode(void);
src/mame/machine/znsec.c
r1070r1071
8282                      = Shift(c[n-1, 6])^Shift(c[n-1, 7])
8383*/
8484
85#include "driver.h"
8586#include "znsec.h"
8687
8788typedef struct {
src/mame/machine/znsec.h
r1070r1071
11/*  CAT702 ZN security chip */
2#include "osdcore.h"
32
43void znsec_init(int chip, const UINT8 *transform);
54void znsec_start(int chip);
src/mame/machine/pci.c
r1070r1071
6969
7070***************************************************************************/
7171
72#include "driver.h"
73#include "memconv.h"
7274#include "machine/pci.h"
73#include "memconv.h"
7475
7576#define LOG_PCI   0
7677
src/mame/machine/pci.h
r1070r1071
99#ifndef PCI_H
1010#define PCI_H
1111
12#include "driver.h"
13
1412struct pci_device_info
1513{
1614   UINT32 (*read_callback)(int function, int reg, UINT32 mem_mask);
src/mame/machine/rtc65271.c
r1070r1071
1515    Raphael Nabet, 2003-2004
1616*/
1717
18#include "mame.h"
18#include "driver.h"
1919#include "rtc65271.h"
2020
2121static void field_interrupts(void);
src/mame/machine/rtc65271.h
r1070r1071
22    rtc65271.h: include file for rtc65271.c
33*/
44
5#include "driver.h"
6
75extern int rtc65271_file_load(mame_file *file);
86extern int rtc65271_file_save(mame_file *file);
97extern void rtc65271_init(UINT8 *xram, void (*interrupt_callback)(int state));
src/mame/machine/6526cia.h
r1070r1071
1010#ifndef _6526CIA_H_
1111#define _6526CIA_H_
1212
13#include "driver.h"
14
1513typedef enum
1614{
1715   CIA6526,
src/mame/machine/6532riot.h
r1070r1071
77#ifndef RIOT_6532
88#define RIOT_6532
99
10#include "driver.h"
11
1210#define   MAX_R6532   8
1311
1412struct riot6532_interface
src/mame/machine/tmp68301.h
r1070r1071
11#ifndef TMP68301_H
22#define TMP68301_H
33
4#include "driver.h"
5
64// Machine init
75MACHINE_RESET( tmp68301 );
86
src/mame/machine/mb3773.c
r1070r1071
66 *
77 */
88
9#include "driver.h"
910#include "machine/mb3773.h"
1011
1112static mame_timer *watchdog_timer;
src/mame/machine/mb3773.h
r1070r1071
66#if !defined( MB3773_H )
77#define MB3773_H ( 1 )
88
9#include "driver.h"
10
119extern void mb3773_set_ck( UINT8 new_ck );
1210extern void mb3773_init( void );
1311
src/mame/machine/atarigen.h
r1070r1071
66
77##########################################################################*/
88
9#include "driver.h"
109#include "video/atarimo.h"
1110#include "video/atarirle.h"
1211
src/mame/machine/laserdsc.h
r1070r1071
1414#ifndef __LASERDSC_H__
1515#define __LASERDSC_H__
1616
17#include "driver.h"
1817
1918
20
2119/***************************************************************************
2220    CONSTANTS
2321***************************************************************************/
src/mame/machine/8237dma.c
r1070r1071
1818
1919**********************************************************************/
2020
21#include "driver.h"
22#include "memconv.h"
2123#include "8237dma.h"
22#include "memconv.h"
2324
2425struct dma8237
2526{
src/mame/machine/8237dma.h
r1070r1071
77#ifndef DMA8237_H
88#define DMA8237_H
99
10#include "driver.h"
11
1210struct dma8237_interface
1311{
1412   /* CPU to halt when DMA is active */
src/mame/machine/mb87078.c
r1070r1071
66
77 *****************************************************************************/
88
9#include "osdcore.h"
9#include "driver.h"
1010#include "machine/mb87078.h"
1111
1212struct MB87078 {
src/mame/machine/mc146818.c
r1070r1071
7171
7272*********************************************************************/
7373
74#include "driver.h"
75#include "memconv.h"
7476#include "machine/mc146818.h"
75#include "memconv.h"
7677
7778
7879
src/mame/mamedriv.c
r1070r1071
107107   DRIVER( rocktrv2 )   /* (c) 1986 Triumph Software Inc */
108108   DRIVER( bigbucks )   /* (c) 1986 Dynasoft Inc. */
109109   DRIVER( mschamp )   /* hack */
110   DRIVER( cannonbp )   /* hack */
110111
111112   /* S2650 Pacman Kits */
112113   DRIVER( drivfrcp )   /* (c) 1984 Shinkai Inc. (Magic Eletronics Inc. licence) */
r1070r1071
12111212   DRIVER( goldbug )   /* (c) 1982 Century */
12121213   DRIVER( heartatk )   /* (c) 1983 Century Electronics */
12131214   DRIVER( hunchbak )   /* (c) 1983 Century */
1215   DRIVER( hunchbka )   /* (c) 1983 Century */
12141216   DRIVER( superbik )   /* (c) 1983 Century */
12151217   DRIVER( raiders )   /* (c) 1983 Century Electronics UK */
12161218   DRIVER( hero )      /* (c) 1983 Seatongrove (c) 1984 CVS */
r1070r1071
13841386   DRIVER( nspiritj )   /* (c) 1988 (Japan) */
13851387   DRIVER( imgfight )   /* (c) 1988 (Japan) */
13861388   DRIVER( loht )      /* (c) 1989 */
1389   DRIVER( lohtj )      /* (c) 1989 (Japan) */
1390   DRIVER( lohtb )      /* (c) 1989 (bootleg) */
1391   DRIVER( lohtb2 )   /* (c) 1989 (bootleg) */
13871392   DRIVER( xmultipl )   /* (c) 1989 (Japan) */
13881393   DRIVER( dbreed )   /* (c) 1989 */
13891394   DRIVER( dbreed72 )   /* (c) 1989 */
r1070r1071
16571662   DRIVER( tetrsark )   /* ??? (c) D.R.Korea */
16581663   DRIVER( sqix )      /* B03 1987 */
16591664   DRIVER( sqixa )      /* B03 1987 */
1665   DRIVER( sqixu )      /* B03 1987 */
16601666   DRIVER( sqixbl )   /* bootleg? but (c) 1987 */
16611667   DRIVER( perestro )   /* (c) 1994 Promat */
16621668   DRIVER( perestrf )   /* (c) 1993 Promat / Fuuki */
r1070r1071
29652971            /*  8/1989 Dokaben 2 (baseball) */
29662972   DRIVER( pang )      /* (c) 1989 Mitchell (World) */
29672973   DRIVER( pangb )      /* bootleg */
2974   DRIVER( pangbold )   /* bootleg */
29682975   DRIVER( bbros )      /* (c) 1989 Capcom (US) not listed on Capcom's site */
29692976   DRIVER( pompingw )   /* (c) 1989 Mitchell (Japan) */
29702977   DRIVER( cbasebal )   /* 10/1989 (c) 1989 Capcom (Japan) (different hardware) */
r1070r1071
29722979   DRIVER( hatena )   /* 28/02/1990 (QUIZ 2) (c) 1990 Capcom (Japan) */
29732980   DRIVER( spang )      /* 14/09/1990 (c) 1990 Mitchell (World) */
29742981   DRIVER( spangj )   /* --/--/1990 (c) 1990 Mitchell (Japan) */
2982   DRIVER( spangbl )   /* bootleg */
29752983   DRIVER( sbbros )   /* 01/10/1990 (c) 1990 Mitchell + Capcom (US) not listed on Capcom's site */
29762984   DRIVER( marukin )   /* 17/10/1990 (c) 1990 Yuga (Japan) */
29772985   DRIVER( qtono1 )   /* 25/12/1990 (QUIZ 3) (c) 1991 Capcom (Japan) */
r1070r1071
33443352   DRIVER( sdi )      /* (c) 1987 (FD1089B, decrypted) */
33453353   DRIVER( shinobi )   /* (c) 1987 */
33463354   DRIVER( shinobi1 )   /* (c) 1987 (FD1094, decrypted) */
3355   DRIVER( shinobls )   /* (c) 1987 (Star bootleg) */
33473356   DRIVER( sjryuko1 )   /* (c) 1988 White Board (FD1089B, decrypted) */
33483357   DRIVER( tetris )   /* (c) 1988 (FD1094, decrypted) S16A */
33493358   DRIVER( tetris3 )   /* (c) 1988 (FD1094, decrypted) S16A */
r1070r1071
34343443   DRIVER( goldnab2 )   /* BOOTLEG  */
34353444   DRIVER( passht4b )   /* bootleg */
34363445   DRIVER( passshtb )   /* bootleg */
3437   DRIVER( shinobl )   /* (c) 1987 (but bootleg) */
3446   DRIVER( shinoblb )   /* (c) 1987 (but bootleg) */
3447   DRIVER( shinobld )   /* (c) 1987 (but bootleg) */
34383448   DRIVER( tetrisbl )   /* (c) 1988 (but bootleg) */
34393449   DRIVER( tturfbl )   /* (c) 1989 (Datsu bootleg) */
34403450   DRIVER( wb3bbl )   /* BOOTLEG */
r1070r1071
35473557   DRIVER( gground )   /* (c) 1988 (FD1094, decrypted) */
35483558   DRIVER( ggroundj )   /* (c) 1988 (FD1094, decrypted) */
35493559   DRIVER( crkdown )   /* (c) 1989 (FD1094, decrypted) */
3560   DRIVER( crkdownu )   /* (c) 1989 (FD1094, decrypted) */
35503561   DRIVER( crkdownj )   /* (c) 1989 (FD1094, decrypted) */
35513562   DRIVER( sgmast )   /* (c) 1989 (protected) */
35523563   DRIVER( sgmastc )   /* (c) 1989 (FD1094, decrypted) */
r1070r1071
38123823   DRIVER( tantrkor )   /* (c) 1992 Sega */
38133824   DRIVER( tantrbl )   /* bootleg */
38143825   DRIVER( tantrbl2 )   /* bootleg */
3826   DRIVER( tantrbl3 )   /* bootleg */
38153827   DRIVER( puyo )      /* (c) 1992 Sega / Compile */
38163828   DRIVER( puyobl )   /* bootleg */
38173829   DRIVER( puyoj )      /* (c) 1992 Sega / Compile */
r1070r1071
43144326   DRIVER( lvpoker )   /* ???? - (c) 1985 Tehkan */
43154327   DRIVER( lvcards )   /* (c) 1985 Tehkan */
43164328   DRIVER( tehkanwc )   /* (c) 1985 Tehkan */
4329   DRIVER( tehkanwb )   /* bootleg */
43174330   DRIVER( gridiron )   /* (c) 1985 Tehkan */
43184331   DRIVER( teedoff )   /* 6102 - (c) 1986 Tecmo */
43194332   DRIVER( solomon )   /* (c) 1986 Tecmo */
r1070r1071
57075720   DRIVER( ddragonw )   /* TA-0021 (c) 1987 Taito */
57085721   DRIVER( ddragnw1 )   /* TA-0021 (c) 1987 Taito */
57095722   DRIVER( ddragonb )   /* bootleg */
5723   DRIVER( ddragnba )   /* bootleg */
57105724   DRIVER( spdodgeb )   /* TA-0022 (c) 1987 */
5725   DRIVER( nkdodge )   /* TA-0022 (c) 1987 (Japan) */
57115726   DRIVER( nkdodgeb )   /* TA-0022 (c) 1987 (Japan) */
57125727   DRIVER( chinagat )   /* TA-0023 (c) 1988 Taito + Romstar license (US) */
57135728   DRIVER( saiyugou )   /* TA-0023 (c) 1988 (Japan) */
r1070r1071
61616176
61626177   /* Tad games (Tad games run on Seibu hardware) */
61636178   DRIVER( cabal )      /* (c) 1988 Tad + Fabtek license */
6164   DRIVER( cabal2 )   /* (c) 1988 Tad + Fabtek license */
6179   DRIVER( cabala )   /* (c) 1988 Tad + Fabtek license */
61656180   DRIVER( cabalbl )   /* bootleg */
6181   DRIVER( cabalus )   /* (c) 1988 Tad + Fabtek license */
6182   DRIVER( cabalus2 )   /* (c) 1988 Tad + Fabtek license */
61666183   DRIVER( toki )      /* (c) 1989 Tad (World) */
61676184   DRIVER( tokia )      /* (c) 1989 Tad (World) */
61686185   DRIVER( tokiu )      /* (c) 1989 Tad + Fabtek license (US) */
r1070r1071
62796296   DRIVER( tp2m32 )   /* (c) 1997 */
62806297   DRIVER( f1superb )   /* (c) 1994 */
62816298
6299   DRIVER( bnstars1 )   /* (c) 1994 */
6300
62826301   /* Video System Co. games */
62836302   DRIVER( rabiolep )   /* (c) 1987 V-System Co. (Japan) */
62846303   DRIVER( rpunch )   /* (c) 1987 V-System Co. + Bally/Midway/Sente license (US) */
r1070r1071
64686487   /* Kaneko games */
64696488   DRIVER( djboy )      /* (c) 1989 Kaneko */
64706489   DRIVER( djboyj )   /* (c) 1989 Kaneko */
6490   DRIVER( djboya )   /* (c) 1989 Kaneko */
64716491   DRIVER( airbustr )   /* (c) 1990 Kaneko + Namco */
64726492   DRIVER( airbustj )   /* (c) 1990 Kaneko + Namco (Japan) */
64736493   DRIVER( airbusb )   /* bootleg */
r1070r1071
69977017   DRIVER( quiz365 )   /* "78" (c) 1994 Nakanihon */
69987018   DRIVER( quiz365t )   /* "78" (c) 1994 Nakanihon (Taiwan) */
69997019   DRIVER( rongrong )   /* "80" (c) 1994 Nakanihon */
7020   DRIVER( rongrngj )   /* "80" (c) 1994 Nakanihon */
70007021   DRIVER( rongrngg )   /* "80" (c) 1994 Nakanihon */
7022   DRIVER( hparadis )   /*      (c) 1994 Nakanihon */
7023   DRIVER( hgokou )   /*      (c) 1995 Nakanihon */
70017024   DRIVER( mjdchuka )   /*      (c) 1995 Nakanihon */
70027025   DRIVER( mjtensin )   /* "100" 1995 Dynax */
70037026   DRIVER( nettoqc )   /* "103" (c) 1995 Nakanihon */
r1070r1071
77737796   DRIVER( comebaby )   /* (c) 2000 ExPotato */
77747797   DRIVER( mirage )   /* (c) 1994 Mitchell */
77757798   DRIVER( dominob )   /* (c) 1990 Wonwoo Systems */
7799   DRIVER( jongkyo )   /* (c) 1985 Kiwako */
77767800
77777801#endif   /* DRIVER_RECURSIVE */
src/mame/includes/cubocd32.h
r1070r1071
77#ifndef __CUBOCD32_H__
88#define __CUBOCD32_H__
99
10/*----------- defined in machine/cubocd32.c -----------*/
11
1012extern void amiga_akiko_init(void);
1113extern NVRAM_HANDLER( cd32 );
1214extern READ32_HANDLER(amiga_akiko32_r);
src/mame/includes/dc.h
r1070r1071
77#ifndef __DC_H__
88#define __DC_H__
99
10/* machine/dc.c */
10/*----------- defined in machine/dc.c -----------*/
11
1112READ64_HANDLER( dc_sysctrl_r );
1213WRITE64_HANDLER( dc_sysctrl_w );
1314READ64_HANDLER( dc_maple_r );
r1070r1071
2728
2829MACHINE_RESET( dc );
2930
30/* video/dc.c */
31/*----------- defined in video/dc.c -----------*/
32
3133READ64_HANDLER( pvr_ctrl_r );
3234WRITE64_HANDLER( pvr_ctrl_w );
3335READ64_HANDLER( pvr_ta_r );
src/mame/includes/namcos21.h
r1070r1071
55#define NAMCOS21_POLY_FRAME_WIDTH 496
66#define NAMCOS21_POLY_FRAME_HEIGHT 480
77
8/*----------- defined in video/namcos21.c -----------*/
9
810extern void namcos21_ClearPolyFrameBuffer( void );
911extern void namcos21_DrawQuad( int sx[4], int sy[4], int zcode[4], int color );
1012
src/mame/includes/m92.h
r1070r1071
66
77/*----------- defined in video/m92.c -----------*/
88
9extern int m92_raster_irq_position, m92_raster_enable;
9extern UINT32 m92_raster_irq_position;
1010extern UINT16 *m92_vram_data, *m92_spritecontrol;
1111
1212extern UINT8 m92_sprite_buffer_busy, m92_game_kludge;
src/mame/includes/nam_cust.h
r0r1071
1/* Namco Custom Chip ROM loading Macros */
2
3
4/* the 50XX is a player score controller, used for protection */
5#define ROM_REGION_NAMCO_50XX( region ) \
6   ROM_REGION( 0x800, region, 0 ) /* 2k for the 50xx  */ \
7   ROM_LOAD( "50xx.bin",     0x0000, 0x0800, CRC(a0acbaf7) SHA1(f03c79451e73b3a93c1591cdb27fedc9f130508d) ) \
8
9/* the 51XX is an I/O controller */
10#define ROM_REGION_NAMCO_51XX( region ) \
11   ROM_REGION( 0x400, region, 0 ) /* 1k for the 51xx  */ \
12   ROM_LOAD( "51xx.bin",     0x0000, 0x0400, CRC(c2f57ef8) SHA1(50de79e0d6a76bda95ffb02fcce369a79e6abfec) ) \
13
14/* the 52XX is a sample player */
15#define ROM_REGION_NAMCO_52XX( region ) \
16   ROM_REGION( 0x400, region, 0 ) /* 1k for the 52xx  */ \
17   ROM_LOAD( "52xx.bin",     0x0000, 0x0400, CRC(3257d11e) SHA1(4883b2fdbc99eb7b9906357fcc53915842c2c186) ) \
18
19/* the 53XX is an I/O controller */
20#define ROM_REGION_NAMCO_53XX( region ) \
21   ROM_REGION( 0x400, region, 0 ) /* 1k for the 53xx  */ \
22   ROM_LOAD( "53xx.bin",     0x0000, 0x0400, CRC(b326fecb) SHA1(758d8583d658e4f1df93184009d86c3eb8713899) ) \
23
24/* the 54XX is an explosion sound generator */
25#define ROM_REGION_NAMCO_54XX( region ) \
26   ROM_REGION( 0x400, region, 0 ) /* 1k for the 54xx  */ \
27   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) ) \
28
src/mame/includes/amiga.h
r1070r1071
371371
372372extern const char *amiga_custom_names[0x100];
373373
374extern UINT16 (*amiga_chip_ram_r)(offs_t offset);
375extern void (*amiga_chip_ram_w)(offs_t offset, UINT16 data);
376
374377void amiga_machine_config(const amiga_machine_interface *intf);
375378
376379MACHINE_RESET( amiga );
r1070r1071
411414void amiga_sprite_dma_reset(int which);
412415void amiga_sprite_enable_comparitor(int which, int enable);
413416
414extern UINT16 (*amiga_chip_ram_r)(offs_t offset);
415extern void (*amiga_chip_ram_w)(offs_t offset, UINT16 data);
416
417417#endif /* __AMIGA_H__ */
src/mame/includes/m107.h
r1070r1071
1313
1414WRITE16_HANDLER( m107_spritebuffer_w );
1515VIDEO_UPDATE( m107 );
16VIDEO_UPDATE( dsoccr );
1716VIDEO_START( m107 );
1817WRITE16_HANDLER( m107_control_w );
1918WRITE16_HANDLER( m107_vram_w );
src/mame/includes/megasys1.h
r1070r1071
173173extern UINT16 *megasys1_scrollram[3];
174174extern UINT16 *megasys1_objectram, *megasys1_vregs, *megasys1_ram;
175175
176extern int megasys1_scrollx[3], megasys1_scrolly[3], megasys1_pages_per_tmap_x[3], megasys1_pages_per_tmap_y[3];
176extern int megasys1_scrollx[3], megasys1_scrolly[3];
177177extern int megasys1_active_layers;
178178//extern int megasys1_screen_flag, megasys1_sprite_flag;
179179extern int megasys1_bits_per_color_code;
src/mame/includes/genesis.h
r1070r1071
1414/*----------- defined in drivers/megatech.c -----------*/
1515
1616extern UINT32 bios_ctrl_inputs;
17extern READ8_HANDLER (megatech_bios_port_be_bf_r);
18extern WRITE8_HANDLER (megatech_bios_port_be_bf_w);
19extern INTERRUPT_GEN (megatech_irq);
2017
2118/*----------- defined in drivers/genesis.c -----------*/
2219
r1070r1071
4643extern UINT16      genesis_sp_pal_lookup[];
4744
4845VIDEO_START( genesis );
49VIDEO_START( megatech );
50VIDEO_START( megaplay );
5146VIDEO_START( segac2 );
5247
5348VIDEO_UPDATE( genesis );
5449VIDEO_UPDATE( segac2 );
55VIDEO_UPDATE( megatech );
5650VIDEO_UPDATE( megaplay );
5751
5852void   segac2_enable_display(int enable);
src/mame/mame.mak
r1070r1071
817817   $(DRIVERS)/bestleag.o \
818818   $(DRIVERS)/bigstrkb.o $(VIDEO)/bigstrkb.o \
819819   $(DRIVERS)/blueprnt.o $(VIDEO)/blueprnt.o \
820   $(DRIVERS)/bnstars.o \
820821   $(DRIVERS)/cischeat.o $(VIDEO)/cischeat.o \
821822   $(DRIVERS)/citycon.o $(VIDEO)/citycon.o \
822823   $(DRIVERS)/ddayjlc.o \
r1070r1071
15831584   $(DRIVERS)/intrscti.o \
15841585   $(DRIVERS)/istellar.o \
15851586   $(DRIVERS)/jackpool.o \
1587   $(DRIVERS)/jongkyo.o \
15861588   $(DRIVERS)/jpmimpct.o $(VIDEO)/jpmimpct.o \
15871589   $(DRIVERS)/kingpin.o \
15881590   $(DRIVERS)/koikoi.o \
src/mame/video/mitchell.c
r1070r1071
174174   /* bit 3 is unknown (used, e.g. marukin pulses it on the title screen) */
175175
176176   /* bit 4 selects OKI M6295 bank */
177   OKIM6295_set_bank_base(0, (data & 0x10) ? 0x40000 : 0x00000);
177   if (sndti_exists(SOUND_OKIM6295,0)) OKIM6295_set_bank_base(0, (data & 0x10) ? 0x40000 : 0x00000);
178178
179179   /* bit 5 is palette RAM bank selector (doesn't apply to mgakuen) */
180180   paletteram_bank = data & 0x20;
src/mame/video/dynduke.c
r1070r1071
44static tilemap *bg_layer,*fg_layer,*tx_layer;
55UINT16 *dynduke_back_data,*dynduke_fore_data,*dynduke_scroll_ram;
66
7static int back_bankbase,fore_bankbase,back_palbase;
8static int back_enable,fore_enable,sprite_enable;
7static int back_bankbase,fore_bankbase;
8static int back_enable,fore_enable,sprite_enable,txt_enable;
99
1010/******************************************************************************/
1111
r1070r1071
1616   COMBINE_DATA(&paletteram16[offset]);
1717   color=paletteram16[offset];
1818   palette_set_color_rgb(Machine,offset,pal4bit(color >> 0),pal4bit(color >> 4),pal4bit(color >> 8));
19
20   /* This is a kludge to handle 5bpp graphics but 4bpp palette data */
21   /* the 5th bit is actually transparency, so I should use TILEMAP_TYPE_PEN */
22   if (offset<512)
23   {
24      palette_set_color_rgb(Machine,(offset&0x0f) | ((offset*2)&0xffe0) | 2048,pal4bit(color >> 0),pal4bit(color >> 4),pal4bit(color >> 8));
25      palette_set_color_rgb(Machine,(offset&0x0f) | ((offset*2)&0xffe0) | 2048 | 16,pal4bit(color >> 0),pal4bit(color >> 4),pal4bit(color >> 8));
26   }
2719}
2820
2921WRITE16_HANDLER( dynduke_background_w )
r1070r1071
5446   SET_TILE_INFO(
5547         1,
5648         tile+back_bankbase,
57         color+back_palbase,
49         color,
5850         0);
5951}
6052
r1070r1071
9284   fg_layer = tilemap_create(get_fg_tile_info,tilemap_scan_cols,TILEMAP_TYPE_PEN,16,16,32,32);
9385   tx_layer = tilemap_create(get_tx_tile_info,tilemap_scan_rows,TILEMAP_TYPE_PEN, 8, 8,32,32);
9486
95   tilemap_set_transmask(bg_layer,0,0x0000ffff,0xffff0000); /* 4bpp + The rest - 1bpp */
96
9787   tilemap_set_transparent_pen(fg_layer,15);
9888   tilemap_set_transparent_pen(tx_layer,15);
9989}
r1070r1071
117107   }
118108}
119109
110
120111WRITE16_HANDLER( dynduke_control_w )
121112{
122   static int old_bpal;
123113
124114   if (ACCESSING_LSB)
125115   {
126      if (data&0x1) back_enable=0; else back_enable=1;
127      if (data&0x2) back_palbase=16; else back_palbase=0;
128      if (data&0x4) fore_enable=0; else fore_enable=1;
116      // bit 0x80 toggles, maybe sprite buffering?
117      // bit 0x40 is flipscreen
118      // bit 0x20 not used?
119      // bit 0x10 not used?
120      // bit 0x08 is set on the title screen (sprite disable?)
121      // bit 0x04 unused? txt disable?
122      // bit 0x02 is used on the map screen (fore disable?)
123      // bit 0x01 set when inserting coin.. bg disable?
124
125      if (data&0x1) back_enable = 0; else back_enable = 1;
126      if (data&0x2) fore_enable=0; else fore_enable=1;
127      if (data&0x4) txt_enable = 0; else txt_enable = 1;
129128      if (data&0x8) sprite_enable=0; else sprite_enable=1;
130129
131      if (back_palbase!=old_bpal)
132         tilemap_mark_all_tiles_dirty(bg_layer);
133
134      old_bpal=back_palbase;
135130      flip_screen_set(data & 0x40);
136131   }
137132}
r1070r1071
173168   }
174169}
175170
171static void draw_background(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect, int pri )
172{
173   /* The transparency / palette handling on the background layer is very strange */
174   mame_bitmap *bm = tilemap_get_pixmap(bg_layer);
175   int scrolly, scrollx;
176   int x,y;
177
178   /* if we're disabled, don't draw */
179   if (!back_enable)
180   {
181      fillbitmap(bitmap,get_black_pen(machine),cliprect);
182      return;
183   }
184
185   scrolly = ((dynduke_scroll_ram[0x01]&0x30)<<4)+((dynduke_scroll_ram[0x02]&0x7f)<<1)+((dynduke_scroll_ram[0x02]&0x80)>>7);
186   scrollx = ((dynduke_scroll_ram[0x09]&0x30)<<4)+((dynduke_scroll_ram[0x0a]&0x7f)<<1)+((dynduke_scroll_ram[0x0a]&0x80)>>7);
187
188   for (y=0;y<256;y++)
189   {
190      int realy = (y + scrolly) & 0x1ff;
191      UINT16 *src = BITMAP_ADDR16(bm,     realy, 0);
192      UINT16 *dst = BITMAP_ADDR16(bitmap, y,     0);
193
194
195      for (x=0;x<256;x++)
196      {
197         int realx = (x + scrollx) & 0x1ff;
198         UINT16 srcdat = src[realx];
199
200         /* 0x01 - data bits
201               0x02
202               0x04
203               0x08
204               0x10 - extra colour bit? (first boss)
205               0x20 - priority over sprites
206               the old driver also had 'bg_palbase' but I don't see what it's for?
207            */
208
209         if ((srcdat & 0x20) == pri)
210         {
211            if (srcdat & 0x10) srcdat += 0x400;
212            //if (srcdat & 0x10) srcdat += mame_rand(machine)&0x1f;
213
214            srcdat = (srcdat & 0x000f) | ((srcdat & 0xffc0) >> 2);
215            dst[x] = srcdat;
216         }
217
218
219      }
220   }
221}
222
176223VIDEO_UPDATE( dynduke )
177224{
178225   /* Setup the tilemaps */
179   tilemap_set_scrolly( bg_layer,0, ((dynduke_scroll_ram[0x01]&0x30)<<4)+((dynduke_scroll_ram[0x02]&0x7f)<<1)+((dynduke_scroll_ram[0x02]&0x80)>>7) );
180   tilemap_set_scrollx( bg_layer,0, ((dynduke_scroll_ram[0x09]&0x30)<<4)+((dynduke_scroll_ram[0x0a]&0x7f)<<1)+((dynduke_scroll_ram[0x0a]&0x80)>>7) );
181226   tilemap_set_scrolly( fg_layer,0, ((dynduke_scroll_ram[0x11]&0x30)<<4)+((dynduke_scroll_ram[0x12]&0x7f)<<1)+((dynduke_scroll_ram[0x12]&0x80)>>7) );
182227   tilemap_set_scrollx( fg_layer,0, ((dynduke_scroll_ram[0x19]&0x30)<<4)+((dynduke_scroll_ram[0x1a]&0x7f)<<1)+((dynduke_scroll_ram[0x1a]&0x80)>>7) );
183   tilemap_set_enable( bg_layer,back_enable);
184228   tilemap_set_enable( fg_layer,fore_enable);
229   tilemap_set_enable( tx_layer,txt_enable);
185230
186   if (back_enable)
187      tilemap_draw(bitmap,cliprect,bg_layer,TILEMAP_DRAW_LAYER1,0);
188   else
189      fillbitmap(bitmap,get_black_pen(machine),cliprect);
190231
232   draw_background(machine, bitmap, cliprect,0x00);
191233   draw_sprites(machine,bitmap,cliprect,0); // Untested: does anything use it? Could be behind background
192234   draw_sprites(machine,bitmap,cliprect,1);
193   tilemap_draw(bitmap,cliprect,bg_layer,TILEMAP_DRAW_LAYER0,0);
235   draw_background(machine, bitmap, cliprect,0x20);
236
194237   draw_sprites(machine,bitmap,cliprect,2);
195238   tilemap_draw(bitmap,cliprect,fg_layer,0,0);
196239   draw_sprites(machine,bitmap,cliprect,3);
197240   tilemap_draw(bitmap,cliprect,tx_layer,0,0);
241
198242   return 0;
199243}
200244
src/mame/video/voodoo.c
r1070r1071
11//fix me -- blitz2k dies when starting a game with heavy fog (in DRC)
2//optimize -- 64-bit multiplies for S/T
32
43/*************************************************************************
54
r1070r1071
206205static void banshee_io_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask);
207206static UINT32 banshee_io_r(voodoo_state *v, offs_t offset, UINT32 mem_mask);
208207static UINT32 banshee_rom_r(voodoo_state *v, offs_t offset, UINT32 mem_mask);
208
209/* work item management */
210static void work_item_enqueue(voodoo_state *v);
211static void work_item_wait(voodoo_state *v);
212static void *work_item_callback(void *param);
213
214/* command handlers */
209215static INT32 fastfill(voodoo_state *v);
210216static INT32 swapbuffer(voodoo_state *v, UINT32 data);
217static INT32 triangle(voodoo_state *v);
211218static INT32 begin_triangle(voodoo_state *v);
212219static INT32 draw_triangle(voodoo_state *v);
213static INT32 triangle(voodoo_state *v);
220
221/* triangle helpers */
214222static INT32 setup_and_draw_triangle(voodoo_state *v);
223static INT32 triangle_create_work_item(voodoo_state *v, UINT16 *drawbuf, int texcount);
224
225/* rasterizer management */
215226static raster_info *add_rasterizer(voodoo_state *v, const raster_info *cinfo);
216227static raster_info *find_rasterizer(voodoo_state *v, int texcount);
217228static void dump_rasterizer_stats(voodoo_state *v);
218229
219static void raster_generic_0tmu(voodoo_state *v, UINT16 *drawbuf);
220static void raster_generic_1tmu(voodoo_state *v, UINT16 *drawbuf);
221static void raster_generic_2tmu(voodoo_state *v, UINT16 *drawbuf);
230/* generic rasterizers */
231static void raster_fastfill(voodoo_state *v, INT32 scanline);
232static void raster_generic_0tmu(voodoo_state *v, INT32 y);
233static void raster_generic_1tmu(voodoo_state *v, INT32 y);
234static void raster_generic_2tmu(voodoo_state *v, INT32 y);
222235
223236
224237
r1070r1071
244257 *************************************/
245258
246259#define RASTERIZER_ENTRY(fbzcp, alpha, fog, fbz, tex0, tex1) \
247   { NULL, raster_##fbzcp##_##alpha##_##fog##_##fbz##_##tex0##_##tex1, FALSE, 0, 0, fbzcp, alpha, fog, fbz, tex0, tex1 },
260   { NULL, raster_##fbzcp##_##alpha##_##fog##_##fbz##_##tex0##_##tex1, FALSE, 0, 0, 0, fbzcp, alpha, fog, fbz, tex0, tex1 },
248261
249262static const raster_info predef_raster_table[] =
250263{
r1070r1071
273286   memset(v, 0, sizeof(*v));
274287   voodoo[which] = v;
275288
289   /* create a multiprocessor work queue */
290   v->work.queue = osd_work_queue_alloc(WORK_QUEUE_FLAG_MULTI);
291
276292   /* create a table of precomputed 1/n and log2(n) values */
277293   /* n ranges from 1.0000 to 2.0000 */
278294   for (val = 0; val <= (1 << RECIPLOG_LOOKUP_BITS); val++)
r1070r1071
400416
401417/*************************************
402418 *
419 *  Video exit
420 *
421 *************************************/
422
423void voodoo_exit(int which)
424{
425   /* release the work queue, ensuring all work is finished */
426   if (voodoo[which] != NULL && voodoo[which]->work.queue != NULL)
427      osd_work_queue_free(voodoo[which]->work.queue);
428}
429
430
431
432/*************************************
433 *
403434 *  Video update
404435 *
405436 *************************************/
r1070r1071
21512182      return 0;
21522183   }
21532184
2185   /* wait for any outstanding work to finish */
2186   work_item_wait(v);
2187
21542188   /* switch off the register */
21552189   switch (regnum)
21562190   {
r1070r1071
28222856   int x, y, scry, mask;
28232857   int pixel, destbuf;
28242858
2859   /* wait for any outstanding work to finish */
2860   work_item_wait(v);
2861
28252862   /* statistics */
28262863   v->stats.lfb_writes++;
28272864
r1070r1071
31003137   /* tricky case: run the full pixel pipeline on the pixel */
31013138   else
31023139   {
3140      DECLARE_STATISTICS;
3141
31033142      if (LOG_LFB) logerror("VOODOO.%d.LFB:write pipelined mode %X (%d,%d) = %08X & %08X\n", v->index, LFBMODE_WRITE_FORMAT(v->reg[lfbMode].u), x, y, data, mem_mask);
31043143
31053144      /* determine the screen Y */
r1070r1071
31433182         x++;
31443183         mask >>= 4;
31453184      }
3185
3186      UPDATE_STATISTICS(v);
31463187   }
31473188
31483189   return 0;
r1070r1071
31613202   int tmunum = (offset >> 19) & 0x03;
31623203   tmu_state *t;
31633204
3205   /* wait for any outstanding work to finish */
3206   work_item_wait(v);
3207
31643208   /* statistics */
31653209   v->stats.tex_writes++;
31663210
r1070r1071
37673811   UINT32 data;
37683812   int x, y, scry, destbuf;
37693813
3814   /* wait for any outstanding work to finish */
3815   work_item_wait(v);
3816
37703817   /* statistics */
37713818   v->stats.lfb_reads++;
37723819
r1070r1071
44034450
44044451
44054452
4406/*************************************
4407 *
4408 *  Command handlers
4409 *
4410 *************************************/
4453/***************************************************************************
4454    WORK ITEM MANAGEMENT
4455***************************************************************************/
44114456
4457/*-------------------------------------------------
4458    work_item_enqueue - enqueue a new work item,
4459    remembering starting statistics
4460-------------------------------------------------*/
4461
4462static void work_item_enqueue(voodoo_state *v)
4463{
4464   /* remember the starting statistics values */
4465   v->work.start_pixels_in = v->reg[fbiPixelsIn].u;
4466   v->work.start_pixels_out = v->reg[fbiPixelsOut].u;
4467   v->work.start_chroma_fail = v->reg[fbiChromaFail].u;
4468   v->work.start_zfunc_fail = v->reg[fbiZfuncFail].u;
4469   v->work.start_afunc_fail = v->reg[fbiAfuncFail].u;
4470
4471   /* enqueue the work item */
4472   osd_work_item_queue(v->work.queue, work_item_callback, &v->work, WORK_ITEM_FLAG_AUTO_RELEASE | WORK_ITEM_FLAG_SHARED);
4473}
4474
4475
4476/*-------------------------------------------------
4477    work_item_wait - wait for all pending work
4478    items to complete, then update statistics
4479-------------------------------------------------*/
4480
4481static void work_item_wait(voodoo_state *v)
4482{
4483   /* wait for the work item to complete */
4484   osd_work_queue_wait(v->work.queue, osd_ticks_per_second());
4485
4486   /* update our global stats based on the results */
4487   v->stats.total_pixels_in += v->reg[fbiPixelsIn].u - v->work.start_pixels_in;
4488   v->stats.total_pixels_out += v->reg[fbiPixelsOut].u - v->work.start_pixels_out;
4489   v->stats.total_chroma_fail += v->reg[fbiChromaFail].u - v->work.start_chroma_fail;
4490   v->stats.total_zfunc_fail += v->reg[fbiZfuncFail].u - v->work.start_zfunc_fail;
4491   v->stats.total_afunc_fail += v->reg[fbiAfuncFail].u - v->work.start_afunc_fail;
4492   if (v->work.info != NULL)
4493      v->work.info->hits += v->reg[fbiPixelsIn].u - v->work.start_pixels_in;
4494
4495   /* remember the starting statistics values */
4496   v->work.start_pixels_in = v->reg[fbiPixelsIn].u;
4497   v->work.start_pixels_out = v->reg[fbiPixelsOut].u;
4498   v->work.start_chroma_fail = v->reg[fbiChromaFail].u;
4499   v->work.start_zfunc_fail = v->reg[fbiZfuncFail].u;
4500   v->work.start_afunc_fail = v->reg[fbiAfuncFail].u;
4501}
4502
4503
4504/*-------------------------------------------------
4505    work_item_callback - work item callback;
4506    loop over scanlines and call the rasterizer
4507    for each one
4508-------------------------------------------------*/
4509
4510static void *work_item_callback(void *param)
4511{
4512   /* recover the state pointer and scanline from the param */
4513   work_info *work = param;
4514   voodoo_state *v = work->state;
4515
4516   /* render the scanlines and return */
4517   while (1)
4518   {
4519      int scanline = osd_sync_add(&work->curscanline, 1) - 1;
4520
4521      /* stop when we hit the end scanline */
4522      if (scanline >= work->endscanline)
4523         break;
4524
4525      /* handle this scanline then continue */
4526      (*work->callback)(v, scanline);
4527   }
4528   return NULL;
4529}
4530
4531
4532
4533/***************************************************************************
4534    COMMAND HANDLERS
4535***************************************************************************/
4536
4537/*-------------------------------------------------
4538    fastfill - execute the 'fastfill'
4539    command
4540-------------------------------------------------*/
4541
44124542static INT32 fastfill(voodoo_state *v)
44134543{
44144544   int sx = (v->reg[clipLeftRight].u >> 16) & 0x3ff;
r1070r1071
44184548   int x, y;
44194549
44204550   /* if we're not clearing either, take no time */
4421   if (!FBZMODE_RGB_BUFFER_MASK(v->reg[fbzMode].u) &&
4422      !FBZMODE_AUX_BUFFER_MASK(v->reg[fbzMode].u))
4551   if (!FBZMODE_RGB_BUFFER_MASK(v->reg[fbzMode].u) && !FBZMODE_AUX_BUFFER_MASK(v->reg[fbzMode].u))
44234552      return 0;
44244553
44254554   /* are we clearing the RGB buffer? */
44264555   if (FBZMODE_RGB_BUFFER_MASK(v->reg[fbzMode].u))
44274556   {
4428      UINT16 dither[16];
4429      UINT16 *drawbuf;
4430      int destbuf;
4431
44324557      /* determine the draw buffer */
4433      destbuf = (v->type >= VOODOO_BANSHEE) ? 1 : FBZMODE_DRAW_BUFFER(v->reg[fbzMode].u);
4558      int destbuf = (v->type >= VOODOO_BANSHEE) ? 1 : FBZMODE_DRAW_BUFFER(v->reg[fbzMode].u);
44344559      switch (destbuf)
44354560      {
44364561         case 0:      /* front buffer */
4437            drawbuf = v->fbi.rgb[v->fbi.frontbuf];
4562            v->work.drawbuf = v->fbi.rgb[v->fbi.frontbuf];
44384563            break;
44394564
44404565         case 1:      /* back buffer */
4441            drawbuf = v->fbi.rgb[v->fbi.backbuf];
4566            v->work.drawbuf = v->fbi.rgb[v->fbi.backbuf];
44424567            break;
44434568
44444569         default:   /* reserved */
4445            return 0;
4570            break;
44464571      }
44474572
44484573      /* determine the dither pattern */
r1070r1071
44544579            int b = RGB_BLUE(v->reg[color1].u);
44554580
44564581            APPLY_DITHER(v->reg[fbzMode].u, x, y, r, g, b);
4457            dither[y*4 + x] = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3);
4582            v->work.dither[y*4 + x] = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3);
44584583         }
4584   }
44594585
4460      /* now do the fill */
4461      for (y = sy; y < ey; y++)
4462      {
4463         UINT16 *ditherow = &dither[(y & 3) * 4];
4464         UINT16 *dest;
4465         int scry;
4586   /* create a shared work item to actually perform the fill */
4587   v->work.state = v;
4588   v->work.minx = sx;
4589   v->work.maxx = ex;
4590   v->work.curscanline = sy;
4591   v->work.endscanline = ey;
4592   v->work.callback = raster_fastfill;
4593   v->work.info = NULL;
4594   work_item_enqueue(v);
44664595
4467         /* determine the screen Y */
4468         scry = y;
4469         if (FBZMODE_Y_ORIGIN(v->reg[fbzMode].u))
4470            scry = (v->fbi.yorigin - y) & 0x3ff;
4471
4472         /* fill this row */
4473         dest = drawbuf + scry * v->fbi.rowpixels;
4474         for (x = sx; x < ex; x++)
4475            dest[x] = ditherow[x & 3];
4476      }
4477
4478      /* track pixel writes to the frame buffer regardless of mask */
4596   /* track pixel writes to the frame buffer regardless of mask */
4597   if (FBZMODE_RGB_BUFFER_MASK(v->reg[fbzMode].u))
44794598      v->reg[fbiPixelsOut].u += (ey - sy) * (ex - sx);
4480   }
44814599
4482   /* are we clearing the depth buffer? */
4483   if (FBZMODE_AUX_BUFFER_MASK(v->reg[fbzMode].u) && v->fbi.aux)
4484   {
4485      UINT16 color = v->reg[zaColor].u;
4486
4487      /* now do the fill */
4488      for (y = sy; y < ey; y++)
4489      {
4490         UINT16 *dest;
4491         int scry;
4492
4493         /* determine the screen Y */
4494         scry = y;
4495         if (FBZMODE_Y_ORIGIN(v->reg[fbzMode].u))
4496            scry = (v->fbi.yorigin - y) & 0x3ff;
4497
4498         /* fill this row */
4499         dest = v->fbi.aux + scry * v->fbi.rowpixels;
4500         for (x = sx; x < ex; x++)
4501            dest[x] = color;
4502      }
4503   }
4504
45054600   /* 2 pixels per clock */
45064601   return ((ey - sy) * (ex - sx)) / 2;
45074602}
45084603
45094604
4605/*-------------------------------------------------
4606    swapbuffer - execute the 'swapbuffer'
4607    command
4608-------------------------------------------------*/
4609
45104610static INT32 swapbuffer(voodoo_state *v, UINT32 data)
45114611{
45124612   /* set the don't swap value for Voodoo 2 */
r1070r1071
45274627}
45284628
45294629
4630/*-------------------------------------------------
4631    triangle - execute the 'triangle'
4632    command
4633-------------------------------------------------*/
4634
45304635static INT32 triangle(voodoo_state *v)
45314636{
4532   INT32 start_pixels_in = v->reg[fbiPixelsIn].u;
4533   INT32 start_pixels_out = v->reg[fbiPixelsOut].u;
4534   INT32 start_chroma_fail = v->reg[fbiChromaFail].u;
4535   INT32 start_zfunc_fail = v->reg[fbiZfuncFail].u;
4536   INT32 start_afunc_fail = v->reg[fbiAfuncFail].u;
4537   raster_info *info;
4538   int texcount = 0;
4637   int texcount = 0, texnum;
45394638   UINT16 *drawbuf;
45404639   int destbuf;
4640   int pixels;
45414641
45424642   profiler_mark(PROFILER_USER2);
45434643
4644   /* determine the number of TMUs involved */
4645   texcount = 0;
4646   if (!FBIINIT3_DISABLE_TMUS(v->reg[fbiInit3].u) && FBZCP_TEXTURE_ENABLE(v->reg[fbzColorPath].u))
4647   {
4648      texcount = 1;
4649      if (v->chipmask & 0x04)
4650         texcount = 2;
4651   }
4652
45444653   /* perform subpixel adjustments */
45454654   if (FBZCP_CCA_SUBPIXEL_ADJUST(v->reg[fbzColorPath].u))
45464655   {
45474656      INT32 dx = 8 - (v->fbi.ax & 15);
45484657      INT32 dy = 8 - (v->fbi.ay & 15);
45494658
4659      /* adjust iterated R,G,B,A and W/Z */
45504660      v->fbi.startr += (dy * v->fbi.drdy + dx * v->fbi.drdx) >> 4;
45514661      v->fbi.startg += (dy * v->fbi.dgdy + dx * v->fbi.dgdx) >> 4;
45524662      v->fbi.startb += (dy * v->fbi.dbdy + dx * v->fbi.dbdx) >> 4;
r1070r1071
45544664      v->fbi.startw += (dy * v->fbi.dwdy + dx * v->fbi.dwdx) >> 4;
45554665      v->fbi.startz += fixed_mul_shift(dy, v->fbi.dzdy, 4) + fixed_mul_shift(dx, v->fbi.dzdx, 4);
45564666
4557      v->tmu[0].startw += (dy * v->tmu[0].dwdy + dx * v->tmu[0].dwdx) >> 4;
4558      v->tmu[0].starts += (dy * v->tmu[0].dsdy + dx * v->tmu[0].dsdx) >> 4;
4559      v->tmu[0].startt += (dy * v->tmu[0].dtdy + dx * v->tmu[0].dtdx) >> 4;
4667      /* adjust iterated W/S/T for TMU 0 */
4668      if (texcount >= 1)
4669      {
4670         v->tmu[0].startw += (dy * v->tmu[0].dwdy + dx * v->tmu[0].dwdx) >> 4;
4671         v->tmu[0].starts += (dy * v->tmu[0].dsdy + dx * v->tmu[0].dsdx) >> 4;
4672         v->tmu[0].startt += (dy * v->tmu[0].dtdy + dx * v->tmu[0].dtdx) >> 4;
45604673
4561      if (v->chipmask & 0x04)
4562      {
4563         v->tmu[1].startw += (dy * v->tmu[1].dwdy + dx * v->tmu[1].dwdx) >> 4;
4564         v->tmu[1].starts += (dy * v->tmu[1].dsdy + dx * v->tmu[1].dsdx) >> 4;
4565         v->tmu[1].startt += (dy * v->tmu[1].dtdy + dx * v->tmu[1].dtdx) >> 4;
4674         /* adjust iterated W/S/T for TMU 1 */
4675         if (texcount >= 2)
4676         {
4677            v->tmu[1].startw += (dy * v->tmu[1].dwdy + dx * v->tmu[1].dwdx) >> 4;
4678            v->tmu[1].starts += (dy * v->tmu[1].dsdy + dx * v->tmu[1].dsdx) >> 4;
4679            v->tmu[1].startt += (dy * v->tmu[1].dtdy + dx * v->tmu[1].dtdx) >> 4;
4680         }
45664681      }
45674682   }
45684683
4684   /* set up the textures */
4685   for (texnum = 0; texnum < texcount; texnum++)
4686   {
4687      prepare_tmu(&v->tmu[texnum]);
4688      v->stats.texture_mode[TEXMODE_FORMAT(v->tmu[texnum].reg[textureMode].u)]++;
4689   }
4690
45694691   /* determine the draw buffer */
45704692   destbuf = (v->type >= VOODOO_BANSHEE) ? 1 : FBZMODE_DRAW_BUFFER(v->reg[fbzMode].u);
45714693   switch (destbuf)
r1070r1071
45834705         return TRIANGLE_SETUP_CLOCKS;
45844706   }
45854707
4586   /* set up the textures */
4587   texcount = 0;
4588   if (!FBIINIT3_DISABLE_TMUS(v->reg[fbiInit3].u) && FBZCP_TEXTURE_ENABLE(v->reg[fbzColorPath].u))
4589   {
4590      texcount = 1;
4591      prepare_tmu(&v->tmu[0]);
4592      v->stats.texture_mode[TEXMODE_FORMAT(v->tmu[0].reg[textureMode].u)]++;
4593
4594      /* see if we need to deal with a second TMU */
4595      if (v->chipmask & 0x04)
4596      {
4597         texcount = 2;
4598         prepare_tmu(&v->tmu[1]);
4599         v->stats.texture_mode[TEXMODE_FORMAT(v->tmu[1].reg[textureMode].u)]++;
4600      }
4601   }
4602
46034708   /* find a rasterizer that matches our current state */
4604   info = find_rasterizer(v, texcount);
4605   (*info->callback)(v, drawbuf);
4606   info->polys++;
4607   info->hits += v->reg[fbiPixelsIn].u - start_pixels_in;
4709   pixels = triangle_create_work_item(v, drawbuf, texcount);
46084710
46094711   /* update stats */
46104712   v->reg[fbiTrianglesOut].u++;
46114713
4612   if (LOG_REGISTERS) logerror("cycles = %d\n", TRIANGLE_SETUP_CLOCKS + v->reg[fbiPixelsIn].u - start_pixels_in);
4613
46144714   /* update stats */
46154715   v->stats.total_triangles++;
4616   v->stats.total_pixels_in += v->reg[fbiPixelsIn].u - start_pixels_in;
4617   v->stats.total_pixels_out += v->reg[fbiPixelsOut].u - start_pixels_out;
4618   v->stats.total_chroma_fail += v->reg[fbiChromaFail].u - start_chroma_fail;
4619   v->stats.total_zfunc_fail += v->reg[fbiZfuncFail].u - start_zfunc_fail;
4620   v->stats.total_afunc_fail += v->reg[fbiAfuncFail].u - start_afunc_fail;
46214716
46224717   profiler_mark(PROFILER_END);
46234718
46244719   /* 1 pixel per clock, plus some setup time */
4625   return TRIANGLE_SETUP_CLOCKS + v->reg[fbiPixelsIn].u - start_pixels_in;
4720   if (LOG_REGISTERS) logerror("cycles = %d\n", TRIANGLE_SETUP_CLOCKS + pixels);
4721   return TRIANGLE_SETUP_CLOCKS + pixels;
46264722}
46274723
46284724
4725/*-------------------------------------------------
4726    begin_triangle - execute the 'beginTri'
4727    command
4728-------------------------------------------------*/
4729
46294730static INT32 begin_triangle(voodoo_state *v)
46304731{
46314732   setup_vertex *sv = &v->fbi.svert[2];
r1070r1071
46534754}
46544755
46554756
4757/*-------------------------------------------------
4758    draw_triangle - execute the 'DrawTri'
4759    command
4760-------------------------------------------------*/
4761
46564762static INT32 draw_triangle(voodoo_state *v)
46574763{
46584764   setup_vertex *sv = &v->fbi.svert[2];
r1070r1071
46894795
46904796
46914797
4692/*************************************
4693 *
4694 *  Triangle setup
4695 *
4696 *************************************/
4798/***************************************************************************
4799    TRIANGLE HELPERS
4800***************************************************************************/
46974801
4802/*-------------------------------------------------
4803    setup_and_draw_triangle - process the setup
4804    parameters and render the triangle
4805-------------------------------------------------*/
4806
46984807static INT32 setup_and_draw_triangle(voodoo_state *v)
46994808{
47004809   float dx1, dy1, dx2, dy2;
47014810   float divisor, tdiv;
47024811
4812   /* wait for any outstanding work to finish */
4813   work_item_wait(v);
4814
47034815   /* grab the X/Ys at least */
47044816   v->fbi.ax = (INT16)(v->fbi.svert[0].x * 16.0);
47054817   v->fbi.ay = (INT16)(v->fbi.svert[0].y * 16.0);
r1070r1071
48174929}
48184930
48194931
4932/*-------------------------------------------------
4933    triangle_create_work_item - finish triangle
4934    setup and create the work item
4935-------------------------------------------------*/
48204936
4821/*************************************
4822 *
4823 *  Rasterizer management
4824 *
4825 *************************************/
4937static INT32 triangle_create_work_item(voodoo_state *v, UINT16 *drawbuf, int texcount)
4938{
4939   raster_info *info = find_rasterizer(v, texcount);
4940   int curscan, pixels = 0;
48264941
4942   /* sort the vertices */
4943   /* note that this is not necessary on the Voodoo 1 as the card assumes the vertices */
4944   /* are presorted such that ay <= by <= cy, but we do it anyway because it is cheap enough */
4945   if (v->fbi.ay <= v->fbi.by)
4946   {
4947      if (v->fbi.by <= v->fbi.cy)
4948      {
4949         v->work.minx = v->fbi.ax;   v->work.miny = v->fbi.ay;
4950         v->work.midx = v->fbi.bx;   v->work.midy = v->fbi.by;
4951         v->work.maxx = v->fbi.cx;   v->work.maxy = v->fbi.cy;
4952      }
4953      else if (v->fbi.ay <= v->fbi.cy)
4954      {
4955         v->work.minx = v->fbi.ax;   v->work.miny = v->fbi.ay;
4956         v->work.midx = v->fbi.cx;   v->work.midy = v->fbi.cy;
4957         v->work.maxx = v->fbi.bx;   v->work.maxy = v->fbi.by;
4958      }
4959      else
4960      {
4961         v->work.minx = v->fbi.cx;   v->work.miny = v->fbi.cy;
4962         v->work.midx = v->fbi.ax;   v->work.midy = v->fbi.ay;
4963         v->work.maxx = v->fbi.bx;   v->work.maxy = v->fbi.by;
4964      }
4965   }
4966   else
4967   {
4968      if (v->fbi.ay <= v->fbi.cy)
4969      {
4970         v->work.minx = v->fbi.bx;   v->work.miny = v->fbi.by;
4971         v->work.midx = v->fbi.ax;   v->work.midy = v->fbi.ay;
4972         v->work.maxx = v->fbi.cx;   v->work.maxy = v->fbi.cy;
4973      }
4974      else if (v->fbi.by <= v->fbi.cy)
4975      {
4976         v->work.minx = v->fbi.bx;   v->work.miny = v->fbi.by;
4977         v->work.midx = v->fbi.cx;   v->work.midy = v->fbi.cy;
4978         v->work.maxx = v->fbi.ax;   v->work.maxy = v->fbi.ay;
4979      }
4980      else
4981      {
4982         v->work.minx = v->fbi.cx;   v->work.miny = v->fbi.cy;
4983         v->work.midx = v->fbi.bx;   v->work.midy = v->fbi.by;
4984         v->work.maxx = v->fbi.ax;   v->work.maxy = v->fbi.ay;
4985      }
4986   }
4987
4988   /* compute the slopes as 16.16 numbers */
4989   v->work.dxdy_minmid = (v->work.miny == v->work.midy) ? 0 : ((v->work.midx - v->work.minx) << 16) / (v->work.midy - v->work.miny);
4990   v->work.dxdy_minmax = (v->work.miny == v->work.maxy) ? 0 : ((v->work.maxx - v->work.minx) << 16) / (v->work.maxy - v->work.miny);
4991   v->work.dxdy_midmax = (v->work.midy == v->work.maxy) ? 0 : ((v->work.maxx - v->work.midx) << 16) / (v->work.maxy - v->work.midy);
4992
4993   /* clamp to full pixels */
4994   v->work.startscanline = v->work.curscanline = (v->work.miny + 7) >> 4;
4995   v->work.endscanline = (v->work.maxy + 7) >> 4;
4996
4997   /* compute the X extents for each scanline */
4998   for (curscan = v->work.startscanline; curscan < v->work.endscanline; curscan++)
4999   {
5000      INT32 fully = (curscan << 4) + 8;
5001      INT32 startx = v->work.minx + (((fully - v->work.miny) * v->work.dxdy_minmax) >> 16);
5002      INT32 stopx;
5003
5004      if (fully < v->work.midy)
5005         stopx = v->work.minx + (((fully - v->work.miny) * v->work.dxdy_minmid) >> 16);
5006      else
5007         stopx = v->work.midx + (((fully - v->work.midy) * v->work.dxdy_midmax) >> 16);
5008
5009      /* clamp to full pixels */
5010      startx = (startx + 7) >> 4;
5011      stopx = (stopx + 7) >> 4;
5012
5013      /* force start < stop */
5014      if (startx > stopx)
5015      {
5016         int temp = startx;
5017         startx = stopx;
5018         stopx = temp;
5019      }
5020
5021      /* set the extent and update the total pixel count */
5022      v->work.extent[curscan - v->work.startscanline].startx = startx;
5023      v->work.extent[curscan - v->work.startscanline].stopx = stopx;
5024      pixels += stopx - startx;
5025   }
5026
5027   /* farm the rasterization out to other threads */
5028   v->work.state = v;
5029   v->work.callback = info->callback;
5030   v->work.drawbuf = drawbuf;
5031   v->work.info = info;
5032   work_item_enqueue(v);
5033
5034   /* update statistics */
5035   info->polys++;
5036   return pixels;
5037}
5038
5039
5040
5041/***************************************************************************
5042    RASTERIZER MANAGEMENT
5043***************************************************************************/
5044
5045/*-------------------------------------------------
5046    add_rasterizer - add a rasterizer to our
5047    hash table
5048-------------------------------------------------*/
5049
48275050static raster_info *add_rasterizer(voodoo_state *v, const raster_info *cinfo)
48285051{
48295052   raster_info *info = &v->rasterizer[v->next_rasterizer++];
r1070r1071
48435066   v->raster_hash[hash] = info;
48445067
48455068   if (LOG_RASTERIZERS)
4846      mame_printf_debug("Adding rasterizer @ %p : %08X %08X %08X %08X %08X %08X (hash=%d)\n",
5069      printf("Adding rasterizer @ %p : %08X %08X %08X %08X %08X %08X (hash=%d)\n",
48475070            info->callback,
48485071            info->eff_color_path, info->eff_alpha_mode, info->eff_fog_mode, info->eff_fbz_mode,
48495072            info->eff_tex_mode_0, info->eff_tex_mode_1, hash);
r1070r1071
48525075}
48535076
48545077
5078/*-------------------------------------------------
5079    find_rasterizer - find a rasterizer that
5080    matches  our current parameters and return
5081    it, creating a new one if necessary
5082-------------------------------------------------*/
5083
48555084static raster_info *find_rasterizer(voodoo_state *v, int texcount)
48565085{
48575086   raster_info *info, *prev = NULL;
r1070r1071
48905119         return info;
48915120      }
48925121
4893   /* attempt to generate one */
4894#ifdef VOODOO_DRC
4895   curinfo.callback = generate_rasterizer(v);
4896   curinfo.is_generic = FALSE;
4897   if (curinfo.callback == NULL)
4898#endif
4899   {
4900      curinfo.callback = (texcount == 0) ? raster_generic_0tmu : (texcount == 1) ? raster_generic_1tmu : raster_generic_2tmu;
4901      curinfo.is_generic = TRUE;
4902   }
4903
5122   /* generate a new one using the generic entry */
5123   curinfo.callback = (texcount == 0) ? raster_generic_0tmu : (texcount == 1) ? raster_generic_1tmu : raster_generic_2tmu;
5124   curinfo.is_generic = TRUE;
5125   curinfo.display = 0;
49045126   curinfo.polys = 0;
49055127   curinfo.hits = 0;
49065128   curinfo.next = 0;
r1070r1071
49095131}
49105132
49115133
5134/*-------------------------------------------------
5135    dump_rasterizer_stats - dump statistics on
5136    the current rasterizer usage patterns
5137-------------------------------------------------*/
5138
49125139static void dump_rasterizer_stats(voodoo_state *v)
49135140{
5141   static UINT8 display_index;
49145142   raster_info *cur, *best;
49155143   int hash;
49165144
4917   mame_printf_debug("----\n");
5145   printf("----\n");
5146   display_index++;
49185147
49195148   /* loop until we've displayed everything */
49205149   while (1)
r1070r1071
49245153      /* find the highest entry */
49255154      for (hash = 0; hash < RASTER_HASH_SIZE; hash++)
49265155         for (cur = v->raster_hash[hash]; cur; cur = cur->next)
4927            if (!best || cur->hits > best->hits)
5156            if (cur->display != display_index && (best == NULL || cur->hits > best->hits))
49285157               best = cur;
49295158
49305159      /* if we're done, we're done */
4931      if (!best || best->hits == 0)
5160      if (best == NULL || best->hits == 0)
49325161         break;
49335162
49345163      /* print it */
4935      mame_printf_debug("%9d  %10d %c  ( 0x%08X,  0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X )\n",
4936         best->polys,
4937         best->hits,
4938         best->is_generic ? '*' : ' ',
5164      printf("RASTERIZER_ENTRY( 0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X ) /* %c %8d %10d */\n",
49395165         best->eff_color_path,
49405166         best->eff_alpha_mode,
49415167         best->eff_fog_mode,
49425168         best->eff_fbz_mode,
49435169         best->eff_tex_mode_0,
4944         best->eff_tex_mode_1);
5170         best->eff_tex_mode_1,
5171         best->is_generic ? '*' : ' ',
5172         best->polys,
5173         best->hits);
49455174
49465175      /* reset */
4947      best->hits = best->polys = 0;
5176      best->display = display_index;
49485177   }
49495178}
49505179
49515180
49525181
4953/*************************************
4954 *
4955 *  Generic rasterizers
4956 *
4957 *************************************/
5182/***************************************************************************
5183    GENERIC RASTERIZERS
5184***************************************************************************/
49585185
5186/*-------------------------------------------------
5187    raster_fastfill - per-scanline
5188    implementation of the 'fastfill' command
5189-------------------------------------------------*/
5190
5191static void raster_fastfill(voodoo_state *v, INT32 scanline)
5192{
5193   int scry, x;
5194
5195   /* determine the screen Y */
5196   scry = scanline;
5197   if (FBZMODE_Y_ORIGIN(v->reg[fbzMode].u))
5198      scry = (v->fbi.yorigin - scanline) & 0x3ff;
5199
5200   /* fill this RGB row */
5201   if (FBZMODE_RGB_BUFFER_MASK(v->reg[fbzMode].u))
5202   {
5203      UINT16 *ditherow = &v->work.dither[(scanline & 3) * 4];
5204      UINT16 *dest = v->work.drawbuf + scry * v->fbi.rowpixels;
5205
5206      for (x = v->work.minx; x < v->work.maxx; x++)
5207         dest[x] = ditherow[x & 3];
5208   }
5209
5210   /* fill this dest buffer row */
5211   if (FBZMODE_AUX_BUFFER_MASK(v->reg[fbzMode].u) && v->fbi.aux)
5212   {
5213      UINT16 color = v->reg[zaColor].u;
5214      UINT16 *dest = v->fbi.aux + scry * v->fbi.rowpixels;
5215
5216      for (x = v->work.minx; x < v->work.maxx; x++)
5217         dest[x] = color;
5218   }
5219}
5220
5221
5222/*-------------------------------------------------
5223    generic_0tmu - generic rasterizer for 0 TMUs
5224-------------------------------------------------*/
5225
49595226RASTERIZER(generic_0tmu, 0, v->reg[fbzColorPath].u, v->reg[fbzMode].u, v->reg[alphaMode].u,
49605227         v->reg[fogMode].u, 0, 0)
49615228
5229
5230/*-------------------------------------------------
5231    generic_1tmu - generic rasterizer for 1 TMU
5232-------------------------------------------------*/
5233
49625234RASTERIZER(generic_1tmu, 1, v->reg[fbzColorPath].u, v->reg[fbzMode].u, v->reg[alphaMode].u,
49635235         v->reg[fogMode].u, v->tmu[0].reg[textureMode].u, 0)
49645236
5237
5238/*-------------------------------------------------
5239    generic_2tmu - generic rasterizer for 2 TMUs
5240-------------------------------------------------*/
5241
49655242RASTERIZER(generic_2tmu, 2, v->reg[fbzColorPath].u, v->reg[fbzMode].u, v->reg[alphaMode].u,
49665243         v->reg[fogMode].u, v->tmu[0].reg[textureMode].u, v->tmu[1].reg[textureMode].u)
49675244
49685245
4969
49705246#else
49715247
4972/*************************************
4973 *
4974 *  Specific rasterizers
4975 *
4976 *************************************/
49775248
4978/* blitz -------> fbzColorPath alphaMode   fogMode,    fbzMode,    texMode0,   texMode1  */
4979RASTERIZER_ENTRY( 0x01420039,  0x00000000, 0x00000000, 0x000B073B, 0x0C261ACF, 0xFFFFFFFF )   /* title */
4980RASTERIZER_ENTRY( 0x00582C35,  0x00515110, 0x00000000, 0x000B0739, 0x0C261ACF, 0xFFFFFFFF )   /* video */
4981RASTERIZER_ENTRY( 0x00000035,  0x00000000, 0x00000000, 0x000B0739, 0x0C261A0F, 0xFFFFFFFF )   /* in-game */
4982RASTERIZER_ENTRY( 0x00002C35,  0x00515110, 0x00000000, 0x000B07F9, 0x0C261A0F, 0xFFFFFFFF )   /* select screen */
4983RASTERIZER_ENTRY( 0x01420039,  0x00000000, 0x00000000, 0x000B07F9, 0x0C261ACF, 0xFFFFFFFF )   /* select screens */
49845249
4985/* blitz2k -----> fbzColorPath alphaMode   fogMode,    fbzMode,    texMode0,   texMode1  */
4986RASTERIZER_ENTRY( 0x01420039,  0x00000000, 0x00000000, 0x000B0739, 0x0C261ACF, 0xFFFFFFFF )   /* select screens */
5250/***************************************************************************
5251    GAME-SPECIFIC RASTERIZERS
5252***************************************************************************/
49875253
4988/* carnevil ----> fbzColorPath alphaMode   fogMode,    fbzMode,    texMode0,   texMode1  */
4989RASTERIZER_ENTRY( 0x00002435,  0x04045119, 0x00000000, 0x00030279, 0x0C261A0F, 0xFFFFFFFF )   /* clown */
4990RASTERIZER_ENTRY( 0x00002425,  0x00045119, 0x00000000, 0x00030679, 0x0C261A0F, 0xFFFFFFFF )   /* clown */
5254/* blitz ------> fbzColorPath alphaMode   fogMode,    fbzMode,    texMode0,   texMode1  */
5255RASTERIZER_ENTRY( 0x00000035, 0x00000000, 0x00000000, 0x000B0739, 0x0C261A0F, 0xFFFFFFFF ) /*     284269  914846168 */
5256RASTERIZER_ENTRY( 0x00002C35, 0x00515110, 0x00000000, 0x000B07F9, 0x0C261A0F, 0xFFFFFFFF ) /*     485421  440309121 */
5257RASTERIZER_ENTRY( 0x00582C35, 0x00515110, 0x00000000, 0x000B0739, 0x0C261ACF, 0xFFFFFFFF ) /*      31606  230753709 */
5258RASTERIZER_ENTRY( 0x00582C35, 0x00515110, 0x00000000, 0x000B0739, 0x0C261A0F, 0xFFFFFFFF ) /*      76742  211701679 */
5259RASTERIZER_ENTRY( 0x01420039, 0x00000000, 0x00000000, 0x000B073B, 0x0C261ACF, 0xFFFFFFFF ) /*       6188  152109056 */
5260RASTERIZER_ENTRY( 0x01420039, 0x00000000, 0x00000000, 0x000B07F9, 0x0C261ACF, 0xFFFFFFFF ) /*       1100  108134400 */
5261RASTERIZER_ENTRY( 0x00002C35, 0x64515119, 0x00000000, 0x000B0739, 0x0C261A0F, 0xFFFFFFFF ) /*    6229525  106197740 */
5262RASTERIZER_ENTRY( 0x00002C35, 0x40515119, 0x00000000, 0x000B0739, 0x0C261A0F, 0xFFFFFFFF ) /*      87756  103438805 */
5263RASTERIZER_ENTRY( 0x00002C35, 0x64515119, 0x00000000, 0x000B0799, 0x0C261A0F, 0xFFFFFFFF ) /*     905641   75886220 */
5264RASTERIZER_ENTRY( 0x00002C35, 0x40515119, 0x00000000, 0x000B07F9, 0x0C261A0F, 0xFFFFFFFF ) /*     205236   53317253 */
5265RASTERIZER_ENTRY( 0x01422439, 0x00000000, 0x00000000, 0x000B073B, 0x0C2610C9, 0xFFFFFFFF ) /*     817356   48881349 */
5266RASTERIZER_ENTRY( 0x00000035, 0x00000000, 0x00000000, 0x000B07F9, 0x0C261A0F, 0xFFFFFFFF ) /*      37979   41687251 */
5267RASTERIZER_ENTRY( 0x00002C35, 0x00515110, 0x00000000, 0x000B0739, 0x0C261A0F, 0xFFFFFFFF ) /*      26014   41183295 */
5268RASTERIZER_ENTRY( 0x01420039, 0x00000000, 0x00000000, 0x000B07F9, 0x0C261A0F, 0xFFFFFFFF ) /*       2512   37911104 */
5269RASTERIZER_ENTRY( 0x00006136, 0x40515119, 0x00000000, 0x000B07F9, 0x0C261A0F, 0xFFFFFFFF ) /*      28834   15527654 */
5270RASTERIZER_ENTRY( 0x00582435, 0x00515110, 0x00000000, 0x000B0739, 0x0C261ACF, 0xFFFFFFFF ) /*       9878    4979429 */
5271RASTERIZER_ENTRY( 0x00002C35, 0x64515119, 0x00000000, 0x000B0739, 0x0C261ACF, 0xFFFFFFFF ) /*     199952    4622064 */
5272RASTERIZER_ENTRY( 0x00582C35, 0x00515110, 0x00000000, 0x000B0739, 0x0C261AC9, 0xFFFFFFFF ) /*       8672    3676949 */
5273RASTERIZER_ENTRY( 0x00582C35, 0x00515010, 0x00000000, 0x000B0739, 0x0C2610CF, 0xFFFFFFFF ) /*        616    2743972 */
5274RASTERIZER_ENTRY( 0x01422C39, 0x00045110, 0x00000000, 0x000B0739, 0x0C261A0F, 0xFFFFFFFF ) /*      81380    2494832 */
5275//RASTERIZER_ENTRY( 0x00582435, 0x00515110, 0x00000000, 0x000B0739, 0x0C261AC9, 0xFFFFFFFF ) /*       7670    2235587 */
5276//RASTERIZER_ENTRY( 0x00592136, 0x00515110, 0x00000000, 0x000B073B, 0x0C261A0F, 0xFFFFFFFF ) /*        210    1639140 */
5277//RASTERIZER_ENTRY( 0x00582C35, 0x00515110, 0x00000000, 0x000B073B, 0x0C261A0F, 0xFFFFFFFF ) /*        108    1154736 */
5278//RASTERIZER_ENTRY( 0x00002C35, 0x00515110, 0x00000000, 0x000B07F9, 0x0C26180F, 0xFFFFFFFF ) /*       2152    1150842 */
5279//RASTERIZER_ENTRY( 0x00592136, 0x00515110, 0x00000000, 0x000B073B, 0x0C261ACF, 0xFFFFFFFF ) /*        152     880560 */
5280//RASTERIZER_ENTRY( 0x00008035, 0x64515119, 0x00000000, 0x000B0739, 0x0C261A0F, 0xFFFFFFFF ) /*      90848     805730 */
5281//RASTERIZER_ENTRY( 0x00002C35, 0x40515119, 0x00000000, 0x000B07F9, 0x0C261AC9, 0xFFFFFFFF ) /*       2024     571406 */
5282//RASTERIZER_ENTRY( 0x00012136, 0x00515110, 0x00000000, 0x000B07F9, 0x0C261A0F, 0xFFFFFFFF ) /*       1792     494592 */
5283//RASTERIZER_ENTRY( 0x00000002, 0x00000000, 0x00000000, 0x00000300, 0xFFFFFFFF, 0xFFFFFFFF ) /*        256     161280 */
49915284
4992/* calspeed ----> fbzColorPath alphaMode   fogMode,    fbzMode,    texMode0,   texMode1  */
4993RASTERIZER_ENTRY( 0x00002815,  0x05045119, 0x00000001, 0x000A0723, 0x0C261ACF, 0xFFFFFFFF )   /* movie */
4994RASTERIZER_ENTRY( 0x01022C19,  0x05000009, 0x00000001, 0x000B0739, 0x0C26100F, 0xFFFFFFFF )   /* in-game */
4995RASTERIZER_ENTRY( 0x00002C15,  0x05045119, 0x00000001, 0x000B0739, 0x0C26180F, 0xFFFFFFFF )   /* in-game */
4996RASTERIZER_ENTRY( 0x01022C19,  0x05000009, 0x00000001, 0x000B073B, 0x0C26100F, 0xFFFFFFFF )   /* in-game */
4997RASTERIZER_ENTRY( 0x00480015,  0x05045119, 0x00000001, 0x000B0339, 0x0C26100F, 0xFFFFFFFF )   /* in-game */
5285/* blitz99 ----> fbzColorPath alphaMode   fogMode,    fbzMode,    texMode0,   texMode1  */
5286RASTERIZER_ENTRY( 0x00000035, 0x64000009, 0x00000000, 0x000B0739, 0x0C261A0F, 0xFFFFFFFF ) /* *  6297478  149465839 */
5287RASTERIZER_ENTRY( 0x00000035, 0x64000009, 0x00000000, 0x000B0739, 0x0C261ACF, 0xFFFFFFFF ) /* *   210693    6285480 */
5288RASTERIZER_ENTRY( 0x01422C39, 0x00045110, 0x00000000, 0x000B073B, 0x0C2610C9, 0xFFFFFFFF ) /* *    20180    2718710 */
5289RASTERIZER_ENTRY( 0x00582C35, 0x00515110, 0x00000000, 0x000B073B, 0x0C261ACF, 0xFFFFFFFF ) /* *      360    2425416 */
5290RASTERIZER_ENTRY( 0x00002C35, 0x64000009, 0x00000000, 0x000B0739, 0x0C261A0F, 0xFFFFFFFF ) /* *    67059    1480978 */
5291RASTERIZER_ENTRY( 0x00008035, 0x64000009, 0x00000000, 0x000B0739, 0x0C261A0F, 0xFFFFFFFF ) /* *    24811     400666 */
5292RASTERIZER_ENTRY( 0x01420039, 0x00000000, 0x00000000, 0x000B073B, 0x0C2610C9, 0xFFFFFFFF ) /* *    10304     324468 */
5293RASTERIZER_ENTRY( 0x00002C35, 0x00515110, 0x00000000, 0x000B0739, 0x0C261ACF, 0xFFFFFFFF ) /* *     1024     112665 */
49985294
4999/* mace --------> fbzColorPath alphaMode   fogMode,    fbzMode,    texMode0,   texMode1  */
5000RASTERIZER_ENTRY( 0x00000035,  0x00045119, 0x00000000, 0x000B0779, 0x082418DF, 0xFFFFFFFF )   /* character screen */
5001RASTERIZER_ENTRY( 0x00600C09,  0x00045119, 0x00000000, 0x000B0779, 0x0824100F, 0xFFFFFFFF )   /* in-game */
5002RASTERIZER_ENTRY( 0x00600C09,  0x00045119, 0x00000000, 0x000B0779, 0x0824180F, 0xFFFFFFFF )   /* in-game */
5003RASTERIZER_ENTRY( 0x00600C09,  0x00045119, 0x00000000, 0x000B0779, 0x082410CF, 0xFFFFFFFF )   /* in-game */
5004RASTERIZER_ENTRY( 0x00600C09,  0x00045119, 0x00000000, 0x000B0779, 0x082418CF, 0xFFFFFFFF )   /* in-game */
5295/* blitz2k ----> fbzColorPath alphaMode   fogMode,    fbzMode,    texMode0,   texMode1  */
5296RASTERIZER_ENTRY( 0x01420039, 0x00000000, 0x00000000, 0x000B0739, 0x0C261ACF, 0xFFFFFFFF ) /* *     3880   95344128 */
5297RASTERIZER_ENTRY( 0x00582C35, 0x00514110, 0x00000000, 0x000B0739, 0x0C261ACF, 0xFFFFFFFF ) /* *      148    1785480 */
5298RASTERIZER_ENTRY( 0x01420039, 0x00000000, 0x00000000, 0x000B073B, 0x0C2610CF, 0xFFFFFFFF ) /* *     9976     314244 */
50055299
5006/* vaportrx ----> fbzColorPath alphaMode   fogMode,    fbzMode,    texMode0,   texMode1  */
5007RASTERIZER_ENTRY( 0x00482405,  0x00000009, 0x00000000, 0x000B0739, 0x0C26100F, 0xFFFFFFFF )   /* intro */
5008RASTERIZER_ENTRY( 0x00482405,  0x00000000, 0x00000000, 0x000B0739, 0x0C26100F, 0xFFFFFFFF )   /* in-game */
5009RASTERIZER_ENTRY( 0x00482435,  0x00000000, 0x00000000, 0x000B0739, 0x0C261A0F, 0xFFFFFFFF )   /* in-game */
5010RASTERIZER_ENTRY( 0x00482435,  0x00045119, 0x00000000, 0x000B07F9, 0x0C261ACF, 0xFFFFFFFF )   /* in-game */
5300/* carnevil ---> fbzColorPath alphaMode   fogMode,    fbzMode,    texMode0,   texMode1  */
5301RASTERIZER_ENTRY( 0x00002435, 0x04045119, 0x00000000, 0x00030279, 0x0C261A0F, 0xFFFFFFFF ) /* *      492   84128082 */
5302RASTERIZER_ENTRY( 0x00002425, 0x00045119, 0x00000000, 0x00030679, 0x0C261A0F, 0xFFFFFFFF ) /* *  1988398   36166780 */
5303RASTERIZER_ENTRY( 0x00486116, 0x01045119, 0x00000000, 0x00030279, 0x0C26180F, 0xFFFFFFFF ) /* *    34424   28788847 */
5304RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000000, 0x00030679, 0x0C261A0F, 0xFFFFFFFF ) /* *      514   26316800 */
5305RASTERIZER_ENTRY( 0x00480015, 0x0F045119, 0x00000000, 0x000306F9, 0x0C261AC9, 0xFFFFFFFF ) /* *     7346   18805760 */
5306RASTERIZER_ENTRY( 0x00002435, 0x40045119, 0x00000000, 0x000302F9, 0x0C26180F, 0xFFFFFFFF ) /* *   130764   18678972 */
5307RASTERIZER_ENTRY( 0x00000035, 0x40045119, 0x00000000, 0x00030679, 0x0C261A0F, 0xFFFFFFFF ) /* *     3380   13844480 */
5308RASTERIZER_ENTRY( 0x00482415, 0x0F045119, 0x00000000, 0x000306F9, 0x0C2618C9, 0xFFFFFFFF ) /* *     7244   12179040 */
5309RASTERIZER_ENTRY( 0x00482415, 0x0A045119, 0x00000000, 0x000306F9, 0x0C26180F, 0xFFFFFFFF ) /* *    84520   12059721 */
5310RASTERIZER_ENTRY( 0x00000035, 0x0A045119, 0x00000000, 0x000306F9, 0x0C261AC9, 0xFFFFFFFF ) /* *    21926   11226112 */
5311RASTERIZER_ENTRY( 0x00482415, 0x40045119, 0x00000000, 0x00030679, 0x0C2618C9, 0xFFFFFFFF ) /* *    92115    8926536 */
5312RASTERIZER_ENTRY( 0x00480015, 0x04045119, 0x00000000, 0x000306F9, 0x0C261AC9, 0xFFFFFFFF ) /* *     5018    7711968 */
5313RASTERIZER_ENTRY( 0x00482415, 0x04045119, 0x00000000, 0x00030279, 0x0C261A0F, 0xFFFFFFFF ) /* *     1730    7629334 */
5314RASTERIZER_ENTRY( 0x00002435, 0x40045119, 0x00000000, 0x000B0779, 0x0C26180F, 0xFFFFFFFF ) /* *    37408    5545956 */
5315RASTERIZER_ENTRY( 0x00002435, 0x40045119, 0x00000000, 0x00030679, 0x0C26180F, 0xFFFFFFFF ) /* *    26528    4225026 */
5316RASTERIZER_ENTRY( 0x00002435, 0x08045119, 0x00000000, 0x000306F9, 0x0C26180F, 0xFFFFFFFF ) /* *    35764    3230884 */
5317RASTERIZER_ENTRY( 0x00000035, 0x08045119, 0x00000000, 0x000306F9, 0x0C261AC9, 0xFFFFFFFF ) /* *     3926    2404352 */
5318RASTERIZER_ENTRY( 0x01422409, 0x00045119, 0x00000000, 0x00030679, 0x0C261A0F, 0xFFFFFFFF ) /* *    96020    1226438 */
5319RASTERIZER_ENTRY( 0x00482415, 0x04045119, 0x00000000, 0x00030279, 0x0C2618C9, 0xFFFFFFFF ) /* *     1020     574649 */
5320RASTERIZER_ENTRY( 0x00482415, 0x05045119, 0x00000000, 0x00030679, 0x0C261A0F, 0xFFFFFFFF ) /* *      360     370008 */
5321RASTERIZER_ENTRY( 0x00480015, 0x04045119, 0x00000000, 0x000306F9, 0x0C261A0F, 0xFFFFFFFF ) /* *      576     334404 */
50115322
5012/* wg3dh -------> fbzColorPath alphaMode   fogMode,    fbzMode,    texMode0,   texMode1  */
5013RASTERIZER_ENTRY( 0x00000035,  0x00045119, 0x00000000, 0x000B0779, 0x082410DF, 0xFFFFFFFF )   /* title */
5014RASTERIZER_ENTRY( 0x00000035,  0x00045119, 0x00000000, 0x000B0779, 0x0824101F, 0xFFFFFFFF )   /* credits */
5015RASTERIZER_ENTRY( 0x00000035,  0x00045119, 0x00000000, 0x000B0779, 0x08241ADF, 0xFFFFFFFF )   /* in-game */
5016RASTERIZER_ENTRY( 0x00480035,  0x00045119, 0x00000000, 0x000B0779, 0x082418DF, 0xFFFFFFFF )   /* in-game */
5017RASTERIZER_ENTRY( 0x00000035,  0x00045119, 0x00000000, 0x000B0779, 0x0824189F, 0xFFFFFFFF )   /* in-game */
5323/* calspeed ---> fbzColorPath alphaMode   fogMode,    fbzMode,    texMode0,   texMode1  */
5324RASTERIZER_ENTRY( 0x00002815, 0x05045119, 0x00000001, 0x000B07F9, 0x0C26100F, 0xFFFFFFFF ) /* *    99120 1731923836 */
5325RASTERIZER_ENTRY( 0x01022819, 0x05000009, 0x00000001, 0x000B0739, 0x0C26100F, 0xFFFFFFFF ) /* *  9955804 1526119944 */
5326RASTERIZER_ENTRY( 0x00002815, 0x05045119, 0x00000001, 0x000B0739, 0x0C26180F, 0xFFFFFFFF ) /* *  1898207 1124776864 */
5327RASTERIZER_ENTRY( 0x01022819, 0x05000009, 0x00000001, 0x000B073B, 0x0C26100F, 0xFFFFFFFF ) /* *  3487467 1101663125 */
5328RASTERIZER_ENTRY( 0x01022C19, 0x05000009, 0x00000001, 0x000B0739, 0x0C26100F, 0xFFFFFFFF ) /* *  1079277  609256033 */
5329RASTERIZER_ENTRY( 0x00002815, 0x05045119, 0x00000001, 0x000A0723, 0x0C261ACF, 0xFFFFFFFF ) /* *    11880  583925760 */
5330RASTERIZER_ENTRY( 0x00602819, 0x05045119, 0x00000001, 0x000B07F9, 0x0C26180F, 0xFFFFFFFF ) /* *    63644  582469888 */
5331RASTERIZER_ENTRY( 0x01022819, 0x05000009, 0x00000001, 0x000B07F9, 0x0C261A0F, 0xFFFFFFFF ) /* *    22688  556797972 */
5332RASTERIZER_ENTRY( 0x00002815, 0x05045119, 0x00000001, 0x000B07F9, 0x0C26180F, 0xFFFFFFFF ) /* *  1360254  417068457 */
5333RASTERIZER_ENTRY( 0x00002815, 0x05045119, 0x00000001, 0x000B0739, 0x0C26100F, 0xFFFFFFFF ) /* *  3427489  405421272 */
5334RASTERIZER_ENTRY( 0x00002C15, 0x05045119, 0x00000001, 0x000B0739, 0x0C26180F, 0xFFFFFFFF ) /* *   286809  238944049 */
5335RASTERIZER_ENTRY( 0x00002815, 0x05045119, 0x00000001, 0x000A0321, 0x0C26180F, 0xFFFFFFFF ) /* *    28160  231084818 */
5336RASTERIZER_ENTRY( 0x01022819, 0x05000009, 0x00000001, 0x000B07FB, 0x0C26100F, 0xFFFFFFFF ) /* *   183564  201014424 */
5337RASTERIZER_ENTRY( 0x00480015, 0x05045119, 0x00000001, 0x000B0339, 0x0C26100F, 0xFFFFFFFF ) /* *    15275  168207109 */
5338RASTERIZER_ENTRY( 0x01022819, 0x05000009, 0x00000001, 0x000B07F9, 0x0C26100F, 0xFFFFFFFF ) /* *     2856  134400000 */
5339RASTERIZER_ENTRY( 0x00002815, 0x05045119, 0x00000001, 0x000B0339, 0x0C26180F, 0xFFFFFFFF ) /* *    98551  110417974 */
5340RASTERIZER_ENTRY( 0x01022819, 0x05000009, 0x00000001, 0x000B07F9, 0x0C2610CF, 0xFFFFFFFF ) /* *    47040  107360728 */
5341RASTERIZER_ENTRY( 0x00480015, 0x05045119, 0x00000001, 0x000B0339, 0x0C26180F, 0xFFFFFFFF ) /* *    13128   86876789 */
5342RASTERIZER_ENTRY( 0x01022C19, 0x05000009, 0x00000001, 0x000B073B, 0x0C26100F, 0xFFFFFFFF ) /* *   257515   76329054 */
5343RASTERIZER_ENTRY( 0x00002815, 0x05045119, 0x00000001, 0x000B07F9, 0x0C261A0F, 0xFFFFFFFF ) /* *     3934   64958208 */
5344//RASTERIZER_ENTRY( 0x00002C15, 0x05045119, 0x00000001, 0x000B07F9, 0x0C26180F, 0xFFFFFFFF ) /* *    77400   63786236 */
5345//RASTERIZER_ENTRY( 0x01022C19, 0x05000009, 0x00000001, 0x000B07F9, 0x0C261A0F, 0xFFFFFFFF ) /* *    12500   63151200 */
5346//RASTERIZER_ENTRY( 0x0102001A, 0x05045119, 0x00000001, 0x000A0321, 0xFFFFFFFF, 0xFFFFFFFF ) /* *     8764   57629312 */
5347//RASTERIZER_ENTRY( 0x00002C15, 0x05045119, 0x00000001, 0x000A0321, 0x0C26180F, 0xFFFFFFFF ) /* *     3257   32708448 */
5348//RASTERIZER_ENTRY( 0x00002815, 0x05045119, 0x00000001, 0x000A07E3, 0x0C2610CF, 0xFFFFFFFF ) /* *    28364   31195605 */
5349//RASTERIZER_ENTRY( 0x00002C15, 0x05045119, 0x00000001, 0x000B0739, 0x0C26100F, 0xFFFFFFFF ) /* *   409001   30699647 */
5350//RASTERIZER_ENTRY( 0x00482C35, 0x05045119, 0x00000001, 0x000A0321, 0x0C26100F, 0xFFFFFFFF ) /* *    17669   11214172 */
5351//RASTERIZER_ENTRY( 0x00002C15, 0x05045119, 0x00000001, 0x000B0339, 0x0C26180F, 0xFFFFFFFF ) /* *     5844    6064373 */
5352//RASTERIZER_ENTRY( 0x00002C15, 0x05045119, 0x00000001, 0x000B07FB, 0x0C26100F, 0xFFFFFFFF ) /* *      626    4651080 */
5353//RASTERIZER_ENTRY( 0x00482C35, 0x05045119, 0x00000001, 0x000A0321, 0x0C26180F, 0xFFFFFFFF ) /* *     5887    2945500 */
5354//RASTERIZER_ENTRY( 0x00480015, 0x05045119, 0x00000001, 0x000B0339, 0x0C261A0F, 0xFFFFFFFF ) /* *     1090    2945093 */
5355//RASTERIZER_ENTRY( 0x00602C19, 0x05045119, 0x00000001, 0x000B07F9, 0x0C26180F, 0xFFFFFFFF ) /* *      228    1723908 */
5356//RASTERIZER_ENTRY( 0x00002C15, 0x05045119, 0x00000001, 0x000A0321, 0x0C261A0F, 0xFFFFFFFF ) /* *      112    1433600 */
5357//RASTERIZER_ENTRY( 0x00002815, 0x05045119, 0x00000001, 0x000B0739, 0x0C261A0F, 0xFFFFFFFF ) /* *     3091    1165805 */
5358//RASTERIZER_ENTRY( 0x01022C19, 0x05000009, 0x00000001, 0x000B07FB, 0x0C26100F, 0xFFFFFFFF ) /* *      620     791202 */
50185359
5360/* hyprdriv ---> fbzColorPath alphaMode   fogMode,    fbzMode,    texMode0,   texMode1  */
5361RASTERIZER_ENTRY( 0x01420039, 0x00000000, 0x00000001, 0x000B0739, 0x0C261ACF, 0xFFFFFFFF ) /* *    60860  498565120 */
5362RASTERIZER_ENTRY( 0x01420039, 0x00000000, 0x00000001, 0x000B07F9, 0x0C261A0F, 0xFFFFFFFF ) /* *    28688  235012096 */
5363RASTERIZER_ENTRY( 0x01420039, 0x00000000, 0x00000001, 0x000B07F9, 0x0C261ACF, 0xFFFFFFFF ) /* *    11844  156499968 */
5364RASTERIZER_ENTRY( 0x00580035, 0x0A045119, 0x00000001, 0x00030279, 0x0C261A0F, 0xFFFFFFFF ) /* *   175990  146518715 */
5365RASTERIZER_ENTRY( 0x00582C35, 0x00515110, 0x00000001, 0x000B0739, 0x0C261ACF, 0xFFFFFFFF ) /* *     2336  114819072 */
5366RASTERIZER_ENTRY( 0x00580035, 0x00000000, 0x00000001, 0x000B073B, 0x0C261A1F, 0xFFFFFFFF ) /* *   363325  100404294 */
5367RASTERIZER_ENTRY( 0x00582C35, 0x00045110, 0x00000001, 0x000B073B, 0x0C261A0F, 0xFFFFFFFF ) /* *    40918   96318738 */
5368RASTERIZER_ENTRY( 0x01420039, 0x00000000, 0x00000001, 0x000B0739, 0x0C26101F, 0xFFFFFFFF ) /* *    54815   94990269 */
5369RASTERIZER_ENTRY( 0x01420039, 0x00000000, 0x00000001, 0x000B0739, 0x0C261A1F, 0xFFFFFFFF ) /* *   123032   91652828 */
5370RASTERIZER_ENTRY( 0x01422429, 0x00000000, 0x00000001, 0x000B0739, 0x0C261A1F, 0xFFFFFFFF ) /* *    82767   86431997 */
5371RASTERIZER_ENTRY( 0x01422429, 0x00000000, 0x00000001, 0x000B0739, 0x0C26101F, 0xFFFFFFFF ) /* *     9874   78101834 */
5372RASTERIZER_ENTRY( 0x01422429, 0x00000000, 0x00000001, 0x000B073B, 0x0C261A1F, 0xFFFFFFFF ) /* *   102146   72570879 */
5373RASTERIZER_ENTRY( 0x01420039, 0x00000000, 0x00000001, 0x000B073B, 0x0C26100F, 0xFFFFFFFF ) /* *   657804   67229658 */
5374RASTERIZER_ENTRY( 0x00580035, 0x00045110, 0x00000001, 0x000B03F9, 0x0C261A0F, 0xFFFFFFFF ) /* *    10428   63173865 */
5375RASTERIZER_ENTRY( 0x01422429, 0x00000000, 0x00000001, 0x000B073B, 0x0C261A0F, 0xFFFFFFFF ) /* *   230145   57902926 */
5376RASTERIZER_ENTRY( 0x01422C19, 0x00000000, 0x00000001, 0x000B073B, 0x0C261A0F, 0xFFFFFFFF ) /* *   769654   53992486 */
5377RASTERIZER_ENTRY( 0x01422C19, 0x00000000, 0x00000001, 0x000B0739, 0x0C26101F, 0xFFFFFFFF ) /* *    85365   51865697 */
5378RASTERIZER_ENTRY( 0x00582435, 0x00515110, 0x00000001, 0x000B0739, 0x0C261AC9, 0xFFFFFFFF ) /* *   454674   46165536 */
5379RASTERIZER_ENTRY( 0x00580035, 0x00000000, 0x00000001, 0x000B073B, 0x0C26101F, 0xFFFFFFFF ) /* *   101889   33337987 */
5380RASTERIZER_ENTRY( 0x00580035, 0x00000000, 0x00000001, 0x000B0739, 0x0C26101F, 0xFFFFFFFF ) /* *   255952   29810993 */
5381//RASTERIZER_ENTRY( 0x00582425, 0x00000000, 0x00000001, 0x000B073B, 0x0C261A1F, 0xFFFFFFFF ) /* *   106190   25430383 */
5382//RASTERIZER_ENTRY( 0x01420039, 0x00000000, 0x00000001, 0x000B073B, 0x0C261A1F, 0xFFFFFFFF ) /* *   595001   23268601 */
5383//RASTERIZER_ENTRY( 0x0142612A, 0x00000000, 0x00000001, 0x000B0739, 0xFFFFFFFF, 0xFFFFFFFF ) /* *   946410   22589110 */
5384//RASTERIZER_ENTRY( 0x01420039, 0x00000000, 0x00000001, 0x000B073B, 0x0C261A0F, 0xFFFFFFFF ) /* *   330036   21323230 */
5385//RASTERIZER_ENTRY( 0x01422C19, 0x00000000, 0x00000001, 0x000B0739, 0x0C261A1F, 0xFFFFFFFF ) /* *    40089   13470498 */
5386//RASTERIZER_ENTRY( 0x01422C19, 0x00000000, 0x00000000, 0x000B073B, 0x0C261A0F, 0xFFFFFFFF ) /* *    90906   12850855 */
5387//RASTERIZER_ENTRY( 0x00582C35, 0x00515110, 0x00000001, 0x000B0739, 0x0C261A0F, 0xFFFFFFFF ) /* *     9492   12115280 */
5388//RASTERIZER_ENTRY( 0x01420039, 0x00000000, 0x00000001, 0x000B073B, 0x0C26101F, 0xFFFFFFFF ) /* *   453515   12013961 */
5389//RASTERIZER_ENTRY( 0x01422C19, 0x00000000, 0x00000001, 0x000B073B, 0x0C261A1F, 0xFFFFFFFF ) /* *    33829    8384312 */
5390//RASTERIZER_ENTRY( 0x00580035, 0x00000000, 0x00000001, 0x000B073B, 0x0C26100F, 0xFFFFFFFF ) /* *    83986    7841206 */
5391//RASTERIZER_ENTRY( 0x00580035, 0x00045110, 0x00000001, 0x000B0339, 0x0C261A0F, 0xFFFFFFFF ) /* *    42515    7242660 */
5392//RASTERIZER_ENTRY( 0x00582425, 0x00000000, 0x00000001, 0x000B0739, 0x0C26100F, 0xFFFFFFFF ) /* *      706    6158684 */
5393//RASTERIZER_ENTRY( 0x00582425, 0x00000000, 0x00000001, 0x000B0739, 0x0C26101F, 0xFFFFFFFF ) /* *    62051    5819485 */
5394//RASTERIZER_ENTRY( 0x0142612A, 0x00000000, 0x00000000, 0x000B0739, 0xFFFFFFFF, 0xFFFFFFFF ) /* *   135139    5063467 */
5395//RASTERIZER_ENTRY( 0x01422429, 0x00000000, 0x00000001, 0x000B073B, 0x0C26100F, 0xFFFFFFFF ) /* *    10359    5135837 */
5396//RASTERIZER_ENTRY( 0x01420039, 0x00000000, 0x00000001, 0x000B0739, 0x0C26100F, 0xFFFFFFFF ) /* *   170159    4449246 */
5397//RASTERIZER_ENTRY( 0x00582425, 0x00000000, 0x00000001, 0x000B073B, 0x0C26101F, 0xFFFFFFFF ) /* *    19037    4371219 */
5398//RASTERIZER_ENTRY( 0x01422429, 0x00000000, 0x00000001, 0x000B073B, 0x0C26101F, 0xFFFFFFFF ) /* *     8963    4352501 */
5399//RASTERIZER_ENTRY( 0x01422C39, 0x00045110, 0x00000001, 0x000B073B, 0x0C261A0F, 0xFFFFFFFF ) /* *    47712    4159994 */
5400//RASTERIZER_ENTRY( 0x01422C19, 0x00000000, 0x00000000, 0x000B073B, 0x0C261ACF, 0xFFFFFFFF ) /* *    47525    4151435 */
5401//RASTERIZER_ENTRY( 0x01422C19, 0x00000000, 0x00000001, 0x000B0739, 0x0C261A0F, 0xFFFFFFFF ) /* *    34980    3794066 */
5402//RASTERIZER_ENTRY( 0x0142613A, 0x00045110, 0x00000000, 0x000B0739, 0xFFFFFFFF, 0xFFFFFFFF ) /* *     6540    2358068 */
5403//RASTERIZER_ENTRY( 0x0142611A, 0x00045110, 0x00000000, 0x000B0739, 0xFFFFFFFF, 0xFFFFFFFF ) /* *   703308    2096781 */
5404//RASTERIZER_ENTRY( 0x00580035, 0x00045110, 0x00000001, 0x000B0339, 0x0C261A1F, 0xFFFFFFFF ) /* *     3963    2079440 */
5405//RASTERIZER_ENTRY( 0x01422439, 0x00000000, 0x00000001, 0x000B073B, 0x0C261AC9, 0xFFFFFFFF ) /* *    22866    2008397 */
5406//RASTERIZER_ENTRY( 0x01420039, 0x00000000, 0x00000001, 0x000B0739, 0x0C261A0F, 0xFFFFFFFF ) /* *    69705    1673671 */
5407//RASTERIZER_ENTRY( 0x01422C19, 0x00000000, 0x00000001, 0x000B073B, 0x0C26100F, 0xFFFFFFFF ) /* *    13366    1575120 */
5408//RASTERIZER_ENTRY( 0x0142613A, 0x00000000, 0x00000000, 0x000B0739, 0xFFFFFFFF, 0xFFFFFFFF ) /* *    50625    1408211 */
5409//RASTERIZER_ENTRY( 0x0142613A, 0x00045110, 0x00000001, 0x000B0739, 0xFFFFFFFF, 0xFFFFFFFF ) /* *  1244348    1244346 */
5410//RASTERIZER_ENTRY( 0x00582425, 0x00000000, 0x00000001, 0x000B073B, 0x0C26100F, 0xFFFFFFFF ) /* *    13791    1222735 */
5411//RASTERIZER_ENTRY( 0x00580035, 0x00000000, 0x00000001, 0x000B073B, 0x0C261A0F, 0xFFFFFFFF ) /* *    33064     943590 */
5412//RASTERIZER_ENTRY( 0x0142610A, 0x00045110, 0x00000001, 0x000B0739, 0xFFFFFFFF, 0xFFFFFFFF ) /* *     2041     926507 */
5413//RASTERIZER_ENTRY( 0x00480019, 0x00045110, 0x00000001, 0x000B073B, 0x0C261A0F, 0xFFFFFFFF ) /* *     2722     453924 */
5414//RASTERIZER_ENTRY( 0x00580035, 0x00000000, 0x00000001, 0x000B0739, 0x0C26100F, 0xFFFFFFFF ) /* *    68232     306869 */
5415//RASTERIZER_ENTRY( 0x0142611A, 0x00045110, 0x00000001, 0x000B0379, 0xFFFFFFFF, 0xFFFFFFFF ) /* *     7164     269002 */
5416
5417/* mace -------> fbzColorPath alphaMode   fogMode,    fbzMode,    texMode0,   texMode1  */
5418RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x0824100F, 0xFFFFFFFF ) /* *  7204150 1340201579 */
5419RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000000, 0x000B0779, 0x08241ADF, 0xFFFFFFFF ) /* *    15332 1181663232 */
5420RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000000, 0x000B0779, 0x082418DF, 0xFFFFFFFF ) /* *   104456  652582379 */
5421RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x0824180F, 0xFFFFFFFF ) /* *   488613  368880164 */
5422RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x082418CF, 0xFFFFFFFF ) /* *   352924  312417405 */
5423RASTERIZER_ENTRY( 0x00480035, 0x00045119, 0x00000000, 0x000B0779, 0x082418DF, 0xFFFFFFFF ) /* *    15024  291762384 */
5424RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x082410CF, 0xFFFFFFFF ) /* *   711824  279246170 */
5425RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000001, 0x000B0779, 0x0824100F, 0xFFFFFFFF ) /* *   735574  171881981 */
5426RASTERIZER_ENTRY( 0x00602401, 0x00045119, 0x00000000, 0x000B0779, 0x082418DF, 0xFFFFFFFF ) /* *   943006  154374023 */
5427RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000001, 0x000B0779, 0x082410CF, 0xFFFFFFFF ) /* *   103877  101077498 */
5428RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x0824108F, 0xFFFFFFFF ) /* *   710125   87547221 */
5429RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x08241ACF, 0xFFFFFFFF ) /* *     9834   79774966 */
5430RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000000, 0x000B0379, 0x082418DF, 0xFFFFFFFF ) /* *    17644   70187036 */
5431RASTERIZER_ENTRY( 0x00480035, 0x00045119, 0x00000000, 0x000B0379, 0x082418DF, 0xFFFFFFFF ) /* *    11324   56633925 */
5432RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x00000000, 0x000B0379, 0x0824180F, 0xFFFFFFFF ) /* *    96743   40820171 */
5433RASTERIZER_ENTRY( 0x00482435, 0xA4045119, 0x00000000, 0x000B0739, 0x082418CF, 0xFFFFFFFF ) /* *   166053   29100794 */
5434RASTERIZER_ENTRY( 0x00482435, 0xA4045117, 0x00000000, 0x000B0339, 0x082418CF, 0xFFFFFFFF ) /* *   166053   29100697 */
5435RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000001, 0x000B0379, 0x0824188F, 0xFFFFFFFF ) /* *     6723   29076516 */
5436RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x0824188F, 0xFFFFFFFF ) /* *    53297   23928976 */
5437RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000001, 0x000B0779, 0x0824180F, 0xFFFFFFFF ) /* *    10309   19001776 */
5438//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0379, 0x0824180F, 0xFFFFFFFF ) /* *    22105   17473157 */
5439//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0379, 0x0824188F, 0xFFFFFFFF ) /* *    11304   17236698 */
5440//RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000000, 0x000B0779, 0x082410DF, 0xFFFFFFFF ) /* *     1664   17180883 */
5441//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x08241A0F, 0xFFFFFFFF ) /* *   148606   12274278 */
5442//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000001, 0x000B0779, 0x082418CF, 0xFFFFFFFF ) /* *    80692    9248007 */
5443//RASTERIZER_ENTRY( 0x00482435, 0xA4045119, 0x00000001, 0x000B0739, 0x082418CF, 0xFFFFFFFF ) /* *    37819    8080994 */
5444//RASTERIZER_ENTRY( 0x00482435, 0xA4045117, 0x00000001, 0x000B0339, 0x082418CF, 0xFFFFFFFF ) /* *    37819    8080969 */
5445//RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000001, 0x000B0379, 0x082418DF, 0xFFFFFFFF ) /* *      536    7930305 */
5446//RASTERIZER_ENTRY( 0x00482435, 0x99045117, 0x00000000, 0x000B0339, 0x082418CF, 0xFFFFFFFF ) /* *    27601    7905364 */
5447//RASTERIZER_ENTRY( 0x00482435, 0x99045119, 0x00000000, 0x000B0739, 0x082418CF, 0xFFFFFFFF ) /* *    27601    7905364 */
5448//RASTERIZER_ENTRY( 0x00482435, 0xAF045119, 0x00000000, 0x000B0739, 0x082418CF, 0xFFFFFFFF ) /* *    36314    7667917 */
5449//RASTERIZER_ENTRY( 0x00482435, 0xAF045117, 0x00000000, 0x000B0339, 0x082418CF, 0xFFFFFFFF ) /* *    36314    7667917 */
5450//RASTERIZER_ENTRY( 0x00482435, 0xBA045119, 0x00000000, 0x000B0739, 0x082418CF, 0xFFFFFFFF ) /* *    31109    6020110 */
5451//RASTERIZER_ENTRY( 0x00482435, 0xBA045117, 0x00000000, 0x000B0339, 0x082418CF, 0xFFFFFFFF ) /* *    31109    6020110 */
5452//RASTERIZER_ENTRY( 0x00482435, 0x6D045117, 0x00000000, 0x000B0339, 0x082418CF, 0xFFFFFFFF ) /* *    42689    5959231 */
5453//RASTERIZER_ENTRY( 0x00482435, 0x6D045119, 0x00000000, 0x000B0739, 0x082418CF, 0xFFFFFFFF ) /* *    42689    5959231 */
5454//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000001, 0x000B0779, 0x0824188F, 0xFFFFFFFF ) /* *    11965    5118044 */
5455//RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x00000001, 0x000B0379, 0x0824180F, 0xFFFFFFFF ) /* *    11923    4662909 */
5456//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0379, 0x082410CF, 0xFFFFFFFF ) /* *     4422    4624260 */
5457//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0379, 0x0824100F, 0xFFFFFFFF ) /* *     3853    3596375 */
5458//RASTERIZER_ENTRY( 0x00480035, 0x00045119, 0x00000001, 0x000B0379, 0x082418DF, 0xFFFFFFFF ) /* *      400    3555759 */
5459//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000001, 0x000B0379, 0x0824180F, 0xFFFFFFFF ) /* *     3755    3453084 */
5460//RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000001, 0x000B0779, 0x082418DF, 0xFFFFFFFF ) /* *     4170    2425016 */
5461//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x0824184F, 0xFFFFFFFF ) /* *      322    2220073 */
5462//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0379, 0x082418CF, 0xFFFFFFFF ) /* *     4008    1201335 */
5463//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000001, 0x000B0779, 0x0824108F, 0xFFFFFFFF ) /* *    13704     883585 */
5464
5465/* sfrush -----> fbzColorPath alphaMode   fogMode,    fbzMode,    texMode0,   texMode1  */
5466RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x00000000, 0x0824101F ) /* *   590139  246714190 */
5467RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000001, 0x000B0779, 0x0824101F, 0x0824101F ) /* *   397774  153418144 */
5468RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x00000000, 0x082410DF ) /* *    22732  146975666 */
5469RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000001, 0x000B0779, 0x00000000, 0x0824101F ) /* *   306398  130393278 */
5470RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x0824101F, 0x0824101F ) /* *   437743  117403881 */
5471RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x0824181F, 0x0824101F ) /* *    66608  109289500 */
5472RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000001, 0x000B0779, 0x00000000, 0x082410DF ) /* *    19101   92573085 */
5473RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x00000000, 0x0824181F ) /* *   258287   78618228 */
5474RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000001, 0x000B0779, 0x0824181F, 0x0824101F ) /* *    61814   68788856 */
5475RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000001, 0x000B0779, 0x082410DF, 0x0824181F ) /* *   149792   61464124 */
5476RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x0824181F, 0x0824181F ) /* *   109988   55083276 */
5477RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000000, 0x000B0779, 0x08241ADF, 0x00000000 ) /* *      478   46989312 */
5478RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000000, 0x000B0779, 0x08241ADF, 0x0824181F ) /* *      468   46006272 */
5479RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000001, 0x000B0779, 0x00000000, 0x0824181F ) /* *   125204   39023396 */
5480RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000000, 0x000B0779, 0x08241ADF, 0x082410DB ) /* *      394   38731776 */
5481RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000000, 0x000B0779, 0x082410DF, 0x082410DB ) /* *    12890   36333568 */
5482RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x00000000, 0x000B0379, 0x0824101F, 0x0824101F ) /* *   147995   31086325 */
5483RASTERIZER_ENTRY( 0x00480035, 0x00045119, 0x00000000, 0x000B077B, 0x00000000, 0x082410DB ) /* *     3576   29294592 */
5484RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000001, 0x000B0779, 0x0824181F, 0x0824181F ) /* *    76059   29282981 */
5485RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000001, 0x000B0779, 0x082418DF, 0x0824101F ) /* *    12632   29173808 */
5486//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000001, 0x000B0779, 0x00000000, 0x082418DF ) /* *    14040   24318118 */
5487//RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x00000001, 0x000B0379, 0x0824101F, 0x0824101F ) /* *    56586   17643207 */
5488//RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000001, 0x000B0779, 0x082418DF, 0x0824181F ) /* *     9130   17277440 */
5489//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x082418DF, 0x0824101F ) /* *    66302   17049921 */
5490//RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000001, 0x000B0779, 0x082410DF, 0x0824101F ) /* *    64380   16463672 */
5491//RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000000, 0x000B0779, 0x082410DF, 0x0824181F ) /* *      152   14942208 */
5492//RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000000, 0x000B0779, 0x082418DF, 0x0824101F ) /* *     8748   13810176 */
5493//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x082708DF, 0x0824101F ) /* *   216634   10628656 */
5494//RASTERIZER_ENTRY( 0x00480035, 0x00045119, 0x00000001, 0x000B077B, 0x00000000, 0x082410DB ) /* *     1282   10502144 */
5495//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000001, 0x000B0779, 0x082418DF, 0x0824101F ) /* *    74636    9758030 */
5496//RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000000, 0x000B0779, 0x082418DF, 0x082410DB ) /* *    58652    9353671 */
5497//RASTERIZER_ENTRY( 0x00480035, 0x00045119, 0x00000000, 0x000B0779, 0x082418DF, 0x082410DB ) /* *     5242    8038747 */
5498//RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000000, 0x000B077B, 0x082410DB, 0x082410DB ) /* *    11048    7538060 */
5499//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x0824101F, 0x0824181F ) /* *   121630    6906591 */
5500//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x00000000, 0x082418DF ) /* *    19553    6864245 */
5501//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000001, 0x000B0779, 0x082418DF, 0x082418DF ) /* *     1287    6648834 */
5502//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000001, 0x000B0779, 0x082708DF, 0x0824101F ) /* *   197766    6617876 */
5503//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x082700DF, 0x0824101F ) /* *    75470    6231739 */
5504//RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000001, 0x000B0779, 0x08241ADF, 0x0824101F ) /* *      180    5898240 */
5505//RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000001, 0x000B0779, 0x082410DF, 0x082410DB ) /* *     7692    5743360 */
5506//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000001, 0x000B0779, 0x082418DF, 0x0824181F ) /* *    20128    4980591 */
5507//RASTERIZER_ENTRY( 0x00480035, 0x00045119, 0x00000001, 0x000B0779, 0x082418DF, 0x0824181F ) /* *     1144    4685824 */
5508//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000001, 0x000B0779, 0x082700DF, 0x0824101F ) /* *    72299    4466336 */
5509//RASTERIZER_ENTRY( 0x00480035, 0x00045119, 0x00000000, 0x000B0779, 0x082410DF, 0x082410DB ) /* *     3750    4018176 */
5510//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000001, 0x000B0779, 0x082410DF, 0x082410DF ) /* *     7533    3692141 */
5511//RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000001, 0x000B077B, 0x082410DB, 0x0824101F ) /* *     9484    3610674 */
5512//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000001, 0x000B0779, 0x0824101F, 0x0824181F ) /* *   128660    3216280 */
5513//RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000001, 0x000B0779, 0x082418DF, 0x082410DB ) /* *    22214    3172813 */
5514//RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000001, 0x000B077B, 0x082410DB, 0x0824181F ) /* *     5094    3099098 */
5515//RASTERIZER_ENTRY( 0x00480035, 0x00045119, 0x00000001, 0x000B0779, 0x082418DF, 0x0824101F ) /* *     1954    2850924 */
5516//RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000000, 0x000B0779, 0x082418DF, 0x0824181F ) /* *     1542    2434304 */
5517//RASTERIZER_ENTRY( 0x00480035, 0x00045119, 0x00000000, 0x000B0779, 0x082418DF, 0x00000000 ) /* *      478    1957888 */
5518//RASTERIZER_ENTRY( 0x00480035, 0x00045119, 0x00000000, 0x000B0779, 0x082418DF, 0x0824181F ) /* *      468    1916928 */
5519//RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000000, 0x000B077B, 0x082410DB, 0x0824101F ) /* *    11664    1729188 */
5520//RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000001, 0x000B077B, 0x082410DB, 0x082410DB ) /* *     1282    1640960 */
5521//RASTERIZER_ENTRY( 0x00480035, 0x00045119, 0x00000001, 0x000B077B, 0x082410DB, 0x0824101F ) /* *      388    1589248 */
5522//RASTERIZER_ENTRY( 0x00480035, 0x00045119, 0x00000001, 0x000B0779, 0x082410DF, 0x082410DB ) /* *     1282    1312768 */
5523//RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000000, 0x000B077B, 0x082410DB, 0x0824181F ) /* *     3928    1046582 */
5524
5525/* vaportrx ---> fbzColorPath alphaMode   fogMode,    fbzMode,    texMode0,   texMode1  */
5526RASTERIZER_ENTRY( 0x00482405, 0x00000000, 0x00000000, 0x000B0739, 0x0C26100F, 0xFFFFFFFF ) /* *  2226138  592165102 */
5527RASTERIZER_ENTRY( 0x00482435, 0x00000000, 0x00000000, 0x000B0739, 0x0C261A0F, 0xFFFFFFFF ) /* *    53533  281405105 */
5528RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x00000000, 0x000B07F9, 0x0C261ACF, 0xFFFFFFFF ) /* *   314131  219103141 */
5529RASTERIZER_ENTRY( 0x00482405, 0x00045119, 0x00000000, 0x000B0339, 0x0C261A0F, 0xFFFFFFFF ) /* *   216329   95014510 */
5530RASTERIZER_ENTRY( 0x00482405, 0x00000009, 0x00000000, 0x000B0739, 0x0C26100F, 0xFFFFFFFF ) /* *   317128   92010096 */
5531RASTERIZER_ENTRY( 0x0142613A, 0x00045119, 0x00000000, 0x000B07F9, 0xFFFFFFFF, 0xFFFFFFFF ) /* *    13728   88595930 */
5532RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x00000000, 0x000B0339, 0x0C261ACF, 0xFFFFFFFF ) /* *   649448   81449105 */
5533RASTERIZER_ENTRY( 0x00482435, 0x00000000, 0x00000000, 0x000B0739, 0x0C26100F, 0xFFFFFFFF ) /* *   444231   60067944 */
5534RASTERIZER_ENTRY( 0x00482405, 0x00045119, 0x00000000, 0x000B0339, 0x0C26184F, 0xFFFFFFFF ) /* *    36057   58970468 */
5535RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x00000000, 0x000B0339, 0x0C26100F, 0xFFFFFFFF ) /* *    53147   48856709 */
5536RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x00000000, 0x000B07F9, 0x0C2610C9, 0xFFFFFFFF ) /* *   447654   47171792 */
5537RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x00000000, 0x000B0339, 0x0C261A0F, 0xFFFFFFFF ) /* *   207392   38933691 */
5538RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x00000000, 0x000B0739, 0x0C2610CF, 0xFFFFFFFF ) /* *  2015632   33364173 */
5539RASTERIZER_ENTRY( 0x00482405, 0x00045119, 0x00000000, 0x000B0339, 0x0C26100F, 0xFFFFFFFF ) /* *   196361   30395218 */
5540RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x00000000, 0x000B0339, 0x0C2610CF, 0xFFFFFFFF ) /* *   110898   28973006 */
5541RASTERIZER_ENTRY( 0x00482435, 0x00000009, 0x00000000, 0x000B0739, 0x0C26100F, 0xFFFFFFFF ) /* *   135107   16301589 */
5542RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x00000000, 0x000B0339, 0x0C261A8F, 0xFFFFFFFF ) /* *    22375   15797748 */
5543RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x00000000, 0x000B0339, 0x0C26184F, 0xFFFFFFFF ) /* *   141539    7513140 */
5544RASTERIZER_ENTRY( 0x0142613A, 0x00045119, 0x00000000, 0x000B0739, 0xFFFFFFFF, 0xFFFFFFFF ) /* *   621403    5369705 */
5545RASTERIZER_ENTRY( 0x00482435, 0x00045110, 0x00000000, 0x000B0739, 0x0C261A0F, 0xFFFFFFFF ) /* *    30443    4070277 */
5546//RASTERIZER_ENTRY( 0x00482405, 0x00045110, 0x00000000, 0x000B0739, 0x0C261A0F, 0xFFFFFFFF ) /* *    22121    3129894 */
5547//RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x00000000, 0x000B0739, 0x0C26100F, 0xFFFFFFFF ) /* *     9187    1864599 */
5548//RASTERIZER_ENTRY( 0x00482405, 0x00044110, 0x00000000, 0x000B0739, 0x0C2610CF, 0xFFFFFFFF ) /* *    10390    1694950 */
5549//RASTERIZER_ENTRY( 0x0142610A, 0x00000009, 0x00000000, 0x000B0739, 0xFFFFFFFF, 0xFFFFFFFF ) /* *    25366    1624563 */
5550//RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x00000000, 0x000B0739, 0x0C261A0F, 0xFFFFFFFF ) /* *    69033    1607970 */
5551//RASTERIZER_ENTRY( 0x0142610A, 0x00000000, 0x00000000, 0x000B0739, 0xFFFFFFFF, 0xFFFFFFFF ) /* *    36316    1084818 */
5552//RASTERIZER_ENTRY( 0x00482405, 0x00045119, 0x00000000, 0x000B0339, 0x0C2610CF, 0xFFFFFFFF ) /* *     1813     816763 */
5553//RASTERIZER_ENTRY( 0x0142613A, 0x00045119, 0x00000000, 0x000B0339, 0xFFFFFFFF, 0xFFFFFFFF ) /* *     6602     767221 */
5554//RASTERIZER_ENTRY( 0x00482435, 0x00045110, 0x00000000, 0x000B0739, 0x0C26100F, 0xFFFFFFFF ) /* *     2547     646048 */
5555//RASTERIZER_ENTRY( 0x00482405, 0x00045119, 0x00000000, 0x000B0339, 0x0C261A8F, 0xFFFFFFFF ) /* *     2394     501590 */
5556//RASTERIZER_ENTRY( 0x0142613A, 0x00000009, 0x00000000, 0x000B0739, 0xFFFFFFFF, 0xFFFFFFFF ) /* *    14078     440086 */
5557//RASTERIZER_ENTRY( 0x0142610A, 0x00045119, 0x00000000, 0x000B0339, 0xFFFFFFFF, 0xFFFFFFFF ) /* *     9877     429160 */
5558//RASTERIZER_ENTRY( 0x00482405, 0x00045119, 0x00000000, 0x000B0339, 0x0C261ACF, 0xFFFFFFFF ) /* *     3222     366052 */
5559//RASTERIZER_ENTRY( 0x00482435, 0x00000009, 0x00000000, 0x000B0739, 0x0C2610CF, 0xFFFFFFFF ) /* *     5942     285657 */
5560//RASTERIZER_ENTRY( 0x00482405, 0x00044119, 0x00000000, 0x000B0339, 0x0C2610CF, 0xFFFFFFFF ) /* *     2328     239688 */
5561//RASTERIZER_ENTRY( 0x00482405, 0x00045119, 0x00000000, 0x000B0739, 0x0C26100F, 0xFFFFFFFF ) /* *     1129     208448 */
5562
5563/* wg3dh ------> fbzColorPath alphaMode   fogMode,    fbzMode,    texMode0,   texMode1  */
5564RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000000, 0x000B0779, 0x0824181F, 0xFFFFFFFF ) /* *   127676  116109477 */
5565RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000000, 0x000B0779, 0x0824189F, 0xFFFFFFFF ) /* *    96310  112016758 */
5566RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000000, 0x000B0779, 0x0824109F, 0xFFFFFFFF ) /* *  1412831  108682642 */
5567RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000000, 0x000B0779, 0x0824101F, 0xFFFFFFFF ) /* *  1612798   45952714 */
5568RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000000, 0x000B0779, 0x08241AD9, 0xFFFFFFFF ) /* *     5960    6103040 */
5569RASTERIZER_ENTRY( 0x00002435, 0x00045119, 0x00000000, 0x000B0779, 0x082418DF, 0xFFFFFFFF ) /* *    56512    4856542 */
5570RASTERIZER_ENTRY( 0x00480035, 0x00045119, 0x00000000, 0x000B0779, 0x0824109F, 0xFFFFFFFF ) /* *     8480    2045940 */
5571RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000000, 0x000B0379, 0x0824181F, 0xFFFFFFFF ) /* *     2779    1994317 */
5572RASTERIZER_ENTRY( 0x00000035, 0x00045119, 0x00000000, 0x000B0779, 0x0824105F, 0xFFFFFFFF ) /* *   154691    1922774 */
5573RASTERIZER_ENTRY( 0x00002435, 0x00045119, 0x00000000, 0x000B0779, 0x082410DF, 0xFFFFFFFF ) /* *    18114     776139 */
5574
5575/* gauntleg ---> fbzColorPath alphaMode   fogMode,    fbzMode,    texMode0,   texMode1  */
5576RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x00000000, 0x000B0779, 0x00000000, 0x0C24100F ) /* *   157050  668626339 */
5577RASTERIZER_ENTRY( 0x00600039, 0x00045119, 0x00000000, 0x000B0779, 0x0C22400F, 0x0C241ACF ) /* *  1079126  580272490 */
5578RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x00000000, 0x000B0779, 0x0C241A4F, 0x0C24100F ) /* *    49686  232178144 */
5579RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x00000000, 0x000B0779, 0x0C24104F, 0x0C24100F ) /* *  1048560  206304396 */
5580RASTERIZER_ENTRY( 0x00600039, 0x00045119, 0x00000000, 0x000B0779, 0x0C2240CF, 0x0C241ACF ) /* *    59176  182444375 */
5581RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x00000000, 0x000B0779, 0x00000000, 0x0C241A4F ) /* *    66342  179689728 */
5582RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x00000000, 0x000B0779, 0x0C24180F, 0x0C24180F ) /* *    72264  109413344 */
5583RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x00000000, 0x000B0779, 0x0C24100F, 0x0C24100F ) /* *   281243   75399210 */
5584RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x00000000, 0x000B0779, 0x00000000, 0x0C24104F ) /* *   126384   68412120 */
5585RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x0C241A0F, 0x0C24100F ) /* *    26864   43754988 */
5586RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x00000000, 0x000B0779, 0x00000000, 0x0C241ACF ) /* *    30510   32759936 */
5587RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x00000000, 0x000B0779, 0x0C24180F, 0x0C24100F ) /* *    44783   31884168 */
5588RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x00000000, 0x000B0779, 0x00000000, 0x0C24180F ) /* *    34946   31359362 */
5589RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x00000000, 0x0C241ACF ) /* *     8006   28367999 */
5590RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x00000000, 0x000B0379, 0x0C24180F, 0x0C24180F ) /* *    15430   27908213 */
5591RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x00000000, 0x0C241A0F ) /* *    29306   25166802 */
5592RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x00000000, 0x000B0779, 0x0C24180F, 0x0C241ACF ) /* *    27737   24517949 */
5593RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x0C241ACF, 0x0C24100F ) /* *     6783   21292092 */
5594RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x00000000, 0x000B0379, 0x00000000, 0x0C24180F ) /* *     9591   17815763 */
5595RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x00000000, 0x000B0779, 0x0C24100F, 0x0C24180F ) /* *   343966   13864759 */
5596//RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x00000000, 0x000B0779, 0x0C241ACF, 0x0C24100F ) /* *    11842   12126208 */
5597//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x0C241A8F, 0x0C24100F ) /* *     6648    9788508 */
5598//RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x00000000, 0x000B0779, 0x00000000, 0x0C2418CF ) /* *     8444    8646656 */
5599//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0379, 0x0C24180F, 0x0C24100F ) /* *     9677    8365606 */
5600//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x0C24100F, 0x0C24100F ) /* *   844920    8289326 */
5601//RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x00000000, 0x000B0779, 0x00000000, 0x0C24184F ) /* *     3108    8010176 */
5602//RASTERIZER_ENTRY( 0x00600039, 0x00045119, 0x00000000, 0x000B03F9, 0x00000000, 0x0C24180F ) /* *     1435    6209238 */
5603//RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x00000000, 0x000B0379, 0x0C24180F, 0x0C24100F ) /* *     5754    5617499 */
5604//RASTERIZER_ENTRY( 0x00600039, 0x00045119, 0x00000000, 0x000B0379, 0x0C24180F, 0x0C24180F ) /* *     1608    5557253 */
5605//RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x00000000, 0x000B0779, 0x0C24100F, 0x0C241ACF ) /* *   105127    5133321 */
5606//RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x00000000, 0x000B0379, 0x0C24180F, 0x0C241ACF ) /* *     3460    4689138 */
5607//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x0C24180F, 0x0C24100F ) /* *     7025    4629550 */
5608//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x00000000, 0x0C24180F ) /* *     7164    4407683 */
5609//RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x00000000, 0x000B0779, 0x00000000, 0x0C24188F ) /* *     1922    3924179 */
5610//RASTERIZER_ENTRY( 0x00600039, 0x00045119, 0x00000000, 0x000B0779, 0x00000000, 0x0C24180F ) /* *     4116    3733777 */
5611//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0779, 0x00000000, 0x0C241A8F ) /* *     2626    3732809 */
5612//RASTERIZER_ENTRY( 0x00600039, 0x00045119, 0x00000000, 0x000B03F9, 0x0C24180F, 0x0C24180F ) /* *      778    3202973 */
5613//RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x00000000, 0x000B0779, 0x0C24184F, 0x0C24100F ) /* *     1525    2997446 */
5614//RASTERIZER_ENTRY( 0x00600039, 0x00045119, 0x00000000, 0x000B03F9, 0x0C24180F, 0x0C241A0F ) /* *      645    2975266 */
5615//RASTERIZER_ENTRY( 0x00600039, 0x00044119, 0x00000000, 0x000B0379, 0x00000000, 0x0C241A0F ) /* *     5212    2491361 */
5616//RASTERIZER_ENTRY( 0x00600039, 0x00045119, 0x00000000, 0x000B0379, 0x00000000, 0x0C24180F ) /* *      825    1996513 */
5617//RASTERIZER_ENTRY( 0x00600039, 0x00045119, 0x00000000, 0x000B0379, 0x0C24180F, 0x0C241A0F ) /* *      466    1967163 */
5618//RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x00000000, 0x000B0779, 0x0580000F, 0x0C24180F ) /* *    77400    1883434 */
5619//RASTERIZER_ENTRY( 0x00600039, 0x00045119, 0x00000000, 0x000B0379, 0x0C24180F, 0x0C24100F ) /* *      472    1698177 */
5620//RASTERIZER_ENTRY( 0x00600039, 0x00045119, 0x00000000, 0x000B0779, 0x0C24180F, 0x0C24180F ) /* *     2476    1678760 */
5621//RASTERIZER_ENTRY( 0x00600C09, 0x00045119, 0x00000000, 0x000B0379, 0x00000000, 0x0C24180F ) /* *     4054    1541748 */
5622//RASTERIZER_ENTRY( 0x00600039, 0x00044119, 0x00000000, 0x000B0379, 0x0C241A0F, 0x0C24180F ) /* *     3132    1509438 */
5623//RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x00000000, 0x000B0779, 0x0580080F, 0x0C24180F ) /* *     8582    1324196 */
5624//RASTERIZER_ENTRY( 0x00602C19, 0x00044119, 0x00000000, 0x000B0379, 0x00000000, 0x0C24100F ) /* *     1436    1239704 */
5625//RASTERIZER_ENTRY( 0x00600039, 0x00045119, 0x00000000, 0x000B03F9, 0x0C24180F, 0x0C24100F ) /* *      253    1220316 */
5626//RASTERIZER_ENTRY( 0x00600039, 0x00045119, 0x00000000, 0x000B0779, 0x0C22480F, 0x0C241ACF ) /* *     2433    1014668 */
5627
5628/* gauntdl ----> fbzColorPath alphaMode   fogMode,    fbzMode,    texMode0,   texMode1  */
5629RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x000000C1, 0x000B0779, 0x00000009, 0x0C241ACF ) /* *    30860 1128173568 */
5630RASTERIZER_ENTRY( 0x0060743A, 0x00045119, 0x000000C1, 0x000B0779, 0x0C22400F, 0x0C241ACF ) /* *  2631692 1117011118 */
5631RASTERIZER_ENTRY( 0x0060743A, 0x00045110, 0x000000C1, 0x000B0779, 0x0C22400F, 0x0C241ACF ) /* *  2429239  826969012 */
5632RASTERIZER_ENTRY( 0x0060743A, 0x00045119, 0x000000C1, 0x000B0779, 0x0C22480F, 0x0C241ACF ) /* *   454056  468285142 */
5633RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x000000C1, 0x000B0779, 0x00000009, 0x0C2418CF ) /* *   257586  355634672 */
5634RASTERIZER_ENTRY( 0x00602439, 0x00045119, 0x000000C1, 0x000B0379, 0x00000009, 0x0C24180F ) /* *    10898  134362122 */
5635RASTERIZER_ENTRY( 0x00602439, 0x00045119, 0x000000C1, 0x000B0779, 0x00000009, 0x0C241A0F ) /* *    32195  126327049 */
5636RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x000000C1, 0x000B0779, 0x0C2410CF, 0x0C24100F ) /* *   855240  123899880 */
5637RASTERIZER_ENTRY( 0x00602439, 0x00045110, 0x000000C1, 0x000B0379, 0x00000009, 0x0C24180F ) /* *     1718  120629204 */
5638RASTERIZER_ENTRY( 0x0060743A, 0x00045119, 0x000000C1, 0x000B0779, 0x0C22488F, 0x0C241ACF ) /* *   186839  120281357 */
5639RASTERIZER_ENTRY( 0x0060743A, 0x00045119, 0x000000C1, 0x000B0379, 0x0C22480F, 0x0C241ACF ) /* *    14102  115428820 */
5640RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x000000C1, 0x000B0779, 0x00000009, 0x0C2410CF ) /* *    88530   98271949 */
5641RASTERIZER_ENTRY( 0x0060743A, 0x00045110, 0x000000C1, 0x000B0379, 0x0C22480F, 0x0C241ACF ) /* *    12994   68053222 */
5642RASTERIZER_ENTRY( 0x00602439, 0x00044110, 0x00000000, 0x000B0379, 0x00000009, 0x0C24100F ) /* *    68273   67454880 */
5643RASTERIZER_ENTRY( 0x00602439, 0x00045119, 0x000000C1, 0x000B0779, 0x00000009, 0x0C24180F ) /* *   100026   62271618 */
5644RASTERIZER_ENTRY( 0x0060743A, 0x00045110, 0x000000C1, 0x000B0779, 0x0C22480F, 0x0C241ACF ) /* *   153285   44411342 */
5645RASTERIZER_ENTRY( 0x00602439, 0x00045119, 0x000000C1, 0x000B0779, 0x00000009, 0x0C24100F ) /* *   157545   40702131 */
5646RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x000000C1, 0x000B0779, 0x0C241ACF, 0x0C24100F ) /* *     7800   31948800 */
5647RASTERIZER_ENTRY( 0x0060743A, 0x00045110, 0x000000C1, 0x000B0779, 0x0C22408F, 0x0C241ACF ) /* *    47623   20321183 */
5648RASTERIZER_ENTRY( 0x00602439, 0x00044119, 0x00000000, 0x000B0379, 0x00000009, 0x0C24188F ) /* *    21570   19324892 */
5649//RASTERIZER_ENTRY( 0x00482435, 0x00045110, 0x000000C1, 0x000B0779, 0x0C241ACF, 0x0C24100F ) /* *     3698   15147008 */
5650//RASTERIZER_ENTRY( 0x0060743A, 0x00045119, 0x000000C1, 0x000B0779, 0x0C22408F, 0x0C241ACF ) /* *    19765   12383722 */
5651//RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x000000C1, 0x000B0779, 0x0C24100F, 0x0C241ACF ) /* *   662274   10563855 */
5652//RASTERIZER_ENTRY( 0x00602439, 0x00045110, 0x000000C1, 0x000B0779, 0x0C24180F, 0x0C241ACF ) /* *    27909   10462997 */
5653//RASTERIZER_ENTRY( 0x00602439, 0x00045110, 0x000000C1, 0x000B0779, 0x00000009, 0x0C24180F ) /* *    78671   10286957 */
5654//RASTERIZER_ENTRY( 0x00602439, 0x00045110, 0x000000C1, 0x000B0779, 0x00000009, 0x0C24188F ) /* *    52038    9928244 */
5655//RASTERIZER_ENTRY( 0x0060743A, 0x00045119, 0x000000C1, 0x000B0779, 0x0C224A0F, 0x0C241ACF ) /* *    27469    9239782 */
5656//RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x000000C1, 0x000B0779, 0x00000009, 0x0C24100F ) /* *   757116    8072783 */
5657//RASTERIZER_ENTRY( 0x0060743A, 0x00045110, 0x000000C1, 0x000B0779, 0x0C22488F, 0x0C241ACF ) /* *    18018    7035833 */
5658//RASTERIZER_ENTRY( 0x00602439, 0x00044119, 0x00000000, 0x000B0379, 0x00000009, 0x0C241A0F ) /* *    50339    5976564 */
5659//RASTERIZER_ENTRY( 0x00603430, 0x00040219, 0x00000000, 0x000B0379, 0x00000009, 0x0C2410CE ) /* *    29385    5466384 */
5660//RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x000000C1, 0x000B0779, 0x0C24100F, 0x0C24180F ) /* *   423347    5355017 */
5661//RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x000000C1, 0x000B0779, 0x0C24180F, 0x0C241ACF ) /* *   162620    4709092 */
5662//RASTERIZER_ENTRY( 0x00602C19, 0x00045110, 0x000000C1, 0x000B0779, 0x00000009, 0x0C24100F ) /* *   463705    4642480 */
5663//RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x000000C1, 0x000B0779, 0x0C24180F, 0x0C24180F ) /* *   280337    4425529 */
5664//RASTERIZER_ENTRY( 0x00602C19, 0x00045110, 0x000000C1, 0x000B0779, 0x0C24180F, 0x0C24180F ) /* *   212646    3432265 */
5665//RASTERIZER_ENTRY( 0x00482435, 0x00045119, 0x000000C1, 0x000B0779, 0x0C2418CF, 0x0C24100F ) /* *     5788    2963456 */
5666//RASTERIZER_ENTRY( 0x00602C19, 0x00045110, 0x000000C1, 0x000B0779, 0x0C24180F, 0x0C24100F ) /* *   460800    2609198 */
5667//RASTERIZER_ENTRY( 0x00602439, 0x00045119, 0x000000C1, 0x000B0779, 0x0C24100F, 0x0C24180F ) /* *   251108    2392362 */
5668//RASTERIZER_ENTRY( 0x00602C19, 0x00045110, 0x000000C1, 0x000B0779, 0x0C24100F, 0x0C24100F ) /* *   297219    2352862 */
5669//RASTERIZER_ENTRY( 0x00602439, 0x00045119, 0x000000C1, 0x000B0779, 0x0584180F, 0x0C2410CF ) /* *     9913    2097069 */
5670//RASTERIZER_ENTRY( 0x00602C19, 0x00045110, 0x000000C1, 0x000B0779, 0x0C24180F, 0x0C241ACF ) /* *   142722    2091569 */
5671//RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x000000C1, 0x000B0379, 0x0C24180F, 0x0C241ACF ) /* *     8820    2053325 */
5672//RASTERIZER_ENTRY( 0x00602439, 0x00045119, 0x000000C1, 0x000B0779, 0x00000009, 0x0C24188F ) /* *    10346    2033427 */
5673//RASTERIZER_ENTRY( 0x00602439, 0x00045119, 0x000000C1, 0x000B0779, 0x0C24188F, 0x0C241ACF ) /* *     2136    2017241 */
5674//RASTERIZER_ENTRY( 0x00602439, 0x00044119, 0x00000000, 0x000B0379, 0x00000009, 0x0C24100F ) /* *     1505    1928490 */
5675//RASTERIZER_ENTRY( 0x00602C19, 0x00045110, 0x000000C1, 0x000B0779, 0x0C24100F, 0x0C241ACF ) /* *   176734    1842440 */
5676//RASTERIZER_ENTRY( 0x00602C19, 0x00045110, 0x000000C1, 0x000B0779, 0x0C24100F, 0x0C24180F ) /* *   262577    1799080 */
5677//RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x000000C1, 0x000B0779, 0x00000009, 0x0C24180F ) /* *    83179    1534171 */
5678//RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x000000C1, 0x000B0779, 0x00000009, 0x0C24188F ) /* *     3863    1527077 */
5679//RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x000000C1, 0x000B0379, 0x0C24180F, 0x0C24180F ) /* *     8021    1472661 */
5680//RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x000000C1, 0x000B0779, 0x0C241A0F, 0x0C241ACF ) /* *    85416    1342195 */
5681//RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x000000C1, 0x000B0779, 0x0C24180F, 0x0C24100F ) /* *   261360    1335048 */
5682//RASTERIZER_ENTRY( 0x00602C19, 0x80000009, 0x000000C1, 0x000B0779, 0x0C2418CF, 0x0C24100F ) /* *    74811    1320900 */
5683//RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x000000C1, 0x000B0779, 0x0C24100F, 0x0C24100F ) /* *   239331    1268661 */
5684//RASTERIZER_ENTRY( 0x00602439, 0x00045119, 0x000000C1, 0x000B0779, 0x0C24100F, 0x0C241ACF ) /* *   107769    1244175 */
5685//RASTERIZER_ENTRY( 0x00602C19, 0x00045110, 0x000000C1, 0x000B0379, 0x0C24180F, 0x0C241ACF ) /* *     3706    1216182 */
5686//RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x000000C1, 0x000B0779, 0x0C24100F, 0x0C24188F ) /* *    49608    1206129 */
5687//RASTERIZER_ENTRY( 0x00602C19, 0x80000009, 0x000000C1, 0x000B0779, 0x0C2418CF, 0x0C241ACF ) /* *    42440    1204109 */
5688//RASTERIZER_ENTRY( 0x00482435, 0x00045110, 0x000000C1, 0x000B0779, 0x0C2410CF, 0x0C24100F ) /* *    29584    1168568 */
5689//RASTERIZER_ENTRY( 0x00602439, 0x00045119, 0x000000C1, 0x000B0779, 0x0C24180F, 0x0C241ACF ) /* *    17729    1152869 */
5690//RASTERIZER_ENTRY( 0x00602C19, 0x00045110, 0x000000C1, 0x000B0379, 0x0C24180F, 0x0C24100F ) /* *     4052    1108726 */
5691//RASTERIZER_ENTRY( 0x00602C19, 0x00045119, 0x000000C1, 0x000B0779, 0x0C2418CF, 0x0C24100F ) /* *     7082    1079348 */
5692//RASTERIZER_ENTRY( 0x00602439, 0x00044119, 0x00000000, 0x000B0379, 0x00000009, 0x0C24180F ) /* *     7761    1023855 */
5693
50195694/* gradius4 ----> fbzColorPath alphaMode   fogMode,    fbzMode,    texMode0,   texMode1  */
5020RASTERIZER_ENTRY( 0x02420002,  0x00000009, 0x00000000, 0x00030F7B, 0x08241AC7, 0xFFFFFFFF )   /* intro */
5021RASTERIZER_ENTRY( 0x01420021,  0x00005119, 0x00000000, 0x00030F7B, 0x14261AC7, 0xFFFFFFFF )   /* intro */
5022RASTERIZER_ENTRY( 0x00000005,  0x00005119, 0x00000000, 0x00030F7B, 0x14261A87, 0xFFFFFFFF )   /* in-game */
5695//RASTERIZER_ENTRY( 0x02420002,  0x00000009, 0x00000000, 0x00030F7B, 0x08241AC7, 0xFFFFFFFF )   /* intro */
5696//RASTERIZER_ENTRY( 0x01420021,  0x00005119, 0x00000000, 0x00030F7B, 0x14261AC7, 0xFFFFFFFF )   /* intro */
5697//RASTERIZER_ENTRY( 0x00000005,  0x00005119, 0x00000000, 0x00030F7B, 0x14261A87, 0xFFFFFFFF )   /* in-game */
50235698
50245699/* nbapbp ------> fbzColorPath alphaMode   fogMode,    fbzMode,    texMode0,   texMode1  */
5025RASTERIZER_ENTRY( 0x00424219,  0x00000000, 0x00000001, 0x00030B7B, 0x08241AC7, 0xFFFFFFFF )   /* intro */
5026RASTERIZER_ENTRY( 0x00002809,  0x00004110, 0x00000001, 0x00030FFB, 0x08241AC7, 0xFFFFFFFF )   /* in-game */
5027RASTERIZER_ENTRY( 0x00424219,  0x00000000, 0x00000001, 0x00030F7B, 0x08241AC7, 0xFFFFFFFF )   /* in-game */
5028RASTERIZER_ENTRY( 0x0200421A,  0x00001510, 0x00000001, 0x00030F7B, 0x08241AC7, 0xFFFFFFFF )   /* in-game */
5700//RASTERIZER_ENTRY( 0x00424219,  0x00000000, 0x00000001, 0x00030B7B, 0x08241AC7, 0xFFFFFFFF )   /* intro */
5701//RASTERIZER_ENTRY( 0x00002809,  0x00004110, 0x00000001, 0x00030FFB, 0x08241AC7, 0xFFFFFFFF )   /* in-game */
5702//RASTERIZER_ENTRY( 0x00424219,  0x00000000, 0x00000001, 0x00030F7B, 0x08241AC7, 0xFFFFFFFF )   /* in-game */
5703//RASTERIZER_ENTRY( 0x0200421A,  0x00001510, 0x00000001, 0x00030F7B, 0x08241AC7, 0xFFFFFFFF )   /* in-game */
50295704
50305705#endif
src/mame/video/voodoo.h
r1070r1071
2020void voodoo_start(int which, int scrnum, int type, int fbmem_in_mb, int tmem0_in_mb, int tmem1_in_mb);
2121int voodoo_update(int which, mame_bitmap *bitmap, const rectangle *cliprect);
2222void voodoo_reset(int which);
23void voodoo_exit(int which);
2324int voodoo_get_type(int which);
2425int voodoo_is_stalled(int which);
2526void voodoo_set_init_enable(int which, UINT32 newval);
src/mame/video/poly.c
r1070r1071
88
99#ifndef RECURSIVE_INCLUDE
1010
11#include "driver.h"
1112#include "poly.h"
1213
1314/***************************************************************************
src/mame/video/poly.h
r1070r1071
66
77***************************************************************************/
88
9#include "driver.h"
10
11
129/* up to 6 params (Z,U,V,R,G,B), plus it makes the vertex struct a nice size */
1310#define MAX_VERTEX_PARAMS      6
1411#define MAX_POLY_SCANLINES      512
src/mame/video/system1.c
r1070r1071
77
88*************************************************************************/
99
10#include "driver.h"
1011#include "system1.h"
1112
1213UINT8 *system1_scroll_y;
src/mame/video/system1.h
r1070r1071
11#ifndef _system1_H_
22#define _system1_H_
33
4#include "driver.h"
5
64#define SPR_Y_TOP      0
75#define SPR_Y_BOTTOM   1
86#define SPR_X_LO      2
src/mame/video/grchamp.c
r1070r1071
7676
7777static TILE_GET_INFO( get_text_tile_info )
7878{
79   grchamp_state *state = Machine->driver_data;
79   grchamp_state *state = machine->driver_data;
8080   SET_TILE_INFO(0, state->videoram[tile_index], 0, 0);
8181}
8282
8383static TILE_GET_INFO( get_left_tile_info )
8484{
85   grchamp_state *state = Machine->driver_data;
85   grchamp_state *state = machine->driver_data;
8686   SET_TILE_INFO(1, state->leftram[tile_index], 0, 0);
8787}
8888
8989static TILE_GET_INFO( get_right_tile_info )
9090{
91   grchamp_state *state = Machine->driver_data;
91   grchamp_state *state = machine->driver_data;
9292   SET_TILE_INFO(2, state->rightram[tile_index], 0, 0);
9393}
9494
9595static TILE_GET_INFO( get_center_tile_info )
9696{
97   grchamp_state *state = Machine->driver_data;
97   grchamp_state *state = machine->driver_data;
9898   SET_TILE_INFO(3, state->centerram[tile_index], 0, 0);
9999}
100100
src/mame/video/kaneko16.c
r1070r1071
10071007      {
10081008         UINT16 dat = (galsnew_fg_pixram[count] & 0xfffe)>>1;
10091009         dat+=2048;
1010         dest[x] = Machine->pens[dat];
1010         dest[x] = machine->pens[dat];
10111011         count++;
10121012      }
10131013   }
r1070r1071
10231023         //dat &=0x3ff;
10241024         if (dat)
10251025         {
1026            dest[x] = Machine->pens[dat];
1026            dest[x] = machine->pens[dat];
10271027         }
10281028         count++;
10291029      }
src/mame/video/model2.c
r1070r1071
1/*********************************************************************************************************************************
2
3    Sega Model 2 Geometry Engine and 3D Rasterizer Emulation
4
5    General Notes:
6
7    - The 3D rendering system has 3 main parts:
8        1) The Geometry Engine: Model 2B and 2C hardware upload the geometry code to a DSP. The original and 2A hardware
9        have the geometry code in an internal ROM inside the DSP itself. The simulation written here for the geometry engine
10        is based off the disassembly of the code uploaded to a 2B game.
11        2) The Z-Sort and Clip Hardware: Not much information about this hardware. There are a couple of variables that
12        can be passed to this stage, like a master Z-Clip enable register, and a Z-Sort mode variable.
13        3) The Hardware Renderer: Not much information about the inner workings of this hardware. Based on the available
14        tidbits from the 2B manual, it is a double-buffered device (can be toggled between page flipping and single
15        buffer mode), and can also be switched to generate output at 60Hz or 30Hz.
16
17    - Most of the information used to write this code come from 3 main sources:
18        1) The Geometry Engine code disassembly from a 2B game.
19        2) The Model 2B-CRX Manual.
20        3) ElSemi's Direct3D implementation of the geometrizer engine.
21
22    - The emulation strategy used here is to decouple the geometrizer code from the Z-Sort/Clip/Renderer code, so that for
23    original and 2A games, the HLE version of the geometrizer can be used, while for 2B and 2C games, the original geometrizer
24    DSP can be emulated, and data can be pushed to the Z-Sort/Clip/Renderer code.
25
26
27
28    Geometry Engine Notes and Known Bugs:
29
30    - Top Skater seem to use a slightly different geometry code that has a secondary transformation matrix. Once we implement
31    the real DSP code upload and emulation for 2B and 2C games, this should not be an issue.
32
33
34
35    Z-Sort Notes and Known Bugs:
36
37    - The Z-Sort algorithm is not entirely understood. The manual states that the Z-Sort works internally in 1.4.8 bit format,
38    but then it states that the Z-Sort Mode register value is added to the floating point z value, and converted to a 16 bit
39    format (most likely 4.12).
40    - The system allows for Z-Sort override, by means of specifying wether a polygon will use the same Z value ordinal as the
41    previous polygon, or the calculated minimum or maximum from it's points. This allows for a full object to be in front of
42    another, even though the first object might have some z coordinates that are bigger than the second object's z coordinates.
43    - The current implementation takes the effective computed z value for the polygon and converts it into a 4.12 fixed point
44    representation, used as an index into an array of linked polygons. Every polygon with the same z value is linked with any
45    previous polygon that had that same z value:
46
47        z-value index   linked list of polygons
48            0000        triangle3->triangle2->triangle1
49            0001        triangle22->triangle8->triangle7
50            ....
51            FFFF        triangle33->triangle11->triangle9
52
53    As we add polygons to the array, we also keep track of the minimum and maximum z-value indexes seen this frame.
54    When it's time to render, we start and the max z-value seen, and iterate through the array going down to the minimum
55    z-value seen, clipping and rendering the linked polygons as we go.
56    Unfortunately, it seems there's something not quite right, as there are some visible Z-Sort problems in various games.
57    Perhaps the linked list of polygons need to be presorted by a unknown factor before rendering.
58
59
60
61    Clip Notes and Known Bugs:
62
63    - The Z-Clip happens at z=0. Since dividing by 0 during projection would give bogus values, we scale by a distance of
64    1, thus our projection equation turns into vd.x = (d*vs.x) / (d+vs.z) where d = 1, since we know we won't have polygons
65    with a z < 0. This, however, poses the problem that for objects originally between 0.0 and 1.0 are not going to be
66    scaled properly. We still need to find a solution for this.
67    - A small offset need to be added horizontally and vertically to the viewport and center variables for certain games (like
68    the original Model 2 games). The coordinate system has been worked out from the 2B specifications, but the older games
69    need a slight adjustment.
70
71
72
73    Hardware Renderer Notes and Known Bugs:
74
75    - Texturing code could use a real good speed optimization.
76    - The U and V coordinates provided by the game are in 13.3 fixed point format.
77    - The luma/texel combination algorithm is not known. There are currently some small color glitches here and
78    there, and this might be the culprit.
79    - The log tables and distance coefficients are used to calculate the number of texels per world unit that need to
80    be used to render a texture. Textures can also be provided with smaller levels of details and a LOD bit selector
81    in the texture header tells the rasterizer which texture map to use. The rasterizer then can average two texture
82    maps to do mip mapping. More information can be found on the 2B manual, on the 'Texturing' and 'Data Format' chapters.
83    This is currently unemulated. We always use the texture data from the bigger texture map.
84    - The rasterizer supports up to 128x128 'microtex' textures, which are supposed to be higher resolution textures used
85    to display more detail when a texture is real close to the viewer. This is currently unemulated.
86
87*********************************************************************************************************************************/
188#include "driver.h"
289#include "video/segaic24.h"
390#include "video/poly.h"
r1070r1071
289
3typedef struct
4{
5   int x, y, width, height;
6} WINDOW;
90#define DEBUG 0
791
92extern UINT32 geo_read_start_address;
93extern UINT32 geo_write_start_address;
94extern UINT32 *model2_bufferram;
95extern UINT32 *model2_colorxlat;
96extern UINT32 *model2_textureram0;
97extern UINT32 *model2_textureram1;
98extern UINT32 *model2_lumaram;
99
100/*******************************************
101 *
102 *  Basic Data Types
103 *
104 *******************************************/
105
8106typedef struct
9107{
10108   float x, y, z;
11109   UINT16 u, v;
12} VERTEX;
110} vertex;
13111
14112typedef struct
15113{
16   VERTEX v[3];
17   WINDOW window;
18   float z;
19   int luminance;
20   UINT16 r, g, b;
21   UINT16 luma_select;
22   UINT16 tex_x, tex_y, tex_width, tex_height;
23   UINT32 flags;
24} TRIANGLE;
114   vertex   normal;
115   float   distance;
116} plane;
25117
26typedef struct {
27   float x,y,z,d;
28} PLANE;
118typedef struct
119{
120   float   diffuse;
121   float   ambient;
122   UINT32   specular_control;
123   float   specular_scale;
124} texture_parameter;
29125
126typedef struct
127{
128   void *            next;
129   vertex            v[3];
130   UINT16            z;
131   UINT16            texheader[4];
132   UINT16            luma;
133   INT16            viewport[4];
134   INT16            center[2];
135} triangle;
30136
31137typedef struct
32138{
33   UINT32 diffuse;
34   UINT32 ambient;
35   UINT32 reflection;
36   float c;
37} TEXTURE_PARAMETER;
139   vertex   v[4];
140   UINT16   z;
141   UINT16   texheader[4];
142   UINT16   luma;
143} quad;
38144
39#define TRI_FLAG_TEXTURE            0x1
40#define TRI_FLAG_TEXTURE_TRANS         0x2
41#define TRI_FLAG_EVEN_BANK            0x4
42#define TRI_FLAG_CHECKER            0x8
43#define TRI_FLAG_MICROTEX            0x10
44#define TRI_FLAG_MIRROR_X            0x20
45#define TRI_FLAG_MIRROR_Y            0x40
46#define TRI_FLAG_WRAP_X               0x80
47#define TRI_FLAG_WRAP_Y               0x100
48145
146/*******************************************
147 *
148 *  Generic 3D Math Functions
149 *
150 *******************************************/
49151
50static UINT32 geo_mode;
152static void transform_point( vertex *point, float *matrix )
153{
154   float tx = (point->x * matrix[0]) + (point->y * matrix[3]) + (point->z * matrix[6]) + (matrix[9]);
155   float ty = (point->x * matrix[1]) + (point->y * matrix[4]) + (point->z * matrix[7]) + (matrix[10]);
156   float tz = (point->x * matrix[2]) + (point->y * matrix[5]) + (point->z * matrix[8]) + (matrix[11]);
51157
158   point->x = tx;
159   point->y = ty;
160   point->z = tz;
161}
52162
53static void parse_display_list(void);
54static void render_triangles(mame_bitmap *bitmap, const rectangle *cliprect);
163static void transform_vector( vertex *vector, float *matrix )
164{
165   float tx = (vector->x * matrix[0]) + (vector->y * matrix[3]) + (vector->z * matrix[6]);
166   float ty = (vector->x * matrix[1]) + (vector->y * matrix[4]) + (vector->z * matrix[7]);
167   float tz = (vector->x * matrix[2]) + (vector->y * matrix[5]) + (vector->z * matrix[8]);
55168
169   vector->x = tx;
170   vector->y = ty;
171   vector->z = tz;
172}
56173
57#define TRIBUFFER_SIZE      16384
174static void normalize_vector( vertex *vector )
175{
176   float n = sqrt( (vector->x * vector->x) + (vector->y * vector->y) + (vector->z * vector->z) );
58177
59static TRIANGLE *tribuffer;
60static int tribuffer_pos;
178   if ( n )
179   {
180      vector->x /= n;
181      vector->y /= n;
182      vector->z /= n;
183   }
184}
61185
62extern UINT32 geo_read_start_address;
63extern UINT32 geo_write_start_address;
64extern UINT32 *model2_bufferram;
65extern UINT32 *model2_textureram0;
66extern UINT32 *model2_textureram1;
67extern UINT32 *model2_colorxlat;
68extern UINT32 *model2_lumaram;
186static float dot_product( vertex *v1, vertex *v2 )
187{
188   return (v1->x * v2->x) + (v1->y * v2->y) + (v1->z * v2->z);
189}
69190
70static float matrix[12];
71static float light_vector[3];
191static void vector_cross3( vertex *dst, vertex *v0, vertex *v1, vertex *v2 )
192{
193   vertex   p1, p2;
72194
73static WINDOW window;
74static float focus_x, focus_y;
195   p1.x = v1->x - v0->x;   p1.y = v1->y - v0->y;   p1.z = v1->z - v0->z;
196   p2.x = v2->x - v0->x;   p2.y = v2->y - v0->y;   p2.z = v2->z - v0->z;
75197
76static UINT32 *polygon_rom;
77static UINT32 *polygon_ram;
78static UINT16 *texture_rom;
79static UINT16 *texture_ram;
198   dst->x = (p1.y * p2.z) - (p1.z * p2.y);
199   dst->y = (p1.z * p2.x) - (p1.x * p2.z);
200   dst->z = (p1.x * p2.y) - (p1.y * p2.x);
201}
80202
81static TEXTURE_PARAMETER texture_parameter[32];
203/* 1.8.23 float to 4.12 float converter, courtesy of Aaron Giles */
204static UINT16 float_to_zval( float floatval )
205{
206   INT32 fpint = f2u(floatval);
207   INT32 exponent = ((fpint >> 23) & 0xff) - 127;
208   UINT32 mantissa = fpint & 0x7fffff;
82209
83static bitmap_t *sys24_bitmap = NULL;
210   /* round the low bits and reduce to 12 */
211   mantissa += 0x400;
212   if (mantissa > 0x7fffff) { exponent++; mantissa = (mantissa & 0x7fffff) >> 1; }
213   mantissa >>= 11;
84214
85static void model2_exit(running_machine *machine)
215   /* if negative, clamp to 0 */
216   if (fpint < 0)
217      return 0x0000;
218
219   /* the rest depends on the exponent */
220   /* less than -12 is too small, return 0 */
221   if ( exponent < -12 )
222      return 0x0000;
223
224   /* between -12 and 0 create a denormal with exponent of 0 */
225   else if ( exponent < 0 )
226      return (mantissa | 0x1000) >> -exponent;
227
228   /* between 0 and 14 create a FP value with exponent + 1 */
229   else if ( exponent < 15 )
230      return (( exponent + 1 ) << 12) | mantissa;
231
232   /* above 14 is too large */
233   return 0xffff;
234}
235
236static INT32 clip_polygon(vertex *v, INT32 num_vertices, plane *cp, vertex *vout)
86237{
87   if ( sys24_bitmap != NULL )
238   vertex *cur, *out;
239   float   curdot, nextdot, scale;
240   INT32   i, curin, nextin, nextvert, outcount;
241
242   outcount = 0;
243
244   cur = v;
245   out = vout;
246
247   curdot = dot_product( cur, &cp->normal );
248   curin = (curdot >= cp->distance) ? 1 : 0;
249
250   for( i = 0; i < num_vertices; i++ )
88251   {
89      bitmap_free( sys24_bitmap );
90      sys24_bitmap = NULL;
252      nextvert = (i + 1) % num_vertices;
253
254      /* if the current point is inside the plane, add it */
255      if ( curin ) memcpy( &out[outcount++], cur, sizeof( vertex ) );
256
257      nextdot = dot_product( &v[nextvert], &cp->normal );
258      nextin = (nextdot >= cp->distance) ? 1 : 0;
259
260      /* Add a clipped vertex if one end of the current edge is inside the plane and the other is outside */
261        if ( curin != nextin )
262        {
263            scale = (cp->distance - curdot) / (nextdot - curdot);
264
265         out[outcount].x = cur->x + ((v[nextvert].x - cur->x) * scale);
266         out[outcount].y = cur->y + ((v[nextvert].y - cur->y) * scale);
267         out[outcount].z = cur->z + ((v[nextvert].z - cur->z) * scale);
268         out[outcount].u = (UINT16)((float)cur->u + (((float)v[nextvert].u - (float)cur->u) * scale));
269         out[outcount].v = (UINT16)((float)cur->v + (((float)v[nextvert].v - (float)cur->v) * scale));
270            outcount++;
271        }
272
273        curdot = nextdot;
274        curin = nextin;
275        cur++;
91276   }
277
278   return outcount;
92279}
93280
94VIDEO_START(model2)
281/***********************************************************************************************/
282
283/*******************************************
284 *
285 *  Hardware 3D Rasterizer Interal State
286 *
287 *******************************************/
288
289#define MAX_TRIANGLES      32768
290
291typedef struct
95292{
96   int   width = machine->screen[0].visarea.max_x - machine->screen[0].visarea.min_x;
97   int   height = machine->screen[0].visarea.max_y - machine->screen[0].visarea.min_y;
293   UINT32            mode;            /* bit 0 = Test Mode, bit 2 = Switch 60Hz(1)/30Hz(0) operation */
294   UINT16 *         texture_rom;      /* Texture ROM pointer */
295   UINT16 *         texture_ram;      /* Texture RAM pointer */
296   UINT8 *            log_ram;         /* Log RAM pointer */
297   INT16            viewport[4];      /* View port (startx,starty,endx,endy) */
298   INT16            center[4][2];      /* Centers (eye 0[x,y],1[x,y],2[x,y],3[x,y]) */
299   UINT16            center_sel;         /* Selected center */
300   UINT32            reverse;         /* Left/Right Reverse */
301   float            z_adjust;         /* ZSort Mode */
302   float            triangle_z;         /* Current Triangle z value */
303   UINT8            master_z_clip;      /* Master Z-Clip value */
304   UINT32            cur_command;      /* Current command */
305   UINT32            command_buffer[32];   /* Command buffer */
306   UINT32            command_index;      /* Command buffer index */
307   triangle *         tri_list;         /* Triangle list */
308   UINT32            tri_list_index;      /* Triangle list index */
309   triangle **         tri_sorted_list;   /* Sorted Triangle list */
310   UINT16            min_z;            /* Minimum sortable Z value */
311   UINT16            max_z;            /* Maximum sortable Z value */
98312
99   sys24_tile_vh_start(machine, 0x3fff);
313} raster_state;
100314
101   sys24_bitmap = bitmap_alloc(width, height+4, BITMAP_FORMAT_INDEXED16);
315static raster_state raster;
102316
103   add_exit_callback(machine, model2_exit);
317/*******************************************
318 *
319 *  Hardware 3D Rasterizer Initialization
320 *
321 *******************************************/
104322
105   tribuffer = auto_malloc(TRIBUFFER_SIZE * sizeof(TRIANGLE));
323static void model2_3d_init( UINT16 *texture_rom )
324{
325   memset( &raster, 0, sizeof( raster_state ) );
106326
107   polygon_rom = (UINT32*)memory_region(REGION_USER2);
108   polygon_ram = auto_malloc(0x8000 * sizeof(UINT32));
327   raster.texture_rom = texture_rom;
328   raster.texture_ram = auto_malloc(0x10000 * sizeof(UINT16));
329   raster.log_ram = auto_malloc(0x40000 * sizeof(UINT8));
330   raster.tri_list = auto_malloc(MAX_TRIANGLES * sizeof(triangle));
331   raster.tri_sorted_list = auto_malloc(0x10000 * sizeof( triangle * ));
332}
109333
110   texture_rom = (UINT16*)memory_region(REGION_USER3);
111   texture_ram = auto_malloc(0x10000 * sizeof(UINT16));
334/*******************************************
335 *
336 *  Hardware 3D Rasterizer Z-Clip selection
337 *
338 *******************************************/
339
340void model2_3d_set_zclip( UINT8 clip )
341{
342   raster.master_z_clip = clip;
112343}
113344
114static void convert_bitmap( running_machine *machine, bitmap_t *dst, bitmap_t *src, const rectangle *rect )
345/*******************************************
346 *
347 *  Hardware 3D Rasterizer Processing
348 *
349 *******************************************/
350
351static void model2_3d_process_quad( UINT32 attr )
115352{
116   int   x, y;
353   quad      object;
354   UINT16      *th, *tp;
355   INT32      tho;
356   UINT32      cull, i;
357   float      zvalue;
358   float      min_z, max_z;
117359
118   for( y = rect->min_y; y < rect->max_y; y++ )
360   /* extract P0(n-1) */
361   object.v[1].x = u2f( raster.command_buffer[2] << 8 );
362   object.v[1].y = u2f( raster.command_buffer[3] << 8 );
363   object.v[1].z = u2f( raster.command_buffer[4] << 8 );
364
365   /* extract P1(n-1) */
366   object.v[0].x = u2f( raster.command_buffer[5] << 8 );
367   object.v[0].y = u2f( raster.command_buffer[6] << 8 );
368   object.v[0].z = u2f( raster.command_buffer[7] << 8 );
369
370   /* extract P0(n) */
371   object.v[2].x = u2f( raster.command_buffer[11] << 8 );
372   object.v[2].y = u2f( raster.command_buffer[12] << 8 );
373   object.v[2].z = u2f( raster.command_buffer[13] << 8 );
374
375   /* extract P1(n) */
376   object.v[3].x = u2f( raster.command_buffer[14] << 8 );
377   object.v[3].y = u2f( raster.command_buffer[15] << 8 );
378   object.v[3].z = u2f( raster.command_buffer[16] << 8 );
379
380   /* always calculate the min z and max z value */
381   min_z = object.v[0].z;
382   if ( object.v[1].z < min_z ) min_z = object.v[1].z;
383   if ( object.v[2].z < min_z ) min_z = object.v[2].z;
384   if ( object.v[3].z < min_z ) min_z = object.v[3].z;
385
386   max_z = object.v[0].z;
387   if ( object.v[1].z > max_z ) max_z = object.v[1].z;
388   if ( object.v[2].z > max_z ) max_z = object.v[2].z;
389   if ( object.v[3].z > max_z ) max_z = object.v[3].z;
390
391   /* read in the texture information */
392
393   /* texture point data */
394   if ( raster.command_buffer[0] & 0x800000 )
395      tp = &raster.texture_ram[raster.command_buffer[0] & 0xFFFF];
396   else
397      tp = &raster.texture_rom[raster.command_buffer[0] & 0x7FFFFF];
398
399   object.v[0].v = *tp++;
400   object.v[0].u = *tp++;
401   object.v[1].v = *tp++;
402   object.v[1].u = *tp++;
403   object.v[2].v = *tp++;
404   object.v[2].u = *tp++;
405   object.v[3].v = *tp++;
406   object.v[3].u = *tp++;
407
408   /* update the address */
409   raster.command_buffer[0] += 8;
410
411   /* texture header data */
412   if ( raster.command_buffer[1] & 0x800000 )
413      th = &raster.texture_ram[raster.command_buffer[1] & 0xFFFF];
414   else
415      th = &raster.texture_rom[raster.command_buffer[1] & 0x7FFFFF];
416
417   object.texheader[0] = *th++;
418   object.texheader[1] = *th++;
419   object.texheader[2] = *th++;
420   object.texheader[3] = *th++;
421
422   /* extract the texture header offset */
423   tho = (attr >> 12) & 0x1F;
424
425   /* adjust for sign */
426   if ( tho & 0x10 )
427      tho |= -16;
428
429   /* update the address */
430   raster.command_buffer[1] += tho * 4;
431
432   /* set the luma value of this quad */
433   object.luma = (raster.command_buffer[9] >> 14) & 0xFF;
434
435   /* determine wether we can cull this quad */
436   cull = 0;
437
438   /* if doubleside is disabled */
439   if ( ((attr >> 17) & 1) == 0 )
119440   {
120      UINT32 *d = BITMAP_ADDR32( dst, y, 0 );
121      UINT16 *s = BITMAP_ADDR16( src, y, 0 );
441      /* if it's the backface, cull it */
442      if ( raster.command_buffer[9] & 0x00800000 )
443         cull = 1;
444   }
122445
123      for( x = rect->min_x; x < rect->max_x; x++ )
446   /* if the linktype is 0, then we can also cull it */
447   if ( ((attr >> 8) & 3) == 0 )
448      cull = 1;
449
450   /* if the minimum z value is bigger than the master z clip value, don't render */
451   if ( (INT32)(1.0/min_z) > raster.master_z_clip )
452      cull = 1;
453
454   /* if the maximum z value is < 0 then we can safely clip the entire polygon */
455   if ( max_z < 0 )
456      cull = 1;
457
458   if ( cull == 0 )
459   {
460      INT32   clipped_verts;
461      vertex   verts[10];
462      plane   clip_plane;
463
464      clip_plane.normal.x = 0;
465      clip_plane.normal.y = 0;
466      clip_plane.normal.z = 1;
467      clip_plane.distance = 0;
468
469      /* do near z clipping */
470      clipped_verts = clip_polygon( object.v, 4, &clip_plane, verts);
471
472      if ( clipped_verts > 2 )
124473      {
125         if ( s[x] )
126            d[x] = machine->pens[s[x]];
474         triangle *ztri;
475
476         /* set the object's z value */
477         zvalue = raster.triangle_z;
478
479         /* see if we need to recompute min/max z */
480         if ( (attr >> 10) & 3 )
481         {
482            /* update min_z and max_z with the new clipped values */
483            min_z = verts[0].z;
484            max_z = verts[0].z;
485
486            for( i = 1; i < clipped_verts; i++ )
487            {
488               if ( verts[i].z < min_z ) min_z = verts[i].z;
489               if ( verts[i].z > max_z ) max_z = verts[i].z;
490            }
491
492            if ( (attr >> 10) & 1 ) /* min value */
493            {
494               zvalue = min_z;
495            }
496            else if ( (attr >> 10) & 2 ) /* max value */
497            {
498               zvalue = max_z;
499            }
500
501            raster.triangle_z = zvalue;
502         }
503
504         /* adjust and set the object z-sort value */
505         object.z = float_to_zval( zvalue + raster.z_adjust );
506
507         /* get our list read to add the triangles */
508         ztri = raster.tri_sorted_list[object.z];
509
510         if ( ztri != NULL )
511         {
512            while( ztri->next != NULL )
513               ztri = ztri->next;
514         }
515
516         /* go through the clipped vertex list, adding triangles */
517         for( i = 2; i < clipped_verts; i++ )
518         {
519            triangle   *tri;
520
521            tri = &raster.tri_list[raster.tri_list_index++];
522
523            if ( raster.tri_list_index >= MAX_TRIANGLES )
524            {
525               fatalerror( "SEGA 3D: Max triangle limit exceeded\n" );
526            }
527
528            /* copy the object information */
529            tri->z = object.z;
530            tri->texheader[0] = object.texheader[0];
531            tri->texheader[1] = object.texheader[1];
532            tri->texheader[2] = object.texheader[2];
533            tri->texheader[3] = object.texheader[3];
534            tri->luma = object.luma;
535
536            /* set the viewport */
537            tri->viewport[0] = raster.viewport[0];
538            tri->viewport[1] = raster.viewport[1];
539            tri->viewport[2] = raster.viewport[2];
540            tri->viewport[3] = raster.viewport[3];
541
542            /* set the center */
543            tri->center[0] = raster.center[raster.center_sel][0];
544            tri->center[1] = raster.center[raster.center_sel][1];
545
546            memcpy( &tri->v[0], &verts[0], sizeof( vertex ) );
547            memcpy( &tri->v[1], &verts[i-1], sizeof( vertex ) );
548            memcpy( &tri->v[2], &verts[i], sizeof( vertex ) );
549
550            /* add to our sorted list */
551            tri->next = NULL;
552
553            if ( ztri == NULL )
554            {
555               raster.tri_sorted_list[object.z] = tri;
556            }
557            else
558            {
559               ztri->next = tri;
560            }
561
562            ztri = tri;
563         }
564
565         /* keep around the min and max z values for this frame */
566         if ( object.z < raster.min_z ) raster.min_z = object.z;
567         if ( object.z > raster.max_z ) raster.max_z = object.z;
127568      }
128569   }
570
571   /* update linking */
572   switch( ((attr >> 8) & 3) )
573   {
574      case 0:
575      case 2:
576      {
577         /* reuse P0(n) and P1(n) */
578         for( i = 0; i < 6; i++ )                              /* P0(n) -> P0(n-1) */
579            raster.command_buffer[2+i] = raster.command_buffer[11+i];   /* P1(n) -> P1(n-1) */
580      }
581      break;
582
583      case 1:
584      {
585         /* reuse P0(n-1) and P0(n) */
586         for( i = 0; i < 3; i++ )
587            raster.command_buffer[5+i] = raster.command_buffer[11+i];   /* P0(n) -> P1(n-1) */
588      }
589      break;
590
591      case 3:
592      {
593         /* reuse P1(n-1) and P1(n) */
594         for( i = 0; i < 3; i++ )
595            raster.command_buffer[2+i] = raster.command_buffer[14+i];   /* P1(n) -> P1(n-1) */
596      }
597      break;
598   }
129599}
130600
131VIDEO_UPDATE(model2)
601static void model2_3d_process_triangle( UINT32 attr )
132602{
133   sys24_tile_update(machine);
134   fillbitmap(bitmap, machine->pens[0], &machine->screen[0].visarea);
135   fillbitmap(sys24_bitmap, 0, &machine->screen[0].visarea);
603   triangle   object;
604   UINT16      *th, *tp;
605   INT32      tho;
606   UINT32      cull, i;
607   float      zvalue;
608   float      min_z, max_z;
136609
137   sys24_tile_draw(machine, sys24_bitmap, cliprect, 7, 0, 0);
138   sys24_tile_draw(machine, sys24_bitmap, cliprect, 6, 0, 0);
139   sys24_tile_draw(machine, sys24_bitmap, cliprect, 5, 0, 0);
140   sys24_tile_draw(machine, sys24_bitmap, cliprect, 4, 0, 0);
610   /* extract P0(n-1) */
611   object.v[1].x = u2f( raster.command_buffer[2] << 8 );
612   object.v[1].y = u2f( raster.command_buffer[3] << 8 );
613   object.v[1].z = u2f( raster.command_buffer[4] << 8 );
141614
142   convert_bitmap(machine, bitmap, sys24_bitmap, cliprect);
615   /* extract P1(n-1) */
616   object.v[0].x = u2f( raster.command_buffer[5] << 8 );
617   object.v[0].y = u2f( raster.command_buffer[6] << 8 );
618   object.v[0].z = u2f( raster.command_buffer[7] << 8 );
143619
144   tribuffer_pos = 0;
145   parse_display_list();
146   render_triangles(bitmap, cliprect);
620   /* extract P0(n) */
621   object.v[2].x = u2f( raster.command_buffer[11] << 8 );
622   object.v[2].y = u2f( raster.command_buffer[12] << 8 );
623   object.v[2].z = u2f( raster.command_buffer[13] << 8 );
147624
148   fillbitmap(sys24_bitmap, 0, &machine->screen[0].visarea);
149   sys24_tile_draw(machine, sys24_bitmap, cliprect, 3, 0, 0);
150   sys24_tile_draw(machine, sys24_bitmap, cliprect, 2, 0, 0);
151   sys24_tile_draw(machine, sys24_bitmap, cliprect, 1, 0, 0);
152   sys24_tile_draw(machine, sys24_bitmap, cliprect, 0, 0, 0);
625   /* for triangles, the rope of P1(n) is achieved by P0(n-1) (linktype 3) */
626   raster.command_buffer[14] = raster.command_buffer[11];
627   raster.command_buffer[15] = raster.command_buffer[12];
628   raster.command_buffer[16] = raster.command_buffer[13];
153629
154   convert_bitmap(machine, bitmap, sys24_bitmap, cliprect);
630   /* always calculate the min z and max z values */
631   min_z = object.v[0].z;
632   if ( object.v[1].z < min_z ) min_z = object.v[1].z;
633   if ( object.v[2].z < min_z ) min_z = object.v[2].z;
155634
156   return 0;
157}
635   max_z = object.v[0].z;
636   if ( object.v[1].z > max_z ) max_z = object.v[1].z;
637   if ( object.v[2].z > max_z ) max_z = object.v[2].z;
158638
159static void draw_solid_triangle(mame_bitmap *bitmap, const rectangle *rect, TRIANGLE *tri)
160{
161   int x, y;
162   struct poly_vertex vert[3];
163   const struct poly_scanline_data *scans;
164   int r, g, b;
165   UINT32 luminance, tr, tg, tb, ri, gi, bi;
166   UINT32 color, loffset;
639   /* read in the texture information */
167640
168   UINT32 *colortable_r = &model2_colorxlat[0x0000/4];
169   UINT32 *colortable_g = &model2_colorxlat[0x4000/4];
170   UINT32 *colortable_b = &model2_colorxlat[0x8000/4];
641   /* texture point data */
642   if ( raster.command_buffer[0] & 0x800000 )
643      tp = &raster.texture_ram[raster.command_buffer[0] & 0xFFFF];
644   else
645      tp = &raster.texture_rom[raster.command_buffer[0] & 0x7FFFFF];
171646
172   vert[0].x = tri->v[0].x;   vert[0].y = tri->v[0].y;
173   vert[1].x = tri->v[1].x;   vert[1].y = tri->v[1].y;
174   vert[2].x = tri->v[2].x;   vert[2].y = tri->v[2].y;
647   object.v[0].v = *tp++;
648   object.v[0].u = *tp++;
649   object.v[1].v = *tp++;
650   object.v[1].u = *tp++;
651   object.v[2].v = *tp++;
652   object.v[2].u = *tp++;
175653
176   scans = setup_triangle_0(&vert[0], &vert[1], &vert[2], rect);
654   /* update the address */
655   raster.command_buffer[0] += 6;
177656
178   r = tri->r;
179   g = tri->g;
180   b = tri->b;
181   luminance = tri->luminance;
657   /* texture header data */
658   if ( raster.command_buffer[1] & 0x800000 )
659      th = &raster.texture_ram[raster.command_buffer[1] & 0xFFFF];
660   else
661      th = &raster.texture_rom[raster.command_buffer[1] & 0x7FFFFF];
182662
183   /* apply luma to texel */
184   loffset = (tri->luma_select << 8) + (0x0f << 4) + ((luminance >> 4) & 0x0f);
663   object.texheader[0] = *th++;
664   object.texheader[1] = *th++;
665   object.texheader[2] = *th++;
666   object.texheader[3] = *th++;
185667
186   luminance = model2_lumaram[loffset >> 2];
668   /* extract the texture header offset */
669   tho = (attr >> 12) & 0x1F;
187670
188   if ( loffset & 2 )
189      luminance >>= 16;
671   /* adjust for sign */
672   if ( tho & 0x10 )
673      tho |= -16;
190674
191   luminance &= 0xff;
675   /* update the address */
676   raster.command_buffer[1] += tho * 4;
192677
193   ri = (r<<9) + (luminance<<1);
194   gi = (g<<9) + (luminance<<1);
195   bi = (b<<9) + (luminance<<1);
678   /* set the luma value of this quad */
679   object.luma = (raster.command_buffer[9] >> 14) & 0xFF;
196680
197   tr = colortable_r[ri>>2];
198   tg = colortable_g[gi>>2];
199   tb = colortable_b[bi>>2];
681   /* determine wether we can cull this quad */
682   cull = 0;
200683
201   if ( ri & 2 ) tr >>= 16;
202   if ( gi & 2 ) tg >>= 16;
203   if ( bi & 2 ) tb >>= 16;
684   /* if doubleside is disabled */
685   if ( ((attr >> 17) & 1) == 0 )
686   {
687      /* if it's the backface, cull it */
688      if ( raster.command_buffer[9] & 0x00800000 )
689         cull = 1;
690   }
204691
205   tr &= 0xff;
206   tg &= 0xff;
207   tb &= 0xff;
692   /* if the linktype is 0, then we can also cull it */
693   if ( ((attr >> 8) & 3) == 0 )
694      cull = 1;
208695
209   color = (tr << 16) | (tg << 8) | (tb);
696   /* if the minimum z value is bigger than the master z clip value, don't render */
697   if ( (INT32)(1.0/min_z) > raster.master_z_clip )
698      cull = 1;
210699
211   if(scans)
700   /* if the maximum z value is < 0 then we can safely clip the entire polygon */
701   if ( max_z < 0 )
702      cull = 1;
703
704   /* if we're not culling, do z-clip and add to out triangle list */
705   if ( cull == 0 )
212706   {
213      for(y = scans->sy; y <= scans->ey; y++)
707      INT32   clipped_verts;
708      vertex   verts[10];
709      plane   clip_plane;
710
711      clip_plane.normal.x = 0;
712      clip_plane.normal.y = 0;
713      clip_plane.normal.z = 1;
714      clip_plane.distance = 0;
715
716      /* do near z clipping */
717      clipped_verts = clip_polygon( object.v, 3, &clip_plane, verts);
718
719      if ( clipped_verts > 2 )
214720      {
215         int x1, x2;
216         const struct poly_scanline *scan = &scans->scanline[y - scans->sy];
217         UINT32 *p = BITMAP_ADDR32(bitmap, y, 0);
721         triangle *ztri;
218722
219         x1 = scan->sx;
220         x2 = scan->ex;
723         /* set the object's z value */
724         zvalue = raster.triangle_z;
221725
222         for(x = x1; x <= x2; x++)
726         /* see if we need to recompute min/max z */
727         if ( (attr >> 10) & 3 )
223728         {
224            if ( tri->flags & TRI_FLAG_CHECKER )
729            /* update min_z and max_z with the new clipped values */
730            min_z = verts[0].z;
731            max_z = verts[0].z;
732
733            for( i = 1; i < clipped_verts; i++ )
225734            {
226               UINT32   br, bg, bb;
735               if ( verts[i].z < min_z ) min_z = verts[i].z;
736               if ( verts[i].z > max_z ) max_z = verts[i].z;
737            }
227738
228               /* blend */
229               br = (tr + ( ( p[x] >> 16 ) & 0xff ) / 2 );
230               bg = (tg + ( ( p[x] >>  8 ) & 0xff ) / 2 );
231               bb = (tb + ( ( p[x] >>  0 ) & 0xff ) / 2 );
739            if ( (attr >> 10) & 1 ) /* min value */
740            {
741               zvalue = min_z;
742            }
743            else if ( (attr >> 10) & 2 ) /* max value */
744            {
745               zvalue = max_z;
746            }
232747
233               color = (br << 16) | (bg << 8) | (bb);
748            raster.triangle_z = zvalue;
749         }
750
751         /* adjust and set the object z-sort value */
752         object.z = float_to_zval( zvalue + raster.z_adjust );
753
754         /* get our list read to add the triangles */
755         ztri = raster.tri_sorted_list[object.z];
756
757         if ( ztri != NULL )
758         {
759            while( ztri->next != NULL )
760               ztri = ztri->next;
761         }
762
763         /* go through the clipped vertex list, adding triangles */
764         for( i = 2; i < clipped_verts; i++ )
765         {
766            triangle   *tri;
767
768            tri = &raster.tri_list[raster.tri_list_index++];
769
770            if ( raster.tri_list_index >= MAX_TRIANGLES )
771            {
772               fatalerror( "SEGA 3D: Max triangle limit exceeded\n" );
234773            }
235774
236            p[x] = color;
775            /* copy the object information */
776            tri->z = object.z;
777            tri->texheader[0] = object.texheader[0];
778            tri->texheader[1] = object.texheader[1];
779            tri->texheader[2] = object.texheader[2];
780            tri->texheader[3] = object.texheader[3];
781            tri->luma = object.luma;
782
783            /* set the viewport */
784            tri->viewport[0] = raster.viewport[0];
785            tri->viewport[1] = raster.viewport[1];
786            tri->viewport[2] = raster.viewport[2];
787            tri->viewport[3] = raster.viewport[3];
788
789            /* set the center */
790            tri->center[0] = raster.center[raster.center_sel][0];
791            tri->center[1] = raster.center[raster.center_sel][1];
792
793            memcpy( &tri->v[0], &verts[0], sizeof( vertex ) );
794            memcpy( &tri->v[1], &verts[i-1], sizeof( vertex ) );
795            memcpy( &tri->v[2], &verts[i], sizeof( vertex ) );
796
797            /* add to our sorted list */
798            tri->next = NULL;
799
800            if ( ztri == NULL )
801            {
802               raster.tri_sorted_list[object.z] = tri;
803            }
804            else
805            {
806               ztri->next = tri;
807            }
808
809            ztri = tri;
237810         }
811
812         /* keep around the min and max z values for this frame */
813         if ( object.z < raster.min_z ) raster.min_z = object.z;
814         if ( object.z > raster.max_z ) raster.max_z = object.z;
238815      }
239816   }
817
818   /* update linking */
819   switch( ((attr >> 8) & 3) )
820   {
821      case 0:
822      case 2:
823      {
824         /* reuse P0(n) and P1(n) */
825         for( i = 0; i < 6; i++ )                              /* P0(n) -> P0(n-1) */
826            raster.command_buffer[2+i] = raster.command_buffer[11+i];   /* P1(n) -> P1(n-1) */
827      }
828      break;
829
830      case 1:
831      {
832         /* reuse P0(n-1) and P0(n) */
833         for( i = 0; i < 3; i++ )
834            raster.command_buffer[5+i] = raster.command_buffer[11+i];   /* P0(n) -> P1(n-1) */
835      }
836      break;
837
838      case 3:
839      {
840         /* reuse P1(n-1) and P1(n) */
841         for( i = 0; i < 3; i++ )
842            raster.command_buffer[2+i] = raster.command_buffer[14+i];   /* P1(n) -> P1(n-1) */
843      }
844      break;
845   }
240846}
241847
242INLINE int get_texel( UINT32 base_x, UINT32 base_y, int x, int y, UINT32 *sheet )
848/***********************************************************************************************/
849
850INLINE UINT16 get_texel( UINT32 base_x, UINT32 base_y, int x, int y, UINT32 *sheet )
243851{
r1070r1071
260868   return (texel & 0x0f);
261869}
262870
263static void draw_textured_triangle(mame_bitmap *bitmap, const rectangle *rect, TRIANGLE *tri)
264{
265   int x, y;
266   struct poly_vertex vert[3];
267   const struct poly_scanline_data *scans;
268   int r, g, b;
269   int luminance;
270   UINT32 tex_x      = 32 * tri->tex_x;
271   UINT32 tex_y      = 32 * tri->tex_y;
272   UINT32 tex_width   = 32 << tri->tex_width;
273   UINT32 tex_height   = 32 << tri->tex_height;
274   UINT32 tex_x_mask   = tex_width - 1;
275   UINT32 tex_y_mask   = tex_height - 1;
276   UINT32 *sheet   = (tri->flags & TRI_FLAG_EVEN_BANK)   ? (model2_textureram1) : (model2_textureram0);
871/* checker = 0, textured = 0, transparent = 0 */
872#define MODEL2_FUNC 0
873#define MODEL2_FUNC_NAME   model2_3d_render_0
874#include "model2rd.c"
875#undef MODEL2_FUNC
876#undef MODEL2_FUNC_NAME
277877
278   UINT32 *colortable_r = &model2_colorxlat[0x0000/4];
279   UINT32 *colortable_g = &model2_colorxlat[0x4000/4];
280   UINT32 *colortable_b = &model2_colorxlat[0x8000/4];
878/* checker = 0, textured = 0, translucent = 1 */
879#define MODEL2_FUNC 1
880#define MODEL2_FUNC_NAME   model2_3d_render_1
881#include "model2rd.c"
882#undef MODEL2_FUNC
883#undef MODEL2_FUNC_NAME
281884
282//  mame_printf_debug("Tex X: %d, Tex Y: %d, Tex Width: %d, Tex Height: %d - Bank = %d\n", tex_x, tex_y, tex_width, tex_height, (tri->flags & TRI_FLAG_EVEN_BANK) ? 1 : 0 );
283//  mame_printf_debug("U0: %d, V0: %d, U1: %d, V1: %d, U2: %d, V2: %d\n", tri->v[0].u, tri->v[0].v, tri->v[1].u, tri->v[1].v, tri->v[2].u, tri->v[2].v);
885/* checker = 0, textured = 1, translucent = 0 */
886#define MODEL2_FUNC 2
887#define MODEL2_FUNC_NAME   model2_3d_render_2
888#include "model2rd.c"
889#undef MODEL2_FUNC
890#undef MODEL2_FUNC_NAME
284891
285   vert[0].x = tri->v[0].x;   vert[0].y = tri->v[0].y;   vert[0].p[0] = tri->v[0].u;      vert[0].p[1] = tri->v[0].v;
286   vert[1].x = tri->v[1].x;   vert[1].y = tri->v[1].y;   vert[1].p[0] = tri->v[1].u;      vert[1].p[1] = tri->v[1].v;
287   vert[2].x = tri->v[2].x;   vert[2].y = tri->v[2].y;   vert[2].p[0] = tri->v[2].u;      vert[2].p[1] = tri->v[2].v;
892/* checker = 0, textured = 1, translucent = 1 */
893#define MODEL2_FUNC 3
894#define MODEL2_FUNC_NAME   model2_3d_render_3
895#include "model2rd.c"
896#undef MODEL2_FUNC
897#undef MODEL2_FUNC_NAME
288898
289   scans = setup_triangle_2(&vert[0], &vert[1], &vert[2], rect);
899/* checker = 1, textured = 0, translucent = 0 */
900#define MODEL2_FUNC 4
901#define MODEL2_FUNC_NAME   model2_3d_render_4
902#include "model2rd.c"
903#undef MODEL2_FUNC
904#undef MODEL2_FUNC_NAME
290905
291   r = tri->r;
292   g = tri->g;
293   b = tri->b;
294   luminance = tri->luminance;
906/* checker = 1, textured = 0, translucent = 1 */
907#define MODEL2_FUNC 5
908#define MODEL2_FUNC_NAME   model2_3d_render_5
909#include "model2rd.c"
910#undef MODEL2_FUNC
911#undef MODEL2_FUNC_NAME
295912
296   if(scans)
297   {
298      INT64 du, dv;
299      du = scans->dp[0];
300      dv = scans->dp[1];
913/* checker = 1, textured = 1, translucent = 0 */
914#define MODEL2_FUNC 6
915#define MODEL2_FUNC_NAME   model2_3d_render_6
916#include "model2rd.c"
917#undef MODEL2_FUNC
918#undef MODEL2_FUNC_NAME
301919
302      for(y = scans->sy; y <= scans->ey; y++)
303      {
304         INT64 u, v;
305         int x1, x2;
306         UINT16 loffset;
307         const struct poly_scanline *scan = &scans->scanline[y - scans->sy];
308         UINT32 *p = BITMAP_ADDR32(bitmap, y, 0);
920/* checker = 1, textured = 1, translucent = 1 */
921#define MODEL2_FUNC 7
922#define MODEL2_FUNC_NAME   model2_3d_render_7
923#include "model2rd.c"
924#undef MODEL2_FUNC
925#undef MODEL2_FUNC_NAME
309926
310         x1 = scan->sx;
311         x2 = scan->ex;
927/***********************************************************************************************/
312928
313         u = scans->scanline[y - scans->sy].p[0];
314         v = scans->scanline[y - scans->sy].p[1];
929typedef void (*model2_3d_render_func)( mame_bitmap *bitmap, triangle *tri, const rectangle *cliprect );
315930
316         for(x = x1; x <= x2; x++)
317         {
318            UINT32 tr, tg, tb, luma, ri, gi, bi;
319            UINT16 t;
320            int u2 = (int)(u >> (16+3)) & tex_x_mask;
321            int v2 = (int)(v >> (16+3)) & tex_y_mask;
931static model2_3d_render_func render_funcs[8] =
932{
933   model2_3d_render_0,   /* checker = 0, textured = 0, translucent = 0 */
934   model2_3d_render_1,   /* checker = 0, textured = 0, translucent = 1 */
935   model2_3d_render_2,   /* checker = 0, textured = 1, translucent = 0 */
936   model2_3d_render_3,   /* checker = 0, textured = 1, translucent = 1 */
937   model2_3d_render_4,   /* checker = 1, textured = 0, translucent = 0 */
938   model2_3d_render_5,   /* checker = 1, textured = 0, translucent = 1 */
939   model2_3d_render_6,   /* checker = 1, textured = 1, translucent = 0 */
940   model2_3d_render_7   /* checker = 1, textured = 1, translucent = 1 */
941};
322942
323            if ( tri->flags & TRI_FLAG_MIRROR_X )
324               u2 = ( tex_width - 1 ) - u2;
943static void model2_3d_render( mame_bitmap *bitmap, triangle *tri, const rectangle *cliprect )
944{
945   UINT8      renderer;
946   rectangle   vp;
325947
326            if ( tri->flags & TRI_FLAG_MIRROR_Y )
327               v2 = ( tex_height - 1 ) - v2;
948   /* select renderer based on attributes (bit15 = checker, bit14 = textured, bit13 = transparent */
949   renderer = (tri->texheader[0] >> 13) & 7;
328950
329            t = get_texel( tex_x, tex_y, u2, v2, sheet );
951   /* calculate and clip to viewport */
952   vp.min_x = tri->viewport[0] - 8;
953   vp.max_x = tri->viewport[2] - 8;
954   vp.min_y = (384-tri->viewport[3])+90;
955   vp.max_y = (384-tri->viewport[1])+90;
330956
331            if ( !(t == 0x0f && ( tri->flags & TRI_FLAG_TEXTURE_TRANS ) ) )
332            {
333               loffset = (tri->luma_select << 8) + (t << 4) + ((luminance >> 4) & 0x0f);
957   if ( vp.min_x < cliprect->min_x ) vp.min_x = cliprect->min_x;
958   if ( vp.max_x > cliprect->max_x ) vp.max_x = cliprect->max_x;
959   if ( vp.min_y < cliprect->min_y ) vp.min_y = cliprect->min_y;
960   if ( vp.max_y > cliprect->max_y ) vp.max_y = cliprect->max_y;
334961
335               luma = model2_lumaram[loffset >> 2];
962   /* render */
963   (*render_funcs[renderer])( bitmap, tri, &vp );
964}
336965
337               if ( loffset & 2 )
338                  luma >>= 16;
966/*
967    Projection:
339968
340               luma &= 0xff;
969    According to the 2B Manual the screen coordinates are:
341970
342               ri = (r<<9) + (luma<<1);
343               gi = (g<<9) + (luma<<1);
344               bi = (b<<9) + (luma<<1);
971    (8,474)                         (504,474)
972       +--------------------------------+
973       |                                |
974       |                                |
975       |                                |
976       |                                |
977       |                                |
978       |                                |
979       |                                |
980       |                                |
981       +--------------------------------+
982    (8,90)                          (504,90)
983*/
345984
346               tr = colortable_r[ri>>2];
347               tg = colortable_g[gi>>2];
348               tb = colortable_b[bi>>2];
985/* 3D Rasterizer projection: projects a triangle into screen coordinates */
986static void model2_3d_project( triangle *tri )
987{
988   UINT16   i;
349989
350               if ( ri & 2 ) tr >>= 16;
351               if ( gi & 2 ) tg >>= 16;
352               if ( bi & 2 ) tb >>= 16;
353
354               tr &= 0xff;
355               tg &= 0xff;
356               tb &= 0xff;
357
358               if ( tri->flags & TRI_FLAG_CHECKER )
359               {
360                  /* blend */
361                  tr = ( tr + ( ( p[x] >> 16 ) & 0xff ) ) / 2;
362                  tg = ( tg + ( ( p[x] >>  8 ) & 0xff ) ) / 2;
363                  tb = ( tb + ( ( p[x] >>  0 ) & 0xff ) ) / 2;
364               }
365
366               p[x] = (tr << 16) | (tg << 8) | (tb);
367            }
368
369            u += du;
370            v += dv;
371         }
372      }
990   for( i = 0; i < 3; i++ )
991   {
992      /* project the vertices */
993      tri->v[i].x = -8 + tri->center[0] + (tri->v[i].x / (1.0+tri->v[i].z));
994      tri->v[i].y = ((384 - tri->center[1])+90) - (tri->v[i].y / (1.0+tri->v[i].z));
373995   }
374996}
375997
376static int zsort(const void * a, const void * b)
998/* 3D Rasterizer frame start: Resets frame variables */
999static void model2_3d_frame_start( void )
3771000{
378   if (((TRIANGLE*)(a))->z < ((TRIANGLE*)(b))->z)
379      return 1;
380   else if (((TRIANGLE*)(a))->z > ((TRIANGLE*)(b))->z)
381      return -1;
382   else
383      return 0;
1001   /* reset the triangle list index */
1002   raster.tri_list_index = 0;
1003
1004   /* reset the sorted z list */
1005   memset( raster.tri_sorted_list, 0, 0x10000 * sizeof( triangle * ) );
1006
1007   /* reset the min-max sortable Z values */
1008   raster.min_z = 0xFFFF;
1009   raster.max_z = 0;
3841010}
3851011
386static void render_triangles(mame_bitmap *bitmap, const rectangle *cliprect)
1012static void model2_3d_frame_end( bitmap_t *bitmap, const rectangle *cliprect )
3871013{
388   int i;
1014   INT32      z;
3891015
390   qsort(tribuffer, tribuffer_pos, sizeof(TRIANGLE), zsort);
1016   /* if we have nothing to render, bail */
1017   if ( raster.tri_list_index == 0 )
1018      return;
3911019
392   for (i=0; i < tribuffer_pos; i++)
1020#if DEBUG
1021   if (input_code_pressed(KEYCODE_Q))
3931022   {
394      rectangle rect;
395      rect.min_x = tribuffer[i].window.x;
396      rect.max_x = tribuffer[i].window.x + tribuffer[i].window.width;
397      rect.min_y = tribuffer[i].window.y;
398      rect.max_y = tribuffer[i].window.y + tribuffer[i].window.height;
1023      UINT32   i;
3991024
400      if (rect.min_x < cliprect->min_x)   rect.min_x = cliprect->min_x;
401      if (rect.min_x > cliprect->max_x)   rect.min_x = cliprect->max_x;
402      if (rect.max_x < cliprect->min_x)   rect.max_x = cliprect->min_x;
403      if (rect.max_x > cliprect->max_x)   rect.max_x = cliprect->max_x;
404      if (rect.min_y < cliprect->min_y)   rect.min_y = cliprect->min_y;
405      if (rect.min_y > cliprect->max_y)   rect.min_y = cliprect->max_y;
406      if (rect.max_y < cliprect->min_y)   rect.max_y = cliprect->min_y;
407      if (rect.max_y > cliprect->max_y)   rect.max_y = cliprect->max_y;
1025      FILE *f = fopen( "triangles.txt", "w" );
4081026
409      if (tribuffer[i].flags & TRI_FLAG_TEXTURE)
1027      if ( f )
4101028      {
411         draw_textured_triangle(bitmap, &rect, &tribuffer[i]);
412         //draw_solid_triangle(bitmap, &rect, &tribuffer[i]);
1029         for( i = 0; i < raster.tri_list_index; i++ )
1030         {
1031
1032            fprintf( f, "index: %d\n", i );
1033            fprintf( f, "v0.x = %f, v0.y = %f, v0.z = %f\n", raster.tri_list[i].v[0].x, raster.tri_list[i].v[0].y, raster.tri_list[i].v[0].z );
1034            fprintf( f, "v1.x = %f, v1.y = %f, v1.z = %f\n", raster.tri_list[i].v[1].x, raster.tri_list[i].v[1].y, raster.tri_list[i].v[1].z );
1035            fprintf( f, "v2.x = %f, v2.y = %f, v2.z = %f\n", raster.tri_list[i].v[2].x, raster.tri_list[i].v[2].y, raster.tri_list[i].v[2].z );
1036
1037            fprintf( f, "tri z: %04x\n", raster.tri_list[i].z );
1038            fprintf( f, "texheader - 0: %04x\n", raster.tri_list[i].texheader[0] );
1039            fprintf( f, "texheader - 1: %04x\n", raster.tri_list[i].texheader[1] );
1040            fprintf( f, "texheader - 2: %04x\n", raster.tri_list[i].texheader[2] );
1041            fprintf( f, "texheader - 3: %04x\n", raster.tri_list[i].texheader[3] );
1042            fprintf( f, "luma: %02x\n", raster.tri_list[i].luma );
1043            fprintf( f, "vp.sx: %04x\n", raster.tri_list[i].viewport[0] );
1044            fprintf( f, "vp.sy: %04x\n", raster.tri_list[i].viewport[1] );
1045            fprintf( f, "vp.ex: %04x\n", raster.tri_list[i].viewport[2] );
1046            fprintf( f, "vp.ey: %04x\n", raster.tri_list[i].viewport[3] );
1047            fprintf( f, "vp.swx: %04x\n", raster.tri_list[i].center[0] );
1048            fprintf( f, "vp.swy: %04x\n", raster.tri_list[i].center[1] );
1049            fprintf( f, "\n---\n\n" );
1050         }
1051
1052         fprintf( f, "min_z = %04x, max_z = %04x\n", raster.min_z, raster.max_z );
1053
1054         fclose( f );
4131055      }
414      else
1056   }
1057#endif
1058
1059   /* go through the Z levels, and render each bucket */
1060   for( z = raster.max_z; z >= raster.min_z; z-- )
1061   {
1062      /* see if we have items at this z level */
1063      if ( raster.tri_sorted_list[z] != NULL )
4151064      {
416         draw_solid_triangle(bitmap, &rect, &tribuffer[i]);
1065         /* get a pointer to the first triangle */
1066         triangle *tri = raster.tri_sorted_list[z];
1067
1068         /* and loop clipping and rendering each triangle */
1069         while( tri != NULL )
1070         {
1071            /* project and render */
1072            model2_3d_project( tri );
1073            model2_3d_render( bitmap, tri, cliprect );
1074
1075            tri = tri->next;
1076         }
4171077      }
4181078   }
1079}
4191080
420#if 0
1081/* 3D Rasterizer main data input port */
1082void model2_3d_push( UINT32 input )
1083{
1084   /* see if we have a command in progress */
1085   if ( raster.cur_command != 0 )
4211086   {
1087      raster.command_buffer[raster.command_index++] = input;
4221088
423#define   TEX_BASE_X   512
424#define   TEX_BASE_Y   640
425#define   TEX_WIDTH   128
426#define   TEX_HEIGHT   128
427#define   TEX_BANK   1
1089      switch( raster.cur_command )
1090      {
1091         case 0x00:   /* NOP */
1092         break;
4281093
429      int x,y;
1094         case 0x01:   /* Polygon Data */
1095         {
1096            UINT32   attr;
4301097
431      for( y = 0; y < TEX_HEIGHT; y++ )
432      {
433         UINT32 *y0 = BITMAP_ADDR32(bitmap, y, 0);
1098            /* start by looking if we have the basic input data */
1099            if ( raster.command_index < 9 )
1100               return;
4341101
435         for( x = 0; x < TEX_WIDTH; x++ )
1102            /* get the attributes */
1103            attr = raster.command_buffer[8];
1104
1105            /* see if we're done */
1106            if ( (attr & 3) == 0 )
1107            {
1108               raster.cur_command = 0;
1109               return;
1110            }
1111
1112            /* see if it's a quad or a triangle */
1113            if ( attr & 1 )
1114            {
1115               /* it's a quad, wait for the rest of the points */
1116               if ( raster.command_index < 17 )
1117                  return;
1118
1119               /* we have a full quad info, fill up our quad structure */
1120               model2_3d_process_quad( attr );
1121
1122               /* back up and wait for more data */
1123               raster.command_index = 8;
1124            }
1125            else
1126            {
1127               /* it's a triangle, wait for the rest of the point */
1128               if ( raster.command_index < 14 )
1129                  return;
1130
1131               /* we have a full quad info, fill up our quad structure */
1132               model2_3d_process_triangle( attr );
1133
1134               /* back up and wait for more data */
1135               raster.command_index = 8;
1136            }
1137         }
1138         break;
1139
1140         case 0x03:   /* Window Data */
4361141         {
437            UINT32   lup[0x10] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
438                             0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff };
1142            UINT32   i;
4391143
440            UINT32 *tb = (TEX_BANK) ? model2_textureram1 : model2_textureram0;
1144            /* make sure we have all the data */
1145            if ( raster.command_index < 6 )
1146               return;
4411147
442            UINT16   tv = get_texel( TEX_BASE_X, TEX_BASE_Y, x, y, tb );
1148            /* coordinates are 12 bit signed */
4431149
444            if ( x >= cliprect->min_x && x < cliprect->max_x && y >= cliprect->min_y && y < cliprect->max_y )
1150            /* extract the viewport start x */
1151            raster.viewport[0] = (raster.command_buffer[0] >> 12) & 0xFFF;
1152
1153            if ( raster.viewport[0] & 0x800 )
1154               raster.viewport[0] = -( 0x800 - (raster.viewport[0] & 0x7FF) );
1155
1156            /* extract the viewport start y */
1157            raster.viewport[1] = raster.command_buffer[0] & 0xFFF;
1158
1159            if ( raster.viewport[1] & 0x800 )
1160               raster.viewport[1] = -( 0x800 - (raster.viewport[1] & 0x7FF) );
1161
1162            /* extract the viewport end x */
1163            raster.viewport[2] = (raster.command_buffer[1] >> 12) & 0xFFF;
1164
1165            if ( raster.viewport[2] & 0x800 )
1166               raster.viewport[2] = -( 0x800 - (raster.viewport[2] & 0x7FF) );
1167
1168            /* extract the viewport end y */
1169            raster.viewport[3] = raster.command_buffer[1] & 0xFFF;
1170
1171            if ( raster.viewport[3] & 0x800 )
1172               raster.viewport[3] = -( 0x800 - (raster.viewport[3] & 0x7FF) );
1173
1174            /* extract the centers */
1175            for( i = 0; i < 4; i++ )
4451176            {
446               y0[x] = lup[tv] | ((lup[tv])<<8) | ((lup[tv])<<16);
1177               /* center x */
1178               raster.center[i][0] = (raster.command_buffer[2+i] >> 12) & 0xFFF;
1179
1180               if ( raster.center[i][0] & 0x800 )
1181                  raster.center[i][0] = -( 0x800 - (raster.center[i][0] & 0x7FF) );
1182
1183               /* center y */
1184               raster.center[i][1] = raster.command_buffer[2+i] & 0xFFF;
1185
1186               if ( raster.center[i][1] & 0x800 )
1187                  raster.center[i][1] = -( 0x800 - (raster.center[i][1] & 0x7FF) );
4471188            }
1189
1190            /* done with this command */
1191            raster.cur_command = 0;
4481192         }
1193         break;
1194
1195         case 0x04:   /* Texture/Log Data write */
1196         {
1197            /* make sure we have enough data */
1198            if ( raster.command_index < 2 )
1199               return;
1200
1201            /* see if the count is non-zero */
1202            if ( raster.command_buffer[1] > 0 )
1203            {
1204               /* see if we have data available */
1205               if ( raster.command_index >= 3 )
1206               {
1207                  /* get the address */
1208                  UINT32   address = raster.command_buffer[0];
1209
1210                  /* do the write */
1211                  if ( address & 0x800000 )
1212                     raster.texture_ram[address&0xFFFF] = raster.command_buffer[2];
1213                  else
1214                     raster.log_ram[address&0xFFFF] = raster.command_buffer[2];
1215
1216                  /* increment the address and decrease the count */
1217                  raster.command_buffer[0]++;
1218                  raster.command_buffer[1]--;
1219
1220                  /* decrease the index, so we keep placing data in the same slot */
1221                  raster.command_index--;
1222               }
1223            }
1224
1225            /* see if we're done with this command */
1226            if ( raster.command_buffer[1] == 0 )
1227               raster.cur_command = 0;
1228         }
1229         break;
1230
1231         case 0x08:   /* ZSort mode */
1232         {
1233            /* save the zsort mode value */
1234            raster.z_adjust = u2f( raster.command_buffer[0] << 8 );
1235
1236            /* done with this command */
1237            raster.cur_command = 0;
1238         }
1239         break;
1240
1241         default:
1242         {
1243            fatalerror( "SEGA 3D: Unknown rasterizer command %08x\n", raster.cur_command );
1244         }
1245         break;
4491246      }
4501247   }
451#endif
1248   else
1249   {
1250      /* new command */
1251      raster.cur_command = input & 0x0F;
1252      raster.command_index = 0;
1253
1254      /* see if it's object data */
1255      if ( raster.cur_command == 1 )
1256      {
1257         /* extract reverse bit */
1258         raster.reverse = (input >> 4) & 1;
1259
1260         /* extract center select */
1261         raster.center_sel = ( input >> 6 ) & 3;
1262
1263         /* reset the triangle z value */
1264         raster.triangle_z = 0;
1265      }
1266   }
4521267}
4531268
454INLINE int is_point_inside(float x, float y, float z, PLANE cp)
1269/***********************************************************************************************/
1270
1271
1272
1273/*******************************************
1274 *
1275 *  Geometry Engine Internal State
1276 *
1277 *******************************************/
1278
1279typedef struct
4551280{
456   float s = (x * cp.x) + (y * cp.y) + (z * cp.z) + cp.d;
457   if (s >= 0.0f)
458      return 1;
459   else
460      return 0;
461}
1281   UINT32            mode;               /* bit 0 = Enable Specular, bit 1 = Calculate Normals */
1282   UINT32 *         polygon_rom;         /* Polygon ROM pointer */
1283   UINT32 *         polygon_ram0;         /* Fast Polygon RAM pointer */
1284   UINT32 *         polygon_ram1;         /* Slow Polygon RAM pointer */
1285   float            matrix[12];            /* Current Transformation Matrix */
1286   vertex            focus;               /* Focus (x,y) */
1287   vertex            light;               /* Light Vector */
1288   float            lod;               /* LOD */
1289   float            coef_table[32];         /* Distane Coefficient table */
1290   texture_parameter   texture_parameters[32];   /* Texture parameters */
1291} geo_state;
4621292
463INLINE float line_plane_intersection(VERTEX *v1, VERTEX *v2, PLANE cp)
1293static geo_state geo;
1294
1295/*******************************************
1296 *
1297 *  Geometry Engine Initialization
1298 *
1299 *******************************************/
1300
1301static void geo_init( UINT32 *polygon_rom )
4641302{
465   float x = v1->x - v2->x;
466   float y = v1->y - v2->y;
467   float z = v1->z - v2->z;
468   float t = ((cp.x * v1->x) + (cp.y * v1->y) + (cp.z * v1->z)) / ((cp.x * x) + (cp.y * y) + (cp.z * z));
469   return t;
1303   memset( &geo, 0, sizeof( geo_state ) );
1304
1305   geo.polygon_rom = polygon_rom;
1306   geo.polygon_ram0 = auto_malloc(0x8000 * sizeof(UINT32));
1307   geo.polygon_ram1 = auto_malloc(0x8000 * sizeof(UINT32));
4701308}
4711309
472static int clip_polygon(VERTEX *v, int num_vertices, PLANE cp, VERTEX *vout)
1310/*******************************************
1311 *
1312 *  Geometry Engine Polygon Parsers
1313 *
1314 *******************************************/
1315
1316/* Parse Polygons: Normals Present, No Specular case */
1317static void geo_parse_np_ns( UINT32 *input, UINT32 count )
4731318{
474   VERTEX clipv[10];
475   int clip_verts = 0;
476   float t;
477   int i;
1319   vertex   point, normal;
1320   UINT32   attr, i;
4781321
479   int pv = num_vertices - 1;
1322   /* read the 1st point */
1323   point.x = u2f( *input++ );
1324   point.y = u2f( *input++ );
1325   point.z = u2f( *input++ );
4801326
481   for (i=0; i < num_vertices; i++)
1327   /* transform with the current matrix */
1328   transform_point( &point, geo.matrix );
1329
1330   /* apply focus */
1331   point.x *= geo.focus.x;
1332   point.y *= geo.focus.y;
1333
1334   /* push it to the 3d rasterizer */
1335   model2_3d_push( f2u(point.x) >> 8 );
1336   model2_3d_push( f2u(point.y) >> 8 );
1337   model2_3d_push( f2u(point.z) >> 8 );
1338
1339   /* read the 2nd point */
1340   point.x = u2f( *input++ );
1341   point.y = u2f( *input++ );
1342   point.z = u2f( *input++ );
1343
1344   /* transform with the current matrix */
1345   transform_point( &point, geo.matrix );
1346
1347   /* apply focus */
1348   point.x *= geo.focus.x;
1349   point.y *= geo.focus.y;
1350
1351   /* push it to the 3d rasterizer */
1352   model2_3d_push( f2u(point.x) >> 8 );
1353   model2_3d_push( f2u(point.y) >> 8 );
1354   model2_3d_push( f2u(point.z) >> 8 );
1355
1356   /* loop through the following links */
1357   for( i = 0; i < count; i++ )
4821358   {
483      int v1_in = is_point_inside(v[i].x, v[i].y, v[i].z, cp);
484      int v2_in = is_point_inside(v[pv].x, v[pv].y, v[pv].z, cp);
1359      /* read in the attributes */
1360      attr = *input++;
4851361
486      if (v1_in && v2_in)         /* edge is completely inside the volume */
1362      /* push to the 3d rasterizer */
1363      model2_3d_push( attr & 0x0003FFFF );
1364
1365      /* read in the normal */
1366      normal.x = u2f(*input++);
1367      normal.y = u2f(*input++);
1368      normal.z = u2f(*input++);
1369
1370      /* transform with the current matrix */
1371      transform_vector( &normal, geo.matrix );
1372
1373      if ( (attr & 3) != 0 ) /* quad or triangle */
4871374      {
488         memcpy(&clipv[clip_verts], &v[i], sizeof(VERTEX));
489         ++clip_verts;
490      }
491      else if (!v1_in && v2_in)   /* edge is entering the volume */
492      {
493         /* insert vertex at intersection point */
494         t = line_plane_intersection(&v[i], &v[pv], cp);
495         clipv[clip_verts].x = v[i].x + ((v[pv].x - v[i].x) * t);
496         clipv[clip_verts].y = v[i].y + ((v[pv].y - v[i].y) * t);
497         clipv[clip_verts].z = v[i].z + ((v[pv].z - v[i].z) * t);
498         clipv[clip_verts].u = (UINT32)((float)v[i].u + (((float)v[pv].u - (float)v[i].u) * t));
499         clipv[clip_verts].v = (UINT32)((float)v[i].v + (((float)v[pv].v - (float)v[i].v) * t));
500         ++clip_verts;
501      }
502      else if (v1_in && !v2_in)   /* edge is leaving the volume */
503      {
504         /* insert vertex at intersection point */
505         t = line_plane_intersection(&v[i], &v[pv], cp);
506         clipv[clip_verts].x = v[i].x + ((v[pv].x - v[i].x) * t);
507         clipv[clip_verts].y = v[i].y + ((v[pv].y - v[i].y) * t);
508         clipv[clip_verts].z = v[i].z + ((v[pv].z - v[i].z) * t);
509         clipv[clip_verts].u = (UINT32)((float)v[i].u + (((float)v[pv].u - (float)v[i].u) * t));
510         clipv[clip_verts].v = (UINT32)((float)v[i].v + (((float)v[pv].v - (float)v[i].v) * t));
511         ++clip_verts;
1375         float            dotl, dotp, luminance, distance;
1376         float            coef, face;
1377         INT32            luma;
1378         texture_parameter *   texparam;
5121379
513         /* insert the existing vertex */
514         memcpy(&clipv[clip_verts], &v[i], sizeof(VERTEX));
515         ++clip_verts;
516      }
1380         /* read in the next point */
1381         point.x = u2f( *input++ );
1382         point.y = u2f( *input++ );
1383         point.z = u2f( *input++ );
5171384
518      pv = i;
519   }
520   memcpy(&vout[0], &clipv[0], sizeof(VERTEX) * clip_verts);
521   return clip_verts;
522}
1385         /* transform with the current matrix */
1386         transform_point( &point, geo.matrix );
5231387
524INLINE void project_point( VERTEX *v )
525{
526   float ooz = 1.0f / -v->z;
527   v->x = -((v->x * ooz) * focus_x) + (float)(window.x + (window.width / 2));
528   v->y = ((v->y * ooz) * focus_y) + (float)(window.y + (window.height / 2));
529}
1388         /* calculate the dot product of the normal and the light vector */
1389         dotl = dot_product( &normal, &geo.light );
5301390
531static void push_triangle(TRIANGLE *tri)
532{
533   int i;
534   int clipped_verts;
535   VERTEX verts[10];
536   PLANE clip_plane = { 0.0f, 0.0f, 1.0f, -1.0f };
537   clipped_verts = clip_polygon(tri->v, 3, clip_plane, verts);
1391         /* calculate the dot product of the normal and the point */
1392         dotp = dot_product( &normal, &point );
5381393
539   project_point( &verts[0] );
540   project_point( &verts[1] );
541   for (i=2; i < clipped_verts; i++)
542   {
543      TRIANGLE *dt = &tribuffer[tribuffer_pos];
1394         /* apply focus */
1395         point.x *= geo.focus.x;
1396         point.y *= geo.focus.y;
5441397
545      project_point( &verts[i] );
1398         /* determine wether this is the front or the back of the polygon */
1399         face = 0x100; /* rear */
1400         if ( dotp >= 0 ) face = 0; /* front */
5461401
547      memcpy(dt, tri, sizeof(TRIANGLE));
1402         /* get the texture parameters */
1403         texparam = &geo.texture_parameters[(attr>>18) & 0x1f];
5481404
549      memcpy(&dt->v[0], &verts[0], sizeof(VERTEX));
550      memcpy(&dt->v[1], &verts[i-1], sizeof(VERTEX));
551      memcpy(&dt->v[2], &verts[i], sizeof(VERTEX));
552      memcpy(&dt->window, &window, sizeof(WINDOW));
1405         /* calculate luminance */
1406         if ( (dotl * dotp) < 0 ) luminance = 0;
1407         else luminance = fabs( dotl );
5531408
554      tribuffer_pos++;
555      if (tribuffer_pos >= TRIBUFFER_SIZE)
1409         luminance = (luminance * texparam->diffuse) + texparam->ambient;
1410         luma = (INT32)luminance;
1411
1412         if ( luma > 255 ) luma = 255;
1413         if ( luma < 0 ) luma = 0;
1414
1415         /* add the face bit to the luma */
1416         luma += face;
1417
1418         /* extract distance coefficient */
1419         coef = geo.coef_table[attr>>27];
1420
1421         /* calculate texture level of detail */
1422         distance = coef * fabs( dotp ) * geo.lod;
1423
1424         /* push to the 3d rasterizer */
1425         model2_3d_push( luma << 15 );
1426         model2_3d_push( f2u(distance) >> 8 );
1427         model2_3d_push( f2u(point.x) >> 8 );
1428         model2_3d_push( f2u(point.y) >> 8 );
1429         model2_3d_push( f2u(point.z) >> 8 );
1430
1431         /* if it's a quad, push one more point */
1432         if ( attr & 1 )
1433         {
1434            /* read in the next point */
1435            point.x = u2f( *input++ );
1436            point.y = u2f( *input++ );
1437            point.z = u2f( *input++ );
1438
1439            /* transform with the current matrix */
1440            transform_point( &point, geo.matrix );
1441
1442            /* apply focus */
1443            point.x *= geo.focus.x;
1444            point.y *= geo.focus.y;
1445
1446            /* push to the 3d rasterizer */
1447            model2_3d_push( f2u(point.x) >> 8 );
1448            model2_3d_push( f2u(point.y) >> 8 );
1449            model2_3d_push( f2u(point.z) >> 8 );
1450         }
1451         else /* triangle */
1452         {
1453            /* skip the next 3 points */
1454            input += 3;
1455         }
1456      }
1457      else /* we're done */
5561458      {
557         fatalerror("push_triangle: tribuffer overflow");
1459         break;
5581460      }
5591461   }
560}
5611462
562static void push_direct_triangle(TRIANGLE *tri)
563{
564   TRIANGLE *dt = &tribuffer[tribuffer_pos];
565
566   memcpy(dt, tri, sizeof(TRIANGLE));
567   memcpy(&dt->window, &window, sizeof(WINDOW));
1463   /* notify the 3d rasterizer we're done */
1464   model2_3d_push( 0 );
5681465}
5691466
570static void draw_object(UINT32 address, UINT32 num_polys, UINT32 tex_point_addr, UINT32 tex_hdr_addr)
1467/* Parse Polygons: Normals Present, Specular case */
1468static void geo_parse_np_s( UINT32 *input, UINT32 count )
5711469{
572   int i;
573   VERTEX prev_p1 = { 0 }, prev_p2 = { 0 };
1470   vertex   point, normal;
1471   UINT32   attr, i;
5741472
575   UINT16 *thdr;
576   UINT16 *tpoint;
577   UINT32 *object;
1473   /* read the 1st point */
1474   point.x = u2f( *input++ );
1475   point.y = u2f( *input++ );
1476   point.z = u2f( *input++ );
5781477
579   int th_addr = 0;
580   int tp_addr = 0;
581   float previous_zvalue = -12345.0f;
1478   /* transform with the current matrix */
1479   transform_point( &point, geo.matrix );
5821480
583   (void)num_polys;
1481   /* apply focus */
1482   point.x *= geo.focus.x;
1483   point.y *= geo.focus.y;
5841484
585   if (address < 0x800000)
586   {
587      object = polygon_ram;
588      address &= 0x7fff;
589   }
590   else
591   {
592      object = polygon_rom;
593      address = address - 0x800000;
594   }
1485   /* push it to the 3d rasterizer */
1486   model2_3d_push( f2u(point.x) >> 8 );
1487   model2_3d_push( f2u(point.y) >> 8 );
1488   model2_3d_push( f2u(point.z) >> 8 );
5951489
596   if (tex_hdr_addr < 0x800000)
597   {
598      thdr = texture_rom;
599      th_addr = tex_hdr_addr;
600   }
601   else
602   {
603      thdr = texture_ram;
604      th_addr = tex_hdr_addr & 0xffff;
605   }
1490   /* read the 2nd point */
1491   point.x = u2f( *input++ );
1492   point.y = u2f( *input++ );
1493   point.z = u2f( *input++ );
6061494
607   if (tex_point_addr < 0x800000)
608   {
609      tpoint = texture_rom;
610      tp_addr = tex_point_addr;
611   }
612   else
613   {
614      tpoint = texture_ram;
615      tp_addr = tex_point_addr & 0xffff;
616   }
1495   /* transform with the current matrix */
1496   transform_point( &point, geo.matrix );
6171497
618   prev_p1.x = u2f(object[address++]);
619   prev_p1.y = u2f(object[address++]);
620   prev_p1.z = u2f(object[address++]);
1498   /* apply focus */
1499   point.x *= geo.focus.x;
1500   point.y *= geo.focus.y;
6211501
622   prev_p2.x = u2f(object[address++]);
623   prev_p2.y = u2f(object[address++]);
624   prev_p2.z = u2f(object[address++]);
1502   /* push it to the 3d rasterizer */
1503   model2_3d_push( f2u(point.x) >> 8 );
1504   model2_3d_push( f2u(point.y) >> 8 );
1505   model2_3d_push( f2u(point.z) >> 8 );
6251506
626   while ( 1 )
1507   /* loop through the following links */
1508   for( i = 0; i < count; i++ )
6271509   {
628      TEXTURE_PARAMETER *texparam;
629      VERTEX v[4], p1, p2;
630      float nx, ny, nz;
631      UINT32 attr;
632      UINT16 color, rgb;
633      UINT16 tex_header[4];
634      UINT16 s[4], t[4];
635      int polytype, linktype, tex_hdr_offset, zsort_type, texture_code;
1510      /* read in the attributes */
1511      attr = *input++;
6361512
637      attr = object[address++];
638      polytype = attr & 0x3;
1513      /* push to the 3d rasterizer */
1514      model2_3d_push( attr & 0x0003FFFF );
6391515
640      if ( polytype == 0 )
641         break;
1516      /* read in the normal */
1517      normal.x = u2f(*input++);
1518      normal.y = u2f(*input++);
1519      normal.z = u2f(*input++);
6421520
643      linktype = (attr >> 8) & 0x3;
644      if (linktype != ((attr >> 23) & 0x3))
1521      /* transform with the current matrix */
1522      transform_vector( &normal, geo.matrix );
1523
1524      if ( (attr & 3) != 0 ) /* quad or triangle */
6451525      {
646         //return;
647         //fatalerror("Linktype not matching, attribute = %08X at %08X\n", attr, address*4);
648         linktype = (attr >> 23) & 0x3;
649      }
1526         float            dotl, dotp, luminance, distance, specular;
1527         float            coef, face;
1528         INT32            luma;
1529         texture_parameter *   texparam;
6501530
651      zsort_type = (attr >> 10) & 0x3;
652      texture_code = (attr >> 12) & 0x1f;
1531         /* read in the next point */
1532         point.x = u2f( *input++ );
1533         point.y = u2f( *input++ );
1534         point.z = u2f( *input++ );
6531535
654      texparam = &texture_parameter[texture_code];
1536         /* transform with the current matrix */
1537         transform_point( &point, geo.matrix );
6551538
656      // load vertex data and polygon normal
657      nx = -(u2f(object[address++]));
658      ny = -(u2f(object[address++]));
659      nz = -(u2f(object[address++]));
660      p1.x = u2f(object[address++]);
661      p1.y = u2f(object[address++]);
662      p1.z = u2f(object[address++]);
663      p2.x = u2f(object[address++]);
664      p2.y = u2f(object[address++]);
665      p2.z = u2f(object[address++]);
1539         /* calculate the dot product of the normal and the light vector */
1540         dotl = dot_product( &normal, &geo.light );
6661541
1542         /* calculate the dot product of the normal and the point */
1543         dotp = dot_product( &normal, &point );
6671544
668      // load texture parameters
669      tex_header[0] = thdr[th_addr+0];
670      tex_header[1] = thdr[th_addr+1];
671      tex_header[2] = thdr[th_addr+2];
672      tex_header[3] = thdr[th_addr+3];
1545         /* apply focus */
1546         point.x *= geo.focus.x;
1547         point.y *= geo.focus.y;
6731548
674      color = (tex_header[3] >> 6) & 0x3ff;
1549         /* determine wether this is the front or the back of the polygon */
1550         face = 0x100; /* rear */
1551         if ( dotp >= 0 ) face = 0; /* front */
6751552
676      // lookup color in palette ram
677      // we need the original 15 bit color, not the remapped 32 bit version
678      {
679         UINT32   pval = paletteram32[(0x2000/4)+(color >> 1)];
1553         /* get the texture parameters */
1554         texparam = &geo.texture_parameters[(attr>>18) & 0x1f];
6801555
681         if ( color & 1 )
682            rgb = (pval >> 16);
683         else
684            rgb = pval;
685      }
1556         /* calculate luminance and specular */
1557         if ( (dotl * dotp) < 0 ) luminance = 0;
1558         else luminance = fabs( dotl );
6861559
687      rgb &= 0x7fff;
1560         specular = ((2*dotl) * normal.z) - geo.light.z;
1561         if ( specular < 0 )   specular = 0;
1562         if ( texparam->specular_control == 0 ) specular = 0;
1563         if ( (texparam->specular_control >> 1) != 0 ) specular *= specular;
1564         if ( (texparam->specular_control >> 2) != 0 ) specular *= specular;
1565         if ( ((texparam->specular_control+1) >> 3) != 0 ) specular *= specular;
6881566
689      tex_hdr_offset = (attr >> 12) & 0x1f;
1567         specular *= texparam->specular_scale;
6901568
691      if (tex_hdr_offset & 0x10)
692         tex_hdr_offset |= -16;
1569         luminance = (luminance * texparam->diffuse) + texparam->ambient + specular;
1570         luma = (INT32)luminance;
6931571
694      th_addr += tex_hdr_offset * 4;
1572         if ( luma > 255 ) luma = 255;
1573         if ( luma < 0 ) luma = 0;
6951574
696      // load texture coordinates
697      if (polytype == 2)
698      {
699         t[0] = tpoint[tp_addr+0];
700         s[0] = tpoint[tp_addr+1];
701         t[1] = tpoint[tp_addr+2];
702         s[1] = tpoint[tp_addr+3];
703         t[2] = tpoint[tp_addr+4];
704         s[2] = tpoint[tp_addr+5];
705         t[3] = 0; /* unused */
706         s[3] = 0; /* unused */
707         tp_addr += 6;
708      }
709      else
710      {
711         t[0] = tpoint[tp_addr+0];
712         s[0] = tpoint[tp_addr+1];
713         t[1] = tpoint[tp_addr+2];
714         s[1] = tpoint[tp_addr+3];
715         t[2] = tpoint[tp_addr+4];
716         s[2] = tpoint[tp_addr+5];
717         t[3] = tpoint[tp_addr+6];
718         s[3] = tpoint[tp_addr+7];
719         tp_addr += 8;
720      }
1575         /* add the face bit to the luma */
1576         luma += face;
7211577
722      // transform and normalize the normal
723      {
724         float tx =   (nx * matrix[0]) + (ny * matrix[3]) + (nz * matrix[6]);
725         float ty =   (nx * matrix[1]) + (ny * matrix[4]) + (nz * matrix[7]);
726         float tz =   (nx * matrix[2]) + (ny * matrix[5]) + (nz * matrix[8]);
727         float norm = sqrt( tx*tx + ty*ty + tz*tz );
728         if ( norm )
1578         /* extract distance coefficient */
1579         coef = geo.coef_table[attr>>27];
1580
1581         /* calculate texture level of detail */
1582         distance = coef * fabs( dotp ) * geo.lod;
1583
1584         /* push to the 3d rasterizer */
1585         model2_3d_push( luma << 15 );
1586         model2_3d_push( f2u(distance) >> 8 );
1587         model2_3d_push( f2u(point.x) >> 8 );
1588         model2_3d_push( f2u(point.y) >> 8 );
1589         model2_3d_push( f2u(point.z) >> 8 );
1590
1591         /* if it's a quad, push one more point */
1592         if ( attr & 1 )
7291593         {
730            tx /= norm;
731            ty /= norm;
732            tz /= norm;
1594            /* read in the next point */
1595            point.x = u2f( *input++ );
1596            point.y = u2f( *input++ );
1597            point.z = u2f( *input++ );
1598
1599            /* transform with the current matrix */
1600            transform_point( &point, geo.matrix );
1601
1602            /* apply focus */
1603            point.x *= geo.focus.x;
1604            point.y *= geo.focus.y;
1605
1606            /* push to the 3d rasterizer */
1607            model2_3d_push( f2u(point.x) >> 8 );
1608            model2_3d_push( f2u(point.y) >> 8 );
1609            model2_3d_push( f2u(point.z) >> 8 );
7331610         }
734         nx = tx;
735         ny = ty;
736         nz = tz;
1611         else /* triangle */
1612         {
1613            /* skip the next 3 points */
1614            input += 3;
1615         }
7371616      }
1617      else /* we're done */
1618      {
1619         break;
1620      }
1621   }
7381622
739      // transform and push the polygon to render buffer
1623   /* notify the 3d rasterizer we're done */
1624   model2_3d_push( 0 );
1625}
1626
1627/* Parse Polygons: No Normals, No Specular case */
1628static void geo_parse_nn_ns( UINT32 *input, UINT32 count )
1629{
1630   vertex   point, normal, p0, p1, p2, p3;
1631   UINT32   attr, i;
1632
1633   /* read the 1st point */
1634   point.x = u2f( *input++ );
1635   point.y = u2f( *input++ );
1636   point.z = u2f( *input++ );
1637
1638   /* transform with the current matrix */
1639   transform_point( &point, geo.matrix );
1640
1641   /* save for normal calculation */
1642   p0.x = point.x; p0.y = point.y; p0.z = point.z;
1643
1644   /* apply focus */
1645   point.x *= geo.focus.x;
1646   point.y *= geo.focus.y;
1647
1648   /* push it to the 3d rasterizer */
1649   model2_3d_push( f2u(point.x) >> 8 );
1650   model2_3d_push( f2u(point.y) >> 8 );
1651   model2_3d_push( f2u(point.z) >> 8 );
1652
1653   /* read the 2nd point */
1654   point.x = u2f( *input++ );
1655   point.y = u2f( *input++ );
1656   point.z = u2f( *input++ );
1657
1658   /* transform with the current matrix */
1659   transform_point( &point, geo.matrix );
1660
1661   /* save for normal calculation */
1662   p1.x = point.x; p1.y = point.y; p1.z = point.z;
1663
1664   /* apply focus */
1665   point.x *= geo.focus.x;
1666   point.y *= geo.focus.y;
1667
1668   /* push it to the 3d rasterizer */
1669   model2_3d_push( f2u(point.x) >> 8 );
1670   model2_3d_push( f2u(point.y) >> 8 );
1671   model2_3d_push( f2u(point.z) >> 8 );
1672
1673   /* skip 4 */
1674   input += 4;
1675
1676   /* loop through the following links */
1677   for( i = 0; i < count; i++ )
1678   {
1679      /* read in the attributes */
1680      attr = *input++;
1681
1682      /* push to the 3d rasterizer */
1683      model2_3d_push( attr & 0x0003FFFF );
1684
1685      if ( (attr & 3) != 0 ) /* quad or triangle */
7401686      {
1687         float            dotl, dotp, luminance, distance;
1688         float            coef, face;
1689         INT32            luma;
1690         texture_parameter *   texparam;
7411691
742         float dot, intensity;
743         float zvalue;
744         TRIANGLE tri1, tri2;
745         v[0].x = prev_p2.x;      v[0].y = prev_p2.y;      v[0].z = prev_p2.z;      v[0].u = s[0];   v[0].v = t[0];
746         v[1].x = prev_p1.x;      v[1].y = prev_p1.y;      v[1].z = prev_p1.z;      v[1].u = s[1];   v[1].v = t[1];
747         v[2].x = p1.x;         v[2].y = p1.y;         v[2].z = p1.z;         v[2].u = s[2];   v[2].v = t[2];
748         v[3].x = p2.x;         v[3].y = p2.y;         v[3].z = p2.z;         v[3].u = s[3];   v[3].v = t[3];
1692         /* read in the next point */
1693         point.x = u2f( *input++ );
1694         point.y = u2f( *input++ );
1695         point.z = u2f( *input++ );
7491696
750         // transform with the current matrix
751         for ( i = 0; i < 4; i++)
752         {
753            float tx =   (v[i].x * matrix[0]) + (v[i].y * matrix[3]) + (v[i].z * matrix[6]) + (matrix[9]);
754            float ty =   (v[i].x * matrix[1]) + (v[i].y * matrix[4]) + (v[i].z * matrix[7]) + (matrix[10]);
755            float tz =   (v[i].x * matrix[2]) + (v[i].y * matrix[5]) + (v[i].z * matrix[8]) + (matrix[11]);
756            v[i].x = tx;
757            v[i].y = ty;
758            v[i].z = tz;
759         }
1697         /* transform with the current matrix */
1698         transform_point( &point, geo.matrix );
7601699
761         dot = -( (light_vector[0] * nx) + (light_vector[1] * ny) + (light_vector[2] * nz) );
1700         /* save for normal calculation */
1701         p2.x = point.x; p2.y = point.y; p2.z = point.z;
7621702
763         if (dot < 0.0f)
764            dot = 0.0f;
765         if (dot > 1.0f)
766            dot = 1.0f;
1703         /* compute the normal */
1704         vector_cross3( &normal, &p0, &p1, &p2 );
7671705
768         intensity = (dot * (float)texparam->diffuse);
769         intensity += (float)texparam->ambient;
1706         /* normalize it */
1707         normalize_vector( &normal );
7701708
771         if (intensity < 0)
772            intensity = 0;
773         if (intensity > 255.0f)
774            intensity = 255.0f;
1709         /* calculate the dot product of the normal and the light vector */
1710         dotl = dot_product( &normal, &geo.light );
7751711
776         memcpy(&tri1.v[0], &v[0], sizeof(VERTEX));
777         memcpy(&tri1.v[1], &v[1], sizeof(VERTEX));
778         memcpy(&tri1.v[2], &v[2], sizeof(VERTEX));
1712         /* calculate the dot product of the normal and the point */
1713         dotp = dot_product( &normal, &point );
7791714
780         memcpy(&tri2.v[0], &v[2], sizeof(VERTEX));
781         memcpy(&tri2.v[1], &v[3], sizeof(VERTEX));
782         memcpy(&tri2.v[2], &v[0], sizeof(VERTEX));
1715         /* apply focus */
1716         point.x *= geo.focus.x;
1717         point.y *= geo.focus.y;
7831718
784         switch (zsort_type)
785         {
786            case 0:         // Previous value
787            {
788               zvalue = previous_zvalue;
789               break;
790            }
791            case 1:         // Min value
792            {
793               zvalue = v[0].z;
794               zvalue = MIN(zvalue, v[1].z);
795               zvalue = MIN(zvalue, v[2].z);
796               zvalue = MIN(zvalue, v[3].z);
797               break;
798            }
799            case 2:         // Max value
800            {
801               zvalue = v[0].z;
802               zvalue = MAX(zvalue, v[1].z);
803               zvalue = MAX(zvalue, v[2].z);
804               zvalue = MAX(zvalue, v[3].z);
805               break;
806            }
807            default:   mame_printf_error("draw_object: unknown zsort mode %d!\n", zsort_type);
808               zvalue = /* previous_zvalue */0.0;   /* complete hack */
809               break;
810         }
1719         /* determine wether this is the front or the back of the polygon */
1720         face = 0x100; /* rear */
1721         if ( dotp >= 0 ) face = 0; /* front */
8111722
812         previous_zvalue = zvalue;
1723         /* get the texture parameters */
1724         texparam = &geo.texture_parameters[(attr>>18) & 0x1f];
8131725
814         if (polytype == 2)
815            memcpy(&p2, &p1, sizeof(VERTEX));
1726         /* calculate luminance */
1727         if ( (dotl * dotp) < 0 ) luminance = 0;
1728         else luminance = fabs( dotl );
8161729
817         if (linktype != 0)
1730         luminance = (luminance * texparam->diffuse) + texparam->ambient;
1731         luma = (INT32)luminance;
1732
1733         if ( luma > 255 ) luma = 255;
1734         if ( luma < 0 ) luma = 0;
1735
1736         /* add the face bit to the luma */
1737         luma += face;
1738
1739         /* extract distance coefficient */
1740         coef = geo.coef_table[attr>>27];
1741
1742         /* calculate texture level of detail */
1743         distance = coef * fabs( dotp ) * geo.lod;
1744
1745         /* push to the 3d rasterizer */
1746         model2_3d_push( luma << 15 );
1747         model2_3d_push( f2u(distance) >> 8 );
1748         model2_3d_push( f2u(point.x) >> 8 );
1749         model2_3d_push( f2u(point.y) >> 8 );
1750         model2_3d_push( f2u(point.z) >> 8 );
1751
1752         /* if it's a quad, push one more point */
1753         if ( attr & 1 )
8181754         {
819            tri1.flags = 0;
820            if (tex_header[0] & 0x8000)      tri1.flags |= TRI_FLAG_CHECKER;
821            if (tex_header[0] & 0x4000)      tri1.flags |= TRI_FLAG_TEXTURE;
822            if (tex_header[0] & 0x2000)      tri1.flags |= TRI_FLAG_TEXTURE_TRANS;
823            if (tex_header[0] & 0x1000)      tri1.flags |= TRI_FLAG_MICROTEX;
824            if (tex_header[0] & 0x0200)      tri1.flags |= TRI_FLAG_MIRROR_X;
825            if (tex_header[0] & 0x0100)      tri1.flags |= TRI_FLAG_MIRROR_Y;
826            if (tex_header[0] & 0x0080)      tri1.flags |= TRI_FLAG_WRAP_X;
827            if (tex_header[0] & 0x0040)      tri1.flags |= TRI_FLAG_WRAP_Y;
828            if (tex_header[2] & 0x1000)      tri1.flags |= TRI_FLAG_EVEN_BANK;
829            tri2.flags = tri1.flags;
1755            /* read in the next point */
1756            point.x = u2f( *input++ );
1757            point.y = u2f( *input++ );
1758            point.z = u2f( *input++ );
8301759
831            tri1.tex_x = tri2.tex_x            = (tex_header[2] >> 0) & 0x1f;
832            tri1.tex_y = tri2.tex_y            = (tex_header[2] >> 6) & 0x1f;
1760            /* transform with the current matrix */
1761            transform_point( &point, geo.matrix );
8331762
834            if ( tex_header[2] & 0x20 )
835            {
836               tri1.tex_y += 0x20;
837               tri2.tex_y += 0x20;
838            }
1763            /* save for normal calculation */
1764            p3.x = point.x; p3.y = point.y; p3.z = point.z;
8391765
840            tri1.tex_width = tri2.tex_width      = (tex_header[0] >> 0) & 0x7;
841            tri1.tex_height = tri2.tex_height   = (tex_header[0] >> 3) & 0x7;
842            tri1.luma_select = tri2.luma_select = tex_header[1] & 0xff;
1766            /* apply focus */
1767            point.x *= geo.focus.x;
1768            point.y *= geo.focus.y;
8431769
844            tri1.z = tri2.z = zvalue;
845            tri1.r = tri2.r = (rgb >>  0) & 0x1f;
846            tri1.g = tri2.g = (rgb >>  5) & 0x1f;
847            tri1.b = tri2.b = (rgb >> 10) & 0x1f;
848            tri1.luminance = tri2.luminance = (int)intensity;
1770            /* push to the 3d rasterizer */
1771            model2_3d_push( f2u(point.x) >> 8 );
1772            model2_3d_push( f2u(point.y) >> 8 );
1773            model2_3d_push( f2u(point.z) >> 8 );
1774         }
1775         else
1776         {
1777            /* skip the next 3 points */
1778            input += 3;
8491779
850            if (polytype == 1)
851            {
852               push_triangle(&tri2);
853               push_triangle(&tri1);
854            }
855            else
856            {
857               push_triangle(&tri1);
858            }
1780            /* for triangles, the rope of P1(n) is achieved by P0(n-1) (linktype 3) */
1781            p3.x = p2.x; p3.y = p2.y; p3.z = p2.z;
8591782         }
8601783      }
1784      else /* we're done */
1785      {
1786         break;
1787      }
8611788
862      switch (linktype)
1789      /* link type */
1790      switch( (attr>>8) & 3 )
8631791      {
8641792         case 0:
8651793         case 2:
8661794         {
867            memcpy(&prev_p1, &p1, sizeof(VERTEX));
868            memcpy(&prev_p2, &p2, sizeof(VERTEX));
869            break;
1795            /* reuse P0(n) and P1(n) */
1796            p0.x = p2.x; p0.y = p2.y; p0.z = p2.z;
1797            p1.x = p3.x; p1.y = p3.y; p1.z = p3.z;
8701798         }
1799         break;
8711800
8721801         case 1:
8731802         {
874            // prev P1 = prev P1
875            memcpy(&prev_p2, &p1, sizeof(VERTEX));
876            break;
1803            /* reuse P0(n-1) and P0(n) */
1804            p1.x = p2.x; p1.y = p2.y; p1.z = p2.z;
8771805         }
1806         break;
8781807
8791808         case 3:
8801809         {
881            // prev P2 = prev P2
882            memcpy(&prev_p1, &p2, sizeof(VERTEX));
883            break;
1810            /* reuse P1(n-1) and P1(n) */
1811            p0.x = p3.x; p0.y = p3.y; p0.z = p3.z;
8841812         }
1813         break;
8851814      }
8861815   }
1816
1817   /* notify the 3d rasterizer we're done */
1818   model2_3d_push( 0 );
8871819}
8881820
889static int draw_direct_data(UINT32 *mem)
1821/* Parse Polygons: No Normals, Specular case */
1822static void geo_parse_nn_s( UINT32 *input, UINT32 count )
8901823{
891   int offset = 0;
892   int end = 0;
893   VERTEX prev_p1, prev_p2;
894   UINT32 texture_point_address;
895   UINT32 texture_header_address;
1824   vertex   point, normal, p0, p1, p2, p3;
1825   UINT32   attr, i;
8961826
897   texture_point_address   = mem[offset++];
898   texture_header_address   = mem[offset++];
899   prev_p1.x = u2f(mem[offset++]);
900   prev_p1.y = u2f(mem[offset++]);
901   prev_p1.z = u2f(mem[offset++]);
902   prev_p2.x = u2f(mem[offset++]);
903   prev_p2.y = u2f(mem[offset++]);
904   prev_p2.z = u2f(mem[offset++]);
1827   /* read the 1st point */
1828   point.x = u2f( *input++ );
1829   point.y = u2f( *input++ );
1830   point.z = u2f( *input++ );
9051831
906   while (!end)
1832   /* transform with the current matrix */
1833   transform_point( &point, geo.matrix );
1834
1835   /* save for normal calculation */
1836   p0.x = point.x; p0.y = point.y; p0.z = point.z;
1837
1838   /* apply focus */
1839   point.x *= geo.focus.x;
1840   point.y *= geo.focus.y;
1841
1842   /* push it to the 3d rasterizer */
1843   model2_3d_push( f2u(point.x) >> 8 );
1844   model2_3d_push( f2u(point.y) >> 8 );
1845   model2_3d_push( f2u(point.z) >> 8 );
1846
1847   /* read the 2nd point */
1848   point.x = u2f( *input++ );
1849   point.y = u2f( *input++ );
1850   point.z = u2f( *input++ );
1851
1852   /* transform with the current matrix */
1853   transform_point( &point, geo.matrix );
1854
1855   /* save for normal calculation */
1856   p1.x = point.x; p1.y = point.y; p1.z = point.z;
1857
1858   /* apply focus */
1859   point.x *= geo.focus.x;
1860   point.y *= geo.focus.y;
1861
1862   /* push it to the 3d rasterizer */
1863   model2_3d_push( f2u(point.x) >> 8 );
1864   model2_3d_push( f2u(point.y) >> 8 );
1865   model2_3d_push( f2u(point.z) >> 8 );
1866
1867   /* skip 4 */
1868   input += 4;
1869
1870   /* loop through the following links */
1871   for( i = 0; i < count; i++ )
9071872   {
908      UINT32 luminance_data;
909      float d;
910      VERTEX p1, p2;
911      UINT32 attr;
912      int polytype, linktype;
1873      /* read in the attributes */
1874      attr = *input++;
9131875
914      attr = mem[offset++];
915      polytype = attr & 0x3;
1876      /* push to the 3d rasterizer */
1877      model2_3d_push( attr & 0x0003FFFF );
9161878
917      if (polytype == 0)
1879      if ( (attr & 3) != 0 ) /* quad or triangle */
9181880      {
919         return offset;
920      }
1881         float            dotl, dotp, luminance, distance, specular;
1882         float            coef, face;
1883         INT32            luma;
1884         texture_parameter *   texparam;
9211885
922      linktype = (attr >> 8) & 0x3;
923      if (linktype != ((attr >> 23) & 0x3))
924      {
925         //return;
926         fatalerror("draw_direct_data: Linktype not matching, attribute = %08X\n", attr);
927      }
1886         /* read in the next point */
1887         point.x = u2f( *input++ );
1888         point.y = u2f( *input++ );
1889         point.z = u2f( *input++ );
9281890
929      luminance_data = mem[offset++];
930      d      = u2f(mem[offset++]);
931      p1.x   = u2f(mem[offset++]);
932      p1.y   = u2f(mem[offset++]);
933      p1.z   = u2f(mem[offset++]);
934      p2.x   = u2f(mem[offset++]);
935      p2.y   = u2f(mem[offset++]);
936      p2.z   = u2f(mem[offset++]);
1891         /* transform with the current matrix */
1892         transform_point( &point, geo.matrix );
9371893
938      if (linktype != 0)
939      {
940         TRIANGLE tri1, tri2;
941         tri1.v[0].x = p1.x;         tri1.v[0].y = p1.y;         tri1.v[0].z = p1.z;
942         tri1.v[1].x = p2.x;         tri1.v[1].y = p2.y;         tri1.v[1].z = p2.z;
943         tri1.v[2].x = prev_p1.x;   tri1.v[2].y = prev_p1.y;   tri1.v[2].z = prev_p1.z;
944         tri2.v[0].x = p2.x;         tri2.v[0].y = p2.y;         tri2.v[0].z = p2.z;
945         tri2.v[1].x = prev_p1.x;   tri2.v[1].y = prev_p1.y;   tri2.v[1].z = prev_p1.z;
946         tri2.v[2].x = prev_p2.x;   tri2.v[2].y = prev_p2.y;   tri2.v[2].z = prev_p2.z;
1894         /* save for normal calculation */
1895         p2.x = point.x; p2.y = point.y; p2.z = point.z;
9471896
948         if (polytype == 1)
1897         /* compute the normal */
1898         vector_cross3( &normal, &p0, &p1, &p2 );
1899
1900         /* normalize it */
1901         normalize_vector( &normal );
1902
1903         /* calculate the dot product of the normal and the light vector */
1904         dotl = dot_product( &normal, &geo.light );
1905
1906         /* calculate the dot product of the normal and the point */
1907         dotp = dot_product( &normal, &point );
1908
1909         /* apply focus */
1910         point.x *= geo.focus.x;
1911         point.y *= geo.focus.y;
1912
1913         /* determine wether this is the front or the back of the polygon */
1914         face = 0x100; /* rear */
1915         if ( dotp >= 0 ) face = 0; /* front */
1916
1917         /* get the texture parameters */
1918         texparam = &geo.texture_parameters[(attr>>18) & 0x1f];
1919
1920         /* calculate luminance and specular */
1921         if ( (dotl * dotp) < 0 ) luminance = 0;
1922         else luminance = fabs( dotl );
1923
1924         specular = ((2*dotl) * normal.z) - geo.light.z;
1925         if ( specular < 0 )   specular = 0;
1926         if ( texparam->specular_control == 0 ) specular = 0;
1927         if ( (texparam->specular_control >> 1) != 0 ) specular *= specular;
1928         if ( (texparam->specular_control >> 2) != 0 ) specular *= specular;
1929         if ( ((texparam->specular_control+1) >> 3) != 0 ) specular *= specular;
1930
1931         specular *= texparam->specular_scale;
1932
1933         luminance = (luminance * texparam->diffuse) + texparam->ambient + specular;
1934         luma = (INT32)luminance;
1935
1936         if ( luma > 255 ) luma = 255;
1937         if ( luma < 0 ) luma = 0;
1938
1939         /* add the face bit to the luma */
1940         luma += face;
1941
1942         /* extract distance coefficient */
1943         coef = geo.coef_table[attr>>27];
1944
1945         /* calculate texture level of detail */
1946         distance = coef * fabs( dotp ) * geo.lod;
1947
1948         /* push to the 3d rasterizer */
1949         model2_3d_push( luma << 15 );
1950         model2_3d_push( f2u(distance) >> 8 );
1951         model2_3d_push( f2u(point.x) >> 8 );
1952         model2_3d_push( f2u(point.y) >> 8 );
1953         model2_3d_push( f2u(point.z) >> 8 );
1954
1955         /* if it's a quad, push one more point */
1956         if ( attr & 1 )
9491957         {
950            push_direct_triangle(&tri1);
951            push_direct_triangle(&tri2);
1958            /* read in the next point */
1959            point.x = u2f( *input++ );
1960            point.y = u2f( *input++ );
1961            point.z = u2f( *input++ );
1962
1963            /* transform with the current matrix */
1964            transform_point( &point, geo.matrix );
1965
1966            /* save for normal calculation */
1967            p3.x = point.x; p3.y = point.y; p3.z = point.z;
1968
1969            /* apply focus */
1970            point.x *= geo.focus.x;
1971            point.y *= geo.focus.y;
1972
1973            /* push to the 3d rasterizer */
1974            model2_3d_push( f2u(point.x) >> 8 );
1975            model2_3d_push( f2u(point.y) >> 8 );
1976            model2_3d_push( f2u(point.z) >> 8 );
9521977         }
9531978         else
9541979         {
955            push_direct_triangle(&tri1);
1980            /* skip the next 3 points */
1981            input += 3;
1982
1983            /* for triangles, the rope of P1(n) is achieved by P0(n-1) (linktype 3) */
1984            p3.x = p2.x; p3.y = p2.y; p3.z = p2.z;
9561985         }
9571986      }
1987      else /* we're done */
1988      {
1989         break;
1990      }
9581991
959      switch (linktype)
1992      /* link type */
1993      switch( (attr>>8) & 3 )
9601994      {
9611995         case 0:
9621996         case 2:
9631997         {
964            memcpy(&prev_p1, &p1, sizeof(VERTEX));
965            memcpy(&prev_p2, &p2, sizeof(VERTEX));
966            break;
1998            /* reuse P0(n) and P1(n) */
1999            p0.x = p2.x; p0.y = p2.y; p0.z = p2.z;
2000            p1.x = p3.x; p1.y = p3.y; p1.z = p3.z;
9672001         }
2002         break;
9682003
9692004         case 1:
9702005         {
971            // prev P1 = prev P1
972            memcpy(&prev_p2, &p1, sizeof(VERTEX));
973            break;
2006            /* reuse P0(n-1) and P0(n) */
2007            p1.x = p2.x; p1.y = p2.y; p1.z = p2.z;
9742008         }
2009         break;
9752010
9762011         case 3:
9772012         {
978            // prev P2 = prev P2
979            memcpy(&prev_p1, &p2, sizeof(VERTEX));
980            break;
2013            /* reuse P1(n-1) and P1(n) */
2014            p0.x = p3.x; p0.y = p3.y; p0.z = p3.z;
9812015         }
2016         break;
9822017      }
9832018   }
9842019
985   return offset;
2020   /* notify the 3d rasterizer we're done */
2021   model2_3d_push( 0 );
9862022}
9872023
988static void parse_display_list(void)
2024/*******************************************
2025 *
2026 *  Geometry Engine Commands
2027 *
2028 *******************************************/
2029
2030/* Command 00: NOP */
2031static UINT32 * geo_nop( UINT32 opcode, UINT32 *input )
9892032{
990   UINT32 address, length, tex_point_addr, tex_hdr_addr;
991   int i;
992   int end;
993   int dlptr;
2033   /* push the opcode to the 3d rasterizer */
2034   model2_3d_push( opcode >> 23 );
9942035
995   dlptr = geo_read_start_address / 4;
2036   return input;
2037}
9962038
997   end = 0;
998   while (!end && dlptr < (0x20000/4))
2039/* Command 01: Object Data */
2040static UINT32 * geo_object_data( UINT32 opcode, UINT32 *input )
2041{
2042   UINT32   tpa = *input++;      /* Texture Point Address */
2043   UINT32   tha = *input++;      /* Texture Header Address */
2044   UINT32   oba = *input++;      /* Object Address */
2045   UINT32   obc = *input++;      /* Object Count */
2046
2047   UINT32 *obp;            /* Object Pointer */
2048
2049   /* push the initial set of data to the 3d rasterizer */
2050   model2_3d_push( opcode >> 23 );
2051   model2_3d_push( tpa );
2052   model2_3d_push( tha );
2053
2054   /* select where we're reading polygon information from */
2055   if ( oba & 0x01000000 )
9992056   {
1000      UINT32 op = model2_bufferram[dlptr++];
1001      int cmd3 = (op >>  0) & 0xff;
1002      int cmd2 = (op >>  8) & 0xff;
1003      int cmd1 = (op >> 23) & 0xff;
2057      /* Fast polygon RAM */
2058      obp = &geo.polygon_ram0[oba & 0x7FFF];
2059   }
2060   else if ( oba & 0x00800000 )
2061   {
2062      /* Polygon ROM */
2063      obp = &geo.polygon_rom[oba & 0x7FFFFF];
2064   }
2065   else
2066   {
2067      /* Slow Polygon RAM */
2068      obp = &geo.polygon_ram1[oba & 0x7FFF];
2069   }
10042070
1005      if (op & 0x80000000)
2071   switch( geo.mode & 3 )
2072   {
2073      /* Normals present, No Specular */
2074      case 0:   geo_parse_np_ns( obp, obc ); break;
2075
2076      /* Normals present, Specular */
2077      case 1: geo_parse_np_s( obp, obc ); break;
2078
2079      /* No Normals present, No Specular */
2080      case 2: geo_parse_nn_ns( obp, obc ); break;
2081
2082      /* No Normals present, Specular */
2083      case 3: geo_parse_nn_s( obp, obc ); break;
2084   }
2085
2086   /* move by 4 parameters */
2087   return input;
2088}
2089
2090/* Command 02: Direct Data */
2091static UINT32 * geo_direct_data( UINT32 opcode, UINT32 *input )
2092{
2093   UINT32   tpa = *input++;      /* Texture Point Address */
2094   UINT32   tha = *input++;      /* Texture Header Address */
2095   UINT32   attr;
2096
2097   /* push the initial set of data to the 3d rasterizer */
2098   model2_3d_push( (opcode >> 23) - 1 );
2099   model2_3d_push( tpa );
2100   model2_3d_push( tha );
2101
2102   /* push the initial points */
2103   model2_3d_push( (*input++) >> 8 ); /* x */
2104   model2_3d_push( (*input++) >> 8 ); /* y */
2105   model2_3d_push( (*input++) >> 8 ); /* z */
2106
2107   model2_3d_push( (*input++) >> 8 ); /* x */
2108   model2_3d_push( (*input++) >> 8 ); /* y */
2109   model2_3d_push( (*input++) >> 8 ); /* z */
2110
2111   do
2112   {
2113      /* read in the attributes */
2114      attr = *input++;
2115
2116      if ( (attr & 3) == 0 )
2117         break;
2118
2119      /* push attributes */
2120      model2_3d_push( attr & 0x00FFFFFF );
2121
2122      /* push luma */
2123      model2_3d_push( (*input++) >> 8 );
2124
2125      /* push distance */
2126      model2_3d_push( (*input++) >> 8 );
2127
2128      /* push the next point */
2129      model2_3d_push( (*input++) >> 8 ); /* x */
2130      model2_3d_push( (*input++) >> 8 ); /* y */
2131      model2_3d_push( (*input++) >> 8 ); /* z */
2132
2133      /* if it's a quad, output another point */
2134      if ( attr & 1 )
10062135      {
1007         // Jump command
2136         model2_3d_push( (*input++) >> 8 ); /* x */
2137         model2_3d_push( (*input++) >> 8 ); /* y */
2138         model2_3d_push( (*input++) >> 8 ); /* z */
10082139      }
1009      else
2140   } while( 1 );
2141
2142   /* we're done */
2143   model2_3d_push( 0 );
2144
2145   return input;
2146}
2147
2148/* Command 03: Window Data */
2149static UINT32 * geo_window_data( UINT32 opcode, UINT32 *input )
2150{
2151   UINT32   x, y, i;
2152
2153   /* start by pushing the opcode */
2154   model2_3d_push( opcode >> 23 );
2155
2156   /*
2157        we're going to move 6 coordinates to the 3d rasterizer:
2158        - starting coordinate
2159        - completion coordinate
2160        - vanishing point 0 (eye mode 0)
2161        - vanishing point 1 (eye mode 1)
2162        - vanishing point 2 (eye mode 2)
2163        - vanishing point 3 (eye mode 3)
2164    */
2165
2166   for( i = 0; i < 6; i++ )
2167   {
2168      /* read in the coordinate */
2169      y = *input++;
2170
2171      /* convert to the 3d rasterizer format (00XXXYYY) */
2172      x = ( y & 0x0FFF0000 ) >> 4 ;
2173      y &= 0xFFF;
2174
2175      /* push it */
2176      model2_3d_push( x | y );
2177   }
2178
2179   return input;
2180}
2181
2182/* Command 04: Texture Data Write */
2183static UINT32 * geo_texture_data( UINT32 opcode, UINT32 *input )
2184{
2185   UINT32   i, count;
2186
2187   /* start by pushing the opcode */
2188   model2_3d_push( opcode >> 23 );
2189
2190   /* push the starting address/dsp id */
2191   model2_3d_push( *input++ );
2192
2193   /* get the count */
2194   count = *input++;
2195
2196   /* push the count */
2197   model2_3d_push( count );
2198
2199   /* loop and send the data */
2200   for( i = 0; i < count; i++ )
2201      model2_3d_push( *input++ );
2202
2203   return input;
2204}
2205
2206/* Command 05: Polygon Data */
2207static UINT32 * geo_polygon_data( UINT32 opcode, UINT32 *input )
2208{
2209   UINT32   address, count, i;
2210   UINT32 *p;
2211
2212   (void)opcode;
2213
2214   /* read in the address */
2215   address = *input++;
2216
2217   /* prepare the pointer */
2218   if ( address & 0x01000000 )
2219   {
2220      /* Fast polygon RAM */
2221      p = &geo.polygon_ram0[address & 0x7FFF];
2222   }
2223   else
2224   {
2225      /* Slow Polygon RAM */
2226      p = &geo.polygon_ram1[address & 0x7FFF];
2227   }
2228
2229   /* read the count */
2230   count = *input++;
2231
2232   /* move the data */
2233   for( i = 0; i < count; i++ )
2234      *p++ = *input++;
2235
2236   return input;
2237}
2238
2239/* Command 06: Texture Parameters */
2240static UINT32 * geo_texture_parameters( UINT32 opcode, UINT32 *input )
2241{
2242   UINT32   index, count, i, param;
2243
2244   (void)opcode;
2245
2246   /* read in the index */
2247   index = *input++;
2248
2249   /* read in the conut */
2250   count = *input++;
2251
2252   for( i = 0; i < count; i++ )
2253   {
2254      /* read in the texture parameters */
2255      param = *input++;
2256
2257      geo.texture_parameters[index].diffuse = (float)( param & 0xFF );
2258      geo.texture_parameters[index].ambient = (float)( (param >> 8) & 0xFF );
2259      geo.texture_parameters[index].specular_control = (param >> 24) & 0xFF;
2260      geo.texture_parameters[index].specular_scale = (float)( (param >> 16) & 0xFF );
2261
2262      /* read in the distance coefficient */
2263      geo.coef_table[index] = u2f(*input++);
2264
2265      index = (index + 1) & 0x1F;
2266   }
2267
2268   return input;
2269}
2270
2271/* Command 07: Geo Mode */
2272static UINT32 * geo_mode( UINT32 opcode, UINT32 *input )
2273{
2274   (void)opcode;
2275
2276   /* read in the mode */
2277   geo.mode = *input++;
2278
2279   return input;
2280}
2281
2282/* Command 08: ZSort Mode */
2283static UINT32 * geo_zsort_mode( UINT32 opcode, UINT32 *input )
2284{
2285   /* push the opcode */
2286   model2_3d_push( opcode >> 23 );
2287
2288   /* push the mode */
2289   model2_3d_push( (*input++) >> 8 );
2290
2291   return input;
2292}
2293
2294/* Command 09: Focal Distance */
2295static UINT32 * geo_focal_distance( UINT32 opcode, UINT32 *input )
2296{
2297   (void)opcode;
2298
2299   /* read the x focus value */
2300   geo.focus.x = u2f( *input++ );
2301
2302   /* read the y focus value */
2303   geo.focus.y = u2f( *input++ );
2304
2305   return input;
2306}
2307
2308/* Command 0A: Light Source Vector Write */
2309static UINT32 * geo_light_source( UINT32 opcode, UINT32 *input )
2310{
2311   (void)opcode;
2312
2313   /* read the x light value */
2314   geo.light.x = u2f( *input++ );
2315
2316   /* read the y light value */
2317   geo.light.y = u2f( *input++ );
2318
2319   /* read the z light value */
2320   geo.light.z = u2f( *input++ );
2321
2322   return input;
2323}
2324
2325/* Command 0B: Transformation Matrix Write */
2326static UINT32 * geo_matrix_write( UINT32 opcode, UINT32 *input )
2327{
2328   UINT32   i;
2329
2330   (void)opcode;
2331
2332   /* read in the transformation matrix */
2333   for( i = 0; i < 12; i++ )
2334      geo.matrix[i] = u2f( *input++ );
2335
2336   return input;
2337}
2338
2339/* Command 0C: Parallel Transfer Vector Write */
2340static UINT32 * geo_translate_write( UINT32 opcode, UINT32 *input )
2341{
2342   UINT32   i;
2343
2344   (void)opcode;
2345
2346   /* read in the translation vector */
2347   for( i = 0; i < 3; i++ )
2348      geo.matrix[i+9] = u2f( *input++ );
2349
2350   return input;
2351}
2352
2353/* Command 0D: Geo Data Memory Push (undocumented, unsupported) */
2354static UINT32 * geo_data_mem_push( UINT32 opcode, UINT32 *input )
2355{
2356   UINT32   address, count, i;
2357
2358   /*
2359        This command pushes data stored in the Geometry DSP's RAM
2360        to the hardware 3D rasterizer. Since we don't emulate the
2361        DSP, we don't know what the RAM contents are.
2362
2363        Eventually, we could check for the address, and if it
2364        happens to point to a polygon ROM, we could potentially
2365        emulate it partially.
2366
2367        No games are known to use this command yet.
2368    */
2369
2370
2371   (void)opcode;
2372
2373   /* read in the address */
2374   address = *input++;
2375
2376   /* read in the count */
2377   count = *input++;
2378
2379   logerror( "SEGA GEO: Executing unsupported geo_data_mem_push (address = %08x, count = %08x)\n", address, count );
2380
2381   (void)i;
2382/*
2383    for( i = 0; i < count; i++ )
2384        model2_3d_push( 0 );
2385*/
2386
2387   return input;
2388}
2389
2390/* Command 0E: Geo Test */
2391static UINT32 * geo_test( UINT32 opcode, UINT32 *input )
2392{
2393   UINT32      data, blocks, address, count, checksum, i;
2394
2395   (void)opcode;
2396
2397   /* fifo test */
2398   data = 1;
2399
2400   for( i = 0; i < 32; i++ )
2401   {
2402      if ( *input++ != data )
10102403      {
1011         if (cmd2 != cmd1 || cmd3 != cmd1)
1012         {
1013            //mame_printf_debug("parse_display_list: CMD bits not matching: %08X at %08X\n", op, dlptr);
1014            //return;
1015            /*{
1016                    int i;
1017                    FILE *file = fopen("buffer2.bin", "wb");
1018                    for (i=0; i < 0x20000/4; i++)
1019                    {
1020                        fputc((model2_bufferram[i] >> 24) & 0xff, file);
1021                        fputc((model2_bufferram[i] >> 16) & 0xff, file);
1022                        fputc((model2_bufferram[i] >>  8) & 0xff, file);
1023                        fputc((model2_bufferram[i] >>  0) & 0xff, file);
1024                    }
1025                    fclose(file);
1026                }*/
2404         /* TODO: Set Red LED on */
2405         logerror( "SEGA GEO: FIFO Test failed\n" );
2406      }
10272407
1028            //fatalerror("parse_display_list: CMD bits not matching: %08X at %08X\n", op, dlptr*4);
1029         }
2408      data <<= 1;
2409   }
10302410
1031         switch (cmd1)
1032         {
1033            case 0x00:      // NOP
1034            {
1035               break;
1036            }
1037            case 0x01:      // Object Data
1038            {
1039               tex_point_addr   = model2_bufferram[dlptr+0] & 0xffffff;
1040               tex_hdr_addr   = model2_bufferram[dlptr+1] & 0xffffff;
1041               address         = model2_bufferram[dlptr+2];
1042               length         = model2_bufferram[dlptr+3];
2411   /* get the number of checksums we have to run */
2412   blocks = *input++;
10432413
1044               if ( tex_point_addr != 0 || tex_hdr_addr != 0 || address != 0 || length != 0 )
1045               {
1046                  draw_object(address, length, tex_point_addr, tex_hdr_addr);
1047               }
2414   for( i = 0; i < blocks; i++ )
2415   {
2416      UINT32   sum_even, sum_odd, j;
10482417
1049               dlptr += 4;
1050               break;
1051            }
1052            case 0x02:      // Direct Data
1053            {
1054               length = draw_direct_data(&model2_bufferram[dlptr]);
1055               dlptr += length;
1056               break;
1057            }
1058            case 0x03:      // Window Data
1059            {
1060               int x1 = (INT16)(model2_bufferram[dlptr+0] >> 16);
1061               int y1 = (INT16)(model2_bufferram[dlptr+0] >>  0);
1062               int x2 = (INT16)(model2_bufferram[dlptr+1] >> 16);
1063               int y2 = (INT16)(model2_bufferram[dlptr+1] >>  0);
2418      /* read in the address */
2419      address = (*input++) & 0x7FFFFF;
10642420
1065               window.x = x1;
1066               window.y = 0;
1067               window.width = x2 - x1;
1068               window.height = y2 - y1;
2421      /* read in the count */
2422      count = *input++;
10692423
1070               dlptr += 6;
1071               break;
1072            }
1073            case 0x04:      // Texture Data Write
1074            {
1075               address      = model2_bufferram[dlptr++];
1076               length      = model2_bufferram[dlptr++];
2424      /* read in the checksum */
2425      checksum = *input++;
10772426
1078               if ((address & 0x800000) == 0)
1079               {
1080                  fatalerror("Trying to write log data at texture data write");
1081               }
2427      /* reset the checksum counters */
2428      sum_even = 0;
2429      sum_odd = 0;
10822430
1083               address &= 0x7fffff;
2431      for( j = 0; j < count; j++ )
2432      {
2433         data = geo.polygon_rom[address++];
10842434
1085               for (i=0; i < length; i++)
1086               {
1087                  texture_ram[address] = model2_bufferram[dlptr++];
1088                  address++;
1089               }
1090               break;
1091            }
1092            case 0x05:      // Object Data Write
1093            {
1094               address      = model2_bufferram[dlptr++] & 0x7fff;
1095               length      = model2_bufferram[dlptr++] & 0xffff;
2435         address &= 0x7FFFFF;
10962436
1097               for (i=0; i < length; i++)
1098               {
1099                  polygon_ram[address] = model2_bufferram[dlptr++];
1100                  address++;
1101               }
1102               break;
1103            }
1104            case 0x06:      // Texture Parameter Write
1105            {
1106               address      = model2_bufferram[dlptr++];
1107               length      = model2_bufferram[dlptr++];
2437         sum_even += data >> 16;
2438         sum_even &= 0xFFFF;
11082439
1109               if (address > 0x1f)
1110               {
1111                  mame_printf_debug("texture_parameter_write: address = %08X\n", address);
1112                  break;
1113               }
2440         sum_odd += data & 0xFFFF;
2441         sum_odd &= 0xFFFF;
2442      }
11142443
1115               if (length > 0x20)
1116               {
1117                  mame_printf_debug("texture_parameter_write: length = %08X\n", length);
1118                  break;
1119               }
2444      sum_even += checksum >> 16;
2445      sum_even &= 0xFFFF;
11202446
1121               for (i=0; i < length; i++)
1122               {
1123                  UINT32 data = model2_bufferram[dlptr++];
1124                  texture_parameter[i].diffuse   = (data >>  0) & 0xff;
1125                  texture_parameter[i].ambient   = (data >>  8) & 0xff;
1126                  texture_parameter[i].reflection   = (data >> 16) & 0xff;
1127                  texture_parameter[i].c = u2f(model2_bufferram[dlptr++]);
1128               }
1129               break;
1130            }
1131            case 0x07:      // Operation Mode
1132            {
1133               geo_mode = model2_bufferram[dlptr];
1134               dlptr++;
1135               break;
1136            }
1137            case 0x08:      // Z-Sort Mode
1138            {
1139               dlptr++;
1140               break;
1141            }
1142            case 0x09:      // Focal Distance
1143            {
1144               focus_x = u2f(model2_bufferram[dlptr+0]);
1145               focus_y = u2f(model2_bufferram[dlptr+1]);
1146               dlptr += 2;
1147               break;
1148            }
1149            case 0x0a:      // Light Source Vector
1150            {
1151               float norm;
2447      sum_odd += checksum & 0xFFFF;
2448      sum_odd &= 0xFFFF;
11522449
1153               light_vector[0] = u2f(model2_bufferram[dlptr++]);
1154               light_vector[1] = u2f(model2_bufferram[dlptr++]);
1155               light_vector[2] = u2f(model2_bufferram[dlptr++]);
2450      if ( sum_even != 0 || sum_odd != 0 )
2451      {
2452         /* TODO: Set Green LED on */
2453         logerror( "SEGA GEO: Polygon ROM Test failed\n" );
2454      }
2455   }
11562456
1157               norm = sqrt( light_vector[0]*light_vector[0] + light_vector[1]*light_vector[1] + light_vector[2]*light_vector[2] );
1158               if ( norm )
1159               {
1160                  light_vector[0] /= norm;
1161                  light_vector[1] /= norm;
1162                  light_vector[2] /= norm;
1163               }
2457   return input;
2458}
11642459
1165               break;
1166            }
1167            case 0x0b:      // Matrix
1168            {
1169               matrix[ 0] = u2f(model2_bufferram[dlptr++]);
1170               matrix[ 1] = u2f(model2_bufferram[dlptr++]);
1171               matrix[ 2] = u2f(model2_bufferram[dlptr++]);
1172               matrix[ 3] = u2f(model2_bufferram[dlptr++]);
1173               matrix[ 4] = u2f(model2_bufferram[dlptr++]);
1174               matrix[ 5] = u2f(model2_bufferram[dlptr++]);
1175               matrix[ 6] = u2f(model2_bufferram[dlptr++]);
1176               matrix[ 7] = u2f(model2_bufferram[dlptr++]);
1177               matrix[ 8] = u2f(model2_bufferram[dlptr++]);
1178               matrix[ 9] = u2f(model2_bufferram[dlptr++]);
1179               matrix[10] = u2f(model2_bufferram[dlptr++]);
1180               matrix[11] = u2f(model2_bufferram[dlptr++]);
1181               break;
1182            }
1183            case 0x0c:      // Parallel Transfer Vector
1184            {
1185               matrix[ 9] = u2f(model2_bufferram[dlptr++]);
1186               matrix[10] = u2f(model2_bufferram[dlptr++]);
1187               matrix[11] = u2f(model2_bufferram[dlptr++]);
1188               break;
1189            }
1190            case 0x0e:      // TGP Test
1191            {
1192               dlptr += 32;
1193               length = model2_bufferram[dlptr++];
1194               dlptr += length;
1195               break;
1196            }
1197            case 0x0f:      // End
1198            {
1199               end = 1;
1200               break;
1201            }
1202            case 0x10:      // Dummy
1203            {
1204               dlptr++;
1205               break;
1206            }
1207            case 0x14:      // Log Data Write
1208            {
1209               dlptr++;
1210               length = model2_bufferram[dlptr++];
1211               dlptr += length;
1212               break;
1213            }
1214            case 0x16:      // LOD
1215            {
1216               dlptr++;
1217               break;
1218            }
1219            default:
1220            {
1221               /*
1222                    {
1223                        int i;
1224                        FILE *file = fopen("buffer2.bin", "wb");
1225                        for (i=0; i < 0x20000/4; i++)
1226                        {
1227                            fputc((model2_bufferram[i] >> 24) & 0xff, file);
1228                            fputc((model2_bufferram[i] >> 16) & 0xff, file);
1229                            fputc((model2_bufferram[i] >>  8) & 0xff, file);
1230                            fputc((model2_bufferram[i] >>  0) & 0xff, file);
1231                        }
1232                        fclose(file);
1233                    }
1234                    fatalerror("parse_display_list: unknown command %02X (%08X) at %08X\n", cmd1, op, dlptr*4);
1235                    */
1236            }
1237         }
2460/* Command 0F: End */
2461static UINT32 * geo_end( UINT32 opcode, UINT32 *input )
2462{
2463   (void)opcode;
2464
2465   /* signal the end of this data block the rasterizer */
2466   model2_3d_push( 0xFF000000 );
2467
2468   /* signal end by returning NULL */
2469   return NULL;
2470}
2471
2472/* Command 10: Dummy */
2473static UINT32 * geo_dummy( UINT32 opcode, UINT32 *input )
2474{
2475   UINT32   data;
2476   (void)opcode;
2477
2478   /* do the dummy read cycle */
2479   data = *input++;
2480
2481   return input;
2482}
2483
2484/* Command 14: Log Data Write */
2485static UINT32 * geo_log_data( UINT32 opcode, UINT32 *input )
2486{
2487   UINT32   i, count;
2488
2489   /* start by pushing the opcode */
2490   model2_3d_push( opcode >> 23 );
2491
2492   /* push the starting address/dsp id */
2493   model2_3d_push( *input++ );
2494
2495   /* get the count */
2496   count = *input++;
2497
2498   /* push the count */
2499   model2_3d_push( count << 2 );
2500
2501   /* loop and send the data */
2502   for( i = 0; i < count; i++ )
2503   {
2504      UINT32   data = *input++;
2505
2506      model2_3d_push( data & 0xff );
2507      model2_3d_push( (data >> 8) & 0xff );
2508      model2_3d_push( (data >> 16) & 0xff );
2509      model2_3d_push( (data >> 24) & 0xff );
2510   }
2511
2512   return input;
2513}
2514
2515/* Command 16: LOD */
2516static UINT32 * geo_lod( UINT32 opcode, UINT32 *input )
2517{
2518   (void)opcode;
2519
2520   /* read in the LOD */
2521   geo.lod = u2f(*input++);
2522
2523   return input;
2524}
2525
2526/* Command 1D: Code Upload  (undocumented, unsupported) */
2527static UINT32 * geo_code_upload( UINT32 opcode, UINT32 *input )
2528{
2529   UINT32   flags, count, i;
2530
2531   /*
2532        This command uploads code to program memory and
2533        optionally runs it. Probably used for debugging.
2534
2535        No games are known to use this command yet.
2536    */
2537
2538   logerror( "SEGA GEO: Uploading debug code (unimplemented)\n" );
2539
2540   (void)opcode;
2541
2542   /* read in the flags */
2543   flags = *input++;
2544
2545   /* read in the count */
2546   count = *input++;
2547
2548   for( i = 0; i < count; i++ )
2549   {
2550      UINT64   code;
2551
2552      /* read the top part of the opcode */
2553      code = *input++;
2554
2555      code <<= 32;
2556
2557      /* the bottom part comes in two pieces */
2558      code |= *input++;
2559      code |= (*input++) << 16;
2560   }
2561
2562   /*
2563        Bit 10 of flags indicate wether to run iummediately after upload
2564    */
2565
2566/*
2567    if ( flags & 0x400 )
2568        code_jump();
2569*/
2570
2571   return input;
2572}
2573
2574/* Command 1E: Code Jump (undocumented, unsupported) */
2575static UINT32 * geo_code_jump( UINT32 opcode, UINT32 *input )
2576{
2577   UINT32   address;
2578
2579   /*
2580        This command jumps to a specified address in program
2581        memory. Code can be uploaded with function 1D.
2582        Probably used for debugging.
2583
2584        No games are known to use this command yet.
2585    */
2586
2587   logerror( "SEGA GEO: Jumping to debug code (unimplemented)\n" );
2588
2589   (void)opcode;
2590
2591   address = *input++ & 0x3FF;
2592
2593/*
2594    code_jump( address )
2595*/
2596   return input;
2597}
2598
2599static UINT32 * geo_process_command( UINT32 opcode, UINT32 *input )
2600{
2601   switch( opcode >> 23 )
2602   {
2603      case 0x00: input = geo_nop( opcode, input );            break;
2604      case 0x01: input = geo_object_data( opcode, input );      break;
2605      case 0x02: input = geo_direct_data( opcode, input );      break;
2606      case 0x03: input = geo_window_data( opcode, input );      break;
2607      case 0x04: input = geo_texture_data( opcode, input );      break;
2608      case 0x05: input = geo_polygon_data( opcode, input );      break;
2609      case 0x06: input = geo_texture_parameters( opcode, input );   break;
2610      case 0x07: input = geo_mode( opcode, input );            break;
2611      case 0x08: input = geo_zsort_mode( opcode, input );         break;
2612      case 0x09: input = geo_focal_distance( opcode, input );      break;
2613      case 0x0A: input = geo_light_source( opcode, input );      break;
2614      case 0x0B: input = geo_matrix_write( opcode, input );      break;
2615      case 0x0C: input = geo_translate_write( opcode, input );   break;
2616      case 0x0D: input = geo_data_mem_push( opcode, input );      break;
2617      case 0x0E: input = geo_test( opcode, input );            break;
2618      case 0x0F: input = geo_end( opcode, input );            break;
2619      case 0x10: input = geo_dummy( opcode, input );            break;
2620      case 0x11: input = geo_object_data( opcode, input );      break;
2621      case 0x12: input = geo_direct_data( opcode, input );      break;
2622      case 0x13: input = geo_window_data( opcode, input );      break;
2623      case 0x14: input = geo_log_data( opcode, input );         break;
2624      case 0x15: input = geo_polygon_data( opcode, input );      break;
2625      case 0x16: input = geo_lod( opcode, input );            break;
2626      case 0x17: input = geo_mode( opcode, input );            break;
2627      case 0x18: input = geo_zsort_mode( opcode, input );         break;
2628      case 0x19: input = geo_focal_distance( opcode, input );      break;
2629      case 0x1A: input = geo_light_source( opcode, input );      break;
2630      case 0x1B: input = geo_matrix_write( opcode, input );      break;
2631      case 0x1C: input = geo_translate_write( opcode, input );   break;
2632      case 0x1D: input = geo_code_upload( opcode, input );      break;
2633      case 0x1E: input = geo_code_jump( opcode, input );         break;
2634      case 0x1F: input = geo_end( opcode, input );            break;
2635   }
2636
2637   return input;
2638}
2639
2640static void geo_parse( void )
2641{
2642   UINT32   address = (geo_read_start_address/4);
2643   UINT32 *input = &model2_bufferram[address];
2644   UINT32   opcode;
2645
2646   while( input != NULL && (input - model2_bufferram) < 0x20000  )
2647   {
2648      /* read in the opcode */
2649      opcode = *input++;
2650
2651      /* if it's a jump opcode, do the jump */
2652      if ( opcode & 0x80000000 )
2653      {
2654         /* get the address */
2655         address = (opcode & 0x7FFFF) / 4;
2656
2657         /* update our pointer */
2658         input = &model2_bufferram[address];
2659
2660         /* go again */
2661         continue;
12382662      }
1239   };
2663
2664      /* process it */
2665      input = geo_process_command( opcode, input );
2666   }
12402667}
2668
2669/***********************************************************************************************/
2670
2671static bitmap_t *sys24_bitmap = NULL;
2672
2673static void model2_exit(running_machine *machine)
2674{
2675   if ( sys24_bitmap != NULL )
2676   {
2677      bitmap_free( sys24_bitmap );
2678      sys24_bitmap = NULL;
2679   }
2680}
2681
2682VIDEO_START(model2)
2683{
2684   int   width = machine->screen[0].visarea.max_x - machine->screen[0].visarea.min_x;
2685   int   height = machine->screen[0].visarea.max_y - machine->screen[0].visarea.min_y;
2686
2687   sys24_tile_vh_start(machine, 0x3fff);
2688   sys24_bitmap = bitmap_alloc(width, height+4, BITMAP_FORMAT_INDEXED16);
2689   add_exit_callback(machine, model2_exit);
2690
2691   /* initialize the geometry engine */
2692   geo_init( (UINT32*)memory_region(REGION_USER2) );
2693
2694   /* initialize the hardware rasterizer */
2695   model2_3d_init( (UINT16*)memory_region(REGION_USER3) );
2696}
2697
2698static void convert_bitmap( running_machine *machine, bitmap_t *dst, bitmap_t *src, const rectangle *rect )
2699{
2700   int   x, y;
2701
2702   for( y = rect->min_y; y < rect->max_y; y++ )
2703   {
2704      UINT32 *d = BITMAP_ADDR32( dst, y, 0 );
2705      UINT16 *s = BITMAP_ADDR16( src, y, 0 );
2706
2707      for( x = rect->min_x; x < rect->max_x; x++ )
2708      {
2709         if ( s[x] )
2710            d[x] = machine->pens[s[x]];
2711      }
2712   }
2713}
2714
2715VIDEO_UPDATE(model2)
2716{
2717   sys24_tile_update(machine);
2718   fillbitmap(bitmap, machine->pens[0], &machine->screen[0].visarea);
2719   fillbitmap(sys24_bitmap, 0, &machine->screen[0].visarea);
2720
2721   sys24_tile_draw(machine, sys24_bitmap, cliprect, 7, 0, 0);
2722   sys24_tile_draw(machine, sys24_bitmap, cliprect, 6, 0, 0);
2723   sys24_tile_draw(machine, sys24_bitmap, cliprect, 5, 0, 0);
2724   sys24_tile_draw(machine, sys24_bitmap, cliprect, 4, 0, 0);
2725
2726   convert_bitmap(machine, bitmap, sys24_bitmap, cliprect);
2727
2728   /* tell the rasterizer we're starting a frame */
2729   model2_3d_frame_start();
2730
2731   /* let the geometry engine do it's thing */
2732   geo_parse();
2733
2734   /* have the rasterizer output the frame */
2735   model2_3d_frame_end( bitmap, cliprect );
2736
2737   fillbitmap(sys24_bitmap, 0, &machine->screen[0].visarea);
2738   sys24_tile_draw(machine, sys24_bitmap, cliprect, 3, 0, 0);
2739   sys24_tile_draw(machine, sys24_bitmap, cliprect, 2, 0, 0);
2740   sys24_tile_draw(machine, sys24_bitmap, cliprect, 1, 0, 0);
2741   sys24_tile_draw(machine, sys24_bitmap, cliprect, 0, 0, 0);
2742
2743   convert_bitmap(machine, bitmap, sys24_bitmap, cliprect);
2744
2745   return 0;
2746}
2747
src/mame/video/st0016.c
r1070r1071
659659         {
660660            if(srcline[x])
661661            {
662               rgb_t color=palette_get_color(Machine, srcline[x]);
662               rgb_t color=palette_get_color(machine, srcline[x]);
663663               PLOT_PIXEL_RGB(x,y,RGB_RED(color),RGB_GREEN(color),RGB_BLUE(color));
664664            }
665665         }
src/mame/video/vooddefs.h
r1070r1071
2424/* maximum number of TMUs */
2525#define MAX_TMU               2
2626
27/* number of render groups for parallelism */
28#define RENDER_GROUPS         2
29
2730/* accumulate operations less than this number of clocks */
2831#define ACCUMULATE_THRESHOLD   0
2932
r1070r1071
13321335
13331336typedef struct _voodoo_state voodoo_state;
13341337
1338typedef union _voodoo_reg voodoo_reg;
13351339union _voodoo_reg
13361340{
13371341   INT32      i;
13381342   UINT32      u;
13391343   float      f;
13401344};
1341typedef union _voodoo_reg voodoo_reg;
13421345
13431346
1347typedef struct _fifo_state fifo_state;
13441348struct _fifo_state
13451349{
13461350   UINT32 *   base;               /* base of the FIFO */
r1070r1071
13481352   INT32      in;                  /* input pointer */
13491353   INT32      out;               /* output pointer */
13501354};
1351typedef struct _fifo_state fifo_state;
13521355
13531356
1357typedef struct _cmdfifo_info cmdfifo_info;
13541358struct _cmdfifo_info
13551359{
13561360   UINT8      enable;               /* enabled? */
r1070r1071
13631367   UINT32      depth;               /* current depth */
13641368   UINT32      holes;               /* number of holes */
13651369};
1366typedef struct _cmdfifo_info cmdfifo_info;
13671370
13681371
1372typedef struct _pci_state pci_state;
13691373struct _pci_state
13701374{
13711375   fifo_state   fifo;               /* PCI FIFO */
r1070r1071
13771381   mame_time   op_end_time;         /* time when the pending operation ends */
13781382   mame_timer *continue_timer;         /* timer to use to continue processing */
13791383};
1380typedef struct _pci_state pci_state;
13811384
13821385
1386typedef struct _ncc_table ncc_table;
13831387struct _ncc_table
13841388{
13851389   UINT8      dirty;               /* is the texel lookup dirty? */
r1070r1071
13911395   rgb_t *      palette;            /* pointer to associated RGB palette */
13921396   rgb_t *      palettea;            /* pointer to associated ARGB palette */
13931397};
1394typedef struct _ncc_table ncc_table;
13951398
13961399
1400typedef struct _tmu_state tmu_state;
13971401struct _tmu_state
13981402{
13991403   UINT8 *      ram;               /* pointer to our RAM */
r1070r1071
14331437   rgb_t      palette[256];         /* palette lookup table */
14341438   rgb_t      palettea[256];         /* palette+alpha lookup table */
14351439};
1436typedef struct _tmu_state tmu_state;
14371440
14381441
1442typedef struct _tmu_shared_state tmu_shared_state;
14391443struct _tmu_shared_state
14401444{
14411445   rgb_t      rgb332[256];         /* RGB 3-3-2 lookup table */
r1070r1071
14471451   rgb_t      argb1555[65536];      /* ARGB 1-5-5-5 lookup table */
14481452   rgb_t      argb4444[65536];      /* ARGB 4-4-4-4 lookup table */
14491453};
1450typedef struct _tmu_shared_state tmu_shared_state;
14511454
14521455
1456typedef struct _setup_vertex setup_vertex;
14531457struct _setup_vertex
14541458{
14551459   float      x, y;               /* X, Y coordinates */
r1070r1071
14581462   float      w0, s0, t0;            /* W, S, T for TMU 0 */
14591463   float      w1, s1, t1;            /* W, S, T for TMU 1 */
14601464};
1461typedef struct _setup_vertex setup_vertex;
14621465
14631466
1467typedef struct _fbi_state fbi_state;
14641468struct _fbi_state
14651469{
14661470   void *      ram;               /* pointer to frame buffer RAM */
r1070r1071
15271531   UINT8      sverts;               /* number of vertices ready */
15281532   setup_vertex svert[3];            /* 3 setup vertices */
15291533};
1530typedef struct _fbi_state fbi_state;
15311534
15321535
1536typedef struct _dac_state dac_state;
15331537struct _dac_state
15341538{
15351539   UINT8      reg[8];               /* 8 registers */
15361540   UINT8      read_result;         /* pending read result */
15371541};
1538typedef struct _dac_state dac_state;
15391542
15401543
1544typedef struct _voodoo_stats voodoo_stats;
15411545struct _voodoo_stats
15421546{
15431547   char      buffer[1024];         /* string */
r1070r1071
15611565   INT32      texture_mode[16];      /* 16 different texture modes */
15621566   UINT8      render_override;      /* render override */
15631567};
1564typedef struct _voodoo_stats voodoo_stats;
15651568
15661569
1570typedef void (*raster_callback)(voodoo_state *, INT32);
1571
1572
1573typedef struct _raster_info raster_info;
15671574struct _raster_info
15681575{
15691576   struct _raster_info *next;         /* pointer to next entry with the same hash */
1570   void      (*callback)(voodoo_state *, UINT16 *); /* callback pointer */
1577   raster_callback callback;          /* callback pointer */
15711578   UINT8      is_generic;            /* TRUE if this is one of the generic rasterizers */
1579   UINT8      display;            /* display index */
15721580   UINT32      hits;               /* how many hits (pixels) we've used this for */
15731581   UINT32      polys;               /* how many polys we've used this for */
15741582   UINT32      eff_color_path;         /* effective fbzColorPath value */
r1070r1071
15781586   UINT32      eff_tex_mode_0;         /* effective textureMode value for TMU #0 */
15791587   UINT32      eff_tex_mode_1;         /* effective textureMode value for TMU #1 */
15801588};
1581typedef struct _raster_info raster_info;
15821589
15831590
1591typedef struct _work_info work_info;
1592struct _work_info
1593{
1594   voodoo_state *state;            /* pointer to the state object */
1595   osd_work_queue *queue;            /* work queue for offloading rasterization */
1596
1597   raster_callback callback;         /* callback to handle a scanline's worth of work */
1598   UINT16 *   drawbuf;            /* pointer to render buffer */
1599
1600   volatile INT32 curscanline;         /* current scanline, shared by all helpers */
1601   INT32      startscanline;         /* starting scanline */
1602   INT32      endscanline;         /* ending scanline */
1603
1604   INT32      dxdy_minmid;         /* dx/dy between the top and middle points */
1605   INT32      dxdy_minmax;         /* dx/dy between the top and bottom points */
1606   INT32      dxdy_midmax;         /* dx/dy between the middle and bottom points */
1607   INT32       minx, miny;            /* x,y of the top point */
1608   INT32      midx, midy;            /* x,y of the middle point */
1609   INT32      maxx, maxy;            /* x,y of the bottom point */
1610
1611   UINT16       dither[16];            /* dither matrix, for fastfill */
1612
1613   INT32       start_pixels_in;      /* starting fbiPixelsIn value */
1614   INT32       start_pixels_out;      /* starting fbiPixelsOut value */
1615   INT32       start_chroma_fail;      /* starting fbiChromaFail value */
1616   INT32       start_zfunc_fail;      /* starting fbiZfuncFail value */
1617   INT32       start_afunc_fail;      /* starting fbiAfuncFail value */
1618   raster_info *info;               /* pointer to rasterizer information */
1619
1620   struct
1621   {
1622      INT32   startx, stopx;         /* starting/ending X points for each scanline */
1623   } extent[4097];
1624};
1625
1626
1627typedef struct _banshee_info banshee_info;
15841628struct _banshee_info
15851629{
15861630   UINT32      io[0x40];            /* I/O registers */
r1070r1071
15921636   UINT8      att[0x15];            /* VGA attribute registers */
15931637   UINT8      attff;               /* VGA attribute flip-flop */
15941638};
1595typedef struct _banshee_info banshee_info;
15961639
15971640
1641/* typedef struct _voodoo_state voodoo_state; -- declared above */
15981642struct _voodoo_state
15991643{
16001644   UINT8      index;               /* index of board */
r1070r1071
16191663   tmu_shared_state tmushare;         /* TMU shared state */
16201664   banshee_info banshee;            /* Banshee state */
16211665
1666   work_info    work;               /* work queue management */
1667
16221668   voodoo_stats stats;               /* internal statistics */
16231669
16241670   offs_t      last_status_pc;         /* PC of last status read (for logging) */
r1070r1071
16281674   raster_info   rasterizer[MAX_RASTERIZERS]; /* array of rasterizers */
16291675   raster_info *raster_hash[RASTER_HASH_SIZE]; /* hash table of rasterizers */
16301676};
1631/* typedef struct _voodoo_state voodoo_state; -- declared above */
16321677
16331678
16341679
r1070r1071
21092154      {                                                      \
21102155         if ((((COLOR) ^ (VV)->reg[chromaKey].u) & 0xffffff) == 0)         \
21112156         {                                                   \
2112            (VV)->reg[fbiChromaFail].u++;                           \
2157            chromafail++;                                       \
21132158            goto skipdrawdepth;                                    \
21142159         }                                                   \
21152160      }                                                      \
r1070r1071
21492194         {                                                   \
21502195            if (results != 0)                                    \
21512196            {                                                \
2152               (VV)->reg[fbiChromaFail].u++;                        \
2197               chromafail++;                                    \
21532198               goto skipdrawdepth;                                 \
21542199            }                                                \
21552200         }                                                   \
r1070r1071
21572202         {                                                   \
21582203            if (results == 7)                                    \
21592204            {                                                \
2160               (VV)->reg[fbiChromaFail].u++;                        \
2205               chromafail++;                                    \
21612206               goto skipdrawdepth;                                 \
21622207            }                                                \
21632208         }                                                   \
r1070r1071
21812226   {                                                         \
21822227      if (((AA) & 1) == 0)                                       \
21832228      {                                                      \
2184         (VV)->reg[fbiAfuncFail].u++;                              \
2229         afail++;                                             \
21852230         goto skipdrawdepth;                                       \
21862231      }                                                      \
21872232   }                                                         \
r1070r1071
22042249      switch (ALPHAMODE_ALPHAFUNCTION(ALPHAMODE))                        \
22052250      {                                                      \
22062251         case 0:      /* alphaOP = never */                           \
2207            (VV)->reg[fbiAfuncFail].u++;                           \
2252            afail++;                                          \
22082253            goto skipdrawdepth;                                    \
22092254                                                            \
22102255         case 1:      /* alphaOP = less than */                        \
22112256            if ((AA) >= ALPHAMODE_ALPHAREF(ALPHAMODE))                  \
22122257            {                                                \
2213               (VV)->reg[fbiAfuncFail].u++;                        \
2258               afail++;                                       \
22142259               goto skipdrawdepth;                                 \
22152260            }                                                \
22162261            break;                                             \
r1070r1071
22182263         case 2:      /* alphaOP = equal */                           \
22192264            if ((AA) != ALPHAMODE_ALPHAREF(ALPHAMODE))                  \
22202265            {                                                \
2221               (VV)->reg[fbiAfuncFail].u++;                        \
2266               afail++;                                       \
22222267               goto skipdrawdepth;                                 \
22232268            }                                                \
22242269            break;                                             \
r1070r1071
22262271         case 3:      /* alphaOP = less than or equal */                  \
22272272            if ((AA) > ALPHAMODE_ALPHAREF(ALPHAMODE))                  \
22282273            {                                                \
2229               (VV)->reg[fbiAfuncFail].u++;                        \
2274               afail++;                                       \
22302275               goto skipdrawdepth;                                 \
22312276            }                                                \
22322277            break;                                             \
r1070r1071
22342279         case 4:      /* alphaOP = greater than */                     \
22352280            if ((AA) <= ALPHAMODE_ALPHAREF(ALPHAMODE))                  \
22362281            {                                                \
2237               (VV)->reg[fbiAfuncFail].u++;                        \
2282               afail++;                                       \
22382283               goto skipdrawdepth;                                 \
22392284            }                                                \
22402285            break;                                             \
r1070r1071
22422287         case 5:      /* alphaOP = not equal */                        \
22432288            if ((AA) == ALPHAMODE_ALPHAREF(ALPHAMODE))                  \
22442289            {                                                \
2245               (VV)->reg[fbiAfuncFail].u++;                        \
2290               afail++;                                       \
22462291               goto skipdrawdepth;                                 \
22472292            }                                                \
22482293            break;                                             \
r1070r1071
22502295         case 6:      /* alphaOP = greater than or equal */               \
22512296            if ((AA) < ALPHAMODE_ALPHAREF(ALPHAMODE))                  \
22522297            {                                                \
2253               (VV)->reg[fbiAfuncFail].u++;                        \
2298               afail++;                                       \
22542299               goto skipdrawdepth;                                 \
22552300            }                                                \
22562301            break;                                             \
r1070r1071
24582503      /* non-constant fog comes from several sources */                  \
24592504      else                                                   \
24602505      {                                                      \
2461         INT32 fogblend = 0;                                          \
2506         INT32 fogblend = 0;                                       \
24622507                                                            \
24632508         /* if fog_add is zero, we start with the fog color */            \
24642509         if (FOGMODE_FOG_ADD(FOGMODE) == 0)                           \
r1070r1071
29262971   INT32 prefogr, prefogg, prefogb;                                 \
29272972   INT32 r, g, b, a;                                             \
29282973                                                            \
2929   (VV)->reg[fbiPixelsIn].u++;                                       \
2974   pixin++;                                                   \
29302975                                                            \
29312976   /* apply clipping */                                          \
29322977   if (FBZMODE_ENABLE_CLIPPING(FBZMODE))                              \
r1070r1071
30303075      switch (FBZMODE_DEPTH_FUNCTION(FBZMODE))                        \
30313076      {                                                      \
30323077         case 0:      /* depthOP = never */                           \
3033            (VV)->reg[fbiZfuncFail].u++;                           \
3078            zfail++;                                          \
30343079            goto skipdrawdepth;                                    \
30353080                                                            \
30363081         case 1:      /* depthOP = less than */                        \
30373082            if (depthsource >= depth[XX])                           \
30383083            {                                                \
3039               (VV)->reg[fbiZfuncFail].u++;                        \
3084               zfail++;                                       \
30403085               goto skipdrawdepth;                                 \
30413086            }                                                \
30423087            break;                                             \
r1070r1071
30443089         case 2:      /* depthOP = equal */                           \
30453090            if (depthsource != depth[XX])                           \
30463091            {                                                \
3047               (VV)->reg[fbiZfuncFail].u++;                        \
3092               zfail++;                                       \
30483093               goto skipdrawdepth;                                 \
30493094            }                                                \
30503095            break;                                             \
r1070r1071
30523097         case 3:      /* depthOP = less than or equal */                  \
30533098            if (depthsource > depth[XX])                           \
30543099            {                                                \
3055               (VV)->reg[fbiZfuncFail].u++;                        \
3100               zfail++;                                       \
30563101               goto skipdrawdepth;                                 \
30573102            }                                                \
30583103            break;                                             \
r1070r1071
30603105         case 4:      /* depthOP = greater than */                     \
30613106            if (depthsource <= depth[XX])                           \
30623107            {                                                \
3063               (VV)->reg[fbiZfuncFail].u++;                        \
3108               zfail++;                                       \
30643109               goto skipdrawdepth;                                 \
30653110            }                                                \
30663111            break;                                             \
r1070r1071
30683113         case 5:      /* depthOP = not equal */                        \
30693114            if (depthsource == depth[XX])                           \
30703115            {                                                \
3071               (VV)->reg[fbiZfuncFail].u++;                        \
3116               zfail++;                                       \
30723117               goto skipdrawdepth;                                 \
30733118            }                                                \
30743119            break;                                             \
r1070r1071
30763121         case 6:      /* depthOP = greater than or equal */               \
30773122            if (depthsource < depth[XX])                           \
30783123            {                                                \
3079               (VV)->reg[fbiZfuncFail].u++;                        \
3124               zfail++;                                       \
30803125               goto skipdrawdepth;                                 \
30813126            }                                                \
30823127            break;                                             \
r1070r1071
31203165   }                                                         \
31213166                                                            \
31223167   /* track pixel writes to the frame buffer regardless of mask */            \
3123   (VV)->reg[fbiPixelsOut].u++;                                    \
3168   pixout++;                                                   \
31243169                                                            \
31253170skipdrawdepth:                                                   \
31263171   ;                                                         \
r1070r1071
34173462
34183463/*************************************
34193464 *
3465 *  Statistics manipulation
3466 *
3467 *************************************/
3468
3469#define DECLARE_STATISTICS                                          \
3470   INT32 pixin = 0, pixout = 0, afail = 0, zfail = 0, chromafail = 0         \
3471
3472#define UPDATE_STATISTICS(VV)                                       \
3473do                                                            \
3474{                                                            \
3475   /* update statistics atomically */                                 \
3476   if (pixin != 0)                                                \
3477      osd_sync_add((INT32 volatile *)&(VV)->reg[fbiPixelsIn].u, pixin);      \
3478   if (pixout != 0)                                             \
3479      osd_sync_add((INT32 volatile *)&(VV)->reg[fbiPixelsOut].u, pixout);      \
3480   if (afail != 0)                                                \
3481      osd_sync_add((INT32 volatile *)&(VV)->reg[fbiAfuncFail].u, afail);      \
3482   if (zfail != 0)                                                \
3483      osd_sync_add((INT32 volatile *)&(VV)->reg[fbiZfuncFail].u, zfail);      \
3484   if (chromafail != 0)                                          \
3485      osd_sync_add((INT32 volatile *)&(VV)->reg[fbiChromaFail].u, chromafail);\
3486}                                                            \
3487while (0)
3488
3489
3490
3491/*************************************
3492 *
34203493 *  Rasterizer generator macro
34213494 *
34223495 *************************************/
r1070r1071
34253498
34263499#define RASTERIZER(name, TMUS, FBZCOLORPATH, FBZMODE, ALPHAMODE, FOGMODE, TEXMODE0, TEXMODE1) \
34273500                                                            \
3428static void raster_##name(voodoo_state *v, UINT16 *drawbuf)                  \
3501static void raster_##name(voodoo_state *v, INT32 y)                      \
34293502{                                                            \
3430   INT32 dxdy_minmid, dxdy_minmax, dxdy_midmax;                        \
3431   INT32 minx, miny, midx, midy, maxx, maxy;                           \
3432   INT32 starty, stopy;                                          \
3433   INT32 x, y;                                                   \
3503   DECLARE_STATISTICS;                                             \
3504   INT32 iterr, iterg, iterb, itera;                                 \
3505   INT32 iterz;                                                \
3506   INT64 iterw, iterw0 = 0, iterw1 = 0;                              \
3507   INT64 iters0 = 0, iters1 = 0;                                    \
3508   INT64 itert0 = 0, itert1 = 0;                                    \
3509   INT32 startx, stopx;                                          \
3510   UINT16 *depth;                                                \
3511   UINT16 *dest;                                                \
3512   INT32 dx, dy;                                                \
3513   INT32 scry;                                                   \
3514   INT32 x;                                                   \
34343515                                                            \
3435   /* sort the vertices */                                          \
3436   if (v->fbi.ay <= v->fbi.by)                                       \
3516   /* extract X extents */                                          \
3517   startx = v->work.extent[y - v->work.startscanline].startx;               \
3518   stopx = v->work.extent[y - v->work.startscanline].stopx;               \
3519                                                            \
3520   /* determine the screen Y */                                    \
3521   scry = y;                                                   \
3522   if (FBZMODE_Y_ORIGIN(FBZMODE))                                    \
3523      scry = (v->fbi.yorigin - y) & 0x3ff;                           \
3524                                                            \
3525   /* get pointers to the target buffer and depth buffer */               \
3526   dest = v->work.drawbuf + scry * v->fbi.rowpixels;                     \
3527   depth = v->fbi.aux ? (v->fbi.aux + scry * v->fbi.rowpixels) : NULL;         \
3528                                                            \
3529   /* compute the starting parameters */                              \
3530   dx = startx - (v->fbi.ax >> 4);                                    \
3531   dy = y - (v->fbi.ay >> 4);                                       \
3532   iterr = v->fbi.startr + dy * v->fbi.drdy + dx * v->fbi.drdx;            \
3533   iterg = v->fbi.startg + dy * v->fbi.dgdy + dx * v->fbi.dgdx;            \
3534   iterb = v->fbi.startb + dy * v->fbi.dbdy + dx * v->fbi.dbdx;            \
3535   itera = v->fbi.starta + dy * v->fbi.dady + dx * v->fbi.dadx;            \
3536   iterz = v->fbi.startz + dy * v->fbi.dzdy + dx * v->fbi.dzdx;            \
3537   iterw = v->fbi.startw + dy * v->fbi.dwdy + dx * v->fbi.dwdx;            \
3538   if (TMUS >= 1)                                                \
34373539   {                                                         \
3438      if (v->fbi.by <= v->fbi.cy)                                    \
3439      {                                                      \
3440         minx = v->fbi.ax;   miny = v->fbi.ay;                        \
3441         midx = v->fbi.bx;   midy = v->fbi.by;                        \
3442         maxx = v->fbi.cx;   maxy = v->fbi.cy;                        \
3443      }                                                      \
3444      else if (v->fbi.ay <= v->fbi.cy)                              \
3445      {                                                      \
3446         minx = v->fbi.ax;   miny = v->fbi.ay;                        \
3447         midx = v->fbi.cx;   midy = v->fbi.cy;                        \
3448         maxx = v->fbi.bx;   maxy = v->fbi.by;                        \
3449      }                                                      \
3450      else                                                   \
3451      {                                                      \
3452         minx = v->fbi.cx;   miny = v->fbi.cy;                        \
3453         midx = v->fbi.ax;   midy = v->fbi.ay;                        \
3454         maxx = v->fbi.bx;   maxy = v->fbi.by;                        \
3455      }                                                      \
3540      iterw0 = v->tmu[0].startw + dy * v->tmu[0].dwdy +                  \
3541                           dx * v->tmu[0].dwdx;                  \
3542      iters0 = v->tmu[0].starts + dy * v->tmu[0].dsdy +                   \
3543                           dx * v->tmu[0].dsdx;                  \
3544      itert0 = v->tmu[0].startt + dy * v->tmu[0].dtdy +                   \
3545                           dx * v->tmu[0].dtdx;                  \
34563546   }                                                         \
3457   else                                                      \
3547   if (TMUS >= 2)                                                \
34583548   {                                                         \
3459      if (v->fbi.ay <= v->fbi.cy)                                    \
3460      {                                                      \
3461         minx = v->fbi.bx;   miny = v->fbi.by;                        \
3462         midx = v->fbi.ax;   midy = v->fbi.ay;                        \
3463         maxx = v->fbi.cx;   maxy = v->fbi.cy;                        \
3464      }                                                      \
3465      else if (v->fbi.by <= v->fbi.cy)                              \
3466      {                                                      \
3467         minx = v->fbi.bx;   miny = v->fbi.by;                        \
3468         midx = v->fbi.cx;   midy = v->fbi.cy;                        \
3469         maxx = v->fbi.ax;   maxy = v->fbi.ay;                        \
3470      }                                                      \
3471      else                                                   \
3472      {                                                      \
3473         minx = v->fbi.cx;   miny = v->fbi.cy;                        \
3474         midx = v->fbi.bx;   midy = v->fbi.by;                        \
3475         maxx = v->fbi.ax;   maxy = v->fbi.ay;                        \
3476      }                                                      \
3549      iterw1 = v->tmu[1].startw + dy * v->tmu[1].dwdy +                   \
3550                           dx * v->tmu[1].dwdx;                  \
3551      iters1 = v->tmu[1].starts + dy * v->tmu[1].dsdy +                   \
3552                           dx * v->tmu[1].dsdx;                  \
3553      itert1 = v->tmu[1].startt + dy * v->tmu[1].dtdy +                   \
3554                           dx * v->tmu[1].dtdx;                  \
34773555   }                                                         \
34783556                                                            \
3479   /* compute the slopes as 16.16 numbers */                           \
3480   dxdy_minmid = (miny == midy) ? 0 : ((midx - minx) << 16) / (midy - miny);   \
3481   dxdy_minmax = (miny == maxy) ? 0 : ((maxx - minx) << 16) / (maxy - miny);   \
3482   dxdy_midmax = (midy == maxy) ? 0 : ((maxx - midx) << 16) / (maxy - midy);   \
3483                                                            \
3484   /* clamp to full pixels */                                       \
3485   starty = (miny + 7) >> 4;                                       \
3486   stopy = (maxy + 7) >> 4;                                       \
3487                                                            \
3488   /* loop in Y */                                                \
3489   for (y = starty; y < stopy; y++)                                 \
3557   /* loop in X */                                                \
3558   for (x = startx; x < stopx; x++)                                 \
34903559   {                                                         \
3491      INT32 iterr, iterg, iterb, itera;                              \
3492      INT32 iterz;                                             \
3493      INT64 iterw, iterw0 = 0, iterw1 = 0;                           \
3494      INT64 iters0 = 0, iters1 = 0;                                 \
3495      INT64 itert0 = 0, itert1 = 0;                                 \
3496      INT32 startx, stopx;                                       \
3497      INT32 fully;                                             \
3498      UINT16 *depth;                                             \
3499      UINT16 *dest;                                             \
3500      INT32 dx, dy;                                             \
3501      INT32 scry;                                                \
3560      rgb_t iterargb = 0;                                          \
3561      rgb_t texel = 0;                                          \
35023562                                                            \
3503      /* compute X endpoints */                                    \
3504      fully = (y << 4) + 8;                                       \
3505      startx = minx + (((fully - miny) * dxdy_minmax) >> 16);               \
3506      if (fully < midy)                                          \
3507         stopx = minx + (((fully - miny) * dxdy_minmid) >> 16);            \
3508      else                                                   \
3509         stopx = midx + (((fully - midy) * dxdy_midmax) >> 16);            \
3563      /* pixel pipeline part 1 handles depth testing and stippling */         \
3564      PIXEL_PIPELINE_BEGIN(v, x, y, scry, FBZCOLORPATH, FBZMODE,             \
3565                        iterz, iterw);                           \
35103566                                                            \
3511      /* clamp to full pixels */                                    \
3512      startx = (startx + 7) >> 4;                                    \
3513      stopx = (stopx + 7) >> 4;                                    \
3567      /* run the texture pipeline on TMU1 to produce a value in texel */      \
3568      /* note that they set LOD min to 8 to "disable" a TMU */            \
3569      if (TMUS >= 2 && v->tmu[1].lodmin < (8 << 8))                     \
3570         TEXTURE_PIPELINE(&v->tmu[1], x, y, TEXMODE1, texel,               \
3571                        v->tmu[1].lookup, v->tmu[1].lodbase,         \
3572                        iters1, itert1, iterw1, texel);               \
35143573                                                            \
3515      /* force start < stop */                                    \
3516      if (startx > stopx)                                          \
3517      {                                                      \
3518         int temp = startx;                                       \
3519         startx = stopx;                                          \
3520         stopx = temp;                                          \
3521      }                                                      \
3574      /* run the texture pipeline on TMU0 to produce a final */            \
3575      /* result in texel */                                       \
3576      /* note that they set LOD min to 8 to "disable" a TMU */            \
3577      if (TMUS >= 1 && v->tmu[0].lodmin < (8 << 8))                     \
3578         TEXTURE_PIPELINE(&v->tmu[0], x, y, TEXMODE0, texel,             \
3579                        v->tmu[0].lookup, v->tmu[0].lodbase,         \
3580                        iters0, itert0, iterw0, texel);               \
35223581                                                            \
3523      /* determine the screen Y */                                 \
3524      scry = y;                                                \
3525      if (FBZMODE_Y_ORIGIN(FBZMODE))                                 \
3526         scry = (v->fbi.yorigin - y) & 0x3ff;                        \
3582      /* colorpath pipeline selects source colors and does blending */      \
3583      CLAMPED_ARGB(iterr, iterg, iterb, itera, FBZCOLORPATH, iterargb);      \
3584      COLORPATH_PIPELINE(v, FBZCOLORPATH, FBZMODE, ALPHAMODE,   texel,         \
3585                     iterz, iterw, iterargb);                     \
35273586                                                            \
3528      /* get pointers to the target buffer and depth buffer */            \
3529      dest = drawbuf + scry * v->fbi.rowpixels;                        \
3530      depth = v->fbi.aux ? (v->fbi.aux + scry * v->fbi.rowpixels) : NULL;      \
3587      /* pixel pipeline part 2 handles fog, alpha, and final output */      \
3588      PIXEL_PIPELINE_END(v, x, y, dest, depth, FBZMODE, FBZCOLORPATH,          \
3589                        ALPHAMODE, FOGMODE, iterz, iterw, iterargb);   \
35313590                                                            \
3532      /* compute the starting parameters */                           \
3533      dx = startx - (v->fbi.ax >> 4);                                 \
3534      dy = y - (v->fbi.ay >> 4);                                    \
3535      iterr = v->fbi.startr + dy * v->fbi.drdy + dx * v->fbi.drdx;         \
3536      iterg = v->fbi.startg + dy * v->fbi.dgdy + dx * v->fbi.dgdx;         \
3537      iterb = v->fbi.startb + dy * v->fbi.dbdy + dx * v->fbi.dbdx;         \
3538      itera = v->fbi.starta + dy * v->fbi.dady + dx * v->fbi.dadx;         \
3539      iterz = v->fbi.startz + dy * v->fbi.dzdy + dx * v->fbi.dzdx;         \
3540      iterw = v->fbi.startw + dy * v->fbi.dwdy + dx * v->fbi.dwdx;         \
3591      /* update the iterated parameters */                           \
3592      iterr += v->fbi.drdx;                                       \
3593      iterg += v->fbi.dgdx;                                       \
3594      iterb += v->fbi.dbdx;                                       \
3595      itera += v->fbi.dadx;                                       \
3596      iterz += v->fbi.dzdx;                                       \
3597      iterw += v->fbi.dwdx;                                       \
35413598      if (TMUS >= 1)                                             \
35423599      {                                                      \
3543         iterw0 = v->tmu[0].startw + dy * v->tmu[0].dwdy +               \
3544                              dx * v->tmu[0].dwdx;               \
3545         iters0 = v->tmu[0].starts + dy * v->tmu[0].dsdy +                \
3546                              dx * v->tmu[0].dsdx;               \
3547         itert0 = v->tmu[0].startt + dy * v->tmu[0].dtdy +                \
3548                              dx * v->tmu[0].dtdx;               \
3600         iterw0 += v->tmu[0].dwdx;                                 \
3601         iters0 += v->tmu[0].dsdx;                                 \
3602         itert0 += v->tmu[0].dtdx;                                 \
35493603      }                                                      \
35503604      if (TMUS >= 2)                                             \
35513605      {                                                      \
3552         iterw1 = v->tmu[1].startw + dy * v->tmu[1].dwdy +                \
3553                              dx * v->tmu[1].dwdx;               \
3554         iters1 = v->tmu[1].starts + dy * v->tmu[1].dsdy +                \
3555                              dx * v->tmu[1].dsdx;               \
3556         itert1 = v->tmu[1].startt + dy * v->tmu[1].dtdy +                \
3557                              dx * v->tmu[1].dtdx;               \
3606         iterw1 += v->tmu[1].dwdx;                                 \
3607         iters1 += v->tmu[1].dsdx;                                 \
3608         itert1 += v->tmu[1].dtdx;                                 \
35583609      }                                                      \
3559                                                            \
3560      /* loop in X */                                             \
3561      for (x = startx; x < stopx; x++)                              \
3562      {                                                      \
3563         rgb_t iterargb = 0;                                       \
3564         rgb_t texel = 0;                                       \
3565                                                            \
3566         /* pixel pipeline part 1 handles depth testing and stippling */      \
3567         PIXEL_PIPELINE_BEGIN(v, x, y, scry, FBZCOLORPATH, FBZMODE,          \
3568                           iterz, iterw);                        \
3569                                                            \
3570         /* run the texture pipeline on TMU1 to produce a value in texel */   \
3571         /* note that they set LOD min to 8 to "disable" a TMU */         \
3572         if (TMUS >= 2 && v->tmu[1].lodmin < (8 << 8))                  \
3573            TEXTURE_PIPELINE(&v->tmu[1], x, y, TEXMODE1, texel,            \
3574                           v->tmu[1].lookup, v->tmu[1].lodbase,      \
3575                           iters1, itert1, iterw1, texel);            \
3576                                                            \
3577         /* run the texture pipeline on TMU0 to produce a final */         \
3578         /* result in texel */                                    \
3579         /* note that they set LOD min to 8 to "disable" a TMU */         \
3580         if (TMUS >= 1 && v->tmu[0].lodmin < (8 << 8))                  \
3581            TEXTURE_PIPELINE(&v->tmu[0], x, y, TEXMODE0, texel,          \
3582                           v->tmu[0].lookup, v->tmu[0].lodbase,      \
3583                           iters0, itert0, iterw0, texel);            \
3584                                                            \
3585         /* colorpath pipeline selects source colors and does blending */   \
3586         CLAMPED_ARGB(iterr, iterg, iterb, itera, FBZCOLORPATH, iterargb);   \
3587         COLORPATH_PIPELINE(v, FBZCOLORPATH, FBZMODE, ALPHAMODE,   texel,      \
3588                        iterz, iterw, iterargb);                  \
3589                                                            \
3590         /* pixel pipeline part 2 handles fog, alpha, and final output */   \
3591         PIXEL_PIPELINE_END(v, x, y, dest, depth, FBZMODE, FBZCOLORPATH,       \
3592                           ALPHAMODE, FOGMODE, iterz, iterw, iterargb);\
3593                                                            \
3594         /* update the iterated parameters */                        \
3595         iterr += v->fbi.drdx;                                    \
3596         iterg += v->fbi.dgdx;                                    \
3597         iterb += v->fbi.dbdx;                                    \
3598         itera += v->fbi.dadx;                                    \
3599         iterz += v->fbi.dzdx;                                    \
3600         iterw += v->fbi.dwdx;                                    \
3601         if (TMUS >= 1)                                          \
3602         {                                                   \
3603            iterw0 += v->tmu[0].dwdx;                              \
3604            iters0 += v->tmu[0].dsdx;                              \
3605            itert0 += v->tmu[0].dtdx;                              \
3606         }                                                   \
3607         if (TMUS >= 2)                                          \
3608         {                                                   \
3609            iterw1 += v->tmu[1].dwdx;                              \
3610            iters1 += v->tmu[1].dsdx;                              \
3611            itert1 += v->tmu[1].dtdx;                              \
3612         }                                                   \
3613      }                                                      \
36143610   }                                                         \
3611   UPDATE_STATISTICS(v);                                          \
36153612}
src/mame/video/pastelg.c
r1070r1071
286286         for (x = 0; x < machine->screen[0].width; x++)
287287         {
288288            color = pastelg_videoram[(y * machine->screen[0].width) + x];
289            *BITMAP_ADDR16(pastelg_tmpbitmap, y, x) = Machine->pens[color];
289            *BITMAP_ADDR16(pastelg_tmpbitmap, y, x) = machine->pens[color];
290290         }
291291      }
292292   }
src/mame/video/bfm_adr2.h
r1070r1071
1010
1111GFXDECODE_EXTERN( adder2 );
1212extern void adder2_decode_char_roms(void);
13void adder2_update(mame_bitmap *bitmap);
1413
1514MACHINE_RESET( adder2 );
1615INTERRUPT_GEN( adder2_vbl );
src/mame/video/spdodgeb.c
r1070r1071
66
77static int tile_palbank;
88static int sprite_palbank;
9static int scrollx[30];
109
1110static tilemap *bg_tilemap;
1211
r1070r1071
8079VIDEO_START( spdodgeb )
8180{
8281   bg_tilemap = tilemap_create(get_bg_tile_info,background_scan,TILEMAP_TYPE_PEN,8,8,64,32);
83
84   tilemap_set_scroll_rows(bg_tilemap,32);
8582}
8683
8784
r1070r1071
9693INTERRUPT_GEN( spdodgeb_interrupt )
9794{
9895   int iloop = cpu_getiloops();
96   int scanline = (32-iloop) * 8;
9997
10098   if (iloop > 1 && iloop < 32)
10199   {
102      scrollx[31-iloop] = lastscroll;
103100      cpunum_set_input_line(0, M6502_IRQ_LINE, HOLD_LINE);
101      video_screen_update_partial(0, scanline+7);
104102   }
105103   else if (!iloop)
104   {
106105      cpunum_set_input_line(0, INPUT_LINE_NMI, PULSE_LINE);
106      video_screen_update_partial(0, 256);
107   }
107108}
108109
109110WRITE8_HANDLER( spdodgeb_scrollx_lo_w )
r1070r1071
211212
212213VIDEO_UPDATE( spdodgeb )
213214{
214   int i;
215215
216   tilemap_set_scrollx(bg_tilemap,0,lastscroll+5);
216217
217   if (flip_screen)
218   {
219      for (i = 0;i < 30;i++)
220         tilemap_set_scrollx(bg_tilemap,i+1,scrollx[29 - i]+5);
221   }
222   else
223   {
224      for (i = 0;i < 30;i++)
225         tilemap_set_scrollx(bg_tilemap,i+1,scrollx[i]+5);
226   }
227
228218   tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
229219   draw_sprites(machine, bitmap,cliprect);
230220   return 0;
src/mame/video/turbo.c
r1070r1071
168168
169169static TILE_GET_INFO( get_fg_tile_info )
170170{
171   turbo_state *state = Machine->driver_data;
171   turbo_state *state = machine->driver_data;
172172   int code = state->videoram[tile_index];
173173   SET_TILE_INFO(0, code, code >> 2, 0);
174174}
src/mame/video/realbrk.c
r1070r1071
603603      return 0;
604604   }
605605   else
606      fillbitmap(bitmap,Machine->pens[realbrk_vregs[0xc/2] & 0x7fff],cliprect);
606      fillbitmap(bitmap,machine->pens[realbrk_vregs[0xc/2] & 0x7fff],cliprect);
607607
608608
609609
src/mame/video/model2rd.c
r0r1071
1/********************************************************************
2
3    Sega Model 2 3D rasterization functions
4
5********************************************************************/
6
7#undef MODEL2_CHECKER
8#undef MODEL2_TEXTURED
9#undef MODEL2_TRANSLUCENT
10
11#ifndef MODEL2_FUNC
12#error "Model 2 renderer: No function defined!"
13#endif
14
15#ifndef MODEL2_FUNC_NAME
16#error "Model 2 renderer: No function name defined!"
17#endif
18
19#if MODEL2_FUNC == 0
20#undef MODEL2_CHECKER
21#undef MODEL2_TEXTURED
22#undef MODEL2_TRANSLUCENT
23#elif MODEL2_FUNC == 1
24#undef MODEL2_CHECKER
25#undef MODEL2_TEXTURED
26#define MODEL2_TRANSLUCENT
27#elif MODEL2_FUNC == 2
28#undef MODEL2_CHECKER
29#define MODEL2_TEXTURED
30#undef MODEL2_TRANSLUCENT
31#elif MODEL2_FUNC == 3
32#undef MODEL2_CHECKER
33#define MODEL2_TEXTURED
34#define MODEL2_TRANSLUCENT
35#elif MODEL2_FUNC == 4
36#define MODEL2_CHECKER
37#undef MODEL2_TEXTURED
38#undef MODEL2_TRANSLUCENT
39#elif MODEL2_FUNC == 5
40#define MODEL2_CHECKER
41#undef MODEL2_TEXTURED
42#define MODEL2_TRANSLUCENT
43#elif MODEL2_FUNC == 6
44#define MODEL2_CHECKER
45#define MODEL2_TEXTURED
46#undef MODEL2_TRANSLUCENT
47#elif MODEL2_FUNC == 7
48#define MODEL2_CHECKER
49#define MODEL2_TEXTURED
50#define MODEL2_TRANSLUCENT
51#elif
52#error "Model 2 renderer: Invalif function selected!"
53#endif
54
55#ifndef MODEL2_TEXTURED
56/* non-textured render path */
57static void MODEL2_FUNC_NAME ( mame_bitmap *bitmap, triangle *tri, const rectangle *cliprect )
58{
59   struct poly_vertex vert[3];
60   const struct poly_scanline_data *scans;
61
62   /* if it's translucent, there's nothing to render */
63#if defined( MODEL2_TRANSLUCENT)
64   return;
65#endif
66
67   /* setup vertices to be scanned */
68   vert[0].x = (INT32)tri->v[0].x;   vert[0].y = (INT32)tri->v[0].y;
69   vert[1].x = (INT32)tri->v[1].x;   vert[1].y = (INT32)tri->v[1].y;
70   vert[2].x = (INT32)tri->v[2].x;   vert[2].y = (INT32)tri->v[2].y;
71
72   /* get the scan parameters */
73   scans = setup_triangle_0(&vert[0], &vert[1], &vert[2], cliprect);
74
75   /* see if we have something to render */
76   if ( scans )
77   {
78      /* extract color information */
79      UINT32   color = (tri->texheader[3] >> 6) & 0x3FF;
80      UINT32   lumabase = (tri->texheader[1] & 0xFF);
81      UINT32   lumaindex = (lumabase << 8) + 0xF0 + (((tri->luma >> 4) & 0x0f) ^ 0x0f);
82      UINT32   luma = model2_lumaram[lumaindex/4];
83      UINT32   r, g, b, ri, gi, bi, tr, tg, tb, pval;
84      UINT32 *colortable_r = &model2_colorxlat[0x0000/4];
85      UINT32 *colortable_g = &model2_colorxlat[0x4000/4];
86      UINT32 *colortable_b = &model2_colorxlat[0x8000/4];
87      int      x, y;
88
89      if ( lumaindex & 2 )
90         luma >>= 16;
91
92      luma &= 0x3F;
93
94      pval = paletteram32[(0x2000/4)+(color >> 1)];
95
96      if ( color & 1 )
97         color = (pval >> 16);
98      else
99         color = pval;
100
101      color &= 0x7fff;
102
103      r = (color >>  0) & 0x1f;
104      g = (color >>  5) & 0x1f;
105      b = (color >> 10) & 0x1f;
106
107      /* we have the 6 bits of luma information along with 5 bits per color component */
108      /* now build and index into the master color lookup table and extract the raw RGB values */
109
110      ri = (r<<9) + (luma<<1);
111      gi = (g<<9) + (luma<<1);
112      bi = (b<<9) + (luma<<1);
113
114      tr = colortable_r[ri>>2];
115      tg = colortable_g[gi>>2];
116      tb = colortable_b[bi>>2];
117
118      if ( ri & 2 ) tr >>= 16;
119      if ( gi & 2 ) tg >>= 16;
120      if ( bi & 2 ) tb >>= 16;
121
122      tr &= 0xff;
123      tg &= 0xff;
124      tb &= 0xff;
125
126      /* build the final color */
127      color = (tr << 16) | (tg << 8) | (tb);
128
129      /* go through our scan list and paint the lines */
130      for(y = scans->sy; y <= scans->ey; y++)
131      {
132         int x1, x2;
133         const struct poly_scanline *scan = &scans->scanline[y - scans->sy];
134         UINT32 *p = BITMAP_ADDR32(bitmap, y, 0);
135
136         x1 = scan->sx;
137         x2 = scan->ex;
138
139         for(x = x1; x <= x2; x++)
140#if defined(MODEL2_CHECKER)
141            if ((x^y) & 1) p[x] = color;
142#else
143            p[x] = color;
144#endif
145      }
146   }
147}
148
149#else
150/* textured render path */
151static void MODEL2_FUNC_NAME ( mame_bitmap *bitmap, triangle *tri, const rectangle *cliprect )
152{
153   struct poly_vertex vert[3];
154   const struct poly_scanline_data *scans;
155   UINT32   tex_width   = (tri->texheader[0] >> 0) & 0x7;
156   UINT32   tex_height   = (tri->texheader[0] >> 3) & 0x7;
157   float   zu[3], zv[3], tz[3];
158   int i;
159
160   tex_width = 32 << tex_width;
161   tex_height = 32 << tex_height;
162
163   for( i = 0; i < 3; i++ )
164   {
165      zu[i] = ((float)tri->v[i].u) / 8.0f;
166      zv[i] = ((float)tri->v[i].v) / 8.0f;
167
168      zu[i] /= (float)tex_width;
169      zv[i] /= (float)tex_height;
170
171      /* now u,v are within 0-1 range */
172
173      tz[i] = 1.0/(1.0+tri->v[i].z);
174
175      zu[i] *= tz[i];
176      zv[i] *= tz[i];
177
178      tz[i] *= 1048576.0f;
179      zu[i] *= 1048576.0f;
180      zv[i] *= 1048576.0f;
181   }
182
183   vert[0].x = (INT32)tri->v[0].x;      vert[0].y = (INT32)tri->v[0].y;      vert[0].p[0] = (INT32)zu[0];   vert[0].p[1] = (INT32)zv[0];   vert[0].p[2] = (INT32)tz[0];
184   vert[1].x = (INT32)tri->v[1].x;      vert[1].y = (INT32)tri->v[1].y;      vert[1].p[0] = (INT32)zu[1];   vert[1].p[1] = (INT32)zv[1];   vert[1].p[2] = (INT32)tz[1];
185   vert[2].x = (INT32)tri->v[2].x;      vert[2].y = (INT32)tri->v[2].y;      vert[2].p[0] = (INT32)zu[2];   vert[2].p[1] = (INT32)zv[2];   vert[2].p[2] = (INT32)tz[2];
186
187   /* get the scan parameters */
188   scans = setup_triangle_3(&vert[0], &vert[1], &vert[2], cliprect);
189
190   /* see if we have something to render */
191   if ( scans )
192   {
193      INT64 du, dv, dz;
194
195      /* extract color information */
196      UINT32   r, g, b, pval;
197      UINT32   colorbase = (tri->texheader[3] >> 6) & 0x3FF;
198      UINT32   lumabase = (tri->texheader[1] & 0xFF );
199      UINT32   tex_x      = (tri->texheader[2] >> 0) & 0x1f;
200      UINT32   tex_y      = (tri->texheader[2] >> 6) & 0x1f;
201      UINT32   tex_x_mask, tex_y_mask;
202      UINT32   tex_mirr_x   = (tri->texheader[0] >> 9) & 1;
203      UINT32   tex_mirr_y   = (tri->texheader[0] >> 8) & 1;
204      UINT32 *colortable_r = &model2_colorxlat[0x0000/4];
205      UINT32 *colortable_g = &model2_colorxlat[0x4000/4];
206      UINT32 *colortable_b = &model2_colorxlat[0x8000/4];
207      UINT32 *sheet;
208      int      x, y;
209
210      if ( tri->texheader[2] & 0x20 )
211         tex_y += 0x20;
212
213      tex_x = 32 * tex_x;
214      tex_y = 32 * tex_y;
215      tex_x_mask   = tex_width - 1;
216      tex_y_mask   = tex_height - 1;
217
218      sheet = model2_textureram0;
219
220      if (tri->texheader[2] & 0x1000)
221         sheet = model2_textureram1;
222
223      pval = paletteram32[(0x2000/4)+(colorbase >> 1)];
224
225      if ( colorbase & 1 )
226         colorbase = (pval >> 16);
227      else
228         colorbase = pval;
229
230      colorbase &= 0x7fff;
231
232      r = (colorbase >>  0) & 0x1f;
233      g = (colorbase >>  5) & 0x1f;
234      b = (colorbase >> 10) & 0x1f;
235
236      du = scans->dp[0];
237      dv = scans->dp[1];
238      dz = scans->dp[2];
239
240      for(y = scans->sy; y <= scans->ey; y++)
241      {
242         INT64 u, v, z;
243         int x1, x2;
244         UINT32   lumaindex;
245         const struct poly_scanline *scan = &scans->scanline[y - scans->sy];
246         UINT32 *p = BITMAP_ADDR32(bitmap, y, 0);
247
248         x1 = scan->sx;
249         x2 = scan->ex;
250
251         u = scans->scanline[y - scans->sy].p[0];
252         v = scans->scanline[y - scans->sy].p[1];
253         z = scans->scanline[y - scans->sy].p[2];
254
255         for(x = x1; x <= x2; x++, u += du, v += dv, z += dz)
256         {
257            UINT32   tr, tg, tb, luma, ri, gi, bi;
258            UINT16   t;
259            float   uf = ((float)(u>>16)) / 1048576.0;
260            float   vf = ((float)(v>>16)) / 1048576.0;
261            float   zf = ((float)(z>>16)) / 1048576.0;
262            int u2;
263            int v2;
264
265#if defined(MODEL2_CHECKER)
266            if ( ((x^y) & 1) == 0 )
267               continue;
268#endif
269            u2 = (int)((uf/zf)*tex_width) & tex_x_mask;
270            v2 = (int)((vf/zf)*tex_height) & tex_y_mask;
271
272            if ( tex_mirr_x )
273               u2 = ( tex_width - 1 ) - u2;
274
275            if ( tex_mirr_y )
276               v2 = ( tex_height - 1 ) - v2;
277
278            t = get_texel( tex_x, tex_y, u2, v2, sheet );
279
280#if defined(MODEL2_TRANSLUCENT)
281            if ( t == 0x0f )
282               continue;
283#endif
284            lumaindex = (lumabase << 8) + ( t << 4 ) + (((tri->luma >> 4) & 0x0f) ^ 0x0f);
285            luma = model2_lumaram[lumaindex/4];
286
287            if ( lumaindex & 2 )
288               luma >>= 16;
289
290            luma &= 0x3F;
291
292            /* we have the 6 bits of luma information along with 5 bits per color component */
293            /* now build and index into the master color lookup table and extract the raw RGB values */
294
295            ri = (r<<9) + (luma<<1);
296            gi = (g<<9) + (luma<<1);
297            bi = (b<<9) + (luma<<1);
298
299            tr = colortable_r[ri>>2];
300            tg = colortable_g[gi>>2];
301            tb = colortable_b[bi>>2];
302
303            if ( ri & 2 ) tr >>= 16;
304            if ( gi & 2 ) tg >>= 16;
305            if ( bi & 2 ) tb >>= 16;
306
307            tr &= 0xff;
308            tg &= 0xff;
309            tb &= 0xff;
310
311            p[x] = (tr << 16) | (tg << 8) | (tb);
312         }
313      }
314   }
315}
316
317#endif
src/mame/video/ppu2c0x.c
r1070r1071
2525******************************************************************************/
2626
2727#include <math.h>
28
28#include "driver.h"
29#include "profiler.h"
2930#include "video/ppu2c0x.h"
30#include "profiler.h"
3131
3232/* constant definitions */
3333#define VISIBLE_SCREEN_WIDTH   (32*8)   /* Visible screen width */
src/mame/video/ppu2c0x.h
r1070r1071
99#ifndef __PPU_2C03B_H__
1010#define __PPU_2C03B_H__
1111
12#include "driver.h"
13
1412/* increment to use more chips */
1513#define MAX_PPU 2
1614
src/mame/video/m92.c
r1070r1071
4040*****************************************************************************/
4141
4242#include "driver.h"
43#include "m92.h"
4344
4445typedef struct _pf_layer_info pf_layer_info;
4546struct _pf_layer_info
src/mame/video/changela.c
r1070r1071
686686   {
687687      int riv_col, prev_col;
688688
689      if((*BITMAP_ADDR16(river_bitmap, sy, sx) == Machine->pens[0x08])
690      || (*BITMAP_ADDR16(river_bitmap, sy, sx) == Machine->pens[0x09])
691      || (*BITMAP_ADDR16(river_bitmap, sy, sx) == Machine->pens[0x0a]))
689      if((*BITMAP_ADDR16(river_bitmap, sy, sx) == machine->pens[0x08])
690      || (*BITMAP_ADDR16(river_bitmap, sy, sx) == machine->pens[0x09])
691      || (*BITMAP_ADDR16(river_bitmap, sy, sx) == machine->pens[0x0a]))
692692         riv_col = 1;
693693      else
694694         riv_col = 0;
695695
696      if((*BITMAP_ADDR16(river_bitmap, sy, sx-1) == Machine->pens[0x08])
697      || (*BITMAP_ADDR16(river_bitmap, sy, sx-1) == Machine->pens[0x09])
698      || (*BITMAP_ADDR16(river_bitmap, sy, sx-1) == Machine->pens[0x0a]))
696      if((*BITMAP_ADDR16(river_bitmap, sy, sx-1) == machine->pens[0x08])
697      || (*BITMAP_ADDR16(river_bitmap, sy, sx-1) == machine->pens[0x09])
698      || (*BITMAP_ADDR16(river_bitmap, sy, sx-1) == machine->pens[0x0a]))
699699         prev_col = 1;
700700      else
701701         prev_col = 0;
702702
703      if(*BITMAP_ADDR16(obj0_bitmap, sy, sx) == Machine->pens[0x14]) /* Car Outline Color */
703      if(*BITMAP_ADDR16(obj0_bitmap, sy, sx) == machine->pens[0x14]) /* Car Outline Color */
704704      {
705705         /* Tree 0 Collision */
706706         if(*BITMAP_ADDR16(tree0_bitmap, sy, sx) != 0)
src/mame/drivers/mitchell.c
r1070r1071
8282#include "sound/okim6295.h"
8383#include "sound/3812intf.h"
8484#include "sound/2413intf.h"
85#include "sound/msm5205.h"
8586
8687/* in machine/kabuki.c */
8788void mgakuen2_decode(void);
r1070r1071
410411ADDRESS_MAP_END
411412
412413
414/* spangbl */
415
416static ADDRESS_MAP_START( spangb_memmap, ADDRESS_SPACE_PROGRAM, 8 )
417   AM_RANGE(0x0000, 0x7fff) AM_ROM
418   AM_RANGE(0x8000, 0xbfff) AM_READWRITE(MRA8_BANK1, MWA8_NOP)
419   AM_RANGE(0xc000, 0xc7ff) AM_READWRITE(pang_paletteram_r, pang_paletteram_w)   /* Banked palette RAM */
420   AM_RANGE(0xc800, 0xcfff) AM_READWRITE(pang_colorram_r, pang_colorram_w)   AM_BASE(&pang_colorram)/* Attribute RAM */
421   AM_RANGE(0xd000, 0xdfff) AM_READWRITE(pang_videoram_r, pang_videoram_w)   AM_BASE(&pang_videoram) AM_SIZE(&pang_videoram_size) /* Banked char / OBJ RAM */
422   AM_RANGE(0xe000, 0xffff) AM_READ(MRA8_RAM)   /* Work RAM */
423   AM_RANGE(0xe000, 0xffff) AM_RAM
424ADDRESS_MAP_END
425
426static ADDRESS_MAP_START( spangb_portmap, ADDRESS_SPACE_IO, 8 )
427   ADDRESS_MAP_FLAGS( AMEF_ABITS(8) )
428   AM_RANGE(0x00, 0x02) AM_READ(input_r)   /* Super Pang needs a kludge to initialize EEPROM. */
429   AM_RANGE(0x00, 0x00) AM_WRITE(pang_gfxctrl_w)    /* Palette bank, layer enable, coin counters, more */
430   AM_RANGE(0x02, 0x02) AM_WRITE(pang_bankswitch_w)      /* Code bank register */
431   AM_RANGE(0x03, 0x03) AM_WRITE(YM2413_data_port_0_w)
432   AM_RANGE(0x04, 0x04) AM_WRITE(YM2413_register_port_0_w)
433   AM_RANGE(0x05, 0x05) AM_READ(pang_port5_r)
434   AM_RANGE(0x06, 0x06) AM_WRITE(MWA8_NOP)   /* watchdog? irq ack? */
435   AM_RANGE(0x07, 0x07) AM_WRITE(pang_video_bank_w)      /* Video RAM bank register */
436   AM_RANGE(0x08, 0x08) AM_WRITE(eeprom_cs_w)
437   AM_RANGE(0x10, 0x10) AM_WRITE(eeprom_clock_w)
438   AM_RANGE(0x18, 0x18) AM_WRITE(eeprom_serial_w)
439ADDRESS_MAP_END
440
441
442static int sample_buffer = 0;
443static int sample_select = 0;
444
445/*
446static WRITE8_HANDLER( spangbl_msm5205_data_w )
447{
448    sample_buffer = data;
449}
450*/
451
452static ADDRESS_MAP_START( spangb_sound_memmap, ADDRESS_SPACE_PROGRAM, 8 )
453   AM_RANGE(0x0000, 0x3fff) AM_ROM
454//  AM_RANGE(0xec00, 0xec00) AM_WRITE( spangbl_msm5205_data_w )
455   AM_RANGE(0xf000, 0xf3ff) AM_RAM
456ADDRESS_MAP_END
457
458static ADDRESS_MAP_START( spangb_sound_portmap, ADDRESS_SPACE_IO, 8 )
459   ADDRESS_MAP_FLAGS( AMEF_ABITS(8) )
460ADDRESS_MAP_END
461
413462/**** Monsters World ****/
414463
415464static WRITE8_HANDLER( oki_banking_w )
r1070r1071
913962   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
914963INPUT_PORTS_END
915964
965INPUT_PORTS_START( spangbl )
966   PORT_START      /* DSW */
967   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* USED - handled in port5_r */
968   PORT_BIT(0x02, 0x02, IPT_SERVICE ) PORT_NAME( DEF_STR( Service_Mode )) PORT_CODE(KEYCODE_F2)
969   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
970   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* USED - handled in port5_r */
971   PORT_BIT( 0x70, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
972   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* data from EEPROM */
973
974   PORT_START      /* IN0 */
975   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
976   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )
977   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* probably unused */
978   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
979   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* probably unused */
980   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* probably unused */
981   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE1 )
982   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
983
984   PORT_START      /* IN1 */
985   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
986   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNKNOWN ) // must be high for game to boot..
987   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 )
988   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 )
989   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY
990   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY
991   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY
992   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY
993
994   PORT_START      /* IN2 */
995   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
996   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
997   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
998   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
999   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
1000   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
1001   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
1002   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
1003INPUT_PORTS_END
1004
9161005INPUT_PORTS_START( mstworld )
9171006   /* this port may not have the same role */
9181007   PORT_START      /* DSW */
r1070r1071
12721361static MACHINE_DRIVER_START( pang )
12731362
12741363   /* basic machine hardware */
1275   MDRV_CPU_ADD(Z80, 8000000)   /* Super Pang says 8MHZ ORIGINAL BOARD */
1364   MDRV_CPU_ADD_TAG("main",Z80, 8000000)   /* Super Pang says 8MHZ ORIGINAL BOARD */
12761365   MDRV_CPU_PROGRAM_MAP(readmem,writemem)
12771366   MDRV_CPU_IO_MAP(readport,writeport)
12781367   MDRV_CPU_VBLANK_INT(irq0_line_hold,2)   /* ??? one extra irq seems to be needed for music (see input5_r) */
r1070r1071
12961385   /* sound hardware */
12971386   MDRV_SPEAKER_STANDARD_MONO("mono")
12981387
1299   MDRV_SOUND_ADD(OKIM6295, 990000)
1388   MDRV_SOUND_ADD_TAG("oki", OKIM6295, 990000)
13001389   MDRV_SOUND_CONFIG(okim6295_interface_region_1_pin7high) // clock frequency & pin 7 not verified
13011390   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
13021391
1303   MDRV_SOUND_ADD(YM2413, 4000000)
1392   MDRV_SOUND_ADD_TAG("ym2413",YM2413, 4000000)
13041393   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
13051394MACHINE_DRIVER_END
13061395
1396static const gfx_layout blcharlayout =
1397{
1398   8,8,   /* 8*8 characters */
1399   RGN_FRAC(1,2),   /* 32768 characters */
1400   4,      /* 4 bits per pixel */
1401   { RGN_FRAC(1,2)+8, RGN_FRAC(1,2)+0,8, 0 },
1402   { 0, 1, 2, 3, 4,5,6,7 },
1403   { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
1404   16*8    /* every char takes 16 consecutive bytes */
1405};
13071406
1407
1408static GFXDECODE_START( spangbl )
1409   GFXDECODE_ENTRY( REGION_GFX1, 0, blcharlayout,     0, 128 ) /* colors 0-2047 */
1410   GFXDECODE_ENTRY( REGION_GFX2, 0, spritelayout,   0,  16 ) /* colors 0- 255 */
1411GFXDECODE_END
1412
1413
1414
1415static void spangbl_adpcm_int(int data)
1416{
1417   MSM5205_data_w(0, sample_buffer & 0x0F);
1418   sample_buffer >>= 4;
1419   sample_select ^= 1;
1420   if(sample_select == 0)
1421      cpunum_set_input_line(1, INPUT_LINE_NMI, PULSE_LINE);
1422}
1423
1424
1425static struct MSM5205interface msm5205_interface =
1426{
1427   spangbl_adpcm_int,   /* interrupt function */
1428   MSM5205_S48_4B      /* 4KHz 4-bit */
1429};
1430
1431
1432static MACHINE_DRIVER_START( spangbl )
1433   MDRV_IMPORT_FROM(pang)
1434
1435   MDRV_CPU_MODIFY("main")
1436   MDRV_CPU_PROGRAM_MAP(spangb_memmap,0)
1437   MDRV_CPU_IO_MAP(spangb_portmap,0)
1438   MDRV_CPU_VBLANK_INT(irq0_line_hold,1)
1439
1440   MDRV_CPU_ADD_TAG("sound",Z80, 8000000)
1441   MDRV_CPU_PROGRAM_MAP(spangb_sound_memmap,0 )
1442   MDRV_CPU_IO_MAP(spangb_sound_portmap,0)
1443   MDRV_CPU_VBLANK_INT(irq0_line_hold,1)
1444//  MDRV_CPU_VBLANK_INT(nmi_line_pulse,1)
1445
1446   MDRV_GFXDECODE(spangbl)
1447
1448
1449   MDRV_SOUND_REPLACE("oki", MSM5205, 384000)
1450   MDRV_SOUND_CONFIG(msm5205_interface)
1451   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
1452MACHINE_DRIVER_END
1453
13081454static MACHINE_DRIVER_START( mstworld )
13091455
13101456   /* basic machine hardware */
r1070r1071
15671713   ROM_LOAD( "bb1.bin",      0x00000, 0x20000, CRC(c52e5b8e) SHA1(933b954bfdd2d67e28b032ffabde192531249c1f) )
15681714ROM_END
15691715
1716/* I suspect the only real difference in this set is that it doesn't have the date hacked to (c)1990 like
1717   the above bootleg, and it uses a different PCB layout.  Multiple PCBs with these ROMs have been found,
1718   so it's worth supporting anyway. */
1719ROM_START( pangbold )
1720   ROM_REGION( 2*0x50000, REGION_CPU1, 0 )
1721   ROM_LOAD( "4.6l",  0x50000, 0x08000, CRC(f68f88a5) SHA1(6f57891d399a46d8d5a531771129552ed420d10a) )   /* Decrypted opcode + data */
1722   ROM_CONTINUE(      0x00000, 0x08000 )
1723   ROM_LOAD( "2.3l",  0x60000, 0x20000, CRC(3f15bb61) SHA1(4f74ee25f32a201482840158b4d4c7aca1cda684) )   /* Decrypted op codes */
1724   ROM_LOAD( "3.5l",  0x10000, 0x20000, CRC(ce6375e4) SHA1(fdd40d82553fcd4d2762ecfd898d0e3112dfde79) )   /* Decrypted data */
1725
1726   ROM_REGION( 0x100000, REGION_GFX1, ROMREGION_DISPOSE | ROMREGION_ERASEFF ) /* chars */
1727   ROM_LOAD( "9.10o",  0x000000, 0x20000, CRC(3a5883f5) SHA1(a8a33071e10f5992e80afdb782c334829f9ae27f) )
1728   ROM_LOAD( "10.14o", 0x020000, 0x20000, CRC(79a8ed08) SHA1(c1e43889e29b80c7fe2c09b11eecde24450a1ff5) )
1729   /* 40000-7ffff empty */
1730   ROM_LOAD( "11.17j", 0x080000, 0x20000, CRC(166a16ae) SHA1(7f907c78b7ac8c99e3d79761a6ae689c77e3a1f5) )
1731   ROM_LOAD( "12.20j", 0x0a0000, 0x20000, CRC(2fb3db6c) SHA1(328814d28569fec763975a8ae4c2767517a680af) )
1732   /* c0000-fffff empty */
1733
1734   ROM_REGION( 0x040000, REGION_GFX2, ROMREGION_DISPOSE ) /* sprites */
1735   ROM_LOAD( "8.7o",     0x000000, 0x10000, CRC(f3188aa1) SHA1(f59da8986c0c7d74185211eae1d1cc3f59a54f82) )
1736   ROM_LOAD( "7.5o",     0x010000, 0x10000, CRC(011da14b) SHA1(3af9c5ca263b3df98b4f4c88d5428a115ddebef8) )
1737   ROM_LOAD( "6.3o",     0x020000, 0x10000, CRC(0e25e797) SHA1(88c99e544923142256c93ed2b71f06489f6a90a8) )
1738   ROM_LOAD( "5.1o",     0x030000, 0x10000, CRC(6daa4e27) SHA1(23411928de911b6303efa3a229646001459e4c70) )
1739
1740   ROM_REGION( 0x80000, REGION_SOUND1, 0 )   /* OKIM */
1741   ROM_LOAD( "1.1a",      0x00000, 0x10000, CRC(b6463907) SHA1(b79e0dca10c639b7f0ea9cbc49300b80708d46fa) )
1742ROM_END
1743
1744
15701745ROM_START( bbros )
15711746   ROM_REGION( 0x50000, REGION_CPU1, 0 )
15721747   ROM_LOAD( "bb6.bin",      0x00000, 0x08000, CRC(a3041ca4) SHA1(2accb2151f621e4802211efe986969ebd3acb6d4) )
r1070r1071
17171892   ROM_LOAD( "spe_01.rom",   0x00000, 0x20000, CRC(2d19c133) SHA1(b3ec226f35494dfc259e910895cec8a49dd2f846) )
17181893ROM_END
17191894
1895/*
18961x Z0840006PSC (main)
18971x Z0840006PSC (sound)
18981x OKI M5205
18991x YM2413
19001x LM324N
19011x oscillator 29.700 (close to sound)
19021x oscillator 12.0 MHz (close to main)
1903ROMs    16x AM27C512 (1,3-17)
19041x AM27C020 (2)
19052x GAL16V8A (read protected - no dump available)
1906Note    1x JAMMA edge connector
19071x trimmer (volume)
19081x 8 switches dip
1909*/
1910
1911ROM_START( spangbl )
1912   ROM_REGION( 0x50000*2, REGION_CPU1, ROMREGION_ERASEFF )
1913   ROM_LOAD( "ic17.1",   0x00000, 0x08000, CRC(f0b2bf86) SHA1(b42a6c0b98c7ccd1e8acd41066a25c7ed4a3aabe) )
1914   ROM_CONTINUE(0x50000,0x8000)
1915   ROM_LOAD( "ic18.2",   0x60000, 0x04000, CRC(6f377832) SHA1(25755ed77a797f50fdfbb4c42a04f51d3d08f87c) )
1916   ROM_CONTINUE(0x10000,0x4000)
1917   ROM_CONTINUE(0x64000,0x4000)
1918   ROM_CONTINUE(0x14000,0x4000)
1919   ROM_CONTINUE(0x68000,0x4000)
1920   ROM_CONTINUE(0x18000,0x4000)
1921   ROM_CONTINUE(0x6c000,0x4000)
1922   ROM_CONTINUE(0x1c000,0x4000)
1923   ROM_CONTINUE(0x70000,0x4000)
1924   ROM_CONTINUE(0x20000,0x4000)
1925   ROM_CONTINUE(0x74000,0x4000)
1926   ROM_CONTINUE(0x24000,0x4000)
1927   ROM_CONTINUE(0x78000,0x4000)
1928   ROM_CONTINUE(0x28000,0x4000)
1929   ROM_CONTINUE(0x7c000,0x4000)
1930   ROM_CONTINUE(0x2c000,0x4000)
1931   ROM_LOAD( "ic19.3",   0x40000, 0x04000, CRC(7c776309) SHA1(8861ed11484ca0727dfbc3003888a9de32ed8ecc) )
1932   ROM_CONTINUE(0x48000,0x4000)
1933   ROM_CONTINUE(0x44000,0x4000)
1934   ROM_CONTINUE(0x4c000,0x4000)
1935
1936   ROM_REGION( 0x20000, REGION_CPU2, 0 ) /* Sound Z80 + M5205 samples */
1937   ROM_LOAD( "ic28.4",   0x00000, 0x10000, CRC(02b07d0a) SHA1(77cb9bf1b0d93ebad1bd8cdbedb7fdbad23697be) )
1938   ROM_LOAD( "ic45.5",   0x10000, 0x10000, CRC(95c32824) SHA1(02de90a7bfbe89feb7708fda8dfac4ed32bc0773) )
1939
1940   ROM_REGION( 0x100000, REGION_GFX1, ROMREGION_INVERT| ROMREGION_DISPOSE | ROMREGION_ERASE00 )
1941   ROM_LOAD16_BYTE( "ic79.11",  0x000001, 0x10000, CRC(10839ddd) SHA1(bfb56aa5d6ee1d3aa19e346264bee90d64545e51) )
1942   ROM_LOAD16_BYTE( "ic78.7",   0x000000, 0x10000, CRC(c1d5df89) SHA1(a86e641af1b41c8f642fe3a14ebcbe6c27f80c79) )
1943   ROM_LOAD16_BYTE( "ic49.10",  0x020001, 0x10000, CRC(113c2753) SHA1(37b480b5d9c581d3c807c81924b4bbbc21d0698d) )
1944   ROM_LOAD16_BYTE( "ic48.6",   0x020000, 0x10000, CRC(4ffae6c9) SHA1(71df3c374a24d6a90e78d33929cb91d05bd10b78) )
1945   ROM_LOAD16_BYTE( "ic81.13",  0x080001, 0x10000, CRC(ebe9c63a) SHA1(1aeeea5051086405ceb803ca7a5bfd82a07ade0f) )
1946   ROM_LOAD16_BYTE( "ic80.9",   0x080000, 0x10000, CRC(f680051d) SHA1(b6e09e14baf839961f46e0986d2c17f7edfaf13d) )
1947   ROM_LOAD16_BYTE( "ic51.12",  0x0a0001, 0x10000, CRC(beb49dc9) SHA1(c93f65b0f4ce0a0f400202f2998b89abad1f6942) )
1948   ROM_LOAD16_BYTE( "ic50.8",   0x0a0000, 0x10000, CRC(3f91014c) SHA1(b3947caa0c667d871c19d7dda6536d043ad296f2) )
1949
1950   ROM_REGION( 0x040000, REGION_GFX2, ROMREGION_INVERT|ROMREGION_DISPOSE )
1951   ROM_LOAD( "ic94.17",   0x000000, 0x10000, CRC(a56f3c20) SHA1(cb440e0e612da8b8a50fe25a6336869b62ab4cfd) )
1952   ROM_LOAD( "ic95.16",   0x020000, 0x10000, CRC(14df4659) SHA1(d73fab0a8c1e56a26cc15333a294e876f1552bc9) )
1953   ROM_LOAD( "ic124.15",  0x010000, 0x10000, CRC(4702c768) SHA1(ff996f1355f32451fa57836c2255027a8108eb40) )
1954   ROM_LOAD( "ic125.14",  0x030000, 0x10000, CRC(bd5c2f4b) SHA1(3c71d63637633a98ab513e4336e2954af3f964f4) )
1955ROM_END
1956
1957
17201958ROM_START( spangj )
17211959   ROM_REGION( 0x50000, REGION_CPU1, 0 )
17221960   ROM_LOAD( "spj_11h.bin",    0x00000, 0x08000, CRC(1a548b0b) SHA1(3aa65028876ab6e176f5b227366e65212c944888) )
r1070r1071
19842222   spang_decode();
19852223   configure_banks();
19862224}
2225
2226static DRIVER_INIT( spangbl )
2227{
2228   input_type = 3;
2229   nvram_size = 0x80;
2230   nvram = &memory_region(REGION_CPU1)[0xe000];   /* NVRAM */
2231   bootleg_decode();
2232   configure_banks();
2233}
2234
19872235static DRIVER_INIT( spangj )
19882236{
19892237   input_type = 3;
r1070r1071
21212369GAME( 1989, pkladila, pkladies, marukin, pkladies, pkladies, ROT0,   "Leprechaun", "Poker Ladies (Leprechaun ver. 401)", 0 )
21222370GAME( 1989, dokaben,  0,        pang,    pang,     dokaben,  ROT0,   "Capcom", "Dokaben (Japan)", 0 )
21232371GAME( 1989, pang,     0,        pang,    pang,     pang,     ROT0,   "Mitchell", "Pang (World)", 0 )
2124GAME( 1989, pangb,    pang,     pang,    pang,     pangb,    ROT0,   "bootleg", "Pang (bootleg)", 0 )
2372GAME( 1989, pangb,    pang,     pang,    pang,     pangb,    ROT0,   "[Mitchell] (bootleg)", "Pang (bootleg, set 1)", 0 )
2373GAME( 1989, pangbold, pang,     pang,    pang,     pangb,    ROT0,   "[Mitchell] (bootleg)", "Pang (bootleg, set 2)", 0 )
21252374GAME( 1989, bbros,    pang,     pang,    pang,     pang,     ROT0,   "Capcom", "Buster Bros. (US)", 0 )
21262375GAME( 1989, pompingw, pang,     pang,    pang,     pang,     ROT0,   "Mitchell", "Pomping World (Japan)", 0 )
21272376GAME( 1989, cworld,   0,        pang,    qtono1,   cworld,   ROT0,   "Capcom", "Capcom World (Japan)", 0 )
21282377GAME( 1990, hatena,   0,        pang,    qtono1,   hatena,   ROT0,   "Capcom", "Adventure Quiz 2 Hatena Hatena no Dai-Bouken (Japan 900228)", 0 )
21292378GAME( 1990, spang,    0,        pang,    pang,     spang,    ROT0,   "Mitchell", "Super Pang (World 900914)", 0 )
21302379GAME( 1990, spangj,   spang,    pang,    pang,     spangj,   ROT0,   "Mitchell", "Super Pang (Japan 901023)", 0 )
2380GAME( 1990, spangbl,  spang,    spangbl, spangbl,  spangbl,  ROT0,   "[Mitchell] (bootleg)", "Super Pang (World 900914, bootleg)", GAME_NO_SOUND ) // different sound hardware
21312381GAME( 1994, mstworld, 0,        mstworld,mstworld, mstworld, ROT0,   "TCH", "Monsters World",GAME_IMPERFECT_GRAPHICS ) // bootleg of Spang
21322382GAME( 1990, sbbros,   spang,    pang,    pang,     sbbros,   ROT0,   "Mitchell + Capcom", "Super Buster Bros. (US 901001)", 0 )
21332383GAME( 1990, marukin,  0,        marukin, marukin,  marukin,  ROT0,   "Yuga", "Super Marukin-Ban (Japan 901017)", 0 )
src/mame/drivers/dynduke.c
r1070r1071
214214static const gfx_layout bg_layout =
215215{
216216   16,16,
217   0x2000,
218   5,   /* actually 4, 5th bit is transparency */
219   { 0x100000*8+4, 0x80000*8+4,0x80000*8,4,0 },
217   RGN_FRAC(1,3),
218   6,
219   { RGN_FRAC(2,3)+4, RGN_FRAC(2,3)+0,
220     RGN_FRAC(1,3)+4, RGN_FRAC(1,3)+0,
221                   4,               0 },
220222   {
221223      0,1,2,3,8,9,10,11,
222224      256+0,256+1,256+2,256+3,256+8,256+9,256+10,256+11
r1070r1071
228230   512
229231};
230232
233
231234static const gfx_layout fg_layout =
232235{
233236   16,16,
r1070r1071
248251/* Graphics Decode Information */
249252
250253static GFXDECODE_START( dynduke )
251   GFXDECODE_ENTRY( REGION_GFX1, 0, charlayout,   1280, 16 )
252   GFXDECODE_ENTRY( REGION_GFX2, 0, bg_layout,    2048, 32 ) // Really 0
253   GFXDECODE_ENTRY( REGION_GFX3, 0, fg_layout,     512, 16 )
254   GFXDECODE_ENTRY( REGION_GFX4, 0, spritelayout,  768, 32 )
254   GFXDECODE_ENTRY( REGION_GFX1, 0, charlayout,    0x500, 16 )
255   GFXDECODE_ENTRY( REGION_GFX2, 0, bg_layout,     0x000, 128 )
256   GFXDECODE_ENTRY( REGION_GFX3, 0, fg_layout,     0x200, 16 )
257   GFXDECODE_ENTRY( REGION_GFX4, 0, spritelayout,  0x300, 32 )
255258GFXDECODE_END
256259
257260/* Parameters: YM3812 frequency, Oki frequency, Oki memory region */
r1070r1071
291294   MDRV_SCREEN_SIZE(32*8, 32*8)
292295   MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1)
293296   MDRV_GFXDECODE(dynduke)
294   MDRV_PALETTE_LENGTH(2048+1024)   // 2048 real palette, 1024 for transparency kludge
297   MDRV_PALETTE_LENGTH(2048)
295298
296299   MDRV_VIDEO_START(dynduke)
297300   MDRV_VIDEO_UPDATE(dynduke)
r1070r1071
429432   ROM_REGION( 0x180000, REGION_GFX2, ROMREGION_DISPOSE )
430433   ROM_LOAD( "dd.a2",      0x000000, 0x40000, CRC(598f343f) SHA1(eee794d9d0a92e066f00818bfb63e8ca46bda764) ) /* background */
431434   ROM_LOAD( "dd.b2",      0x040000, 0x40000, CRC(41a9088d) SHA1(eb0b7370dc773cb6f5066b044934ffb42bb06587) )
435
432436   ROM_LOAD( "dd.c2",      0x080000, 0x40000, CRC(cc341b42) SHA1(8c3cf09a3a0080a1cd7c1049cb8d11f03de50919) )
433437   ROM_LOAD( "dd.d2",      0x0c0000, 0x40000, CRC(4752b4d7) SHA1(4625b7885ff9d302e78d7324b3592ac5a3cead86) )
438
434439   ROM_LOAD( "dd.de3",      0x100000, 0x40000, CRC(44a4cb62) SHA1(70b2043d0428c90ee22ccd479d9710af24d359f6) )
435440   ROM_LOAD( "dd.ef3",      0x140000, 0x40000, CRC(aa8aee1a) SHA1(8b2b8dcb2287318e314b256f84c23424cfe29462) )
436441
r1070r1071
479484   ROM_LOAD( "dd.b2",      0x040000, 0x40000, CRC(41a9088d) SHA1(eb0b7370dc773cb6f5066b044934ffb42bb06587) )
480485   ROM_LOAD( "dd.c2",      0x080000, 0x40000, CRC(cc341b42) SHA1(8c3cf09a3a0080a1cd7c1049cb8d11f03de50919) )
481486   ROM_LOAD( "dd.d2",      0x0c0000, 0x40000, CRC(4752b4d7) SHA1(4625b7885ff9d302e78d7324b3592ac5a3cead86) )
487
482488   ROM_LOAD( "dd.de3",      0x100000, 0x40000, CRC(44a4cb62) SHA1(70b2043d0428c90ee22ccd479d9710af24d359f6) )
483489   ROM_LOAD( "dd.ef3",      0x140000, 0x40000, CRC(aa8aee1a) SHA1(8b2b8dcb2287318e314b256f84c23424cfe29462) )
484490
src/mame/drivers/expro02.c
r1070r1071
428428   ROM_LOAD( "pm006e.u83", 0x000000, 0x080000, CRC(a7555d9a) SHA1(f95821b3358d9ab03ca9ead38fd358062259d89d) )
429429   ROM_LOAD( "pm206e.u82", 0x080000, 0x080000, CRC(cc978baa) SHA1(59a95bcbaeca9d356f61ea42af4da116afbb1491) )
430430   ROM_LOAD( "pm018e.u94", 0x100000, 0x080000, CRC(f542d708) SHA1(f515cca9e96401303ed45b4372f6079f29b7a999) )
431// ROM_LOAD( "u93",      0x180000, 0x010000  ) // NOT present on this set (empty socket)
431   /* U93 is an empty socket and not used with this set */
432432
433433   ROM_REGION( 0x200000, REGION_GFX2, ROMREGION_DISPOSE )   /* sprites */
434434
r1070r1071
460460   ROM_LOAD16_BYTE( "pm003e.u75", 0x200000, 0x80000, CRC(6bb060fd) SHA1(4fc3946866c5a55e8340b62b5ad9beae723ce0da) )
461461
462462   ROM_REGION16_BE( 0x80000, REGION_USER2, 0 )   /* contains real (non-cartoon) women, used after each 3rd round */
463   ROM_LOAD16_WORD_SWAP( "pm017e.u84", 0x00000, 0x80000, CRC(bc41b6ca) SHA1(0aeaf024dd7c84550e7df27230a1d4f04cc1d61c) )
463   /* U84 is an empty socket and not used with this set */
464464
465465   ROM_REGION( 0x200000, REGION_GFX1, ROMREGION_ERASEFF )   /* sprites */
466466   /* the 06e rom from the other type gals panic board ends up split across 2 roms here */
467467   ROM_LOAD( "pm006e.u83", 0x000000, 0x080000, CRC(a7555d9a) SHA1(f95821b3358d9ab03ca9ead38fd358062259d89d) )
468468   ROM_LOAD( "pm206e.u82", 0x080000, 0x080000, CRC(cc978baa) SHA1(59a95bcbaeca9d356f61ea42af4da116afbb1491) )
469469   ROM_LOAD( "pm018e.u94", 0x100000, 0x080000, CRC(f542d708) SHA1(f515cca9e96401303ed45b4372f6079f29b7a999) )
470// ROM_LOAD( "u93",      0x180000, 0x010000  ) // NOT present on this set (empty socket)
470   /* U93 is an empty socket and not used with this set */
471471
472472   ROM_REGION( 0x200000, REGION_GFX2, ROMREGION_DISPOSE )   /* sprites */
473473
src/mame/drivers/snowbros.c
r1070r1071
15911591static MACHINE_DRIVER_START( wintbob )
15921592   /* basic machine hardware */
15931593   MDRV_IMPORT_FROM(snowbros)
1594   MDRV_CPU_REPLACE("main", M68000, 12000000) /* faster cpu on bootleg? otherwise the gfx and scroll break up */
1594   MDRV_CPU_REPLACE("main", M68000, 10000000) /* 10mhz - Confirmed */
15951595   MDRV_CPU_PROGRAM_MAP(wintbob_readmem,wintbob_writemem)
15961596
15971597   /* video hardware */
r1070r1071
18731873
18741874ROM_START( wintbob )
18751875   ROM_REGION( 0x40000, REGION_CPU1, 0 )   /* 6*64k for 68000 code */
1876   ROM_LOAD16_BYTE( "wb03.bin", 0x00000, 0x10000, CRC(df56e168) SHA1(20dbabdd97e6f3d4bf6500bf9e8476942cb48ae3) )
1877   ROM_LOAD16_BYTE( "wb01.bin", 0x00001, 0x10000, CRC(05722f17) SHA1(9356e2488ea35e0a2978689f2ca6dfa0d57fd2ed) )
1876   ROM_LOAD16_BYTE( "wb3", 0x00000, 0x10000, CRC(b9719767) SHA1(431c97d409f2a5ff7f46116a4d8907e446434431) )
1877   ROM_LOAD16_BYTE( "wb1", 0x00001, 0x10000, CRC(a4488998) SHA1(4e927e31c1b865dbdba2b985c7a819a07e2e81b8) )
1878
1879   /* The wb03.bin below is bad, the set has a different copyright message (IN KOREA is replaced with 1990)
1880       but also clearly suffers from bitrot at the following addresses
1881        4FC2, 5F02, 6642, D6C2, D742
1882       in all cases bit 0x20 is incorrectly set in the bad rom
1883    */
1884
1885//  ROM_LOAD16_BYTE( "wb03.bin", 0x00000, 0x10000, CRC(df56e168) SHA1(20dbabdd97e6f3d4bf6500bf9e8476942cb48ae3) )
1886//  ROM_LOAD16_BYTE( "wb01.bin", 0x00001, 0x10000, CRC(05722f17) SHA1(9356e2488ea35e0a2978689f2ca6dfa0d57fd2ed) )
1887
18781888   ROM_LOAD16_BYTE( "wb04.bin", 0x20000, 0x10000, CRC(53be758d) SHA1(56cf85ba23fe699031d73e8f367a1b8ac837d5f8) )
18791889   ROM_LOAD16_BYTE( "wb02.bin", 0x20001, 0x10000, CRC(fc8e292e) SHA1(857cfeb0be121e64e6117120514ae1f2ffeae4d6) )
18801890
r1070r1071
27472757GAME( 1990, snowbrob, snowbros, snowbros, snowbros, 0, ROT0, "Toaplan", "Snow Bros. - Nick & Tom (set 3)", 0 )
27482758GAME( 1990, snowbroc, snowbros, snowbros, snowbros, 0, ROT0, "Toaplan", "Snow Bros. - Nick & Tom (set 4)", 0 )
27492759GAME( 1990, snowbroj, snowbros, snowbros, snowbroj, 0, ROT0, "Toaplan", "Snow Bros. - Nick & Tom (Japan)", 0 )
2750GAME( 1990, wintbob,  snowbros, wintbob,  snowbros, 0, ROT0, "bootleg", "The Winter Bobble", 0 )
2760GAME( 1990, wintbob,  snowbros, wintbob,  snowbros, 0, ROT0, "[Toaplan] (Sakowa Project Korea bootleg)", "The Winter Bobble (bootleg of Snow Bros.)", 0 )
27512761
27522762GAME( 1995, honeydol, 0,        honeydol, honeydol, 0, ROT0, "Barko Corp.", "Honey Dolls", 0 ) // based on snowbros code..
27532763GAME( 1995, twinadv,  0,        twinadv,  twinadv,  0, ROT0, "Barko Corp.", "Twin Adventure (World)", 0 )
src/mame/drivers/hornet.c
r1070r1071
373373{
374374   if (K037122_reg[chip][0xc] & 0x10000)
375375   {
376      tilemap_set_scrolldx(K037122_layer[chip][1], Machine->screen[0].visarea.min_x, Machine->screen[0].visarea.min_x);
377      tilemap_set_scrolldy(K037122_layer[chip][1], Machine->screen[0].visarea.min_y, Machine->screen[0].visarea.min_y);
376378      tilemap_draw(bitmap, cliprect, K037122_layer[chip][1], 0,0);
377379   }
378380   else
379381   {
382      tilemap_set_scrolldx(K037122_layer[chip][0], Machine->screen[0].visarea.min_x, Machine->screen[0].visarea.min_x);
383      tilemap_set_scrolldy(K037122_layer[chip][0], Machine->screen[0].visarea.min_y, Machine->screen[0].visarea.min_y);
380384      tilemap_draw(bitmap, cliprect, K037122_layer[chip][0], 0,0);
381385   }
382386}
r1070r1071
492496   cpunum_set_input_line(0, INPUT_LINE_IRQ1, ASSERT_LINE);
493497}
494498
499static void hornet_exit(running_machine *machine)
500{
501   voodoo_exit(0);
502}
503
504static void hornet_2board_exit(running_machine *machine)
505{
506   voodoo_exit(0);
507   voodoo_exit(1);
508}
509
495510VIDEO_START( hornet )
496511{
512   add_exit_callback(machine, hornet_exit);
513
497514   if (voodoo_version == 0)
498515      voodoo_start(0, 0, VOODOO_1, 2, 4, 0);
499516   else
r1070r1071
506523
507524VIDEO_START( hornet_2board )
508525{
526   add_exit_callback(machine, hornet_2board_exit);
527
509528   if (voodoo_version == 0)
510529   {
511530      voodoo_start(0, 0, VOODOO_1, 2, 4, 0);
src/mame/drivers/cultures.c
r1070r1071
11/*
2    Jibun wo Migaku cultures School Mahjon Hen
2    Jibun wo Migaku Culture School Mahjong Hen
33    (c)1994 Face
44
55    driver by Pierpaolo Prazzoli
r1070r1071
321321//WRONG!
322322static PALETTE_INIT( cultures )
323323{
324   int c;
324   int c,x;
325325
326326   for (c = 0; c < 256; c++)
327327   {
r1070r1071
338338        b = ((c & 0xc0) >> 4) | i;
339339*/
340340
341      x = ((c >> 4) & 0x0f);
341342
342       palette_set_color_rgb(machine, c, pal4bit(r), pal4bit(g), pal4bit(b));
343      x = ((x & 4) << 1) | ((x & 8) >> 1) | (x & 1);
344
345       palette_set_color_rgb(machine, x | (((c << 4) & 0xf0) ^ 0), pal4bit(r), pal4bit(g), pal4bit(b));
343346   }
344347}
345348
r1070r1071
385388
386389/*
387390
388Jibun wo Migaku cultures School Mahjon Hen
391Jibun wo Migaku Culture School Mahjong Hen
389392(c)1994 Face
390393
391394CPU: Z80
r1070r1071
446449   ROM_RELOAD(               0x000000, 0x020000 )
447450ROM_END
448451
449GAME( 1994, cultures, 0, cultures, cultures, 0, ROT0, "Face", "Jibun wo Migaku cultures School Mahjon Hen", GAME_WRONG_COLORS )
452GAME( 1994, cultures, 0, cultures, cultures, 0, ROT0, "Face", "Jibun wo Migaku Culture School Mahjong Hen", GAME_WRONG_COLORS )
src/mame/drivers/megadriv.h
r1070r1071
11extern DRIVER_INIT( megadrie );
22extern DRIVER_INIT( megadriv );
33extern DRIVER_INIT( megadrij );
4extern DRIVER_INIT( _32x );
54
65INPUT_PORTS_EXTERN(megadriv);
76INPUT_PORTS_EXTERN(aladbl);
src/mame/drivers/vegas.c
r1070r1071
509509 *
510510 *************************************/
511511
512static void vegas_exit(running_machine *machine)
513{
514   voodoo_exit(0);
515}
516
517
512518static VIDEO_START( vegas_voodoo2 )
513519{
520   add_exit_callback(machine, vegas_exit);
521
514522   voodoo_start(0, 0, VOODOO_2, 2, 4, 4);
515523   voodoo_set_vblank_callback(0, vblank_assert);
516524}
r1070r1071
518526
519527static VIDEO_START( vegas_voodoo_banshee )
520528{
529   add_exit_callback(machine, vegas_exit);
530
521531   voodoo_start(0, 0, VOODOO_BANSHEE, 16, 16, 0);
522532   voodoo_set_vblank_callback(0, vblank_assert);
523533}
r1070r1071
525535
526536static VIDEO_START( vegas_voodoo3 )
527537{
538   add_exit_callback(machine, vegas_exit);
539
528540   voodoo_start(0, 0, VOODOO_3, 16, 16, 16);
529541   voodoo_set_vblank_callback(0, vblank_assert);
530542}
src/mame/drivers/system24.c
r1070r1071
21762176   ROM_LOAD16_BYTE( "epr-12186.ic1", 0x000001, 0x20000, CRC(ce76319d) SHA1(0ede61f0700f9161285c768fa97636f0e42b96f8) )
21772177
21782178   ROM_REGION( 0x1c2000, REGION_USER2, 0)
2179   /* this image was repaired using other images, a dump of a known good disk would be preferable */
2180   ROM_LOAD( "ds3-5000-02-repaired.img",         0x000000, 0x1c2000, BAD_DUMP CRC(cefbda69) SHA1(5b47ae0f1584ce1eb697246273ba761bd9e981c1)  )
2179   ROM_LOAD( "ds3-5000-02-.img",         0x000000, 0x1c2000, CRC(cefbda69) SHA1(5b47ae0f1584ce1eb697246273ba761bd9e981c1)  )
21812180ROM_END
21822181
21832182ROM_START( sspiritj )
r1070r1071
22832282   ROM_LOAD16_BYTE( "epr-12186.ic1", 0x000001, 0x20000, CRC(ce76319d) SHA1(0ede61f0700f9161285c768fa97636f0e42b96f8) )
22842283
22852284   ROM_REGION( 0x2000, REGION_USER3, 0 )   /* decryption key */
2285   ROM_LOAD( "317-0058-04c.key", 0x0000, 0x2000,  CRC(16e978cc) SHA1(0e1482b5efa93b732d4cf0990919cb3fc903dca7) )
2286
2287   ROM_REGION( 0x1c2000, REGION_USER2, 0)
2288   ROM_LOAD( "ds3-5000-04c.img",    0x000000, 0x1c2000, CRC(5edc01a5) SHA1(8eb1bf41f533d16c12930f5831f8bccd4d8de4f7) )
2289ROM_END
2290
2291ROM_START( crkdownu )
2292   ROM_REGION( 0x40000, REGION_CPU1, 0 ) /* 68000 code */
2293   ROM_LOAD16_BYTE( "epr-12187.ic2", 0x000000, 0x20000, CRC(e83783f3) SHA1(4b3b32df7de85aef9cd77c8a4ffc17e10466b638) )
2294   ROM_LOAD16_BYTE( "epr-12186.ic1", 0x000001, 0x20000, CRC(ce76319d) SHA1(0ede61f0700f9161285c768fa97636f0e42b96f8) )
2295
2296   ROM_REGION( 0x2000, REGION_USER3, 0 )   /* decryption key */
22862297   ROM_LOAD( "317-0058-04d.key", 0x0000, 0x2000,  CRC(934ac358) SHA1(73418e22c9d201bc3fec5c63284858958c010e05) )
22872298
22882299   ROM_REGION( 0x1c2000, REGION_USER2, 0)
r1070r1071
24062417/* 02 */GAME( 1988, sspirtfc, sspirits, system24, sspirits, sspirits, ROT270, "Sega", "Scramble Spirits (FD1094 317-0058-02c)",GAME_NOT_WORKING ) /* MISSING disk image */
24072418/* 03 */GAME( 1988, gground,  0,        system24, gground,  gground,  ROT270, "Sega", "Gain Ground (World, FD1094 317-0058-03c?)", 0 )
24082419/* 03 */GAME( 1988, ggroundj, gground,  system24, ggroundj, gground,  ROT270, "Sega", "Gain Ground (Japan, FD1094 317-0058-03b)", 0 )
2409/* 04 */GAME( 1989, crkdown,  0,        system24, crkdown,  crkdown,  ROT0,   "Sega", "Crack Down (US, FD1094 317-0058-04d)", GAME_IMPERFECT_GRAPHICS ) // clipping probs / solid layer probs? (radar display)
2420/* 04 */GAME( 1989, crkdown,  0,        system24, crkdown,  crkdown,  ROT0,   "Sega", "Crack Down (World, FD1094 317-0058-04c)", GAME_IMPERFECT_GRAPHICS ) // clipping probs / solid layer probs? (radar display)
2421/* 04 */GAME( 1989, crkdownu, crkdown,  system24, crkdown,  crkdown,  ROT0,   "Sega", "Crack Down (US, FD1094 317-0058-04d)", GAME_IMPERFECT_GRAPHICS ) // clipping probs / solid layer probs? (radar display)
24102422/* 04 */GAME( 1989, crkdownj, crkdown,  system24, crkdown,  crkdown,  ROT0,   "Sega", "Crack Down (Japan, FD1094 317-0058-04b)", GAME_IMPERFECT_GRAPHICS ) // clipping probs / solid layer probs? (radar display)
24112423/* 05 */GAME( 1989, sgmast,   0,        system24, bnzabros, sgmast,   ROT0,   "Sega", "Super Masters Golf (FD1094 317-0058-05d?)", GAME_NOT_WORKING|GAME_UNEMULATED_PROTECTION ) // NOT decrypted
24122424/* 05 */GAME( 1989, sgmastc,  sgmast,   system24, bnzabros, sgmast,   ROT0,   "Sega", "Jumbo Ozaki Super Masters Golf (World, FD1094 317-0058-05c)", GAME_NOT_WORKING ) // controls, some gfx offset / colour probs?
src/mame/drivers/ddenlovr.c
r1070r1071
99Sound: (AY-3-8910) + YM2413 + MSM6295
1010Other: Real Time Clock (Oki MSM6242B or 72421B)
1111
12---------------------------------------------------------------------------------------------------------------------------
13Year + Game                 Board           CPU     Sound                       Custom                              Notes
14---------------------------------------------------------------------------------------------------------------------------
1592 Monkey Mole Panic                        2xZ80   AY8910 + YM2413 + M6295     Dynax NL-001                        8251
1693 Animalandia Jr.                          2xZ80   AY8910 + YM2413 + M6295     NL-001, NL-003 (x2), NL-004 (x2)    TMP82C51 (USART)
1793 Quiz Channel Question    N7311208L1-2    Z80              YM2413 + M6295     NAKANIHON NL-002
1893 The First Funky Fighter  N7403208L-2     2xZ80   YM2149 + YM2413 + M6295     NL-001, NL-002, NL-005
1994 Mahjong Mysterious World D7107058L1-1    Z80     YM2149 + YM2413 + M6295
2094 Quiz 365                                 68000   AY8910 + YM2413 + M6295
2194 Rong Rong                                Z80              YM2413 + M6295     NAKANIHON NL-002
2295 Mahjong Dai Chuuka Ken   D11107218L1     Z80     AY8910 + YM2413 + M6295     70C160F009
2395 Nettoh Quiz Champion                     68000   AY8910 + YM2413 + M6295
2495 Don Den Lover Vol 1 (J)  D1120901L8      68000   YMZ284 + YM2413 + M6295     NAKANIHON NL-005
2596 Don Den Lover Vol 1 (HK) D11309208L1     68000   YMZ284 + YM2413 + M6295     NAKANIHON NL-005
2696 Panel & Variety Akamaru                  68000   YMZ284 + YM2413 + M6295     NAKANIHON NL-005
2796 Mahjong Fantastic Love   NS5000101 + ?   Z80     YMZ284 + YM2413 + M6295     NAKANIHON NL-005
2896 Hana Kanzashi                            Z80              YM2413 + M6295     70C160F011?
2997 Hana Kagerou                             Z80              YM2413 + M6295     70C160F011
3098 Mahjong Chuukanejyo      D11107218L1     Z80     AY8910 + YM2413 + M6295     70C160F009
3198 Mahjong Reach Ippatsu                    Z80              YM2413 + M6295     70C160F011
32---------------------------------------------------------------------------------------------------------------------------
12-----------------------------------------------------------------------------------------------------------------------------
13Year + Game                 Board             CPU     Sound                    Custom                            Notes
14-----------------------------------------------------------------------------------------------------------------------------
1592 Monkey Mole Panic                          2xZ80   AY8910 + YM2413 + M6295  NL-001 1108(x2)   1427(x2)         8251
1693 Animalandia Jr.                            2xZ80   AY8910 + YM2413 + M6295  NL-001 NL-003(x2) NL-004(x2)      TMP82C51
1793 Quiz Channel Question  N7311208L1-2        Z80              YM2413 + M6295  NL-002 1108F0405  1427F0071
1893 First Funky Fighter    N7403208L-2         2xZ80   YM2149 + YM2413 + M6295  NL-001 NL-002     NL-005
1994 Mysterious World       D7107058L1-1        Z80     YM2149 + YM2413 + M6295  NL-002 1108F0405  1427F0071 4L02?
2094 Mysterious Universe    D7107058L1-1        Z80     YM2149 + YM2413 + M6295  NL-002 1108F0405  1427F0071
2194 Mysterious Orient      D7107058L1-1        Z80     YM2149 + YM2413 + M6295  NL-002 1108F0405  1427F0071
2294 Quiz 365                                   68000   AY8910 + YM2413 + M6295
2394 Rong Rong (J)          N8010178L1          Z80              YM2413 + M6295  NL-002 1108F0405  1427F0071 4L02F2637
2494 Hana Ginga             D8102048L1          Z80     YM2149 + YM2413 + M6295  NL-002 1108F0405  1427F0071 4L02?
2594 Super Hana Paradise    N8010178L1+N73RSUB  Z80              YM2413 + M6295  NL-002 1108F0406  1427F0071 4L02F2637
2695 Dai Chuuka Ken         D11107218L1         Z80     AY8910 + YM2413 + M6295  70C160F009
2795 Hana Gokou             N83061581L1         Z80     AY8910 + YM2413 + M6295  NL-002 1108?      1427?     4L02?
2895 Nettoh Quiz Champion                       68000   AY8910 + YM2413 + M6295
2995 Don Den Lover (J)      D1120901L8          68000   YMZ284 + YM2413 + M6295  NL-005
3096 Don Den Lover (HK)     D11309208L1         68000   YMZ284 + YM2413 + M6295  NL-005
3196 Panel&Variety Akamaru                      68000   YMZ284 + YM2413 + M6295  NL-005
3296 Fantasic Love          NS5000101+?         Z80     YMZ284 + YM2413 + M6295  NL-005
3396 Hana Kanzashi                              Z80              YM2413 + M6295  70C160F011?
3497 Hana Kagerou                               Z80              YM2413 + M6295  70C160F011
3598 Chuukanejyo            D11107218L1         Z80     AY8910 + YM2413 + M6295  70C160F009
3698 Reach Ippatsu                              Z80              YM2413 + M6295  70C160F011
37-----------------------------------------------------------------------------------------------------------------------------
3338
3439Notes:
3540
r1070r1071
27492754   hginga_rombank = data;
27502755}
27512756
2752static READ8_HANDLER( hginga_rand_r )
2757// similar to rongrong
2758static READ8_HANDLER( hginga_protection_r )
27532759{
27542760   UINT8 *rom = memory_region(REGION_CPU1);
27552761   if (hginga_rombank & 0x10)
r1070r1071
27612767   AM_RANGE(0x0000, 0x5fff) AM_READ( MRA8_ROM            )   // ROM
27622768   AM_RANGE(0x6000, 0x6fff) AM_READ( MRA8_RAM            )   // RAM
27632769   AM_RANGE(0x7000, 0x7fff) AM_READ( MRA8_BANK2         )   // RAM (Banked)
2764   AM_RANGE(0xf601, 0xf601) AM_READ( hginga_rand_r         )
2770   AM_RANGE(0xf601, 0xf601) AM_READ( hginga_protection_r   )
27652771   AM_RANGE(0x8000, 0xffff) AM_READ( MRA8_BANK1         )   // ROM/RAM (Banked)
27662772ADDRESS_MAP_END
27672773
r1070r1071
27692775   AM_RANGE(0x6000, 0x6fff) AM_WRITE( MWA8_RAM            )   // RAM
27702776   AM_RANGE(0x7000, 0x7fff) AM_WRITE( MWA8_BANK2         )   // RAM (Banked)
27712777   AM_RANGE(0xf000, 0xf1ff) AM_WRITE( rongrong_palette_w   )   // RAM enabled by bit 4 of rombank
2772   AM_RANGE(0xf705, 0xf706) AM_WRITE( MWA8_NOP            )
2778   AM_RANGE(0xf700, 0xf706) AM_WRITE( MWA8_NOP            )
27732779ADDRESS_MAP_END
27742780
27752781static READ8_HANDLER( hginga_dsw_r )
r1070r1071
28202826         // bit 1 = out counter
28212827         // bit 2 = 1 if bet on
28222828         // bit 3 = 1 if bet on
2823         // bit 8?
2829         // bit 7?
28242830         coin_counter_w(0, data & 1);
2831#ifdef MAME_DEBUG
28252832//          popmessage("COINS %02x",data);
2833#endif
28262834         hginga_coins = data;
28272835         break;
28282836      default:
r1070r1071
29112919ADDRESS_MAP_END
29122920
29132921
2922/***************************************************************************
2923                             Hanafuda Hana Gokou
2924***************************************************************************/
29142925
2926UINT8 hgokou_hopper;
2927
2928static UINT8 hgokou_player_r(int player)
2929{
2930   UINT8 hopper_bit = ((hgokou_hopper && !(cpu_getcurrentframe()%10)) ? 0 : (1<<6));
2931
2932   if (!(dynax_select2 & 0x01))   return readinputport(player * 5 + 1) | hopper_bit;
2933   if (!(dynax_select2 & 0x02))   return readinputport(player * 5 + 2) | hopper_bit;
2934   if (!(dynax_select2 & 0x04))   return readinputport(player * 5 + 3) | hopper_bit;
2935   if (!(dynax_select2 & 0x08))   return readinputport(player * 5 + 4) | hopper_bit;
2936   if (!(dynax_select2 & 0x10))   return readinputport(player * 5 + 5) | hopper_bit;
2937
2938   return 0x7f;   // bit 7 = blitter busy, bit 6 = hopper
2939}
2940
2941static READ8_HANDLER( hgokou_input_r )
2942{
2943   switch (hginga_select)
2944   {
2945      case 0x20:   return readinputport(0);
2946      case 0x21:   return hgokou_player_r(1);
2947      case 0x22:   return hgokou_player_r(0);
2948      case 0x23:   return hginga_coins;
2949   }
2950   logerror("%06x: warning, unknown bits read, hginga_select = %02x\n", activecpu_get_pc(), hginga_select);
2951   return 0xff;
2952}
2953
2954static WRITE8_HANDLER( hgokou_input_w )
2955{
2956   switch (hginga_select)
2957   {
2958      case 0x2c:
2959         // bit 0 = coin counter
2960         // bit 1 = out counter
2961         // bit 2 = hopper
2962         coin_counter_w(0, data & 1);
2963         hgokou_hopper = data & 0x04;
2964#ifdef MAME_DEBUG
2965//          popmessage("COINS %02x",data);
2966#endif
2967         hginga_coins = data;
2968         break;
2969
2970      case 0x2d:   dynax_select2 = data;   break;
2971
2972      case 0x2f:   break;   // ? written with 2f
2973
2974      default:
2975         logerror("%04x: input_w with select = %02x, data = %02x\n",activecpu_get_pc(),hginga_select,data);
2976   }
2977}
2978
2979// similar to rongrong
2980static READ8_HANDLER( hgokou_protection_r )
2981{
2982   UINT8 *rom = memory_region(REGION_CPU1);
2983   if (hginga_rombank == 0)
2984      return hanakanz_rand_r(0);
2985   return rom[0x10000 + 0x8000 * (hginga_rombank & 0x7) + 0xe601 - 0x8000];
2986}
2987
2988static ADDRESS_MAP_START( hgokou_readmem, ADDRESS_SPACE_PROGRAM, 8 )
2989   AM_RANGE(0x0000, 0x5fff) AM_READ(MRA8_ROM               )   // ROM
2990   AM_RANGE(0x6000, 0x6fff) AM_READ(MRA8_RAM               )   // RAM
2991   AM_RANGE(0x7000, 0x7fff) AM_READ(MRA8_BANK2               )   // RAM (Banked)
2992   AM_RANGE(0xe601, 0xe601) AM_READ(hgokou_protection_r      )
2993   AM_RANGE(0x8000, 0xffff) AM_READ(MRA8_BANK1               )   // ROM (Banked)
2994ADDRESS_MAP_END
2995static ADDRESS_MAP_START( hgokou_writemem, ADDRESS_SPACE_PROGRAM, 8 )
2996   AM_RANGE(0x6000, 0x6fff) AM_WRITE(MWA8_RAM               )   // RAM
2997   AM_RANGE(0x7000, 0x7fff) AM_WRITE(MWA8_BANK2            )   // RAM (Banked)
2998   AM_RANGE(0xe000, 0xe1ff) AM_WRITE(rongrong_palette_w      )
2999   AM_RANGE(0xe700, 0xe706) AM_WRITE(MWA8_NOP               )
3000ADDRESS_MAP_END
3001
3002
3003static ADDRESS_MAP_START( hgokou_readport, ADDRESS_SPACE_IO, 8 )   ADDRESS_MAP_FLAGS( AMEF_ABITS(8) )
3004   AM_RANGE(0x03, 0x03) AM_READ(rongrong_gfxrom_r         )
3005   AM_RANGE(0x1c, 0x1c) AM_READ(MRA8_NOP               )   // ? ack on RTC int
3006   AM_RANGE(0x20, 0x2f) AM_READ(msm6242_r               )   // 6242RTC
3007   AM_RANGE(0x58, 0x58) AM_READ(unk_r                  )   // ? must be 78 on startup
3008   AM_RANGE(0x62, 0x62) AM_READ(hgokou_input_r            )
3009   AM_RANGE(0x80, 0x80) AM_READ(OKIM6295_status_0_r      )
3010   AM_RANGE(0x84, 0x84) AM_READ(AY8910_read_port_0_r      )
3011   AM_RANGE(0xb0, 0xb0) AM_READ(hanakanz_rand_r         )
3012ADDRESS_MAP_END
3013static ADDRESS_MAP_START( hgokou_writeport, ADDRESS_SPACE_IO, 8 )   ADDRESS_MAP_FLAGS( AMEF_ABITS(8) )
3014   AM_RANGE(0x00, 0x01) AM_WRITE(hginga_blitter_w         )
3015   AM_RANGE(0x1c, 0x1c) AM_WRITE(mjmyster_rambank_w      )
3016   AM_RANGE(0x1e, 0x1e) AM_WRITE(hginga_rombank_w         )
3017   AM_RANGE(0x20, 0x2f) AM_WRITE(msm6242_w               )   // 6242RTC
3018   AM_RANGE(0x40, 0x43) AM_WRITE(dynax_palette_base_w      )
3019   AM_RANGE(0x44, 0x47) AM_WRITE(dynax_palette_mask_w      )
3020   AM_RANGE(0x48, 0x4b) AM_WRITE(dynax_transparency_pen_w   )
3021   AM_RANGE(0x4c, 0x4f) AM_WRITE(dynax_transparency_mask_w   )
3022   AM_RANGE(0x54, 0x54) AM_WRITE(dynax_bgcolor_w         )
3023   AM_RANGE(0x55, 0x55) AM_WRITE(dynax_priority_w         )
3024   AM_RANGE(0x56, 0x56) AM_WRITE(dynax_layer_enable_w      )
3025   AM_RANGE(0x60, 0x60) AM_WRITE(hginga_input_w         )
3026   AM_RANGE(0x61, 0x61) AM_WRITE(hgokou_input_w         )
3027   AM_RANGE(0x80, 0x80) AM_WRITE(OKIM6295_data_0_w         )
3028   AM_RANGE(0x82, 0x82) AM_WRITE(YM2413_register_port_0_w   )
3029   AM_RANGE(0x83, 0x83) AM_WRITE(YM2413_data_port_0_w      )
3030   AM_RANGE(0x86, 0x86) AM_WRITE(AY8910_write_port_0_w   )
3031   AM_RANGE(0x88, 0x88) AM_WRITE(AY8910_control_port_0_w   )
3032ADDRESS_MAP_END
3033
3034
3035/***************************************************************************
3036                            Super Hana Paradise
3037***************************************************************************/
3038
3039static WRITE8_HANDLER( hparadis_select_w )
3040{
3041   UINT8 *rom = memory_region(REGION_CPU1);
3042
3043   dynax_select = data;
3044   hginga_ip = 0;
3045
3046   memory_set_bankptr(1, &rom[0x10000 + 0x8000 * (data & 0x07)]);
3047   memory_set_bankptr(2, &rom[0x50000 + 0x1000 * ((data & 0xe0) >> 5)]);
3048}
3049
3050
3051static READ8_HANDLER( hparadis_input_r )
3052{
3053   switch (hginga_select)
3054   {
3055      case 0x00:   return readinputport(0);            // P1 (Joy)
3056      case 0x01:   return readinputport(1);            // P2 (Joy)
3057      case 0x02:   return readinputport(2);            // Coins
3058      case 0x0d:   return 0x00;
3059      case 0x80:   return readinputport(3 + hginga_ip++);   // P1 (Keys)
3060      case 0x81:   return readinputport(8 + hginga_ip++);   // P2 (Keys)
3061   }
3062   logerror("%06x: warning, unknown bits read, hginga_select = %02x\n", activecpu_get_pc(), hginga_select);
3063   return 0xff;
3064}
3065
3066static READ8_HANDLER( hparadis_dsw_r )
3067{
3068   if (!(dynax_select & 0x01))   return readinputport(13);
3069   if (!(dynax_select & 0x02))   return readinputport(14);
3070   if (!(dynax_select & 0x04))   return 0xff;
3071   if (!(dynax_select & 0x08))   return 0xff;
3072   if (!(dynax_select & 0x10))   return readinputport(15);
3073   return 0xff;
3074}
3075
3076static WRITE8_HANDLER( hparadis_coin_w )
3077{
3078   switch ( hginga_select )
3079   {
3080      case 0x0c:   coin_counter_w(0, data & 1);   break;
3081      case 0x0d:   break;
3082      default:
3083         logerror("%04x: coins_w with select = %02x, data = %02x\n",activecpu_get_pc(),hginga_select,data);
3084   }
3085}
3086
3087static ADDRESS_MAP_START( hparadis_readmem, ADDRESS_SPACE_PROGRAM, 8 )
3088   AM_RANGE(0x0000, 0x5fff) AM_READ(MRA8_ROM               )   // ROM
3089   AM_RANGE(0x6000, 0x6fff) AM_READ(MRA8_RAM               )   // RAM
3090   AM_RANGE(0x7000, 0x7fff) AM_READ(MRA8_BANK2               )   // RAM (Banked)
3091   AM_RANGE(0x8000, 0xffff) AM_READ(MRA8_BANK1               )   // ROM (Banked)
3092ADDRESS_MAP_END
3093static ADDRESS_MAP_START( hparadis_writemem, ADDRESS_SPACE_PROGRAM, 8 )
3094   AM_RANGE(0x6000, 0x6fff) AM_WRITE(MWA8_RAM               )   // RAM
3095   AM_RANGE(0x7000, 0x7fff) AM_WRITE(MWA8_BANK2            )   // RAM (Banked)
3096   AM_RANGE(0xc000, 0xc1ff) AM_WRITE(rongrong_palette_w      )
3097ADDRESS_MAP_END
3098
3099// the RTC seems unused
3100static ADDRESS_MAP_START( hparadis_readport, ADDRESS_SPACE_IO, 8 )   ADDRESS_MAP_FLAGS( AMEF_ABITS(8) )
3101   AM_RANGE(0x03, 0x03) AM_READ(rongrong_gfxrom_r         )
3102   AM_RANGE(0x1b, 0x1b) AM_READ(rongrong_blitter_busy_r   )
3103   AM_RANGE(0x1c, 0x1c) AM_READ(hparadis_dsw_r            )
3104   AM_RANGE(0x40, 0x40) AM_READ(OKIM6295_status_0_r      )
3105   AM_RANGE(0x98, 0x98) AM_READ(unk_r                  )   // ? must be 78 on startup
3106   AM_RANGE(0xa2, 0xa3) AM_READ(hparadis_input_r         )
3107ADDRESS_MAP_END
3108static ADDRESS_MAP_START( hparadis_writeport, ADDRESS_SPACE_IO, 8 )   ADDRESS_MAP_FLAGS( AMEF_ABITS(8) )
3109   AM_RANGE(0x00, 0x01) AM_WRITE(rongrong_blitter_w      )
3110   AM_RANGE(0x1b, 0x1b) AM_WRITE(rongrong_blitter_busy_w   )
3111   AM_RANGE(0x1e, 0x1e) AM_WRITE(hparadis_select_w         )
3112   AM_RANGE(0x40, 0x40) AM_WRITE(OKIM6295_data_0_w         )
3113   AM_RANGE(0x60, 0x60) AM_WRITE(YM2413_register_port_0_w   )
3114   AM_RANGE(0x61, 0x61) AM_WRITE(YM2413_data_port_0_w      )
3115   AM_RANGE(0x80, 0x83) AM_WRITE(dynax_palette_base_w      )
3116   AM_RANGE(0x84, 0x87) AM_WRITE(dynax_palette_mask_w      )
3117   AM_RANGE(0x88, 0x8b) AM_WRITE(dynax_transparency_pen_w   )
3118   AM_RANGE(0x8c, 0x8f) AM_WRITE(dynax_transparency_mask_w   )
3119   AM_RANGE(0x94, 0x94) AM_WRITE(dynax_bgcolor_w         )
3120   AM_RANGE(0x95, 0x95) AM_WRITE(dynax_priority_w         )
3121   AM_RANGE(0x96, 0x96) AM_WRITE(dynax_layer_enable_w      )
3122   AM_RANGE(0xa0, 0xa0) AM_WRITE(hginga_input_w         )
3123   AM_RANGE(0xa1, 0xa1) AM_WRITE(hparadis_coin_w         )
3124   AM_RANGE(0xc2, 0xc2) AM_WRITE(MWA8_NOP               )   // enables palette RAM at c000
3125ADDRESS_MAP_END
3126
3127
3128/***************************************************************************
3129                          Mahjong Mysterious World
3130***************************************************************************/
3131
29153132static READ8_HANDLER( mjmywrld_coins_r )
29163133{
29173134   switch( dynax_select2 )
r1070r1071
30543271
30553272
30563273/***************************************************************************
3057                          Mahjong Fantastic Love
3274                          Mahjong Fantasic Love
30583275***************************************************************************/
30593276
30603277static WRITE8_HANDLER( mjflove_rombank_w )
r1070r1071
35293746   PORT_BIT(  0x01, IP_ACTIVE_LOW, IPT_COIN1    )
35303747   PORT_BIT(  0x02, IP_ACTIVE_LOW, IPT_COIN2    )
35313748   PORT_BIT(  0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
3532   PORT_BIT(  0x08, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME(DEF_STR( Test )) PORT_CODE(KEYCODE_F1)   /* Test */
3749   PORT_BIT(  0x08, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME(DEF_STR( Test )) PORT_CODE(KEYCODE_F1) PORT_TOGGLE
35333750   PORT_BIT(  0x10, IP_ACTIVE_LOW, IPT_UNKNOWN  )
35343751   PORT_BIT(  0x20, IP_ACTIVE_LOW, IPT_SPECIAL  )   // ? quiz365
35353752   PORT_BIT(  0x40, IP_ACTIVE_LOW, IPT_SPECIAL  )   // ? blitter irq flag ?
r1070r1071
35493766    PORT_DIPNAME( 0x10, 0x10, DEF_STR( Free_Play ) )
35503767     PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
35513768     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3552    PORT_DIPNAME( 0x20, 0x20, "Help" )
3769    PORT_DIPNAME( 0x20, 0x20, "Helps" )
3770    PORT_DIPSETTING(    0x00, "2" )
35533771    PORT_DIPSETTING(    0x20, "3" )
3554    PORT_DIPSETTING(    0x00, "2" )
35553772    PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) )
35563773   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
35573774    PORT_DIPSETTING(    0x40, DEF_STR( On ) )
r1070r1071
35603777     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
35613778
35623779     PORT_START   // IN4 - DSW
3563    PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
3564     PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
3565     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3566    PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
3567     PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
3568     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3569    PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
3570     PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
3571     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3572    PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
3573     PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
3574     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3575    PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
3576     PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
3577     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3578    PORT_DIPNAME( 0x20, 0x20, "VS Round" )
3579    PORT_DIPSETTING(    0x20, "1" )
3580    PORT_DIPSETTING(    0x00, "2" )
3780    PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
3781     PORT_DIPSETTING(    0x02, DEF_STR( Easy ) )
3782     PORT_DIPSETTING(    0x03, DEF_STR( Normal ) )
3783     PORT_DIPSETTING(    0x01, DEF_STR( Hard ) )
3784     PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
3785    PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Unknown ) )
3786     PORT_DIPSETTING(    0x0c, "0" )
3787     PORT_DIPSETTING(    0x08, "1" )
3788     PORT_DIPSETTING(    0x04, "2" )
3789     PORT_DIPSETTING(    0x00, "3" )
3790    PORT_DIPNAME( 0x30, 0x30, "VS Rounds" )
3791     PORT_DIPSETTING(    0x30, "1" )
3792     PORT_DIPSETTING(    0x20, "2" )
3793     PORT_DIPSETTING(    0x10, "3" )
3794//  PORT_DIPSETTING(    0x00, "3" )
35813795    PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
35823796     PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
35833797     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
r1070r1071
35863800     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
35873801
35883802     PORT_START   // IN5 - DSW
3589    PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
3803    PORT_DIPNAME( 0x01, 0x01, DEF_STR( Flip_Screen ) )
35903804     PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
35913805     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3592    PORT_DIPNAME( 0x02, 0x02, "Test Mode" )
3593     PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
3594     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3806    PORT_SERVICE( 0x02, IP_ACTIVE_LOW )
35953807    PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
35963808     PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
35973809     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
r1070r1071
53185530   PORT_BIT( 0xbf, IP_ACTIVE_LOW, IPT_UNKNOWN   )
53195531INPUT_PORTS_END
53205532
5533INPUT_PORTS_START( hgokou )
5534   PORT_START   // IN0
5535   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE3   )   // medal out
5536   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN   )
5537   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE  ) PORT_NAME(DEF_STR( Test )) PORT_CODE(KEYCODE_F1)   PORT_TOGGLE
5538   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE1   )   // analyzer
5539   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE2   )   // data clear
5540   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2   )   // note
5541   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1   )
5542   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN   )
5543
5544   // keyb 1
5545   PORT_START   // IN1
5546   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("1") PORT_CODE(KEYCODE_1_PAD)   // A
5547   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("5") PORT_CODE(KEYCODE_5_PAD)   // E
5548   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN         )   // I
5549   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME(DEF_STR( Yes )) PORT_CODE(KEYCODE_Y)   // M
5550   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_SCORE   )   // Kan
5551   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1         )
5552
5553   PORT_START   // IN2
5554   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("2") PORT_CODE(KEYCODE_2_PAD)   // B
5555   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("6") PORT_CODE(KEYCODE_6_PAD)   // F
5556   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN         )   // J
5557   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME(DEF_STR( No )) PORT_CODE(KEYCODE_N)   // N
5558   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_SMALL   )   // Reach
5559   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN         )   // BET
5560
5561   PORT_START   // IN3
5562   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("3") PORT_CODE(KEYCODE_3_PAD)   // C
5563   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN      )   // G
5564   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN      )   // K
5565   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_BIG   )   // Chi
5566   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN      )   // Ron
5567   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN      )
5568
5569   PORT_START   // IN4
5570   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("4") PORT_CODE(KEYCODE_4_PAD)   // D
5571   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN            )   // H
5572   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN            )   // L
5573   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_DOUBLE_UP   )   // PON
5574   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN            )
5575   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN            )
5576
5577   PORT_START   // IN5
5578   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN   )
5579   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN   )   // "t"
5580   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN   )   // "w"
5581   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN   )
5582   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN   )   // "b"
5583   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN   )   // "s"
5584
5585   // keyb 2
5586   PORT_START   // IN6
5587   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_A      )   PORT_PLAYER(2)   // A
5588   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_E      )   PORT_PLAYER(2)   // E
5589   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN         )   // I
5590   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_M      )   PORT_PLAYER(2)   // M
5591   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_SCORE   )   PORT_PLAYER(2)   // Kan
5592   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2         )
5593
5594   PORT_START   // IN7
5595   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_B      )   PORT_PLAYER(2)   // B
5596   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_F      )   PORT_PLAYER(2)   // F
5597   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN         )   // J
5598   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_N      )   PORT_PLAYER(2)   // N
5599   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_SMALL   )   PORT_PLAYER(2)   // Reach
5600   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN         )   // BET
5601
5602   PORT_START   // IN8
5603   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_C   )   PORT_PLAYER(2)   // C
5604   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN      )   PORT_PLAYER(2)   // G
5605   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN      )   // K
5606   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_BIG   )   PORT_PLAYER(2)   // Chi
5607   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN      )   // Ron
5608   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN      )
5609
5610   PORT_START   // IN9
5611   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_D         )   PORT_PLAYER(2)   // D
5612   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN            )   PORT_PLAYER(2)   // H
5613   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN            )   // L
5614   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_DOUBLE_UP   )   PORT_PLAYER(2)   // PON
5615   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN            )
5616   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN            )
5617
5618   PORT_START   // IN10
5619   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN   )
5620   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN   )   // "t"
5621   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN   )   // "w"
5622   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN   )
5623   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN   )   // "b"
5624   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN   )   // "s"
5625
5626   PORT_START   // IN11 - DSW4
5627   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Demo_Sounds ) )
5628   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
5629   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
5630   PORT_DIPNAME( 0x02, 0x02, "Unknown 4-1" )
5631   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
5632   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
5633   PORT_DIPNAME( 0x04, 0x04, "Girls" )
5634   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
5635   PORT_DIPSETTING(    0x04, DEF_STR( On ) )
5636   PORT_DIPNAME( 0x08, 0x08, "Unknown 4-3" )
5637   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
5638   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
5639   PORT_DIPNAME( 0x10, 0x10, "Change Cards" )
5640   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
5641   PORT_DIPSETTING(    0x10, DEF_STR( On ) )
5642   PORT_DIPNAME( 0x20, 0x20, "Unknown 4-5" )
5643   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
5644   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
5645   PORT_DIPNAME( 0x40, 0x40, "Unknown 4-6" )
5646   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
5647   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
5648   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
5649   PORT_DIPNAME( 0x80, 0x00, "Cards Labels" )
5650   PORT_DIPSETTING(    0x80, "Numbers" )
5651   PORT_DIPSETTING(    0x00, "Letters" )
5652
5653   PORT_START   // IN12 - DSW3
5654   PORT_DIPNAME( 0x03, 0x03, "Unknown 3-0&1" )
5655   PORT_DIPSETTING(    0x03, "1" )
5656   PORT_DIPSETTING(    0x02, "2" )
5657   PORT_DIPSETTING(    0x01, "3" )
5658   PORT_DIPSETTING(    0x00, "4" )
5659   PORT_DIPNAME( 0x04, 0x04, "Unknown 3-2" )
5660   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
5661   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
5662   PORT_DIPNAME( 0x18, 0x18, "Unknown 3-3&4" )
5663   PORT_DIPSETTING(    0x18, "10" )
5664   PORT_DIPSETTING(    0x10, "20" )
5665   PORT_DIPSETTING(    0x08, "30" )
5666   PORT_DIPSETTING(    0x00, "50" )
5667   PORT_DIPNAME( 0x20, 0x20, "Unknown 3-5" )
5668   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
5669   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
5670   PORT_DIPNAME( 0xc0, 0xc0, "Unknown 3-6&7" )
5671   PORT_DIPSETTING(    0xc0, "0" )
5672   PORT_DIPSETTING(    0x80, "1" )
5673   PORT_DIPSETTING(    0x40, "2" )
5674   PORT_DIPSETTING(    0x00, "3" )
5675
5676   PORT_START   // IN13 - DSW2
5677   PORT_DIPNAME( 0x03, 0x03, "Unknown 2-0&1" )
5678   PORT_DIPSETTING(    0x03, "1" )
5679   PORT_DIPSETTING(    0x02, "2" )
5680   PORT_DIPSETTING(    0x01, "5" )
5681   PORT_DIPSETTING(    0x00, "10" )
5682   PORT_DIPNAME( 0x04, 0x04, "Unknown 2-2" )
5683   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
5684   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
5685   PORT_DIPNAME( 0x08, 0x08, "Unknown 2-3" )
5686   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
5687   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
5688   PORT_DIPNAME( 0x30, 0x30, "Odds Rate" )
5689   PORT_DIPSETTING(    0x30, "2 5 6 20 50 100" )
5690   PORT_DIPSETTING(    0x20, "2 5 6 20 50 200" )
5691   PORT_DIPSETTING(    0x10, "2 5 6 20 50 250" )
5692   PORT_DIPSETTING(    0x00, "2 5 6 20 50 300" )
5693   PORT_DIPNAME( 0xc0, 0xc0, "Unknown 2-6&7" )
5694   PORT_DIPSETTING(    0xc0, "50" )
5695   PORT_DIPSETTING(    0x80, "60" )
5696   PORT_DIPSETTING(    0x40, "70" )
5697   PORT_DIPSETTING(    0x00, "80" )
5698
5699   PORT_START   // IN14 - DSW1
5700   PORT_DIPNAME( 0x07, 0x07, "Unknown 1-0&1&2" )
5701   PORT_DIPSETTING(    0x07, "0" )
5702   PORT_DIPSETTING(    0x06, "1" )
5703   PORT_DIPSETTING(    0x05, "2" )
5704   PORT_DIPSETTING(    0x04, "3" )
5705   PORT_DIPSETTING(    0x03, "4" )
5706   PORT_DIPSETTING(    0x02, "5" )
5707   PORT_DIPSETTING(    0x01, "6" )
5708   PORT_DIPSETTING(    0x00, "7" )
5709   PORT_DIPNAME( 0x08, 0x08, "Unknown 1-3" )
5710   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
5711   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
5712   PORT_DIPNAME( 0x10, 0x10, "Unknown 1-4" )
5713   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
5714   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
5715   PORT_DIPNAME( 0x60, 0x60, "Unknown 1-5&6" )
5716   PORT_DIPSETTING(    0x60, "0" )
5717   PORT_DIPSETTING(    0x40, "1" )
5718   PORT_DIPSETTING(    0x20, "2" )
5719   PORT_DIPSETTING(    0x00, "3" )
5720   PORT_DIPNAME( 0x80, 0x80, "Unknown 1-7" )
5721   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
5722   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
5723
5724   PORT_START   // IN15 - DSWs top bits
5725   PORT_DIPNAME( 0x01, 0x00, "Control Panel" )
5726   PORT_DIPSETTING(    0x00, "Hanafuda" )
5727   PORT_DIPSETTING(    0x01, "Mahjong" )   // Requires different inputs
5728   PORT_SERVICE( 0x02, IP_ACTIVE_LOW )
5729   PORT_DIPNAME( 0x04, 0x04, "Unknown 2-8" )
5730   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
5731   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
5732   PORT_DIPNAME( 0x08, 0x08, "Unknown 2-9" )
5733   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
5734   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
5735   PORT_DIPNAME( 0x10, 0x10, "Unknown 3-8" )
5736   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
5737   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
5738   PORT_DIPNAME( 0x20, 0x20, "Unknown 3-9" )
5739   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
5740   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
5741   PORT_DIPNAME( 0x40, 0x40, "Unknown 4-8" )
5742   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
5743   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
5744   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Flip_Screen ) )
5745   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
5746   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
5747INPUT_PORTS_END
5748
53215749INPUT_PORTS_START( mjmyornt )
53225750   PORT_START   // IN0 - Coins + Service Keys
53235751   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE3   )   // medal out
r1070r1071
59026330   PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
59036331INPUT_PORTS_END
59046332
6333INPUT_PORTS_START( hparadis )
6334   PORT_START   // IN0 - Player 1
6335   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
6336   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )
6337   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )
6338   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )
6339   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT )
6340   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 )
6341   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
6342   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
59056343
6344   PORT_START   // IN1 - Player 2
6345   PORT_BIT( 0x3f, IP_ACTIVE_LOW, IPT_UNKNOWN )
6346
6347   PORT_START   // IN2
6348   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1    )
6349   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2    )
6350   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
6351   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE  ) PORT_NAME(DEF_STR( Test )) PORT_CODE(KEYCODE_F1)   PORT_TOGGLE
6352   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE2   )   // analyzer
6353   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE3   )   // data clear
6354   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN  )
6355   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN  )
6356
6357   // keyb 1
6358   PORT_START   // IN3
6359   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("1") PORT_CODE(KEYCODE_1_PAD)   // A
6360   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("5") PORT_CODE(KEYCODE_5_PAD)   // E
6361   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN      )   // I
6362   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME(DEF_STR( Yes )) PORT_CODE(KEYCODE_Y)   // M
6363   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN      )   // Kan
6364   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1      )
6365
6366   PORT_START   // IN4
6367   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("2") PORT_CODE(KEYCODE_2_PAD)   // B
6368   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("6") PORT_CODE(KEYCODE_6_PAD)   // F
6369   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN      )   // J
6370   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME(DEF_STR( No )) PORT_CODE(KEYCODE_N)   // N
6371   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN      )   // Reach
6372   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN      )   // BET
6373
6374   PORT_START   // IN5
6375   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("3") PORT_CODE(KEYCODE_3_PAD)   // C
6376   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("7") PORT_CODE(KEYCODE_7_PAD)   // G
6377   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN      )   // K
6378   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN      )   // Chi
6379   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN      )   // Ron
6380   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN      )
6381
6382   PORT_START   // IN6
6383   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("4") PORT_CODE(KEYCODE_4_PAD)   // D
6384   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("8") PORT_CODE(KEYCODE_8_PAD)   // H
6385   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN      )   // L
6386   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN      )   // PON
6387   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN      )
6388   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN      )
6389
6390   PORT_START   // IN7
6391   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN   )
6392   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN   )   // "t"
6393   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN   )   // "w"
6394   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN   )   // Flip Flop
6395   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN   )   // "b"
6396   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN   )   // "s"
6397
6398   // keyb 2
6399   PORT_START   // IN8
6400   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_A   )   PORT_PLAYER(2)   // A
6401   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_E   )   PORT_PLAYER(2)   // E
6402   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN      )   // I
6403   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_M   )   PORT_PLAYER(2)   // M
6404   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN      )   // Kan
6405   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2      )
6406
6407   PORT_START   // IN9
6408   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_B   )   PORT_PLAYER(2)   // B
6409   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_F   )   PORT_PLAYER(2)   // F
6410   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN      )   // J
6411   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_N   )   PORT_PLAYER(2)   // N
6412   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN      )   // Reach
6413   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN      )   // BET
6414
6415   PORT_START   // IN10
6416   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_C   )   PORT_PLAYER(2)   // C
6417   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_G   )   PORT_PLAYER(2)   // G
6418   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN      )   // K
6419   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN      )   // Chi
6420   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN      )   // Ron
6421   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN      )
6422
6423   PORT_START   // IN11
6424   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_D   )   PORT_PLAYER(2)   // D
6425   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_H   )   PORT_PLAYER(2)   // H
6426   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN      )   // L
6427   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN      )   // PON
6428   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN      )
6429   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN      )
6430
6431   PORT_START   // IN12
6432   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN   )
6433   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN   )   // "t"
6434   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN   )   // "w"
6435   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN   )   // Flip Flop
6436   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN   )   // "b"
6437   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN   )   // "s"
6438
6439   PORT_START   // IN13 - DSW1
6440   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coinage ) )
6441   PORT_DIPSETTING(    0x00, DEF_STR( 3C_1C ) )
6442   PORT_DIPSETTING(    0x01, DEF_STR( 2C_1C ) )
6443   PORT_DIPSETTING(    0x03, DEF_STR( 1C_1C ) )
6444   PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
6445   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Difficulty ) )
6446   PORT_DIPSETTING(    0x08, DEF_STR( Easy ) )
6447   PORT_DIPSETTING(    0x0c, DEF_STR( Normal ) )
6448   PORT_DIPSETTING(    0x04, DEF_STR( Hard ) )
6449   PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
6450   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Demo_Sounds ) )
6451   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
6452   PORT_DIPSETTING(    0x10, DEF_STR( On ) )
6453   PORT_DIPNAME( 0x60, 0x60, "Control Panel" )
6454   PORT_DIPSETTING(    0x60, "Hanafuda" )
6455   PORT_DIPSETTING(    0x40, "Mahjong" )
6456   PORT_DIPSETTING(    0x20, DEF_STR( Joystick ) )
6457//  PORT_DIPSETTING(    0x00, DEF_STR( Joystick ) )
6458   PORT_DIPNAME( 0x80, 0x80, "First Chance" )
6459   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
6460   PORT_DIPSETTING(    0x80, DEF_STR( Yes ) )
6461
6462   PORT_START   // IN14 - DSW2
6463   PORT_DIPNAME( 0x03, 0x03, "Unknown 2-0&1" )
6464   PORT_DIPSETTING(    0x03, "0" )
6465   PORT_DIPSETTING(    0x02, "1" )
6466   PORT_DIPSETTING(    0x01, "2" )
6467   PORT_DIPSETTING(    0x00, "0?" )
6468   PORT_DIPNAME( 0x04, 0x04, "Unknown 2-2" )
6469   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
6470   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
6471   PORT_DIPNAME( 0x08, 0x08, "Unknown 2-3" )
6472   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
6473   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
6474   PORT_DIPNAME( 0x10, 0x10, "Unknown 2-4" )
6475   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
6476   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
6477   PORT_DIPNAME( 0x20, 0x20, "Unknown 2-5" )
6478   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
6479   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
6480   PORT_DIPNAME( 0x40, 0x40, "Unknown 2-6" )
6481   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
6482   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
6483   PORT_DIPNAME( 0x80, 0x80, "Unknown 2-7" )
6484   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
6485   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
6486
6487   PORT_START   // IN15 - DSWs top bits
6488   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Flip_Screen ) )
6489   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
6490   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
6491   PORT_SERVICE( 0x02, IP_ACTIVE_LOW )
6492   PORT_DIPNAME( 0x04, 0x04, "Unknown 2-8" )
6493   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
6494   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
6495   PORT_DIPNAME( 0x08, 0x08, "Unknown 2-9" )
6496   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
6497   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
6498   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
6499   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
6500   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
6501   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
6502   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
6503   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
6504   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
6505   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
6506   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
6507   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
6508   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
6509   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
6510INPUT_PORTS_END
6511
6512
59066513/***************************************************************************
59076514                            Don Den Lover Vol.1
59086515***************************************************************************/
r1070r1071
63676974   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30)
63686975MACHINE_DRIVER_END
63696976
6977static MACHINE_DRIVER_START( hgokou )
6978   /* basic machine hardware */
6979   MDRV_IMPORT_FROM( quizchq )
6980   MDRV_CPU_MODIFY("main")
6981   MDRV_CPU_PROGRAM_MAP(hgokou_readmem,hgokou_writemem)
6982   MDRV_CPU_IO_MAP(hgokou_readport,hgokou_writeport)
6983   MDRV_CPU_VBLANK_INT(hginga_irq, 1)
6984
6985   MDRV_SOUND_ADD(AY8910, 3579545)
6986   MDRV_SOUND_CONFIG(hginga_ay8910_interface)
6987   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30)
6988MACHINE_DRIVER_END
6989
63706990static MACHINE_DRIVER_START( mjmywrld )
63716991   /* basic machine hardware */
63726992   MDRV_IMPORT_FROM( mjmyster )
r1070r1071
64337053   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30)
64347054MACHINE_DRIVER_END
64357055
7056/*  It runs in IM 2, thus needs a vector on the data bus:
7057    0xee is vblank  */
7058INTERRUPT_GEN( hparadis_irq )
7059{
7060   cpunum_set_input_line_and_vector(0, 0, HOLD_LINE, 0xee);
7061}
64367062
7063static MACHINE_DRIVER_START( hparadis )
7064   /* basic machine hardware */
7065   MDRV_IMPORT_FROM( quizchq )
7066   MDRV_CPU_MODIFY("main")
7067   MDRV_CPU_PROGRAM_MAP(hparadis_readmem,hparadis_writemem)
7068   MDRV_CPU_IO_MAP(hparadis_readport,hparadis_writeport)
7069   MDRV_CPU_VBLANK_INT(hparadis_irq, 1)
7070MACHINE_DRIVER_END
7071
7072
64377073/***************************************************************************
64387074
64397075Monkey Mole Panic
r1070r1071
66657301   ROM_LOAD( "gal16v8b.1e",   0x0000, 0x0117, CRC(cf1b6e1d) SHA1(f1db4cd0636f390d745be33026b2e9e0da599d22) )
66667302ROM_END
66677303
7304/***************************************************************************
7305
7306 Rong Rong (Europe)
7307 Nakanihon
7308
7309 Revision: 6.2.14
7310
7311 CPU:
7312 1x Nakanihon NL-002-3D1 (main)
7313 1x oscillator 28.6363MHz
7314 1x Toshiba TMPZ84C015BF-8-9328ECZ
7315 1x OKI M6295-3372202 (sound)
7316 1x YM2413-9344HAAG (sound)
7317 1x Tpshiba TD62003AP-9348K
7318 1x DYNAX 1108F405-9401EAI
7319 1x DYNAX 4L02F2637-9337EAI
7320 1x DYNAX 1427F0071-9232EAI
7321
7322 ROMs:
7323 1x M27C2001-12FI (8001W)(sound)
7324 1x M27C4001-12FI (8002E)(sound)
7325 2x TC534000AP (8003-8004)
7326 2x M27C4001-12FI (8005E-8007E)
7327 1x TMS 27C040-15 (8006E)
7328 1x GAL16V8B-25LP
7329
7330***************************************************************************/
7331
66687332ROM_START( rongrngg )
66697333   ROM_REGION( 0x118000, REGION_CPU1, 0 )   /* Z80 Code + space for banked RAM */
66707334   ROM_LOAD( "rr_8002g.rom", 0x00000, 0x80000, CRC(9a5d2885) SHA1(9ca049085d14b1cfba6bd48adbb0b883494e7d29) )
r1070r1071
66827346   ROM_LOAD( "rr_8001w.rom", 0x00000, 0x40000, CRC(8edc87a2) SHA1(87e8ad50be025263e682cbfb5623f3a35b17118f) )
66837347ROM_END
66847348
7349/***************************************************************************
66857350
7351Rong Rong (Japan)
7352(c)1994 Nakanihon (Dynax)
7353
7354N8010178L1
7355
7356CPU   : TMPZ84C015BF-8
7357Sound : YM2413, M6295
7358OSC   : 28.6363MHz, ?(near CPU)
7359DIPs  : 10 position (x2)
7360Custom: NL-002
7361        1427F0071 (10D)
7362        4L02F2637 (10F)
7363        1108F0405 (10H)
7364
7365ROMs  : 8001.2F      [9fc8a367] - Samples
7366
7367        8002.3E      [27142684] - Main program
7368
7369        8003.8C      [f57192e5] \
7370        8004.9C      [c8c0b5cb] |
7371        8005.10C     [d1e5f74c] |- Blitter data
7372        8006.11C     [bcbd1b0b] |
7373        8007.12C     [c76cbb69] /
7374
7375***************************************************************************/
7376
7377ROM_START( rongrngj )
7378   ROM_REGION( 0x118000, REGION_CPU1, 0 )   /* Z80 Code + space for banked RAM */
7379   ROM_LOAD( "8002.3e", 0x00000, 0x80000, CRC(27142684) SHA1(4626576d032a89b558c8542f82b286e5673f8662) )
7380   ROM_RELOAD(          0x10000, 0x80000 )
7381   /* 90000-10ffff empty */
7382
7383   ROM_REGION( 0x240000, REGION_GFX1, 0 )   /* blitter data */
7384   ROM_LOAD( "8003.8c",  0x000000, 0x80000, CRC(f57192e5) SHA1(e33f5243028520492cd876be3e4b6a76a9b20d46) )
7385   ROM_LOAD( "8004.9c",  0x080000, 0x80000, CRC(c8c0b5cb) SHA1(d0c99908022b7d5d484e6d1990c00f15f7d8665a) )
7386   ROM_LOAD( "8005.10c", 0x100000, 0x80000, CRC(d1e5f74c) SHA1(808b37a4992f27768b85eea24fd868d5c9b1e1c0) )
7387   ROM_LOAD( "8006.11c", 0x180000, 0x80000, CRC(bcbd1b0b) SHA1(9b2f990de495b8fafbed71e9649d715f30768f0e) )
7388   ROM_LOAD( "8007.12c", 0x200000, 0x40000, CRC(c76cbb69) SHA1(691133fb4d6669106ea10880757168c45661154f) )
7389
7390   ROM_REGION( 0x40000, REGION_SOUND1, 0 )   /* Samples */
7391   ROM_LOAD( "8001.2f",  0x00000, 0x40000, CRC(9fc8a367) SHA1(bd8c9ddb3c1c8867321ca235f2d53cdc4c837907) )
7392ROM_END
7393
66867394/***************************************************************************
66877395
66887396Netto Quiz Champion (c) Nakanihon
r1070r1071
75168224
75178225/***************************************************************************
75188226
7519Mahjong Fantastic Love
8227Mahjong Fantasic Love
75208228Nakanihon, 1996
75218229
75228230PCB Layout
r1070r1071
76088316   ROM_RELOAD(           0x1c0000, 0x40000 )
76098317ROM_END
76108318
8319/***************************************************************************
76118320
8321Super Hana Paradise
83221995
8323
8324PCB almost like Mysterious World
8325
8326PCB Layout
8327----------
8328N8010178L1
8329|-------------------------------------------------------|
8330|MA1384  VOL             1011.2F                        |
8331|                          62256                        |
8332|                   M6295   1012.3E                     |
8333|        VOL                                     16MHz  |
8334|        YM2413                       TMPZ84C015        |
8335|                                                       |
8336|M                                                      |
8337|A     NL-002                                   DSW1(10)|
8338|H                                                      |
8339|J                                              DSW2(10)|
8340|O                                                      |
8341|N                                                      |
8342|G                                               DIP32  |
8343|                         28.636MHz                     |
8344|             TC5588                             DIP32  |
8345|                                                       |
8346|          1108F0406   4L02F2637     1427F0071   DIP32  |
8347|                                                       |
8348|                                                DIP32  |
8349|       TC524258Z-10  TC524258Z-10                      |
8350|       TC524258Z-10  TC524258Z-10               DIP32  |
8351|-------------------------------------------------------|
8352Notes:
8353      TMPZ84C015   - Toshiba TMPZ84C015F-6 (QFP100). Clocks 16.000MHz (pins 65 & 66), 8.000MHz (pins 68 & 69)
8354      62256        - 32k x8 SRAM (DIP28)
8355      TC5588       - 8k x8 SRAM (DIP28)
8356      TC524258Z-10 - Toshiba TC524258Z-10 256k x4 Dual Port VRAM (ZIP28)
8357      1427F0071    \
8358      1108F0406    | Dynax Custom ICs
8359      NL-002       |
8360      4L02F2637    /
8361      DIP32        - Empty sockets
8362      M6295        - Oki M6295 (QFP44). Clock 1.02272MHz [28.636/28]. pin 7 = high
8363      YM2413       - Clock 3.579545MHz [28.636/8]
8364      VSync        - 61Hz
8365      HSync        - 15.27kHz
8366
8367ROM Daughterboard N73RSUB
8368Contains the remaining ROMS, 1 PAL and nothing else
83691013, 1014, 1015, 1016
8370
8371--
8372
8373Super Hana Paradise
8374(c)1994 Dynax
8375
8376D10110258L1
8377
8378CPU: TMPZ84C015BF-8
8379Sound: YM2413 M6295
8380OSC: 28.6363MHz 16AKSS
8381Custom: NL-002
8382        1427F0071
8383        4L02F2637
8384        1108F0405
8385
8386ROMs:
83871011.2F
83881012.3E
8389
8390Subboard
83911013.1A
83921014.2A
83931015.3A
83941016.4A
8395
8396***************************************************************************/
8397
8398ROM_START( hparadis )
8399   ROM_REGION( 0x50000+8*0x1000, REGION_CPU1, 0 )   /* Z80 Code */
8400   ROM_LOAD( "1012.3e", 0x00000, 0x40000, CRC(bd3a3a8f) SHA1(35d70c2869a93192de7041b5c90b8a8a5e910946) )
8401   ROM_RELOAD(          0x10000, 0x40000 )
8402
8403   ROM_REGION( 0x600000, REGION_GFX1, 0 )   /* blitter data */
8404   // unused
8405   ROM_LOAD( "1015.3a", 0x400000, 0x80000, CRC(ea7b282e) SHA1(4fb33f3a8fe0dd792bcdd90894b90f1ac09ef6a5) )
8406   ROM_LOAD( "1014.2a", 0x480000, 0x80000, CRC(5f057c13) SHA1(d17211c3b697b48012018b738cff22fc4743d607) )
8407   ROM_LOAD( "1016.4a", 0x500000, 0x80000, CRC(c8e7ffb6) SHA1(9a7df1d6b3723e56b69d56831ce32c5326764a68) )
8408   ROM_LOAD( "1013.1a", 0x580000, 0x80000, CRC(c26b0563) SHA1(a09209c7e44fde418f917aed3a436bdf515942eb) )
8409
8410   ROM_REGION( 0x40000, REGION_SOUND1, 0 )   /* Samples */
8411   ROM_LOAD( "1011.2f", 0x00000, 0x40000, CRC(8c852b1a) SHA1(39e3e037f441df1d7cc7a698fea3e7825f8f6984) )
8412ROM_END
8413
8414
8415/***************************************************************************
8416
8417Hanafuda Hana Gokou
8418Dynax (Alba License), 1995
8419
8420PCB almost like Mysterious World
8421
8422PCB Layout
8423----------
8424N83061581L1
8425|-------------------------------------------------------|
8426|MB3714  VOL     DSW1(10)    M6242B   TC55257   BATTERY |
8427|                   32.768kHz 1081.2D  1082B.2B         |
8428|   VOL          DSW2(10)    M6295                      |
8429|   DSW5(4)                                      16MHz  |
8430|        YM2413  DSW3(10)        PAL         TMPZ84C015 |
8431|                                                       |
8432|M               DSW4(10)                               |
8433|A         YM2149                                       |
8434|H                          *                           |
8435|J     NL-002                           28.63636MHz     |
8436|O                                                 PAL  |
8437|N                                                      |
8438|G                                                      |
8439|2                                                      |
8440|8                                              1083.9A |
8441|                                                       |
8442|            &           %            #         1084.10A|
8443|                                                       |
8444|                      TC5588                    DIP32  |
8445|       TC524258Z-10  TC524258Z-10               DIP32  |
8446|       TC524258Z-10  TC524258Z-10               DIP32  |
8447|-------------------------------------------------------|
8448Notes:
8449      TMPZ84C015   - Toshiba TMPZ84C015F-6 (QFP100). Clocks 16.000MHz (pins 65 & 66), 8.000MHz (pins 68 & 69)
8450      TC55257      - 32k x8 SRAM (DIP28)
8451      TC5588       - 8k x8 SRAM (DIP28)
8452      TC524258Z-10 - Toshiba TC524258Z-10 256k x4 Dual Port VRAM (ZIP28)
8453      &            - Unknown QFP64. Possibly Dynax Custom 1108F0406
8454      %            - Unknown QFP100. Possibly Dynax Custom 4L02F2637
8455      #            - Unknown QFP100. Possibly Dynax Custom 1427F0071
8456      *            - Unknown PLCC44. Possibly MACH311 or similar CPLD
8457      DIP32        - Empty sockets
8458      M6295        - Oki M6295 (QFP44). Clock 1.02272MHz [28.63636/28]. pin 7 = HIGH
8459      YM2413       - Clock 3.579545MHz [28.63636/8]
8460      YM2149       - Clock 3.579545MHz [28.63636/8]
8461      VSync        - 60Hz
8462      HSync        - 15.36kHz
8463
8464***************************************************************************/
8465
8466ROM_START( hgokou )
8467   ROM_REGION( 0x90000+8*0x1000, REGION_CPU1, 0 )   /* Z80 Code */
8468   ROM_LOAD( "1082b.2b", 0x00000, 0x40000, CRC(e33bc5a5) SHA1(cb723cc81b914b45f89236812492c105c93c4e0b) )
8469   ROM_RELOAD(           0x10000, 0x40000 )
8470
8471   ROM_REGION( 0x200000, REGION_GFX1, 0 )   /* blitter data */
8472   // unused
8473   ROM_LOAD( "1083.9a",  0x100000, 0x80000, CRC(054200c3) SHA1(7db457fa1f8639d15a6faa3e1e05d4302e7dd281) )
8474   ROM_LOAD( "1084.10a", 0x180000, 0x80000, CRC(49f657e8) SHA1(077c553f88a76f826495ad516350a53ce361c6da) )
8475
8476   ROM_REGION( 0x40000, REGION_SOUND1, 0 )   /* Samples */
8477   ROM_LOAD( "1081.2d",  0x00000, 0x40000, CRC(74dede40) SHA1(d148f9ab9223b4c0b2f457a6f0e7fa3d173ab12b) )
8478ROM_END
8479
8480
76128481GAME( 1992, mmpanic,  0,        mmpanic,  mmpanic,  0,        ROT0, "Nakanihon + East Technology (Taito license)", "Monkey Mole Panic (USA)",                            GAME_NO_COCKTAIL )
76138482GAME( 1993, funkyfig, 0,        funkyfig, funkyfig, 0,        ROT0, "Nakanihon + East Technology (Taito license)", "The First Funky Fighter",                            GAME_NO_COCKTAIL | GAME_IMPERFECT_GRAPHICS )   // scrolling, priority?
76148483GAME( 1993, quizchq,  0,        quizchq,  quizchq,  0,        ROT0, "Nakanihon",                                   "Quiz Channel Question (Ver 1.00) (Japan)",           GAME_NO_COCKTAIL | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
r1070r1071
76218490GAME( 1994, mjmyuniv, 0,        mjmyuniv, mjmyster, 0,        ROT0, "Dynax",                                       "Mahjong The Mysterious Universe",                    GAME_NO_COCKTAIL )
76228491GAME( 1994, quiz365,  0,        quiz365,  quiz365,  0,        ROT0, "Nakanihon",                                   "Quiz 365 (Japan)",                                   GAME_NO_COCKTAIL | GAME_IMPERFECT_GRAPHICS | GAME_UNEMULATED_PROTECTION )
76238492GAME( 1994, quiz365t, quiz365,  quiz365,  quiz365,  0,        ROT0, "Nakanihon + Taito",                           "Quiz 365 (Hong Kong & Taiwan)",                      GAME_NO_COCKTAIL | GAME_IMPERFECT_GRAPHICS | GAME_UNEMULATED_PROTECTION )
7624GAME( 1994, rongrong, 0,        rongrong, rongrong, rongrong, ROT0, "Nakanihon",                                   "Rong Rong (Europe)",                                 GAME_NO_COCKTAIL | GAME_IMPERFECT_COLORS )
7625GAME( 1994, rongrngg, rongrong, rongrong, rongrong, rongrong, ROT0, "Nakanihon",                                   "Rong Rong (Germany)",                                GAME_NO_COCKTAIL | GAME_IMPERFECT_COLORS )
8493GAME( 1994, rongrong, 0,        rongrong, rongrong, rongrong, ROT0, "Nakanihon (Activision licence)",              "Puzzle Game Rong Rong (Europe)",                     GAME_NO_COCKTAIL | GAME_IMPERFECT_COLORS )
8494GAME( 1994, rongrngj, rongrong, rongrong, rongrong, rongrong, ROT0, "Nakanihon (Activision licence)",              "Puzzle Game Rong Rong (Japan)",                      GAME_NO_COCKTAIL | GAME_IMPERFECT_COLORS )
8495GAME( 1994, rongrngg, rongrong, rongrong, rongrong, rongrong, ROT0, "Nakanihon (Activision licence)",              "Puzzle Game Rong Rong (Germany)",                    GAME_NO_COCKTAIL | GAME_IMPERFECT_COLORS )
8496GAME( 1994, hparadis, 0,        hparadis, hparadis, 0,        ROT0, "Dynax",                                       "Super Hana Paradise (Japan)",                        GAME_NO_COCKTAIL )
8497GAME( 1995, hgokou,   0,        hgokou,   hgokou,   0,        ROT0, "Dynax (Alba licence)",                      "Hanafuda Hana Gokou (Japan)",                        GAME_NO_COCKTAIL )
76268498GAME( 1995, mjdchuka, 0,        mjchuuka, mjchuuka, 0,        ROT0, "Dynax",                                       "Mahjong The Dai Chuuka Ken (China, v. D111)",        GAME_NO_COCKTAIL )
76278499GAME( 1995, nettoqc,  0,        nettoqc,  nettoqc,  0,        ROT0, "Nakanihon",                                   "Nettoh Quiz Champion (Japan)",                       GAME_NO_COCKTAIL | GAME_IMPERFECT_COLORS )
76288500GAME( 1995, ddenlvrj, 0,        ddenlvrj, ddenlvrj, 0,        ROT0, "Dynax",                                       "Don Den Lover Vol. 1 - Shiro Kuro Tsukeyo! (Japan)", GAME_NO_COCKTAIL )
r1070r1071
76308502GAME( 1996, ddenlovb, ddenlvrj, ddenlovr, ddenlovr, 0,        ROT0, "[Dynax] (bootleg)",                           "Don Den Lover Vol. 1 (Korea, bootleg)",              GAME_NO_COCKTAIL )
76318503GAME( 1996, hanakanz, 0,        hanakanz, hanakanz, 0,        ROT0, "Dynax",                                       "Hana Kanzashi (Japan)",                              GAME_NO_COCKTAIL )
76328504GAME( 1996, akamaru,  0,        akamaru,  akamaru,  0,        ROT0, "Dynax (Nakanihon licence)",                   "Panel & Variety Akamaru Q Jousyou Dont-R",           GAME_NO_COCKTAIL )
7633GAME( 1996, mjflove,  0,        mjflove,  mjflove,  0,        ROT0, "Nakanihon",                                   "Mahjong Fantastic Love (Japan)",                     GAME_NO_COCKTAIL )
8505GAME( 1996, mjflove,  0,        mjflove,  mjflove,  0,        ROT0, "Nakanihon",                                   "Mahjong Fantasic Love (Japan)",                      GAME_NO_COCKTAIL )
76348506GAME( 1997, hkagerou, 0,        hkagerou, hkagerou, 0,        ROT0, "Nakanihon + Dynax",                           "Hana Kagerou [BET] (Japan)",                         GAME_NO_COCKTAIL )
76358507GAME( 1998, mjchuuka, 0,        mjchuuka, mjchuuka, 0,        ROT0, "Dynax",                                       "Mahjong Chuukanejyo (China)",                        GAME_NO_COCKTAIL )
76368508GAME( 1998, mjreach1, 0,        mjreach1, mjreach1, 0,        ROT0, "Nihon System",                                "Mahjong Reach Ippatsu (Japan)",                      GAME_NO_COCKTAIL )
src/mame/drivers/ms32.c
r1070r1071
21392139
21402140/* SS92048-01: p47aces, 47pie2, 47pie2o */
21412141
2142static void rearrange_sprites(void)
2142void ms32_rearrange_sprites(int region)
21432143{
21442144   /* sprites are not encrypted, but we need to move the data around to handle them as 256x256 tiles */
21452145   int i;
r1070r1071
21482148
21492149   UINT8 *result_data;
21502150
2151   source_data = memory_region       ( REGION_GFX1 );
2152   source_size = memory_region_length( REGION_GFX1 );
2151   source_data = memory_region       ( region );
2152   source_size = memory_region_length( region );
21532153
21542154   result_data = malloc_or_die(source_size);
21552155
r1070r1071
21652165}
21662166
21672167
2168static void decrypt_ms32_tx(int addr_xor,int data_xor)
2168void decrypt_ms32_tx(int addr_xor,int data_xor, int region)
21692169{
21702170   int i;
21712171   UINT8 *source_data;
r1070r1071
21732173
21742174   UINT8 *result_data;
21752175
2176   source_data = memory_region       ( REGION_GFX4 );
2177   source_size = memory_region_length( REGION_GFX4 );
2176   source_data = memory_region       ( region );
2177   source_size = memory_region_length( region );
21782178
21792179   result_data = malloc_or_die(source_size);
21802180
r1070r1071
22192219   free (result_data);
22202220}
22212221
2222static void decrypt_ms32_bg(int addr_xor,int data_xor)
2222void decrypt_ms32_bg(int addr_xor,int data_xor, int region)
22232223{
22242224   int i;
22252225   UINT8 *source_data;
r1070r1071
22272227
22282228   UINT8 *result_data;
22292229
2230   source_data = memory_region       ( REGION_GFX3 );
2231   source_size = memory_region_length( REGION_GFX3 );
2230   source_data = memory_region       ( region );
2231   source_size = memory_region_length( region );
22322232
22332233   result_data = malloc_or_die(source_size);
22342234
r1070r1071
22872287static DRIVER_INIT (ss91022_10)
22882288{
22892289   configure_banks();
2290   rearrange_sprites();
2291   decrypt_ms32_tx(0x00000,0x35);
2292   decrypt_ms32_bg(0x00000,0xa3);
2290   ms32_rearrange_sprites(REGION_GFX1);
2291   decrypt_ms32_tx(0x00000,0x35, REGION_GFX4);
2292   decrypt_ms32_bg(0x00000,0xa3, REGION_GFX3);
22932293}
22942294
22952295/* SS92046_01: bbbxing, f1superb, tetrisp, hayaosi1 */
22962296static DRIVER_INIT (ss92046_01)
22972297{
22982298   configure_banks();
2299   rearrange_sprites();
2300   decrypt_ms32_tx(0x00020,0x7e);
2301   decrypt_ms32_bg(0x00001,0x9b);
2299   ms32_rearrange_sprites(REGION_GFX1);
2300   decrypt_ms32_tx(0x00020,0x7e, REGION_GFX4);
2301   decrypt_ms32_bg(0x00001,0x9b, REGION_GFX3);
23022302}
23032303
23042304/* SS92047-01: gratia, kirarast */
23052305static DRIVER_INIT (ss92047_01)
23062306{
23072307   configure_banks();
2308   rearrange_sprites();
2309   decrypt_ms32_tx(0x24000,0x18);
2310   decrypt_ms32_bg(0x24000,0x55);
2308   ms32_rearrange_sprites(REGION_GFX1);
2309   decrypt_ms32_tx(0x24000,0x18, REGION_GFX4);
2310   decrypt_ms32_bg(0x24000,0x55, REGION_GFX3);
23112311}
23122312
23132313/* SS92048-01: p47aces, 47pie2, 47pie2o */
23142314static DRIVER_INIT (ss92048_01)
23152315{
23162316   configure_banks();
2317   rearrange_sprites();
2318   decrypt_ms32_tx(0x20400,0xd6);
2319   decrypt_ms32_bg(0x20400,0xd4);
2317   ms32_rearrange_sprites(REGION_GFX1);
2318   decrypt_ms32_tx(0x20400,0xd6, REGION_GFX4);
2319   decrypt_ms32_bg(0x20400,0xd4, REGION_GFX3);
23202320}
23212321
23222322static DRIVER_INIT (kirarast)
r1070r1071
23372337
23382338static DRIVER_INIT (f1superb)
23392339{
2340#if 0 // we shouldn't need this hack, something else is wrong, and the x offsets are never copied either, v70 problems??
23402341   UINT32 *pROM = (UINT32 *)memory_region(REGION_CPU1);
23412342   pROM[0x19d04/4]=0x167a021a; // bne->br  : sprite Y offset table is always copied to RAM
2343#endif
23422344   driver_init_ss92046_01(machine);
23432345}
23442346
src/mame/drivers/mpu4.c
r1070r1071
26152615   RGN_FRAC(1,1),
26162616   4,
26172617   { 0, 1, 2, 3 },
2618   { 0*4, 1*4, 2*4, 3*4, 4*4, 5*4, 6*4, 7*4 },
2618   { 3*4, 2*4, 1*4, 0*4, 7*4, 6*4, 5*4, 4*4 },
26192619   { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
26202620   32*8
26212621};
26222622
26232623static GFXDECODE_START( dealem )
2624   GFXDECODE_ENTRY( REGION_GFX1, 0x0000, dealemcharlayout, 0, 32 )
2624   GFXDECODE_ENTRY( REGION_GFX1, 0x0000, dealemcharlayout, 0, 1 )
26252625GFXDECODE_END
26262626
26272627UINT8 *dealem_videoram,*dealem_charram;
26282628
2629
2630tilemap *dealem_tilemap;
2631
2632
26332629/***************************************************************************
26342630
26352631  Convert the color PROMs into a more useable format.
r1070r1071
26782674
26792675}
26802676
2681static TILE_GET_INFO( get_bg_tile_info )
2682{
2683   int tileno, colour;
2684
2685   tileno = dealem_videoram[tile_index];
2686   colour = dealem_videoram[tile_index];
2687
2688   SET_TILE_INFO(0,tileno,colour,0);
2689}
2690
26912677VIDEO_START(dealem)
26922678{
2693   dealem_tilemap = tilemap_create(get_bg_tile_info,tilemap_scan_rows,TILEMAP_TYPE_PEN, 8, 8,32,32);
2694}
26952679
2696WRITE8_HANDLER( dealem_videoram_w )
2697{
2698   dealem_videoram[offset] = data;
2699   tilemap_mark_tile_dirty(dealem_tilemap, offset);
27002680}
27012681
2702// this is wrong, the PAL handles the colour selection
2703WRITE8_HANDLER( dealem_colorram_w )
2704{
2705   colorram[offset] = data;
2706   tilemap_mark_tile_dirty(dealem_tilemap, offset);
2707}
27082682
27092683VIDEO_UPDATE(dealem)
27102684{
2711   tilemap_draw(bitmap, &machine->screen[0].visarea, dealem_tilemap, 0, 0);
2685   int x,y;
2686   int count = 0;
2687
2688   for (y=0;y<32;y++)
2689   {
2690      for (x=0;x<40;x++)
2691      {
2692         int tile = dealem_videoram[count+0x1000] | (dealem_videoram[count] << 8);
2693         count++;
2694         drawgfx(bitmap,machine->gfx[0],tile,0,0,0,x*8,y*8,cliprect,TRANSPARENCY_NONE,0);
2695      }
2696   }
2697
27122698   return 0;
27132699}
27142700
r1070r1071
27352721
27362722//  AM_RANGE(0x0850, 0x0850) AM_WRITE(bankswitch_w) // write bank (rom page select)
27372723
2738   AM_RANGE(0x0880, 0x0880) AM_READ(MRA8_RAM) AM_WRITE(dealem_colorram_w) AM_BASE(&colorram) //AM_WRITE(dealem_pal_w)//
2739
27402724//  AM_RANGE(0x08E0, 0x08E7) AM_READ( 68681_duart_r)
27412725//  AM_RANGE(0x08E0, 0x08E7) AM_WRITE( 68681_duart_w)
27422726
r1070r1071
27612745   AM_RANGE(0x0F00, 0x0F03) AM_WRITE(pia_5_w)      // PIA6821 IC8
27622746   AM_RANGE(0x0F00, 0x0F03) AM_READ( pia_5_r)
27632747
2764   AM_RANGE(0x1000, 0x3000) AM_WRITE(dealem_videoram_w) AM_BASE(&dealem_videoram)
2765   AM_RANGE(0xBE00, 0xFFFF) AM_ROM   AM_WRITENOP// 64k  paged ROM (4 pages)
2748   AM_RANGE(0x1000, 0x2fff) AM_RAM AM_BASE(&dealem_videoram)
2749   AM_RANGE(0x8000, 0xffff) AM_ROM   AM_WRITENOP// 64k  paged ROM (4 pages)
27662750
27672751ADDRESS_MAP_END
27682752
src/mame/drivers/system16.c
r1070r1071
364364   AM_RANGE(0x01, 0x01) AM_WRITE(YM2151_data_port_0_w)
365365ADDRESS_MAP_END
366366
367// 7751 Sound
368static ADDRESS_MAP_START( sound_readmem_7751, ADDRESS_SPACE_PROGRAM, 8 )
369   AM_RANGE(0x0000, 0x7fff) AM_READ(MRA8_ROM)
370   AM_RANGE(0xe800, 0xe800) AM_READ(soundlatch_r)
371   AM_RANGE(0xf800, 0xffff) AM_READ(MRA8_RAM)
372ADDRESS_MAP_END
373367
374static ADDRESS_MAP_START( sound_readport_7751, ADDRESS_SPACE_IO, 8 )
375   ADDRESS_MAP_FLAGS( AMEF_ABITS(8) )
376   AM_RANGE(0x01, 0x01) AM_READ(YM2151_status_port_0_r)
377//    AM_RANGE(0x0e, 0x0e) AM_READ(sys16_7751_audio_8255_r)
378   AM_RANGE(0xc0, 0xc0) AM_READ(soundlatch_r)
379ADDRESS_MAP_END
380
381static ADDRESS_MAP_START( sound_writeport_7751, ADDRESS_SPACE_IO, 8 )
382   ADDRESS_MAP_FLAGS( AMEF_ABITS(8) )
383   AM_RANGE(0x00, 0x00) AM_WRITE(YM2151_register_port_0_w)
384   AM_RANGE(0x01, 0x01) AM_WRITE(YM2151_data_port_0_w)
385   AM_RANGE(0x80, 0x80) AM_WRITE(sys16_7751_audio_8255_w)
386ADDRESS_MAP_END
387
388static ADDRESS_MAP_START( readmem_7751, ADDRESS_SPACE_PROGRAM, 8 )
389   AM_RANGE(0x0000, 0x03ff) AM_READ(MRA8_ROM)
390ADDRESS_MAP_END
391
392static ADDRESS_MAP_START( writemem_7751, ADDRESS_SPACE_PROGRAM, 8 )
393   AM_RANGE(0x0000, 0x03ff) AM_WRITE(MWA8_ROM)
394ADDRESS_MAP_END
395
396static ADDRESS_MAP_START( readport_7751, ADDRESS_SPACE_IO, 8 )
397   AM_RANGE(I8039_t1, I8039_t1) AM_READ(sys16_7751_sh_t1_r)
398   AM_RANGE(I8039_p2, I8039_p2) AM_READ(sys16_7751_sh_command_r)
399   AM_RANGE(I8039_bus, I8039_bus) AM_READ(sys16_7751_sh_rom_r)
400ADDRESS_MAP_END
401
402static ADDRESS_MAP_START( writeport_7751, ADDRESS_SPACE_IO, 8 )
403   AM_RANGE(I8039_p1, I8039_p1) AM_WRITE(sys16_7751_sh_dac_w)
404   AM_RANGE(I8039_p2, I8039_p2) AM_WRITE(sys16_7751_sh_busy_w)
405   AM_RANGE(I8039_p4, I8039_p4) AM_WRITE(sys16_7751_sh_offset_a0_a3_w)
406   AM_RANGE(I8039_p5, I8039_p5) AM_WRITE(sys16_7751_sh_offset_a4_a7_w)
407   AM_RANGE(I8039_p6, I8039_p6) AM_WRITE(sys16_7751_sh_offset_a8_a11_w)
408   AM_RANGE(I8039_p7, I8039_p7) AM_WRITE(sys16_7751_sh_rom_select_w)
409ADDRESS_MAP_END
410
411368// 7759
412369static ADDRESS_MAP_START( sound_readmem_7759, ADDRESS_SPACE_PROGRAM, 8 )
413370   AM_RANGE(0x0000, 0x7fff) AM_READ(MRA8_ROM)
r1070r1071
526483MACHINE_DRIVER_END
527484
528485
529static MACHINE_DRIVER_START( system16_7751 )
530486
531   /* basic machine hardware */
532   MDRV_IMPORT_FROM(system16)
533
534   MDRV_CPU_MODIFY("sound")
535   MDRV_CPU_PROGRAM_MAP(sound_readmem_7751,sound_writemem)
536   MDRV_CPU_IO_MAP(sound_readport_7751,sound_writeport_7751)
537
538   MDRV_CPU_ADD(N7751, 6000000/15)
539   /* audio CPU */
540   MDRV_CPU_PROGRAM_MAP(readmem_7751,writemem_7751)
541   MDRV_CPU_IO_MAP(readport_7751,writeport_7751)
542
543   /* sound hardware */
544   MDRV_SOUND_ADD(DAC, 0)
545   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 0.80)
546   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 0.80)
547MACHINE_DRIVER_END
548
549487/***************************************************************************/
550488
551489static WRITE16_HANDLER( sys16_tilebank_w )
r1070r1071
18421780
18431781/***************************************************************************/
18441782
1845static MACHINE_DRIVER_START( shinobl )
18461783
1784
1785static MACHINE_DRIVER_START( shinob2 )
1786
18471787   /* basic machine hardware */
1848   MDRV_IMPORT_FROM(system16_7751)
1788   MDRV_IMPORT_FROM(system16)
18491789   MDRV_CPU_MODIFY("main")
18501790   MDRV_CPU_PROGRAM_MAP(shinobl_readmem,shinobl_writemem)
18511791
18521792   MDRV_MACHINE_RESET(shinobl)
18531793MACHINE_DRIVER_END
18541794
1795
18551796/***************************************************************************/
18561797
18571798
r1070r1071
26772618   ROM_LOAD( "epr11861.a11", 0x28000, 0x08000, CRC(38b54a71) SHA1(68ec4ef5b115844214ff2213be1ce6678904fbd2) )
26782619ROM_END
26792620
2680ROM_START( shinobl )
2621/* Shinobi bootleg by 'Beta' (7751 replaced by what? Sample rom is different, but no extra sound CPU rom present, missing?) */
2622/* otherwise it seems to run fine on System 16A */
2623ROM_START( shinoblb )
26812624   ROM_REGION( 0x040000, REGION_CPU1, 0 ) /* 68000 code */
2682// Star Bootleg
2683   ROM_LOAD16_BYTE( "b3",          0x000000, 0x10000, CRC(38e59646) SHA1(6a13015a93260ab99811b95950bb122eade01c27) )
2684   ROM_LOAD16_BYTE( "b1",          0x000001, 0x10000, CRC(8529d192) SHA1(202b912d20a2d82abe055b4a5e8c509ab7d69ff8) )
2685   ROM_LOAD16_BYTE( "epr11263.43", 0x020000, 0x10000, CRC(a2a620bd) SHA1(f8b135ce14d6c5eac5e40ddfd5ad2f1e6f2bc7a6) )
2686   ROM_LOAD16_BYTE( "epr11261.25", 0x020001, 0x10000, CRC(a3ceda52) SHA1(97a1c52a162fb1d43b3f8f16613b70ce582a8d26) )
2625   ROM_LOAD16_BYTE( "4.3k", 0x000000, 0x10000, CRC(c178a39c) SHA1(05ff1679cdfc3618df8b3fabdeab64b1f2299aa3) )
2626   ROM_LOAD16_BYTE( "2.3n", 0x000001, 0x10000, CRC(5ad8ebf2) SHA1(b22e0c8d4b27c553abface17c625e207d19417ab) )
2627   ROM_LOAD16_BYTE( "5.2k", 0x020000, 0x10000, CRC(a2a620bd) SHA1(f8b135ce14d6c5eac5e40ddfd5ad2f1e6f2bc7a6) )
2628   ROM_LOAD16_BYTE( "3.2n", 0x020001, 0x10000, CRC(a3ceda52) SHA1(97a1c52a162fb1d43b3f8f16613b70ce582a8d26) )
26872629
2688// Beta Bootleg
2689//  ROM_LOAD16_BYTE( "4",           0x000000, 0x10000, CRC(c178a39c) )
2690//  ROM_LOAD16_BYTE( "2",           0x000001, 0x10000, CRC(5ad8ebf2) )
2691//  ROM_LOAD16_BYTE( "epr11263.43", 0x020000, 0x10000, CRC(a2a620bd) SHA1(f8b135ce14d6c5eac5e40ddfd5ad2f1e6f2bc7a6) )
2692//  ROM_LOAD16_BYTE( "epr11261.25", 0x020001, 0x10000, CRC(a3ceda52) SHA1(97a1c52a162fb1d43b3f8f16613b70ce582a8d26) )
2693
26942630   ROM_REGION( 0x30000, REGION_GFX1, ROMREGION_DISPOSE ) /* tiles */
2695   ROM_LOAD( "epr11264.95", 0x00000, 0x10000, CRC(46627e7d) SHA1(66bb5b22a2100e7b9df303007a837bc2d52cf7ba) )
2696   ROM_LOAD( "epr11265.94", 0x10000, 0x10000, CRC(87d0f321) SHA1(885b38eaff2dcaeab4eeaa20cc8a2885d520abd6) )
2697   ROM_LOAD( "epr11266.93", 0x20000, 0x10000, CRC(efb4af87) SHA1(0b8a905023e1bc808fd2b1c3cfa3778cde79e659) )
2631   ROM_LOAD( "8.3b", 0x00000, 0x10000, CRC(46627e7d) SHA1(66bb5b22a2100e7b9df303007a837bc2d52cf7ba) )
2632   ROM_LOAD( "7.4b", 0x10000, 0x10000, CRC(87d0f321) SHA1(885b38eaff2dcaeab4eeaa20cc8a2885d520abd6) )
2633   ROM_LOAD( "6.5b", 0x20000, 0x10000, CRC(efb4af87) SHA1(0b8a905023e1bc808fd2b1c3cfa3778cde79e659) )
26982634
2699   ROM_REGION( 0x080000, REGION_GFX2, 0 ) /* sprites */
2700   ROM_LOAD16_BYTE( "epr11290.10", 0x00001, 0x10000, CRC(611f413a) SHA1(180f83216e2dfbfd77b0fb3be83c3042954d12df) )
2701   ROM_LOAD16_BYTE( "epr11294.11", 0x00000, 0x10000, CRC(5eb00fc1) SHA1(97e02eee74f61fabcad2a9e24f1868cafaac1d51) )
2702   ROM_LOAD16_BYTE( "epr11291.17", 0x20001, 0x10000, CRC(3c0797c0) SHA1(df18c7987281bd9379026c6cf7f96f6ae49fd7f9) )
2703   ROM_LOAD16_BYTE( "epr11295.18", 0x20000, 0x10000, CRC(25307ef8) SHA1(91ffbe436f80d583524ee113a8b7c0cf5d8ab286) )
2704   ROM_LOAD16_BYTE( "epr11292.23", 0x40001, 0x10000, CRC(c29ac34e) SHA1(b5e9b8c3233a7d6797f91531a0d9123febcf1660) )
2705   ROM_LOAD16_BYTE( "epr11296.24", 0x40000, 0x10000, CRC(04a437f8) SHA1(ea5fed64443236e3404fab243761e60e2e48c84c) )
2706   ROM_LOAD16_BYTE( "epr11293.29", 0x60001, 0x10000, CRC(41f41063) SHA1(5cc461e9738dddf9eea06831fce3702d94674163) )
2707//  ROM_LOAD16_BYTE( "epr11297.30", 0x60000, 0x10000, CRC(b6e1fd72) SHA1(eb86e4bf880bd1a1d9bcab3f2f2e917bcaa06172) )
2708   ROM_LOAD16_BYTE( "b17",         0x60000, 0x10000, CRC(0315cf42) SHA1(2d129171aece883cb9c2805f894b3867ec98332b) )   // Beta bootleg uses the rom above.
2635   ROM_REGION16_BE( 0x080000, REGION_GFX2, 0 ) /* sprites */
2636   ROM_LOAD16_BYTE( "9.6r",  0x00001, 0x08000, CRC(611f413a) SHA1(180f83216e2dfbfd77b0fb3be83c3042954d12df) )
2637   ROM_CONTINUE(             0x40001, 0x08000 )
2638   ROM_LOAD16_BYTE( "13.8r", 0x00000, 0x08000, CRC(5eb00fc1) SHA1(97e02eee74f61fabcad2a9e24f1868cafaac1d51) )
2639   ROM_CONTINUE(             0x40000, 0x08000 )
2640   ROM_LOAD16_BYTE( "10.6q", 0x10001, 0x08000, CRC(3c0797c0) SHA1(df18c7987281bd9379026c6cf7f96f6ae49fd7f9) )
2641   ROM_CONTINUE(             0x50001, 0x08000 )
2642   ROM_LOAD16_BYTE( "14.8q", 0x10000, 0x08000, CRC(25307ef8) SHA1(91ffbe436f80d583524ee113a8b7c0cf5d8ab286) )
2643   ROM_CONTINUE(             0x50000, 0x08000 )
2644   ROM_LOAD16_BYTE( "11.6p", 0x20001, 0x08000, CRC(c29ac34e) SHA1(b5e9b8c3233a7d6797f91531a0d9123febcf1660) )
2645   ROM_CONTINUE(             0x60001, 0x08000 )
2646   ROM_LOAD16_BYTE( "15.8p", 0x20000, 0x08000, CRC(04a437f8) SHA1(ea5fed64443236e3404fab243761e60e2e48c84c) )
2647   ROM_CONTINUE(             0x60000, 0x08000 )
2648   ROM_LOAD16_BYTE( "12.6n", 0x30001, 0x08000, CRC(41f41063) SHA1(5cc461e9738dddf9eea06831fce3702d94674163) )
2649   ROM_CONTINUE(             0x70001, 0x08000 )
2650   ROM_LOAD16_BYTE( "16.8n", 0x30000, 0x08000, CRC(b6e1fd72) SHA1(eb86e4bf880bd1a1d9bcab3f2f2e917bcaa06172) )
2651   ROM_CONTINUE(             0x70000, 0x08000 )
27092652
27102653   ROM_REGION( 0x20000, REGION_CPU2, 0 ) /* sound CPU */
2711   ROM_LOAD( "epr11267.12", 0x0000, 0x8000, CRC(dd50b745) SHA1(52e1977569d3713ad864d607170c9a61cd059a65) )
2654   ROM_LOAD( "1.5s", 0x0000, 0x8000, CRC(dd50b745) SHA1(52e1977569d3713ad864d607170c9a61cd059a65) )
27122655
2713   ROM_REGION( 0x1000, REGION_CPU3, 0 )      /* 4k for 7751 onboard ROM */
2714   ROM_LOAD( "7751.bin",     0x0000, 0x0400, CRC(6a9534fc) SHA1(67ad94674db5c2aab75785668f610f6f4eccd158) ) /* 7751 - U34 */
2656   ROM_REGION( 0x08000, REGION_SOUND1, 0 ) /* sound samples (played by what?, not the same as the original) */
2657   ROM_LOAD( "17.6u", 0x0000, 0x8000, CRC(b7a6890c) SHA1(6431df82c7dbe454cabc6084c1a677ebb42ae4b3) )
2658ROM_END
27152659
2716   ROM_REGION( 0x08000, REGION_SOUND1, 0 ) /* 7751 sound data */
2717   ROM_LOAD( "epr11268.1", 0x0000, 0x8000, CRC(6d7966da) SHA1(90f55a99f784c21d7c135e630f4e8b1d4d043d66) )
2660/* Shinobi bootleg by 'Datsu' - Sound hardware is different */
2661ROM_START( shinobld )
2662   ROM_REGION( 0x040000, REGION_CPU1, 0 ) /* 68000 code */
2663   ROM_LOAD16_BYTE( "12.bin", 0x000001, 0x10000, CRC(757a0c71) SHA1(8f476b0fd5f5dd480489af09b99585c58a4801fc) )
2664   ROM_LOAD16_BYTE( "14.bin", 0x000000, 0x10000, CRC(a65870b2) SHA1(3e9b4aa694bf86ef9db4756ebaa3d8d87d7f269a) )
2665   ROM_LOAD16_BYTE( "13.bin", 0x020001, 0x10000, CRC(c4334bcd) SHA1(ea1dd23ca6fbf632d8e10bbb9ced6515a69bd14a) )
2666   ROM_LOAD16_BYTE( "15.bin", 0x020000, 0x10000, CRC(b70a6ec1) SHA1(79db41c36d6a053bcdc355b46b19ae938a7755a9) )
2667
2668   ROM_REGION( 0x30000, REGION_GFX1, ROMREGION_INVERT | ROMREGION_DISPOSE ) /* tiles */
2669   ROM_LOAD( "9.bin",  0x10000, 0x10000, CRC(565e11c6) SHA1(e063400b3d0470b932d75da0be9cd4b446189dea) )
2670   ROM_LOAD( "10.bin", 0x20000, 0x10000, CRC(7cc40b6c) SHA1(ffad7eef7ab2ff9a2e49a8d71b5785a61fa3c675) )
2671   ROM_LOAD( "11.bin", 0x00000, 0x10000, CRC(0f6c7b1c) SHA1(defc76592c285b3396e89a3cff7a73f3a948117f) )
2672
2673   ROM_REGION( 0x080000, REGION_GFX2, 0 ) /* sprites */
2674   ROM_LOAD16_BYTE( "5.bin", 0x00001, 0x08000, CRC(611f413a) SHA1(180f83216e2dfbfd77b0fb3be83c3042954d12df) )
2675   ROM_CONTINUE(             0x40001, 0x08000 )
2676   ROM_LOAD16_BYTE( "3.bin", 0x00000, 0x08000, CRC(5eb00fc1) SHA1(97e02eee74f61fabcad2a9e24f1868cafaac1d51) )
2677   ROM_CONTINUE(             0x40000, 0x08000 )
2678   ROM_LOAD16_BYTE( "8.bin", 0x10001, 0x08000, CRC(3c0797c0) SHA1(df18c7987281bd9379026c6cf7f96f6ae49fd7f9) )
2679   ROM_CONTINUE(             0x50001, 0x08000 )
2680   ROM_LOAD16_BYTE( "2.bin", 0x10000, 0x08000, CRC(25307ef8) SHA1(91ffbe436f80d583524ee113a8b7c0cf5d8ab286) )
2681   ROM_CONTINUE(             0x50000, 0x08000 )
2682   ROM_LOAD16_BYTE( "6.bin", 0x30001, 0x08000, CRC(c29ac34e) SHA1(b5e9b8c3233a7d6797f91531a0d9123febcf1660) )
2683   ROM_CONTINUE(             0x60001, 0x08000 )
2684   ROM_LOAD16_BYTE( "4.bin", 0x30000, 0x08000, CRC(04a437f8) SHA1(ea5fed64443236e3404fab243761e60e2e48c84c) )
2685   ROM_CONTINUE(             0x60000, 0x08000 )
2686   ROM_LOAD16_BYTE( "7.bin", 0x40001, 0x08000, CRC(41f41063) SHA1(5cc461e9738dddf9eea06831fce3702d94674163) )
2687   ROM_CONTINUE(             0x70001, 0x08000 )
2688   ROM_LOAD16_BYTE( "1.bin", 0x40000, 0x08000, CRC(b6e1fd72) SHA1(eb86e4bf880bd1a1d9bcab3f2f2e917bcaa06172) )
2689   ROM_CONTINUE(             0x70000, 0x08000 )
2690
2691   ROM_REGION( 0x10000, REGION_CPU2, 0 ) /* sound CPU + data */
2692   ROM_LOAD( "16.bin", 0x0000, 0x10000, CRC(52c8364e) SHA1(01d30b82f92498d155d2e31d43d58dff0285cce3) )
27182693ROM_END
27192694
2695
27202696// sys16B
27212697
27222698// sys16A custom
r1070r1071
28082784
28092785/* System16A */
28102786/*          rom       parent    machine   inp       init */
2811GAME( 1987, shinobl,  shinobi,  shinobl,  shinobi,  shinobl,  ROT0,   "bootleg", "Shinobi (bootleg)", 0 )
2787GAME( 1987, shinoblb,   shinobi,  shinob2,  shinobi,  shinobl,  ROT0,   "[Sega] (Beta bootleg)", "Shinobi (Beta bootleg)", 0 )
2788GAME( 1987, shinobld,   shinobi,  shinob2,  shinobi,  shinobl,  ROT0,   "[Sega] (Datsu bootleg)", "Shinobi (Datsu bootleg)", 0 )
28122789
28132790/* System16B */
28142791/*          rom       parent    machine   inp       init */
src/mame/drivers/polepos.c
r1070r1071
218218#include "sound/samples.h"
219219#include "audio/namco54.h"
220220#include "polepos.h"
221#include "nam_cust.h"
221222
222
223223#define POLEPOS_TOGGLE   PORT_TOGGLE
224224
225225
r1070r1071
947947 * ROM definitions
948948 *********************************************************************/
949949
950#define POLEPOS_CUSTOMS \
951   ROM_REGION_NAMCO_54XX( REGION_CPU4 ) \
952   ROM_REGION_NAMCO_51XX( REGION_CPU5 ) \
953   ROM_REGION_NAMCO_52XX( REGION_CPU6 ) \
954   ROM_REGION_NAMCO_53XX( REGION_CPU7 ) \
955
950956ROM_START( polepos )
951957   /* Z80 memory/ROM data */
952958   ROM_REGION( 0x10000, REGION_CPU1, 0 )
r1070r1071
963969   ROM_LOAD16_BYTE( "pp1_5b.4m",     0x0001, 0x2000, CRC(5cdf5294) SHA1(dbdf327a541fd71aadafda9c925fa4cf7f7c4a24) )
964970   ROM_LOAD16_BYTE( "pp1_6b.4l",     0x0000, 0x2000, CRC(81696272) SHA1(27041a7c24297a6f317537c44922b51d2b2278a6) )
965971
966   /* 54XX ROM */
967   ROM_REGION( 0x400, REGION_CPU4, 0 )
968   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
972   POLEPOS_CUSTOMS
969973
970974   /* graphics data */
971975   ROM_REGION( 0x01000, REGION_GFX1, ROMREGION_DISPOSE )    /* 2bpp alpha layer */
r1070r1071
10451049   ROM_LOAD16_BYTE( "136014.203",   0x0001, 0x2000, CRC(eedea6e7) SHA1(e1459c5e3f824e589e624c3acb18a183fd160df6) )
10461050   ROM_LOAD16_BYTE( "136014.204",   0x0000, 0x2000, CRC(c52c98ed) SHA1(2e33c487deaf8afb941e07e511a9828d2d8f6b31) )
10471051
1048   /* 54XX ROM */
1049   ROM_REGION( 0x400, REGION_CPU4, 0 )
1050   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
1052   POLEPOS_CUSTOMS
10511053
10521054   /* graphics data */
10531055   ROM_REGION( 0x01000, REGION_GFX1, ROMREGION_DISPOSE )    /* 2bpp alpha layer */
r1070r1071
11241126   ROM_LOAD16_BYTE( "136014.103",   0x0001, 0x2000, CRC(af4fc019) SHA1(1bb6c0f3ffada2e1df72e1767581f8e8bb2b18f9) )
11251127   ROM_LOAD16_BYTE( "136014.104",   0x0000, 0x2000, CRC(ba0045f3) SHA1(aedb8d8c56407963aa4ffb66243288c8fd6d845a) )
11261128
1127   /* 54XX ROM */
1128   ROM_REGION( 0x400, REGION_CPU4, 0 )
1129   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
1129   POLEPOS_CUSTOMS
11301130
11311131   /* graphics data */
11321132   ROM_REGION( 0x01000, REGION_GFX1, ROMREGION_DISPOSE )    /* 2bpp alpha layer */
r1070r1071
12031203   ROM_LOAD16_BYTE( "tr5b.bin",     0x0001, 0x2000, CRC(4e5f7b9c) SHA1(d26b1f24dd9ef00388987890bc5b95d4db403815) )
12041204   ROM_LOAD16_BYTE( "tr6b.bin",     0x0000, 0x2000, CRC(9d038ada) SHA1(7a9496c3fb93fd1945393656f8510a0c6421a9ab) )
12051205
1206   /* 54XX ROM */
1207   ROM_REGION( 0x400, REGION_CPU4, 0 )
1208   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
1206   /* this is a bootleg, should we really be loading these? */
1207   POLEPOS_CUSTOMS
12091208
12101209   /* graphics data */
12111210   ROM_REGION( 0x01000, REGION_GFX1, ROMREGION_DISPOSE )    /* 2bpp alpha layer */
r1070r1071
12811280   ROM_LOAD16_BYTE( "tr5b.bin",     0x0001, 0x2000, CRC(4e5f7b9c) SHA1(d26b1f24dd9ef00388987890bc5b95d4db403815) )
12821281   ROM_LOAD16_BYTE( "pole-d",       0x0000, 0x2000, CRC(932bb5a7) SHA1(8045fe1f9b4b1973ec0d6705adf3ba3891bddaa1) )
12831282
1284   /* 54XX ROM */
1285   ROM_REGION( 0x400, REGION_CPU4, 0 )
1286   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
1283   /* this is a bootleg, should we really be loading these? */
1284   POLEPOS_CUSTOMS
12871285
12881286   /* graphics data */
12891287   ROM_REGION( 0x01000, REGION_GFX1, ROMREGION_DISPOSE )    /* 2bpp alpha layer */
r1070r1071
13621360   ROM_LOAD16_BYTE( "tr5b.f7",     0x0001, 0x2000, CRC(4e5f7b9c) SHA1(d26b1f24dd9ef00388987890bc5b95d4db403815) )
13631361   ROM_LOAD16_BYTE( "tr6b.f5",     0x0000, 0x2000, CRC(b3641d0c) SHA1(38ce172b2e38895749cbd3cc1c0e2c0fe8be744a) )
13641362
1365   /* 54XX ROM */
1366   ROM_REGION( 0x400, REGION_CPU4, 0 )
1367   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
1363   /* this is a bootleg, should we really be loading these? */
1364   POLEPOS_CUSTOMS
13681365
13691366   /* graphics data */
13701367   ROM_REGION( 0x01000, REGION_GFX1, ROMREGION_DISPOSE )    /* 2bpp alpha layer */
r1070r1071
14431440   ROM_LOAD16_BYTE( "pp4_7.3m",      0x4001, 0x1000, CRC(ad1c8994) SHA1(2877de9641516767170c0109900955cc7d1ff402) )
14441441   ROM_LOAD16_BYTE( "pp4_8.3l",      0x4000, 0x1000, CRC(ef25a2ee) SHA1(45959355cad1a48f19ae14193374e03d4f9965c7) )
14451442
1446   /* 54XX ROM */
1447   ROM_REGION( 0x400, REGION_CPU4, 0 )
1448   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
1443   POLEPOS_CUSTOMS
14491444
14501445   /* graphics data */
14511446   ROM_REGION( 0x02000, REGION_GFX1, ROMREGION_DISPOSE )    /* 2bpp alpha layer */
r1070r1071
15291524   ROM_LOAD16_BYTE( "136014.184",   0x4001, 0x2000, CRC(d893c4ed) SHA1(60d39abefbb0c8df68864a30b1f5fcbf4780c86c) )
15301525   ROM_LOAD16_BYTE( "136014.185",   0x4000, 0x2000, CRC(899de75e) SHA1(4a16535115e37a3d342b2cb53f610a87c0d0abe1) )
15311526
1532   /* 54XX ROM */
1533   ROM_REGION( 0x400, REGION_CPU4, 0 )
1534   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
1527   POLEPOS_CUSTOMS
15351528
15361529   /* graphics data */
15371530   ROM_REGION( 0x02000, REGION_GFX1, ROMREGION_DISPOSE )    /* 2bpp alpha layer */
r1070r1071
16131606   ROM_LOAD16_BYTE( "136014.184",   0x4001, 0x2000, CRC(d893c4ed) SHA1(60d39abefbb0c8df68864a30b1f5fcbf4780c86c) )
16141607   ROM_LOAD16_BYTE( "136014.185",   0x4000, 0x2000, CRC(899de75e) SHA1(4a16535115e37a3d342b2cb53f610a87c0d0abe1) )
16151608
1616   /* 54XX ROM */
1617   ROM_REGION( 0x400, REGION_CPU4, 0 )
1618   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
1609   /* this is a bootleg, should we really be loading these? */
1610   POLEPOS_CUSTOMS
16191611
16201612   /* graphics data */
16211613   ROM_REGION( 0x02000, REGION_GFX1, ROMREGION_DISPOSE )    /* 2bpp alpha layer */
src/mame/drivers/model2.c
r1070r1071
6262extern VIDEO_START(model2);
6363extern VIDEO_UPDATE(model2);
6464
65extern void model2_3d_set_zclip( UINT8 clip );
66
6567UINT32 *model2_bufferram, *model2_colorxlat, *model2_workram, *model2_backup1, *model2_backup2;
6668UINT32 *model2_textureram0, *model2_textureram1, *model2_lumaram;
6769static UINT32 model2_intreq;
r1070r1071
526528         logerror("Boot copro, %d dwords\n", model2_coprocnt);
527529         if (dsp_type != DSP_TYPE_TGPX4)
528530         {
529         cpunum_set_input_line(2, INPUT_LINE_HALT, CLEAR_LINE);
531            cpunum_set_input_line(2, INPUT_LINE_HALT, CLEAR_LINE);
532         }
530533      }
531534   }
532   }
533535
534536   model2_coproctl = data;
535537}
r1070r1071
12391241   }
12401242}
12411243
1244static WRITE32_HANDLER(model2_3d_zclip_w)
1245{
1246   model2_3d_set_zclip( data & 0xFF );
1247}
1248
12421249/* common map for all Model 2 versions */
12431250static ADDRESS_MAP_START( model2_base_mem, ADDRESS_SPACE_PROGRAM, 32 )
12441251   AM_RANGE(0x00000000, 0x001fffff) AM_ROM AM_WRITENOP
r1070r1071
12731280
12741281   AM_RANGE(0x01800000, 0x01803fff) AM_READWRITE(MRA32_RAM, pal32_w) AM_BASE(&paletteram32)
12751282   AM_RANGE(0x01810000, 0x0181bfff) AM_RAM AM_BASE(&model2_colorxlat)
1283   AM_RANGE(0x0181c000, 0x0181c003) AM_WRITE(model2_3d_zclip_w)
12761284   AM_RANGE(0x01a10000, 0x01a1ffff) AM_READWRITE(network_r, network_w)
12771285   AM_RANGE(0x01d00000, 0x01d03fff) AM_RAM AM_BASE( &model2_backup1 ) // Backup sram
12781286   AM_RANGE(0x02000000, 0x03ffffff) AM_ROM AM_REGION(REGION_USER1, 0)
src/mame/drivers/gstream.c
r1070r1071
99    Simple Sprites (16x16x8bpp tiles)
1010    3 Simple Tilemaps (32x32x8bpp tiles)
1111
12
13
1412    todo: sprite lag (sprites need buffering?)
1513          sound banking
1614
r1070r1071
9492    . Board supplied by Tormod
9593    . Board dumped by Tormod
9694
97
98
9995*********************************************************************/
10096
10197#include "driver.h"
10298#include "sound/okim6295.h"
10399
104static UINT32* gstream_vram;
105static UINT32* gstream_workram;
106static UINT32* gstream_backupram;
100static UINT32 *gstream_vram;
101static UINT32 *gstream_workram;
107102
108103static tilemap *gstream_tilemap1;
109104static tilemap *gstream_tilemap2;
r1070r1071
114109
115110static WRITE32_HANDLER( gstream_palette_w )
116111{
117
118112   COMBINE_DATA(&paletteram32[offset]);
119113
120114   palette_set_color_rgb(Machine,offset*2,pal5bit(paletteram32[offset] >> (0+16)),
r1070r1071
156150static WRITE32_HANDLER( gstream_tilemap3_scrolly_w ) { tilemap3_scrolly = data; }
157151
158152static ADDRESS_MAP_START( gstream_32bit_map, ADDRESS_SPACE_PROGRAM, 32 )
159   AM_RANGE(0x00000000, 0x00FFFFFF) AM_RAM AM_BASE(&gstream_workram) // work ram, how big?
160
153   AM_RANGE(0x00000000, 0x003FFFFF) AM_RAM AM_BASE(&gstream_workram) // work ram
161154//  AM_RANGE(0x40000000, 0x40FFFFFF) AM_RAM // ?? lots of data gets copied here if present, but game runs without it??
162
163155   AM_RANGE(0x80000000, 0x80003FFF) AM_RAM AM_WRITE(gstream_vram_w) AM_BASE(&gstream_vram) // video ram
164
165156   AM_RANGE(0x4E000000, 0x4E1FFFFF) AM_ROM AM_REGION(REGION_USER2,0) // main game rom
166
167157   AM_RANGE(0x4F000000, 0x4F000003) AM_WRITE(gstream_tilemap3_scrollx_w)
168158   AM_RANGE(0x4F200000, 0x4F200003) AM_WRITE(gstream_tilemap3_scrolly_w)
169159   AM_RANGE(0x4F400000, 0x4F406FFF) AM_RAM AM_WRITE(gstream_palette_w) AM_BASE(&paletteram32)
r1070r1071
171161   AM_RANGE(0x4FA00000, 0x4FA00003) AM_WRITE(gstream_tilemap1_scrolly_w)
172162   AM_RANGE(0x4FC00000, 0x4FC00003) AM_WRITE(gstream_tilemap2_scrollx_w)
173163   AM_RANGE(0x4FE00000, 0x4FE00003) AM_WRITE(gstream_tilemap2_scrolly_w)
164   AM_RANGE(0xFFC00000, 0xFFC01FFF) AM_RAM AM_BASE(&generic_nvram32) AM_SIZE(&generic_nvram_size) // Backup RAM
165   AM_RANGE(0xFFF80000, 0xFFFFFFFF) AM_ROM AM_REGION(REGION_USER1,0) // boot rom
166ADDRESS_MAP_END
174167
175   AM_RANGE(0xFFC00000, 0xFFC01FFF) AM_RAM AM_BASE(&gstream_backupram) // Backup RAM
168static READ32_HANDLER( gstream_oki_0_r ) { return OKIM6295_status_0_r(0); }
169static READ32_HANDLER( gstream_oki_1_r ) { return OKIM6295_status_1_r(0); }
170static WRITE32_HANDLER( gstream_oki_0_w ) { OKIM6295_data_0_w(0, data & 0xff); }
171static WRITE32_HANDLER( gstream_oki_1_w ) { OKIM6295_data_1_w(0, data & 0xff); }
176172
177   AM_RANGE(0xFFF80000, 0xFFFFFFFF) AM_ROM AM_REGION(REGION_USER1,0) // boot rom
173static WRITE32_HANDLER( gstream_oki_4030_w )
174{
175/*
176    // the only nibbles that are written are: 0x6 0x7 0x9 0xa 0xb 0xe 0xd 0xf which should map to the 8 oki banks
178177
179ADDRESS_MAP_END
178    static const int bank_lookup[16] = { -1, -1, -1, -1, -1, -1, 0, 1, -1, 2, 3, 4, -1, 5, 6, 7 };
180179
180    static int old_bank_0 = -1;
181    static int old_bank_1 = -1;
181182
182static READ32_HANDLER(player1_inputs_read) { return readinputport(0); }
183static READ32_HANDLER(player2_inputs_read) { return readinputport(1); }
184static READ32_HANDLER(gstream_unk_r)       { return readinputport(2); }
183    if(bank_lookup[data & 0xf] != old_bank_0)
184    {
185        old_bank_0 = bank_lookup[data & 0xf];
185186
186static READ32_HANDLER( gstream_oki_0_r ) {   return OKIM6295_status_0_r(0); }
187static READ32_HANDLER( gstream_oki_1_r ) {   return OKIM6295_status_1_r(0); }
188static WRITE32_HANDLER( gstream_oki_0_w ) { OKIM6295_data_0_w(0, data & 0x000000ff); } // check other bits
189static WRITE32_HANDLER( gstream_oki_1_w ) { OKIM6295_data_1_w(0, data & 0x000000ff); } // check other bits
187        if(old_bank_0 != -1)
188            OKIM6295_set_bank_base(0, old_bank_0 * 0x40000);
189        else
190            logerror("oki_0 banking value = %X\n",data & 0xf);
191    }
190192
191static WRITE32_HANDLER( gstream_oki_4030_w )
192{
193   //printf("4030: %08x\n", data);
193    if(bank_lookup[(data >> 4) & 0xf] != old_bank_1)
194    {
195        old_bank_1 = bank_lookup[(data >> 4) & 0xf];
196
197        if(old_bank_1 != -1)
198            OKIM6295_set_bank_base(1, old_bank_1 * 0x40000);
199        else
200            logerror("oki_1 banking value = %X\n",(data >> 4) & 0xf);
201    }
202*/
194203}
195204
196205static WRITE32_HANDLER( gstream_oki_4040_w )
197206{
198   //printf("4040: %08x\n", data);
207   // data == 0 or data == 0x81
199208}
200209
201
202210static ADDRESS_MAP_START( gstream_io, ADDRESS_SPACE_IO, 32 )
203
204   AM_RANGE(0x0000, 0x0003)                    AM_WRITE(MWA32_NOP) // unknown
205   AM_RANGE(0x001c, 0x001f) AM_READ(MRA32_NOP) AM_WRITE(MWA32_NOP) // unknown
206
207   AM_RANGE(0x4000, 0x4003) AM_READ(player1_inputs_read)
208   AM_RANGE(0x4010, 0x4013) AM_READ(player2_inputs_read)
209   AM_RANGE(0x4020, 0x4023) AM_READ(gstream_unk_r) // extra coin switches etc??
210
211   /* oki banking?? */
211   AM_RANGE(0x4000, 0x4003) AM_READ(input_port_0_dword_r)
212   AM_RANGE(0x4010, 0x4013) AM_READ(input_port_1_dword_r)
213   AM_RANGE(0x4020, 0x4023) AM_READ(input_port_2_dword_r) // extra coin switches etc
212214   AM_RANGE(0x4030, 0x4033) AM_WRITE(gstream_oki_4030_w) // ??
213215   AM_RANGE(0x4040, 0x4043) AM_WRITE(gstream_oki_4040_w) // ??
214
215   AM_RANGE(0x4050, 0x4053) AM_READ(gstream_oki_1_r) AM_WRITE(gstream_oki_1_w) // music
216   AM_RANGE(0x4060, 0x4063) AM_READ(gstream_oki_0_r) AM_WRITE(gstream_oki_0_w) // samples
216   AM_RANGE(0x4050, 0x4053) AM_READWRITE(gstream_oki_1_r, gstream_oki_1_w) // music
217   AM_RANGE(0x4060, 0x4063) AM_READWRITE(gstream_oki_0_r, gstream_oki_0_w) // samples
217218ADDRESS_MAP_END
218219
219220
220221static INPUT_PORTS_START( gstream )
221222   PORT_START
222   PORT_BIT( 0x00000001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
223   PORT_BIT( 0x00000002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)
224   PORT_BIT( 0x00000004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)
225   PORT_BIT( 0x00000008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)
226   PORT_BIT( 0x00000010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
227   PORT_BIT( 0x00000020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
228   PORT_BIT( 0x00000040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
229   PORT_BIT( 0x00000080, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(1)
230   PORT_BIT( 0x00000100, IP_ACTIVE_LOW, IPT_UNUSED )
231   PORT_BIT( 0x00000200, IP_ACTIVE_LOW, IPT_COIN1 )
232   PORT_BIT( 0x00000400, IP_ACTIVE_LOW, IPT_START1 )
233   PORT_BIT( 0x00000800, IP_ACTIVE_LOW, IPT_SERVICE1 )
234    PORT_DIPNAME( 0x00001000, 0x00001000, DEF_STR( Unknown ) )
235    PORT_DIPSETTING(          0x00001000, DEF_STR( Off ) )
236    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
237    PORT_DIPNAME( 0x00002000, 0x00002000, DEF_STR( Unknown ) )
238    PORT_DIPSETTING(          0x00002000, DEF_STR( Off ) )
239    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
240    PORT_DIPNAME( 0x00004000, 0x00004000, DEF_STR( Unknown ) )
241    PORT_DIPSETTING(          0x00004000, DEF_STR( Off ) )
242    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
243    PORT_DIPNAME( 0x00008000, 0x00008000, DEF_STR( Unknown ) ) // test1?
244    PORT_DIPSETTING(          0x00008000, DEF_STR( Off ) )
245    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
223   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
224   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)
225   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)
226   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)
227   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
228   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
229   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
230   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(1)
231   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_UNUSED )
232   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_COIN1 )
233   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_START1 )
234   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_SERVICE1 )
235   PORT_BIT( 0xe000, IP_ACTIVE_LOW, IPT_UNUSED )
236   PORT_SERVICE_NO_TOGGLE( 0x8000, IP_ACTIVE_LOW )
246237
247238   PORT_START
248   PORT_BIT( 0x00000001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2)
249   PORT_BIT( 0x00000002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)
250   PORT_BIT( 0x00000004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)
251   PORT_BIT( 0x00000008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
252   PORT_BIT( 0x00000010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
253   PORT_BIT( 0x00000020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
254   PORT_BIT( 0x00000040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
255   PORT_BIT( 0x00000080, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(2)
256   PORT_BIT( 0x00000100, IP_ACTIVE_LOW, IPT_UNUSED )
257   PORT_BIT( 0x00000200, IP_ACTIVE_LOW, IPT_COIN2 )
258   PORT_BIT( 0x00000400, IP_ACTIVE_LOW, IPT_START2 )
259   PORT_BIT( 0x00000800, IP_ACTIVE_LOW, IPT_SERVICE2 )
260    PORT_DIPNAME( 0x00001000, 0x00001000, DEF_STR( Unknown ) )
261    PORT_DIPSETTING(          0x00001000, DEF_STR( Off ) )
262    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
263    PORT_DIPNAME( 0x00002000, 0x00002000, DEF_STR( Unknown ) )
264    PORT_DIPSETTING(          0x00002000, DEF_STR( Off ) )
265    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
266    PORT_DIPNAME( 0x00004000, 0x00004000, DEF_STR( Unknown ) )
267    PORT_DIPSETTING(          0x00004000, DEF_STR( Off ) )
268    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
269    PORT_DIPNAME( 0x00008000, 0x00008000, DEF_STR( Unknown ) ) // test 2?
270    PORT_DIPSETTING(          0x00008000, DEF_STR( Off ) )
271    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
239   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2)
240   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)
241   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)
242   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
243   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
244   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
245   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
246   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(2)
247   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_UNUSED )
248   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_COIN2 )
249   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_START2 )
250   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_SERVICE2 )
251   PORT_BIT( 0xe000, IP_ACTIVE_LOW, IPT_UNUSED )
252   PORT_SERVICE_NO_TOGGLE( 0x8000, IP_ACTIVE_LOW )
272253
273254   PORT_START
274    PORT_DIPNAME( 0x00000001, 0x00000001, "0" )
275    PORT_DIPSETTING(          0x00000001, DEF_STR( Off ) )
276    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
277    PORT_DIPNAME( 0x00000002, 0x00000002, DEF_STR( Unknown ) )
278    PORT_DIPSETTING(          0x00000002, DEF_STR( Off ) )
279    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
280    PORT_DIPNAME( 0x00000004, 0x00000004, DEF_STR( Unknown ) )
281    PORT_DIPSETTING(          0x00000004, DEF_STR( Off ) )
282    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
283    PORT_DIPNAME( 0x00000008, 0x00000008, DEF_STR( Unknown ) )
284    PORT_DIPSETTING(          0x00000008, DEF_STR( Off ) )
285    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
286    PORT_DIPNAME( 0x00000010, 0x00000010, DEF_STR( Unknown ) )
287    PORT_DIPSETTING(          0x00000010, DEF_STR( Off ) )
288    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
289    PORT_DIPNAME( 0x00000020, 0x00000020, DEF_STR( Unknown ) )
290    PORT_DIPSETTING(          0x00000020, DEF_STR( Off ) )
291    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
292    PORT_DIPNAME( 0x00000040, 0x00000040, DEF_STR( Unknown ) )
293    PORT_DIPSETTING(          0x00000040, DEF_STR( Off ) )
294    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
295    PORT_DIPNAME( 0x00000080, 0x00000080, DEF_STR( Unknown ) )
296    PORT_DIPSETTING(          0x00000080, DEF_STR( Off ) )
297    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
298    PORT_DIPNAME( 0x00000100, 0x00000100, DEF_STR( Unknown ) )
299    PORT_DIPSETTING(          0x00000100, DEF_STR( Off ) )
300    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
301    PORT_DIPNAME( 0x00000200, 0x00000200, DEF_STR( Unknown ) )
302    PORT_DIPSETTING(          0x00000200, DEF_STR( Off ) )
303    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
304    PORT_DIPNAME( 0x00000400, 0x00000400, DEF_STR( Unknown ) )
305    PORT_DIPSETTING(          0x00000400, DEF_STR( Off ) )
306    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
307    PORT_DIPNAME( 0x00000800, 0x00000800, DEF_STR( Unknown ) )
308    PORT_DIPSETTING(          0x00000800, DEF_STR( Off ) )
309    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
310    PORT_DIPNAME( 0x00001000, 0x00001000, DEF_STR( Unknown ) )
311    PORT_DIPSETTING(          0x00001000, DEF_STR( Off ) )
312    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
313    PORT_DIPNAME( 0x00002000, 0x00002000, DEF_STR( Unknown ) )
314    PORT_DIPSETTING(          0x00002000, DEF_STR( Off ) )
315    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
316    PORT_DIPNAME( 0x00004000, 0x00004000, DEF_STR( Unknown ) )
317    PORT_DIPSETTING(          0x00004000, DEF_STR( Off ) )
318    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
319    PORT_DIPNAME( 0x00008000, 0x00008000, DEF_STR( Unknown ) )
320    PORT_DIPSETTING(          0x00008000, DEF_STR( Off ) )
321    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
322   PORT_DIPNAME( 0x00010000, 0x00010000, "1" )
323    PORT_DIPSETTING(          0x00010000, DEF_STR( Off ) )
324    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
325    PORT_DIPNAME( 0x00020000, 0x00020000, DEF_STR( Unknown ) )
326    PORT_DIPSETTING(          0x00020000, DEF_STR( Off ) )
327    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
328    PORT_DIPNAME( 0x00040000, 0x00040000, DEF_STR( Unknown ) )
329    PORT_DIPSETTING(          0x00040000, DEF_STR( Off ) )
330    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
331    PORT_DIPNAME( 0x00080000, 0x00080000, DEF_STR( Unknown ) )
332    PORT_DIPSETTING(          0x00080000, DEF_STR( Off ) )
333    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
334    PORT_DIPNAME( 0x00100000, 0x00100000, DEF_STR( Unknown ) )
335    PORT_DIPSETTING(          0x00100000, DEF_STR( Off ) )
336    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
337    PORT_DIPNAME( 0x00200000, 0x00200000, DEF_STR( Unknown ) )
338    PORT_DIPSETTING(          0x00200000, DEF_STR( Off ) )
339    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
340    PORT_DIPNAME( 0x00400000, 0x00400000, DEF_STR( Unknown ) )
341    PORT_DIPSETTING(          0x00400000, DEF_STR( Off ) )
342    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
343    PORT_DIPNAME( 0x00800000, 0x00800000, DEF_STR( Unknown ) )
344    PORT_DIPSETTING(          0x00800000, DEF_STR( Off ) )
345    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
346    PORT_DIPNAME( 0x01000000, 0x01000000, DEF_STR( Unknown ) )
347    PORT_DIPSETTING(          0x01000000, DEF_STR( Off ) )
348    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
349    PORT_DIPNAME( 0x02000000, 0x02000000, DEF_STR( Unknown ) )
350    PORT_DIPSETTING(          0x02000000, DEF_STR( Off ) )
351    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
352    PORT_DIPNAME( 0x04000000, 0x04000000, DEF_STR( Unknown ) )
353    PORT_DIPSETTING(          0x04000000, DEF_STR( Off ) )
354    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
355    PORT_DIPNAME( 0x08000000, 0x08000000, DEF_STR( Unknown ) )
356    PORT_DIPSETTING(          0x08000000, DEF_STR( Off ) )
357    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
358    PORT_DIPNAME( 0x10000000, 0x10000000, DEF_STR( Unknown ) )
359    PORT_DIPSETTING(          0x10000000, DEF_STR( Off ) )
360    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
361    PORT_DIPNAME( 0x20000000, 0x20000000, DEF_STR( Unknown ) )
362    PORT_DIPSETTING(          0x20000000, DEF_STR( Off ) )
363    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
364    PORT_DIPNAME( 0x40000000, 0x40000000, DEF_STR( Unknown ) )
365    PORT_DIPSETTING(          0x40000000, DEF_STR( Off ) )
366    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
367    PORT_DIPNAME( 0x80000000, 0x80000000, DEF_STR( Unknown ) )
368    PORT_DIPSETTING(          0x80000000, DEF_STR( Off ) )
369    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
370
371   PORT_START
372    PORT_DIPNAME( 0x00000001, 0x00000001, "2" )
373    PORT_DIPSETTING(          0x00000001, DEF_STR( Off ) )
374    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
375    PORT_DIPNAME( 0x00000002, 0x00000002, DEF_STR( Unknown ) )
376    PORT_DIPSETTING(          0x00000002, DEF_STR( Off ) )
377    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
378    PORT_DIPNAME( 0x00000004, 0x00000004, DEF_STR( Unknown ) )
379    PORT_DIPSETTING(          0x00000004, DEF_STR( Off ) )
380    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
381    PORT_DIPNAME( 0x00000008, 0x00000008, DEF_STR( Unknown ) )
382    PORT_DIPSETTING(          0x00000008, DEF_STR( Off ) )
383    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
384    PORT_DIPNAME( 0x00000010, 0x00000010, DEF_STR( Unknown ) )
385    PORT_DIPSETTING(          0x00000010, DEF_STR( Off ) )
386    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
387    PORT_DIPNAME( 0x00000020, 0x00000020, DEF_STR( Unknown ) )
388    PORT_DIPSETTING(          0x00000020, DEF_STR( Off ) )
389    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
390    PORT_DIPNAME( 0x00000040, 0x00000040, DEF_STR( Unknown ) )
391    PORT_DIPSETTING(          0x00000040, DEF_STR( Off ) )
392    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
393    PORT_DIPNAME( 0x00000080, 0x00000080, DEF_STR( Unknown ) )
394    PORT_DIPSETTING(          0x00000080, DEF_STR( Off ) )
395    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
396    PORT_DIPNAME( 0x00000100, 0x00000100, DEF_STR( Unknown ) )
397    PORT_DIPSETTING(          0x00000100, DEF_STR( Off ) )
398    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
399    PORT_DIPNAME( 0x00000200, 0x00000200, DEF_STR( Unknown ) )
400    PORT_DIPSETTING(          0x00000200, DEF_STR( Off ) )
401    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
402    PORT_DIPNAME( 0x00000400, 0x00000400, DEF_STR( Unknown ) )
403    PORT_DIPSETTING(          0x00000400, DEF_STR( Off ) )
404    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
405    PORT_DIPNAME( 0x00000800, 0x00000800, DEF_STR( Unknown ) )
406    PORT_DIPSETTING(          0x00000800, DEF_STR( Off ) )
407    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
408    PORT_DIPNAME( 0x00001000, 0x00001000, DEF_STR( Unknown ) )
409    PORT_DIPSETTING(          0x00001000, DEF_STR( Off ) )
410    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
411    PORT_DIPNAME( 0x00002000, 0x00002000, DEF_STR( Unknown ) )
412    PORT_DIPSETTING(          0x00002000, DEF_STR( Off ) )
413    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
414    PORT_DIPNAME( 0x00004000, 0x00004000, DEF_STR( Unknown ) )
415    PORT_DIPSETTING(          0x00004000, DEF_STR( Off ) )
416    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
417    PORT_DIPNAME( 0x00008000, 0x00008000, DEF_STR( Unknown ) )
418    PORT_DIPSETTING(          0x00008000, DEF_STR( Off ) )
419    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
420   PORT_DIPNAME( 0x00010000, 0x00010000, "3" )
421    PORT_DIPSETTING(          0x00010000, DEF_STR( Off ) )
422    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
423    PORT_DIPNAME( 0x00020000, 0x00020000, DEF_STR( Unknown ) )
424    PORT_DIPSETTING(          0x00020000, DEF_STR( Off ) )
425    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
426    PORT_DIPNAME( 0x00040000, 0x00040000, DEF_STR( Unknown ) )
427    PORT_DIPSETTING(          0x00040000, DEF_STR( Off ) )
428    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
429    PORT_DIPNAME( 0x00080000, 0x00080000, DEF_STR( Unknown ) )
430    PORT_DIPSETTING(          0x00080000, DEF_STR( Off ) )
431    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
432    PORT_DIPNAME( 0x00100000, 0x00100000, DEF_STR( Unknown ) )
433    PORT_DIPSETTING(          0x00100000, DEF_STR( Off ) )
434    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
435    PORT_DIPNAME( 0x00200000, 0x00200000, DEF_STR( Unknown ) )
436    PORT_DIPSETTING(          0x00200000, DEF_STR( Off ) )
437    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
438    PORT_DIPNAME( 0x00400000, 0x00400000, DEF_STR( Unknown ) )
439    PORT_DIPSETTING(          0x00400000, DEF_STR( Off ) )
440    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
441    PORT_DIPNAME( 0x00800000, 0x00800000, DEF_STR( Unknown ) )
442    PORT_DIPSETTING(          0x00800000, DEF_STR( Off ) )
443    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
444    PORT_DIPNAME( 0x01000000, 0x01000000, DEF_STR( Unknown ) )
445    PORT_DIPSETTING(          0x01000000, DEF_STR( Off ) )
446    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
447    PORT_DIPNAME( 0x02000000, 0x02000000, DEF_STR( Unknown ) )
448    PORT_DIPSETTING(          0x02000000, DEF_STR( Off ) )
449    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
450    PORT_DIPNAME( 0x04000000, 0x04000000, DEF_STR( Unknown ) )
451    PORT_DIPSETTING(          0x04000000, DEF_STR( Off ) )
452    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
453    PORT_DIPNAME( 0x08000000, 0x08000000, DEF_STR( Unknown ) )
454    PORT_DIPSETTING(          0x08000000, DEF_STR( Off ) )
455    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
456    PORT_DIPNAME( 0x10000000, 0x10000000, DEF_STR( Unknown ) )
457    PORT_DIPSETTING(          0x10000000, DEF_STR( Off ) )
458    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
459    PORT_DIPNAME( 0x20000000, 0x20000000, DEF_STR( Unknown ) )
460    PORT_DIPSETTING(          0x20000000, DEF_STR( Off ) )
461    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
462    PORT_DIPNAME( 0x40000000, 0x40000000, DEF_STR( Unknown ) )
463    PORT_DIPSETTING(          0x40000000, DEF_STR( Off ) )
464    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
465    PORT_DIPNAME( 0x80000000, 0x80000000, DEF_STR( Unknown ) )
466    PORT_DIPSETTING(          0x80000000, DEF_STR( Off ) )
467    PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
468
255    PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 ) // mirror of some inputs...
256   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
257   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_START1 )
258   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_START2 )
259    PORT_BIT( 0xffb0, IP_ACTIVE_LOW, IPT_UNUSED )
260    PORT_SERVICE_NO_TOGGLE( 0x40, IP_ACTIVE_LOW )
469261INPUT_PORTS_END
470262
471263
472static const gfx_layout sprites_layout =
264static const gfx_layout layout16x16 =
473265{
474266   16,16,
475267   RGN_FRAC(1,1),
r1070r1071
480272   16*128,
481273};
482274
483static const gfx_layout sprites32_layout =
275static const gfx_layout layout32x32 =
484276{
485277   32,32,
486278   RGN_FRAC(1,1),
r1070r1071
499291};
500292
501293static GFXDECODE_START( gstream )
502   GFXDECODE_ENTRY( REGION_GFX2, 0, sprites32_layout, 0, 0x80 )
503   GFXDECODE_ENTRY( REGION_GFX1, 0, sprites_layout, 0, 0x80 )
294    GFXDECODE_ENTRY( REGION_GFX2, 0, layout32x32, 0, 0x80 )
295    GFXDECODE_ENTRY( REGION_GFX1, 0, layout16x16, 0, 0x80 )
504296GFXDECODE_END
505297
506298
299
507300static TILE_GET_INFO( get_gs1_tile_info )
508301{
509302   int tileno, palette;
r1070r1071
549342       Sprites start at the top of memory, tilemaps at
550343       the bottom, but the areas can overlap
551344
552       *potential problem*
345       *What seems an actual game bug*
553346       when a sprite ends up with a negative co-ordinate
554347       a value of 0xfffffffe gets set in the sprite list.
555348       this could corrupt the tile value as both words
556       are being set ?! -- todo, check if this happens
557       and if it does figure out if its a core bug
558
349       are being set ?!
559350   */
560351
561352   int i;
r1070r1071
571362   tilemap_set_scrollx( gstream_tilemap2, 0, tilemap2_scrollx>>16 );
572363   tilemap_set_scrolly( gstream_tilemap2, 0, tilemap2_scrolly>>16 );
573364
574
575
576   fillbitmap(bitmap,get_black_pen(machine),cliprect);
577365   tilemap_draw(bitmap,cliprect,gstream_tilemap3,0,0);
578366   tilemap_draw(bitmap,cliprect,gstream_tilemap2,0,0);
579367   tilemap_draw(bitmap,cliprect,gstream_tilemap1,0,0);
r1070r1071
581369   for (i=0x0000/4;i<0x4000/4;i+=4)
582370   {
583371      /* Upper bits are used by the tilemaps */
584      int code = (gstream_vram[i+0]&0x0000ffff);
585      int x =    (gstream_vram[i+1]&0x0000ffff);
586      int y =    (gstream_vram[i+2]&0x0000ffff);
587      int col =  (gstream_vram[i+3]&0x0000ffff)&0x1f;
372      int code = gstream_vram[i+0] & 0xffff;
373      int x    = gstream_vram[i+1] & 0xffff;
374      int y    = gstream_vram[i+2] & 0xffff;
375      int col  = gstream_vram[i+3] & 0x1f;
588376
589377      /* co-ordinates are signed */
590      if (x&0x8000) x-=0x10000;
591      if (y&0x8000) y-=0x10000;
378      if (x & 0x8000) x-=0x10000;
379      if (y & 0x8000) y-=0x10000;
592380
593      drawgfx(bitmap,machine->gfx[1],code,col,0,0,x+1,y+1,cliprect,TRANSPARENCY_PEN,0);
381      drawgfx(bitmap,machine->gfx[1],code,col,0,0,x-2,y,cliprect,TRANSPARENCY_PEN,0);
594382   }
595383
596
597384   return 0;
598385}
599386
600
601static NVRAM_HANDLER( gstream )
602{
603   if (read_or_write)
604   {
605      mame_fwrite(file, (UINT8*)gstream_backupram, 0x2000);
606   }
607   else
608   {
609      if (file)
610      {
611         mame_fread(file, (UINT8*)gstream_backupram, 0x2000);
612      }
613      else
614      {
615         /* Initialize NVRAM to defaults to avoid ambiguous 'RAM ERROR' message */
616         int i;
617         UINT32 data[32] = {
618            0x00000001, 0x00000000, 0x00000001, 0x00000001,
619            0x00000001, 0x00000000, 0x00000000, 0x00000001,
620            0x00000000, 0x00000002, 0x00000000, 0x00000000,
621            0x000F4240, 0x082E2E2E, 0x000DBBA0, 0x072E2E2E,
622            0x000C3500, 0x062E2E2E, 0x000AAE60, 0x052E2E2E,
623            0x000927C0, 0x042E2E2E, 0x0007A120, 0x032E2E2E,
624            0x00061A80, 0x022E2E2E, 0x000493E0, 0x012E2E2E,
625            0x00030D40, 0x012E2E2E, 0x000186A0, 0x012E2E2E
626
627         };
628
629         memset(gstream_backupram, 0, 0x2000);
630         for(i=0;i<32;i++)
631            gstream_backupram[i] = data[i];
632
633         gstream_backupram[(0x2000-4)/4] = 0x4B42290E;
634
635      }
636   }
637
638}
639
640
641387static MACHINE_DRIVER_START( gstream )
642388   MDRV_CPU_ADD_TAG("main", E132XT, 16000000)   /* 16 Mhz? */
643389   MDRV_CPU_PROGRAM_MAP(gstream_32bit_map,0)
r1070r1071
656402   MDRV_PALETTE_LENGTH(0x1000 + 0x400 + 0x400 + 0x400) // sprites + 3 bg layers
657403   MDRV_GFXDECODE(gstream)
658404
659   MDRV_NVRAM_HANDLER(gstream)
405   MDRV_NVRAM_HANDLER(generic_1fill)
660406
661407   MDRV_VIDEO_START(gstream)
662408   MDRV_VIDEO_UPDATE(gstream)
663409
664   MDRV_SPEAKER_STANDARD_STEREO("left", "right")
410   MDRV_SPEAKER_STANDARD_MONO("mono")
665411
666412   MDRV_SOUND_ADD(OKIM6295, 1000000) /* 1 Mhz? */
667413   MDRV_SOUND_CONFIG(okim6295_interface_region_1_pin7low) // pin 7 not verified
668   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 0.50)
669   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 0.50)
414   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
670415
671416   MDRV_SOUND_ADD(OKIM6295, 1000000) /* 1 Mhz? */
672417   MDRV_SOUND_CONFIG(okim6295_interface_region_2_pin7low) // pin 7 not verified
673   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 0.50)
674   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 0.50)
418   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
675419MACHINE_DRIVER_END
676420
677
678421ROM_START( gstream )
679422   ROM_REGION32_BE( 0x080000, REGION_USER1, 0 ) /* Hyperstone CPU Code */
680423   ROM_LOAD( "u56.bin", 0x000000, 0x080000, CRC(0d0c6a38) SHA1(a810bfc1c9158cccc37710d0ea7268e26e520cc2) )
r1070r1071
682425   ROM_REGION32_BE( 0x200000, REGION_USER2, 0 ) /* Hyperstone CPU Code */
683426   ROM_LOAD16_WORD_SWAP( "gs_prg_02.bin", 0x000000, 0x200000, CRC(2f8a6bea) SHA1(c0a32838f4bd8599f09002139f87562db625c1c5) )
684427
685   ROM_REGION( 0x1000000, REGION_GFX1, ROMREGION_DISPOSE | ROMREGION_ERASE00 )  /* sprite tiles (16x16x8) */
428   ROM_REGION( 0x1000000, REGION_GFX1, ROMREGION_DISPOSE )  /* sprite tiles (16x16x8) */
686429   ROM_LOAD32_WORD( "gs_gr_07.bin", 0x000000, 0x200000, CRC(84e66fe1) SHA1(73d828714f9ed9baffdc06998f5bf3298396fe9c) )
687430   ROM_LOAD32_WORD( "gs_gr_11.bin", 0x000002, 0x200000, CRC(946d71d1) SHA1(516bd3f4d7f5bce59f0593ed6565114dbd5a4ef0) )
688431   ROM_LOAD32_WORD( "gs_gr_08.bin", 0x400000, 0x200000, CRC(abd0d6aa) SHA1(dd294bbdda05697df84247257f735ab51bc26ca3) )
r1070r1071
692435   ROM_LOAD32_WORD( "gs_gr_10.bin", 0xc00000, 0x200000, CRC(d696d15d) SHA1(85aaa5cdb35f3a8d3266bb8debec0558c860cb53) )
693436   ROM_LOAD32_WORD( "gs_gr_14.bin", 0xc00002, 0x200000, CRC(6bd2a1e1) SHA1(aedca91643f14ececc101a7708255ce9b1d70f68) )
694437
695   ROM_REGION( 0x1000000, REGION_GFX2, ROMREGION_DISPOSE | ROMREGION_ERASE00 )  /* bg tiles (32x32x8) */
438   ROM_REGION( 0xc00000, REGION_GFX2, ROMREGION_DISPOSE )  /* bg tiles (32x32x8) */
696439   ROM_LOAD( "gs_gr_01.bin", 0x000000, 0x200000, CRC(b82cfab8) SHA1(08f0eaef5c927fb056c6cc9342e39f445aae9062) )
697440   ROM_LOAD( "gs_gr_02.bin", 0x200000, 0x200000, CRC(37e19cbd) SHA1(490ebb037fce09100ec4bba3f73ecdf101526641) )
698441   ROM_LOAD( "gs_gr_03.bin", 0x400000, 0x200000, CRC(1a3b2b11) SHA1(a4b1dc1a9709f8f8f2ab2190d7badc246caa540f) )
r1070r1071
700443   ROM_LOAD( "gs_gr_05.bin", 0x800000, 0x200000, CRC(ef283a73) SHA1(8b598facb344eac33138611abc141a2acb375983) )
701444   ROM_LOAD( "gs_gr_06.bin", 0xa00000, 0x200000, CRC(d4e3a2b2) SHA1(4577c007172c718bf7ca55a8ccee5455c281026c) )
702445
703   ROM_REGION( 0x100000, REGION_SOUND1, 0 )
704   ROM_LOAD( "gs_snd_01.bin", 0x080000, 0x080000, CRC(79b64d3f) SHA1(b2166210d3a3b85b9ace90749a444c881f69d551) )
705   ROM_LOAD( "gs_snd_03.bin", 0x000000, 0x080000, CRC(2bfff4ac) SHA1(cce1bb3c78b86722c926854c737f9589806012ba) )
446   ROM_REGION( 0x200000, REGION_SOUND1, 0 )
447   ROM_LOAD( "gs_snd_01.bin", 0x000000, 0x080000, CRC(79b64d3f) SHA1(b2166210d3a3b85b9ace90749a444c881f69d551) )
448   ROM_LOAD( "gs_snd_02.bin", 0x080000, 0x080000, CRC(e49ed92c) SHA1(a3d7b3fe93a786a246acf2657d9056398c793078) )
449   ROM_LOAD( "gs_snd_03.bin", 0x100000, 0x080000, CRC(2bfff4ac) SHA1(cce1bb3c78b86722c926854c737f9589806012ba) )
450   ROM_LOAD( "gs_snd_04.bin", 0x180000, 0x080000, CRC(b259de3b) SHA1(1a64f41d4344fefad5832332f1a7655e23f6b017) )
706451
707   ROM_REGION( 0x100000, REGION_SOUND2, 0 )
708   ROM_LOAD( "gs_snd_02.bin", 0x000000, 0x080000, CRC(e49ed92c) SHA1(a3d7b3fe93a786a246acf2657d9056398c793078) )
709   ROM_LOAD( "gs_snd_04.bin", 0x080000, 0x080000, CRC(b259de3b) SHA1(1a64f41d4344fefad5832332f1a7655e23f6b017) )
452   ROM_REGION( 0x200000, REGION_SOUND2, 0 )
453   ROM_COPY( REGION_SOUND1, 0, 0, 0x200000 )
710454ROM_END
711455
712456static READ32_HANDLER( gstream_speedup_r )
713457{
714   if (activecpu_get_pc()==0xc0001592) {cpu_spinuntil_int();return gstream_workram[0xd1ee0/4];}
458   if (activecpu_get_pc()==0xc0001592)
459   {
460      cpu_spinuntil_int();
461   }
462
715463   return gstream_workram[0xd1ee0/4];
716464}
717465
r1070r1071
720468   memory_install_read32_handler(0, ADDRESS_SPACE_PROGRAM, 0xd1ee0, 0xd1ee3, 0, 0, gstream_speedup_r );
721469
722470}
723GAME( 2002, gstream, 0,      gstream, gstream,  gstream, ROT270, "Oriental Soft Japan", "G-Stream G2020", GAME_IMPERFECT_SOUND )
471GAME( 2002, gstream, 0, gstream, gstream, gstream, ROT270, "Oriental Soft Japan", "G-Stream G2020", GAME_IMPERFECT_SOUND )
src/mame/drivers/tehkanwc.c
r1070r1071
918918   ROM_LOAD( "twc-5.bin",    0x0000, 0x4000, CRC(444b5544) SHA1(0786d6d9ada7fe49c8ab9751b049095474d2e598) )
919919ROM_END
920920
921/* from a bootleg board, but clearly a different revision of the game code too,
922   it still displays the Tehkan copyright etc. so might actually be a legitimate alt revision */
923
924/*
925CPUs
926
927    on main board:
928        3x Z8400A-Z80ACPU (main, sound)
929        2x YM-3-8910 (sound)
930        1x OKI M5205 (sound)
931
932    on roms board:
933        1x oscillator 18.000MHz
934        1x oscillator 4.00000MHz
935
936ROMs:
937
938    on main board:
939        5x TMM27128D (1,2,3,5,6)
940        1x HN27256G (4)
941        1x PAL16L8A (on a small piggyback, not dumped)
942
943    on roms board:
944        1x TMM27128D (12)
945        4x HN27256G (7,8,9,11)
946
947Notes:
948
949    on main board:
950        2x 18x2 edge connectors
951        2x 50 pins flat cable connectors to roms board
952        1x trimmer (volume)
953        2x red LEDs
954        2x 8x2 switches dip
955
956    on roms board:
957        2x 50 pins flat cable connectors to roms board
958
959*/
960
961ROM_START( tehkanwb )
962   ROM_REGION( 0x10000, REGION_CPU1, 0 )
963   ROM_LOAD( "e-1.3-18.ic32",    0x0000, 0x4000, CRC(ac9d851b) SHA1(38a799cec4f29a88ed22c7a1e35fd2287cee869a) )
964   ROM_LOAD( "e-2.3-17.ic31",    0x4000, 0x4000, CRC(65b53d99) SHA1(ea172b2540763d64dc4a238700421cea27138fae) )
965   ROM_LOAD( "e-3.3-15.ic30",    0x8000, 0x4000, CRC(12064bfc) SHA1(954b56a548c697927d58b9cb2ecfe32b4db8d769) )
966
967   ROM_REGION( 0x10000, REGION_CPU2, 0 )
968   ROM_LOAD( "e-4.9-17.ic100",    0x0000, 0x8000, CRC(70a9f883) SHA1(ace04359265271eb37512a89eb0217eb013aecb7) )
969
970   ROM_REGION( 0x10000, REGION_CPU3, 0 )
971   ROM_LOAD( "e-6.8-3.ic83",    0x0000, 0x4000, CRC(e3112be2) SHA1(7859e51b4312dc5df01c88e1d97cf608abc7ca72) )
972
973   ROM_REGION( 0x04000, REGION_GFX1, ROMREGION_DISPOSE )
974   ROM_LOAD( "e-12.8c.ic233",   0x00000, 0x4000, CRC(a9e274f8) SHA1(02b46e1b149a856f0be74a23faaeb792935b66c7) )   /* fg tiles */
975
976   ROM_REGION( 0x10000, REGION_GFX2, ROMREGION_DISPOSE )
977   ROM_LOAD( "e-8.5n.ic191",    0x00000, 0x8000, CRC(055a5264) SHA1(fe294ba57c2c858952e2fab0be1b8859730846cb) )   /* sprites */
978   ROM_LOAD( "e-7.5r.ic193",    0x08000, 0x8000, CRC(59faebe7) SHA1(85dad90928369601e039467d575750539410fcf6) )
979
980   ROM_REGION( 0x10000, REGION_GFX3, ROMREGION_DISPOSE )
981   ROM_LOAD( "e-11.8k.ic238",   0x00000, 0x8000, CRC(669389fc) SHA1(a93e8455060ce5242cb65f78e47b4840aa13ab13) )   /* bg tiles */
982   ROM_LOAD( "e-9.8n.ic240",    0x08000, 0x8000, CRC(347ef108) SHA1(bb9c2f51d65f28655404e10c3be44d7ade98711b) )
983
984   ROM_REGION( 0x8000, REGION_SOUND1, 0 )   /* ADPCM samples */
985   ROM_LOAD( "e-5.4-3.ic35",    0x0000, 0x4000, CRC(444b5544) SHA1(0786d6d9ada7fe49c8ab9751b049095474d2e598) )
986ROM_END
987
988
921989ROM_START( gridiron )
922990   ROM_REGION( 0x10000, REGION_CPU1, 0 )
923991   ROM_LOAD( "gfight1.bin",  0x0000, 0x4000, CRC(51612741) SHA1(a0417a35f0ce51ba7fc81f27b356852a97f52a58) )
r1070r1071
9771045
9781046
9791047
980GAME( 1985, tehkanwc, 0, tehkanwc, tehkanwc, 0,        ROT0,  "Tehkan", "Tehkan World Cup", 0 )
981GAME( 1985, gridiron, 0, gridiron, gridiron, 0,        ROT0,  "Tehkan", "Gridiron Fight", 0 )
982GAME( 1986, teedoff,  0, teedoff,  teedoff,  teedoff,  ROT90, "Tecmo", "Tee'd Off (Japan)", 0 )
1048GAME( 1985, tehkanwc, 0,        tehkanwc, tehkanwc, 0,        ROT0,  "Tehkan", "Tehkan World Cup (set 1)", 0 )
1049GAME( 1985, tehkanwb, tehkanwc, tehkanwc, tehkanwc, 0,        ROT0,  "Tehkan", "Tehkan World Cup (set 2, bootleg?)", 0 )
1050GAME( 1985, gridiron, 0,        gridiron, gridiron, 0,        ROT0,  "Tehkan", "Gridiron Fight", 0 )
1051GAME( 1986, teedoff,  0,        teedoff,  teedoff,  teedoff,  ROT90, "Tecmo", "Tee'd Off (Japan)", 0 )
src/mame/drivers/sliver.c
r1070r1071
440440
441441VIDEO_START(sliver)
442442{
443   sliver_bitmap_bg = auto_bitmap_alloc(Machine->screen[0].width,Machine->screen[0].height,Machine->screen[0].format);
444   sliver_bitmap_fg = auto_bitmap_alloc(Machine->screen[0].width,Machine->screen[0].height,Machine->screen[0].format);
443   sliver_bitmap_bg = auto_bitmap_alloc(machine->screen[0].width,machine->screen[0].height,machine->screen[0].format);
444   sliver_bitmap_fg = auto_bitmap_alloc(machine->screen[0].width,machine->screen[0].height,machine->screen[0].format);
445445}
446446
447447VIDEO_UPDATE(sliver)
src/mame/drivers/cps3.c
r1070r1071
10461046   {
10471047      if (cps3_screenwidth!=496)
10481048      {
1049         screen_state *state = &Machine->screen[0];
1049         screen_state *state = &machine->screen[0];
10501050         rectangle visarea = state->visarea;
10511051         cps3_screenwidth = 496;
10521052         visarea.min_x = 0; visarea.max_x = 496-1;
r1070r1071
10581058   {
10591059      if (cps3_screenwidth!=384)
10601060      {
1061         screen_state *state = &Machine->screen[0];
1061         screen_state *state = &machine->screen[0];
10621062         rectangle visarea = state->visarea;
10631063         cps3_screenwidth = 384;
10641064         visarea.min_x = 0; visarea.max_x = 384-1;
r1070r1071
12671267
12681268                           if (cps3_char_ram_dirty[realtileno])
12691269                           {
1270                              decodechar(Machine->gfx[1], realtileno, (UINT8*)cps3_char_ram, &cps3_tiles16x16_layout);
1270                              decodechar(machine->gfx[1], realtileno, (UINT8*)cps3_char_ram, &cps3_tiles16x16_layout);
12711271                              cps3_char_ram_dirty[realtileno] = 0;
12721272                           }
12731273
12741274                           if (global_alpha || alpha)
12751275                           {
1276                              cps3_drawgfxzoom(renderbuffer_bitmap, Machine->gfx[1],realtileno,actualpal,0^flipx,0^flipy,current_xpos,current_ypos,&renderbuffer_clip,CPS3_TRANSPARENCY_PEN_INDEX_BLEND,0,xinc,yinc, NULL, 0);
1276                              cps3_drawgfxzoom(renderbuffer_bitmap, machine->gfx[1],realtileno,actualpal,0^flipx,0^flipy,current_xpos,current_ypos,&renderbuffer_clip,CPS3_TRANSPARENCY_PEN_INDEX_BLEND,0,xinc,yinc, NULL, 0);
12771277                           }
12781278                           else
12791279                           {
1280                              cps3_drawgfxzoom(renderbuffer_bitmap, Machine->gfx[1],realtileno,actualpal,0^flipx,0^flipy,current_xpos,current_ypos,&renderbuffer_clip,CPS3_TRANSPARENCY_PEN_INDEX,0,xinc,yinc, NULL, 0);
1280                              cps3_drawgfxzoom(renderbuffer_bitmap, machine->gfx[1],realtileno,actualpal,0^flipx,0^flipy,current_xpos,current_ypos,&renderbuffer_clip,CPS3_TRANSPARENCY_PEN_INDEX,0,xinc,yinc, NULL, 0);
12811281                           }
12821282                           count++;
12831283                        }
r1070r1071
13221322//  for (offset=0;offset<0x200;offset++)
13231323//  {
13241324//      int palreadbase = (cps3_ss_pal_base << 9);
1325//      palette_set_color(Machine,offset,cps3_mame_colours[palreadbase+offset]);
1325//      palette_set_color(machine,offset,cps3_mame_colours[palreadbase+offset]);
13261326//  }
13271327
13281328   // fg layer
r1070r1071
13461346
13471347            if (cps3_ss_ram_dirty[tile])
13481348            {
1349               decodechar(Machine->gfx[0], tile, (UINT8*)cps3_ss_ram, &cps3_tiles8x8_layout);
1349               decodechar(machine->gfx[0], tile, (UINT8*)cps3_ss_ram, &cps3_tiles8x8_layout);
13501350               cps3_ss_ram_dirty[tile] = 0;
13511351            }
13521352
1353            cps3_drawgfxzoom(bitmap, Machine->gfx[0],tile,pal,flipx,flipy,x*8,y*8,cliprect,CPS3_TRANSPARENCY_PEN,0,0x10000,0x10000,NULL,0);
1353            cps3_drawgfxzoom(bitmap, machine->gfx[0],tile,pal,flipx,flipy,x*8,y*8,cliprect,CPS3_TRANSPARENCY_PEN,0,0x10000,0x10000,NULL,0);
13541354            count++;
13551355         }
13561356      }
src/mame/drivers/seattle.c
r1070r1071
483483 *
484484 *************************************/
485485
486static void seattle_exit(running_machine *machine)
487{
488   voodoo_exit(0);
489}
490
491
486492static VIDEO_START( seattle )
487493{
494   add_exit_callback(machine, seattle_exit);
495
488496   voodoo_start(0, 0, VOODOO_1, 2, 4, 0);
489497
490498   voodoo_set_vblank_callback(0, vblank_assert);
r1070r1071
494502
495503static VIDEO_START( flagstaff )
496504{
505   add_exit_callback(machine, seattle_exit);
506
497507   voodoo_start(0, 0, VOODOO_1, 2, 4, 4);
498508
499509   voodoo_set_vblank_callback(0, vblank_assert);
src/mame/drivers/starfire.c
r1070r1071
7272   /* update the previous chunk of scanlines */
7373   starfire_video_update(scanline, SCANLINE_UPDATE_CHUNK);
7474   scanline += SCANLINE_UPDATE_CHUNK;
75   if (scanline >= Machine->screen[0].height)
75   if (scanline >= machine->screen[0].height)
7676      scanline = 32;
7777   mame_timer_set(video_screen_get_time_until_pos(0, scanline + SCANLINE_UPDATE_CHUNK - 1, 0), scanline, update_callback);
7878}
src/mame/drivers/jongkyo.c
r0r1071
1/* Jongkyo */
2#include "driver.h"
3#include "sound/ay8910.h"
4#include "machine/segacrpt.h"
5
6#define JONGKYO_CLOCK 18432000
7
8/*
9
10Jongkyo
11(c)1985 Kiwako
12
13834-5558 JONGKYO
14C2-00173
15
16CPU: SEGA Custom 315-5084 (Z80)
17Sound: AY-3-8910
18OSC: 18.432MHz
19
20ROMs:
21EPR-6258 (2764)
22EPR-6259 (2764)
23EPR-6260 (2764)
24EPR-6261 (2764)
25EPR-6262 (2732)
26
27PR-6263.6J (82S123N)
28PR-6264.0H (82S123N)
29PR-6265.0M (82S129N)
30PR-6266.0B (82S129N)
31
32*/
33
34
35static int rom_bank;
36
37
38VIDEO_START(jongkyo)
39{
40
41}
42
43VIDEO_UPDATE(jongkyo)
44{
45   int y;
46
47   for (y = 0; y < 256; ++y)
48   {
49      int x;
50
51      for (x = 0; x < 256; x += 4)
52      {
53         int b;
54         UINT8 data;
55
56         // bottom layer
57         data = videoram[0x4000 + x/4 + y*64];
58         for (b = 0; b < 4; ++b)
59         {
60            *BITMAP_ADDR16(bitmap, 255-y, 255-(x+b)) = (data & 0x01) + ((data & 0x10) >> 3);
61
62            data >>= 1;
63         }
64
65         // top layer
66         data = videoram[x/4 + y*64];
67         for (b = 0; b < 4; ++b)
68         {
69            if (data & 0x11)
70               *BITMAP_ADDR16(bitmap, 255-y, 255-(x+b)) = 4 + (data & 0x01) + ((data & 0x10) >> 3);
71
72            data >>= 1;
73         }
74      }
75   }
76
77   return 0;
78}
79
80
81static WRITE8_HANDLER( bank_select_w )
82{
83   int mask = 1 << (offset >> 1);
84
85   rom_bank &= ~mask;
86
87   if (offset & 1)
88      rom_bank |= mask;
89
90   memory_set_bank(1, rom_bank);
91}
92
93
94static READ8_HANDLER( keyboard1_r )
95{
96   return 0xff;
97}
98
99
100static READ8_HANDLER( keyboard2_r )
101{
102   return 0xff;
103}
104
105
106static ADDRESS_MAP_START( jongkyo_memmap, ADDRESS_SPACE_PROGRAM, 8 )
107   AM_RANGE(0x0000, 0x6bff) AM_ROM   AM_WRITENOP // fixed
108   AM_RANGE(0x6c00, 0x6fff) AM_READ(MRA8_BANK1)   // banked (8 banks)
109   AM_RANGE(0x7000, 0x77ff) AM_RAM
110   AM_RANGE(0x8000, 0xffff) AM_RAM AM_BASE(&videoram)
111ADDRESS_MAP_END
112
113
114static ADDRESS_MAP_START( jongkyo_portmap, ADDRESS_SPACE_IO, 8 )
115   ADDRESS_MAP_FLAGS( AMEF_ABITS(8) )
116   // R 01 keyboard
117   AM_RANGE(0x01, 0x01) AM_READ(AY8910_read_port_0_r)
118   AM_RANGE(0x02, 0x02) AM_WRITE(AY8910_write_port_0_w)
119   AM_RANGE(0x03, 0x03) AM_WRITE(AY8910_control_port_0_w)
120
121   AM_RANGE(0x10, 0x10) AM_READ_PORT("DSW")
122   AM_RANGE(0x11, 0x11) AM_READ_PORT("IN0")
123   // W 11 select keyboard row (fe fd fb f7)
124   AM_RANGE(0x40, 0x45) AM_WRITE(bank_select_w)
125ADDRESS_MAP_END
126
127/*
128-------------------------------------------------------------
129Jongkyo ?1985 Kiwako
130DIPSW         |      |1    2    3    4   |5   |6   |7   |8
131-------------------------------------------------------------
132Payout rate   |50%   |on   on   on   on  |    |    |    |
133              |53%   |off  on   on   on  |    |    |    |
134              |56%   |on   off  on   on  |    |    |    |
135              |59%   |off  off  on   on  |    |    |    |
136              |62%   |on   on   off  on  |    |    |    |
137              |65%   |off  on   off  on  |    |    |    |
138              |68%   |on   off  off  on  |    |    |    |
139              |71%   |off  off  off  on  |    |    |    |
140              |75%   |on   on   on   off |    |    |    |
141              |78%   |off  on   on   off |    |    |    |
142              |81%   |on   off  on   off |    |    |    |
143              |84%   |off  off  on   off |    |    |    |
144              |87%   |on   on   off  off |    |    |    |
145              |90%   |off  on   off  off |    |    |    |
146              |93%   |on   off  off  off |    |    |    |
147              |96%   |off  off  off  off |    |    |    |
148-------------------------------------------------------------
149Start chance  |Yes   |                   |on  |    |    |
150              |No    |                   |off |    |    |
151-------------------------------------------------------------
152Bet up        |Yes   |                   |    |on  |    |
153              |No    |                   |    |off |    |
154-------------------------------------------------------------
155Last chance   |5     |                   |    |    |on  |
156              |1     |                   |    |    |off |
157-------------------------------------------------------------
158Bonus credit  |50    |                   |    |    |    |on
159              |10    |                   |    |    |    |off
160-------------------------------------------------------------
161*/
162
163
164INPUT_PORTS_START( jongkyo )
165   PORT_START_TAG("IN0")
166   PORT_DIPNAME( 0x01, 0x00, "Note" )
167   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
168   PORT_DIPSETTING(    0x01, DEF_STR( Yes ) )
169   PORT_DIPNAME( 0x02, 0x00, "Memory Reset" )
170   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
171   PORT_DIPSETTING(    0x02, DEF_STR( Yes ) )
172   PORT_DIPNAME( 0x04, 0x00, "Analizer" )
173   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
174   PORT_DIPSETTING(    0x04, DEF_STR( Yes ) )
175   PORT_SERVICE( 0x08, IP_ACTIVE_HIGH )
176   PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNKNOWN )
177
178   PORT_START_TAG("DSW")
179   PORT_DIPNAME( 0x0f, 0x0f, "Payout Rate" ) PORT_DIPLOCATION("SW:1,2,3,4")
180   PORT_DIPSETTING(    0x00, "50%" )
181   PORT_DIPSETTING(    0x01, "53%" )
182   PORT_DIPSETTING(    0x02, "56%" )
183   PORT_DIPSETTING(    0x03, "59%" )
184   PORT_DIPSETTING(    0x04, "62%" )
185   PORT_DIPSETTING(    0x05, "65%" )
186   PORT_DIPSETTING(    0x06, "68%" )
187   PORT_DIPSETTING(    0x07, "71%" )
188   PORT_DIPSETTING(    0x08, "75%" )
189   PORT_DIPSETTING(    0x09, "78%" )
190   PORT_DIPSETTING(    0x0a, "81%" )
191   PORT_DIPSETTING(    0x0b, "84$" )
192   PORT_DIPSETTING(    0x0c, "87%" )
193   PORT_DIPSETTING(    0x0d, "90%" )
194   PORT_DIPSETTING(    0x0e, "93%" )
195   PORT_DIPSETTING(    0x0f, "96%" )
196   PORT_DIPNAME( 0x10, 0x10, "Start Chance" ) PORT_DIPLOCATION("SW:5")
197   PORT_DIPSETTING(    0x10, DEF_STR( No ) )
198   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
199   PORT_DIPNAME( 0x20, 0x20, "Bet Up" ) PORT_DIPLOCATION("SW:6")
200   PORT_DIPSETTING(    0x20, DEF_STR( No ) )
201   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
202   PORT_DIPNAME( 0x40, 0x40, "Last Chance" ) PORT_DIPLOCATION("SW:7")
203   PORT_DIPSETTING(    0x40, "1" )
204   PORT_DIPSETTING(    0x00, "5" )
205   PORT_DIPNAME( 0x80, 0x80, "Bonus Credit" ) PORT_DIPLOCATION("SW:8")
206   PORT_DIPSETTING(    0x80, "10" )
207   PORT_DIPSETTING(    0x00, "50" )
208INPUT_PORTS_END
209
210
211static struct AY8910interface ay8910_interface =
212{
213   keyboard1_r,
214   keyboard2_r,
215};
216
217static MACHINE_DRIVER_START( jongkyo )
218   /* basic machine hardware */
219   MDRV_CPU_ADD(Z80,JONGKYO_CLOCK/4)
220   MDRV_CPU_PROGRAM_MAP(jongkyo_memmap,0)
221   MDRV_CPU_IO_MAP(jongkyo_portmap,0)
222   MDRV_CPU_VBLANK_INT(irq0_line_hold,1)
223
224   MDRV_SCREEN_REFRESH_RATE(60)
225   MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION)
226
227   /* video hardware */
228   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER )
229   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
230   MDRV_SCREEN_SIZE(256, 256)
231   MDRV_SCREEN_VISIBLE_AREA(0, 256-1, 8, 256-8-1)
232   MDRV_PALETTE_LENGTH(0x100)
233
234   MDRV_VIDEO_START(jongkyo)
235   MDRV_VIDEO_UPDATE(jongkyo)
236
237   MDRV_SPEAKER_STANDARD_MONO("mono")
238   MDRV_SOUND_ADD(AY8910, JONGKYO_CLOCK/8)
239   MDRV_SOUND_CONFIG(ay8910_interface)
240   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
241MACHINE_DRIVER_END
242
243
244ROM_START( jongkyo )
245   ROM_REGION( 0x9000, REGION_CPU1, 0 )
246   ROM_LOAD( "epr-6258", 0x00000, 0x02000, CRC(fb8b7bcc) SHA1(8ece7c2c82c237b4b51829d412b2109b96ccd0e7) )
247   ROM_LOAD( "epr-6259", 0x02000, 0x02000, CRC(e46cde5d) SHA1(1cbe1677cfb3fa9f76ad90d5b1446ce9cefee6b7) )
248   ROM_LOAD( "epr-6260", 0x04000, 0x02000, CRC(369a5365) SHA1(037a2971a59ab339595b333cbdfd4cbb104de2be) )
249   ROM_LOAD( "epr-6262", 0x06000, 0x01000, CRC(ecf50f34) SHA1(ecfa1a9360d8fbcbed457d46e53bae77f6d78c1d) )
250   ROM_LOAD( "epr-6261", 0x07000, 0x02000, CRC(9c475ae1) SHA1(b993c2636dafed9f80fa87e71921c3c85c039e45) )   // banked at 6c00-6fff
251
252   ROM_REGION( 0x40000, REGION_PROMS, 0 )
253   ROM_LOAD( "pr-6263.6j", 0x00000, 0x00020, CRC(468134d9) SHA1(bb633929df17e448882ee80613fc1dfac3c35d7a) )
254   ROM_LOAD( "pr-6264.0h", 0x00000, 0x00020, CRC(46014727) SHA1(eec451f292ee319fa6bfbbf223aaa12b231692c1) )
255   ROM_LOAD( "pr-6265.0m", 0x00000, 0x00100, CRC(f09d3c4c) SHA1(a9e752d75e7f3ebd05add4ccf2f9f15d8f9a8d15) )
256   ROM_LOAD( "pr-6266.0b", 0x00000, 0x00100, CRC(86aeafd1) SHA1(c4e5c56ce5baf2be3962675ae333e28bd8108a00) )
257ROM_END
258
259
260DRIVER_INIT( jongkyo )
261{
262   int i;
263   UINT8 *rom = memory_region(REGION_CPU1);
264
265   /* first of all, do a simple bitswap */
266   for (i = 0x6000; i < 0x9000; ++i)
267   {
268      rom[i] = BITSWAP8(rom[i], 7,6,5,3,4,2,1,0);
269   }
270
271   /* then do the standard Sega decryption */
272   jongkyo_decode();
273}
274
275
276GAME( 1985, jongkyo,  0,    jongkyo, jongkyo,  jongkyo, ROT0, "Kiwako", "Jongkyo", GAME_NOT_WORKING )
src/mame/drivers/firebeat.c
r1070r1071
18011801
18021802static NVRAM_HANDLER(firebeat)
18031803{
1804   nvram_handler_intelflash(Machine, 0, file, read_or_write);
1805   nvram_handler_intelflash(Machine, 1, file, read_or_write);
1806   nvram_handler_intelflash(Machine, 2, file, read_or_write);
1804   nvram_handler_intelflash(machine, 0, file, read_or_write);
1805   nvram_handler_intelflash(machine, 1, file, read_or_write);
1806   nvram_handler_intelflash(machine, 2, file, read_or_write);
18071807
18081808   if (read_or_write)
18091809   {
src/mame/drivers/spdodgeb.c
r1070r1071
66
77TODO:
88- sprite lag (the real game has quite a bit of lag too)
9- rowscroll (not used expect for status display)
10- double-tap tolerance
9- double-tap tolerance (find a way to dump + emulate MCU?)
1110
1211Notes:
1312- there's probably a 63701 on the board, used for protection. It is checked
r1070r1071
1514  the ports verbatim, it adds further processing, setting flags when the
1615  player double-taps in one direction to run.(updated to edge-triggering)
1716
17- video timing is probably similar to Double Dragon and other Technos games
18  of that era.  The rowscroll of the title bar is done with raster IRQs, I've
19  removed the 'scroll value buffer' hack that the driver was using before and
20  used partial updates instead. (DH, 29 Sept 07)
21
1822***************************************************************************/
1923
2024#include "driver.h"
r1070r1071
500504   ROM_LOAD( "mb7122e.159",  0x0400, 0x0400, CRC(69706e8d) SHA1(778ee88ff566aa38c80e0e61bb3fe8458f0e9450) )
501505ROM_END
502506
507/*
508
509Nekketsu Koukou Dodgeball Bu
510(c)1987 Technos Japan
511
512TA-0022-P1-04
513M6100293A (PCB manufactured by Taito)
514
515CPU: 6502 (Labeled TJC-706002)
516Sound: 68A09, YM3812, M5205x2
517OSC: 12.000MHz
518
519ROMs:
52022J4-0.139 - Main program
52122J5-0.33  - Sound program
52222JA-0.162 - HD63701Y0P (no dump)
523
524TJ22J4-0.121 - Text
525TJ22J3-0.107 /
526
527TJ22J1-0.2  - Graphics
528TJ22J2-0.35 /
529
53022J6-0.83 - ADPCM Samples
53122J7-0.82 /
532
53322J8-0.158 (7132)
53422J9-0.159 (7122)
535
536*/
537
538ROM_START( nkdodge )
539   ROM_REGION( 0x18000, REGION_CPU1, 0 )
540   ROM_LOAD( "22j4-0.139",     0x10000, 0x08000, CRC(aa674fd8) SHA1(4e8d3e07b54d23b221cb39cf10389bc7a56c4021) )  /* Two banks */
541   ROM_CONTINUE(             0x08000, 0x08000 )       /* Static code */
542
543   ROM_REGION( 0x10000, REGION_CPU2, 0 ) /* audio cpu */
544   ROM_LOAD( "22j5-0.33",    0x08000, 0x08000, CRC(c31e264e) SHA1(0828a2094122e3934b784ec9ad7c2b89d91a83bb) )
545
546   ROM_REGION( 0x10000, REGION_CPU3, 0 ) /* I/O mcu */
547   ROM_LOAD( "63701.bin",    0xc000, 0x4000, NO_DUMP )   /* missing */
548
549   ROM_REGION( 0x40000, REGION_GFX1, ROMREGION_DISPOSE ) /* text */
550   ROM_LOAD( "tj22j4-0.121",    0x00000, 0x20000, CRC(d2922b3f) SHA1(30ad37f8355c732b545017c2fc56879256b650be) )
551   ROM_LOAD( "tj22j3-0.107",    0x20000, 0x20000, CRC(79cd1315) SHA1(2d7a877e59f704b10b5f609e60fa565c68f5fdb0) )
552
553   ROM_REGION( 0x40000, REGION_GFX2, ROMREGION_DISPOSE )
554   ROM_LOAD( "tj22j1-0.2",      0x00000, 0x20000, CRC(9ed27a8d) SHA1(d80d275bbe91f3e1bd0495a2d7a3be0280a7cda1) )
555   ROM_LOAD( "tj22j2-0.35",     0x20000, 0x20000, CRC(768934f9) SHA1(922f3154dcfb29c2e5c1bebc53247136160f1229) )
556
557   ROM_REGION( 0x20000, REGION_SOUND1, 0 ) /* adpcm samples */
558   ROM_LOAD( "22j6-0.83",    0x00000, 0x10000, CRC(744a26e3) SHA1(519f22f1e5cc417cb8f9ced97e959d23c711283b) )
559   ROM_LOAD( "22j7-0.82",    0x10000, 0x10000, CRC(2fa1de21) SHA1(e8c7af6057b64ecadd3473b82abd8e9f873082fd) )
560
561   ROM_REGION( 0x0800, REGION_PROMS, 0 )   /* color PROMs */
562   ROM_LOAD( "22j8-0.158",  0x0000, 0x0400, CRC(c368440f) SHA1(39762d102a42211f24db16bc721b01230df1c4d6) )
563   ROM_LOAD( "22j9-0.159",  0x0400, 0x0400, CRC(6059f401) SHA1(280b1bda3a55f2d8c2fd4552c4dcec7100f0170f) )
564ROM_END
565
566/* the bootleg just seems to have the gfx roms in a different format, program is identical */
567
503568ROM_START( nkdodgeb )
504569   ROM_REGION( 0x18000, REGION_CPU1, 0 )
505570   ROM_LOAD( "12.bin",         0x10000, 0x08000, CRC(aa674fd8) SHA1(4e8d3e07b54d23b221cb39cf10389bc7a56c4021) )  /* Two banks */
r1070r1071
535600
536601
537602GAME( 1987, spdodgeb, 0,        spdodgeb, spdodgeb, 0, ROT0, "Technos", "Super Dodge Ball (US)", 0 )
538GAME( 1987, nkdodgeb, spdodgeb, spdodgeb, spdodgeb, 0, ROT0, "Technos", "Nekketsu Koukou Dodgeball Bu (Japan bootleg)", 0 )
603GAME( 1987, nkdodge,  spdodgeb, spdodgeb, spdodgeb, 0, ROT0, "Technos", "Nekketsu Koukou Dodgeball Bu (Japan)", 0 )
604GAME( 1987, nkdodgeb, spdodgeb, spdodgeb, spdodgeb, 0, ROT0, "Technos", "Nekketsu Koukou Dodgeball Bu (Japan, bootleg)", 0 )
src/mame/drivers/cvs.c
r1070r1071
647647   ROM_LOAD( "82s123.10k", 0x0800, 0x0020, CRC(b5221cec) SHA1(71d9830b33b1a8140b0fe1a2ba8024ba8e6e48e0) )
648648ROM_END
649649
650ROM_START( hunchbka )
651
652   ROM_REGION( 0x8000, REGION_CPU1, 0 )
653   ROM_LOAD( "1b.bin", 0x0000, 0x0400, CRC(c816860b) SHA1(1109639645496d4644564d21c816b8baf8c84cf7) )
654   ROM_CONTINUE( 0x2000, 0x0400 )
655   ROM_CONTINUE( 0x4000, 0x0400 )
656   ROM_CONTINUE( 0x6000, 0x0400 )
657   ROM_LOAD( "2a.bin", 0x0400, 0x0400, CRC(cab1e524) SHA1(c3fd7ac9ce5893fd2602a15ad0f6e3267a4ca122) )
658   ROM_CONTINUE( 0x2400, 0x0400 )
659   ROM_CONTINUE( 0x4400, 0x0400 )
660   ROM_CONTINUE( 0x6400, 0x0400 )
661   ROM_LOAD( "3a.bin", 0x0800, 0x0400, CRC(b2adcfeb) SHA1(3090e2c6b945857c1e48dea395015a05c6165cd9) )
662   ROM_CONTINUE( 0x2800, 0x0400 )
663   ROM_CONTINUE( 0x4800, 0x0400 )
664   ROM_CONTINUE( 0x6800, 0x0400 )
665   ROM_LOAD( "4c.bin", 0x0c00, 0x0400, CRC(229a8b71) SHA1(ea3815eb69d4927da356eada0add8382735feb48) )
666   ROM_CONTINUE( 0x2c00, 0x0400 )
667   ROM_CONTINUE( 0x4c00, 0x0400 )
668   ROM_CONTINUE( 0x6c00, 0x0400 )
669   ROM_LOAD( "5a.bin", 0x1000, 0x0400, CRC(cb4f0313) SHA1(1ef63cbe62e7a54d45e0afbc398c9d9b601e6403) )
670   ROM_CONTINUE( 0x3000, 0x0400 )
671   ROM_CONTINUE( 0x5000, 0x0400 )
672   ROM_CONTINUE( 0x7000, 0x0400 )
673
674   ROM_REGION( 0x2000, REGION_CPU2, 0 )
675   ROM_LOAD( "hb-sdp1.bin", 0x0000, 0x1000, CRC(f9ba2854) SHA1(d041198e2e8b8c3e668bd1610310f8d25c5b1119) )
676
677   ROM_REGION( 0x0800, REGION_CPU3, 0 )
678   ROM_LOAD( "5b.bin", 0x0000, 0x0800, CRC(f055a624) SHA1(5dfe89d7271092e665cdd5cd59d15a2b70f92f43) )
679
680   ROM_REGION( 0x1000, REGION_SOUND1, 0 )
681   ROM_LOAD( "hb-sp1.bin", 0x0000, 0x0800, CRC(ed1cd201) SHA1(6cc3842dda1bfddc06ffb436c55d14276286bd67) )
682
683   ROM_REGION( 0x1800, REGION_GFX1, ROMREGION_DISPOSE )
684   ROM_LOAD( "hb-cp1.bin", 0x0000, 0x0800, CRC(f256b047) SHA1(02d79882bad37ffdd58ef478e2658a1369c32ebc) )
685   ROM_LOAD( "hb-cp2.bin", 0x0800, 0x0800, CRC(b870c64f) SHA1(ce4f8de87568782ce02bba754edff85df7f5c393) )
686   ROM_LOAD( "hb-cp3.bin", 0x1000, 0x0800, CRC(9a7dab88) SHA1(cd39a9d4f982a7f49c478db1408d7e07335f2ddc) )
687
688   ROM_REGION( 0x0820, REGION_PROMS, 0 )
689   ROM_LOAD( "82s185.10h", 0x0000, 0x0800, CRC(c205bca6) SHA1(ec9bd220e75f7b067ede6139763ef8aca0fb7a29) )
690   ROM_LOAD( "82s123.10k", 0x0800, 0x0020, CRC(b5221cec) SHA1(71d9830b33b1a8140b0fe1a2ba8024ba8e6e48e0) )
691ROM_END
692
650693ROM_START( wallst )
651694
652695   ROM_REGION( 0x8000, REGION_CPU1, 0 )
r1070r1071
13351378    memory_region(REGION_CPU1)[0x4458] = 0xc0;
13361379}
13371380
1381static DRIVER_INIT( hunchbka )
1382{
1383    /* Program roms are bitswapped */
1384   UINT8 *ROM = memory_region(REGION_CPU1);
1385   int i;
1386
1387   for (i=0;i<0x8000;i++)
1388   {
1389      ROM[i] = BITSWAP8(ROM[i],7,6,2,4  ,3,5,1,0);
1390   }
1391
1392}
1393
13381394static DRIVER_INIT( superbik )
13391395{
13401396    /* Patch out protection */
r1070r1071
14191475GAME( 1982, goldbug,     cvs,      cvs,      cvs,    goldbug,    ROT90, "Century Electronics", "Gold Bug", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL )
14201476GAME( 1982, diggerc,     cvs,      cvs,      cvs,    0,          ROT90, "Century Electronics", "Digger (CVS)", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL )
14211477GAME( 1983, heartatk,    cvs,      cvs,      cvs,    0,          ROT90, "Century Electronics", "Heart Attack", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL )
1422GAME( 1983, hunchbak,    cvs,      cvs,      cvs,    0,          ROT90, "Century Electronics", "Hunchback", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL )
1478GAME( 1983, hunchbak,    cvs,      cvs,      cvs,    0,          ROT90, "Century Electronics", "Hunchback (set 1)", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL )
1479GAME( 1983, hunchbka,    hunchbak, cvs,      cvs,    hunchbka,   ROT90, "Century Electronics", "Hunchback (set 2)", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL )
14231480GAME( 1983, superbik,    cvs,      cvs,      cvs,    superbik,   ROT90, "Century Electronics", "Superbike", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL )
14241481GAME( 1983, raiders,     cvs,      cvs,      cvs,    raiders,    ROT90, "Century Electronics", "Raiders", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL )
14251482GAME( 1983, hero,        cvs,      cvs,      cvs,    hero,       ROT90, "Seatongrove Ltd",     "Hero", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL )
src/mame/drivers/megatech.c
r1070r1071
607607   if (screen ==0)
608608   {
609609      /* if we're running an sms game then use the SMS update.. maybe this should be moved to the megadrive emulation core as compatibility mode is a feature of the chip */
610      if (!current_game_is_sms) video_update_megadriv(Machine,0,bitmap,cliprect);
611      else video_update_megatech_md_sms(Machine,0,bitmap,cliprect);
610      if (!current_game_is_sms) video_update_megadriv(machine,0,bitmap,cliprect);
611      else video_update_megatech_md_sms(machine,0,bitmap,cliprect);
612612   }
613   else if (screen ==1) video_update_megatech_bios(Machine, 1, bitmap,cliprect);
613   else if (screen ==1) video_update_megatech_bios(machine, 1, bitmap,cliprect);
614614   return 0;
615615}
616616
src/mame/drivers/bnstars.c
r0r1071
1/*
2Vs. Janshi Brandnew Stars
3(c)1997 Jaleco
4
5Single board version with Dual Screen output
6(MS32 version also exists)
7
8Main PCB
9--------
10
11PCB ID  : MB-93141 EB91022-20081
12CPU     : NEC D70632GD-20 (V70)
13OSC     : 48.000MHz, 40.000MHz
14RAM     : Cypress CY7C199-25 (x20)
15          OKI M511664-80 (x8)
16DIPs    : 8 position (x3)
17OTHER   : Some PALs
18
19          Custom chips:
20                       JALECO SS91022-01 (208 PIN PQFP)
21                       JALECO SS91022-02 (100 PIN PQFP) (x2)
22                       JALECO SS91022-03 (176 PIN PQFP) (x2)
23                       JALECO SS91022-05 (120 PIN PQFP) (x2)
24                       JALECO SS91022-07 (208 PIN PQFP) (x2)
25                       JALECO GS91022-01 (120 PIN PQFP)
26                       JALECO GS91022-02 (160 PIN PQFP)
27                       JALECO GS91022-03 (100 PIN PQFP)
28                       JALECO GS91022-04 (100 PIN PQFP)
29                       JALECO GS90015-03 ( 80 PIN PQFP) (x3) (not present on MS32)
30
31
32ROMs:     None
33
34
35ROM PCB (equivalent to MS32 cartridge)
36--------------------------------------
37PCB ID  : MB-93142 EB93007-20082
38DIPs    : determine the size of ROMs?
39          8 position (x1, 6 and 8 is on, others are off)
40          4 position (x2, both are off on off off)
41OTHER   : Some PALs
42          Custom chip: JALECO SS92046-01 (144 pin PQFP) (x2)
43          (located on small plug-in board with) (ID: SE93139 EB91022-30056)
44ROMs    : MB-93142.36   [2eb6a503] (IC42, also printed "?u?????j???[Ver1.2")
45          MB-93142.37   [49f60882] (IC57, also printed "?u?????j???[Ver1.2")
46          MB-93142.38   [6e1312cd] (IC58, also printed "?u?????j???[Ver1.2")
47          MB-93142.39   [56b98539] (IC59, also printed "?u?????j???[Ver1.2")
48
49          VSJANSHI5.6   [fdbbac21] (IC9, actual label is "VS?W?????V 5 Ver1.0")
50          VSJANSHI6.5   [fdbbac21] (IC8, actual label is "VS?W?????V 6 Ver1.0")
51
52?@?@?@?@?@MR96004-01.20 [3366d104] (IC29)
53?@?@?@?@?@MR96004-02.28 [ad556664] (IC49)
54?@?@?@?@?@MR96004-03.21 [b399e2b1] (IC30)
55?@?@?@?@?@MR96004-04.29 [f4f4cf4a] (IC50)
56?@?@?@?@?@MR96004-05.22 [cd6c357e] (IC31)
57?@?@?@?@?@MR96004-06.30 [fc6daad7] (IC51)
58?@?@?@?@?@MR96004-07.23 [177e32fa] (IC32)
59?@?@?@?@?@MR96004-08.31 [f6df27b2] (IC52)
60
61?@?@?@?@?@MR96004-09.1  [603143e8] (IC4)
62?@?@?@?@?@MR96004-09.7  [603143e8] (IC10)
63
64?@?@?@?@?@MR96004-11.11 [e6da552c] (IC17)
65?@?@?@?@?@MR96004-11.13 [e6da552c] (IC19)
66
67
68Sound PCB
69---------
70PCB ID  : SB-93143 EB91022-20083
71SOUND   : Z80, YMF271-F, YAC513(x2)
72OSC     : 8.000MHz, 16.9344MHz
73DIPs    : 4 position (all off)
74ROMs    : SB93145.5     [0424e899] (IC34, also printed "Ver1.0") - Sound program
75          MR96004-10.1  [125661cd] (IC19 - Samples)
76
77Sound sub PCB
78-------------
79PCB ID  : SB-93145 EB93007-20086
80SOUND   : YMF271-F
81ROMs    : MR96004-10.1  [125661cd] (IC5 - Samples)
82
83*/
84
85#include "driver.h"
86#include "sound/ymf271.h"
87#include "rendlay.h"
88
89/* drivers/ms32/c */
90extern void ms32_rearrange_sprites(int region);
91extern void decrypt_ms32_tx(int addr_xor,int data_xor, int region);
92extern void decrypt_ms32_bg(int addr_xor,int data_xor, int region);
93
94VIDEO_START(bnstars)
95{
96
97}
98
99VIDEO_UPDATE(bnstars)
100{
101   return 0;
102}
103
104INPUT_PORTS_START( bnstars )
105INPUT_PORTS_END
106
107
108
109/* sprites are contained in 256x256 "tiles" */
110static const gfx_layout spritelayout =
111{
112   256,256,
113   RGN_FRAC(1,1),
114   8,
115   { GFX_RAW },
116   { 0 },      /* org displacement */
117   { 256*8 },   /* line modulo */
118   256*256*8   /* char modulo */
119};
120
121static const gfx_layout bglayout =
122{
123   16,16,
124   RGN_FRAC(1,1),
125   8,
126   { GFX_RAW },
127   { 0 },      /* org displacement */
128   { 16*8 },   /* line modulo */
129   16*16*8      /* char modulo */
130};
131
132
133static const gfx_layout txlayout =
134{
135   8,8,
136   RGN_FRAC(1,1),
137   8,
138   { GFX_RAW },
139   { 0 },      /* org displacement */
140   { 8*8 },   /* line modulo */
141   8*8*8      /* char modulo */
142};
143
144static GFXDECODE_START( bnstars )
145   GFXDECODE_ENTRY( REGION_GFX1, 0, spritelayout, 0x0000, 0x10 )
146
147   GFXDECODE_ENTRY( REGION_GFX2, 0, bglayout,     0x0000, 0x10 ) /* Roz scr1 */
148   GFXDECODE_ENTRY( REGION_GFX3, 0, bglayout,     0x0000, 0x10 ) /* Roz scr2 */
149
150   GFXDECODE_ENTRY( REGION_GFX4, 0, bglayout,     0x0000, 0x10 ) /* Bg scr1 */
151   GFXDECODE_ENTRY( REGION_GFX5, 0, txlayout,     0x0000, 0x10 ) /* Tx scr1 */
152
153   GFXDECODE_ENTRY( REGION_GFX6, 0, bglayout,     0x0000, 0x10 ) /* Bg scr2 */
154   GFXDECODE_ENTRY( REGION_GFX7, 0, txlayout,     0x0000, 0x10 ) /* Tx scr2 */
155
156GFXDECODE_END
157
158
159
160static ADDRESS_MAP_START( bnstars_map, ADDRESS_SPACE_PROGRAM, 32 )
161   AM_RANGE(0x00000000, 0x001fffff) AM_ROM
162   AM_RANGE(0xffe00000, 0xffffffff) AM_READWRITE(MRA32_BANK1, MWA32_ROM)
163ADDRESS_MAP_END
164
165static ADDRESS_MAP_START( bnstars_z80_map, ADDRESS_SPACE_PROGRAM, 8 )
166   AM_RANGE(0x0000, 0x7fff) AM_ROM
167ADDRESS_MAP_END
168
169static struct YMF271interface ymf271_interface1 =
170{
171   REGION_SOUND1
172};
173
174static struct YMF271interface ymf271_interface2 =
175{
176   REGION_SOUND2
177};
178
179static MACHINE_DRIVER_START( bnstars )
180
181   /* basic machine hardware */
182   MDRV_CPU_ADD(V70, 20000000) // 20MHz
183   MDRV_CPU_PROGRAM_MAP(bnstars_map,0)
184//  MDRV_CPU_VBLANK_INT(ms32_interrupt,32)
185
186   MDRV_CPU_ADD(Z80, 4000000) /* audio CPU */
187   MDRV_CPU_PROGRAM_MAP(bnstars_z80_map, 0)
188
189   MDRV_INTERLEAVE(1000)
190
191//  MDRV_MACHINE_RESET(ms32)
192
193   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
194   MDRV_GFXDECODE(bnstars)
195   MDRV_PALETTE_LENGTH(0x8000)
196
197   MDRV_DEFAULT_LAYOUT(layout_dualhsxs)
198
199   MDRV_SCREEN_ADD("left", 0x000)
200   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
201   MDRV_SCREEN_REFRESH_RATE(60)
202   MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION)
203   MDRV_SCREEN_SIZE(40*8, 28*8)
204   MDRV_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 0*8, 28*8-1)
205
206   MDRV_SCREEN_ADD("right", 0x000)
207   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
208   MDRV_SCREEN_REFRESH_RATE(60)
209   MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION)
210   MDRV_SCREEN_SIZE(40*8, 28*8)
211   MDRV_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 0*8, 28*8-1)
212
213   MDRV_VIDEO_START(bnstars)
214   MDRV_VIDEO_UPDATE(bnstars)
215
216   /* sound hardware */
217   MDRV_SPEAKER_STANDARD_STEREO("left", "right")
218
219   MDRV_SOUND_ADD(YMF271, 16934400)
220   MDRV_SOUND_CONFIG(ymf271_interface1)
221   MDRV_SOUND_ROUTE(0, "left", 1.0)
222   MDRV_SOUND_ROUTE(1, "right", 1.0)
223
224   MDRV_SOUND_ADD(YMF271, 16934400)
225   MDRV_SOUND_CONFIG(ymf271_interface2)
226   MDRV_SOUND_ROUTE(0, "left", 1.0)
227   MDRV_SOUND_ROUTE(1, "right", 1.0)
228
229MACHINE_DRIVER_END
230
231
232ROM_START( bnstars1 )
233   ROM_REGION( 0x200000, REGION_CPU1, 0 ) /* V70 code */
234   ROM_LOAD32_BYTE( "mb-93142.36", 0x000003, 0x80000, CRC(2eb6a503) SHA1(27c02ab1b4321924fd4499844467ea4dc97de25d) )
235   ROM_LOAD32_BYTE( "mb-93142.37", 0x000002, 0x80000, CRC(49f60882) SHA1(2ff5b0989aaf970103304a453773e0b9517ebb8d) )
236   ROM_LOAD32_BYTE( "mb-93142.38", 0x000001, 0x80000, CRC(6e1312cd) SHA1(4c22f8f9f1574eefd96147453cf240f50c17f5dc) )
237   ROM_LOAD32_BYTE( "mb-93142.39", 0x000000, 0x80000, CRC(56b98539) SHA1(5eb0e77729b31e6a100c1b43813a39fea57bedee) )
238
239   /* Sprites - shared by both screens? */
240   ROM_REGION( 0x1000000, REGION_GFX1, 0 ) /* sprites, don't dispose since we use GFX_RAW */
241   ROM_LOAD32_WORD( "mr96004-01.20",   0x0000000, 0x200000, CRC(3366d104) SHA1(2de0cabe2ead777b5b02cade7f2003ef7f90b75b) )
242   ROM_LOAD32_WORD( "mr96004-02.28",   0x0000002, 0x200000, CRC(ad556664) SHA1(4b36f8d8d9efa37cf515af41d14433e7eafa27a2) )
243   ROM_LOAD32_WORD( "mr96004-03.21",   0x0400000, 0x200000, CRC(b399e2b1) SHA1(9b6a00a219db8d66dcf592160b7b5f7a86b8f0c9) )
244   ROM_LOAD32_WORD( "mr96004-04.29",   0x0400002, 0x200000, CRC(f4f4cf4a) SHA1(fe497989cf96c68602f68f14920aed44fd934573) )
245   ROM_LOAD32_WORD( "mr96004-05.22",   0x0800000, 0x200000, CRC(cd6c357e) SHA1(44cd2d0607c7ccd80f701cf1675fd283acb07252) )
246   ROM_LOAD32_WORD( "mr96004-06.30",   0x0800002, 0x200000, CRC(fc6daad7) SHA1(99f14ac6b06ad9a8a3d2e9f69b693c7ce420a47d) )
247   ROM_LOAD32_WORD( "mr96004-07.23",   0x0c00000, 0x200000, CRC(177e32fa) SHA1(3ca1f397dc28f1fa3a4136705b92c63e4e438f05) )
248   ROM_LOAD32_WORD( "mr96004-08.31",   0x0c00002, 0x200000, CRC(f6df27b2) SHA1(60590976020d86bdccd4eaf57b349ea31bec6830) )
249
250   /* Roz Tiles #1 (Screen 1) */
251   ROM_REGION( 0x200000, REGION_GFX2, 0 ) /* roz tiles, don't dispose since we use GFX_RAW */
252   ROM_LOAD( "mr96004-09.1", 0x000000, 0x200000, BAD_DUMP CRC(603143e8) SHA1(197ff72d4a6bf9cc5e89505c1a25edad104a9a65) )
253
254   /* Roz Tiles #2 (Screen 2) */
255   ROM_REGION( 0x200000, REGION_GFX3, 0 ) /* roz tiles, don't dispose since we use GFX_RAW */
256   ROM_LOAD( "mr96004-09.7", 0x000000, 0x200000, BAD_DUMP CRC(603143e8) SHA1(197ff72d4a6bf9cc5e89505c1a25edad104a9a65) )
257
258   /* BG Tiles #1 (Screen 1?) */
259   ROM_REGION( 0x200000, REGION_GFX4, 0 ) /* bg tiles, don't dispose since we use GFX_RAW */
260   ROM_LOAD( "mr96004-11.11", 0x000000, 0x200000,  CRC(e6da552c) SHA1(69a5af3015883793c7d1343243ccae23db9ef77c) )
261
262   /* TX Tiles #1 (Screen 1?) */
263   ROM_REGION( 0x080000, REGION_GFX5, 0 ) /* tx tiles, don't dispose since we use GFX_RAW */
264   ROM_LOAD( "vsjanshi6.5", 0x000000, 0x080000, CRC(fdbbac21) SHA1(c77d852e53126cc8ebfe1e79d1134e42b54d1aab) )
265
266   /* BG Tiles #2 (Screen 1?) */
267   ROM_REGION( 0x200000, REGION_GFX6, 0 ) /* bg tiles, don't dispose since we use GFX_RAW */
268   ROM_LOAD( "mr96004-11.13", 0x000000, 0x200000, CRC(e6da552c) SHA1(69a5af3015883793c7d1343243ccae23db9ef77c) )
269
270   /* TX Tiles #2 (Screen 2?) */
271   ROM_REGION( 0x080000, REGION_GFX7, 0 ) /* tx tiles, don't dispose since we use GFX_RAW */
272   ROM_LOAD( "vsjanshi5.6", 0x000000, 0x080000, CRC(fdbbac21) SHA1(c77d852e53126cc8ebfe1e79d1134e42b54d1aab) )
273
274   /* Sound Program (one, driving both screen sound) */
275   ROM_REGION( 0x50000, REGION_CPU2, 0 ) /* z80 program */
276   ROM_LOAD( "sb93145.5",  0x000000, 0x040000, CRC(0424e899) SHA1(fbcdebfa3d5f52b10cf30f7e416f5f53994e4d55) )
277   ROM_RELOAD(              0x010000, 0x40000 )
278
279   /* Samples #1 (Screen 1?) */
280   ROM_REGION( 0x400000, REGION_SOUND1, 0 ) /* samples - 8-bit signed PCM */
281   ROM_LOAD( "mr96004-10.1",  0x000000, 0x200000, BAD_DUMP CRC(125661cd) SHA1(7c5fd952fb756364cc0ab6a53072f5cf8a04486c) )
282
283   /* Samples #2 (Screen 2?) */
284   ROM_REGION( 0x400000, REGION_SOUND2, 0 ) /* samples - 8-bit signed PCM */
285   ROM_LOAD( "mr96004-10.1",  0x000000, 0x200000, BAD_DUMP CRC(125661cd) SHA1(7c5fd952fb756364cc0ab6a53072f5cf8a04486c) )
286ROM_END
287
288
289/* SS92046_01: bbbxing, f1superb, tetrisp, hayaosi1 */
290static DRIVER_INIT (bnstars)
291{
292   ms32_rearrange_sprites(REGION_GFX1);
293
294   decrypt_ms32_tx(0x00020,0x7e, REGION_GFX5);
295   decrypt_ms32_bg(0x00001,0x9b, REGION_GFX4);
296   decrypt_ms32_tx(0x00020,0x7e, REGION_GFX7);
297   decrypt_ms32_bg(0x00001,0x9b, REGION_GFX6);
298
299   memory_set_bankptr(1, memory_region(REGION_CPU1));
300}
301
302GAME( 1997, bnstars1, 0,        bnstars, bnstars, bnstars, ROT0,   "Jaleco", "Vs. Janshi Brandnew Stars", GAME_NOT_WORKING|GAME_NO_SOUND )
src/mame/drivers/galaga.c
r1070r1071
706706#include "rescap.h"
707707#include "sound/samples.h"
708708#include "audio/namco54.h"
709#include "nam_cust.h"
709710
710711
711
712712static INTERRUPT_GEN( galaga_cpu3_nmi )
713713{
714714   /* see notes at the top of the driver */
r1070r1071
18931893
18941894***************************************************************************/
18951895
1896/**********************************************************************************************
1897  Bosconian & clones
1898**********************************************************************************************/
1899
1900#define BOSCO_CUSTOMS \
1901   ROM_REGION_NAMCO_50XX( REGION_CPU4 ) \
1902   ROM_REGION_NAMCO_50XX( REGION_CPU5 ) \
1903   ROM_REGION_NAMCO_54XX( REGION_CPU6 ) \
1904   ROM_REGION_NAMCO_51XX( REGION_CPU7 ) \
1905   ROM_REGION_NAMCO_52XX( REGION_CPU8 ) \
1906
1907
18961908ROM_START( bosco )
18971909   ROM_REGION( 0x10000, REGION_CPU1, 0 )   /* 64k for code for the first CPU  */
18981910   ROM_LOAD( "bos3_1.bin",   0x0000, 0x1000, CRC(96021267) SHA1(bd49b0caabcccf9df45a272d767456a4fc8a7c07) )
r1070r1071
19071919   ROM_REGION( 0x10000, REGION_CPU3, 0 )   /* 64k for the third CPU  */
19081920   ROM_LOAD( "2900.3e",      0x0000, 0x1000, CRC(d45a4911) SHA1(547236adca9174f5cc0ec05b9649618bb92ba630) )
19091921
1910   ROM_REGION( 0x800, REGION_CPU4, 0 )     /* 2k for the 1st 50xx  */
1911   ROM_LOAD( "50xx.bin",     0x0000, 0x0800, CRC(a0acbaf7) SHA1(f03c79451e73b3a93c1591cdb27fedc9f130508d) )
1922   BOSCO_CUSTOMS
19121923
1913   ROM_REGION( 0x800, REGION_CPU5, 0 )     /* 2k for the 2nd 50xx  */
1914   ROM_LOAD( "50xx.bin",     0x0000, 0x0800, CRC(a0acbaf7) SHA1(f03c79451e73b3a93c1591cdb27fedc9f130508d) )
1915
1916   ROM_REGION( 0x400, REGION_CPU6, 0 )     /* 1k for the 54xx  */
1917   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
1918
19191924   ROM_REGION( 0x1000, REGION_GFX1, ROMREGION_DISPOSE )
19201925   ROM_LOAD( "5300.5d",      0x0000, 0x1000, CRC(a956d3c5) SHA1(c5a9d7b1f9b4acda8fb9762414e085cb5fb80c9e) )
19211926
r1070r1071
19551960   ROM_REGION( 0x10000, REGION_CPU3, 0 )   /* 64k for the third CPU  */
19561961   ROM_LOAD( "2900.3e",      0x0000, 0x1000, CRC(d45a4911) SHA1(547236adca9174f5cc0ec05b9649618bb92ba630) )
19571962
1958   ROM_REGION( 0x800, REGION_CPU4, 0 )     /* 2k for the 1st 50xx  */
1959   ROM_LOAD( "50xx.bin",     0x0000, 0x0800, CRC(a0acbaf7) SHA1(f03c79451e73b3a93c1591cdb27fedc9f130508d) )
1963   BOSCO_CUSTOMS
19601964
1961   ROM_REGION( 0x800, REGION_CPU5, 0 )     /* 2k for the 2nd 50xx  */
1962   ROM_LOAD( "50xx.bin",     0x0000, 0x0800, CRC(a0acbaf7) SHA1(f03c79451e73b3a93c1591cdb27fedc9f130508d) )
1963
1964   ROM_REGION( 0x400, REGION_CPU6, 0 )     /* 1k for the 54xx  */
1965   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
1966
19671965   ROM_REGION( 0x1000, REGION_GFX1, ROMREGION_DISPOSE )
19681966   ROM_LOAD( "5300.5d",      0x0000, 0x1000, CRC(a956d3c5) SHA1(c5a9d7b1f9b4acda8fb9762414e085cb5fb80c9e) )
19691967
r1070r1071
20032001   ROM_REGION( 0x10000, REGION_CPU3, 0 )   /* 64k for the third CPU  */
20042002   ROM_LOAD( "2900.3e",      0x0000, 0x1000, CRC(d45a4911) SHA1(547236adca9174f5cc0ec05b9649618bb92ba630) )
20052003
2006   ROM_REGION( 0x800, REGION_CPU4, 0 )     /* 2k for the 1st 50xx  */
2007   ROM_LOAD( "50xx.bin",     0x0000, 0x0800, CRC(a0acbaf7) SHA1(f03c79451e73b3a93c1591cdb27fedc9f130508d) )
2004   BOSCO_CUSTOMS
20082005
2009   ROM_REGION( 0x800, REGION_CPU5, 0 )     /* 2k for the 2nd 50xx  */
2010   ROM_LOAD( "50xx.bin",     0x0000, 0x0800, CRC(a0acbaf7) SHA1(f03c79451e73b3a93c1591cdb27fedc9f130508d) )
2011
2012   ROM_REGION( 0x400, REGION_CPU6, 0 )     /* 1k for the 54xx  */
2013   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
2014
20152006   ROM_REGION( 0x1000, REGION_GFX1, ROMREGION_DISPOSE )
20162007   ROM_LOAD( "5300.5d",      0x0000, 0x1000, CRC(a956d3c5) SHA1(c5a9d7b1f9b4acda8fb9762414e085cb5fb80c9e) )
20172008
r1070r1071
20512042   ROM_REGION( 0x10000, REGION_CPU3, 0 )   /* 64k for the third CPU  */
20522043   ROM_LOAD( "2900.3e",      0x0000, 0x1000, CRC(d45a4911) SHA1(547236adca9174f5cc0ec05b9649618bb92ba630) )
20532044
2054   ROM_REGION( 0x800, REGION_CPU4, 0 )     /* 2k for the 1st 50xx  */
2055   ROM_LOAD( "50xx.bin",     0x0000, 0x0800, CRC(a0acbaf7) SHA1(f03c79451e73b3a93c1591cdb27fedc9f130508d) )
2045   BOSCO_CUSTOMS
20562046
2057   ROM_REGION( 0x800, REGION_CPU5, 0 )     /* 2k for the 2nd 50xx  */
2058   ROM_LOAD( "50xx.bin",     0x0000, 0x0800, CRC(a0acbaf7) SHA1(f03c79451e73b3a93c1591cdb27fedc9f130508d) )
2059
2060   ROM_REGION( 0x400, REGION_CPU6, 0 )     /* 1k for the 54xx  */
2061   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
2062
20632047   ROM_REGION( 0x1000, REGION_GFX1, ROMREGION_DISPOSE )
20642048   ROM_LOAD( "5300.5d",      0x0000, 0x1000, CRC(a956d3c5) SHA1(c5a9d7b1f9b4acda8fb9762414e085cb5fb80c9e) )
20652049
r1070r1071
20992083   ROM_REGION( 0x10000, REGION_CPU3, 0 )   /* 64k for the third CPU  */
21002084   ROM_LOAD( "2900.3e",      0x0000, 0x1000, CRC(d45a4911) SHA1(547236adca9174f5cc0ec05b9649618bb92ba630) )
21012085
2102   ROM_REGION( 0x800, REGION_CPU4, 0 )     /* 2k for the 1st 50xx  */
2103   ROM_LOAD( "50xx.bin",     0x0000, 0x0800, CRC(a0acbaf7) SHA1(f03c79451e73b3a93c1591cdb27fedc9f130508d) )
2086   BOSCO_CUSTOMS
21042087
2105   ROM_REGION( 0x800, REGION_CPU5, 0 )     /* 2k for the 2nd 50xx  */
2106   ROM_LOAD( "50xx.bin",     0x0000, 0x0800, CRC(a0acbaf7) SHA1(f03c79451e73b3a93c1591cdb27fedc9f130508d) )
2107
2108   ROM_REGION( 0x400, REGION_CPU6, 0 )     /* 1k for the 54xx  */
2109   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
2110
21112088   ROM_REGION( 0x1000, REGION_GFX1, ROMREGION_DISPOSE )
21122089   ROM_LOAD( "5300.5d",      0x0000, 0x1000, CRC(a956d3c5) SHA1(c5a9d7b1f9b4acda8fb9762414e085cb5fb80c9e) )
21132090
r1070r1071
21332110   ROM_LOAD( "5100.5l",      0x2000, 0x1000, CRC(17ac9511) SHA1(266f3fae90d2fe38d109096d352863a52b379899) )
21342111ROM_END
21352112
2113/**********************************************************************************************
2114  Galaga & clones
2115**********************************************************************************************/
21362116
2117#define GALAGA_CUSTOMS \
2118   ROM_REGION_NAMCO_54XX( REGION_CPU4 ) \
2119   ROM_REGION_NAMCO_51XX( REGION_CPU5 ) \
21372120
2121
21382122ROM_START( galaga )
21392123   ROM_REGION( 0x10000, REGION_CPU1, 0 )     /* 64k for code for the first CPU  */
21402124   ROM_LOAD( "gg1-1b.3p",    0x0000, 0x1000, CRC(ab036c9f) SHA1(ca7f5da42d4e76fd89bb0b35198a23c01462fbfe) )
r1070r1071
21482132   ROM_REGION( 0x10000, REGION_CPU3, 0 )     /* 64k for the third CPU  */
21492133   ROM_LOAD( "gg1-7b.2c",    0x0000, 0x1000, CRC(d016686b) SHA1(44c1a04fba3c7c826ff484185cb881b4b22e6657) )
21502134
2151   ROM_REGION( 0x400, REGION_CPU4, 0 )     /* 1k for the 54xx  */
2152   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
2135   GALAGA_CUSTOMS
21532136
21542137   ROM_REGION( 0x1000, REGION_GFX1, ROMREGION_DISPOSE )
21552138   ROM_LOAD( "gg1-9.4l",     0x0000, 0x1000, CRC(58b2f47c) SHA1(62f1279a784ab2f8218c4137c7accda00e6a3490) )
r1070r1071
21812164   ROM_REGION( 0x10000, REGION_CPU3, 0 )     /* 64k for the third CPU  */
21822165   ROM_LOAD( "gg1-7",        0x0000, 0x1000, CRC(8995088d) SHA1(d6cb439de0718826d1a0363c9d77de8740b18ecf) )
21832166
2184   ROM_REGION( 0x400, REGION_CPU4, 0 )     /* 1k for the 54xx  */
2185   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
2167   GALAGA_CUSTOMS
21862168
21872169   ROM_REGION( 0x1000, REGION_GFX1, ROMREGION_DISPOSE )
21882170   ROM_LOAD( "gg1-9.4l",     0x0000, 0x1000, CRC(58b2f47c) SHA1(62f1279a784ab2f8218c4137c7accda00e6a3490) )
r1070r1071
22142196   ROM_REGION( 0x10000, REGION_CPU3, 0 )     /* 64k for the third CPU  */
22152197   ROM_LOAD( "3700g.bin",    0x0000, 0x1000, CRC(b07f0aa4) SHA1(7528644a8480d0be2d0d37069515ed319e94778f) )
22162198
2217   ROM_REGION( 0x400, REGION_CPU4, 0 )     /* 1k for the 54xx  */
2218   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
2199   GALAGA_CUSTOMS
22192200
22202201   ROM_REGION( 0x1000, REGION_GFX1, ROMREGION_DISPOSE )
22212202   ROM_LOAD( "gg1-9.4l",     0x0000, 0x1000, CRC(58b2f47c) SHA1(62f1279a784ab2f8218c4137c7accda00e6a3490) )
r1070r1071
22472228   ROM_REGION( 0x10000, REGION_CPU3, 0 )     /* 64k for the third CPU  */
22482229   ROM_LOAD( "3700g.bin",    0x0000, 0x1000, CRC(b07f0aa4) SHA1(7528644a8480d0be2d0d37069515ed319e94778f) )
22492230
2250   ROM_REGION( 0x400, REGION_CPU4, 0 )     /* 1k for the 54xx  */
2251   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
2231   GALAGA_CUSTOMS
22522232
22532233   ROM_REGION( 0x1000, REGION_GFX1, ROMREGION_DISPOSE )
22542234   ROM_LOAD( "gg1-9.4l",     0x0000, 0x1000, CRC(58b2f47c) SHA1(62f1279a784ab2f8218c4137c7accda00e6a3490) )
r1070r1071
22802260   ROM_REGION( 0x10000, REGION_CPU3, 0 )     /* 64k for the third CPU  */
22812261   ROM_LOAD( "gg1-7b.2c",    0x0000, 0x1000, CRC(d016686b) SHA1(44c1a04fba3c7c826ff484185cb881b4b22e6657) )
22822262
2283   ROM_REGION( 0x400, REGION_CPU4, 0 )     /* 1k for the 54xx  */
2284   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
2263   GALAGA_CUSTOMS
22852264
22862265   ROM_REGION( 0x1000, REGION_GFX1, ROMREGION_DISPOSE )
22872266   ROM_LOAD( "gg1-9.4l",     0x0000, 0x1000, CRC(58b2f47c) SHA1(62f1279a784ab2f8218c4137c7accda00e6a3490) )
r1070r1071
23662345   ROM_LOAD( "prom-2.5c",    0x0100, 0x0100, CRC(77245b66) SHA1(0c4d0bee858b97632411c440bea6948a74759746) )   /* timing - not used */
23672346ROM_END
23682347
2348/**********************************************************************************************
2349  Xevious & clones
2350**********************************************************************************************/
23692351
2352#define XEVIOUS_CUSTOMS \
2353   ROM_REGION_NAMCO_50XX( REGION_CPU4 ) \
2354   ROM_REGION_NAMCO_54XX( REGION_CPU5 ) \
2355   ROM_REGION_NAMCO_51XX( REGION_CPU6 ) \
23702356
23712357ROM_START( xevious )
23722358   ROM_REGION( 0x10000, REGION_CPU1, 0 )   /* 64k for the first CPU */
r1070r1071
23822368   ROM_REGION( 0x10000, REGION_CPU3, 0 )
23832369   ROM_LOAD( "xvi_7.2c",     0x0000, 0x1000, CRC(dd35cf1c) SHA1(f8d1f8e019d8198308443c2e7e815d0d04b23d14) )
23842370
2385   ROM_REGION( 0x800, REGION_CPU4, 0 )     /* 2k for the 50xx  */
2386   ROM_LOAD( "50xx.bin",     0x0000, 0x0800, CRC(a0acbaf7) SHA1(f03c79451e73b3a93c1591cdb27fedc9f130508d) )
2371   XEVIOUS_CUSTOMS
23872372
2388   ROM_REGION( 0x400, REGION_CPU5, 0 )     /* 1k for the 54xx  */
2389   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
2390
23912373   ROM_REGION( 0x1000, REGION_GFX1, ROMREGION_DISPOSE )
23922374   ROM_LOAD( "xvi_12.3b",    0x0000, 0x1000, CRC(088c8b26) SHA1(9c3b61dfca2f84673a78f7f66e363777a8f47a59) )   /* foreground characters */
23932375
r1070r1071
24332415   ROM_REGION( 0x10000, REGION_CPU3, 0 )
24342416   ROM_LOAD( "xvi_7.2c",     0x0000, 0x1000, CRC(dd35cf1c) SHA1(f8d1f8e019d8198308443c2e7e815d0d04b23d14) )
24352417
2436   ROM_REGION( 0x800, REGION_CPU4, 0 )     /* 2k for the 50xx  */
2437   ROM_LOAD( "50xx.bin",     0x0000, 0x0800, CRC(a0acbaf7) SHA1(f03c79451e73b3a93c1591cdb27fedc9f130508d) )
2418   XEVIOUS_CUSTOMS
24382419
2439   ROM_REGION( 0x400, REGION_CPU5, 0 )     /* 1k for the 54xx  */
2440   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
2441
24422420   ROM_REGION( 0x1000, REGION_GFX1, ROMREGION_DISPOSE )
24432421   ROM_LOAD( "xvi_12.3b",    0x0000, 0x1000, CRC(088c8b26) SHA1(9c3b61dfca2f84673a78f7f66e363777a8f47a59) )   /* foreground characters */
24442422
r1070r1071
24842462   ROM_REGION( 0x10000, REGION_CPU3, 0 )
24852463   ROM_LOAD( "xvi_7.2c",     0x0000, 0x1000, CRC(dd35cf1c) SHA1(f8d1f8e019d8198308443c2e7e815d0d04b23d14) )
24862464
2487   ROM_REGION( 0x800, REGION_CPU4, 0 )     /* 2k for the 50xx  */
2488   ROM_LOAD( "50xx.bin",     0x0000, 0x0800, CRC(a0acbaf7) SHA1(f03c79451e73b3a93c1591cdb27fedc9f130508d) )
2465   XEVIOUS_CUSTOMS
24892466
2490   ROM_REGION( 0x400, REGION_CPU5, 0 )     /* 1k for the 54xx  */
2491   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
2492
24932467   ROM_REGION( 0x1000, REGION_GFX1, ROMREGION_DISPOSE )
24942468   ROM_LOAD( "xvi_12.3b",    0x0000, 0x1000, CRC(088c8b26) SHA1(9c3b61dfca2f84673a78f7f66e363777a8f47a59) )   /* foreground characters */
24952469
r1070r1071
25382512   ROM_REGION( 0x10000, REGION_CPU3, 0 )
25392513   ROM_LOAD( "xvi_7.2c",     0x0000, 0x1000, CRC(dd35cf1c) SHA1(f8d1f8e019d8198308443c2e7e815d0d04b23d14) )
25402514
2541   ROM_REGION( 0x800, REGION_CPU4, 0 )     /* 2k for the 50xx  */
2542   ROM_LOAD( "50xx.bin",     0x0000, 0x0800, CRC(a0acbaf7) SHA1(f03c79451e73b3a93c1591cdb27fedc9f130508d) )
2515   XEVIOUS_CUSTOMS
25432516
2544   ROM_REGION( 0x400, REGION_CPU5, 0 )     /* 1k for the 54xx  */
2545   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
2546
25472517   ROM_REGION( 0x1000, REGION_GFX1, ROMREGION_DISPOSE )
25482518   ROM_LOAD( "xvi_12.3b",    0x0000, 0x1000, CRC(088c8b26) SHA1(9c3b61dfca2f84673a78f7f66e363777a8f47a59) )   /* foreground characters */
25492519
r1070r1071
25922562   ROM_REGION( 0x10000, REGION_CPU3, 0 )
25932563   ROM_LOAD( "xvi_7.2c",     0x0000, 0x1000, CRC(dd35cf1c) SHA1(f8d1f8e019d8198308443c2e7e815d0d04b23d14) )
25942564
2595   ROM_REGION( 0x800, REGION_CPU4, 0 )     /* 2k for the 50xx  */
2596   ROM_LOAD( "50xx.bin",     0x0000, 0x0800, CRC(a0acbaf7) SHA1(f03c79451e73b3a93c1591cdb27fedc9f130508d) )
2565   /* This is a bootleg, it probably shouldn't be loading these, see 'unknown roms' below */
2566   XEVIOUS_CUSTOMS
25972567
2598   ROM_REGION( 0x400, REGION_CPU5, 0 )     /* 1k for the 54xx  */
2599   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
2600
26012568   ROM_REGION( 0x1000, REGION_GFX1, ROMREGION_DISPOSE )
26022569   ROM_LOAD( "xvi_12.3b",    0x0000, 0x1000, CRC(088c8b26) SHA1(9c3b61dfca2f84673a78f7f66e363777a8f47a59) )   /* foreground characters */
26032570
r1070r1071
26312598   ROM_LOAD( "xvi_2bpr.7n",  0x0000, 0x0100, CRC(550f06bc) SHA1(816a0fafa0b084ac11ae1af70a5186539376fc2a) )
26322599   ROM_LOAD( "xvi_1bpr.5n",  0x0100, 0x0100, CRC(77245b66) SHA1(0c4d0bee858b97632411c440bea6948a74759746) )   /* timing - not used */
26332600
2634   ROM_REGION( 0x3000, REGION_USER1, 0 )
2601   ROM_REGION( 0x3000, REGION_USER1, 0 ) /* unknown roms */
26352602   /* extra ROMs (function unknown, could be emulation of the custom I/O */
26362603   /* chip with a Z80): */
26372604   ROM_LOAD( "1.16j",        0x0000, 0x1000, CRC(2618f0ce) SHA1(54e8644b5609d6f6ec717a7469c76901eb79f26e) )
r1070r1071
27002667   ROM_REGION( 0x10000, REGION_CPU3, 0 )
27012668   ROM_LOAD( "xvi_7.2c",     0x0000, 0x1000, CRC(dd35cf1c) SHA1(f8d1f8e019d8198308443c2e7e815d0d04b23d14) )
27022669
2703   ROM_REGION( 0x800, REGION_CPU4, 0 )     /* 2k for the 50xx  */
2704   ROM_LOAD( "50xx.bin",     0x0000, 0x0800, CRC(a0acbaf7) SHA1(f03c79451e73b3a93c1591cdb27fedc9f130508d) )
2670   XEVIOUS_CUSTOMS
27052671
2706   ROM_REGION( 0x400, REGION_CPU5, 0 )     /* 1k for the 54xx  */
2707   ROM_LOAD( "54xx.bin",     0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) )
2708
27092672   ROM_REGION( 0x1000, REGION_GFX1, ROMREGION_DISPOSE )
27102673   ROM_LOAD( "xvi_12.3b",    0x0000, 0x1000, CRC(088c8b26) SHA1(9c3b61dfca2f84673a78f7f66e363777a8f47a59) )   /* foreground characters */
27112674
r1070r1071
27402703   ROM_LOAD( "xvi_1bpr.5n",  0x0100, 0x0100, CRC(77245b66) SHA1(0c4d0bee858b97632411c440bea6948a74759746) )   /* timing - not used */
27412704ROM_END
27422705
2706/**********************************************************************************************
2707  Dig Dug & clones
2708**********************************************************************************************/
27432709
2710#define DIGDUG_CUSTOMS \
2711   ROM_REGION_NAMCO_51XX( REGION_CPU4 ) \
2712   ROM_REGION_NAMCO_53XX( REGION_CPU5 ) \
27442713
27452714ROM_START( digdug )
27462715   ROM_REGION( 0x10000, REGION_CPU1, 0 ) /* 64k for code for the first CPU  */
r1070r1071
27562725   ROM_REGION( 0x10000, REGION_CPU3, 0 ) /* 64k for the third CPU  */
27572726   ROM_LOAD( "136007.107",   0x0000, 0x1000, CRC(a41bce72) SHA1(2b9b74f56aa7939d9d47cf29497ae11f10d78598) )
27582727
2728   DIGDUG_CUSTOMS
2729
27592730   ROM_REGION( 0x1000, REGION_GFX1, ROMREGION_DISPOSE )
27602731   ROM_LOAD( "dd1.9",        0x0000, 0x0800, CRC(f14a6fe1) SHA1(0aa63300c2cb887196de590aceb98f3cf06fead4) )
27612732
r1070r1071
27952766   ROM_REGION( 0x10000, REGION_CPU3, 0 )   /* 64k for the third CPU  */
27962767   ROM_LOAD( "136007.107",   0x0000, 0x1000, CRC(a41bce72) SHA1(2b9b74f56aa7939d9d47cf29497ae11f10d78598) )
27972768
2769   DIGDUG_CUSTOMS
2770
27982771   ROM_REGION( 0x1000, REGION_GFX1, ROMREGION_DISPOSE )
27992772   ROM_LOAD( "dd1.9",        0x0000, 0x0800, CRC(f14a6fe1) SHA1(0aa63300c2cb887196de590aceb98f3cf06fead4) )
28002773
r1070r1071
28342807   ROM_REGION( 0x10000, REGION_CPU3, 0 )   /* 64k for the third CPU  */
28352808   ROM_LOAD( "136007.107",   0x0000, 0x1000, CRC(a41bce72) SHA1(2b9b74f56aa7939d9d47cf29497ae11f10d78598) )
28362809
2810   DIGDUG_CUSTOMS
2811
28372812   ROM_REGION( 0x1000, REGION_GFX1, ROMREGION_DISPOSE )
28382813   ROM_LOAD( "136007.108",   0x0000, 0x0800, CRC(3d24a3af) SHA1(857ae93e2a41258a129dcecbaed2df359540b735) )
28392814
r1070r1071
28732848   ROM_REGION( 0x10000, REGION_CPU3, 0 )   /* 64k for the third CPU  */
28742849   ROM_LOAD( "136007.107",   0x0000, 0x1000, CRC(a41bce72) SHA1(2b9b74f56aa7939d9d47cf29497ae11f10d78598) )
28752850
2851   DIGDUG_CUSTOMS
2852
28762853   ROM_REGION( 0x1000, REGION_GFX1, ROMREGION_DISPOSE )
28772854   ROM_LOAD( "136007.108",   0x0000, 0x0800, CRC(3d24a3af) SHA1(857ae93e2a41258a129dcecbaed2df359540b735) )
28782855
r1070r1071
30092986   ROM_REGION( 0x10000, REGION_CPU3, 0 )   /* 64k for the third CPU  */
30102987   ROM_LOAD( "digdug6.6",   0x0000, 0x1000, CRC(a41bce72) SHA1(2b9b74f56aa7939d9d47cf29497ae11f10d78598) )
30112988
2989   DIGDUG_CUSTOMS
2990
30122991   ROM_REGION( 0x1000, REGION_GFX1, ROMREGION_DISPOSE )
30132992   ROM_LOAD( "digdug8.8",        0x0000, 0x0800, CRC(f14a6fe1) SHA1(0aa63300c2cb887196de590aceb98f3cf06fead4) )
30142993
r1070r1071
31083087}
31093088
31103089
3090/* Original Namco hardware, with Namco Customs */
31113091
31123092GAME( 1981, bosco,    0,       bosco,   bosco,    0,       ROT0,  "Namco", "Bosconian (new version)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS )
31133093GAME( 1981, boscoo,   bosco,   bosco,   bosco,    0,       ROT0,  "Namco", "Bosconian (old version)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS )
r1070r1071
31203100GAME( 1981, galagamw, galaga,  galaga,  galagamw, galaga,  ROT90, "[Namco] (Midway license)", "Galaga (Midway set 1)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS )
31213101GAME( 1981, galagamk, galaga,  galaga,  galaga,   galaga,  ROT90, "[Namco] (Midway license)", "Galaga (Midway set 2)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS )
31223102GAME( 1981, galagamf, galaga,  galaga,  galaga,   galaga,  ROT90, "[Namco] (Midway license)", "Galaga (Midway set 1 with fast shoot hack)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS )
3123GAME( 1981, gallag,   galaga,  galagab, galaga,   galaga,  ROT90, "bootleg", "Gallag", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
3124GAME( 1984, gatsbee,  galaga,  galagab, gatsbee,  gatsbee, ROT90, "hack", "Gatsbee", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
31253103
31263104GAME( 1982, xevious,  0,       xevious, xevious,  xevious, ROT90, "Namco", "Xevious (Namco)", GAME_SUPPORTS_SAVE )
31273105GAME( 1982, xeviousa, xevious, xevious, xeviousa, xevious, ROT90, "Namco (Atari license)", "Xevious (Atari set 1)", GAME_SUPPORTS_SAVE )
31283106GAME( 1982, xeviousb, xevious, xevious, xeviousb, xevious, ROT90, "Namco (Atari license)", "Xevious (Atari set 2)", GAME_SUPPORTS_SAVE )
31293107GAME( 1982, xeviousc, xevious, xevious, xeviousa, xevious, ROT90, "Namco (Atari license)", "Xevious (Atari set 3)", GAME_SUPPORTS_SAVE )
3130GAME( 1982, xevios,   xevious, xevious, xevious,  xevios,  ROT90, "bootleg", "Xevios", GAME_SUPPORTS_SAVE )
3131GAME( 1982, battles,  xevious, battles, xevious,  battles, ROT90, "bootleg", "Battles", GAME_SUPPORTS_SAVE )
31323108GAME( 1984, sxevious, xevious, xevious, sxevious, xevious, ROT90, "Namco", "Super Xevious", GAME_SUPPORTS_SAVE )
31333109
31343110GAME( 1982, digdug,   0,       digdug,  digdug,   0,       ROT90, "Namco", "Dig Dug (rev 2)", GAME_SUPPORTS_SAVE )
31353111GAME( 1982, digdugb,  digdug,  digdug,  digdug,   0,       ROT90, "Namco", "Dig Dug (rev 1)", GAME_SUPPORTS_SAVE )
31363112GAME( 1982, digdugat, digdug,  digdug,  digdug,   0,       ROT90, "[Namco] (Atari license)", "Dig Dug (Atari, rev 2)", GAME_SUPPORTS_SAVE )
31373113GAME( 1982, digduga1, digdug,  digdug,  digdug,   0,       ROT90, "[Namco] (Atari license)", "Dig Dug (Atari, rev 1)", GAME_SUPPORTS_SAVE )
3114GAME( 1982, digsid,   digdug,  digdug, digdug,    0,       ROT90, "Namco [Sidam license]", "Dig Dug (manufactured by Sidam)", GAME_SUPPORTS_SAVE )
3115
3116/* Bootlegs with replacement I/O chips */
3117
3118GAME( 1981, gallag,   galaga,  galagab, galaga,   galaga,  ROT90, "bootleg", "Gallag", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
3119GAME( 1984, gatsbee,  galaga,  galagab, gatsbee,  gatsbee, ROT90, "hack", "Gatsbee", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
3120
3121GAME( 1982, xevios,   xevious, xevious, xevious,  xevios,  ROT90, "bootleg", "Xevios", GAME_SUPPORTS_SAVE )
3122GAME( 1982, battles,  xevious, battles, xevious,  battles, ROT90, "bootleg", "Battles", GAME_SUPPORTS_SAVE )
3123
31383124GAME( 1982, dzigzag,  digdug,  dzigzag, digdug,   0,       ROT90, "bootleg", "Zig Zag (Dig Dug hardware)", GAME_SUPPORTS_SAVE )
3139GAME( 1982, digsid,   digdug,  digdug, digdug,    0,       ROT90, "[Namco] (Sidam license)", "Dig Dug (Sidam)", GAME_SUPPORTS_SAVE ) // still has Namco copyright intact
src/mame/drivers/djboy.c
r1070r1071
900900   ROM_LOAD( "bs203.5j", 0x000000, 0x40000, CRC(805341fb) SHA1(fb94e400e2283aaa806814d5a39d6196457dc822) )
901901ROM_END
902902
903ROM_START( djboya )
904   ROM_REGION( 0x48000, REGION_CPU1, 0 )
905   ROM_LOAD( "bs19s.rom",  0x00000, 0x08000, CRC(17ce9f6c) SHA1(a0c1832b05dc46991e8949067ca0278f5498835f) )
906   ROM_CONTINUE( 0x10000, 0x18000 )
907   ROM_LOAD( "bs100.4d", 0x28000, 0x20000, CRC(081e8af8) SHA1(3589dab1cf31b109a40370b4db1f31785023e2ed) )
903908
909   ROM_REGION( 0x38000, REGION_CPU2, 0 )
910   ROM_LOAD( "bs15s.rom",  0x00000, 0x08000, CRC(e6f966b2) SHA1(f9df16035a8b09d87eb70315b216892e25d99b03) )
911   ROM_CONTINUE( 0x10000, 0x08000 )
912   ROM_LOAD( "bs101.6w", 0x18000, 0x20000, CRC(a7c85577) SHA1(8296b96d5f69f6c730b7ed77fa8c93496b33529c) )
913
914   ROM_REGION( 0x24000, REGION_CPU3, 0 ) /* sound */
915   ROM_LOAD( "bs200.8c", 0x00000, 0x0c000, CRC(f6c19e51) SHA1(82193f71122df07cce0a7f057a87b89eb2d587a1) )
916   ROM_CONTINUE( 0x10000, 0x14000 )
917
918   ROM_REGION( 0x200000, REGION_GFX1, 0 ) /* sprites */
919   ROM_LOAD( "bs000.1h", 0x000000, 0x80000, CRC(be4bf805) SHA1(a73c564575fe89d26225ca8ec2d98b6ac319ac18) )
920   ROM_LOAD( "bs001.1f", 0x080000, 0x80000, CRC(fdf36e6b) SHA1(a8762458dfd5201304247c113ceb85e96e33d423) )
921   ROM_LOAD( "bs002.1d", 0x100000, 0x80000, CRC(c52fee7f) SHA1(bd33117f7a57899fd4ec0a77413107edd9c44629) )
922   ROM_LOAD( "bs003.1k", 0x180000, 0x80000, CRC(ed89acb4) SHA1(611af362606b73cd2cf501678b463db52dcf69c4) )
923   ROM_LOAD( "bs07.1b",  0x1f0000, 0x10000, CRC(d9b7a220) SHA1(ba3b528d50650c209c986268bb29b42ff1276eb2) )  // replaces last 0x200 tiles
924
925   ROM_REGION( 0x100000, REGION_GFX2, 0 ) /* background */
926   ROM_LOAD( "bs004.1s", 0x000000, 0x80000, CRC(2f1392c3) SHA1(1bc3030b3612766a02133eef0b4d20013c0495a4) )
927   ROM_LOAD( "bs005.1u", 0x080000, 0x80000, CRC(46b400c4) SHA1(35f4823364bbff1fc935994498d462bbd3bc6044) )
928
929   ROM_REGION( 0x40000, REGION_SOUND1, 0 ) /* OKI-M6295 samples */
930   ROM_LOAD( "bs203.5j", 0x000000, 0x40000, CRC(805341fb) SHA1(fb94e400e2283aaa806814d5a39d6196457dc822) )
931ROM_END
932
904933ROM_START( djboyj )
905934   ROM_REGION( 0x48000, REGION_CPU1, 0 )
906935   ROM_LOAD( "bs12.4b",  0x00000, 0x08000, CRC(0971523e) SHA1(f90cd02cedf8632f4b651de7ea75dc8c0e682f6e) )
r1070r1071
10111040INPUT_PORTS_END
10121041
10131042/*     YEAR, NAME,  PARENT, MACHINE, INPUT, INIT, MNTR,  COMPANY, FULLNAME, FLAGS */
1014GAME( 1989, djboy,  0,      djboy,   djboy, djboy,    ROT0, "Sammy / Williams [Kaneko]", "DJ Boy", 0) // Sammy & Williams logos in FG ROM
1015GAME( 1989, djboyj, djboy,  djboy,   djboy, djboyj,   ROT0, "Sega [Kaneko]", "DJ Boy (Japan)", 0 ) // Sega logo in FG ROM
1043GAME( 1989, djboy,  0,      djboy,   djboy, djboy,    ROT0, "Kaneko (American Sammy license)", "DJ Boy (set 1)", 0) // Sammy & Williams logos in FG ROM
1044GAME( 1989, djboya, djboy,  djboy,   djboy, djboy,    ROT0, "Kaneko (American Sammy license)", "DJ Boy (set 2)", 0) // Sammy & Williams logos in FG ROM
1045GAME( 1989, djboyj, djboy,  djboy,   djboy, djboyj,   ROT0, "Kaneko (Sega license)", "DJ Boy (Japan)", 0 ) // Sega logo in FG ROM
10161046
src/mame/drivers/megaplay.c
r1070r1071
682682VIDEO_UPDATE(megplay)
683683{
684684   //printf("megplay vu\n");
685   video_update_megadriv(Machine,0,bitmap,cliprect);
686   megaplay_update_video_normal(Machine, bitmap,cliprect);
685   video_update_megadriv(machine,0,bitmap,cliprect);
686   megaplay_update_video_normal(machine, bitmap,cliprect);
687687   return 0;
688688}
689689
src/mame/drivers/m72.c
r1070r1071
338338   0xc6,0x06,0x00,0x09,0x49^0xff,   // mov [0900h], byte 049h
339339   0xc6,0x06,0x00,0x0a,0x49^0xff,   // mov [0a00h], byte 049h
340340   0xc6,0x06,0x00,0x0b,0x49^0xff,   // mov [0b00h], byte 049h
341
342   0x68,0x00,0xd0,                // push 0d000h // Japan set only
343   0x1f,                        // pop ds // Japan set only
344   0xc6,0x06,0x70,0x16,0x57,      // mov [1670h], byte 057h // Japan set only - checks this (W) of WARNING
345
341346   0xea,0x5d,0x01,0x40,0x00   // jmp  0040:$015d
347
342348};
343349static UINT8 loht_crc[CRC_LEN] =     {   0x39,0x00,0x82,0xae, 0x2c,0x9d,0x4b,0x73,
344350                                    0xfb,0xac,0xd4,0x6d, 0x6d,0x5b,0x77,0xc0, 0x00,0x00 };
351/* service mode crashes at the moment (119u2), so I can't add the CRCs for lohtj */
345352
346353/* X Multiply */
347354static UINT8 xmultipl_code[CODE_LEN] =
r1070r1071
465472   memset(m72_videoram2,0,0x4000);
466473}
467474
475READ16_HANDLER( m72_main_mcu_r)
476{
477   return protection_ram[offset];
478}
479
480WRITE16_HANDLER( m72_main_mcu_w)
481{
482   COMBINE_DATA(&protection_ram[offset]);
483}
484
485static DRIVER_INIT( loht_mcu )
486{
487
488   protection_ram = auto_malloc(0x10000);
489
490   memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0xb0000, 0xb0fff, 0, 0, m72_main_mcu_r);
491   memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0xb0000, 0xb0fff, 0, 0, m72_main_mcu_w);
492
493   memory_install_write16_handler(0, ADDRESS_SPACE_IO, 0xc0, 0xc1, 0, 0, loht_sample_trigger_w);
494
495}
496
497
468498static DRIVER_INIT( xmultipl )
469499{
470500   install_protection_handler(xmultipl_code,xmultipl_crc);
r1070r1071
18681898MACHINE_DRIVER_END
18691899
18701900
1901static ADDRESS_MAP_START( mcu_map, ADDRESS_SPACE_PROGRAM, 8 )
1902   ADDRESS_MAP_FLAGS( AMEF_UNMAP(1) )
1903   AM_RANGE(0x0000, 0x0fff) AM_ROM
1904ADDRESS_MAP_END
1905
1906static WRITE8_HANDLER( m72_mcu_data_w )
1907{
1908   if (offset&1) protection_ram[offset/2] = (protection_ram[offset/2] & 0x00ff) | (data << 8);
1909   else protection_ram[offset/2] = (protection_ram[offset/2] & 0xff00) | (data&0xff);
1910}
1911
1912static READ8_HANDLER(m72_mcu_data_r )
1913{
1914   UINT8 ret;
1915
1916   if (offset&1) ret = (protection_ram[offset/2] & 0xff00)>>8;
1917   else ret =(protection_ram[offset/2] & 0x00ff);
1918
1919//  printf("ret %02x\n",ret);
1920   return ret;
1921}
1922
1923static ADDRESS_MAP_START( mcu_data_map, ADDRESS_SPACE_DATA, 8 )
1924   ADDRESS_MAP_FLAGS( AMEF_UNMAP(1) )
1925   /* shared at b0000 - b0fff on the main cpu */
1926   AM_RANGE(0xc000, 0xcfff) AM_READWRITE(m72_mcu_data_r,m72_mcu_data_w )
1927ADDRESS_MAP_END
1928
1929
18711930static MACHINE_DRIVER_START( m72 )
18721931
18731932   /* basic machine hardware */
r1070r1071
19101969   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 0.40)
19111970MACHINE_DRIVER_END
19121971
1972static MACHINE_DRIVER_START( m72_8751 )
1973   MDRV_IMPORT_FROM(m72)
19131974
1975   MDRV_CPU_ADD(I8751, 8000000)
1976   MDRV_CPU_PROGRAM_MAP(mcu_map,0)
1977   MDRV_CPU_DATA_MAP(mcu_data_map,0)
1978   MDRV_CPU_VBLANK_INT(irq0_line_pulse,1)
1979MACHINE_DRIVER_END
1980
1981
19141982static MACHINE_DRIVER_START( dkgenm72 )
19151983
19161984   /* basic machine hardware */
r1070r1071
25072575   ROM_LOAD16_BYTE( "c-l3-b.rom",   0x60000, 0x10000, CRC(11562221) SHA1(a2f136a487fb6f30350e8d1e26c0729eb0686c7d) )
25082576   ROM_RELOAD(                      0xe0000, 0x10000 )
25092577
2578   ROM_REGION( 0x10000, REGION_CPU3, 0 )
2579   ROM_LOAD( "bchopper_i8751.mcu",  0x00000, 0x10000, NO_DUMP ) // read protected
2580
25102581   ROM_REGION( 0x080000, REGION_GFX1, ROMREGION_DISPOSE )
25112582   ROM_LOAD( "c-00-a.rom",   0x00000, 0x10000, CRC(f6e6e660) SHA1(e066e5ed37719cf2b6fd36e0117f11325bb06f9c) )   /* sprites */
25122583   ROM_LOAD( "c-01-b.rom",   0x10000, 0x10000, CRC(708cdd37) SHA1(24f3fcd381422f0d75410c2af7a56744e3b4a699) )
r1070r1071
25442615   ROM_LOAD16_BYTE( "mh-c-l3.bin",  0x60000, 0x10000, CRC(c0982536) SHA1(45399f8d0577c6e2a277a69303954ce5d2de7c07) )
25452616   ROM_RELOAD(                      0xe0000, 0x10000 )
25462617
2618   ROM_REGION( 0x10000, REGION_CPU3, 0 )
2619   ROM_LOAD( "mrheli_i8751.mcu",  0x00000, 0x10000, NO_DUMP ) // read protected
2620
25472621   ROM_REGION( 0x080000, REGION_GFX1, ROMREGION_DISPOSE )
25482622   ROM_LOAD( "mh-c-00.bin",  0x00000, 0x20000, CRC(dec4e121) SHA1(92169b523f1600e994e016dc1959a52958e1d89d) )   /* sprites */
25492623   ROM_LOAD( "mh-c-10.bin",  0x20000, 0x20000, CRC(7aaa151e) SHA1(efd980bb2eed7084354b7a4aa2f733cd2f876741) )
r1070r1071
25792653   ROM_LOAD16_BYTE( "nin-c-l3.rom", 0x60000, 0x10000, CRC(fd7408b8) SHA1(3cbe72835a561c50265a047f0f5cd62db48378fd) )
25802654   ROM_RELOAD(                      0xe0000, 0x10000 )
25812655
2656   ROM_REGION( 0x10000, REGION_CPU3, 0 )
2657   ROM_LOAD( "nspirit_i8751.mcu",  0x00000, 0x10000, NO_DUMP ) // read protected
2658
25822659   ROM_REGION( 0x080000, REGION_GFX1, ROMREGION_DISPOSE )
25832660   ROM_LOAD( "nin-r00.rom",  0x00000, 0x20000, CRC(5f61d30b) SHA1(7754697e43f6117fa604f50885b76014b1dc5760) )   /* sprites */
25842661   ROM_LOAD( "nin-r10.rom",  0x20000, 0x20000, CRC(0caad107) SHA1(c4eff00327313e05ac8f7c6dbee3a0de1c83fadd) )
r1070r1071
26142691   ROM_LOAD16_BYTE( "c-l3",         0x60000, 0x10000, CRC(e754a87a) SHA1(9951d972ed13a0415c827beff122bc7ddb078447) )
26152692   ROM_RELOAD(                      0xe0000, 0x10000 )
26162693
2694   ROM_REGION( 0x10000, REGION_CPU3, 0 )
2695   ROM_LOAD( "nspiritj_i8751.mcu",  0x00000, 0x10000, NO_DUMP ) // read protected
2696
26172697   ROM_REGION( 0x080000, REGION_GFX1, ROMREGION_DISPOSE )
26182698   ROM_LOAD( "nin-r00.rom",  0x00000, 0x20000, CRC(5f61d30b) SHA1(7754697e43f6117fa604f50885b76014b1dc5760) )   /* sprites */
26192699   ROM_LOAD( "nin-r10.rom",  0x20000, 0x20000, CRC(0caad107) SHA1(c4eff00327313e05ac8f7c6dbee3a0de1c83fadd) )
r1070r1071
26452725   ROM_LOAD16_BYTE( "if-c-l3.bin",  0x40000, 0x20000, CRC(c66ae348) SHA1(eca5096ebd5bffc6e68f3fc9969cda9679bd921f) )
26462726   ROM_RELOAD(                      0xc0000, 0x20000 )
26472727
2728   ROM_REGION( 0x10000, REGION_CPU3, 0 )
2729   ROM_LOAD( "imgfight_i8751.mcu",  0x00000, 0x10000, NO_DUMP ) // read protected
2730
26482731   ROM_REGION( 0x080000, REGION_GFX1, ROMREGION_DISPOSE )
26492732   ROM_LOAD( "if-c-00.bin",  0x00000, 0x20000, CRC(745e6638) SHA1(43fb1f9da4190fea67eee3aee8caf4219becc21b) )   /* sprites */
26502733   ROM_LOAD( "if-c-10.bin",  0x20000, 0x20000, CRC(b7108449) SHA1(1f41ebe7164fab86958caaf6749b99425e682657) )
r1070r1071
26772760   ROM_LOAD16_BYTE( "tom_c-l3.rom", 0x40000, 0x20000, CRC(2f049b03) SHA1(21047cb10912b1fc23795673af3ea7de249328b7) )
26782761   ROM_RELOAD(                      0xc0000, 0x20000 )
26792762
2763   ROM_REGION( 0x10000, REGION_CPU3, 0 )
2764   ROM_LOAD( "loht_i8751.mcu",  0x00000, 0x10000, NO_DUMP ) // read protected
2765
26802766   ROM_REGION( 0x080000, REGION_GFX1, ROMREGION_DISPOSE )
26812767   ROM_LOAD( "tom_m53.rom",  0x00000, 0x20000, CRC(0b83265f) SHA1(b31918d6442b79c9fe4f20410189788b050a994e) )   /* sprites */
26822768   ROM_LOAD( "tom_m51.rom",  0x20000, 0x20000, CRC(8ec5f6f3) SHA1(210f2753f5eeb06396758d21ab1778d459add247) )
r1070r1071
26992785   ROM_LOAD( "tom_m44.rom",  0x00000, 0x10000, CRC(3ed51d1f) SHA1(84f3aa17d640df91387e5f1f5b5971cf8dcd4e17) )
27002786ROM_END
27012787
2788/*
2789
2790Legend of Hero TONMA
2791(c)1989 Irem
2792
2793M72 System
2794Horizontal Freq. = 15.625KHz
2795H.Period         = 64.0us
2796H.Blank          = 16.0us
2797H.Sync Pulse     = 5.0us
2798Vertical Freq.   = 55.02Hz
2799V.Period         = 18.176ms
2800V.Blank          = 1.792ms
2801V.Sync Pulse     = 384us
2802
2803ROMs:
2804on M72-C mainboard
2805set jumper pins
2806J1:A
2807J2:A
2808J3:A
2809J4:A
2810J5:B
2811J6:A
2812J7:A
2813J9:A
2814J10:A
2815J11:B
2816J12:A
2817
2818TOM_C-H0- (M5M27C101K, main programs)
2819TOM_C-L0-
2820TOM_C-H3-
2821TOM_C-H0-
2822
2823R200 (28pin 1Mbit mask, read as 531000)
2824R210
2825R220
2826R230
2827
2828082 - Samples
2829
2830TOM_C-PR- (i8751H, read protected, not dumped)
2831TOM_C-3F- (PAL, read protected, not dumped)
2832
2833
2834on M72-B-B or M72-B-C or M72-B-D
2835set jumper pins (J2, J3, J4, J5) to "B"
2836R2A0.A0 (27C512)
2837R2A1.A1
2838R2A2.A2
2839R2A3.A3
2840
2841078.B0
2842079.B1
2843080.B2
2844081.B3
2845
2846*/
2847
2848ROM_START( lohtj )
2849   ROM_REGION( 0x100000, REGION_CPU1, 0 )
2850   ROM_LOAD16_BYTE( "tom_c-h0-", 0x00001, 0x20000, CRC(2a752998) SHA1(a88c3c75a1106665c94ddd0945bfaa7696a21b75) )
2851   ROM_LOAD16_BYTE( "tom_c-l0-", 0x00000, 0x20000, CRC(a224d928) SHA1(c4744f6ca19ce60b0c03415be979f2a824235a1c) )
2852   ROM_LOAD16_BYTE( "tom_c-h3-", 0x40001, 0x20000, CRC(714778b5) SHA1(e2eaa35d6b5fa5df5163fe0d7b45fa66667f9947) )
2853   ROM_RELOAD(                   0xc0001, 0x20000 )
2854   ROM_LOAD16_BYTE( "tom_c-l3-", 0x40000, 0x20000, CRC(2f049b03) SHA1(21047cb10912b1fc23795673af3ea7de249328b7) )
2855   ROM_RELOAD(                   0xc0000, 0x20000 )
2856
2857   ROM_REGION( 0x10000, REGION_CPU3, 0 )
2858   ROM_LOAD( "lohtj_i8751.mcu",  0x00000, 0x10000, NO_DUMP ) // read protected
2859
2860   ROM_REGION( 0x080000, REGION_GFX1, ROMREGION_DISPOSE )
2861   ROM_LOAD( "r200",  0x00000, 0x20000, CRC(0b83265f) SHA1(b31918d6442b79c9fe4f20410189788b050a994e) )   /* sprites */
2862   ROM_LOAD( "r210",  0x20000, 0x20000, CRC(8ec5f6f3) SHA1(210f2753f5eeb06396758d21ab1778d459add247) )
2863   ROM_LOAD( "r220",  0x40000, 0x20000, CRC(a41d3bfd) SHA1(536fb7c0321dbbc1a8b73e9647fba9c53a253fcc) )
2864   ROM_LOAD( "r230",  0x60000, 0x20000, CRC(9d81a25b) SHA1(a354537c2fbba85f06485aa8487d7583a7133357) )
2865
2866   ROM_REGION( 0x040000, REGION_GFX2, ROMREGION_DISPOSE )
2867   ROM_LOAD( "r2a0.a0",  0x00000, 0x10000, CRC(3ca3e771) SHA1(be052e01c5429ee89057c9d408794f2c7744047c) )   /* tiles #1 */
2868   ROM_LOAD( "r2a1.a1",  0x10000, 0x10000, CRC(7a05ee2f) SHA1(7d1ca5db9a5a85610129e3bc6c640ade036fe7f9) )
2869   ROM_LOAD( "r2a2.a2",  0x20000, 0x10000, CRC(79aa2335) SHA1(6b70c79d800a7b755aa7c9a368c4ea74029aaa1e) )
2870   ROM_LOAD( "r2a3.a3",  0x30000, 0x10000, CRC(789e8b24) SHA1(e957cd25c3c155ca295ab1aea03d610f91562cfb) )
2871
2872   ROM_REGION( 0x040000, REGION_GFX3, ROMREGION_DISPOSE )
2873   ROM_LOAD( "078.b0",  0x00000, 0x10000, CRC(44626bf6) SHA1(571ef74d42d30a272ff0fb33f830652b4a4bad29) )   /* tiles #2 */
2874   ROM_LOAD( "079.b1",  0x10000, 0x10000, CRC(464952cf) SHA1(6b99360b6ba1ed5a72c257f51291f9f7a1ddf363) )
2875   ROM_LOAD( "080.b2",  0x20000, 0x10000, CRC(3db9b2c7) SHA1(02a318ffc459c494b7f40827eff5f89b41ac0426) )
2876   ROM_LOAD( "081.b3",  0x30000, 0x10000, CRC(f01fe899) SHA1(c5ab967b7af55a757638bcdc9975f4b15064022d) )
2877
2878   ROM_REGION( 0x10000, REGION_SOUND1, 0 )   /* samples */
2879   ROM_LOAD( "082",  0x00000, 0x10000, CRC(3ed51d1f) SHA1(84f3aa17d640df91387e5f1f5b5971cf8dcd4e17) )
2880ROM_END
2881
2882/*
2883CPU cpu: nec v30
2884cpu: z80 (sharp LH0080B z80b-cpu)
2885cpu: 2x YM2203C
2886
2887quarzi: 16mhz vicino al v30 e 28mhz vicino allo z80 e ym2203c
2888*/
2889
2890ROM_START( lohtb )
2891   ROM_REGION( 0x100000, REGION_CPU1, 0 )
2892   ROM_LOAD16_BYTE( "lohtb03.b", 0x00001, 0x20000, CRC(8b845a70) SHA1(902c623310cd77b25592496745f9c6121149b516) )
2893   ROM_LOAD16_BYTE( "lohtb05.d", 0x00000, 0x20000, CRC(e90f7623) SHA1(e6e2f66a39286b2d7c03fc267beb2024913fb4ca) )
2894   ROM_LOAD16_BYTE( "lohtb02.a", 0x40001, 0x20000, CRC(714778b5) SHA1(e2eaa35d6b5fa5df5163fe0d7b45fa66667f9947) )
2895   ROM_RELOAD(                   0xc0001, 0x20000 )
2896   ROM_LOAD16_BYTE( "lohtb04.c", 0x40000, 0x20000, CRC(2f049b03) SHA1(21047cb10912b1fc23795673af3ea7de249328b7) )
2897   ROM_RELOAD(                   0xc0000, 0x20000 )
2898
2899   ROM_REGION( 0x10000, REGION_CPU2, 0 ) /* Sound CPU program (Z80) + Samples*/
2900   ROM_LOAD( "lohtb01.02",  0x00000, 0x10000, CRC(e4bd8f03) SHA1(69fe41a978db92daa912cb345c2c7bafd2a6eb93) )
2901
2902   ROM_REGION( 0x080000, REGION_GFX1, ROMREGION_DISPOSE ) /* Sprites */
2903   ROM_LOAD( "lohtb14.11",  0x00000, 0x10000, CRC(df5ac5ee) SHA1(5b45417ada402047d97dfb6cee6545686ad26e37) )
2904   ROM_LOAD( "lohtb15.12",  0x20000, 0x10000, CRC(45220b01) SHA1(83715cf155f91c82067d69f14b3b01ed77777b7d) )
2905   ROM_LOAD( "lohtb16.13",  0x40000, 0x10000, CRC(25b85cfc) SHA1(c7a9962165379193dc6553ed1f977795a79e0f78) )
2906   ROM_LOAD( "lohtb17.14",  0x60000, 0x10000, CRC(763fa4ec) SHA1(2d72b1b41f24ae299fde23869942c0b6bbb82363) )
2907   ROM_LOAD( "lohtb18.15",  0x10000, 0x10000, CRC(d7ecf849) SHA1(ab86a88eae21e054d4e8a740a60c7c6c198232d4) )
2908   ROM_LOAD( "lohtb19.16",  0x30000, 0x10000, CRC(35d1a808) SHA1(9378ff000104ecfb842b3b884197be82c43a01b4))
2909   ROM_LOAD( "lohtb20.17",  0x50000, 0x10000, CRC(464d8579) SHA1(b5981f4865ee5439f0e330091927e6d97d29933f) )
2910   ROM_LOAD( "lohtb21.18",  0x70000, 0x10000, CRC(a73568c7) SHA1(8fe1867256708cc1ed76d1bed5566b1852b47c40) )
2911
2912   ROM_REGION( 0x040000, REGION_GFX2, ROMREGION_INVERT|ROMREGION_DISPOSE ) /* tiles #1 */
2913   ROM_LOAD( "lohtb13.10",  0x00000, 0x10000, CRC(359f17d4) SHA1(2875ba48395e7faa1a58404475be936dcca45ed1) )
2914   ROM_LOAD( "lohtb11.08",  0x10000, 0x10000, CRC(73391e8a) SHA1(53ca89b8a10895f817ecdb9fa5eef462edb94ae6) )
2915   ROM_LOAD( "lohtb09.06",  0x20000, 0x10000, CRC(7096d390) SHA1(f4a16bf8aef7a1a65619ab022cbdb67d2f191888) )
2916   ROM_LOAD( "lohtb07.04",  0x30000, 0x10000, CRC(71a27b81) SHA1(d8fe72d15bbcd5b170d1123d8f4c58874cefdca3) )
2917
2918   ROM_REGION( 0x040000, REGION_GFX3, ROMREGION_INVERT|ROMREGION_DISPOSE ) /* tiles #2 */
2919   ROM_LOAD( "lohtb12.09",  0x00000, 0x10000, CRC(4d5e9b53) SHA1(3e3977bab7a66ed0171afcd555d181960e338749) )
2920   ROM_LOAD( "lohtb10.07",  0x10000, 0x10000, CRC(4f75a26a) SHA1(79c09a1ad3a6f9cfbd07cb527bbd89d2478ce582) )
2921   ROM_LOAD( "lohtb08.05",  0x20000, 0x10000, CRC(34854262) SHA1(37436c12579fb41d22a1596b495f065959c14a26) )
2922   ROM_LOAD( "lohtb06.03",  0x30000, 0x10000, CRC(f923183c) SHA1(a6b578191864aefa81e0cad3ba12a2ca491c91cf) )
2923
2924   ROM_REGION( 0x10000, REGION_SOUND1, ROMREGION_ERASEFF )   /* -- no sample roms on bootleg, included with z80 code */
2925ROM_END
2926
2927
2928ROM_START( lohtb2 )
2929   ROM_REGION( 0x100000, REGION_CPU1, 0 )
2930   ROM_LOAD16_BYTE( "loht-a2.bin", 0x00001, 0x10000, CRC(ccc90e54) SHA1(860da001d9b0782adc25cfc3b453383225253d9e) )
2931   ROM_LOAD16_BYTE( "loht-a3.bin", 0x20001, 0x10000, CRC(ff8a98de) SHA1(ccb8275241bea81abc01dc36e62557712c1b5a8c) )
2932   ROM_LOAD16_BYTE( "loht-a10.bin", 0x00000, 0x10000, CRC(3aa06730) SHA1(483b135f8ee0fc54b1953c7c28e909a88aa2fa2e) )
2933   ROM_LOAD16_BYTE( "loht-a11.bin", 0x20000, 0x10000, CRC(eab1d7bc) SHA1(ec50fe89f05ae46e91b9f2f3d4e4383aa764e71d) )
2934
2935   ROM_LOAD16_BYTE( "loht-a5.bin",  0x40001, 0x10000, CRC(79e007ec) SHA1(b2e4cc4a47f5f127ba9a1a00eaaf067464314ea0) )
2936   ROM_RELOAD(                      0xc0001, 0x10000 )
2937   ROM_LOAD16_BYTE( "loht-a4.bin",  0x60001, 0x10000, CRC(254ea4d5) SHA1(07277bbe2ea6678f0de1f28e40be794880b3faff) )
2938   ROM_RELOAD(                      0xe0001, 0x10000 )
2939   ROM_LOAD16_BYTE( "loht-a13.bin", 0x40000, 0x10000, CRC(b951346e) SHA1(82fa3c4a09a86b74b98c31aaea5c0629ddff83a0) )
2940   ROM_RELOAD(                      0xc0000, 0x10000 )
2941   ROM_LOAD16_BYTE( "loht-a12.bin", 0x60000, 0x10000, CRC(cfb0390d) SHA1(4acc61a51a7ae681bd8d835e2644b44c4d6d7bcb) )
2942   ROM_RELOAD(                      0xe0000, 0x10000 )
2943
2944   ROM_REGION( 0x10000, REGION_CPU3, 0 )
2945   ROM_LOAD( "loht-a26.bin",  0x00000, 0x2000, CRC(ac901e17) SHA1(70a73288d594c78ad2aca78ce55a699cb040bede) ) // unprotected??
2946
2947   ROM_REGION( 0x080000, REGION_GFX1, ROMREGION_DISPOSE )
2948   ROM_LOAD( "loht-a16.bin",  0x00000, 0x10000, CRC(df5ac5ee) SHA1(5b45417ada402047d97dfb6cee6545686ad26e37) )
2949   ROM_LOAD( "loht-a17.bin",  0x10000, 0x10000, CRC(d7ecf849) SHA1(ab86a88eae21e054d4e8a740a60c7c6c198232d4) )
2950   ROM_LOAD( "loht-a8.bin",   0x20000, 0x10000, CRC(45220b01) SHA1(83715cf155f91c82067d69f14b3b01ed77777b7d) )
2951   ROM_LOAD( "loht-a9.bin",   0x30000, 0x10000, CRC(4af9bb3c) SHA1(04f66caae5b3ae985451002293ad8f609a8d9377) )
2952   ROM_LOAD( "loht-a14.bin",  0x40000, 0x10000, CRC(25b85cfc) SHA1(c7a9962165379193dc6553ed1f977795a79e0f78) )
2953   ROM_LOAD( "loht-a15.bin",  0x50000, 0x10000, CRC(464d8579) SHA1(b5981f4865ee5439f0e330091927e6d97d29933f) )
2954   ROM_LOAD( "loht-a6.bin",   0x60000, 0x10000, CRC(763fa4ec) SHA1(2d72b1b41f24ae299fde23869942c0b6bbb82363) )
2955   ROM_LOAD( "loht-a7.bin",   0x70000, 0x10000, CRC(a73568c7) SHA1(8fe1867256708cc1ed76d1bed5566b1852b47c40) )
2956
2957   ROM_REGION( 0x040000, REGION_GFX2, ROMREGION_DISPOSE )
2958   ROM_LOAD( "loht-a19.bin",  0x00000, 0x10000, CRC(3ca3e771) SHA1(be052e01c5429ee89057c9d408794f2c7744047c) )   /* tiles #1 */
2959//  ROM_LOAD( "loht-a20.bin",  0x10000, 0x10000, BAD_DUMP CRC(db2e3d77) SHA1(3f0758f74490b084321d8b2da29525dd1f19da09) )
2960   ROM_LOAD( "loht-a20.bin",  0x10000, 0x10000, CRC(7a05ee2f) SHA1(7d1ca5db9a5a85610129e3bc6c640ade036fe7f9) )
2961   ROM_LOAD( "loht-a18.bin",  0x20000, 0x10000, CRC(79aa2335) SHA1(6b70c79d800a7b755aa7c9a368c4ea74029aaa1e) )
2962   ROM_LOAD( "loht-a21.bin",  0x30000, 0x10000, CRC(789e8b24) SHA1(e957cd25c3c155ca295ab1aea03d610f91562cfb) )
2963
2964   ROM_REGION( 0x040000, REGION_GFX3, ROMREGION_DISPOSE )
2965   ROM_LOAD( "loht-a24.bin",  0x00000, 0x10000, CRC(44626bf6) SHA1(571ef74d42d30a272ff0fb33f830652b4a4bad29) )   /* tiles #2 */
2966   ROM_LOAD( "loht-a25.bin",  0x10000, 0x10000, CRC(464952cf) SHA1(6b99360b6ba1ed5a72c257f51291f9f7a1ddf363) )
2967   ROM_LOAD( "loht-a23.bin",  0x20000, 0x10000, CRC(3db9b2c7) SHA1(02a318ffc459c494b7f40827eff5f89b41ac0426) )
2968   ROM_LOAD( "loht-a22.bin",  0x30000, 0x10000, CRC(f01fe899) SHA1(c5ab967b7af55a757638bcdc9975f4b15064022d) )
2969
2970   ROM_REGION( 0x10000, REGION_SOUND1, 0 )   /* samples */
2971   ROM_LOAD( "loht-a1.bin",  0x00000, 0x10000, CRC(3ed51d1f) SHA1(84f3aa17d640df91387e5f1f5b5971cf8dcd4e17) )
2972ROM_END
2973
2974
27022975ROM_START( xmultipl )
27032976   ROM_REGION( 0x100000, REGION_CPU1, 0 )
27042977   ROM_LOAD16_BYTE( "ch3.h3",       0x00001, 0x20000, CRC(20685021) SHA1(92f4216320bf525045223b9454fb5bb224c536d8) )
r1070r1071
27082981   ROM_LOAD16_BYTE( "cl0.l0",       0x40000, 0x10000, CRC(06a9e213) SHA1(9831c110814642703d6e71d49848d854095b7d3a) )
27092982   ROM_RELOAD(                      0xe0000, 0x10000 )
27102983
2984   ROM_REGION( 0x10000, REGION_CPU3, 0 )
2985   ROM_LOAD( "xmultipl_i8751.mcu",  0x00000, 0x10000, NO_DUMP ) // read protected
2986
27112987   ROM_REGION( 0x100000, REGION_GFX1, ROMREGION_DISPOSE )
27122988   ROM_LOAD( "t44.00",       0x00000, 0x20000, CRC(db45186e) SHA1(8c8edeb4b7e6b0516f2597823dc27eba9c5d9528) )   /* sprites */
27132989   ROM_LOAD( "t45.01",       0x20000, 0x20000, CRC(4d0764d4) SHA1(4942333336a110b033f16ac1afa06ffef7b2dad6) )
r1070r1071
27713047   ROM_LOAD16_BYTE( "db_c-l0.rom",  0x60000, 0x10000, CRC(ed0f5e06) SHA1(9030840b15e83c18d59c884ed08c93c05fa70c5b) )
27723048   ROM_RELOAD(                      0xe0000, 0x10000 )
27733049
3050   ROM_REGION( 0x10000, REGION_CPU3, 0 )
3051   ROM_LOAD( "dbreed72_i8751.mcu",  0x00000, 0x10000, NO_DUMP ) // read protected
3052
27743053   ROM_REGION( 0x080000, REGION_GFX1, ROMREGION_DISPOSE )
27753054   ROM_LOAD( "db_k800m.00", 0x00000, 0x20000, CRC(c027a8cf) SHA1(534dc416b8f5587168c7f644d3f9438c8a190491) )   /* sprites */
27763055   ROM_LOAD( "db_k801m.10", 0x20000, 0x20000, CRC(093faf33) SHA1(2704f644cdce87daf975984f143b1d55ba731c3f) )
r1070r1071
29843263   ROM_LOAD16_BYTE( "ge72-l3.bin",  0x60000, 0x10000, CRC(23d303a5) SHA1(b62010f34d71afb590deae458493454f9af38f7c) )
29853264   ROM_RELOAD(                      0xe0000, 0x10000 )
29863265
3266   ROM_REGION( 0x10000, REGION_CPU3, 0 )
3267   ROM_LOAD( "dkgenm72_i8751.mcu",  0x00000, 0x10000, NO_DUMP ) // read protected
3268
29873269   ROM_REGION( 0x080000, REGION_GFX1, ROMREGION_DISPOSE )
29883270   ROM_LOAD( "hh_00.rom",    0x00000, 0x20000, CRC(ec5127ef) SHA1(014ac8ad7b19cd9b475b72a0f42a4991119501c4) )   /* sprites */
29893271   ROM_LOAD( "hh_10.rom",    0x20000, 0x20000, CRC(def65294) SHA1(23f5d99fa9f604fde37cb52113bff233d9be1d25) )
r1070r1071
30993381   ROM_LOAD16_BYTE( "ad-c-l3.bin",  0x40000, 0x20000, CRC(9dd343f7) SHA1(9f499936b6d3807aa5b5c18e9811c73c9a2c99f9) )
31003382   ROM_RELOAD(                      0xc0000, 0x20000 )
31013383
3384   ROM_REGION( 0x10000, REGION_CPU3, 0 )
3385   ROM_LOAD( "airduel_i8751.mcu",  0x00000, 0x10000, NO_DUMP ) // read protected
3386
31023387   ROM_REGION( 0x080000, REGION_GFX1, ROMREGION_DISPOSE )
31033388   ROM_LOAD( "ad-00.bin",    0x00000, 0x20000, CRC(2f0d599b) SHA1(a966f806b5e25bb98cc63c46c49e0e676a62afcf) )   /* sprites */
31043389   ROM_LOAD( "ad-10.bin",    0x20000, 0x20000, CRC(9865856b) SHA1(b18a06899ae29d45e2351594df544220f3f4485a) )
r1070r1071
32233508GAME( 1988, nspiritj, nspirit,  m72,      nspirit,  nspiritj, ROT0,   "Irem", "Saigo no Nindou (Japan)", GAME_NO_COCKTAIL )
32243509GAME( 1988, imgfight, 0,        m72,      imgfight, imgfight, ROT270, "Irem", "Image Fight (Japan)", 0 )
32253510GAME( 1989, loht,     0,        m72,      loht,     loht,     ROT0,   "Irem", "Legend of Hero Tonma", GAME_NO_COCKTAIL )
3511GAME( 1989, lohtj,    loht,     m72,      loht,     loht,     ROT0,   "Irem", "Legend of Hero Tonma (Japan)", GAME_NO_COCKTAIL )
3512GAME( 1989, lohtb,    loht,     m72,      loht,     0,        ROT0,   "Irem", "Legend of Hero Tonma (bootleg)", GAME_NOT_WORKING| GAME_NO_COCKTAIL )
3513GAME( 1989, lohtb2,   loht,     m72_8751, loht,     loht_mcu, ROT0,   "Irem", "Legend of Hero Tonma (bootleg, set 2)", GAME_NO_COCKTAIL )
32263514GAME( 1989, xmultipl, 0,        xmultipl, xmultipl, xmultipl, ROT0,   "Irem", "X Multiply (Japan)", GAME_NO_COCKTAIL )
32273515GAME( 1989, dbreed,   0,        dbreed,   dbreed,   0,        ROT0,   "Irem", "Dragon Breed (M81 pcb version)", GAME_NO_COCKTAIL )
32283516GAME( 1989, dbreed72, dbreed,   dbreed72, dbreed,   dbreed72, ROT0,   "Irem", "Dragon Breed (M72 pcb version)", GAME_NO_COCKTAIL )
src/mame/drivers/igs_180.c
r1070r1071
22/* also see iqblock.c and tarzan.c */
33
44#include "driver.h"
5#include "cpu/z180/z180.h"
56#include "sound/2413intf.h"
67#include "sound/okim6295.h"
78
9static UINT8 *fg_videoram;
10static tilemap *fg_tilemap;
11
12static TILE_GET_INFO( get_fg_tile_info )
13{
14   int code = fg_videoram[tile_index*4+0] + ((fg_videoram[tile_index*4+1] & 0xf) << 8);
15   SET_TILE_INFO(1, code, 0, 0);
16}
17
818VIDEO_START(igs_180)
919{
20   fg_tilemap = tilemap_create(get_fg_tile_info,tilemap_scan_rows,TILEMAP_TYPE_PEN,8,8,64,32);
1021}
1122
1223VIDEO_UPDATE(igs_180)
1324{
25   tilemap_mark_all_tiles_dirty(fg_tilemap);
26   tilemap_draw(bitmap,cliprect,fg_tilemap,0,0);
27
1428   return 0;
1529}
1630
r1070r1071
1832INPUT_PORTS_END
1933
2034static ADDRESS_MAP_START( igs_180_map, ADDRESS_SPACE_PROGRAM, 8 )
21   AM_RANGE(0x00000, 0x07fff) AM_ROM
35   AM_RANGE(0x00000, 0x0dfff) AM_ROM
36   AM_RANGE(0x0e000, 0x0efff) AM_RAM
37   AM_RANGE(0x0f000, 0x0ffff) AM_RAM
38   AM_RANGE(0x10000, 0x3ffff) AM_ROM
2239ADDRESS_MAP_END
2340
41/*
42#define W(n) \
43    static WRITE8_HANDLER( w##n )\
44    {\
45        static int old = -1;\
46        if(data != old)\
47            printf("w"#n" = %02X\n",old=data);\
48    }\
49
50W(1)
51W(2)
52W(3)
53W(4)
54W(5)
55W(6)
56W(7)
57W(8)
58*/
59
60static WRITE8_HANDLER( nmi_ack_w )
61{
62//  cpunum_set_input_line(0, INPUT_LINE_NMI, CLEAR_LINE);
63}
64
65static WRITE8_HANDLER( irq0_ack_w )
66{
67//  cpunum_set_input_line(0, 0, CLEAR_LINE);
68}
69
70static READ8_HANDLER( ff_r )
71{
72   return 0xff;
73}
74
2475static ADDRESS_MAP_START( igs_180_portmap, ADDRESS_SPACE_IO, 8 )
76   AM_RANGE(0x0000, 0x003f) AM_RAM // internal regs
77
78   AM_RANGE(0x1000, 0x17ff) AM_RAM
79   AM_RANGE(0x1800, 0x19ff) AM_RAM
80   AM_RANGE(0x1a00, 0x1bff) AM_RAM
81   AM_RANGE(0x1c00, 0x1fff) AM_RAM
82   AM_RANGE(0x200a, 0x200a) AM_WRITENOP
83   AM_RANGE(0x2010, 0x2010) AM_READ(ff_r) AM_WRITENOP
84   AM_RANGE(0x2011, 0x2011) AM_READ(ff_r) AM_WRITENOP
85   AM_RANGE(0x2012, 0x2012) AM_READ(ff_r) AM_WRITENOP
86   AM_RANGE(0x2014, 0x2014) AM_WRITE(nmi_ack_w)
87   AM_RANGE(0x2015, 0x2015) AM_WRITE(irq0_ack_w)
88
89   AM_RANGE(0x4000, 0x4fff) AM_RAM AM_BASE(&fg_videoram)
90   AM_RANGE(0x5000, 0x5fff) AM_RAM
91   AM_RANGE(0x6000, 0x7fff) AM_RAM
92
93   AM_RANGE(0x8000, 0x8000) AM_WRITE(YM2413_register_port_0_w)
94   AM_RANGE(0x8001, 0x8001) AM_READ(ff_r) AM_WRITE(YM2413_data_port_0_w)
95   AM_RANGE(0xa000, 0xa000) AM_READ(ff_r)
96   AM_RANGE(0xb000, 0xb000) AM_WRITENOP
97   AM_RANGE(0xb001, 0xb001) AM_WRITENOP
2598ADDRESS_MAP_END
2699
100static const gfx_layout tilelayout =
101{
102   8,8,
103   RGN_FRAC(1,4), //?
104   6, //?
105   { 8, RGN_FRAC(0,4), RGN_FRAC(1,4)+8, RGN_FRAC(1,4), RGN_FRAC(2,4)+8, RGN_FRAC(2,4) }, //?
106   { 0, 1, 2, 3, 4, 5, 6, 7 },
107   { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
108   32*8
109};
110
111static GFXDECODE_START( igs_180 )
112   GFXDECODE_ENTRY( REGION_GFX1, 0, tilelayout, 0, 1 )
113   GFXDECODE_ENTRY( REGION_GFX2, 0, tilelayout, 0, 1 )
114GFXDECODE_END
115
116
117static INTERRUPT_GEN( igs_180_interrupt )
118{
119   if (cpu_getiloops() & 1)
120      cpunum_set_input_line(0, INPUT_LINE_NMI, PULSE_LINE);//ASSERT_LINE);    /* ???? */
121   else
122      cpunum_set_input_line(0, 0, HOLD_LINE);//ASSERT_LINE);          /* ???? */
123}
124
27125static MACHINE_DRIVER_START( igs_180 )
28126
29127   /* basic machine hardware */
30128   MDRV_CPU_ADD(Z180,16000000)   /* 16 MHz? */
31129   MDRV_CPU_PROGRAM_MAP(igs_180_map,0)
32130   MDRV_CPU_IO_MAP(igs_180_portmap,0)
33//  MDRV_CPU_VBLANK_INT(interrupt,1)
131   MDRV_CPU_VBLANK_INT(igs_180_interrupt,2)
132   //MDRV_CPU_VBLANK_INT(irq0_line_hold,1)
34133
35134   MDRV_SCREEN_REFRESH_RATE(60)
36135   MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION)
r1070r1071
40139   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
41140   MDRV_SCREEN_SIZE(64*8, 32*8)
42141   MDRV_SCREEN_VISIBLE_AREA(0*8, 64*8-1, 0*8, 32*8-1)
142   MDRV_GFXDECODE(igs_180)
43143   MDRV_PALETTE_LENGTH(1024)
44144
45145   MDRV_VIDEO_START(igs_180)
r1070r1071
52152
53153   MDRV_SOUND_ADD(OKIM6295, 16000000/16)
54154   MDRV_SOUND_CONFIG(okim6295_interface_region_1_pin7high)
55   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.47)
155   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5)
56156MACHINE_DRIVER_END
57157
58158
r1070r1071
101201  */
102202
103203ROM_START( iqblocka )
104   ROM_REGION( 0x80000, REGION_CPU1, 0 ) /* DIP28 Code */
204   ROM_REGION( 0x40000, REGION_CPU1, 0 ) /* DIP28 Code */
105205   ROM_LOAD( "v.u18", 0x00000, 0x40000, CRC(2e2b7d43) SHA1(cc73f4c8f9a6e2219ee04c9910725558a80b4eb2) )
106206
107   ROM_REGION( 0x80000, REGION_SOUND1, 0 ) /* Samples */
207   ROM_REGION( 0x40000, REGION_SOUND1, 0 ) /* Samples */
108208   ROM_LOAD( "speech.u17", 0x00000, 0x40000, CRC(d9e3d39f) SHA1(bec85d1ac2dfca77453cbca0e7dd53fee8fb438b) )
109209
110   ROM_REGION( 0x80000, REGION_GFX1, 0 )
210   ROM_REGION( 0x80000, REGION_GFX1, ROMREGION_INVERT )
111211   ROM_LOAD( "cg.u7",   0x000000, 0x080000, CRC(cb48a66e) SHA1(6d597193d1333a97957d5ceec8179a24bedfd928) )
212
213   ROM_REGION( 0x80000, REGION_GFX2, ROMREGION_INVERT )
112214   ROM_LOAD( "text.u8", 0x000000, 0x080000, CRC(48c4f4e6) SHA1(b1e1ca62cf6a99c11a5cc56705eef7e22a3b2740) )
113215ROM_END
114216
115217ROM_START( iqblockf )
116   ROM_REGION( 0x80000, REGION_CPU1, 0 ) /* DIP28 Code */
218   ROM_REGION( 0x40000, REGION_CPU1, 0 ) /* DIP28 Code */
117219   ROM_LOAD( "v113fr.u18", 0x00000, 0x40000, CRC(346c68af) SHA1(ceae4c0143c288dc9c1dd1e8a51f1e3371ffa439) )
118220
119   ROM_REGION( 0x80000, REGION_SOUND1, 0 ) /* Samples */
221   ROM_REGION( 0x40000, REGION_SOUND1, 0 ) /* Samples */
120222   ROM_LOAD( "sp.u17", 0x00000, 0x40000, CRC(71357845) SHA1(25f4f7aebdcc0706018f041d3696322df569b0a3) )
121223
122   ROM_REGION( 0x80000, REGION_GFX1, 0 )
224   ROM_REGION( 0x80000, REGION_GFX1, ROMREGION_INVERT )
123225   ROM_LOAD( "cg.u7",   0x000000, 0x080000, CRC(cb48a66e) SHA1(6d597193d1333a97957d5ceec8179a24bedfd928) )
226
227   ROM_REGION( 0x80000, REGION_GFX2, ROMREGION_INVERT )
124228   ROM_LOAD( "text.u8", 0x000000, 0x080000, CRC(48c4f4e6) SHA1(b1e1ca62cf6a99c11a5cc56705eef7e22a3b2740) )
125229ROM_END
126230
r1070r1071
173277*/
174278
175279ROM_START( tjsb )
176   ROM_REGION( 0x80000, REGION_CPU1, 0 ) /* DIP28 Code */
280   ROM_REGION( 0x40000, REGION_CPU1, 0 ) /* DIP28 Code */
177281   ROM_LOAD( "p0700.u16", 0x00000, 0x40000,CRC(1b2a50df) SHA1(95a272e624f727df9523667864f933118d9e633c) )
178282
179283   ROM_REGION( 0x80000, REGION_SOUND1, 0 ) /* Samples */
180284   ROM_LOAD( "s0703.u15", 0x00000, 0x80000,  CRC(c6f94d29) SHA1(ec413580240711fc4977dd3c96c288501aa7ef6c) )
181285
182   ROM_REGION( 0x200000, REGION_GFX1, 0 )
286   ROM_REGION( 0x200000, REGION_GFX1, ROMREGION_INVERT )
183287   ROM_LOAD( "a0701.u3", 0x000000, 0x200000, CRC(aa182140) SHA1(37c2053386c183ff726ba417d13f2063cf9a22df) )
288
289   ROM_REGION( 0x80000, REGION_GFX2, ROMREGION_INVERT )
184290   ROM_LOAD( "text.u6", 0x000000, 0x080000,  CRC(3be886b8) SHA1(15b3624ed076640c1828d065b01306a8656f5a9b) )
185291ROM_END
186292
293static void decrypt_program_rom(int mask, int a7, int a6, int a5, int a4, int a3, int a2, int a1, int a0)
294{
295   int length = memory_region_length(REGION_CPU1);
296   UINT8 *rom = memory_region(REGION_CPU1);
297   UINT8 *tmp = auto_malloc(length);
298   int i;
187299
188 GAME( 1996, iqblocka, iqblock, igs_180, igs_180, 0, ROT0, "IGS", "IQ-Block (set 2)", GAME_NOT_WORKING )
189 GAME( 1996, iqblockf, iqblock, igs_180, igs_180, 0, ROT0, "IGS", "IQ-Block (set 3, French?)", GAME_NOT_WORKING )
190 GAME( 1997, tjsb,     0,       igs_180, igs_180, 0, ROT0, "IGS", "Mahjong Tian Jiang Shen Bing", GAME_NOT_WORKING )
300   /* decrypt the program ROM */
301
302   /* XOR layer */
303   for (i = 0;i < length;i++)
304   {
305      if(i & 0x2000)
306      {
307         if((i & mask) == mask)
308            rom[i] ^= 0x01;
309      }
310      else
311      {
312         if(i & 0x0100)
313         {
314            if((i & mask) == mask)
315               rom[i] ^= 0x01;
316         }
317         else
318         {
319            if(i & 0x0080)
320            {
321               if((i & mask) == mask)
322                  rom[i] ^= 0x01;
323            }
324            else
325            {
326               if((i & mask) != mask)
327                  rom[i] ^= 0x01;
328            }
329         }
330      }
331   }
332
333   memcpy(tmp,rom,length);
334
335   /* address line swap */
336   for (i = 0;i < length;i++)
337   {
338      int addr = (i & ~0xff) | BITSWAP8(i,a7,a6,a5,a4,a3,a2,a1,a0);
339      rom[i] = tmp[addr];
340   }
341}
342
343static DRIVER_INIT( iqblock )
344{
345
346   decrypt_program_rom(0x11, 7, 6, 5, 4, 3, 2, 1, 0);
347}
348
349static DRIVER_INIT( tjsb )
350{
351   decrypt_program_rom(0x05, 7, 6, 3, 2, 5, 4, 1, 0);
352}
353
354GAME( 1996, iqblocka, iqblock, igs_180, igs_180, iqblock, ROT0, "IGS", "IQ-Block (V127M)", 0)//GAME_NOT_WORKING )
355GAME( 1996, iqblockf, iqblock, igs_180, igs_180, iqblock, ROT0, "IGS", "IQ-Block (V113FR)", 0)//GAME_NOT_WORKING )
356GAME( 1997, tjsb,     0,       igs_180, igs_180, tjsb,    ROT0, "IGS", "Mahjong Tian Jiang Shen Bing", 0)//GAME_NOT_WORKING )
src/mame/drivers/segae.c
r1070r1071
299299#include "sound/sn76496.h"
300300#include "machine/mc8123.h"
301301#include "machine/segacrpt.h"
302#include "segae.h"
302303
303304
304305//static UINT8* sms_rom;
src/mame/drivers/segae.h
r1070r1071
11/* System E stuff */
22
3#include "driver.h"
4
53extern VIDEO_UPDATE(megatech_bios);
64extern VIDEO_UPDATE(megatech_md_sms);
75extern DRIVER_INIT( megatech_bios );
src/mame/drivers/2mindril.c
r1070r1071
8383
8484   for (i=0; i<256; i++)
8585   {
86      decodechar(Machine->gfx[1],i,(UINT8*)&charram[0],Machine->drv->gfxdecodeinfo[1].gfxlayout);
86      decodechar(machine->gfx[1],i,(UINT8*)&charram[0],machine->drv->gfxdecodeinfo[1].gfxlayout);
8787   }
8888
8989   DRAW_MAP(map1ram,0)
src/mame/drivers/superqix.c
r1070r1071
11241124   ROM_LOAD( "b03-05",       0x00000, 0x10000, CRC(df326540) SHA1(1fe025edcd38202e24c4e1005f478b6a88533453) )
11251125ROM_END
11261126
1127ROM_START( sqixu )
1128   ROM_REGION( 0x20000, REGION_CPU1, 0 )
1129   ROM_LOAD( "b03-06.f3",     0x00000, 0x08000, CRC(4f59f7af) SHA1(6ea627ea8505cf8d1a5a1350258180c61fbd1ed9) )
1130   ROM_LOAD( "b03-07.h3",     0x10000, 0x10000, CRC(4c417d4a) SHA1(de46551da1b27312dca40240a210e77595cf9dbd) )
1131
1132   ROM_REGION( 0x1000, REGION_CPU2, 0 )   /* I8751 code */
1133   ROM_LOAD( "b03-08",     0x00000, 0x1000, BAD_DUMP CRC(8be4d2a8) SHA1(a0c72cd87b2cddc67070b0a533fca111dbb9a984) )   // from sqixa
1134
1135   ROM_REGION( 0x08000, REGION_GFX1, ROMREGION_DISPOSE )
1136   ROM_LOAD( "b03-04",       0x00000, 0x08000, CRC(f815ef45) SHA1(4189d455b6ccf3ae922d410fb624c4665203febf) )
1137
1138   ROM_REGION( 0x20000, REGION_GFX2, ROMREGION_DISPOSE )
1139   ROM_LOAD( "b03-03",       0x00000, 0x10000, CRC(6e8b6a67) SHA1(c71117cc880a124c46397c446d1edc1cbf681200) )
1140   ROM_LOAD( "b03-06",       0x10000, 0x10000, CRC(38154517) SHA1(703ad4cfe54a4786c67aedcca5998b57f39fd857) )
1141
1142   ROM_REGION( 0x10000, REGION_GFX3, ROMREGION_DISPOSE )
1143   ROM_LOAD( "b03-09.t8",    0x00000, 0x10000, CRC(69d2a84a) SHA1(b461d8a01f73c6aaa4aac85602c688c111bdca5d) )
1144ROM_END
1145
11271146/* this was probably a bootleg */
11281147ROM_START( sqixa )
11291148   ROM_REGION( 0x20000, REGION_CPU1, 0 )
r1070r1071
12801299GAME( 1987, hotsmash, 0,        hotsmash, hotsmash, hotsmash, ROT90, "Taito", "Vs. Hot Smash", 0 )
12811300GAME( 1987, sqix,     0,        sqix,     superqix, sqix,     ROT90, "Taito", "Super Qix (set 1)", 0 )
12821301GAME( 1987, sqixa,    sqix,     sqix,     superqix, sqixa,    ROT90, "Taito", "Super Qix (set 2)", 0 )
1302GAME( 1987, sqixu,    sqix,     sqix,     superqix, sqix,     ROT90, "Taito (Romstar License)", "Super Qix (US)", GAME_NOT_WORKING ) // different MCU?
12831303GAME( 1987, sqixbl,   sqix,     sqixbl,   superqix, 0,        ROT90, "bootleg", "Super Qix (bootleg)", 0 )
12841304GAME( 1994, perestro, 0,        sqixbl,   superqix, perestro, ROT90, "Promat", "Perestroika Girls", 0 )
12851305GAME( 1993, perestrf, perestro, sqixbl,   superqix, perestro, ROT90, "Promat (Fuuki license)", "Perestroika Girls (Fuuki license)", 0 )
src/mame/drivers/looping.c
r1070r1071
163163
164164static TILE_GET_INFO( get_tile_info )
165165{
166   looping_state *state = Machine->driver_data;
166   looping_state *state = machine->driver_data;
167167   int tile_number = state->videoram[tile_index];
168168   int color = state->colorram[(tile_index & 0x1f) * 2 + 1] & 0x07;
169169   SET_TILE_INFO(0, tile_number, color, 0);
src/mame/drivers/segas16a.c
r1070r1071
26472647   ROM_LOAD( "epr11268.1", 0x0000, 0x8000, CRC(6d7966da) SHA1(90f55a99f784c21d7c135e630f4e8b1d4d043d66) )
26482648ROM_END
26492649
2650/* Shinobi bootleg by 'Star' (decrypted version on original HW?, has the 7751 samples etc.) */
2651ROM_START( shinobls )
2652   ROM_REGION( 0x040000, REGION_CPU1, 0 ) /* 68000 code */
2653   ROM_LOAD16_BYTE( "b3", 0x000000, 0x10000, CRC(38e59646) SHA1(6a13015a93260ab99811b95950bb122eade01c27) )
2654   ROM_LOAD16_BYTE( "b1", 0x000001, 0x10000, CRC(8529d192) SHA1(202b912d20a2d82abe055b4a5e8c509ab7d69ff8) )
2655   ROM_LOAD16_BYTE( "b4", 0x020000, 0x10000, CRC(a2a620bd) SHA1(f8b135ce14d6c5eac5e40ddfd5ad2f1e6f2bc7a6) )
2656   ROM_LOAD16_BYTE( "b2", 0x020001, 0x10000, CRC(a3ceda52) SHA1(97a1c52a162fb1d43b3f8f16613b70ce582a8d26) )
2657
2658   ROM_REGION( 0x30000, REGION_GFX1, ROMREGION_DISPOSE ) /* tiles */
2659   ROM_LOAD( "b5", 0x00000, 0x10000, CRC(46627e7d) SHA1(66bb5b22a2100e7b9df303007a837bc2d52cf7ba) )
2660   ROM_LOAD( "b6", 0x10000, 0x10000, CRC(87d0f321) SHA1(885b38eaff2dcaeab4eeaa20cc8a2885d520abd6) )
2661   ROM_LOAD( "b7", 0x20000, 0x10000, CRC(efb4af87) SHA1(0b8a905023e1bc808fd2b1c3cfa3778cde79e659) )
2662
2663   ROM_REGION16_BE( 0x080000, REGION_GFX2, 0 ) /* sprites */
2664   ROM_LOAD16_BYTE( "b10", 0x00001, 0x08000, CRC(611f413a) SHA1(180f83216e2dfbfd77b0fb3be83c3042954d12df) )
2665   ROM_CONTINUE(           0x40001, 0x08000 )
2666   ROM_LOAD16_BYTE( "b14", 0x00000, 0x08000, CRC(5eb00fc1) SHA1(97e02eee74f61fabcad2a9e24f1868cafaac1d51) )
2667   ROM_CONTINUE(           0x40000, 0x08000 )
2668   ROM_LOAD16_BYTE( "b11", 0x10001, 0x08000, CRC(3c0797c0) SHA1(df18c7987281bd9379026c6cf7f96f6ae49fd7f9) )
2669   ROM_CONTINUE(           0x50001, 0x08000 )
2670   ROM_LOAD16_BYTE( "b15", 0x10000, 0x08000, CRC(25307ef8) SHA1(91ffbe436f80d583524ee113a8b7c0cf5d8ab286) )
2671   ROM_CONTINUE(           0x50000, 0x08000 )
2672   ROM_LOAD16_BYTE( "b12", 0x20001, 0x08000, CRC(c29ac34e) SHA1(b5e9b8c3233a7d6797f91531a0d9123febcf1660) )
2673   ROM_CONTINUE(           0x60001, 0x08000 )
2674   ROM_LOAD16_BYTE( "b16", 0x20000, 0x08000, CRC(04a437f8) SHA1(ea5fed64443236e3404fab243761e60e2e48c84c) )
2675   ROM_CONTINUE(           0x60000, 0x08000 )
2676   /* It's possible that the modifications to these roms are meant to stop the Sega logo from appearing,
2677       however, with the current system 16a emulation this doesn't happen, maybe it isn't actually running
2678       on a genuine Sega board? */
2679   ROM_LOAD16_BYTE( "b13", 0x30001, 0x08000, CRC(7e98bd36) SHA1(069c51478af7567e704fc9e25c9e327f02db171d) )
2680   ROM_CONTINUE(           0x70001, 0x08000 )
2681   ROM_LOAD16_BYTE( "b17", 0x30000, 0x08000, CRC(0315cf42) SHA1(2d129171aece883cb9c2805f894b3867ec98332b) )
2682   ROM_CONTINUE(           0x70000, 0x08000 )
2683
2684   ROM_REGION( 0x20000, REGION_CPU2, 0 ) /* sound CPU */
2685   ROM_LOAD( "b8", 0x0000, 0x8000, CRC(dd50b745) SHA1(52e1977569d3713ad864d607170c9a61cd059a65) )
2686
2687   ROM_REGION( 0x1000, REGION_CPU3, 0 )      /* 4k for 7751 onboard ROM */
2688   ROM_LOAD( "7751.bin",     0x0000, 0x0400, CRC(6a9534fc) SHA1(67ad94674db5c2aab75785668f610f6f4eccd158) ) /* 7751 - U34 */
2689
2690   ROM_REGION( 0x08000, REGION_SOUND1, 0 ) /* 7751 sound data */
2691   ROM_LOAD( "b9", 0x0000, 0x8000, CRC(6d7966da) SHA1(90f55a99f784c21d7c135e630f4e8b1d4d043d66) )
2692ROM_END
2693
26502694/**************************************************************************************************************************
26512695    Shinobi, Sega System 16A
26522696    CPU: FD1094 (317-0050)
r1070r1071
30933137GAME( 1987, sdi,      0,        system16a_no7751, sdi,      sdi,         ROT0,   "Sega",           "SDI - Strategic Defense Initiative (Europe, System 16A, FD1089B 317-0027)", 0 )
30943138GAME( 1987, shinobi,  0,        system16a,        shinobi,  generic_16a, ROT0,   "Sega",           "Shinobi (set 5, System 16A, unprotected)", 0 )
30953139GAME( 1987, shinobi1, shinobi,  system16a,        shinobi,  generic_16a, ROT0,   "Sega",           "Shinobi (set 1, System 16A, FD1094 317-0050)", 0 )
3140GAME( 1987, shinobls,  shinobi,  system16a,        shinobi,  generic_16a, ROT0,   "[Sega] (Star bootleg)", "Shinobi (Star bootleg, System 16A)", 0 )
30963141GAME( 1987, sjryuko1, sjryuko,  system16a,        sjryuko,  sjryukoa,    ROT0,   "White Board",    "Sukeban Jansi Ryuko (set 1, System 16A, FD1089B 317-5021)", 0 )
30973142GAME( 1988, tetris,   0,        system16a_no7751, tetris,   generic_16a, ROT0,   "Sega",           "Tetris (set 4, Japan, System 16A, FD1094 317-0093)", 0 )
30983143GAME( 1988, tetris3,  tetris,   system16a_no7751, tetris,   generic_16a, ROT0,   "Sega",           "Tetris (set 3, Japan, System 16A, FD1094 317-0093a)", 0 )
src/mame/drivers/segac2.c
r1070r1071
14151415   ROM_LOAD16_BYTE( "mpr15615.33",  0x100001, 0x080000, CRC(36a88bd4) SHA1(cc7f6a947d1b79bb86957c43035b53d6d2bcfa28) )
14161416ROM_END
14171417
1418ROM_START( tantrbl3 ) /* Tant-R (Puzzle & Action) (Alt Bootleg Running on C Board?, No Samples) */
1419   ROM_REGION( 0x200000, REGION_CPU1, 0 )
1420   ROM_LOAD16_BYTE( "2.u29",  0x000000, 0x080000, CRC(faecb7b1) SHA1(ddca61996dbd0d66e9ecc04647e61a6d0af25807) )
1421   ROM_LOAD16_BYTE( "1.u28",  0x000001, 0x080000, CRC(3304556d) SHA1(586265c846bf6404dcb33404e961bf0733e24bf5) )
1422   ROM_LOAD16_BYTE( "4.u31",  0x100000, 0x080000, CRC(17b80202) SHA1(f47bf2aa0c5972647438619b8453c7dede5c422f) )
1423   ROM_LOAD16_BYTE( "3.u30",  0x100001, 0x080000, CRC(36a88bd4) SHA1(cc7f6a947d1b79bb86957c43035b53d6d2bcfa28) )
1424ROM_END
1425
14181426ROM_START( ichirjbl ) /* Ichident-R (Puzzle & Action 2) (Bootleg Running on C Board?, No Samples) */
14191427   ROM_REGION( 0x200000, REGION_CPU1, 0 )
14201428   ROM_LOAD16_BYTE( "27c4000.2",0x000000, 0x080000, CRC(5a194f44) SHA1(67a4d21b91704f8c2210b5106e82e22ba3366f4c) )
r1070r1071
21752183GAME( 1993, tantrkor, tantr,    segac2,   ichir,    tantrkor, ROT0, "Sega",                   "Puzzle & Action: Tant-R (Korea)", 0 )
21762184GAME( 1992, tantrbl,  tantr,    segac2,   ichir,    c2boot,   ROT0, "bootleg",                "Puzzle & Action: Tant-R (Japan) (bootleg set 1)", 0 )
21772185GAME( 1994, tantrbl2, tantr,    segac,    ichir,    tantr,    ROT0, "bootleg",                "Puzzle & Action: Tant-R (Japan) (bootleg set 2)", 0 ) // Common bootleg in Europe, C board, no samples
2186GAME( 1994, tantrbl3, tantr,    segac,    ichir,    tantr,    ROT0, "bootleg",                "Puzzle & Action: Tant-R (Japan) (bootleg set 3)", 0 ) // Common bootleg in Europe, C board, no samples
21782187GAME( 1992, puyo,     0,        segac2,   puyo,     puyo,     ROT0, "Sega / Compile",         "Puyo Puyo (World)", 0 )
21792188GAME( 1992, puyobl,   puyo,     segac2,   puyo,     puyo,     ROT0, "bootleg",                "Puyo Puyo (World, bootleg)", 0 )
21802189GAME( 1992, puyoj,    puyo,     segac2,   puyo,     puyo,     ROT0, "Sega / Compile",         "Puyo Puyo (Japan)", 0 )
src/mame/drivers/ddragon.c
r1070r1071
524524   AM_RANGE(0xc000, 0xffff) AM_WRITE(MWA8_ROM)
525525ADDRESS_MAP_END
526526
527static ADDRESS_MAP_START( ddragnba_sub_readmem, ADDRESS_SPACE_PROGRAM, 8 )
528   AM_RANGE(0x0000, 0x0fff) AM_READ(MRA8_RAM)
529   AM_RANGE(0x8000, 0x8fff) AM_READ(ddragon_spriteram_r)
530   AM_RANGE(0xc000, 0xffff) AM_READ(MRA8_ROM)
531ADDRESS_MAP_END
532
533static ADDRESS_MAP_START( ddragnba_sub_writemem, ADDRESS_SPACE_PROGRAM, 8 )
534   AM_RANGE(0x0000, 0x0fff) AM_WRITE(MWA8_RAM)
535   AM_RANGE(0x8000, 0x8fff) AM_WRITE(ddragon_spriteram_w)
536   AM_RANGE(0xc000, 0xffff) AM_WRITE(MWA8_ROM)
537ADDRESS_MAP_END
538
539/* might not be 100% accurate, check bits written */
540static WRITE8_HANDLER( ddragnba_port_w )
541{
542   cpunum_set_input_line(0,M6809_IRQ_LINE,ASSERT_LINE);
543   cpunum_set_input_line(1,sprite_irq, CLEAR_LINE );
544}
545
546static ADDRESS_MAP_START( ddragnba_sub_writeport, ADDRESS_SPACE_IO, 8 )
547   AM_RANGE(0x0000, 0xffff) AM_WRITE(ddragnba_port_w)
548ADDRESS_MAP_END
549
550
551
527552static ADDRESS_MAP_START( sound_readmem, ADDRESS_SPACE_PROGRAM, 8 )
528553   AM_RANGE(0x0000, 0x0fff) AM_READ(MRA8_RAM)
529554   AM_RANGE(0x1000, 0x1000) AM_READ(soundlatch_r)
r1070r1071
11121137   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
11131138MACHINE_DRIVER_END
11141139
1140static MACHINE_DRIVER_START( ddragnba )
1141
1142   /* basic machine hardware */
1143    MDRV_CPU_ADD(HD6309, 3579545)   /* 3.579545 MHz */
1144   MDRV_CPU_PROGRAM_MAP(readmem,writemem)
1145   MDRV_CPU_VBLANK_INT(ddragon_interrupt,272)
1146
1147    MDRV_CPU_ADD(M6803, 12000000 / 3) /* 4 MHz */
1148   MDRV_CPU_PROGRAM_MAP(ddragnba_sub_readmem,ddragnba_sub_writemem)
1149   MDRV_CPU_IO_MAP(0,ddragnba_sub_writeport)
1150
1151    MDRV_CPU_ADD(HD6309, 3579545)
1152    /* audio CPU */   /* ? */
1153   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
1154
1155   MDRV_SCREEN_REFRESH_RATE(((12000000.0 / 256.0) / 3.0) / 272.0)
1156   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(0))
1157   MDRV_INTERLEAVE(100) /* heavy interleaving to sync up sprite<->main cpu's */
1158
1159   MDRV_MACHINE_START(ddragon)
1160   MDRV_MACHINE_RESET(ddragonb)
1161
1162   /* video hardware */
1163   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
1164   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1165   MDRV_SCREEN_SIZE(32*8, 32*8)
1166   MDRV_SCREEN_VISIBLE_AREA(1*8, 31*8-1, 2*8, 30*8-1)
1167   MDRV_GFXDECODE(ddragon)
1168   MDRV_PALETTE_LENGTH(384)
1169
1170   MDRV_VIDEO_START(ddragon)
1171   MDRV_VIDEO_UPDATE(ddragon)
1172
1173   /* sound hardware */
1174   MDRV_SPEAKER_STANDARD_MONO("mono")
1175
1176   MDRV_SOUND_ADD(YM2151, 3579545)
1177   MDRV_SOUND_CONFIG(ym2151_interface)
1178   MDRV_SOUND_ROUTE(0, "mono", 0.60)
1179   MDRV_SOUND_ROUTE(1, "mono", 0.60)
1180
1181   MDRV_SOUND_ADD(MSM5205, 384000)
1182   MDRV_SOUND_CONFIG(msm5205_interface)
1183   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
1184
1185   MDRV_SOUND_ADD(MSM5205, 384000)
1186   MDRV_SOUND_CONFIG(msm5205_interface)
1187   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
1188MACHINE_DRIVER_END
1189
1190
11151191static MACHINE_DRIVER_START( ddragon2 )
11161192
11171193   /* basic machine hardware */
r1070r1071
14441520   ROM_LOAD( "21j-l-0",      0x0100, 0x0200, CRC(46339529) SHA1(64f4c42a826d67b7cbaa8a23a45ebc4eb6248891) )   /* unknown */
14451521ROM_END
14461522
1523
1524ROM_START( ddragnba )
1525   ROM_REGION( 0x28000, REGION_CPU1, 0 )   /* 64k for code + bankswitched memory */
1526   ROM_LOAD( "5.bin",     0x08000, 0x08000, CRC(ae714964) SHA1(072522b97ca4edd099c6b48d7634354dc7088c53) )
1527   ROM_LOAD( "4.bin",     0x10000, 0x08000, CRC(48045762) SHA1(ca39eea71ca76627a98210ce9cc61457a58f16b9) ) /* banked at 0x4000-0x8000 */
1528   ROM_CONTINUE(0x20000,0x8000) /* banked at 0x4000-0x8000 */
1529   ROM_LOAD( "3.bin",     0x18000, 0x08000, CRC(dbf24897) SHA1(1504faaf07c541330cd43b72dc6846911dfd85a3) ) /* banked at 0x4000-0x8000 */
1530
1531   ROM_REGION( 0x10000, REGION_CPU2, 0 ) /* sprite cpu */
1532   ROM_LOAD( "2_32.bin",         0x0c000, 0x04000, CRC(67875473) SHA1(66405cb22d41d353335f037ce5aee69e4c6f05c4) ) /* 6803 instead of HD63701 */
1533
1534   ROM_REGION( 0x10000, REGION_CPU3, 0 ) /* audio cpu */
1535   ROM_LOAD( "6.bin",      0x08000, 0x08000, CRC(9efa95bb) SHA1(da997d9cc7b9e7b2c70a4b6d30db693086a6f7d8) )
1536
1537   ROM_REGION( 0x08000, REGION_GFX1, ROMREGION_DISPOSE )
1538   ROM_LOAD( "1.bin",        0x00000, 0x08000, CRC(7a8b8db4) SHA1(8368182234f9d4d763d4714fd7567a9e31b7ebeb) )   /* chars */
1539
1540   ROM_REGION( 0x80000, REGION_GFX2, ROMREGION_DISPOSE )
1541   ROM_LOAD( "21j-a",        0x00000, 0x10000, CRC(574face3) SHA1(481fe574cb79d0159a65ff7486cbc945d50538c5) )   /* sprites */
1542   ROM_LOAD( "21j-b",        0x10000, 0x10000, CRC(40507a76) SHA1(74581a4b6f48100bddf20f319903af2fe36f39fa) )
1543   ROM_LOAD( "21j-c",        0x20000, 0x10000, CRC(bb0bc76f) SHA1(37b2225e0593335f636c1e5fded9b21fdeab2f5a) )
1544   ROM_LOAD( "21j-d",        0x30000, 0x10000, CRC(cb4f231b) SHA1(9f2270f9ceedfe51c5e9a9bbb00d6f43dbc4a3ea) )
1545   ROM_LOAD( "21j-e",        0x40000, 0x10000, CRC(a0a0c261) SHA1(25c534d82bd237386d447d72feee8d9541a5ded4) )
1546   ROM_LOAD( "21j-f",        0x50000, 0x10000, CRC(6ba152f6) SHA1(a301ff809be0e1471f4ff8305b30c2fa4aa57fae) )
1547   ROM_LOAD( "21j-g",        0x60000, 0x10000, CRC(3220a0b6) SHA1(24a16ea509e9aff82b9ddd14935d61bb71acff84) )
1548   ROM_LOAD( "21j-h",        0x70000, 0x10000, CRC(65c7517d) SHA1(f177ba9c1c7cc75ff04d5591b9865ee364788f94) )
1549
1550   ROM_REGION( 0x40000, REGION_GFX3, ROMREGION_DISPOSE )
1551   ROM_LOAD( "21j-8",        0x00000, 0x10000, CRC(7c435887) SHA1(ecb76f2148fa9773426f05aac208eb3ac02747db) )   /* tiles */
1552   ROM_LOAD( "21j-9",        0x10000, 0x10000, CRC(c6640aed) SHA1(f156c337f48dfe4f7e9caee9a72c7ea3d53e3098) )
1553   ROM_LOAD( "21j-i",        0x20000, 0x10000, CRC(5effb0a0) SHA1(1f21acb15dad824e831ed9a42b3fde096bb31141) )
1554   ROM_LOAD( "21j-j",        0x30000, 0x10000, CRC(5fb42e7c) SHA1(7953316712c56c6f8ca6bba127319e24b618b646) )
1555
1556   ROM_REGION( 0x20000, REGION_SOUND1, 0 ) /* adpcm samples */
1557   ROM_LOAD( "8.bin",        0x00000, 0x10000, CRC(34755de3) SHA1(57c06d6ce9497901072fa50a92b6ed0d2d4d6528) )
1558   ROM_LOAD( "7.bin",        0x10000, 0x10000, CRC(f9311f72) SHA1(aa554ef020e04dc896e5495bcddc64e489d0ffff) )
1559
1560   ROM_REGION( 0x0300, REGION_PROMS, 0 )
1561   ROM_LOAD( "21j-k-0",      0x0000, 0x0100, CRC(fdb130a9) SHA1(4c4f214229b9fab2b5d69c745ec5428787b89e1f) )   /* unknown */
1562   ROM_LOAD( "21j-l-0",      0x0100, 0x0200, CRC(46339529) SHA1(64f4c42a826d67b7cbaa8a23a45ebc4eb6248891) )   /* unknown */
1563ROM_END
1564
14471565ROM_START( ddragon2 )
14481566   ROM_REGION( 0x28000, REGION_CPU1, 0 )
14491567   ROM_LOAD( "26a9-04.bin",  0x08000, 0x8000, CRC(f2cfc649) SHA1(d3f1e0bae02472914a940222e4f600170a91736d) )
r1070r1071
17791897GAME( 1987, ddragnw1, ddragon,  ddragon,  ddragon,  0, ROT0, "[Technos] (Taito license)", "Double Dragon (World Set 2)", 0 )
17801898GAME( 1987, ddragonu, ddragon,  ddragon,  ddragon,  0, ROT0, "[Technos] (Taito America license)", "Double Dragon (US Set 1)", 0 )
17811899GAME( 1987, ddragoua, ddragon,  ddragon,  ddragon,  0, ROT0, "[Technos] (Taito America license)", "Double Dragon (US Set 2)", 0 )
1782GAME( 1987, ddragonb, ddragon,  ddragonb, ddragon,  0, ROT0, "bootleg", "Double Dragon (bootleg)", 0 )
1900GAME( 1987, ddragonb, ddragon,  ddragonb, ddragon,  0, ROT0, "bootleg", "Double Dragon (bootleg with HD6903)", 0 ) // according to dump notes
1901GAME( 1987, ddragnba, ddragon,  ddragnba, ddragon,  0, ROT0, "bootleg", "Double Dragon (bootleg with M6803)", 0 )
1902
17831903GAME( 1988, ddragon2, 0,        ddragon2, ddragon2, 0, ROT0, "Technos", "Double Dragon II - The Revenge (World)", 0 )
17841904GAME( 1988, ddragn2u, ddragon2, ddragon2, ddragon2, 0, ROT0, "Technos", "Double Dragon II - The Revenge (US)", 0 )
17851905
src/mame/drivers/macrossp.c
r1070r1071
472472   PORT_MODIFY("DSW")
473473   PORT_DIPUNUSED_DIPLOC( 0x4000, 0x4000, "SW2:7" ) /* no Language dipswitch for this game */
474474
475   PORT_START
476   PORT_BIT( 0xffff, IP_ACTIVE_LOW, IPT_UNUSED ) /* Unknown use, but not dipswitches */
477
478475INPUT_PORTS_END
479476
480477/*** GFX DECODE **************************************************************/
src/mame/drivers/cabal.c
r1070r1071
6464
6565/******************************************************************************************/
6666
67// we should emulate the z80s, not simulate them
68#if 0
6769static struct cabalbl_adpcm_state
6870{
6971   struct adpcm_state adpcm;
r1070r1071
149151      }
150152   }
151153}
152
154#endif
153155static WRITE16_HANDLER( cabalbl_sndcmd_w )
154156{
155157   switch (offset)
r1070r1071
267269
268270/*********************************************************************/
269271
272
270273static READ8_HANDLER( cabalbl_snd_r )
271274{
272275   switch(offset){
r1070r1071
279282
280283static WRITE8_HANDLER( cabalbl_snd_w )
281284{
285#if 0
282286   switch( offset ){
283287      case 0x00: cabalbl_play_adpcm( 0, data ); break;
284288      case 0x02: cabalbl_play_adpcm( 1, data ); break;
285289     }
290#endif
286291}
287292
288293static ADDRESS_MAP_START( readmem_sound, ADDRESS_SPACE_PROGRAM, 8 )
r1070r1071
331336   AM_RANGE(0x8000, 0xffff) AM_WRITE(MWA8_ROM)
332337ADDRESS_MAP_END
333338
334/* ADPCM CPU (common) */
339/* the bootleg has 2x z80 sample players */
335340
336#if 0
337static ADDRESS_MAP_START( cabalbl_readmem_adpcm, ADDRESS_SPACE_PROGRAM, 8 )
338   AM_RANGE(0x0000, 0xffff) AM_READ(MRA8_ROM)
341READ8_HANDLER( cabalbl_talk1_port00_r )
342{
343   return mame_rand(Machine);
344}
345
346static ADDRESS_MAP_START( cabalbl_talk1_map, ADDRESS_SPACE_PROGRAM, 8 )
347   AM_RANGE(0x0000, 0xffff) AM_READWRITE(MRA8_ROM, MWA8_NOP)
339348ADDRESS_MAP_END
340static ADDRESS_MAP_START( cabalbl_writemem_adpcm, ADDRESS_SPACE_PROGRAM, 8 )
341   AM_RANGE(0x0000, 0xffff) AM_WRITE(MWA8_NOP)
349
350static ADDRESS_MAP_START( cabalbl_talk1_portmap, ADDRESS_SPACE_IO, 8 )
351   ADDRESS_MAP_FLAGS( AMEF_ABITS(8) )
352   AM_RANGE(0x00, 0x00) AM_READ(cabalbl_talk1_port00_r)
353   AM_RANGE(0x01, 0x01) AM_WRITE(MWA8_NOP) // DAC output?
342354ADDRESS_MAP_END
343#endif
344355
356READ8_HANDLER( cabalbl_talk2_port00_r )
357{
358   return mame_rand(Machine);
359}
345360
361static ADDRESS_MAP_START( cabalbl_talk2_map, ADDRESS_SPACE_PROGRAM, 8 )
362   AM_RANGE(0x0000, 0xffff) AM_READWRITE(MRA8_ROM, MWA8_NOP)
363ADDRESS_MAP_END
364
365static ADDRESS_MAP_START( cabalbl_talk2_portmap, ADDRESS_SPACE_IO, 8 )
366   ADDRESS_MAP_FLAGS( AMEF_ABITS(8) )
367   AM_RANGE(0x00, 0x00) AM_READ(cabalbl_talk2_port00_r)
368   AM_RANGE(0x01, 0x01) AM_WRITE(MWA8_NOP) // DAC output?
369ADDRESS_MAP_END
370
346371/***************************************************************************/
347372
348373#define CABALDSW\
r1070r1071
409434   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )\
410435   PORT_DIPSETTING(      0x8000, DEF_STR( On ) )
411436
412  INPUT_PORTS_START( cabal )
437INPUT_PORTS_START( cabalt )
438   CABALDSW
413439
414CABALDSW
415440   PORT_START_TAG("IN0")
416441     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
417442     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
r1070r1071
440465   PORT_BIT( 0x0fff, 0x0000, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(100) PORT_KEYDELTA(30) PORT_PLAYER(2)
441466INPUT_PORTS_END
442467
468
469
470INPUT_PORTS_START( cabalj )
471   CABALDSW
472
473   /* Since the Trackball version was produced first, and it doesn't use
474       the third button,  Pin 24 of the JAMMA connector ('JAMMA button 3')
475       has no trace on the pcb.  To work around this design issue the
476       manufacturer had to use pin 15 which is usually the test / service
477       button
478    */
479   PORT_START_TAG("IN0")
480     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
481     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
482     PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
483   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
484   PORT_BIT( 0x0ff0, IP_ACTIVE_LOW, IPT_UNUSED )
485   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2) /* the 3rd button connects to the service switch */
486   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
487   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_START2 )
488   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START1 )
489
490   PORT_START_TAG("IN1")
491   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_IMPULSE(4)   /* read through sound cpu */
492   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 ) PORT_IMPULSE(4)   /* read through sound cpu */
493   PORT_BIT( 0xfc, IP_ACTIVE_LOW, IPT_UNKNOWN )
494
495   /* The joystick version has a PCB marked "Joystick sub" containing a 74ls245. It plugs in the
496       sockets of the two D4701AC */
497   PORT_START_TAG("IN2")
498   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN )
499
500   PORT_START_TAG("IN3")
501   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN )
502
503   PORT_START_TAG("IN4")
504   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
505   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
506   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
507   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
508   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
509   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
510   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
511   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
512
513   PORT_START_TAG("IN5")
514     PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN )
515INPUT_PORTS_END
516
443517INPUT_PORTS_START( cabalbl )
444CABALDSW
518   CABALDSW
445519
446520   PORT_START_TAG("IN0")
447521   PORT_BIT( 0x00ff, IP_ACTIVE_LOW, IPT_UNKNOWN )
r1070r1071
471545   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 ) PORT_IMPULSE(4)   /* read through sound cpu */
472546INPUT_PORTS_END
473547
474
475
476548static const gfx_layout text_layout =
477549{
478550   8,8,
r1070r1071
535607
536608SEIBU_SOUND_SYSTEM_ADPCM_HARDWARE
537609
538static struct CustomSound_interface cabalbl_adpcm_interface =
539{
540   cabalbl_adpcm_start,
541   cabalbl_adpcm_stop
542};
543610
544611
545612static MACHINE_DRIVER_START( cabal )
r1070r1071
580647   MDRV_SOUND_CONFIG(adpcm_interface)
581648   MDRV_SOUND_ROUTE(ALL_OUTPUTS,"mono", 0.40)
582649
583
584650   MDRV_SOUND_ADD(CUSTOM, 8000)
585651   MDRV_SOUND_CONFIG(adpcm_interface)
586652   MDRV_SOUND_ROUTE(ALL_OUTPUTS,"mono", 0.40)
587653MACHINE_DRIVER_END
588654
655#if 0
656static struct CustomSound_interface cabalbl_adpcm_interface =
657{
658   cabalbl_adpcm_start,
659   cabalbl_adpcm_stop
660};
661#endif
662
663/* the bootleg has different sound hardware (2 extra Z80s for ADPCM playback) */
589664static MACHINE_DRIVER_START( cabalbl )
590665
591666   /* basic machine hardware */
r1070r1071
594669   MDRV_CPU_VBLANK_INT(irq1_line_hold,1)
595670
596671   MDRV_CPU_ADD(Z80, 4000000)
597   /* audio CPU */   /* 4 MHz */
598672   MDRV_CPU_PROGRAM_MAP(cabalbl_readmem_sound,cabalbl_writemem_sound)
599673
674   /* there are 2x z80s for the ADPCM */
675   MDRV_CPU_ADD(Z80, 4000000)
676   MDRV_CPU_PROGRAM_MAP(cabalbl_talk1_map,0)
677   MDRV_CPU_IO_MAP(cabalbl_talk1_portmap,0)
678   MDRV_CPU_VBLANK_INT(irq0_line_hold,10)
679
680   MDRV_CPU_ADD(Z80, 4000000)
681   MDRV_CPU_PROGRAM_MAP(cabalbl_talk2_map,0)
682   MDRV_CPU_IO_MAP(cabalbl_talk2_portmap,0)
683   MDRV_CPU_VBLANK_INT(irq0_line_hold,10)
684
685
600686   MDRV_SCREEN_REFRESH_RATE(60)
601687   MDRV_SCREEN_VBLANK_TIME(DEFAULT_REAL_60HZ_VBLANK_DURATION)
602688   MDRV_INTERLEAVE(10)
r1070r1071
621707   MDRV_SOUND_CONFIG(cabalbl_ym2151_interface)
622708   MDRV_SOUND_ROUTE(ALL_OUTPUTS,"mono", 0.80)
623709
624   MDRV_SOUND_ADD(CUSTOM, 8000)
625   MDRV_SOUND_CONFIG(cabalbl_adpcm_interface)
626   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)
710//  MDRV_SOUND_ADD(CUSTOM, 8000)
711//  MDRV_SOUND_CONFIG(cabalbl_adpcm_interface)
712//  MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)
627713
628   MDRV_SOUND_ADD(CUSTOM, 8000)
629   MDRV_SOUND_CONFIG(cabalbl_adpcm_interface)
630   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)
714//  MDRV_SOUND_ADD(CUSTOM, 8000)
715//  MDRV_SOUND_CONFIG(cabalbl_adpcm_interface)
716//  MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)
631717MACHINE_DRIVER_END
632718
633719ROM_START( cabal )
634720   ROM_REGION( 0x50000, REGION_CPU1, 0 )   /* 64k for cpu code */
635   ROM_LOAD16_BYTE( "13.bin",    0x00000, 0x10000, CRC(00abbe0c) SHA1(bacf17444abfb4f56248ff56e37b0aa2b1a3800d) )
636   ROM_LOAD16_BYTE( "11.bin",    0x00001, 0x10000, CRC(96d5e8af) SHA1(1d6da95ef96d9c02aea70791e1cb87b70097d5ed) )
637   ROM_LOAD16_BYTE( "12.bin",    0x20000, 0x10000, CRC(d763a47c) SHA1(146d8082a404b6eddaf2dc9ba41a997949c17f8a) )
638   ROM_LOAD16_BYTE( "10.bin",    0x20001, 0x10000, CRC(96d5e8af) SHA1(ed7d854f08e87db5ae6cf526eafa029dfd2bfb9f) )
721   ROM_LOAD16_BYTE( "13.7h",    0x00000, 0x10000, CRC(00abbe0c) SHA1(bacf17444abfb4f56248ff56e37b0aa2b1a3800d) )
722   ROM_LOAD16_BYTE( "11.6h",    0x00001, 0x10000, CRC(44736281) SHA1(1d6da95ef96d9c02aea70791e1cb87b70097d5ed) )
723   ROM_LOAD16_BYTE( "12.7j",    0x20000, 0x10000, CRC(d763a47c) SHA1(146d8082a404b6eddaf2dc9ba41a997949c17f8a) )
724   ROM_LOAD16_BYTE( "10.6j",    0x20001, 0x10000, CRC(96d5e8af) SHA1(ed7d854f08e87db5ae6cf526eafa029dfd2bfb9f) )
639725
640726   ROM_REGION( 0x10000, REGION_CPU2, 0 )   /* 64k for sound cpu code */
641727   ROM_LOAD( "4-3n",         0x0000, 0x2000, CRC(4038eff2) SHA1(0bcafc1b78c3bef9a0e9b822c482ea4a942fd180) )
r1070r1071
644730   ROM_REGION( 0x4000,  REGION_GFX1, ROMREGION_DISPOSE )
645731   ROM_LOAD( "5-6s",           0x00000, 0x04000, CRC(6a76955a) SHA1(733cb4b862b5dac97c2641b58f2362471e62fcf2) ) /* characters */
646732
733   /* The Joystick versions use a sub-board instead of the mask roms
734       the content is the same as the mask roms */
647735   ROM_REGION( 0x80000, REGION_GFX2, ROMREGION_DISPOSE )
648   ROM_LOAD( "tad-2.7s",       0x00000, 0x80000, CRC(13ca7ae1) SHA1(b26bb4876a6518e3809e0fa4d442616508b3e7e8) ) /* tiles */
649#if 0   /* same data, different layout */
650   ROM_LOAD16_BYTE( "cabal_17.bin",   0x00000, 0x10000, CRC(3b6d2b09) )
651   ROM_LOAD16_BYTE( "cabal_15.bin",   0x00001, 0x10000, CRC(1023319b) )
652   ROM_LOAD16_BYTE( "cabal_16.bin",   0x20000, 0x10000, CRC(77bc7a60) )
653   ROM_LOAD16_BYTE( "cabal_14.bin",   0x20001, 0x10000, CRC(420b0801) )
654   ROM_LOAD16_BYTE( "cabal_18.bin",   0x40000, 0x10000, CRC(0bc50075) )
655   ROM_LOAD16_BYTE( "cabal_12.bin",   0x40001, 0x10000, CRC(543fcb37) )
656   ROM_LOAD16_BYTE( "cabal_19.bin",   0x60000, 0x10000, CRC(67e4fe47) )
657   ROM_LOAD16_BYTE( "cabal_13.bin",   0x60001, 0x10000, CRC(d28d921e) )
658#endif
736   ROM_LOAD16_BYTE( "bg_rom1.bin",   0x00000, 0x10000, CRC(1023319b) )
737   ROM_LOAD16_BYTE( "bg_rom2.bin",   0x00001, 0x10000, CRC(3b6d2b09) )
738   ROM_LOAD16_BYTE( "bg_rom3.bin",   0x20000, 0x10000, CRC(420b0801) )
739   ROM_LOAD16_BYTE( "bg_rom4.bin",   0x20001, 0x10000, CRC(77bc7a60) )
740   ROM_LOAD16_BYTE( "bg_rom5.bin",   0x40000, 0x10000, CRC(543fcb37) )
741   ROM_LOAD16_BYTE( "bg_rom6.bin",   0x40001, 0x10000, CRC(0bc50075) )
742   ROM_LOAD16_BYTE( "bg_rom7.bin",   0x60000, 0x10000, CRC(d28d921e) )
743   ROM_LOAD16_BYTE( "bg_rom8.bin",   0x60001, 0x10000, CRC(67e4fe47) )
659744
660745   ROM_REGION( 0x80000, REGION_GFX3, ROMREGION_DISPOSE )
661   ROM_LOAD( "tad-1.5e",       0x00000, 0x80000, CRC(8324a7fe) SHA1(aed4470df35ec18e65e35bddc9c217a5019fdcbf) ) /* sprites */
662#if 0   /* same data, different layout */
663   ROM_LOAD16_BYTE( "cabal_05.bin",   0x00000, 0x10000, CRC(4e49c28e) )
664   ROM_LOAD16_BYTE( "cabal_04.bin",   0x00001, 0x10000, CRC(34d3cac8) )
665   ROM_LOAD16_BYTE( "cabal_06.bin",   0x20000, 0x10000, CRC(6a0e739d) )
666   ROM_LOAD16_BYTE( "cabal_03.bin",   0x20001, 0x10000, CRC(7065e840) )
667   ROM_LOAD16_BYTE( "cabal_07.bin",   0x40000, 0x10000, CRC(581a50c1) )
668   ROM_LOAD16_BYTE( "cabal_02.bin",   0x40001, 0x10000, CRC(0e1ec30e) )
669   ROM_LOAD16_BYTE( "cabal_08.bin",   0x60000, 0x10000, CRC(702735c9) )
670   ROM_LOAD16_BYTE( "cabal_01.bin",   0x60001, 0x10000, CRC(55c44764) )
671#endif
746   ROM_LOAD16_BYTE( "sp_rom1.bin",   0x00000, 0x10000, CRC(34d3cac8) )
747   ROM_LOAD16_BYTE( "sp_rom2.bin",   0x00001, 0x10000, CRC(4e49c28e) )
748   ROM_LOAD16_BYTE( "sp_rom3.bin",   0x20000, 0x10000, CRC(7065e840) )
749   ROM_LOAD16_BYTE( "sp_rom4.bin",   0x20001, 0x10000, CRC(6a0e739d) )
750   ROM_LOAD16_BYTE( "sp_rom5.bin",   0x40000, 0x10000, CRC(0e1ec30e) )
751   ROM_LOAD16_BYTE( "sp_rom6.bin",   0x40001, 0x10000, CRC(581a50c1) )
752   ROM_LOAD16_BYTE( "sp_rom7.bin",   0x60000, 0x10000, CRC(55c44764) )
753   ROM_LOAD16_BYTE( "sp_rom8.bin",   0x60001, 0x10000, CRC(702735c9) )
672754
673   ROM_REGION( 0x20000, REGION_SOUND1, 0 )   /* Samples? */
755   ROM_REGION( 0x20000, REGION_SOUND1, 0 )   /* Samples */
674756   ROM_LOAD( "2-1s",           0x00000, 0x10000, CRC(850406b4) SHA1(23ac1650c6d6f35607a5264b3aa89868401a645a) )
675757   ROM_LOAD( "1-1u",           0x10000, 0x10000, CRC(8b3e0789) SHA1(b1450db1b1bada237c90930623e4def321099f13) )
758ROM_END
676759
760ROM_START( cabala )
761   ROM_REGION( 0x50000, REGION_CPU1, 0 )   /* 64k for cpu code */
762   ROM_LOAD16_BYTE( "epr-a-9.7h",    0x00000, 0x10000, CRC(00abbe0c) SHA1(bacf17444abfb4f56248ff56e37b0aa2b1a3800d) )
763   ROM_LOAD16_BYTE( "epr-a-7.6h",    0x00001, 0x10000, CRC(c89608db) SHA1(a56e77526227af5b693eea9ef74da0d9d57cc55c) )
764   ROM_LOAD16_BYTE( "epr-a-8.7k",    0x20000, 0x08000, CRC(fe84788a) SHA1(29c49ebbe62357c27befcdcc4c19841a8bf32b2d) )
765   ROM_RELOAD(0x30000,0x08000)
766   ROM_LOAD16_BYTE( "epr-a-6.6k",    0x20001, 0x08000, CRC(81eb1355) SHA1(bbf926d40164d78319e982da0e8fb8ec4d4f8b87) )
767   ROM_RELOAD(0x30001,0x08000)
768
769   ROM_REGION( 0x10000, REGION_CPU2, 0 )   /* 64k for sound cpu code */
770   ROM_LOAD( "epr-a-4.3n",         0x0000, 0x2000, CRC(4038eff2) SHA1(0bcafc1b78c3bef9a0e9b822c482ea4a942fd180) )
771   ROM_LOAD( "epr-a-3.3p",         0x8000, 0x4000, CRC(c0097c55) SHA1(874f813c1b466dab2d15a707e340b9bdb200246c) )
772
773   ROM_REGION( 0x8000,  REGION_GFX1, ROMREGION_DISPOSE )
774   ROM_LOAD( "epr-a-5.6s",           0x00000, 0x08000, CRC(189033fd) SHA1(814f0cbc5f72345c04922d6d7c986f99d57335fa) ) /* characters */
775
776   ROM_REGION( 0x80000, REGION_GFX2, ROMREGION_DISPOSE )
777   ROM_LOAD( "tad-2.7s",       0x00000, 0x80000, CRC(13ca7ae1) SHA1(b26bb4876a6518e3809e0fa4d442616508b3e7e8) ) /* tiles */
778
779   ROM_REGION( 0x80000, REGION_GFX3, ROMREGION_DISPOSE )
780   ROM_LOAD( "tad-1.5e",       0x00000, 0x80000, CRC(8324a7fe) SHA1(aed4470df35ec18e65e35bddc9c217a5019fdcbf) ) /* sprites */
781
782   ROM_REGION( 0x20000, REGION_SOUND1, 0 )   /* Samples */
783   ROM_LOAD( "epr-a-2.1s",           0x00000, 0x10000, CRC(850406b4) SHA1(23ac1650c6d6f35607a5264b3aa89868401a645a) )
784   ROM_LOAD( "epr-a-1.1u",           0x10000, 0x10000, CRC(8b3e0789) SHA1(b1450db1b1bada237c90930623e4def321099f13) )
677785ROM_END
678786
679787ROM_START( cabalus )
r1070r1071
705813   ROM_LOAD( "prom10.4j",      0x0100, 0x0100, CRC(261c93bc) SHA1(942470198143d584d3766f28587d1879abd912c1) )
706814ROM_END
707815
708ROM_START( cabal2 )
816ROM_START( cabalus2 )
709817   ROM_REGION( 0x50000, REGION_CPU1, 0 )   /* 64k for cpu code */
710818   ROM_LOAD16_BYTE( "9-7h",            0x00000, 0x10000, CRC(ebbb9484) SHA1(2c77d5b4acdc37720dc7ccab526862981bf8da51) )
711819   ROM_LOAD16_BYTE( "7-6h",            0x00001, 0x10000, CRC(51aeb49e) SHA1(df38dc58d8c6fa3d35904bf34e29111e7bd523ad) )
r1070r1071
734842   ROM_LOAD( "prom10.4j",      0x0100, 0x0100, CRC(261c93bc) SHA1(942470198143d584d3766f28587d1879abd912c1) )
735843ROM_END
736844
845/*
846
847cabal - tad corporation ? - (clone)
848
8492 boards
850
8511st board
852
853(prg)
8541 x 68000
855from cabal_21 to cabal_24
856
857(snd)
8581 x z80
8591 x ym2151
860cabal_11
861
862(gfx ?)
863from cabal_12 to cabal_19
864
865(?)
8662 x z80
867cabal_09 and cabal_10
868
869(?)
870cabal_20 (near the snd area)
871
8722nd board
873
874(gfx)
875from cabal_01 to cabal_08
876
877Note: The bootleg has *3* Z80s
878
879*/
880
737881ROM_START( cabalbl )
738882   ROM_REGION( 0x50000, REGION_CPU1, 0 )   /* 64k for cpu code */
739883   ROM_LOAD16_BYTE( "cabal_24.bin",    0x00000, 0x10000, CRC(00abbe0c) SHA1(bacf17444abfb4f56248ff56e37b0aa2b1a3800d) )
r1070r1071
744888   ROM_REGION( 0x10000, REGION_CPU2, 0 )   /* 64k for sound cpu code */
745889   ROM_LOAD( "cabal_11.bin",    0x0000, 0x10000, CRC(d308a543) SHA1(4f45db42512f83266001daee55d06f49e7908e35) )
746890
747   ROM_REGION( 0x4000,  REGION_GFX1, ROMREGION_DISPOSE )
748   ROM_LOAD( "5-6s",           0x00000, 0x04000, CRC(6a76955a) SHA1(733cb4b862b5dac97c2641b58f2362471e62fcf2) ) /* characters */
891   ROM_REGION( 0x8000,  REGION_GFX1, ROMREGION_DISPOSE )
892   ROM_LOAD( "cabal_20.bin",           0x00000, 0x08000, CRC(189033fd) SHA1(814f0cbc5f72345c04922d6d7c986f99d57335fa) ) /* characters */
749893
894   /* The bootleg versions use a sub-board instead of the mask roms
895       the content is the same as the mask roms */
750896   ROM_REGION( 0x80000, REGION_GFX2, ROMREGION_DISPOSE )
751   ROM_LOAD( "tad-2.7s",       0x00000, 0x80000, CRC(13ca7ae1) SHA1(b26bb4876a6518e3809e0fa4d442616508b3e7e8) ) /* tiles */
752#if 0   /* same data, different layout */
753   ROM_LOAD16_BYTE( "cabal_17.bin",   0x00000, 0x10000, CRC(3b6d2b09) )
754   ROM_LOAD16_BYTE( "cabal_15.bin",   0x00001, 0x10000, CRC(1023319b) )
755   ROM_LOAD16_BYTE( "cabal_16.bin",   0x20000, 0x10000, CRC(77bc7a60) )
756   ROM_LOAD16_BYTE( "cabal_14.bin",   0x20001, 0x10000, CRC(420b0801) )
757   ROM_LOAD16_BYTE( "cabal_18.bin",   0x40000, 0x10000, CRC(0bc50075) )
758   ROM_LOAD16_BYTE( "cabal_12.bin",   0x40001, 0x10000, CRC(543fcb37) )
759   ROM_LOAD16_BYTE( "cabal_19.bin",   0x60000, 0x10000, CRC(67e4fe47) )
760   ROM_LOAD16_BYTE( "cabal_13.bin",   0x60001, 0x10000, CRC(d28d921e) )
761#endif
897   ROM_LOAD16_BYTE( "cabal_15.bin",   0x00000, 0x10000, CRC(1023319b) )
898   ROM_LOAD16_BYTE( "cabal_17.bin",   0x00001, 0x10000, CRC(3b6d2b09) )
899   ROM_LOAD16_BYTE( "cabal_14.bin",   0x20000, 0x10000, CRC(420b0801) )
900   ROM_LOAD16_BYTE( "cabal_16.bin",   0x20001, 0x10000, CRC(77bc7a60) )
901   ROM_LOAD16_BYTE( "cabal_12.bin",   0x40000, 0x10000, CRC(543fcb37) )
902   ROM_LOAD16_BYTE( "cabal_18.bin",   0x40001, 0x10000, CRC(0bc50075) )
903   ROM_LOAD16_BYTE( "cabal_13.bin",   0x60000, 0x10000, CRC(d28d921e) )
904   ROM_LOAD16_BYTE( "cabal_19.bin",   0x60001, 0x10000, CRC(67e4fe47) )
762905
763906   ROM_REGION( 0x80000, REGION_GFX3, ROMREGION_DISPOSE )
764   ROM_LOAD( "tad-1.5e",       0x00000, 0x80000, CRC(8324a7fe) SHA1(aed4470df35ec18e65e35bddc9c217a5019fdcbf) ) /* sprites */
765#if 0   /* same data, different layout */
766   ROM_LOAD16_BYTE( "cabal_05.bin",   0x00000, 0x10000, CRC(4e49c28e) )
767   ROM_LOAD16_BYTE( "cabal_04.bin",   0x00001, 0x10000, CRC(34d3cac8) )
768   ROM_LOAD16_BYTE( "cabal_06.bin",   0x20000, 0x10000, CRC(6a0e739d) )
769   ROM_LOAD16_BYTE( "cabal_03.bin",   0x20001, 0x10000, CRC(7065e840) )
770   ROM_LOAD16_BYTE( "cabal_07.bin",   0x40000, 0x10000, CRC(581a50c1) )
771   ROM_LOAD16_BYTE( "cabal_02.bin",   0x40001, 0x10000, CRC(0e1ec30e) )
772   ROM_LOAD16_BYTE( "cabal_08.bin",   0x60000, 0x10000, CRC(702735c9) )
773   ROM_LOAD16_BYTE( "cabal_01.bin",   0x60001, 0x10000, CRC(55c44764) )
774#endif
907   ROM_LOAD16_BYTE( "cabal_04.bin",   0x00000, 0x10000, CRC(34d3cac8) )
908   ROM_LOAD16_BYTE( "cabal_05.bin",   0x00001, 0x10000, CRC(4e49c28e) )
909   ROM_LOAD16_BYTE( "cabal_03.bin",   0x20000, 0x10000, CRC(7065e840) )
910   ROM_LOAD16_BYTE( "cabal_06.bin",   0x20001, 0x10000, CRC(6a0e739d) )
911   ROM_LOAD16_BYTE( "cabal_02.bin",   0x40000, 0x10000, CRC(0e1ec30e) )
912   ROM_LOAD16_BYTE( "cabal_07.bin",   0x40001, 0x10000, CRC(581a50c1) )
913   ROM_LOAD16_BYTE( "cabal_01.bin",   0x60000, 0x10000, CRC(55c44764) )
914   ROM_LOAD16_BYTE( "cabal_08.bin",   0x60001, 0x10000, CRC(702735c9) )
775915
776   ROM_REGION( 0x20000, REGION_SOUND1, 0 )
916   ROM_REGION( 0x10000, REGION_CPU3, 0 )
777917   ROM_LOAD( "cabal_09.bin",   0x00000, 0x10000, CRC(4ffa7fe3) SHA1(381d8e765a7b94678fb3308965c748bbe9f8e247) ) /* Z80 code/adpcm data */
778   ROM_LOAD( "cabal_10.bin",   0x10000, 0x10000, CRC(958789b6) SHA1(344c3ee8a1e272b56499e5c0415bb714aec0ddcf) ) /* Z80 code/adpcm data */
918
919   ROM_REGION( 0x10000, REGION_CPU4, 0 )
920   ROM_LOAD( "cabal_10.bin",   0x00000, 0x10000, CRC(958789b6) SHA1(344c3ee8a1e272b56499e5c0415bb714aec0ddcf) ) /* Z80 code/adpcm data */
779921ROM_END
780922
781923
r1070r1071
787929}
788930
789931
790GAME( 1988, cabal,   0,     cabal,   cabal,   cabal, ROT0, "Tad (Fabtek license)", "Cabal (US set 1)", 0 )
791GAME( 1988, cabal2,  cabal, cabal,   cabal,   cabal, ROT0, "Tad (Fabtek license)", "Cabal (US set 2)", 0 )
792GAME( 1988, cabalbl, cabal, cabalbl, cabalbl, 0,     ROT0, "bootleg", "Cabal (bootleg)", GAME_IMPERFECT_SOUND )
932GAME( 1988, cabal,   0,     cabal,   cabalj,   cabal,  ROT0, "Tad Corporation", "Cabal (World, Joystick version)", 0 )
933GAME( 1989, cabala,  cabal, cabal,   cabalj,   cabal,  ROT0, "Tad Corporation (Alpha Trading license)", "Cabal (Alpha Trading)", 0 ) // korea?
934GAME( 1988, cabalbl, cabal, cabalbl, cabalbl,  0,      ROT0, "[Tad Corporation] (Red Corporation bootleg)", "Cabal (bootleg of Joystick version)", GAME_IMPERFECT_SOUND )
935
936GAME( 1988, cabalus, cabal, cabal,   cabalt,   cabal,  ROT0, "Tad (Fabtek license)", "Cabal (US set 1, Trackball version)", 0 )
937GAME( 1988, cabalus2,cabal, cabal,   cabalt,   cabal,  ROT0, "Tad (Fabtek license)", "Cabal (US set 2, Trackball version)", 0 )
src/mame/drivers/pacman.c
r1070r1071
29092909   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
29102910INPUT_PORTS_END
29112911
2912INPUT_PORTS_START( cannonbp )
2913   PORT_START_TAG("IN0")
2914   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )   PORT_PLAYER(1) PORT_4WAY
2915   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )   PORT_PLAYER(1) PORT_4WAY
2916   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT )   PORT_PLAYER(1) PORT_4WAY
2917   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )   PORT_PLAYER(1) PORT_4WAY
2918   PORT_DIPNAME(0x10, 0x10, "Rack Test (Cheat)" )   PORT_CODE(KEYCODE_F1)
2919   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
2920   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2921   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 )
2922   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN2 )
2923   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 )
2924
2925   PORT_START_TAG("IN1")
2926   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )   PORT_PLAYER(2) PORT_4WAY PORT_COCKTAIL
2927   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )   PORT_PLAYER(2) PORT_4WAY PORT_COCKTAIL
2928   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT )   PORT_PLAYER(2) PORT_4WAY PORT_COCKTAIL
2929   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )   PORT_PLAYER(2) PORT_4WAY PORT_COCKTAIL
2930   PORT_SERVICE( 0x10, IP_ACTIVE_LOW )
2931   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 )
2932   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START2 )
2933   PORT_DIPNAME(0x80, 0x80, DEF_STR( Cabinet ) )
2934   PORT_DIPSETTING(   0x80, DEF_STR( Upright ) )
2935   PORT_DIPSETTING(   0x00, DEF_STR( Cocktail ) )
2936
2937   PORT_START_TAG("DSW 1")
2938    PORT_DIPNAME( 0x0001, 0x0001, "DSW1" )
2939    PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
2940    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2941    PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) )
2942    PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
2943    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2944    PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) )
2945    PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
2946    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2947    PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) )
2948    PORT_DIPSETTING(      0x0008, DEF_STR( Off ) )
2949    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2950    PORT_DIPNAME( 0x0010, 0x0000, DEF_STR( Unknown ) )
2951    PORT_DIPSETTING(      0x0010, DEF_STR( Off ) )
2952    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2953    PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) )
2954    PORT_DIPSETTING(      0x0020, DEF_STR( Off ) )
2955    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2956    PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) )
2957    PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
2958    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2959    PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) )
2960    PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
2961    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2962
2963   PORT_START_TAG("DSW 2")
2964    PORT_DIPNAME( 0x0001, 0x0001, "DSW2" )
2965    PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
2966    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2967    PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) )
2968    PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
2969    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2970    PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) )
2971    PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
2972    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2973    PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) )
2974    PORT_DIPSETTING(      0x0008, DEF_STR( Off ) )
2975    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2976    PORT_DIPNAME( 0x0010, 0x0000, DEF_STR( Unknown ) )
2977    PORT_DIPSETTING(      0x0010, DEF_STR( Off ) )
2978    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2979    PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) )
2980    PORT_DIPSETTING(      0x0020, DEF_STR( Off ) )
2981    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2982    PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) )
2983    PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
2984    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2985    PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) )
2986    PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
2987    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2988INPUT_PORTS_END
2989
29122990/*************************************
29132991 *
29142992 *  Graphics layouts
r1070r1071
49995077   ROM_LOAD( "18.aux",       0x3c000, 0x4000, CRC(feb195fd) SHA1(5677d31e526cc7752254e9af0d694f05bc6bc907) )
50005078ROM_END
50015079
5080ROM_START( cannonbp )
5081   ROM_REGION( 0x10000, REGION_CPU1, 0 )
5082   ROM_LOAD( "n1-6e",        0x0000, 0x0800, CRC(c68878c7) SHA1(4ab69f820e861a33fa7555286459e5953c126d33) )
5083   ROM_LOAD( "n2-6k",        0x0800, 0x0800, CRC(ff3951a5) SHA1(8c06526903f2ce3e0ac29ba0138e8c270732150a) )
5084   ROM_LOAD( "n3-6f",        0x1000, 0x0800, CRC(2329079d) SHA1(461d1258a03ea35ba33f4094c05f8ffda8cdfc47) )
5085    ROM_LOAD( "n4-6m",        0x1800, 0x0800, CRC(fcc57ecb) SHA1(9efafbb7f3d44652aded860e734332f47354e299) )
5086   ROM_LOAD( "n5-6h",        0x2000, 0x0800, CRC(52846c9d) SHA1(4a479ff8961c8865aea12976355d0201a8cb1b48) )
5087   ROM_LOAD( "n6-6n",        0x2800, 0x0800, CRC(59e890dd) SHA1(c148b71d71fb49a138ef1afe771be70bec21ad2b) )
50025088
5089   ROM_REGION( 0x2000, REGION_GFX1, ROMREGION_DISPOSE )
5090   ROM_LOAD( "z1-5e",        0x0000, 0x0800, CRC(125779e0) SHA1(c1ae7214e3ff1a941ae0c4948ec886bc84b6f040) )
5091   ROM_LOAD( "z3-5h",        0x0800, 0x0800, CRC(78f866c0) SHA1(171f0b5ed6c8b1f2ae8dc1b7e97ea9f0c3d8e18e) )
5092   ROM_LOAD( "z2-5f",        0x1000, 0x0800, CRC(fbd2c99d) SHA1(135a5d86d59010cc608b099054815dd31d443da7) )
5093   ROM_LOAD( "z4-5j",        0x1800, 0x0800, CRC(8734c904) SHA1(86d9dc72d3cfc863c558967860ac4d2dc8d2c07c) )
50035094
5095   ROM_REGION( 0x0120, REGION_PROMS, 0 ) /* these are from crush roller, just so we can see what's going on */
5096   ROM_LOAD( "colorprom_1",    0x0000, 0x0020, BAD_DUMP CRC(2fc650bd) SHA1(8d0268dee78e47c712202b0ec4f1f51109b1f2a5) )
5097   ROM_LOAD( "colorprom_2",    0x0020, 0x0100, BAD_DUMP CRC(63efb927) SHA1(5c144a613fc4960a1dfd7ead89e7fee258a63171) )
5098
5099   ROM_REGION( 0x0200, REGION_SOUND1, 0 )   /* sound PROMs */
5100   ROM_LOAD( "82s126.1m",    0x0000, 0x0100, CRC(a9cc86bf) SHA1(bbcec0570aeceb582ff8238a4bc8546a23430081) )
5101   ROM_LOAD( "82s126.3m",    0x0100, 0x0100, CRC(77245b66) SHA1(0c4d0bee858b97632411c440bea6948a74759746) )   /* timing - not used */
5102ROM_END
5103
5104
50045105/*************************************
50055106 *
50065107 *  Driver initialization
r1070r1071
52395340   }
52405341}
52415342
5343static READ8_HANDLER( cannonbp_protection_r )
5344{
5345   /* at 6p where a rom would usually be there is an epoxy resin chip with 'Novomatic Industrie' Cannon Ball tm 1984 label. */
5346   switch (offset)
5347   {
5348      default:
5349         logerror("CPU0 %04x: Unhandled protection read, offset %04x\n", activecpu_get_pc(), offset);
5350         return 0x00;
52425351
5352      case 0x000: // unknown
5353      case 0x003: // unknown
5354      case 0x012: // unknown
5355         return 0x00;
5356
5357      case 0x001: // affects the ball hitting the blocks
5358         return 0xff;
5359
5360      case 0x105: // player start x position
5361         return 0x00;
5362
5363      case 0x107: // player start y position
5364         return 0x70;
5365   }
5366}
5367
5368
5369static DRIVER_INIT( cannonbp )
5370{
5371   /* extra memory */
5372   memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0x4800, 0x4bff, 0, 0, MRA8_RAM);
5373   memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0x4800, 0x4bff, 0, 0, MWA8_RAM);
5374
5375   /* protection? */
5376   memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0x3000, 0x3fff, 0, 0, cannonbp_protection_r);
5377}
5378
5379
52435380/*************************************
52445381 *
52455382 *  Game drivers
r1070r1071
53205457GAME( 1986, rocktrv2, 0,        rocktrv2, rocktrv2, rocktrv2, ROT90,  "Triumph Software Inc.", "MTV Rock-N-Roll Trivia (Part 2)", GAME_SUPPORTS_SAVE )
53215458GAME( 1986, bigbucks, 0,        bigbucks, bigbucks, 0,        ROT90,  "Dynasoft Inc.", "Big Bucks", GAME_SUPPORTS_SAVE )
53225459GAME( 1995, mschamp,  mspacman, mschamp,  mschamp,  0,        ROT90,  "hack", "Ms. Pacman Champion Edition / Super Zola Pac Gal", GAME_SUPPORTS_SAVE )
5460GAME( 198?, cannonbp, cannonb,  pacman,   cannonbp, cannonbp, ROT90,  "Novomatic", "Cannon Ball (Pacman Hardware)", GAME_WRONG_COLORS|GAME_SUPPORTS_SAVE )
src/mame/drivers/srmp6.c
r1070r1071
131131   tileram = auto_malloc(0x100000*16);
132132   dirty_tileram = auto_malloc((0x100000*16)/0x40); // every 8x8x8 tile is 0x40 bytes
133133
134   memset(tileram,(0x100000*16),0x00);
135   memset(dirty_tileram,(0x100000*16)/0x40,1);
134   memset(tileram,0x00,(0x100000*16));
135   memset(dirty_tileram,1,(0x100000*16)/0x40);
136136
137137   dmaram = auto_malloc(0x100);
138138
r1070r1071
271271
272272                  if (dirty_tileram[tileno])
273273                  {
274                     decodechar(Machine->gfx[0], tileno, (UINT8*)tileram, &tiles8x8_layout);
274                     decodechar(machine->gfx[0], tileno, (UINT8*)tileram, &tiles8x8_layout);
275275                     dirty_tileram[tileno] = 0;
276276                  }
277277
src/tools/chdcd.c
r1070r1071
1010#include "osdcore.h"
1111#include "chd.h"
1212#include "chdcd.h"
13#include <stdio.h>
14#include <string.h>
1513#include <ctype.h>
1614
1715
src/tools/runtest.cmd
r1070r1071
132132:runone
133133@echo Testing %1 (%2)...
134134echo.>>summary.log
135mame %1 -str 30 -nodebug -nothrottle -inipath .. -video none 1>log\%1.txt 2>log\%1.err
135mame %1 -str 30 -nodebug -nothrottle -inipath .. -video none -nosound 1>log\%1.txt 2>log\%1.err
136136if %errorlevel% equ 100 (
137137echo @@@@@driver=%1: Exception>>summary.log
138138type log\%1.err >>summary.log
src/osd/osdcore.h
r1070r1071
505505void osd_lock_free(osd_lock *lock);
506506
507507
508/*-----------------------------------------------------------------------------
509    osd_compare_exchange32: compare an INT32 against a value in memory; if they
510        are equal, swap in a new value; return the value from memory
508511
512    Parameters:
513
514        ptr - a pointer to the memory to compare and exchange to.
515
516        compare - the value to compare the memory against.
517
518        exchange - the value to swap in if the compare succeeds.
519
520    Return value:
521
522        The original value from memory.
523-----------------------------------------------------------------------------*/
524INT32 osd_compare_exchange32(INT32 volatile *ptr, INT32 compare, INT32 exchange);
525
526
527/*-----------------------------------------------------------------------------
528    osd_compare_exchange64: compare an INT64 against a value in memory; if they
529        are equal, swap in a new value; return the value from memory
530
531    Parameters:
532
533        ptr - a pointer to the memory to compare and exchange to.
534
535        compare - the value to compare the memory against.
536
537        exchange - the value to swap in if the compare succeeds.
538
539    Return value:
540
541        The original value from memory.
542-----------------------------------------------------------------------------*/
543#ifdef PTR64
544INT64 osd_compare_exchange64(INT64 volatile *ptr, INT64 compare, INT64 exchange);
545#endif
546
547
548/*-----------------------------------------------------------------------------
549    osd_compare_exchange_ptr: INLINE wrapper to compare and exchange a
550        pointer value of the appropriate size
551-----------------------------------------------------------------------------*/
552INLINE void *osd_compare_exchange_ptr(void * volatile *ptr, void *compare, void *exchange)
553{
554#ifdef PTR64
555   INT64 result = osd_compare_exchange64((INT64 volatile *)ptr, (INT64)compare, (INT64)exchange);
556   return (void *)result;
557#else
558   INT32 result = osd_compare_exchange32((INT32 volatile *)ptr, (INT32)compare, (INT32)exchange);
559   return (void *)result;
560#endif
561}
562
563
564/*-----------------------------------------------------------------------------
565    osd_sync_add: INLINE wrapper to safely add a delta value to a
566        32-bit integer, returning the final result
567-----------------------------------------------------------------------------*/
568INLINE INT32 osd_sync_add(INT32 volatile *ptr, INT32 delta)
569{
570   INT32 origvalue;
571
572   /* loop until we succeed in updating against an unchanged value */
573   do
574   {
575      origvalue = *ptr;
576   } while (osd_compare_exchange32(ptr, origvalue, origvalue + delta) != origvalue);
577
578   /* return the final result */
579   return origvalue + delta;
580}
581
582
583
509584/***************************************************************************
510585    WORK ITEM INTERFACES
511586***************************************************************************/
r1070r1071
518593/* these flags can be set when queueing a work item to indicate how to handle
519594   its deconstruction */
520595#define WORK_ITEM_FLAG_AUTO_RELEASE   0x0001
596#define WORK_ITEM_FLAG_SHARED      0x0002
521597
522598/* osd_work_queue is an opaque type which represents a queue of work items */
523599typedef struct _osd_work_queue osd_work_queue;
r1070r1071
543619
544620            WORK_QUEUE_FLAG_MULTI - indicates that the work queue should
545621                take advantage of as many processors as it can; items queued
546                here are assumed to be independent
622                here are assumed to be fully independent or shared
547623
548624    Return value:
549625
r1070r1071
624700            WORK_ITEM_FLAG_AUTO_RELEASE - indicates that the work item
625701                should be automatically freed when it is complete
626702
703            WORK_ITEM_FLAG_SHARED - indicates that the same work item can
704                be simultaneously processed by multiple threads; the item
705                remains at the front of the queue until all threads
706                processing it have returned, which allows other threads to
707                process the same item if they have bandwidth
708
627709    Return value:
628710
629711        A pointer to an allocated osd_work_item representing the item.
src/osd/windows/sound.c
r1070r1071
2626#include "window.h"
2727#include "video.h"
2828#include "config.h"
29#include "sound.h"
2930
3031
3132//============================================================
src/osd/windows/winsync.c
r1070r1071
129129   DeleteCriticalSection(&lock->critsect);
130130   free(lock);
131131}
132
133
134//============================================================
135//  osd_compare_exchange32
136//============================================================
137
138INT32 osd_compare_exchange32(INT32 volatile *ptr, INT32 compare, INT32 exchange)
139{
140   return InterlockedCompareExchange((LPLONG)ptr, (LONG)exchange, (LONG)compare);
141}
142
143
144//============================================================
145//  osd_compare_exchange64
146//============================================================
147
148#ifdef PTR64
149INT64 osd_compare_exchange64(INT64 volatile *ptr, INT64 compare, INT64 exchange)
150{
151   return InterlockedCompareExchange64((LONGLONG*)ptr, (LONGLONG)exchange, (LONGLONG)compare);
152}
153#endif
src/osd/windows/winwork.c
r1070r1071
2222
2323
2424//============================================================
25//  TYPE DEFINITIONS
25//  DEBUGGING
2626//============================================================
2727
28struct _osd_work_queue
29{
30   CRITICAL_SECTION critsect;      // critical section protecting the queue
31   osd_work_item * volatile list;   // list of items in the queue
32   osd_work_item ** volatile tailptr;// pointer to the tail pointer of work items in the queue
33   osd_work_item * volatile free;   // free list of work items
34   volatile LONG   items;         // items in the queue
35   volatile LONG   livethreads;   // number of live threads
36   UINT32         threads;      // number of threads in this queue
37   HANDLE *      thread;         // array of thread handles
38   HANDLE         workevent;      // event signalled when work is available
39   HANDLE         doneevent;      // event signalled when work is complete
40   HANDLE         exitevent;      // event signalled when thread should exit
41};
28#define KEEP_STATISTICS         (0)
4229
4330
44struct _osd_work_item
45{
46   osd_work_item *   next;         // pointer to next item
47   osd_work_queue *queue;         // pointer back to the owning queue
48   osd_work_callback callback;      // callback function
49   void *         param;         // callback parameter
50   void *         result;         // callback result
51   HANDLE         event;         // event signalled when complete
52   UINT32         flags;         // creation flags
53   UINT32         complete;      // are we finished yet?
54};
5531
56
57
5832//============================================================
59//  FUNCTION PROTOTYPES
33//  MACROS
6034//============================================================
6135
62static void worker_thread_entry(void *param);
63static int execute_work_item(osd_work_item *item);
36#if KEEP_STATISTICS
37#define add_to_stat(v,x)      do { osd_sync_add((v), (x)); } while (0)
38#else
39#define add_to_stat(v,x)      do { } while (0)
40#endif
6441
42#ifndef YieldProcessor
43#ifdef __GNUC__
44INLINE void YieldProcessor(void)
45{
46   __asm__ ( "rep; nop" );
47}
48#else
49INLINE void YieldProcessor(void)
50{
51   __asm { rep nop }
52}
53#endif
54#endif
6555
6656
57
6758//============================================================
68//  INLINE FUNCTIONS
59//  TYPE DEFINITIONS
6960//============================================================
7061
71INLINE PVOID compare_exchange_pointer(PVOID volatile *ptr, PVOID exchange, PVOID compare)
62typedef struct _thread_info thread_info;
63struct _thread_info
7264{
73   // the mingw headers don't put the volatile keyword on the first parameter
74   // gcc also can't handle casting the result of a function
75#ifdef __GNUC__
76#ifdef PTR64
77   UINT64 result = InterlockedCompareExchange64((UINT64)ptr, (UINT64)exchange, (UINT64)compare);
78   return (PVOID)result;
79#else
80   LONG result = InterlockedCompareExchange((LPLONG)ptr, (LONG)exchange, (LONG)compare);
81   return (PVOID)result;
82#endif
83#else
84   return InterlockedCompareExchangePointer(ptr, exchange, compare);
85#endif
86}
65   osd_work_queue *   queue;         // pointer back to the queue
66   HANDLE            handle;         // handle to the thread
67   HANDLE            wakeevent;      // wake event for the thread
68   UINT8            active;         // are we actively processing work?
69};
8770
8871
89INLINE LONG interlocked_increment(LONG volatile *addend)
72struct _osd_work_queue
9073{
91   // the mingw headers don't put the volatile keyword on the first parameter
92#ifdef __GNUC__
93   return InterlockedIncrement((LPLONG)addend);
94#else
95   return InterlockedIncrement(addend);
74   CRITICAL_SECTION    critsect;      // critical section protecting the queue
75   osd_work_item * volatile list;      // list of items in the queue
76   osd_work_item ** volatile tailptr;   // pointer to the tail pointer of work items in the queue
77   osd_work_item * volatile free;      // free list of work items
78   volatile INT32      items;         // items in the queue
79   volatile INT32      livethreads;   // number of live threads
80   UINT32            threads;      // number of threads in this queue
81   UINT32            flags;         // creation flags
82   thread_info *      thread;         // array of thread information
83   HANDLE            workevent;      // shared event signalled when work is available
84   HANDLE            doneevent;      // event signalled when work is complete
85   HANDLE            exitevent;      // event signalled when thread should exit
86
87#if KEEP_STATISTICS
88   volatile INT32      itemsqueued;   // total items queued
89   volatile INT32      setevents;      // number of times we called SetEvent
90   volatile INT32      extraitems;      // how many extra items we got after the first in the queue loop
91   volatile INT32      spinloops;      // how many times spinning bought us more items
9692#endif
97}
93};
9894
9995
100INLINE LONG interlocked_decrement(LONG volatile *addend)
96struct _osd_work_item
10197{
102   // the mingw headers don't put the volatile keyword on the first parameter
103#ifdef __GNUC__
104   return InterlockedDecrement((LPLONG)addend);
105#else
106   return InterlockedDecrement(addend);
107#endif
108}
98   osd_work_item *      next;         // pointer to next item
99   osd_work_queue *   queue;         // pointer back to the owning queue
100   osd_work_callback    callback;      // callback function
101   void *            param;         // callback parameter
102   void *            result;         // callback result
103   HANDLE            event;         // event signalled when complete
104   UINT32            flags;         // creation flags
105   volatile INT32      refcount;      // reference count of threads processing
106};
109107
110108
111109
112110//============================================================
111//  FUNCTION PROTOTYPES
112//============================================================
113
114static int effective_num_processors(void);
115static unsigned __stdcall worker_thread_entry(void *param);
116static void worker_thread_process(osd_work_queue *queue, thread_info *thread);
117static void execute_work_item(osd_work_item *item);
118
119
120
121//============================================================
113122//  osd_work_queue_alloc
114123//============================================================
115124
116125osd_work_queue *osd_work_queue_alloc(int flags)
117126{
127   int numprocs = effective_num_processors();
118128   osd_work_queue *queue;
119   SYSTEM_INFO info;
120129   int threadnum;
121130
122131   // allocate a new queue
r1070r1071
125134      goto error;
126135   memset(queue, 0, sizeof(*queue));
127136
137   // initialize basic queue members
138   queue->tailptr = (osd_work_item **)&queue->list;
139   queue->flags = flags;
140
128141   // allocate events for the queue
129142   queue->workevent = CreateEvent(NULL, FALSE, FALSE, NULL);   // auto-reset, not signalled
130143   queue->doneevent = CreateEvent(NULL, TRUE, TRUE, NULL);      // manual reset, signalled
r1070r1071
134147
135148   // initialize the critical section
136149   InitializeCriticalSection(&queue->critsect);
137   queue->tailptr = (osd_work_item **)&queue->list;
138150
139   // determine how many threads to create
140   GetSystemInfo(&info);
141   if (info.dwNumberOfProcessors == 1)
151   // determine how many threads to create...
152   // on a single-CPU system, create 1 thread for I/O queues, and 0 threads for everything else
153   if (numprocs == 1)
142154      queue->threads = (flags & WORK_QUEUE_FLAG_IO) ? 1 : 0;
155
156   // on an n-CPU system, create (n-1) threads for multi queues, and 1 thread for everything else
143157   else
144      queue->threads = (flags & WORK_QUEUE_FLAG_MULTI) ? info.dwNumberOfProcessors : 1;
158      queue->threads = (flags & WORK_QUEUE_FLAG_MULTI) ? (numprocs - 1) : 1;
145159
146160   // if we have threads, create them
147161   if (queue->threads > 0)
r1070r1071
155169      // iterate over threads
156170      for (threadnum = 0; threadnum < queue->threads; threadnum++)
157171      {
172         thread_info *thread = &queue->thread[threadnum];
173         uintptr_t handle;
174
175         // set a pointer back to the queue
176         thread->queue = queue;
177
178         // create the per-thread wake event
179         thread->wakeevent = CreateEvent(NULL, FALSE, FALSE, NULL);   // auto-reset, not signalled
180         if (thread->wakeevent == NULL)
181            goto error;
182
158183         // create the thread
159         uintptr_t handle = _beginthread(worker_thread_entry, 0, queue);
160         queue->thread[threadnum] = (HANDLE)handle;
161         if (queue->thread[threadnum] == NULL)
184         handle = _beginthreadex(NULL, 0, worker_thread_entry, thread, 0, NULL);
185         thread->handle = (HANDLE)handle;
186         if (thread->handle == NULL)
162187            goto error;
163188
164         // set its priority
189         // set its priority: I/O threads get high priority because they are assumed to be
190         // blocked most of the time; other threads just match the creator's priority
165191         if (flags & WORK_QUEUE_FLAG_IO)
166            SetThreadPriority(queue->thread[threadnum], THREAD_PRIORITY_ABOVE_NORMAL);
192            SetThreadPriority(thread->handle, THREAD_PRIORITY_ABOVE_NORMAL);
193         else
194            SetThreadPriority(thread->handle, GetThreadPriority(GetCurrentThread()));
167195      }
168196   }
169197   return queue;
r1070r1071
195223   if (queue->threads == 0)
196224      return TRUE;
197225
226   // if no items, we're done
227   if (queue->items == 0)
228      return TRUE;
229
230   // if this is a multi queue, help out rather than doing nothing
231   if (queue->flags & WORK_QUEUE_FLAG_MULTI)
232   {
233      osd_ticks_t stopspin = osd_ticks() + timeout;
234
235      // process what we can as a worker thread
236      worker_thread_process(queue, NULL);
237
238      // spin until we hit 0 items and then return TRUE
239      while (queue->items != 0 && osd_ticks() < stopspin)
240         YieldProcessor();
241      return TRUE;
242   }
243
244   // reset our done event and double-check the items before waiting
245   ResetEvent(queue->doneevent);
246   if (queue->items == 0)
247      return TRUE;
248
198249   // wait for the collection to be signalled
199250   return (WaitForSingleObject(queue->doneevent, timeout * 1000 / osd_ticks_per_second()) == WAIT_OBJECT_0);
200251}
r1070r1071
209260   // if we have threads, clean them up
210261   if (queue->threads > 0 && queue->thread != NULL)
211262   {
212      int threadnum, hcount;
263      int threadnum;
213264
214265      // signal all the threads to exit
215266      SetEvent(queue->exitevent);
216267
217      // count the number of valid threads (we could be partially constructed)
218      for (threadnum = hcount = 0; threadnum < queue->threads; threadnum++)
219         if (queue->thread[threadnum] != NULL)
220            hcount++;
268      // wait for all the threads to go away
269      for (threadnum = 0; threadnum < queue->threads; threadnum++)
270      {
271         thread_info *thread = &queue->thread[threadnum];
221272
222      // wait for all the threads to exit
223      WaitForMultipleObjects(hcount, queue->thread, TRUE, INFINITE);
273         // block on the thread going away, then close the handle
274         if (thread->handle != NULL)
275         {
276            WaitForSingleObject(thread->handle, INFINITE);
277            CloseHandle(thread->handle);
278         }
224279
280         // clean up the wake event
281         if (thread->wakeevent != NULL)
282            CloseHandle(thread->wakeevent);
283      }
284
225285      // free the list
226286      free(queue->thread);
227287   }
r1070r1071
257317      free(item);
258318   }
259319
320#if KEEP_STATISTICS
321   printf("Items queued   = %9d\n", queue->itemsqueued);
322   printf("SetEvent calls = %9d\n", queue->setevents);
323   printf("Extra items    = %9d\n", queue->extraitems);
324   printf("Spin loops     = %9d\n", queue->spinloops);
325#endif
326
260327   // free the queue itself
261328   free(queue);
262329}
r1070r1071
274341   do
275342   {
276343      item = (osd_work_item *)queue->free;
277   } while (item != NULL && compare_exchange_pointer((PVOID volatile *)&queue->free, item->next, item) != item);
344   } while (item != NULL && osd_compare_exchange_ptr((PVOID volatile *)&queue->free, item, item->next) != item);
278345
279346   // if nothing, allocate something new
280347   if (item == NULL)
r1070r1071
283350      item = malloc(sizeof(*item));
284351      if (item == NULL)
285352         return NULL;
353      item->event = NULL;
354      item->queue = queue;
286355   }
287356
288357   // fill in the basics
r1070r1071
291360   item->param = param;
292361   item->result = NULL;
293362   item->flags = flags;
294   item->queue = queue;
295   item->complete = FALSE;
363   item->refcount = 1;
296364   if (item->event != NULL)
297365      ResetEvent(item->event);
298366
299367   // if no threads, just run it now
300368   if (queue->threads == 0)
301      return execute_work_item(item) ? item : NULL;
369   {
370      // execute the callback and clear the refcount back to 0
371      item->result = (*item->callback)(item->param);
372      item->refcount = 0;
302373
303   // otherwise, enqueue it
304   EnterCriticalSection(&queue->critsect);
305   *queue->tailptr = item;
306   queue->tailptr = (osd_work_item **)&item->next;
307   LeaveCriticalSection(&queue->critsect);
374      // handle auto-release; make sure we return NULL in that case
375      if (flags & WORK_ITEM_FLAG_AUTO_RELEASE)
376         osd_work_item_release(item);
377   }
308378
309   // if we're not full up, signal the event
310   if (interlocked_increment(&queue->items) == 1)
311      ResetEvent(queue->doneevent);
312   if (queue->livethreads < queue->threads)
313      SetEvent(queue->workevent);
379   // otherwise, enqueue the item and wake the threads
380   else
381   {
382      // enqueue within the critical section
383      EnterCriticalSection(&queue->critsect);
384      *queue->tailptr = item;
385      queue->tailptr = (osd_work_item **)&item->next;
386      LeaveCriticalSection(&queue->critsect);
314387
315   return item;
388      // increment the number of items in the queue
389      osd_sync_add(&queue->items, 1);
390      add_to_stat(&queue->itemsqueued, 1);
391
392      // non-shared case
393      if (!(flags & WORK_ITEM_FLAG_SHARED))
394      {
395         // if there are still some free threads, signal the shared work event
396         if (queue->livethreads < queue->threads)
397         {
398            SetEvent(queue->workevent);
399            add_to_stat(&queue->setevents, 1);
400         }
401      }
402
403      // shared case
404      else
405      {
406         int threadnum;
407
408         // signal the wake event for all non-active threads
409         for (threadnum = 0; threadnum < queue->threads; threadnum++)
410            if (!queue->thread[threadnum].active)
411            {
412               SetEvent(queue->thread[threadnum].wakeevent);
413               add_to_stat(&queue->setevents, 1);
414            }
415      }
416   }
417
418   // only return the item if it won't get released automatically
419   return (flags & WORK_ITEM_FLAG_AUTO_RELEASE) ? NULL : item;
316420}
317421
318422
r1070r1071
323427int osd_work_item_wait(osd_work_item *item, osd_ticks_t timeout)
324428{
325429   // if we're done already, just return
326   if (item->complete)
430   if (item->refcount == 0)
327431      return TRUE;
328432
329433   // if we don't have an event, create one
r1070r1071
333437   // if we don't have an event, we need to spin (shouldn't ever really happen)
334438   if (item->event != NULL)
335439   {
336      osd_ticks_t endtime = osd_ticks() + timeout;
337      while (!item->complete && endtime - osd_ticks() > 0) ;
440      osd_ticks_t stopspin = osd_ticks() + timeout;
441      while (item->refcount != 0 && osd_ticks() < stopspin)
442         YieldProcessor();
338443   }
339444
340445   // otherwise, block on the event until done
341   else if (!item->complete)
446   else if (item->refcount != 0)
342447      WaitForSingleObject(item->event, timeout * 1000 / osd_ticks_per_second());
343448
344   return item->complete;
449   // return TRUE if the refcount actually hit 0
450   return (item->refcount == 0);
345451}
346452
347453
r1070r1071
371477   {
372478      next = (osd_work_item *)item->queue->free;
373479      item->next = next;
374   } while (compare_exchange_pointer((PVOID volatile *)&item->queue->free, item, next) != next);
480   } while (osd_compare_exchange_ptr((PVOID volatile *)&item->queue->free, next, item) != next);
375481}
376482
377483
378484//============================================================
485//  effective_num_processors
486//============================================================
487
488static int effective_num_processors(void)
489{
490   char *procsoverride;
491   SYSTEM_INFO info;
492   int numprocs = 0;
493
494   // if the OSDPROCESSORS environment variable is set, use that value if valid
495   procsoverride = getenv("OSDPROCESSORS");
496   if (procsoverride != NULL && sscanf(procsoverride, "%d", &numprocs) == 1 && numprocs > 0)
497      return numprocs;
498
499   // otherwise, fetch the info from the system
500   GetSystemInfo(&info);
501   return info.dwNumberOfProcessors;
502}
503
504
505//============================================================
379506//  worker_thread_entry
380507//============================================================
381508
382static void worker_thread_entry(void *param)
509static unsigned __stdcall worker_thread_entry(void *param)
383510{
384   osd_work_queue *queue = param;
385   HANDLE hlist[2];
511   thread_info *thread = param;
512   osd_work_queue *queue = thread->queue;
513   HANDLE hlist[3];
386514
387515   // fill in our handle list
388516   hlist[0] = queue->workevent;
389   hlist[1] = queue->exitevent;
517   hlist[1] = thread->wakeevent;
518   hlist[2] = queue->exitevent;
390519
391520   // loop until we exit
392521   for ( ;; )
393522   {
394523      // block waiting for work or exit
395      DWORD result = WaitForMultipleObjects(ARRAY_LENGTH(hlist), hlist, FALSE, INFINITE);
524      DWORD result = WAIT_OBJECT_0;
396525
397      // bail on exit
398      if (result == WAIT_OBJECT_0 + 1)
526      // bail on exit, and only wait if there are no pending items in queue
527      if (queue->items == 0)
528         result = WaitForMultipleObjects(ARRAY_LENGTH(hlist), hlist, FALSE, INFINITE);
529      if (result == WAIT_OBJECT_0 + 2)
399530         break;
400531
401      // loop until everything is processed
402//again:
403      while (queue->items != 0)
532      // indicate that we are live
533      thread->active = TRUE;
534      osd_sync_add(&queue->livethreads, 1);
535
536      // process work items
537      for ( ;; )
404538      {
405         osd_work_item *item;
539         osd_ticks_t stopspin;
406540
407         // indicate that we are live
408         interlocked_increment(&queue->livethreads);
541         // process as much as we can
542         worker_thread_process(queue, thread);
409543
410         // pull an item off the head
411         EnterCriticalSection(&queue->critsect);
544         // spin for a while looking for more work
545         stopspin = osd_ticks() + osd_ticks_per_second() / 1000;
546         while (queue->items == 0 && osd_ticks() < stopspin)
547            YieldProcessor();
548
549         // if nothing more, release the processor
550         if (queue->items == 0)
551            break;
552         add_to_stat(&queue->spinloops, 1);
553      }
554
555      // decrement the live thread count
556      thread->active = FALSE;
557      osd_sync_add(&queue->livethreads, -1);
558   }
559   return 0;
560}
561
562
563//============================================================
564//  worker_thread_process
565//============================================================
566
567static void worker_thread_process(osd_work_queue *queue, thread_info *thread)
568{
569   // loop until everything is processed
570   while (queue->items != 0)
571   {
572      int removed_item = FALSE;
573      osd_work_item *item;
574
575      // use a critical section to synchronize the removal of items
576      EnterCriticalSection(&queue->critsect);
577      {
412578         item = (osd_work_item *)queue->list;
413         if (item != NULL)
579
580         // if it is a regular item, or if it is a shared item that is complete, remove it
581         if (item != NULL && (!(item->flags & WORK_ITEM_FLAG_SHARED) || item->refcount == 0))
414582         {
583            removed_item = TRUE;
415584            queue->list = item->next;
416585            if (item->next == NULL)
417586               queue->tailptr = (osd_work_item **)&queue->list;
418587         }
419         LeaveCriticalSection(&queue->critsect);
588      }
589      LeaveCriticalSection(&queue->critsect);
420590
421         // call the callback and signal its event
591      // call the callback and signal its event
592      if (item != NULL && item->refcount != 0)
422593         execute_work_item(item);
423594
424         // decrement the count
425         if (interlocked_decrement(&queue->items) == 0)
595      // if we removed an item, decrement the item count and signal done if appropriate
596      if (removed_item && osd_sync_add(&queue->items, -1) == 0)
597      {
598         // we don't need to set the doneevent for multi queues because they spin
599         if (!(item->flags & WORK_QUEUE_FLAG_MULTI))
426600            SetEvent(queue->doneevent);
427601
428         // decrement the live thread count
429         interlocked_decrement(&queue->livethreads);
602         // if it's an auto-release item, release it
603         if (item->flags & WORK_ITEM_FLAG_AUTO_RELEASE)
604            osd_work_item_release(item);
430605      }
431606
432      // hard loop for a while
433/*{
434    int count = 0;
435        while (queue->items == 0 && count++ < 10000000) ;
436    if (queue->items != 0) goto again;
437}*/
607      // if we removed an item and there's still work to do, bump the stats
608      if (removed_item && queue->items != 0)
609         add_to_stat(&queue->extraitems, 1);
438610   }
439611}
440612
r1070r1071
443615//  execute_work_item
444616//============================================================
445617
446static int execute_work_item(osd_work_item *item)
618static void execute_work_item(osd_work_item *item)
447619{
620   void *result;
621
622   // add a claim to this work item; if it had already been completed, back off and exit
623   if (osd_sync_add(&item->refcount, 1) == 1)
624   {
625      item->refcount = 0;
626      return;
627   }
628
448629   // call the callback and stash the result
449   item->result = (*item->callback)(item->param);
630   result = (*item->callback)(item->param);
450631
451632   // mark it complete and signal the event
452   item->complete = TRUE;
453   if (item->event != NULL)
454      SetEvent(item->event);
455
456   // if it's an auto-release item, release it
457   if (item->flags & WORK_ITEM_FLAG_AUTO_RELEASE)
633   if (osd_sync_add(&item->refcount, -1) == 1 && osd_compare_exchange32(&item->refcount, 1, 0) == 1)
458634   {
459      osd_work_item_release(item);
460      return FALSE;
635      // set the result and signal the event
636      item->result = result;
637      if (item->event != NULL)
638         SetEvent(item->event);
461639   }
462
463   return TRUE;
464640}
src/osd/windows/video.h
r1070r1071
9797float winvideo_monitor_get_aspect(win_monitor_info *monitor);
9898win_monitor_info *winvideo_monitor_from_handle(HMONITOR monitor);
9999
100void winvideo_set_frameskip(int frameskip);      // <0 = auto
101int winvideo_get_frameskip(void);            // <0 = auto
102
103100#endif
src/osd/windows/window.h
r1070r1071
9696// windows
9797extern win_window_info *win_window_list;
9898
99// visible bounds
100extern RECT         win_visible_rect;
101extern int         win_visible_width;
102extern int         win_visible_height;
10399
104// raw input support
105extern int         win_use_raw_mouse;
106100
107
108
109101//============================================================
110102//  PROTOTYPES
111103//============================================================
src/emu/debug/debugvw.h
r1070r1071
158158void            debug_view_update_type(int type);
159159
160160/* misc stuff */
161void            debug_view_add_to_errorlog(const char *text);
162161void            debug_disasm_update_all(void);
163162
164163
src/emu/cpu/m68000/m68kcpu.h
r1070r1071
19321932     */
19331933   if(CPU_RUN_MODE == RUN_MODE_BERR_AERR_RESET)
19341934   {
1935m68k_read_memory_8(0x00ffff01);
1935      m68k_read_memory_8(0x00ffff01);
19361936      CPU_STOPPED = STOP_LEVEL_HALT;
19371937      return;
19381938   }
src/emu/cpu/cpu.mak
r1070r1071
14341434$(CPUOBJ)/tms9900/tms9900.o:   $(CPUSRC)/tms9900/tms9900.c \
14351435                        $(CPUSRC)/tms9900/tms9900.h \
14361436                        $(CPUSRC)/tms9900/99xxcore.h \
1437                        $(CPUSRC)/tms9900/9900stat.h
1437                        $(CPUSRC)/tms9900/99xxstat.h
14381438
14391439$(CPUOBJ)/tms9900/tms9980a.o:   $(CPUSRC)/tms9900/tms9980a.c \
14401440                        $(CPUSRC)/tms9900/tms9900.h \
src/emu/cpu/drcfe.c
r1070r1071
282282      return desc;
283283   }
284284
285   /* get a pointer to the physical address */
286   memory_set_opbase(desc->physpc);
287   desc->opptr.v = cpu_opptr(desc->physpc);
288   assert(desc->opptr.v != NULL);
289   if (desc->opptr.v == NULL)
290   {
291      /* address is unmapped; report it as such */
292      desc->flags |= OPFLAG_VALIDATE_TLB | OPFLAG_CAN_CAUSE_EXCEPTION | OPFLAG_COMPILER_UNMAPPED | OPFLAG_VIRTUAL_NOOP;
293      return desc;
294   }
295
285296   /* call the callback to describe an instruction */
286297   if (!(*drcfe->describe)(drcfe->param, desc))
287298   {
r1070r1071
340351   UINT64 fprread = 0, fprwrite = 0;
341352   int consecutive = 0;
342353   int seqstart = -1;
354   int skipsleft = 0;
343355   int descnum;
344356
345357   /* iterate in order from start to end, picking up all non-NULL instructions */
r1070r1071
348360      {
349361         opcode_desc *curdesc = drcfe->desc_array[descnum];
350362         opcode_desc *nextdesc = NULL;
351         int scandescnum;
363         int nextdescnum;
364         UINT8 skipnum;
352365
353         /* determine the next instruction */
354         if (descnum + curdesc->length < end)
355            nextdesc = drcfe->desc_array[descnum + curdesc->length];
366         /* determine the next instruction, taking skips into account */
367         nextdescnum = descnum + curdesc->length;
368         nextdesc = (nextdescnum < end) ? drcfe->desc_array[nextdescnum] : NULL;
369         for (skipnum = 0; skipnum < curdesc->skipslots && nextdesc != NULL; skipnum++)
370         {
371            nextdescnum = nextdescnum + nextdesc->length;
372            nextdesc = (nextdescnum < end) ? drcfe->desc_array[nextdescnum] : NULL;
373         }
356374
357375         /* start a new sequence if we aren't already in the middle of one */
358376         if (seqstart == -1)
r1070r1071
365383         /* otherwise, do some analysis based on the next instruction */
366384         else
367385         {
386            opcode_desc *scandesc = NULL;
387            int scandescnum;
388
368389            /* if there are instructions between us and the next instruction, we must end our sequence here */
369            for (scandescnum = 1; scandescnum < curdesc->length; scandescnum++)
370               if (drcfe->desc_array[descnum + scandescnum] != NULL)
390            for (scandescnum = descnum + 1; scandescnum < end; scandescnum++)
391            {
392               scandesc = drcfe->desc_array[scandescnum];
393               if (scandesc != NULL || scandesc == nextdesc)
371394                  break;
372            if (scandescnum != curdesc->length)
395            }
396            if (scandesc != nextdesc)
373397               curdesc->flags |= OPFLAG_END_SEQUENCE;
374398
375399            /* if the next instruction is a branch target, mark this instruction as end of sequence */
r1070r1071
404428            fprread = fprwrite = 0;
405429         }
406430
407         /* add us to the end of the list and clear our array slot */
408         *tailptr = curdesc;
409         tailptr = &curdesc->next;
431         /* if we have instructions remaining to be skipped, and this instruction is a branch target */
432         /* belay the skip order */
433         if (skipsleft > 0 && (curdesc->flags & OPFLAG_IS_BRANCH_TARGET))
434            skipsleft = 0;
435
436         /* if we're not getting skipped, add us to the end of the list and clear our array slot */
437         if (skipsleft == 0)
438         {
439            *tailptr = curdesc;
440            tailptr = &curdesc->next;
441         }
442         else
443            desc_free(drcfe, curdesc);
444
445         /* if the current instruction starts skipping, reset our skip count */
446         /* otherwise, just decrement */
447         if (curdesc->skipslots > 0)
448            skipsleft = curdesc->skipslots;
449         else if (skipsleft > 0)
450            skipsleft--;
410451      }
411452
412453   /* zap the array */
src/emu/cpu/i86/i286intf.h
r1070r1071
4141};
4242
4343/* Public functions */
44extern void i80286_set_irq_line(int irqline, int state);
45extern void i80286_set_irq_callback(int (*callback)(int irqline));
46extern const char *i80286_info(void *context, int regnum);
4744void i80286_get_info(UINT32 state, cpuinfo *info);
4845
4946#endif
src/emu/cpu/i86/instr86.c
r1070r1071
538538      for (; count > 0; count--)
539539      {
540540         if (ICOUNT <= 0) { I.pc = I.prevpc; break; }
541         PutMemB(ES,I.regs.w[DI],I.regs.b[AL]);
542         PutMemB(ES,I.regs.w[DI]+1,I.regs.b[AH]);
541         PutMemW(ES,I.regs.w[DI],I.regs.w[AX]);
543542         I.regs.w[DI] += 2 * I.DirVal;
544543         ICOUNT -= cycles.rep_stos16_count;
545544      }
r1070r1071
19881987
19891988static void PREFIX86(_wait)(void)    /* Opcode 0x9b */
19901989{
1991/* PJB 03/05 */
1992        if(!I.test_state) ICOUNT -= cycles.wait;
1993        else{
1994            ICOUNT -= cycles.wait;
1995            I.pc --;
1996        }
1990   if (I.test_state)
1991   {
1992      ICOUNT = 0;
1993      I.pc--;
1994   }
1995   else
1996      ICOUNT -= cycles.wait;
19971997}
19981998
19991999static void PREFIX86(_pushf)(void)    /* Opcode 0x9c */
r1070r1071
20562056   addr += FETCH << 8;
20572057
20582058   ICOUNT -= cycles.mov_am16;
2059   I.regs.b[AL] = GetMemB(DS, addr);
2060   I.regs.b[AH] = GetMemB(DS, addr+1);
2059   I.regs.w[AX] = GetMemW(DS, addr);
20612060}
20622061
20632062static void PREFIX86(_mov_dispal)(void)    /* Opcode 0xa2 */
r1070r1071
20792078   addr += FETCH << 8;
20802079
20812080   ICOUNT -= cycles.mov_ma16;
2082   PutMemB(DS, addr, I.regs.b[AL]);
2083   PutMemB(DS, addr+1, I.regs.b[AH]);
2081   PutMemW(DS, addr, I.regs.w[AX]);
20842082}
20852083
20862084static void PREFIX86(_movsb)(void)    /* Opcode 0xa4 */
r1070r1071
21442142
21452143static void PREFIX86(_stosw)(void)    /* Opcode 0xab */
21462144{
2147   PutMemB(ES,I.regs.w[DI],I.regs.b[AL]);
2148   PutMemB(ES,I.regs.w[DI]+1,I.regs.b[AH]);
2145   PutMemW(ES,I.regs.w[DI],I.regs.w[AX]);
21492146   I.regs.w[DI] += 2 * I.DirVal;
21502147   ICOUNT -= cycles.stos16;
21512148}
src/emu/cpu/drcfe.h
r1070r1071
6868#define OPFLAG_VALIDATE_TLB            0x00000200      /* instruction must validate TLB before execution */
6969#define OPFLAG_MODIFIES_TRANSLATION      0x00000400      /* instruction modifies the TLB */
7070#define OPFLAG_COMPILER_PAGE_FAULT      0x00000800      /* compiler hit a page fault when parsing */
71#define OPFLAG_COMPILER_UNMAPPED      0x00001000      /* compiler hit unmapped memory when parsing */
7172
7273/* opcode flags */
73#define OPFLAG_INVALID_OPCODE         0x00001000      /* instruction is invalid */
74#define OPFLAG_VIRTUAL_NOOP            0x00002000      /* instruction is a virtual no-op */
74#define OPFLAG_INVALID_OPCODE         0x00002000      /* instruction is invalid */
75#define OPFLAG_VIRTUAL_NOOP            0x00004000      /* instruction is a virtual no-op */
7576
7677/* opcode sequence flow flags */
77#define OPFLAG_REDISPATCH            0x00004000      /* instruction must redispatch after completion */
78#define OPFLAG_RETURN_TO_START         0x00008000      /* instruction must jump back to the beginning after completion */
79#define OPFLAG_END_SEQUENCE            0x00010000      /* this is the last instruction in a sequence */
80#define OPFLAG_CAN_CHANGE_MODES         0x00020000      /* instruction can change modes */
78#define OPFLAG_REDISPATCH            0x00008000      /* instruction must redispatch after completion */
79#define OPFLAG_RETURN_TO_START         0x00010000      /* instruction must jump back to the beginning after completion */
80#define OPFLAG_END_SEQUENCE            0x00020000      /* this is the last instruction in a sequence */
81#define OPFLAG_CAN_CHANGE_MODES         0x00040000      /* instruction can change modes */
8182
8283/* execution semantics */
83#define OPFLAG_READS_MEMORY            0x00040000      /* instruction reads memory */
84#define OPFLAG_WRITES_MEMORY         0x00080000      /* instruction writes memory */
85#define OPFLAG_VARIABLE_SHIFT         0x00100000      /* instruction performs a variable count shift */
86#define OPFLAG_MULTIPLY_DIVIDE         0x00200000      /* instruction performs a multiply/divide */
84#define OPFLAG_READS_MEMORY            0x00080000      /* instruction reads memory */
85#define OPFLAG_WRITES_MEMORY         0x00100000      /* instruction writes memory */
86#define OPFLAG_VARIABLE_SHIFT         0x00200000      /* instruction performs a variable count shift */
87#define OPFLAG_MULTIPLY_DIVIDE         0x00400000      /* instruction performs a multiply/divide */
8788
8889
8990
r1070r1071
124125   /* pointer to the current opcode */
125126   union
126127   {
128      void *      v;
127129      UINT8 *      b;
128130      UINT16 *   w;
129131      UINT32 *   l;
r1070r1071
133135   /* information about this instruction's execution */
134136   UINT8         length;               /* length in bytes of this opcode */
135137   UINT8         delayslots;            /* number of delay slots (for branches) */
138   UINT8         skipslots;            /* number of skip slots (for branches) */
136139   UINT32         flags;               /* OPFLAG_* opcode flags */
137140   UINT32         cycles;               /* number of cycles needed to execute */
138141
r1070r1071
153156   UINT32         window_start;         /* code window start offset = startpc - window_start */
154157   UINT32         window_end;            /* code window end offset = startpc + window_end */
155158   UINT32         max_sequence;         /* maximum instructions to include in a sequence */
156
157159   drcfe_describe   describe;            /* callback to describe a single instruction */
158160};
159161
162/*
163    for each register:
164        callback to load
165        callback to store
166        pointer to memory
167    if (pointer != NULL)
168        - can return reference to memory for operations
169    else
170        - must always load/store from register
171*/
160172
161173
162174/***************************************************************************
src/emu/cpu/minx/minxfunc.h
r1070r1071
249249   JMP( arg );
250250}
251251
252UINT32 addr1, addr2;
252static UINT32 addr1, addr2;
253253
254254#define AD1_IHL   addr1 = ( regs.I << 16 ) | regs.HL;
255255#define AD1_IN8   addr1 = ( regs.I << 16 ) | ( regs.N << 8 ) | rdop();
src/emu/cpu/v60/v60.h
r1070r1071
7676};
7777
7878extern const char *v60_reg_names[];
79void v60_dasm_init(void);
8079void v60_stall(void);
8180
8281#if HAS_V60
src/emu/cpu/spc700/spc700ds.h
r1070r1071
2121
2222offs_t spc700_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram);
2323
24unsigned int spc700_read_8_disassembler(unsigned int address);
25
2624#define spc700_read_8_disassembler(addr)            program_read_byte_8(addr)
2725
2826
src/emu/cpu/m6502/m6502.h
r1070r1071
116116
117117extern void m6510t_get_info(UINT32 state, cpuinfo *info);
118118
119#ifdef MAME_DEBUG
120extern unsigned m6510t_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram);
121119#endif
122120
123#endif
124
125121#if (HAS_M7501)
126122#define M7501_A                   M6502_A
127123#define M7501_X                   M6502_X
src/emu/cpu/powerpc/ppc.h
r1070r1071
326326typedef void  (* SPU_TX_HANDLER)(UINT8);
327327typedef void (* PPC_DMA_HANDLER)(int);
328328
329void ppc403_get_info(UINT32 state, cpuinfo *info);
330329void ppc403_spu_rx(UINT8 data);
331330void ppc403_install_spu_rx_handler(SPU_RX_HANDLER rx_handler);
332331void ppc403_install_spu_tx_handler(SPU_TX_HANDLER tx_handler);
src/emu/cpu/nec/nec.c
r1070r1071
643643OP( 0x9f, i_lahf      ) { I.regs.b[AH] = CompressFlags() & 0xff; CLKS(3,3,2); }
644644
645645OP( 0xa0, i_mov_aldisp ) { UINT32 addr; FETCHWORD(addr); I.regs.b[AL] = GetMemB(DS0, addr); CLKS(10,10,5); }
646OP( 0xa1, i_mov_axdisp ) { UINT32 addr; FETCHWORD(addr); I.regs.b[AL] = GetMemB(DS0, addr); I.regs.b[AH] = GetMemB(DS0, (addr+1)&0xffff); CLKW(14,14,7,14,10,5,addr); }
646OP( 0xa1, i_mov_axdisp ) { UINT32 addr; FETCHWORD(addr); I.regs.w[AW] = GetMemW(DS0, addr); CLKW(14,14,7,14,10,5,addr); }
647647OP( 0xa2, i_mov_dispal ) { UINT32 addr; FETCHWORD(addr); PutMemB(DS0, addr, I.regs.b[AL]);  CLKS(9,9,3); }
648OP( 0xa3, i_mov_dispax ) { UINT32 addr; FETCHWORD(addr); PutMemB(DS0, addr, I.regs.b[AL]); PutMemB(DS0, (addr+1)&0xffff, I.regs.b[AH]); CLKW(13,13,5,13,9,3,addr); }
648OP( 0xa3, i_mov_dispax ) { UINT32 addr; FETCHWORD(addr); PutMemW(DS0, addr, I.regs.w[AW]); CLKW(13,13,5,13,9,3,addr); }
649649OP( 0xa4, i_movsb      ) { UINT32 tmp = GetMemB(DS0,I.regs.w[IX]); PutMemB(DS1,I.regs.w[IY], tmp); I.regs.w[IY] += -2 * I.DF + 1; I.regs.w[IX] += -2 * I.DF + 1; CLKS(8,8,6); }
650650OP( 0xa5, i_movsw      ) { UINT32 tmp = GetMemW(DS0,I.regs.w[IX]); PutMemW(DS1,I.regs.w[IY], tmp); I.regs.w[IY] += -4 * I.DF + 2; I.regs.w[IX] += -4 * I.DF + 2; CLKS(16,16,10); }
651651OP( 0xa6, i_cmpsb      ) { UINT32 src = GetMemB(DS1, I.regs.w[IY]); UINT32 dst = GetMemB(DS0, I.regs.w[IX]); SUBB; I.regs.w[IY] += -2 * I.DF + 1; I.regs.w[IX] += -2 * I.DF + 1; CLKS(14,14,14); }
src/emu/cpu/mips/mdrc64.c
r1070r1071
6060            anything and tracks both, or else shifts ownership to new
6161            target
6262
63        * generic frontend:
64            * flags to indicate variable shifts and multiply/divides
65                to help register allocator avoid ECX/EDX/EAX as
66                appropriate
67
6863        * generic drc:
6964            * common code to load registers prior to instruction
7065                - each register has a callback that generates the load
r1070r1071
9085    DEBUGGING
9186***************************************************************************/
9287
93#define SINGLE_INSTRUCTION_MODE         (0)
9488#define DISABLE_FIXED_RAM_LOAD         (0)
9589#define DISABLE_FIXED_RAM_STORE         (0)
9690#define FLUSH_AFTER_EACH_INSTRUCTION   (0)
r1070r1071
224218
225219struct _oob_handler
226220{
227   oob_callback   callback;            /* pointer to callback function */
228   void *         param;               /* callback parameter */
229   const mips3_opcode_desc *desc;         /* pointer to description of relevant instruction */
230   emit_link      link;               /* link to source of the branch */
231   compiler_state   compiler;            /* state of the compiler at this time */
221   oob_callback      callback;         /* pointer to callback function */
222   void *            param;            /* callback parameter */
223   const opcode_desc *   desc;            /* pointer to description of relevant instruction */
224   emit_link         link;            /* link to source of the branch */
225   compiler_state      compiler;         /* state of the compiler at this time */
232226};
233227
234228
r1070r1071
270264   oob_handler      ooblist[COMPILE_MAX_INSTRUCTIONS*2];
271265   int            oobcount;
272266
273#if COMPARE_AGAINST_C
274267   /* C functions */
275268   x86code *      execute_c_version;
276#endif
277269};
278270
279271
r1070r1071
286278static void drc_recompile_callback(drc_core *drc);
287279static void drc_entrygen_callback(drc_core *drc);
288280
289static void compile_one(drc_core *drc, compiler_state *compiler, mips3_opcode_desc *desc);
281static void compile_one(drc_core *drc, compiler_state *compiler, const opcode_desc *desc);
290282
291283static void oob_exception_cleanup(drc_core *drc, oob_handler *oob, void *param);
292284static void oob_interrupt_cleanup(drc_core *drc, oob_handler *oob, void *param);
293285
294286static void compiler_register_set_constant(compiler_state *compiler, UINT8 mipsreg, UINT64 constval);
295static mipsreg_state compiler_register_allocate(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, UINT8 mipsreg, UINT8 flags);
287static mipsreg_state compiler_register_allocate(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, UINT8 mipsreg, UINT8 flags);
296288static void compiler_register_flush(drc_core *drc, compiler_state *compiler, UINT8 mipsreg, int free);
297289static void compiler_register_flush_all(drc_core *drc, compiler_state *compiler);
298290
r1070r1071
305297static void append_find_exception_handler(drc_core *drc);
306298static void append_explode_ccr31(drc_core *drc);
307299static void append_recover_ccr31(drc_core *drc);
308static void append_check_interrupts(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc);
300static void append_check_interrupts(drc_core *drc, compiler_state *compiler, const opcode_desc *desc);
309301static void append_check_sw_interrupts(drc_core *drc, int inline_generate);
310302
311static int compile_instruction(drc_core *drc, compiler_state *compiler, mips3_opcode_desc *desc);
312static int compile_special(drc_core *drc, compiler_state *compiler, mips3_opcode_desc *desc);
313static int compile_regimm(drc_core *drc, compiler_state *compiler, mips3_opcode_desc *desc);
314static int compile_idt(drc_core *drc, compiler_state *compiler, mips3_opcode_desc *desc);
315static int compile_cop0(drc_core *drc, compiler_state *compiler, mips3_opcode_desc *desc);
316static int compile_cop1(drc_core *drc, compiler_state *compiler, mips3_opcode_desc *desc);
317static int compile_cop1x(drc_core *drc, compiler_state *compiler, mips3_opcode_desc *desc);
303static int compile_instruction(drc_core *drc, compiler_state *compiler, const opcode_desc *desc);
304static int compile_special(drc_core *drc, compiler_state *compiler, const opcode_desc *desc);
305static int compile_regimm(drc_core *drc, compiler_state *compiler, const opcode_desc *desc);
306static int compile_idt(drc_core *drc, compiler_state *compiler, const opcode_desc *desc);
307static int compile_cop0(drc_core *drc, compiler_state *compiler, const opcode_desc *desc);
308static int compile_cop1(drc_core *drc, compiler_state *compiler, const opcode_desc *desc);
309static int compile_cop1x(drc_core *drc, compiler_state *compiler, const opcode_desc *desc);
318310
319static int compile_shift(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int shift_type, int shift_variable);
320static int compile_dshift(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int shift_type, int shift_variable, int shift_const_plus32);
321static int compile_movzn(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int is_movn);
322static int compile_trapcc(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int condition, int immediate);
323static int compile_branchcc(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int condition);
324static int compile_branchcz(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int condition, int link);
325static int compile_add(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int suppress_exceptions, int immediate);
326static int compile_dadd(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int suppress_exceptions, int immediate);
327static int compile_sub(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int suppress_exceptions);
328static int compile_dsub(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int suppress_exceptions);
329static int compile_mult(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int is_unsigned);
330static int compile_dmult(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int is_unsigned);
331static int compile_div(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int is_unsigned);
332static int compile_ddiv(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int is_unsigned);
333static int compile_logical(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int operation, int immediate);
334static int compile_slt(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int is_unsigned, int immediate);
335static int compile_load(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int size, int is_unsigned);
336static int compile_load_cop(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int size, void *dest);
337static int compile_loadx_cop(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int size, void *dest);
338static int compile_load_word_partial(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int is_right);
339static int compile_load_double_partial(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int is_right);
340static int compile_store(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int size);
341static int compile_store_cop(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int size, void *src);
342static int compile_storex_cop(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int size, void *src);
343static int compile_store_word_partial(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int is_right);
344static int compile_store_double_partial(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int is_right);
311static int compile_shift(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int shift_type, int shift_variable);
312static int compile_dshift(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int shift_type, int shift_variable, int shift_const_plus32);
313static int compile_movzn(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int is_movn);
314static int compile_trapcc(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int condition, int immediate);
315static int compile_branchcc(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int condition);
316static int compile_branchcz(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int condition, int link);
317static int compile_add(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int suppress_exceptions, int immediate);
318static int compile_dadd(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int suppress_exceptions, int immediate);
319static int compile_sub(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int suppress_exceptions);
320static int compile_dsub(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int suppress_exceptions);
321static int compile_mult(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int is_unsigned);
322static int compile_dmult(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int is_unsigned);
323static int compile_div(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int is_unsigned);
324static int compile_ddiv(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int is_unsigned);
325static int compile_logical(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int operation, int immediate);
326static int compile_slt(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int is_unsigned, int immediate);
327static int compile_load(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int size, int is_unsigned);
328static int compile_load_cop(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int size, void *dest);
329static int compile_loadx_cop(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int size, void *dest);
330static int compile_load_word_partial(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int is_right);
331static int compile_load_double_partial(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int is_right);
332static int compile_store(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int size);
333static int compile_store_cop(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int size, void *src);
334static int compile_storex_cop(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int size, void *src);
335static int compile_store_word_partial(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int is_right);
336static int compile_store_double_partial(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int is_right);
345337
346338
347339
r1070r1071
370362    bounds callback for later
371363-------------------------------------------------*/
372364
373INLINE void oob_request_callback(drc_core *drc, UINT8 condition, oob_callback callback, const compiler_state *compiler, const mips3_opcode_desc *desc, void *param)
365INLINE void oob_request_callback(drc_core *drc, UINT8 condition, oob_callback callback, const compiler_state *compiler, const opcode_desc *desc, void *param)
374366{
375367   oob_handler *oob = &mips3.drcdata->ooblist[mips3.drcdata->oobcount++];
376368
r1070r1071
423415   memset(&drconfig, 0, sizeof(drconfig));
424416   drconfig.cache_base       = mips3.cache;
425417   drconfig.cache_size       = CACHE_SIZE;
426   drconfig.max_instructions = MAX_INSTRUCTIONS;
418   drconfig.max_instructions = (512 + 128) / 4;
427419   drconfig.address_bits     = 32;
428420   drconfig.lsbs_to_ignore   = 2;
429421   drconfig.baseptr         = &mips3.core->r[17];
r1070r1071
467459static void mips3drc_exit(void)
468460{
469461   printf("Final code size = %d\n", (int)(mips3.drc->cache_top - mips3.drc->cache_base));
470   mips3fe_exit();
471462}
472463
473464
r1070r1071
568559
569560static void drc_recompile_callback(drc_core *drc)
570561{
571   int maxseq = (Machine->debug_mode || SINGLE_INSTRUCTION_MODE) ? 1 : MAX_INSTRUCTION_SEQUENCE;
572562   int compiled_last_sequence = FALSE;
573   mips3_opcode_desc *seqhead, *seqlast;
574   mips3_opcode_desc *desclist;
563   const opcode_desc *seqhead, *seqlast;
564   const opcode_desc *desclist;
575565   void *start = drc->cache_top;
576566   int override = FALSE;
577567   int oobnum;
r1070r1071
583573   mips3.drcdata->oobcount = 0;
584574
585575   /* get a description of this sequence */
586   desclist = mips3fe_describe_sequence(mips3.core, mips3.core->pc, mips3.core->pc - 128, mips3.core->pc + 512, maxseq);
576   desclist = drcfe_describe_code(mips3.drcfe, mips3.core->pc);
587577   if (LOG_CODE)
588578      log_opcode_desc(mips3.log, desclist, 0);
589579
590580   /* loop until we get through all instruction sequences */
591581   for (seqhead = desclist; seqhead != NULL; seqhead = seqlast->next)
592582   {
593      mips3_opcode_desc *curdesc;
583      const opcode_desc *curdesc;
594584      compiler_state compiler;
595585
596586      /* determine the last instruction in this sequence */
597587      for (seqlast = seqhead; seqlast != NULL; seqlast = seqlast->next)
598         if (seqlast->flags & IDESC_END_SEQUENCE)
588         if (seqlast->flags & OPFLAG_END_SEQUENCE)
599589            break;
600590      assert(seqlast != NULL);
601591
r1070r1071
630620      {
631621         if (LOG_CODE)
632622            x86log_add_comment(mips3.log, drc->cache_top, "[Validation for %08X]", seqhead->pc);
633         emit_mov_r64_imm(DRCTOP, REG_RAX, (UINT64)seqhead->opptr);                     // mov  rax,seqhead->opptr
623         emit_mov_r64_imm(DRCTOP, REG_RAX, (UINT64)seqhead->opptr.v);                  // mov  rax,seqhead->opptr
634624         for (curdesc = seqhead; curdesc != seqlast->next; curdesc = curdesc->next)
635625         {
636            emit_cmp_m32_imm(DRCTOP, MBD(REG_RAX, (UINT8 *)curdesc->opptr - (UINT8 *)seqhead->opptr), *curdesc->opptr);
626            emit_cmp_m32_imm(DRCTOP, MBD(REG_RAX, curdesc->opptr.b - seqhead->opptr.b), *curdesc->opptr.l);
637627                                                                        // cmp  [code],val
638628            emit_jcc(DRCTOP, COND_NE, mips3.drc->recompile);                        // jne  recompile
639629         }
r1070r1071
647637         compile_one(drc, &compiler, curdesc);
648638
649639      /* at the end of the sequence; update the PC in memory and check cycle counts */
650      if (!(seqlast->flags & (IDESC_IS_UNCONDITIONAL_BRANCH | IDESC_WILL_CAUSE_EXCEPTION)))
640      if (!(seqlast->flags & (OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_WILL_CAUSE_EXCEPTION)))
651641      {
652         UINT32 nextpc = seqlast->pc + ((seqlast->flags & IDESC_IS_LIKELY_BRANCH) ? 8 : 4);
642         UINT32 nextpc = seqlast->pc + (seqlast->skipslots + 1) * 4;
653643         if (compiler.cycles != 0)
654644            emit_sub_m32_imm(DRCTOP, ICOUNTADDR, compiler.cycles);                  // sub  [icount],cycles
655645         emit_mov_r32_imm(DRCTOP, REG_P1, nextpc);                              // mov  p1,nextpc
r1070r1071
659649      }
660650
661651      /* if this is a likely branch, the fall through case needs to skip the next instruction */
662      if ((seqlast->flags & (IDESC_IS_CONDITIONAL_BRANCH | IDESC_IS_LIKELY_BRANCH)) == (IDESC_IS_CONDITIONAL_BRANCH | IDESC_IS_LIKELY_BRANCH))
652      if ((seqlast->flags & OPFLAG_IS_CONDITIONAL_BRANCH) && seqlast->skipslots > 0)
663653         if (seqlast->next != NULL && seqlast->next->pc != seqlast->pc + 8)
664654         {
665655            compiler_register_flush_all(drc, &compiler);
r1070r1071
667657         }
668658
669659      /* if we need a redispatch, do it now */
670      if (seqlast->flags & IDESC_REDISPATCH)
660      if (seqlast->flags & OPFLAG_REDISPATCH)
671661      {
672         UINT32 nextpc = seqlast->pc + ((seqlast->flags & IDESC_IS_LIKELY_BRANCH) ? 8 : 4);
662         UINT32 nextpc = seqlast->pc + (seqlast->skipslots + 1) * 4;
673663         compiler_register_flush_all(drc, &compiler);
674664          drc_append_tentative_fixed_dispatcher(drc, nextpc, TRUE);                  // jmp  <nextpc>
675665       }
676666
677667       /* if we need to return to the start, do it */
678      if (seqlast->flags & IDESC_RETURN_TO_START)
668      if (seqlast->flags & OPFLAG_RETURN_TO_START)
679669      {
680670         compiler_register_flush_all(drc, &compiler);
681671          drc_append_tentative_fixed_dispatcher(drc, mips3.core->pc, FALSE);            // jmp  <startpc>
682672      }
683673   }
684674
685   /* free the list */
686   mips3fe_release_descriptions(desclist);
687
688675   /* end the sequence */
689676   drc_end_sequence(drc);
690677
r1070r1071
724711    compile_one
725712------------------------------------------------------------------*/
726713
727static void compile_one(drc_core *drc, compiler_state *compiler, mips3_opcode_desc *desc)
714static void compile_one(drc_core *drc, compiler_state *compiler, const opcode_desc *desc)
728715{
729716   int hotnum;
730717
731718   /* register this instruction */
732   if (!(desc->flags & IDESC_IN_DELAY_SLOT))
719   if (!(desc->flags & OPFLAG_IN_DELAY_SLOT))
733720      drc_register_code_at_cache_top(drc, desc->pc);
734721
735722   /* add an entry for the log */
736723   if (LOG_CODE)
737      log_add_disasm_comment(mips3.log, drc->cache_top, desc->pc, *desc->opptr);
724      log_add_disasm_comment(mips3.log, drc->cache_top, desc->pc, *desc->opptr.l);
738725
739726   /* if we want a probe, add it here */
740727   if (desc->pc == PROBE_ADDRESS)
r1070r1071
746733   }
747734
748735   /* if we are debugging, call the debugger */
749   if (Machine->debug_mode)
736   if (Machine->debug_mode || COMPARE_AGAINST_C)
750737   {
751738      emit_mov_m32_imm(DRCTOP, PCADDR, desc->pc);                                 // mov  [pc],desc->pc
752#if COMPARE_AGAINST_C
753      if (!(desc->flags & IDESC_IN_DELAY_SLOT))
739      if (COMPARE_AGAINST_C && !(desc->flags & OPFLAG_IN_DELAY_SLOT))
754740         emit_call_m64(DRCTOP, MDRC(&mips3.drcdata->execute_c_version));
755#endif
756      drc_append_call_debugger(drc);                                          // <call debugger>
741      if (Machine->debug_mode)
742         drc_append_call_debugger(drc);                                       // <call debugger>
757743   }
758744
759745   /* validate our TLB entry at this PC; if we fail, we need to recompile */
760   if (desc->flags & IDESC_VALIDATE_TLB)
746   if ((desc->flags & OPFLAG_VALIDATE_TLB) && (desc->pc < 0x80000000 || desc->pc >= 0xc0000000))
761747   {
762748      emit_cmp_m32_imm(DRCTOP, MDRC(&mips3.core->tlb_table[desc->pc >> 12]), mips3.core->tlb_table[desc->pc >> 12]);
763749                                                                     // cmp  tlb_table[pc>>12],<original value>
r1070r1071
770756
771757   /* is this a hotspot? */
772758   for (hotnum = 0; hotnum < MIPS3_MAX_HOTSPOTS; hotnum++)
773      if (desc->pc == mips3.hotspot[hotnum].pc && *desc->opptr == mips3.hotspot[hotnum].opcode)
759      if (desc->pc == mips3.hotspot[hotnum].pc && *desc->opptr.l == mips3.hotspot[hotnum].opcode)
774760      {
775761         compiler->cycles += mips3.hotspot[hotnum].cycles;
776762         break;
777763      }
778764
779765   /* if this is an invalid opcode, generate the exception now */
780   if (desc->flags & IDESC_INVALID_OPCODE)
766   if (desc->flags & OPFLAG_INVALID_OPCODE)
781767      oob_request_callback(drc, COND_NONE, oob_exception_cleanup, compiler, desc, mips3.drcdata->generate_invalidop_exception);
782768
783769   /* otherwise, it's a regular instruction */
784770   else
785771   {
786      UINT32 nextpc = desc->pc + ((desc->flags & IDESC_IS_LIKELY_BRANCH) ? 8 : 4);
787
788772      /* compile the instruction */
789773      if (!compile_instruction(drc, compiler, desc))
790         fatalerror("Unimplemented op %08X (%02X,%02X)", *desc->opptr, *desc->opptr >> 26, *desc->opptr & 0x3f);
774         fatalerror("Unimplemented op %08X (%02X,%02X)", *desc->opptr.l, *desc->opptr.l >> 26, *desc->opptr.l & 0x3f);
791775
792776      /* flush */
793777      if (FLUSH_AFTER_EACH_INSTRUCTION)
r1070r1071
842826      emit_sub_m32_imm(DRCTOP, ICOUNTADDR, oob->compiler.cycles);                     // sub  [icount],cycles
843827
844828   /* update the PC with the instruction PC */
845   if (!(oob->desc->flags & IDESC_IN_DELAY_SLOT))
829   if (!(oob->desc->flags & OPFLAG_IN_DELAY_SLOT))
846830      emit_mov_r32_imm(DRCTOP, REG_P1, oob->desc->pc);                           // mov  p1,pc
847831   else
848832      emit_mov_r32_imm(DRCTOP, REG_P1, oob->desc->pc | 1);                        // mov  p1,pc | 1
r1070r1071
876860      emit_sub_m32_imm(DRCTOP, ICOUNTADDR, oob->compiler.cycles);                     // sub  [icount],cycles
877861
878862   /* update the PC with the following instruction PC */
879   if (!(oob->desc->flags & IDESC_IN_DELAY_SLOT))
863   if (!(oob->desc->flags & OPFLAG_IN_DELAY_SLOT))
880864   {
881      assert(!(oob->desc->flags & IDESC_IS_BRANCH));
865      assert(!(oob->desc->flags & OPFLAG_IS_BRANCH));
882866      emit_mov_r32_imm(DRCTOP, REG_P1, oob->desc->pc + 4);                        // mov  p1,pc + 4
883867   }
884868   else
885869   {
886870      assert(oob->desc->branch != NULL);
887      if (oob->desc->branch->targetpc != ~0)
871      if (oob->desc->branch->targetpc != BRANCH_TARGET_DYNAMIC)
888872         emit_mov_r32_imm(DRCTOP, REG_P1, oob->desc->branch->targetpc);               // mov  p1,<targetpc>
889873      else
890874         emit_mov_r32_m32(DRCTOP, REG_P1, MBD(REG_RSP, SPOFFS_NEXTPC));               // mov  p1,[rsp + nextpc]
r1070r1071
931915    register to hold a MIPS register
932916-------------------------------------------------*/
933917
934static mipsreg_state compiler_register_allocate(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, UINT8 mipsreg, UINT8 flags)
918static mipsreg_state compiler_register_allocate(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, UINT8 mipsreg, UINT8 flags)
935919{
936920   UINT8 regindex, regnum = 0;
937921   UINT64 livemask = 0;
r1070r1071
983967      }
984968
985969      /* advance to the next instruction; stop if we hit end-of-sequence */
986      if (desc->flags & IDESC_END_SEQUENCE)
970      if (desc->flags & OPFLAG_END_SEQUENCE)
987971         break;
988972      desc = desc->next;
989973   }
r1070r1071
16041588   for (ramnum = 0; ramnum < MIPS3_MAX_FASTRAM; ramnum++)
16051589   {
16061590      const fast_ram_info *raminfo = &mips3.fastram[ramnum];
1607      if (!Machine->debug_mode && raminfo->base != NULL && (!(flags & ARW_WRITE) || !raminfo->readonly))
1591      if (!COMPARE_AGAINST_C && !Machine->debug_mode && raminfo->base != NULL && (!(flags & ARW_WRITE) || !raminfo->readonly))
16081592      {
16091593         emit_link notram1 = { 0 }, notram2 = { 0 };
16101594
r1070r1071
18261810    append_check_interrupts
18271811------------------------------------------------------------------*/
18281812
1829static void append_check_interrupts(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc)
1813static void append_check_interrupts(drc_core *drc, compiler_state *compiler, const opcode_desc *desc)
18301814{
18311815   emit_link link1, link2;
18321816
r1070r1071
18901874    register and populate it
18911875-------------------------------------------------*/
18921876
1893static void emit_set_constant_value(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, UINT8 mipsreg, UINT64 constval)
1877static void emit_set_constant_value(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, UINT8 mipsreg, UINT64 constval)
18941878{
18951879   /* ignore reigster 0 destination */
18961880   if (mipsreg == 0)
r1070r1071
19131897    emit_delay_slot_and_branch
19141898------------------------------------------------------------------*/
19151899
1916static void emit_delay_slot_and_branch(drc_core *drc, const compiler_state *compiler, const mips3_opcode_desc *desc, UINT8 linkreg)
1900static void emit_delay_slot_and_branch(drc_core *drc, const compiler_state *compiler, const opcode_desc *desc, UINT8 linkreg)
19171901{
19181902   compiler_state compiler_temp = *compiler;
19191903
r1070r1071
19301914      emit_sub_m32_imm(DRCTOP, ICOUNTADDR, compiler_temp.cycles);                     // sub  [icount],cycles
19311915
19321916   /* load the target PC into P1 */
1933   if (desc->targetpc != ~0)
1917   if (desc->targetpc != BRANCH_TARGET_DYNAMIC)
19341918      emit_mov_r32_imm(DRCTOP, REG_P1, desc->targetpc);                           // mov  p1,desc->targetpc
19351919   else
19361920      emit_mov_r32_m32(DRCTOP, REG_P1, MBD(REG_RSP, SPOFFS_NEXTPC));                  // mov  p1,[esp+nextpc]
r1070r1071
19431927      emit_jcc(DRCTOP, COND_S, mips3.drc->exit_point);                           // js   exit_point
19441928
19451929   /* otherwise, append a dispatcher */
1946   if (desc->targetpc != ~0)
1930   if (desc->targetpc != BRANCH_TARGET_DYNAMIC)
19471931      drc_append_tentative_fixed_dispatcher(drc, desc->targetpc, FALSE);               // <redispatch>
19481932   else
19491933      drc_append_dispatcher(drc);                                             // <redispatch>
r1070r1071
19541938    emit_fixed_byte_read
19551939------------------------------------------------------------------*/
19561940
1957static int emit_fixed_byte_read(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, UINT8 destreg, int is_unsigned, offs_t address)
1941static int emit_fixed_byte_read(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, UINT8 destreg, int is_unsigned, offs_t address)
19581942{
19591943   void *fastram = fastram_ptr(address, 1, FALSE);
19601944
r1070r1071
20061990    emit_fixed_half_read
20071991------------------------------------------------------------------*/
20081992
2009static int emit_fixed_half_read(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, UINT8 destreg, int is_unsigned, offs_t address)
1993static int emit_fixed_half_read(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, UINT8 destreg, int is_unsigned, offs_t address)
20101994{
20111995   void *fastram = fastram_ptr(address & ~1, 2, FALSE);
20121996
r1070r1071
20582042    emit_fixed_word_read
20592043------------------------------------------------------------------*/
20602044
2061static int emit_fixed_word_read(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, UINT8 destreg, int is_unsigned, offs_t address, UINT32 mask)
2045static int emit_fixed_word_read(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, UINT8 destreg, int is_unsigned, offs_t address, UINT32 mask)
20622046{
20632047   void *fastram = fastram_ptr(address & ~3, 4, FALSE);
20642048
r1070r1071
21152099    emit_fixed_double_read
21162100------------------------------------------------------------------*/
21172101
2118static int emit_fixed_double_read(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, UINT8 destreg, offs_t address, UINT64 mask)
2102static int emit_fixed_double_read(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, UINT8 destreg, offs_t address, UINT64 mask)
21192103{
21202104   void *fastram = fastram_ptr(address & ~7, 8, FALSE);
21212105
r1070r1071
21662150    emit_fixed_byte_write
21672151------------------------------------------------------------------*/
21682152
2169static int emit_fixed_byte_write(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, mipsreg_state srcreg, offs_t address)
2153static int emit_fixed_byte_write(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, mipsreg_state srcreg, offs_t address)
21702154{
21712155   void *fastram = fastram_ptr(address, 1, TRUE);
21722156
r1070r1071
22192203    emit_fixed_half_write
22202204------------------------------------------------------------------*/
22212205
2222static int emit_fixed_half_write(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, mipsreg_state srcreg, offs_t address)
2206static int emit_fixed_half_write(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, mipsreg_state srcreg, offs_t address)
22232207{
22242208   void *fastram = fastram_ptr(address & ~1, 2, TRUE);
22252209
r1070r1071
22722256    emit_fixed_word_write
22732257------------------------------------------------------------------*/
22742258
2275static int emit_fixed_word_write(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, mipsreg_state srcreg, offs_t address, UINT32 mask)
2259static int emit_fixed_word_write(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, mipsreg_state srcreg, offs_t address, UINT32 mask)
22762260{
22772261   void *fastram = fastram_ptr(address & ~3, 4, TRUE);
22782262
r1070r1071
23642348    emit_fixed_double_write
23652349------------------------------------------------------------------*/
23662350
2367static int emit_fixed_double_write(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, mipsreg_state srcreg, offs_t address, UINT64 mask)
2351static int emit_fixed_double_write(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, mipsreg_state srcreg, offs_t address, UINT64 mask)
23682352{
23692353   void *fastram = fastram_ptr(address & ~7, 8, TRUE);
23702354
r1070r1071
24802464    for compiling a given opcode
24812465-------------------------------------------------*/
24822466
2483static int compile_instruction(drc_core *drc, compiler_state *compiler, mips3_opcode_desc *desc)
2467static int compile_instruction(drc_core *drc, compiler_state *compiler, const opcode_desc *desc)
24842468{
2485   UINT32 op = *desc->opptr;
2469   UINT32 op = *desc->opptr.l;
24862470   UINT8 opswitch = op >> 26;
24872471
24882472   switch (opswitch)
r1070r1071
26472631    'SPECIAL' group
26482632-------------------------------------------------*/
26492633
2650static int compile_special(drc_core *drc, compiler_state *compiler, mips3_opcode_desc *desc)
2634static int compile_special(drc_core *drc, compiler_state *compiler, const opcode_desc *desc)
26512635{
2652   UINT32 op = *desc->opptr;
2636   UINT32 op = *desc->opptr.l;
26532637   UINT8 opswitch = op & 63;
26542638   emit_link link1;
26552639
r1070r1071
28442828    'REGIMM' group
28452829-------------------------------------------------*/
28462830
2847static int compile_regimm(drc_core *drc, compiler_state *compiler, mips3_opcode_desc *desc)
2831static int compile_regimm(drc_core *drc, compiler_state *compiler, const opcode_desc *desc)
28482832{
2849   UINT32 op = *desc->opptr;
2833   UINT32 op = *desc->opptr.l;
28502834   UINT8 opswitch = RTREG;
28512835
28522836   switch (opswitch)
r1070r1071
28782862    specific group
28792863-------------------------------------------------*/
28802864
2881static int compile_idt(drc_core *drc, compiler_state *compiler, mips3_opcode_desc *desc)
2865static int compile_idt(drc_core *drc, compiler_state *compiler, const opcode_desc *desc)
28822866{
28832867   fatalerror("Unimplemented IDT instructions");
28842868#if 0
2885   UINT32 op = *desc->opptr;
2869   UINT32 op = *desc->opptr.l;
28862870   UINT8 opswitch = op & 0x1f;
28872871
28882872   switch (opswitch)
r1070r1071
29512935    handle special COP0 registers
29522936-------------------------------------------------*/
29532937
2954static int compile_set_cop0_reg(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, UINT8 reg)
2938static int compile_set_cop0_reg(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, UINT8 reg)
29552939{
29562940   emit_link link1;
29572941
r1070r1071
30273011    read special COP0 registers
30283012-------------------------------------------------*/
30293013
3030static int compile_get_cop0_reg(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, UINT8 reg)
3014static int compile_get_cop0_reg(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, UINT8 reg)
30313015{
30323016   emit_link link1, link2;
30333017
30343018   switch (reg)
30353019   {
30363020      case COP0_Count:
3037#if (!COMPARE_AGAINST_C)
3038         emit_sub_m32_imm(DRCTOP, ICOUNTADDR, compiler->cycles + MIPS3_COUNT_READ_CYCLES);
3039                                                                     // sub  [icount],<lots>
3040         compiler->cycles = 0;
3041         emit_jcc_short_link(DRCTOP, COND_NS, &link1);                           // jns  notneg
3042         emit_mov_m32_imm(DRCTOP, ICOUNTADDR, 0);                              // mov  [icount],0
3043         resolve_link(DRCTOP, &link1);                                    // notneg:
3044#endif
3045         emit_call_m64(DRCTOP, MDRC(&mips3.drcdata->activecpu_gettotalcycles64));
3046                                                                     // call activecpu_gettotalcycles64
3021         compiler->cycles += MIPS3_COUNT_READ_CYCLES;
3022         emit_call_m64(DRCTOP, MDRC(&mips3.drcdata->activecpu_gettotalcycles64));      // call activecpu_gettotalcycles64
30473023         emit_sub_r64_m64(DRCTOP, REG_RAX, MDRC(&mips3.core->count_zero_time));         // sub  rax,[count_zero_time]
30483024         emit_shr_r64_imm(DRCTOP, REG_RAX, 1);                                 // shr  rax,1
30493025         emit_movsxd_r64_r32(DRCTOP, REG_RAX, REG_EAX);                           // movsxd rax,eax
30503026         return TRUE;
30513027
30523028      case COP0_Cause:
3053#if (!COMPARE_AGAINST_C)
3054         emit_sub_m32_imm(DRCTOP, ICOUNTADDR, compiler->cycles + MIPS3_CAUSE_READ_CYCLES);
3055                                                                     // sub  [icount],<lots>
3056         compiler->cycles = 0;
3057         emit_jcc_short_link(DRCTOP, COND_NS, &link1);                           // jns  notneg
3058         emit_mov_m32_imm(DRCTOP, ICOUNTADDR, 0);                              // mov  [icount],0
3059         resolve_link(DRCTOP, &link1);                                    // notneg:
3060#endif
3029         compiler->cycles += MIPS3_COUNT_READ_CYCLES;
30613030         emit_movsxd_r64_m32(DRCTOP, REG_RAX, CPR0ADDR(COP0_Cause));                  // movsxd rax,[Cause]
30623031         return TRUE;
30633032
30643033      case COP0_Random:
3065         emit_call_m64(DRCTOP, MDRC(&mips3.drcdata->activecpu_gettotalcycles64));
3066                                                                     // call activecpu_gettotalcycles64
3067         emit_sub_r64_m64(DRCTOP, REG_RAX, MDRC(&mips3.core->count_zero_time));         // sub  rax,[count_zero_time]
3034         emit_call_m64(DRCTOP, MDRC(&mips3.drcdata->activecpu_gettotalcycles64));      // call activecpu_gettotalcycles64
30683035         emit_mov_r32_m32(DRCTOP, REG_ECX, CPR0ADDR(COP0_Wired));                  // mov  ecx,[Wired]
30693036         emit_mov_r32_imm(DRCTOP, REG_R8D, 48);                                 // mov  r8d,48
30703037         emit_and_r32_imm(DRCTOP, REG_ECX, 0x3f);                              // and  ecx,0x3f
3038         emit_sub_r64_m64(DRCTOP, REG_RAX, MDRC(&mips3.core->count_zero_time));         // sub  rax,[count_zero_time]
30713039         emit_sub_r32_r32(DRCTOP, REG_R8D, REG_ECX);                              // sub  r8d,ecx
3072         emit_mov_r64_r64(DRCTOP, REG_RDX, REG_RAX);                              // mov  rdx,rax
30733040         emit_jcc_short_link(DRCTOP, COND_BE, &link1);                           // jbe  link1
3074         emit_shr_r64_imm(DRCTOP, REG_RDX, 32);                                 // shr  rdx,32
3075         emit_idiv_r32(DRCTOP, REG_R8D);                                       // idiv r8d
3041         emit_xor_r32_r32(DRCTOP, REG_EDX, REG_EDX);                              // xor  edx,edx
3042         emit_div_r64(DRCTOP, REG_R8);                                       // div  r8
30763043         emit_mov_r32_r32(DRCTOP, REG_EAX, REG_EDX);                              // mov  eax,edx
30773044         emit_add_r32_r32(DRCTOP, REG_EAX, REG_ECX);                              // add  eax,ecx
30783045         emit_and_r32_imm(DRCTOP, REG_EAX, 0x3f);                              // and  eax,0x3f
r1070r1071
30943061    compile_cop0 - compile COP0 opcodes
30953062-------------------------------------------------*/
30963063
3097static int compile_cop0(drc_core *drc, compiler_state *compiler, mips3_opcode_desc *desc)
3064static int compile_cop0(drc_core *drc, compiler_state *compiler, const opcode_desc *desc)
30983065{
3099   UINT32 op = *desc->opptr;
3066   UINT32 op = *desc->opptr.l;
31003067   UINT8 opswitch = RSREG;
31013068
31023069   /* generate an exception if COP0 is disabled or we are not in kernel mode */
r1070r1071
31273094         }
31283095         return TRUE;
31293096
3097      case 0x02:   /* CFCz */
3098         if (RTREG != 0)
3099         {
3100            mipsreg_state rt = compiler_register_allocate(drc, compiler, desc, RTREG, ALLOC_DST | ALLOC_DIRTY);
3101            emit_movsxd_r64_m32(DRCTOP, X86REG(rt), CCR0ADDR(RDREG));               // movsxd <rt>,ccr1[rd]
3102         }
3103         return TRUE;
3104
31303105      case 0x04:   /* MTCz */
31313106      case 0x05:   /* DMTCz */
31323107         {
r1070r1071
31363111         }
31373112         return TRUE;
31383113
3114      case 0x06:   /* CTCz */
3115         {
3116            mipsreg_state rt = compiler_register_allocate(drc, compiler, desc, RTREG, ALLOC_SRC);
3117            emit_load_register_value(drc, compiler, REG_EAX, rt);                  // mov  eax,<rt>
3118            emit_mov_m32_r32(DRCTOP, CCR0ADDR(RDREG), REG_EAX);                     // mov  ccr1[rd],eax
3119         }
3120         return TRUE;
3121
31393122      case 0x10:
31403123      case 0x11:
31413124      case 0x12:
r1070r1071
32003183    compile_cop1 - compile COP1 opcodes
32013184-------------------------------------------------*/
32023185
3203static int compile_cop1(drc_core *drc, compiler_state *compiler, mips3_opcode_desc *desc)
3186static int compile_cop1(drc_core *drc, compiler_state *compiler, const opcode_desc *desc)
32043187{
3205   UINT32 op = *desc->opptr;
3188   UINT32 op = *desc->opptr.l;
32063189   emit_link link1;
32073190
32083191   /* generate an exception if COP1 is disabled */
r1070r1071
37063689
37073690            case 0x37:
37083691            case 0x3f:
3709               if (IS_SINGLE(op))   /* C.OLE.S */
3692               if (IS_SINGLE(op))   /* C.ULE.S */
37103693               {
37113694                  emit_movss_r128_m32(DRCTOP, REG_XMM0, FPR32ADDR(FSREG));         // movss xmm0,[fsreg]
37123695                  emit_ucomiss_r128_m32(DRCTOP, REG_XMM0, FPR32ADDR(FTREG));         // ucomiss xmm0,[ftreg]
37133696               }
3714               else            /* C.OLE.D */
3697               else            /* C.ULE.D */
37153698               {
37163699                  emit_movsd_r128_m64(DRCTOP, REG_XMM0, FPR64ADDR(FSREG));         // movsd xmm0,[fsreg]
37173700                  emit_ucomisd_r128_m64(DRCTOP, REG_XMM0, FPR64ADDR(FTREG));         // ucomisd xmm0,[ftreg]
r1070r1071
37343717    compile_cop1x - compile COP1X opcodes
37353718-------------------------------------------------*/
37363719
3737static int compile_cop1x(drc_core *drc, compiler_state *compiler, mips3_opcode_desc *desc)
3720static int compile_cop1x(drc_core *drc, compiler_state *compiler, const opcode_desc *desc)
37383721{
3739   UINT32 op = *desc->opptr;
3722   UINT32 op = *desc->opptr.l;
37403723
37413724   if (mips3.drcoptions & MIPS3DRC_STRICT_COP1)
37423725   {
r1070r1071
38543837    3: sra/srav rD,rT,rS
38553838-------------------------------------------------*/
38563839
3857static int compile_shift(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int shift_type, int shift_variable)
3840static int compile_shift(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int shift_type, int shift_variable)
38583841{
3859   UINT32 op = *desc->opptr;
3842   UINT32 op = *desc->opptr.l;
38603843   mipsreg_state rd, rs, rt;
38613844
38623845   assert(shift_type == 0 || shift_type == 2 || shift_type == 3);
r1070r1071
38843867   else
38853868   {
38863869      /* allocate the register and load rT into it */
3870      /* if rS is non-const, must load it first in case rD == rS */
38873871      rd = compiler_register_allocate(drc, compiler, desc, RDREG, ALLOC_DST | ALLOC_DIRTY);
3872      if (!ISCONST(rs))
3873         emit_load_register_value(drc, compiler, REG_ECX, rs);                     // mov  ecx,<rs>
38883874      emit_load_register_value(drc, compiler, X86REG(rd), rt);                     // mov  <rd>,<rt>
38893875
38903876      /* if rs is constant, use immediate forms of the shift */
r1070r1071
39013887      /* otherwise, load rs into cl so we can do a variable shift */
39023888      else
39033889      {
3904         emit_load_register_value(drc, compiler, REG_ECX, rs);                     // mov  ecx,<rs>
39053890         if (shift_type == 0)
39063891            emit_shl_r32_cl(DRCTOP, X86REG(rd));                              // shl  <rd>,cl
39073892         else if (shift_type == 2)
r1070r1071
39243909    3: dsra/dsra32/dsrav rD,rT,rS
39253910-------------------------------------------------*/
39263911
3927static int compile_dshift(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int shift_type, int shift_variable, int shift_const_plus32)
3912static int compile_dshift(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int shift_type, int shift_variable, int shift_const_plus32)
39283913{
3929   UINT32 op = *desc->opptr;
3914   UINT32 op = *desc->opptr.l;
39303915   mipsreg_state rd, rs, rt;
39313916
39323917   assert(shift_type == 0 || shift_type == 2 || shift_type == 3);
r1070r1071
39543939   else
39553940   {
39563941      /* allocate the register and load rT into it */
3942      /* if rS is non-const, must load it first in case rD == rS */
39573943      rd = compiler_register_allocate(drc, compiler, desc, RDREG, ALLOC_DST | ALLOC_DIRTY);
3944      if (!ISCONST(rs))
3945         emit_load_register_value(drc, compiler, REG_ECX, rs);                     // mov  ecx,<rs>
39583946      emit_load_register_value(drc, compiler, X86REG(rd), rt);                     // mov  <rd>,<rt>
39593947
39603948      /* if rs is constant, use immediate forms of the shift */
r1070r1071
39713959      /* otherwise, load rs into cl so we can do a variable shift */
39723960      else
39733961      {
3974         emit_load_register_value(drc, compiler, REG_ECX, rs);                     // mov  ecx,<rs>
39753962         if (shift_type == 0)
39763963            emit_shl_r64_cl(DRCTOP, X86REG(rd));                              // shl  <rd>,cl
39773964         else if (shift_type == 2)
r1070r1071
39913978    movz/movn rD,rS,rT
39923979-------------------------------------------------*/
39933980
3994static int compile_movzn(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int is_movn)
3981static int compile_movzn(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int is_movn)
39953982{
3996   UINT32 op = *desc->opptr;
3983   UINT32 op = *desc->opptr.l;
39973984   mipsreg_state rd, rs, rt;
39983985   emit_link skip = { 0 };
39993986
r1070r1071
40404027      6: tne      rS,rT / tnei       rS,SIMM
40414028-------------------------------------------------*/
40424029
4043static int compile_trapcc(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int condition, int immediate)
4030static int compile_trapcc(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int condition, int immediate)
40444031{
40454032   static const UINT8 condtype[] = { COND_GE, COND_AE, COND_L, COND_B, COND_E, COND_NONE, COND_NE, COND_NONE };
4046   UINT32 op = *desc->opptr;
4033   UINT32 op = *desc->opptr.l;
40474034   mipsreg_state rs, rt;
40484035
40494036   assert(condition < ARRAY_LENGTH(condtype) && condtype[condition] != COND_NONE);
r1070r1071
41114098    bne rS,rT,dest
41124099-------------------------------------------------*/
41134100
4114static int compile_branchcc(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int condition)
4101static int compile_branchcc(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int condition)
41154102{
4116   UINT32 op = *desc->opptr;
4103   UINT32 op = *desc->opptr.l;
41174104   emit_link skip = { 0 };
41184105   mipsreg_state rs, rt;
41194106
r1070r1071
41804167    bgezall rS,dest
41814168-------------------------------------------------*/
41824169
4183static int compile_branchcz(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int condition, int link)
4170static int compile_branchcz(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int condition, int link)
41844171{
4185   UINT32 op = *desc->opptr;
4172   UINT32 op = *desc->opptr.l;
41864173   emit_link skip = { 0 };
41874174   mipsreg_state rs;
41884175
r1070r1071
42224209    addu rD,rS,rT / addiu rT,rS,SIMM
42234210-------------------------------------------------*/
42244211
4225static int compile_add(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int suppress_exceptions, int immediate)
4212static int compile_add(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int suppress_exceptions, int immediate)
42264213{
4227   UINT32 op = *desc->opptr;
4214   UINT32 op = *desc->opptr.l;
42284215   UINT8 destreg = immediate ? RTREG : RDREG;
42294216   mipsreg_state rd, rs, rt;
42304217
r1070r1071
43074294    daddu rD,rS,rT
43084295-------------------------------------------------*/
43094296
4310static int compile_dadd(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int suppress_exceptions, int immediate)
4297static int compile_dadd(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int suppress_exceptions, int immediate)
43114298{
4312   UINT32 op = *desc->opptr;
4299   UINT32 op = *desc->opptr.l;
43134300   UINT8 destreg = immediate ? RTREG : RDREG;
43144301   mipsreg_state rd, rs, rt;
43154302
r1070r1071
43794366    subu rD,rS,rT
43804367-------------------------------------------------*/
43814368
4382static int compile_sub(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int suppress_exceptions)
4369static int compile_sub(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int suppress_exceptions)
43834370{
4384   UINT32 op = *desc->opptr;
4371   UINT32 op = *desc->opptr.l;
43854372   mipsreg_state rd, rs, rt;
43864373
43874374   /* note that we still must perform this operation even if RDREG == 0
r1070r1071
44724459    dsubu rD,rS,rT
44734460-------------------------------------------------*/
44744461
4475static int compile_dsub(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int suppress_exceptions)
4462static int compile_dsub(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int suppress_exceptions)
44764463{
4477   UINT32 op = *desc->opptr;
4464   UINT32 op = *desc->opptr.l;
44784465   mipsreg_state rd, rs, rt;
44794466
44804467   /* note that we still must perform this operation even if RDREG == 0
r1070r1071
45644551    multu rS,rT
45654552-------------------------------------------------*/
45664553
4567static int compile_mult(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int is_unsigned)
4554static int compile_mult(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int is_unsigned)
45684555{
4569   UINT32 op = *desc->opptr;
4556   UINT32 op = *desc->opptr.l;
45704557   mipsreg_state rs, rt, lo, hi;
45714558
45724559   /* allocate source registers */
r1070r1071
46104597    dmultu rS,rT
46114598-------------------------------------------------*/
46124599
4613static int compile_dmult(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int is_unsigned)
4600static int compile_dmult(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int is_unsigned)
46144601{
4615   UINT32 op = *desc->opptr;
4602   UINT32 op = *desc->opptr.l;
46164603   mipsreg_state rs, rt, lo, hi;
46174604
46184605   /* allocate source registers */
r1070r1071
46564643    divu  rS,rT
46574644-------------------------------------------------*/
46584645
4659static int compile_div(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int is_unsigned)
4646static int compile_div(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int is_unsigned)
46604647{
4661   UINT32 op = *desc->opptr;
4648   UINT32 op = *desc->opptr.l;
46624649   mipsreg_state rs, rt, lo, hi;
46634650
46644651   /* allocate source registers */
r1070r1071
47224709    ddivu  rS,rT
47234710-------------------------------------------------*/
47244711
4725static int compile_ddiv(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int is_unsigned)
4712static int compile_ddiv(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int is_unsigned)
47264713{
4727   UINT32 op = *desc->opptr;
4714   UINT32 op = *desc->opptr.l;
47284715   mipsreg_state rs, rt, lo, hi;
47294716
47304717   /* allocate source registers */
r1070r1071
47864773    3: nor rD,rS,rT
47874774-------------------------------------------------*/
47884775
4789static int compile_logical(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int operation, int immediate)
4776static int compile_logical(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int operation, int immediate)
47904777{
4791   UINT32 op = *desc->opptr;
4778   UINT32 op = *desc->opptr.l;
47924779   UINT8 destreg = immediate ? RTREG : RDREG;
47934780   mipsreg_state rd, rs, rt;
47944781
r1070r1071
48734860    sltiu rD,rS,rT / sltiu rT,rS,SIMM
48744861-------------------------------------------------*/
48754862
4876static int compile_slt(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int is_unsigned, int immediate)
4863static int compile_slt(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int is_unsigned, int immediate)
48774864{
4878   UINT32 op = *desc->opptr;
4865   UINT32 op = *desc->opptr.l;
48794866   UINT8 destreg = immediate ? RTREG : RDREG;
48804867   mipsreg_state rd, rs, rt;
48814868
r1070r1071
49264913    ld   rT,SIMM(rS)
49274914-------------------------------------------------*/
49284915
4929static int compile_load(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int size, int is_unsigned)
4916static int compile_load(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int size, int is_unsigned)
49304917{
4931   UINT32 op = *desc->opptr;
4918   UINT32 op = *desc->opptr.l;
49324919   mipsreg_state rs, rt;
49334920   int was_fixed = FALSE;
49344921
r1070r1071
50024989    ldc2 rT,SIMM(rs)
50034990-------------------------------------------------*/
50044991
5005static int compile_load_cop(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int size, void *dest)
4992static int compile_load_cop(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int size, void *dest)
50064993{
5007   UINT32 op = *desc->opptr;
4994   UINT32 op = *desc->opptr.l;
50084995   int was_fixed = FALSE;
50094996   mipsreg_state rs;
50104997
r1070r1071
50605047    ldxc1 fD,rS,rT
50615048-------------------------------------------------*/
50625049
5063static int compile_loadx_cop(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int size, void *dest)
5050static int compile_loadx_cop(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int size, void *dest)
50645051{
5065   UINT32 op = *desc->opptr;
5052   UINT32 op = *desc->opptr.l;
50665053   int was_fixed = FALSE;
50675054   mipsreg_state rs, rt;
50685055
r1070r1071
51235110    lwr   rT,SIMM(rS)
51245111-------------------------------------------------*/
51255112
5126static int compile_load_word_partial(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int is_right)
5113static int compile_load_word_partial(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int is_right)
51275114{
5128   UINT32 op = *desc->opptr;
5115   UINT32 op = *desc->opptr.l;
51295116   int was_fixed = FALSE;
51305117   mipsreg_state rs, rt;
51315118
r1070r1071
51685155   else
51695156   {
51705157      /* compute the address and mask values */
5171      emit_lea_r32_m32(DRCTOP, REG_EAX, MBD(X86REG(rs), SIMMVAL));                  // lea  eax,[<rs> + SIMMVAL]
5158      if (ISCONST(rs))
5159         emit_mov_r32_imm(DRCTOP, REG_EAX, CONSTVAL(rs) + SIMMVAL);                  // mov  eax,<rs> + SIMMVAL
5160      else
5161         emit_lea_r32_m32(DRCTOP, REG_EAX, MBD(X86REG(rs), SIMMVAL));               // lea  eax,[<rs> + SIMMVAL]
51725162      emit_lea_r32_m32(DRCTOP, REG_ECX, MISD(REG_RAX, 8, 0));                        // lea  ecx,[rax*8]
51735163      emit_or_r32_imm(DRCTOP, REG_P2, -1);                                    // or   p2,-1
51745164      if ((!mips3.core->bigendian && !is_right) || (mips3.core->bigendian && is_right))
r1070r1071
52265216    ldr   rT,SIMM(rS)
52275217-------------------------------------------------*/
52285218
5229static int compile_load_double_partial(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int is_right)
5219static int compile_load_double_partial(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int is_right)
52305220{
5231   UINT32 op = *desc->opptr;
5221   UINT32 op = *desc->opptr.l;
52325222   int was_fixed = FALSE;
52335223   mipsreg_state rs, rt;
52345224
r1070r1071
52765266   else
52775267   {
52785268      /* compute the address and mask values */
5279      emit_lea_r32_m32(DRCTOP, REG_EAX, MBD(X86REG(rs), SIMMVAL));                  // lea  eax,[<rs> + SIMMVAL]
5269      if (ISCONST(rs))
5270         emit_mov_r32_imm(DRCTOP, REG_EAX, CONSTVAL(rs) + SIMMVAL);                  // mov  eax,<rs> + SIMMVAL
5271      else
5272         emit_lea_r32_m32(DRCTOP, REG_EAX, MBD(X86REG(rs), SIMMVAL));               // lea  eax,[<rs> + SIMMVAL]
52805273      emit_lea_r32_m32(DRCTOP, REG_ECX, MISD(REG_RAX, 8, 0));                        // lea  ecx,[rax*8]
52815274      emit_or_r64_imm(DRCTOP, REG_P2, -1);                                    // or   p2,-1
52825275      if ((!mips3.core->bigendian && !is_right) || (mips3.core->bigendian && is_right))
r1070r1071
53355328    sd   rT,SIMM(rS)
53365329-------------------------------------------------*/
53375330
5338static int compile_store(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int size)
5331static int compile_store(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int size)
53395332{
5340   UINT32 op = *desc->opptr;
5333   UINT32 op = *desc->opptr.l;
53415334   int was_fixed = FALSE;
53425335   mipsreg_state rs, rt;
53435336
r1070r1071
53995392    sdc2 rT,SIMM(rs)
54005393-------------------------------------------------*/
54015394
5402static int compile_store_cop(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int size, void *src)
5395static int compile_store_cop(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int size, void *src)
54035396{
5404   UINT32 op = *desc->opptr;
5397   UINT32 op = *desc->opptr.l;
54055398   int was_fixed = FALSE;
54065399   mipsreg_state rs;
54075400
r1070r1071
54575450    sdxc1 fD,rS,rT
54585451-------------------------------------------------*/
54595452
5460static int compile_storex_cop(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int size, void *src)
5453static int compile_storex_cop(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int size, void *src)
54615454{
5462   UINT32 op = *desc->opptr;
5455   UINT32 op = *desc->opptr.l;
54635456   int was_fixed = FALSE;
54645457   mipsreg_state rs, rt;
54655458
r1070r1071
55205513    swr   rT,SIMM(rS)
55215514-------------------------------------------------*/
55225515
5523static int compile_store_word_partial(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int is_right)
5516static int compile_store_word_partial(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int is_right)
55245517{
5525   UINT32 op = *desc->opptr;
5518   UINT32 op = *desc->opptr.l;
55265519   int was_fixed = FALSE;
55275520   mipsreg_state rs, rt;
55285521
r1070r1071
56155608    sdr   rT,SIMM(rS)
56165609-------------------------------------------------*/
56175610
5618static int compile_store_double_partial(drc_core *drc, compiler_state *compiler, const mips3_opcode_desc *desc, int is_right)
5611static int compile_store_double_partial(drc_core *drc, compiler_state *compiler, const opcode_desc *desc, int is_right)
56195612{
5620   UINT32 op = *desc->opptr;
5613   UINT32 op = *desc->opptr.l;
56215614   int was_fixed = FALSE;
56225615   mipsreg_state rs, rt;
56235616
src/emu/cpu/mips/mips3fe.c
r1070r1071
44
55    Front-end for MIPS3 recompiler
66
7    Copyright (c) 2007, Aaron Giles
8    Released for general use under the MAME license
9    Visit http://mamedev.org for licensing and usage restrictions.
10
711***************************************************************************/
812
913#include <stddef.h>
1014#include "cpuintrf.h"
1115#include "mips3fe.h"
16#include "mips3com.h"
1217
1318
1419/***************************************************************************
15    CONSTANTS
16***************************************************************************/
17
18#define MAX_STACK_DEPTH      100
19
20
21
22/***************************************************************************
23    TYPE DEFINITIONS
24***************************************************************************/
25
26typedef struct _pc_stack_entry pc_stack_entry;
27struct _pc_stack_entry
28{
29   UINT32      targetpc;
30   UINT32      srcpc;
31};
32
33
34
35/***************************************************************************
36    LOCAL VARAIBLES
37***************************************************************************/
38
39static mips3_opcode_desc *desc_free_list;
40static mips3_opcode_desc **desc_array;
41static UINT32 desc_array_size;
42static UINT32 dummy_nop = 0;
43
44
45
46/***************************************************************************
4720    FUNCTION PROTOTYPES
4821***************************************************************************/
4922
50static mips3_opcode_desc **build_sequence(mips3_opcode_desc **tailptr, int start, int end, UINT32 endflag, int maxseq);
23static int describe_instruction_special(mips3_state *mips, UINT32 op, opcode_desc *desc);
24static int describe_instruction_regimm(mips3_state *mips, UINT32 op, opcode_desc *desc);
25static int describe_instruction_idt(mips3_state *mips, UINT32 op, opcode_desc *desc);
26static int describe_instruction_cop0(mips3_state *mips, UINT32 op, opcode_desc *desc);
27static int describe_instruction_cop1(mips3_state *mips, UINT32 op, opcode_desc *desc);
28static int describe_instruction_cop1x(mips3_state *mips, UINT32 op, opcode_desc *desc);
29static int describe_instruction_cop2(mips3_state *mips, UINT32 op, opcode_desc *desc);
5130
52static int describe_one(mips3_state *mips, UINT32 curpc, mips3_opcode_desc *curdesc);
53static void describe_instruction(mips3_state *mips, UINT32 pc, UINT32 op, mips3_opcode_desc *desc);
54static void describe_instruction_special(mips3_state *mips, UINT32 pc, UINT32 op, mips3_opcode_desc *desc);
55static void describe_instruction_regimm(mips3_state *mips, UINT32 pc, UINT32 op, mips3_opcode_desc *desc);
56static void describe_instruction_idt(mips3_state *mips, UINT32 pc, UINT32 op, mips3_opcode_desc *desc);
57static void describe_instruction_cop0(mips3_state *mips, UINT32 pc, UINT32 op, mips3_opcode_desc *desc);
58static void describe_instruction_cop1(mips3_state *mips, UINT32 pc, UINT32 op, mips3_opcode_desc *desc);
59static void describe_instruction_cop1x(mips3_state *mips, UINT32 pc, UINT32 op, mips3_opcode_desc *desc);
60static void describe_instruction_cop2(mips3_state *mips, UINT32 pc, UINT32 op, mips3_opcode_desc *desc);
6131
6232
63
6433/***************************************************************************
65    INLINE FUNCTIONS
66***************************************************************************/
67
68INLINE mips3_opcode_desc *desc_alloc(void)
69{
70   mips3_opcode_desc *desc = desc_free_list;
71
72   /* pull a description off of the free list or allocate a new one */
73   if (desc != NULL)
74      desc_free_list = desc->next;
75   else
76      desc = malloc_or_die(sizeof(*desc));
77   return desc;
78}
79
80
81INLINE void desc_free(mips3_opcode_desc *desc)
82{
83   /* just put ourselves on the free list */
84   desc->next = desc_free_list;
85   desc_free_list = desc;
86}
87
88
89INLINE void invalid_opcode(mips3_opcode_desc *desc)
90{
91   desc->flags |= IDESC_WILL_CAUSE_EXCEPTION | IDESC_END_SEQUENCE | IDESC_INVALID_OPCODE;
92}
93
94
95INLINE int is_fixed_mapped(UINT32 pc)
96{
97   return (pc >= 0x80000000 && pc < 0xc0000000);
98}
99
100
101
102/***************************************************************************
103    CORE IMPLEMENTATION
104***************************************************************************/
105
106/*-------------------------------------------------
107    mips3fe_init - initialization
108-------------------------------------------------*/
109
110void mips3fe_init(void)
111{
112   desc_free_list = NULL;
113   desc_array = NULL;
114   desc_array_size = 0;
115}
116
117
118/*-------------------------------------------------
119    mipsfe_exit - clean up after ourselves
120-------------------------------------------------*/
121
122void mips3fe_exit(void)
123{
124   /* free our free list of descriptions */
125   while (desc_free_list != NULL)
126   {
127      mips3_opcode_desc *freeme = desc_free_list;
128      desc_free_list = desc_free_list->next;
129      free(freeme);
130   }
131
132   /* free the description array */
133   if (desc_array != NULL)
134      free(desc_array);
135   desc_array_size = 0;
136}
137
138
139/*-------------------------------------------------
140    mips3fe_describe_sequence - describe a
141    sequence of instructions that falls within
142    the given range
143-------------------------------------------------*/
144
145mips3_opcode_desc *mips3fe_describe_sequence(mips3_state *mips, UINT32 startpc, UINT32 minpc, UINT32 maxpc, int maxseq)
146{
147   pc_stack_entry pcstack[MAX_STACK_DEPTH];
148   pc_stack_entry *pcstackptr = &pcstack[0];
149   mips3_opcode_desc *head, **tailptr;
150
151   /* make sure our array is big enough */
152   if ((maxpc - minpc) / 4 + 10 > desc_array_size)
153   {
154      desc_array_size = (maxpc - minpc) / 4 + 10;
155      desc_array = realloc(desc_array, desc_array_size * sizeof(desc_array[0]));
156      memset(desc_array, 0, desc_array_size * sizeof(desc_array[0]));
157   }
158
159   /* add the initial PC to the stack */
160   pcstackptr->srcpc = 0;
161   pcstackptr->targetpc = startpc;
162   pcstackptr++;
163
164   /* loop while we still have a stack */
165   while (pcstackptr != &pcstack[0])
166   {
167      pc_stack_entry *curstack = --pcstackptr;
168      mips3_opcode_desc *prevdesc = NULL;
169      mips3_opcode_desc *curdesc;
170      UINT32 curpc;
171
172      /* if we've already hit this PC, just mark it a branch target and continue */
173      curdesc = desc_array[(curstack->targetpc - minpc) / 4];
174      if (curdesc != NULL)
175      {
176         curdesc->flags |= IDESC_IS_BRANCH_TARGET;
177
178         /* if the branch crosses a page boundary, mark the target as needing to revalidate */
179         if (!is_fixed_mapped(curdesc->pc) && ((curstack->srcpc ^ curdesc->pc) & ~0xfff) != 0)
180            curdesc->flags |= IDESC_VALIDATE_TLB | IDESC_CAN_CAUSE_EXCEPTION;
181
182         /* continue processing */
183         continue;
184      }
185
186      /* loop until we exit the block */
187      for (curpc = curstack->targetpc; curpc < maxpc && desc_array[(curpc - minpc) / 4] == NULL; curpc += 4)
188      {
189         /* describe one instruction */
190         desc_array[(curpc - minpc) / 4] = curdesc = desc_alloc();
191         if (!describe_one(mips, curpc, curdesc))
192            break;
193
194         /* first instruction in a block is always a branch target */
195         if (curpc == curstack->targetpc)
196            curdesc->flags |= IDESC_IS_BRANCH_TARGET;
197
198         /* first instruction in a block or page must always validate the TLB */
199         if (!is_fixed_mapped(curpc) && (curpc == startpc || (curpc & 0xfff) == 0))
200            curdesc->flags |= IDESC_VALIDATE_TLB | IDESC_CAN_CAUSE_EXCEPTION;
201
202         /* if we are a branch, add the branch target to our stack */
203         if ((curdesc->flags & IDESC_IS_BRANCH) && curdesc->targetpc >= minpc && curdesc->targetpc < maxpc && pcstackptr < &pcstack[MAX_STACK_DEPTH])
204         {
205            curdesc->flags |= IDESC_INTRABLOCK_BRANCH;
206            pcstackptr->srcpc = curdesc->pc;
207            pcstackptr->targetpc = curdesc->targetpc;
208            pcstackptr++;
209         }
210
211         /* we now become the previous desc */
212         prevdesc = curdesc;
213
214         /* if we're done, we're done */
215         if (curdesc->flags & IDESC_END_SEQUENCE)
216            break;
217
218         /* if this is a likely branch, advance an extra 4 */
219         if (curdesc->flags & IDESC_IS_LIKELY_BRANCH)
220            curpc += 4;
221      }
222   }
223
224   /* now build the list of descriptions in order */
225   /* first from startpc -> maxpc, then from minpc -> startpc */
226   head = NULL;
227   tailptr = build_sequence(&head, (startpc - minpc) / 4, (maxpc - minpc) / 4, IDESC_REDISPATCH, maxseq);
228   tailptr = build_sequence(tailptr, (minpc - minpc) / 4, (startpc - minpc) / 4, IDESC_RETURN_TO_START, maxseq);
229   return head;
230}
231
232
233/*-------------------------------------------------
234    mips3fe_release_descriptions - release a
235    list of descriptions
236-------------------------------------------------*/
237
238void mips3fe_release_descriptions(mips3_opcode_desc *desc)
239{
240   while (desc != NULL)
241   {
242      mips3_opcode_desc *freeme = desc;
243      if (desc->delay != NULL)
244         mips3fe_release_descriptions(desc->delay);
245      desc = desc->next;
246      desc_free(freeme);
247   }
248}
249
250
251
252/***************************************************************************
253    INTERNAL HELPERS
254***************************************************************************/
255
256/*-------------------------------------------------
257    accumulate_live_info_forwards - recursively
258    accumulate live register liveness information
259    walking in a forward direction
260-------------------------------------------------*/
261
262static void accumulate_live_info_forwards(mips3_opcode_desc *desc, UINT64 *gprread, UINT64 *gprwrite, UINT64 *fprread, UINT64 *fprwrite)
263{
264   /* set the initial information */
265   desc->gpr.liveread = (*gprread |= desc->gpr.used);
266   desc->gpr.livewrite = (*gprwrite |= desc->gpr.modified);
267   desc->fpr.liveread = (*fprread |= desc->fpr.used);
268   desc->fpr.livewrite = (*fprwrite |= desc->fpr.modified);
269
270   /* recursively handle delay slots */
271   if (desc->delay != NULL)
272      accumulate_live_info_forwards(desc->delay, gprread, gprwrite, fprread, fprwrite);
273}
274
275
276/*-------------------------------------------------
277    accumulate_live_info_backwards - recursively
278    accumulate live register liveness information
279    walking in a backwards direction
280-------------------------------------------------*/
281
282static void accumulate_live_info_backwards(mips3_opcode_desc *desc, UINT64 *gprread, UINT64 *gprwrite, UINT64 *fprread, UINT64 *fprwrite)
283{
284   /* recursively handle delay slots */
285   if (desc->delay != NULL)
286      accumulate_live_info_backwards(desc->delay, gprread, gprwrite, fprread, fprwrite);
287
288   /* accumulate the info from this instruction */
289   desc->gpr.liveread &= (*gprread |= desc->gpr.used);
290   desc->gpr.livewrite &= (*gprwrite |= desc->gpr.modified);
291   desc->fpr.liveread &= (*fprread |= desc->fpr.used);
292   desc->fpr.livewrite &= (*fprwrite |= desc->fpr.modified);
293}
294
295
296/*-------------------------------------------------
297    build_sequence - build an ordered sequence
298    of instructions
299-------------------------------------------------*/
300
301static mips3_opcode_desc **build_sequence(mips3_opcode_desc **tailptr, int start, int end, UINT32 endflag, int maxseq)
302{
303   UINT64 gprread = 0, gprwrite = 0;
304   UINT64 fprread = 0, fprwrite = 0;
305   int consecutive = 0;
306   int seqstart = -1;
307   int descnum;
308
309   /* iterate in order from start to end, picking up all non-NULL instructions */
310   for (descnum = start; descnum < end; descnum++)
311      if (desc_array[descnum] != NULL)
312      {
313         mips3_opcode_desc *desc = desc_array[descnum];
314         mips3_opcode_desc *next = NULL;
315         int nextoffs;
316
317         /* determine the next instruction */
318         nextoffs = (desc->flags & IDESC_IS_LIKELY_BRANCH) ? 2 : 1;
319         if (descnum + nextoffs < end)
320            next = desc_array[descnum + nextoffs];
321
322         /* start a new sequence if we aren't already in the middle of one */
323         if (seqstart == -1)
324            seqstart = descnum;
325
326         /* if this is a likely branch and there is a branch into the delay slot, mark it as */
327         /* end-of-sequence so that the common flow will branch over it */
328         if ((desc->flags & IDESC_IS_LIKELY_BRANCH) && desc_array[descnum + 1] != NULL)
329            desc->flags |= IDESC_END_SEQUENCE;
330
331         /* if the next instruction is a branch target, mark this instruction as end of sequence */
332         if (next != NULL && (next->flags & IDESC_IS_BRANCH_TARGET))
333            desc->flags |= IDESC_END_SEQUENCE;
334
335         /* if we are the last instruction, indicate end-of-sequence and redispatch */
336         if (next == NULL)
337            desc->flags |= IDESC_END_SEQUENCE | endflag;
338
339         /* if we exceed the maximum consecutive count, cut off the sequence */
340         if (!(desc->flags & IDESC_END_SEQUENCE) && ++consecutive >= maxseq)
341            desc->flags |= IDESC_END_SEQUENCE;
342         if (desc->flags & IDESC_END_SEQUENCE)
343            consecutive = 0;
344
345         /* update register accumulators */
346         accumulate_live_info_forwards(desc, &gprread, &gprwrite, &fprread, &fprwrite);
347
348         /* if this is the end of a sequence, work backwards */
349         if (desc->flags & IDESC_END_SEQUENCE)
350         {
351            int backdesc;
352
353            /* loop until all the registers have been accounted for */
354            gprread = gprwrite = 0;
355            fprread = fprwrite = 0;
356            for (backdesc = descnum; backdesc != seqstart - 1; backdesc--)
357               if (desc_array[backdesc] != NULL)
358                  accumulate_live_info_backwards(desc_array[backdesc], &gprread, &gprwrite, &fprread, &fprwrite);
359
360            /* reset the register states */
361            seqstart = -1;
362            gprread = gprwrite = 0;
363            fprread = fprwrite = 0;
364         }
365
366         /* add us to the end of the list and clear our array slot */
367         *tailptr = desc;
368         tailptr = &desc->next;
369      }
370
371   /* zap the array */
372   memset(&desc_array[start], 0, (end - start) * sizeof(desc_array[0]));
373
374   /* return the final tailptr */
375   return tailptr;
376}
377
378
379
380/***************************************************************************
38134    INSTRUCTION PARSERS
38235***************************************************************************/
38336
38437/*-------------------------------------------------
385    describe_one - describe a single instruction
386-------------------------------------------------*/
387
388static int describe_one(mips3_state *mips, UINT32 curpc, mips3_opcode_desc *curdesc)
389{
390   /* fill in default values */
391   curdesc->next = NULL;
392   curdesc->delay = NULL;
393   curdesc->pc = curpc;
394   curdesc->targetpc = ~0;
395   curdesc->flags = 0;
396   curdesc->cycles = 1;
397   curdesc->gpr.used = 0;
398   curdesc->gpr.modified = 0;
399   curdesc->gpr.liveread = 0;
400   curdesc->gpr.livewrite = 0;
401   curdesc->fpr.used = 0;
402   curdesc->fpr.modified = 0;
403   curdesc->fpr.liveread = 0;
404   curdesc->fpr.livewrite = 0;
405
406   /* determine the physical PC and pointer to opcode for this instruction */
407   curdesc->physpc = curpc;
408   if (!mips3com_translate_address(mips, ADDRESS_SPACE_PROGRAM, &curdesc->physpc))
409   {
410      /* if we're not mapped, generate an exception */
411      curdesc->opptr = &dummy_nop;
412      curdesc->flags = IDESC_CAN_CAUSE_EXCEPTION | IDESC_END_SEQUENCE | IDESC_REDISPATCH;
413      return FALSE;
414   }
415   curdesc->opptr = memory_get_op_ptr(cpu_getactivecpu(), curdesc->physpc, FALSE);
416   assert(curdesc->opptr != NULL);
417
418   /* describe this instruction */
419   describe_instruction(mips, curpc, *curdesc->opptr, curdesc);
420
421   /* if we are a branch, describe the delay slot as well */
422   if (curdesc->flags & IDESC_IS_BRANCH)
423   {
424      curdesc->delay = desc_alloc();
425      describe_one(mips, curpc + 4, curdesc->delay);
426      curdesc->delay->flags |= IDESC_IN_DELAY_SLOT;
427      curdesc->delay->branch = curdesc;
428   }
429   return TRUE;
430}
431
432
433/*-------------------------------------------------
43438    describe_instruction - build a description
43539    of a single instruction
43640-------------------------------------------------*/
43741
438static void describe_instruction(mips3_state *mips, UINT32 pc, UINT32 op, mips3_opcode_desc *desc)
42int mips3fe_describe(void *param, opcode_desc *desc)
43943{
44   mips3_state *mips = param;
45   UINT32 op = *desc->opptr.l;
46   UINT8 opswitch = op >> 26;
47
48   /* all instructions are 4 bytes and default to a single cycle each */
49   desc->length = 4;
50   desc->cycles = 1;
51
44052   /* parse the instruction */
441   switch (op >> 26)
53   switch (opswitch)
44254   {
44355      case 0x00:   /* SPECIAL */
444         describe_instruction_special(mips, pc, op, desc);
445         break;
56         return describe_instruction_special(mips, op, desc);
44657
44758      case 0x01:   /* REGIMM */
448         describe_instruction_regimm(mips, pc, op, desc);
449         break;
59         return describe_instruction_regimm(mips, op, desc);
45060
45161      case 0x10:   /* COP0 */
452         describe_instruction_cop0(mips, pc, op, desc);
453         break;
62         return describe_instruction_cop0(mips, op, desc);
45463
45564      case 0x11:   /* COP1 */
456         describe_instruction_cop1(mips, pc, op, desc);
457         break;
65         return describe_instruction_cop1(mips, op, desc);
45866
45967      case 0x12:   /* COP2 */
460         describe_instruction_cop2(mips, pc, op, desc);
461         break;
68         return describe_instruction_cop2(mips, op, desc);
46269
46370      case 0x13:   /* COP1X - MIPS IV */
46471         if (mips->flavor < MIPS3_TYPE_MIPS_IV)
465         {
466            invalid_opcode(desc);
467            break;
468         }
469         describe_instruction_cop1x(mips, pc, op, desc);
470         break;
72            return FALSE;
73         return describe_instruction_cop1x(mips, op, desc);
47174
47275      case 0x1c:   /* IDT-specific opcodes: mad/madu/mul on R4640/4650, msub on RC32364 */
473         describe_instruction_idt(mips, pc, op, desc);
474         break;
76         return describe_instruction_idt(mips, op, desc);
47577
47678      case 0x02:   /* J */
477         desc->flags |= IDESC_IS_UNCONDITIONAL_BRANCH | IDESC_END_SEQUENCE;
478         desc->targetpc = (pc & 0xf0000000) | (LIMMVAL << 2);
479         break;
79         desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
80         desc->targetpc = (desc->pc & 0xf0000000) | (LIMMVAL << 2);
81         desc->delayslots = 1;
82         return TRUE;
48083
48184      case 0x03:   /* JAL */
48285         desc->gpr.modified |= REGFLAG_R(31);
483         desc->flags |= IDESC_IS_UNCONDITIONAL_BRANCH | IDESC_END_SEQUENCE;
484         desc->targetpc = (pc & 0xf0000000) | (LIMMVAL << 2);
485         break;
86         desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
87         desc->targetpc = (desc->pc & 0xf0000000) | (LIMMVAL << 2);
88         desc->delayslots = 1;
89         return TRUE;
48690
487      case 0x14:   /* BEQL */
488      case 0x15:   /* BNEL */
489         desc->flags |= IDESC_IS_LIKELY_BRANCH;
490         /* fall through */
491
49291      case 0x04:   /* BEQ */
49392      case 0x05:   /* BNE */
494         if (((op >> 26) == 0x04 || (op >> 26) == 0x14) && RSREG == RTREG)
495            desc->flags |= IDESC_IS_UNCONDITIONAL_BRANCH | IDESC_END_SEQUENCE;
93      case 0x14:   /* BEQL */
94      case 0x15:   /* BNEL */
95         if ((opswitch == 0x04 || opswitch == 0x14) && RSREG == RTREG)
96            desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
49697         else
49798         {
49899            desc->gpr.used |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
499            desc->flags |= IDESC_IS_CONDITIONAL_BRANCH;
100            desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
500101         }
501         desc->targetpc = pc + 4 + (SIMMVAL << 2);
502         break;
102         desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
103         desc->delayslots = 1;
104         desc->skipslots = (opswitch & 0x10) ? 1 : 0;
105         return TRUE;
503106
504      case 0x16:   /* BLEZL */
505      case 0x17:   /* BGTZL */
506         desc->flags |= IDESC_IS_LIKELY_BRANCH;
507         /* fall through */
508
509107      case 0x06:   /* BLEZ */
510108      case 0x07:   /* BGTZ */
511         if (((op >> 26) == 0x06 || (op >> 26) == 0x16) && RSREG == 0)
512            desc->flags |= IDESC_IS_UNCONDITIONAL_BRANCH | IDESC_END_SEQUENCE;
109      case 0x16:   /* BLEZL */
110      case 0x17:   /* BGTZL */
111         if ((opswitch == 0x06 || opswitch == 0x16) && RSREG == 0)
112            desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
513113         else
514114         {
515115            desc->gpr.used |= REGFLAG_R(RSREG);
516            desc->flags |= IDESC_IS_CONDITIONAL_BRANCH;
116            desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
517117         }
518         desc->targetpc = pc + 4 + (SIMMVAL << 2);
519         break;
118         desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
119         desc->delayslots = 1;
120         desc->skipslots = (opswitch & 0x10) ? 1 : 0;
121         return TRUE;
520122
521123      case 0x08:   /* ADDI */
522124      case 0x18:   /* DADDI */
523125         desc->gpr.used |= REGFLAG_R(RSREG);
524126         desc->gpr.modified |= REGFLAG_R(RTREG);
525         desc->flags |= IDESC_CAN_CAUSE_EXCEPTION;
526         break;
127         desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
128         return TRUE;
527129
528130      case 0x09:   /* ADDIU */
529131      case 0x0a:   /* SLTI */
r1070r1071
534136      case 0x19:   /* DADDIU */
535137         desc->gpr.used |= REGFLAG_R(RSREG);
536138         desc->gpr.modified |= REGFLAG_R(RTREG);
537         break;
139         return TRUE;
538140
539141      case 0x0f:   /* LUI */
540142         desc->gpr.modified |= REGFLAG_R(RTREG);
541         break;
143         return TRUE;
542144
543145      case 0x1a:   /* LDL */
544146      case 0x1b:   /* LDR */
r1070r1071
556158      case 0x37:   /* LD */
557159         desc->gpr.used |= REGFLAG_R(RSREG);
558160         desc->gpr.modified |= REGFLAG_R(RTREG);
559         desc->flags |= IDESC_READS_MEMORY | IDESC_CAN_CAUSE_EXCEPTION;
560         break;
161         desc->flags |= OPFLAG_READS_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
162         return TRUE;
561163
562164      case 0x28:   /* SB */
563165      case 0x29:   /* SH */
r1070r1071
570172      case 0x3c:   /* SCD */
571173      case 0x3f:   /* SD */
572174         desc->gpr.used |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
573         desc->flags |= IDESC_WRITES_MEMORY | IDESC_CAN_CAUSE_EXCEPTION;
574         break;
175         desc->flags |= OPFLAG_WRITES_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
176         return TRUE;
575177
576178      case 0x31:   /* LWC1 */
577179      case 0x35:   /* LDC1 */
578180         desc->gpr.used |= REGFLAG_R(RSREG);
579181         desc->fpr.modified |= REGFLAG_CPR1(RTREG);
580         desc->flags |= IDESC_READS_MEMORY | IDESC_CAN_CAUSE_EXCEPTION;
581         break;
182         desc->flags |= OPFLAG_READS_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
183         return TRUE;
582184
583185      case 0x39:   /* SWC1 */
584186      case 0x3d:   /* SDC1 */
585187         desc->gpr.used |= REGFLAG_R(RSREG);
586188         desc->fpr.used |= REGFLAG_CPR1(RTREG);
587         desc->flags |= IDESC_WRITES_MEMORY | IDESC_CAN_CAUSE_EXCEPTION;
588         break;
189         desc->flags |= OPFLAG_WRITES_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
190         return TRUE;
589191
590192      case 0x32:   /* LWC2 */
591193      case 0x36:   /* LDC2 */
592194         desc->gpr.used |= REGFLAG_R(RSREG);
593         desc->flags |= IDESC_READS_MEMORY | IDESC_CAN_CAUSE_EXCEPTION;
594         break;
195         desc->flags |= OPFLAG_READS_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
196         return TRUE;
595197
596198      case 0x3a:   /* SWC2 */
597199      case 0x3e:   /* SDC2 */
598200         desc->gpr.used |= REGFLAG_R(RSREG);
599         desc->flags |= IDESC_WRITES_MEMORY | IDESC_CAN_CAUSE_EXCEPTION;
600         break;
201         desc->flags |= OPFLAG_WRITES_MEMORY | OPFLAG_CAN_CAUSE_EXCEPTION;
202         return TRUE;
601203
602      case 0x2f:   /* CACHE */
603         /* effective no-op */
604         break;
605
606204      case 0x33:   /* PREF */
607205         if (mips->flavor < MIPS3_TYPE_MIPS_IV)
608            invalid_opcode(desc);
609         else
610            ; /* effective no-op */
611         break;
612
613      default: /* anything else */
614         invalid_opcode(desc);
615         break;
206            return FALSE;
207      case 0x2f:   /* CACHE */
208         /* effective no-op */
209         return TRUE;
616210   }
617211
618   /* remove any modifications of R0 */
619   desc->gpr.modified &= ~REGFLAG_R(0);
212   return FALSE;
620213}
621214
622215
r1070r1071
626219    'special' group
627220-------------------------------------------------*/
628221
629static void describe_instruction_special(mips3_state *mips, UINT32 pc, UINT32 op, mips3_opcode_desc *desc)
222static int describe_instruction_special(mips3_state *mips, UINT32 op, opcode_desc *desc)
630223{
631224   switch (op & 63)
632225   {
r1070r1071
641234      case 0x3f:   /* DSRA32 */
642235         desc->gpr.used |= REGFLAG_R(RTREG);
643236         desc->gpr.modified |= REGFLAG_R(RDREG);
644         break;
237         return TRUE;
645238
646239      case 0x0a:   /* MOVZ - MIPS IV */
647240      case 0x0b:   /* MOVN - MIPS IV */
648241         if (mips->flavor < MIPS3_TYPE_MIPS_IV)
649         {
650            invalid_opcode(desc);
651            break;
652         }
242            return FALSE;
653243         desc->gpr.used |= REGFLAG_R(RDREG);
654244      case 0x04:   /* SLLV */
655245      case 0x06:   /* SRLV */
r1070r1071
669259      case 0x2f:   /* DSUBU */
670260         desc->gpr.used |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
671261         desc->gpr.modified |= REGFLAG_R(RDREG);
672         break;
262         return TRUE;
673263
674264      case 0x20:   /* ADD */
675265      case 0x22:   /* SUB */
r1070r1071
677267      case 0x2e:   /* DSUB */
678268         desc->gpr.used |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
679269         desc->gpr.modified |= REGFLAG_R(RDREG);
680         desc->flags |= IDESC_CAN_CAUSE_EXCEPTION;
681         break;
270         desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
271         return TRUE;
682272
683273      case 0x30:   /* TGE */
684274      case 0x31:   /* TGEU */
r1070r1071
687277      case 0x34:   /* TEQ */
688278      case 0x36:   /* TNE */
689279         desc->gpr.used |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
690         desc->flags |= IDESC_CAN_CAUSE_EXCEPTION;
691         break;
280         desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
281         return TRUE;
692282
693283      case 0x01:   /* MOVF - MIPS IV */
694284         if (mips->flavor < MIPS3_TYPE_MIPS_IV)
695         {
696            invalid_opcode(desc);
697            break;
698         }
285            return FALSE;
699286         desc->gpr.used |= REGFLAG_R(RSREG);
700287         desc->fpr.used |= REGFLAG_FCC;
701288         desc->gpr.modified |= REGFLAG_R(RDREG);
702         break;
289         return TRUE;
703290
704291      case 0x08:   /* JR */
705292         desc->gpr.used |= REGFLAG_R(RSREG);
706         desc->flags |= IDESC_IS_UNCONDITIONAL_BRANCH | IDESC_END_SEQUENCE;
707         break;
293         desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
294         desc->delayslots = 1;
295         return TRUE;
708296
709297      case 0x09:   /* JALR */
710298         desc->gpr.used |= REGFLAG_R(RSREG);
711299         desc->gpr.modified |= REGFLAG_R(RDREG);
712         desc->flags |= IDESC_IS_UNCONDITIONAL_BRANCH | IDESC_END_SEQUENCE;
713         break;
300         desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
301         desc->delayslots = 1;
302         return TRUE;
714303
715304      case 0x10:   /* MFHI */
716305         desc->gpr.used |= REGFLAG_HI;
717306         desc->gpr.modified |= REGFLAG_R(RDREG);
718         break;
307         return TRUE;
719308
720309      case 0x11:   /* MTHI */
721310         desc->gpr.used |= REGFLAG_R(RSREG);
722311         desc->gpr.modified |= REGFLAG_HI;
723         break;
312         return TRUE;
724313
725314      case 0x12:   /* MFLO */
726315         desc->gpr.used |= REGFLAG_LO;
727316         desc->gpr.modified |= REGFLAG_R(RDREG);
728         break;
317         return TRUE;
729318
730319      case 0x13:   /* MTLO */
731320         desc->gpr.used |= REGFLAG_R(RSREG);
732321         desc->gpr.modified |= REGFLAG_LO;
733         break;
322         return TRUE;
734323
735324      case 0x18:   /* MULT */
736325      case 0x19:   /* MULTU */
737326         desc->gpr.used |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
738327         desc->gpr.modified |= REGFLAG_LO | REGFLAG_HI;
739328         desc->cycles = 3;
740         break;
329         return TRUE;
741330
742331      case 0x1a:   /* DIV */
743332      case 0x1b:   /* DIVU */
744333         desc->gpr.used |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
745334         desc->gpr.modified |= REGFLAG_LO | REGFLAG_HI;
746335         desc->cycles = 35;
747         break;
336         return TRUE;
748337
749338      case 0x1c:   /* DMULT */
750339      case 0x1d:   /* DMULTU */
751340         desc->gpr.used |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
752341         desc->gpr.modified |= REGFLAG_LO | REGFLAG_HI;
753342         desc->cycles = 7;
754         break;
343         return TRUE;
755344
756345      case 0x1e:   /* DDIV */
757346      case 0x1f:   /* DDIVU */
758347         desc->gpr.used |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
759348         desc->gpr.modified |= REGFLAG_LO | REGFLAG_HI;
760349         desc->cycles = 67;
761         break;
350         return TRUE;
762351
763352      case 0x0c:   /* SYSCALL */
764353      case 0x0d:   /* BREAK */
765         desc->flags |= IDESC_WILL_CAUSE_EXCEPTION | IDESC_END_SEQUENCE;
766         break;
354         desc->flags |= OPFLAG_WILL_CAUSE_EXCEPTION | OPFLAG_END_SEQUENCE;
355         return TRUE;
767356
768357      case 0x0f:   /* SYNC */
769358         /* effective no-op */
770         break;
771
772      default:   /* anything else */
773         invalid_opcode(desc);
774         break;
359         return TRUE;
775360   }
361
362   return FALSE;
776363}
777364
778365
r1070r1071
782369    'regimm' group
783370-------------------------------------------------*/
784371
785static void describe_instruction_regimm(mips3_state *mips, UINT32 pc, UINT32 op, mips3_opcode_desc *desc)
372static int describe_instruction_regimm(mips3_state *mips, UINT32 op, opcode_desc *desc)
786373{
787374   switch (RTREG)
788375   {
789      case 0x02:   /* BLTZL */
790      case 0x03:   /* BGEZL */
791         desc->flags |= IDESC_IS_LIKELY_BRANCH;
792         /* fall through */
793
794376      case 0x00:   /* BLTZ */
795377      case 0x01:   /* BGEZ */
378      case 0x02:   /* BLTZL */
379      case 0x03:   /* BGEZL */
796380         if (RTREG == 0x01 && RSREG == 0)
797            desc->flags |= IDESC_IS_UNCONDITIONAL_BRANCH | IDESC_END_SEQUENCE;
381            desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
798382         else
799383         {
800384            desc->gpr.used |= REGFLAG_R(RSREG);
801            desc->flags |= IDESC_IS_CONDITIONAL_BRANCH;
385            desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
802386         }
803         desc->targetpc = pc + 4 + (SIMMVAL << 2);
804         break;
387         desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
388         desc->delayslots = 1;
389         desc->skipslots = (RTREG & 0x02) ? 1 : 0;
390         return TRUE;
805391
806392      case 0x08:   /* TGEI */
807393      case 0x09:   /* TGEIU */
r1070r1071
810396      case 0x0c:   /* TEQI */
811397      case 0x0e:   /* TNEI */
812398         desc->gpr.used |= REGFLAG_R(RSREG);
813         desc->flags |= IDESC_CAN_CAUSE_EXCEPTION;
814         break;
399         desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
400         return TRUE;
815401
816      case 0x12:   /* BLTZALL */
817      case 0x13:   /* BGEZALL */
818         desc->flags |= IDESC_IS_LIKELY_BRANCH;
819         /* fall through */
820
821402      case 0x10:   /* BLTZAL */
822403      case 0x11:   /* BGEZAL */
404      case 0x12:   /* BLTZALL */
405      case 0x13:   /* BGEZALL */
823406         if (RTREG == 0x11 && RSREG == 0)
824            desc->flags |= IDESC_IS_UNCONDITIONAL_BRANCH | IDESC_END_SEQUENCE;
407            desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
825408         else
826409         {
827410            desc->gpr.used |= REGFLAG_R(RSREG);
828            desc->flags |= IDESC_IS_CONDITIONAL_BRANCH;
411            desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
829412         }
830413         desc->gpr.modified |= REGFLAG_R(31);
831         desc->targetpc = pc + 4 + (SIMMVAL << 2);
832         break;
833
834      default:   /* anything else */
835         invalid_opcode(desc);
836         break;
414         desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
415         desc->delayslots = 1;
416         desc->skipslots = (RTREG & 0x02) ? 1 : 0;
417         return TRUE;
837418   }
419
420   return FALSE;
838421}
839422
840423
r1070r1071
844427    IDT-specific group
845428-------------------------------------------------*/
846429
847static void describe_instruction_idt(mips3_state *mips, UINT32 pc, UINT32 op, mips3_opcode_desc *desc)
430static int describe_instruction_idt(mips3_state *mips, UINT32 op, opcode_desc *desc)
848431{
849432   switch (op & 0x1f)
850433   {
r1070r1071
852435      case 1: /* MADU */
853436         desc->gpr.used |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG) | REGFLAG_LO | REGFLAG_HI;
854437         desc->gpr.modified |= REGFLAG_LO | REGFLAG_HI;
855         break;
438         return TRUE;
856439
857440      case 2: /* MUL */
858441         desc->gpr.used |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
859442         desc->gpr.modified |= REGFLAG_R(RDREG);
860443         desc->cycles = 3;
861         break;
862
863      default: /* anything else */
864         invalid_opcode(desc);
865         break;
444         return TRUE;
866445   }
446
447   return FALSE;
867448}
868449
869450
r1070r1071
873454    COP0 group
874455-------------------------------------------------*/
875456
876static void describe_instruction_cop0(mips3_state *mips, UINT32 pc, UINT32 op, mips3_opcode_desc *desc)
457static int describe_instruction_cop0(mips3_state *mips, UINT32 op, opcode_desc *desc)
877458{
878459   /* any COP0 instruction can potentially cause an exception */
879   desc->flags |= IDESC_CAN_CAUSE_EXCEPTION;
460   desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
880461
881462   switch (RSREG)
882463   {
r1070r1071
884465      case 0x01:   /* DMFCz */
885466      case 0x02:   /* CFCz */
886467         desc->gpr.modified |= REGFLAG_R(RTREG);
887         break;
468         return TRUE;
888469
889470      case 0x04:   /* MTCz */
890471      case 0x05:   /* DMTCz */
r1070r1071
893474         if (RSREG == 0x04 || RSREG == 0x05)
894475         {
895476            if (RDREG == COP0_Cause)
896               desc->flags |= IDESC_CAN_TRIGGER_SW_INT;
477               desc->flags |= OPFLAG_CAN_TRIGGER_SW_INT;
897478            if (RDREG == COP0_Status)
898               desc->flags |= IDESC_CAN_EXPOSE_EXTERNAL_INT;
479               desc->flags |= OPFLAG_CAN_EXPOSE_EXTERNAL_INT | OPFLAG_CAN_CHANGE_MODES | OPFLAG_END_SEQUENCE;
899480         }
900         break;
481         return TRUE;
901482
902483      case 0x08:   /* BC */
903484         switch (RTREG)
904485         {
905486            case 0x00:   /* BCzF */
906487            case 0x01:   /* BCzT */
907               desc->flags |= IDESC_IS_CONDITIONAL_BRANCH;
908               desc->targetpc = pc + 4 + (SIMMVAL << 2);
909               break;
910
911            default: /* anything else */
912               invalid_opcode(desc);
913               break;
488               desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
489               desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
490               desc->delayslots = 1;
491               return TRUE;
914492         }
915         break;
493         return FALSE;
916494
917495      case 0x10:   case 0x11:   case 0x12:   case 0x13:   case 0x14:   case 0x15:   case 0x16:   case 0x17:
918496      case 0x18:   case 0x19:   case 0x1a:   case 0x1b:   case 0x1c:   case 0x1d:   case 0x1e:   case 0x1f:   /* COP */
r1070r1071
921499            case 0x01:   /* TLBR */
922500            case 0x08:   /* TLBP */
923501            case 0x20:   /* WAIT */
924               break;
502               return TRUE;
925503
926504            case 0x02:   /* TLBWI */
927505            case 0x06:   /* TLBWR */
928               desc->flags |= IDESC_MODIFIES_TRANSLATION;
929               break;
506               desc->flags |= OPFLAG_MODIFIES_TRANSLATION;
507               return TRUE;
930508
931509            case 0x18:   /* ERET */
932               desc->flags |= IDESC_IS_UNCONDITIONAL_BRANCH | IDESC_END_SEQUENCE;
933               break;
934
935            default: /* anything else */
936               invalid_opcode(desc);
937               break;
510               desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
511               return TRUE;
938512         }
939         break;
940
941      default: /* anything else */
942         invalid_opcode(desc);
943         break;
513         return FALSE;
944514   }
515
516   return FALSE;
945517}
946518
947519
r1070r1071
951523    COP1 group
952524-------------------------------------------------*/
953525
954static void describe_instruction_cop1(mips3_state *mips, UINT32 pc, UINT32 op, mips3_opcode_desc *desc)
526static int describe_instruction_cop1(mips3_state *mips, UINT32 op, opcode_desc *desc)
955527{
956528   /* any COP1 instruction can potentially cause an exception */
957//  desc->flags |= IDESC_CAN_CAUSE_EXCEPTION;
529//  desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
958530
959531   switch (RSREG)
960532   {
r1070r1071
962534      case 0x01:   /* DMFCz */
963535         desc->fpr.used |= REGFLAG_CPR1(RDREG);
964536         desc->gpr.modified |= REGFLAG_R(RTREG);
965         break;
537         return TRUE;
966538
967539      case 0x02:   /* CFCz */
968540         desc->gpr.modified |= REGFLAG_R(RTREG);
969         break;
541         return TRUE;
970542
971543      case 0x04:   /* MTCz */
972544      case 0x05:   /* DMTCz */
973545         desc->gpr.used |= REGFLAG_R(RTREG);
974546         desc->fpr.modified |= REGFLAG_CPR1(RDREG);
975         break;
547         return TRUE;
976548
977549      case 0x06:   /* CTCz */
978550         desc->gpr.used |= REGFLAG_R(RTREG);
979         break;
551         return TRUE;
980552
981553      case 0x08:   /* BC */
982         switch (RTREG)
554         switch (RTREG & 3)
983555         {
984            case 0x02:   /* BCzFL */
985            case 0x03:   /* BCzTL */
986               desc->flags |= IDESC_IS_LIKELY_BRANCH;
987               /* fall through */
988
989556            case 0x00:   /* BCzF */
990557            case 0x01:   /* BCzT */
558            case 0x02:   /* BCzFL */
559            case 0x03:   /* BCzTL */
991560               desc->fpr.used |= REGFLAG_FCC;
992               desc->flags |= IDESC_IS_CONDITIONAL_BRANCH;
993               desc->targetpc = pc + 4 + (SIMMVAL << 2);
994               break;
995
996            default: /* anything else */
997               invalid_opcode(desc);
998               break;
561               desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
562               desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
563               desc->delayslots = 1;
564               desc->skipslots = (RTREG & 0x02) ? 1 : 0;
565               return TRUE;
999566         }
1000         break;
567         return FALSE;
1001568
1002569      case 0x10:   case 0x11:   case 0x12:   case 0x13:   case 0x14:   case 0x15:   case 0x16:   case 0x17:
1003570      case 0x18:   case 0x19:   case 0x1a:   case 0x1b:   case 0x1c:   case 0x1d:   case 0x1e:   case 0x1f:   /* COP */
r1070r1071
1006573            case 0x12:   /* MOVZ - MIPS IV */
1007574            case 0x13:   /* MOVN - MIPS IV */
1008575               if (mips->flavor < MIPS3_TYPE_MIPS_IV)
1009               {
1010                  invalid_opcode(desc);
1011                  break;
1012               }
576                  return FALSE;
1013577            case 0x00:   /* ADD */
1014578            case 0x01:   /* SUB */
1015579            case 0x02:   /* MUL */
1016580            case 0x03:   /* DIV */
1017581               desc->fpr.used |= REGFLAG_CPR1(FSREG) | REGFLAG_CPR1(FTREG);
1018582               desc->fpr.modified |= REGFLAG_CPR1(FDREG);
1019               break;
583               return TRUE;
1020584
1021585            case 0x15:   /* RECIP - MIPS IV */
1022586            case 0x16:   /* RSQRT - MIPS IV */
1023587               if (mips->flavor < MIPS3_TYPE_MIPS_IV)
1024               {
1025                  invalid_opcode(desc);
1026                  break;
1027               }
588                  return FALSE;
1028589            case 0x04:   /* SQRT */
1029590            case 0x05:   /* ABS */
1030591            case 0x06:   /* MOV */
r1070r1071
1043604            case 0x25:   /* CVT.L */
1044605               desc->fpr.used |= REGFLAG_CPR1(FSREG);
1045606               desc->fpr.modified |= REGFLAG_CPR1(FDREG);
1046               break;
607               return TRUE;
1047608
1048609            case 0x11:   /* MOVT/F - MIPS IV */
1049610               if (mips->flavor < MIPS3_TYPE_MIPS_IV)
1050               {
1051                  invalid_opcode(desc);
1052                  break;
1053               }
611                  return FALSE;
1054612               desc->fpr.used |= REGFLAG_CPR1(FSREG) | REGFLAG_FCC;
1055613               desc->fpr.modified |= REGFLAG_CPR1(FDREG);
1056               break;
614               return TRUE;
1057615
1058616            case 0x30:   case 0x38:   /* C.F */
1059617            case 0x31:   case 0x39:   /* C.UN */
1060618               desc->fpr.modified |= REGFLAG_FCC;
1061               break;
619               return TRUE;
1062620
1063621            case 0x32:   case 0x3a:   /* C.EQ */
1064622            case 0x33:   case 0x3b:   /* C.UEQ */
r1070r1071
1068626            case 0x37:   case 0x3f:   /* C.ULE */
1069627               desc->fpr.used |= REGFLAG_CPR1(FSREG) | REGFLAG_CPR1(FTREG);
1070628               desc->fpr.modified |= REGFLAG_FCC;
1071               break;
1072
1073            default: /* anything else */
1074               invalid_opcode(desc);
1075               break;
629               return TRUE;
1076630         }
1077         break;
1078
1079      default: /* anything else */
1080         invalid_opcode(desc);
1081         break;
631         return FALSE;
1082632   }
633
634   return FALSE;
1083635}
1084636
1085637
r1070r1071
1089641    COP1X group
1090642-------------------------------------------------*/
1091643
1092static void describe_instruction_cop1x(mips3_state *mips, UINT32 pc, UINT32 op, mips3_opcode_desc *desc)
644static int describe_instruction_cop1x(mips3_state *mips, UINT32 op, opcode_desc *desc)
1093645{
1094646   /* any COP1 instruction can potentially cause an exception */
1095//  desc->flags |= IDESC_CAN_CAUSE_EXCEPTION;
647//  desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
1096648
1097649   switch (op & 0x3f)
1098650   {
r1070r1071
1100652      case 0x01:   /* LDXC1 */
1101653         desc->gpr.used |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
1102654         desc->fpr.modified |= REGFLAG_CPR1(FDREG);
1103         desc->flags |= IDESC_READS_MEMORY;
1104         break;
655         desc->flags |= OPFLAG_READS_MEMORY;
656         return TRUE;
1105657
1106      case 0x02:   /* SWXC1 */
1107      case 0x03:   /* SDXC1 */
658      case 0x08:   /* SWXC1 */
659      case 0x09:   /* SDXC1 */
1108660         desc->gpr.used |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
1109661         desc->fpr.used |= REGFLAG_CPR1(FDREG);
1110         desc->flags |= IDESC_WRITES_MEMORY;
1111         break;
662         desc->flags |= OPFLAG_WRITES_MEMORY;
663         return TRUE;
1112664
1113665      case 0x0f:   /* PREFX */
1114666         /* effective no-op */
1115         break;
667         return TRUE;
1116668
1117669      case 0x20:   case 0x21:   /* MADD */
1118670      case 0x28:   case 0x29:   /* MSUB */
1119671      case 0x30:   case 0x31:   /* NMADD */
1120      case 0x32:   case 0x39:   /* NMSUB */
672      case 0x38:   case 0x39:   /* NMSUB */
1121673         desc->fpr.used |= REGFLAG_CPR1(FSREG) | REGFLAG_CPR1(FTREG) | REGFLAG_CPR1(FRREG);
1122674         desc->fpr.modified |= REGFLAG_CPR1(FDREG);
1123         break;
1124
1125      default: /* anything else */
1126         invalid_opcode(desc);
1127         break;
675         return TRUE;
1128676   }
677
678   return FALSE;
1129679}
1130680
1131681
r1070r1071
1135685    COP2 group
1136686-------------------------------------------------*/
1137687
1138static void describe_instruction_cop2(mips3_state *mips, UINT32 pc, UINT32 op, mips3_opcode_desc *desc)
688static int describe_instruction_cop2(mips3_state *mips, UINT32 op, opcode_desc *desc)
1139689{
1140690   /* any COP2 instruction can potentially cause an exception */
1141   desc->flags |= IDESC_CAN_CAUSE_EXCEPTION;
691   desc->flags |= OPFLAG_CAN_CAUSE_EXCEPTION;
1142692
1143693   switch (RSREG)
1144694   {
r1070r1071
1146696      case 0x01:   /* DMFCz */
1147697      case 0x02:   /* CFCz */
1148698         desc->gpr.modified |= REGFLAG_R(RTREG);
1149         break;
699         return TRUE;
1150700
1151701      case 0x04:   /* MTCz */
1152702      case 0x05:   /* DMTCz */
1153703      case 0x06:   /* CTCz */
1154704         desc->gpr.used |= REGFLAG_R(RTREG);
1155         break;
705         return TRUE;
1156706
1157707      case 0x08:   /* BC */
1158708         switch (RTREG)
1159709         {
1160710            case 0x00:   /* BCzF */
1161711            case 0x01:   /* BCzT */
1162               desc->flags |= IDESC_IS_CONDITIONAL_BRANCH;
1163               desc->targetpc = pc + 4 + (SIMMVAL << 2);
1164               break;
1165
1166            default: /* anything else */
1167               invalid_opcode(desc);
1168               break;
712               desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
713               desc->targetpc = desc->pc + 4 + (SIMMVAL << 2);
714               desc->delayslots = 1;
715               return TRUE;
1169716         }
1170         break;
1171
1172      default: /* anything else */
1173         invalid_opcode(desc);
1174         break;
717         return FALSE;
1175718   }
719
720   return FALSE;
1176721}
src/emu/cpu/mips/mips3fe.h
r1070r1071
44
55    Front-end for MIPS3 recompiler
66
7    Copyright (c) 2007, Aaron Giles
8    Released for general use under the MAME license
9    Visit http://mamedev.org for licensing and usage restrictions.
10
711***************************************************************************/
812
913#ifndef __MIPS3FE_H__
1014#define __MIPS3FE_H__
1115
12#include "mips3com.h"
16#include "cpu/drcfe.h"
1317
1418
1519/***************************************************************************
r1070r1071
1721***************************************************************************/
1822
1923/* register flags */
20#define REGFLAG_R(n)               ((UINT64)1 << (n))
24#define REGFLAG_R(n)               (((n) == 0) ? 0 : ((UINT64)1 << (n)))
2125#define REGFLAG_LO                  (REGFLAG_R(REG_LO))
2226#define REGFLAG_HI                  (REGFLAG_R(REG_HI))
2327#define REGFLAG_CPR1(n)               ((UINT64)1 << (n))
2428#define REGFLAG_FCC                  (REGFLAG_CPR1(32))
2529
26/* instruction description flags */
27#define IDESC_IS_UNCONDITIONAL_BRANCH   0x00000001      /* instruction is unconditional branch */
28#define IDESC_IS_CONDITIONAL_BRANCH      0x00000002      /* instruction is conditional branch */
29#define IDESC_IS_LIKELY_BRANCH         0x00000004      /* instruction is likely branch */
30#define IDESC_CAN_TRIGGER_SW_INT      0x00000008      /* instruction can trigger a software interrupt */
31#define IDESC_CAN_EXPOSE_EXTERNAL_INT   0x00000010      /* instruction can expose an external interrupt */
32#define IDESC_CAN_CAUSE_EXCEPTION      0x00000020      /* instruction may generate exception */
33#define IDESC_WILL_CAUSE_EXCEPTION      0x00000040      /* instruction will generate exception */
34#define IDESC_INVALID_OPCODE         0x00000080      /* instruction is invalid */
35#define IDESC_READS_MEMORY            0x00000100      /* instruction reads memory */
36#define IDESC_WRITES_MEMORY            0x00000200      /* instruction writes memory */
37#define IDESC_VALIDATE_TLB            0x00000400      /* instruction must validate TLB */
38#define IDESC_MODIFIES_TRANSLATION      0x00000800      /* instruction modifies the TLB */
39#define IDESC_REDISPATCH            0x00001000      /* instruction must redispatch */
40#define IDESC_RETURN_TO_START         0x00002000      /* instruction must jump back to the beginning */
41#define IDESC_IS_BRANCH_TARGET         0x00004000      /* instruction is the target of a branch */
42#define IDESC_IN_DELAY_SLOT            0x00008000      /* instruction is in the delay slot of a branch */
43#define IDESC_INTRABLOCK_BRANCH         0x00010000      /* instruction branches within the block */
44#define IDESC_END_SEQUENCE            0x00020000      /* this is the last instruction in a sequence */
4530
46/* pre-defined groups of flags */
47#define IDESC_IS_BRANCH               (IDESC_IS_UNCONDITIONAL_BRANCH | IDESC_IS_CONDITIONAL_BRANCH)
4831
49
50
5132/***************************************************************************
52    TYPE DEFINITIONS
33    CONSTANTS
5334***************************************************************************/
5435
55typedef struct _mips3_reginfo mips3_reginfo;
56struct _mips3_reginfo
57{
58   UINT64         used;                  /* bitmask of used registers */
59   UINT64         modified;               /* bitmask of modified registers */
60   UINT64         liveread;               /* bitmask of registers that are live for reading */
61   UINT64         livewrite;               /* bitmask of registers that are live for writing */
62};
36/* this defines a branch targetpc that is dynamic at runtime */
37#define BRANCH_TARGET_DYNAMIC         (~0)
6338
6439
65typedef struct _mips3_opcode_desc mips3_opcode_desc;
66struct _mips3_opcode_desc
67{
68   mips3_opcode_desc *next;               /* pointer to next description */
69   mips3_opcode_desc *delay;               /* pointer to delay slot description */
70   mips3_opcode_desc *branch;               /* pointer back to branch description for delay slots */
40/* opcode branch flags */
41#define OPFLAG_IS_UNCONDITIONAL_BRANCH   0x00000001      /* instruction is unconditional branch */
7142
72   UINT32         pc;                     /* PC of this opcode */
73   UINT32         physpc;                  /* physical PC of this opcode */
74   UINT32         targetpc;               /* target PC if we are a branch */
7543
76   UINT32 *      opptr;                  /* physical memory pointer */
77   UINT32         flags;                  /* opcode flags */
78   UINT32         cycles;                  /* number of cycles needed to execute */
79
80   mips3_reginfo   gpr;                  /* register info for GPRs */
81   mips3_reginfo   fpr;                  /* register info for FPRs */
82};
83
84
85
8644/***************************************************************************
8745    FUNCTION PROTOTYPES
8846***************************************************************************/
8947
90void mips3fe_init(void);
91void mips3fe_exit(void);
48int mips3fe_describe(void *param, opcode_desc *desc);
9249
93mips3_opcode_desc *mips3fe_describe_sequence(mips3_state *mips, UINT32 startpc, UINT32 minpc, UINT32 maxpc, int maxseq);
94void mips3fe_release_descriptions(mips3_opcode_desc *desc);
95
9650#endif
src/emu/cpu/mips/mips3drc.c
r1070r1071
1515#include "cpuintrf.h"
1616#include "debugger.h"
1717#include "mips3com.h"
18#include "mips3fe.h"
1819#include "cpu/x86log.h"
20#include "cpu/drcfe.h"
1921
20#ifdef PTR64
21#include "cpu/x64drc.h"
22#include "mips3fe.h"
23#else
24#include "cpu/x86drc.h"
25#endif
26
2722extern unsigned dasmmips3(char *buffer, unsigned pc, UINT32 op);
2823
2924
r1070r1071
3328***************************************************************************/
3429
3530#define LOG_CODE            (0)
31#define SINGLE_INSTRUCTION_MODE   (0)
3632
3733#ifdef MAME_DEBUG
3834#define COMPARE_AGAINST_C      (0)
r1070r1071
4642    CONFIGURATION
4743***************************************************************************/
4844
49#define MAX_INSTRUCTIONS      512
5045#define CACHE_SIZE            (32 * 1024 * 1024)
5146
5247
r1070r1071
106101   /* core state */
107102   UINT8 *         cache;                  /* base of the cache */
108103   mips3_state *   core;                  /* pointer to the core MIPS3 state */
104   drcfe_state *   drcfe;                  /* pointer to the DRC front-end state */
109105   drc_core *      drc;                  /* pointer to the DRC core */
110106   mips3drc_data *   drcdata;               /* pointer to the DRC-specific data */
111107   UINT32         drcoptions;               /* configurable DRC options */
r1070r1071
170166    mips3_init - initialize the processor
171167-------------------------------------------------*/
172168
173static void mips3_init(mips3_state *mips, mips3_flavor flavor, int bigendian, int index, int clock, const struct mips3_config *config, int (*irqcallback)(int))
169static void mips3_init(mips3_flavor flavor, int bigendian, int index, int clock, const struct mips3_config *config, int (*irqcallback)(int))
174170{
171   drcfe_config feconfig =
172   {
173      128,            /* code window start offset = startpc - window_start */
174      512,            /* code window end offset = startpc + window_end */
175      32,               /* maximum instructions to include in a sequence */
176      mips3fe_describe   /* callback to describe a single instruction */
177   };
178
175179   /* allocate a cache and memory for the core data in a single block */
176180   mips3.core = osd_alloc_executable(CACHE_SIZE + sizeof(*mips3.core));
177181   if (mips3.core == NULL)
r1070r1071
186190
187191   /* initialize the DRC to use the cache */
188192   mips3drc_init();
193   if (Machine->debug_mode || SINGLE_INSTRUCTION_MODE)
194      feconfig.max_sequence = 1;
195   mips3.drcfe = drcfe_init(&feconfig, mips3.core);
189196
190197   /* start up code logging */
191198   if (LOG_CODE)
r1070r1071
243250
244251   /* clean up the DRC */
245252   mips3drc_exit();
253   drcfe_exit(mips3.drcfe);
246254   drc_exit(mips3.drc);
247255
248256   /* free the cache */
r1070r1071
354362
355363static void log_add_disasm_comment(x86log_context *log, x86code *base, UINT32 pc, UINT32 op)
356364{
357   if (LOG_CODE)
365#if (LOG_CODE)
358366   {
359367      char buffer[100];
360368      dasmmips3(buffer, pc, op);
361369      x86log_add_comment(log, base, "%08X: %s", pc, buffer);
362370   }
371#endif
363372}
364373
365374
r1070r1071
377386   char *dest = tempbuf;
378387
379388   /* branches */
380   if (flags & IDESC_IS_UNCONDITIONAL_BRANCH)
389   if (flags & OPFLAG_IS_UNCONDITIONAL_BRANCH)
381390      *dest++ = 'U';
382   else if (flags & IDESC_IS_CONDITIONAL_BRANCH)
391   else if (flags & OPFLAG_IS_CONDITIONAL_BRANCH)
383392      *dest++ = 'C';
384393   else
385394      *dest++ = '.';
386395
387396   /* intrablock branches */
388   *dest++ = (flags & IDESC_INTRABLOCK_BRANCH) ? 'i' : '.';
397   *dest++ = (flags & OPFLAG_INTRABLOCK_BRANCH) ? 'i' : '.';
389398
390399   /* branch targets */
391   *dest++ = (flags & IDESC_IS_BRANCH_TARGET) ? 'B' : '.';
400   *dest++ = (flags & OPFLAG_IS_BRANCH_TARGET) ? 'B' : '.';
392401
393402   /* delay slots */
394   *dest++ = (flags & IDESC_IN_DELAY_SLOT) ? 'D' : '.';
403   *dest++ = (flags & OPFLAG_IN_DELAY_SLOT) ? 'D' : '.';
395404
396405   /* exceptions */
397   if (flags & IDESC_WILL_CAUSE_EXCEPTION)
406   if (flags & OPFLAG_WILL_CAUSE_EXCEPTION)
398407      *dest++ = 'E';
399   else if (flags & IDESC_CAN_CAUSE_EXCEPTION)
408   else if (flags & OPFLAG_CAN_CAUSE_EXCEPTION)
400409      *dest++ = 'e';
401410   else
402411      *dest++ = '.';
403412
404413   /* read/write */
405   if (flags & IDESC_READS_MEMORY)
414   if (flags & OPFLAG_READS_MEMORY)
406415      *dest++ = 'R';
407   else if (flags & IDESC_WRITES_MEMORY)
416   else if (flags & OPFLAG_WRITES_MEMORY)
408417      *dest++ = 'W';
409418   else
410419      *dest++ = '.';
411420
412421   /* TLB validation */
413   *dest++ = (flags & IDESC_VALIDATE_TLB) ? 'V' : '.';
422   *dest++ = (flags & OPFLAG_VALIDATE_TLB) ? 'V' : '.';
414423
415424   /* TLB modification */
416   *dest++ = (flags & IDESC_MODIFIES_TRANSLATION) ? 'T' : '.';
425   *dest++ = (flags & OPFLAG_MODIFIES_TRANSLATION) ? 'T' : '.';
417426
418427   /* redispatch */
419   *dest++ = (flags & IDESC_REDISPATCH) ? 'R' : '.';
428   *dest++ = (flags & OPFLAG_REDISPATCH) ? 'R' : '.';
420429   return tempbuf;
421430}
422431
r1070r1071
457466    log_opcode_desc - log a list of descriptions
458467-------------------------------------------------*/
459468
460static void log_opcode_desc(x86log_context *log, const mips3_opcode_desc *desclist, int indent)
469static void log_opcode_desc(x86log_context *log, const opcode_desc *desclist, int indent)
461470{
462471   /* open the file, creating it if necessary */
463472   if (indent == 0)
r1070r1071
470479
471480      /* disassemle the current instruction and output it to the log */
472481#if LOG_CODE
473      dasmmips3(buffer, desclist->pc, *desclist->opptr);
482      dasmmips3(buffer, desclist->pc, *desclist->opptr.l);
474483#else
475484      strcpy(buffer, "???");
476485#endif
r1070r1071
488497         log_opcode_desc(log, desclist->delay, indent + 1);
489498
490499      /* at the end of a sequence add a dividing line */
491      if (desclist->flags & IDESC_END_SEQUENCE)
500      if (desclist->flags & OPFLAG_END_SEQUENCE)
492501         x86log_printf(log, "-----\n");
493502   }
494503}
r1070r1071
576585#if (HAS_R4600)
577586static void r4600be_init(int index, int clock, const void *config, int (*irqcallback)(int))
578587{
579   mips3_init(mips3.core, MIPS3_TYPE_R4600, TRUE, index, clock, config, irqcallback);
588   mips3_init(MIPS3_TYPE_R4600, TRUE, index, clock, config, irqcallback);
580589}
581590
582591static void r4600le_init(int index, int clock, const void *config, int (*irqcallback)(int))
583592{
584   mips3_init(mips3.core, MIPS3_TYPE_R4600, FALSE, index, clock, config, irqcallback);
593   mips3_init(MIPS3_TYPE_R4600, FALSE, index, clock, config, irqcallback);
585594}
586595
587596void r4600be_get_info(UINT32 state, cpuinfo *info)
r1070r1071
630639#if (HAS_R4650)
631640static void r4650be_init(int index, int clock, const void *config, int (*irqcallback)(int))
632641{
633   mips3_init(mips3.core, MIPS3_TYPE_R4650, TRUE, index, clock, config, irqcallback);
642   mips3_init(MIPS3_TYPE_R4650, TRUE, index, clock, config, irqcallback);
634643}
635644
636645static void r4650le_init(int index, int clock, const void *config, int (*irqcallback)(int))
637646{
638   mips3_init(mips3.core, MIPS3_TYPE_R4650, FALSE, index, clock, config, irqcallback);
647   mips3_init(MIPS3_TYPE_R4650, FALSE, index, clock, config, irqcallback);
639648}
640649
641650void r4650be_get_info(UINT32 state, cpuinfo *info)
r1070r1071
684693#if (HAS_R4700)
685694static void r4700be_init(int index, int clock, const void *config, int (*irqcallback)(int))
686695{
687   mips3_init(mips3.core, MIPS3_TYPE_R4700, TRUE, index, clock, config, irqcallback);
696   mips3_init(MIPS3_TYPE_R4700, TRUE, index, clock, config, irqcallback);
688697}
689698
690699static void r4700le_init(int index, int clock, const void *config, int (*irqcallback)(int))
691700{
692   mips3_init(mips3.core, MIPS3_TYPE_R4700, FALSE, index, clock, config, irqcallback);
701   mips3_init(MIPS3_TYPE_R4700, FALSE, index, clock, config, irqcallback);
693702}
694703
695704void r4700be_get_info(UINT32 state, cpuinfo *info)
r1070r1071
739748#if (HAS_R5000)
740749static void r5000be_init(int index, int clock, const void *config, int (*irqcallback)(int))
741750{
742   mips3_init(mips3.core, MIPS3_TYPE_R5000, TRUE, index, clock, config, irqcallback);
751   mips3_init(MIPS3_TYPE_R5000, TRUE, index, clock, config, irqcallback);
743752}
744753
745754static void r5000le_init(int index, int clock, const void *config, int (*irqcallback)(int))
746755{
747   mips3_init(mips3.core, MIPS3_TYPE_R5000, FALSE, index, clock, config, irqcallback);
756   mips3_init(MIPS3_TYPE_R5000, FALSE, index, clock, config, irqcallback);
748757}
749758
750759void r5000be_get_info(UINT32 state, cpuinfo *info)
r1070r1071
793802#if (HAS_QED5271)
794803static void qed5271be_init(int index, int clock, const void *config, int (*irqcallback)(int))
795804{
796   mips3_init(mips3.core, MIPS3_TYPE_QED5271, TRUE, index, clock, config, irqcallback);
805   mips3_init(MIPS3_TYPE_QED5271, TRUE, index, clock, config, irqcallback);
797806}
798807
799808static void qed5271le_init(int index, int clock, const void *config, int (*irqcallback)(int))
800809{
801   mips3_init(mips3.core, MIPS3_TYPE_QED5271, FALSE, index, clock, config, irqcallback);
810   mips3_init(MIPS3_TYPE_QED5271, FALSE, index, clock, config, irqcallback);
802811}
803812
804813void qed5271be_get_info(UINT32 state, cpuinfo *info)
r1070r1071
847856#if (HAS_RM7000)
848857static void rm7000be_init(int index, int clock, const void *config, int (*irqcallback)(int))
849858{
850   mips3_init(mips3.core, MIPS3_TYPE_RM7000, TRUE, index, clock, config, irqcallback);
859   mips3_init(MIPS3_TYPE_RM7000, TRUE, index, clock, config, irqcallback);
851860}
852861
853862static void rm7000le_init(int index, int clock, const void *config, int (*irqcallback)(int))
854863{
855   mips3_init(mips3.core, MIPS3_TYPE_RM7000, FALSE, index, clock, config, irqcallback);
864   mips3_init(MIPS3_TYPE_RM7000, FALSE, index, clock, config, irqcallback);
856865}
857866
858867void rm7000be_get_info(UINT32 state, cpuinfo *info)
src/emu/cpu/mips/mdrcold.c
r1070r1071
1313    CONSTANTS
1414***************************************************************************/
1515
16#define MAX_INSTRUCTIONS            ((512 + 128) / 4)
17
1618/* recompiler flags */
1719#define RECOMPILE_UNIMPLEMENTED         0x0000
1820#define RECOMPILE_SUCCESSFUL         0x0001
src/emu/cpu/mips/mips3com.c
r1070r1071
394394   vpn = ((mips->cpr[0][COP0_EntryHi] >> 13) & 0x07ffffff) << 1;
395395   if (index != ARRAY_LENGTH(mips->tlb))
396396   {
397      assert(mips->tlb_table[vpn & 0xfffff] != 0xffffffff);
397      /* we can't assert this because the TLB entry may not be valid */
398      /* assert(mips->tlb_table[vpn & 0xfffff] != 0xffffffff); */
398399      mips->cpr[0][COP0_Index] = index;
399400   }
400401   else
src/emu/cpu/mips/mips3.c
r1070r1071
689689{
690690   if (idx == 31)
691691   {
692      UINT32 result = mips3.core.ccr[1][31] & ~0xfe800000;
692693      int i;
693694
694      mips3.core.ccr[1][31] &= ~0xfe800000;
695695      for (i = 0; i < 8; i++)
696696         if (mips3.core.cf[1][i])
697            mips3.core.ccr[1][31] |= (UINT64)1 << fcc_shift[i];
697            result |= 1 << fcc_shift[i];
698      return result;
698699   }
699700   return mips3.core.ccr[1][idx];
700701}
src/emu/cpu/arm7/arm7core.h
r1070r1071
4040 ***************************************************************************************************/
4141enum
4242{
43ARM7_IRQ_LINE=0, ARM7_FIRQ_LINE,
44ARM7_ABORT_EXCEPTION, ARM7_ABORT_PREFETCH_EXCEPTION, ARM7_UNDEFINE_EXCEPTION,
45ARM7_NUM_LINES
43    ARM7_IRQ_LINE=0, ARM7_FIRQ_LINE,
44    ARM7_ABORT_EXCEPTION, ARM7_ABORT_PREFETCH_EXCEPTION, ARM7_UNDEFINE_EXCEPTION,
45    ARM7_NUM_LINES
4646};
4747//Really there's only 1 ABORT Line.. and cpu decides whether it's during data fetch or prefetch, but we let the user specify
4848
src/emu/uigfx.c
r1070r1071
1313#include "render.h"
1414#include "rendfont.h"
1515#include "rendutil.h"
16#include "uigfx.h"
1617
1718
1819
src/emu/video/vector.c
r1070r1071
260260VIDEO_UPDATE( vector )
261261{
262262   UINT32 flags = PRIMFLAG_ANTIALIAS(options_get_bool(mame_options(), OPTION_ANTIALIAS) ? 1 : 0) | PRIMFLAG_BLENDMODE(BLENDMODE_ADD);
263   float xscale = 1.0f / (65536 * (Machine->screen[screen].visarea.max_x - Machine->screen[screen].visarea.min_x));
264   float yscale = 1.0f / (65536 * (Machine->screen[screen].visarea.max_y - Machine->screen[screen].visarea.min_y));
265   float xoffs = (float)Machine->screen[screen].visarea.min_x;
266   float yoffs = (float)Machine->screen[screen].visarea.min_y;
263   float xscale = 1.0f / (65536 * (machine->screen[screen].visarea.max_x - machine->screen[screen].visarea.min_x));
264   float yscale = 1.0f / (65536 * (machine->screen[screen].visarea.max_y - machine->screen[screen].visarea.min_y));
265   float xoffs = (float)machine->screen[screen].visarea.min_x;
266   float yoffs = (float)machine->screen[screen].visarea.min_y;
267267   point *curpoint;
268268   render_bounds clip;
269269   int lastx = 0, lasty = 0;
src/emu/video/resnet.h
r1070r1071
158158rgb_t *compute_res_net_all(const UINT8 *prom, const res_net_decode_info *rdi, const res_net_info *di);
159159
160160
161void normalize_palette(running_machine *machine, int start, int end, int lum_min, int lum_max);
162
163
164161/* legacy interface */
165162
166163double compute_resistor_weights(
src/emu/video/generic.c
r1070r1071
334334   memset(dirtybuffer, 1, videoram_size);
335335
336336   /* allocate the temporary bitmap */
337   tmpbitmap = auto_bitmap_alloc(Machine->screen[0].width, Machine->screen[0].height, Machine->screen[0].format);
337   tmpbitmap = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, machine->screen[0].format);
338338
339339   /* on a restore, we automatically zap the dirty buffer */
340340   state_save_register_func_postload(video_generic_postload);
r1070r1071
349349VIDEO_START( generic_bitmapped )
350350{
351351   /* allocate the temporary bitmap */
352   tmpbitmap = auto_bitmap_alloc(Machine->screen[0].width, Machine->screen[0].height, Machine->screen[0].format);
352   tmpbitmap = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, machine->screen[0].format);
353353
354354   /* ensure the contents of the bitmap are saved */
355355   state_save_register_bitmap("video", 0, "tmpbitmap", tmpbitmap);
r1070r1071
363363
364364VIDEO_UPDATE( generic_bitmapped )
365365{
366   copybitmap(bitmap, tmpbitmap, 0, 0, 0, 0, &Machine->screen[0].visarea, TRANSPARENCY_NONE, 0);
366   copybitmap(bitmap, tmpbitmap, 0, 0, 0, 0, &machine->screen[0].visarea, TRANSPARENCY_NONE, 0);
367367   return 0;
368368}
369369
r1070r1071
666666{
667667   int i;
668668
669   for (i = 0; i < Machine->drv->total_colors; i++)
669   for (i = 0; i < machine->drv->total_colors; i++)
670670   {
671671      int bit0,bit1,bit2,bit3,r,g,b;
672672
r1070r1071
678678      r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
679679
680680      /* green component */
681      bit0 = (color_prom[i + Machine->drv->total_colors] >> 0) & 0x01;
682      bit1 = (color_prom[i + Machine->drv->total_colors] >> 1) & 0x01;
683      bit2 = (color_prom[i + Machine->drv->total_colors] >> 2) & 0x01;
684      bit3 = (color_prom[i + Machine->drv->total_colors] >> 3) & 0x01;
681      bit0 = (color_prom[i + machine->drv->total_colors] >> 0) & 0x01;
682      bit1 = (color_prom[i + machine->drv->total_colors] >> 1) & 0x01;
683      bit2 = (color_prom[i + machine->drv->total_colors] >> 2) & 0x01;
684      bit3 = (color_prom[i + machine->drv->total_colors] >> 3) & 0x01;
685685      g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
686686
687687      /* blue component */
688      bit0 = (color_prom[i + 2*Machine->drv->total_colors] >> 0) & 0x01;
689      bit1 = (color_prom[i + 2*Machine->drv->total_colors] >> 1) & 0x01;
690      bit2 = (color_prom[i + 2*Machine->drv->total_colors] >> 2) & 0x01;
691      bit3 = (color_prom[i + 2*Machine->drv->total_colors] >> 3) & 0x01;
688      bit0 = (color_prom[i + 2*machine->drv->total_colors] >> 0) & 0x01;
689      bit1 = (color_prom[i + 2*machine->drv->total_colors] >> 1) & 0x01;
690      bit2 = (color_prom[i + 2*machine->drv->total_colors] >> 2) & 0x01;
691      bit3 = (color_prom[i + 2*machine->drv->total_colors] >> 3) & 0x01;
692692      b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
693693
694694      palette_set_color(machine,i,MAKE_RGB(r,g,b));
src/emu/memory.c
r1070r1071
23702370-------------------------------------------------*/
23712371
23722372#define READBYTE8(name,spacenum)                                          \
2373UINT8 name(offs_t address)                                                \
2373UINT8 name(offs_t original_address)                                          \
23742374{                                                                  \
2375   offs_t address = original_address;                                       \
23752376   UINT32 entry;                                                      \
23762377   MEMREADSTART();                                                      \
23772378   PERFORM_LOOKUP(readlookup,active_address_space[spacenum],~0);                  \
r1070r1071
23892390}                                                                  \
23902391
23912392#define READBYTE(name,spacenum,xormacro,handlertype,ignorebits,shiftbytes,masktype)      \
2392UINT8 name(offs_t address)                                                \
2393UINT8 name(offs_t original_address)                                          \
23932394{                                                                  \
2395   offs_t address = original_address;                                       \
23942396   UINT32 entry;                                                      \
23952397   MEMREADSTART();                                                      \
23962398   PERFORM_LOOKUP(readlookup,active_address_space[spacenum],~0);                  \
r1070r1071
24242426-------------------------------------------------*/
24252427
24262428#define READWORD16(name,spacenum)                                          \
2427UINT16 name(offs_t address)                                                \
2429UINT16 name(offs_t original_address)                                       \
24282430{                                                                  \
2431   offs_t address = original_address;                                       \
24292432   UINT32 entry;                                                      \
24302433   MEMREADSTART();                                                      \
24312434   PERFORM_LOOKUP(readlookup,active_address_space[spacenum],~1);                  \
r1070r1071
24432446}                                                                  \
24442447
24452448#define READWORD(name,spacenum,xormacro,handlertype,ignorebits,shiftbytes,masktype)      \
2446UINT16 name(offs_t address)                                                \
2449UINT16 name(offs_t original_address)                                       \
24472450{                                                                  \
2451   offs_t address = original_address;                                       \
24482452   UINT32 entry;                                                      \
24492453   MEMREADSTART();                                                      \
24502454   PERFORM_LOOKUP(readlookup,active_address_space[spacenum],~1);                  \
r1070r1071
24762480-------------------------------------------------*/
24772481
24782482#define READDWORD32(name,spacenum)                                          \
2479UINT32 name(offs_t address)                                                \
2483UINT32 name(offs_t original_address)                                       \
24802484{                                                                  \
2485   offs_t address = original_address;                                       \
24812486   UINT32 entry;                                                      \
24822487   MEMREADSTART();                                                      \
24832488   PERFORM_LOOKUP(readlookup,active_address_space[spacenum],~3);                  \
r1070r1071
24952500}                                                                  \
24962501
24972502#define READMASKED32(name,spacenum)                                          \
2498UINT32 name(offs_t address, UINT32 mem_mask)                                 \
2503UINT32 name(offs_t original_address, UINT32 mem_mask)                           \
24992504{                                                                  \
2505   offs_t address = original_address;                                       \
25002506   UINT32 entry;                                                      \
25012507   MEMREADSTART();                                                      \
25022508   PERFORM_LOOKUP(readlookup,active_address_space[spacenum],~3);                  \
r1070r1071
25142520}                                                                  \
25152521
25162522#define READDWORD(name,spacenum,xormacro,handlertype,ignorebits,shiftbytes,masktype)   \
2517UINT32 name(offs_t address)                                                \
2523UINT32 name(offs_t original_address)                                       \
25182524{                                                                  \
2525   offs_t address = original_address;                                       \
25192526   UINT32 entry;                                                      \
25202527   MEMREADSTART();                                                      \
25212528   PERFORM_LOOKUP(readlookup,active_address_space[spacenum],~3);                  \
r1070r1071
25452552-------------------------------------------------*/
25462553
25472554#define READQWORD64(name,spacenum)                                          \
2548UINT64 name(offs_t address)                                                \
2555UINT64 name(offs_t original_address)                                       \
25492556{                                                                  \
2557   offs_t address = original_address;                                       \
25502558   UINT32 entry;                                                      \
25512559   MEMREADSTART();                                                      \
25522560   PERFORM_LOOKUP(readlookup,active_address_space[spacenum],~7);                  \
r1070r1071
25642572}                                                                  \
25652573
25662574#define READMASKED64(name,spacenum)                                          \
2567UINT64 name(offs_t address, UINT64 mem_mask)                                 \
2575UINT64 name(offs_t original_address, UINT64 mem_mask)                           \
25682576{                                                                  \
2577   offs_t address = original_address;                                       \
25692578   UINT32 entry;                                                      \
25702579   MEMREADSTART();                                                      \
25712580   PERFORM_LOOKUP(readlookup,active_address_space[spacenum],~7);                  \
r1070r1071
25882597-------------------------------------------------*/
25892598
25902599#define WRITEBYTE8(name,spacenum)                                          \
2591void name(offs_t address, UINT8 data)                                       \
2600void name(offs_t original_address, UINT8 data)                                 \
25922601{                                                                  \
2602   offs_t address = original_address;                                       \
25932603   UINT32 entry;                                                      \
25942604   MEMWRITESTART();                                                   \
25952605   PERFORM_LOOKUP(writelookup,active_address_space[spacenum],~0);                  \
r1070r1071
26062616}                                                                  \
26072617
26082618#define WRITEBYTE(name,spacenum,xormacro,handlertype,ignorebits,shiftbytes,masktype)   \
2609void name(offs_t address, UINT8 data)                                       \
2619void name(offs_t original_address, UINT8 data)                                 \
26102620{                                                                  \
2621   offs_t address = original_address;                                       \
26112622   UINT32 entry;                                                      \
26122623   MEMWRITESTART();                                                   \
26132624   PERFORM_LOOKUP(writelookup,active_address_space[spacenum],~0);                  \
r1070r1071
26402651-------------------------------------------------*/
26412652
26422653#define WRITEWORD16(name,spacenum)                                          \
2643void name(offs_t address, UINT16 data)                                       \
2654void name(offs_t original_address, UINT16 data)                                 \
26442655{                                                                  \
2656   offs_t address = original_address;                                       \
26452657   UINT32 entry;                                                      \
26462658   MEMWRITESTART();                                                   \
26472659   PERFORM_LOOKUP(writelookup,active_address_space[spacenum],~1);                  \
r1070r1071
26582670}                                                                  \
26592671
26602672#define WRITEWORD(name,spacenum,xormacro,handlertype,ignorebits,shiftbytes,masktype)   \
2661void name(offs_t address, UINT16 data)                                       \
2673void name(offs_t original_address, UINT16 data)                                 \
26622674{                                                                  \
2675   offs_t address = original_address;                                       \
26632676   UINT32 entry;                                                      \
26642677   MEMWRITESTART();                                                   \
26652678   PERFORM_LOOKUP(writelookup,active_address_space[spacenum],~1);                  \
r1070r1071
26902703-------------------------------------------------*/
26912704
26922705#define WRITEDWORD32(name,spacenum)                                          \
2693void name(offs_t address, UINT32 data)                                       \
2706void name(offs_t original_address, UINT32 data)                                 \
26942707{                                                                  \
2708   offs_t address = original_address;                                       \
26952709   UINT32 entry;                                                      \
26962710   MEMWRITESTART();                                                   \
26972711   PERFORM_LOOKUP(writelookup,active_address_space[spacenum],~3);                  \
r1070r1071
27082722}                                                                  \
27092723
27102724#define WRITEMASKED32(name,spacenum)                                       \
2711void name(offs_t address, UINT32 data, UINT32 mem_mask)                           \
2725void name(offs_t original_address, UINT32 data, UINT32 mem_mask)                  \
27122726{                                                                  \
2727   offs_t address = original_address;                                       \
27132728   UINT32 entry;                                                      \
27142729   MEMWRITESTART();                                                   \
27152730   PERFORM_LOOKUP(writelookup,active_address_space[spacenum],~3);                  \
r1070r1071
27292744}                                                                  \
27302745
27312746#define WRITEDWORD(name,spacenum,xormacro,handlertype,ignorebits,shiftbytes,masktype)   \
2732void name(offs_t address, UINT32 data)                                       \
2747void name(offs_t original_address, UINT32 data)                                 \
27332748{                                                                  \
2749   offs_t address = original_address;                                       \
27342750   UINT32 entry;                                                      \
27352751   MEMWRITESTART();                                                   \
27362752   PERFORM_LOOKUP(writelookup,active_address_space[spacenum],~3);                  \
r1070r1071
27592775-------------------------------------------------*/
27602776
27612777#define WRITEQWORD64(name,spacenum)                                          \
2762void name(offs_t address, UINT64 data)                                       \
2778void name(offs_t original_address, UINT64 data)                                 \
27632779{                                                                  \
2780   offs_t address = original_address;                                       \
27642781   UINT32 entry;                                                      \
27652782   MEMWRITESTART();                                                   \
27662783   PERFORM_LOOKUP(writelookup,active_address_space[spacenum],~7);                  \
r1070r1071
27772794}                                                                  \
27782795
27792796#define WRITEMASKED64(name,spacenum)                                       \
2780void name(offs_t address, UINT64 data, UINT64 mem_mask)                           \
2797void name(offs_t original_address, UINT64 data, UINT64 mem_mask)                  \
27812798{                                                                  \
2799   offs_t address = original_address;                                       \
27822800   UINT32 entry;                                                      \
27832801   MEMWRITESTART();                                                   \
27842802   PERFORM_LOOKUP(writelookup,active_address_space[spacenum],~7);                  \
src/emu/memory.h
r1070r1071
538538typedef struct _handler_data handler_data;
539539
540540/* ----- a union of all the different read handler types ----- */
541typedef union _read_handlers read_handlers;
541542union _read_handlers
542543{
543544   genf *            handler;
r1070r1071
546547   read32_handler      handler32;
547548   read64_handler      handler64;
548549};
549typedef union _read_handlers read_handlers;
550550
551551/* ----- a union of all the different write handler types ----- */
552typedef union _write_handlers write_handlers;
552553union _write_handlers
553554{
554555   genf *            handler;
r1070r1071
557558   write32_handler      handler32;
558559   write64_handler      handler64;
559560};
560typedef union _write_handlers write_handlers;
561561
562562/* ----- a generic address map type ----- */
563typedef struct _address_map address_map;
563564struct _address_map
564565{
565566   UINT32            flags;            /* flags and additional info about this entry */
r1070r1071
577578   UINT32            region;            /* region containing the memory backing this entry */
578579   offs_t            region_offs;      /* offset within the region */
579580};
580typedef struct _address_map address_map;
581581
582582/* ----- structs to contain internal data ----- */
583typedef struct _address_space address_space;
583584struct _address_space
584585{
585586   offs_t            addrmask;         /* address mask */
r1070r1071
589590   handler_data *      writehandlers;      /* write handlers */
590591   data_accessors *   accessors;         /* pointers to the data access handlers */
591592};
592typedef struct _address_space address_space;
593593
594594
595595
src/emu/mamecore.h
r1070r1071
167167#endif
168168
169169
170/* map mame_* helpers to core_* helpers */
171#define mame_stricmp      core_stricmp
172#define mame_strnicmp      core_strnicmp
173#define mame_strdup         core_strdup
174#define mame_strwildcmp      core_strwildcmp
175
176
177/* prevent the use of rand() -- use mame_rand() instead */
178#define rand
179
180
170181/* macros to convert radians to degrees and degrees to radians */
171182#define RADIAN_TO_DEGREE(x)   ((180.0 / M_PI) * (x))
172183#define DEGREE_TO_RADIAN(x)   ((M_PI / 180.0) * (x))
r1070r1071
274285       (BIT(val, B0) <<  0))
275286
276287
277#define mame_stricmp      core_stricmp
278#define mame_strnicmp      core_strnicmp
279#define mame_strdup      core_strdup
280#define mame_strwildcmp   core_strwildcmp
281288
282
283289/***************************************************************************
284290    FUNCTION PROTOTYPES
285291***************************************************************************/
r1070r1071
382388#endif
383389
384390
385/* prevent the use of rand() -- use mame_rand() instead */
386#define rand
387
388
389391#endif   /* __MAMECORE_H__ */
src/emu/sound/scspdsp.c
r1070r1071
77static UINT16 PACK(INT32 val)
88{
99   //cut to 16 bits
10   UINT32 f=((UINT32 ) val)>>8;
10   INT32 f=((UINT32 ) val)>>8;
1111   return f;
1212}
1313
r1070r1071
260260         //ADDR+=DSP->RBP<<13;
261261         //MEMVAL=DSP->SCSPRAM[ADDR>>1];
262262         ADDR+=DSP->RBP<<12;
263         if (ADDR > 0x7ffff) ADDR = 0;
263264         if(MRD && (step&1))   //memory only allowed on odd? DoA inserts NOPs on even
264265         {
265266            if(NOFL)
266267               MEMVAL=DSP->SCSPRAM[ADDR]<<8;
267268            else
268               MEMVAL=UNPACK(DSP->SCSPRAM[ADDR%DSP->SCSPRAM_LENGTH]);
269               MEMVAL=UNPACK(DSP->SCSPRAM[ADDR]);
269270         }
270271         if(MWT && (step&1))
271272         {
272273            if(NOFL)
273               DSP->SCSPRAM[ADDR]=SHIFTED>>8;
274                     DSP->SCSPRAM[ADDR]=SHIFTED>>8;
274275            else
275               DSP->SCSPRAM[ADDR%DSP->SCSPRAM_LENGTH]=PACK(SHIFTED);
276               DSP->SCSPRAM[ADDR]=PACK(SHIFTED);
276277         }
277278      }
278279
src/emu/sound/wave.c
r1070r1071
1212#include "utils.h"
1313#include "devices/cassette.h"
1414#include "streams.h"
15#include "wave.h"
1516
1617#define ALWAYS_PLAY_SOUND   0
1718#define WAVE_TOKEN_MASK      0xFFFF0000
r1070r1071
5455
5556static void *wave_start(int sndindex, int clock, const void *config)
5657{
57   stream_create(0, 1, Machine->sample_rate, (void *) sndindex, wave_sound_update);
58    return (void *) (sndindex | WAVE_TOKEN_MASK);
58   stream_create(0, 1, Machine->sample_rate, (void *) (FPTR)sndindex, wave_sound_update);
59   return (void *) (FPTR)(sndindex | WAVE_TOKEN_MASK);
5960}
6061
6162
src/emu/sound/speaker.c
r1070r1071
99
1010#include "sndintrf.h"
1111#include "streams.h"
12#include "speaker.h"
1213
1314static INT16 default_levels[2] = {0,32767};
1415
src/emu/sound/s14001a.h
r1070r1071
99int S14001A_bsy_0_r(void);           /* read BUSY pin */
1010void S14001A_reg_0_w(int data);      /* write to input latch */
1111void S14001A_rst_0_w(int data);      /* write to RESET pin */
12void S14001A_0_set_rate(int newrate);   /* set sample rate */
1312void S14001A_set_rate(int newrate);     /* set VSU-1000 clock divider */
1413void S14001A_set_volume(int volume);    /* set VSU-1000 volume control */
1514
src/emu/cheat.c
r1070r1071
1414#include "uimenu.h"
1515#include "uitext.h"
1616#include "machine/eeprom.h"
17#include "cheat.h"
1718#include <ctype.h>
1819#include <math.h>
1920
src/lib/util/options.c
r1070r1071
700700      sscanf(astring_c(data->data), "%d", &value);
701701      if (!data->error_reported)
702702      {
703         message(opts, OPTMSG_ERROR, "Illegal boolean value for %s; reverting to %d\n", data->links[0].name, value);
703         message(opts, OPTMSG_ERROR, "Illegal boolean value for %s; reverting to %d\n", astring_c(data->links[0].name), value);
704704         data->error_reported = TRUE;
705705      }
706706   }
r1070r1071
729729      sscanf(astring_c(data->data), "%d", &value);
730730      if (!data->error_reported)
731731      {
732         message(opts, OPTMSG_ERROR, "Illegal integer value for %s; reverting to %d\n", data->links[0].name, value);
732         message(opts, OPTMSG_ERROR, "Illegal integer value for %s; reverting to %d\n", astring_c(data->links[0].name), value);
733733         data->error_reported = TRUE;
734734      }
735735   }
r1070r1071
758758      sscanf(astring_c(data->data), "%f", &value);
759759      if (!data->error_reported)
760760      {
761         message(opts, OPTMSG_ERROR, "Illegal float value for %s; reverting to %f\n", data->links[0].name, (double)value);
761         message(opts, OPTMSG_ERROR, "Illegal float value for %s; reverting to %f\n", astring_c(data->links[0].name), (double)value);
762762         data->error_reported = TRUE;
763763      }
764764   }
r1070r1071
994994         i = 0;
995995         if (sscanf(datastart, "%d", &i) != 1)
996996         {
997            message(opts, OPTMSG_ERROR, "Illegal integer value for %s; keeping value of %s\n", data->links[0].name, astring_c(data->data));
997            message(opts, OPTMSG_ERROR, "Illegal integer value for %s; keeping value of %s\n", astring_c(data->links[0].name), astring_c(data->data));
998998            data->error_reported = TRUE;
999999            return;
10001000         }
10011001         if (i < data->range_minimum.i || i > data->range_maximum.i)
10021002         {
10031003            message(opts, OPTMSG_ERROR, "Invalid %s value (must be between %i and %i); keeping value of %s\n",
1004               data->links[0].name, data->range_minimum.i, data->range_maximum.i, astring_c(data->data));
1004               astring_c(data->links[0].name), data->range_minimum.i, data->range_maximum.i, astring_c(data->data));
10051005            data->error_reported = TRUE;
10061006            return;
10071007         }
r1070r1071
10121012         f = 0;
10131013         if (sscanf(datastart, "%f", &f) != 1)
10141014         {
1015            message(opts, OPTMSG_ERROR, "Illegal float value for %s; keeping value of %s\n", data->links[0].name, astring_c(data->data));
1015            message(opts, OPTMSG_ERROR, "Illegal float value for %s; keeping value of %s\n", astring_c(data->links[0].name), astring_c(data->data));
10161016            data->error_reported = TRUE;
10171017            return;
10181018         }
10191019         if (f < data->range_minimum.f || f > data->range_maximum.f)
10201020         {
10211021            message(opts, OPTMSG_ERROR, "Invalid %s value (must be between %f and %f); keeping value of %s\n",
1022               data->links[0].name, data->range_minimum.f, data->range_maximum.f, astring_c(data->data));
1022               astring_c(data->links[0].name), data->range_minimum.f, data->range_maximum.f, astring_c(data->data));
10231023            data->error_reported = TRUE;
10241024            return;
10251025         }
src/mess/tools/messtest/tststubs.c
r1070r1071
121121{
122122}
123123
124osd_lock *osd_lock_alloc(void)
125{
126   return (osd_lock *) ~0;
127}
128
129void osd_lock_acquire(osd_lock *lock)
130{
131}
132
133int osd_lock_try(osd_lock *lock)
134{
135   return TRUE;
136}
137
138void osd_lock_release(osd_lock *lock)
139{
140}
141
142void osd_lock_free(osd_lock *lock)
143{
144}
145
146124#ifdef MAME_DEBUG
147125void osd_wait_for_debugger(void)
148126{
src/mess/machine/mpc105.c
r1070r1071
66
77***************************************************************************/
88
9#include "driver.h"
910#include "mpc105.h"
1011#include "machine/pci.h"
1112
src/mess/machine/i82439tx.c
r1070r1071
66
77***************************************************************************/
88
9#include "driver.h"
910#include "machine/i82439tx.h"
1011#include "machine/pci.h"
1112
docs/messnew.txt
r1070r1071
3535
3636Source Changes:
3737----------------
38- The core is based on MAME 0.119u2.  This incorporates all features of the
38- The core is based on MAME 0.119u3.  This incorporates all features of the
3939  update to this core.  [MAME team]
4040
4141- Fixed multisession crash with the new menu selector.  (bug #1328) [Nate

Previous 15994 Revisions Next


© 1998-2018 The MESS Team