summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/drivers/hshavoc.c
blob: c791c6710de2cbfb85f4c9faae13f4d94f6a5251 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
/*

  High Seas Havoc
   (c)1993 Data East

   This is an unusual Data East PCB based on the Sega Genesis / Megadrive.  The Game was also released on the home system.


Produttore  Data East
N.revisione CG-2

CPU
1x MC68000P8 (main)(12c)
1x Z8400B (sound)(1a)
1x custom SEGA315-5660-FC1004 (QFP208)(5d)
1x PIC16C57 (7a)
1x oscillator 53.6931MHz (osc1)

ROMs
2x TMS27C040 (25,26)(11a,9a)
2x PEEL18CV8 (4b,5b)

Note
1x JAMMA edge connector
1x trimmer (volume)(vr1)
2x 6 switches dip (dsw1,dsw2)
-----------------------------------
PCB markings:"DE-0407-2 MADE IN JAPAN"
-----------------------------------

Thanks to DOX, the "mistery chip" has been identified (and verified) as a PIC.
Unfortunately it's read protected.

*/


#include "driver.h"
#include "cpu/z80/z80.h"
#include "cpu/m68000/m68000.h"
#include "sound/2612intf.h"
#include "sound/sn76496.h"

#include "megadriv.h"

static INPUT_PORTS_START( hshavoc )
	PORT_START("IN0")	/* 16bit */
	PORT_DIPNAME( 0x0001, 0x0000, DEF_STR( Unknown ) )
	PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0x0002, 0x0000, DEF_STR( Unknown ) )
	PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0x0004, 0x0000, DEF_STR( Unknown ) )
	PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0x0008, 0x0000, DEF_STR( Unknown ) )
	PORT_DIPSETTING(      0x0008, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0x0010, 0x0000, DEF_STR( Unknown ) )
	PORT_DIPSETTING(      0x0010, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0x0020, 0x0000, DEF_STR( Unknown ) )
	PORT_DIPSETTING(      0x0020, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0x0040, 0x0000, DEF_STR( Unknown ) )
	PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0x0080, 0x0000, DEF_STR( Unknown ) )
	PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0x0100, 0x0000, DEF_STR( Unknown ) )
	PORT_DIPSETTING(      0x0100, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0x0200, 0x0000, DEF_STR( Unknown ) )
	PORT_DIPSETTING(      0x0200, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0x0400, 0x0000, DEF_STR( Unknown ) )
	PORT_DIPSETTING(      0x0400, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0x0800, 0x0000, DEF_STR( Unknown ) )
	PORT_DIPSETTING(      0x0800, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0x1000, 0x0000, DEF_STR( Unknown ) )
	PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0x2000, 0x0000, DEF_STR( Unknown ) )
	PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0x4000, 0x0000, DEF_STR( Unknown ) )
	PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
	PORT_DIPNAME( 0x8000, 0x0000, DEF_STR( Unknown ) )
	PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
	PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
INPUT_PORTS_END


ROM_START( hshavoc )
	ROM_REGION( 0x200000, "maincpu", 0 )
	ROM_LOAD16_BYTE( "d-25.11a", 0x000000, 0x080000, CRC(6a155060) SHA1(ecb47bd428786e50e300a062b5038f943419a389) )
	ROM_LOAD16_BYTE( "d-26.9a",  0x000001, 0x080000, CRC(1afa84fe) SHA1(041296e0360b7747aedc2d948c39e06ba03a7d08) )

	ROM_REGION( 0x200000, "user1", 0 ) // other
	ROM_LOAD( "peel18cv8s.4b.bin",  0x000, 0x155, CRC(b5fb1d5f) SHA1(f0ac80471d97f77f415b5a1f153e1fce66720963) )
	ROM_LOAD( "peel18cv8s.5b.bin",  0x000, 0x155, CRC(efc7ceea) SHA1(1c31a56bc4b83bfa708048b7de4cee7a24537500) )

	ROM_REGION( 0x200000, "user2", 0 ) // other
	ROM_LOAD( "pic16c57",  0x00, 0x01, NO_DUMP ) // protected
ROM_END

#ifdef UNUSED_DEFINITION
ROM_START( hshavoc2 ) /* Genesis Version, for reference */
	ROM_REGION( 0x200000, "maincpu", 0 )
	ROM_LOAD( "hsh.rom", 0x000000, 0x100000, CRC(17be551c) SHA1(0dc1969098716ba332978b89356f62961417682b) )
ROM_END

#endif

static DRIVER_INIT(hshavoc)
{

	int x;
	UINT16 *src = (UINT16 *)memory_region(machine, "maincpu");

	static const UINT16 typedat[16] = {
		1,1,1,1, 1,1,1,1,
		1,0,0,1, 1,0,1,1  };

	/* this decryption is wrong / incomplete, maybe it uses slightly different decryption for opcodes / data */
	/* I think the PIC that exists on the PCB controls a state-based encryption... there is a large amount
       of code encrypted using the same encryption as the data, but all the startup-code + vectors use additional
       encryption.. maybe the PIC can also patch the code, I'm also concerned that we may decrypt it and find
       that it runs as the genesis (no insert coin etc.) version without the PIC, or the PIC supplies additonal
       code in RAM.. but as of yet we can't know */

	int rom_size = 0xe8000;

	for (x = 0; x < rom_size / 2; x++)
	{
		src[x] = BITSWAP16(src[x],
                                7, 15,6, 14,
                                5, 2, 1, 10,
                                13,4, 12,3,
                                11,0, 8, 9 );


		if (typedat[x & 0xf] == 1) 
			src[x] = src[x] ^ 0x0501;
		else 
			src[x] = src[x] ^ 0x0406;


		if (src[x] & 0x0400) 
			src[x] ^= 0x0200;

		if (typedat[x & 0xf] == 0)
		{
			if (src[x] & 0x0100) 
				src[x] ^= 0x0004;

			src[x] = BITSWAP16(src[x], 15,14,13,12,
                                             11,9, 10,8,
                                             7, 6, 5, 4,
                                             3, 2, 1, 0 );
		}
	}

	/* START e? from e80000 to end you need THIS ALONE to match the genesis rom */
	for (x = rom_size / 2; x < 0x100000 / 2; x++)
	{
		src[x] = BITSWAP16(src[x],
                                7, 15,6, 14,
                                5, 2, 1, 10,
                                13,4, 12,3,
                                11,0, 8, 9 );

		src[x] = BITSWAP16(src[x],
                                15,14,13,12,
                                11,10,9, 2,
                                7, 6, 5, 4,
                                3, 8, 0, 1 );
	}
	/* EMD e80000 - end */

	src[0] ^= 0x0107;
	src[1] ^= 0x0107;
	src[2] ^= 0x0107;
	src[3] ^= 0x0707; //? 0701 not 0107 .. conditional 0x600 extra xor?, different 'typemap' ??

	/* I'm pretty sure c42 is where the startup code is located, comparing genesis version
       and this there is at least one jump in the genesis version to the startup code which
       has been changed to this address in the arcade version.

       there are several blocks of code like this, all appear to end with a normal rts instruction
       tho...
       */
	for (x = 0xc42 / 2; x < 0xc9a / 2; x++)
	{
		src[x] ^= 0x0107; //? seems conditional..

		src[x] = BITSWAP16(src[x],
                                15,13,14,12,
                                11,10,9, 0,
                                8, 6, 5, 4,
                                3, 2, 1, 7 ); // probably wrong

		src[x] ^= 0x0001; // wrong..
	}

/* Uncommented until actively worked on
    {
        FILE*FP;

        FP = fopen("hshavoc.dump", "wb");

        fwrite(src, rom_size / 2, 2, FP);
        fclose(FP);
    }
*/

	memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x200000, 0x201fff, 0, 0, SMH_NOP);

	DRIVER_INIT_CALL(megadriv);

}



GAME( 1993, hshavoc,   0,        md_bootleg, hshavoc, hshavoc, ROT0, "Data East",                  "High Seas Havoc",GAME_NOT_WORKING )
//GAME( 1993, hshavoc2,  hshavoc,  md_bootleg, hshavoc, genesis, ROT0, "Data East",                  "High Seas Havoc (Genesis ROM)",GAME_NOT_WORKING )