summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/drivers/magicard.c
blob: 07f4b43839af5c27783cc72a1fe3780410196747 (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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
/******************************************************************************


    MAGIC CARD - IMPERA
    -------------------

    Preliminary driver by Roberto Fresca, David Haywood & Angelo Salese


    Games running on this hardware:

    * Magic Card (set 1),  Impera, 199?
    * Magic Card (set 2),  Impera, 199?

*******************************************************************************


    *** Hardware Notes ***

    (All ICs on this board are surface scratched, so we're guessing...)

    Identified:

    - CPU:  1x Philips SCC 68070 CCA84 (16 bits Microprocessor, PLCC) @ 15 MHz
    - VSC:  1x Philips SCC 66470 CAB (Video and System Controller, QFP)

    - Protection: 1x Dallas TimeKey DS1207-1 (for book-keeping protection)

    - Crystals:   1x 30.0000 MHz.
                  1x 19.6608 MHz.

    - PLDs:       1x PAL16L8ACN
                  1x PALCE18V8H-25


*******************************************************************************


    *** General Notes ***

    Impera released "Magic Card" in a custom 16-bits PCB.
    The hardware was so expensive and they never have reached the expected sales,
    so... they ported the game to Impera/Funworld 8bits boards, losing part of
    graphics and sound/music quality. The new product was named "Magic Card II".

*******************************************************************************

TODO:

-Understand these two things:
 -bpset 1a2a82
  do pc=1a2a92 ;tests the 260000-27ffff region
  After the boot screen (the angel with torch),will come a screen with a circle
  and a counter in the middle like a warning screen.I think is checksuming
  something -RF

 -bpset 75600
  do pc=75648 ;there are various tests/tight hangs while testing the 2005 area
  Chances are that the inputs are located in a RAM-based fashion,similar of the
  way used by spool99 (probably the latter copied from this one). -AS

-Fix properly the starting vectors;

-Colors;

-Inputs;

-Sound;

-Visible Area;

-Clone romset magicrda not checked at all;

*******************************************************************************/


#define CLOCK_A	XTAL_30MHz
#define CLOCK_B	XTAL_19_6608MHz

#include "driver.h"
#include "cpu/m68000/m68000.h"

static UINT16 *magicram;
static UINT16 *blit_ram;

/*************************
*     Video Hardware     *
*************************/

static VIDEO_START(magicard)
{

}

static VIDEO_UPDATE(magicard)
{
	int x,y,count;

	count = (0/2);

	for(y=0;y<300;y++)
	{
		for(x=0;x<168;x++)
		{
			UINT32 color;

			color = ((blit_ram[count]) & 0x00ff)>>0;

			if((x*2)<video_screen_get_visible_area(screen)->max_x && ((y)+0)<video_screen_get_visible_area(screen)->max_y)
				*BITMAP_ADDR32(bitmap, y, (x*2)+1) = screen->machine->pens[color];

			color = ((blit_ram[count]) & 0xff00)>>8;

			if(((x*2)+1)<video_screen_get_visible_area(screen)->max_x && ((y)+0)<video_screen_get_visible_area(screen)->max_y)
				*BITMAP_ADDR32(bitmap, y, (x*2)+0) = screen->machine->pens[color];

			count++;
		}
	}
	return 0;
}


/*************************
* Memory map information *
*************************/

static READ16_HANDLER( test_r )
{
	return mame_rand(space->machine);
}

static ADDRESS_MAP_START( magicard_mem, ADDRESS_SPACE_PROGRAM, 16 )
	AM_RANGE(0x000000, 0x01ffff) AM_RAM AM_BASE(&magicram)
	AM_RANGE(0x020000, 0x020001) AM_READ(test_r)
	AM_RANGE(0x020002, 0x020003) AM_READ(test_r)
	AM_RANGE(0x040000, 0x05ffff) AM_RAM
	AM_RANGE(0x060000, 0x07ffff) AM_RAM AM_BASE(&blit_ram)
//  AM_RANGE(0x100000, 0x17ffff) AM_RAM AM_REGION("main", 0)
	AM_RANGE(0x180000, 0x1ffbff) AM_ROM AM_REGION("main", 0)
	AM_RANGE(0x1ffc00, 0x1fffff) AM_RAM
	AM_RANGE(0x260000, 0x27ffff) AM_RAM /*???*/
ADDRESS_MAP_END


/*************************
*      Input ports       *
*************************/

static INPUT_PORTS_START( magicard )
INPUT_PORTS_END


MACHINE_RESET( magicard )
{
	UINT16 *src    = (UINT16*)memory_region( machine, "main" );
	UINT16 *dst    = magicram;
	memcpy (dst, src, 0x20000);
}

static PALETTE_INIT( magicard )
{
/*  int bit0, bit1, bit2 , r, g, b;
    int i;

    for (i = 0; i < 0x100; ++i)
    {
        bit0 = (color_prom[0] >> 0) & 0x01;
        bit1 = (color_prom[0] >> 1) & 0x01;
        bit2 = (color_prom[0] >> 2) & 0x01;
        r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
        bit0 = (color_prom[0] >> 3) & 0x01;
        bit1 = (color_prom[0] >> 4) & 0x01;
        bit2 = (color_prom[0] >> 5) & 0x01;
        g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
        bit0 = 0;
        bit1 = (color_prom[0] >> 6) & 0x01;
        bit2 = (color_prom[0] >> 7) & 0x01;
        b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;

        palette_set_color(machine, i, MAKE_RGB(r, g, b));
        color_prom++;
    }*/
}

/*************************
*    Graphics Layouts    *
*************************/

static const gfx_layout mca_charlayout =
{
/* text layer is only 1bpp??
   there are 2 charsets, but very different
*/
	8, 10,
	190,
	1,		/* 1bpp? */
	{ 0 },
	{ 0, 1, 2, 3, 4, 5, 6, 7 },
	{ 1*8, 0*8, 3*8, 2*8, 5*8, 4*8, 7*8, 6*8, 9*8, 8*8 },
	8*10

};

static const gfx_layout mca_tilelayout =
{
/* this is only to see the GFX and find
   a proper way to decode
*/
	8, 8,
	0x8000,
	1,		/* just for testing */
	{ 0 },
	{ 0, 1, 2, 3, 4, 5, 6, 7 },
	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
	8*8
};


/******************************
* Graphics Decode Information *
******************************/

static GFXDECODE_START( magicard )
	GFXDECODE_ENTRY( "main", 0x21562, mca_charlayout,  0, 32 )
	GFXDECODE_ENTRY( "main", 0x16470, mca_tilelayout,  0, 32 )
//  GFXDECODE_ENTRY( "main", 0x22efa, mca_tilelayout,  0, 32 )
GFXDECODE_END

static GFXDECODE_START( magicrda )
	GFXDECODE_ENTRY( "main", 0x21562 + 0x792, mca_charlayout,  0, 32 )
	GFXDECODE_ENTRY( "main", 0x16470, mca_tilelayout,  0, 32 )
//  GFXDECODE_ENTRY( "main", 0x22efa, mca_tilelayout,  0, 32 )
GFXDECODE_END


/*************************
*    Machine Drivers     *
*************************/

#if 0
/*Probably there's a mask somewhere if it REALLY uses irqs at all...irq vectors dynamically changes after some time.*/
static INTERRUPT_GEN( magicard_irq )
{
	if(input_code_pressed(KEYCODE_Z))
		cpu_set_input_line(device->machine->cpu[0], 1, HOLD_LINE);
}
#endif

static MACHINE_DRIVER_START( magicard )
	MDRV_CPU_ADD("main", M68000, CLOCK_A/2)	/* SCC-68070 CCA84 datasheet */
	MDRV_CPU_PROGRAM_MAP(magicard_mem,0)
//  MDRV_CPU_VBLANK_INT("main", magicard_irq) /* no interrupts? (it erases the vectors..) */

	MDRV_SCREEN_ADD("main", RASTER)
	MDRV_SCREEN_REFRESH_RATE(60)
	MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
	MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
	MDRV_SCREEN_SIZE(400, 300)
	MDRV_SCREEN_VISIBLE_AREA(0, 400-1, 0, 300-1)
	MDRV_PALETTE_INIT(magicard)

	MDRV_PALETTE_LENGTH(0x20000/2)
	MDRV_GFXDECODE(magicard)

	MDRV_VIDEO_START(magicard)
	MDRV_VIDEO_UPDATE(magicard)

	MDRV_MACHINE_RESET(magicard)

MACHINE_DRIVER_END

static MACHINE_DRIVER_START( magicrda )
	MDRV_IMPORT_FROM(magicard)
	MDRV_CPU_MODIFY("main")

	MDRV_GFXDECODE(magicrda)

MACHINE_DRIVER_END


/*************************
*        Rom Load        *
*************************/

ROM_START( magicard )
	ROM_REGION( 0x80000, "main", 0 ) /* 68000 Code & GFX */
	ROM_LOAD16_WORD_SWAP( "magicorg.bin", 0x000000, 0x80000, CRC(810edf9f) SHA1(0f1638a789a4be7413aa019b4e198353ba9c12d9) )

//  ROM_REGION( 0x400, "boot_prg", 0 )
//  ROM_COPY( "main", 0x00000, 0x00000, 0x400)

	ROM_REGION( 0x0100, "proms", 0 ) /* Color PROM?? */
	ROM_LOAD16_WORD_SWAP("mgorigee.bin",	0x0000,	0x0100, CRC(73522889) SHA1(3e10d6c1585c3a63cff717a0b950528d5373c781) )
ROM_END

ROM_START( magicrda )
	ROM_REGION( 0x80000, "main", 0 ) /* 68000 Code & GFX */
	ROM_LOAD16_WORD_SWAP( "mcorigg2.bin", 0x00000, 0x20000, CRC(48546aa9) SHA1(23099a5e4c9f2c3386496f6d7f5bb7d435a6fb16) )
	ROM_LOAD16_WORD_SWAP( "mcorigg1.bin", 0x20000, 0x20000, CRC(c9e4a38d) SHA1(812e5826b27c7ad98142a0f52fbdb6b61a2e31d7) )

//  ROM_REGION( 0x400, "boot_prg", 0 )
//  ROM_COPY( "main", 0x00000, 0x00000, 0x400)

	ROM_REGION( 0x0100, "proms", 0 ) /* Color PROM?? */
	ROM_LOAD("mgorigee.bin",	0x0000,	0x0100, CRC(73522889) SHA1(3e10d6c1585c3a63cff717a0b950528d5373c781) )
ROM_END


/*************************
*      Game Drivers      *
*************************/

static DRIVER_INIT( magicard )
{
	UINT16 *src    = (UINT16*)memory_region( machine, "main" );
	UINT16 *dst    = magicram;
	memcpy (dst, src, 0x20000);
}

/*    YEAR  NAME      PARENT MACHINE   INPUT  INIT  ROT    COMPANY   FULLNAME             FLAGS... */

GAME( 199?, magicard, 0,     magicard, 0,     magicard,    ROT0, "Impera", "Magic Card (set 1)", GAME_NO_SOUND | GAME_NOT_WORKING )
GAME( 199?, magicrda, 0,     magicrda, 0,     magicard,    ROT0, "Impera", "Magic Card (set 2)", GAME_NO_SOUND | GAME_NOT_WORKING )