Previous 15994 Revisions Next

r10887 Monday 21st March, 2011 at 07:17:02 UTC by Curt Coder
Synced with MAME.
[src/emu]memory.c memory.h
[src/emu/cpu/hd6309]6309ops.c
[src/emu/cpu/konami]konamops.c
[src/emu/cpu/m6800]6800ops.c
[src/emu/cpu/m6805]6805ops.c
[src/emu/cpu/m6809]6809ops.c m6809.c
[src/emu/cpu/pps4]pps4.c
[src/emu/machine]s3c2400.c s3c2410.c s3c2440.c
[src/emu/video]resnet.h
[src/mame]mamedriv.c
[src/mame/audio]toaplan2.c
[src/mame/drivers]5clown.c 8080bw.c acefruit.c adp.c asteroid.c astrocde.c atvtrack.c avt.c bingor.c blackt96.c blitz.c blitz68k.c buster.c bwing.c calchase.c carrera.c cb2001.c chsuper.c coinmstr.c coinmvga.c combatsc.c contra.c cubeqst.c cybertnk.c dgpix.c dmndrby.c drw80pkr.c esh.c ettrivia.c flower.c fortecar.c gal3.c galaga.c galaxian.c gamecstl.c gei.c goldngam.c goldnpkr.c gunpey.c hitpoker.c hotstuff.c hvyunit.c intrscti.c istellar.c itgambl2.c itgambl3.c jackpool.c jokrwild.c jubilee.c kingpin.c ksys573.c kungfur.c limenko.c ltcasino.c luckgrln.c m92.c magic10.c magicard.c magicfly.c mcr3.c megasys1.c midas.c mil4000.c miniboy7.c mirax.c murogem.c murogmbl.c namcona1.c namcos86.c naomi.c neoprint.c nmk16.c nsmpoker.c pachifev.c pcat_nit.c pcxt.c peplus.c photon2.c photoply.c pinkiri8.c pipeline.c pkscram.c play_1.c pntnpuzl.c poker72.c poo.c rbmk.c re900.c rgum.c rocnrope.c roul.c sfbonus.c shangkid.c skimaxx.c skylncr.c slotcarn.c sms.c sothello.c ssfindo.c st_mp200.c statriv2.c taito_f3.c tattack.c tgtpanic.c thayers.c thedeep.c tickee.c trvmadns.c ttchamp.c tugboat.c vamphalf.c vcombat.c vicdual.c videopkr.c vpoker.c vroulet.c wldarrow.c zaxxon.c
[src/mame/includes]astrocde.h flower.h galaxian.h mcr3.h megasys1.h namcona1.h namcos86.h nmk16.h shangkid.h taito_f3.h thedeep.h
[src/mame/layout]depthch.lay
[src/mame/machine]ms32crpt.c ms32crpt.h
[src/mame/video]astrocde.c bwing.c flower.c galaxian.c konamiic.c konicdev.c mcr3.c megasys1.c namcona1.c namcos86.c shangkid.c taito_f3.c thedeep.c
[src/mess/drivers]vixen.c

src/mame/audio/toaplan2.c
r10886r10887
1#include "emu.h"
2#include "sound/okim6295.h"
3#include "includes/toaplan2.h"
4
5/****************************************************************************
6  The Toaplan 2 hardware with V25 secondary CPU controls the sound through
7  to a YM2151 and OKI M6295 on some boards. Here we just interpret some of
8  commands sent to the V25, directly onto the OKI M6295
9
10  These tables convert commands sent from the main CPU, into sample numbers
11  played back by the sound processor.
12  The ADPCM ROMs contain intrument samples which are sequenced by the
13  sound processor to create some of the backing tracks. This is beyond the
14  scope of this playback file. Time would be better spent elsewhere.
15****************************************************************************/
16
17static const UINT8 fixeight_cmd_snd[128] =
18{
19/* Some sound commands are mixed with tones produced by the FM chip */
20/* Probably 96(60H), 82(52H), 80(50H) and 70(46H) and maybe others */
21/*00*/  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22/*08*/  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23/*10*/  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24/*18*/  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25/*20*/  0x18, 0x3e, 0x37, 0x48, 0x38, 0x49, 0x4a, 0x4b,
26/*28*/  0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x53, 0x54, 0x51,
27/*30*/  0x52, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00,
28/*38*/  0x07, 0x08, 0x00, 0x1b, 0x00, 0x43, 0x00, 0x00,
29/*40*/  0x00, 0x47, 0x00, 0x3a, 0x44, 0x0a, 0x0a, 0x06,
30/*48*/  0x3c, 0x46, 0x3f, 0x45, 0x00, 0x02, 0x04, 0x10,
31/*50*/  0x0f, 0x11, 0x09, 0x0d, 0x0c, 0x0b, 0x00, 0x00,
32/*58*/  0x00, 0x15, 0x3d, 0x3f, 0x1e, 0x1c, 0x19, 0x13,
33/*60*/  0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34/*68*/  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35/*70*/  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36/*78*/  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
37};
38
39static void play_oki_sound(okim6295_device *oki, int game_sound, int data)
40{
41   int status = oki->read_status();
42
43   logerror("Playing sample %02x from command %02x\n",game_sound,data);
44
45   if (game_sound != 0)
46   {
47      if ((status & 0x01) == 0) {
48         oki->write_command(0x80 | game_sound);
49         oki->write_command(0x11);
50      }
51      else if ((status & 0x02) == 0) {
52         oki->write_command(0x80 | game_sound);
53         oki->write_command(0x21);
54      }
55      else if ((status & 0x04) == 0) {
56         oki->write_command(0x80 | game_sound);
57         oki->write_command(0x41);
58      }
59      else if ((status & 0x08) == 0) {
60         oki->write_command(0x80 | game_sound);
61         oki->write_command(0x81);
62      }
63   }
64}
65
66void fixeight_okisnd_w(device_t *device, int data)
67{
68//  popmessage("Writing %04x to Sound CPU",data);
69
70   okim6295_device *oki = downcast<okim6295_device *>(device);
71   if (data == 0)
72   {
73      oki->write_command(0x78);      /* Stop playing effects */
74   }
75   else if ((data > 0) && (data < 128))
76   {
77      play_oki_sound(oki, fixeight_cmd_snd[data], data);
78   }
79}
src/mame/machine/ms32crpt.c
r10886r10887
1#include "emu.h"
2#include "machine/ms32crpt.h"
3
4
5/********** DECRYPT **********/
6
7/* 4 known types */
8
9/* SS91022-10: desertwr, gratiaa, tp2m32, gametngk */
10
11/* SS92046_01: bbbxing, f1superb, tetrisp, hayaosi2 */
12
13/* SS92047-01: gratia, kirarast */
14
15/* SS92048-01: p47aces, 47pie2, 47pie2o */
16
17void ms32_rearrange_sprites(running_machine *machine, const char *region)
18{
19   /* sprites are not encrypted, but we need to move the data around to handle them as 256x256 tiles */
20   int i;
21   UINT8 *source_data;
22   int source_size;
23
24   UINT8 *result_data;
25
26   source_data = machine->region       ( region )->base();
27   source_size = machine->region( region )->bytes();
28
29   result_data = auto_alloc_array(machine, UINT8, source_size);
30
31   for(i=0; i<source_size; i++)
32   {
33      int j = (i & ~0x07f8) | ((i & 0x00f8) << 3) | ((i & 0x0700) >> 5);
34
35      result_data[i] = source_data[j];
36   }
37
38   memcpy (source_data, result_data, source_size);
39   auto_free (machine, result_data);
40}
41
42
43void decrypt_ms32_tx(running_machine *machine, int addr_xor,int data_xor, const char *region)
44{
45   int i;
46   UINT8 *source_data;
47   int source_size;
48
49   UINT8 *result_data;
50
51   source_data = machine->region       ( region )->base();
52   source_size = machine->region( region )->bytes();
53
54   result_data = auto_alloc_array(machine, UINT8, source_size);
55
56   addr_xor ^= 0x1005d;
57
58   for(i=0; i<source_size; i++)
59   {
60      int j;
61
62      /* two groups of cascading XORs for the address */
63      j = 0;
64      i ^= addr_xor;
65
66      if (BIT(i,18)) j ^= 0x40000;   // 18
67      if (BIT(i,17)) j ^= 0x60000;   // 17
68      if (BIT(i, 7)) j ^= 0x70000;   // 16
69      if (BIT(i, 3)) j ^= 0x78000;   // 15
70      if (BIT(i,14)) j ^= 0x7c000;   // 14
71      if (BIT(i,13)) j ^= 0x7e000;   // 13
72      if (BIT(i, 0)) j ^= 0x7f000;   // 12
73      if (BIT(i,11)) j ^= 0x7f800;   // 11
74      if (BIT(i,10)) j ^= 0x7fc00;   // 10
75
76      if (BIT(i, 9)) j ^= 0x00200;   //  9
77      if (BIT(i, 8)) j ^= 0x00300;   //  8
78      if (BIT(i,16)) j ^= 0x00380;   //  7
79      if (BIT(i, 6)) j ^= 0x003c0;   //  6
80      if (BIT(i,12)) j ^= 0x003e0;   //  5
81      if (BIT(i, 4)) j ^= 0x003f0;   //  4
82      if (BIT(i,15)) j ^= 0x003f8;   //  3
83      if (BIT(i, 2)) j ^= 0x003fc;   //  2
84      if (BIT(i, 1)) j ^= 0x003fe;   //  1
85      if (BIT(i, 5)) j ^= 0x003ff;   //  0
86
87      i ^= addr_xor;
88
89      /* simple XOR for the data */
90      result_data[i] = source_data[j] ^ (i & 0xff) ^ data_xor;
91   }
92
93   memcpy (source_data, result_data, source_size);
94   auto_free (machine, result_data);
95}
96
97void decrypt_ms32_bg(running_machine *machine, int addr_xor,int data_xor, const char *region)
98{
99   int i;
100   UINT8 *source_data;
101   int source_size;
102
103   UINT8 *result_data;
104
105   source_data = machine->region       ( region )->base();
106   source_size = machine->region( region )->bytes();
107
108   result_data = auto_alloc_array(machine, UINT8, source_size);
109
110   addr_xor ^= 0xc1c5b;
111
112   for(i=0; i<source_size; i++)
113   {
114      int j;
115
116      /* two groups of cascading XORs for the address */
117      j = (i & ~0xfffff);   /* top bits are not affected */
118      i ^= addr_xor;
119
120      if (BIT(i,19)) j ^= 0x80000;   // 19
121      if (BIT(i, 8)) j ^= 0xc0000;   // 18
122      if (BIT(i,17)) j ^= 0xe0000;   // 17
123      if (BIT(i, 2)) j ^= 0xf0000;   // 16
124      if (BIT(i,15)) j ^= 0xf8000;   // 15
125      if (BIT(i,14)) j ^= 0xfc000;   // 14
126      if (BIT(i,13)) j ^= 0xfe000;   // 13
127      if (BIT(i,12)) j ^= 0xff000;   // 12
128      if (BIT(i, 1)) j ^= 0xff800;   // 11
129      if (BIT(i,10)) j ^= 0xffc00;   // 10
130
131      if (BIT(i, 9)) j ^= 0x00200;   //  9
132      if (BIT(i, 3)) j ^= 0x00300;   //  8
133      if (BIT(i, 7)) j ^= 0x00380;   //  7
134      if (BIT(i, 6)) j ^= 0x003c0;   //  6
135      if (BIT(i, 5)) j ^= 0x003e0;   //  5
136      if (BIT(i, 4)) j ^= 0x003f0;   //  4
137      if (BIT(i,18)) j ^= 0x003f8;   //  3
138      if (BIT(i,16)) j ^= 0x003fc;   //  2
139      if (BIT(i,11)) j ^= 0x003fe;   //  1
140      if (BIT(i, 0)) j ^= 0x003ff;   //  0
141
142      i ^= addr_xor;
143
144      /* simple XOR for the data */
145      result_data[i] = source_data[j] ^ (i & 0xff) ^ data_xor;
146   }
147
148   memcpy (source_data, result_data, source_size);
149   auto_free (machine, result_data);
150}
src/mame/machine/ms32crpt.h
r10886r10887
1void ms32_rearrange_sprites(running_machine *machine, const char *region);
2void decrypt_ms32_tx(running_machine *machine, int addr_xor,int data_xor, const char *region);
3void decrypt_ms32_bg(running_machine *machine, int addr_xor,int data_xor, const char *region);
src/mame/mamedriv.c
r10886r10887
55235523   DRIVER( mastkin )   /* (c) 1988 Du Tech */
55245524   DRIVER( rocnrope )   /* GX364 (c) 1983 */
55255525   DRIVER( rocnropek )   /* GX364 (c) 1983 + Kosuka */
5526   DRIVER( ropeman )   /* (c) 1983 bootleg */
55265527   DRIVER( circusc )   /* GX380 (c) 1984 */
55275528   DRIVER( circusc2 )   /* GX380 (c) 1984 */
55285529   DRIVER( circusc3 )   /* GX380 (c) 1984 */
r10886r10887
78807881
78817882   /* SH-4 hardware */
78827883   DRIVER( atvtrack )   /* (c) 2002 - Ref 020419 */
7884   DRIVER( atvtracka )   /* (c) 2002 - Ref 020419 */
78837885
78847886   /*
78857887    Remaining Gaelco Games:
r10886r10887
78957897   /* Kaneko games */
78967898   DRIVER( hvyunit )   /* (c) 1988 Kaneko */
78977899   DRIVER( hvyunitj )   /* (c) 1988 Kaneko */
7898   DRIVER( hvyunito )   /* (c) 1988 Kaneko */
7900   DRIVER( hvyunitjo )   /* (c) 1988 Kaneko */
7901   DRIVER( hvyunitu )   /* (c) 1988 Kaneko */
78997902   DRIVER( djboy )      /* (c) 1989 Kaneko */
79007903   DRIVER( djboyj )   /* (c) 1989 Kaneko */
79017904   DRIVER( djboya )   /* (c) 1989 Kaneko */
src/mame/includes/nmk16.h
r10886r10887
3737   UINT16 vscroll[4];
3838   UINT8 *spriteram;
3939   size_t spriteram_size;
40   int prot_count;
41   UINT8 input_pressed;
42   UINT8 start_helper;
43   UINT8 coin_count[2];
44   UINT8 coin_count_frac[2];
4045};
4146
4247
src/mame/includes/shangkid.h
r10886r10887
66
77   UINT8 *videoram;
88   UINT8 *spriteram;
9   UINT8 bbx_sound_enable;
10   UINT8 sound_latch;
11   UINT8 *videoreg;
12   int gfx_type;
13   tilemap_t *background;
914};
1015
1116
1217/*----------- defined in video/shangkid.c -----------*/
1318
14extern UINT8 *shangkid_videoreg;
15extern int shangkid_gfx_type;
16
1719VIDEO_START( shangkid );
1820SCREEN_UPDATE( shangkid );
1921WRITE8_HANDLER( shangkid_videoram_w );
src/mame/includes/namcona1.h
r10886r10887
1class namcona1_state : public driver_device
2{
3public:
4   namcona1_state(running_machine &machine, const driver_device_config_base &config)
5      : driver_device(machine, config) { }
6
7   UINT16 *videoram;
8   UINT16 *spriteram;
9};
10
11
12/*----------- defined in video/namcona1.c -----------*/
13
141enum
152{
163   NAMCO_CGANGPZL,
r10886r10887
2714};
2815
2916#define NA1_NVRAM_SIZE (0x800)
17#define NAMCONA1_NUM_TILEMAPS 4
3018
31extern UINT16 *namcona1_workram;
32extern UINT16 *namcona1_vreg;
33extern UINT16 *namcona1_scroll;
19class namcona1_state : public driver_device
20{
21public:
22   namcona1_state(running_machine &machine, const driver_device_config_base &config)
23      : driver_device(machine, config) { }
3424
25   UINT16 *videoram;
26   UINT16 *spriteram;
27   UINT16 *mpBank0;
28   UINT16 *mpBank1;
29   int mEnableInterrupts;
30   int gametype;
31   UINT8 nvmem[NA1_NVRAM_SIZE];
32   UINT16 count;
33   UINT32 keyval;
34   UINT16 mcu_mailbox[8];
35   UINT8 mcu_port4;
36   UINT8 mcu_port5;
37   UINT8 mcu_port6;
38   UINT8 mcu_port8;
39   UINT16 *workram;
40   UINT16 *vreg;
41   UINT16 *scroll;
42   UINT16 *shaperam;
43   UINT16 *cgram;
44   tilemap_t *roz_tilemap;
45   int roz_palette;
46   tilemap_t *bg_tilemap[NAMCONA1_NUM_TILEMAPS];
47   int tilemap_palette_bank[NAMCONA1_NUM_TILEMAPS];
48   int palette_is_dirty;
49   UINT8 mask_data[8];
50   UINT8 conv_data[9];
51};
52
53
54/*----------- defined in video/namcona1.c -----------*/
55
56
3557extern WRITE16_HANDLER( namcona1_videoram_w );
3658extern READ16_HANDLER( namcona1_videoram_r );
3759
src/mame/includes/mcr3.h
r10886r10887
77   UINT8 *videoram;
88   UINT8 *spriteram;
99   size_t spriteram_size;
10   UINT8 input_mux;
11   UINT8 latched_input;
12   UINT8 last_op4;
13   UINT8 maxrpm_adc_control;
14   UINT8 maxrpm_adc_select;
15   UINT8 maxrpm_last_shift;
16   INT8 maxrpm_p1_shift;
17   INT8 maxrpm_p2_shift;
18   UINT8 spyhunt_sprite_color_mask;
19   INT16 spyhunt_scroll_offset;
20   UINT8 *spyhunt_alpharam;
21   INT16 spyhunt_scrollx;
22   INT16 spyhunt_scrolly;
23   tilemap_t *bg_tilemap;
24   tilemap_t *alpha_tilemap;
1025};
1126
1227
1328/*----------- defined in video/mcr3.c -----------*/
1429
15extern UINT8 spyhunt_sprite_color_mask;
16extern INT16 spyhunt_scroll_offset;
17
18extern UINT8 *spyhunt_alpharam;
19
2030WRITE8_HANDLER( mcr3_paletteram_w );
2131WRITE8_HANDLER( mcr3_videoram_w );
2232WRITE8_HANDLER( spyhunt_videoram_w );
src/mame/includes/namcos86.h
r10886r10887
55      : driver_device(machine, config) { }
66
77   UINT8 *spriteram;
8   int wdog;
9   UINT8 *rthunder_videoram1;
10   UINT8 *rthunder_videoram2;
11   UINT8 *rthunder_spriteram;
12   int tilebank;
13   int xscroll[4];
14   int yscroll[4];
15   tilemap_t *bg_tilemap[4];
16   int backcolor;
17   const UINT8 *tile_address_prom;
18   int copy_sprites;
819};
920
1021
1122/*----------- defined in video/namcos86.c -----------*/
1223
13extern UINT8 *rthunder_videoram1, *rthunder_videoram2, *rthunder_spriteram;
14
1524PALETTE_INIT( namcos86 );
1625VIDEO_START( namcos86 );
1726SCREEN_UPDATE( namcos86 );
src/mame/includes/galaxian.h
r10886r10887
4242
4343extern UINT8 galaxian_frogger_adjust;
4444extern UINT8 galaxian_sfx_tilemap;
45extern UINT8 galaxian_sprite_clip_start;
46extern UINT8 galaxian_sprite_clip_end;
4745
4846PALETTE_INIT( galaxian );
4947PALETTE_INIT( moonwar );
src/mame/includes/flower.h
r10886r10887
77      : driver_device(machine, config) { }
88
99   UINT8 *spriteram;
10   UINT8 *sn_irq_enable;
11   UINT8 *sn_nmi_enable;
12   UINT8 *textram;
13   UINT8 *bg0ram;
14   UINT8 *bg1ram;
15   UINT8 *bg0_scroll;
16   UINT8 *bg1_scroll;
17   tilemap_t *bg0_tilemap;
18   tilemap_t *bg1_tilemap;
19   tilemap_t *text_tilemap;
20   tilemap_t *text_right_tilemap;
1021};
1122
1223
r10886r10887
2031
2132/*----------- defined in video/flower.c -----------*/
2233
23extern UINT8 *flower_textram, *flower_bg0ram, *flower_bg1ram, *flower_bg0_scroll, *flower_bg1_scroll;
24
2534WRITE8_HANDLER( flower_textram_w );
2635WRITE8_HANDLER( flower_bg0ram_w );
2736WRITE8_HANDLER( flower_bg1ram_w );
src/mame/includes/astrocde.h
r10886r10887
99#define AC_SOUND_PRESENT   (0x01)
1010#define AC_LIGHTPEN_INTS   (0x02)
1111#define AC_STARS         (0x04)
12#define AC_MONITOR_BW      (0x08)
1213
1314
1415class astrocde_state : public driver_device
src/mame/includes/thedeep.h
r10886r10887
66
77   UINT8 *spriteram;
88   size_t spriteram_size;
9   int nmi_enable;
10   UINT8 protection_command;
11   UINT8 protection_data;
12   int protection_index;
13   int protection_irq;
14   int rombank;
15   UINT8 *vram_0;
16   UINT8 *vram_1;
17   UINT8 *scroll;
18   UINT8 *scroll2;
19   tilemap_t *tilemap_0;
20   tilemap_t *tilemap_1;
921};
1022
1123
1224/*----------- defined in video/thedeep.c -----------*/
1325
14extern UINT8 *thedeep_vram_0, *thedeep_vram_1;
15extern UINT8 *thedeep_scroll, *thedeep_scroll2;
16
1726WRITE8_HANDLER( thedeep_vram_0_w );
1827WRITE8_HANDLER( thedeep_vram_1_w );
1928
src/mame/includes/taito_f3.h
r10886r10887
4848   UINT32 *videoram;
4949   UINT32 *spriteram;
5050   size_t spriteram_size;
51   UINT32 coin_word[2];
52   UINT32 *f3_ram;
53   int f3_game;
54   UINT32 *f3_vram;
55   UINT32 *f3_line_ram;
56   UINT32 *f3_pf_data;
57   UINT32 *f3_pivot_ram;
58   tilemap_t *pf1_tilemap;
59   tilemap_t *pf2_tilemap;
60   tilemap_t *pf3_tilemap;
61   tilemap_t *pf4_tilemap;
62   tilemap_t *pixel_layer;
63   tilemap_t *vram_layer;
64   UINT32 *spriteram32_buffered;
65   UINT32 f3_control_0[8];
66   UINT32 f3_control_1[8];
67   int flipscreen;
68   UINT8 sprite_extra_planes;
69   UINT8 sprite_pen_mask;
70   UINT32 *f3_pf_data_1;
71   UINT32 *f3_pf_data_2;
72   UINT32 *f3_pf_data_3;
73   UINT32 *f3_pf_data_4;
74   int f3_skip_this_frame;
75   int sprite_lag;
76   UINT8 sprite_pri_usage;
77   bitmap_t *pri_alp_bitmap;
78   int f3_alpha_level_2as;
79   int f3_alpha_level_2ad;
80   int f3_alpha_level_3as;
81   int f3_alpha_level_3ad;
82   int f3_alpha_level_2bs;
83   int f3_alpha_level_2bd;
84   int f3_alpha_level_3bs;
85   int f3_alpha_level_3bd;
86   int alpha_level_last;
87   int width_mask;
88   int twidth_mask;
89   int twidth_mask_bit;
90   UINT8 *tile_opaque_sp;
91   UINT8 *tile_opaque_pf[4];
92   UINT8 add_sat[256][256];
93   int alpha_s_1_1;
94   int alpha_s_1_2;
95   int alpha_s_1_4;
96   int alpha_s_1_5;
97   int alpha_s_1_6;
98   int alpha_s_1_8;
99   int alpha_s_1_9;
100   int alpha_s_1_a;
101   int alpha_s_2a_0;
102   int alpha_s_2a_4;
103   int alpha_s_2a_8;
104   int alpha_s_2b_0;
105   int alpha_s_2b_4;
106   int alpha_s_2b_8;
107   int alpha_s_3a_0;
108   int alpha_s_3a_1;
109   int alpha_s_3a_2;
110   int alpha_s_3b_0;
111   int alpha_s_3b_1;
112   int alpha_s_3b_2;
113   UINT32 dval;
114   UINT8 pval;
115   UINT8 tval;
116   UINT8 pdest_2a;
117   UINT8 pdest_2b;
118   int tr_2a;
119   int tr_2b;
120   UINT8 pdest_3a;
121   UINT8 pdest_3b;
122   int tr_3a;
123   int tr_3b;
124   UINT16 *src0;
125   UINT16 *src_s0;
126   UINT16 *src_e0;
127   UINT16 clip_al0;
128   UINT16 clip_ar0;
129   UINT16 clip_bl0;
130   UINT16 clip_br0;
131   UINT8 *tsrc0;
132   UINT8 *tsrc_s0;
133   UINT32 x_count0;
134   UINT32 x_zoom0;
135   UINT16 *src1;
136   UINT16 *src_s1;
137   UINT16 *src_e1;
138   UINT16 clip_al1;
139   UINT16 clip_ar1;
140   UINT16 clip_bl1;
141   UINT16 clip_br1;
142   UINT8 *tsrc1;
143   UINT8 *tsrc_s1;
144   UINT32 x_count1;
145   UINT32 x_zoom1;
146   UINT16 *src2;
147   UINT16 *src_s2;
148   UINT16 *src_e2;
149   UINT16 clip_al2;
150   UINT16 clip_ar2;
151   UINT16 clip_bl2;
152   UINT16 clip_br2;
153   UINT8 *tsrc2;
154   UINT8 *tsrc_s2;
155   UINT32 x_count2;
156   UINT32 x_zoom2;
157   UINT16 *src3;
158   UINT16 *src_s3;
159   UINT16 *src_e3;
160   UINT16 clip_al3;
161   UINT16 clip_ar3;
162   UINT16 clip_bl3;
163   UINT16 clip_br3;
164   UINT8 *tsrc3;
165   UINT8 *tsrc_s3;
166   UINT32 x_count3;
167   UINT32 x_zoom3;
168   UINT16 *src4;
169   UINT16 *src_s4;
170   UINT16 *src_e4;
171   UINT16 clip_al4;
172   UINT16 clip_ar4;
173   UINT16 clip_bl4;
174   UINT16 clip_br4;
175   UINT8 *tsrc4;
176   UINT8 *tsrc_s4;
177   UINT32 x_count4;
178   UINT32 x_zoom4;
179   struct tempsprite *spritelist;
180   const struct tempsprite *sprite_end;
181   struct f3_playfield_line_inf *pf_line_inf;
182   struct f3_spritealpha_line_inf *sa_line_inf;
183   const struct F3config *f3_game_config;
184   int (*dpix_n[8][16])(taito_f3_state *state, UINT32 s_pix);
185   int (**dpix_lp[5])(taito_f3_state *state, UINT32 s_pix);
186   int (**dpix_sp[9])(taito_f3_state *state, UINT32 s_pix);
51187};
52188
53189
54/*----------- defined in drivers/taito_f3.c -----------*/
55
56extern int f3_game;
57
58190/*----------- defined in video/taito_f3.c -----------*/
59191
60extern UINT32 *f3_vram,*f3_line_ram;
61extern UINT32 *f3_pf_data,*f3_pivot_ram;
62
63192VIDEO_START( f3 );
64193SCREEN_UPDATE( f3 );
65194SCREEN_EOF( f3 );
src/mame/includes/megasys1.h
r10886r10887
1414***************************************************************************/
1515
1616
17/***************************************************************************
18
19                            Scrolling Layers Handling
20
21***************************************************************************/
22
2317class megasys1_state : public driver_device
2418{
2519public:
r10886r10887
2721      : driver_device(machine, config) { }
2822
2923   UINT16 *spriteram;
24   UINT16 ip_select;
25   UINT16 ip_select_values[5];
26   UINT8 ignore_oki_status;
27   UINT16 protection_val;
28   int bank;
29   UINT16 *scrollram[3];
30   UINT16 *objectram;
31   UINT16 *vregs;
32   UINT16 *ram;
33   int scrollx[3];
34   int scrolly[3];
35   int active_layers;
36   int bits_per_color_code;
37   int scroll_flag[3];
38   int sprite_bank;
39   int screen_flag;
40   int sprite_flag;
41   int _8x8_scroll_factor[3];
42   int _16x16_scroll_factor[3];
43   tilemap_t *tmap[3];
44   tilemap_t *tilemap[3][2][4];
45   int hardware_type_z;
46   UINT16 *buffer_objectram;
47   UINT16 *buffer2_objectram;
48   UINT16 *buffer_spriteram16;
49   UINT16 *buffer2_spriteram16;
50   int layers_order[16];
3051};
3152
3253
3354/*----------- defined in video/megasys1.c -----------*/
3455
35/* Variables */
36extern UINT16 *megasys1_scrollram[3];
37extern UINT16 *megasys1_objectram, *megasys1_vregs, *megasys1_ram;
38
39
40/* Functions */
4156VIDEO_START( megasys1 );
4257SCREEN_UPDATE( megasys1 );
4358SCREEN_EOF( megasys1 );
src/mame/video/shangkid.c
r10886r10887
44#include "cpu/z80/z80.h"
55#include "includes/shangkid.h"
66
7static tilemap_t *background;
8UINT8 *shangkid_videoreg;
9int shangkid_gfx_type;
107
11
12
138static TILE_GET_INFO( get_bg_tile_info ){
149   shangkid_state *state = machine->driver_data<shangkid_state>();
1510   UINT8 *videoram = state->videoram;
r10886r10887
1712   int tile_number = videoram[tile_index]+0x100*(attributes&0x3);
1813   int color;
1914
20   if( shangkid_gfx_type==1 )
15   if( state->gfx_type==1 )
2116   {
2217      /* Shanghai Kid:
2318            ------xx    bank
r10886r10887
5348
5449VIDEO_START( shangkid )
5550{
56   background = tilemap_create(machine, get_bg_tile_info,tilemap_scan_rows,8,8,64,32);
51   shangkid_state *state = machine->driver_data<shangkid_state>();
52   state->background = tilemap_create(machine, get_bg_tile_info,tilemap_scan_rows,8,8,64,32);
5753}
5854
5955WRITE8_HANDLER( shangkid_videoram_w )
r10886r10887
6157   shangkid_state *state = space->machine->driver_data<shangkid_state>();
6258   UINT8 *videoram = state->videoram;
6359   videoram[offset] = data;
64   tilemap_mark_tile_dirty( background, offset&0x7ff );
60   tilemap_mark_tile_dirty( state->background, offset&0x7ff );
6561}
6662
6763static void draw_sprite(running_machine *machine, const UINT8 *source, bitmap_t *bitmap, const rectangle *cliprect)
6864{
65   shangkid_state *state = machine->driver_data<shangkid_state>();
6966   const gfx_element *gfx;
7067   int transparent_pen;
7168   int bank_index;
r10886r10887
8986   if( xsize==0 && xflip ) xpos -= 16;
9087   if( ysize==0 && yflip==0 ) ypos += 16;
9188
92   if( shangkid_gfx_type == 1 )
89   if( state->gfx_type == 1 )
9390   {
9491      /* Shanghai Kid */
9592      switch( bank&0x30 )
r10886r10887
190187
191188SCREEN_UPDATE( shangkid )
192189{
193   int flipscreen = shangkid_videoreg[1]&0x80;
194   tilemap_set_flip( background, flipscreen?(TILEMAP_FLIPX|TILEMAP_FLIPY):0 );
195   tilemap_set_scrollx( background,0,shangkid_videoreg[0]-40 );
196   tilemap_set_scrolly( background,0,shangkid_videoreg[2]+0x10 );
190   shangkid_state *state = screen->machine->driver_data<shangkid_state>();
191   int flipscreen = state->videoreg[1]&0x80;
192   tilemap_set_flip( state->background, flipscreen?(TILEMAP_FLIPX|TILEMAP_FLIPY):0 );
193   tilemap_set_scrollx( state->background,0,state->videoreg[0]-40 );
194   tilemap_set_scrolly( state->background,0,state->videoreg[2]+0x10 );
197195
198   tilemap_draw( bitmap,cliprect,background,0,0 );
196   tilemap_draw( bitmap,cliprect,state->background,0,0 );
199197   shangkid_draw_sprites(screen->machine, bitmap,cliprect );
200   tilemap_draw( bitmap,cliprect,background,1,0 ); /* high priority tiles */
198   tilemap_draw( bitmap,cliprect,state->background,1,0 ); /* high priority tiles */
201199   return 0;
202200}
203201
src/mame/video/namcona1.c
r10886r10887
99#include "emu.h"
1010#include "includes/namcona1.h"
1111
12#define NAMCONA1_NUM_TILEMAPS 4
1312
14/* public variables */
15UINT16 *namcona1_vreg;
16UINT16 *namcona1_scroll;
17UINT16 *namcona1_workram;
18//UINT16 *namcona1_sparevram;
19//UINT16 *namcona1_pixmap;
20
21/* private variables */
22static UINT16 *shaperam;
23static UINT16 *cgram;
24static tilemap_t *roz_tilemap;
25static int roz_palette;
26static tilemap_t *bg_tilemap[NAMCONA1_NUM_TILEMAPS];
27static int tilemap_palette_bank[NAMCONA1_NUM_TILEMAPS];
28static int palette_is_dirty;
29
3013static void tilemap_get_info(
3114   running_machine *machine,
3215   tile_data *tileinfo,
r10886r10887
3518   int tilemap_color,
3619   int use_4bpp_gfx )
3720{
21   namcona1_state *state = machine->driver_data<namcona1_state>();
3822   UINT16 *source;
39   static UINT8 mask_data[8];
4023
4124   int data = tilemap_videoram[tile_index];
4225   int tile = data&0xfff;
r10886r10887
6144   {
6245      SET_TILE_INFO( gfx,tile,tilemap_color,0 );
6346      if (ENDIANNESS_NATIVE == ENDIANNESS_BIG)
64         tileinfo->mask_data = (UINT8 *)(shaperam+4*tile);
47         tileinfo->mask_data = (UINT8 *)(state->shaperam+4*tile);
6548      else
6649      {
67         source = shaperam+4*tile;
50         UINT8 *mask_data = state->mask_data;
51         source = state->shaperam+4*tile;
6852         mask_data[0] = source[0]>>8;
6953         mask_data[1] = source[0]&0xff;
7054         mask_data[2] = source[1]>>8;
r10886r10887
8266{
8367   namcona1_state *state = machine->driver_data<namcona1_state>();
8468   UINT16 *videoram = state->videoram;
85   tilemap_get_info(machine,tileinfo,tile_index,0*0x1000+videoram,tilemap_palette_bank[0],namcona1_vreg[0xbc/2]&1);
69   tilemap_get_info(machine,tileinfo,tile_index,0*0x1000+videoram,state->tilemap_palette_bank[0],state->vreg[0xbc/2]&1);
8670}
8771
8872static TILE_GET_INFO( tilemap_get_info1 )
8973{
9074   namcona1_state *state = machine->driver_data<namcona1_state>();
9175   UINT16 *videoram = state->videoram;
92   tilemap_get_info(machine,tileinfo,tile_index,1*0x1000+videoram,tilemap_palette_bank[1],namcona1_vreg[0xbc/2]&2);
76   tilemap_get_info(machine,tileinfo,tile_index,1*0x1000+videoram,state->tilemap_palette_bank[1],state->vreg[0xbc/2]&2);
9377}
9478
9579static TILE_GET_INFO( tilemap_get_info2 )
9680{
9781   namcona1_state *state = machine->driver_data<namcona1_state>();
9882   UINT16 *videoram = state->videoram;
99   tilemap_get_info(machine,tileinfo,tile_index,2*0x1000+videoram,tilemap_palette_bank[2],namcona1_vreg[0xbc/2]&4);
83   tilemap_get_info(machine,tileinfo,tile_index,2*0x1000+videoram,state->tilemap_palette_bank[2],state->vreg[0xbc/2]&4);
10084}
10185
10286static TILE_GET_INFO( tilemap_get_info3 )
10387{
10488   namcona1_state *state = machine->driver_data<namcona1_state>();
10589   UINT16 *videoram = state->videoram;
106   tilemap_get_info(machine,tileinfo,tile_index,3*0x1000+videoram,tilemap_palette_bank[3],namcona1_vreg[0xbc/2]&8);
90   tilemap_get_info(machine,tileinfo,tile_index,3*0x1000+videoram,state->tilemap_palette_bank[3],state->vreg[0xbc/2]&8);
10791}
10892
10993static TILE_GET_INFO( roz_get_info )
r10886r10887
11195   namcona1_state *state = machine->driver_data<namcona1_state>();
11296   UINT16 *videoram = state->videoram;
11397   /* each logical tile is constructed from 4*4 normal tiles */
114   int tilemap_color = roz_palette;
115   int use_4bpp_gfx = namcona1_vreg[0xbc/2]&16; /* ? */
98   int tilemap_color = state->roz_palette;
99   int use_4bpp_gfx = state->vreg[0xbc/2]&16; /* ? */
116100   int c = tile_index%0x40;
117101   int r = tile_index/0x40;
118102   int data = videoram[0x8000/2+(r/4)*0x40+c/4]&0xfbf; /* mask out bit 0x40 - patch for Emeraldia Japan */
r10886r10887
129113   }
130114   else
131115   {
132      UINT8 *mask_data = (UINT8 *)(shaperam+4*tile);
116      UINT8 *mask_data = (UINT8 *)(state->shaperam+4*tile);
133117
134118      if (ENDIANNESS_NATIVE == ENDIANNESS_LITTLE)
135119      {
136120         UINT16 *source = (UINT16 *)mask_data;
137         static UINT8 conv_data[9];
121         UINT8 *conv_data = state->conv_data;
138122         conv_data[0] = source[0]>>8;
139123         conv_data[1] = source[0]&0xff;
140124         conv_data[2] = source[1]>>8;
r10886r10887
159143   COMBINE_DATA( &videoram[offset] );
160144   if( offset<0x8000/2 )
161145   {
162      tilemap_mark_tile_dirty( bg_tilemap[offset/0x1000], offset&0xfff );
146      tilemap_mark_tile_dirty( state->bg_tilemap[offset/0x1000], offset&0xfff );
163147   }
164148   else if( offset<0xa000/2 )
165149   {
166      tilemap_mark_all_tiles_dirty( roz_tilemap );
150      tilemap_mark_all_tiles_dirty( state->roz_tilemap );
167151   }
168152} /* namcona1_videoram_w */
169153
r10886r10887
201185
202186WRITE16_HANDLER( namcona1_paletteram_w )
203187{
188   namcona1_state *state = space->machine->driver_data<namcona1_state>();
204189   COMBINE_DATA( &space->machine->generic.paletteram.u16[offset] );
205   if( namcona1_vreg[0x8e/2] )
190   if( state->vreg[0x8e/2] )
206191   { /* graphics enabled; update palette immediately */
207192      UpdatePalette(space->machine, offset );
208193   }
209194   else
210195   {
211      palette_is_dirty = 1;
196      state->palette_is_dirty = 1;
212197   }
213198}
214199
r10886r10887
251236
252237READ16_HANDLER( namcona1_gfxram_r )
253238{
254   UINT16 type = namcona1_vreg[0x0c/2];
239   namcona1_state *state = space->machine->driver_data<namcona1_state>();
240   UINT16 type = state->vreg[0x0c/2];
255241   if( type == 0x03 )
256242   {
257243      if( offset<0x4000 )
258244      {
259         return shaperam[offset];
245         return state->shaperam[offset];
260246      }
261247   }
262248   else if( type == 0x02 )
263249   {
264      return cgram[offset];
250      return state->cgram[offset];
265251   }
266252   return 0x0000;
267253} /* namcona1_gfxram_r */
268254
269255WRITE16_HANDLER( namcona1_gfxram_w )
270256{
271   UINT16 type = namcona1_vreg[0x0c/2];
257   namcona1_state *state = space->machine->driver_data<namcona1_state>();
258   UINT16 type = state->vreg[0x0c/2];
272259   UINT16 old_word;
273260
274261   if( type == 0x03 )
275262   {
276263      if( offset<0x4000 )
277264      {
278         old_word = shaperam[offset];
279         COMBINE_DATA( &shaperam[offset] );
280         if( shaperam[offset]!=old_word )
265         old_word = state->shaperam[offset];
266         COMBINE_DATA( &state->shaperam[offset] );
267         if( state->shaperam[offset]!=old_word )
281268            gfx_element_mark_dirty(space->machine->gfx[2], offset/4);
282269      }
283270   }
284271   else if( type == 0x02 )
285272   {
286      old_word = cgram[offset];
287      COMBINE_DATA( &cgram[offset] );
288      if( cgram[offset]!=old_word )
273      old_word = state->cgram[offset];
274      COMBINE_DATA( &state->cgram[offset] );
275      if( state->cgram[offset]!=old_word )
289276      {
290277         gfx_element_mark_dirty(space->machine->gfx[0], offset/0x20);
291278         gfx_element_mark_dirty(space->machine->gfx[1], offset/0x20);
r10886r10887
299286
300287VIDEO_START( namcona1 )
301288{
289   namcona1_state *state = machine->driver_data<namcona1_state>();
302290   static const tile_get_info_func get_info[4] = { tilemap_get_info0, tilemap_get_info1, tilemap_get_info2, tilemap_get_info3 };
303291   int i;
304292
305   roz_tilemap = tilemap_create( machine, roz_get_info, tilemap_scan_rows, 8,8,64,64 );
306   roz_palette = -1;
293   state->roz_tilemap = tilemap_create( machine, roz_get_info, tilemap_scan_rows, 8,8,64,64 );
294   state->roz_palette = -1;
307295
308296   for( i=0; i<NAMCONA1_NUM_TILEMAPS; i++ )
309297   {
310      bg_tilemap[i] = tilemap_create( machine, get_info[i], tilemap_scan_rows, 8,8,64,64 );
311      tilemap_palette_bank[i] = -1;
298      state->bg_tilemap[i] = tilemap_create( machine, get_info[i], tilemap_scan_rows, 8,8,64,64 );
299      state->tilemap_palette_bank[i] = -1;
312300   }
313301
314   shaperam           = auto_alloc_array(machine, UINT16, 0x2000*4/2 );
315   cgram              = auto_alloc_array(machine, UINT16, 0x1000*0x40/2 );
302   state->shaperam           = auto_alloc_array(machine, UINT16, 0x2000*4/2 );
303   state->cgram              = auto_alloc_array(machine, UINT16, 0x1000*0x40/2 );
316304
317   machine->gfx[0] = gfx_element_alloc( machine, &cg_layout_8bpp, (UINT8 *)cgram, machine->total_colors()/256, 0 );
318   machine->gfx[1] = gfx_element_alloc( machine, &cg_layout_4bpp, (UINT8 *)cgram, machine->total_colors()/16, 0 );
319   machine->gfx[2] = gfx_element_alloc( machine, &shape_layout, (UINT8 *)shaperam, machine->total_colors()/2, 0 );
305   machine->gfx[0] = gfx_element_alloc( machine, &cg_layout_8bpp, (UINT8 *)state->cgram, machine->total_colors()/256, 0 );
306   machine->gfx[1] = gfx_element_alloc( machine, &cg_layout_4bpp, (UINT8 *)state->cgram, machine->total_colors()/16, 0 );
307   machine->gfx[2] = gfx_element_alloc( machine, &shape_layout, (UINT8 *)state->shaperam, machine->total_colors()/2, 0 );
320308
321309} /* namcona1_vh_start */
322310
r10886r10887
481469   int row,col;
482470   int sx,sy;
483471
484   sprite_control = namcona1_vreg[0x22/2];
472   sprite_control = state->vreg[0x22/2];
485473   if( sprite_control&1 ) source += 0x400; /* alternate spriteram bank */
486474
487475   for( which=0; which<0x100; which++ )
r10886r10887
576564     *  tmap3   ffec00  ffee00
577565     */
578566   int xadjust = 0x3a - which*2;
579   const UINT16 *scroll = namcona1_scroll+0x200*which;
567   const UINT16 *scroll = state->scroll+0x200*which;
580568   int line;
581569   UINT16 xdata, ydata;
582570   int scrollx, scrolly;
r10886r10887
585573   gfx_element *pGfx;
586574
587575   pGfx = machine->gfx[0];
588   paldata = &machine->pens[pGfx->color_base + pGfx->color_granularity * tilemap_palette_bank[which]];
576   paldata = &machine->pens[pGfx->color_base + pGfx->color_granularity * state->tilemap_palette_bank[which]];
589577
590578   /* draw one scanline at a time */
591579   clip.min_x = cliprect->min_x;
r10886r10887
626614         {
627615            if(which == NAMCONA1_NUM_TILEMAPS )
628616            {
629               int incxx = ((INT16)namcona1_vreg[0xc0/2])<<8;
630               int incxy = ((INT16)namcona1_vreg[0xc2/2])<<8;
631               int incyx = ((INT16)namcona1_vreg[0xc4/2])<<8;
632               int incyy = ((INT16)namcona1_vreg[0xc6/2])<<8;
633               INT16 xoffset = namcona1_vreg[0xc8/2];
634               INT16 yoffset = namcona1_vreg[0xca/2];
617               int incxx = ((INT16)state->vreg[0xc0/2])<<8;
618               int incxy = ((INT16)state->vreg[0xc2/2])<<8;
619               int incyx = ((INT16)state->vreg[0xc4/2])<<8;
620               int incyy = ((INT16)state->vreg[0xc6/2])<<8;
621               INT16 xoffset = state->vreg[0xc8/2];
622               INT16 yoffset = state->vreg[0xca/2];
635623               int dx = 46; /* horizontal adjust */
636624               int dy = -8; /* vertical adjust */
637625               UINT32 startx = (xoffset<<12)+incxx*dx+incyx*dy;
638626               UINT32 starty = (yoffset<<12)+incxy*dx+incyy*dy;
639               tilemap_draw_roz_primask(bitmap, &clip, roz_tilemap,
627               tilemap_draw_roz_primask(bitmap, &clip, state->roz_tilemap,
640628                  startx, starty, incxx, incxy, incyx, incyy, 0, 0, primask, 0);
641629            }
642630            else
643631            {
644               tilemap_set_scrollx( bg_tilemap[which], 0, scrollx );
645               tilemap_set_scrolly( bg_tilemap[which], 0, scrolly );
646               tilemap_draw_primask( bitmap, &clip, bg_tilemap[which], 0, primask, 0 );
632               tilemap_set_scrollx( state->bg_tilemap[which], 0, scrollx );
633               tilemap_set_scrolly( state->bg_tilemap[which], 0, scrolly );
634               tilemap_draw_primask( bitmap, &clip, state->bg_tilemap[which], 0, primask, 0 );
647635            }
648636         }
649637      }
r10886r10887
652640
653641SCREEN_UPDATE( namcona1 )
654642{
643   namcona1_state *state = screen->machine->driver_data<namcona1_state>();
655644   int which;
656645   int priority;
657646
658   /* int flipscreen = namcona1_vreg[0x98/2]; (TBA) */
647   /* int flipscreen = state->vreg[0x98/2]; (TBA) */
659648
660   if( namcona1_vreg[0x8e/2] )
649   if( state->vreg[0x8e/2] )
661650   { /* gfx enabled */
662      if( palette_is_dirty )
651      if( state->palette_is_dirty )
663652      {
664653         /* palette updates are delayed when graphics are disabled */
665654         for( which=0; which<0x1000; which++ )
666655         {
667656            UpdatePalette(screen->machine, which );
668657         }
669         palette_is_dirty = 0;
658         state->palette_is_dirty = 0;
670659      }
671660      UpdateGfx(screen->machine);
672661      for( which=0; which<NAMCONA1_NUM_TILEMAPS; which++ )
673662      {
674         int tilemap_color = namcona1_vreg[0xb0/2+(which&3)]&0xf;
675         if( tilemap_color!=tilemap_palette_bank[which] )
663         int tilemap_color = state->vreg[0xb0/2+(which&3)]&0xf;
664         if( tilemap_color!=state->tilemap_palette_bank[which] )
676665         {
677            tilemap_mark_all_tiles_dirty( bg_tilemap[which] );
678            tilemap_palette_bank[which] = tilemap_color;
666            tilemap_mark_all_tiles_dirty( state->bg_tilemap[which] );
667            state->tilemap_palette_bank[which] = tilemap_color;
679668         }
680669      } /* next tilemap */
681670
682671      { /* ROZ tilemap */
683         int color = namcona1_vreg[0xba/2]&0xf;
684         if( color != roz_palette )
672         int color = state->vreg[0xba/2]&0xf;
673         if( color != state->roz_palette )
685674         {
686            tilemap_mark_all_tiles_dirty( roz_tilemap );
687            roz_palette = color;
675            tilemap_mark_all_tiles_dirty( state->roz_tilemap );
676            state->roz_palette = color;
688677         }
689678      }
690679
r10886r10887
699688            int pri;
700689            if( which==4 )
701690            {
702               pri = namcona1_vreg[0xa0/2+5]&0x7;
691               pri = state->vreg[0xa0/2+5]&0x7;
703692            }
704693            else
705694            {
706               pri = namcona1_vreg[0xa0/2+which]&0x7;
695               pri = state->vreg[0xa0/2+which]&0x7;
707696            }
708697            if( pri == priority )
709698            {
src/mame/video/mcr3.c
r10886r10887
1212
1313/*************************************
1414 *
15 *  Global variables
16 *
17 *************************************/
18
19/* Spy Hunter hardware extras */
20UINT8 spyhunt_sprite_color_mask;
21static INT16 spyhunt_scrollx, spyhunt_scrolly;
22INT16 spyhunt_scroll_offset;
23
24UINT8 *spyhunt_alpharam;
25//size_t spyhunt_alpharam_size;
26
27
28
29/*************************************
30 *
31 *  Local variables
32 *
33 *************************************/
34
35static tilemap_t *bg_tilemap;
36static tilemap_t *alpha_tilemap;
37
38
39
40/*************************************
41 *
4215 *  Tilemap callbacks
4316 *
4417 *************************************/
r10886r10887
8659
8760static TILE_GET_INFO( spyhunt_get_alpha_tile_info )
8861{
89   SET_TILE_INFO(2, spyhunt_alpharam[tile_index], 0, 0);
62   mcr3_state *state = machine->driver_data<mcr3_state>();
63   SET_TILE_INFO(2, state->spyhunt_alpharam[tile_index], 0, 0);
9064}
9165
9266
r10886r10887
11791#ifdef UNUSED_FUNCTION
11892VIDEO_START( mcr3 )
11993{
94   mcr3_state *state = machine->driver_data<mcr3_state>();
12095   /* initialize the background tilemap */
121   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows,  16,16, 32,30);
96   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows,  16,16, 32,30);
12297}
12398#endif
12499
125100
126101VIDEO_START( mcrmono )
127102{
103   mcr3_state *state = machine->driver_data<mcr3_state>();
128104   /* initialize the background tilemap */
129   bg_tilemap = tilemap_create(machine, mcrmono_get_bg_tile_info, tilemap_scan_rows,  16,16, 32,30);
105   state->bg_tilemap = tilemap_create(machine, mcrmono_get_bg_tile_info, tilemap_scan_rows,  16,16, 32,30);
130106}
131107
132108
133109VIDEO_START( spyhunt )
134110{
111   mcr3_state *state = machine->driver_data<mcr3_state>();
135112   /* initialize the background tilemap */
136   bg_tilemap = tilemap_create(machine, spyhunt_get_bg_tile_info, spyhunt_bg_scan,  64,32, 64,32);
113   state->bg_tilemap = tilemap_create(machine, spyhunt_get_bg_tile_info, spyhunt_bg_scan,  64,32, 64,32);
137114
138115   /* initialize the text tilemap */
139   alpha_tilemap = tilemap_create(machine, spyhunt_get_alpha_tile_info, tilemap_scan_cols,  16,16, 32,32);
140   tilemap_set_transparent_pen(alpha_tilemap, 0);
141   tilemap_set_scrollx(alpha_tilemap, 0, 16);
116   state->alpha_tilemap = tilemap_create(machine, spyhunt_get_alpha_tile_info, tilemap_scan_cols,  16,16, 32,32);
117   tilemap_set_transparent_pen(state->alpha_tilemap, 0);
118   tilemap_set_scrollx(state->alpha_tilemap, 0, 16);
142119
143   state_save_register_global(machine, spyhunt_sprite_color_mask);
144   state_save_register_global(machine, spyhunt_scrollx);
145   state_save_register_global(machine, spyhunt_scrolly);
146   state_save_register_global(machine, spyhunt_scroll_offset);
120   state_save_register_global(machine, state->spyhunt_sprite_color_mask);
121   state_save_register_global(machine, state->spyhunt_scrollx);
122   state_save_register_global(machine, state->spyhunt_scrolly);
123   state_save_register_global(machine, state->spyhunt_scroll_offset);
147124}
148125
149126
r10886r10887
176153   mcr3_state *state = space->machine->driver_data<mcr3_state>();
177154   UINT8 *videoram = state->videoram;
178155   videoram[offset] = data;
179   tilemap_mark_tile_dirty(bg_tilemap, offset / 2);
156   tilemap_mark_tile_dirty(state->bg_tilemap, offset / 2);
180157}
181158
182159
r10886r10887
185162   mcr3_state *state = space->machine->driver_data<mcr3_state>();
186163   UINT8 *videoram = state->videoram;
187164   videoram[offset] = data;
188   tilemap_mark_tile_dirty(bg_tilemap, offset);
165   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
189166}
190167
191168
192169WRITE8_HANDLER( spyhunt_alpharam_w )
193170{
194   spyhunt_alpharam[offset] = data;
195   tilemap_mark_tile_dirty(alpha_tilemap, offset);
171   mcr3_state *state = space->machine->driver_data<mcr3_state>();
172   state->spyhunt_alpharam[offset] = data;
173   tilemap_mark_tile_dirty(state->alpha_tilemap, offset);
196174}
197175
198176
199177WRITE8_HANDLER( spyhunt_scroll_value_w )
200178{
179   mcr3_state *state = space->machine->driver_data<mcr3_state>();
201180   switch (offset)
202181   {
203182      case 0:
204183         /* low 8 bits of horizontal scroll */
205         spyhunt_scrollx = (spyhunt_scrollx & ~0xff) | data;
184         state->spyhunt_scrollx = (state->spyhunt_scrollx & ~0xff) | data;
206185         break;
207186
208187      case 1:
209188         /* upper 3 bits of horizontal scroll and upper 1 bit of vertical scroll */
210         spyhunt_scrollx = (spyhunt_scrollx & 0xff) | ((data & 0x07) << 8);
211         spyhunt_scrolly = (spyhunt_scrolly & 0xff) | ((data & 0x80) << 1);
189         state->spyhunt_scrollx = (state->spyhunt_scrollx & 0xff) | ((data & 0x07) << 8);
190         state->spyhunt_scrolly = (state->spyhunt_scrolly & 0xff) | ((data & 0x80) << 1);
212191         break;
213192
214193      case 2:
215194         /* low 8 bits of vertical scroll */
216         spyhunt_scrolly = (spyhunt_scrolly & ~0xff) | data;
195         state->spyhunt_scrolly = (state->spyhunt_scrolly & ~0xff) | data;
217196         break;
218197   }
219198}
r10886r10887
303282
304283SCREEN_UPDATE( mcr3 )
305284{
285   mcr3_state *state = screen->machine->driver_data<mcr3_state>();
306286   /* update the flip state */
307   tilemap_set_flip(bg_tilemap, mcr_cocktail_flip ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0);
287   tilemap_set_flip(state->bg_tilemap, mcr_cocktail_flip ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0);
308288
309289   /* draw the background */
310   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
290   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
311291
312292   /* draw the sprites */
313293   mcr3_update_sprites(screen->machine, bitmap, cliprect, 0x03, 0, 0, 0);
r10886r10887
317297
318298SCREEN_UPDATE( spyhunt )
319299{
300   mcr3_state *state = screen->machine->driver_data<mcr3_state>();
320301   /* for every character in the Video RAM, check if it has been modified */
321302   /* since last time and update it accordingly. */
322   tilemap_set_scrollx(bg_tilemap, 0, spyhunt_scrollx * 2 + spyhunt_scroll_offset);
323   tilemap_set_scrolly(bg_tilemap, 0, spyhunt_scrolly * 2);
324   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
303   tilemap_set_scrollx(state->bg_tilemap, 0, state->spyhunt_scrollx * 2 + state->spyhunt_scroll_offset);
304   tilemap_set_scrolly(state->bg_tilemap, 0, state->spyhunt_scrolly * 2);
305   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
325306
326307   /* draw the sprites */
327   mcr3_update_sprites(screen->machine, bitmap, cliprect, spyhunt_sprite_color_mask, 0, -12, 0);
308   mcr3_update_sprites(screen->machine, bitmap, cliprect, state->spyhunt_sprite_color_mask, 0, -12, 0);
328309
329310   /* render any characters on top */
330   tilemap_draw(bitmap, cliprect, alpha_tilemap, 0, 0);
311   tilemap_draw(bitmap, cliprect, state->alpha_tilemap, 0, 0);
331312   return 0;
332313}
src/mame/video/namcos86.c
r10886r10887
88#include "includes/namcos86.h"
99
1010
11UINT8 *rthunder_videoram1, *rthunder_videoram2, *rthunder_spriteram;
12
13static int tilebank;
14static int xscroll[4], yscroll[4];   /* scroll + priority */
15
16static tilemap_t *bg_tilemap[4];
17
18static int backcolor;
19static const UINT8 *tile_address_prom;
20
21
2211/***************************************************************************
2312
2413  Convert the color PROMs into a more useable format.
r10886r10887
4534
4635PALETTE_INIT( namcos86 )
4736{
37   namcos86_state *state = machine->driver_data<namcos86_state>();
4838   int i;
4939   rgb_t palette[512];
5040
r10886r10887
8575
8676   /* color_prom now points to the beginning of the tile address decode PROM */
8777
88   tile_address_prom = color_prom;   /* we'll need this at run time */
78   state->tile_address_prom = color_prom;   /* we'll need this at run time */
8979}
9080
9181
r10886r10887
9989
10090INLINE void get_tile_info(running_machine *machine,tile_data *tileinfo,int tile_index,int layer,UINT8 *vram)
10191{
92   namcos86_state *state = machine->driver_data<namcos86_state>();
10293   int attr = vram[2*tile_index + 1];
10394   int tile_offs;
10495   if (layer & 2)
105      tile_offs = ((tile_address_prom[((layer & 1) << 4) + (attr & 0x03)] & 0xe0) >> 5) * 0x100;
96      tile_offs = ((state->tile_address_prom[((layer & 1) << 4) + (attr & 0x03)] & 0xe0) >> 5) * 0x100;
10697   else
107      tile_offs = ((tile_address_prom[((layer & 1) << 4) + ((attr & 0x03) << 2)] & 0x0e) >> 1) * 0x100 + tilebank * 0x800;
98      tile_offs = ((state->tile_address_prom[((layer & 1) << 4) + ((attr & 0x03) << 2)] & 0x0e) >> 1) * 0x100 + state->tilebank * 0x800;
10899
109100   SET_TILE_INFO(
110101         (layer & 2) ? 1 : 0,
r10886r10887
113104         0);
114105}
115106
116static TILE_GET_INFO( get_tile_info0 ) { get_tile_info(machine,tileinfo,tile_index,0,&rthunder_videoram1[0x0000]); }
117static TILE_GET_INFO( get_tile_info1 ) { get_tile_info(machine,tileinfo,tile_index,1,&rthunder_videoram1[0x1000]); }
118static TILE_GET_INFO( get_tile_info2 ) { get_tile_info(machine,tileinfo,tile_index,2,&rthunder_videoram2[0x0000]); }
119static TILE_GET_INFO( get_tile_info3 ) { get_tile_info(machine,tileinfo,tile_index,3,&rthunder_videoram2[0x1000]); }
107static TILE_GET_INFO( get_tile_info0 )
108{
109   namcos86_state *state = machine->driver_data<namcos86_state>();
110   get_tile_info(machine,tileinfo,tile_index,0,&state->rthunder_videoram1[0x0000]);
111}
120112
113static TILE_GET_INFO( get_tile_info1 )
114{
115   namcos86_state *state = machine->driver_data<namcos86_state>();
116   get_tile_info(machine,tileinfo,tile_index,1,&state->rthunder_videoram1[0x1000]);
117}
121118
119static TILE_GET_INFO( get_tile_info2 )
120{
121   namcos86_state *state = machine->driver_data<namcos86_state>();
122   get_tile_info(machine,tileinfo,tile_index,2,&state->rthunder_videoram2[0x0000]);
123}
124
125static TILE_GET_INFO( get_tile_info3 )
126{
127   namcos86_state *state = machine->driver_data<namcos86_state>();
128   get_tile_info(machine,tileinfo,tile_index,3,&state->rthunder_videoram2[0x1000]);
129}
130
131
122132/***************************************************************************
123133
124134  Start the video hardware emulation.
r10886r10887
128138VIDEO_START( namcos86 )
129139{
130140   namcos86_state *state = machine->driver_data<namcos86_state>();
131   bg_tilemap[0] = tilemap_create(machine, get_tile_info0,tilemap_scan_rows,8,8,64,32);
132   bg_tilemap[1] = tilemap_create(machine, get_tile_info1,tilemap_scan_rows,8,8,64,32);
133   bg_tilemap[2] = tilemap_create(machine, get_tile_info2,tilemap_scan_rows,8,8,64,32);
134   bg_tilemap[3] = tilemap_create(machine, get_tile_info3,tilemap_scan_rows,8,8,64,32);
141   state->bg_tilemap[0] = tilemap_create(machine, get_tile_info0,tilemap_scan_rows,8,8,64,32);
142   state->bg_tilemap[1] = tilemap_create(machine, get_tile_info1,tilemap_scan_rows,8,8,64,32);
143   state->bg_tilemap[2] = tilemap_create(machine, get_tile_info2,tilemap_scan_rows,8,8,64,32);
144   state->bg_tilemap[3] = tilemap_create(machine, get_tile_info3,tilemap_scan_rows,8,8,64,32);
135145
136   tilemap_set_transparent_pen(bg_tilemap[0],7);
137   tilemap_set_transparent_pen(bg_tilemap[1],7);
138   tilemap_set_transparent_pen(bg_tilemap[2],7);
139   tilemap_set_transparent_pen(bg_tilemap[3],7);
146   tilemap_set_transparent_pen(state->bg_tilemap[0],7);
147   tilemap_set_transparent_pen(state->bg_tilemap[1],7);
148   tilemap_set_transparent_pen(state->bg_tilemap[2],7);
149   tilemap_set_transparent_pen(state->bg_tilemap[3],7);
140150
141   state->spriteram = rthunder_spriteram + 0x1800;
151   state->spriteram = state->rthunder_spriteram + 0x1800;
142152}
143153
144154
r10886r10887
151161
152162READ8_HANDLER( rthunder_videoram1_r )
153163{
154   return rthunder_videoram1[offset];
164   namcos86_state *state = space->machine->driver_data<namcos86_state>();
165   return state->rthunder_videoram1[offset];
155166}
156167
157168WRITE8_HANDLER( rthunder_videoram1_w )
158169{
159   rthunder_videoram1[offset] = data;
160   tilemap_mark_tile_dirty(bg_tilemap[offset/0x1000],(offset & 0xfff)/2);
170   namcos86_state *state = space->machine->driver_data<namcos86_state>();
171   state->rthunder_videoram1[offset] = data;
172   tilemap_mark_tile_dirty(state->bg_tilemap[offset/0x1000],(offset & 0xfff)/2);
161173}
162174
163175READ8_HANDLER( rthunder_videoram2_r )
164176{
165   return rthunder_videoram2[offset];
177   namcos86_state *state = space->machine->driver_data<namcos86_state>();
178   return state->rthunder_videoram2[offset];
166179}
167180
168181WRITE8_HANDLER( rthunder_videoram2_w )
169182{
170   rthunder_videoram2[offset] = data;
171   tilemap_mark_tile_dirty(bg_tilemap[2+offset/0x1000],(offset & 0xfff)/2);
183   namcos86_state *state = space->machine->driver_data<namcos86_state>();
184   state->rthunder_videoram2[offset] = data;
185   tilemap_mark_tile_dirty(state->bg_tilemap[2+offset/0x1000],(offset & 0xfff)/2);
172186}
173187
174188WRITE8_HANDLER( rthunder_tilebank_select_w )
175189{
190   namcos86_state *state = space->machine->driver_data<namcos86_state>();
176191   int bit = BIT(offset,10);
177   if (tilebank != bit)
192   if (state->tilebank != bit)
178193   {
179      tilebank = bit;
180      tilemap_mark_all_tiles_dirty(bg_tilemap[0]);
181      tilemap_mark_all_tiles_dirty(bg_tilemap[1]);
194      state->tilebank = bit;
195      tilemap_mark_all_tiles_dirty(state->bg_tilemap[0]);
196      tilemap_mark_all_tiles_dirty(state->bg_tilemap[1]);
182197   }
183198}
184199
185static void scroll_w(int layer,int offset,int data)
200static void scroll_w(address_space *space, int offset, int data, int layer)
186201{
202   namcos86_state *state = space->machine->driver_data<namcos86_state>();
187203   switch (offset)
188204   {
189205      case 0:
190         xscroll[layer] = (xscroll[layer]&0xff)|(data<<8);
206         state->xscroll[layer] = (state->xscroll[layer]&0xff)|(data<<8);
191207         break;
192208      case 1:
193         xscroll[layer] = (xscroll[layer]&0xff00)|data;
209         state->xscroll[layer] = (state->xscroll[layer]&0xff00)|data;
194210         break;
195211      case 2:
196         yscroll[layer] = data;
212         state->yscroll[layer] = data;
197213         break;
198214   }
199215}
200216
201217WRITE8_HANDLER( rthunder_scroll0_w )
202218{
203   scroll_w(0,offset,data);
219   scroll_w(space,offset,data,0);
204220}
205221WRITE8_HANDLER( rthunder_scroll1_w )
206222{
207   scroll_w(1,offset,data);
223   scroll_w(space,offset,data,1);
208224}
209225WRITE8_HANDLER( rthunder_scroll2_w )
210226{
211   scroll_w(2,offset,data);
227   scroll_w(space,offset,data,2);
212228}
213229WRITE8_HANDLER( rthunder_scroll3_w )
214230{
215   scroll_w(3,offset,data);
231   scroll_w(space,offset,data,3);
216232}
217233
218234WRITE8_HANDLER( rthunder_backcolor_w )
219235{
220   backcolor = data;
236   namcos86_state *state = space->machine->driver_data<namcos86_state>();
237   state->backcolor = data;
221238}
222239
223240
224static int copy_sprites;
225241
226242READ8_HANDLER( rthunder_spriteram_r )
227243{
228   return rthunder_spriteram[offset];
244   namcos86_state *state = space->machine->driver_data<namcos86_state>();
245   return state->rthunder_spriteram[offset];
229246}
230247
231248WRITE8_HANDLER( rthunder_spriteram_w )
232249{
233   rthunder_spriteram[offset] = data;
250   namcos86_state *state = space->machine->driver_data<namcos86_state>();
251   state->rthunder_spriteram[offset] = data;
234252
235253   /* a write to this offset tells the sprite chip to buffer the sprite list */
236254   if (offset == 0x1ff2)
237      copy_sprites = 1;
255      state->copy_sprites = 1;
238256}
239257
240258
r10886r10887
328346
329347static void set_scroll(running_machine *machine, int layer)
330348{
349   namcos86_state *state = machine->driver_data<namcos86_state>();
331350   static const int xdisp[4] = { 47, 49, 46, 48 };
332351   int scrollx,scrolly;
333352
334   scrollx = xscroll[layer] - xdisp[layer];
335   scrolly = yscroll[layer] + 9;
353   scrollx = state->xscroll[layer] - xdisp[layer];
354   scrolly = state->yscroll[layer] + 9;
336355   if (flip_screen_get(machine))
337356   {
338357      scrollx = -scrollx;
339358      scrolly = -scrolly;
340359   }
341   tilemap_set_scrollx(bg_tilemap[layer], 0, scrollx);
342   tilemap_set_scrolly(bg_tilemap[layer], 0, scrolly);
360   tilemap_set_scrollx(state->bg_tilemap[layer], 0, scrollx);
361   tilemap_set_scrolly(state->bg_tilemap[layer], 0, scrolly);
343362}
344363
345364
r10886r10887
359378
360379   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
361380
362   bitmap_fill(bitmap,cliprect,screen->machine->gfx[0]->color_base + 8*backcolor+7);
381   bitmap_fill(bitmap,cliprect,screen->machine->gfx[0]->color_base + 8*state->backcolor+7);
363382
364383   for (layer = 0;layer < 8;layer++)
365384   {
r10886r10887
367386
368387      for (i = 3;i >= 0;i--)
369388      {
370         if (((xscroll[i] & 0x0e00) >> 9) == layer)
371            tilemap_draw_primask(bitmap,cliprect,bg_tilemap[i],0,layer,0);
389         if (((state->xscroll[i] & 0x0e00) >> 9) == layer)
390            tilemap_draw_primask(bitmap,cliprect,state->bg_tilemap[i],0,layer,0);
372391      }
373392   }
374393
r10886r10887
380399SCREEN_EOF( namcos86 )
381400{
382401   namcos86_state *state = machine->driver_data<namcos86_state>();
383   if (copy_sprites)
402   if (state->copy_sprites)
384403   {
385404      UINT8 *spriteram = state->spriteram;
386405      int i,j;
r10886r10887
391410            spriteram[i+j] = spriteram[i+j - 6];
392411      }
393412
394      copy_sprites = 0;
413      state->copy_sprites = 0;
395414   }
396415}
src/mame/video/galaxian.c
r10886r10887
245245/* global tweaks */
246246UINT8 galaxian_frogger_adjust;
247247UINT8 galaxian_sfx_tilemap;
248UINT8 galaxian_sprite_clip_start;
249UINT8 galaxian_sprite_clip_end;
250248
251249
252250
r10886r10887
427425{
428426   PALETTE_INIT_CALL(galaxian);
429427
430
431428   /* wire mod to connect the bullet blue output to the 220 ohm resistor */
432429   bullet_color[7] = MAKE_RGB(0xef,0xef,0x97);
433430}
r10886r10887
600597{
601598   rectangle clip = *cliprect;
602599   int sprnum;
603   int clip_ofs = (flipscreen_x ? 16 : 0);
604600
605601   /* 16 of the 256 pixels of the sprites are hard-clipped at the line buffer */
606   /* according to the schematics, it should be the first 16 pixels; however, */
607   /* some bootlegs demonstrate that this can be shifted to other positions. */
608   clip.min_x = MAX(clip.min_x, (galaxian_sprite_clip_start - clip_ofs) * GALAXIAN_XSCALE);
609   clip.max_x = MIN(clip.max_x, (galaxian_sprite_clip_end - clip_ofs + 1) * GALAXIAN_XSCALE - 1);
602   /* according to the schematics, it should be the first 16 pixels */
603   clip.min_x = MAX(clip.min_x, (!flipscreen_x) * 16 * GALAXIAN_XSCALE);
604   clip.max_x = MIN(clip.max_x, (256 - flipscreen_x * 16) * GALAXIAN_XSCALE - 1);
610605
611606   /* The line buffer is only written if it contains a '0' currently; */
612607   /* it is cleared during the visible area, and populated during HBLANK */
r10886r10887
623618      UINT8 flipx = base[1] & 0x40;
624619      UINT8 flipy = base[1] & 0x80;
625620      UINT8 color = base[2] & 7;
626      UINT8 sx = base[3];
621      UINT8 sx = base[3] + 1;
627622
628623      /* extend the sprite information */
629624      if (galaxian_extend_sprite_info_ptr != NULL)
r10886r10887
632627      /* apply flipscreen in X direction */
633628      if (flipscreen_x)
634629      {
635         sx = 242 - sx; // + 8 - HOFS
630         sx = 240 - sx;
636631         flipx = !flipx;
637632      }
638633
r10886r10887
12391234
12401235/*************************************
12411236 *
1242 *  Generic extensions
1237 *  Video extensions
12431238 *
12441239 *************************************/
12451240
1241/*** generic ***/
12461242void upper_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
12471243{
12481244   /* tiles are in the upper half of a larger ROM */
12491245   *code += 0x100;
12501246}
12511247
1252
12531248void upper_extend_sprite_info(const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color)
12541249{
12551250   /* sprites are in the upper half of a larger ROM */
r10886r10887
12571252}
12581253
12591254
1260
1261/*************************************
1262 *
1263 *  Frogger extensions
1264 *
1265 *************************************/
1266
1255/*** Frogger ***/
12671256void frogger_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
12681257{
12691258   *color = ((*color >> 1) & 0x03) | ((*color << 2) & 0x04);
r10886r10887
12751264}
12761265
12771266
1278
1279/*************************************
1280 *
1281 *  Ghostmuncher Galaxian extensions
1282 *
1283 *************************************/
1284
1267/*** Ghostmuncher Galaxian ***/
12851268void gmgalax_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
12861269{
12871270   *code |= gfxbank[0] << 9;
r10886r10887
12951278}
12961279
12971280
1298
1299/*************************************
1300 *
1301 *  Pisces extensions
1302 *
1303 *************************************/
1304
1281/*** Pisces ***/
13051282void pisces_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
13061283{
13071284   *code |= gfxbank[0] << 8;
r10886r10887
13131290}
13141291
13151292
1316
1317/*************************************
1318 *
1319 *  Batman Part 2 extensions
1320 *
1321 *************************************/
1322
1293/*** Batman Part 2 ***/
13231294void batman2_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
13241295{
13251296   if (*code & 0x80)
r10886r10887
13271298}
13281299
13291300
1330
1331/*************************************
1332 *
1333 *  Moon Cresta extensions
1334 *
1335 *************************************/
1336
1301/*** Moon Cresta ***/
13371302void mooncrst_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
13381303{
13391304   if (gfxbank[2] && (*code & 0xc0) == 0x80)
r10886r10887
13471312}
13481313
13491314
1350
1351/*************************************
1352 *
1353 *  Moon Quasar extensions
1354 *
1355 *************************************/
1356
1315/*** Moon Quasar ***/
13571316void moonqsr_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
13581317{
13591318   *code |= (attrib & 0x20) << 3;
r10886r10887
13651324}
13661325
13671326
1368
1369/*************************************
1370 *
1371 *  Moon Shuttle extensions
1372 *
1373 *************************************/
1374
1327/*** Moon Shuttle ***/
13751328void mshuttle_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
13761329{
13771330   *code |= (attrib & 0x30) << 4;
r10886r10887
13831336}
13841337
13851338
1386/*************************************
1387 *
1388 *  Calipso extensions
1389 *
1390 *************************************/
1391
1339/*** Calipso ***/
13921340void calipso_extend_sprite_info(const UINT8 *base, UINT8 *sx, UINT8 *sy, UINT8 *flipx, UINT8 *flipy, UINT16 *code, UINT8 *color)
13931341{
13941342   /* same as the others, but no sprite flipping, but instead the bits are used
r10886r10887
13991347   *flipy = 0;
14001348}
14011349
1402/*************************************
1403 *
1404 *  Jumpbug extensions
1405 *
1406 *************************************/
14071350
1351/*** Jumpbug ***/
14081352void jumpbug_extend_tile_info(UINT16 *code, UINT8 *color, UINT8 attrib, UINT8 x)
14091353{
14101354   if ((*code & 0xc0) == 0x80 && (gfxbank[2] & 0x01))
src/mame/video/flower.c
r10886r10887
33#include "emu.h"
44#include "includes/flower.h"
55
6static tilemap_t *flower_bg0_tilemap, *flower_bg1_tilemap, *flower_text_tilemap, *flower_text_right_tilemap;
7UINT8 *flower_textram, *flower_bg0ram, *flower_bg1ram, *flower_bg0_scroll, *flower_bg1_scroll;
86
9
107PALETTE_INIT( flower )
118{
129   int i;
r10886r10887
122119
123120static TILE_GET_INFO( get_bg0_tile_info )
124121{
125   int code = flower_bg0ram[tile_index];
126   int color = flower_bg0ram[tile_index+0x100];
122   flower_state *state = machine->driver_data<flower_state>();
123   int code = state->bg0ram[tile_index];
124   int color = state->bg0ram[tile_index+0x100];
127125   /* Todo - may be tile flip bits? */
128126
129127   SET_TILE_INFO(2, code, color>>4, 0);
r10886r10887
131129
132130static TILE_GET_INFO( get_bg1_tile_info )
133131{
134   int code = flower_bg1ram[tile_index];
135   int color = flower_bg1ram[tile_index+0x100];
132   flower_state *state = machine->driver_data<flower_state>();
133   int code = state->bg1ram[tile_index];
134   int color = state->bg1ram[tile_index+0x100];
136135   /* Todo - may be tile flip bits? */
137136
138137   SET_TILE_INFO(2, code, color>>4, 0);
r10886r10887
140139
141140static TILE_GET_INFO( get_text_tile_info )
142141{
143   int code = flower_textram[tile_index];
144   int color = flower_textram[tile_index+0x400];
142   flower_state *state = machine->driver_data<flower_state>();
143   int code = state->textram[tile_index];
144   int color = state->textram[tile_index+0x400];
145145   /* Todo - may be tile flip bits? */
146146
147147   SET_TILE_INFO(0, code, color>>2, 0);
r10886r10887
149149
150150VIDEO_START(flower)
151151{
152   flower_bg0_tilemap        = tilemap_create(machine, get_bg0_tile_info, tilemap_scan_rows,     16,16,16,16);
153   flower_bg1_tilemap        = tilemap_create(machine, get_bg1_tile_info, tilemap_scan_rows,16,16,16,16);
154   flower_text_tilemap       = tilemap_create(machine, get_text_tile_info,tilemap_scan_rows, 8, 8,32,32);
155   flower_text_right_tilemap = tilemap_create(machine, get_text_tile_info,tilemap_scan_cols, 8, 8, 2,32);
152   flower_state *state = machine->driver_data<flower_state>();
153   state->bg0_tilemap        = tilemap_create(machine, get_bg0_tile_info, tilemap_scan_rows,     16,16,16,16);
154   state->bg1_tilemap        = tilemap_create(machine, get_bg1_tile_info, tilemap_scan_rows,16,16,16,16);
155   state->text_tilemap       = tilemap_create(machine, get_text_tile_info,tilemap_scan_rows, 8, 8,32,32);
156   state->text_right_tilemap = tilemap_create(machine, get_text_tile_info,tilemap_scan_cols, 8, 8, 2,32);
156157
157   tilemap_set_transparent_pen(flower_bg1_tilemap,15);
158   tilemap_set_transparent_pen(flower_text_tilemap,3);
159   tilemap_set_transparent_pen(flower_text_right_tilemap,3);
158   tilemap_set_transparent_pen(state->bg1_tilemap,15);
159   tilemap_set_transparent_pen(state->text_tilemap,3);
160   tilemap_set_transparent_pen(state->text_right_tilemap,3);
160161
161   tilemap_set_scrolly(flower_text_tilemap, 0, 16);
162   tilemap_set_scrolly(flower_text_right_tilemap, 0, 16);
162   tilemap_set_scrolly(state->text_tilemap, 0, 16);
163   tilemap_set_scrolly(state->text_right_tilemap, 0, 16);
163164}
164165
165166SCREEN_UPDATE( flower )
166167{
168   flower_state *state = screen->machine->driver_data<flower_state>();
167169   rectangle myclip = *cliprect;
168170
169   tilemap_set_scrolly(flower_bg0_tilemap,0, flower_bg0_scroll[0]+16);
170   tilemap_set_scrolly(flower_bg1_tilemap,0, flower_bg1_scroll[0]+16);
171   tilemap_set_scrolly(state->bg0_tilemap,0, state->bg0_scroll[0]+16);
172   tilemap_set_scrolly(state->bg1_tilemap,0, state->bg1_scroll[0]+16);
171173
172   tilemap_draw(bitmap,cliprect,flower_bg0_tilemap,0,0);
173   tilemap_draw(bitmap,cliprect,flower_bg1_tilemap,0,0);
174   tilemap_draw(bitmap,cliprect,state->bg0_tilemap,0,0);
175   tilemap_draw(bitmap,cliprect,state->bg1_tilemap,0,0);
174176
175177   draw_sprites(screen->machine,bitmap,cliprect);
176178
r10886r10887
185187      myclip.max_x = cliprect->max_x;
186188   }
187189
188   tilemap_draw(bitmap,cliprect,flower_text_tilemap,0,0);
189   tilemap_draw(bitmap,&myclip,flower_text_right_tilemap,0,0);
190   tilemap_draw(bitmap,cliprect,state->text_tilemap,0,0);
191   tilemap_draw(bitmap,&myclip,state->text_right_tilemap,0,0);
190192   return 0;
191193}
192194
193195WRITE8_HANDLER( flower_textram_w )
194196{
195   flower_textram[offset] = data;
196   tilemap_mark_tile_dirty(flower_text_tilemap, offset);
197   tilemap_mark_all_tiles_dirty(flower_text_right_tilemap);
197   flower_state *state = space->machine->driver_data<flower_state>();
198   state->textram[offset] = data;
199   tilemap_mark_tile_dirty(state->text_tilemap, offset);
200   tilemap_mark_all_tiles_dirty(state->text_right_tilemap);
198201}
199202
200203WRITE8_HANDLER( flower_bg0ram_w )
201204{
202   flower_bg0ram[offset] = data;
203   tilemap_mark_tile_dirty(flower_bg0_tilemap, offset & 0x1ff);
205   flower_state *state = space->machine->driver_data<flower_state>();
206   state->bg0ram[offset] = data;
207   tilemap_mark_tile_dirty(state->bg0_tilemap, offset & 0x1ff);
204208}
205209
206210WRITE8_HANDLER( flower_bg1ram_w )
207211{
208   flower_bg1ram[offset] = data;
209   tilemap_mark_tile_dirty(flower_bg1_tilemap, offset & 0x1ff);
212   flower_state *state = space->machine->driver_data<flower_state>();
213   state->bg1ram[offset] = data;
214   tilemap_mark_tile_dirty(state->bg1_tilemap, offset & 0x1ff);
210215}
211216
212217WRITE8_HANDLER( flower_flipscreen_w )
src/mame/video/astrocde.c
r10886r10887
305305{
306306   astrocde_state *state = screen->machine->driver_data<astrocde_state>();
307307   UINT8 *videoram = state->videoram;
308   UINT32 sparklebase = 0;
309   const int colormask = (astrocade_video_config & AC_MONITOR_BW) ? 0 : 0x1f0;
308310   int xystep = 2 - video_mode;
309   UINT32 sparklebase = 0;
310311   int y;
311312
312313   /* compute the starting point of sparkle for the current frame */
r10886r10887
349350         for (xx = 0; xx < 4; xx++)
350351         {
351352            UINT8 pixdata = (data >> 6) & 3;
352            int coldata = colorbase[pixdata] << 1;
353            int luma = coldata & 0x0f;
353            int colordata = colorbase[pixdata] << 1;
354            int luma = colordata & 0x0f;
354355            rgb_t color;
355356
356357            /* handle stars/sparkle */
r10886r10887
363364                  if (pixdata != 0 || (sparklestar[staroffs] & 0x10))
364365                     luma = sparklestar[sparkleoffs] & 0x0f;
365366                  else if (pixdata == 0)
366                     coldata = luma = 0;
367                     colordata = luma = 0;
367368               }
368369
369370               /* update sparkle/star offsets */
r10886r10887
371372               if (++sparkleoffs >= RNG_PERIOD)
372373                  sparkleoffs = 0;
373374            }
374            color = (coldata & 0x1f0) | luma;
375            color = (colordata & colormask) | luma;
375376
376377            /* store the final color to the destination and shift */
377378            *dest++ = color;
src/mame/video/konamiic.c
r10886r10887
4444  Koi no Hotrock
4545Mr Kabuki/Mr Goemon GX621*1986     Z80           005849
4646Jackal              GX631*1986    6809           005885(x2)               007327 007343 (address decoder)
47Contra / Gryzor     GX633*1987    6809?          007121(x2)               007593
47Contra / Gryzor     GX633*1987    6309           007121(x2)               007593
4848Flak Attack         GX669*1987    6309           007121                   007327 007452
4949Devil World / Dark  GX687*1987 2x68000           TWIN16
5050  Adventure / Majuu no Oukoku
src/mame/video/thedeep.c
r10886r10887
3131#include "emu.h"
3232#include "includes/thedeep.h"
3333
34/* Variables only used here: */
3534
36static tilemap_t *tilemap_0,*tilemap_1;
37
38/* Variables & functions needed by drivers: */
39
40UINT8 *thedeep_vram_0, *thedeep_vram_1;
41UINT8 *thedeep_scroll, *thedeep_scroll2;
42
43
4435/***************************************************************************
4536
4637                        Callbacks for the TileMap code
r10886r10887
5445
5546static TILE_GET_INFO( get_tile_info_0 )
5647{
57   UINT8 code   =   thedeep_vram_0[ tile_index * 2 + 0 ];
58   UINT8 color   =   thedeep_vram_0[ tile_index * 2 + 1 ];
48   thedeep_state *state = machine->driver_data<thedeep_state>();
49   UINT8 code   =   state->vram_0[ tile_index * 2 + 0 ];
50   UINT8 color   =   state->vram_0[ tile_index * 2 + 1 ];
5951   SET_TILE_INFO(
6052         1,
6153         code + (color << 8),
r10886r10887
6557
6658static TILE_GET_INFO( get_tile_info_1 )
6759{
68   UINT8 code   =   thedeep_vram_1[ tile_index * 2 + 0 ];
69   UINT8 color   =   thedeep_vram_1[ tile_index * 2 + 1 ];
60   thedeep_state *state = machine->driver_data<thedeep_state>();
61   UINT8 code   =   state->vram_1[ tile_index * 2 + 0 ];
62   UINT8 color   =   state->vram_1[ tile_index * 2 + 1 ];
7063   SET_TILE_INFO(
7164         2,
7265         code + (color << 8),
r10886r10887
7669
7770WRITE8_HANDLER( thedeep_vram_0_w )
7871{
79   thedeep_vram_0[offset] = data;
80   tilemap_mark_tile_dirty(tilemap_0, offset / 2);
72   thedeep_state *state = space->machine->driver_data<thedeep_state>();
73   state->vram_0[offset] = data;
74   tilemap_mark_tile_dirty(state->tilemap_0, offset / 2);
8175}
8276
8377WRITE8_HANDLER( thedeep_vram_1_w )
8478{
85   thedeep_vram_1[offset] = data;
86   tilemap_mark_tile_dirty(tilemap_1, offset / 2);
79   thedeep_state *state = space->machine->driver_data<thedeep_state>();
80   state->vram_1[offset] = data;
81   tilemap_mark_tile_dirty(state->tilemap_1, offset / 2);
8782}
8883
8984
r10886r10887
108103
109104VIDEO_START( thedeep )
110105{
111   tilemap_0  = tilemap_create(machine, get_tile_info_0,tilemap_scan_rows_back,16,16,0x20,0x20);
112   tilemap_1  = tilemap_create(machine, get_tile_info_1,tilemap_scan_rows,8,8,0x20,0x20);
106   thedeep_state *state = machine->driver_data<thedeep_state>();
107   state->tilemap_0  = tilemap_create(machine, get_tile_info_0,tilemap_scan_rows_back,16,16,0x20,0x20);
108   state->tilemap_1  = tilemap_create(machine, get_tile_info_1,tilemap_scan_rows,8,8,0x20,0x20);
113109
114   tilemap_set_transparent_pen( tilemap_0,  0 );
115   tilemap_set_transparent_pen( tilemap_1,  0 );
110   tilemap_set_transparent_pen( state->tilemap_0,  0 );
111   tilemap_set_transparent_pen( state->tilemap_1,  0 );
116112
117   tilemap_set_scroll_cols(tilemap_0, 0x20);   // column scroll for the background
113   tilemap_set_scroll_cols(state->tilemap_0, 0x20);   // column scroll for the background
118114}
119115
120116/***************************************************************************
r10886r10887
215211
216212SCREEN_UPDATE( thedeep )
217213{
218   int scrollx = thedeep_scroll[0] + (thedeep_scroll[1]<<8);
219   int scrolly = thedeep_scroll[2] + (thedeep_scroll[3]<<8);
214   thedeep_state *state = screen->machine->driver_data<thedeep_state>();
215   int scrollx = state->scroll[0] + (state->scroll[1]<<8);
216   int scrolly = state->scroll[2] + (state->scroll[3]<<8);
220217   int x;
221218
222   tilemap_set_scrollx(tilemap_0, 0, scrollx);
219   tilemap_set_scrollx(state->tilemap_0, 0, scrollx);
223220
224221   for (x = 0; x < 0x20; x++)
225222   {
226      int y = thedeep_scroll2[x*2+0] + (thedeep_scroll2[x*2+1]<<8);
227      tilemap_set_scrolly(tilemap_0, x, y + scrolly);
223      int y = state->scroll2[x*2+0] + (state->scroll2[x*2+1]<<8);
224      tilemap_set_scrolly(state->tilemap_0, x, y + scrolly);
228225   }
229226
230227   bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
231228
232   tilemap_draw(bitmap,cliprect,tilemap_0,0,0);
229   tilemap_draw(bitmap,cliprect,state->tilemap_0,0,0);
233230   draw_sprites(screen->machine, bitmap,cliprect);
234   tilemap_draw(bitmap,cliprect,tilemap_1,0,0);
231   tilemap_draw(bitmap,cliprect,state->tilemap_1,0,0);
235232   return 0;
236233}
src/mame/video/konicdev.c
r10886r10887
4444  Koi no Hotrock
4545Mr Kabuki/Mr Goemon GX621*1986     Z80           005849
4646Jackal              GX631*1986    6809           005885(x2)               007327 007343 (address decoder)
47Contra / Gryzor     GX633*1987    6809?          007121(x2)               007593
47Contra / Gryzor     GX633*1987    6309           007121(x2)               007593
4848Flak Attack         GX669*1987    6309           007121                   007327 007452
4949Devil World / Dark  GX687*1987 2x68000           TWIN16
5050  Adventure / Majuu no Oukoku
src/mame/video/taito_f3.c
r10886r10887
212212#define DARIUSG_KLUDGE
213213//#define DEBUG_F3 1
214214
215static tilemap_t *pf1_tilemap,*pf2_tilemap,*pf3_tilemap,*pf4_tilemap;
216static tilemap_t *pixel_layer,*vram_layer;
217static UINT32 *spriteram32_buffered;
218static UINT32 f3_control_0[8];
219static UINT32 f3_control_1[8];
220static int flipscreen;
221static UINT8 sprite_extra_planes;
222static UINT8 sprite_pen_mask;
223215
224static UINT32 *f3_pf_data_1,*f3_pf_data_2,*f3_pf_data_3,*f3_pf_data_4;
225
226UINT32 *f3_vram,*f3_line_ram;
227UINT32 *f3_pf_data,*f3_pivot_ram;
228
229static int f3_skip_this_frame;
230
231216/* Game specific data, some of this can be
232217removed when the software values are figured out */
233218struct F3config
r10886r10887
237222   int sprite_lag;
238223};
239224
240static const struct F3config *f3_game_config;
241
242225static const struct F3config f3_config_table[] =
243226{
244227   /* Name    Extend  Lag */
r10886r10887
286269   int zoomx,zoomy;
287270   int pri;
288271};
289static struct tempsprite *spritelist;
290static const struct tempsprite *sprite_end;
291272
292273static void get_sprite_info(running_machine *machine, const UINT32 *spriteram32_ptr);
293static int sprite_lag;
294static UINT8 sprite_pri_usage=0;
295274
296275struct f3_playfield_line_inf
297276{
r10886r10887
3283071--------    opaque line
329308*/
330309
331static struct f3_playfield_line_inf *pf_line_inf;
332static struct f3_spritealpha_line_inf *sa_line_inf;
333310
334
335static bitmap_t *pri_alp_bitmap;
336311/*
337312pri_alp_bitmap
338313---- ---1    sprite priority 0
r10886r10887
3453201--- ----    alpha level b b000
3463211111 1111    opaque pixel
347322*/
348static int f3_alpha_level_2as;
349static int f3_alpha_level_2ad;
350static int f3_alpha_level_3as;
351static int f3_alpha_level_3ad;
352static int f3_alpha_level_2bs;
353static int f3_alpha_level_2bd;
354static int f3_alpha_level_3bs;
355static int f3_alpha_level_3bd;
356static int alpha_level_last;
357323
358static void init_alpha_blend_func(void);
324static void init_alpha_blend_func(running_machine *machine);
359325
360static int width_mask;
361static int twidth_mask;
362static int twidth_mask_bit;
363
364static UINT8 *tile_opaque_sp;
365static UINT8 *tile_opaque_pf[4];
366
367
368static UINT8 add_sat[256][256];
369
370static int alpha_s_1_1;
371static int alpha_s_1_2;
372static int alpha_s_1_4;
373static int alpha_s_1_5;
374static int alpha_s_1_6;
375static int alpha_s_1_8;
376static int alpha_s_1_9;
377static int alpha_s_1_a;
378
379static int alpha_s_2a_0;
380static int alpha_s_2a_4;
381static int alpha_s_2a_8;
382
383static int alpha_s_2b_0;
384static int alpha_s_2b_4;
385static int alpha_s_2b_8;
386
387static int alpha_s_3a_0;
388static int alpha_s_3a_1;
389static int alpha_s_3a_2;
390
391static int alpha_s_3b_0;
392static int alpha_s_3b_1;
393static int alpha_s_3b_2;
394
395static UINT32 dval;
396static UINT8 pval;
397static UINT8 tval;
398static UINT8 pdest_2a;
399static UINT8 pdest_2b;
400static int tr_2a;
401static int tr_2b;
402static UINT8 pdest_3a;
403static UINT8 pdest_3b;
404static int tr_3a;
405static int tr_3b;
406
407static int (*dpix_n[8][16])(UINT32 s_pix);
408static int (**dpix_lp[5])(UINT32 s_pix);
409static int (**dpix_sp[9])(UINT32 s_pix);
410
411
412326/******************************************************************************/
413327
414328static void print_debug_info(running_machine *machine, bitmap_t *bitmap)
415329{
330   taito_f3_state *state = machine->driver_data<taito_f3_state>();
331   UINT32 *f3_line_ram = state->f3_line_ram;
416332   int l[16];
417333   char buf[64*16];
418334   char *bufptr = buf;
419335
420   bufptr += sprintf(bufptr,"%04X %04X %04X %04X\n",f3_control_0[0]>>22,(f3_control_0[0]&0xffff)>>6,f3_control_0[1]>>22,(f3_control_0[1]&0xffff)>>6);
421   bufptr += sprintf(bufptr,"%04X %04X %04X %04X\n",f3_control_0[2]>>23,(f3_control_0[2]&0xffff)>>7,f3_control_0[3]>>23,(f3_control_0[3]&0xffff)>>7);
422   bufptr += sprintf(bufptr,"%04X %04X %04X %04X\n",f3_control_1[0]>>16,f3_control_1[0]&0xffff,f3_control_1[1]>>16,f3_control_1[1]&0xffff);
423   bufptr += sprintf(bufptr,"%04X %04X %04X %04X\n",f3_control_1[2]>>16,f3_control_1[2]&0xffff,f3_control_1[3]>>16,f3_control_1[3]&0xffff);
336   bufptr += sprintf(bufptr,"%04X %04X %04X %04X\n",state->f3_control_0[0]>>22,(state->f3_control_0[0]&0xffff)>>6,state->f3_control_0[1]>>22,(state->f3_control_0[1]&0xffff)>>6);
337   bufptr += sprintf(bufptr,"%04X %04X %04X %04X\n",state->f3_control_0[2]>>23,(state->f3_control_0[2]&0xffff)>>7,state->f3_control_0[3]>>23,(state->f3_control_0[3]&0xffff)>>7);
338   bufptr += sprintf(bufptr,"%04X %04X %04X %04X\n",state->f3_control_1[0]>>16,state->f3_control_1[0]&0xffff,state->f3_control_1[1]>>16,state->f3_control_1[1]&0xffff);
339   bufptr += sprintf(bufptr,"%04X %04X %04X %04X\n",state->f3_control_1[2]>>16,state->f3_control_1[2]&0xffff,state->f3_control_1[3]>>16,state->f3_control_1[3]&0xffff);
424340
425   bufptr += sprintf(bufptr,"%04X %04X %04X %04X %04X %04X %04X %04X\n",spriteram32_buffered[0]>>16,spriteram32_buffered[0]&0xffff,spriteram32_buffered[1]>>16,spriteram32_buffered[1]&0xffff,spriteram32_buffered[2]>>16,spriteram32_buffered[2]&0xffff,spriteram32_buffered[3]>>16,spriteram32_buffered[3]&0xffff);
426   bufptr += sprintf(bufptr,"%04X %04X %04X %04X %04X %04X %04X %04X\n",spriteram32_buffered[4]>>16,spriteram32_buffered[4]&0xffff,spriteram32_buffered[5]>>16,spriteram32_buffered[5]&0xffff,spriteram32_buffered[6]>>16,spriteram32_buffered[6]&0xffff,spriteram32_buffered[7]>>16,spriteram32_buffered[7]&0xffff);
427   bufptr += sprintf(bufptr,"%04X %04X %04X %04X %04X %04X %04X %04X\n",spriteram32_buffered[8]>>16,spriteram32_buffered[8]&0xffff,spriteram32_buffered[9]>>16,spriteram32_buffered[9]&0xffff,spriteram32_buffered[10]>>16,spriteram32_buffered[10]&0xffff,spriteram32_buffered[11]>>16,spriteram32_buffered[11]&0xffff);
341   bufptr += sprintf(bufptr,"%04X %04X %04X %04X %04X %04X %04X %04X\n",state->spriteram32_buffered[0]>>16,state->spriteram32_buffered[0]&0xffff,state->spriteram32_buffered[1]>>16,state->spriteram32_buffered[1]&0xffff,state->spriteram32_buffered[2]>>16,state->spriteram32_buffered[2]&0xffff,state->spriteram32_buffered[3]>>16,state->spriteram32_buffered[3]&0xffff);
342   bufptr += sprintf(bufptr,"%04X %04X %04X %04X %04X %04X %04X %04X\n",state->spriteram32_buffered[4]>>16,state->spriteram32_buffered[4]&0xffff,state->spriteram32_buffered[5]>>16,state->spriteram32_buffered[5]&0xffff,state->spriteram32_buffered[6]>>16,state->spriteram32_buffered[6]&0xffff,state->spriteram32_buffered[7]>>16,state->spriteram32_buffered[7]&0xffff);
343   bufptr += sprintf(bufptr,"%04X %04X %04X %04X %04X %04X %04X %04X\n",state->spriteram32_buffered[8]>>16,state->spriteram32_buffered[8]&0xffff,state->spriteram32_buffered[9]>>16,state->spriteram32_buffered[9]&0xffff,state->spriteram32_buffered[10]>>16,state->spriteram32_buffered[10]&0xffff,state->spriteram32_buffered[11]>>16,state->spriteram32_buffered[11]&0xffff);
428344
429345   l[0]=f3_line_ram[0x0040]&0xffff;
430346   l[1]=f3_line_ram[0x00c0]&0xffff;
r10886r10887
505421
506422static TILE_GET_INFO( get_tile_info1 )
507423{
508   get_tile_info(machine,tileinfo,tile_index,f3_pf_data_1);
424   taito_f3_state *state = machine->driver_data<taito_f3_state>();
425   get_tile_info(machine,tileinfo,tile_index,state->f3_pf_data_1);
509426}
510427
511428static TILE_GET_INFO( get_tile_info2 )
512429{
513   get_tile_info(machine,tileinfo,tile_index,f3_pf_data_2);
430   taito_f3_state *state = machine->driver_data<taito_f3_state>();
431   get_tile_info(machine,tileinfo,tile_index,state->f3_pf_data_2);
514432}
515433
516434static TILE_GET_INFO( get_tile_info3 )
517435{
518   get_tile_info(machine,tileinfo,tile_index,f3_pf_data_3);
436   taito_f3_state *state = machine->driver_data<taito_f3_state>();
437   get_tile_info(machine,tileinfo,tile_index,state->f3_pf_data_3);
519438}
520439
521440static TILE_GET_INFO( get_tile_info4 )
522441{
523   get_tile_info(machine,tileinfo,tile_index,f3_pf_data_4);
442   taito_f3_state *state = machine->driver_data<taito_f3_state>();
443   get_tile_info(machine,tileinfo,tile_index,state->f3_pf_data_4);
524444}
525445
526446static TILE_GET_INFO( get_tile_info_vram )
r10886r10887
551471   UINT32 *videoram = state->videoram;
552472   int vram_tile,col_off;
553473   int flags=0;
554   int y_offs=(f3_control_1[2]&0x1ff);
555   if (flipscreen) y_offs+=0x100;
474   int y_offs=(state->f3_control_1[2]&0x1ff);
475   if (state->flipscreen) y_offs+=0x100;
556476
557477   /* Colour is shared with VRAM layer */
558478   if ((((tile_index%32)*8 + y_offs)&0x1ff)>0xff)
r10886r10887
580500SCREEN_EOF( f3 )
581501{
582502   taito_f3_state *state = machine->driver_data<taito_f3_state>();
583   if (sprite_lag==2)
503   if (state->sprite_lag==2)
584504   {
585505      if (machine->video().skip_this_frame() == 0)
586506      {
587         get_sprite_info(machine, spriteram32_buffered);
507         get_sprite_info(machine, state->spriteram32_buffered);
588508      }
589      memcpy(spriteram32_buffered,state->spriteram,state->spriteram_size);
509      memcpy(state->spriteram32_buffered,state->spriteram,state->spriteram_size);
590510   }
591   else if (sprite_lag==1)
511   else if (state->sprite_lag==1)
592512   {
593513      if (machine->video().skip_this_frame() == 0)
594514      {
r10886r10887
603523   const struct F3config *pCFG=&f3_config_table[0];
604524   int width, height, i;
605525
606   f3_alpha_level_2as=127;
607   f3_alpha_level_2ad=127;
608   f3_alpha_level_3as=127;
609   f3_alpha_level_3ad=127;
610   f3_alpha_level_2bs=127;
611   f3_alpha_level_2bd=127;
612   f3_alpha_level_3bs=127;
613   f3_alpha_level_3bd=127;
614   alpha_level_last = -1;
526   state->f3_alpha_level_2as=127;
527   state->f3_alpha_level_2ad=127;
528   state->f3_alpha_level_3as=127;
529   state->f3_alpha_level_3ad=127;
530   state->f3_alpha_level_2bs=127;
531   state->f3_alpha_level_2bd=127;
532   state->f3_alpha_level_3bs=127;
533   state->f3_alpha_level_3bd=127;
534   state->alpha_level_last = -1;
615535
616   pdest_2a = 0x10;
617   pdest_2b = 0x20;
618   tr_2a = 0;
619   tr_2b = 1;
620   pdest_3a = 0x40;
621   pdest_3b = 0x80;
622   tr_3a = 0;
623   tr_3b = 1;
536   state->pdest_2a = 0x10;
537   state->pdest_2b = 0x20;
538   state->tr_2a = 0;
539   state->tr_2b = 1;
540   state->pdest_3a = 0x40;
541   state->pdest_3b = 0x80;
542   state->tr_3a = 0;
543   state->tr_3b = 1;
624544
625   spritelist=0;
626   spriteram32_buffered=0;
627   pf_line_inf=0;
628   pri_alp_bitmap=0;
629   tile_opaque_sp=0;
545   state->spritelist=0;
546   state->spriteram32_buffered=0;
547   state->pf_line_inf=0;
548   state->pri_alp_bitmap=0;
549   state->tile_opaque_sp=0;
630550
631551   /* Setup individual game */
632552   do {
633      if (pCFG->name==f3_game)
553      if (pCFG->name==state->f3_game)
634554      {
635555         break;
636556      }
637557      pCFG++;
638558   } while(pCFG->name);
639559
640   f3_game_config=pCFG;
560   state->f3_game_config=pCFG;
641561
642   if (f3_game_config->extend) {
643      pf1_tilemap = tilemap_create(machine, get_tile_info1,tilemap_scan_rows,16,16,64,32);
644      pf2_tilemap = tilemap_create(machine, get_tile_info2,tilemap_scan_rows,16,16,64,32);
645      pf3_tilemap = tilemap_create(machine, get_tile_info3,tilemap_scan_rows,16,16,64,32);
646      pf4_tilemap = tilemap_create(machine, get_tile_info4,tilemap_scan_rows,16,16,64,32);
562   if (state->f3_game_config->extend) {
563      state->pf1_tilemap = tilemap_create(machine, get_tile_info1,tilemap_scan_rows,16,16,64,32);
564      state->pf2_tilemap = tilemap_create(machine, get_tile_info2,tilemap_scan_rows,16,16,64,32);
565      state->pf3_tilemap = tilemap_create(machine, get_tile_info3,tilemap_scan_rows,16,16,64,32);
566      state->pf4_tilemap = tilemap_create(machine, get_tile_info4,tilemap_scan_rows,16,16,64,32);
647567
648      f3_pf_data_1=f3_pf_data+0x0000;
649      f3_pf_data_2=f3_pf_data+0x0800;
650      f3_pf_data_3=f3_pf_data+0x1000;
651      f3_pf_data_4=f3_pf_data+0x1800;
568      state->f3_pf_data_1=state->f3_pf_data+0x0000;
569      state->f3_pf_data_2=state->f3_pf_data+0x0800;
570      state->f3_pf_data_3=state->f3_pf_data+0x1000;
571      state->f3_pf_data_4=state->f3_pf_data+0x1800;
652572
653      width_mask=0x3ff;
654      twidth_mask=0x3f;
655      twidth_mask_bit=6;
573      state->width_mask=0x3ff;
574      state->twidth_mask=0x3f;
575      state->twidth_mask_bit=6;
656576
657577   } else {
658      pf1_tilemap = tilemap_create(machine, get_tile_info1,tilemap_scan_rows,16,16,32,32);
659      pf2_tilemap = tilemap_create(machine, get_tile_info2,tilemap_scan_rows,16,16,32,32);
660      pf3_tilemap = tilemap_create(machine, get_tile_info3,tilemap_scan_rows,16,16,32,32);
661      pf4_tilemap = tilemap_create(machine, get_tile_info4,tilemap_scan_rows,16,16,32,32);
578      state->pf1_tilemap = tilemap_create(machine, get_tile_info1,tilemap_scan_rows,16,16,32,32);
579      state->pf2_tilemap = tilemap_create(machine, get_tile_info2,tilemap_scan_rows,16,16,32,32);
580      state->pf3_tilemap = tilemap_create(machine, get_tile_info3,tilemap_scan_rows,16,16,32,32);
581      state->pf4_tilemap = tilemap_create(machine, get_tile_info4,tilemap_scan_rows,16,16,32,32);
662582
663      f3_pf_data_1=f3_pf_data+0x0000;
664      f3_pf_data_2=f3_pf_data+0x0400;
665      f3_pf_data_3=f3_pf_data+0x0800;
666      f3_pf_data_4=f3_pf_data+0x0c00;
583      state->f3_pf_data_1=state->f3_pf_data+0x0000;
584      state->f3_pf_data_2=state->f3_pf_data+0x0400;
585      state->f3_pf_data_3=state->f3_pf_data+0x0800;
586      state->f3_pf_data_4=state->f3_pf_data+0x0c00;
667587
668      width_mask=0x1ff;
669      twidth_mask=0x1f;
670      twidth_mask_bit=5;
588      state->width_mask=0x1ff;
589      state->twidth_mask=0x1f;
590      state->twidth_mask_bit=5;
671591   }
672592
673   spriteram32_buffered = auto_alloc_array(machine, UINT32, 0x10000/4);
674   spritelist = auto_alloc_array(machine, struct tempsprite, 0x400);
675   sprite_end = spritelist;
676   vram_layer = tilemap_create(machine, get_tile_info_vram,tilemap_scan_rows,8,8,64,64);
677   pixel_layer = tilemap_create(machine, get_tile_info_pixel,tilemap_scan_cols,8,8,64,32);
678   pf_line_inf = auto_alloc_array(machine, struct f3_playfield_line_inf, 5);
679   sa_line_inf = auto_alloc_array(machine, struct f3_spritealpha_line_inf, 1);
593   state->spriteram32_buffered = auto_alloc_array(machine, UINT32, 0x10000/4);
594   state->spritelist = auto_alloc_array(machine, struct tempsprite, 0x400);
595   state->sprite_end = state->spritelist;
596   state->vram_layer = tilemap_create(machine, get_tile_info_vram,tilemap_scan_rows,8,8,64,64);
597   state->pixel_layer = tilemap_create(machine, get_tile_info_pixel,tilemap_scan_cols,8,8,64,32);
598   state->pf_line_inf = auto_alloc_array(machine, struct f3_playfield_line_inf, 5);
599   state->sa_line_inf = auto_alloc_array(machine, struct f3_spritealpha_line_inf, 1);
680600   width = machine->primary_screen->width();
681601   height = machine->primary_screen->height();
682   pri_alp_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED8 );
683   tile_opaque_sp = auto_alloc_array(machine, UINT8, machine->gfx[2]->total_elements);
602   state->pri_alp_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED8 );
603   state->tile_opaque_sp = auto_alloc_array(machine, UINT8, machine->gfx[2]->total_elements);
684604   for (i=0; i<4; i++)
685      tile_opaque_pf[i] = auto_alloc_array(machine, UINT8, machine->gfx[1]->total_elements);
605      state->tile_opaque_pf[i] = auto_alloc_array(machine, UINT8, machine->gfx[1]->total_elements);
686606
687   tilemap_set_transparent_pen(pf1_tilemap,0);
688   tilemap_set_transparent_pen(pf2_tilemap,0);
689   tilemap_set_transparent_pen(pf3_tilemap,0);
690   tilemap_set_transparent_pen(pf4_tilemap,0);
691   tilemap_set_transparent_pen(vram_layer,0);
692   tilemap_set_transparent_pen(pixel_layer,0);
607   tilemap_set_transparent_pen(state->pf1_tilemap,0);
608   tilemap_set_transparent_pen(state->pf2_tilemap,0);
609   tilemap_set_transparent_pen(state->pf3_tilemap,0);
610   tilemap_set_transparent_pen(state->pf4_tilemap,0);
611   tilemap_set_transparent_pen(state->vram_layer,0);
612   tilemap_set_transparent_pen(state->pixel_layer,0);
693613
694614   /* Palettes have 4 bpp indexes despite up to 6 bpp data. The unused */
695615   /* top bits in the gfx data are cleared later.                      */
696616   machine->gfx[1]->color_granularity=16;
697617   machine->gfx[2]->color_granularity=16;
698618
699   flipscreen = 0;
700   memset(spriteram32_buffered,0,state->spriteram_size);
619   state->flipscreen = 0;
620   memset(state->spriteram32_buffered,0,state->spriteram_size);
701621   memset(state->spriteram,0,state->spriteram_size);
702622
703   state_save_register_global_array(machine, f3_control_0);
704   state_save_register_global_array(machine, f3_control_1);
623   state_save_register_global_array(machine, state->f3_control_0);
624   state_save_register_global_array(machine, state->f3_control_1);
705625
706   gfx_element_set_source(machine->gfx[0], (UINT8 *)f3_vram);
707   gfx_element_set_source(machine->gfx[3], (UINT8 *)f3_pivot_ram);
626   gfx_element_set_source(machine->gfx[0], (UINT8 *)state->f3_vram);
627   gfx_element_set_source(machine->gfx[3], (UINT8 *)state->f3_pivot_ram);
708628
709   f3_skip_this_frame=0;
629   state->f3_skip_this_frame=0;
710630
711   sprite_lag=f3_game_config->sprite_lag;
631   state->sprite_lag=state->f3_game_config->sprite_lag;
712632
713   init_alpha_blend_func();
633   init_alpha_blend_func(machine);
714634
715635   {
716636      const gfx_element *sprite_gfx = machine->gfx[2];
r10886r10887
730650            }
731651            dp += sprite_gfx->line_modulo;
732652         }
733         if(chk_trans_or_opa==1) tile_opaque_sp[c]=1;
734         else               tile_opaque_sp[c]=0;
653         if(chk_trans_or_opa==1) state->tile_opaque_sp[c]=1;
654         else               state->tile_opaque_sp[c]=0;
735655      }
736656   }
737657
r10886r10887
762682               }
763683               dp += pf_gfx->line_modulo;
764684            }
765            tile_opaque_pf[extra_planes][c]=chk_trans_or_opa;
685            state->tile_opaque_pf[extra_planes][c]=chk_trans_or_opa;
766686         }
767687      }
768688   }
r10886r10887
772692
773693WRITE32_HANDLER( f3_pf_data_w )
774694{
775   COMBINE_DATA(&f3_pf_data[offset]);
695   taito_f3_state *state = space->machine->driver_data<taito_f3_state>();
696   COMBINE_DATA(&state->f3_pf_data[offset]);
776697
777   if (f3_game_config->extend) {
778      if (offset<0x800) tilemap_mark_tile_dirty(pf1_tilemap,offset-0x0000);
779      else if (offset<0x1000) tilemap_mark_tile_dirty(pf2_tilemap,offset-0x0800);
780      else if (offset<0x1800) tilemap_mark_tile_dirty(pf3_tilemap,offset-0x1000);
781      else if (offset<0x2000) tilemap_mark_tile_dirty(pf4_tilemap,offset-0x1800);
698   if (state->f3_game_config->extend) {
699      if (offset<0x800) tilemap_mark_tile_dirty(state->pf1_tilemap,offset-0x0000);
700      else if (offset<0x1000) tilemap_mark_tile_dirty(state->pf2_tilemap,offset-0x0800);
701      else if (offset<0x1800) tilemap_mark_tile_dirty(state->pf3_tilemap,offset-0x1000);
702      else if (offset<0x2000) tilemap_mark_tile_dirty(state->pf4_tilemap,offset-0x1800);
782703   } else {
783      if (offset<0x400) tilemap_mark_tile_dirty(pf1_tilemap,offset-0x0000);
784      else if (offset<0x800) tilemap_mark_tile_dirty(pf2_tilemap,offset-0x0400);
785      else if (offset<0xc00) tilemap_mark_tile_dirty(pf3_tilemap,offset-0x0800);
786      else if (offset<0x1000) tilemap_mark_tile_dirty(pf4_tilemap,offset-0xc00);
704      if (offset<0x400) tilemap_mark_tile_dirty(state->pf1_tilemap,offset-0x0000);
705      else if (offset<0x800) tilemap_mark_tile_dirty(state->pf2_tilemap,offset-0x0400);
706      else if (offset<0xc00) tilemap_mark_tile_dirty(state->pf3_tilemap,offset-0x0800);
707      else if (offset<0x1000) tilemap_mark_tile_dirty(state->pf4_tilemap,offset-0xc00);
787708   }
788709}
789710
790711WRITE32_HANDLER( f3_control_0_w )
791712{
792   COMBINE_DATA(&f3_control_0[offset]);
713   taito_f3_state *state = space->machine->driver_data<taito_f3_state>();
714   COMBINE_DATA(&state->f3_control_0[offset]);
793715}
794716
795717WRITE32_HANDLER( f3_control_1_w )
796718{
797   COMBINE_DATA(&f3_control_1[offset]);
719   taito_f3_state *state = space->machine->driver_data<taito_f3_state>();
720   COMBINE_DATA(&state->f3_control_1[offset]);
798721}
799722
800723WRITE32_HANDLER( f3_videoram_w )
r10886r10887
804727   int tile,col_off;
805728   COMBINE_DATA(&videoram[offset]);
806729
807   tilemap_mark_tile_dirty(vram_layer,offset<<1);
808   tilemap_mark_tile_dirty(vram_layer,(offset<<1)+1);
730   tilemap_mark_tile_dirty(state->vram_layer,offset<<1);
731   tilemap_mark_tile_dirty(state->vram_layer,(offset<<1)+1);
809732
810733   if (offset>0x3ff) offset-=0x400;
811734
812735   tile=offset<<1;
813736   col_off=((tile&0x3f)*32)+((tile&0xfc0)>>6);
814737
815   tilemap_mark_tile_dirty(pixel_layer,col_off);
816   tilemap_mark_tile_dirty(pixel_layer,col_off+32);
738   tilemap_mark_tile_dirty(state->pixel_layer,col_off);
739   tilemap_mark_tile_dirty(state->pixel_layer,col_off+32);
817740}
818741
819742WRITE32_HANDLER( f3_vram_w )
820743{
821   COMBINE_DATA(&f3_vram[offset]);
744   taito_f3_state *state = space->machine->driver_data<taito_f3_state>();
745   COMBINE_DATA(&state->f3_vram[offset]);
822746   gfx_element_mark_dirty(space->machine->gfx[0], offset/8);
823747}
824748
825749WRITE32_HANDLER( f3_pivot_w )
826750{
827   COMBINE_DATA(&f3_pivot_ram[offset]);
751   taito_f3_state *state = space->machine->driver_data<taito_f3_state>();
752   COMBINE_DATA(&state->f3_pivot_ram[offset]);
828753   gfx_element_mark_dirty(space->machine->gfx[3], offset/8);
829754}
830755
831756WRITE32_HANDLER( f3_lineram_w )
832757{
758   taito_f3_state *state = space->machine->driver_data<taito_f3_state>();
833759   /* DariusGX has an interesting bug at the start of Round D - the clearing of lineram
834760    (0xa000->0x0xa7ff) overflows into priority RAM (0xb000) and creates garbage priority
835761    values.  I'm not sure what the real machine would do with these values, and this
836762    emulation certainly doesn't like it, so I've chosen to catch the bug here, and prevent
837763    the trashing of priority ram.  If anyone has information on what the real machine does,
838764    please let me know! */
839   if (f3_game==DARIUSG) {
840      if (f3_skip_this_frame)
765   if (state->f3_game==DARIUSG) {
766      if (state->f3_skip_this_frame)
841767         return;
842768      if (offset==0xb000/4 && data==0x003f0000) {
843         f3_skip_this_frame=1;
769         state->f3_skip_this_frame=1;
844770         return;
845771      }
846772   }
847773
848   COMBINE_DATA(&f3_line_ram[offset]);
774   COMBINE_DATA(&state->f3_line_ram[offset]);
849775}
850776
851777WRITE32_HANDLER( f3_palette_24bit_w )
852778{
779   taito_f3_state *state = space->machine->driver_data<taito_f3_state>();
853780   int r,g,b;
854781
855782   COMBINE_DATA(&space->machine->generic.paletteram.u32[offset]);
856783
857784   /* 12 bit palette games - there has to be a palette select bit somewhere */
858   if (f3_game==SPCINVDX || f3_game==RIDINGF || f3_game==ARABIANM || f3_game==RINGRAGE) {
785   if (state->f3_game==SPCINVDX || state->f3_game==RIDINGF || state->f3_game==ARABIANM || state->f3_game==RINGRAGE) {
859786      b = 15 * ((space->machine->generic.paletteram.u32[offset] >> 4) & 0xf);
860787      g = 15 * ((space->machine->generic.paletteram.u32[offset] >> 8) & 0xf);
861788      r = 15 * ((space->machine->generic.paletteram.u32[offset] >> 12) & 0xf);
862789   }
863790
864791   /* This is weird - why are only the sprites and VRAM palettes 21 bit? */
865   else if (f3_game==CLEOPATR) {
792   else if (state->f3_game==CLEOPATR) {
866793      if (offset<0x100 || offset>0x1000) {
867794         r = ((space->machine->generic.paletteram.u32[offset] >>16) & 0x7f)<<1;
868795         g = ((space->machine->generic.paletteram.u32[offset] >> 8) & 0x7f)<<1;
r10886r10887
875802   }
876803
877804   /* Another weird couple - perhaps this is alpha blending related? */
878   else if (f3_game==TWINQIX || f3_game==RECALH) {
805   else if (state->f3_game==TWINQIX || state->f3_game==RECALH) {
879806      if (offset>0x1c00) {
880807         r = ((space->machine->generic.paletteram.u32[offset] >>16) & 0x7f)<<1;
881808         g = ((space->machine->generic.paletteram.u32[offset] >> 8) & 0x7f)<<1;
r10886r10887
908835   d = level+1;                  \
909836}
910837
911INLINE void f3_alpha_set_level(void)
838INLINE void f3_alpha_set_level(taito_f3_state *state)
912839{
913//  SET_ALPHA_LEVEL(alpha_s_1_1, f3_alpha_level_2ad)
914   SET_ALPHA_LEVEL(alpha_s_1_1, 255-f3_alpha_level_2as)
915//  SET_ALPHA_LEVEL(alpha_s_1_2, f3_alpha_level_2bd)
916   SET_ALPHA_LEVEL(alpha_s_1_2, 255-f3_alpha_level_2bs)
917   SET_ALPHA_LEVEL(alpha_s_1_4, f3_alpha_level_3ad)
918//  SET_ALPHA_LEVEL(alpha_s_1_5, f3_alpha_level_3ad*f3_alpha_level_2ad/255)
919   SET_ALPHA_LEVEL(alpha_s_1_5, f3_alpha_level_3ad*(255-f3_alpha_level_2as)/255)
920//  SET_ALPHA_LEVEL(alpha_s_1_6, f3_alpha_level_3ad*f3_alpha_level_2bd/255)
921   SET_ALPHA_LEVEL(alpha_s_1_6, f3_alpha_level_3ad*(255-f3_alpha_level_2bs)/255)
922   SET_ALPHA_LEVEL(alpha_s_1_8, f3_alpha_level_3bd)
923//  SET_ALPHA_LEVEL(alpha_s_1_9, f3_alpha_level_3bd*f3_alpha_level_2ad/255)
924   SET_ALPHA_LEVEL(alpha_s_1_9, f3_alpha_level_3bd*(255-f3_alpha_level_2as)/255)
925//  SET_ALPHA_LEVEL(alpha_s_1_a, f3_alpha_level_3bd*f3_alpha_level_2bd/255)
926   SET_ALPHA_LEVEL(alpha_s_1_a, f3_alpha_level_3bd*(255-f3_alpha_level_2bs)/255)
840//  SET_ALPHA_LEVEL(state->alpha_s_1_1, state->f3_alpha_level_2ad)
841   SET_ALPHA_LEVEL(state->alpha_s_1_1, 255-state->f3_alpha_level_2as)
842//  SET_ALPHA_LEVEL(state->alpha_s_1_2, state->f3_alpha_level_2bd)
843   SET_ALPHA_LEVEL(state->alpha_s_1_2, 255-state->f3_alpha_level_2bs)
844   SET_ALPHA_LEVEL(state->alpha_s_1_4, state->f3_alpha_level_3ad)
845//  SET_ALPHA_LEVEL(state->alpha_s_1_5, state->f3_alpha_level_3ad*state->f3_alpha_level_2ad/255)
846   SET_ALPHA_LEVEL(state->alpha_s_1_5, state->f3_alpha_level_3ad*(255-state->f3_alpha_level_2as)/255)
847//  SET_ALPHA_LEVEL(state->alpha_s_1_6, state->f3_alpha_level_3ad*state->f3_alpha_level_2bd/255)
848   SET_ALPHA_LEVEL(state->alpha_s_1_6, state->f3_alpha_level_3ad*(255-state->f3_alpha_level_2bs)/255)
849   SET_ALPHA_LEVEL(state->alpha_s_1_8, state->f3_alpha_level_3bd)
850//  SET_ALPHA_LEVEL(state->alpha_s_1_9, state->f3_alpha_level_3bd*state->f3_alpha_level_2ad/255)
851   SET_ALPHA_LEVEL(state->alpha_s_1_9, state->f3_alpha_level_3bd*(255-state->f3_alpha_level_2as)/255)
852//  SET_ALPHA_LEVEL(state->alpha_s_1_a, state->f3_alpha_level_3bd*state->f3_alpha_level_2bd/255)
853   SET_ALPHA_LEVEL(state->alpha_s_1_a, state->f3_alpha_level_3bd*(255-state->f3_alpha_level_2bs)/255)
927854
928   SET_ALPHA_LEVEL(alpha_s_2a_0, f3_alpha_level_2as)
929   SET_ALPHA_LEVEL(alpha_s_2a_4, f3_alpha_level_2as*f3_alpha_level_3ad/255)
930   SET_ALPHA_LEVEL(alpha_s_2a_8, f3_alpha_level_2as*f3_alpha_level_3bd/255)
855   SET_ALPHA_LEVEL(state->alpha_s_2a_0, state->f3_alpha_level_2as)
856   SET_ALPHA_LEVEL(state->alpha_s_2a_4, state->f3_alpha_level_2as*state->f3_alpha_level_3ad/255)
857   SET_ALPHA_LEVEL(state->alpha_s_2a_8, state->f3_alpha_level_2as*state->f3_alpha_level_3bd/255)
931858
932   SET_ALPHA_LEVEL(alpha_s_2b_0, f3_alpha_level_2bs)
933   SET_ALPHA_LEVEL(alpha_s_2b_4, f3_alpha_level_2bs*f3_alpha_level_3ad/255)
934   SET_ALPHA_LEVEL(alpha_s_2b_8, f3_alpha_level_2bs*f3_alpha_level_3bd/255)
859   SET_ALPHA_LEVEL(state->alpha_s_2b_0, state->f3_alpha_level_2bs)
860   SET_ALPHA_LEVEL(state->alpha_s_2b_4, state->f3_alpha_level_2bs*state->f3_alpha_level_3ad/255)
861   SET_ALPHA_LEVEL(state->alpha_s_2b_8, state->f3_alpha_level_2bs*state->f3_alpha_level_3bd/255)
935862
936   SET_ALPHA_LEVEL(alpha_s_3a_0, f3_alpha_level_3as)
937   SET_ALPHA_LEVEL(alpha_s_3a_1, f3_alpha_level_3as*f3_alpha_level_2ad/255)
938   SET_ALPHA_LEVEL(alpha_s_3a_2, f3_alpha_level_3as*f3_alpha_level_2bd/255)
863   SET_ALPHA_LEVEL(state->alpha_s_3a_0, state->f3_alpha_level_3as)
864   SET_ALPHA_LEVEL(state->alpha_s_3a_1, state->f3_alpha_level_3as*state->f3_alpha_level_2ad/255)
865   SET_ALPHA_LEVEL(state->alpha_s_3a_2, state->f3_alpha_level_3as*state->f3_alpha_level_2bd/255)
939866
940   SET_ALPHA_LEVEL(alpha_s_3b_0, f3_alpha_level_3bs)
941   SET_ALPHA_LEVEL(alpha_s_3b_1, f3_alpha_level_3bs*f3_alpha_level_2ad/255)
942   SET_ALPHA_LEVEL(alpha_s_3b_2, f3_alpha_level_3bs*f3_alpha_level_2bd/255)
867   SET_ALPHA_LEVEL(state->alpha_s_3b_0, state->f3_alpha_level_3bs)
868   SET_ALPHA_LEVEL(state->alpha_s_3b_1, state->f3_alpha_level_3bs*state->f3_alpha_level_2ad/255)
869   SET_ALPHA_LEVEL(state->alpha_s_3b_2, state->f3_alpha_level_3bs*state->f3_alpha_level_2bd/255)
943870}
944871#undef SET_ALPHA_LEVEL
945872
r10886r10887
951878
952879
953880
954INLINE void f3_alpha_blend32_s( int alphas, UINT32 s )
881INLINE void f3_alpha_blend32_s( taito_f3_state *state, int alphas, UINT32 s )
955882{
956883   UINT8 *sc = (UINT8 *)&s;
957   UINT8 *dc = (UINT8 *)&dval;
884   UINT8 *dc = (UINT8 *)&state->dval;
958885   dc[COLOR1] = (alphas * sc[COLOR1]) >> 8;
959886   dc[COLOR2] = (alphas * sc[COLOR2]) >> 8;
960887   dc[COLOR3] = (alphas * sc[COLOR3]) >> 8;
961888}
962889
963INLINE void f3_alpha_blend32_d( int alphas, UINT32 s )
890INLINE void f3_alpha_blend32_d( taito_f3_state *state, int alphas, UINT32 s )
964891{
965892   UINT8 *sc = (UINT8 *)&s;
966   UINT8 *dc = (UINT8 *)&dval;
967   dc[COLOR1] = add_sat[dc[COLOR1]][(alphas * sc[COLOR1]) >> 8];
968   dc[COLOR2] = add_sat[dc[COLOR2]][(alphas * sc[COLOR2]) >> 8];
969   dc[COLOR3] = add_sat[dc[COLOR3]][(alphas * sc[COLOR3]) >> 8];
893   UINT8 *dc = (UINT8 *)&state->dval;
894   dc[COLOR1] = state->add_sat[dc[COLOR1]][(alphas * sc[COLOR1]) >> 8];
895   dc[COLOR2] = state->add_sat[dc[COLOR2]][(alphas * sc[COLOR2]) >> 8];
896   dc[COLOR3] = state->add_sat[dc[COLOR3]][(alphas * sc[COLOR3]) >> 8];
970897}
971898
972899/*============================================================================*/
973900
974INLINE void f3_alpha_blend_1_1( UINT32 s ){f3_alpha_blend32_d(alpha_s_1_1,s);}
975INLINE void f3_alpha_blend_1_2( UINT32 s ){f3_alpha_blend32_d(alpha_s_1_2,s);}
976INLINE void f3_alpha_blend_1_4( UINT32 s ){f3_alpha_blend32_d(alpha_s_1_4,s);}
977INLINE void f3_alpha_blend_1_5( UINT32 s ){f3_alpha_blend32_d(alpha_s_1_5,s);}
978INLINE void f3_alpha_blend_1_6( UINT32 s ){f3_alpha_blend32_d(alpha_s_1_6,s);}
979INLINE void f3_alpha_blend_1_8( UINT32 s ){f3_alpha_blend32_d(alpha_s_1_8,s);}
980INLINE void f3_alpha_blend_1_9( UINT32 s ){f3_alpha_blend32_d(alpha_s_1_9,s);}
981INLINE void f3_alpha_blend_1_a( UINT32 s ){f3_alpha_blend32_d(alpha_s_1_a,s);}
901INLINE void f3_alpha_blend_1_1( taito_f3_state *state, UINT32 s ){f3_alpha_blend32_d(state, state->alpha_s_1_1,s);}
902INLINE void f3_alpha_blend_1_2( taito_f3_state *state, UINT32 s ){f3_alpha_blend32_d(state, state->alpha_s_1_2,s);}
903INLINE void f3_alpha_blend_1_4( taito_f3_state *state, UINT32 s ){f3_alpha_blend32_d(state, state->alpha_s_1_4,s);}
904INLINE void f3_alpha_blend_1_5( taito_f3_state *state, UINT32 s ){f3_alpha_blend32_d(state, state->alpha_s_1_5,s);}
905INLINE void f3_alpha_blend_1_6( taito_f3_state *state, UINT32 s ){f3_alpha_blend32_d(state, state->alpha_s_1_6,s);}
906INLINE void f3_alpha_blend_1_8( taito_f3_state *state, UINT32 s ){f3_alpha_blend32_d(state, state->alpha_s_1_8,s);}
907INLINE void f3_alpha_blend_1_9( taito_f3_state *state, UINT32 s ){f3_alpha_blend32_d(state, state->alpha_s_1_9,s);}
908INLINE void f3_alpha_blend_1_a( taito_f3_state *state, UINT32 s ){f3_alpha_blend32_d(state, state->alpha_s_1_a,s);}
982909
983INLINE void f3_alpha_blend_2a_0( UINT32 s ){f3_alpha_blend32_s(alpha_s_2a_0,s);}
984INLINE void f3_alpha_blend_2a_4( UINT32 s ){f3_alpha_blend32_d(alpha_s_2a_4,s);}
985INLINE void f3_alpha_blend_2a_8( UINT32 s ){f3_alpha_blend32_d(alpha_s_2a_8,s);}
910INLINE void f3_alpha_blend_2a_0( taito_f3_state *state, UINT32 s ){f3_alpha_blend32_s(state, state->alpha_s_2a_0,s);}
911INLINE void f3_alpha_blend_2a_4( taito_f3_state *state, UINT32 s ){f3_alpha_blend32_d(state, state->alpha_s_2a_4,s);}
912INLINE void f3_alpha_blend_2a_8( taito_f3_state *state, UINT32 s ){f3_alpha_blend32_d(state, state->alpha_s_2a_8,s);}
986913
987INLINE void f3_alpha_blend_2b_0( UINT32 s ){f3_alpha_blend32_s(alpha_s_2b_0,s);}
988INLINE void f3_alpha_blend_2b_4( UINT32 s ){f3_alpha_blend32_d(alpha_s_2b_4,s);}
989INLINE void f3_alpha_blend_2b_8( UINT32 s ){f3_alpha_blend32_d(alpha_s_2b_8,s);}
914INLINE void f3_alpha_blend_2b_0( taito_f3_state *state, UINT32 s ){f3_alpha_blend32_s(state, state->alpha_s_2b_0,s);}
915INLINE void f3_alpha_blend_2b_4( taito_f3_state *state, UINT32 s ){f3_alpha_blend32_d(state, state->alpha_s_2b_4,s);}
916INLINE void f3_alpha_blend_2b_8( taito_f3_state *state, UINT32 s ){f3_alpha_blend32_d(state, state->alpha_s_2b_8,s);}
990917
991INLINE void f3_alpha_blend_3a_0( UINT32 s ){f3_alpha_blend32_s(alpha_s_3a_0,s);}
992INLINE void f3_alpha_blend_3a_1( UINT32 s ){f3_alpha_blend32_d(alpha_s_3a_1,s);}
993INLINE void f3_alpha_blend_3a_2( UINT32 s ){f3_alpha_blend32_d(alpha_s_3a_2,s);}
918INLINE void f3_alpha_blend_3a_0( taito_f3_state *state, UINT32 s ){f3_alpha_blend32_s(state, state->alpha_s_3a_0,s);}
919INLINE void f3_alpha_blend_3a_1( taito_f3_state *state, UINT32 s ){f3_alpha_blend32_d(state, state->alpha_s_3a_1,s);}
920INLINE void f3_alpha_blend_3a_2( taito_f3_state *state, UINT32 s ){f3_alpha_blend32_d(state, state->alpha_s_3a_2,s);}
994921
995INLINE void f3_alpha_blend_3b_0( UINT32 s ){f3_alpha_blend32_s(alpha_s_3b_0,s);}
996INLINE void f3_alpha_blend_3b_1( UINT32 s ){f3_alpha_blend32_d(alpha_s_3b_1,s);}
997INLINE void f3_alpha_blend_3b_2( UINT32 s ){f3_alpha_blend32_d(alpha_s_3b_2,s);}
922INLINE void f3_alpha_blend_3b_0( taito_f3_state *state, UINT32 s ){f3_alpha_blend32_s(state, state->alpha_s_3b_0,s);}
923INLINE void f3_alpha_blend_3b_1( taito_f3_state *state, UINT32 s ){f3_alpha_blend32_d(state, state->alpha_s_3b_1,s);}
924INLINE void f3_alpha_blend_3b_2( taito_f3_state *state, UINT32 s ){f3_alpha_blend32_d(state, state->alpha_s_3b_2,s);}
998925
999926/*============================================================================*/
1000927
1001static int dpix_1_noalpha(UINT32 s_pix) {dval = s_pix; return 1;}
1002static int dpix_ret1(UINT32 s_pix) {return 1;}
1003static int dpix_ret0(UINT32 s_pix) {return 0;}
1004static int dpix_1_1(UINT32 s_pix) {if(s_pix) f3_alpha_blend_1_1(s_pix); return 1;}
1005static int dpix_1_2(UINT32 s_pix) {if(s_pix) f3_alpha_blend_1_2(s_pix); return 1;}
1006static int dpix_1_4(UINT32 s_pix) {if(s_pix) f3_alpha_blend_1_4(s_pix); return 1;}
1007static int dpix_1_5(UINT32 s_pix) {if(s_pix) f3_alpha_blend_1_5(s_pix); return 1;}
1008static int dpix_1_6(UINT32 s_pix) {if(s_pix) f3_alpha_blend_1_6(s_pix); return 1;}
1009static int dpix_1_8(UINT32 s_pix) {if(s_pix) f3_alpha_blend_1_8(s_pix); return 1;}
1010static int dpix_1_9(UINT32 s_pix) {if(s_pix) f3_alpha_blend_1_9(s_pix); return 1;}
1011static int dpix_1_a(UINT32 s_pix) {if(s_pix) f3_alpha_blend_1_a(s_pix); return 1;}
928static int dpix_1_noalpha(taito_f3_state *state, UINT32 s_pix) {state->dval = s_pix; return 1;}
929static int dpix_ret1(taito_f3_state *state, UINT32 s_pix) {return 1;}
930static int dpix_ret0(taito_f3_state *state, UINT32 s_pix) {return 0;}
931static int dpix_1_1(taito_f3_state *state, UINT32 s_pix) {if(s_pix) f3_alpha_blend_1_1(state, s_pix); return 1;}
932static int dpix_1_2(taito_f3_state *state, UINT32 s_pix) {if(s_pix) f3_alpha_blend_1_2(state, s_pix); return 1;}
933static int dpix_1_4(taito_f3_state *state, UINT32 s_pix) {if(s_pix) f3_alpha_blend_1_4(state, s_pix); return 1;}
934static int dpix_1_5(taito_f3_state *state, UINT32 s_pix) {if(s_pix) f3_alpha_blend_1_5(state, s_pix); return 1;}
935static int dpix_1_6(taito_f3_state *state, UINT32 s_pix) {if(s_pix) f3_alpha_blend_1_6(state, s_pix); return 1;}
936static int dpix_1_8(taito_f3_state *state, UINT32 s_pix) {if(s_pix) f3_alpha_blend_1_8(state, s_pix); return 1;}
937static int dpix_1_9(taito_f3_state *state, UINT32 s_pix) {if(s_pix) f3_alpha_blend_1_9(state, s_pix); return 1;}
938static int dpix_1_a(taito_f3_state *state, UINT32 s_pix) {if(s_pix) f3_alpha_blend_1_a(state, s_pix); return 1;}
1012939
1013static int dpix_2a_0(UINT32 s_pix)
940static int dpix_2a_0(taito_f3_state *state, UINT32 s_pix)
1014941{
1015   if(s_pix) f3_alpha_blend_2a_0(s_pix);
1016   else     dval = 0;
1017   if(pdest_2a) {pval |= pdest_2a;return 0;}
942   if(s_pix) f3_alpha_blend_2a_0(state, s_pix);
943   else     state->dval = 0;
944   if(state->pdest_2a) {state->pval |= state->pdest_2a;return 0;}
1018945   return 1;
1019946}
1020static int dpix_2a_4(UINT32 s_pix)
947static int dpix_2a_4(taito_f3_state *state, UINT32 s_pix)
1021948{
1022   if(s_pix) f3_alpha_blend_2a_4(s_pix);
1023   if(pdest_2a) {pval |= pdest_2a;return 0;}
949   if(s_pix) f3_alpha_blend_2a_4(state, s_pix);
950   if(state->pdest_2a) {state->pval |= state->pdest_2a;return 0;}
1024951   return 1;
1025952}
1026static int dpix_2a_8(UINT32 s_pix)
953static int dpix_2a_8(taito_f3_state *state, UINT32 s_pix)
1027954{
1028   if(s_pix) f3_alpha_blend_2a_8(s_pix);
1029   if(pdest_2a) {pval |= pdest_2a;return 0;}
955   if(s_pix) f3_alpha_blend_2a_8(state, s_pix);
956   if(state->pdest_2a) {state->pval |= state->pdest_2a;return 0;}
1030957   return 1;
1031958}
1032959
1033static int dpix_3a_0(UINT32 s_pix)
960static int dpix_3a_0(taito_f3_state *state, UINT32 s_pix)
1034961{
1035   if(s_pix) f3_alpha_blend_3a_0(s_pix);
1036   else     dval = 0;
1037   if(pdest_3a) {pval |= pdest_3a;return 0;}
962   if(s_pix) f3_alpha_blend_3a_0(state, s_pix);
963   else     state->dval = 0;
964   if(state->pdest_3a) {state->pval |= state->pdest_3a;return 0;}
1038965   return 1;
1039966}
1040static int dpix_3a_1(UINT32 s_pix)
967static int dpix_3a_1(taito_f3_state *state, UINT32 s_pix)
1041968{
1042   if(s_pix) f3_alpha_blend_3a_1(s_pix);
1043   if(pdest_3a) {pval |= pdest_3a;return 0;}
969   if(s_pix) f3_alpha_blend_3a_1(state, s_pix);
970   if(state->pdest_3a) {state->pval |= state->pdest_3a;return 0;}
1044971   return 1;
1045972}
1046static int dpix_3a_2(UINT32 s_pix)
973static int dpix_3a_2(taito_f3_state *state, UINT32 s_pix)
1047974{
1048   if(s_pix) f3_alpha_blend_3a_2(s_pix);
1049   if(pdest_3a) {pval |= pdest_3a;return 0;}
975   if(s_pix) f3_alpha_blend_3a_2(state, s_pix);
976   if(state->pdest_3a) {state->pval |= state->pdest_3a;return 0;}
1050977   return 1;
1051978}
1052979
1053static int dpix_2b_0(UINT32 s_pix)
980static int dpix_2b_0(taito_f3_state *state, UINT32 s_pix)
1054981{
1055   if(s_pix) f3_alpha_blend_2b_0(s_pix);
1056   else     dval = 0;
1057   if(pdest_2b) {pval |= pdest_2b;return 0;}
982   if(s_pix) f3_alpha_blend_2b_0(state, s_pix);
983   else     state->dval = 0;
984   if(state->pdest_2b) {state->pval |= state->pdest_2b;return 0;}
1058985   return 1;
1059986}
1060static int dpix_2b_4(UINT32 s_pix)
987static int dpix_2b_4(taito_f3_state *state, UINT32 s_pix)
1061988{
1062   if(s_pix) f3_alpha_blend_2b_4(s_pix);
1063   if(pdest_2b) {pval |= pdest_2b;return 0;}
989   if(s_pix) f3_alpha_blend_2b_4(state, s_pix);
990   if(state->pdest_2b) {state->pval |= state->pdest_2b;return 0;}
1064991   return 1;
1065992}
1066static int dpix_2b_8(UINT32 s_pix)
993static int dpix_2b_8(taito_f3_state *state, UINT32 s_pix)
1067994{
1068   if(s_pix) f3_alpha_blend_2b_8(s_pix);
1069   if(pdest_2b) {pval |= pdest_2b;return 0;}
995   if(s_pix) f3_alpha_blend_2b_8(state, s_pix);
996   if(state->pdest_2b) {state->pval |= state->pdest_2b;return 0;}
1070997   return 1;
1071998}
1072999
1073static int dpix_3b_0(UINT32 s_pix)
1000static int dpix_3b_0(taito_f3_state *state, UINT32 s_pix)
10741001{
1075   if(s_pix) f3_alpha_blend_3b_0(s_pix);
1076   else     dval = 0;
1077   if(pdest_3b) {pval |= pdest_3b;return 0;}
1002   if(s_pix) f3_alpha_blend_3b_0(state, s_pix);
1003   else     state->dval = 0;
1004   if(state->pdest_3b) {state->pval |= state->pdest_3b;return 0;}
10781005   return 1;
10791006}
1080static int dpix_3b_1(UINT32 s_pix)
1007static int dpix_3b_1(taito_f3_state *state, UINT32 s_pix)
10811008{
1082   if(s_pix) f3_alpha_blend_3b_1(s_pix);
1083   if(pdest_3b) {pval |= pdest_3b;return 0;}
1009   if(s_pix) f3_alpha_blend_3b_1(state, s_pix);
1010   if(state->pdest_3b) {state->pval |= state->pdest_3b;return 0;}
10841011   return 1;
10851012}
1086static int dpix_3b_2(UINT32 s_pix)
1013static int dpix_3b_2(taito_f3_state *state, UINT32 s_pix)
10871014{
1088   if(s_pix) f3_alpha_blend_3b_2(s_pix);
1089   if(pdest_3b) {pval |= pdest_3b;return 0;}
1015   if(s_pix) f3_alpha_blend_3b_2(state, s_pix);
1016   if(state->pdest_3b) {state->pval |= state->pdest_3b;return 0;}
10901017   return 1;
10911018}
10921019
1093static int dpix_2_0(UINT32 s_pix)
1020static int dpix_2_0(taito_f3_state *state, UINT32 s_pix)
10941021{
1095   UINT8 tr2=tval&1;
1022   UINT8 tr2=state->tval&1;
10961023   if(s_pix)
10971024   {
1098      if(tr2==tr_2b)      {f3_alpha_blend_2b_0(s_pix);if(pdest_2b) pval |= pdest_2b;else return 1;}
1099      else if(tr2==tr_2a)   {f3_alpha_blend_2a_0(s_pix);if(pdest_2a) pval |= pdest_2a;else return 1;}
1025      if(tr2==state->tr_2b)      {f3_alpha_blend_2b_0(state, s_pix);if(state->pdest_2b) state->pval |= state->pdest_2b;else return 1;}
1026      else if(tr2==state->tr_2a)   {f3_alpha_blend_2a_0(state, s_pix);if(state->pdest_2a) state->pval |= state->pdest_2a;else return 1;}
11001027   }
11011028   else
11021029   {
1103      if(tr2==tr_2b)      {dval = 0;if(pdest_2b) pval |= pdest_2b;else return 1;}
1104      else if(tr2==tr_2a)   {dval = 0;if(pdest_2a) pval |= pdest_2a;else return 1;}
1030      if(tr2==state->tr_2b)      {state->dval = 0;if(state->pdest_2b) state->pval |= state->pdest_2b;else return 1;}
1031      else if(tr2==state->tr_2a)   {state->dval = 0;if(state->pdest_2a) state->pval |= state->pdest_2a;else return 1;}
11051032   }
11061033   return 0;
11071034}
1108static int dpix_2_4(UINT32 s_pix)
1035static int dpix_2_4(taito_f3_state *state, UINT32 s_pix)
11091036{
1110   UINT8 tr2=tval&1;
1037   UINT8 tr2=state->tval&1;
11111038   if(s_pix)
11121039   {
1113      if(tr2==tr_2b)      {f3_alpha_blend_2b_4(s_pix);if(pdest_2b) pval |= pdest_2b;else return 1;}
1114      else if(tr2==tr_2a)   {f3_alpha_blend_2a_4(s_pix);if(pdest_2a) pval |= pdest_2a;else return 1;}
1040      if(tr2==state->tr_2b)      {f3_alpha_blend_2b_4(state, s_pix);if(state->pdest_2b) state->pval |= state->pdest_2b;else return 1;}
1041      else if(tr2==state->tr_2a)   {f3_alpha_blend_2a_4(state, s_pix);if(state->pdest_2a) state->pval |= state->pdest_2a;else return 1;}
11151042   }
11161043   else
11171044   {
1118      if(tr2==tr_2b)      {if(pdest_2b) pval |= pdest_2b;else return 1;}
1119      else if(tr2==tr_2a)   {if(pdest_2a) pval |= pdest_2a;else return 1;}
1045      if(tr2==state->tr_2b)      {if(state->pdest_2b) state->pval |= state->pdest_2b;else return 1;}
1046      else if(tr2==state->tr_2a)   {if(state->pdest_2a) state->pval |= state->pdest_2a;else return 1;}
11201047   }
11211048   return 0;
11221049}
1123static int dpix_2_8(UINT32 s_pix)
1050static int dpix_2_8(taito_f3_state *state, UINT32 s_pix)
11241051{
1125   UINT8 tr2=tval&1;
1052   UINT8 tr2=state->tval&1;
11261053   if(s_pix)
11271054   {
1128      if(tr2==tr_2b)      {f3_alpha_blend_2b_8(s_pix);if(pdest_2b) pval |= pdest_2b;else return 1;}
1129      else if(tr2==tr_2a)   {f3_alpha_blend_2a_8(s_pix);if(pdest_2a) pval |= pdest_2a;else return 1;}
1055      if(tr2==state->tr_2b)      {f3_alpha_blend_2b_8(state, s_pix);if(state->pdest_2b) state->pval |= state->pdest_2b;else return 1;}
1056      else if(tr2==state->tr_2a)   {f3_alpha_blend_2a_8(state, s_pix);if(state->pdest_2a) state->pval |= state->pdest_2a;else return 1;}
11301057   }
11311058   else
11321059   {
1133      if(tr2==tr_2b)      {if(pdest_2b) pval |= pdest_2b;else return 1;}
1134      else if(tr2==tr_2a)   {if(pdest_2a) pval |= pdest_2a;else return 1;}
1060      if(tr2==state->tr_2b)      {if(state->pdest_2b) state->pval |= state->pdest_2b;else return 1;}
1061      else if(tr2==state->tr_2a)   {if(state->pdest_2a) state->pval |= state->pdest_2a;else return 1;}
11351062   }
11361063   return 0;
11371064}
11381065
1139static int dpix_3_0(UINT32 s_pix)
1066static int dpix_3_0(taito_f3_state *state, UINT32 s_pix)
11401067{
1141   UINT8 tr2=tval&1;
1068   UINT8 tr2=state->tval&1;
11421069   if(s_pix)
11431070   {
1144      if(tr2==tr_3b)      {f3_alpha_blend_3b_0(s_pix);if(pdest_3b) pval |= pdest_3b;else return 1;}
1145      else if(tr2==tr_3a)   {f3_alpha_blend_3a_0(s_pix);if(pdest_3a) pval |= pdest_3a;else return 1;}
1071      if(tr2==state->tr_3b)      {f3_alpha_blend_3b_0(state, s_pix);if(state->pdest_3b) state->pval |= state->pdest_3b;else return 1;}
1072      else if(tr2==state->tr_3a)   {f3_alpha_blend_3a_0(state, s_pix);if(state->pdest_3a) state->pval |= state->pdest_3a;else return 1;}
11461073   }
11471074   else
11481075   {
1149      if(tr2==tr_3b)      {dval = 0;if(pdest_3b) pval |= pdest_3b;else return 1;}
1150      else if(tr2==tr_3a)   {dval = 0;if(pdest_3a) pval |= pdest_3a;else return 1;}
1076      if(tr2==state->tr_3b)      {state->dval = 0;if(state->pdest_3b) state->pval |= state->pdest_3b;else return 1;}
1077      else if(tr2==state->tr_3a)   {state->dval = 0;if(state->pdest_3a) state->pval |= state->pdest_3a;else return 1;}
11511078   }
11521079   return 0;
11531080}
1154static int dpix_3_1(UINT32 s_pix)
1081static int dpix_3_1(taito_f3_state *state, UINT32 s_pix)
11551082{
1156   UINT8 tr2=tval&1;
1083   UINT8 tr2=state->tval&1;
11571084   if(s_pix)
11581085   {
1159      if(tr2==tr_3b)      {f3_alpha_blend_3b_1(s_pix);if(pdest_3b) pval |= pdest_3b;else return 1;}
1160      else if(tr2==tr_3a)   {f3_alpha_blend_3a_1(s_pix);if(pdest_3a) pval |= pdest_3a;else return 1;}
1086      if(tr2==state->tr_3b)      {f3_alpha_blend_3b_1(state, s_pix);if(state->pdest_3b) state->pval |= state->pdest_3b;else return 1;}
1087      else if(tr2==state->tr_3a)   {f3_alpha_blend_3a_1(state, s_pix);if(state->pdest_3a) state->pval |= state->pdest_3a;else return 1;}
11611088   }
11621089   else
11631090   {
1164      if(tr2==tr_3b)      {if(pdest_3b) pval |= pdest_3b;else return 1;}
1165      else if(tr2==tr_3a)   {if(pdest_3a) pval |= pdest_3a;else return 1;}
1091      if(tr2==state->tr_3b)      {if(state->pdest_3b) state->pval |= state->pdest_3b;else return 1;}
1092      else if(tr2==state->tr_3a)   {if(state->pdest_3a) state->pval |= state->pdest_3a;else return 1;}
11661093   }
11671094   return 0;
11681095}
1169static int dpix_3_2(UINT32 s_pix)
1096static int dpix_3_2(taito_f3_state *state, UINT32 s_pix)
11701097{
1171   UINT8 tr2=tval&1;
1098   UINT8 tr2=state->tval&1;
11721099   if(s_pix)
11731100   {
1174      if(tr2==tr_3b)      {f3_alpha_blend_3b_2(s_pix);if(pdest_3b) pval |= pdest_3b;else return 1;}
1175      else if(tr2==tr_3a)   {f3_alpha_blend_3a_2(s_pix);if(pdest_3a) pval |= pdest_3a;else return 1;}
1101      if(tr2==state->tr_3b)      {f3_alpha_blend_3b_2(state, s_pix);if(state->pdest_3b) state->pval |= state->pdest_3b;else return 1;}
1102      else if(tr2==state->tr_3a)   {f3_alpha_blend_3a_2(state, s_pix);if(state->pdest_3a) state->pval |= state->pdest_3a;else return 1;}
11761103   }
11771104   else
11781105   {
1179      if(tr2==tr_3b)      {if(pdest_3b) pval |= pdest_3b;else return 1;}
1180      else if(tr2==tr_3a)   {if(pdest_3a) pval |= pdest_3a;else return 1;}
1106      if(tr2==state->tr_3b)      {if(state->pdest_3b) state->pval |= state->pdest_3b;else return 1;}
1107      else if(tr2==state->tr_3a)   {if(state->pdest_3a) state->pval |= state->pdest_3a;else return 1;}
11811108   }
11821109   return 0;
11831110}
11841111
1185INLINE void dpix_1_sprite(UINT32 s_pix)
1112INLINE void dpix_1_sprite(taito_f3_state *state, UINT32 s_pix)
11861113{
11871114   if(s_pix)
11881115   {
1189      UINT8 p1 = pval&0xf0;
1190      if     (p1==0x10)   f3_alpha_blend_1_1(s_pix);
1191      else if(p1==0x20)   f3_alpha_blend_1_2(s_pix);
1192      else if(p1==0x40)   f3_alpha_blend_1_4(s_pix);
1193      else if(p1==0x50)   f3_alpha_blend_1_5(s_pix);
1194      else if(p1==0x60)   f3_alpha_blend_1_6(s_pix);
1195      else if(p1==0x80)   f3_alpha_blend_1_8(s_pix);
1196      else if(p1==0x90)   f3_alpha_blend_1_9(s_pix);
1197      else if(p1==0xa0)   f3_alpha_blend_1_a(s_pix);
1116      UINT8 p1 = state->pval&0xf0;
1117      if     (p1==0x10)   f3_alpha_blend_1_1(state, s_pix);
1118      else if(p1==0x20)   f3_alpha_blend_1_2(state, s_pix);
1119      else if(p1==0x40)   f3_alpha_blend_1_4(state, s_pix);
1120      else if(p1==0x50)   f3_alpha_blend_1_5(state, s_pix);
1121      else if(p1==0x60)   f3_alpha_blend_1_6(state, s_pix);
1122      else if(p1==0x80)   f3_alpha_blend_1_8(state, s_pix);
1123      else if(p1==0x90)   f3_alpha_blend_1_9(state, s_pix);
1124      else if(p1==0xa0)   f3_alpha_blend_1_a(state, s_pix);
11981125   }
11991126}
12001127
1201INLINE void dpix_bg(UINT32 bgcolor)
1128INLINE void dpix_bg(taito_f3_state *state, UINT32 bgcolor)
12021129{
1203   UINT8 p1 = pval&0xf0;
1204   if(!p1)         dval = bgcolor;
1205   else if(p1==0x10)   f3_alpha_blend_1_1(bgcolor);
1206   else if(p1==0x20)   f3_alpha_blend_1_2(bgcolor);
1207   else if(p1==0x40)   f3_alpha_blend_1_4(bgcolor);
1208   else if(p1==0x50)   f3_alpha_blend_1_5(bgcolor);
1209   else if(p1==0x60)   f3_alpha_blend_1_6(bgcolor);
1210   else if(p1==0x80)   f3_alpha_blend_1_8(bgcolor);
1211   else if(p1==0x90)   f3_alpha_blend_1_9(bgcolor);
1212   else if(p1==0xa0)   f3_alpha_blend_1_a(bgcolor);
1130   UINT8 p1 = state->pval&0xf0;
1131   if(!p1)         state->dval = bgcolor;
1132   else if(p1==0x10)   f3_alpha_blend_1_1(state, bgcolor);
1133   else if(p1==0x20)   f3_alpha_blend_1_2(state, bgcolor);
1134   else if(p1==0x40)   f3_alpha_blend_1_4(state, bgcolor);
1135   else if(p1==0x50)   f3_alpha_blend_1_5(state, bgcolor);
1136   else if(p1==0x60)   f3_alpha_blend_1_6(state, bgcolor);
1137   else if(p1==0x80)   f3_alpha_blend_1_8(state, bgcolor);
1138   else if(p1==0x90)   f3_alpha_blend_1_9(state, bgcolor);
1139   else if(p1==0xa0)   f3_alpha_blend_1_a(state, bgcolor);
12131140}
12141141
12151142/******************************************************************************/
12161143
1217static void init_alpha_blend_func(void)
1144static void init_alpha_blend_func(running_machine *machine)
12181145{
1146   taito_f3_state *state = machine->driver_data<taito_f3_state>();
12191147   int i,j;
12201148
1221   dpix_n[0][0x0]=dpix_1_noalpha;
1222   dpix_n[0][0x1]=dpix_1_noalpha;
1223   dpix_n[0][0x2]=dpix_1_noalpha;
1224   dpix_n[0][0x3]=dpix_1_noalpha;
1225   dpix_n[0][0x4]=dpix_1_noalpha;
1226   dpix_n[0][0x5]=dpix_1_noalpha;
1227   dpix_n[0][0x6]=dpix_1_noalpha;
1228   dpix_n[0][0x7]=dpix_1_noalpha;
1229   dpix_n[0][0x8]=dpix_1_noalpha;
1230   dpix_n[0][0x9]=dpix_1_noalpha;
1231   dpix_n[0][0xa]=dpix_1_noalpha;
1232   dpix_n[0][0xb]=dpix_1_noalpha;
1233   dpix_n[0][0xc]=dpix_1_noalpha;
1234   dpix_n[0][0xd]=dpix_1_noalpha;
1235   dpix_n[0][0xe]=dpix_1_noalpha;
1236   dpix_n[0][0xf]=dpix_1_noalpha;
1149   state->dpix_n[0][0x0]=dpix_1_noalpha;
1150   state->dpix_n[0][0x1]=dpix_1_noalpha;
1151   state->dpix_n[0][0x2]=dpix_1_noalpha;
1152   state->dpix_n[0][0x3]=dpix_1_noalpha;
1153   state->dpix_n[0][0x4]=dpix_1_noalpha;
1154   state->dpix_n[0][0x5]=dpix_1_noalpha;
1155   state->dpix_n[0][0x6]=dpix_1_noalpha;
1156   state->dpix_n[0][0x7]=dpix_1_noalpha;
1157   state->dpix_n[0][0x8]=dpix_1_noalpha;
1158   state->dpix_n[0][0x9]=dpix_1_noalpha;
1159   state->dpix_n[0][0xa]=dpix_1_noalpha;
1160   state->dpix_n[0][0xb]=dpix_1_noalpha;
1161   state->dpix_n[0][0xc]=dpix_1_noalpha;
1162   state->dpix_n[0][0xd]=dpix_1_noalpha;
1163   state->dpix_n[0][0xe]=dpix_1_noalpha;
1164   state->dpix_n[0][0xf]=dpix_1_noalpha;
12371165
1238   dpix_n[1][0x0]=dpix_1_noalpha;
1239   dpix_n[1][0x1]=dpix_1_1;
1240   dpix_n[1][0x2]=dpix_1_2;
1241   dpix_n[1][0x3]=dpix_ret1;
1242   dpix_n[1][0x4]=dpix_1_4;
1243   dpix_n[1][0x5]=dpix_1_5;
1244   dpix_n[1][0x6]=dpix_1_6;
1245   dpix_n[1][0x7]=dpix_ret1;
1246   dpix_n[1][0x8]=dpix_1_8;
1247   dpix_n[1][0x9]=dpix_1_9;
1248   dpix_n[1][0xa]=dpix_1_a;
1249   dpix_n[1][0xb]=dpix_ret1;
1250   dpix_n[1][0xc]=dpix_ret1;
1251   dpix_n[1][0xd]=dpix_ret1;
1252   dpix_n[1][0xe]=dpix_ret1;
1253   dpix_n[1][0xf]=dpix_ret1;
1166   state->dpix_n[1][0x0]=dpix_1_noalpha;
1167   state->dpix_n[1][0x1]=dpix_1_1;
1168   state->dpix_n[1][0x2]=dpix_1_2;
1169   state->dpix_n[1][0x3]=dpix_ret1;
1170   state->dpix_n[1][0x4]=dpix_1_4;
1171   state->dpix_n[1][0x5]=dpix_1_5;
1172   state->dpix_n[1][0x6]=dpix_1_6;
1173   state->dpix_n[1][0x7]=dpix_ret1;
1174   state->dpix_n[1][0x8]=dpix_1_8;
1175   state->dpix_n[1][0x9]=dpix_1_9;
1176   state->dpix_n[1][0xa]=dpix_1_a;
1177   state->dpix_n[1][0xb]=dpix_ret1;
1178   state->dpix_n[1][0xc]=dpix_ret1;
1179   state->dpix_n[1][0xd]=dpix_ret1;
1180   state->dpix_n[1][0xe]=dpix_ret1;
1181   state->dpix_n[1][0xf]=dpix_ret1;
12541182
1255   dpix_n[2][0x0]=dpix_2a_0;
1256   dpix_n[2][0x1]=dpix_ret0;
1257   dpix_n[2][0x2]=dpix_ret0;
1258   dpix_n[2][0x3]=dpix_ret0;
1259   dpix_n[2][0x4]=dpix_2a_4;
1260   dpix_n[2][0x5]=dpix_ret0;
1261   dpix_n[2][0x6]=dpix_ret0;
1262   dpix_n[2][0x7]=dpix_ret0;
1263   dpix_n[2][0x8]=dpix_2a_8;
1264   dpix_n[2][0x9]=dpix_ret0;
1265   dpix_n[2][0xa]=dpix_ret0;
1266   dpix_n[2][0xb]=dpix_ret0;
1267   dpix_n[2][0xc]=dpix_ret0;
1268   dpix_n[2][0xd]=dpix_ret0;
1269   dpix_n[2][0xe]=dpix_ret0;
1270   dpix_n[2][0xf]=dpix_ret0;
1183   state->dpix_n[2][0x0]=dpix_2a_0;
1184   state->dpix_n[2][0x1]=dpix_ret0;
1185   state->dpix_n[2][0x2]=dpix_ret0;
1186   state->dpix_n[2][0x3]=dpix_ret0;
1187   state->dpix_n[2][0x4]=dpix_2a_4;
1188   state->dpix_n[2][0x5]=dpix_ret0;
1189   state->dpix_n[2][0x6]=dpix_ret0;
1190   state->dpix_n[2][0x7]=dpix_ret0;
1191   state->dpix_n[2][0x8]=dpix_2a_8;
1192   state->dpix_n[2][0x9]=dpix_ret0;
1193   state->dpix_n[2][0xa]=dpix_ret0;
1194   state->dpix_n[2][0xb]=dpix_ret0;
1195   state->dpix_n[2][0xc]=dpix_ret0;
1196   state->dpix_n[2][0xd]=dpix_ret0;
1197   state->dpix_n[2][0xe]=dpix_ret0;
1198   state->dpix_n[2][0xf]=dpix_ret0;
12711199
1272   dpix_n[3][0x0]=dpix_3a_0;
1273   dpix_n[3][0x1]=dpix_3a_1;
1274   dpix_n[3][0x2]=dpix_3a_2;
1275   dpix_n[3][0x3]=dpix_ret0;
1276   dpix_n[3][0x4]=dpix_ret0;
1277   dpix_n[3][0x5]=dpix_ret0;
1278   dpix_n[3][0x6]=dpix_ret0;
1279   dpix_n[3][0x7]=dpix_ret0;
1280   dpix_n[3][0x8]=dpix_ret0;
1281   dpix_n[3][0x9]=dpix_ret0;
1282   dpix_n[3][0xa]=dpix_ret0;
1283   dpix_n[3][0xb]=dpix_ret0;
1284   dpix_n[3][0xc]=dpix_ret0;
1285   dpix_n[3][0xd]=dpix_ret0;
1286   dpix_n[3][0xe]=dpix_ret0;
1287   dpix_n[3][0xf]=dpix_ret0;
1200   state->dpix_n[3][0x0]=dpix_3a_0;
1201   state->dpix_n[3][0x1]=dpix_3a_1;
1202   state->dpix_n[3][0x2]=dpix_3a_2;
1203   state->dpix_n[3][0x3]=dpix_ret0;
1204   state->dpix_n[3][0x4]=dpix_ret0;
1205   state->dpix_n[3][0x5]=dpix_ret0;
1206   state->dpix_n[3][0x6]=dpix_ret0;
1207   state->dpix_n[3][0x7]=dpix_ret0;
1208   state->dpix_n[3][0x8]=dpix_ret0;
1209   state->dpix_n[3][0x9]=dpix_ret0;
1210   state->dpix_n[3][0xa]=dpix_ret0;
1211   state->dpix_n[3][0xb]=dpix_ret0;
1212   state->dpix_n[3][0xc]=dpix_ret0;
1213   state->dpix_n[3][0xd]=dpix_ret0;
1214   state->dpix_n[3][0xe]=dpix_ret0;
1215   state->dpix_n[3][0xf]=dpix_ret0;
12881216
1289   dpix_n[4][0x0]=dpix_2b_0;
1290   dpix_n[4][0x1]=dpix_ret0;
1291   dpix_n[4][0x2]=dpix_ret0;
1292   dpix_n[4][0x3]=dpix_ret0;
1293   dpix_n[4][0x4]=dpix_2b_4;
1294   dpix_n[4][0x5]=dpix_ret0;
1295   dpix_n[4][0x6]=dpix_ret0;
1296   dpix_n[4][0x7]=dpix_ret0;
1297   dpix_n[4][0x8]=dpix_2b_8;
1298   dpix_n[4][0x9]=dpix_ret0;
1299   dpix_n[4][0xa]=dpix_ret0;
1300   dpix_n[4][0xb]=dpix_ret0;
1301   dpix_n[4][0xc]=dpix_ret0;
1302   dpix_n[4][0xd]=dpix_ret0;
1303   dpix_n[4][0xe]=dpix_ret0;
1304   dpix_n[4][0xf]=dpix_ret0;
1217   state->dpix_n[4][0x0]=dpix_2b_0;
1218   state->dpix_n[4][0x1]=dpix_ret0;
1219   state->dpix_n[4][0x2]=dpix_ret0;
1220   state->dpix_n[4][0x3]=dpix_ret0;
1221   state->dpix_n[4][0x4]=dpix_2b_4;
1222   state->dpix_n[4][0x5]=dpix_ret0;
1223   state->dpix_n[4][0x6]=dpix_ret0;
1224   state->dpix_n[4][0x7]=dpix_ret0;
1225   state->dpix_n[4][0x8]=dpix_2b_8;
1226   state->dpix_n[4][0x9]=dpix_ret0;
1227   state->dpix_n[4][0xa]=dpix_ret0;
1228   state->dpix_n[4][0xb]=dpix_ret0;
1229   state->dpix_n[4][0xc]=dpix_ret0;
1230   state->dpix_n[4][0xd]=dpix_ret0;
1231   state->dpix_n[4][0xe]=dpix_ret0;
1232   state->dpix_n[4][0xf]=dpix_ret0;
13051233
1306   dpix_n[5][0x0]=dpix_3b_0;
1307   dpix_n[5][0x1]=dpix_3b_1;
1308   dpix_n[5][0x2]=dpix_3b_2;
1309   dpix_n[5][0x3]=dpix_ret0;
1310   dpix_n[5][0x4]=dpix_ret0;
1311   dpix_n[5][0x5]=dpix_ret0;
1312   dpix_n[5][0x6]=dpix_ret0;
1313   dpix_n[5][0x7]=dpix_ret0;
1314   dpix_n[5][0x8]=dpix_ret0;
1315   dpix_n[5][0x9]=dpix_ret0;
1316   dpix_n[5][0xa]=dpix_ret0;
1317   dpix_n[5][0xb]=dpix_ret0;
1318   dpix_n[5][0xc]=dpix_ret0;
1319   dpix_n[5][0xd]=dpix_ret0;
1320   dpix_n[5][0xe]=dpix_ret0;
1321   dpix_n[5][0xf]=dpix_ret0;
1234   state->dpix_n[5][0x0]=dpix_3b_0;
1235   state->dpix_n[5][0x1]=dpix_3b_1;
1236   state->dpix_n[5][0x2]=dpix_3b_2;
1237   state->dpix_n[5][0x3]=dpix_ret0;
1238   state->dpix_n[5][0x4]=dpix_ret0;
1239   state->dpix_n[5][0x5]=dpix_ret0;
1240   state->dpix_n[5][0x6]=dpix_ret0;
1241   state->dpix_n[5][0x7]=dpix_ret0;
1242   state->dpix_n[5][0x8]=dpix_ret0;
1243   state->dpix_n[5][0x9]=dpix_ret0;
1244   state->dpix_n[5][0xa]=dpix_ret0;
1245   state->dpix_n[5][0xb]=dpix_ret0;
1246   state->dpix_n[5][0xc]=dpix_ret0;
1247   state->dpix_n[5][0xd]=dpix_ret0;
1248   state->dpix_n[5][0xe]=dpix_ret0;
1249   state->dpix_n[5][0xf]=dpix_ret0;
13221250
1323   dpix_n[6][0x0]=dpix_2_0;
1324   dpix_n[6][0x1]=dpix_ret0;
1325   dpix_n[6][0x2]=dpix_ret0;
1326   dpix_n[6][0x3]=dpix_ret0;
1327   dpix_n[6][0x4]=dpix_2_4;
1328   dpix_n[6][0x5]=dpix_ret0;
1329   dpix_n[6][0x6]=dpix_ret0;
1330   dpix_n[6][0x7]=dpix_ret0;
1331   dpix_n[6][0x8]=dpix_2_8;
1332   dpix_n[6][0x9]=dpix_ret0;
1333   dpix_n[6][0xa]=dpix_ret0;
1334   dpix_n[6][0xb]=dpix_ret0;
1335   dpix_n[6][0xc]=dpix_ret0;
1336   dpix_n[6][0xd]=dpix_ret0;
1337   dpix_n[6][0xe]=dpix_ret0;
1338   dpix_n[6][0xf]=dpix_ret0;
1251   state->dpix_n[6][0x0]=dpix_2_0;
1252   state->dpix_n[6][0x1]=dpix_ret0;
1253   state->dpix_n[6][0x2]=dpix_ret0;
1254   state->dpix_n[6][0x3]=dpix_ret0;
1255   state->dpix_n[6][0x4]=dpix_2_4;
1256   state->dpix_n[6][0x5]=dpix_ret0;
1257   state->dpix_n[6][0x6]=dpix_ret0;
1258   state->dpix_n[6][0x7]=dpix_ret0;
1259   state->dpix_n[6][0x8]=dpix_2_8;
1260   state->dpix_n[6][0x9]=dpix_ret0;
1261   state->dpix_n[6][0xa]=dpix_ret0;
1262   state->dpix_n[6][0xb]=dpix_ret0;
1263   state->dpix_n[6][0xc]=dpix_ret0;
1264   state->dpix_n[6][0xd]=dpix_ret0;
1265   state->dpix_n[6][0xe]=dpix_ret0;
1266   state->dpix_n[6][0xf]=dpix_ret0;
13391267
1340   dpix_n[7][0x0]=dpix_3_0;
1341   dpix_n[7][0x1]=dpix_3_1;
1342   dpix_n[7][0x2]=dpix_3_2;
1343   dpix_n[7][0x3]=dpix_ret0;
1344   dpix_n[7][0x4]=dpix_ret0;
1345   dpix_n[7][0x5]=dpix_ret0;
1346   dpix_n[7][0x6]=dpix_ret0;
1347   dpix_n[7][0x7]=dpix_ret0;
1348   dpix_n[7][0x8]=dpix_ret0;
1349   dpix_n[7][0x9]=dpix_ret0;
1350   dpix_n[7][0xa]=dpix_ret0;
1351   dpix_n[7][0xb]=dpix_ret0;
1352   dpix_n[7][0xc]=dpix_ret0;
1353   dpix_n[7][0xd]=dpix_ret0;
1354   dpix_n[7][0xe]=dpix_ret0;
1355   dpix_n[7][0xf]=dpix_ret0;
1268   state->dpix_n[7][0x0]=dpix_3_0;
1269   state->dpix_n[7][0x1]=dpix_3_1;
1270   state->dpix_n[7][0x2]=dpix_3_2;
1271   state->dpix_n[7][0x3]=dpix_ret0;
1272   state->dpix_n[7][0x4]=dpix_ret0;
1273   state->dpix_n[7][0x5]=dpix_ret0;
1274   state->dpix_n[7][0x6]=dpix_ret0;
1275   state->dpix_n[7][0x7]=dpix_ret0;
1276   state->dpix_n[7][0x8]=dpix_ret0;
1277   state->dpix_n[7][0x9]=dpix_ret0;
1278   state->dpix_n[7][0xa]=dpix_ret0;
1279   state->dpix_n[7][0xb]=dpix_ret0;
1280   state->dpix_n[7][0xc]=dpix_ret0;
1281   state->dpix_n[7][0xd]=dpix_ret0;
1282   state->dpix_n[7][0xe]=dpix_ret0;
1283   state->dpix_n[7][0xf]=dpix_ret0;
13561284
13571285   for(i=0;i<256;i++)
13581286      for(j=0;j<256;j++)
1359         add_sat[i][j] = (i + j < 256) ? i + j : 255;
1287         state->add_sat[i][j] = (i + j < 256) ? i + j : 255;
13601288}
13611289
13621290/******************************************************************************/
r10886r10887
13641292#define GET_PIXMAP_POINTER(pf_num) \
13651293{ \
13661294   const struct f3_playfield_line_inf *line_tmp=line_t[pf_num]; \
1367   src##pf_num=line_tmp->src[y]; \
1368   src_s##pf_num=line_tmp->src_s[y]; \
1369   src_e##pf_num=line_tmp->src_e[y]; \
1370   tsrc##pf_num=line_tmp->tsrc[y]; \
1371   tsrc_s##pf_num=line_tmp->tsrc_s[y]; \
1372   x_count##pf_num=line_tmp->x_count[y]; \
1373   x_zoom##pf_num=line_tmp->x_zoom[y]; \
1374   clip_al##pf_num=line_tmp->clip0[y]&0xffff; \
1375   clip_ar##pf_num=line_tmp->clip0[y]>>16; \
1376   clip_bl##pf_num=line_tmp->clip1[y]&0xffff; \
1377   clip_br##pf_num=line_tmp->clip1[y]>>16; \
1295   state->src##pf_num=line_tmp->src[y]; \
1296   state->src_s##pf_num=line_tmp->src_s[y]; \
1297   state->src_e##pf_num=line_tmp->src_e[y]; \
1298   state->tsrc##pf_num=line_tmp->tsrc[y]; \
1299   state->tsrc_s##pf_num=line_tmp->tsrc_s[y]; \
1300   state->x_count##pf_num=line_tmp->x_count[y]; \
1301   state->x_zoom##pf_num=line_tmp->x_zoom[y]; \
1302   state->clip_al##pf_num=line_tmp->clip0[y]&0xffff; \
1303   state->clip_ar##pf_num=line_tmp->clip0[y]>>16; \
1304   state->clip_bl##pf_num=line_tmp->clip1[y]&0xffff; \
1305   state->clip_br##pf_num=line_tmp->clip1[y]>>16; \
13781306}
13791307
13801308#define CULC_PIXMAP_POINTER(pf_num) \
13811309{ \
1382   x_count##pf_num += x_zoom##pf_num; \
1383   if(x_count##pf_num>>16) \
1310   state->x_count##pf_num += state->x_zoom##pf_num; \
1311   if(state->x_count##pf_num>>16) \
13841312   { \
1385      x_count##pf_num &= 0xffff; \
1386      src##pf_num++; \
1387      tsrc##pf_num++; \
1388      if(src##pf_num==src_e##pf_num) {src##pf_num=src_s##pf_num; tsrc##pf_num=tsrc_s##pf_num;} \
1313      state->x_count##pf_num &= 0xffff; \
1314      state->src##pf_num++; \
1315      state->tsrc##pf_num++; \
1316      if(state->src##pf_num==state->src_e##pf_num) {state->src##pf_num=state->src_s##pf_num; state->tsrc##pf_num=state->tsrc_s##pf_num;} \
13891317   } \
13901318}
13911319
13921320#define UPDATE_PIXMAP_SP(pf_num) \
13931321   if(cx>=clip_als && cx<clip_ars && !(cx>=clip_bls && cx<clip_brs)) \
13941322   { \
1395      sprite_pri=sprite[pf_num]&pval; \
1323      sprite_pri=sprite[pf_num]&state->pval; \
13961324      if(sprite_pri) \
13971325      { \
13981326         if(sprite[pf_num]&0x100) break; \
1399         if(!dpix_sp[sprite_pri]) \
1327         if(!state->dpix_sp[sprite_pri]) \
14001328         { \
1401            if(!(pval&0xf0)) break; \
1402            else {dpix_1_sprite(*dsti);*dsti=dval;break;} \
1329            if(!(state->pval&0xf0)) break; \
1330            else {dpix_1_sprite(state, *dsti);*dsti=state->dval;break;} \
14031331         } \
1404         if(dpix_sp[sprite_pri][pval>>4](*dsti)) {*dsti=dval;break;} \
1332         if(state->dpix_sp[sprite_pri][state->pval>>4](state, *dsti)) {*dsti=state->dval;break;} \
14051333      } \
14061334   }
14071335
14081336#define UPDATE_PIXMAP_LP(pf_num) \
1409   if (cx>=clip_al##pf_num && cx<clip_ar##pf_num && !(cx>=clip_bl##pf_num && cx<clip_br##pf_num)) \
1337   if (cx>=state->clip_al##pf_num && cx<state->clip_ar##pf_num && !(cx>=state->clip_bl##pf_num && cx<state->clip_br##pf_num)) \
14101338   { \
1411      tval=*tsrc##pf_num; \
1412      if(tval&0xf0) \
1413         if(dpix_lp[pf_num][pval>>4](clut[*src##pf_num])) {*dsti=dval;break;} \
1339      state->tval=*state->tsrc##pf_num; \
1340      if(state->tval&0xf0) \
1341         if(state->dpix_lp[pf_num][state->pval>>4](state, clut[*state->src##pf_num])) {*dsti=state->dval;break;} \
14141342   }
14151343
14161344
r10886r10887
14231351      UINT32 orient,
14241352      int skip_layer_num)
14251353{
1354   taito_f3_state *state = machine->driver_data<taito_f3_state>();
14261355   const pen_t *clut = &machine->pens[0];
14271356   UINT32 bgcolor=clut[0];
14281357   int length;
14291358
14301359   const int x=46;
14311360
1432   static UINT16 *src0=0,*src_s0=0,*src_e0=0,clip_al0=0,clip_ar0=0,clip_bl0=0,clip_br0=0;
1433   static UINT8 *tsrc0=0,*tsrc_s0=0;
1434   static UINT32 x_count0=0,x_zoom0=0;
14351361
1436   static UINT16 *src1=0,*src_s1=0,*src_e1=0,clip_al1=0,clip_ar1=0,clip_bl1=0,clip_br1=0;
1437   static UINT8 *tsrc1=0,*tsrc_s1=0;
1438   static UINT32 x_count1=0,x_zoom1=0;
14391362
1440   static UINT16 *src2=0,*src_s2=0,*src_e2=0,clip_al2=0,clip_ar2=0,clip_bl2=0,clip_br2=0;
1441   static UINT8 *tsrc2=0,*tsrc_s2=0;
1442   static UINT32 x_count2=0,x_zoom2=0;
14431363
1444   static UINT16 *src3=0,*src_s3=0,*src_e3=0,clip_al3=0,clip_ar3=0,clip_bl3=0,clip_br3=0;
1445   static UINT8 *tsrc3=0,*tsrc_s3=0;
1446   static UINT32 x_count3=0,x_zoom3=0;
14471364
1448   static UINT16 *src4=0,*src_s4=0,*src_e4=0,clip_al4=0,clip_ar4=0,clip_bl4=0,clip_br4=0;
1449   static UINT8 *tsrc4=0,*tsrc_s4=0;
1450   static UINT32 x_count4=0,x_zoom4=0;
14511365
14521366   UINT16 clip_als=0, clip_ars=0, clip_bls=0, clip_brs=0;
14531367
r10886r10887
14631377      yadv = -yadv;
14641378   }
14651379
1466   dstp0 = BITMAP_ADDR8(pri_alp_bitmap, ty, x);
1380   dstp0 = BITMAP_ADDR8(state->pri_alp_bitmap, ty, x);
14671381
1468   pdest_2a = f3_alpha_level_2ad ? 0x10 : 0;
1469   pdest_2b = f3_alpha_level_2bd ? 0x20 : 0;
1470   tr_2a =(f3_alpha_level_2as==0 && f3_alpha_level_2ad==255) ? -1 : 0;
1471   tr_2b =(f3_alpha_level_2bs==0 && f3_alpha_level_2bd==255) ? -1 : 1;
1472   pdest_3a = f3_alpha_level_3ad ? 0x40 : 0;
1473   pdest_3b = f3_alpha_level_3bd ? 0x80 : 0;
1474   tr_3a =(f3_alpha_level_3as==0 && f3_alpha_level_3ad==255) ? -1 : 0;
1475   tr_3b =(f3_alpha_level_3bs==0 && f3_alpha_level_3bd==255) ? -1 : 1;
1382   state->pdest_2a = state->f3_alpha_level_2ad ? 0x10 : 0;
1383   state->pdest_2b = state->f3_alpha_level_2bd ? 0x20 : 0;
1384   state->tr_2a =(state->f3_alpha_level_2as==0 && state->f3_alpha_level_2ad==255) ? -1 : 0;
1385   state->tr_2b =(state->f3_alpha_level_2bs==0 && state->f3_alpha_level_2bd==255) ? -1 : 1;
1386   state->pdest_3a = state->f3_alpha_level_3ad ? 0x40 : 0;
1387   state->pdest_3b = state->f3_alpha_level_3bd ? 0x80 : 0;
1388   state->tr_3a =(state->f3_alpha_level_3as==0 && state->f3_alpha_level_3ad==255) ? -1 : 0;
1389   state->tr_3b =(state->f3_alpha_level_3bs==0 && state->f3_alpha_level_3bd==255) ? -1 : 1;
14761390
14771391   {
14781392      UINT32 *dsti0,*dsti;
r10886r10887
14811395      {
14821396         int cx=0;
14831397
1484         clip_als=sa_line_inf->sprite_clip0[y]&0xffff;
1485         clip_ars=sa_line_inf->sprite_clip0[y]>>16;
1486         clip_bls=sa_line_inf->sprite_clip1[y]&0xffff;
1487         clip_brs=sa_line_inf->sprite_clip1[y]>>16;
1398         clip_als=state->sa_line_inf[0].sprite_clip0[y]&0xffff;
1399         clip_ars=state->sa_line_inf[0].sprite_clip0[y]>>16;
1400         clip_bls=state->sa_line_inf[0].sprite_clip1[y]&0xffff;
1401         clip_brs=state->sa_line_inf[0].sprite_clip1[y]>>16;
14881402
14891403         length=xsize;
14901404         dsti = dsti0;
r10886r10887
15011415
15021416         while (1)
15031417         {
1504            pval=*dstp;
1505            if (pval!=0xff)
1418            state->pval=*dstp;
1419            if (state->pval!=0xff)
15061420            {
15071421               UINT8 sprite_pri;
15081422               switch(skip_layer_num)
r10886r10887
15131427                  case 3: UPDATE_PIXMAP_SP(3) UPDATE_PIXMAP_LP(3)
15141428                  case 4: UPDATE_PIXMAP_SP(4) UPDATE_PIXMAP_LP(4)
15151429                  case 5: UPDATE_PIXMAP_SP(5)
1516                        if(!bgcolor) {if(!(pval&0xf0)) {*dsti=0;break;}}
1517                        else dpix_bg(bgcolor);
1518                        *dsti=dval;
1430                        if(!bgcolor) {if(!(state->pval&0xf0)) {*dsti=0;break;}}
1431                        else dpix_bg(state, bgcolor);
1432                        *dsti=state->dval;
15191433               }
15201434            }
15211435
r10886r10887
15641478                        UINT32 x_index_fx,UINT32 y_index,
15651479                        UINT32 *f3_pf_data_n)
15661480{
1481   taito_f3_state *state = machine->driver_data<taito_f3_state>();
15671482   UINT32 *pf_base;
15681483   int i,trans_all,tile_index,tile_num;
15691484   int alpha_type,alpha_mode;
r10886r10887
15791494   tile_num=(((line_t->x_zoom[line]*320+(x_index_fx & 0xffff)+0xffff)>>16)+(tile_index%16)+15)/16;
15801495   tile_index/=16;
15811496
1582   if (flipscreen)
1497   if (state->flipscreen)
15831498   {
1584      pf_base=f3_pf_data_n+((31-(y_index/16))<<twidth_mask_bit);
1585      tile_index=(twidth_mask-tile_index)-tile_num+1;
1499      pf_base=f3_pf_data_n+((31-(y_index/16))<<state->twidth_mask_bit);
1500      tile_index=(state->twidth_mask-tile_index)-tile_num+1;
15861501   }
1587   else pf_base=f3_pf_data_n+((y_index/16)<<twidth_mask_bit);
1502   else pf_base=f3_pf_data_n+((y_index/16)<<state->twidth_mask_bit);
15881503
15891504
15901505   trans_all=1;
r10886r10887
15921507   alpha_type=0;
15931508   for(i=0;i<tile_num;i++)
15941509   {
1595      UINT32 tile=pf_base[(tile_index)&twidth_mask];
1510      UINT32 tile=pf_base[(tile_index)&state->twidth_mask];
15961511      UINT8  extra_planes = (tile>>(16+10)) & 3;
15971512      if(tile&0xffff)
15981513      {
15991514         trans_all=0;
16001515         if(opaque_all)
16011516         {
1602            if(tile_opaque_pf[extra_planes][(tile&0xffff)%total_elements]!=1) opaque_all=0;
1517            if(state->tile_opaque_pf[extra_planes][(tile&0xffff)%total_elements]!=1) opaque_all=0;
16031518         }
16041519
16051520         if(alpha_mode==1)
r10886r10887
16341549
16351550/******************************************************************************/
16361551
1637static void calculate_clip(int y, UINT16 pri, UINT32* clip0, UINT32* clip1, int* line_enable)
1552static void calculate_clip(taito_f3_state *state, int y, UINT16 pri, UINT32* clip0, UINT32* clip1, int* line_enable)
16381553{
1639   const struct f3_spritealpha_line_inf *sa_line_t=&sa_line_inf[0];
1554   const struct f3_spritealpha_line_inf *sa_line_t=&state->sa_line_inf[0];
16401555
16411556   switch (pri)
16421557   {
r10886r10887
17381653   }
17391654}
17401655
1741static void get_spritealphaclip_info(void)
1656static void get_spritealphaclip_info(taito_f3_state *state)
17421657{
1743   struct f3_spritealpha_line_inf *line_t=&sa_line_inf[0];
1658   struct f3_spritealpha_line_inf *line_t=&state->sa_line_inf[0];
17441659
17451660   int y,y_end,y_inc;
17461661
r10886r10887
17521667   int alpha_level=0;
17531668   UINT16 sprite_alpha=0;
17541669
1755   if (flipscreen)
1670   if (state->flipscreen)
17561671   {
17571672      spri_base=0x77fe;
17581673      clip_base_low=0x51fe;
r10886r10887
17791694      /* The zoom, column and row values can latch according to control ram */
17801695      if (y&1)
17811696      {
1782         if (f3_line_ram[0x080+(y>>1)]&1)
1783            clip0_low=(f3_line_ram[clip_base_low/4]>> 0)&0xffff;
1784         if (f3_line_ram[0x000+(y>>1)]&4)
1785            clip0_high=(f3_line_ram[clip_base_high/4]>> 0)&0xffff;
1786         if (f3_line_ram[0x080+(y>>1)]&2)
1787            clip1_low=(f3_line_ram[(clip_base_low+0x200)/4]>> 0)&0xffff;
1697         if (state->f3_line_ram[0x080+(y>>1)]&1)
1698            clip0_low=(state->f3_line_ram[clip_base_low/4]>> 0)&0xffff;
1699         if (state->f3_line_ram[0x000+(y>>1)]&4)
1700            clip0_high=(state->f3_line_ram[clip_base_high/4]>> 0)&0xffff;
1701         if (state->f3_line_ram[0x080+(y>>1)]&2)
1702            clip1_low=(state->f3_line_ram[(clip_base_low+0x200)/4]>> 0)&0xffff;
17881703
1789         if (f3_line_ram[(0x0600/4)+(y>>1)]&0x8)
1790            spri=f3_line_ram[spri_base/4]&0xffff;
1791         if (f3_line_ram[(0x0600/4)+(y>>1)]&0x4)
1792            sprite_clip=f3_line_ram[(spri_base-0x200)/4]&0xffff;
1793         if (f3_line_ram[(0x0400/4)+(y>>1)]&0x1)
1794            sprite_alpha=f3_line_ram[(spri_base-0x1600)/4]&0xffff;
1795         if (f3_line_ram[(0x0400/4)+(y>>1)]&0x2)
1796            alpha_level=f3_line_ram[(spri_base-0x1400)/4]&0xffff;
1704         if (state->f3_line_ram[(0x0600/4)+(y>>1)]&0x8)
1705            spri=state->f3_line_ram[spri_base/4]&0xffff;
1706         if (state->f3_line_ram[(0x0600/4)+(y>>1)]&0x4)
1707            sprite_clip=state->f3_line_ram[(spri_base-0x200)/4]&0xffff;
1708         if (state->f3_line_ram[(0x0400/4)+(y>>1)]&0x1)
1709            sprite_alpha=state->f3_line_ram[(spri_base-0x1600)/4]&0xffff;
1710         if (state->f3_line_ram[(0x0400/4)+(y>>1)]&0x2)
1711            alpha_level=state->f3_line_ram[(spri_base-0x1400)/4]&0xffff;
17971712      }
17981713      else
17991714      {
1800         if (f3_line_ram[0x080+(y>>1)]&0x10000)
1801            clip0_low=(f3_line_ram[clip_base_low/4]>>16)&0xffff;
1802         if (f3_line_ram[0x000+(y>>1)]&0x40000)
1803            clip0_high=(f3_line_ram[clip_base_high/4]>>16)&0xffff;
1804         if (f3_line_ram[0x080+(y>>1)]&0x20000)
1805            clip1_low=(f3_line_ram[(clip_base_low+0x200)/4]>>16)&0xffff;
1715         if (state->f3_line_ram[0x080+(y>>1)]&0x10000)
1716            clip0_low=(state->f3_line_ram[clip_base_low/4]>>16)&0xffff;
1717         if (state->f3_line_ram[0x000+(y>>1)]&0x40000)
1718            clip0_high=(state->f3_line_ram[clip_base_high/4]>>16)&0xffff;
1719         if (state->f3_line_ram[0x080+(y>>1)]&0x20000)
1720            clip1_low=(state->f3_line_ram[(clip_base_low+0x200)/4]>>16)&0xffff;
18061721
1807         if (f3_line_ram[(0x0600/4)+(y>>1)]&0x80000)
1808            spri=f3_line_ram[spri_base/4]>>16;
1809         if (f3_line_ram[(0x0600/4)+(y>>1)]&0x40000)
1810            sprite_clip=f3_line_ram[(spri_base-0x200)/4]>>16;
1811         if (f3_line_ram[(0x0400/4)+(y>>1)]&0x10000)
1812            sprite_alpha=f3_line_ram[(spri_base-0x1600)/4]>>16;
1813         if (f3_line_ram[(0x0400/4)+(y>>1)]&0x20000)
1814            alpha_level=f3_line_ram[(spri_base-0x1400)/4]>>16;
1722         if (state->f3_line_ram[(0x0600/4)+(y>>1)]&0x80000)
1723            spri=state->f3_line_ram[spri_base/4]>>16;
1724         if (state->f3_line_ram[(0x0600/4)+(y>>1)]&0x40000)
1725            sprite_clip=state->f3_line_ram[(spri_base-0x200)/4]>>16;
1726         if (state->f3_line_ram[(0x0400/4)+(y>>1)]&0x10000)
1727            sprite_alpha=state->f3_line_ram[(spri_base-0x1600)/4]>>16;
1728         if (state->f3_line_ram[(0x0400/4)+(y>>1)]&0x20000)
1729            alpha_level=state->f3_line_ram[(spri_base-0x1400)/4]>>16;
18151730      }
18161731
18171732      line_t->alpha_level[y]=alpha_level;
r10886r10887
18351750      else if (sprite_clip&0x33)
18361751      {
18371752         int line_enable=1;
1838         calculate_clip(y, ((sprite_clip&0x33)<<4), &line_t->sprite_clip0[y], &line_t->sprite_clip1[y], &line_enable);
1753         calculate_clip(state, y, ((sprite_clip&0x33)<<4), &line_t->sprite_clip0[y], &line_t->sprite_clip1[y], &line_enable);
18391754         if (line_enable==0)
18401755            line_t->sprite_clip0[y]=0x7fff7fff;
18411756      }
r10886r10887
18551770/* sx and sy are 16.16 fixed point numbers */
18561771static void get_line_ram_info(running_machine *machine, tilemap_t *tmap, int sx, int sy, int pos, UINT32 *f3_pf_data_n)
18571772{
1858   struct f3_playfield_line_inf *line_t=&pf_line_inf[pos];
1773   taito_f3_state *state = machine->driver_data<taito_f3_state>();
1774   struct f3_playfield_line_inf *line_t=&state->pf_line_inf[pos];
18591775   const bitmap_t *srcbitmap;
18601776   const bitmap_t *flagsbitmap;
18611777
r10886r10887
18751791
18761792   sx+=((46<<16));
18771793
1878   if (flipscreen)
1794   if (state->flipscreen)
18791795   {
18801796      line_base=0xa1fe + (pos*0x200);
18811797      zoom_base=0x81fe;// + (pos*0x200);
r10886r10887
18861802      y_end=-1;
18871803      y_inc=-1;
18881804
1889      if (f3_game_config->extend)   sx=-sx+((188-512)<<16); else sx=-sx+(188<<16); /* Adjust for flipped scroll position */
1805      if (state->f3_game_config->extend)   sx=-sx+((188-512)<<16); else sx=-sx+(188<<16); /* Adjust for flipped scroll position */
18901806      y_index_fx=-sy-(256<<16); /* Adjust for flipped scroll position */
18911807   }
18921808   else
r10886r10887
19091825      /* The zoom, column and row values can latch according to control ram */
19101826      if (y&1)
19111827      {
1912         if (f3_line_ram[0x300+(y>>1)]&bit_select1)
1913            x_offset=(f3_line_ram[line_base/4]&0xffff)<<10;
1914         if (f3_line_ram[0x380+(y>>1)]&bit_select1)
1915            pri=f3_line_ram[pri_base/4]&0xffff;
1828         if (state->f3_line_ram[0x300+(y>>1)]&bit_select1)
1829            x_offset=(state->f3_line_ram[line_base/4]&0xffff)<<10;
1830         if (state->f3_line_ram[0x380+(y>>1)]&bit_select1)
1831            pri=state->f3_line_ram[pri_base/4]&0xffff;
19161832
19171833         // Zoom for playfields 1 & 3 is interleaved, as is the latch select
19181834         switch (pos)
19191835         {
19201836         case 0:
1921            if (f3_line_ram[0x200+(y>>1)]&bit_select1)
1922               line_zoom=f3_line_ram[(zoom_base+0x000)/4]&0xffff;
1837            if (state->f3_line_ram[0x200+(y>>1)]&bit_select1)
1838               line_zoom=state->f3_line_ram[(zoom_base+0x000)/4]&0xffff;
19231839            break;
19241840         case 1:
1925            if (f3_line_ram[0x200+(y>>1)]&0x2)
1926               line_zoom=((f3_line_ram[(zoom_base+0x200)/4]&0xffff)&0xff00) | (line_zoom&0x00ff);
1927            if (f3_line_ram[0x200+(y>>1)]&0x8)
1928               line_zoom=((f3_line_ram[(zoom_base+0x600)/4]&0xffff)&0x00ff) | (line_zoom&0xff00);
1841            if (state->f3_line_ram[0x200+(y>>1)]&0x2)
1842               line_zoom=((state->f3_line_ram[(zoom_base+0x200)/4]&0xffff)&0xff00) | (line_zoom&0x00ff);
1843            if (state->f3_line_ram[0x200+(y>>1)]&0x8)
1844               line_zoom=((state->f3_line_ram[(zoom_base+0x600)/4]&0xffff)&0x00ff) | (line_zoom&0xff00);
19291845            break;
19301846         case 2:
1931            if (f3_line_ram[0x200+(y>>1)]&bit_select1)
1932               line_zoom=f3_line_ram[(zoom_base+0x400)/4]&0xffff;
1847            if (state->f3_line_ram[0x200+(y>>1)]&bit_select1)
1848               line_zoom=state->f3_line_ram[(zoom_base+0x400)/4]&0xffff;
19331849            break;
19341850         case 3:
1935            if (f3_line_ram[0x200+(y>>1)]&0x8)
1936               line_zoom=((f3_line_ram[(zoom_base+0x600)/4]&0xffff)&0xff00) | (line_zoom&0x00ff);
1937            if (f3_line_ram[0x200+(y>>1)]&0x2)
1938               line_zoom=((f3_line_ram[(zoom_base+0x200)/4]&0xffff)&0x00ff) | (line_zoom&0xff00);
1851            if (state->f3_line_ram[0x200+(y>>1)]&0x8)
1852               line_zoom=((state->f3_line_ram[(zoom_base+0x600)/4]&0xffff)&0xff00) | (line_zoom&0x00ff);
1853            if (state->f3_line_ram[0x200+(y>>1)]&0x2)
1854               line_zoom=((state->f3_line_ram[(zoom_base+0x200)/4]&0xffff)&0x00ff) | (line_zoom&0xff00);
19391855            break;
19401856         default:
19411857            break;
19421858         }
19431859
19441860         // Column scroll only affects playfields 2 & 3
1945         if (pos>=2 && f3_line_ram[0x000+(y>>1)]&bit_select1)
1946            colscroll=(f3_line_ram[col_base/4]>> 0)&0x3ff;
1861         if (pos>=2 && state->f3_line_ram[0x000+(y>>1)]&bit_select1)
1862            colscroll=(state->f3_line_ram[col_base/4]>> 0)&0x3ff;
19471863      }
19481864      else
19491865      {
1950         if (f3_line_ram[0x300+(y>>1)]&bit_select0)
1951            x_offset=(f3_line_ram[line_base/4]&0xffff0000)>>6;
1866         if (state->f3_line_ram[0x300+(y>>1)]&bit_select0)
1867            x_offset=(state->f3_line_ram[line_base/4]&0xffff0000)>>6;
19521868
1953         if (f3_line_ram[0x380+(y>>1)]&bit_select0)
1954            pri=(f3_line_ram[pri_base/4]>>16)&0xffff;
1869         if (state->f3_line_ram[0x380+(y>>1)]&bit_select0)
1870            pri=(state->f3_line_ram[pri_base/4]>>16)&0xffff;
19551871
19561872         // Zoom for playfields 1 & 3 is interleaved, as is the latch select
19571873         switch (pos)
19581874         {
19591875         case 0:
1960            if (f3_line_ram[0x200+(y>>1)]&bit_select0)
1961               line_zoom=f3_line_ram[(zoom_base+0x000)/4]>>16;
1876            if (state->f3_line_ram[0x200+(y>>1)]&bit_select0)
1877               line_zoom=state->f3_line_ram[(zoom_base+0x000)/4]>>16;
19621878            break;
19631879         case 1:
1964            if (f3_line_ram[0x200+(y>>1)]&0x20000)
1965               line_zoom=((f3_line_ram[(zoom_base+0x200)/4]>>16)&0xff00) | (line_zoom&0x00ff);
1966            if (f3_line_ram[0x200+(y>>1)]&0x80000)
1967               line_zoom=((f3_line_ram[(zoom_base+0x600)/4]>>16)&0x00ff) | (line_zoom&0xff00);
1880            if (state->f3_line_ram[0x200+(y>>1)]&0x20000)
1881               line_zoom=((state->f3_line_ram[(zoom_base+0x200)/4]>>16)&0xff00) | (line_zoom&0x00ff);
1882            if (state->f3_line_ram[0x200+(y>>1)]&0x80000)
1883               line_zoom=((state->f3_line_ram[(zoom_base+0x600)/4]>>16)&0x00ff) | (line_zoom&0xff00);
19681884            break;
19691885         case 2:
1970            if (f3_line_ram[0x200+(y>>1)]&bit_select0)
1971               line_zoom=f3_line_ram[(zoom_base+0x400)/4]>>16;
1886            if (state->f3_line_ram[0x200+(y>>1)]&bit_select0)
1887               line_zoom=state->f3_line_ram[(zoom_base+0x400)/4]>>16;
19721888            break;
19731889         case 3:
1974            if (f3_line_ram[0x200+(y>>1)]&0x80000)
1975               line_zoom=((f3_line_ram[(zoom_base+0x600)/4]>>16)&0xff00) | (line_zoom&0x00ff);
1976            if (f3_line_ram[0x200+(y>>1)]&0x20000)
1977               line_zoom=((f3_line_ram[(zoom_base+0x200)/4]>>16)&0x00ff) | (line_zoom&0xff00);
1890            if (state->f3_line_ram[0x200+(y>>1)]&0x80000)
1891               line_zoom=((state->f3_line_ram[(zoom_base+0x600)/4]>>16)&0xff00) | (line_zoom&0x00ff);
1892            if (state->f3_line_ram[0x200+(y>>1)]&0x20000)
1893               line_zoom=((state->f3_line_ram[(zoom_base+0x200)/4]>>16)&0x00ff) | (line_zoom&0xff00);
19781894            break;
19791895         default:
19801896            break;
19811897         }
19821898
19831899         // Column scroll only affects playfields 2 & 3
1984         if (pos>=2 && f3_line_ram[0x000+(y>>1)]&bit_select0)
1985            colscroll=(f3_line_ram[col_base/4]>>16)&0x3ff;
1900         if (pos>=2 && state->f3_line_ram[0x000+(y>>1)]&bit_select0)
1901            colscroll=(state->f3_line_ram[col_base/4]>>16)&0x3ff;
19861902      }
19871903
1988      if (!pri || (!flipscreen && y<24) || (flipscreen && y>231) ||
1904      if (!pri || (!state->flipscreen && y<24) || (state->flipscreen && y>231) ||
19891905         (pri&0xc000)==0xc000 || !(pri&0x2000)/**/)
19901906         line_enable=0;
19911907      else if(pri&0x4000)   //alpha1
r10886r10887
20131929      else if (pri&0x0330)
20141930      {
20151931         //fast path todo - remove line enable
2016         calculate_clip(y, pri&0x0330, &line_t->clip0[y], &line_t->clip1[y], &line_enable);
1932         calculate_clip(state, y, pri&0x0330, &line_t->clip0[y], &line_t->clip1[y], &line_enable);
20171933      }
20181934      else
20191935      {
r10886r10887
20481964         UINT16 *src_s;
20491965         UINT8 *tsrc_s;
20501966
2051         x_index_fx = (sx+_x_offset[y]-(10*0x10000)+(10*line_t->x_zoom[y]))&((width_mask<<16)|0xffff);
1967         x_index_fx = (sx+_x_offset[y]-(10*0x10000)+(10*line_t->x_zoom[y]))&((state->width_mask<<16)|0xffff);
20521968         y_index = ((y_index_fx>>16)+_colscroll[y])&0x1ff;
20531969
20541970         /* check tile status */
r10886r10887
20611977         /* set pixmap index */
20621978         line_t->x_count[y]=x_index_fx & 0xffff; // Fractional part
20631979         line_t->src_s[y]=src_s=BITMAP_ADDR16(srcbitmap, y_index, 0);
2064         line_t->src_e[y]=&src_s[width_mask+1];
1980         line_t->src_e[y]=&src_s[state->width_mask+1];
20651981         line_t->src[y]=&src_s[x_index_fx>>16];
20661982
20671983         line_t->tsrc_s[y]=tsrc_s=BITMAP_ADDR8(flagsbitmap, y_index, 0);
r10886r10887
20731989   }
20741990}
20751991
2076static void get_vram_info(tilemap_t *vram_tilemap, tilemap_t *pixel_tilemap, int sx, int sy)
1992static void get_vram_info(running_machine *machine, tilemap_t *vram_tilemap, tilemap_t *pixel_tilemap, int sx, int sy)
20771993{
2078   const struct f3_spritealpha_line_inf *sprite_alpha_line_t=&sa_line_inf[0];
2079   struct f3_playfield_line_inf *line_t=&pf_line_inf[4];
1994   taito_f3_state *state = machine->driver_data<taito_f3_state>();
1995   const struct f3_spritealpha_line_inf *sprite_alpha_line_t=&state->sa_line_inf[0];
1996   struct f3_playfield_line_inf *line_t=&state->pf_line_inf[4];
20801997   const bitmap_t *srcbitmap_pixel, *srcbitmap_vram;
20811998   const bitmap_t *flagsbitmap_pixel, *flagsbitmap_vram;
20821999
r10886r10887
20892006
20902007   const int vram_width_mask=0x1ff;
20912008
2092   if (flipscreen)
2009   if (state->flipscreen)
20932010   {
20942011      pri_base =0x73fe;
20952012      inc=-2;
r10886r10887
21132030      /* The zoom, column and row values can latch according to control ram */
21142031      if (y&1)
21152032      {
2116         if (f3_line_ram[(0x0600/4)+(y>>1)]&0x2)
2117            pri=(f3_line_ram[pri_base/4]&0xffff);
2033         if (state->f3_line_ram[(0x0600/4)+(y>>1)]&0x2)
2034            pri=(state->f3_line_ram[pri_base/4]&0xffff);
21182035      }
21192036      else
21202037      {
2121         if (f3_line_ram[(0x0600/4)+(y>>1)]&0x20000)
2122            pri=(f3_line_ram[pri_base/4]&0xffff0000)>>16;
2038         if (state->f3_line_ram[(0x0600/4)+(y>>1)]&0x20000)
2039            pri=(state->f3_line_ram[pri_base/4]&0xffff0000)>>16;
21232040      }
21242041
2125      if (!pri || (!flipscreen && y<24) || (flipscreen && y>231) ||
2042      if (!pri || (!state->flipscreen && y<24) || (state->flipscreen && y>231) ||
21262043         (pri&0xc000)==0xc000 || !(pri&0x2000)/**/)
21272044         line_enable=0;
21282045      else if(pri&0x4000)   //alpha1
r10886r10887
21402057      else if (pri&0x0330)
21412058      {
21422059         //fast path todo - remove line enable
2143         calculate_clip(y, pri&0x0330, &line_t->clip0[y], &line_t->clip1[y], &line_enable);
2060         calculate_clip(state, y, pri&0x0330, &line_t->clip0[y], &line_t->clip1[y], &line_enable);
21442061      }
21452062      else
21462063      {
r10886r10887
22032120
22042121static void scanline_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
22052122{
2123   taito_f3_state *state = machine->driver_data<taito_f3_state>();
22062124   int i,j,y,ys,ye;
22072125   int y_start,y_end,y_start_next,y_end_next;
22082126   UINT8 draw_line[256];
r10886r10887
22102128
22112129   UINT32 rot=0;
22122130
2213   if (flipscreen)
2131   if (state->flipscreen)
22142132   {
22152133      rot=ORIENTATION_FLIP_Y;
22162134      ys=0;
r10886r10887
22362154      int spri;
22372155      int alpha;
22382156      int layer_tmp[5];
2239
2157      struct f3_playfield_line_inf *pf_line_inf = state->pf_line_inf;
2158      struct f3_spritealpha_line_inf *sa_line_inf = state->sa_line_inf;
22402159      int count_skip_layer=0;
22412160      int sprite[6]={0,0,0,0,0,0};
22422161      const struct f3_playfield_line_inf *line_t[5];
r10886r10887
23112230         (sprite_alpha&0xff) != 0xff  )
23122231      {
23132232         /* set alpha level */
2314         if(alpha_level!=alpha_level_last)
2233         if(alpha_level!=state->alpha_level_last)
23152234         {
23162235            int al_s,al_d;
23172236            int a=alpha_level;
r10886r10887
23252244            al_d = ( (15-b)*256) / 8;
23262245            if(al_s>255) al_s = 255;
23272246            if(al_d>255) al_d = 255;
2328            f3_alpha_level_3as = al_s;
2329            f3_alpha_level_3ad = al_d;
2330            f3_alpha_level_2as = al_d;
2331            f3_alpha_level_2ad = al_s;
2247            state->f3_alpha_level_3as = al_s;
2248            state->f3_alpha_level_3ad = al_d;
2249            state->f3_alpha_level_2as = al_d;
2250            state->f3_alpha_level_2ad = al_s;
23322251
23332252            al_s = ( (15-c)*256) / 8;
23342253            al_d = ( (15-a)*256) / 8;
23352254            if(al_s>255) al_s = 255;
23362255            if(al_d>255) al_d = 255;
2337            f3_alpha_level_3bs = al_s;
2338            f3_alpha_level_3bd = al_d;
2339            f3_alpha_level_2bs = al_d;
2340            f3_alpha_level_2bd = al_s;
2256            state->f3_alpha_level_3bs = al_s;
2257            state->f3_alpha_level_3bd = al_d;
2258            state->f3_alpha_level_2bs = al_d;
2259            state->f3_alpha_level_2bd = al_s;
23412260
2342            f3_alpha_set_level();
2343            alpha_level_last=alpha_level;
2261            f3_alpha_set_level(state);
2262            state->alpha_level_last=alpha_level;
23442263         }
23452264
23462265         /* set sprite alpha mode */
23472266         sprite_alpha_check=0;
23482267         sprite_alpha_all_2a=1;
2349         dpix_sp[1]=0;
2350         dpix_sp[2]=0;
2351         dpix_sp[4]=0;
2352         dpix_sp[8]=0;
2268         state->dpix_sp[1]=0;
2269         state->dpix_sp[2]=0;
2270         state->dpix_sp[4]=0;
2271         state->dpix_sp[8]=0;
23532272         for(i=0;i<4;i++)   /* i = sprite priority offset */
23542273         {
23552274            UINT8 sprite_alpha_mode=(sprite_alpha>>(i*2))&3;
23562275            UINT8 sftbit=1<<i;
2357            if(sprite_pri_usage&sftbit)
2276            if(state->sprite_pri_usage&sftbit)
23582277            {
23592278               if(sprite_alpha_mode==1)
23602279               {
2361                  if(f3_alpha_level_2as==0 && f3_alpha_level_2ad==255)
2362                     sprite_pri_usage&=~sftbit;  // Disable sprite priority block
2280                  if(state->f3_alpha_level_2as==0 && state->f3_alpha_level_2ad==255)
2281                     state->sprite_pri_usage&=~sftbit;  // Disable sprite priority block
23632282                  else
23642283                  {
2365                     dpix_sp[sftbit]=dpix_n[2];
2284                     state->dpix_sp[sftbit]=state->dpix_n[2];
23662285                     sprite_alpha_check|=sftbit;
23672286                  }
23682287               }
r10886r10887
23702289               {
23712290                  if(sprite_alpha&0xff00)
23722291                  {
2373                     if(f3_alpha_level_3as==0 && f3_alpha_level_3ad==255) sprite_pri_usage&=~sftbit;
2292                     if(state->f3_alpha_level_3as==0 && state->f3_alpha_level_3ad==255) state->sprite_pri_usage&=~sftbit;
23742293                     else
23752294                     {
2376                        dpix_sp[sftbit]=dpix_n[3];
2295                        state->dpix_sp[sftbit]=state->dpix_n[3];
23772296                        sprite_alpha_check|=sftbit;
23782297                        sprite_alpha_all_2a=0;
23792298                     }
23802299                  }
23812300                  else
23822301                  {
2383                     if(f3_alpha_level_3bs==0 && f3_alpha_level_3bd==255) sprite_pri_usage&=~sftbit;
2302                     if(state->f3_alpha_level_3bs==0 && state->f3_alpha_level_3bd==255) state->sprite_pri_usage&=~sftbit;
23842303                     else
23852304                     {
2386                        dpix_sp[sftbit]=dpix_n[5];
2305                        state->dpix_sp[sftbit]=state->dpix_n[5];
23872306                        sprite_alpha_check|=sftbit;
23882307                        sprite_alpha_all_2a=0;
23892308                     }
r10886r10887
24022321            {
24032322               if(alpha_type==1)
24042323               {
2405                  /* if (f3_alpha_level_2as==0   && f3_alpha_level_2ad==255)
2324                  /* if (state->f3_alpha_level_2as==0   && state->f3_alpha_level_2ad==255)
24062325                         *     alpha_mode[i]=3; alpha_mode_flag[i] |= 0x80;}
24072326                         * will display continue screen in gseeker (mt 00026) */
2408                  if     (f3_alpha_level_2as==0   && f3_alpha_level_2ad==255) alpha_mode[i]=0;
2409                  else if(f3_alpha_level_2as==255 && f3_alpha_level_2ad==0  ) alpha_mode[i]=1;
2327                  if     (state->f3_alpha_level_2as==0   && state->f3_alpha_level_2ad==255) alpha_mode[i]=0;
2328                  else if(state->f3_alpha_level_2as==255 && state->f3_alpha_level_2ad==0  ) alpha_mode[i]=1;
24102329               }
24112330               else if(alpha_type==2)
24122331               {
2413                  if     (f3_alpha_level_2bs==0   && f3_alpha_level_2bd==255) alpha_mode[i]=0;
2414                  else if(f3_alpha_level_2as==255 && f3_alpha_level_2ad==0 &&
2415                        f3_alpha_level_2bs==255 && f3_alpha_level_2bd==0  ) alpha_mode[i]=1;
2332                  if     (state->f3_alpha_level_2bs==0   && state->f3_alpha_level_2bd==255) alpha_mode[i]=0;
2333                  else if(state->f3_alpha_level_2as==255 && state->f3_alpha_level_2ad==0 &&
2334                        state->f3_alpha_level_2bs==255 && state->f3_alpha_level_2bd==0  ) alpha_mode[i]=1;
24162335               }
24172336               else if(alpha_type==3)
24182337               {
2419                  if     (f3_alpha_level_2as==0   && f3_alpha_level_2ad==255 &&
2420                        f3_alpha_level_2bs==0   && f3_alpha_level_2bd==255) alpha_mode[i]=0;
2421                  else if(f3_alpha_level_2as==255 && f3_alpha_level_2ad==0   &&
2422                        f3_alpha_level_2bs==255 && f3_alpha_level_2bd==0  ) alpha_mode[i]=1;
2338                  if     (state->f3_alpha_level_2as==0   && state->f3_alpha_level_2ad==255 &&
2339                        state->f3_alpha_level_2bs==0   && state->f3_alpha_level_2bd==255) alpha_mode[i]=0;
2340                  else if(state->f3_alpha_level_2as==255 && state->f3_alpha_level_2ad==0   &&
2341                        state->f3_alpha_level_2bs==255 && state->f3_alpha_level_2bd==0  ) alpha_mode[i]=1;
24232342               }
24242343            }
24252344            else if(alpha_mode[i]==3)
24262345            {
24272346               if(alpha_type==1)
24282347               {
2429                  if     (f3_alpha_level_3as==0   && f3_alpha_level_3ad==255) alpha_mode[i]=0;
2430                  else if(f3_alpha_level_3as==255 && f3_alpha_level_3ad==0  ) alpha_mode[i]=1;
2348                  if     (state->f3_alpha_level_3as==0   && state->f3_alpha_level_3ad==255) alpha_mode[i]=0;
2349                  else if(state->f3_alpha_level_3as==255 && state->f3_alpha_level_3ad==0  ) alpha_mode[i]=1;
24312350               }
24322351               else if(alpha_type==2)
24332352               {
2434                  if     (f3_alpha_level_3bs==0   && f3_alpha_level_3bd==255) alpha_mode[i]=0;
2435                  else if(f3_alpha_level_3as==255 && f3_alpha_level_3ad==0 &&
2436                        f3_alpha_level_3bs==255 && f3_alpha_level_3bd==0  ) alpha_mode[i]=1;
2353                  if     (state->f3_alpha_level_3bs==0   && state->f3_alpha_level_3bd==255) alpha_mode[i]=0;
2354                  else if(state->f3_alpha_level_3as==255 && state->f3_alpha_level_3ad==0 &&
2355                        state->f3_alpha_level_3bs==255 && state->f3_alpha_level_3bd==0  ) alpha_mode[i]=1;
24372356               }
24382357               else if(alpha_type==3)
24392358               {
2440                  if     (f3_alpha_level_3as==0   && f3_alpha_level_3ad==255 &&
2441                        f3_alpha_level_3bs==0   && f3_alpha_level_3bd==255) alpha_mode[i]=0;
2442                  else if(f3_alpha_level_3as==255 && f3_alpha_level_3ad==0   &&
2443                        f3_alpha_level_3bs==255 && f3_alpha_level_3bd==0  ) alpha_mode[i]=1;
2359                  if     (state->f3_alpha_level_3as==0   && state->f3_alpha_level_3ad==255 &&
2360                        state->f3_alpha_level_3bs==0   && state->f3_alpha_level_3bd==255) alpha_mode[i]=0;
2361                  else if(state->f3_alpha_level_3as==255 && state->f3_alpha_level_3ad==0   &&
2362                        state->f3_alpha_level_3bs==255 && state->f3_alpha_level_3bd==0  ) alpha_mode[i]=1;
24442363               }
24452364            }
24462365         }
r10886r10887
24532372               sprite_alpha_all_2a                  )
24542373         {
24552374            int alpha_type = (alpha_mode_flag[0] | alpha_mode_flag[1] | alpha_mode_flag[2] | alpha_mode_flag[3])&0x30;
2456            if(      (alpha_type==0x10 && f3_alpha_level_2as==255) ||
2457                  (alpha_type==0x20 && f3_alpha_level_2as==255 && f3_alpha_level_2bs==255) ||
2458                  (alpha_type==0x30 && f3_alpha_level_2as==255 && f3_alpha_level_2bs==255)   )
2375            if(      (alpha_type==0x10 && state->f3_alpha_level_2as==255) ||
2376                  (alpha_type==0x20 && state->f3_alpha_level_2as==255 && state->f3_alpha_level_2bs==255) ||
2377                  (alpha_type==0x30 && state->f3_alpha_level_2as==255 && state->f3_alpha_level_2bs==255)   )
24592378            {
24602379               if(alpha_mode[0]>1) alpha_mode[0]=1;
24612380               if(alpha_mode[1]>1) alpha_mode[1]=1;
r10886r10887
24632382               if(alpha_mode[3]>1) alpha_mode[3]=1;
24642383               if(alpha_mode[4]>1) alpha_mode[4]=1;
24652384               sprite_alpha_check=0;
2466               dpix_sp[1]=0;
2467               dpix_sp[2]=0;
2468               dpix_sp[4]=0;
2469               dpix_sp[8]=0;
2385               state->dpix_sp[1]=0;
2386               state->dpix_sp[2]=0;
2387               state->dpix_sp[4]=0;
2388               state->dpix_sp[8]=0;
24702389            }
24712390         }
24722391      }
24732392      else
24742393      {
24752394         sprite_alpha_check=0;
2476         dpix_sp[1]=0;
2477         dpix_sp[2]=0;
2478         dpix_sp[4]=0;
2479         dpix_sp[8]=0;
2395         state->dpix_sp[1]=0;
2396         state->dpix_sp[2]=0;
2397         state->dpix_sp[4]=0;
2398         state->dpix_sp[8]=0;
24802399      }
24812400
24822401
r10886r10887
25472466         for(i=0;i<4;i++)   /* i = sprite priority offset */
25482467         {
25492468            int sp,sflg=1<<i;
2550            if(!(sprite_pri_usage & sflg)) continue;
2469            if(!(state->sprite_pri_usage & sflg)) continue;
25512470            sp=pri_sp[i];
25522471
25532472            /*
r10886r10887
25572476                        DARIUSG (ZONE V' BOSS) ---> playfield
25582477                */
25592478
2560            if (f3_game == BUBSYMPH ) sp++;      //BUBSYMPH (title)
2561            if (f3_game == GSEEKER ) sp++;      //GSEEKER (plane leaving hangar)
2479            if (state->f3_game == BUBSYMPH ) sp++;      //BUBSYMPH (title)
2480            if (state->f3_game == GSEEKER ) sp++;      //GSEEKER (plane leaving hangar)
25622481
25632482                if(        sp>l0) sprite[0]|=sflg;
25642483            else if(sp<=l0 && sp>l1) sprite[1]|=sflg;
r10886r10887
25832502         if(alpha_mode[pos]>1)
25842503         {
25852504            int alpha_type=(((alpha_mode_flag[pos]>>4)&3)-1)*2;
2586            dpix_lp[i]=dpix_n[alpha_mode[pos]+alpha_type];
2505            state->dpix_lp[i]=state->dpix_n[alpha_mode[pos]+alpha_type];
25872506            alpha=1;
25882507         }
25892508         else
25902509         {
2591            if(alpha) dpix_lp[i]=dpix_n[1];
2592            else     dpix_lp[i]=dpix_n[0];
2510            if(alpha) state->dpix_lp[i]=state->dpix_n[1];
2511            else     state->dpix_lp[i]=state->dpix_n[0];
25932512         }
25942513      }
25952514      if(sprite[5]&sprite_alpha_check) alpha=1;
r10886r10887
26032522/******************************************************************************/
26042523
26052524#define PSET_T               \
2606   c = *source & sprite_pen_mask;   \
2525   c = *source & state->sprite_pen_mask;   \
26072526   if(c)                  \
26082527   {                     \
26092528      p=*pri;               \
r10886r10887
26182537   p=*pri;                  \
26192538   if(!p || p==0xff)         \
26202539   {                     \
2621      *dest = pal[*source & sprite_pen_mask];   \
2540      *dest = pal[*source & state->sprite_pen_mask];   \
26222541      *pri = pri_dst;         \
26232542   }
26242543
r10886r10887
26352554      int sx,int sy,
26362555      UINT8 pri_dst)
26372556{
2557   taito_f3_state *state = gfx->machine->driver_data<taito_f3_state>();
26382558   rectangle myclip;
26392559
26402560   pri_dst=1<<pri_dst;
r10886r10887
27242644//              if (dest_bmp->bpp == 32)
27252645            {
27262646               int y=ey-sy;
2727               int x=(ex-sx-1)|(tile_opaque_sp[code % gfx->total_elements]<<4);
2647               int x=(ex-sx-1)|(state->tile_opaque_sp[code % gfx->total_elements]<<4);
27282648               const UINT8 *source0 = code_base + y_index * 16 + x_index_base;
27292649               UINT32 *dest0 = BITMAP_ADDR32(dest_bmp, sy, sx);
2730               UINT8 *pri0 = BITMAP_ADDR8(pri_alp_bitmap, sy, sx);
2650               UINT8 *pri0 = BITMAP_ADDR8(state->pri_alp_bitmap, sy, sx);
27312651               int yadv = dest_bmp->rowpixels;
27322652               dy=dy*16;
27332653               while(1)
r10886r10887
27992719      int scalex, int scaley,
28002720      UINT8 pri_dst)
28012721{
2722   taito_f3_state *state = gfx->machine->driver_data<taito_f3_state>();
28022723   rectangle myclip;
28032724
28042725   pri_dst=1<<pri_dst;
r10886r10887
28922813               {
28932814                  const UINT8 *source = code_base + (y_index>>16) * 16;
28942815                  UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
2895                  UINT8 *pri = BITMAP_ADDR8(pri_alp_bitmap, y, 0);
2816                  UINT8 *pri = BITMAP_ADDR8(state->pri_alp_bitmap, y, 0);
28962817
28972818                  int x, x_index = x_index_base;
28982819                  for( x=sx; x<ex; x++ )
28992820                  {
2900                     int c = source[x_index>>16] & sprite_pen_mask;
2821                     int c = source[x_index>>16] & state->sprite_pen_mask;
29012822                     if(c)
29022823                     {
29032824                        UINT8 p=pri[x];
r10886r10887
29272848
29282849static void get_sprite_info(running_machine *machine, const UINT32 *spriteram32_ptr)
29292850{
2851   taito_f3_state *state = machine->driver_data<taito_f3_state>();
29302852   const rectangle &visarea = machine->primary_screen->visible_area();
29312853   const int min_x=visarea.min_x,max_x=visarea.max_x;
29322854   const int min_y=visarea.min_y,max_y=visarea.max_y;
r10886r10887
29412863
29422864   int x_addition_left = 8, y_addition_left = 8;
29432865
2944   struct tempsprite *sprite_ptr = spritelist;
2866   struct tempsprite *sprite_ptr = state->spritelist;
29452867
29462868   int total_sprites=0;
29472869
r10886r10887
29682890      /* Check if special command bit is set */
29692891      if (spriteram32_ptr[current_offs+1] & 0x8000) {
29702892         UINT32 cntrl=(spriteram32_ptr[current_offs+2])&0xffff;
2971         flipscreen=cntrl&0x2000;
2893         state->flipscreen=cntrl&0x2000;
29722894
29732895         /*  cntrl&0x1000 = disabled?  (From F2 driver, doesn't seem used anywhere)
29742896                cntrl&0x0010 = ???
29752897                cntrl&0x0020 = ???
29762898            */
29772899
2978         sprite_extra_planes = (cntrl & 0x0300) >> 8;   // 0 = 4bpp, 1 = 5bpp, 2 = unused?, 3 = 6bpp
2979         sprite_pen_mask = (sprite_extra_planes << 4) | 0x0f;
2900         state->sprite_extra_planes = (cntrl & 0x0300) >> 8;   // 0 = 4bpp, 1 = 5bpp, 2 = unused?, 3 = 6bpp
2901         state->sprite_pen_mask = (state->sprite_extra_planes << 4) | 0x0f;
29802902
29812903         /* Sprite bank select */
29822904         if (cntrl&1) {
r10886r10887
30172939/* These games either don't set the XY control bits properly (68020 bug?), or
30182940    have some different mode from the others */
30192941#ifdef DARIUSG_KLUDGE
3020      if (f3_game==DARIUSG || f3_game==GEKIRIDO || f3_game==CLEOPATR || f3_game==RECALH)
2942      if (state->f3_game==DARIUSG || state->f3_game==GEKIRIDO || state->f3_game==CLEOPATR || state->f3_game==RECALH)
30212943         multi=spritecont&0xf0;
30222944#endif
30232945
r10886r10887
30282950         else color=(spriteram32_ptr[current_offs+2]>>16)&0xff;
30292951
30302952#ifdef DARIUSG_KLUDGE
3031         if (f3_game==DARIUSG || f3_game==GEKIRIDO || f3_game==CLEOPATR || f3_game==RECALH) {
2953         if (state->f3_game==DARIUSG || state->f3_game==GEKIRIDO || state->f3_game==CLEOPATR || state->f3_game==RECALH) {
30322954            /* Adjust X Position */
30332955            if ((spritecont & 0x40) == 0) {
30342956               if (spritecont & 0x4) {
r10886r10887
31563078      if (!sprite) continue;
31573079      if (!x_addition || !y_addition) continue;
31583080
3159      if (flipscreen)
3081      if (state->flipscreen)
31603082      {
31613083         int tx,ty;
31623084
r10886r10887
31873109      sprite_ptr++;
31883110      total_sprites++;
31893111   }
3190   sprite_end = sprite_ptr;
3112   state->sprite_end = sprite_ptr;
31913113}
31923114#undef CALC_ZOOM
31933115
31943116
31953117static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
31963118{
3119   taito_f3_state *state = machine->driver_data<taito_f3_state>();
31973120   const struct tempsprite *sprite_ptr;
31983121   const gfx_element *sprite_gfx = machine->gfx[2];
31993122
3200   sprite_ptr = sprite_end;
3201   sprite_pri_usage=0;
3123   sprite_ptr = state->sprite_end;
3124   state->sprite_pri_usage=0;
32023125
32033126   // if sprites use more than 4bpp, the bottom bits of the color code must be masked out.
32043127   // This fixes (at least) stage 1 battle ships and attract mode explosions in Ray Force.
32053128
3206   while (sprite_ptr != spritelist)
3129   while (sprite_ptr != state->spritelist)
32073130   {
32083131      int pri;
32093132      sprite_ptr--;
32103133
32113134      pri=sprite_ptr->pri;
3212      sprite_pri_usage|=1<<pri;
3135      state->sprite_pri_usage|=1<<pri;
32133136
32143137      if(sprite_ptr->zoomx==16 && sprite_ptr->zoomy==16)
32153138         f3_drawgfx(
32163139               bitmap,cliprect,sprite_gfx,
32173140               sprite_ptr->code,
3218               sprite_ptr->color & (~sprite_extra_planes),
3141               sprite_ptr->color & (~state->sprite_extra_planes),
32193142               sprite_ptr->flipx,sprite_ptr->flipy,
32203143               sprite_ptr->x,sprite_ptr->y,
32213144               pri);
r10886r10887
32233146         f3_drawgfxzoom(
32243147               bitmap,cliprect,sprite_gfx,
32253148               sprite_ptr->code,
3226               sprite_ptr->color & (~sprite_extra_planes),
3149               sprite_ptr->color & (~state->sprite_extra_planes),
32273150               sprite_ptr->flipx,sprite_ptr->flipy,
32283151               sprite_ptr->x,sprite_ptr->y,
32293152               sprite_ptr->zoomx,sprite_ptr->zoomy,
r10886r10887
32383161   taito_f3_state *state = screen->machine->driver_data<taito_f3_state>();
32393162   UINT32 sy_fix[5],sx_fix[5];
32403163
3241   f3_skip_this_frame=0;
3242   tilemap_set_flip_all(screen->machine,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
3164   state->f3_skip_this_frame=0;
3165   tilemap_set_flip_all(screen->machine,state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
32433166
32443167   /* Setup scroll */
3245   sy_fix[0]=((f3_control_0[2]&0xffff0000)>> 7) + (1<<16);
3246   sy_fix[1]=((f3_control_0[2]&0x0000ffff)<< 9) + (1<<16);
3247   sy_fix[2]=((f3_control_0[3]&0xffff0000)>> 7) + (1<<16);
3248   sy_fix[3]=((f3_control_0[3]&0x0000ffff)<< 9) + (1<<16);
3249   sx_fix[0]=((f3_control_0[0]&0xffc00000)>> 6) - (6<<16);
3250   sx_fix[1]=((f3_control_0[0]&0x0000ffc0)<<10) - (10<<16);
3251   sx_fix[2]=((f3_control_0[1]&0xffc00000)>> 6) - (14<<16);
3252   sx_fix[3]=((f3_control_0[1]&0x0000ffc0)<<10) - (18<<16);
3253   sx_fix[4]=-(f3_control_1[2]>>16)+41;
3254   sy_fix[4]=-(f3_control_1[2]&0x1ff);
3168   sy_fix[0]=((state->f3_control_0[2]&0xffff0000)>> 7) + (1<<16);
3169   sy_fix[1]=((state->f3_control_0[2]&0x0000ffff)<< 9) + (1<<16);
3170   sy_fix[2]=((state->f3_control_0[3]&0xffff0000)>> 7) + (1<<16);
3171   sy_fix[3]=((state->f3_control_0[3]&0x0000ffff)<< 9) + (1<<16);
3172   sx_fix[0]=((state->f3_control_0[0]&0xffc00000)>> 6) - (6<<16);
3173   sx_fix[1]=((state->f3_control_0[0]&0x0000ffc0)<<10) - (10<<16);
3174   sx_fix[2]=((state->f3_control_0[1]&0xffc00000)>> 6) - (14<<16);
3175   sx_fix[3]=((state->f3_control_0[1]&0x0000ffc0)<<10) - (18<<16);
3176   sx_fix[4]=-(state->f3_control_1[2]>>16)+41;
3177   sy_fix[4]=-(state->f3_control_1[2]&0x1ff);
32553178
3256   sx_fix[0]-=((f3_control_0[0]&0x003f0000)>> 6)+0x0400-0x10000;
3257   sx_fix[1]-=((f3_control_0[0]&0x0000003f)<<10)+0x0400-0x10000;
3258   sx_fix[2]-=((f3_control_0[1]&0x003f0000)>> 6)+0x0400-0x10000;
3259   sx_fix[3]-=((f3_control_0[1]&0x0000003f)<<10)+0x0400-0x10000;
3179   sx_fix[0]-=((state->f3_control_0[0]&0x003f0000)>> 6)+0x0400-0x10000;
3180   sx_fix[1]-=((state->f3_control_0[0]&0x0000003f)<<10)+0x0400-0x10000;
3181   sx_fix[2]-=((state->f3_control_0[1]&0x003f0000)>> 6)+0x0400-0x10000;
3182   sx_fix[3]-=((state->f3_control_0[1]&0x0000003f)<<10)+0x0400-0x10000;
32603183
3261   if (flipscreen)
3184   if (state->flipscreen)
32623185   {
32633186      sy_fix[0]= 0x3000000-sy_fix[0];
32643187      sy_fix[1]= 0x3000000-sy_fix[1];
r10886r10887
32723195      sy_fix[4]=-sy_fix[4];
32733196   }
32743197
3275   bitmap_fill(pri_alp_bitmap,cliprect,0);
3198   bitmap_fill(state->pri_alp_bitmap,cliprect,0);
32763199
32773200   /* sprites */
3278   if (sprite_lag==0)
3201   if (state->sprite_lag==0)
32793202      get_sprite_info(screen->machine, state->spriteram);
32803203
32813204   /* Update sprite buffer */
32823205   draw_sprites(screen->machine, bitmap,cliprect);
32833206
32843207   /* Parse sprite, alpha & clipping parts of lineram */
3285   get_spritealphaclip_info();
3208   get_spritealphaclip_info(state);
32863209
32873210   /* Parse playfield effects */
3288   get_line_ram_info(screen->machine, pf1_tilemap,sx_fix[0],sy_fix[0],0,f3_pf_data_1);
3289   get_line_ram_info(screen->machine, pf2_tilemap,sx_fix[1],sy_fix[1],1,f3_pf_data_2);
3290   get_line_ram_info(screen->machine, pf3_tilemap,sx_fix[2],sy_fix[2],2,f3_pf_data_3);
3291   get_line_ram_info(screen->machine, pf4_tilemap,sx_fix[3],sy_fix[3],3,f3_pf_data_4);
3292   get_vram_info(vram_layer,pixel_layer,sx_fix[4],sy_fix[4]);
3211   get_line_ram_info(screen->machine, state->pf1_tilemap,sx_fix[0],sy_fix[0],0,state->f3_pf_data_1);
3212   get_line_ram_info(screen->machine, state->pf2_tilemap,sx_fix[1],sy_fix[1],1,state->f3_pf_data_2);
3213   get_line_ram_info(screen->machine, state->pf3_tilemap,sx_fix[2],sy_fix[2],2,state->f3_pf_data_3);
3214   get_line_ram_info(screen->machine, state->pf4_tilemap,sx_fix[3],sy_fix[3],3,state->f3_pf_data_4);
3215   get_vram_info(screen->machine, state->vram_layer,state->pixel_layer,sx_fix[4],sy_fix[4]);
32933216
32943217   /* Draw final framebuffer */
32953218   scanline_draw(screen->machine, bitmap,cliprect);
src/mame/video/megasys1.c
r10886r10887
194194#include "emu.h"
195195#include "includes/megasys1.h"
196196
197/* Variables defined here, that have to be shared: */
198UINT16 *megasys1_scrollram[3];
199UINT16 *megasys1_objectram, *megasys1_vregs, *megasys1_ram;
200
201static int megasys1_scrollx[3], megasys1_scrolly[3];
202static int megasys1_active_layers;
203static int megasys1_bits_per_color_code;
204
205static int megasys1_scroll_flag[3];
206static int megasys1_sprite_bank;
207static int megasys1_screen_flag, megasys1_sprite_flag;
208static int megasys1_8x8_scroll_factor[3], megasys1_16x16_scroll_factor[3];
209
210static tilemap_t *megasys1_tmap[3];
211static tilemap_t *megasys1_tilemap[3][2][4];
212
213/* Variables defined in driver: */
214static int hardware_type_z;
215
216197static void create_tilemaps(running_machine *machine);
217198
218static UINT16 *megasys1_buffer_objectram,*megasys1_buffer2_objectram,*megasys1_buffer_spriteram16,*megasys1_buffer2_spriteram16;
219199
220
221
222200#ifdef MAME_DEBUG
223201
224202#define SHOW_WRITE_ERROR(_format_,_offset_,_data_)\
r10886r10887
247225   megasys1_state *state = machine->driver_data<megasys1_state>();
248226   int i;
249227
250   state->spriteram = &megasys1_ram[0x8000/2];
228   state->spriteram = &state->ram[0x8000/2];
251229
252   megasys1_buffer_objectram = auto_alloc_array(machine, UINT16, 0x2000);
253   megasys1_buffer_spriteram16 = auto_alloc_array(machine, UINT16, 0x2000);
254   megasys1_buffer2_objectram = auto_alloc_array(machine, UINT16, 0x2000);
255   megasys1_buffer2_spriteram16 = auto_alloc_array(machine, UINT16, 0x2000);
230   state->buffer_objectram = auto_alloc_array(machine, UINT16, 0x2000);
231   state->buffer_spriteram16 = auto_alloc_array(machine, UINT16, 0x2000);
232   state->buffer2_objectram = auto_alloc_array(machine, UINT16, 0x2000);
233   state->buffer2_spriteram16 = auto_alloc_array(machine, UINT16, 0x2000);
256234
257235   create_tilemaps(machine);
258   megasys1_tmap[0] = megasys1_tilemap[0][0][0];
259   megasys1_tmap[1] = megasys1_tilemap[1][0][0];
260   megasys1_tmap[2] = megasys1_tilemap[2][0][0];
236   state->tmap[0] = state->tilemap[0][0][0];
237   state->tmap[1] = state->tilemap[1][0][0];
238   state->tmap[2] = state->tilemap[2][0][0];
261239
262   megasys1_active_layers = megasys1_sprite_bank = megasys1_screen_flag = megasys1_sprite_flag = 0;
240   state->active_layers = state->sprite_bank = state->screen_flag = state->sprite_flag = 0;
263241
264242   for (i = 0; i < 3; i ++)
265243   {
266      megasys1_scroll_flag[i] = megasys1_scrollx[i] = megasys1_scrolly[i] = 0;
244      state->scroll_flag[i] = state->scrollx[i] = state->scrolly[i] = 0;
267245   }
268246
269   megasys1_bits_per_color_code = 4;
247   state->bits_per_color_code = 4;
270248
271249/*
272250    The tile code of a specific layer is multiplied for a constant
r10886r10887
285263    for each layer and hardwired to 1x or 4x for both tile sizes
286264*/
287265
288   megasys1_8x8_scroll_factor[0] = 1;   megasys1_16x16_scroll_factor[0] = 4;
289   megasys1_8x8_scroll_factor[1] = 1;   megasys1_16x16_scroll_factor[1] = 4;
290   megasys1_8x8_scroll_factor[2] = 1;   megasys1_16x16_scroll_factor[2] = 4;
266   state->_8x8_scroll_factor[0] = 1;   state->_16x16_scroll_factor[0] = 4;
267   state->_8x8_scroll_factor[1] = 1;   state->_16x16_scroll_factor[1] = 4;
268   state->_8x8_scroll_factor[2] = 1;   state->_16x16_scroll_factor[2] = 4;
291269
292270   if (strcmp(machine->gamedrv->name, "soldamj") == 0)
293271   {
294      megasys1_8x8_scroll_factor[1] = 4;   megasys1_16x16_scroll_factor[1] = 4;
272      state->_8x8_scroll_factor[1] = 4;   state->_16x16_scroll_factor[1] = 4;
295273   }
296274
297   hardware_type_z = 0;
275   state->hardware_type_z = 0;
298276   if (strcmp(machine->gamedrv->name, "lomakai") == 0 ||
299277      strcmp(machine->gamedrv->name, "makaiden") == 0)
300      hardware_type_z = 1;
278      state->hardware_type_z = 1;
301279}
302280
303281/***************************************************************************
r10886r10887
313291#define TILES_PER_PAGE_Y (0x20)
314292#define TILES_PER_PAGE (TILES_PER_PAGE_X * TILES_PER_PAGE_Y)
315293
316INLINE void scrollram_w(int which, offs_t offset, UINT16 data, UINT16 mem_mask)
294INLINE void scrollram_w(address_space *space, offs_t offset, UINT16 data, UINT16 mem_mask, int which)
317295{
318   COMBINE_DATA(&megasys1_scrollram[which][offset]);
319   if (offset < 0x40000/2 && megasys1_tmap[which])
296   megasys1_state *state = space->machine->driver_data<megasys1_state>();
297   COMBINE_DATA(&state->scrollram[which][offset]);
298   if (offset < 0x40000/2 && state->tmap[which])
320299   {
321      if (megasys1_scroll_flag[which] & 0x10)   /* tiles are 8x8 */
300      if (state->scroll_flag[which] & 0x10)   /* tiles are 8x8 */
322301      {
323         tilemap_mark_tile_dirty(megasys1_tmap[which], offset );
302         tilemap_mark_tile_dirty(state->tmap[which], offset );
324303      }
325304      else
326305      {
327         tilemap_mark_tile_dirty(megasys1_tmap[which], offset*4 + 0);
328         tilemap_mark_tile_dirty(megasys1_tmap[which], offset*4 + 1);
329         tilemap_mark_tile_dirty(megasys1_tmap[which], offset*4 + 2);
330         tilemap_mark_tile_dirty(megasys1_tmap[which], offset*4 + 3);
306         tilemap_mark_tile_dirty(state->tmap[which], offset*4 + 0);
307         tilemap_mark_tile_dirty(state->tmap[which], offset*4 + 1);
308         tilemap_mark_tile_dirty(state->tmap[which], offset*4 + 2);
309         tilemap_mark_tile_dirty(state->tmap[which], offset*4 + 3);
331310      }
332311   }
333312}
334313
335WRITE16_HANDLER( megasys1_scrollram_0_w ) { scrollram_w(0, offset, data, mem_mask); }
336WRITE16_HANDLER( megasys1_scrollram_1_w ) { scrollram_w(1, offset, data, mem_mask); }
337WRITE16_HANDLER( megasys1_scrollram_2_w ) { scrollram_w(2, offset, data, mem_mask); }
314WRITE16_HANDLER( megasys1_scrollram_0_w ) { scrollram_w(space, offset, data, mem_mask, 0); }
315WRITE16_HANDLER( megasys1_scrollram_1_w ) { scrollram_w(space, offset, data, mem_mask, 1); }
316WRITE16_HANDLER( megasys1_scrollram_2_w ) { scrollram_w(space, offset, data, mem_mask, 2); }
338317
339318
340319
r10886r10887
372351
373352static TILE_GET_INFO( megasys1_get_scroll_tile_info_8x8 )
374353{
354   megasys1_state *state = machine->driver_data<megasys1_state>();
375355   int tmap = (FPTR)param;
376   UINT16 code = megasys1_scrollram[tmap][tile_index];
377   SET_TILE_INFO(tmap, (code & 0xfff) * megasys1_8x8_scroll_factor[tmap], code >> (16 - megasys1_bits_per_color_code), 0);
356   UINT16 code = state->scrollram[tmap][tile_index];
357   SET_TILE_INFO(tmap, (code & 0xfff) * state->_8x8_scroll_factor[tmap], code >> (16 - state->bits_per_color_code), 0);
378358}
379359
380360static TILE_GET_INFO( megasys1_get_scroll_tile_info_16x16 )
381361{
362   megasys1_state *state = machine->driver_data<megasys1_state>();
382363   int tmap = (FPTR)param;
383   UINT16 code = megasys1_scrollram[tmap][tile_index/4];
384   SET_TILE_INFO(tmap, (code & 0xfff) * megasys1_16x16_scroll_factor[tmap] + (tile_index & 3), code >> (16 - megasys1_bits_per_color_code), 0);
364   UINT16 code = state->scrollram[tmap][tile_index/4];
365   SET_TILE_INFO(tmap, (code & 0xfff) * state->_16x16_scroll_factor[tmap] + (tile_index & 3), code >> (16 - state->bits_per_color_code), 0);
385366}
386367
387368static void create_tilemaps(running_machine *machine)
388369{
370   megasys1_state *state = machine->driver_data<megasys1_state>();
389371   int layer, i;
390372
391373   for (layer = 0; layer < 3; layer++)
392374   {
393375      /* 16x16 tilemaps */
394      megasys1_tilemap[layer][0][0] = tilemap_create(machine, megasys1_get_scroll_tile_info_16x16, megasys1_scan_16x16,
376      state->tilemap[layer][0][0] = tilemap_create(machine, megasys1_get_scroll_tile_info_16x16, megasys1_scan_16x16,
395377                         8,8, TILES_PER_PAGE_X * 16, TILES_PER_PAGE_Y * 2);
396      megasys1_tilemap[layer][0][1] = tilemap_create(machine, megasys1_get_scroll_tile_info_16x16, megasys1_scan_16x16,
378      state->tilemap[layer][0][1] = tilemap_create(machine, megasys1_get_scroll_tile_info_16x16, megasys1_scan_16x16,
397379                         8,8, TILES_PER_PAGE_X * 8, TILES_PER_PAGE_Y * 4);
398      megasys1_tilemap[layer][0][2] = tilemap_create(machine, megasys1_get_scroll_tile_info_16x16, megasys1_scan_16x16,
380      state->tilemap[layer][0][2] = tilemap_create(machine, megasys1_get_scroll_tile_info_16x16, megasys1_scan_16x16,
399381                         8,8, TILES_PER_PAGE_X * 4, TILES_PER_PAGE_Y * 8);
400      megasys1_tilemap[layer][0][3] = tilemap_create(machine, megasys1_get_scroll_tile_info_16x16, megasys1_scan_16x16,
382      state->tilemap[layer][0][3] = tilemap_create(machine, megasys1_get_scroll_tile_info_16x16, megasys1_scan_16x16,
401383                         8,8, TILES_PER_PAGE_X * 2, TILES_PER_PAGE_Y * 16);
402384
403385      /* 8x8 tilemaps */
404      megasys1_tilemap[layer][1][0] = tilemap_create(machine, megasys1_get_scroll_tile_info_8x8, megasys1_scan_8x8,
386      state->tilemap[layer][1][0] = tilemap_create(machine, megasys1_get_scroll_tile_info_8x8, megasys1_scan_8x8,
405387                         8,8, TILES_PER_PAGE_X * 8, TILES_PER_PAGE_Y * 1);
406      megasys1_tilemap[layer][1][1] = tilemap_create(machine, megasys1_get_scroll_tile_info_8x8, megasys1_scan_8x8,
388      state->tilemap[layer][1][1] = tilemap_create(machine, megasys1_get_scroll_tile_info_8x8, megasys1_scan_8x8,
407389                         8,8, TILES_PER_PAGE_X * 4, TILES_PER_PAGE_Y * 2);
408      megasys1_tilemap[layer][1][2] = tilemap_create(machine, megasys1_get_scroll_tile_info_8x8, megasys1_scan_8x8,
390      state->tilemap[layer][1][2] = tilemap_create(machine, megasys1_get_scroll_tile_info_8x8, megasys1_scan_8x8,
409391                         8,8, TILES_PER_PAGE_X * 4, TILES_PER_PAGE_Y * 2);
410      megasys1_tilemap[layer][1][3] = tilemap_create(machine, megasys1_get_scroll_tile_info_8x8, megasys1_scan_8x8,
392      state->tilemap[layer][1][3] = tilemap_create(machine, megasys1_get_scroll_tile_info_8x8, megasys1_scan_8x8,
411393                         8,8, TILES_PER_PAGE_X * 2, TILES_PER_PAGE_Y * 4);
412394
413395      /* set user data and transparency */
414396      for (i = 0; i < 8; i++)
415397      {
416         tilemap_set_user_data(megasys1_tilemap[layer][i/4][i%4], (void *)(FPTR)layer);
417         tilemap_set_transparent_pen(megasys1_tilemap[layer][i/4][i%4], 15);
398         tilemap_set_user_data(state->tilemap[layer][i/4][i%4], (void *)(FPTR)layer);
399         tilemap_set_transparent_pen(state->tilemap[layer][i/4][i%4], 15);
418400      }
419401   }
420402}
421403
422static void megasys1_set_vreg_flag(int which, int data)
404static void megasys1_set_vreg_flag(megasys1_state *state, int which, int data)
423405{
424   if (megasys1_scroll_flag[which] != data)
406   if (state->scroll_flag[which] != data)
425407   {
426      megasys1_scroll_flag[which] = data;
427      megasys1_tmap[which] = megasys1_tilemap[which][(data >> 4) & 1][data & 3];
428      tilemap_mark_all_tiles_dirty(megasys1_tmap[which]);
408      state->scroll_flag[which] = data;
409      state->tmap[which] = state->tilemap[which][(data >> 4) & 1][data & 3];
410      tilemap_mark_all_tiles_dirty(state->tmap[which]);
429411   }
430412}
431413
r10886r10887
434416/* Used by MS1-A/Z, B */
435417WRITE16_HANDLER( megasys1_vregs_A_w )
436418{
437   UINT16 new_data = COMBINE_DATA(&megasys1_vregs[offset]);
419   megasys1_state *state = space->machine->driver_data<megasys1_state>();
420   UINT16 new_data = COMBINE_DATA(&state->vregs[offset]);
438421
439422   switch (offset)
440423   {
441      case 0x000/2   :   megasys1_active_layers = new_data;   break;
424      case 0x000/2   :   state->active_layers = new_data;   break;
442425
443      case 0x008/2+0 :   megasys1_scrollx[2] = new_data;   break;
444      case 0x008/2+1 :   megasys1_scrolly[2] = new_data;   break;
445      case 0x008/2+2 :   megasys1_set_vreg_flag(2, new_data);      break;
426      case 0x008/2+0 :   state->scrollx[2] = new_data;   break;
427      case 0x008/2+1 :   state->scrolly[2] = new_data;   break;
428      case 0x008/2+2 :   megasys1_set_vreg_flag(state, 2, new_data);      break;
446429
447      case 0x200/2+0 :   megasys1_scrollx[0] = new_data;   break;
448      case 0x200/2+1 :   megasys1_scrolly[0] = new_data;   break;
449      case 0x200/2+2 :   megasys1_set_vreg_flag(0, new_data);      break;
430      case 0x200/2+0 :   state->scrollx[0] = new_data;   break;
431      case 0x200/2+1 :   state->scrolly[0] = new_data;   break;
432      case 0x200/2+2 :   megasys1_set_vreg_flag(state, 0, new_data);      break;
450433
451      case 0x208/2+0 :   megasys1_scrollx[1] = new_data;   break;
452      case 0x208/2+1 :   megasys1_scrolly[1] = new_data;   break;
453      case 0x208/2+2 :   megasys1_set_vreg_flag(1, new_data);      break;
434      case 0x208/2+0 :   state->scrollx[1] = new_data;   break;
435      case 0x208/2+1 :   state->scrolly[1] = new_data;   break;
436      case 0x208/2+2 :   megasys1_set_vreg_flag(state, 1, new_data);      break;
454437
455      case 0x100/2   :   megasys1_sprite_flag = new_data;      break;
438      case 0x100/2   :   state->sprite_flag = new_data;      break;
456439
457      case 0x300/2   :   megasys1_screen_flag = new_data;
440      case 0x300/2   :   state->screen_flag = new_data;
458441                     if (space->machine->device("soundcpu"))
459442                     {
460443                        if (new_data & 0x10)
r10886r10887
479462/* Used by MS1-C only */
480463READ16_HANDLER( megasys1_vregs_C_r )
481464{
465   megasys1_state *state = space->machine->driver_data<megasys1_state>();
482466   switch (offset)
483467   {
484468      case 0x8000/2:   return soundlatch2_word_r(space,0,0xffff);
485      default:      return megasys1_vregs[offset];
469      default:      return state->vregs[offset];
486470   }
487471}
488472
489473WRITE16_HANDLER( megasys1_vregs_C_w )
490474{
491   UINT16 new_data = COMBINE_DATA(&megasys1_vregs[offset]);
475   megasys1_state *state = space->machine->driver_data<megasys1_state>();
476   UINT16 new_data = COMBINE_DATA(&state->vregs[offset]);
492477
493478   switch (offset)
494479   {
495      case 0x2000/2+0 :   megasys1_scrollx[0] = new_data;   break;
496      case 0x2000/2+1 :   megasys1_scrolly[0] = new_data;   break;
497      case 0x2000/2+2 :   megasys1_set_vreg_flag(0, new_data);      break;
480      case 0x2000/2+0 :   state->scrollx[0] = new_data;   break;
481      case 0x2000/2+1 :   state->scrolly[0] = new_data;   break;
482      case 0x2000/2+2 :   megasys1_set_vreg_flag(state, 0, new_data);      break;
498483
499      case 0x2008/2+0 :   megasys1_scrollx[1] = new_data;   break;
500      case 0x2008/2+1 :   megasys1_scrolly[1] = new_data;   break;
501      case 0x2008/2+2 :   megasys1_set_vreg_flag(1, new_data);      break;
484      case 0x2008/2+0 :   state->scrollx[1] = new_data;   break;
485      case 0x2008/2+1 :   state->scrolly[1] = new_data;   break;
486      case 0x2008/2+2 :   megasys1_set_vreg_flag(state, 1, new_data);      break;
502487
503      case 0x2100/2+0 :   megasys1_scrollx[2] = new_data;   break;
504      case 0x2100/2+1 :   megasys1_scrolly[2] = new_data;   break;
505      case 0x2100/2+2 :   megasys1_set_vreg_flag(2, new_data);      break;
488      case 0x2100/2+0 :   state->scrollx[2] = new_data;   break;
489      case 0x2100/2+1 :   state->scrolly[2] = new_data;   break;
490      case 0x2100/2+2 :   megasys1_set_vreg_flag(state, 2, new_data);      break;
506491
507      case 0x2108/2   :   megasys1_sprite_bank   = new_data;   break;
508      case 0x2200/2   :   megasys1_sprite_flag   = new_data;   break;
509      case 0x2208/2   :   megasys1_active_layers = new_data;   break;
492      case 0x2108/2   :   state->sprite_bank   = new_data;   break;
493      case 0x2200/2   :   state->sprite_flag   = new_data;   break;
494      case 0x2208/2   :   state->active_layers = new_data;   break;
510495
511      case 0x2308/2   :   megasys1_screen_flag = new_data;
496      case 0x2308/2   :   state->screen_flag = new_data;
512497                     if (new_data & 0x10)
513498                        cputag_set_input_line(space->machine, "soundcpu", INPUT_LINE_RESET, ASSERT_LINE);
514499                     else
r10886r10887
529514/* Used by MS1-D only */
530515WRITE16_HANDLER( megasys1_vregs_D_w )
531516{
532   UINT16 new_data = COMBINE_DATA(&megasys1_vregs[offset]);
517   megasys1_state *state = space->machine->driver_data<megasys1_state>();
518   UINT16 new_data = COMBINE_DATA(&state->vregs[offset]);
533519
534520   switch (offset)
535521   {
536      case 0x2000/2+0 :   megasys1_scrollx[0] = new_data;   break;
537      case 0x2000/2+1 :   megasys1_scrolly[0] = new_data;   break;
538      case 0x2000/2+2 :   megasys1_set_vreg_flag(0, new_data);      break;
522      case 0x2000/2+0 :   state->scrollx[0] = new_data;   break;
523      case 0x2000/2+1 :   state->scrolly[0] = new_data;   break;
524      case 0x2000/2+2 :   megasys1_set_vreg_flag(state, 0, new_data);      break;
539525
540      case 0x2008/2+0 :   megasys1_scrollx[1] = new_data;   break;
541      case 0x2008/2+1 :   megasys1_scrolly[1] = new_data;   break;
542      case 0x2008/2+2 :   megasys1_set_vreg_flag(1, new_data);      break;
526      case 0x2008/2+0 :   state->scrollx[1] = new_data;   break;
527      case 0x2008/2+1 :   state->scrolly[1] = new_data;   break;
528      case 0x2008/2+2 :   megasys1_set_vreg_flag(state, 1, new_data);      break;
543529
544//      case 0x2100/2+0 :   megasys1_scrollx[2] = new_data; break;
545//      case 0x2100/2+1 :   megasys1_scrolly[2] = new_data; break;
546//      case 0x2100/2+2 :   megasys1_set_vreg_flag(2, new_data);        break;
530//      case 0x2100/2+0 :   state->scrollx[2] = new_data; break;
531//      case 0x2100/2+1 :   state->scrolly[2] = new_data; break;
532//      case 0x2100/2+2 :   megasys1_set_vreg_flag(state, 2, new_data);        break;
547533
548      case 0x2108/2   :   megasys1_sprite_bank   =   new_data;      break;
549      case 0x2200/2   :   megasys1_sprite_flag   =   new_data;      break;
550      case 0x2208/2   :   megasys1_active_layers   =   new_data;      break;
551      case 0x2308/2   :   megasys1_screen_flag   =   new_data;      break;
534      case 0x2108/2   :   state->sprite_bank   =   new_data;      break;
535      case 0x2200/2   :   state->sprite_flag   =   new_data;      break;
536      case 0x2208/2   :   state->active_layers   =   new_data;      break;
537      case 0x2308/2   :   state->screen_flag   =   new_data;      break;
552538
553539      default:      SHOW_WRITE_ERROR("vreg %04X <- %04X",offset*2,data);
554540   }
r10886r10887
590576
591577   /* sprite order is from first in Sprite Data RAM (frontmost) to last */
592578
593   if (hardware_type_z == 0)   /* standard sprite hardware */
579   if (state->hardware_type_z == 0)   /* standard sprite hardware */
594580   {
595      color_mask = (megasys1_sprite_flag & 0x100) ? 0x07 : 0x0f;
581      color_mask = (state->sprite_flag & 0x100) ? 0x07 : 0x0f;
596582
597583      for (offs = (0x800-8)/2;offs >= 0;offs -= 8/2)
598584      {
599585         for (sprite = 0; sprite < 4 ; sprite ++)
600586         {
601            UINT16 *objectdata = &megasys1_buffer2_objectram[offs + (0x800/2) * sprite];
602            UINT16 *spritedata = &megasys1_buffer2_spriteram16[ (objectdata[ 0 ] & 0x7f) * 0x10/2];
587            UINT16 *objectdata = &state->buffer2_objectram[offs + (0x800/2) * sprite];
588            UINT16 *spritedata = &state->buffer2_spriteram16[ (objectdata[ 0 ] & 0x7f) * 0x10/2];
603589
604590            attr = spritedata[ 8/2 ];
605591            if (((attr & 0xc0)>>6) != sprite)   continue;   // flipping
r10886r10887
614600            flipx = attr & 0x40;
615601            flipy = attr & 0x80;
616602
617            if (megasys1_screen_flag & 1)
603            if (state->screen_flag & 1)
618604            {
619605               flipx = !flipx;      flipy = !flipy;
620606               sx = 240-sx;      sy = 240-sy;
r10886r10887
626612
627613            pdrawgfx_transpen(bitmap,cliprect,
628614                  machine->gfx[3],
629                  (code & 0xfff ) + ((megasys1_sprite_bank & 1) << 12),
615                  (code & 0xfff ) + ((state->sprite_bank & 1) << 12),
630616                  color,
631617                  flipx, flipy,
632618                  sx, sy,
r10886r10887
659645         flipx = attr & 0x40;
660646         flipy = attr & 0x80;
661647
662         if (megasys1_screen_flag & 1)
648         if (state->screen_flag & 1)
663649         {
664650            flipx = !flipx;      flipy = !flipy;
665651            sx = 240-sx;      sy = 240-sy;
r10886r10887
691677   int priorities[16];
692678};
693679
694static int megasys1_layers_order[16];
695680
696681/*
697682    Layers order encoded as an int like: 0x01234, where
r10886r10887
772757
773758PALETTE_INIT( megasys1 )
774759{
760   megasys1_state *state = machine->driver_data<megasys1_state>();
775761   int pri_code, offset, i, order;
776762
777763   /* First check if we have an hand-crafted priority scheme
r10886r10887
786772
787773   if (priorities[i].driver)
788774   {
789      memcpy (megasys1_layers_order, priorities[i].priorities, 16 * sizeof(int));
775      memcpy (state->layers_order, priorities[i].priorities, 16 * sizeof(int));
790776
791777      logerror("WARNING: using an hand-crafted priorities scheme\n");
792778
r10886r10887
914900
915901      }   // merging
916902
917      megasys1_layers_order[pri_code] = order & 0xfffff;   // at last!
903      state->layers_order[pri_code] = order & 0xfffff;   // at last!
918904
919905   }   // pri_code
920906
r10886r10887
923909#if 0
924910   /* log the priority schemes */
925911   for (i = 0; i < 16; i++)
926      logerror("PROM %X] %05x\n", i, megasys1_layers_order[i]);
912      logerror("PROM %X] %05x\n", i, state->layers_order[i]);
927913#endif
928914
929915
r10886r10887
940926
941927SCREEN_UPDATE( megasys1 )
942928{
929   megasys1_state *state = screen->machine->driver_data<megasys1_state>();
943930   int i,flag,pri,primask;
944931   int active_layers;
945932
946   if (hardware_type_z)
933   if (state->hardware_type_z)
947934   {
948935      /* no layer 2 and fixed layers order? */
949936      active_layers = 0x000b;
r10886r10887
954941      int reallyactive = 0;
955942
956943      /* get layers order */
957      pri = megasys1_layers_order[(megasys1_active_layers & 0x0f0f) >> 8];
944      pri = state->layers_order[(state->active_layers & 0x0f0f) >> 8];
958945
959946#ifdef MAME_DEBUG
960947      if (pri == 0xfffff)
961948      {
962         popmessage("Pri: %04X - Flag: %04X", megasys1_active_layers, megasys1_sprite_flag);
949         popmessage("Pri: %04X - Flag: %04X", state->active_layers, state->sprite_flag);
963950      }
964951#endif
965952
r10886r10887
969956      for (i = 0;i < 5;i++)
970957         reallyactive |= 1 << ((pri >> (4*i)) & 0x0f);
971958
972      active_layers = megasys1_active_layers & reallyactive;
959      active_layers = state->active_layers & reallyactive;
973960      active_layers |= 1 << ((pri & 0xf0000) >> 16);   // bottom layer can't be disabled
974961   }
975962
976   tilemap_set_flip_all( screen->machine, (megasys1_screen_flag & 1) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0 );
963   tilemap_set_flip_all( screen->machine, (state->screen_flag & 1) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0 );
977964
978965   for (i = 0;i < 3;i++)
979966   {
980      if (megasys1_tmap[i])
967      if (state->tmap[i])
981968      {
982         tilemap_set_enable(megasys1_tmap[i],active_layers & (1 << i));
969         tilemap_set_enable(state->tmap[i],active_layers & (1 << i));
983970
984         tilemap_set_scrollx(megasys1_tmap[i],0,megasys1_scrollx[i]);
985         tilemap_set_scrolly(megasys1_tmap[i],0,megasys1_scrolly[i]);
971         tilemap_set_scrollx(state->tmap[i],0,state->scrollx[i]);
972         tilemap_set_scrolly(state->tmap[i],0,state->scrolly[i]);
986973      }
987974   }
988975
r10886r10887
1001988         case 0:
1002989         case 1:
1003990         case 2:
1004            if ( (megasys1_tmap[layer]) && (active_layers & (1 << layer) ) )
991            if ( (state->tmap[layer]) && (active_layers & (1 << layer) ) )
1005992            {
1006               tilemap_draw(bitmap,cliprect,megasys1_tmap[layer],flag,primask);
993               tilemap_draw(bitmap,cliprect,state->tmap[layer],flag,primask);
1007994               flag = 0;
1008995            }
1009996            break;
r10886r10887
10151002               bitmap_fill(bitmap,cliprect,0);
10161003            }
10171004
1018            if (megasys1_sprite_flag & 0x100)   /* sprites are split */
1005            if (state->sprite_flag & 0x100)   /* sprites are split */
10191006            {
10201007               /* following tilemaps will obscure this sprites layer */
10211008               primask |= 1 << (layer-3);
r10886r10887
10371024{
10381025   megasys1_state *state = machine->driver_data<megasys1_state>();
10391026   /* Sprite are TWO frames ahead, like NMK16 HW. */
1040//megasys1_objectram
1041   memcpy(megasys1_buffer2_objectram,megasys1_buffer_objectram, 0x2000);
1042   memcpy(megasys1_buffer_objectram, megasys1_objectram, 0x2000);
1027//state->objectram
1028   memcpy(state->buffer2_objectram,state->buffer_objectram, 0x2000);
1029   memcpy(state->buffer_objectram, state->objectram, 0x2000);
10431030//spriteram16
1044   memcpy(megasys1_buffer2_spriteram16, megasys1_buffer_spriteram16, 0x2000);
1045   memcpy(megasys1_buffer_spriteram16, state->spriteram, 0x2000);
1031   memcpy(state->buffer2_spriteram16, state->buffer_spriteram16, 0x2000);
1032   memcpy(state->buffer_spriteram16, state->spriteram, 0x2000);
10461033
10471034}
10481035
src/mame/video/bwing.c
r10886r10887
5757
5858WRITE8_HANDLER( bwing_spriteram_w )
5959{
60   space->machine->generic.buffered_spriteram.u8[offset] = data;
60   bwing_state *state = space->machine->driver_data<bwing_state>();
61   state->spriteram[offset] = data;
6162}
6263
6364WRITE8_HANDLER( bwing_videoram_w )
r10886r10887
318319      bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
319320
320321   // draw low priority sprites
321   draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.buffered_spriteram.u8, 0);
322   draw_sprites(screen->machine, bitmap, cliprect, state->spriteram, 0);
322323
323324   // draw foreground
324325   if (!(state->mapmask & 2))
r10886r10887
332333   }
333334
334335   // draw high priority sprites
335   draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.buffered_spriteram.u8, 1);
336   draw_sprites(screen->machine, bitmap, cliprect, state->spriteram, 1);
336337
337338   // draw text layer
338339//  if (state->mapmask & 4)
src/mame/layout/depthch.lay
r10886r10887
11<?xml version="1.0"?>
22<mamelayout version="2">
3   <element name="overlay">
3   <element name="overlay_gremlin">
44      <rect>
55         <bounds left="0" top="0" right="256" bottom="224" />
66         <color red="0.27" green="0.53" blue="0.8" />
77      </rect>
88   </element>
99
10   <view name="Color Overlay">
10   <!-- TODO: Taito (Japan) version needs a different overlay -->
11
12   <view name="Color Overlay (Gremlin)">
1113      <screen index="0">
1214         <bounds left="0" top="0" right="4" bottom="3" />
1315      </screen>
14      <overlay name="overlay" element="overlay">
16      <overlay name="overlay" element="overlay_gremlin">
1517         <bounds left="0" top="0" right="4" bottom="3" />
1618      </overlay>
1719   </view>
src/mame/drivers/coinmstr.c
r10886r10887
3636      : driver_device(machine, config) { }
3737
3838   UINT8 *videoram;
39   UINT8 *attr_ram1;
40   UINT8 *attr_ram2;
41   UINT8 *attr_ram3;
42   tilemap_t *bg_tilemap;
43   UINT8 question_adr[4];
3944};
4045
4146
42
43static UINT8 *attr_ram1, *attr_ram2, *attr_ram3;
44static tilemap_t *bg_tilemap;
45
46static UINT8 question_adr[4];
47
4847static WRITE8_HANDLER( quizmstr_bg_w )
4948{
5049   coinmstr_state *state = space->machine->driver_data<coinmstr_state>();
r10886r10887
5251   videoram[offset] = data;
5352
5453   if(offset >= 0x0240)
55      tilemap_mark_tile_dirty(bg_tilemap,offset - 0x0240);
54      tilemap_mark_tile_dirty(state->bg_tilemap,offset - 0x0240);
5655}
5756
5857
r10886r10887
9190
9291static WRITE8_HANDLER( quizmstr_attr1_w )
9392{
94   attr_ram1[offset] = data;
93   coinmstr_state *state = space->machine->driver_data<coinmstr_state>();
94   state->attr_ram1[offset] = data;
9595
9696   if(offset >= 0x0240)
9797   {
9898      // the later games also use attr3 for something..
99      UINT32   paldata = (attr_ram1[offset] & 0x7f) | ((attr_ram2[offset] & 0x7f) << 7);
100      tilemap_mark_tile_dirty(bg_tilemap, offset - 0x0240);
99      UINT32   paldata = (state->attr_ram1[offset] & 0x7f) | ((state->attr_ram2[offset] & 0x7f) << 7);
100      tilemap_mark_tile_dirty(state->bg_tilemap, offset - 0x0240);
101101
102102      coinmstr_set_pal(space->machine, paldata, offset - 0x240);
103103
r10886r10887
106106
107107static WRITE8_HANDLER( quizmstr_attr2_w )
108108{
109   attr_ram2[offset] = data;
109   coinmstr_state *state = space->machine->driver_data<coinmstr_state>();
110   state->attr_ram2[offset] = data;
110111
111112   if(offset >= 0x0240)
112113   {
113114      // the later games also use attr3 for something..
114      UINT32   paldata = (attr_ram1[offset] & 0x7f) | ((attr_ram2[offset] & 0x7f) << 7);
115      tilemap_mark_tile_dirty(bg_tilemap, offset - 0x0240);
115      UINT32   paldata = (state->attr_ram1[offset] & 0x7f) | ((state->attr_ram2[offset] & 0x7f) << 7);
116      tilemap_mark_tile_dirty(state->bg_tilemap, offset - 0x0240);
116117
117118      coinmstr_set_pal(space->machine, paldata, offset - 0x240);
118119
r10886r10887
121122
122123static WRITE8_HANDLER( quizmstr_attr3_w )
123124{
124   attr_ram3[offset] = data;
125   coinmstr_state *state = space->machine->driver_data<coinmstr_state>();
126   state->attr_ram3[offset] = data;
125127
126128   if(offset >= 0x0240)
127      tilemap_mark_tile_dirty(bg_tilemap, offset - 0x0240);
129      tilemap_mark_tile_dirty(state->bg_tilemap, offset - 0x0240);
128130
129131}
130132
131133
132134static READ8_HANDLER( question_r )
133135{
136   coinmstr_state *state = space->machine->driver_data<coinmstr_state>();
134137   int address;
135138   UINT8 *questions = space->machine->region("user1")->base();
136139
137   switch(question_adr[2])
140   switch(state->question_adr[2])
138141   {
139      case 0x38: address = 0x00000; break; // question_adr[3] == 7
140      case 0x39: address = 0x08000; break; // question_adr[3] == 7
141      case 0x3a: address = 0x10000; break; // question_adr[3] == 7
142      case 0x3b: address = 0x18000; break; // question_adr[3] == 7
143      case 0x3c: address = 0x20000; break; // question_adr[3] == 7
144      case 0x3d: address = 0x28000; break; // question_adr[3] == 7
145      case 0x3e: address = 0x30000; break; // question_adr[3] == 7
146      case 0x07: address = 0x38000; break; // question_adr[3] == 7
147      case 0x0f: address = 0x40000; break; // question_adr[3] == 7
148      case 0x17: address = 0x48000; break; // question_adr[3] == 7
149      case 0x1f: address = 0x50000; break; // question_adr[3] == 7
150      case 0x27: address = 0x58000; break; // question_adr[3] == 7
151      case 0x2f: address = 0x60000; break; // question_adr[3] == 7
152      case 0x37: address = 0x68000; break; // question_adr[3] == 7
153      case 0x3f: address = 0x70000 + question_adr[3] * 0x8000; break;
142      case 0x38: address = 0x00000; break; // state->question_adr[3] == 7
143      case 0x39: address = 0x08000; break; // state->question_adr[3] == 7
144      case 0x3a: address = 0x10000; break; // state->question_adr[3] == 7
145      case 0x3b: address = 0x18000; break; // state->question_adr[3] == 7
146      case 0x3c: address = 0x20000; break; // state->question_adr[3] == 7
147      case 0x3d: address = 0x28000; break; // state->question_adr[3] == 7
148      case 0x3e: address = 0x30000; break; // state->question_adr[3] == 7
149      case 0x07: address = 0x38000; break; // state->question_adr[3] == 7
150      case 0x0f: address = 0x40000; break; // state->question_adr[3] == 7
151      case 0x17: address = 0x48000; break; // state->question_adr[3] == 7
152      case 0x1f: address = 0x50000; break; // state->question_adr[3] == 7
153      case 0x27: address = 0x58000; break; // state->question_adr[3] == 7
154      case 0x2f: address = 0x60000; break; // state->question_adr[3] == 7
155      case 0x37: address = 0x68000; break; // state->question_adr[3] == 7
156      case 0x3f: address = 0x70000 + state->question_adr[3] * 0x8000; break;
154157
155158      default:
156159         address = 0;
157         logerror("unknown question rom # = %02X\n",question_adr[2]);
160         logerror("unknown question rom # = %02X\n",state->question_adr[2]);
158161   }
159162
160   if(question_adr[3] == 6 || question_adr[3] > 7)
161      logerror("question_adr[3] = %02X\n",question_adr[3]);
163   if(state->question_adr[3] == 6 || state->question_adr[3] > 7)
164      logerror("question_adr[3] = %02X\n",state->question_adr[3]);
162165
163166/*
164167    in these offsets they set 0x80... why?
165168
166    if( (question_adr[0] & 0x5f) == 0x00 ||
167        (question_adr[0] & 0x5f) == 0x01 ||
168        (question_adr[0] & 0x5f) == 0x0f ||
169        (question_adr[0] & 0x5f) == 0x56 )
169    if( (state->question_adr[0] & 0x5f) == 0x00 ||
170        (state->question_adr[0] & 0x5f) == 0x01 ||
171        (state->question_adr[0] & 0x5f) == 0x0f ||
172        (state->question_adr[0] & 0x5f) == 0x56 )
170173*/
171174
172175
173176//  don't know...
174//  address |= ((question_adr[0] & 0x7f) << 8) | question_adr[1];
175   address |= (question_adr[1] << 7) | (question_adr[0] & 0x7f);
177//  address |= ((state->question_adr[0] & 0x7f) << 8) | state->question_adr[1];
178   address |= (state->question_adr[1] << 7) | (state->question_adr[0] & 0x7f);
176179
177180   return questions[address];
178181}
179182
180183static WRITE8_HANDLER( question_w )
181184{
182   if(data != question_adr[offset])
185   coinmstr_state *state = space->machine->driver_data<coinmstr_state>();
186   if(data != state->question_adr[offset])
183187   {
184188      logerror("offset = %d data = %02X\n",offset,data);
185189   }
186190
187   question_adr[offset] = data;
191   state->question_adr[offset] = data;
188192}
189193
190194static READ8_HANDLER( ff_r )
r10886r10887
198202   AM_RANGE(0x0000, 0xbfff) AM_ROM
199203   AM_RANGE(0xc000, 0xdfff) AM_RAM
200204   AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(quizmstr_bg_w) AM_BASE_MEMBER(coinmstr_state, videoram)
201   AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(quizmstr_attr1_w) AM_BASE(&attr_ram1)
202   AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(quizmstr_attr2_w) AM_BASE(&attr_ram2)
203   AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(quizmstr_attr3_w) AM_BASE(&attr_ram3)
205   AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(quizmstr_attr1_w) AM_BASE_MEMBER(coinmstr_state, attr_ram1)
206   AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(quizmstr_attr2_w) AM_BASE_MEMBER(coinmstr_state, attr_ram2)
207   AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(quizmstr_attr3_w) AM_BASE_MEMBER(coinmstr_state, attr_ram3)
204208ADDRESS_MAP_END
205209
206210// Different I/O mappping for every game
r10886r10887
896900   int tile = videoram[tile_index + 0x0240];
897901   int color = tile_index;
898902
899   tile |= (attr_ram1[tile_index + 0x0240] & 0x80) << 1;
900   tile |= (attr_ram2[tile_index + 0x0240] & 0x80) << 2;
903   tile |= (state->attr_ram1[tile_index + 0x0240] & 0x80) << 1;
904   tile |= (state->attr_ram2[tile_index + 0x0240] & 0x80) << 2;
901905
902   tile |= (attr_ram3[tile_index + 0x0240] & 0x03) << (6+4);
906   tile |= (state->attr_ram3[tile_index + 0x0240] & 0x03) << (6+4);
903907
904908   SET_TILE_INFO(0, tile, color, 0);
905909}
906910
907911static VIDEO_START( coinmstr )
908912{
909   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 46, 32);
913   coinmstr_state *state = machine->driver_data<coinmstr_state>();
914   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 46, 32);
910915}
911916
912917static SCREEN_UPDATE( coinmstr )
913918{
914   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
919   coinmstr_state *state = screen->machine->driver_data<coinmstr_state>();
920   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
915921   return 0;
916922}
917923
src/mame/drivers/magicard.c
r10886r10887
165165#include "cpu/m68000/m68000.h"
166166#include "sound/2413intf.h"
167167
168static UINT16 *magicram;
169static UINT16 *pcab_vregs;
170168
169class magicard_state : public driver_device
170{
171public:
172   magicard_state(running_machine &machine, const driver_device_config_base &config)
173      : driver_device(machine, config) { }
171174
175   UINT16 *magicram;
176   UINT16 *pcab_vregs;
177   UINT16 *scc68070_ext_irqc_regs;
178   UINT16 *scc68070_iic_regs;
179   UINT16 *scc68070_uart_regs;
180   UINT16 *scc68070_timer_regs;
181   UINT16 *scc68070_int_irqc_regs;
182   UINT16 *scc68070_dma_ch1_regs;
183   UINT16 *scc68070_dma_ch2_regs;
184   UINT16 *scc68070_mmu_regs;
185   struct { int r,g,b,offs,offs_internal; } pal;
186};
187
188
172189/*************************
173190*     Video Hardware     *
174191*************************/
r10886r10887
200217*/
201218
202219/*63 at post test,6d all the time.*/
203#define SCC_CSR_VREG    (pcab_vregs[0x00/2] & 0xffff)
220#define SCC_CSR_VREG    (state->pcab_vregs[0x00/2] & 0xffff)
204221#define SCC_CG_VREG      ((SCC_CSR_VREG & 0x10)>>4)
205222
206223/*
r10886r10887
226243    w ........ ....aaaa  VSR:H = video start address (MSB's)
227244*/
228245
229#define SCC_DCR_VREG    (pcab_vregs[0x02/2] & 0xffff)
246#define SCC_DCR_VREG    (state->pcab_vregs[0x02/2] & 0xffff)
230247#define SCC_DE_VREG      ((SCC_DCR_VREG & 0x8000)>>15)
231248#define SCC_FG_VREG      ((SCC_DCR_VREG & 0x0080)>>7)
232249#define SCC_VSR_VREG_H  ((SCC_DCR_VREG & 0xf)>>0)
r10886r10887
236253    w aaaaaaaa aaaaaaaa  VSR:L = video start address (LSB's)
237254*/
238255
239#define SCC_VSR_VREG_L  (pcab_vregs[0x04/2] & 0xffff)
256#define SCC_VSR_VREG_L  (state->pcab_vregs[0x04/2] & 0xffff)
240257#define SCC_VSR_VREG    ((SCC_VSR_VREG_H)<<16) | (SCC_VSR_VREG_L)
241258
242259/*
r10886r10887
255272    w ........ xxxx....  not used
256273    w ........ ....aaaa  "data" (dunno the purpose...)
257274*/
258#define SCC_DCR2_VREG  (pcab_vregs[0x08/2] & 0xffff)
275#define SCC_DCR2_VREG  (state->pcab_vregs[0x08/2] & 0xffff)
259276
260277/*
261278(Note: not present on the original vreg listing)
r10886r10887
2762931ffff0  a = source register a
277294    w nnnnnnnn nnnnnnnn  source
278295*/
279#define SCC_SRCA_VREG  (pcab_vregs[0x10/2] & 0xffff)
296#define SCC_SRCA_VREG  (state->pcab_vregs[0x10/2] & 0xffff)
280297
281298/*
2822991ffff2  b = destination register b
283300   rw nnnnnnnn nnnnnnnn  destination
284301*/
285302
286#define SCC_DSTB_VREG  (pcab_vregs[0x12/2] & 0xffff)
303#define SCC_DSTB_VREG  (state->pcab_vregs[0x12/2] & 0xffff)
287304
288305/*
2893061ffff4  pcr = pixac command register
r10886r10887
330347    w ........ .......0
331348*/
332349
333#define SCC_PCR_VREG  (pcab_vregs[0x14/2] & 0xffff)
350#define SCC_PCR_VREG  (state->pcab_vregs[0x14/2] & 0xffff)
334351
335352/*
3363531ffff6  mask = mask register
r10886r10887
363380
364381static SCREEN_UPDATE(magicard)
365382{
383   magicard_state *state = screen->machine->driver_data<magicard_state>();
366384   int x,y;
367385   UINT32 count;
368386
r10886r10887
381399         {
382400            UINT32 color;
383401
384            color = ((magicram[count]) & 0x000f)>>0;
402            color = ((state->magicram[count]) & 0x000f)>>0;
385403
386404            if(((x*4)+3)<screen->visible_area().max_x && ((y)+0)<screen->visible_area().max_y)
387405               *BITMAP_ADDR32(bitmap, y, (x*4)+3) = screen->machine->pens[color];
388406
389            color = ((magicram[count]) & 0x00f0)>>4;
407            color = ((state->magicram[count]) & 0x00f0)>>4;
390408
391409            if(((x*4)+2)<screen->visible_area().max_x && ((y)+0)<screen->visible_area().max_y)
392410               *BITMAP_ADDR32(bitmap, y, (x*4)+2) = screen->machine->pens[color];
393411
394            color = ((magicram[count]) & 0x0f00)>>8;
412            color = ((state->magicram[count]) & 0x0f00)>>8;
395413
396414            if(((x*4)+1)<screen->visible_area().max_x && ((y)+0)<screen->visible_area().max_y)
397415               *BITMAP_ADDR32(bitmap, y, (x*4)+1) = screen->machine->pens[color];
398416
399            color = ((magicram[count]) & 0xf000)>>12;
417            color = ((state->magicram[count]) & 0xf000)>>12;
400418
401419            if(((x*4)+0)<screen->visible_area().max_x && ((y)+0)<screen->visible_area().max_y)
402420               *BITMAP_ADDR32(bitmap, y, (x*4)+0) = screen->machine->pens[color];
r10886r10887
413431         {
414432            UINT32 color;
415433
416            color = ((magicram[count]) & 0x00ff)>>0;
434            color = ((state->magicram[count]) & 0x00ff)>>0;
417435
418436            if(((x*2)+1)<screen->visible_area().max_x && ((y)+0)<screen->visible_area().max_y)
419437               *BITMAP_ADDR32(bitmap, y, (x*2)+1) = screen->machine->pens[color];
420438
421            color = ((magicram[count]) & 0xff00)>>8;
439            color = ((state->magicram[count]) & 0xff00)>>8;
422440
423441            if(((x*2)+0)<screen->visible_area().max_x && ((y)+0)<screen->visible_area().max_y)
424442               *BITMAP_ADDR32(bitmap, y, (x*2)+0) = screen->machine->pens[color];
r10886r10887
443461
444462static WRITE16_HANDLER( paletteram_io_w )
445463{
446   static int pal_offs,r,g,b,internal_pal_offs;
447
464   magicard_state *state = space->machine->driver_data<magicard_state>();
448465   switch(offset*2)
449466   {
450467      case 0:
451         pal_offs = data;
452         internal_pal_offs = 0;
468         state->pal.offs = data;
469         state->pal.offs_internal = 0;
453470         break;
454471      case 4:
455472         break;
456473      case 2:
457         switch(internal_pal_offs)
474         switch(state->pal.offs_internal)
458475         {
459476            case 0:
460               r = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
461               internal_pal_offs++;
477               state->pal.r = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
478               state->pal.offs_internal++;
462479               break;
463480            case 1:
464               g = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
465               internal_pal_offs++;
481               state->pal.g = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
482               state->pal.offs_internal++;
466483               break;
467484            case 2:
468               b = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
469               palette_set_color(space->machine, pal_offs, MAKE_RGB(r, g, b));
470               internal_pal_offs = 0;
471               pal_offs++;
485               state->pal.b = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
486               palette_set_color(space->machine, state->pal.offs, MAKE_RGB(state->pal.r, state->pal.g, state->pal.b));
487               state->pal.offs_internal = 0;
488               state->pal.offs++;
472489               break;
473490         }
474491
r10886r10887
478495
479496static READ16_HANDLER( philips_66470_r )
480497{
498   magicard_state *state = space->machine->driver_data<magicard_state>();
481499   switch(offset)
482500   {
483501//      case 0/2:
r10886r10887
487505   //printf("[%04x]\n",offset*2);
488506
489507
490   return pcab_vregs[offset];
508   return state->pcab_vregs[offset];
491509}
492510
493511static WRITE16_HANDLER( philips_66470_w )
494512{
495   COMBINE_DATA(&pcab_vregs[offset]);
513   magicard_state *state = space->machine->driver_data<magicard_state>();
514   COMBINE_DATA(&state->pcab_vregs[offset]);
496515
497516//  if(offset == 0x10/2)
498517//  {
499      //printf("%04x %04x %04x\n",data,pcab_vregs[0x12/2],pcab_vregs[0x14/2]);
500      //pcab_vregs[0x12/2] = pcab_vregs[0x10/2];
518      //printf("%04x %04x %04x\n",data,state->pcab_vregs[0x12/2],state->pcab_vregs[0x14/2]);
519      //state->pcab_vregs[0x12/2] = state->pcab_vregs[0x10/2];
501520//  }
502521}
503522
504523/* scc68070 specific stuff (to be moved) */
505static UINT16 *scc68070_ext_irqc_regs;
506static UINT16 *scc68070_iic_regs;
507static UINT16 *scc68070_uart_regs;
508static UINT16 *scc68070_timer_regs;
509static UINT16 *scc68070_int_irqc_regs;
510static UINT16 *scc68070_dma_ch1_regs;
511static UINT16 *scc68070_dma_ch2_regs;
512static UINT16 *scc68070_mmu_regs;
513524
514static READ16_HANDLER( scc68070_ext_irqc_r ) { return scc68070_ext_irqc_regs[offset]; }
515static WRITE16_HANDLER( scc68070_ext_irqc_w ){ scc68070_ext_irqc_regs[offset] = data; }
525static READ16_HANDLER( scc68070_ext_irqc_r )
526{
527   magicard_state *state = space->machine->driver_data<magicard_state>();
528   return state->scc68070_ext_irqc_regs[offset];
529}
530
531static WRITE16_HANDLER( scc68070_ext_irqc_w )
532{
533   magicard_state *state = space->machine->driver_data<magicard_state>();
534   state->scc68070_ext_irqc_regs[offset] = data;
535}
536
516537static READ16_HANDLER( scc68070_iic_r )
517538{
539   magicard_state *state = space->machine->driver_data<magicard_state>();
518540   //printf("%04x\n",offset*2);
519541
520542   switch(offset)
521543   {
522      case 0x04/2: return scc68070_iic_regs[offset] & 0xef; //iic status register, bit 4 = pending irq
544      case 0x04/2: return state->scc68070_iic_regs[offset] & 0xef; //iic status register, bit 4 = pending irq
523545   }
524546
525   return scc68070_iic_regs[offset];
547   return state->scc68070_iic_regs[offset];
526548}
527549
528static WRITE16_HANDLER( scc68070_iic_w ){ scc68070_iic_regs[offset] = data; }
550static WRITE16_HANDLER( scc68070_iic_w )
551{
552   magicard_state *state = space->machine->driver_data<magicard_state>();
553   state->scc68070_iic_regs[offset] = data;
554}
529555
530556static READ16_HANDLER( scc68070_uart_r )
531557{
558   magicard_state *state = space->machine->driver_data<magicard_state>();
532559   //printf("%02x\n",offset*2);
533560
534561   switch(offset)
r10886r10887
536563      case 0x02/2: return space->machine->rand(); //uart mode register
537564   }
538565
539   return scc68070_uart_regs[offset];
566   return state->scc68070_uart_regs[offset];
540567}
541568
542static WRITE16_HANDLER( scc68070_uart_w ) {   scc68070_uart_regs[offset] = data; }
569static WRITE16_HANDLER( scc68070_uart_w )
570{
571   magicard_state *state = space->machine->driver_data<magicard_state>();
572   state->scc68070_uart_regs[offset] = data;
573}
543574
544static READ16_HANDLER( scc68070_timer_r ) { return scc68070_timer_regs[offset]; }
545static WRITE16_HANDLER( scc68070_timer_w ){ scc68070_timer_regs[offset] = data; }
546static READ16_HANDLER( scc68070_int_irqc_r ) { return scc68070_int_irqc_regs[offset]; }
547static WRITE16_HANDLER( scc68070_int_irqc_w ){ scc68070_int_irqc_regs[offset] = data; }
548static READ16_HANDLER( scc68070_dma_ch1_r ) { return scc68070_dma_ch1_regs[offset]; }
549static WRITE16_HANDLER( scc68070_dma_ch1_w ){ scc68070_dma_ch1_regs[offset] = data; }
550static READ16_HANDLER( scc68070_dma_ch2_r ) { return scc68070_dma_ch2_regs[offset]; }
551static WRITE16_HANDLER( scc68070_dma_ch2_w ){ scc68070_dma_ch2_regs[offset] = data; }
552static READ16_HANDLER( scc68070_mmu_r ) { return scc68070_mmu_regs[offset]; }
575static READ16_HANDLER( scc68070_timer_r )
576{
577   magicard_state *state = space->machine->driver_data<magicard_state>();
578   return state->scc68070_timer_regs[offset];
579}
580
581static WRITE16_HANDLER( scc68070_timer_w )
582{
583   magicard_state *state = space->machine->driver_data<magicard_state>();
584   state->scc68070_timer_regs[offset] = data;
585}
586
587static READ16_HANDLER( scc68070_int_irqc_r )
588{
589   magicard_state *state = space->machine->driver_data<magicard_state>();
590   return state->scc68070_int_irqc_regs[offset];
591}
592
593static WRITE16_HANDLER( scc68070_int_irqc_w )
594{
595   magicard_state *state = space->machine->driver_data<magicard_state>();
596   state->scc68070_int_irqc_regs[offset] = data;
597}
598
599static READ16_HANDLER( scc68070_dma_ch1_r )
600{
601   magicard_state *state = space->machine->driver_data<magicard_state>();
602   return state->scc68070_dma_ch1_regs[offset];
603}
604
605static WRITE16_HANDLER( scc68070_dma_ch1_w )
606{
607   magicard_state *state = space->machine->driver_data<magicard_state>();
608   state->scc68070_dma_ch1_regs[offset] = data;
609}
610
611static READ16_HANDLER( scc68070_dma_ch2_r )
612{
613   magicard_state *state = space->machine->driver_data<magicard_state>();
614   return state->scc68070_dma_ch2_regs[offset];
615}
616
617static WRITE16_HANDLER( scc68070_dma_ch2_w )
618{
619   magicard_state *state = space->machine->driver_data<magicard_state>();
620   state->scc68070_dma_ch2_regs[offset] = data;
621}
622
623static READ16_HANDLER( scc68070_mmu_r )
624{
625   magicard_state *state = space->machine->driver_data<magicard_state>();
626   return state->scc68070_mmu_regs[offset];
627}
628
553629static WRITE16_HANDLER( scc68070_mmu_w )
554630{
555   scc68070_mmu_regs[offset] = data;
631   magicard_state *state = space->machine->driver_data<magicard_state>();
632   state->scc68070_mmu_regs[offset] = data;
556633
557634   switch(offset)
558635   {
r10886r10887
570647
571648static ADDRESS_MAP_START( magicard_mem, ADDRESS_SPACE_PROGRAM, 16 )
572649//  ADDRESS_MAP_GLOBAL_MASK(0x1fffff)
573   AM_RANGE(0x00000000, 0x0017ffff) AM_MIRROR(0x7fe00000) AM_RAM AM_BASE(&magicram) /*only 0-7ffff accessed in Magic Card*/
650   AM_RANGE(0x00000000, 0x0017ffff) AM_MIRROR(0x7fe00000) AM_RAM AM_BASE_MEMBER(magicard_state, magicram) /*only 0-7ffff accessed in Magic Card*/
574651   AM_RANGE(0x00180000, 0x001ffbff) AM_MIRROR(0x7fe00000) AM_RAM AM_REGION("maincpu", 0)
575652   /* 001ffc00-001ffdff System I/O */
576653   AM_RANGE(0x001ffc00, 0x001ffc01) AM_MIRROR(0x7fe00000) AM_READ(test_r)
r10886r10887
581658   AM_RANGE(0x001ffd80, 0x001ffd81) AM_MIRROR(0x7fe00000) AM_READ(test_r)
582659   AM_RANGE(0x001ffd80, 0x001ffd81) AM_MIRROR(0x7fe00000) AM_WRITENOP //?
583660   AM_RANGE(0x001fff80, 0x001fffbf) AM_MIRROR(0x7fe00000) AM_RAM //DRAM I/O, not accessed by this game, CD buffer?
584   AM_RANGE(0x001fffe0, 0x001fffff) AM_MIRROR(0x7fe00000) AM_READWRITE(philips_66470_r,philips_66470_w) AM_BASE(&pcab_vregs) //video registers
585   AM_RANGE(0x80001000, 0x8000100f) AM_READWRITE(scc68070_ext_irqc_r,scc68070_ext_irqc_w) AM_BASE(&scc68070_ext_irqc_regs) //lir
586   AM_RANGE(0x80002000, 0x8000200f) AM_READWRITE(scc68070_iic_r,scc68070_iic_w) AM_BASE(&scc68070_iic_regs) //i2c
587   AM_RANGE(0x80002010, 0x8000201f) AM_READWRITE(scc68070_uart_r,scc68070_uart_w) AM_BASE(&scc68070_uart_regs)
588   AM_RANGE(0x80002020, 0x8000202f) AM_READWRITE(scc68070_timer_r,scc68070_timer_w) AM_BASE(&scc68070_timer_regs)
589   AM_RANGE(0x80002040, 0x8000204f) AM_READWRITE(scc68070_int_irqc_r,scc68070_int_irqc_w) AM_BASE(&scc68070_int_irqc_regs)
590   AM_RANGE(0x80004000, 0x8000403f) AM_READWRITE(scc68070_dma_ch1_r,scc68070_dma_ch1_w) AM_BASE(&scc68070_dma_ch1_regs)
591   AM_RANGE(0x80004040, 0x8000407f) AM_READWRITE(scc68070_dma_ch2_r,scc68070_dma_ch2_w) AM_BASE(&scc68070_dma_ch2_regs)
592   AM_RANGE(0x80008000, 0x8000807f) AM_READWRITE(scc68070_mmu_r,scc68070_mmu_w) AM_BASE(&scc68070_mmu_regs)
661   AM_RANGE(0x001fffe0, 0x001fffff) AM_MIRROR(0x7fe00000) AM_READWRITE(philips_66470_r,philips_66470_w) AM_BASE_MEMBER(magicard_state, pcab_vregs) //video registers
662   AM_RANGE(0x80001000, 0x8000100f) AM_READWRITE(scc68070_ext_irqc_r,scc68070_ext_irqc_w) AM_BASE_MEMBER(magicard_state, scc68070_ext_irqc_regs) //lir
663   AM_RANGE(0x80002000, 0x8000200f) AM_READWRITE(scc68070_iic_r,scc68070_iic_w) AM_BASE_MEMBER(magicard_state, scc68070_iic_regs) //i2c
664   AM_RANGE(0x80002010, 0x8000201f) AM_READWRITE(scc68070_uart_r,scc68070_uart_w) AM_BASE_MEMBER(magicard_state, scc68070_uart_regs)
665   AM_RANGE(0x80002020, 0x8000202f) AM_READWRITE(scc68070_timer_r,scc68070_timer_w) AM_BASE_MEMBER(magicard_state, scc68070_timer_regs)
666   AM_RANGE(0x80002040, 0x8000204f) AM_READWRITE(scc68070_int_irqc_r,scc68070_int_irqc_w) AM_BASE_MEMBER(magicard_state, scc68070_int_irqc_regs)
667   AM_RANGE(0x80004000, 0x8000403f) AM_READWRITE(scc68070_dma_ch1_r,scc68070_dma_ch1_w) AM_BASE_MEMBER(magicard_state, scc68070_dma_ch1_regs)
668   AM_RANGE(0x80004040, 0x8000407f) AM_READWRITE(scc68070_dma_ch2_r,scc68070_dma_ch2_w) AM_BASE_MEMBER(magicard_state, scc68070_dma_ch2_regs)
669   AM_RANGE(0x80008000, 0x8000807f) AM_READWRITE(scc68070_mmu_r,scc68070_mmu_w) AM_BASE_MEMBER(magicard_state, scc68070_mmu_regs)
593670ADDRESS_MAP_END
594671
595672
r10886r10887
603680
604681static MACHINE_RESET( magicard )
605682{
606   UINT16 *src    = (UINT16*)machine->region( "maincpu" )->base();
607   UINT16 *dst    = magicram;
683   magicard_state *state = machine->driver_data<magicard_state>();
684   UINT16 *src    = (UINT16*)machine->region("maincpu" )->base();
685   UINT16 *dst    = state->magicram;
608686   memcpy (dst, src, 0x80000);
609687   machine->device("maincpu")->reset();
610688}
r10886r10887
623701      cpu_set_input_line_and_vector(device, 1, HOLD_LINE,0xf0/4);
624702}
625703
626static MACHINE_CONFIG_START( magicard, driver_device )
704static MACHINE_CONFIG_START( magicard, magicard_state )
627705   MCFG_CPU_ADD("maincpu", SCC68070, CLOCK_A/2)   /* SCC-68070 CCA84 datasheet */
628706   MCFG_CPU_PROGRAM_MAP(magicard_mem)
629707   MCFG_CPU_VBLANK_INT("screen", magicard_irq) /* no interrupts? (it erases the vectors..) */
src/mame/drivers/murogem.c
r10886r10887
9898#include "cpu/m6800/m6800.h"
9999#include "video/mc6845.h"
100100
101static UINT8 *murogem_videoram;
102101
102class murogem_state : public driver_device
103{
104public:
105   murogem_state(running_machine &machine, const driver_device_config_base &config)
106      : driver_device(machine, config) { }
103107
108   UINT8 *videoram;
109};
110
111
104112static ADDRESS_MAP_START( murogem_map, ADDRESS_SPACE_PROGRAM, 8 )
105113   AM_RANGE(0x0000, 0x007f) AM_RAM
106114   AM_RANGE(0x4000, 0x4000) AM_DEVWRITE("crtc", mc6845_address_w)
r10886r10887
108116   AM_RANGE(0x5000, 0x5000) AM_READ_PORT("IN0")
109117   AM_RANGE(0x5800, 0x5800) AM_READ_PORT("IN1")
110118   AM_RANGE(0x7000, 0x7000) AM_WRITENOP // sound? payout?
111   AM_RANGE(0x8000, 0x87ff) AM_RAM AM_BASE(&murogem_videoram)
119   AM_RANGE(0x8000, 0x87ff) AM_RAM AM_BASE_MEMBER(murogem_state, videoram)
112120   AM_RANGE(0xf000, 0xffff) AM_ROM
113121ADDRESS_MAP_END
114122
r10886r10887
169177
170178static SCREEN_UPDATE(murogem)
171179{
180   murogem_state *state = screen->machine->driver_data<murogem_state>();
172181   int xx,yy,count;
173182   count = 0x000;
174183
r10886r10887
178187   {
179188      for(xx=0;xx<32;xx++)
180189      {
181         int tileno = murogem_videoram[count]&0x3f;
182         int attr = murogem_videoram[count+0x400]&0x0f;
190         int tileno = state->videoram[count]&0x3f;
191         int attr = state->videoram[count+0x400]&0x0f;
183192
184193         drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[0],tileno,attr,0,0,xx*8,yy*8,0);
185194
r10886r10887
207216};
208217
209218
210static MACHINE_CONFIG_START( murogem, driver_device )
219static MACHINE_CONFIG_START( murogem, murogem_state )
211220   /* basic machine hardware */
212221   MCFG_CPU_ADD("maincpu", M6802,8000000)       /* ? MHz */
213222   MCFG_CPU_PROGRAM_MAP(murogem_map)
src/mame/drivers/hotstuff.c
r10886r10887
33#include "emu.h"
44#include "cpu/m68000/m68000.h"
55
6static UINT16* hotstuff_bitmapram;
76
7class hotstuff_state : public driver_device
8{
9public:
10   hotstuff_state(running_machine &machine, const driver_device_config_base &config)
11      : driver_device(machine, config) { }
12
13   UINT16* bitmapram;
14};
15
16
817VIDEO_START( hotstuff )
918{
10
1119}
1220
1321/* the first 0x20 bytes in every 0x200 (each line) of video ram are the colour data, providing a palette of 16 RGB444 colours for that line */
1422
1523SCREEN_UPDATE( hotstuff )
1624{
25   hotstuff_state *state = screen->machine->driver_data<hotstuff_state>();
1726   int count, y,yyy,x,xxx;
1827   UINT16 row_palette_data[0x10];
1928   rgb_t row_palette_data_as_rgb32_pen_data[0x10];
r10886r10887
2837
2938      for (p=0;p<0x10;p++)
3039      {
31         row_palette_data[p] = hotstuff_bitmapram[count+p];
40         row_palette_data[p] = state->bitmapram[count+p];
3241
3342         row_palette_data_as_rgb32_pen_data[p] = MAKE_RGB( (row_palette_data[p] & 0x0f00)>>4, (row_palette_data[p] & 0x00f0)>>0, (row_palette_data[p] & 0x000f)<<4  );
3443
r10886r10887
3746      for(x = 0; x < xxx; x++)
3847      {
3948         {
40            *BITMAP_ADDR32(bitmap, y, x) = row_palette_data_as_rgb32_pen_data[(hotstuff_bitmapram[count] &0xf000)>>12];
49            *BITMAP_ADDR32(bitmap, y, x) = row_palette_data_as_rgb32_pen_data[(state->bitmapram[count] &0xf000)>>12];
4150            x++;
42            *BITMAP_ADDR32(bitmap, y, x) = row_palette_data_as_rgb32_pen_data[(hotstuff_bitmapram[count] &0x0f00)>>8];
51            *BITMAP_ADDR32(bitmap, y, x) = row_palette_data_as_rgb32_pen_data[(state->bitmapram[count] &0x0f00)>>8];
4352            x++;
44            *BITMAP_ADDR32(bitmap, y, x) = row_palette_data_as_rgb32_pen_data[(hotstuff_bitmapram[count] &0x00f0)>>4];
53            *BITMAP_ADDR32(bitmap, y, x) = row_palette_data_as_rgb32_pen_data[(state->bitmapram[count] &0x00f0)>>4];
4554            x++;
46            *BITMAP_ADDR32(bitmap, y, x) = row_palette_data_as_rgb32_pen_data[(hotstuff_bitmapram[count] &0x000f)>>0];
55            *BITMAP_ADDR32(bitmap, y, x) = row_palette_data_as_rgb32_pen_data[(state->bitmapram[count] &0x000f)>>0];
4756         }
4857
4958         count++;
r10886r10887
5867
5968   AM_RANGE(0x400000, 0x40ffff) AM_RAM
6069
61   AM_RANGE(0x980000, 0x9bffff) AM_RAM AM_BASE(&hotstuff_bitmapram)
70   AM_RANGE(0x980000, 0x9bffff) AM_RAM AM_BASE_MEMBER(hotstuff_state, bitmapram)
6271ADDRESS_MAP_END
6372
6473static INPUT_PORTS_START( hotstuff )
6574INPUT_PORTS_END
6675
67static MACHINE_CONFIG_START( hotstuff, driver_device )
76static MACHINE_CONFIG_START( hotstuff, hotstuff_state )
6877
6978   MCFG_CPU_ADD("maincpu", M68000, 16000000)
7079   MCFG_CPU_PROGRAM_MAP(hotstuff_map)
src/mame/drivers/st_mp200.c
r10886r10887
351351GAME(1981,   ironmaid,   0,         st_mp200,   st_mp200,   st_mp200,   ROT0,   "Stern",            "Iron Maiden",            GAME_NOT_WORKING | GAME_NO_SOUND | GAME_MECHANICAL)
352352GAME(1984,   lazrlord,   0,         st_mp200,   st_mp200,   st_mp200,   ROT0,   "Stern",            "Lazer Lord",            GAME_NOT_WORKING | GAME_NO_SOUND | GAME_MECHANICAL)
353353GAME(1981,   lightnin,   0,         st_mp200,   st_mp200,   st_mp200,   ROT0,   "Stern",            "Lightning",            GAME_NOT_WORKING | GAME_NO_SOUND | GAME_MECHANICAL)
354GAME(1979,   meteorp,   0,         st_mp200,   st_mp200,   st_mp200,   ROT0,   "Stern",            "Meteor (Pinball)",            GAME_NOT_WORKING | GAME_NO_SOUND | GAME_MECHANICAL)
354GAME(1979,   meteorp,   0,         st_mp200,   st_mp200,   st_mp200,   ROT0,   "Stern",            "Meteor (Stern)",            GAME_NOT_WORKING | GAME_NO_SOUND | GAME_MECHANICAL)
355355GAME(1980,   nineball,   0,         st_mp200,   st_mp200,   st_mp200,   ROT0,   "Stern",            "Nine Ball",            GAME_NOT_WORKING | GAME_NO_SOUND | GAME_MECHANICAL)
356356GAME(1982,   orbitor1,   0,         st_mp200,   st_mp200,   st_mp200,   ROT0,   "Stern",            "Orbitor 1",            GAME_NOT_WORKING | GAME_NO_SOUND | GAME_MECHANICAL)
357357GAME(1980,   quicksil,   0,         st_mp200,   st_mp200,   st_mp200,   ROT0,   "Stern",            "Quicksilver",            GAME_NOT_WORKING | GAME_NO_SOUND | GAME_MECHANICAL)
src/mame/drivers/skimaxx.c
r10886r10887
4040#include "sound/okim6295.h"
4141
4242
43/*************************************
44 *
45 *  Statics
46 *
47 *************************************/
43class skimaxx_state : public driver_device
44{
45public:
46   skimaxx_state(running_machine &machine, const driver_device_config_base &config)
47      : driver_device(machine, config) { }
4848
49static UINT32 *bg_buffer;   // i.e. background and sprites
50static UINT16 *fg_buffer;   // i.e. text
49   UINT32 *bg_buffer;
50   UINT16 *fg_buffer;
51   UINT32 *bg_buffer_front;
52   UINT32 *bg_buffer_back;
53   UINT32 *blitter_regs;
54   UINT16 *blitter_gfx;
55   UINT32 blitter_gfx_len;
56   UINT32 blitter_src_x;
57   UINT32 blitter_src_dx;
58   UINT32 blitter_src_y;
59   UINT32 blitter_src_dy;
60   UINT32 *fpga_ctrl;
61};
5162
5263
5364/*************************************
r10886r10887
5667 *
5768 *************************************/
5869
59static UINT32 *skimaxx_bg_buffer_front;
60static UINT32 *skimaxx_bg_buffer_back;
61
62static UINT32 *skimaxx_blitter_regs;
63static UINT16 *skimaxx_blitter_gfx;
64
65static UINT32 skimaxx_blitter_gfx_len;
66
67static UINT32 skimaxx_blitter_src_x, skimaxx_blitter_src_dx;
68static UINT32 skimaxx_blitter_src_y, skimaxx_blitter_src_dy;
69
7070// Set up blit parameters
7171static WRITE32_HANDLER( skimaxx_blitter_w )
7272{
73   UINT32 newdata = COMBINE_DATA( &skimaxx_blitter_regs[offset] );
73   skimaxx_state *state = space->machine->driver_data<skimaxx_state>();
74   UINT32 newdata = COMBINE_DATA( &state->blitter_regs[offset] );
7475
7576   switch (offset)
7677   {
7778      case 0:
78         skimaxx_blitter_src_dy = (newdata & 0x7fff) - (newdata & 0x8000);
79         state->blitter_src_dy = (newdata & 0x7fff) - (newdata & 0x8000);
7980         break;
8081
8182      case 1:
82         skimaxx_blitter_src_x = (newdata & 0x1ff) << 8;
83         skimaxx_blitter_src_y = (newdata >> 9) << 8;
83         state->blitter_src_x = (newdata & 0x1ff) << 8;
84         state->blitter_src_y = (newdata >> 9) << 8;
8485         break;
8586
8687      case 2:
8788         if (ACCESSING_BITS_16_31)
88            skimaxx_blitter_src_dx = (newdata >> 16) & 0xffff;
89            state->blitter_src_dx = (newdata >> 16) & 0xffff;
8990         if (ACCESSING_BITS_0_15)
90            skimaxx_blitter_src_dx = newdata & 0xffff;
91            state->blitter_src_dx = newdata & 0xffff;
9192
92         skimaxx_blitter_src_dx = (skimaxx_blitter_src_dx & 0x7fff) - (skimaxx_blitter_src_dx & 0x8000);
93         state->blitter_src_dx = (state->blitter_src_dx & 0x7fff) - (state->blitter_src_dx & 0x8000);
9394         break;
9495
9596      case 3:
r10886r10887
101102// A read by the 68030 from this area blits one pixel to the back buffer (at the same offset)
102103static READ32_HANDLER( skimaxx_blitter_r )
103104{
104   UINT32 penaddr = ((skimaxx_blitter_src_x >> 8) & 0x1ff) + ((skimaxx_blitter_src_y >> 8) << 9);
105   UINT16 *src = skimaxx_blitter_gfx + (penaddr % skimaxx_blitter_gfx_len);
106   UINT32 *dst = skimaxx_bg_buffer_back + offset;
105   skimaxx_state *state = space->machine->driver_data<skimaxx_state>();
106   UINT32 penaddr = ((state->blitter_src_x >> 8) & 0x1ff) + ((state->blitter_src_y >> 8) << 9);
107   UINT16 *src = state->blitter_gfx + (penaddr % state->blitter_gfx_len);
108   UINT32 *dst = state->bg_buffer_back + offset;
107109
108110   UINT16 pen = (*src) & 0x7fff;
109111
r10886r10887
115117         *dst = (*dst & 0xffff0000) | pen;
116118   }
117119
118   skimaxx_blitter_src_x = (skimaxx_blitter_src_x & 0x10000) | ((skimaxx_blitter_src_x + skimaxx_blitter_src_dx) & 0xffff);
119   skimaxx_blitter_src_y = (skimaxx_blitter_src_y & 0xffff0000) | ((skimaxx_blitter_src_y + skimaxx_blitter_src_dy) & 0xffff);
120   state->blitter_src_x = (state->blitter_src_x & 0x10000) | ((state->blitter_src_x + state->blitter_src_dx) & 0xffff);
121   state->blitter_src_y = (state->blitter_src_y & 0xffff0000) | ((state->blitter_src_y + state->blitter_src_dy) & 0xffff);
120122
121123   return 0;
122124}
r10886r10887
124126
125127static VIDEO_START( skimaxx )
126128{
127   skimaxx_blitter_gfx = (UINT16 *) machine->region( "blitter" )->base();
128   skimaxx_blitter_gfx_len = machine->region( "blitter" )->bytes() / 2;
129   skimaxx_state *state = machine->driver_data<skimaxx_state>();
130   state->blitter_gfx = (UINT16 *) machine->region( "blitter" )->base();
131   state->blitter_gfx_len = machine->region( "blitter" )->bytes() / 2;
129132
130   bg_buffer = auto_alloc_array(machine, UINT32, 0x400 * 0x100 * sizeof(UINT16) / sizeof(UINT32) * 2);   // 2 buffers
131   skimaxx_bg_buffer_back  = bg_buffer + 0x400 * 0x100 * sizeof(UINT16) / sizeof(UINT32) * 0;
132   skimaxx_bg_buffer_front = bg_buffer + 0x400 * 0x100 * sizeof(UINT16) / sizeof(UINT32) * 1;
133   memory_configure_bank(machine, "bank1", 0, 1, skimaxx_bg_buffer_back,  0);
134   memory_configure_bank(machine, "bank1", 1, 1, skimaxx_bg_buffer_front, 0);
133   state->bg_buffer = auto_alloc_array(machine, UINT32, 0x400 * 0x100 * sizeof(UINT16) / sizeof(UINT32) * 2);   // 2 buffers
134   state->bg_buffer_back  = state->bg_buffer + 0x400 * 0x100 * sizeof(UINT16) / sizeof(UINT32) * 0;
135   state->bg_buffer_front = state->bg_buffer + 0x400 * 0x100 * sizeof(UINT16) / sizeof(UINT32) * 1;
136   memory_configure_bank(machine, "bank1", 0, 1, state->bg_buffer_back,  0);
137   memory_configure_bank(machine, "bank1", 1, 1, state->bg_buffer_front, 0);
135138}
136139
137140static SCREEN_UPDATE( skimaxx )
r10886r10887
152155// TODO: Might not be used
153156static void skimaxx_to_shiftreg(address_space *space, UINT32 address, UINT16 *shiftreg)
154157{
155   memcpy(shiftreg, &fg_buffer[TOWORD(address)], 512 * sizeof(UINT16));
158   skimaxx_state *state = space->machine->driver_data<skimaxx_state>();
159   memcpy(shiftreg, &state->fg_buffer[TOWORD(address)], 512 * sizeof(UINT16));
156160}
157161
158162static void skimaxx_from_shiftreg(address_space *space, UINT32 address, UINT16 *shiftreg)
159163{
160   memcpy(&fg_buffer[TOWORD(address)], shiftreg, 512 * sizeof(UINT16));
164   skimaxx_state *state = space->machine->driver_data<skimaxx_state>();
165   memcpy(&state->fg_buffer[TOWORD(address)], shiftreg, 512 * sizeof(UINT16));
161166}
162167
163168
r10886r10887
169174
170175static void skimaxx_scanline_update(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params)
171176{
177   skimaxx_state *state = screen.machine->driver_data<skimaxx_state>();
172178   // TODO: This isn't correct. I just hacked it together quickly so I could see something!
173179
174180   if (params->rowaddr >= 0x220)
175181   {
176182      UINT32 rowaddr = (params->rowaddr - 0x220);
177      UINT16 *fg = &fg_buffer[rowaddr << 8];
178      UINT32 *bg = &skimaxx_bg_buffer_front[rowaddr/2 * 1024/2];
183      UINT16 *fg = &state->fg_buffer[rowaddr << 8];
184      UINT32 *bg = &state->bg_buffer_front[rowaddr/2 * 1024/2];
179185      UINT16 *dest = BITMAP_ADDR16(bitmap, scanline, 0);
180186      //int coladdr = params->coladdr;
181187      int x;
r10886r10887
236242  bit 0: bit banging data
237243*/
238244
239static UINT32 *skimaxx_fpga_ctrl;
240245static WRITE32_HANDLER( skimaxx_fpga_ctrl_w )
241246{
242   UINT32 newdata = COMBINE_DATA( skimaxx_fpga_ctrl );
247   skimaxx_state *state = space->machine->driver_data<skimaxx_state>();
248   UINT32 newdata = COMBINE_DATA( state->fpga_ctrl );
243249
244250   if (ACCESSING_BITS_0_7)
245251   {
246252      // double buffering
247253      UINT8 bank_bg_buffer = (newdata & 0x40) ? 1 : 0;
248254
249      skimaxx_bg_buffer_back  = bg_buffer + 0x400 * 0x100 * sizeof(UINT16) / sizeof(UINT32) * bank_bg_buffer;
250      skimaxx_bg_buffer_front = bg_buffer + 0x400 * 0x100 * sizeof(UINT16) / sizeof(UINT32) * (1 - bank_bg_buffer);
255      state->bg_buffer_back  = state->bg_buffer + 0x400 * 0x100 * sizeof(UINT16) / sizeof(UINT32) * bank_bg_buffer;
256      state->bg_buffer_front = state->bg_buffer + 0x400 * 0x100 * sizeof(UINT16) / sizeof(UINT32) * (1 - bank_bg_buffer);
251257
252258      memory_set_bank(space->machine, "bank1", bank_bg_buffer);
253259   }
r10886r10887
256262// 0x2000004c: bit 7, bit 0
257263static READ32_HANDLER( unk_r )
258264{
259   return (*skimaxx_fpga_ctrl & 0x20) ? 0x80 : 0x00;
265   skimaxx_state *state = space->machine->driver_data<skimaxx_state>();
266   return (*state->fpga_ctrl & 0x20) ? 0x80 : 0x00;
260267}
261268
262269// 0x20000023
r10886r10887
338345   AM_RANGE(0x00000000, 0x003fffff) AM_ROM
339346
340347   AM_RANGE(0x20000000, 0x2007ffff) AM_READ ( skimaxx_blitter_r )   // do blit
341   AM_RANGE(0x30000000, 0x3000000f) AM_WRITE( skimaxx_blitter_w ) AM_BASE( &skimaxx_blitter_regs )
348   AM_RANGE(0x30000000, 0x3000000f) AM_WRITE( skimaxx_blitter_w ) AM_BASE_MEMBER(skimaxx_state, blitter_regs )
342349
343   AM_RANGE(0x40000000, 0x40000003) AM_WRITE( skimaxx_fpga_ctrl_w ) AM_BASE( &skimaxx_fpga_ctrl )
350   AM_RANGE(0x40000000, 0x40000003) AM_WRITE( skimaxx_fpga_ctrl_w ) AM_BASE_MEMBER(skimaxx_state, fpga_ctrl )
344351
345352   AM_RANGE(0x50000000, 0x5007ffff) AM_RAMBANK("bank1")   // background ram allocated here at video_start (skimaxx_bg_buffer_back/front)
346353//  AM_RANGE(0xfffc0000, 0xfffc7fff) AM_RAM AM_SHARE("share1")
r10886r10887
362369   AM_RANGE(0x00000000, 0x000100ff) AM_RAM
363370   AM_RANGE(0x00008000, 0x0003ffff) AM_RAM
364371   AM_RANGE(0x00050000, 0x0005ffff) AM_RAM
365   AM_RANGE(0x00220000, 0x003fffff) AM_RAM AM_BASE(&fg_buffer)
372   AM_RANGE(0x00220000, 0x003fffff) AM_RAM AM_BASE_MEMBER(skimaxx_state, fg_buffer)
366373   AM_RANGE(0x02000000, 0x0200000f) AM_RAM
367374   AM_RANGE(0x02100000, 0x0210000f) AM_RAM
368375   AM_RANGE(0x04000000, 0x047fffff) AM_ROM AM_REGION("tmsgfx", 0)
r10886r10887
503510 *
504511 *************************************/
505512
506static MACHINE_CONFIG_START( skimaxx, driver_device )
513static MACHINE_CONFIG_START( skimaxx, skimaxx_state )
507514   MCFG_CPU_ADD("maincpu", M68EC030, XTAL_40MHz)
508515   MCFG_CPU_PROGRAM_MAP(68030_1_map)
509516   MCFG_CPU_VBLANK_INT("screen", irq3_line_hold)   // 1,3,7 are identical, rest is RTE
src/mame/drivers/vroulet.c
r10886r10887
4040#include "sound/ay8910.h"
4141#include "machine/nvram.h"
4242
43
44class vroulet_state : public driver_device
45{
46public:
47   vroulet_state(running_machine &machine, const driver_device_config_base &config)
48      : driver_device(machine, config) { }
49
50   UINT8 *ball;
51   UINT8 *videoram;
52   UINT8 *colorram;
53   tilemap_t *bg_tilemap;
54};
55
56
4357/* video */
4458
45static UINT8 *vroulet_ball;
46static UINT8 *videoram;
47static UINT8 *colorram;
48static tilemap_t *bg_tilemap;
4959
5060static WRITE8_HANDLER(vroulet_paletteram_w)
5161{
r10886r10887
6979
7080static WRITE8_HANDLER( vroulet_videoram_w )
7181{
72   videoram[offset] = data;
73   tilemap_mark_tile_dirty(bg_tilemap, offset);
82   vroulet_state *state = space->machine->driver_data<vroulet_state>();
83   state->videoram[offset] = data;
84   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
7485}
7586
7687static WRITE8_HANDLER( vroulet_colorram_w )
7788{
78   colorram[offset] = data;
79   tilemap_mark_tile_dirty(bg_tilemap, offset);
89   vroulet_state *state = space->machine->driver_data<vroulet_state>();
90   state->colorram[offset] = data;
91   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
8092}
8193
8294static TILE_GET_INFO( get_bg_tile_info )
8395{
84   int attr = colorram[tile_index];
85   int code = videoram[tile_index] + ((attr & 0xc0) << 2);
96   vroulet_state *state = machine->driver_data<vroulet_state>();
97   int attr = state->colorram[tile_index];
98   int code = state->videoram[tile_index] + ((attr & 0xc0) << 2);
8699   int color = attr & 0x1f;
87100
88101   SET_TILE_INFO(0, code, color, 0);
r10886r10887
90103
91104static VIDEO_START(vroulet)
92105{
93   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows,
106   vroulet_state *state = machine->driver_data<vroulet_state>();
107   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows,
94108      8, 8, 32, 32);
95109}
96110
97111static SCREEN_UPDATE(vroulet)
98112{
99   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
113   vroulet_state *state = screen->machine->driver_data<vroulet_state>();
114   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
100115   drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[0], 0x320, 1, 0, 0,
101      vroulet_ball[1], vroulet_ball[0] - 12, 0);
116      state->ball[1], state->ball[0] - 12, 0);
102117   return 0;
103118}
104119
r10886r10887
108123   AM_RANGE(0x0000, 0x5fff) AM_ROM
109124   AM_RANGE(0x6000, 0x67ff) AM_RAM AM_SHARE("nvram")
110125   AM_RANGE(0x8000, 0x8000) AM_NOP
111   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(vroulet_videoram_w) AM_BASE(&videoram)
112   AM_RANGE(0x9400, 0x97ff) AM_RAM_WRITE(vroulet_colorram_w) AM_BASE(&colorram)
113   AM_RANGE(0xa000, 0xa001) AM_RAM AM_BASE(&vroulet_ball)
126   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(vroulet_videoram_w) AM_BASE_MEMBER(vroulet_state, videoram)
127   AM_RANGE(0x9400, 0x97ff) AM_RAM_WRITE(vroulet_colorram_w) AM_BASE_MEMBER(vroulet_state, colorram)
128   AM_RANGE(0xa000, 0xa001) AM_RAM AM_BASE_MEMBER(vroulet_state, ball)
114129   AM_RANGE(0xb000, 0xb0ff) AM_WRITE(vroulet_paletteram_w) AM_BASE_GENERIC(paletteram)
115130   AM_RANGE(0xc000, 0xc000) AM_NOP
116131ADDRESS_MAP_END
r10886r10887
260275
261276/* Machine Driver */
262277
263static MACHINE_CONFIG_START( vroulet, driver_device )
278static MACHINE_CONFIG_START( vroulet, vroulet_state )
264279   // basic machine hardware
265280   MCFG_CPU_ADD("maincpu", Z80, 4000000)   //???
266281   MCFG_CPU_PROGRAM_MAP(vroulet_map)
src/mame/drivers/coinmvga.c
r10886r10887
218218#include "sound/ymz280b.h"
219219#include "machine/nvram.h"
220220
221static UINT16 *vram;
222221
222class coinmvga_state : public driver_device
223{
224public:
225   coinmvga_state(running_machine &machine, const driver_device_config_base &config)
226      : driver_device(machine, config) { }
223227
228   UINT16 *vram;
229   struct { int r,g,b,offs,offs_internal; } bgpal, fgpal;
230};
231
232
224233/*************************
225234*     Video Hardware     *
226235*************************/
r10886r10887
228237
229238static VIDEO_START( coinmvga )
230239{
231
232240}
233241
234242
235243static SCREEN_UPDATE( coinmvga )
236244{
245   coinmvga_state *state = screen->machine->driver_data<coinmvga_state>();
237246   const gfx_element *gfx = screen->machine->gfx[0];
238247   int count = 0x04000/2;
239248
r10886r10887
244253   {
245254      for (x=0;x<128;x++)
246255      {
247         int tile = vram[count];
256         int tile = state->vram[count];
248257         //int colour = tile>>12;
249258         drawgfx_opaque(bitmap,cliprect,gfx,tile,0,0,0,x*8,y*8);
250259
r10886r10887
274283
275284static WRITE16_HANDLER( ramdac_bg_w )
276285{
277   static int pal_offs,internal_pal_offs,r,g,b;
278
286   coinmvga_state *state = space->machine->driver_data<coinmvga_state>();
279287   if(ACCESSING_BITS_8_15)
280288   {
281      pal_offs = data >> 8;
282      internal_pal_offs = 0;
289      state->bgpal.offs = data >> 8;
290      state->bgpal.offs_internal = 0;
283291   }
284292   else //if(mem_mask == 0x00ff)
285293   {
286      switch(internal_pal_offs)
294      switch(state->bgpal.offs_internal)
287295      {
288296         case 0:
289            r = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
290            internal_pal_offs++;
297            state->bgpal.r = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
298            state->bgpal.offs_internal++;
291299            break;
292300         case 1:
293            g = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
294            internal_pal_offs++;
301            state->bgpal.g = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
302            state->bgpal.offs_internal++;
295303            break;
296304         case 2:
297            b = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
298            palette_set_color(space->machine, pal_offs, MAKE_RGB(r, g, b));
299            internal_pal_offs = 0;
300            pal_offs++;
305            state->bgpal.b = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
306            palette_set_color(space->machine, state->bgpal.offs, MAKE_RGB(state->bgpal.r, state->bgpal.g, state->bgpal.b));
307            state->bgpal.offs_internal = 0;
308            state->bgpal.offs++;
301309            break;
302310      }
303311   }
r10886r10887
306314
307315static WRITE16_HANDLER( ramdac_fg_w )
308316{
309   static int pal_offs,internal_pal_offs,r,g,b;
310
317   coinmvga_state *state = space->machine->driver_data<coinmvga_state>();
311318   if(ACCESSING_BITS_8_15)
312319   {
313      pal_offs = data >> 8;
314      internal_pal_offs = 0;
320      state->fgpal.offs = data >> 8;
321      state->fgpal.offs_internal = 0;
315322   }
316323   else
317324   {
318      switch(internal_pal_offs)
325      switch(state->fgpal.offs_internal)
319326      {
320327         case 0:
321            r = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
322            internal_pal_offs++;
328            state->fgpal.r = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
329            state->fgpal.offs_internal++;
323330            break;
324331         case 1:
325            g = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
326            internal_pal_offs++;
332            state->fgpal.g = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
333            state->fgpal.offs_internal++;
327334            break;
328335         case 2:
329            b = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
330            palette_set_color(space->machine, 0x100+pal_offs, MAKE_RGB(r, g, b));
331            internal_pal_offs = 0;
332            pal_offs++;
336            state->fgpal.b = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
337            palette_set_color(space->machine, 0x100+state->fgpal.offs, MAKE_RGB(state->fgpal.r, state->fgpal.g, state->fgpal.b));
338            state->fgpal.offs_internal = 0;
339            state->fgpal.offs++;
333340            break;
334341      }
335342   }
r10886r10887
351358
352359//  AM_RANGE(0x0a0000, 0x0fffff) AM_RAM
353360//  AM_RANGE(0x100000, 0x1fffff) AM_RAM //colorama
354   AM_RANGE(0x210000, 0x21ffff) AM_RAM AM_BASE(&vram)
361   AM_RANGE(0x210000, 0x21ffff) AM_RAM AM_BASE_MEMBER(coinmvga_state, vram)
355362//  AM_RANGE(0x40746e, 0x40746f) AM_READ(test_r) AM_WRITENOP //touch screen related, colorama
356363//  AM_RANGE(0x403afa, 0x403afb) AM_READ(test_r) AM_WRITENOP //touch screen related, cmrltv75
357364   AM_RANGE(0x400000, 0x40ffff) AM_RAM
r10886r10887
653660*    Machine Drivers     *
654661*************************/
655662
656static MACHINE_CONFIG_START( coinmvga, driver_device )
663static MACHINE_CONFIG_START( coinmvga, coinmvga_state )
657664
658665   /* basic machine hardware */
659666   MCFG_CPU_ADD("maincpu", H83007, CPU_CLOCK)   /* xtal */
src/mame/drivers/5clown.c
r10886r10887
450450#include "sound/ay8910.h"
451451#include "sound/okim6295.h"
452452
453static UINT8 main_latch_d800;
454static UINT8 snd_latch_0800;
455static UINT8 snd_latch_0a02;
456static UINT8 ay8910_addr;
457static device_t *ay8910;
458453
454class _5clown_state : public driver_device
455{
456public:
457   _5clown_state(running_machine &machine, const driver_device_config_base &config)
458      : driver_device(machine, config) { }
459459
460   UINT8 main_latch_d800;
461   UINT8 snd_latch_0800;
462   UINT8 snd_latch_0a02;
463   UINT8 ay8910_addr;
464   device_t *ay8910;
465   UINT8 *videoram;
466   UINT8 *colorram;
467   tilemap_t *bg_tilemap;
468   int mux_data;
469};
470
471
472
473
460474/*************************
461475*     Video Hardware     *
462476*************************/
463477
464static UINT8 *videoram;
465static UINT8 *colorram;
466static tilemap_t *bg_tilemap;
467478
468479
469480static WRITE8_HANDLER( fclown_videoram_w )
470481{
471   videoram[offset] = data;
472   tilemap_mark_tile_dirty(bg_tilemap, offset);
482   _5clown_state *state = space->machine->driver_data<_5clown_state>();
483   state->videoram[offset] = data;
484   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
473485}
474486
475487static WRITE8_HANDLER( fclown_colorram_w )
476488{
477   colorram[offset] = data;
478   tilemap_mark_tile_dirty(bg_tilemap, offset);
489   _5clown_state *state = space->machine->driver_data<_5clown_state>();
490   state->colorram[offset] = data;
491   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
479492}
480493
481494
482495static TILE_GET_INFO( get_fclown_tile_info )
483496{
497   _5clown_state *state = machine->driver_data<_5clown_state>();
484498
485499/*  - bits -
486500    7654 3210
r10886r10887
491505    x--- ----   Extra color for 7's.
492506*/
493507
494   int attr = colorram[tile_index];
495   int code = ((attr & 0x01) << 8) | ((attr & 0x40) << 2) | videoram[tile_index];   /* bit 8 for extended char set */
508   int attr = state->colorram[tile_index];
509   int code = ((attr & 0x01) << 8) | ((attr & 0x40) << 2) | state->videoram[tile_index];   /* bit 8 for extended char set */
496510   int bank = (attr & 0x02) >> 1;                                       /* bit 1 switch the gfx banks */
497511   int color = (attr & 0x3c) >> 2 | ((attr & 0x80) >> 3);                     /* bits 2-3-4-5-7 for color */
498512
r10886r10887
502516
503517static VIDEO_START(fclown)
504518{
505   bg_tilemap = tilemap_create(machine, get_fclown_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
519   _5clown_state *state = machine->driver_data<_5clown_state>();
520   state->bg_tilemap = tilemap_create(machine, get_fclown_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
506521}
507522
508523
509524static SCREEN_UPDATE( fclown )
510525{
511   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
526   _5clown_state *state = screen->machine->driver_data<_5clown_state>();
527   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
512528   return 0;
513529}
514530
r10886r10887
557573*         R/W Handlers        *
558574******************************/
559575
560static int mux_data = 0;
561576
562577/* Inputs (buttons) are multiplexed.
563578   There are 4 sets of 5 bits each and are connected to PIA0, portA.
r10886r10887
565580*/
566581static READ8_DEVICE_HANDLER( mux_port_r )
567582{
568   switch( mux_data & 0xf0 )      /* bits 4-7 */
583   _5clown_state *state = device->machine->driver_data<_5clown_state>();
584   switch( state->mux_data & 0xf0 )      /* bits 4-7 */
569585   {
570586      case 0x10: return input_port_read(device->machine, "IN0-0");
571587      case 0x20: return input_port_read(device->machine, "IN0-1");
r10886r10887
579595
580596static WRITE8_DEVICE_HANDLER( mux_w )
581597{
582   mux_data = data ^ 0xff;   /* Inverted */
598   _5clown_state *state = device->machine->driver_data<_5clown_state>();
599   state->mux_data = data ^ 0xff;   /* Inverted */
583600}
584601
585602
r10886r10887
643660
644661static WRITE8_HANDLER( cpu_d800_w )
645662{
663   _5clown_state *state = space->machine->driver_data<_5clown_state>();
646664   logerror("Main: Write to $D800: %02x\n", data);
647   main_latch_d800 = data;
665   state->main_latch_d800 = data;
648666}
649667
650668
r10886r10887
665683
666684static READ8_HANDLER( snd_e06_r )
667685{
686   _5clown_state *state = space->machine->driver_data<_5clown_state>();
668687   logerror("Sound: Read from $0E06 \n");
669   return main_latch_d800;
688   return state->main_latch_d800;
670689}
671690
672691static WRITE8_HANDLER( snd_800_w )
673692{
674   snd_latch_0800 = data;
693   _5clown_state *state = space->machine->driver_data<_5clown_state>();
694   state->snd_latch_0800 = data;
675695
676   if (snd_latch_0a02 == 0xc0)
696   if (state->snd_latch_0a02 == 0xc0)
677697   {
678      ay8910_addr = snd_latch_0800;
698      state->ay8910_addr = state->snd_latch_0800;
679699   }
680700
681   if (snd_latch_0a02 == 0x00)
701   if (state->snd_latch_0a02 == 0x00)
682702   {
683      fclown_ay8910_w( ay8910, ay8910_addr, snd_latch_0800);
703      fclown_ay8910_w( state->ay8910, state->ay8910_addr, state->snd_latch_0800);
684704   }
685705}
686706
687707static WRITE8_HANDLER( snd_a02_w )
688708{
689   snd_latch_0a02 = data & 0xff;
690   logerror("Sound: Write to $0A02: %02x\n", snd_latch_0a02);
709   _5clown_state *state = space->machine->driver_data<_5clown_state>();
710   state->snd_latch_0a02 = data & 0xff;
711   logerror("Sound: Write to $0A02: %02x\n", state->snd_latch_0a02);
691712}
692713
693714
r10886r10887
701722   AM_RANGE(0x0801, 0x0801) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
702723   AM_RANGE(0x0844, 0x0847) AM_DEVREADWRITE("pia0", pia6821_r, pia6821_w)
703724   AM_RANGE(0x0848, 0x084b) AM_DEVREADWRITE("pia1", pia6821_r, pia6821_w)
704   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(fclown_videoram_w) AM_BASE(&videoram)   /* Init'ed at $2042 */
705   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(fclown_colorram_w) AM_BASE(&colorram)   /* Init'ed at $2054 */
725   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(fclown_videoram_w) AM_BASE_MEMBER(_5clown_state, videoram)   /* Init'ed at $2042 */
726   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(fclown_colorram_w) AM_BASE_MEMBER(_5clown_state, colorram)   /* Init'ed at $2054 */
706727   AM_RANGE(0x2000, 0x7fff) AM_ROM               /* ROM space */
707728
708729   AM_RANGE(0xc048, 0xc048) AM_WRITE(cpu_c048_w )
r10886r10887
10281049*    Machine Drivers     *
10291050*************************/
10301051
1031static MACHINE_CONFIG_START( fclown, driver_device )
1052static MACHINE_CONFIG_START( fclown, _5clown_state )
10321053
10331054   /* basic machine hardware */
10341055   MCFG_CPU_ADD("maincpu", M6502, MASTER_CLOCK/8)   /* guess, seems ok */
r10886r10887
11771198
11781199static DRIVER_INIT( fclown )
11791200{
1201   _5clown_state *state = machine->driver_data<_5clown_state>();
11801202    /* Decrypting main program */
11811203
11821204   int x;
r10886r10887
12291251
12301252   /* Assigning AY-3-8910 sound device */
12311253
1232   ay8910 = machine->device("ay8910");
1254   state->ay8910 = machine->device("ay8910");
12331255}
12341256
12351257
src/mame/drivers/tgtpanic.c
r10886r10887
1212#include "emu.h"
1313#include "cpu/z80/z80.h"
1414
15static UINT8 *ram;
16static UINT8 color;
1715
16class tgtpanic_state : public driver_device
17{
18public:
19   tgtpanic_state(running_machine &machine, const driver_device_config_base &config)
20      : driver_device(machine, config) { }
1821
22   UINT8 *ram;
23   UINT8 color;
24};
25
26
1927/*************************************
2028 *
2129 *  Video hardware
r10886r10887
2432
2533static SCREEN_UPDATE( tgtpanic )
2634{
35   tgtpanic_state *state = screen->machine->driver_data<tgtpanic_state>();
2736   UINT32 colors[4];
2837   UINT32 offs;
2938   UINT32 x, y;
3039
3140   colors[0] = 0;
3241   colors[1] = 0xffffffff;
33   colors[2] = MAKE_RGB(pal1bit(color >> 2), pal1bit(color >> 1), pal1bit(color >> 0));
34   colors[3] = MAKE_RGB(pal1bit(color >> 6), pal1bit(color >> 5), pal1bit(color >> 4));
42   colors[2] = MAKE_RGB(pal1bit(state->color >> 2), pal1bit(state->color >> 1), pal1bit(state->color >> 0));
43   colors[3] = MAKE_RGB(pal1bit(state->color >> 6), pal1bit(state->color >> 5), pal1bit(state->color >> 4));
3544
3645   for (offs = 0; offs < 0x2000; ++offs)
3746   {
38      UINT8 val = ram[offs];
47      UINT8 val = state->ram[offs];
3948
4049      y = (offs & 0x7f) << 1;
4150      x = (offs >> 7) << 2;
r10886r10887
5968
6069static WRITE8_HANDLER( color_w )
6170{
71   tgtpanic_state *state = space->machine->driver_data<tgtpanic_state>();
6272   space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos());
63   color = data;
73   state->color = data;
6474}
6575
6676
r10886r10887
7282
7383static ADDRESS_MAP_START( prg_map, ADDRESS_SPACE_PROGRAM, 8 )
7484   AM_RANGE(0x0000, 0x7fff) AM_ROM
75   AM_RANGE(0x8000, 0xbfff) AM_RAM AM_BASE(&ram)
85   AM_RANGE(0x8000, 0xbfff) AM_RAM AM_BASE_MEMBER(tgtpanic_state, ram)
7686ADDRESS_MAP_END
7787
7888static ADDRESS_MAP_START( io_map, ADDRESS_SPACE_IO, 8 )
r10886r10887
117127 *
118128 *************************************/
119129
120static MACHINE_CONFIG_START( tgtpanic, driver_device )
130static MACHINE_CONFIG_START( tgtpanic, tgtpanic_state )
121131
122132   /* basic machine hardware */
123133   MCFG_CPU_ADD("maincpu", Z80, XTAL_4MHz)
src/mame/drivers/contra.c
r10886r10887
1717***************************************************************************/
1818
1919#include "emu.h"
20#include "cpu/hd6309/hd6309.h"
2021#include "cpu/m6809/m6809.h"
2122#include "sound/2151intf.h"
2223#include "video/konicdev.h"
r10886r10887
2425#include "includes/contra.h"
2526
2627
28static INTERRUPT_GEN( contra_interrupt )
29{
30   contra_state *state = device->machine->driver_data<contra_state>();
31   if (k007121_ctrlram_r(state->k007121_1, 7) & 0x02)
32      cpu_set_input_line(device, HD6309_IRQ_LINE, HOLD_LINE);
33}
34
2735static WRITE8_HANDLER( contra_bankswitch_w )
2836{
29   if ((data & 0x0f) < 12)   /* for safety */
30      memory_set_bank(space->machine, "bank1", data & 0x0f);
37   memory_set_bank(space->machine, "bank1", data & 0x0f);
3138}
3239
3340static WRITE8_HANDLER( contra_sh_irqtrigger_w )
r10886r10887
174181   contra_state *state = machine->driver_data<contra_state>();
175182   UINT8 *ROM = machine->region("maincpu")->base();
176183
177   memory_configure_bank(machine, "bank1", 0, 12, &ROM[0x10000], 0x2000);
184   memory_configure_bank(machine, "bank1", 0, 16, &ROM[0x10000], 0x2000);
178185
179186   state->audiocpu = machine->device("audiocpu");
180187   state->k007121_1 = machine->device("k007121_1");
r10886r10887
184191static MACHINE_CONFIG_START( contra, contra_state )
185192
186193   /* basic machine hardware */
187   MCFG_CPU_ADD("maincpu", M6809, XTAL_24MHz/16) /* 1500000? */
194   MCFG_CPU_ADD("maincpu", HD6309, XTAL_24MHz / 2 /* 3000000*4? */)
188195   MCFG_CPU_PROGRAM_MAP(contra_map)
189   MCFG_CPU_VBLANK_INT("screen", irq0_line_hold)
196   MCFG_CPU_VBLANK_INT("screen", contra_interrupt)
190197
191   MCFG_CPU_ADD("audiocpu", M6809, XTAL_24MHz/12) /* 2000000? */
198   MCFG_CPU_ADD("audiocpu", M6809, XTAL_24MHz/8) /* 3000000? */
192199   MCFG_CPU_PROGRAM_MAP(sound_map)
193200
194   MCFG_QUANTUM_TIME(attotime::from_hz(600))   /* 10 CPU slices per frame - enough for the sound CPU to read all commands */
201   MCFG_QUANTUM_TIME(attotime::from_hz(6000))   /* enough for the sound CPU to read all commands */
195202
196203   MCFG_MACHINE_START(contra)
197204
r10886r10887
223230
224231
225232ROM_START( contra )
226   ROM_REGION( 0x28000, "maincpu", 0 )   /* 64k for code + 96k for banked ROMs */
233   ROM_REGION( 0x30000, "maincpu", ROMREGION_ERASEFF )   /* 64k for code + 96k for banked ROMs */
227234   ROM_LOAD( "633m03.18a",   0x20000, 0x08000, CRC(d045e1da) SHA1(ec781e98a6efb14861223250c6239b06ec98ed0b) )
228235   ROM_CONTINUE(             0x08000, 0x08000 )
229236   ROM_LOAD( "633i02.17a",   0x10000, 0x10000, CRC(b2f7bd9a) SHA1(6c29568419bc49f0be3995b0c34edd9038f6f8d9) )
r10886r10887
250257ROM_END
251258
252259ROM_START( contra1 )
253   ROM_REGION( 0x28000, "maincpu", 0 )   /* 64k for code + 96k for banked ROMs */
260   ROM_REGION( 0x30000, "maincpu", ROMREGION_ERASEFF )   /* 64k for code + 96k for banked ROMs */
254261   ROM_LOAD( "633e03.18a",   0x20000, 0x08000, CRC(7fc0d8cf) SHA1(cf1cf15646a4e5dc72671e957bc51ca44d30995c) )
255262   ROM_CONTINUE(             0x08000, 0x08000 )
256263   ROM_LOAD( "633i02.17a",   0x10000, 0x10000, CRC(b2f7bd9a) SHA1(6c29568419bc49f0be3995b0c34edd9038f6f8d9) )
r10886r10887
277284ROM_END
278285
279286ROM_START( contrab )
280   ROM_REGION( 0x28000, "maincpu", 0 )   /* 64k for code + 96k for banked ROMs */
287   ROM_REGION( 0x30000, "maincpu", ROMREGION_ERASEFF )   /* 64k for code + 96k for banked ROMs */
281288   ROM_LOAD( "633m03.18a",   0x20000, 0x08000, CRC(d045e1da) SHA1(ec781e98a6efb14861223250c6239b06ec98ed0b) )
282289   ROM_CONTINUE(             0x08000, 0x08000 )
283290   ROM_LOAD( "633i02.17a",   0x10000, 0x10000, CRC(b2f7bd9a) SHA1(6c29568419bc49f0be3995b0c34edd9038f6f8d9) )
r10886r10887
316323ROM_END
317324
318325ROM_START( contraj )
319   ROM_REGION( 0x28000, "maincpu", 0 )   /* 64k for code + 96k for banked ROMs */
326   ROM_REGION( 0x30000, "maincpu", ROMREGION_ERASEFF )   /* 64k for code + 96k for banked ROMs */
320327   ROM_LOAD( "633n03.18a",   0x20000, 0x08000, CRC(fedab568) SHA1(7fd4546335bdeef7f8326d4cbde7fa36d74e5cfc) )
321328   ROM_CONTINUE(             0x08000, 0x08000 )
322329   ROM_LOAD( "633k02.17a",   0x10000, 0x10000, CRC(5d5f7438) SHA1(489fe56ca57ef4f6a7792fba07a9656009f3f285) )
r10886r10887
343350ROM_END
344351
345352ROM_START( contrajb )
346   ROM_REGION( 0x28000, "maincpu", 0 )   /* 64k for code + 96k for banked ROMs */
353   ROM_REGION( 0x30000, "maincpu", ROMREGION_ERASEFF )   /* 64k for code + 96k for banked ROMs */
347354   ROM_LOAD( "g-2.18a",      0x20000, 0x08000, CRC(bdb9196d) SHA1(fad170e8fda94c9c9d7b82433daa30b80af12efc) )
348355   ROM_CONTINUE(             0x08000, 0x08000 )
349356   ROM_LOAD( "633k02.17a",   0x10000, 0x10000, CRC(5d5f7438) SHA1(489fe56ca57ef4f6a7792fba07a9656009f3f285) )
r10886r10887
382389ROM_END
383390
384391ROM_START( gryzor )
385   ROM_REGION( 0x28000, "maincpu", 0 )   /* 64k for code + 96k for banked ROMs */
392   ROM_REGION( 0x30000, "maincpu", ROMREGION_ERASEFF )   /* 64k for code + 96k for banked ROMs */
386393   ROM_LOAD( "g2.18a",       0x20000, 0x08000, CRC(92ca77bd) SHA1(3a56f51a617edff9f2a60df0141dff040881b82a) )
387394   ROM_CONTINUE(             0x08000, 0x08000 )
388395   ROM_LOAD( "g3.17a",       0x10000, 0x10000, CRC(bbd9e95e) SHA1(fd5de1bcc485de7b8fc2e321351c2e3ddd25d053) )
r10886r10887
409416ROM_END
410417
411418ROM_START( gryzora )
412   ROM_REGION( 0x28000, "maincpu", 0 )   /* 64k for code + 96k for banked ROMs */
419   ROM_REGION( 0x30000, "maincpu", ROMREGION_ERASEFF )   /* 64k for code + 96k for banked ROMs */
413420   ROM_LOAD( "633j03.18a",   0x20000, 0x08000, CRC(20919162) SHA1(2f375166428ee03f6e8ac0372a373bb8ab35e64c) )
414421   ROM_CONTINUE(             0x08000, 0x08000 )
415422   ROM_LOAD( "633j02.17a",   0x10000, 0x10000, CRC(b5922f9a) SHA1(441a23dc99a908ec2c09c855e73070dbab8c5ae2) )
src/mame/drivers/itgambl2.c
r10886r10887
5757#include "sound/upd7759.h"
5858
5959
60static int test_x, test_y, start_offs;
60class itgambl2_state : public driver_device
61{
62public:
63   itgambl2_state(running_machine &machine, const driver_device_config_base &config)
64      : driver_device(machine, config) { }
6165
66   int test_x;
67   int test_y;
68   int start_offs;
69};
70
71
6272/*************************
6373*     Video Hardware     *
6474*************************/
6575
6676static VIDEO_START( itgambl2 )
6777{
68   test_x = 256;
69   test_y = 256;
70   start_offs = 0;
78   itgambl2_state *state = machine->driver_data<itgambl2_state>();
79   state->test_x = 256;
80   state->test_y = 256;
81   state->start_offs = 0;
7182}
7283
7384/* (dirty) debug code for looking 8bpps blitter-based gfxs */
7485static SCREEN_UPDATE( itgambl2 )
7586{
87   itgambl2_state *state = screen->machine->driver_data<itgambl2_state>();
7688   int x,y,count;
7789   const UINT8 *blit_ram = screen->machine->region("gfx1")->base();
7890
7991   if(input_code_pressed(screen->machine, KEYCODE_Z))
80      test_x++;
92      state->test_x++;
8193
8294   if(input_code_pressed(screen->machine, KEYCODE_X))
83      test_x--;
95      state->test_x--;
8496
8597   if(input_code_pressed(screen->machine, KEYCODE_A))
86      test_y++;
98      state->test_y++;
8799
88100   if(input_code_pressed(screen->machine, KEYCODE_S))
89      test_y--;
101      state->test_y--;
90102
91103   if(input_code_pressed(screen->machine, KEYCODE_Q))
92      start_offs+=0x200;
104      state->start_offs+=0x200;
93105
94106   if(input_code_pressed(screen->machine, KEYCODE_W))
95      start_offs-=0x200;
107      state->start_offs-=0x200;
96108
97109   if(input_code_pressed(screen->machine, KEYCODE_E))
98      start_offs++;
110      state->start_offs++;
99111
100112   if(input_code_pressed(screen->machine, KEYCODE_R))
101      start_offs--;
113      state->start_offs--;
102114
103   popmessage("%d %d %04x",test_x,test_y,start_offs);
115   popmessage("%d %d %04x",state->test_x,state->test_y,state->start_offs);
104116
105117   bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
106118
107   count = (start_offs);
119   count = (state->start_offs);
108120
109   for(y=0;y<test_y;y++)
121   for(y=0;y<state->test_y;y++)
110122   {
111      for(x=0;x<test_x;x++)
123      for(x=0;x<state->test_x;x++)
112124      {
113125         UINT32 color;
114126
r10886r10887
247259*     Machine Drivers     *
248260**************************/
249261
250static MACHINE_CONFIG_START( itgambl2, driver_device )
262static MACHINE_CONFIG_START( itgambl2, itgambl2_state )
251263
252264    /* basic machine hardware */
253265   MCFG_CPU_ADD("maincpu", H83044, MAIN_CLOCK)   /* wrong CPU, but we have not a H8/3337 core ATM */
src/mame/drivers/drw80pkr.c
r10886r10887
3030#include "sound/ay8910.h"
3131#include "cpu/mcs48/mcs48.h"
3232
33
34class drw80pkr_state : public driver_device
35{
36public:
37   drw80pkr_state(running_machine &machine, const driver_device_config_base &config)
38      : driver_device(machine, config) { }
39
40   tilemap_t *bg_tilemap;
41   UINT8 t0;
42   UINT8 t1;
43   UINT8 p0;
44   UINT8 p1;
45   UINT8 p2;
46   UINT8 prog;
47   UINT8 bus;
48   UINT8 attract_mode;
49   UINT8 active_bank;
50   UINT8 pkr_io_ram[0x100];
51   UINT16 video_ram[0x0400];
52   UINT8 color_ram[0x0400];
53};
54
55
3356#define CPU_CLOCK         XTAL_8MHz
3457#define DATA_NVRAM_SIZE     0x100
3558
36static tilemap_t *bg_tilemap;
3759
38static UINT8 t0, t1, p0, p1, p2, prog, bus;
39static UINT8 attract_mode = 0;
40static UINT8 active_bank = 0;
41
42static UINT8 pkr_io_ram[0x100];
43static UINT16 video_ram[0x0400];
44static UINT8 color_ram[0x0400];
45
4660static MACHINE_START( drw80pkr )
4761{
48   machine->device<nvram_device>("nvram")->set_base(pkr_io_ram, sizeof(pkr_io_ram));
62   drw80pkr_state *state = machine->driver_data<drw80pkr_state>();
63   machine->device<nvram_device>("nvram")->set_base(state->pkr_io_ram, sizeof(state->pkr_io_ram));
4964}
5065
5166/*****************
r10886r10887
5469
5570static WRITE8_HANDLER( t0_w )
5671{
57   t0 = data;
72   drw80pkr_state *state = space->machine->driver_data<drw80pkr_state>();
73   state->t0 = data;
5874}
5975
6076static WRITE8_HANDLER( t1_w )
6177{
62   t1 = data;
78   drw80pkr_state *state = space->machine->driver_data<drw80pkr_state>();
79   state->t1 = data;
6380}
6481
6582static WRITE8_HANDLER( p0_w )
6683{
67   p0 = data;
84   drw80pkr_state *state = space->machine->driver_data<drw80pkr_state>();
85   state->p0 = data;
6886}
6987
7088static WRITE8_HANDLER( p1_w )
7189{
72   p1 = data;
90   drw80pkr_state *state = space->machine->driver_data<drw80pkr_state>();
91   state->p1 = data;
7392}
7493
7594static WRITE8_HANDLER( p2_w )
7695{
77   p2 = data;
96   drw80pkr_state *state = space->machine->driver_data<drw80pkr_state>();
97   state->p2 = data;
7898}
7999
80100static WRITE8_HANDLER( prog_w )
81101{
82   prog = data;
102   drw80pkr_state *state = space->machine->driver_data<drw80pkr_state>();
103   state->prog = data;
83104
84105   // Bankswitch Program Memory
85   if (prog == 0x01)
106   if (state->prog == 0x01)
86107   {
87      active_bank = active_bank ^ 0x01;
108      state->active_bank = state->active_bank ^ 0x01;
88109
89      memory_set_bank(space->machine, "bank1", active_bank);
110      memory_set_bank(space->machine, "bank1", state->active_bank);
90111   }
91112}
92113
93114static WRITE8_HANDLER( bus_w )
94115{
95   bus = data;
116   drw80pkr_state *state = space->machine->driver_data<drw80pkr_state>();
117   state->bus = data;
96118}
97119
98120static WRITE8_HANDLER( drw80pkr_io_w )
99121{
122   drw80pkr_state *state = space->machine->driver_data<drw80pkr_state>();
100123   UINT16 n_offs;
101124
102   if (p2 == 0x3f || p2 == 0x7f)
125   if (state->p2 == 0x3f || state->p2 == 0x7f)
103126   {
104      n_offs = ((p1 & 0xc0) << 2 ) + offset;
127      n_offs = ((state->p1 & 0xc0) << 2 ) + offset;
105128
106      if (p2 == 0x3f)
129      if (state->p2 == 0x3f)
107130      {
108         video_ram[n_offs] = data; // low address
131         state->video_ram[n_offs] = data; // low address
109132      } else {
110         color_ram[n_offs] = data & 0x0f; // color palette
111         video_ram[n_offs] += ((data & 0xf0) << 4 ); // high address
133         state->color_ram[n_offs] = data & 0x0f; // color palette
134         state->video_ram[n_offs] += ((data & 0xf0) << 4 ); // high address
112135      }
113136
114      tilemap_mark_tile_dirty(bg_tilemap, n_offs);
137      tilemap_mark_tile_dirty(state->bg_tilemap, n_offs);
115138   }
116139
117   if (p2 == 0xc7)
140   if (state->p2 == 0xc7)
118141   {
119142      // CRTC Register
120143      // R0 = 0x1f(31)    Horizontal Total
r10886r10887
138161      // R13 = 0x00       Display Start Address (Low)
139162   }
140163
141   if (p2 == 0xd7)
164   if (state->p2 == 0xd7)
142165   {
143166      // CRTC Address
144167   }
145168
146   if (p2 == 0xfb) {
147      pkr_io_ram[offset] = data;
169   if (state->p2 == 0xfb) {
170      state->pkr_io_ram[offset] = data;
148171   }
149172
150   if (p2 == 0xff)
173   if (state->p2 == 0xff)
151174   {
152      if (p1 == 0xdf)
175      if (state->p1 == 0xdf)
153176      {
154         attract_mode = data; // Latch this for use in input reads (0x01 = attract mode, 0x00 = game in progress)
177         state->attract_mode = data; // Latch this for use in input reads (0x01 = attract mode, 0x00 = game in progress)
155178      }
156179
157      if (p1 == 0xdb || p1 == 0xef || p1 == 0xf7 || p1 == 0xfb)
180      if (state->p1 == 0xdb || state->p1 == 0xef || state->p1 == 0xf7 || state->p1 == 0xfb)
158181      {
159182         // unknown, most likely lamps, meters, hopper etc.
160183      }
161184
162185      // ay8910 control port
163      if (p1 == 0xfc)
186      if (state->p1 == 0xfc)
164187         ay8910_address_w(space->machine->device("aysnd"), 0, data);
165188
166189      // ay8910_write_port_0_w
167      if (p1 == 0xfe)
190      if (state->p1 == 0xfe)
168191         ay8910_data_w(space->machine->device("aysnd"), 0, data);
169192   }
170193}
r10886r10887
175198
176199static READ8_HANDLER( t0_r )
177200{
178    return t0;
201   drw80pkr_state *state = space->machine->driver_data<drw80pkr_state>();
202    return state->t0;
179203}
180204
181205static READ8_HANDLER( t1_r )
182206{
183    return t1;
207   drw80pkr_state *state = space->machine->driver_data<drw80pkr_state>();
208    return state->t1;
184209}
185210
186211static READ8_HANDLER( p0_r )
187212{
188    return p0;
213   drw80pkr_state *state = space->machine->driver_data<drw80pkr_state>();
214    return state->p0;
189215}
190216
191217static READ8_HANDLER( p1_r )
192218{
193    return p1;
219   drw80pkr_state *state = space->machine->driver_data<drw80pkr_state>();
220    return state->p1;
194221}
195222
196223static READ8_HANDLER( p2_r )
197224{
198    return p2;
225   drw80pkr_state *state = space->machine->driver_data<drw80pkr_state>();
226    return state->p2;
199227}
200228
201229static READ8_HANDLER( bus_r )
202230{
203    return bus;
231   drw80pkr_state *state = space->machine->driver_data<drw80pkr_state>();
232    return state->bus;
204233}
205234
206235static READ8_HANDLER( drw80pkr_io_r )
207236{
237   drw80pkr_state *state = space->machine->driver_data<drw80pkr_state>();
208238   UINT8 ret;
209239   UINT16 kbdin;
210240
211241   ret = 0x00;
212242
213   if (p2 == 0x3b)
243   if (state->p2 == 0x3b)
214244   {
215245      // unknown
216246   }
217247
218   if (p2 == 0x7b)
248   if (state->p2 == 0x7b)
219249   {
220      ret = pkr_io_ram[offset];
250      ret = state->pkr_io_ram[offset];
221251   }
222252
223   if (p2 == 0xf7)
253   if (state->p2 == 0xf7)
224254   {
225255      // unknown
226256   }
227257
228   if (p2 == 0xfb)
258   if (state->p2 == 0xfb)
229259   {
230      ret = pkr_io_ram[offset];
260      ret = state->pkr_io_ram[offset];
231261   }
232262
233   if (p2 == 0xff)
263   if (state->p2 == 0xff)
234264   {
235      if (p1 == 0x5f || p1 == 0x9f || p1 == 0xdb)
265      if (state->p1 == 0x5f || state->p1 == 0x9f || state->p1 == 0xdb)
236266      {
237267         // unknown
238268      }
239269
240      if (p1 == 0xfe)
270      if (state->p1 == 0xfe)
241271      {
242272         // Dip switches tied to sound chip
243273         //
r10886r10887
250280         ret = 0x77; // double-up with credit payout
251281      }
252282
253      if ((attract_mode == 0x01 && p1 == 0xef) || p1 == 0xf7)
283      if ((state->attract_mode == 0x01 && state->p1 == 0xef) || state->p1 == 0xf7)
254284      {
255285
256286         // TODO: Get Input Port Values
r10886r10887
294324
295325static TILE_GET_INFO( get_bg_tile_info )
296326{
297   int color = color_ram[tile_index];
298   int code = video_ram[tile_index];
327   drw80pkr_state *state = machine->driver_data<drw80pkr_state>();
328   int color = state->color_ram[tile_index];
329   int code = state->video_ram[tile_index];
299330
300331   SET_TILE_INFO(0, code, color, 0);
301332}
302333
303334static VIDEO_START( drw80pkr )
304335{
305   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 24, 27);
336   drw80pkr_state *state = machine->driver_data<drw80pkr_state>();
337   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 24, 27);
306338}
307339
308340static SCREEN_UPDATE( drw80pkr )
309341{
310   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
342   drw80pkr_state *state = screen->machine->driver_data<drw80pkr_state>();
343   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
311344
312345   return 0;
313346}
r10886r10887
426459*     Machine Driver     *
427460*************************/
428461
429static MACHINE_CONFIG_START( drw80pkr, driver_device )
462static MACHINE_CONFIG_START( drw80pkr, drw80pkr_state )
430463   // basic machine hardware
431464   MCFG_CPU_ADD("maincpu", I8039, CPU_CLOCK)
432465   MCFG_CPU_PROGRAM_MAP(drw80pkr_map)
src/mame/drivers/zaxxon.c
r10886r10887
724724   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SERVICE1 ) PORT_CHANGED(zaxxon_coin_inserted, (void *)2)
725725
726726   PORT_START("SERVICESW")
727   PORT_SERVICE_NO_TOGGLE( 0x01, IP_ACTIVE_HIGH )
727   PORT_SERVICE_NO_TOGGLE( 0x01, IP_ACTIVE_HIGH ) PORT_CHANGED(service_switch, 0)
728728
729729   PORT_START("DSW02")
730730   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Bonus_Life ) )
src/mame/drivers/shangkid.c
r10886r10887
5656
5757/***************************************************************************************/
5858
59static UINT8 bbx_sound_enable;
60static UINT8 sound_latch;
61
62/***************************************************************************************/
63
6459static WRITE8_HANDLER( shangkid_maincpu_bank_w )
6560{
6661   memory_set_bank(space->machine, "bank1", data & 1);
r10886r10887
8580
8681static WRITE8_HANDLER( shangkid_sound_enable_w )
8782{
88   bbx_sound_enable = data;
83   shangkid_state *state = space->machine->driver_data<shangkid_state>();
84   state->bbx_sound_enable = data;
8985}
9086
9187static WRITE8_DEVICE_HANDLER( chinhero_ay8910_porta_w )
9288{
93   if( bbx_sound_enable )
89   shangkid_state *state = device->machine->driver_data<shangkid_state>();
90   if( state->bbx_sound_enable )
9491   {
9592      if( data == 0x01 )
9693         /* 0->1 transition triggers interrupt on Sound CPU */
r10886r10887
10097
10198static WRITE8_DEVICE_HANDLER( shangkid_ay8910_porta_w )
10299{
103   if( bbx_sound_enable )
100   shangkid_state *state = device->machine->driver_data<shangkid_state>();
101   if( state->bbx_sound_enable )
104102   {
105103      if( data == 0x01 )
106104         /* 0->1 transition triggers interrupt on Sound CPU */
r10886r10887
112110
113111static WRITE8_DEVICE_HANDLER( ay8910_portb_w )
114112{
115   sound_latch = data;
113   shangkid_state *state = device->machine->driver_data<shangkid_state>();
114   state->sound_latch = data;
116115}
117116
118117/***************************************************************************************/
119118
120119static READ8_HANDLER( shangkid_soundlatch_r )
121120{
122   return sound_latch;
121   shangkid_state *state = space->machine->driver_data<shangkid_state>();
122   return state->sound_latch;
123123}
124124
125125/***************************************************************************************/
126126
127127static DRIVER_INIT( chinhero )
128128{
129   shangkid_gfx_type = 0;
129   shangkid_state *state = machine->driver_data<shangkid_state>();
130   state->gfx_type = 0;
130131}
131132
132133static DRIVER_INIT( shangkid )
133134{
134   shangkid_gfx_type = 1;
135   shangkid_state *state = machine->driver_data<shangkid_state>();
136   state->gfx_type = 1;
135137
136138   /* set up banking */
137139   memory_configure_bank(machine, "bank1", 0, 2, machine->region("maincpu")->base() + 0x8000, 0x8000);
r10886r10887
246248   AM_RANGE(0xb801, 0xb801) AM_READ_PORT("SYSTEM")
247249   AM_RANGE(0xb802, 0xb802) AM_READ_PORT("P2")
248250   AM_RANGE(0xb803, 0xb803) AM_READ_PORT("P1")
249   AM_RANGE(0xc000, 0xc002) AM_WRITEONLY AM_BASE(&shangkid_videoreg)
251   AM_RANGE(0xc000, 0xc002) AM_WRITEONLY AM_BASE_MEMBER(shangkid_state, videoreg)
250252   AM_RANGE(0xd000, 0xdfff) AM_RAM_WRITE(shangkid_videoram_w) AM_BASE_MEMBER(shangkid_state, videoram) AM_SHARE("share1")
251253   AM_RANGE(0xe000, 0xfdff) AM_RAM AM_SHARE("share2")
252254   AM_RANGE(0xfe00, 0xffff) AM_RAM AM_BASE_MEMBER(shangkid_state, spriteram) AM_SHARE("share3")
r10886r10887
267269   AM_RANGE(0xb801, 0xb801) AM_READ_PORT("SYSTEM")
268270   AM_RANGE(0xb802, 0xb802) AM_READ_PORT("P2")
269271   AM_RANGE(0xb803, 0xb803) AM_READ_PORT("P1")
270   AM_RANGE(0xc000, 0xc002) AM_WRITEONLY AM_BASE(&shangkid_videoreg)
272   AM_RANGE(0xc000, 0xc002) AM_WRITEONLY AM_BASE_MEMBER(shangkid_state, videoreg)
271273   AM_RANGE(0xd000, 0xdfff) AM_RAM_WRITE(shangkid_videoram_w) AM_BASE_MEMBER(shangkid_state, videoram) AM_SHARE("share1")
272274   AM_RANGE(0xe000, 0xfdff) AM_RAM AM_SHARE("share2")
273275   AM_RANGE(0xfe00, 0xffff) AM_RAM AM_BASE_MEMBER(shangkid_state, spriteram) AM_SHARE("share3")
src/mame/drivers/atvtrack.c
r10886r10887
22  ATV Track
33  (c)2002 Gaelco
44 
5  2x SH4 (HD64177506), bus clock of 33 MHz
6  There is a chip hidden under a heatsink with RAM connected, probably GFX
5ATV Track
6Gaelco 2002
7 
8PCB Layout
9 
10GAELCO
11REF. 020419
12 |--------------------------------------------------------------|
13 |                                                              |
14 |   SW3                                               EPC1PC8  |
15 |                                         K4S643232            |
16 |    LC245A                                         7LB176    |-|
17 |                        FLASH.IC14  FLASH.IC19     7LB176    | |
18 |       |-----|                                     7LB176    | |DB9
19 |       | SH4 |                                     7LB176    |-|
20 |       |     |          FLASH.IC15  FLASH.IC20                |
21 |       |-----|                                                |
22 |                                                |----------|  |
23|-|                            K4S643232          |ALTERA    |  |
24| |  L4955                                        |FLEX      |  |
25| |      |-----|               K4S643232          |EPF10K50  |  |
26| |CN1   | SH4 |                                  |EQC240-3  |  |
27| |      |     |                                  |----------|  |
28| |      |-----|                                                |
29|-|                                                             |
30 |                                                              |
31 |      33MHz                       K4S643232     |----------|  |
32 |                                  K4S643232     | GFX      |  |
33 |             LED                                |          | |-|
34 |             LED                                |          | | |
35 |                                  K4S643232     |          | | |DB9
36 |                                  K4S643232     |----------| |-|
37 | TL074C   TL074C                                     385-1    |
38 |     TDA1387   TDA1387                          14.31818MHz   |
39 |                                                              |
40 |--------------------------------------------------------------|   
41Notes:
42      SH4       - Hitachi HD6417750S SH4 CPU (BGA)
43      K4S643232 - Samsung K4S643232E-TC70 64M x 32-bit SDRAM (TSSOP86)
44      GFX       - Unknown BGA graphics chip (heatsinked)
45      FLASH.IC* - Samsung K9F2808U0B 128MBit (16M + 512k Spare x 8-bit) FlashROM (TSOP48)
46      EPF10K50  - Altera Flex EPF10K50EQC240-3 FPGA (QFP240)
47      EPC1PC8   - Altera EPC1PC8 FPGA Configuration Device (DIP8)
48      TL074C    - Texas Instruments TL074C Low Noise Quad JFet Operational Amplifier (SOIC14)
49      TDA1387   - Philips TDA1387 Stereo Continuous Calibration DAC (SOIC8)
50      L4955     - ST Microelectronics L4955 low-power, quad channel, 8-bit buffered voltage output DAC and amplifier
51      7LB176    - Texas Instruments 7LB176 Differential Bus Tranceiver (SOIC8)
52      385-1     - National LM385 Adjustable Micropower Voltage Reference Diode (SOIC8)
53      CN1       - Multi-pin connector for filter board (input power & controls connectors etc)
54      DB9       - Video output connector (for twin monitors)
55      SW3       - Push button switch
56     
757*/
858 
959#include "emu.h"
r10886r10887
67117   ROM_LOAD32_BYTE("20.bin", 0x0000001, 0x1080000, CRC(649dc331) SHA1(0cac2d0c15dd564c7fdebdf4365422958f453d63) )
68118   ROM_LOAD32_BYTE("14.bin", 0x0000002, 0x1080000, CRC(67983453) SHA1(05389a0ffc1a1bae9bac16a53a97d78b6eccc626) )
69119   ROM_LOAD32_BYTE("19.bin", 0x0000003, 0x1080000, CRC(9fc5c579) SHA1(8829329ef229564952aea2108ef1750dc226cbac) )
120 
121   ROM_REGION( 0x20000, "eeprom", ROMREGION_ERASEFF)
122   ROM_LOAD("epc1pc8.ic23", 0x0000000, 0x1ff01, CRC(752444c7) SHA1(c77e8fcfcbe15b53eda25553763bdac45f0ef7df) ) // contains a large amount of data, maybe used for some form of protection
70123ROM_END
71124 
72GAME( 2002, atvtrack, 0,   atvtrack,    atvtrack,    0, ROT0, "Gaelco", "ATV Track", GAME_NOT_WORKING | GAME_NO_SOUND )
125ROM_START( atvtracka )
126   ROM_REGION( 0x4200000, "maincpu", ROMREGION_ERASEFF) // NAND roms, contain additional data hence the sizes
127   ROM_LOAD32_BYTE("k9f2808u0b.ic15", 0x0000000, 0x1080000, CRC(10730001) SHA1(48c685a6ff7135abd074dc7fb7d10834c44da58f) )
128   ROM_LOAD32_BYTE("k9f2808u0b.ic20", 0x0000001, 0x1080000, CRC(b0c34433) SHA1(852c79bb3d7082cd2c056140071ae7d71679ec1d) )
129   ROM_LOAD32_BYTE("k9f2808u0b.ic14", 0x0000002, 0x1080000, CRC(02a12085) SHA1(acb112c9c7b29d92610465fb92268ce787ca06f4) )
130   ROM_LOAD32_BYTE("k9f2808u0b.ic19", 0x0000003, 0x1080000, CRC(856c1e6a) SHA1(a6b2839120d61811c36cc6b4095de9cefceb394b) )
131ROM_END
132 
133GAME( 2002, atvtrack,  0,          atvtrack,    atvtrack,    0, ROT0, "Gaelco", "ATV Track (set 1)", GAME_NOT_WORKING | GAME_NO_SOUND )
134GAME( 2002, atvtracka, atvtrack,   atvtrack,    atvtrack,    0, ROT0, "Gaelco", "ATV Track (set 2)", GAME_NOT_WORKING | GAME_NO_SOUND )
src/mame/drivers/cybertnk.c
r10886r10887
165165#include "sound/8950intf.h"
166166#include "rendlay.h"
167167
168static tilemap_t *tx_tilemap;
169static UINT16 *tx_vram,*bg_vram,*fg_vram,*spr_ram;
170static UINT16 *io_ram;
171static UINT16 *cybertnk_roadram;
172168
169class cybertnk_state : public driver_device
170{
171public:
172   cybertnk_state(running_machine &machine, const driver_device_config_base &config)
173      : driver_device(machine, config) { }
174
175   tilemap_t *tx_tilemap;
176   UINT16 *tx_vram;
177   UINT16 *bg_vram;
178   UINT16 *fg_vram;
179   UINT16 *spr_ram;
180   UINT16 *io_ram;
181   UINT16 *roadram;
182   int test_x;
183   int test_y;
184   int start_offs;
185   int color_pen;
186};
187
188
173189#define LOG_UNKNOWN_WRITE logerror("unknown io write CPU '%s':%08x  0x%08x 0x%04x & 0x%04x\n", space->cpu->tag(), cpu_get_pc(space->cpu), offset*2, data, mem_mask);
174190
175191static TILE_GET_INFO( get_tx_tile_info )
176192{
177   int code = tx_vram[tile_index];
193   cybertnk_state *state = machine->driver_data<cybertnk_state>();
194   int code = state->tx_vram[tile_index];
178195   SET_TILE_INFO(
179196         0,
180197         code & 0x1fff,
r10886r10887
184201
185202static VIDEO_START( cybertnk )
186203{
187   tx_tilemap = tilemap_create(machine, get_tx_tile_info,tilemap_scan_rows,8,8,128,32);
188   tilemap_set_transparent_pen(tx_tilemap,0);
204   cybertnk_state *state = machine->driver_data<cybertnk_state>();
205   state->tx_tilemap = tilemap_create(machine, get_tx_tile_info,tilemap_scan_rows,8,8,128,32);
206   tilemap_set_transparent_pen(state->tx_tilemap,0);
189207}
190208
191209static void draw_pixel( bitmap_t* bitmap, const rectangle *cliprect, int y, int x, int pen)
r10886r10887
200218
201219static SCREEN_UPDATE( cybertnk )
202220{
221   cybertnk_state *state = screen->machine->driver_data<cybertnk_state>();
203222   device_t *left_screen  = screen->machine->device("lscreen");
204223   device_t *right_screen = screen->machine->device("rscreen");
205224   int screen_shift = 0;
r10886r10887
214233      screen_shift = -256;
215234   }
216235
217   tilemap_set_scrolldx(tx_tilemap, screen_shift, screen_shift);
236   tilemap_set_scrolldx(state->tx_tilemap, screen_shift, screen_shift);
218237
219238
220239   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
r10886r10887
226245
227246      for (i=0;i<0x1000/4;i+=4)
228247      {
229         UINT16 param1 = cybertnk_roadram[i+2];
230         UINT16 param2 = cybertnk_roadram[i+0];
248         UINT16 param1 = state->roadram[i+2];
249         UINT16 param2 = state->roadram[i+0];
231250
232251         drawgfx_transpen(bitmap,cliprect,gfx,param1,0,0,0,-param2+screen_shift,i/4,0);
233252
r10886r10887
247266      {
248267         for (x=0;x<128;x++)
249268         {
250            UINT16 tile = bg_vram[count] & 0x1fff;
251            UINT16 color = (fg_vram[count] & 0xe000) >> 13;
269            UINT16 tile = state->bg_vram[count] & 0x1fff;
270            UINT16 color = (state->fg_vram[count] & 0xe000) >> 13;
252271
253272            drawgfx_transpen(bitmap,cliprect,gfx,tile,color+0x194,0,0,(x*8)+screen_shift,(y*8),0);
254273
r10886r10887
268287      {
269288         for (x=0;x<128;x++)
270289         {
271            UINT16 tile = fg_vram[count] & 0x1fff;
272            UINT16 color = (fg_vram[count] & 0xe000) >> 13;
290            UINT16 tile = state->fg_vram[count] & 0x1fff;
291            UINT16 color = (state->fg_vram[count] & 0xe000) >> 13;
273292
274293            drawgfx_transpen(bitmap,cliprect,gfx,tile,color+0x1c0,0,0,(x*8)+screen_shift,(y*8),0);
275294
r10886r10887
289308
290309      for(offs=0;offs<0x1000/2;offs+=8)
291310      {
292         z = (spr_ram[offs+(0x6/2)] & 0xffff);
293         if(z == 0xffff || spr_ram[offs+(0x0/2)] == 0x0000) //TODO: check the correct bit
311         z = (state->spr_ram[offs+(0x6/2)] & 0xffff);
312         if(z == 0xffff || state->spr_ram[offs+(0x0/2)] == 0x0000) //TODO: check the correct bit
294313            continue;
295         x = (spr_ram[offs+(0xa/2)] & 0x3ff);
296         y = (spr_ram[offs+(0x4/2)] & 0xff);
297         if(spr_ram[offs+(0x4/2)] & 0x100)
314         x = (state->spr_ram[offs+(0xa/2)] & 0x3ff);
315         y = (state->spr_ram[offs+(0x4/2)] & 0xff);
316         if(state->spr_ram[offs+(0x4/2)] & 0x100)
298317            y = 0x100 - y;
299         spr_offs = (((spr_ram[offs+(0x0/2)] & 7) << 16) | (spr_ram[offs+(0x2/2)])) << 2;
300         xsize = ((spr_ram[offs+(0xc/2)] & 0x000f)+1) << 3;
301         ysize = (spr_ram[offs+(0x8/2)] & 0x00ff)+1;
302         fx = (spr_ram[offs+(0xa/2)] & 0x8000) >> 15;
303         zoom = (spr_ram[offs+(0xc/2)] & 0xff00) >> 8;
318         spr_offs = (((state->spr_ram[offs+(0x0/2)] & 7) << 16) | (state->spr_ram[offs+(0x2/2)])) << 2;
319         xsize = ((state->spr_ram[offs+(0xc/2)] & 0x000f)+1) << 3;
320         ysize = (state->spr_ram[offs+(0x8/2)] & 0x00ff)+1;
321         fx = (state->spr_ram[offs+(0xa/2)] & 0x8000) >> 15;
322         zoom = (state->spr_ram[offs+(0xc/2)] & 0xff00) >> 8;
304323
305         col_bank = (spr_ram[offs+(0x0/2)] & 0xff00) >> 8;
324         col_bank = (state->spr_ram[offs+(0x0/2)] & 0xff00) >> 8;
306325
307326         xf = 0;
308327         yf = 0;
r10886r10887
403422      }
404423   }
405424
406   tilemap_draw(bitmap,cliprect,tx_tilemap,0,0);
425   tilemap_draw(bitmap,cliprect,state->tx_tilemap,0,0);
407426
408427
409428//0x62 0x9a 1c2d0
r10886r10887
414433      if(0) //sprite gfx debug viewer
415434      {
416435         int x,y,count;
417         static int test_x, test_y, start_offs,color_pen;
418436         const UINT8 *blit_ram = screen->machine->region("spr_gfx")->base();
419437
420438         if(input_code_pressed(screen->machine, KEYCODE_Z))
421         test_x++;
439         state->test_x++;
422440
423441         if(input_code_pressed(screen->machine, KEYCODE_X))
424         test_x--;
442         state->test_x--;
425443
426444         if(input_code_pressed(screen->machine, KEYCODE_A))
427         test_y++;
445         state->test_y++;
428446
429447         if(input_code_pressed(screen->machine, KEYCODE_S))
430         test_y--;
448         state->test_y--;
431449
432450         if(input_code_pressed(screen->machine, KEYCODE_Q))
433         start_offs+=0x200;
451         state->start_offs+=0x200;
434452
435453         if(input_code_pressed(screen->machine, KEYCODE_W))
436         start_offs-=0x200;
454         state->start_offs-=0x200;
437455
438456         if(input_code_pressed_once(screen->machine, KEYCODE_T))
439         start_offs+=0x20000;
457         state->start_offs+=0x20000;
440458
441459         if(input_code_pressed_once(screen->machine, KEYCODE_Y))
442         start_offs-=0x20000;
460         state->start_offs-=0x20000;
443461
444462         if(input_code_pressed(screen->machine, KEYCODE_E))
445         start_offs+=4;
463         state->start_offs+=4;
446464
447465         if(input_code_pressed(screen->machine, KEYCODE_R))
448         start_offs-=4;
466         state->start_offs-=4;
449467
450468         if(input_code_pressed(screen->machine, KEYCODE_D))
451         color_pen++;
469         state->color_pen++;
452470
453471         if(input_code_pressed(screen->machine, KEYCODE_F))
454         color_pen--;
472         state->color_pen--;
455473
456         popmessage("%02x %02x %04x %02x",test_x,test_y,start_offs,color_pen);
474         popmessage("%02x %02x %04x %02x",state->test_x,state->test_y,state->start_offs,state->color_pen);
457475
458476         bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
459477
460         count = (start_offs);
478         count = (state->start_offs);
461479
462         for(y=0;y<test_y;y++)
480         for(y=0;y<state->test_y;y++)
463481         {
464            for(x=0;x<test_x;x+=8)
482            for(x=0;x<state->test_x;x+=8)
465483            {
466484               UINT32 color;
467485               UINT8 dot;
r10886r10887
472490               color|= ((blit_ram[count+3] & 0xff) << 0);
473491
474492               dot = (color & 0xf0000000) >> 28;
475               *BITMAP_ADDR16(bitmap, y, x+0) = screen->machine->pens[dot+(color_pen<<4)];
493               *BITMAP_ADDR16(bitmap, y, x+0) = screen->machine->pens[dot+(state->color_pen<<4)];
476494
477495               dot = (color & 0x0f000000) >> 24;
478               *BITMAP_ADDR16(bitmap, y, x+4) = screen->machine->pens[dot+(color_pen<<4)];
496               *BITMAP_ADDR16(bitmap, y, x+4) = screen->machine->pens[dot+(state->color_pen<<4)];
479497
480498               dot = (color & 0x00f00000) >> 20;
481               *BITMAP_ADDR16(bitmap, y, x+1) = screen->machine->pens[dot+(color_pen<<4)];
499               *BITMAP_ADDR16(bitmap, y, x+1) = screen->machine->pens[dot+(state->color_pen<<4)];
482500
483501               dot = (color & 0x000f0000) >> 16;
484               *BITMAP_ADDR16(bitmap, y, x+5) = screen->machine->pens[dot+(color_pen<<4)];
502               *BITMAP_ADDR16(bitmap, y, x+5) = screen->machine->pens[dot+(state->color_pen<<4)];
485503
486504               dot = (color & 0x0000f000) >> 12;
487               *BITMAP_ADDR16(bitmap, y, x+2) = screen->machine->pens[dot+(color_pen<<4)];
505               *BITMAP_ADDR16(bitmap, y, x+2) = screen->machine->pens[dot+(state->color_pen<<4)];
488506
489507               dot = (color & 0x00000f00) >> 8;
490               *BITMAP_ADDR16(bitmap, y, x+6) = screen->machine->pens[dot+(color_pen<<4)];
508               *BITMAP_ADDR16(bitmap, y, x+6) = screen->machine->pens[dot+(state->color_pen<<4)];
491509
492510               dot = (color & 0x000000f0) >> 4;
493               *BITMAP_ADDR16(bitmap, y, x+3) = screen->machine->pens[dot+(color_pen<<4)];
511               *BITMAP_ADDR16(bitmap, y, x+3) = screen->machine->pens[dot+(state->color_pen<<4)];
494512
495513               dot = (color & 0x0000000f) >> 0;
496               *BITMAP_ADDR16(bitmap, y, x+7) = screen->machine->pens[dot+(color_pen<<4)];
514               *BITMAP_ADDR16(bitmap, y, x+7) = screen->machine->pens[dot+(state->color_pen<<4)];
497515
498516               count+=4;
499517            }
r10886r10887
508526
509527static WRITE16_HANDLER( tx_vram_w )
510528{
511   COMBINE_DATA(&tx_vram[offset]);
512   tilemap_mark_tile_dirty(tx_tilemap,offset);
529   cybertnk_state *state = space->machine->driver_data<cybertnk_state>();
530   COMBINE_DATA(&state->tx_vram[offset]);
531   tilemap_mark_tile_dirty(state->tx_tilemap,offset);
513532}
514533
515534static READ16_HANDLER( io_r )
516535{
536   cybertnk_state *state = space->machine->driver_data<cybertnk_state>();
517537   switch( offset )
518538   {
519539      case 2/2:
r10886r10887
523543      // 0x001100D5 is controller data
524544      // 0x00110004 low is controller data ready
525545      case 4/2:
526         switch( (io_ram[6/2]) & 0xff )
546         switch( (state->io_ram[6/2]) & 0xff )
527547         {
528548            case 0:
529               io_ram[0xd4/2] = input_port_read(space->machine, "TRAVERSE");
549               state->io_ram[0xd4/2] = input_port_read(space->machine, "TRAVERSE");
530550               break;
531551
532552            case 0x20:
533               io_ram[0xd4/2] = input_port_read(space->machine, "ELEVATE");
553               state->io_ram[0xd4/2] = input_port_read(space->machine, "ELEVATE");
534554               break;
535555
536556            case 0x40:
537               io_ram[0xd4/2] = input_port_read(space->machine, "ACCEL");
557               state->io_ram[0xd4/2] = input_port_read(space->machine, "ACCEL");
538558               break;
539559
540560            case 0x42:
r10886r10887
542562               // controller return value is stored in $42(a6)
543563               // but I don't see it referenced again.
544564               //popmessage("unknown controller device 0x42");
545               io_ram[0xd4/2] = 0;
565               state->io_ram[0xd4/2] = 0;
546566               break;
547567
548568            case 0x60:
549               io_ram[0xd4/2] = input_port_read(space->machine, "HANDLE");
569               state->io_ram[0xd4/2] = input_port_read(space->machine, "HANDLE");
550570               break;
551571
552572            //default:
r10886r10887
564584         return input_port_read(space->machine, "DSW2");
565585
566586      case 0xd4/2:
567         return io_ram[offset]; // controller data
587         return state->io_ram[offset]; // controller data
568588
569589      default:
570590      {
571591         //popmessage("unknown io read 0x%08x", offset);
572         return io_ram[offset];
592         return state->io_ram[offset];
573593      }
574594   }
575595}
576596
577597static WRITE16_HANDLER( io_w )
578598{
579   COMBINE_DATA(&io_ram[offset]);
599   cybertnk_state *state = space->machine->driver_data<cybertnk_state>();
600   COMBINE_DATA(&state->io_ram[offset]);
580601
581602   switch( offset )
582603   {
r10886r10887
637658      case 0x80/2:
638659      case 0x82/2:
639660      case 0x84/2:
640         popmessage("%02x %02x %02x %02x %02x %02x %02x",io_ram[0x40/2],io_ram[0x42/2],io_ram[0x44/2],io_ram[0x46/2],io_ram[0x48/2],io_ram[0x4a/2],io_ram[0x4c/2]);
661         popmessage("%02x %02x %02x %02x %02x %02x %02x",state->io_ram[0x40/2],state->io_ram[0x42/2],state->io_ram[0x44/2],state->io_ram[0x46/2],state->io_ram[0x48/2],state->io_ram[0x4a/2],state->io_ram[0x4c/2]);
641662         break;
642663
643664      default:
r10886r10887
648669
649670static READ8_HANDLER( soundport_r )
650671{
651   return io_ram[0] & 0xff;
672   cybertnk_state *state = space->machine->driver_data<cybertnk_state>();
673   return state->io_ram[0] & 0xff;
652674}
653675
654676static ADDRESS_MAP_START( master_mem, ADDRESS_SPACE_PROGRAM, 16 )
655677   AM_RANGE(0x000000, 0x03ffff) AM_ROM
656678   AM_RANGE(0x080000, 0x087fff) AM_RAM /*Work RAM*/
657   AM_RANGE(0x0a0000, 0x0a0fff) AM_RAM AM_BASE(&spr_ram) // non-tile based sprite ram
658   AM_RANGE(0x0c0000, 0x0c1fff) AM_RAM_WRITE(tx_vram_w) AM_BASE(&tx_vram)
659   AM_RANGE(0x0c4000, 0x0c5fff) AM_RAM AM_BASE(&bg_vram)
660   AM_RANGE(0x0c8000, 0x0c9fff) AM_RAM AM_BASE(&fg_vram)
679   AM_RANGE(0x0a0000, 0x0a0fff) AM_RAM AM_BASE_MEMBER(cybertnk_state, spr_ram) // non-tile based sprite ram
680   AM_RANGE(0x0c0000, 0x0c1fff) AM_RAM_WRITE(tx_vram_w) AM_BASE_MEMBER(cybertnk_state, tx_vram)
681   AM_RANGE(0x0c4000, 0x0c5fff) AM_RAM AM_BASE_MEMBER(cybertnk_state, bg_vram)
682   AM_RANGE(0x0c8000, 0x0c9fff) AM_RAM AM_BASE_MEMBER(cybertnk_state, fg_vram)
661683   AM_RANGE(0x0e0000, 0x0e0fff) AM_RAM AM_SHARE("sharedram")
662684   AM_RANGE(0x100000, 0x107fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
663   AM_RANGE(0x110000, 0x1101ff) AM_READWRITE(io_r,io_w) AM_BASE(&io_ram)
685   AM_RANGE(0x110000, 0x1101ff) AM_READWRITE(io_r,io_w) AM_BASE_MEMBER(cybertnk_state, io_ram)
664686ADDRESS_MAP_END
665687
666688static ADDRESS_MAP_START( slave_mem, ADDRESS_SPACE_PROGRAM, 16 )
667689   AM_RANGE(0x000000, 0x01ffff) AM_ROM
668690   AM_RANGE(0x080000, 0x083fff) AM_RAM /*Work RAM*/
669   AM_RANGE(0x0c0000, 0x0c0fff) AM_RAM AM_BASE(&cybertnk_roadram)
691   AM_RANGE(0x0c0000, 0x0c0fff) AM_RAM AM_BASE_MEMBER(cybertnk_state, roadram)
670692   AM_RANGE(0x100000, 0x100fff) AM_RAM AM_SHARE("sharedram")
671693   AM_RANGE(0x140000, 0x140003) AM_NOP /*Watchdog? Written during loops and interrupts*/
672694ADDRESS_MAP_END
r10886r10887
836858   0 /* TODO */
837859};
838860
839static MACHINE_CONFIG_START( cybertnk, driver_device )
861static MACHINE_CONFIG_START( cybertnk, cybertnk_state )
840862   MCFG_CPU_ADD("maincpu", M68000,20000000/2)
841863   MCFG_CPU_PROGRAM_MAP(master_mem)
842864   MCFG_CPU_VBLANK_INT("lscreen", irq1_line_hold)
src/mame/drivers/mcr3.c
r10886r10887
117117
118118
119119
120/*************************************
121 *
122 *  Local variables and tables
123 *
124 *************************************/
125
126static UINT8 input_mux;
127static UINT8 latched_input;
128
129static UINT8 last_op4;
130
131static UINT8 maxrpm_adc_control;
132static UINT8 maxrpm_adc_select;
133static UINT8 maxrpm_last_shift;
134static INT8 maxrpm_p1_shift;
135static INT8 maxrpm_p2_shift;
136
137
138
139120static WRITE8_HANDLER( mcrmono_control_port_w )
140121{
141122   /*
r10886r10887
163144
164145static READ8_HANDLER( demoderm_ip1_r )
165146{
147   mcr3_state *state = space->machine->driver_data<mcr3_state>();
166148   return input_port_read(space->machine, "MONO.IP1") |
167      (input_port_read(space->machine, input_mux ? "MONO.IP1.ALT2" : "MONO.IP1.ALT1") << 2);
149      (input_port_read(space->machine, state->input_mux ? "MONO.IP1.ALT2" : "MONO.IP1.ALT1") << 2);
168150}
169151
170152
171153static READ8_HANDLER( demoderm_ip2_r )
172154{
155   mcr3_state *state = space->machine->driver_data<mcr3_state>();
173156   return input_port_read(space->machine, "MONO.IP2") |
174      (input_port_read(space->machine, input_mux ? "MONO.IP2.ALT2" : "MONO.IP2.ALT1") << 2);
157      (input_port_read(space->machine, state->input_mux ? "MONO.IP2.ALT2" : "MONO.IP2.ALT1") << 2);
175158}
176159
177160
178161static WRITE8_HANDLER( demoderm_op6_w )
179162{
163   mcr3_state *state = space->machine->driver_data<mcr3_state>();
180164   /* top 2 bits select the input */
181   if (data & 0x80) input_mux = 0;
182   if (data & 0x40) input_mux = 1;
165   if (data & 0x80) state->input_mux = 0;
166   if (data & 0x40) state->input_mux = 1;
183167
184168   /* low 5 bits control the turbo CS */
185169   turbocs_data_w(space, offset, data);
r10886r10887
195179
196180static READ8_HANDLER( maxrpm_ip1_r )
197181{
198   return latched_input;
182   mcr3_state *state = space->machine->driver_data<mcr3_state>();
183   return state->latched_input;
199184}
200185
201186
202187static READ8_HANDLER( maxrpm_ip2_r )
203188{
189   mcr3_state *state = space->machine->driver_data<mcr3_state>();
204190   static const UINT8 shift_bits[5] = { 0x00, 0x05, 0x06, 0x01, 0x02 };
205191   UINT8 start = input_port_read(space->machine, "MONO.IP0");
206192   UINT8 shift = input_port_read(space->machine, "SHIFT");
207193
208194   /* reset on a start */
209195   if (!(start & 0x08))
210      maxrpm_p1_shift = 0;
196      state->maxrpm_p1_shift = 0;
211197   if (!(start & 0x04))
212      maxrpm_p2_shift = 0;
198      state->maxrpm_p2_shift = 0;
213199
214200   /* increment, decrement on falling edge */
215   if (!(shift & 0x01) && (maxrpm_last_shift & 0x01))
201   if (!(shift & 0x01) && (state->maxrpm_last_shift & 0x01))
216202   {
217      maxrpm_p1_shift++;
218      if (maxrpm_p1_shift > 4)
219         maxrpm_p1_shift = 4;
203      state->maxrpm_p1_shift++;
204      if (state->maxrpm_p1_shift > 4)
205         state->maxrpm_p1_shift = 4;
220206   }
221   if (!(shift & 0x02) && (maxrpm_last_shift & 0x02))
207   if (!(shift & 0x02) && (state->maxrpm_last_shift & 0x02))
222208   {
223      maxrpm_p1_shift--;
224      if (maxrpm_p1_shift < 0)
225         maxrpm_p1_shift = 0;
209      state->maxrpm_p1_shift--;
210      if (state->maxrpm_p1_shift < 0)
211         state->maxrpm_p1_shift = 0;
226212   }
227   if (!(shift & 0x04) && (maxrpm_last_shift & 0x04))
213   if (!(shift & 0x04) && (state->maxrpm_last_shift & 0x04))
228214   {
229      maxrpm_p2_shift++;
230      if (maxrpm_p2_shift > 4)
231         maxrpm_p2_shift = 4;
215      state->maxrpm_p2_shift++;
216      if (state->maxrpm_p2_shift > 4)
217         state->maxrpm_p2_shift = 4;
232218   }
233   if (!(shift & 0x08) && (maxrpm_last_shift & 0x08))
219   if (!(shift & 0x08) && (state->maxrpm_last_shift & 0x08))
234220   {
235      maxrpm_p2_shift--;
236      if (maxrpm_p2_shift < 0)
237         maxrpm_p2_shift = 0;
221      state->maxrpm_p2_shift--;
222      if (state->maxrpm_p2_shift < 0)
223         state->maxrpm_p2_shift = 0;
238224   }
239225
240   maxrpm_last_shift = shift;
226   state->maxrpm_last_shift = shift;
241227
242   return ~((shift_bits[maxrpm_p1_shift] << 4) + shift_bits[maxrpm_p2_shift]);
228   return ~((shift_bits[state->maxrpm_p1_shift] << 4) + shift_bits[state->maxrpm_p2_shift]);
243229}
244230
245231
246232static WRITE8_HANDLER( maxrpm_op5_w )
247233{
234   mcr3_state *state = space->machine->driver_data<mcr3_state>();
248235   /* latch the low 4 bits as input to the ADC0844 */
249   maxrpm_adc_control = data & 0x0f;
236   state->maxrpm_adc_control = data & 0x0f;
250237
251238   /* remaining bits go to standard connections */
252239   mcrmono_control_port_w(space, offset, data);
r10886r10887
255242
256243static WRITE8_HANDLER( maxrpm_op6_w )
257244{
245   mcr3_state *state = space->machine->driver_data<mcr3_state>();
258246   static const char *const inputs[] = { "MONO.IP1", "MONO.IP1.ALT1", "MONO.IP1.ALT2", "MONO.IP1.ALT3" };
259247   /*
260248        Reflective Sensor Control:
r10886r10887
276264
277265   /* when the read is toggled is when the ADC value is latched */
278266   if (!(data & 0x80))
279      latched_input = input_port_read(space->machine, inputs[maxrpm_adc_select]);
267      state->latched_input = input_port_read(space->machine, inputs[state->maxrpm_adc_select]);
280268
281269   /* when both the write and the enable are low, it's a write to the ADC0844 */
282270   /* unfortunately the behavior below doesn't match up with the inputs on the */
283271   /* schematics and wiring diagrams, so they must be wrong */
284272   if (!(data & 0x40) && !(data & 0x20))
285      maxrpm_adc_select = (maxrpm_adc_control >> 1) & 3;
273      state->maxrpm_adc_select = (state->maxrpm_adc_control >> 1) & 3;
286274
287275   /* low 5 bits control the turbo CS */
288276   turbocs_data_w(space, offset, data);
r10886r10887
365353
366354static READ8_HANDLER( stargrds_ip0_r )
367355{
356   mcr3_state *state = space->machine->driver_data<mcr3_state>();
368357   UINT8 result = input_port_read(space->machine, "MONO.IP0");
369   if (input_mux)
358   if (state->input_mux)
370359      result = (result & ~0x0a) | (input_port_read(space->machine, "MONO.IP0.ALT") & 0x0a);
371360   return (result & ~0x10) | ((soundsgood_status_r(space, 0) << 4) & 0x10);
372361}
r10886r10887
374363
375364static WRITE8_HANDLER( stargrds_op5_w )
376365{
366   mcr3_state *state = space->machine->driver_data<mcr3_state>();
377367   /* bit 1 controls input muxing on port 0 */
378   input_mux = (data >> 1) & 1;
368   state->input_mux = (data >> 1) & 1;
379369
380370   /* bit 2 controls light #0 */
381371   /* bit 3 controls light #1 */
r10886r10887
414404
415405static READ8_HANDLER( spyhunt_ip2_r )
416406{
407   mcr3_state *state = space->machine->driver_data<mcr3_state>();
417408   /* multiplexed steering wheel/gas pedal */
418   return input_port_read(space->machine, input_mux ? "SSIO.IP2.ALT" : "SSIO.IP2");
409   return input_port_read(space->machine, state->input_mux ? "SSIO.IP2.ALT" : "SSIO.IP2");
419410}
420411
421412
422413static WRITE8_HANDLER( spyhunt_op4_w )
423414{
415   mcr3_state *state = space->machine->driver_data<mcr3_state>();
424416   /* Spy Hunter uses port 4 for talking to the Chip Squeak Deluxe */
425417   /* (and for toggling the lamps and muxing the analog inputs) */
426418
427419   /* mux select is in bit 7 */
428   input_mux = (data >> 7) & 1;
420   state->input_mux = (data >> 7) & 1;
429421
430422   /*
431423        Lamp Driver:
r10886r10887
436428            demuxer. The eight outputs directly control 8 lamps.
437429    */
438430   /* bit 5 = STR1 (J1-13) */
439   if (((last_op4 ^ data) & 0x20) && !(data & 0x20))
431   if (((state->last_op4 ^ data) & 0x20) && !(data & 0x20))
440432   {
441433      static const char *const lampname[8] =
442434      {
r10886r10887
449441      /* bit 0 -> J1-12 (A0) */
450442      output_set_value(lampname[data & 7], (data >> 3) & 1);
451443   }
452   last_op4 = data;
444   state->last_op4 = data;
453445
454446   /* low 5 bits go to control the Chip Squeak Deluxe */
455447   csdeluxe_data_w(space, offset, data);
r10886r10887
465457
466458static READ8_HANDLER( turbotag_ip2_r )
467459{
460   mcr3_state *state = space->machine->driver_data<mcr3_state>();
468461   /* multiplexed steering wheel/gas pedal */
469   if (input_mux)
462   if (state->input_mux)
470463      return input_port_read(space->machine, "SSIO.IP2.ALT");
471464
472465   return input_port_read(space->machine, "SSIO.IP2") + 5 * (space->machine->primary_screen->frame_number() & 1);
r10886r10887
533526   ADDRESS_MAP_UNMAP_HIGH
534527   AM_RANGE(0x0000, 0xdfff) AM_ROM
535528   AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(spyhunt_videoram_w) AM_BASE_MEMBER(mcr3_state, videoram)
536   AM_RANGE(0xe800, 0xebff) AM_MIRROR(0x0400) AM_RAM_WRITE(spyhunt_alpharam_w) AM_BASE(&spyhunt_alpharam)
529   AM_RANGE(0xe800, 0xebff) AM_MIRROR(0x0400) AM_RAM_WRITE(spyhunt_alpharam_w) AM_BASE_MEMBER(mcr3_state, spyhunt_alpharam)
537530   AM_RANGE(0xf000, 0xf7ff) AM_RAM AM_SHARE("nvram")
538531   AM_RANGE(0xf800, 0xf9ff) AM_RAM AM_BASE_SIZE_MEMBER(mcr3_state, spriteram, spriteram_size)
539532   AM_RANGE(0xfa00, 0xfa7f) AM_MIRROR(0x0180) AM_WRITE(mcr3_paletteram_w) AM_BASE_GENERIC(paletteram)
r10886r10887
15361529
15371530static void mcr_common_init(running_machine *machine, int sound_board)
15381531{
1532   mcr3_state *state = machine->driver_data<mcr3_state>();
15391533   mcr_sound_init(machine, sound_board);
15401534
1541   state_save_register_global(machine, input_mux);
1542   state_save_register_global(machine, latched_input);
1543   state_save_register_global(machine, last_op4);
1535   state_save_register_global(machine, state->input_mux);
1536   state_save_register_global(machine, state->latched_input);
1537   state_save_register_global(machine, state->last_op4);
15441538}
15451539
15461540
r10886r10887
15621556
15631557static DRIVER_INIT( maxrpm )
15641558{
1559   mcr3_state *state = machine->driver_data<mcr3_state>();
15651560   mcr_common_init(machine, MCR_TURBO_CHIP_SQUEAK);
15661561   memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x01, 0x01, 0, 0, maxrpm_ip1_r);
15671562   memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x02, 0x02, 0, 0, maxrpm_ip2_r);
15681563   memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x05, 0x05, 0, 0, maxrpm_op5_w);
15691564   memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x06, 0x06, 0, 0, maxrpm_op6_w);
15701565
1571   state_save_register_global(machine, maxrpm_adc_control);
1572   state_save_register_global(machine, maxrpm_adc_select);
1573   state_save_register_global(machine, maxrpm_last_shift);
1574   state_save_register_global(machine, maxrpm_p1_shift);
1575   state_save_register_global(machine, maxrpm_p2_shift);
1566   state_save_register_global(machine, state->maxrpm_adc_control);
1567   state_save_register_global(machine, state->maxrpm_adc_select);
1568   state_save_register_global(machine, state->maxrpm_last_shift);
1569   state_save_register_global(machine, state->maxrpm_p1_shift);
1570   state_save_register_global(machine, state->maxrpm_p2_shift);
15761571}
15771572
15781573
r10886r10887
16041599
16051600static DRIVER_INIT( spyhunt )
16061601{
1602   mcr3_state *state = machine->driver_data<mcr3_state>();
16071603   mcr_common_init(machine, MCR_SSIO | MCR_CHIP_SQUEAK_DELUXE);
16081604   ssio_set_custom_input(1, 0x60, spyhunt_ip1_r);
16091605   ssio_set_custom_input(2, 0xff, spyhunt_ip2_r);
16101606   ssio_set_custom_output(4, 0xff, spyhunt_op4_w);
16111607
1612   spyhunt_sprite_color_mask = 0x00;
1613   spyhunt_scroll_offset = 16;
1608   state->spyhunt_sprite_color_mask = 0x00;
1609   state->spyhunt_scroll_offset = 16;
16141610}
16151611
16161612
16171613static DRIVER_INIT( crater )
16181614{
1615   mcr3_state *state = machine->driver_data<mcr3_state>();
16191616   mcr_common_init(machine, MCR_SSIO);
16201617
1621   spyhunt_sprite_color_mask = 0x03;
1622   spyhunt_scroll_offset = 96;
1618   state->spyhunt_sprite_color_mask = 0x03;
1619   state->spyhunt_scroll_offset = 96;
16231620}
16241621
16251622
16261623static DRIVER_INIT( turbotag )
16271624{
1625   mcr3_state *state = machine->driver_data<mcr3_state>();
16281626   mcr_common_init(machine, MCR_SSIO | MCR_CHIP_SQUEAK_DELUXE);
16291627   ssio_set_custom_input(1, 0x60, spyhunt_ip1_r);
16301628   ssio_set_custom_input(2, 0xff, turbotag_ip2_r);
16311629   ssio_set_custom_output(4, 0xff, spyhunt_op4_w);
16321630
1633   spyhunt_sprite_color_mask = 0x00;
1634   spyhunt_scroll_offset = 88;
1631   state->spyhunt_sprite_color_mask = 0x00;
1632   state->spyhunt_scroll_offset = 88;
16351633
16361634   /* the SSIO Z80 doesn't have any program to execute */
16371635   machine->device<cpu_device>("csdcpu")->suspend(SUSPEND_REASON_DISABLE, 1);
src/mame/drivers/pipeline.c
r10886r10887
7171#include "cpu/z80/z80daisy.h"
7272#include "cpu/m6805/m6805.h"
7373
74static tilemap_t *tilemap1;
75static tilemap_t *tilemap2;
7674
77static UINT8 *vram1;
78static UINT8 *vram2;
75class pipeline_state : public driver_device
76{
77public:
78   pipeline_state(running_machine &machine, const driver_device_config_base &config)
79      : driver_device(machine, config) { }
7980
80static UINT8 vidctrl;
81static UINT8 *palram;
82static UINT8 toMCU, fromMCU, ddrA;
81   tilemap_t *tilemap1;
82   tilemap_t *tilemap2;
83   UINT8 *vram1;
84   UINT8 *vram2;
85   UINT8 vidctrl;
86   UINT8 *palram;
87   UINT8 toMCU;
88   UINT8 fromMCU;
89   UINT8 ddrA;
90};
8391
92
8493static TILE_GET_INFO( get_tile_info )
8594{
86   int code = vram2[tile_index]+vram2[tile_index+0x800]*256;
95   pipeline_state *state = machine->driver_data<pipeline_state>();
96   int code = state->vram2[tile_index]+state->vram2[tile_index+0x800]*256;
8797   SET_TILE_INFO(
8898      0,
8999      code,
r10886r10887
93103
94104static TILE_GET_INFO( get_tile_info2 )
95105{
96   int code =vram1[tile_index]+((vram1[tile_index+0x800]>>4))*256;
97   int color=((vram1[tile_index+0x800])&0xf);
106   pipeline_state *state = machine->driver_data<pipeline_state>();
107   int code =state->vram1[tile_index]+((state->vram1[tile_index+0x800]>>4))*256;
108   int color=((state->vram1[tile_index+0x800])&0xf);
98109   SET_TILE_INFO
99110   (
100111      1,
r10886r10887
106117
107118static VIDEO_START ( pipeline )
108119{
109   palram=auto_alloc_array(machine, UINT8, 0x1000);
110   tilemap1 = tilemap_create( machine, get_tile_info,tilemap_scan_rows,8,8,64,32 );
111   tilemap2 = tilemap_create( machine, get_tile_info2,tilemap_scan_rows,8,8,64,32 );
112   tilemap_set_transparent_pen(tilemap2,0);
120   pipeline_state *state = machine->driver_data<pipeline_state>();
121   state->palram=auto_alloc_array(machine, UINT8, 0x1000);
122   state->tilemap1 = tilemap_create( machine, get_tile_info,tilemap_scan_rows,8,8,64,32 );
123   state->tilemap2 = tilemap_create( machine, get_tile_info2,tilemap_scan_rows,8,8,64,32 );
124   tilemap_set_transparent_pen(state->tilemap2,0);
113125}
114126
115127static SCREEN_UPDATE( pipeline )
116128{
117   tilemap_draw(bitmap,cliprect,tilemap1, 0,0);
118   tilemap_draw(bitmap,cliprect,tilemap2, 0,0);
129   pipeline_state *state = screen->machine->driver_data<pipeline_state>();
130   tilemap_draw(bitmap,cliprect,state->tilemap1, 0,0);
131   tilemap_draw(bitmap,cliprect,state->tilemap2, 0,0);
119132   return 0;
120133}
121134
122135
123136static WRITE8_DEVICE_HANDLER(vidctrl_w)
124137{
125   vidctrl=data;
138   pipeline_state *state = device->machine->driver_data<pipeline_state>();
139   state->vidctrl=data;
126140}
127141
128142static WRITE8_HANDLER(vram2_w)
129143{
130   if(!(vidctrl&1))
144   pipeline_state *state = space->machine->driver_data<pipeline_state>();
145   if(!(state->vidctrl&1))
131146   {
132      tilemap_mark_tile_dirty(tilemap1,offset&0x7ff);
133      vram2[offset]=data;
147      tilemap_mark_tile_dirty(state->tilemap1,offset&0x7ff);
148      state->vram2[offset]=data;
134149   }
135150   else
136151   {
137       palram[offset]=data;
152       state->palram[offset]=data;
138153       if(offset<0x300)
139154       {
140155         offset&=0xff;
141         palette_set_color_rgb(space->machine, offset, pal6bit(palram[offset]), pal6bit(palram[offset+0x100]), pal6bit(palram[offset+0x200]));
156         palette_set_color_rgb(space->machine, offset, pal6bit(state->palram[offset]), pal6bit(state->palram[offset+0x100]), pal6bit(state->palram[offset+0x200]));
142157       }
143158   }
144159}
145160
146161static WRITE8_HANDLER(vram1_w)
147162{
148   tilemap_mark_tile_dirty(tilemap2,offset&0x7ff);
149   vram1[offset]=data;
163   pipeline_state *state = space->machine->driver_data<pipeline_state>();
164   tilemap_mark_tile_dirty(state->tilemap2,offset&0x7ff);
165   state->vram1[offset]=data;
150166}
151167
152168static READ8_DEVICE_HANDLER(protection_r)
153169{
154   return fromMCU;
170   pipeline_state *state = device->machine->driver_data<pipeline_state>();
171   return state->fromMCU;
155172}
156173
157174static TIMER_CALLBACK( protection_deferred_w )
158175{
159   toMCU = param;
176   pipeline_state *state = machine->driver_data<pipeline_state>();
177   state->toMCU = param;
160178}
161179
162180static WRITE8_DEVICE_HANDLER(protection_w)
r10886r10887
168186static ADDRESS_MAP_START( cpu0_mem, ADDRESS_SPACE_PROGRAM, 8 )
169187   AM_RANGE(0x0000, 0x7fff) AM_ROM
170188   AM_RANGE(0x8000, 0x87ff) AM_RAM
171   AM_RANGE(0x8800, 0x97ff) AM_RAM_WRITE(vram1_w) AM_BASE(&vram1)
172   AM_RANGE(0x9800, 0xa7ff) AM_RAM_WRITE(vram2_w) AM_BASE(&vram2)
189   AM_RANGE(0x8800, 0x97ff) AM_RAM_WRITE(vram1_w) AM_BASE_MEMBER(pipeline_state, vram1)
190   AM_RANGE(0x9800, 0xa7ff) AM_RAM_WRITE(vram2_w) AM_BASE_MEMBER(pipeline_state, vram2)
173191   AM_RANGE(0xb800, 0xb803) AM_DEVREADWRITE("ppi8255_0", ppi8255_r, ppi8255_w)
174192   AM_RANGE(0xb810, 0xb813) AM_DEVREADWRITE("ppi8255_1", ppi8255_r, ppi8255_w)
175193   AM_RANGE(0xb830, 0xb830) AM_NOP
r10886r10887
190208
191209static WRITE8_HANDLER(mcu_portA_w)
192210{
193   fromMCU=data;
211   pipeline_state *state = space->machine->driver_data<pipeline_state>();
212   state->fromMCU=data;
194213}
195214
196215static READ8_HANDLER(mcu_portA_r)
197216{
198   return (fromMCU&ddrA)|(toMCU& ~ddrA);
217   pipeline_state *state = space->machine->driver_data<pipeline_state>();
218   return (state->fromMCU&state->ddrA)|(state->toMCU& ~state->ddrA);
199219}
200220
201221static WRITE8_HANDLER(mcu_ddrA_w)
202222{
203   ddrA=data;
223   pipeline_state *state = space->machine->driver_data<pipeline_state>();
224   state->ddrA=data;
204225}
205226
206227static ADDRESS_MAP_START( mcu_mem, ADDRESS_SPACE_PROGRAM, 8 )
r10886r10887
360381   }
361382}
362383
363static MACHINE_CONFIG_START( pipeline, driver_device )
384static MACHINE_CONFIG_START( pipeline, pipeline_state )
364385   /* basic machine hardware */
365386
366387   MCFG_CPU_ADD("maincpu", Z80, 7372800/2)
src/mame/drivers/kungfur.c
r10886r10887
4747   UINT8 mux_data;
4848   UINT32 adpcm_pos[2];
4949   UINT8 adpcm_idle[2];
50   UINT8 trigger1;
51   UINT8 adpcm_data1;
52   UINT8 trigger2;
53   UINT8 adpcm_data2;
5054};
5155
5256
r10886r10887
276280static void kfr_adpcm1_int(device_t *device)
277281{
278282   kungfur_state *state = device->machine->driver_data<kungfur_state>();
279   static UINT8 trigger,adpcm_data;
280283
281284   if (state->adpcm_pos[0] >= 0x40000 || state->adpcm_idle[0])
282285   {
283286      msm5205_reset_w(device->machine->device("adpcm1"),1);
284      trigger = 0;
287      state->trigger1 = 0;
285288   }
286289   else
287290   {
288291      UINT8 *ROM = device->machine->region("adpcm1")->base();
289292
290      adpcm_data = ((trigger ? (ROM[state->adpcm_pos[0]] & 0x0f) : (ROM[state->adpcm_pos[0]] & 0xf0)>>4) );
291      msm5205_data_w(device->machine->device("adpcm1"),adpcm_data & 0xf);
292      trigger^=1;
293      if(trigger == 0)
293      state->adpcm_data1 = ((state->trigger1 ? (ROM[state->adpcm_pos[0]] & 0x0f) : (ROM[state->adpcm_pos[0]] & 0xf0)>>4) );
294      msm5205_data_w(device->machine->device("adpcm1"), state->adpcm_data1 & 0xf);
295      state->trigger1 ^= 1;
296      if(state->trigger1 == 0)
294297      {
295298         state->adpcm_pos[0]++;
296299         if((ROM[state->adpcm_pos[0]] & 0xff) == 0xff)
r10886r10887
303306static void kfr_adpcm2_int(device_t *device)
304307{
305308   kungfur_state *state = device->machine->driver_data<kungfur_state>();
306   static UINT8 trigger,adpcm_data;
307309
308310   if (state->adpcm_pos[1] >= 0x10000 || state->adpcm_idle[1])
309311   {
310312      msm5205_reset_w(device->machine->device("adpcm2"),1);
311      trigger = 0;
313      state->trigger2 = 0;
312314   }
313315   else
314316   {
315317      UINT8 *ROM = device->machine->region("adpcm2")->base();
316318
317      adpcm_data = ((trigger ? (ROM[state->adpcm_pos[1]] & 0x0f) : (ROM[state->adpcm_pos[1]] & 0xf0)>>4) );
318      msm5205_data_w(device->machine->device("adpcm2"),adpcm_data & 0xf);
319      trigger^=1;
320      if(trigger == 0)
319      state->adpcm_data2 = ((state->trigger2 ? (ROM[state->adpcm_pos[1]] & 0x0f) : (ROM[state->adpcm_pos[1]] & 0xf0)>>4) );
320      msm5205_data_w(device->machine->device("adpcm2"), state->adpcm_data2 & 0xf);
321      state->trigger2 ^= 1;
322      if(state->trigger2 == 0)
321323      {
322324         state->adpcm_pos[1]++;
323325         if((ROM[state->adpcm_pos[1]] & 0xff) == 0xff)
src/mame/drivers/pinkiri8.c
r10886r10887
3535#include "sound/okim6295.h"
3636#include "video/generic.h"
3737
38static UINT8* janshi_vram1;
39static UINT8* janshi_vram2;
40static UINT8* janshi_back_vram;
41static UINT8* janshi_crtc_regs;
42static UINT8* janshi_unk1;
43static UINT8* janshi_widthflags;
44static UINT8* janshi_unk2;
4538
39class pinkiri8_state : public driver_device
40{
41public:
42   pinkiri8_state(running_machine &machine, const driver_device_config_base &config)
43      : driver_device(machine, config) { }
44
45   UINT8* janshi_vram1;
46   UINT8* janshi_vram2;
47   UINT8* janshi_back_vram;
48   UINT8* janshi_crtc_regs;
49   UINT8* janshi_unk1;
50   UINT8* janshi_widthflags;
51   UINT8* janshi_unk2;
52   UINT32 vram_addr;
53   int prev_writes;
54   UINT8 mux_data;
55   UINT8 prot_read_index;
56   UINT8 prot_char[6];
57   UINT8 prot_index;
58};
59
60
4661static ADDRESS_MAP_START( janshi_vdp_map8, 0, 8 )
4762
48   AM_RANGE(0xfc0000, 0xfc1fff) AM_RAM AM_BASE(&janshi_back_vram) // bg tilemap?
49   AM_RANGE(0xfc2000, 0xfc2fff) AM_RAM AM_BASE(&janshi_vram1) // xpos, colour, tile number etc.
63   AM_RANGE(0xfc0000, 0xfc1fff) AM_RAM AM_BASE_MEMBER(pinkiri8_state, janshi_back_vram) // bg tilemap?
64   AM_RANGE(0xfc2000, 0xfc2fff) AM_RAM AM_BASE_MEMBER(pinkiri8_state, janshi_vram1) // xpos, colour, tile number etc.
5065
51   AM_RANGE(0xfc3700, 0xfc377f) AM_RAM AM_BASE(&janshi_unk1) // ?? height related?
52   AM_RANGE(0xfc3780, 0xfc37bf) AM_RAM AM_BASE(&janshi_widthflags)
53   AM_RANGE(0xfc37c0, 0xfc37ff) AM_RAM AM_BASE(&janshi_unk2) // 2x increasing tables 00 10 20 30 etc.
66   AM_RANGE(0xfc3700, 0xfc377f) AM_RAM AM_BASE_MEMBER(pinkiri8_state, janshi_unk1) // ?? height related?
67   AM_RANGE(0xfc3780, 0xfc37bf) AM_RAM AM_BASE_MEMBER(pinkiri8_state, janshi_widthflags)
68   AM_RANGE(0xfc37c0, 0xfc37ff) AM_RAM AM_BASE_MEMBER(pinkiri8_state, janshi_unk2) // 2x increasing tables 00 10 20 30 etc.
5469
55   AM_RANGE(0xfc3800, 0xfc3fff) AM_RAM AM_BASE(&janshi_vram2) // y pos + unknown
70   AM_RANGE(0xfc3800, 0xfc3fff) AM_RAM AM_BASE_MEMBER(pinkiri8_state, janshi_vram2) // y pos + unknown
5671
5772   AM_RANGE(0xff0000, 0xff07ff) AM_RAM_WRITE(paletteram_xBBBBBGGGGGRRRRR_split1_w) AM_BASE_GENERIC(paletteram)
5873   AM_RANGE(0xff2000, 0xff27ff) AM_RAM_WRITE(paletteram_xBBBBBGGGGGRRRRR_split2_w) AM_BASE_GENERIC(paletteram2)
5974
60   AM_RANGE(0xff6000, 0xff601f) AM_RAM AM_BASE(&janshi_crtc_regs)
75   AM_RANGE(0xff6000, 0xff601f) AM_RAM AM_BASE_MEMBER(pinkiri8_state, janshi_crtc_regs)
6176ADDRESS_MAP_END
6277
6378
r10886r10887
149164
150165
151166
152static UINT32 vram_addr;
153167
154168static VIDEO_START( pinkiri8 )
155169{
r10886r10887
191205
192206static SCREEN_UPDATE( pinkiri8 )
193207{
194   static int col_bank;
208   pinkiri8_state *state = screen->machine->driver_data<pinkiri8_state>();
209   int col_bank;
195210   const gfx_element *gfx = screen->machine->gfx[0];
196211
197   static int game_type_hack = 0;
212   int game_type_hack = 0;
198213
199214   if (!strcmp(screen->machine->gamedrv->name,"janshi")) game_type_hack = 1;
200215
r10886r10887
207222      for (i=0x00;i<0x40;i+=2)
208223      {
209224
210         printf("%02x, ", janshi_widthflags[i+1]);
225         printf("%02x, ", state->janshi_widthflags[i+1]);
211226
212227         count2++;
213228
r10886r10887
225240
226241
227242
228   //popmessage("%02x",janshi_crtc_regs[0x0a]);
229   col_bank = (janshi_crtc_regs[0x0a] & 0x40) >> 6;
243   //popmessage("%02x",state->janshi_crtc_regs[0x0a]);
244   col_bank = (state->janshi_crtc_regs[0x0a] & 0x40) >> 6;
230245
231246   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
232247
r10886r10887
240255      {
241256         for(x=0;x<32;x++)
242257         {
243            tile = janshi_back_vram[count+1]<<8 | janshi_back_vram[count+0];
244            attr = janshi_back_vram[count+2] ^ 0xf0;
258            tile = state->janshi_back_vram[count+1]<<8 | state->janshi_back_vram[count+0];
259            attr = state->janshi_back_vram[count+2] ^ 0xf0;
245260            col = (attr >> 4) | 0x10;
246261
247262            drawgfx_transpen(bitmap,cliprect,gfx,tile,col,0,0,x*16,y*8,0);
r10886r10887
277292
278293          */
279294
280         spr_offs = ((janshi_vram1[(i*4)+0] & 0xff) | (janshi_vram1[(i*4)+1]<<8)) & 0xffff;
281         col = (janshi_vram1[(i*4)+2] & 0xf8) >> 3;
282         x =   janshi_vram1[(i*4)+3];
295         spr_offs = ((state->janshi_vram1[(i*4)+0] & 0xff) | (state->janshi_vram1[(i*4)+1]<<8)) & 0xffff;
296         col = (state->janshi_vram1[(i*4)+2] & 0xf8) >> 3;
297         x =   state->janshi_vram1[(i*4)+3];
283298
284299         x &= 0xff;
285300         x *= 2;
286301
287         unk2 = janshi_vram2[(i*2)+1];
288         y = (janshi_vram2[(i*2)+0]);
302         unk2 = state->janshi_vram2[(i*2)+1];
303         y = (state->janshi_vram2[(i*2)+0]);
289304
290305         y = 0x100-y;
291306
r10886r10887
298313
299314
300315         // these bits seem to somehow determine the sprite height / widths for the sprite ram region?
301         int bit = janshi_widthflags[(i/0x20)*2 + 1];
316         int bit = state->janshi_widthflags[(i/0x20)*2 + 1];
302317
303318         if (bit)
304319         {
r10886r10887
406421   //data & 0x80 is probably NMI mask
407422}
408423
409static int prev_writes = 0;
410424
411425#define LOG_VRAM 0
412426
413427static WRITE8_HANDLER( pinkiri8_vram_w )
414428{
429   pinkiri8_state *state = space->machine->driver_data<pinkiri8_state>();
415430   switch(offset)
416431   {
417432      case 0:
418         vram_addr = (data << 0)  | (vram_addr&0xffff00);
419         if (LOG_VRAM) printf("\n prev writes was %04x\n\naddress set to %04x -\n", prev_writes, vram_addr );
420         prev_writes = 0;
433         state->vram_addr = (data << 0)  | (state->vram_addr&0xffff00);
434         if (LOG_VRAM) printf("\n prev writes was %04x\n\naddress set to %04x -\n", state->prev_writes, state->vram_addr );
435         state->prev_writes = 0;
421436         break;
422437
423438      case 1:
424         vram_addr = (data << 8)  | (vram_addr & 0xff00ff);
425         if (LOG_VRAM)printf("\naddress set to %04x\n", vram_addr);
439         state->vram_addr = (data << 8)  | (state->vram_addr & 0xff00ff);
440         if (LOG_VRAM)printf("\naddress set to %04x\n", state->vram_addr);
426441         break;
427442
428443      case 2:
429         vram_addr = (data << 16) | (vram_addr & 0x00ffff);
430         if (LOG_VRAM)printf("\naddress set to %04x\n", vram_addr);
444         state->vram_addr = (data << 16) | (state->vram_addr & 0x00ffff);
445         if (LOG_VRAM)printf("\naddress set to %04x\n", state->vram_addr);
431446         break;
432447
433448      case 3:
r10886r10887
435450         address_space *vdp_space = space->machine->device<janshi_vdp_device>("janshivdp")->space();
436451
437452         if (LOG_VRAM) printf("%02x ", data);
438         prev_writes++;
439         vram_addr++;
453         state->prev_writes++;
454         state->vram_addr++;
440455
441         vdp_space->write_byte(vram_addr, data);
456         vdp_space->write_byte(state->vram_addr, data);
442457         break;
443458   }
444459}
445460
446static UINT8 mux_data;
447461
448462static WRITE8_HANDLER( mux_w )
449463{
450   mux_data = data;
464   pinkiri8_state *state = space->machine->driver_data<pinkiri8_state>();
465   state->mux_data = data;
451466}
452467
453468static READ8_HANDLER( mux_p2_r )
454469{
455   switch(mux_data)
470   pinkiri8_state *state = space->machine->driver_data<pinkiri8_state>();
471   switch(state->mux_data)
456472   {
457473      case 0x01: return input_port_read(space->machine, "PL2_01");
458474      case 0x02: return input_port_read(space->machine, "PL2_02");
r10886r10887
466482
467483static READ8_HANDLER( mux_p1_r )
468484{
469   switch(mux_data)
485   pinkiri8_state *state = space->machine->driver_data<pinkiri8_state>();
486   switch(state->mux_data)
470487   {
471488      case 0x01: return input_port_read(space->machine, "PL1_01");
472489      case 0x02: return input_port_read(space->machine, "PL1_02");
r10886r10887
11071124   GFXDECODE_ENTRY( "gfx1", 0, charlayout,     0, 0x100 )
11081125GFXDECODE_END
11091126
1110static MACHINE_CONFIG_START( pinkiri8, driver_device )
1127static MACHINE_CONFIG_START( pinkiri8, pinkiri8_state )
11111128   MCFG_CPU_ADD("maincpu",Z180,16000000)
11121129   MCFG_CPU_PROGRAM_MAP(pinkiri8_map)
11131130   MCFG_CPU_IO_MAP(pinkiri8_io)
r10886r10887
11891206   ROM_LOAD( "eagle.6", 0x00000, 0x40000, CRC(8197034d) SHA1(b501dc7a27b1faad1361c309afd726da14b8b5f5) )
11901207ROM_END
11911208
1192static UINT8 prot_read_index;
11931209
11941210static READ8_HANDLER( ronjan_prot_r )
11951211{
1212   pinkiri8_state *state = space->machine->driver_data<pinkiri8_state>();
11961213   static const char wing_str[6] = { 'W', 'I', 'N', 'G', '8', '9' };
11971214
1198   prot_read_index++;
1215   state->prot_read_index++;
11991216
1200   if(prot_read_index & 1)
1217   if(state->prot_read_index & 1)
12011218      return 0xff; //value is discarded
12021219
1203   return wing_str[(prot_read_index >> 1)-1];
1220   return wing_str[(state->prot_read_index >> 1)-1];
12041221}
12051222
12061223static WRITE8_HANDLER( ronjan_prot_w )
12071224{
1208   static UINT8 prot_char[6],prot_index;
1225   pinkiri8_state *state = space->machine->driver_data<pinkiri8_state>();
12091226
12101227   if(data == 0)
12111228   {
1212      prot_index = 0;
1229      state->prot_index = 0;
12131230   }
12141231   else
12151232   {
1216      prot_char[prot_index] = data;
1217      prot_index++;
1233      state->prot_char[state->prot_index] = data;
1234      state->prot_index++;
12181235
1219      if(prot_char[0] == 'E' && prot_char[1] == 'R' && prot_char[2] == 'R' && prot_char[3] == 'O' && prot_char[4] == 'R')
1220         prot_read_index = 0;
1236      if(state->prot_char[0] == 'E' && state->prot_char[1] == 'R' && state->prot_char[2] == 'R' && state->prot_char[3] == 'O' && state->prot_char[4] == 'R')
1237         state->prot_read_index = 0;
12211238   }
12221239}
12231240
src/mame/drivers/namcos86.c
r10886r10887
256256}
257257
258258
259static int wdog;
260
261259static WRITE8_HANDLER( watchdog1_w )
262260{
263   wdog |= 1;
264   if (wdog == 3)
261   namcos86_state *state = space->machine->driver_data<namcos86_state>();
262   state->wdog |= 1;
263   if (state->wdog == 3)
265264   {
266      wdog = 0;
265      state->wdog = 0;
267266      watchdog_reset_w(space,0,0);
268267   }
269268}
270269
271270static WRITE8_HANDLER( watchdog2_w )
272271{
273   wdog |= 2;
274   if (wdog == 3)
272   namcos86_state *state = space->machine->driver_data<namcos86_state>();
273   state->wdog |= 2;
274   if (state->wdog == 3)
275275   {
276      wdog = 0;
276      state->wdog = 0;
277277      watchdog_reset_w(space,0,0);
278278   }
279279}
r10886r10887
334334
335335
336336static ADDRESS_MAP_START( cpu1_map, ADDRESS_SPACE_PROGRAM, 8 )
337   AM_RANGE(0x0000, 0x1fff) AM_READWRITE(rthunder_videoram1_r,rthunder_videoram1_w) AM_BASE(&rthunder_videoram1)
338   AM_RANGE(0x2000, 0x3fff) AM_READWRITE(rthunder_videoram2_r,rthunder_videoram2_w) AM_BASE(&rthunder_videoram2)
337   AM_RANGE(0x0000, 0x1fff) AM_READWRITE(rthunder_videoram1_r,rthunder_videoram1_w) AM_BASE_MEMBER(namcos86_state, rthunder_videoram1)
338   AM_RANGE(0x2000, 0x3fff) AM_READWRITE(rthunder_videoram2_r,rthunder_videoram2_w) AM_BASE_MEMBER(namcos86_state, rthunder_videoram2)
339339
340340   AM_RANGE(0x4000, 0x43ff) AM_DEVREADWRITE("namco", namcos1_cus30_r, namcos1_cus30_w) /* PSG device, shared RAM */
341341
r10886r10887
365365
366366#define CPU2_MEMORY(NAME,ADDR_SPRITE,ADDR_VIDEO1,ADDR_VIDEO2,ADDR_ROM,ADDR_BANK,ADDR_WDOG,ADDR_INT)   \
367367static ADDRESS_MAP_START( NAME##_cpu2_map, ADDRESS_SPACE_PROGRAM, 8 )                     \
368   AM_RANGE(ADDR_SPRITE+0x0000, ADDR_SPRITE+0x1fff) AM_READWRITE(rthunder_spriteram_r,rthunder_spriteram_w) AM_BASE(&rthunder_spriteram)   \
368   AM_RANGE(ADDR_SPRITE+0x0000, ADDR_SPRITE+0x1fff) AM_READWRITE(rthunder_spriteram_r,rthunder_spriteram_w) AM_BASE_MEMBER(namcos86_state, rthunder_spriteram)   \
369369   AM_RANGE(ADDR_VIDEO1+0x0000, ADDR_VIDEO1+0x1fff) AM_READWRITE(rthunder_videoram1_r,rthunder_videoram1_w)   \
370370   AM_RANGE(ADDR_VIDEO2+0x0000, ADDR_VIDEO2+0x1fff) AM_READWRITE(rthunder_videoram2_r,rthunder_videoram2_w)   \
371371   AM_RANGE(ADDR_ROM+0x0000, ADDR_ROM+0x1fff) AM_ROMBANK("bank2")                        \
src/mame/drivers/chsuper.c
r10886r10887
1515#include "sound/dac.h"
1616#include "machine/nvram.h"
1717
18static int chsuper_tilexor;
1918
19class chsuper_state : public driver_device
20{
21public:
22   chsuper_state(running_machine &machine, const driver_device_config_base &config)
23      : driver_device(machine, config) { }
24
25   int tilexor;
26   struct { int r,g,b,offs,offs_internal; } pal;
27};
28
29
30
2031static VIDEO_START(chsuper)
2132{
2233}
2334
2435static SCREEN_UPDATE(chsuper)
2536{
37   //chsuper_state *state = screen->machine->driver_data<chsuper_state>();
2638   const gfx_element *gfx = screen->machine->gfx[0];
2739   UINT8 *vram = screen->machine->region("vram")->base();
2840   int count = 0x0000;
r10886r10887
3446      {
3547         int tile = ((vram[count+1]<<8) | vram[count]) & 0xffff;
3648
37         //tile ^=chsuper_tilexor;
49         //tile ^=state->tilexor;
3850
3951         drawgfx_opaque(bitmap,cliprect,gfx,tile,0,0,0,x*4,y*8);
4052         count+=2;
r10886r10887
4658
4759static WRITE8_HANDLER( paletteram_io_w )
4860{
49   static int pal_offs,r,g,b,internal_pal_offs;
50
61   chsuper_state *state = space->machine->driver_data<chsuper_state>();
5162   switch(offset)
5263   {
5364      case 0:
54         pal_offs = data;
65         state->pal.offs = data;
5566         break;
5667      case 2:
57         internal_pal_offs = 0;
68         state->pal.offs_internal = 0;
5869         break;
5970      case 1:
60         switch(internal_pal_offs)
71         switch(state->pal.offs_internal)
6172         {
6273            case 0:
63               r = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
64               internal_pal_offs++;
74               state->pal.r = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
75               state->pal.offs_internal++;
6576               break;
6677            case 1:
67               g = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
68               internal_pal_offs++;
78               state->pal.g = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
79               state->pal.offs_internal++;
6980               break;
7081            case 2:
71               b = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
72               palette_set_color(space->machine, pal_offs, MAKE_RGB(r, g, b));
73               internal_pal_offs = 0;
74               pal_offs++;
82               state->pal.b = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
83               palette_set_color(space->machine, state->pal.offs, MAKE_RGB(state->pal.r, state->pal.g, state->pal.b));
84               state->pal.offs_internal = 0;
85               state->pal.offs++;
7586               break;
7687         }
7788
r10886r10887
190201   GFXDECODE_ENTRY( "gfx1", 0x00000, charlayout,   0, 1 )
191202GFXDECODE_END
192203
193static MACHINE_CONFIG_START( chsuper, driver_device )
204static MACHINE_CONFIG_START( chsuper, chsuper_state )
194205
195206   /* basic machine hardware */
196207   MCFG_CPU_ADD("maincpu", Z180, XTAL_12MHz / 2)   /* HD64180RP8, 8 MHz? */
r10886r10887
269280
270281static DRIVER_INIT( chsuper2 )
271282{
283   chsuper_state *state = machine->driver_data<chsuper_state>();
272284   UINT8 *buffer;
273285   UINT8 *rom = machine->region("gfx1")->base();
274286   int i;
275287
276   chsuper_tilexor = 0x7f00;
288   state->tilexor = 0x7f00;
277289
278290   buffer = auto_alloc_array(machine, UINT8, 0x100000);
279291
r10886r10887
281293   {
282294      int j;
283295
284      j = i ^ (chsuper_tilexor << 5);
296      j = i ^ (state->tilexor << 5);
285297
286298      buffer[j] = rom[i];
287299   }
288300
289301   memcpy(rom,buffer,0x100000);
290302
291   chsuper_tilexor = 0x0000;
303   state->tilexor = 0x0000;
292304}
293305
294306static DRIVER_INIT( chsuper3 )
295307{
308   chsuper_state *state = machine->driver_data<chsuper_state>();
296309   UINT8 *buffer;
297310   UINT8 *rom = machine->region("gfx1")->base();
298311   int i;
299312
300   chsuper_tilexor = 0x0e00;
313   state->tilexor = 0x0e00;
301314
302315   buffer = auto_alloc_array(machine, UINT8, 0x100000);
303316
r10886r10887
305318   {
306319      int j;
307320
308      j = i ^ (chsuper_tilexor << 5);
321      j = i ^ (state->tilexor << 5);
309322
310323      buffer[j] = rom[i];
311324   }
312325
313326   memcpy(rom,buffer,0x100000);
314327
315   chsuper_tilexor = 0x0000;
328   state->tilexor = 0x0000;
316329}
317330
318331static DRIVER_INIT( chmpnum )
319332{
333   chsuper_state *state = machine->driver_data<chsuper_state>();
320334   UINT8 *buffer;
321335   UINT8 *rom = machine->region("gfx1")->base();
322336   int i;
323337
324   chsuper_tilexor = 0x1800;
338   state->tilexor = 0x1800;
325339
326340   buffer = auto_alloc_array(machine, UINT8, 0x100000);
327341
r10886r10887
329343   {
330344      int j;
331345
332      j = i ^ (chsuper_tilexor << 5);
346      j = i ^ (state->tilexor << 5);
333347
334348      j = BITSWAP24(j,23,22,21,20,19,18,17,13, 15,14,16,12, 11,10,9,8, 7,6,5,4, 3,2,1,0);
335349      j = BITSWAP24(j,23,22,21,20,19,18,17,14, 15,16,13,12, 11,10,9,8, 7,6,5,4, 3,2,1,0);
r10886r10887
340354
341355   memcpy(rom,buffer,0x100000);
342356
343   chsuper_tilexor = 0x0000;
357   state->tilexor = 0x0000;
344358}
345359
346360
src/mame/drivers/photon2.c
r10886r10887
1313#include "cpu/z80/z80.h"
1414#include "sound/speaker.h"
1515
16/*************************************
17 *
18 *  Globals
19 *
20 *************************************/
2116
22static UINT8 *spectrum_video_ram;
23static int spectrum_frame_number;    /* Used for handling FLASH 1 */
24static int spectrum_flash_invert;
25static UINT8 spectrum_port_fe;
26static UINT8 nmi_enable = 0;
17class photon2_state : public driver_device
18{
19public:
20   photon2_state(running_machine &machine, const driver_device_config_base &config)
21      : driver_device(machine, config) { }
2722
23   UINT8 *spectrum_video_ram;
24   int spectrum_frame_number;
25   int spectrum_flash_invert;
26   UINT8 spectrum_port_fe;
27   UINT8 nmi_enable;
28};
2829
30
2931/*************************************
3032 *
3133 *  Video (copied from MESS apart from support
r10886r10887
7981
8082static VIDEO_START( spectrum )
8183{
82   spectrum_frame_number = 0;
83   spectrum_flash_invert = 0;
84   photon2_state *state = machine->driver_data<photon2_state>();
85   state->spectrum_frame_number = 0;
86   state->spectrum_flash_invert = 0;
8487}
8588
8689/* return the color to be used inverting FLASHing colors if necessary */
r10886r10887
9699   independent of frame skip etc. */
97100static SCREEN_EOF( spectrum )
98101{
99    spectrum_frame_number++;
100    if (spectrum_frame_number >= 25)
102   photon2_state *state = machine->driver_data<photon2_state>();
103    state->spectrum_frame_number++;
104    if (state->spectrum_frame_number >= 25)
101105    {
102        spectrum_frame_number = 0;
103        spectrum_flash_invert = !spectrum_flash_invert;
106        state->spectrum_frame_number = 0;
107        state->spectrum_flash_invert = !state->spectrum_flash_invert;
104108    }
105109}
106110
r10886r10887
111115
112116static SCREEN_UPDATE( spectrum )
113117{
118   photon2_state *state = screen->machine->driver_data<photon2_state>();
114119    /* for now do a full-refresh */
115120    int x, y, b, scrx, scry;
116121    unsigned short ink, pap;
117122    unsigned char *attr, *scr;
118123//  int full_refresh = 1;
119124
120    scr=spectrum_video_ram;
125    scr=state->spectrum_video_ram;
121126
122   bitmap_fill(bitmap, cliprect, spectrum_port_fe & 0x07);
127   bitmap_fill(bitmap, cliprect, state->spectrum_port_fe & 0x07);
123128
124129    for (y=0; y<192; y++)
125130    {
126131        scrx=SPEC_LEFT_BORDER;
127132        scry=((y&7) * 8) + ((y&0x38)>>3) + (y&0xC0);
128        attr=spectrum_video_ram + ((scry>>3)*32) + 0x1800;
133        attr=state->spectrum_video_ram + ((scry>>3)*32) + 0x1800;
129134
130135        for (x=0;x<32;x++)
131136        {
132137            /* Get ink and paper colour with bright */
133                if (spectrum_flash_invert && (*attr & 0x80))
138                if (state->spectrum_flash_invert && (*attr & 0x80))
134139                {
135140                        ink=((*attr)>>3) & 0x0f;
136141                        pap=((*attr) & 0x07) + (((*attr)>>3) & 0x08);
r10886r10887
192197
193198static WRITE8_HANDLER(photon2_fe_w)
194199{
200   photon2_state *state = space->machine->driver_data<photon2_state>();
195201   device_t *speaker = space->machine->device("speaker");
196   spectrum_port_fe = data;
202   state->spectrum_port_fe = data;
197203
198204   speaker_level_w(speaker, BIT(data,4));
199205}
200206
201207static WRITE8_HANDLER(photon2_misc_w)
202208{
203   nmi_enable = !BIT(data,5);
209   photon2_state *state = space->machine->driver_data<photon2_state>();
210   state->nmi_enable = !BIT(data,5);
204211}
205212
206213/*************************************
r10886r10887
211218
212219static ADDRESS_MAP_START (spectrum_mem, ADDRESS_SPACE_PROGRAM, 8)
213220   AM_RANGE(0x0000, 0x3fff) AM_ROMBANK("bank1")
214   AM_RANGE(0x4000, 0x5aff) AM_RAM AM_BASE(&spectrum_video_ram )
221   AM_RANGE(0x4000, 0x5aff) AM_RAM AM_BASE_MEMBER(photon2_state, spectrum_video_ram )
215222   AM_RANGE(0x5b00, 0xffff) AM_RAM
216223ADDRESS_MAP_END
217224
r10886r10887
278285
279286static INTERRUPT_GEN( spec_interrupt_hack )
280287{
288   photon2_state *state = device->machine->driver_data<photon2_state>();
281289   if (cpu_getiloops(device) == 1)
282290   {
283291      cpu_set_input_line(device, 0, HOLD_LINE);
284292   }
285293   else
286294   {
287      if ( nmi_enable )
295      if ( state->nmi_enable )
288296      {
289297         cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE);
290298      }
r10886r10887
296304   memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base());
297305}
298306
299static MACHINE_CONFIG_START( photon2, driver_device )
307static MACHINE_CONFIG_START( photon2, photon2_state )
300308   /* basic machine hardware */
301309   MCFG_CPU_ADD("maincpu", Z80, 3500000)        /* 3.5 MHz */
302310   MCFG_CPU_PROGRAM_MAP(spectrum_mem)
src/mame/drivers/nsmpoker.c
r10886r10887
6464#include "sound/ay8910.h"
6565
6666
67class nsmpoker_state : public driver_device
68{
69public:
70   nsmpoker_state(running_machine &machine, const driver_device_config_base &config)
71      : driver_device(machine, config) { }
72
73   UINT8 *videoram;
74   UINT8 *colorram;
75   tilemap_t *bg_tilemap;
76};
77
78
6779/*************************
6880*     Video Hardware     *
6981*************************/
7082
71static UINT8 *videoram;
72static UINT8 *colorram;
73static tilemap_t *bg_tilemap;
7483
75
7684static WRITE8_HANDLER( nsmpoker_videoram_w )
7785{
78   videoram[offset] = data;
79   tilemap_mark_tile_dirty(bg_tilemap, offset);
86   nsmpoker_state *state = space->machine->driver_data<nsmpoker_state>();
87   state->videoram[offset] = data;
88   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
8089}
8190
8291
8392static WRITE8_HANDLER( nsmpoker_colorram_w )
8493{
85   colorram[offset] = data;
86   tilemap_mark_tile_dirty(bg_tilemap, offset);
94   nsmpoker_state *state = space->machine->driver_data<nsmpoker_state>();
95   state->colorram[offset] = data;
96   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
8797}
8898
8999
90100static TILE_GET_INFO( get_bg_tile_info )
91101{
102   nsmpoker_state *state = machine->driver_data<nsmpoker_state>();
92103/*  - bits -
93104    7654 3210
94105    ---- ----   bank select.
95106    ---- ----   color code.
96107    ---- ----   seems unused.
97108*/
98//  int attr = colorram[tile_index];
99   int code = videoram[tile_index];
109//  int attr = state->colorram[tile_index];
110   int code = state->videoram[tile_index];
100111//  int bank = (attr & 0x08) >> 3;
101112//  int color = (attr & 0x03);
102113
r10886r10887
106117
107118static VIDEO_START( nsmpoker )
108119{
109   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
120   nsmpoker_state *state = machine->driver_data<nsmpoker_state>();
121   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
110122}
111123
112124
113125static SCREEN_UPDATE( nsmpoker )
114126{
115   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
127   nsmpoker_state *state = screen->machine->driver_data<nsmpoker_state>();
128   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
116129   return 0;
117130}
118131
r10886r10887
151164   AM_RANGE(0x0000, 0x7fff) AM_ROM
152165   AM_RANGE(0x9000, 0xafff) AM_RAM   // OK... cleared at beginning.
153166   AM_RANGE(0xb000, 0xcfff) AM_ROM   // WRONG... just to map the last rom somewhere.
154   AM_RANGE(0xe000, 0xefff) AM_RAM_WRITE(nsmpoker_videoram_w) AM_BASE(&videoram) // WRONG... just a placeholder.
155   AM_RANGE(0xf000, 0xffff) AM_RAM_WRITE(nsmpoker_colorram_w) AM_BASE(&colorram) // WRONG... just a placeholder.
167   AM_RANGE(0xe000, 0xefff) AM_RAM_WRITE(nsmpoker_videoram_w) AM_BASE_MEMBER(nsmpoker_state, videoram) // WRONG... just a placeholder.
168   AM_RANGE(0xf000, 0xffff) AM_RAM_WRITE(nsmpoker_colorram_w) AM_BASE_MEMBER(nsmpoker_state, colorram) // WRONG... just a placeholder.
156169ADDRESS_MAP_END
157170
158171static ADDRESS_MAP_START( nsmpoker_portmap, ADDRESS_SPACE_IO, 8 )
r10886r10887
374387*    Machine Drivers     *
375388*************************/
376389
377static MACHINE_CONFIG_START( nsmpoker, driver_device )
390static MACHINE_CONFIG_START( nsmpoker, nsmpoker_state )
378391
379392   /* basic machine hardware */
380393   MCFG_CPU_ADD("maincpu", TMS9995, MASTER_CLOCK/2)   /* guess */
src/mame/drivers/avt.c
r10886r10887
414414//#include "machine/z80pio.h"
415415
416416
417class avt_state : public driver_device
418{
419public:
420   avt_state(running_machine &machine, const driver_device_config_base &config)
421      : driver_device(machine, config) { }
422
423   UINT8 *videoram;
424   UINT8 *colorram;
425   tilemap_t *bg_tilemap;
426};
427
428
429
417430/*********************************************
418431*               Video Hardware               *
419432*********************************************/
420433
421static UINT8 *videoram;
422static UINT8 *colorram;
423static tilemap_t *bg_tilemap;
424434
425
426435static WRITE8_HANDLER( avt_videoram_w )
427436{
428   videoram[offset] = data;
429   tilemap_mark_tile_dirty(bg_tilemap, offset);
437   avt_state *state = space->machine->driver_data<avt_state>();
438   state->videoram[offset] = data;
439   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
430440}
431441
432442
433443static WRITE8_HANDLER( avt_colorram_w )
434444{
435   colorram[offset] = data;
436   tilemap_mark_tile_dirty(bg_tilemap, offset);
445   avt_state *state = space->machine->driver_data<avt_state>();
446   state->colorram[offset] = data;
447   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
437448}
438449
439450
440451static TILE_GET_INFO( get_bg_tile_info )
441452{
453   avt_state *state = machine->driver_data<avt_state>();
442454/*  - bits -
443455    7654 3210
444456    xxxx ----   color code.
445457    ---- xxxx   seems unused.
446458*/
447   int attr = colorram[tile_index];
448   int code = videoram[tile_index];
459   int attr = state->colorram[tile_index];
460   int code = state->videoram[tile_index];
449461   int color = (attr & 0xf0)>>4;
450462
451463   SET_TILE_INFO( 0, code, color, 0);
r10886r10887
454466
455467static VIDEO_START( avt )
456468{
457   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 28, 32);
469   avt_state *state = machine->driver_data<avt_state>();
470   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 28, 32);
458471}
459472
460473
461474static SCREEN_UPDATE( avt )
462475{
463   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
476   avt_state *state = screen->machine->driver_data<avt_state>();
477   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
464478   return 0;
465479}
466480
r10886r10887
535549   AM_RANGE(0x0000, 0x5fff) AM_ROM
536550   AM_RANGE(0x6000, 0x7fff) AM_RAM
537551   AM_RANGE(0x8000, 0x9fff) AM_RAM // AM_SHARE("nvram")
538   AM_RANGE(0xa000, 0xa7ff) AM_RAM_WRITE(avt_videoram_w) AM_BASE(&videoram)
539   AM_RANGE(0xc000, 0xc7ff) AM_RAM_WRITE(avt_colorram_w) AM_BASE(&colorram)
552   AM_RANGE(0xa000, 0xa7ff) AM_RAM_WRITE(avt_videoram_w) AM_BASE_MEMBER(avt_state, videoram)
553   AM_RANGE(0xc000, 0xc7ff) AM_RAM_WRITE(avt_colorram_w) AM_BASE_MEMBER(avt_state, colorram)
540554ADDRESS_MAP_END
541555
542556static ADDRESS_MAP_START( avt_portmap, ADDRESS_SPACE_IO, 8 )
r10886r10887
796810*              Machine Drivers               *
797811*********************************************/
798812
799static MACHINE_CONFIG_START( avt, driver_device )
813static MACHINE_CONFIG_START( avt, avt_state )
800814
801815   /* basic machine hardware */
802816   MCFG_CPU_ADD("maincpu", Z80, CPU_CLOCK)   /* guess */
src/mame/drivers/adp.c
r10886r10887
161161   /* misc */
162162   UINT8 mux_data;
163163   UINT8 register_active;
164   struct { int r,g,b,offs,offs_internal; } pal;
164165
165166   /* devices */
166167   device_t *maincpu;
r10886r10887
415416
416417static READ8_DEVICE_HANDLER(t2_r)
417418{
418   static UINT8 res;
419   static int h,w;
419   UINT8 res;
420   int h,w;
420421   res = 0;
421422   h = device->machine->primary_screen->height();
422423   w = device->machine->primary_screen->width();
r10886r10887
464465
465466static WRITE8_HANDLER( ramdac_io_w )
466467{
467   static int pal_offs,r,g,b,internal_pal_offs;
468
468   adp_state *state = space->machine->driver_data<adp_state>();
469469   switch(offset)
470470   {
471471      case 0:
472         pal_offs = data;
473         internal_pal_offs = 0;
472         state->pal.offs = data;
473         state->pal.offs_internal = 0;
474474         break;
475475      case 2:
476476         //mask pen reg
477477         break;
478478      case 1:
479         switch(internal_pal_offs)
479         switch(state->pal.offs_internal)
480480         {
481481            case 0:
482               r = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
483               internal_pal_offs++;
482               state->pal.r = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
483               state->pal.offs_internal++;
484484               break;
485485            case 1:
486               g = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
487               internal_pal_offs++;
486               state->pal.g = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
487               state->pal.offs_internal++;
488488               break;
489489            case 2:
490               b = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
491               palette_set_color(space->machine, pal_offs, MAKE_RGB(r, g, b));
492               internal_pal_offs = 0;
493               pal_offs++;
494               pal_offs&=0xff;
490               state->pal.b = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
491               palette_set_color(space->machine, state->pal.offs, MAKE_RGB(state->pal.r, state->pal.g, state->pal.b));
492               state->pal.offs_internal = 0;
493               state->pal.offs++;
494               state->pal.offs&=0xff;
495495               break;
496496         }
497497
src/mame/drivers/pcxt.c
r10886r10887
7070#include "sound/hc55516.h"
7171#include "sound/beep.h"
7272
73
74class pcxt_state : public driver_device
75{
76public:
77   pcxt_state(running_machine &machine, const driver_device_config_base &config)
78      : driver_device(machine, config) { }
79
80   UINT8 *vga_vram;
81   UINT8 *work_ram;
82   UINT8 video_regs[0x19];
83   UINT8 *vga_mode;
84   UINT8 hv_blank;
85   UINT8 *vga_bg_bank;
86   int bank;
87   int lastvalue;
88   UINT8 video_index;
89   UINT8 disk_data[2];
90   UINT8 port_b_data;
91   UINT8 wss1_data;
92   UINT8 wss2_data;
93   UINT8 status;
94   UINT8 clr_status;
95   UINT8 drive_data;
96   int dma_channel;
97   UINT8 dma_offset[2][4];
98   UINT8 at_pages[0x10];
99
100   device_t   *pit8253;
101   device_t   *pic8259_1;
102   device_t   *pic8259_2;
103   device_t   *dma8237_1;
104   device_t   *dma8237_2;
105};
106
107
73108#define SET_VISIBLE_AREA(_x_,_y_) \
74109   { \
75110   rectangle visarea; \
r10886r10887
81116   } \
82117
83118
84static UINT8 *vga_vram,*work_ram;
85static UINT8 video_regs[0x19];
86static UINT8 *vga_mode;
87static UINT8 hv_blank;
88static UINT8 *vga_bg_bank;
89
90static int bank;
91static int lastvalue;
92
93119/*Add here Video regs defines...*/
94120
95121
r10886r10887
113139    ---- x--- Vertical Retrace
114140    ---- ---x Horizontal Retrace
115141    */
116   static UINT8 res;
117   static int h,w;
142   UINT8 res;
143   int h,w;
118144   res = 0;
119145   h = space->machine->primary_screen->height();
120146   w = space->machine->primary_screen->width();
r10886r10887
134160/*TODO: non-black colours should use the bright versions*/
135161static void cga_graphic_bitmap(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect,UINT16 size,UINT32 map_offs)
136162{
137   static UINT16 x,y;
138   static UINT32 offs;
163   pcxt_state *state = machine->driver_data<pcxt_state>();
164   UINT16 x,y;
165   UINT32 offs;
139166
140167   SET_VISIBLE_AREA(320,200);
141168   offs = map_offs;
142169   for(y=0;y<200;y+=2)
143170      for(x=0;x<320;x+=4)
144171      {
145         *BITMAP_ADDR16(bitmap, y, x+0) = machine->pens[0x200+(((vga_vram[offs] & 0xc0)>>6)<<1)];
146         *BITMAP_ADDR16(bitmap, y, x+1) = machine->pens[0x200+(((vga_vram[offs] & 0x30)>>4)<<1)];
147         *BITMAP_ADDR16(bitmap, y, x+2) = machine->pens[0x200+(((vga_vram[offs] & 0x0c)>>2)<<1)];
148         *BITMAP_ADDR16(bitmap, y, x+3) = machine->pens[0x200+(((vga_vram[offs] & 0x03)>>0)<<1)];
172         *BITMAP_ADDR16(bitmap, y, x+0) = machine->pens[0x200+(((state->vga_vram[offs] & 0xc0)>>6)<<1)];
173         *BITMAP_ADDR16(bitmap, y, x+1) = machine->pens[0x200+(((state->vga_vram[offs] & 0x30)>>4)<<1)];
174         *BITMAP_ADDR16(bitmap, y, x+2) = machine->pens[0x200+(((state->vga_vram[offs] & 0x0c)>>2)<<1)];
175         *BITMAP_ADDR16(bitmap, y, x+3) = machine->pens[0x200+(((state->vga_vram[offs] & 0x03)>>0)<<1)];
149176         offs++;
150177      }
151178
r10886r10887
153180   for(y=1;y<200;y+=2)
154181      for(x=0;x<320;x+=4)
155182      {
156         *BITMAP_ADDR16(bitmap, y, x+0) = machine->pens[0x200+(((vga_vram[offs] & 0xc0)>>6)<<1)];
157         *BITMAP_ADDR16(bitmap, y, x+1) = machine->pens[0x200+(((vga_vram[offs] & 0x30)>>4)<<1)];
158         *BITMAP_ADDR16(bitmap, y, x+2) = machine->pens[0x200+(((vga_vram[offs] & 0x0c)>>2)<<1)];
159         *BITMAP_ADDR16(bitmap, y, x+3) = machine->pens[0x200+(((vga_vram[offs] & 0x03)>>0)<<1)];
183         *BITMAP_ADDR16(bitmap, y, x+0) = machine->pens[0x200+(((state->vga_vram[offs] & 0xc0)>>6)<<1)];
184         *BITMAP_ADDR16(bitmap, y, x+1) = machine->pens[0x200+(((state->vga_vram[offs] & 0x30)>>4)<<1)];
185         *BITMAP_ADDR16(bitmap, y, x+2) = machine->pens[0x200+(((state->vga_vram[offs] & 0x0c)>>2)<<1)];
186         *BITMAP_ADDR16(bitmap, y, x+3) = machine->pens[0x200+(((state->vga_vram[offs] & 0x03)>>0)<<1)];
160187         offs++;
161188      }
162189
r10886r10887
166193
167194static void cga_alphanumeric_tilemap(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,UINT16 size,UINT32 map_offs,UINT8 gfx_num)
168195{
169   static UINT32 offs,x,y,max_x,max_y;
196   pcxt_state *state = machine->driver_data<pcxt_state>();
197   UINT32 offs,x,y,max_x,max_y;
170198
171199   /*define the visible area*/
172200   switch(size)
r10886r10887
181209         max_x = 80;
182210         max_y = 25;
183211         break;
212      default:
213         fatalerror("Unknown size");
184214   }
185215
186216   offs = map_offs;
r10886r10887
188218   for(y=0;y<max_y;y++)
189219      for(x=0;x<max_x;x++)
190220      {
191         int tile =  vga_vram[offs] & 0xff;
192         int color = vga_vram[offs+1] & 0xff;
221         int tile =  state->vga_vram[offs] & 0xff;
222         int color = state->vga_vram[offs+1] & 0xff;
193223
194224         drawgfx_transpen(bitmap,cliprect,machine->gfx[gfx_num],
195225               tile,
r10886r10887
205235
206236static SCREEN_UPDATE( filetto )
207237{
238   pcxt_state *state = screen->machine->driver_data<pcxt_state>();
208239/*          xx1x xxxx  Attribute bit 7. 0=blink, 1=Intesity
209240            xxx1 xxxx  640x200 mode
210241            xxxx 1xxx  Enable video signal
r10886r10887
214245            */
215246   bitmap_fill(bitmap, cliprect, 0);
216247
217   if(vga_mode[0] & 8)
248   if(state->vga_mode[0] & 8)
218249   {
219      if(vga_mode[0] & 2)
250      if(state->vga_mode[0] & 2)
220251         cga_graphic_bitmap(screen->machine,bitmap,cliprect,0,0x18000);
221252      else
222253      {
223         switch(vga_mode[0] & 1)
254         switch(state->vga_mode[0] & 1)
224255         {
225256            case 0x00:
226257               cga_alphanumeric_tilemap(screen->machine,bitmap,cliprect,RES_320x200,0x18000,2);
r10886r10887
237268
238269static void vga_bitmap_layer(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
239270{
271   pcxt_state *state = machine->driver_data<pcxt_state>();
240272   int x,y,z;
241273   UINT8 *region = machine->region("user1")->base();
242   static UINT32 cur_bank;
274   UINT32 cur_bank;
243275
244276   /*TODO: might be a different descramble algorythm plus plain bg bank*/
245   cur_bank = (((8-vga_bg_bank[0]) & 0x1f)*0x10000);
277   cur_bank = (((8-state->vga_bg_bank[0]) & 0x1f)*0x10000);
246278
247279   for(y=0;y<200;y+=8)
248280   {
r10886r10887
257289/*S3 Video card,VGA*/
258290static SCREEN_UPDATE( tetriskr )
259291{
292   pcxt_state *state = screen->machine->driver_data<pcxt_state>();
260293   bitmap_fill(bitmap, cliprect, 0);
261294
262   if(vga_mode[0] & 8)
295   if(state->vga_mode[0] & 8)
263296   {
264      if(vga_mode[0] & 2)
297      if(state->vga_mode[0] & 2)
265298         cga_graphic_bitmap(screen->machine,bitmap,cliprect,0,0x18000);
266299      else
267300      {
268301         vga_bitmap_layer(screen->machine,bitmap,cliprect);
269302
270         switch(vga_mode[0] & 1)
303         switch(state->vga_mode[0] & 1)
271304         {
272305            case 0x00:
273306               cga_alphanumeric_tilemap(screen->machine,bitmap,cliprect,RES_320x200,0x18000,0);
r10886r10887
290323
291324static WRITE8_HANDLER( vga_regs_w )
292325{
293   static UINT8 video_index;
326   pcxt_state *state = space->machine->driver_data<pcxt_state>();
294327
295328   if(offset == 0)
296329   {
297      video_index = data;
330      state->video_index = data;
298331   }
299332   if(offset == 1)
300333   {
301      if(video_index <= 0x18)
334      if(state->video_index <= 0x18)
302335      {
303         video_regs[video_index] = data;
304         //logerror("write %02x to video register [%02x]",data,video_index);
336         state->video_regs[state->video_index] = data;
337         //logerror("write %02x to video register [%02x]",data,state->video_index);
305338      }
306339      else
307         logerror("(PC=%05x) Warning: Undefined VGA reg port write (I=%02x D=%02x)\n",cpu_get_pc(space->cpu),video_index,data);
340         logerror("(PC=%05x) Warning: Undefined VGA reg port write (I=%02x D=%02x)\n",cpu_get_pc(space->cpu),state->video_index,data);
308341   }
309342}
310343
311344static WRITE8_HANDLER( vga_vram_w )
312345{
313   vga_vram[offset] = data;
346   pcxt_state *state = space->machine->driver_data<pcxt_state>();
347   state->vga_vram[offset] = data;
314348}
315349
316350/*end of Video HW file*/
317351
318static struct {
319   device_t   *pit8253;
320   device_t   *pic8259_1;
321   device_t   *pic8259_2;
322   device_t   *dma8237_1;
323   device_t   *dma8237_2;
324} filetto_devices;
325352
326353
327static UINT8 disk_data[2];
328354
329355static READ8_HANDLER( disk_iobank_r )
330356{
357   pcxt_state *state = space->machine->driver_data<pcxt_state>();
331358   //printf("Read Prototyping card [%02x] @ PC=%05x\n",offset,cpu_get_pc(space->cpu));
332359   //if(offset == 0) return input_port_read(space->machine, "DSW");
333360   if(offset == 1) return input_port_read(space->machine, "IN1");
334361
335   return disk_data[offset];
362   return state->disk_data[offset];
336363}
337364
338365static WRITE8_HANDLER( disk_iobank_w )
339366{
367   pcxt_state *state = space->machine->driver_data<pcxt_state>();
340368/*
341369    BIOS does a single out $0310,$F0 on reset
342370
r10886r10887
367395   }
368396   else
369397   {
370      if((lastvalue == 0xF0) && (data == 0xF2))
398      if((state->lastvalue == 0xF0) && (data == 0xF2))
371399         newbank = 0;
372      else if ((lastvalue == 0xF1) && (data == 0xF2))
400      else if ((state->lastvalue == 0xF1) && (data == 0xF2))
373401         newbank = 1;
374      else if ((lastvalue == 0xF0) && (data == 0xF3))
402      else if ((state->lastvalue == 0xF0) && (data == 0xF3))
375403         newbank = 2;
376      else if ((lastvalue == 0xF1) && (data == 0xF3))
404      else if ((state->lastvalue == 0xF1) && (data == 0xF3))
377405         newbank = 3;
378406   }
379407
380408//  printf("newbank = %d\n", newbank);
381409
382   if (newbank != bank)
410   if (newbank != state->bank)
383411   {
384      bank = newbank;
385      memory_set_bankptr(space->machine,  "bank1",space->machine->region("user1")->base() + 0x10000 * bank );
412      state->bank = newbank;
413      memory_set_bankptr(space->machine,  "bank1",space->machine->region("user1")->base() + 0x10000 * state->bank );
386414   }
387415
388   lastvalue = data;
416   state->lastvalue = data;
389417
390   disk_data[offset] = data;
418   state->disk_data[offset] = data;
391419}
392420
393421/*********************************
r10886r10887
413441   }
414442};
415443
416static UINT8 port_b_data;
417static UINT8 wss1_data,wss2_data;
418444
419445static READ8_DEVICE_HANDLER( port_a_r )
420446{
421   if(!(port_b_data & 0x80))//???
447   pcxt_state *state = device->machine->driver_data<pcxt_state>();
448   if(!(state->port_b_data & 0x80))//???
422449   {
423450      /*
424451        x--- ---- Undefined (Always 0)
r10886r10887
428455        ---- --x- 8087 NDP installed
429456        ---- ---x Undefined (Always 1)
430457        */
431      return wss1_data;
458      return state->wss1_data;
432459   }
433460   else//keyboard emulation
434461   {
r10886r10887
440467
441468static READ8_DEVICE_HANDLER( port_b_r )
442469{
443   return port_b_data;
470   pcxt_state *state = device->machine->driver_data<pcxt_state>();
471   return state->port_b_data;
444472}
445473
446474static READ8_DEVICE_HANDLER( port_c_r )
447475{
448   return wss2_data;//???
476   pcxt_state *state = device->machine->driver_data<pcxt_state>();
477   return state->wss2_data;//???
449478}
450479
451480/*'buzzer' sound routes here*/
r10886r10887
453482/* The Korean Tetris uses it as a regular buzzer,probably the sound is all in there...*/
454483static WRITE8_DEVICE_HANDLER( port_b_w )
455484{
456   port_b_data = data;
485   pcxt_state *state = device->machine->driver_data<pcxt_state>();
486   state->port_b_data = data;
457487// device_t *beep = device->machine->device("beep");
458488// device_t *cvsd = device->machine->device("cvsd");
459489//  hc55516_digit_w(cvsd, data);
460490//  popmessage("%02x\n",data);
461491//  beep_set_state(beep, 0);
462492//  beep_set_state(beep, 1);
463//  beep_set_frequency(beep, port_b_data);
493//  beep_set_frequency(beep, state->port_b_data);
464494}
465495
466496static WRITE8_DEVICE_HANDLER( wss_1_w )
467497{
468   wss1_data = data;
498   pcxt_state *state = device->machine->driver_data<pcxt_state>();
499   state->wss1_data = data;
469500}
470501
471502static WRITE8_DEVICE_HANDLER( wss_2_w )
472503{
473   wss2_data = data;
504   pcxt_state *state = device->machine->driver_data<pcxt_state>();
505   state->wss2_data = data;
474506}
475507
476508static WRITE8_DEVICE_HANDLER( sys_reset_w )
r10886r10887
501533
502534/*Floppy Disk Controller 765 device*/
503535/*Currently we only emulate it at a point that the BIOS will pass the checks*/
504static UINT8 status;
505536
506537#define FDC_BUSY 0x10
507538#define FDC_WRITE 0x40
r10886r10887
509540
510541static READ8_HANDLER( fdc765_status_r )
511542{
512   static UINT8 tmp,clr_status;
543   pcxt_state *state = space->machine->driver_data<pcxt_state>();
544   UINT8 tmp;
513545//  popmessage("Read FDC status @ PC=%05x",cpu_get_pc(space->cpu));
514   tmp = status | 0x80;
515   clr_status++;
516   if(clr_status == 0x10)
546   tmp = state->status | 0x80;
547   state->clr_status++;
548   if(state->clr_status == 0x10)
517549   {
518      status = 0;
519      clr_status = 0;
550      state->status = 0;
551      state->clr_status = 0;
520552   }
521553   return tmp;
522554}
523555
524556static READ8_HANDLER( fdc765_data_r )
525557{
526   status = (FDC_READ);
558   pcxt_state *state = space->machine->driver_data<pcxt_state>();
559   state->status = (FDC_READ);
527560   return 0xc0;
528561}
529562
530563static WRITE8_HANDLER( fdc765_data_w )
531564{
532   status = (FDC_WRITE);
565   pcxt_state *state = space->machine->driver_data<pcxt_state>();
566   state->status = (FDC_WRITE);
533567}
534568
535static UINT8 drive_data;
536569
537570static WRITE8_HANDLER( drive_selection_w )
538571{
539   drive_data = data;
572   pcxt_state *state = space->machine->driver_data<pcxt_state>();
573   state->drive_data = data;
540574   /*write to this area then expects that location [43e] has the bit 7 activated*/
541   work_ram[0x3e] = 0x80;
575   state->work_ram[0x3e] = 0x80;
542576}
543577
544578/******************
545579DMA8237 Controller
546580******************/
547581
548static int dma_channel;
549static UINT8 dma_offset[2][4];
550static UINT8 at_pages[0x10];
551582
552583static WRITE_LINE_DEVICE_HANDLER( pc_dma_hrq_changed )
553584{
r10886r10887
560591
561592static READ8_HANDLER( pc_dma_read_byte )
562593{
563   offs_t page_offset = (((offs_t) dma_offset[0][dma_channel]) << 16)
594   pcxt_state *state = space->machine->driver_data<pcxt_state>();
595   offs_t page_offset = (((offs_t) state->dma_offset[0][state->dma_channel]) << 16)
564596      & 0xFF0000;
565597
566598   return space->read_byte(page_offset + offset);
r10886r10887
569601
570602static WRITE8_HANDLER( pc_dma_write_byte )
571603{
572   offs_t page_offset = (((offs_t) dma_offset[0][dma_channel]) << 16)
604   pcxt_state *state = space->machine->driver_data<pcxt_state>();
605   offs_t page_offset = (((offs_t) state->dma_offset[0][state->dma_channel]) << 16)
573606      & 0xFF0000;
574607
575608   space->write_byte(page_offset + offset, data);
r10886r10887
577610
578611static READ8_HANDLER(dma_page_select_r)
579612{
580   UINT8 data = at_pages[offset % 0x10];
613   pcxt_state *state = space->machine->driver_data<pcxt_state>();
614   UINT8 data = state->at_pages[offset % 0x10];
581615
582616   switch(offset % 8) {
583617   case 1:
584      data = dma_offset[(offset / 8) & 1][2];
618      data = state->dma_offset[(offset / 8) & 1][2];
585619      break;
586620   case 2:
587      data = dma_offset[(offset / 8) & 1][3];
621      data = state->dma_offset[(offset / 8) & 1][3];
588622      break;
589623   case 3:
590      data = dma_offset[(offset / 8) & 1][1];
624      data = state->dma_offset[(offset / 8) & 1][1];
591625      break;
592626   case 7:
593      data = dma_offset[(offset / 8) & 1][0];
627      data = state->dma_offset[(offset / 8) & 1][0];
594628      break;
595629   }
596630   return data;
r10886r10887
599633
600634static WRITE8_HANDLER(dma_page_select_w)
601635{
602   at_pages[offset % 0x10] = data;
636   pcxt_state *state = space->machine->driver_data<pcxt_state>();
637   state->at_pages[offset % 0x10] = data;
603638
604639   switch(offset % 8) {
605640   case 1:
606      dma_offset[(offset / 8) & 1][2] = data;
641      state->dma_offset[(offset / 8) & 1][2] = data;
607642      break;
608643   case 2:
609      dma_offset[(offset / 8) & 1][3] = data;
644      state->dma_offset[(offset / 8) & 1][3] = data;
610645      break;
611646   case 3:
612      dma_offset[(offset / 8) & 1][1] = data;
647      state->dma_offset[(offset / 8) & 1][1] = data;
613648      break;
614649   case 7:
615      dma_offset[(offset / 8) & 1][0] = data;
650      state->dma_offset[(offset / 8) & 1][0] = data;
616651      break;
617652   }
618653}
619654
620655static void set_dma_channel(device_t *device, int channel, int state)
621656{
622   if (!state) dma_channel = channel;
657   pcxt_state *drvstate = device->machine->driver_data<pcxt_state>();
658   if (!state) drvstate->dma_channel = channel;
623659}
624660
625661static WRITE_LINE_DEVICE_HANDLER( pc_dack0_w ) { set_dma_channel(device, 0, state); }
r10886r10887
659695
660696static IRQ_CALLBACK(irq_callback)
661697{
698   pcxt_state *state = device->machine->driver_data<pcxt_state>();
662699   int r = 0;
663   r = pic8259_acknowledge(filetto_devices.pic8259_2);
700   r = pic8259_acknowledge(state->pic8259_2);
664701   if (r==0)
665702   {
666      r = pic8259_acknowledge(filetto_devices.pic8259_1);
703      r = pic8259_acknowledge(state->pic8259_1);
667704   }
668705   return r;
669706}
670707
671708static ADDRESS_MAP_START( filetto_map, ADDRESS_SPACE_PROGRAM, 8 )
672709   AM_RANGE(0x00000, 0x003ff) AM_RAM //irq vectors
673   AM_RANGE(0x00400, 0x007ff) AM_RAM AM_BASE(&work_ram)
710   AM_RANGE(0x00400, 0x007ff) AM_RAM AM_BASE_MEMBER(pcxt_state, work_ram)
674711   AM_RANGE(0x00800, 0x9ffff) AM_RAM //work RAM 640KB
675   AM_RANGE(0xa0000, 0xbffff) AM_RAM_WRITE(vga_vram_w) AM_BASE(&vga_vram)//VGA RAM
712   AM_RANGE(0xa0000, 0xbffff) AM_RAM_WRITE(vga_vram_w) AM_BASE_MEMBER(pcxt_state, vga_vram)//VGA RAM
676713   AM_RANGE(0xc0000, 0xcffff) AM_ROMBANK("bank1")
677714   AM_RANGE(0xf0000, 0xfffff) AM_ROM
678715ADDRESS_MAP_END
r10886r10887
697734   AM_RANGE(0x03bc, 0x03bf) AM_RAM //printer port
698735   AM_RANGE(0x03b4, 0x03b5) AM_READWRITE(vga_regs_r,vga_regs_w) //various VGA/CGA/EGA regs
699736   AM_RANGE(0x03d4, 0x03d5) AM_READWRITE(vga_regs_r,vga_regs_w) //mirror of above
700   AM_RANGE(0x03d8, 0x03d9) AM_RAM AM_BASE(&vga_mode)
737   AM_RANGE(0x03d8, 0x03d9) AM_RAM AM_BASE_MEMBER(pcxt_state, vga_mode)
701738   AM_RANGE(0x03ba, 0x03bb) AM_READ(vga_hvretrace_r)//Controls H-Blank/V-Blank
702739   AM_RANGE(0x03da, 0x03db) AM_READ(vga_hvretrace_r)//mirror of above
703740   AM_RANGE(0x03f2, 0x03f2) AM_WRITE(drive_selection_w)
r10886r10887
723760//  AM_RANGE(0x0310, 0x0311) AM_READWRITE(disk_iobank_r,disk_iobank_w) //Prototyping card
724761//  AM_RANGE(0x0312, 0x0312) AM_READ_PORT("IN0") //Prototyping card,read only
725762   AM_RANGE(0x0378, 0x037f) AM_RAM //printer (parallel) port
726   AM_RANGE(0x03c0, 0x03c0) AM_RAM AM_BASE(&vga_bg_bank)
763   AM_RANGE(0x03c0, 0x03c0) AM_RAM AM_BASE_MEMBER(pcxt_state, vga_bg_bank)
727764   AM_RANGE(0x03c8, 0x03c8) AM_READ_PORT("IN0")
728765   AM_RANGE(0x03c9, 0x03c9) AM_READ_PORT("IN1")
729766//  AM_RANGE(0x03ce, 0x03ce) AM_READ_PORT("IN1")
730767   AM_RANGE(0x03bc, 0x03bf) AM_RAM //printer port
731768   AM_RANGE(0x03b4, 0x03b5) AM_READWRITE(vga_regs_r,vga_regs_w) //various VGA/CGA/EGA regs
732769   AM_RANGE(0x03d4, 0x03d5) AM_READWRITE(vga_regs_r,vga_regs_w) //mirror of above
733   AM_RANGE(0x03d8, 0x03d9) AM_RAM AM_BASE(&vga_mode)
770   AM_RANGE(0x03d8, 0x03d9) AM_RAM AM_BASE_MEMBER(pcxt_state, vga_mode)
734771   AM_RANGE(0x03ba, 0x03bb) AM_READ(vga_hvretrace_r)//Controls H-Blank/V-Blank
735772   AM_RANGE(0x03da, 0x03db) AM_READ(vga_hvretrace_r)//mirror of above
736773   AM_RANGE(0x03f2, 0x03f2) AM_WRITE(drive_selection_w)
r10886r10887
906943
907944static MACHINE_RESET( filetto )
908945{
909   bank = -1;
910   lastvalue = -1;
911   hv_blank = 0;
946   pcxt_state *state = machine->driver_data<pcxt_state>();
947   state->bank = -1;
948   state->lastvalue = -1;
949   state->hv_blank = 0;
912950   cpu_set_irq_callback(machine->device("maincpu"), irq_callback);
913   filetto_devices.pit8253 = machine->device( "pit8253" );
914   filetto_devices.pic8259_1 = machine->device( "pic8259_1" );
915   filetto_devices.pic8259_2 = machine->device( "pic8259_2" );
916   filetto_devices.dma8237_1 = machine->device( "dma8237_1" );
917   filetto_devices.dma8237_2 = machine->device( "dma8237_2" );
951   state->pit8253 = machine->device( "pit8253" );
952   state->pic8259_1 = machine->device( "pic8259_1" );
953   state->pic8259_2 = machine->device( "pic8259_2" );
954   state->dma8237_1 = machine->device( "dma8237_1" );
955   state->dma8237_2 = machine->device( "dma8237_2" );
918956}
919957
920static MACHINE_CONFIG_START( filetto, driver_device )
958static MACHINE_CONFIG_START( filetto, pcxt_state )
921959   MCFG_CPU_ADD("maincpu", I8088, 8000000) //or regular PC-XT 14318180/3 clock?
922960   MCFG_CPU_PROGRAM_MAP(filetto_map)
923961   MCFG_CPU_IO_MAP(filetto_io)
r10886r10887
9641002   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.33)
9651003MACHINE_CONFIG_END
9661004
967static MACHINE_CONFIG_START( tetriskr, driver_device )
1005static MACHINE_CONFIG_START( tetriskr, pcxt_state )
9681006   MCFG_CPU_ADD("maincpu", I8088, 14318180/3)
9691007   MCFG_CPU_PROGRAM_MAP(filetto_map)
9701008   MCFG_CPU_IO_MAP(tetriskr_io)
src/mame/drivers/dmndrby.c
r10886r10887
5555#include "machine/nvram.h"
5656#include "video/resnet.h"
5757
58static UINT8* dderby_vidchars;
59static UINT8* scroll_ram;
60static UINT8* dderby_vidattribs;
61static UINT8* sprite_ram;
62static UINT8 *racetrack_tilemap_rom;
63static tilemap_t *racetrack_tilemap;
6458
59class dmndrby_state : public driver_device
60{
61public:
62   dmndrby_state(running_machine &machine, const driver_device_config_base &config)
63      : driver_device(machine, config) { }
64
65   UINT8* dderby_vidchars;
66   UINT8* scroll_ram;
67   UINT8* dderby_vidattribs;
68   UINT8* sprite_ram;
69   UINT8 *racetrack_tilemap_rom;
70   tilemap_t *racetrack_tilemap;
71   UINT8 io_port[8];
72   int bg;
73};
74
75
6576static WRITE8_HANDLER( dderby_sound_w )
6677{
6778   soundlatch_w(space,0,data);
6879   cputag_set_input_line(space->machine, "audiocpu", 0, HOLD_LINE);
6980}
7081
71static UINT8 io_port[8];
7282
7383static READ8_HANDLER( input_r )
7484{
r10886r10887
8999
90100static WRITE8_HANDLER( output_w )
91101{
102   dmndrby_state *state = space->machine->driver_data<dmndrby_state>();
92103   /*
93104    ---- x--- refill meter [4]
94105    ---- x--- token out meter [5]
r10886r10887
100111    ---- --x- coin lockout [0-3]
101112    ---- ---x lamp [0-6]
102113    */
103   io_port[offset] = data;
104//  popmessage("%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|",io_port[0],io_port[1],io_port[2],io_port[3],io_port[4],io_port[5],io_port[6],io_port[7]);
114   state->io_port[offset] = data;
115//  popmessage("%02x|%02x|%02x|%02x|%02x|%02x|%02x|%02x|",state->io_port[0],state->io_port[1],state->io_port[2],state->io_port[3],state->io_port[4],state->io_port[5],state->io_port[6],state->io_port[7]);
105116}
106117
107118static ADDRESS_MAP_START( memmap, ADDRESS_SPACE_PROGRAM, 8 )
r10886r10887
115126   AM_RANGE(0xca01, 0xca01) AM_WRITENOP //watchdog
116127   AM_RANGE(0xca02, 0xca02) AM_RAM_WRITE(dderby_sound_w)
117128   AM_RANGE(0xca03, 0xca03) AM_WRITENOP//(timer_irq_w) //???
118   AM_RANGE(0xcc00, 0xcc05) AM_RAM AM_BASE(&scroll_ram)
119   AM_RANGE(0xce08, 0xce1f) AM_RAM AM_BASE(&sprite_ram) // horse sprites
120   AM_RANGE(0xd000, 0xd3ff) AM_RAM AM_BASE(&dderby_vidchars) // char ram
121   AM_RANGE(0xd400, 0xd7ff) AM_RAM AM_BASE(&dderby_vidattribs) // colours/ attrib ram
129   AM_RANGE(0xcc00, 0xcc05) AM_RAM AM_BASE_MEMBER(dmndrby_state, scroll_ram)
130   AM_RANGE(0xce08, 0xce1f) AM_RAM AM_BASE_MEMBER(dmndrby_state, sprite_ram) // horse sprites
131   AM_RANGE(0xd000, 0xd3ff) AM_RAM AM_BASE_MEMBER(dmndrby_state, dderby_vidchars) // char ram
132   AM_RANGE(0xd400, 0xd7ff) AM_RAM AM_BASE_MEMBER(dmndrby_state, dderby_vidattribs) // colours/ attrib ram
122133ADDRESS_MAP_END
123134
124135static ADDRESS_MAP_START( dderby_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
r10886r10887
302313
303314static TILE_GET_INFO( get_dmndrby_tile_info )
304315{
305   int code = racetrack_tilemap_rom[tile_index];
306   int attr = racetrack_tilemap_rom[tile_index+0x2000];
316   dmndrby_state *state = machine->driver_data<dmndrby_state>();
317   int code = state->racetrack_tilemap_rom[tile_index];
318   int attr = state->racetrack_tilemap_rom[tile_index+0x2000];
307319
308320   int col = attr&0x1f;
309321   int flipx = (attr&0x40)>>6;
r10886r10887
319331
320332static VIDEO_START(dderby)
321333{
322   racetrack_tilemap_rom = machine->region("user1")->base();
323   racetrack_tilemap = tilemap_create(machine,get_dmndrby_tile_info,tilemap_scan_rows,16,16, 16, 512);
324   tilemap_mark_all_tiles_dirty(racetrack_tilemap);
334   dmndrby_state *state = machine->driver_data<dmndrby_state>();
335   state->racetrack_tilemap_rom = machine->region("user1")->base();
336   state->racetrack_tilemap = tilemap_create(machine,get_dmndrby_tile_info,tilemap_scan_rows,16,16, 16, 512);
337   tilemap_mark_all_tiles_dirty(state->racetrack_tilemap);
325338
326339}
327340
328341static SCREEN_UPDATE(dderby)
329342{
343   dmndrby_state *state = screen->machine->driver_data<dmndrby_state>();
330344   int x,y,count;
331345   int off,scrolly;
332   static int bg;
333346   const gfx_element *gfx = screen->machine->gfx[0];
334347   const gfx_element *sprites = screen->machine->gfx[1];
335348   const gfx_element *track = screen->machine->gfx[2];
r10886r10887
343356can we draw it with the tilemap? maybe not, the layout is a litle strange
344357
345358*/
346//  base = scroll_ram[0];
359//  base = state->scroll_ram[0];
347360
348   off=0x1900-(bg*0x100)+(scroll_ram[1])*0x100;
349   scrolly = 0xff-(scroll_ram[0]);
350   if(scroll_ram[1]==0xff) off=0x1800;
361   off=0x1900-(state->bg*0x100)+(state->scroll_ram[1])*0x100;
362   scrolly = 0xff-(state->scroll_ram[0]);
363   if(state->scroll_ram[1]==0xff) off=0x1800;
351364   for(x=0;x<16;x++) {
352365      for(y=0;y<16;y++) {
353         int chr = racetrack_tilemap_rom[off];
354         int col = racetrack_tilemap_rom[off+0x2000]&0x1f;
355         int flipx = racetrack_tilemap_rom[off+0x2000]&0x40;
366         int chr = state->racetrack_tilemap_rom[off];
367         int col = state->racetrack_tilemap_rom[off+0x2000]&0x1f;
368         int flipx = state->racetrack_tilemap_rom[off+0x2000]&0x40;
356369         drawgfx_opaque(bitmap,cliprect,track,chr,col,flipx,0,y*16+scrolly,x*16);
357370         // draw another bit of track
358371         // a rubbish way of doing it
359         chr = racetrack_tilemap_rom[off-0x100];
360         col = racetrack_tilemap_rom[off+0x1f00]&0x1f;
361         flipx = racetrack_tilemap_rom[off+0x1f00]&0x40;
372         chr = state->racetrack_tilemap_rom[off-0x100];
373         col = state->racetrack_tilemap_rom[off+0x1f00]&0x1f;
374         flipx = state->racetrack_tilemap_rom[off+0x1f00]&0x40;
362375         drawgfx_opaque(bitmap,cliprect,track,chr,col,flipx,0,y*16-256+scrolly,x*16);
363376         off++;
364377      }
r10886r10887
379392      int a=0;
380393      int b=0;
381394      int base = count*4;
382      int sprx=sprite_ram[base+3];
383      int spry=sprite_ram[base+2];
384      //sprite_ram[base+1];
385      int col = (sprite_ram[base+1]&0x1f);
386      int anim = (sprite_ram[base]&0x3)*0x40; // animation frame - probably wrong but seems right
387      int horse = (sprite_ram[base+1]&0x7)*8+7;  // horse label from 1 - 6
395      int sprx=state->sprite_ram[base+3];
396      int spry=state->sprite_ram[base+2];
397      //state->sprite_ram[base+1];
398      int col = (state->sprite_ram[base+1]&0x1f);
399      int anim = (state->sprite_ram[base]&0x3)*0x40; // animation frame - probably wrong but seems right
400      int horse = (state->sprite_ram[base+1]&0x7)*8+7;  // horse label from 1 - 6
388401
389402      for (a=0;a<8 ;a++)
390403      {
r10886r10887
407420      for(x=0;x<32;x++)
408421      {
409422         int tileno,bank,color;
410         tileno=dderby_vidchars[count];
411         bank=(dderby_vidattribs[count]&0x20)>>5;
423         tileno=state->dderby_vidchars[count];
424         bank=(state->dderby_vidattribs[count]&0x20)>>5;
412425         tileno|=(bank<<8);
413         color=((dderby_vidattribs[count])&0x1f);
426         color=((state->dderby_vidattribs[count])&0x1f);
414427
415428         drawgfx_transpen(bitmap,cliprect,gfx,tileno,color,0,0,x*8,y*8,(tileno == 0x38) ? 0 : -1);
416429
r10886r10887
487500   cputag_set_input_line_and_vector(device->machine, "maincpu", 0, HOLD_LINE, 0xcf); /* RST 08h */
488501}
489502
490static MACHINE_CONFIG_START( dderby, driver_device )
503static MACHINE_CONFIG_START( dderby, dmndrby_state )
491504   /* basic machine hardware */
492505   MCFG_CPU_ADD("maincpu", Z80,4000000)       /* ? MHz */
493506   MCFG_CPU_PROGRAM_MAP(memmap)
src/mame/drivers/roul.c
r10886r10887
6666#include "roul.lh"
6767#include "machine/nvram.h"
6868
69
70class roul_state : public driver_device
71{
72public:
73   roul_state(running_machine &machine, const driver_device_config_base &config)
74      : driver_device(machine, config) { }
75
76   UINT8 reg[0x10];
77   UINT8 *videobuf;
78   UINT8 lamp_old;
79};
80
81
6982#define VIDEOBUF_SIZE 256*256
7083
71static UINT8 reg[0x10];
72static UINT8 *videobuf;
7384
74static UINT8 lamp_old = 0;
75
7685static PALETTE_INIT( roul )
7786{
7887   int bit6, bit7, bit0, bit1, r, g, b;
r10886r10887
112121
113122static WRITE8_HANDLER( blitter_cmd_w )
114123{
115   reg[offset] = data;
124   roul_state *state = space->machine->driver_data<roul_state>();
125   state->reg[offset] = data;
116126   if (offset==2)
117127   {
118128      int i,j;
119      int width   = reg[2];
120      int y      = reg[0];
121      int x      = reg[1];
122      int color   = reg[3] & 0x0f;
129      int width   = state->reg[2];
130      int y      = state->reg[0];
131      int x      = state->reg[1];
132      int color   = state->reg[3] & 0x0f;
123133      int xdirection = 1, ydirection = 1;
124134
125      if (reg[3] & 0x10) ydirection = -1;
126      if (reg[3] & 0x20) xdirection = -1;
135      if (state->reg[3] & 0x10) ydirection = -1;
136      if (state->reg[3] & 0x20) xdirection = -1;
127137
128138      if (width == 0x00) width = 0x100;
129139
130      switch(reg[3] & 0xc0)
140      switch(state->reg[3] & 0xc0)
131141      {
132         case 0x00: // reg[4] used?
142         case 0x00: // state->reg[4] used?
133143            for (i = - width / 2; i < width / 2; i++)
134144               for (j = - width / 2; j < width / 2; j++)
135                  videobuf[(y + j) * 256 + x + i] = color;
136            logerror("Blitter command 0 : [%02x][%02x][%02x][%02x][%02x]\n",reg[0],reg[1],reg[2],reg[3],reg[4]);
145                  state->videobuf[(y + j) * 256 + x + i] = color;
146            logerror("Blitter command 0 : [%02x][%02x][%02x][%02x][%02x]\n",state->reg[0],state->reg[1],state->reg[2],state->reg[3],state->reg[4]);
137147            break;
138         case 0x40: // vertical line - reg[4] not used
148         case 0x40: // vertical line - state->reg[4] not used
139149            for (i = 0; i < width; i++ )
140               videobuf[(y + i * ydirection) * 256 + x] = color;
150               state->videobuf[(y + i * ydirection) * 256 + x] = color;
141151            break;
142         case 0x80: // horizontal line - reg[4] not used
152         case 0x80: // horizontal line - state->reg[4] not used
143153            for (i = 0; i < width; i++ )
144               videobuf[y * 256 + x + i * xdirection] = color;
154               state->videobuf[y * 256 + x + i * xdirection] = color;
145155            break;
146         case 0xc0: // diagonal line - reg[4] not used
156         case 0xc0: // diagonal line - state->reg[4] not used
147157            for (i = 0; i < width; i++ )
148               videobuf[(y + i * ydirection) * 256 + x + i * xdirection] = color;
158               state->videobuf[(y + i * ydirection) * 256 + x + i * xdirection] = color;
149159      }
150160   }
151161
r10886r10887
159169
160170static WRITE8_HANDLER( ball_w )
161171{
172   roul_state *state = space->machine->driver_data<roul_state>();
162173   int lamp = data;
163174
164175   output_set_lamp_value(data, 1);
165   output_set_lamp_value(lamp_old, 0);
166   lamp_old = lamp;
176   output_set_lamp_value(state->lamp_old, 0);
177   state->lamp_old = lamp;
167178}
168179
169180static ADDRESS_MAP_START( roul_map, ADDRESS_SPACE_PROGRAM, 8 )
r10886r10887
195206
196207static VIDEO_START(roul)
197208{
198   videobuf = auto_alloc_array_clear(machine, UINT8, VIDEOBUF_SIZE);
209   roul_state *state = machine->driver_data<roul_state>();
210   state->videobuf = auto_alloc_array_clear(machine, UINT8, VIDEOBUF_SIZE);
199211}
200212
201213static SCREEN_UPDATE(roul)
202214{
215   roul_state *state = screen->machine->driver_data<roul_state>();
203216   int i,j;
204217   for (i = 0; i < 256; i++)
205218      for (j = 0; j < 256; j++)
206         *BITMAP_ADDR16(bitmap, j, i) = videobuf[j * 256 + 255 - i];
219         *BITMAP_ADDR16(bitmap, j, i) = state->videobuf[j * 256 + 255 - i];
207220   return 0;
208221}
209222
r10886r10887
257270   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
258271INPUT_PORTS_END
259272
260static MACHINE_CONFIG_START( roul, driver_device )
273static MACHINE_CONFIG_START( roul, roul_state )
261274   /* basic machine hardware */
262275   MCFG_CPU_ADD("maincpu", Z80, 4000000)
263276   MCFG_CPU_PROGRAM_MAP(roul_map)
src/mame/drivers/vicdual.c
r10886r10887
34443444
34453445GAMEL(1977, depthch,  0,        depthch,  depthch,  0, ROT0,   "Gremlin", "Depthcharge", GAME_IMPERFECT_SOUND, layout_depthch )
34463446GAMEL(1977, depthcho, depthch,  depthch,  depthch,  0, ROT0,   "Gremlin", "Depthcharge (older)", GAME_IMPERFECT_SOUND, layout_depthch )
3447GAME( 1977, subhunt,  depthch,  depthch,  depthch,  0, ROT0,   "Gremlin (Taito license)", "Sub Hunter", GAME_IMPERFECT_SOUND )
3447GAMEL(1977, subhunt,  depthch,  depthch,  depthch,  0, ROT0,   "Gremlin (Taito license)", "Sub Hunter", GAME_IMPERFECT_SOUND, layout_depthch )
34483448GAME( 1977, safari,   0,        safari,   safari,   0, ROT0,   "Gremlin", "Safari (set 1)", GAME_NO_SOUND )
34493449GAME( 1977, safaria,  safari,   safari,   safari,   0, ROT0,   "Gremlin", "Safari (set 2, bootleg?)", GAME_NO_SOUND ) // on a bootleg board, but seems a different code revision too
34503450GAME( 1978, frogs,    0,        frogs,    frogs,    0, ROT0,   "Gremlin", "Frogs", GAME_IMPERFECT_SOUND )
src/mame/drivers/magicfly.c
r10886r10887
402402#include "machine/nvram.h"
403403
404404
405class magicfly_state : public driver_device
406{
407public:
408   magicfly_state(running_machine &machine, const driver_device_config_base &config)
409      : driver_device(machine, config) { }
410
411   UINT8 *videoram;
412   UINT8 *colorram;
413   tilemap_t *bg_tilemap;
414   int input_selector;
415};
416
417
405418/*************************
406419*     Video Hardware     *
407420*************************/
408421
409static UINT8 *videoram;
410static UINT8 *colorram;
411static tilemap_t *bg_tilemap;
412422
413423static WRITE8_HANDLER( magicfly_videoram_w )
414424{
415   videoram[offset] = data;
416   tilemap_mark_tile_dirty(bg_tilemap, offset);
425   magicfly_state *state = space->machine->driver_data<magicfly_state>();
426   state->videoram[offset] = data;
427   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
417428}
418429
419430static WRITE8_HANDLER( magicfly_colorram_w )
420431{
421   colorram[offset] = data;
422   tilemap_mark_tile_dirty(bg_tilemap, offset);
432   magicfly_state *state = space->machine->driver_data<magicfly_state>();
433   state->colorram[offset] = data;
434   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
423435}
424436
425437static TILE_GET_INFO( get_magicfly_tile_info )
426438{
439   magicfly_state *state = machine->driver_data<magicfly_state>();
427440/*  - bits -
428441    7654 3210
429442    ---- -xxx   Tiles color.
r10886r10887
433446    x--- ----   Mirrored from bit 3. The code check this one to boot the game.
434447
435448*/
436   int attr = colorram[tile_index];
437   int code = videoram[tile_index];
449   int attr = state->colorram[tile_index];
450   int code = state->videoram[tile_index];
438451   int bank = (attr & 0x10) >> 4;   /* bit 4 switch the gfx banks */
439452   int color = attr & 0x07;         /* bits 0-2 for color */
440453
441454    /* Seems that bit 7 is mirrored from bit 3 to have a normal boot */
442455    /* Boot only check the first color RAM offset */
443456
444   colorram[0] = colorram[0] | ((colorram[0] & 0x08) << 4);   /* only for 1st offset */
445   //colorram[tile_index] = attr | ((attr & 0x08) << 4);         /* for the whole color RAM */
457   state->colorram[0] = state->colorram[0] | ((state->colorram[0] & 0x08) << 4);   /* only for 1st offset */
458   //state->colorram[tile_index] = attr | ((attr & 0x08) << 4);         /* for the whole color RAM */
446459
447460   SET_TILE_INFO(bank, code, color, 0);
448461}
449462
450463static VIDEO_START(magicfly)
451464{
452   bg_tilemap = tilemap_create(machine, get_magicfly_tile_info, tilemap_scan_rows, 8, 8, 32, 29);
465   magicfly_state *state = machine->driver_data<magicfly_state>();
466   state->bg_tilemap = tilemap_create(machine, get_magicfly_tile_info, tilemap_scan_rows, 8, 8, 32, 29);
453467}
454468
455469static TILE_GET_INFO( get_7mezzo_tile_info )
456470{
471   magicfly_state *state = machine->driver_data<magicfly_state>();
457472/*  - bits -
458473    7654 3210
459474    ---- -xxx   Tiles color.
r10886r10887
463478    x--- ----   Mirrored from bit 2. The code check this one to boot the game.
464479
465480*/
466   int attr = colorram[tile_index];
467   int code = videoram[tile_index];
481   int attr = state->colorram[tile_index];
482   int code = state->videoram[tile_index];
468483   int bank = (attr & 0x10) >> 4;    /* bit 4 switch the gfx banks */
469484   int color = attr & 0x07;          /* bits 0-2 for color */
470485
471486    /* Seems that bit 7 is mirrored from bit 2 to have a normal boot */
472487    /* Boot only check the first color RAM offset */
473488
474   colorram[0] = colorram[0] | ((colorram[0] & 0x04) << 5);   /* only for 1st offset */
475   //colorram[tile_index] = attr | ((attr & 0x04) << 5);         /* for the whole color RAM */
489   state->colorram[0] = state->colorram[0] | ((state->colorram[0] & 0x04) << 5);   /* only for 1st offset */
490   //state->colorram[tile_index] = attr | ((attr & 0x04) << 5);         /* for the whole color RAM */
476491
477492   SET_TILE_INFO(bank, code, color, 0);
478493}
479494
480495static VIDEO_START( 7mezzo )
481496{
482   bg_tilemap = tilemap_create(machine, get_7mezzo_tile_info, tilemap_scan_rows, 8, 8, 32, 29);
497   magicfly_state *state = machine->driver_data<magicfly_state>();
498   state->bg_tilemap = tilemap_create(machine, get_7mezzo_tile_info, tilemap_scan_rows, 8, 8, 32, 29);
483499}
484500
485501static SCREEN_UPDATE( magicfly )
486502{
487   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
503   magicfly_state *state = screen->machine->driver_data<magicfly_state>();
504   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
488505   return 0;
489506}
490507
r10886r10887
515532*         R/W Handlers        *
516533******************************/
517534
518static int input_selector = 0;
519535
520536static READ8_HANDLER( mux_port_r )
521537{
522   switch( input_selector )
538   magicfly_state *state = space->machine->driver_data<magicfly_state>();
539   switch( state->input_selector )
523540   {
524541      case 0x01: return input_port_read(space->machine, "IN0-0");
525542      case 0x02: return input_port_read(space->machine, "IN0-1");
r10886r10887
532549
533550static WRITE8_HANDLER( mux_port_w )
534551{
552   magicfly_state *state = space->machine->driver_data<magicfly_state>();
535553/*  - bits -
536554    7654 3210
537555    ---- xxxx   Input selector.
r10886r10887
541559    x--- ----   Sound DAC.
542560
543561*/
544   input_selector = data & 0x0f;   /* Input Selector */
562   state->input_selector = data & 0x0f;   /* Input Selector */
545563
546564   dac_data_w(space->machine->device("dac"), data & 0x80);      /* Sound DAC */
547565
r10886r10887
559577   AM_RANGE(0x0000, 0x07ff) AM_RAM AM_SHARE("nvram")    /* MK48Z02B NVRAM */
560578   AM_RANGE(0x0800, 0x0800) AM_DEVWRITE("crtc", mc6845_address_w)
561579   AM_RANGE(0x0801, 0x0801) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
562   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(magicfly_videoram_w) AM_BASE(&videoram)   /* HM6116LP #1 (2K x 8) RAM (only 1st half used) */
563   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(magicfly_colorram_w) AM_BASE(&colorram)   /* HM6116LP #2 (2K x 8) RAM (only 1st half used) */
580   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(magicfly_videoram_w) AM_BASE_MEMBER(magicfly_state, videoram)   /* HM6116LP #1 (2K x 8) RAM (only 1st half used) */
581   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(magicfly_colorram_w) AM_BASE_MEMBER(magicfly_state, colorram)   /* HM6116LP #2 (2K x 8) RAM (only 1st half used) */
564582   AM_RANGE(0x2800, 0x2800) AM_READ(mux_port_r)   /* multiplexed input port */
565583   AM_RANGE(0x3000, 0x3000) AM_WRITE(mux_port_w)   /* output port */
566584   AM_RANGE(0xc000, 0xffff) AM_ROM               /* ROM space */
r10886r10887
756774*    Machine Drivers     *
757775*************************/
758776
759static MACHINE_CONFIG_START( magicfly, driver_device )
777static MACHINE_CONFIG_START( magicfly, magicfly_state )
760778
761779   /* basic machine hardware */
762780   MCFG_CPU_ADD("maincpu", M6502, MASTER_CLOCK/12)   /* guess */
src/mame/drivers/gal3.c
r10886r10887
132132#include "sound/c140.h"
133133#include "rendlay.h"
134134
135static UINT32 *mpSharedRAM0;
136//static UINT32 *mpSharedRAM1;
137static UINT32 *gal3_nvmem;
138static size_t gal3_nvmem_size;
139static UINT16 namcos21_video_enable;
140static UINT16 *rsoSharedRAM;
141135
142static UINT32 led_mst;   //Diagnostic LEDs
143static UINT32 led_slv;
136class gal3_state : public driver_device
137{
138public:
139   gal3_state(running_machine &machine, const driver_device_config_base &config)
140      : driver_device(machine, config) { }
144141
142   UINT32 *mpSharedRAM0;
143   //UINT32 *mpSharedRAM1;
144   UINT32 *nvmem;
145   size_t nvmem_size;
146   UINT16 namcos21_video_enable;
147   UINT16 *rsoSharedRAM;
148   UINT32 led_mst;
149   UINT32 led_slv;
150};
151
152
145153static VIDEO_START(gal3)
146154{
147155   namco_obj_init(machine,
r10886r10887
172180
173181static SCREEN_UPDATE(gal3)
174182{
183   gal3_state *state = screen->machine->driver_data<gal3_state>();
175184   int i;
176185   char mst[18], slv[18];
177186   static int pivot = 15;
r10886r10887
196205
197206   // CPU Diag LEDs
198207   mst[17]='\0', slv[17]='\0';
199/// printf("mst=0x%x\tslv=0x%x\n", led_mst, led_slv);
208/// printf("mst=0x%x\tslv=0x%x\n", state->led_mst, state->led_slv);
200209   for(i=16;i<32;i++)
201210   {
202211      int t;
r10886r10887
206215         t=i+1;
207216      mst[8]=' '; slv[8]=' ';
208217
209      if(led_mst&(1<<i))
218      if(state->led_mst&(1<<i))
210219         mst[t-16]='*';
211220      else
212221         mst[t-16]='O';
213222
214      if(led_slv&(1<<i))
223      if(state->led_slv&(1<<i))
215224         slv[t-16]='*';
216225      else
217226         slv[t-16]='O';
r10886r10887
225234
226235static NVRAM_HANDLER( gal3 )
227236{
237   gal3_state *state = machine->driver_data<gal3_state>();
228238   int i;
229239   UINT8 data[4];
230240   if( read_or_write )
231241   {
232      for( i=0; i<gal3_nvmem_size/4; i++ )
242      for( i=0; i<state->nvmem_size/4; i++ )
233243      {
234         UINT32 dword = gal3_nvmem[i];
244         UINT32 dword = state->nvmem[i];
235245         data[0] = dword>>24;
236246         data[1] = (dword&0x00ff0000)>>16;
237247         data[2] = (dword&0x0000ff00)>>8;
r10886r10887
243253   {
244254      if( file )
245255      {
246         for( i=0; i<gal3_nvmem_size/4; i++ )
256         for( i=0; i<state->nvmem_size/4; i++ )
247257         {
248258            file->read( data, 4 );
249            gal3_nvmem[i] = (data[0]<<24)|(data[1]<<16)|(data[2]<<8)|data[3];
259            state->nvmem[i] = (data[0]<<24)|(data[1]<<16)|(data[2]<<8)|data[3];
250260         }
251261      }
252262      else
253263      {
254264         /* fill in the default values */
255         memset( gal3_nvmem, 0x00, gal3_nvmem_size );
265         memset( state->nvmem, 0x00, state->nvmem_size );
256266      }
257267   }
258268}
r10886r10887
261271
262272static READ32_HANDLER( shareram0_r )
263273{
264   return mpSharedRAM0[offset];
274   gal3_state *state = space->machine->driver_data<gal3_state>();
275   return state->mpSharedRAM0[offset];
265276}
266277
267278static WRITE32_HANDLER( shareram0_w )
268279{
269   COMBINE_DATA( &mpSharedRAM0[offset] );
280   gal3_state *state = space->machine->driver_data<gal3_state>();
281   COMBINE_DATA( &state->mpSharedRAM0[offset] );
270282}
271/*
283
284#if 0
272285static READ32_HANDLER( shareram1_r )
273286{
274    return mpSharedRAM1[offset];
287   gal3_state *state = space->machine->driver_data<gal3_state>();
288   return state->mpSharedRAM1[offset];
275289}
276290
277291static WRITE32_HANDLER( shareram1_w )
278292{
279    COMBINE_DATA( &mpSharedRAM1[offset] );
280}*/
293   gal3_state *state = space->machine->driver_data<gal3_state>();
294   COMBINE_DATA( &state->mpSharedRAM1[offset] );
295}
296#endif
281297
282298/***************************************************************************************/
283299
284300static READ32_HANDLER( led_mst_r )
285301{
286   return led_mst;
302   gal3_state *state = space->machine->driver_data<gal3_state>();
303   return state->led_mst;
287304}
288305
289306static WRITE32_HANDLER( led_mst_w )
290307{
291   COMBINE_DATA(&led_mst);
308   gal3_state *state = space->machine->driver_data<gal3_state>();
309   COMBINE_DATA(&state->led_mst);
292310}
293311
294312static READ32_HANDLER( led_slv_r )
295313{
296   return led_slv;
314   gal3_state *state = space->machine->driver_data<gal3_state>();
315   return state->led_slv;
297316}
298317
299318static WRITE32_HANDLER( led_slv_w )
300319{
301   COMBINE_DATA(&led_slv);
320   gal3_state *state = space->machine->driver_data<gal3_state>();
321   COMBINE_DATA(&state->led_slv);
302322}
303323
304324/* palette memory handlers */
r10886r10887
321341
322342static READ32_HANDLER(namcos21_video_enable_r)
323343{
324   return namcos21_video_enable<<16;
344   gal3_state *state = space->machine->driver_data<gal3_state>();
345   return state->namcos21_video_enable<<16;
325346}
326347
327348static WRITE32_HANDLER(namcos21_video_enable_w)
328349{
350   gal3_state *state = space->machine->driver_data<gal3_state>();
329351   UINT32 v;
330   v = namcos21_video_enable<<16;
352   v = state->namcos21_video_enable<<16;
331353   COMBINE_DATA( &v ); // 0xff53, instead of 0x40 in namcos21
332   namcos21_video_enable = v>>16;
354   state->namcos21_video_enable = v>>16;
333355}
334356
335357static READ32_HANDLER(rso_r)
336358{
359   gal3_state *state = space->machine->driver_data<gal3_state>();
337360   /*store $5555 @$0046, and readback @$0000
338361    read @$0144 and store at A6_21e & A4_5c
339362    Check @$009a==1 to start DEMO
340363    HACK*/
341364   offset *= 2;
342   return (rsoSharedRAM[offset]<<16)|rsoSharedRAM[offset+1];
365   return (state->rsoSharedRAM[offset]<<16)|state->rsoSharedRAM[offset+1];
343366}
344367
345368static WRITE32_HANDLER(rso_w)
346369{
370   gal3_state *state = space->machine->driver_data<gal3_state>();
347371   UINT32 v;
348372   offset *= 2;
349   v = (rsoSharedRAM[offset]<<16)|rsoSharedRAM[offset+1];
373   v = (state->rsoSharedRAM[offset]<<16)|state->rsoSharedRAM[offset+1];
350374   COMBINE_DATA( &v );
351   rsoSharedRAM[offset+0] = v>>16;
352   rsoSharedRAM[offset+1] = v&0xffff;
375   state->rsoSharedRAM[offset+0] = v>>16;
376   state->rsoSharedRAM[offset+1] = v&0xffff;
353377}
354378
355379static ADDRESS_MAP_START( cpu_mst_map, ADDRESS_SPACE_PROGRAM, 32 )
356380   AM_RANGE(0x00000000, 0x001fffff) AM_ROM
357   AM_RANGE(0x20000000, 0x20001fff) AM_RAM AM_BASE(&gal3_nvmem) AM_SIZE(&gal3_nvmem_size)   //NVRAM
381   AM_RANGE(0x20000000, 0x20001fff) AM_RAM AM_BASE_MEMBER(gal3_state, nvmem) AM_SIZE_MEMBER(gal3_state, nvmem_size)   //NVRAM
358382/// AM_RANGE(0x40000000, 0x4000ffff) AM_WRITE() //
359383   AM_RANGE(0x44000000, 0x44000003) AM_READ_PORT("DSW_CPU_mst"   )
360384   AM_RANGE(0x44800000, 0x44800003) AM_READ(led_mst_r) AM_WRITE(led_mst_w)   //LEDs
361385   AM_RANGE(0x48000000, 0x48000003) AM_READNOP   //irq1 v-blank ack
362386   AM_RANGE(0x4c000000, 0x4c000003) AM_READNOP   //irq3 ack
363   AM_RANGE(0x60000000, 0x60007fff) AM_READ(shareram0_r) AM_WRITE(shareram0_w) AM_BASE(&mpSharedRAM0)   //CRAM
387   AM_RANGE(0x60000000, 0x60007fff) AM_READ(shareram0_r) AM_WRITE(shareram0_w) AM_BASE_MEMBER(gal3_state, mpSharedRAM0)   //CRAM
364388   AM_RANGE(0x60010000, 0x60017fff) AM_READ(shareram0_r) AM_WRITE(shareram0_w)   //Mirror
365389   AM_RANGE(0x80000000, 0x8007ffff) AM_RAM   //512K Local RAM
366390/// AM_RANGE(0xc0000000, 0xc000000b) AM_WRITENOP    //upload?
r10886r10887
431455   AM_RANGE(0x2c3800, 0x2c3801) AM_RAM //?
432456   AM_RANGE(0x2c4000, 0x2c4001) AM_RAM //?
433457
434   AM_RANGE(0x300000, 0x300fff) AM_RAM AM_BASE(&rsoSharedRAM)   //shared RAM
458   AM_RANGE(0x300000, 0x300fff) AM_RAM AM_BASE_MEMBER(gal3_state, rsoSharedRAM)   //shared RAM
435459
436460   AM_RANGE(0x400000, 0x400017) AM_RAM //MC68681?
437461   AM_RANGE(0x480000, 0x480017) AM_RAM //?
r10886r10887
624648   C140_TYPE_SYSTEM21_B
625649};
626650
627static MACHINE_CONFIG_START( gal3, driver_device )
651static MACHINE_CONFIG_START( gal3, gal3_state )
628652   MCFG_CPU_ADD("cpumst", M68020, 49152000/2)
629653   MCFG_CPU_PROGRAM_MAP(cpu_mst_map)
630654   MCFG_CPU_VBLANK_INT("lscreen", irq1_line_hold)
src/mame/drivers/rgum.c
r10886r10887
1818#include "machine/8255ppi.h"
1919#include "sound/ay8910.h"
2020
21static UINT8 *vram, *cram;
2221
22class rgum_state : public driver_device
23{
24public:
25   rgum_state(running_machine &machine, const driver_device_config_base &config)
26      : driver_device(machine, config) { }
27
28   UINT8 *vram;
29   UINT8 *cram;
30   UINT8 hbeat;
31};
32
33
2334static VIDEO_START(royalgum)
2435{
25
2636}
2737
2838static SCREEN_UPDATE(royalgum)
2939{
40   rgum_state *state = screen->machine->driver_data<rgum_state>();
3041   int x,y,count;
3142   const gfx_element *gfx = screen->machine->gfx[0];
3243
r10886r10887
3647   {
3748      for(x=0;x<66;x++)
3849      {
39         int tile = vram[count] | ((cram[count] & 0xf) <<8);
50         int tile = state->vram[count] | ((state->cram[count] & 0xf) <<8);
4051
4152         drawgfx_opaque(bitmap,cliprect,gfx,tile,0,0,0,x*8,y*8);
4253
r10886r10887
6172
6273   AM_RANGE(0x3000, 0x3003) AM_DEVREADWRITE("ppi8255_0", ppi8255_r, ppi8255_w)
6374
64   AM_RANGE(0x4000, 0x47ff) AM_RAM AM_BASE(&vram)
65   AM_RANGE(0x5000, 0x57ff) AM_RAM AM_BASE(&cram)
75   AM_RANGE(0x4000, 0x47ff) AM_RAM AM_BASE_MEMBER(rgum_state, vram)
76   AM_RANGE(0x5000, 0x57ff) AM_RAM AM_BASE_MEMBER(rgum_state, cram)
6677
6778   AM_RANGE(0x8000, 0xffff) AM_ROM
6879ADDRESS_MAP_END
r10886r10887
7081
7182static CUSTOM_INPUT( rgum_heartbeat_r )
7283{
73   static UINT8 hbeat;
84   rgum_state *state = field->port->machine->driver_data<rgum_state>();
7485
75   hbeat ^= 1;
86   state->hbeat ^= 1;
7687
77   return hbeat;
88   return state->hbeat;
7889}
7990
8091
r10886r10887
249260   DEVCB_NULL
250261};
251262
252static MACHINE_CONFIG_START( rgum, driver_device )
263static MACHINE_CONFIG_START( rgum, rgum_state )
253264   /* basic machine hardware */
254265   MCFG_CPU_ADD("maincpu", M65C02,24000000/16)       /* ? MHz */
255266   MCFG_CPU_PROGRAM_MAP(rgum_map)
src/mame/drivers/naomi.c
r10886r10887
5353837-13544-01
5454171-7772F
5555837-13707 (sticker)
56(C) SEGA 1999
56(C) SEGA 1999
5757|---------------------------------------------------|
5858|    CN1                           CN3              |
5959|PC910  62256   EPF8452AQC160-3                     |
r10886r10887
6161|A179B    315-6188.IC31     3771                3773|
6262|ADM485  BIOS.IC27   5264165            5264165     |
6363|                    5264165  |-----|   5264165     |
64|    CN3                      |POWER|               |
65|                             |VR2  | 33.3333MHZ    |
64|    CN2                      | SH4 |               |
65|                             |     | 33.3333MHZ    |
6666|CN26                         |-----|          27MHZ|
6767|                                         CY2308SC-3|
6868|        KM416S4030      |------|     HY57V161610   |
69|                        | SH4  |     HY57V161610   |
70| C844G        315-6232  |      |             32MHZ |
69|                        | POWER|     HY57V161610   |
70| C844G        315-6232  | VR2  |             32MHZ |
7171|            33.8688MHZ  |------|     HY57V161610   |
7272|                         xMHz        HY57V161610   |
7373|      PCM1725    JP1                    62256      |
r10886r10887
103103      62256           - 32kx8 SRAM
104104      PCM1725         - Burr-Brown PCM1725
105105      xMHz            - Small round XTAL (possibly 32.768kHz for a clock?)
106      SH4             - Hitachi SH4 CPU (BGAxxx, with heatsink and fan)
107      POWERVR2        - POWERVR2 video generator (BGAxxx, with heatsink)
106      SH4             - Hitachi SH4 CPU (BGAxxx, with heatsink)
107      POWERVR2        - POWERVR2 video generator (BGAxxx, with heatsink and fan)
108108
109109
110110Filter Board
src/mame/drivers/asteroid.c
r10886r10887
943943GAME( 1979, asteroid1,asteroid, asteroid, asteroid, 0,        ROT0, "Atari",   "Asteroids (rev 1)",        GAME_SUPPORTS_SAVE )
944944GAME( 1979, asteroidb,asteroid, asteroid, asteroidb,asteroidb,ROT0, "bootleg", "Asteroids (bootleg on Lunar Lander hardware)", GAME_SUPPORTS_SAVE )
945945GAME( 1979, asterock, asteroid, asterock, asterock, asterock, ROT0, "bootleg (Sidam)", "Asterock",         GAME_SUPPORTS_SAVE )
946GAME( 1979, meteorts, asteroid, asteroid, asteroid, 0,        ROT0, "bootleg (VGG)",   "Meteorites",       GAME_SUPPORTS_SAVE )
947GAME( 1980, meteorho, asteroid, asteroid, asteroid, 0,        ROT0, "bootleg (Hoei)",  "Meteor",           GAME_SUPPORTS_SAVE )
946GAME( 1979, meteorts, asteroid, asteroid, asteroid, 0,        ROT0, "bootleg (VGG)",   "Meteorites (bootleg of Asteroids)", GAME_SUPPORTS_SAVE )
947GAME( 1980, meteorho, asteroid, asteroid, asteroid, 0,        ROT0, "bootleg (Hoei)",  "Meteor (bootleg of Asteroids)", GAME_SUPPORTS_SAVE )
948948GAMEL(1980, astdelux, 0,        astdelux, astdelux, 0,        ROT0, "Atari",   "Asteroids Deluxe (rev 3)", GAME_SUPPORTS_SAVE, layout_ho88ffff )
949949GAMEL(1980, astdelux2,astdelux, astdelux, astdelux, 0,        ROT0, "Atari",   "Asteroids Deluxe (rev 2)", GAME_SUPPORTS_SAVE, layout_ho88ffff )
950950GAMEL(1980, astdelux1,astdelux, astdelux, astdelux, 0,        ROT0, "Atari",   "Asteroids Deluxe (rev 1)", GAME_SUPPORTS_SAVE, layout_ho88ffff )
src/mame/drivers/vamphalf.c
r10886r10887
4444#include "sound/2151intf.h"
4545#include "sound/okim6295.h"
4646
47static UINT16 *tiles = NULL, *wram;
48static UINT32 *tiles32 = NULL, *wram32;
49static int flip_bit, flipscreen = 0;
50static int palshift;
5147
52static int semicom_prot_idx;
53static int semicom_prot_which = 0;
54static UINT16 semicom_prot_data[2];
48class vamphalf_state : public driver_device
49{
50public:
51   vamphalf_state(running_machine &machine, const driver_device_config_base &config)
52      : driver_device(machine, config) { }
5553
56static UINT16 finalgdr_backupram_bank;
57static UINT8 *finalgdr_backupram;
54   UINT16 *tiles;
55   UINT16 *wram;
56   UINT32 *tiles32;
57   UINT32 *wram32;
58   int flip_bit;
59   int flipscreen;
60   int palshift;
61   int semicom_prot_idx;
62   int semicom_prot_which;
63   UINT16 semicom_prot_data[2];
64   UINT16 finalgdr_backupram_bank;
65   UINT8 *finalgdr_backupram;
66};
5867
68
5969static READ16_DEVICE_HANDLER( eeprom_r )
6070{
6171   if(offset)
r10886r10887
97107
98108static WRITE16_HANDLER( flipscreen_w )
99109{
110   vamphalf_state *state = space->machine->driver_data<vamphalf_state>();
100111   if(offset)
101112   {
102      flipscreen = data & flip_bit;
113      state->flipscreen = data & state->flip_bit;
103114   }
104115}
105116
106117static WRITE32_HANDLER( flipscreen32_w )
107118{
108   flipscreen = data & flip_bit;
119   vamphalf_state *state = space->machine->driver_data<vamphalf_state>();
120   state->flipscreen = data & state->flip_bit;
109121}
110122
111123static WRITE16_HANDLER( jmpbreak_flipscreen_w )
112124{
113   flipscreen = data & 0x8000;
125   vamphalf_state *state = space->machine->driver_data<vamphalf_state>();
126   state->flipscreen = data & 0x8000;
114127}
115128
116129
r10886r10887
129142
130143static READ32_HANDLER( wyvernwg_prot_r )
131144{
132   semicom_prot_idx--;
133   return (semicom_prot_data[semicom_prot_which] & (1 << semicom_prot_idx)) >> semicom_prot_idx;
145   vamphalf_state *state = space->machine->driver_data<vamphalf_state>();
146   state->semicom_prot_idx--;
147   return (state->semicom_prot_data[state->semicom_prot_which] & (1 << state->semicom_prot_idx)) >> state->semicom_prot_idx;
134148}
135149
136150static WRITE32_HANDLER( wyvernwg_prot_w )
137151{
138   semicom_prot_which = data & 1;
139   semicom_prot_idx = 8;
152   vamphalf_state *state = space->machine->driver_data<vamphalf_state>();
153   state->semicom_prot_which = data & 1;
154   state->semicom_prot_idx = 8;
140155}
141156
142157static READ32_HANDLER( finalgdr_prot_r )
143158{
144   semicom_prot_idx--;
145   return (semicom_prot_data[semicom_prot_which] & (1 << semicom_prot_idx)) ? 0x8000 : 0;
159   vamphalf_state *state = space->machine->driver_data<vamphalf_state>();
160   state->semicom_prot_idx--;
161   return (state->semicom_prot_data[state->semicom_prot_which] & (1 << state->semicom_prot_idx)) ? 0x8000 : 0;
146162}
147163
148164static WRITE32_HANDLER( finalgdr_prot_w )
149165{
166   vamphalf_state *state = space->machine->driver_data<vamphalf_state>();
150167/*
15116841C6
152169967E
r10886r10887
154171F94B
155172*/
156173   if(data == 0x41c6 || data == 0x446b)
157      semicom_prot_which = 0;
174      state->semicom_prot_which = 0;
158175   else
159      semicom_prot_which =  1;
176      state->semicom_prot_which =  1;
160177
161   semicom_prot_idx = 8;
178   state->semicom_prot_idx = 8;
162179}
163180
164181static WRITE32_DEVICE_HANDLER( finalgdr_oki_bank_w )
r10886r10887
168185
169186static WRITE32_HANDLER( finalgdr_backupram_bank_w )
170187{
171   finalgdr_backupram_bank = (data & 0xff000000) >> 24;
188   vamphalf_state *state = space->machine->driver_data<vamphalf_state>();
189   state->finalgdr_backupram_bank = (data & 0xff000000) >> 24;
172190}
173191
174192static READ32_HANDLER( finalgdr_backupram_r )
175193{
176   return finalgdr_backupram[offset + finalgdr_backupram_bank * 0x80] << 24;
194   vamphalf_state *state = space->machine->driver_data<vamphalf_state>();
195   return state->finalgdr_backupram[offset + state->finalgdr_backupram_bank * 0x80] << 24;
177196}
178197
179198static WRITE32_HANDLER( finalgdr_backupram_w )
180199{
181   finalgdr_backupram[offset + finalgdr_backupram_bank * 0x80] = data >> 24;
200   vamphalf_state *state = space->machine->driver_data<vamphalf_state>();
201   state->finalgdr_backupram[offset + state->finalgdr_backupram_bank * 0x80] = data >> 24;
182202}
183203
184204static WRITE32_HANDLER( finalgdr_prize_w )
r10886r10887
206226
207227
208228static ADDRESS_MAP_START( common_map, ADDRESS_SPACE_PROGRAM, 16 )
209   AM_RANGE(0x00000000, 0x001fffff) AM_RAM AM_BASE(&wram)
210   AM_RANGE(0x40000000, 0x4003ffff) AM_RAM AM_BASE(&tiles)
229   AM_RANGE(0x00000000, 0x001fffff) AM_RAM AM_BASE_MEMBER(vamphalf_state, wram)
230   AM_RANGE(0x40000000, 0x4003ffff) AM_RAM AM_BASE_MEMBER(vamphalf_state, tiles)
211231   AM_RANGE(0x80000000, 0x8000ffff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram)
212232   AM_RANGE(0xfff00000, 0xffffffff) AM_ROM AM_REGION("user1",0)
213233ADDRESS_MAP_END
214234
215235static ADDRESS_MAP_START( common_32bit_map, ADDRESS_SPACE_PROGRAM, 32 )
216   AM_RANGE(0x00000000, 0x001fffff) AM_RAM AM_BASE(&wram32)
217   AM_RANGE(0x40000000, 0x4003ffff) AM_RAM AM_BASE(&tiles32)
236   AM_RANGE(0x00000000, 0x001fffff) AM_RAM AM_BASE_MEMBER(vamphalf_state, wram32)
237   AM_RANGE(0x40000000, 0x4003ffff) AM_RAM AM_BASE_MEMBER(vamphalf_state, tiles32)
218238   AM_RANGE(0x80000000, 0x8000ffff) AM_RAM_WRITE(paletteram32_w) AM_BASE_GENERIC(paletteram)
219239   AM_RANGE(0xfff00000, 0xffffffff) AM_ROM AM_REGION("user1",0)
220240ADDRESS_MAP_END
r10886r10887
329349ADDRESS_MAP_END
330350
331351static ADDRESS_MAP_START( aoh_map, ADDRESS_SPACE_PROGRAM, 32 )
332   AM_RANGE(0x00000000, 0x003fffff) AM_RAM AM_BASE(&wram32)
333   AM_RANGE(0x40000000, 0x4003ffff) AM_RAM AM_BASE(&tiles32)
352   AM_RANGE(0x00000000, 0x003fffff) AM_RAM AM_BASE_MEMBER(vamphalf_state, wram32)
353   AM_RANGE(0x40000000, 0x4003ffff) AM_RAM AM_BASE_MEMBER(vamphalf_state, tiles32)
334354   AM_RANGE(0x80000000, 0x8000ffff) AM_RAM_WRITE(paletteram32_w) AM_BASE_GENERIC(paletteram)
335355   AM_RANGE(0x80210000, 0x80210003) AM_READ_PORT("SYSTEM")
336356   AM_RANGE(0x80220000, 0x80220003) AM_READ_PORT("P1_P2")
r10886r10887
367387*/
368388static void draw_sprites(screen_device *screen, bitmap_t *bitmap)
369389{
390   vamphalf_state *state = screen->machine->driver_data<vamphalf_state>();
370391   const gfx_element *gfx = screen->machine->gfx[0];
371392   UINT32 cnt;
372393   int block, offs;
r10886r10887
378399
379400   for (block=0; block<0x8000; block+=0x800)
380401   {
381      if(flipscreen)
402      if(state->flipscreen)
382403      {
383404         clip.min_y = 256 - (16-(block/0x800))*16;
384405         clip.max_y = 256 - ((16-(block/0x800))*16)+15;
r10886r10887
394415         offs = (block + cnt) / 2;
395416
396417         // 16bit version
397         if(tiles != NULL)
418         if(state->tiles != NULL)
398419         {
399            if(tiles[offs] & 0x0100) continue;
420            if(state->tiles[offs] & 0x0100) continue;
400421
401            code  = tiles[offs+1];
402            color = (tiles[offs+2] >> palshift) & 0x7f;
422            code  = state->tiles[offs+1];
423            color = (state->tiles[offs+2] >> state->palshift) & 0x7f;
403424
404            x = tiles[offs+3] & 0x01ff;
405            y = 256 - (tiles[offs] & 0x00ff);
425            x = state->tiles[offs+3] & 0x01ff;
426            y = 256 - (state->tiles[offs] & 0x00ff);
406427
407            fx = tiles[offs] & 0x8000;
408            fy = tiles[offs] & 0x4000;
428            fx = state->tiles[offs] & 0x8000;
429            fy = state->tiles[offs] & 0x4000;
409430         }
410431         // 32bit version
411432         else
412433         {
413434            offs /= 2;
414435
415            if(tiles32[offs] & 0x01000000) continue;
436            if(state->tiles32[offs] & 0x01000000) continue;
416437
417            code  = tiles32[offs] & 0xffff;
418            color = ((tiles32[offs+1] >> palshift) & 0x7f0000) >> 16;
438            code  = state->tiles32[offs] & 0xffff;
439            color = ((state->tiles32[offs+1] >> state->palshift) & 0x7f0000) >> 16;
419440
420            x = tiles32[offs+1] & 0x01ff;
421            y = 256 - ((tiles32[offs] & 0x00ff0000) >> 16);
441            x = state->tiles32[offs+1] & 0x01ff;
442            y = 256 - ((state->tiles32[offs] & 0x00ff0000) >> 16);
422443
423            fx = tiles32[offs] & 0x80000000;
424            fy = tiles32[offs] & 0x40000000;
444            fx = state->tiles32[offs] & 0x80000000;
445            fy = state->tiles32[offs] & 0x40000000;
425446         }
426447
427         if(flipscreen)
448         if(state->flipscreen)
428449         {
429450            fx = !fx;
430451            fy = !fy;
r10886r10887
440461
441462static void draw_sprites_aoh(screen_device *screen, bitmap_t *bitmap)
442463{
464   vamphalf_state *state = screen->machine->driver_data<vamphalf_state>();
443465   const gfx_element *gfx = screen->machine->gfx[0];
444466   UINT32 cnt;
445467   int block, offs;
r10886r10887
451473
452474   for (block=0; block<0x8000; block+=0x800)
453475   {
454      if(flipscreen)
476      if(state->flipscreen)
455477      {
456478         clip.min_y = 256 - (16-(block/0x800))*16;
457479         clip.max_y = 256 - ((16-(block/0x800))*16)+15;
r10886r10887
467489         offs = (block + cnt) / 2;
468490         {
469491            offs /= 2;
470            code  = (tiles32[offs] & 0xffff) | ((tiles32[offs] & 0x3000000) >> 8);
471            color = ((tiles32[offs+1] >> palshift) & 0x7f0000) >> 16;
492            code  = (state->tiles32[offs] & 0xffff) | ((state->tiles32[offs] & 0x3000000) >> 8);
493            color = ((state->tiles32[offs+1] >> state->palshift) & 0x7f0000) >> 16;
472494
473            x = tiles32[offs+1] & 0x01ff;
474            y = 256 - ((tiles32[offs] & 0x00ff0000) >> 16);
495            x = state->tiles32[offs+1] & 0x01ff;
496            y = 256 - ((state->tiles32[offs] & 0x00ff0000) >> 16);
475497
476            fx = tiles32[offs] & 0x4000000;
477            fy = 0; // not used ? or it's tiles32[offs] & 0x8000000?
498            fx = state->tiles32[offs] & 0x4000000;
499            fy = 0; // not used ? or it's state->tiles32[offs] & 0x8000000?
478500         }
479501
480         if(flipscreen)
502         if(state->flipscreen)
481503         {
482504            fx = !fx;
483505            fy = !fy;
r10886r10887
634656   AM_RANGE( 0x0000, 0x007f) AM_RAM   // RAM?  wavetable registers?  not sure.
635657ADDRESS_MAP_END
636658
637static MACHINE_CONFIG_START( common, driver_device )
659static MACHINE_CONFIG_START( common, vamphalf_state )
638660   MCFG_CPU_ADD("maincpu", E116T, 50000000)   /* 50 MHz */
639661   MCFG_CPU_PROGRAM_MAP(common_map)
640662   MCFG_CPU_VBLANK_INT("screen", irq1_line_hold)
r10886r10887
763785   MCFG_FRAGMENT_ADD(sound_ym_oki)
764786MACHINE_CONFIG_END
765787
766static MACHINE_CONFIG_START( aoh, driver_device )
788static MACHINE_CONFIG_START( aoh, vamphalf_state )
767789   MCFG_CPU_ADD("maincpu", E132XN, 20000000*4)   /* 4x internal multiplier */
768790   MCFG_CPU_PROGRAM_MAP(aoh_map)
769791   MCFG_CPU_IO_MAP(aoh_io)
r10886r10887
15851607
15861608static READ16_HANDLER( vamphalf_speedup_r )
15871609{
1610   vamphalf_state *state = space->machine->driver_data<vamphalf_state>();
15881611   if(cpu_get_pc(space->cpu) == 0x82de)
15891612   {
15901613      if(irq_active(space))
r10886r10887
15931616         cpu_eat_cycles(space->cpu, 50);
15941617   }
15951618
1596   return wram[(0x4a840/2)+offset];
1619   return state->wram[(0x4a840/2)+offset];
15971620}
15981621
15991622static READ16_HANDLER( vamphafk_speedup_r )
16001623{
1624   vamphalf_state *state = space->machine->driver_data<vamphalf_state>();
16011625   if(cpu_get_pc(space->cpu) == 0x82de)
16021626   {
16031627      if(irq_active(space))
r10886r10887
16061630         cpu_eat_cycles(space->cpu, 50);
16071631   }
16081632
1609   return wram[(0x4a6d0/2)+offset];
1633   return state->wram[(0x4a6d0/2)+offset];
16101634}
16111635
16121636static READ16_HANDLER( misncrft_speedup_r )
16131637{
1638   vamphalf_state *state = space->machine->driver_data<vamphalf_state>();
16141639   if(cpu_get_pc(space->cpu) == 0xecc8)
16151640   {
16161641      if(irq_active(space))
r10886r10887
16191644         cpu_eat_cycles(space->cpu, 50);
16201645   }
16211646
1622   return wram[(0x72eb4/2)+offset];
1647   return state->wram[(0x72eb4/2)+offset];
16231648}
16241649
16251650static READ16_HANDLER( coolmini_speedup_r )
16261651{
1652   vamphalf_state *state = space->machine->driver_data<vamphalf_state>();
16271653   if(cpu_get_pc(space->cpu) == 0x75f7a)
16281654   {
16291655      if(irq_active(space))
r10886r10887
16321658         cpu_eat_cycles(space->cpu, 50);
16331659   }
16341660
1635   return wram[(0xd2e80/2)+offset];
1661   return state->wram[(0xd2e80/2)+offset];
16361662}
16371663
16381664static READ16_HANDLER( suplup_speedup_r )
16391665{
1666   vamphalf_state *state = space->machine->driver_data<vamphalf_state>();
16401667   if(cpu_get_pc(space->cpu) == 0xaf18a )
16411668   {
16421669      if(irq_active(space))
r10886r10887
16451672         cpu_eat_cycles(space->cpu, 50);
16461673   }
16471674
1648   return wram[(0x11605c/2)+offset];
1675   return state->wram[(0x11605c/2)+offset];
16491676}
16501677
16511678static READ16_HANDLER( luplup_speedup_r )
16521679{
1680   vamphalf_state *state = space->machine->driver_data<vamphalf_state>();
16531681   if(cpu_get_pc(space->cpu) == 0xaefac )
16541682   {
16551683      if(irq_active(space))
r10886r10887
16581686         cpu_eat_cycles(space->cpu, 50);
16591687   }
16601688
1661   return wram[(0x115e84/2)+offset];
1689   return state->wram[(0x115e84/2)+offset];
16621690}
16631691
16641692static READ16_HANDLER( luplup29_speedup_r )
16651693{
1694   vamphalf_state *state = space->machine->driver_data<vamphalf_state>();
16661695   if(cpu_get_pc(space->cpu) == 0xae6c0 )
16671696   {
16681697      if(irq_active(space))
r10886r10887
16711700         cpu_eat_cycles(space->cpu, 50);
16721701   }
16731702
1674   return wram[(0x113f08/2)+offset];
1703   return state->wram[(0x113f08/2)+offset];
16751704}
16761705
16771706static READ16_HANDLER( puzlbang_speedup_r )
16781707{
1708   vamphalf_state *state = space->machine->driver_data<vamphalf_state>();
16791709   if(cpu_get_pc(space->cpu) == 0xae6d2 )
16801710   {
16811711      if(irq_active(space))
r10886r10887
16841714         cpu_eat_cycles(space->cpu, 50);
16851715   }
16861716
1687   return wram[(0x113ecc/2)+offset];
1717   return state->wram[(0x113ecc/2)+offset];
16881718}
16891719
16901720static READ32_HANDLER( wyvernwg_speedup_r )
16911721{
1722   vamphalf_state *state = space->machine->driver_data<vamphalf_state>();
16921723   if(cpu_get_pc(space->cpu) == 0x10758 )
16931724   {
16941725      if(irq_active(space))
r10886r10887
16971728         cpu_eat_cycles(space->cpu, 50);
16981729   }
16991730
1700   return wram32[0x00b56fc/4];
1731   return state->wram32[0x00b56fc/4];
17011732}
17021733
17031734static READ32_HANDLER( finalgdr_speedup_r )
17041735{
1736   vamphalf_state *state = space->machine->driver_data<vamphalf_state>();
17051737   if(cpu_get_pc(space->cpu) == 0x1c212)
17061738   {
17071739      if(irq_active(space))
r10886r10887
17101742         cpu_eat_cycles(space->cpu, 50);
17111743   }
17121744
1713   return wram32[0x005e874/4];
1745   return state->wram32[0x005e874/4];
17141746}
17151747
17161748static READ32_HANDLER( mrkicker_speedup_r )
17171749{
1750   vamphalf_state *state = space->machine->driver_data<vamphalf_state>();
17181751   UINT32 pc = cpu_get_pc(space->cpu);
17191752   if(pc == 0x469de || pc == 0x46a36)
17201753   {
r10886r10887
17241757         cpu_eat_cycles(space->cpu, 50);
17251758   }
17261759
1727   return wram32[0x00701a4/4];
1760   return state->wram32[0x00701a4/4];
17281761}
17291762
17301763
17311764static READ16_HANDLER( dquizgo2_speedup_r )
17321765{
1766   vamphalf_state *state = space->machine->driver_data<vamphalf_state>();
17331767   if(cpu_get_pc(space->cpu) == 0xaa622)
17341768   {
17351769      if(irq_active(space))
r10886r10887
17381772         cpu_eat_cycles(space->cpu, 50);
17391773   }
17401774
1741   return wram[(0xcde70/2)+offset];
1775   return state->wram[(0xcde70/2)+offset];
17421776}
17431777
17441778static READ32_HANDLER( aoh_speedup_r )
17451779{
1780   vamphalf_state *state = space->machine->driver_data<vamphalf_state>();
17461781   if(cpu_get_pc(space->cpu) == 0xb994 )
17471782   {
17481783      cpu_eat_cycles(space->cpu, 500);
r10886r10887
17531788   }
17541789
17551790
1756   return wram32[0x28a09c/4];
1791   return state->wram32[0x28a09c/4];
17571792}
17581793
17591794static READ16_HANDLER( jmpbreak_speedup_r )
17601795{
1796   vamphalf_state *state = space->machine->driver_data<vamphalf_state>();
17611797   if(cpu_get_pc(space->cpu) == 0x983c)
17621798   {
17631799      if(irq_active(space))
r10886r10887
17661802         cpu_eat_cycles(space->cpu, 50);
17671803   }
17681804
1769   return wram[(0x00906fc / 2)+offset];
1805   return state->wram[(0x00906fc / 2)+offset];
17701806}
17711807
17721808static READ16_HANDLER( mrdig_speedup_r )
17731809{
1810   vamphalf_state *state = space->machine->driver_data<vamphalf_state>();
17741811   if(cpu_get_pc(space->cpu) == 0x1710)
17751812   {
17761813      if(irq_active(space))
r10886r10887
17791816         cpu_eat_cycles(space->cpu, 50);
17801817   }
17811818
1782   return wram[(0x00a99c / 2)+offset];
1819   return state->wram[(0x00a99c / 2)+offset];
17831820}
17841821
17851822static DRIVER_INIT( vamphalf )
17861823{
1824   vamphalf_state *state = machine->driver_data<vamphalf_state>();
17871825   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0004a840, 0x0004a843, 0, 0, vamphalf_speedup_r );
17881826
1789   palshift = 0;
1790   flip_bit = 0x80;
1827   state->palshift = 0;
1828   state->flip_bit = 0x80;
17911829}
17921830
17931831static DRIVER_INIT( vamphafk )
17941832{
1833   vamphalf_state *state = machine->driver_data<vamphalf_state>();
17951834   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0004a6d0, 0x0004a6d3, 0, 0, vamphafk_speedup_r );
17961835
1797   palshift = 0;
1798   flip_bit = 0x80;
1836   state->palshift = 0;
1837   state->flip_bit = 0x80;
17991838}
18001839
18011840static DRIVER_INIT( misncrft )
18021841{
1842   vamphalf_state *state = machine->driver_data<vamphalf_state>();
18031843   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x00072eb4, 0x00072eb7, 0, 0, misncrft_speedup_r );
18041844
1805   palshift = 0;
1806   flip_bit = 1;
1845   state->palshift = 0;
1846   state->flip_bit = 1;
18071847}
18081848
18091849static DRIVER_INIT( coolmini )
18101850{
1851   vamphalf_state *state = machine->driver_data<vamphalf_state>();
18111852   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x000d2e80, 0x000d2e83, 0, 0, coolmini_speedup_r );
18121853
1813   palshift = 0;
1814   flip_bit = 1;
1854   state->palshift = 0;
1855   state->flip_bit = 1;
18151856}
18161857
18171858static DRIVER_INIT( suplup )
18181859{
1860   vamphalf_state *state = machine->driver_data<vamphalf_state>();
18191861   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0011605c, 0x0011605f, 0, 0, suplup_speedup_r );
18201862
1821   palshift = 8;
1863   state->palshift = 8;
18221864   /* no flipscreen */
18231865}
18241866
18251867static DRIVER_INIT( luplup )
18261868{
1869   vamphalf_state *state = machine->driver_data<vamphalf_state>();
18271870   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x00115e84, 0x00115e87, 0, 0, luplup_speedup_r );
18281871
1829   palshift = 8;
1872   state->palshift = 8;
18301873   /* no flipscreen */
18311874}
18321875
18331876static DRIVER_INIT( luplup29 )
18341877{
1878   vamphalf_state *state = machine->driver_data<vamphalf_state>();
18351879   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x00113f08, 0x00113f0b, 0, 0, luplup29_speedup_r );
18361880
1837   palshift = 8;
1881   state->palshift = 8;
18381882   /* no flipscreen */
18391883}
18401884
18411885static DRIVER_INIT( puzlbang )
18421886{
1887   vamphalf_state *state = machine->driver_data<vamphalf_state>();
18431888   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x00113ecc, 0x00113ecf, 0, 0, puzlbang_speedup_r );
18441889
1845   palshift = 8;
1890   state->palshift = 8;
18461891   /* no flipscreen */
18471892}
18481893
18491894static DRIVER_INIT( wyvernwg )
18501895{
1896   vamphalf_state *state = machine->driver_data<vamphalf_state>();
18511897   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x00b56fc, 0x00b56ff, 0, 0, wyvernwg_speedup_r );
18521898
1853   palshift = 0;
1854   flip_bit = 1;
1899   state->palshift = 0;
1900   state->flip_bit = 1;
18551901
1856   semicom_prot_idx = 8;
1857   semicom_prot_data[0] = 2;
1858   semicom_prot_data[1] = 1;
1902   state->semicom_prot_idx = 8;
1903   state->semicom_prot_data[0] = 2;
1904   state->semicom_prot_data[1] = 1;
18591905}
18601906
18611907static DRIVER_INIT( finalgdr )
18621908{
1863   finalgdr_backupram_bank = 1;
1864   finalgdr_backupram = auto_alloc_array(machine, UINT8, 0x80*0x100);
1909   vamphalf_state *state = machine->driver_data<vamphalf_state>();
1910   state->finalgdr_backupram_bank = 1;
1911   state->finalgdr_backupram = auto_alloc_array(machine, UINT8, 0x80*0x100);
18651912   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x005e874, 0x005e877, 0, 0, finalgdr_speedup_r );
1866   machine->device<nvram_device>("nvram")->set_base(finalgdr_backupram, 0x80*0x100);
1913   machine->device<nvram_device>("nvram")->set_base(state->finalgdr_backupram, 0x80*0x100);
18671914
1868   palshift = 0;
1869   flip_bit = 1; //?
1915   state->palshift = 0;
1916   state->flip_bit = 1; //?
18701917
1871   semicom_prot_idx = 8;
1872   semicom_prot_data[0] = 2;
1873   semicom_prot_data[1] = 3;
1918   state->semicom_prot_idx = 8;
1919   state->semicom_prot_data[0] = 2;
1920   state->semicom_prot_data[1] = 3;
18741921}
18751922
18761923static DRIVER_INIT( mrkicker )
18771924{
1925   vamphalf_state *state = machine->driver_data<vamphalf_state>();
18781926   // backup ram isn't used
1879   finalgdr_backupram_bank = 1;
1880   finalgdr_backupram = auto_alloc_array(machine, UINT8, 0x80*0x100);
1927   state->finalgdr_backupram_bank = 1;
1928   state->finalgdr_backupram = auto_alloc_array(machine, UINT8, 0x80*0x100);
18811929   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x00701a4, 0x00701a7, 0, 0, mrkicker_speedup_r );
1882   machine->device<nvram_device>("nvram")->set_base(finalgdr_backupram, 0x80*0x100);
1930   machine->device<nvram_device>("nvram")->set_base(state->finalgdr_backupram, 0x80*0x100);
18831931
1884   palshift = 0;
1885   flip_bit = 1; //?
1932   state->palshift = 0;
1933   state->flip_bit = 1; //?
18861934
1887   semicom_prot_idx = 8;
1888   semicom_prot_data[0] = 2;
1889   semicom_prot_data[1] = 3;
1935   state->semicom_prot_idx = 8;
1936   state->semicom_prot_data[0] = 2;
1937   state->semicom_prot_data[1] = 3;
18901938}
18911939
18921940static DRIVER_INIT( dquizgo2 )
18931941{
1942   vamphalf_state *state = machine->driver_data<vamphalf_state>();
18941943   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x00cde70, 0x00cde73, 0, 0, dquizgo2_speedup_r );
18951944
1896   palshift = 0;
1897   flip_bit = 1;
1945   state->palshift = 0;
1946   state->flip_bit = 1;
18981947}
18991948
19001949static DRIVER_INIT( aoh )
19011950{
1951   vamphalf_state *state = machine->driver_data<vamphalf_state>();
19021952   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x028a09c, 0x028a09f, 0, 0, aoh_speedup_r );
19031953
1904   palshift = 0;
1954   state->palshift = 0;
19051955   /* no flipscreen */
19061956}
19071957
19081958static DRIVER_INIT( jmpbreak )
19091959{
1960   vamphalf_state *state = machine->driver_data<vamphalf_state>();
19101961   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x00906fc, 0x00906ff, 0, 0, jmpbreak_speedup_r );
19111962   memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xe0000000, 0xe0000003, 0, 0, jmpbreak_flipscreen_w );
19121963
1913   palshift = 0;
1964   state->palshift = 0;
19141965}
19151966
19161967static DRIVER_INIT( mrdig )
19171968{
1969   vamphalf_state *state = machine->driver_data<vamphalf_state>();
19181970   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x00a99c, 0x00a99f, 0, 0, mrdig_speedup_r );
19191971   memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xe0000000, 0xe0000003, 0, 0, jmpbreak_flipscreen_w );
19201972
1921   palshift = 0;
1973   state->palshift = 0;
19221974}
19231975
19241976GAME( 1999, coolmini, 0,        coolmini, common,   coolmini, ROT0,   "SemiCom",           "Cool Minigame Collection", 0 )
src/mame/drivers/flower.c
r10886r10887
7575#include "deprecat.h"
7676#include "includes/flower.h"
7777
78static UINT8 *sn_irq_enable;
79static UINT8 *sn_nmi_enable;
8078
8179static WRITE8_HANDLER( flower_irq_ack )
8280{
r10886r10887
8583
8684static WRITE8_HANDLER( sn_irq_enable_w )
8785{
88   *sn_irq_enable = data;
86   flower_state *state = space->machine->driver_data<flower_state>();
87   *state->sn_irq_enable = data;
8988
9089   cputag_set_input_line(space->machine, "audiocpu", 0, CLEAR_LINE);
9190}
9291
9392static INTERRUPT_GEN( sn_irq )
9493{
95   if ((*sn_irq_enable & 1) == 1)
94   flower_state *state = device->machine->driver_data<flower_state>();
95   if ((*state->sn_irq_enable & 1) == 1)
9696      cpu_set_input_line(device, 0, ASSERT_LINE);
9797}
9898
9999static WRITE8_HANDLER( sound_command_w )
100100{
101   flower_state *state = space->machine->driver_data<flower_state>();
101102   soundlatch_w(space, 0, data);
102   if ((*sn_nmi_enable & 1) == 1)
103   if ((*state->sn_nmi_enable & 1) == 1)
103104      cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
104105}
105106
r10886r10887
118119   AM_RANGE(0xa400, 0xa400) AM_WRITE(sound_command_w)
119120   AM_RANGE(0xc000, 0xddff) AM_SHARE("share1") AM_RAM
120121   AM_RANGE(0xde00, 0xdfff) AM_SHARE("share2") AM_RAM AM_BASE_MEMBER(flower_state, spriteram)
121   AM_RANGE(0xe000, 0xe7ff) AM_SHARE("share3") AM_RAM_WRITE(flower_textram_w)  AM_BASE(&flower_textram)
122   AM_RANGE(0xe000, 0xe7ff) AM_SHARE("share3") AM_RAM_WRITE(flower_textram_w)  AM_BASE_MEMBER(flower_state, textram)
122123   AM_RANGE(0xe000, 0xefff) AM_SHARE("share4") AM_RAM //only cleared?
123   AM_RANGE(0xf000, 0xf1ff) AM_SHARE("share5") AM_RAM_WRITE(flower_bg0ram_w)   AM_BASE(&flower_bg0ram)
124   AM_RANGE(0xf200, 0xf200) AM_SHARE("share6") AM_RAM  AM_BASE(&flower_bg0_scroll)
125   AM_RANGE(0xf800, 0xf9ff) AM_SHARE("share7") AM_RAM_WRITE(flower_bg1ram_w)  AM_BASE(&flower_bg1ram)
126   AM_RANGE(0xfa00, 0xfa00) AM_SHARE("share8") AM_RAM AM_BASE(&flower_bg1_scroll)
124   AM_RANGE(0xf000, 0xf1ff) AM_SHARE("share5") AM_RAM_WRITE(flower_bg0ram_w)   AM_BASE_MEMBER(flower_state, bg0ram)
125   AM_RANGE(0xf200, 0xf200) AM_SHARE("share6") AM_RAM  AM_BASE_MEMBER(flower_state, bg0_scroll)
126   AM_RANGE(0xf800, 0xf9ff) AM_SHARE("share7") AM_RAM_WRITE(flower_bg1ram_w)  AM_BASE_MEMBER(flower_state, bg1ram)
127   AM_RANGE(0xfa00, 0xfa00) AM_SHARE("share8") AM_RAM AM_BASE_MEMBER(flower_state, bg1_scroll)
127128ADDRESS_MAP_END
128129
129130
130131static ADDRESS_MAP_START( flower_sound_cpu, ADDRESS_SPACE_PROGRAM, 8 )
131132   AM_RANGE(0x0000, 0x3fff) AM_ROM
132   AM_RANGE(0x4000, 0x4000) AM_WRITE(sn_irq_enable_w) AM_BASE(&sn_irq_enable)
133   AM_RANGE(0x4001, 0x4001) AM_WRITEONLY AM_BASE(&sn_nmi_enable)
133   AM_RANGE(0x4000, 0x4000) AM_WRITE(sn_irq_enable_w) AM_BASE_MEMBER(flower_state, sn_irq_enable)
134   AM_RANGE(0x4001, 0x4001) AM_WRITEONLY AM_BASE_MEMBER(flower_state, sn_nmi_enable)
134135   AM_RANGE(0x6000, 0x6000) AM_READ(soundlatch_r)
135136   AM_RANGE(0x8000, 0x803f) AM_DEVWRITE("flower", flower_sound1_w)
136137   AM_RANGE(0xa000, 0xa03f) AM_DEVWRITE("flower", flower_sound2_w)
src/mame/drivers/hitpoker.c
r10886r10887
4747#include "sound/ay8910.h"
4848#include "video/mc6845.h"
4949
50static UINT8 *hitpoker_sys_regs;
51static UINT8 hitpoker_pic_data;
52static UINT8 *videoram;
53static UINT8 *paletteram;
54static UINT8 *colorram;
5550
51class hitpoker_state : public driver_device
52{
53public:
54   hitpoker_state(running_machine &machine, const driver_device_config_base &config)
55      : driver_device(machine, config) { }
56
57   UINT8 *sys_regs;
58   UINT8 pic_data;
59   UINT8 *videoram;
60   UINT8 *paletteram;
61   UINT8 *colorram;
62   UINT8 eeprom_data[0x200];
63   UINT16 eeprom_index;
64   UINT8 tmp;
65};
66
67
5668#define CRTC_CLOCK XTAL_3_579545MHz
5769
5870static VIDEO_START(hitpoker)
5971{
60   videoram = auto_alloc_array(machine, UINT8, 0x35ff);
61   paletteram = auto_alloc_array(machine, UINT8, 0x1000);
62   colorram = auto_alloc_array(machine, UINT8, 0x2000);
72   hitpoker_state *state = machine->driver_data<hitpoker_state>();
73   state->videoram = auto_alloc_array(machine, UINT8, 0x35ff);
74   state->paletteram = auto_alloc_array(machine, UINT8, 0x1000);
75   state->colorram = auto_alloc_array(machine, UINT8, 0x2000);
6376}
6477
6578static SCREEN_UPDATE(hitpoker)
6679{
80   hitpoker_state *state = screen->machine->driver_data<hitpoker_state>();
6781   int count = 0;
6882   int y,x;
6983
r10886r10887
7589      {
7690         int tile,color,gfx_bpp;
7791
78         tile = (((videoram[count]<<8)|(videoram[count+1])) & 0x3fff);
79         gfx_bpp = (colorram[count] & 0x80)>>7; //flag between 4 and 8 bpp
80         color = gfx_bpp ? ((colorram[count] & 0x70)>>4) : (colorram[count] & 0xf);
92         tile = (((state->videoram[count]<<8)|(state->videoram[count+1])) & 0x3fff);
93         gfx_bpp = (state->colorram[count] & 0x80)>>7; //flag between 4 and 8 bpp
94         color = gfx_bpp ? ((state->colorram[count] & 0x70)>>4) : (state->colorram[count] & 0xf);
8195
8296         drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[gfx_bpp],tile,color,0,0,x*8,y*8);
8397
r10886r10887
90104
91105static READ8_HANDLER( hitpoker_vram_r )
92106{
107   hitpoker_state *state = space->machine->driver_data<hitpoker_state>();
93108   UINT8 *ROM = space->machine->region("maincpu")->base();
94109
95   if(hitpoker_pic_data & 0x10)
96      return videoram[offset];
110   if(state->pic_data & 0x10)
111      return state->videoram[offset];
97112   else
98113      return ROM[offset+0x8000];
99114}
100115
101116static WRITE8_HANDLER( hitpoker_vram_w )
102117{
118   hitpoker_state *state = space->machine->driver_data<hitpoker_state>();
103119//  UINT8 *ROM = space->machine->region("maincpu")->base();
104120
105//  if(hitpoker_sys_regs[0x00] & 0x10)
106   videoram[offset] = data;
121//  if(state->sys_regs[0x00] & 0x10)
122   state->videoram[offset] = data;
107123}
108124
109125static READ8_HANDLER( hitpoker_cram_r )
110126{
127   hitpoker_state *state = space->machine->driver_data<hitpoker_state>();
111128   UINT8 *ROM = space->machine->region("maincpu")->base();
112129
113   if(hitpoker_pic_data & 0x10)
114      return colorram[offset];
130   if(state->pic_data & 0x10)
131      return state->colorram[offset];
115132   else
116133      return ROM[offset+0xc000];
117134}
118135
119136static WRITE8_HANDLER( hitpoker_cram_w )
120137{
121   colorram[offset] = data;
138   hitpoker_state *state = space->machine->driver_data<hitpoker_state>();
139   state->colorram[offset] = data;
122140}
123141
124142static READ8_HANDLER( hitpoker_paletteram_r )
125143{
144   hitpoker_state *state = space->machine->driver_data<hitpoker_state>();
126145   UINT8 *ROM = space->machine->region("maincpu")->base();
127146
128   if(hitpoker_pic_data & 0x10)
129      return paletteram[offset];
147   if(state->pic_data & 0x10)
148      return state->paletteram[offset];
130149   else
131150      return ROM[offset+0xe000];
132151}
133152
134153static WRITE8_HANDLER( hitpoker_paletteram_w )
135154{
155   hitpoker_state *state = space->machine->driver_data<hitpoker_state>();
136156   int r,g,b,datax;
137   paletteram[offset] = data;
157   state->paletteram[offset] = data;
138158   offset>>=1;
139   datax=256*paletteram[offset*2]+paletteram[offset*2+1];
159   datax=256*state->paletteram[offset*2]+state->paletteram[offset*2+1];
140160
141161   /* RGB565 */
142162   b = ((datax)&0xf800)>>11;
r10886r10887
151171   return 0x80; //kludge it for now
152172}
153173
154static UINT8 eeprom_data[0x200];
155static UINT16 eeprom_index;
156174
157175/* tests 0x180, what EEPROM is this one??? */
158176static WRITE8_HANDLER( eeprom_w )
159177{
178   hitpoker_state *state = space->machine->driver_data<hitpoker_state>();
160179   if(offset == 0)
161180   {
162      eeprom_index = (eeprom_index & 0x100)|(data & 0xff);
181      state->eeprom_index = (state->eeprom_index & 0x100)|(data & 0xff);
163182      //printf("W INDEX %02x\n",data);
164183   }
165184   if(offset == 1)
166185   {
167      eeprom_index = (eeprom_index & 0xff)|((data & 0x1)<<8);
186      state->eeprom_index = (state->eeprom_index & 0xff)|((data & 0x1)<<8);
168187      //data & 0x4: eeprom clock
169188      //printf("W CLOCK + INDEX %02x\n",data);
170189   }
r10886r10887
172191
173192static READ8_HANDLER( eeprom_r )
174193{
175   static UINT8 tmp;
176   tmp = eeprom_data[eeprom_index];
177   if((eeprom_index & 0x1f) == 0x1f)
178      tmp = 0xaa;
179   //printf("%02x\n",eeprom_index);
180   eeprom_index++;
181   //eeprom_index&=0x1f;
182   return tmp;
194   hitpoker_state *state = space->machine->driver_data<hitpoker_state>();
195   state->tmp = state->eeprom_data[state->eeprom_index];
196   if((state->eeprom_index & 0x1f) == 0x1f)
197      state->tmp = 0xaa;
198   //printf("%02x\n",state->eeprom_index);
199   state->eeprom_index++;
200   //state->eeprom_index&=0x1f;
201   return state->tmp;
183202}
184203
185204static READ8_HANDLER( hitpoker_pic_r )
186205{
206   hitpoker_state *state = space->machine->driver_data<hitpoker_state>();
187207//  logerror("R\n");
188208
189209   if(offset == 0)
r10886r10887
192212         cpu_get_pc(space->cpu) == 0x314e ||
193213         cpu_get_pc(space->cpu) == 0x3164 ||
194214         cpu_get_pc(space->cpu) == 0x3179)
195         return hitpoker_pic_data;
215         return state->pic_data;
196216
197      return (hitpoker_pic_data & 0x7f) | (hitpoker_pic_data & 0x40 ? 0x80 : 0x00);
217      return (state->pic_data & 0x7f) | (state->pic_data & 0x40 ? 0x80 : 0x00);
198218   }
199219
200   return hitpoker_sys_regs[offset];
220   return state->sys_regs[offset];
201221}
202222
203223static WRITE8_HANDLER( hitpoker_pic_w )
204224{
225   hitpoker_state *state = space->machine->driver_data<hitpoker_state>();
205226   if(offset == 0)
206      hitpoker_pic_data = (data & 0xff);// | (data & 0x40) ? 0x80 : 0x00;
227      state->pic_data = (data & 0xff);// | (data & 0x40) ? 0x80 : 0x00;
207228//  logerror("%02x W\n",data);
208   hitpoker_sys_regs[offset] = data;
229   state->sys_regs[offset] = data;
209230}
210231
211232#if 0
r10886r10887
239260ADDRESS_MAP_END
240261
241262static ADDRESS_MAP_START( hitpoker_io, ADDRESS_SPACE_IO, 8 )
242   AM_RANGE(MC68HC11_IO_PORTA, MC68HC11_IO_PORTA) AM_READWRITE(hitpoker_pic_r,hitpoker_pic_w) AM_BASE(&hitpoker_sys_regs)
263   AM_RANGE(MC68HC11_IO_PORTA, MC68HC11_IO_PORTA) AM_READWRITE(hitpoker_pic_r,hitpoker_pic_w) AM_BASE_MEMBER(hitpoker_state, sys_regs)
243264ADDRESS_MAP_END
244265
245266static INPUT_PORTS_START( hitpoker )
r10886r10887
461482   cpu_set_input_line(device, MC68HC11_IRQ_LINE, HOLD_LINE);
462483}
463484
464static MACHINE_CONFIG_START( hitpoker, driver_device )
485static MACHINE_CONFIG_START( hitpoker, hitpoker_state )
465486   MCFG_CPU_ADD("maincpu", MC68HC11,1000000)
466487   MCFG_CPU_PROGRAM_MAP(hitpoker_map)
467488   MCFG_CPU_IO_MAP(hitpoker_io)
src/mame/drivers/buster.c
r10886r10887
1010#include "cpu/z80/z80.h"
1111#include "sound/ay8910.h"
1212
13static UINT8 *buster_rom;
14static UINT8 *buster_vram;
1513
14class buster_state : public driver_device
15{
16public:
17   buster_state(running_machine &machine, const driver_device_config_base &config)
18      : driver_device(machine, config) { }
19
20   UINT8 *rom;
21   UINT8 *vram;
22};
23
24
1625static VIDEO_START(buster)
1726{
18
1927}
2028
2129static SCREEN_UPDATE(buster)
2230{
31   buster_state *state = screen->machine->driver_data<buster_state>();
2332   const gfx_element *gfx = screen->machine->gfx[0];
2433   int count = 0x0000;
2534
r10886r10887
3039   {
3140      for (x=0;x<32;x++)
3241      {
33         int tile = (buster_vram[count+1])|(buster_vram[count]<<8);
42         int tile = (state->vram[count+1])|(state->vram[count]<<8);
3443         //int colour = tile>>12;
3544         drawgfx_opaque(bitmap,cliprect,gfx,tile,0,0,0,x*8,y*4);
3645
r10886r10887
4150}
4251
4352static ADDRESS_MAP_START( mainmap, ADDRESS_SPACE_PROGRAM, 8 )
44   AM_RANGE(0x0000, 0x3fff) AM_RAM AM_BASE(&buster_rom)
53   AM_RANGE(0x0000, 0x3fff) AM_RAM AM_BASE_MEMBER(buster_state, rom)
4554   AM_RANGE(0x4000, 0x47ff) AM_RAM
46   AM_RANGE(0x5000, 0x5fff) AM_RAM AM_BASE(&buster_vram)
55   AM_RANGE(0x5000, 0x5fff) AM_RAM AM_BASE_MEMBER(buster_state, vram)
4756//  AM_RANGE(0x6000, 0x6000) MC6845 address
4857//  AM_RANGE(0x6001, 0x6001) MC6845 data
4958   AM_RANGE(0x7000, 0xafff) AM_ROM
r10886r10887
6978   GFXDECODE_ENTRY( "gfx1", 0, tiles8x8_layout, 0, 16 )
7079GFXDECODE_END
7180
72static MACHINE_CONFIG_START( buster, driver_device )
81static MACHINE_CONFIG_START( buster, buster_state )
7382   /* basic machine hardware */
7483   MCFG_CPU_ADD("maincpu", Z80,8000000)       /* ? MHz */
7584   MCFG_CPU_PROGRAM_MAP(mainmap)
r10886r10887
113122
114123static DRIVER_INIT( buster )
115124{
125   buster_state *state = machine->driver_data<buster_state>();
116126   UINT8 *ROM = machine->region("maincpu")->base();
117127//  vram = auto_alloc_array(machine, UINT8, 0x2000);
118   memcpy(buster_rom, ROM, 0x4000);
128   memcpy(state->rom, ROM, 0x4000);
119129}
120130
121131GAME( 1987, buster,  0,    buster, buster,  buster, ROT0, "Marian Electronics Ltd.", "Buster", GAME_NOT_WORKING|GAME_NO_SOUND )
src/mame/drivers/midas.c
r10886r10887
5656#include "machine/eeprom.h"
5757#include "machine/ticket.h"
5858
59static UINT16 *midas_gfxram, *midas_gfxregs;
6059
60class midas_state : public driver_device
61{
62public:
63   midas_state(running_machine &machine, const driver_device_config_base &config)
64      : driver_device(machine, config) { }
65
66   UINT16 *gfxram;
67   UINT16 *gfxregs;
68   tilemap_t *tmap;
69};
70
71
6172static VIDEO_START( midas );
6273static SCREEN_UPDATE( midas );
6374
64static tilemap_t *tmap;
6575
6676static TILE_GET_INFO( get_tile_info )
6777{
68   UINT16 code = midas_gfxram[ tile_index + 0x7000 ];
78   midas_state *state = machine->driver_data<midas_state>();
79   UINT16 code = state->gfxram[ tile_index + 0x7000 ];
6980   SET_TILE_INFO(1, code & 0xfff, (code >> 12) & 0xf, TILE_FLIPXY( 0 ));
7081}
7182
7283static VIDEO_START( midas )
7384{
74   midas_gfxram = auto_alloc_array(machine, UINT16, 0x20000/2);
85   midas_state *state = machine->driver_data<midas_state>();
86   state->gfxram = auto_alloc_array(machine, UINT16, 0x20000/2);
7587
76   tmap = tilemap_create(   machine, get_tile_info, tilemap_scan_cols,
88   state->tmap = tilemap_create(   machine, get_tile_info, tilemap_scan_cols,
7789                     8,8, 0x80,0x20   );
7890
79   tilemap_set_transparent_pen(tmap, 0);
91   tilemap_set_transparent_pen(state->tmap, 0);
8092}
8193
8294static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
8395{
84   UINT16 *s      =   midas_gfxram + 0x8000;
85   UINT16 *codes   =   midas_gfxram;
96   midas_state *state = machine->driver_data<midas_state>();
97   UINT16 *s      =   state->gfxram + 0x8000;
98   UINT16 *codes   =   state->gfxram;
8699
87100   int sx_old = 0, sy_old = 0, ynum_old = 0, xzoom_old = 0;
88101   int xdim, ydim, xscale, yscale;
r10886r10887
164177
165178static SCREEN_UPDATE( midas )
166179{
180   midas_state *state = screen->machine->driver_data<midas_state>();
167181   int layers_ctrl = -1;
168182
169183#ifdef MAME_DEBUG
170184   if ( input_code_pressed(screen->machine, KEYCODE_Z) )
171185   {
172186      int msk = 0;
173      if (input_code_pressed(screen->machine, KEYCODE_Q))   msk |= 1 << 0;   // for tmap
187      if (input_code_pressed(screen->machine, KEYCODE_Q))   msk |= 1 << 0;   // for state->tmap
174188      if (input_code_pressed(screen->machine, KEYCODE_A))   msk |= 1 << 1;   // for sprites
175189      if (msk != 0) layers_ctrl &= msk;
176190   }
r10886r10887
179193   bitmap_fill(bitmap,cliprect,4095);
180194
181195   if (layers_ctrl & 2)   draw_sprites(screen->machine, bitmap,cliprect);
182   if (layers_ctrl & 1)   tilemap_draw(bitmap,cliprect, tmap, 0, 0);
196   if (layers_ctrl & 1)   tilemap_draw(bitmap,cliprect, state->tmap, 0, 0);
183197
184198   return 0;
185199}
r10886r10887
206220
207221static WRITE16_HANDLER( midas_gfxregs_w )
208222{
209   COMBINE_DATA( midas_gfxregs + offset );
223   midas_state *state = space->machine->driver_data<midas_state>();
224   COMBINE_DATA( state->gfxregs + offset );
210225
211226   switch( offset )
212227   {
213228      case 1:
214229      {
215         UINT16 addr = midas_gfxregs[0];
216         midas_gfxram[addr] = data;
217         midas_gfxregs[0] += midas_gfxregs[2];
230         UINT16 addr = state->gfxregs[0];
231         state->gfxram[addr] = data;
232         state->gfxregs[0] += state->gfxregs[2];
218233
219         if ( addr >= 0x7000 && addr <= 0x7fff )   tilemap_mark_tile_dirty(tmap, addr - 0x7000);
234         if ( addr >= 0x7000 && addr <= 0x7fff )   tilemap_mark_tile_dirty(state->tmap, addr - 0x7000);
220235
221236         break;
222237      }
r10886r10887
250265
251266   AM_RANGE(0x9a0000, 0x9a0001) AM_DEVWRITE( "eeprom", midas_eeprom_w )
252267
253   AM_RANGE(0x9c0000, 0x9c0005) AM_WRITE( midas_gfxregs_w ) AM_BASE( &midas_gfxregs )
268   AM_RANGE(0x9c0000, 0x9c0005) AM_WRITE( midas_gfxregs_w ) AM_BASE_MEMBER(midas_state, gfxregs )
254269
255270   AM_RANGE(0xa00000, 0xa3ffff) AM_RAM_WRITE( paletteram16_xrgb_word_be_w ) AM_BASE_GENERIC( paletteram )
256271   AM_RANGE(0xa40000, 0xa7ffff) AM_RAM
r10886r10887
329344
330345   AM_RANGE(0x9a0000, 0x9a0001) AM_DEVWRITE( "eeprom", midas_eeprom_w )
331346
332   AM_RANGE(0x9c0000, 0x9c0005) AM_WRITE( midas_gfxregs_w ) AM_BASE( &midas_gfxregs )
347   AM_RANGE(0x9c0000, 0x9c0005) AM_WRITE( midas_gfxregs_w ) AM_BASE_MEMBER(midas_state, gfxregs )
333348
334349   AM_RANGE(0xa00000, 0xa3ffff) AM_RAM_WRITE( paletteram16_xrgb_word_be_w ) AM_BASE_GENERIC( paletteram )
335350   AM_RANGE(0xa40000, 0xa7ffff) AM_RAM
r10886r10887
671686   livequiz_irqhandler
672687};
673688
674static MACHINE_CONFIG_START( livequiz, driver_device )
689static MACHINE_CONFIG_START( livequiz, midas_state )
675690
676691   /* basic machine hardware */
677692   MCFG_CPU_ADD("maincpu", M68000, XTAL_24MHz / 2)
r10886r10887
702717   MCFG_SOUND_ROUTE(1, "rspeaker", 0.80)
703718MACHINE_CONFIG_END
704719
705static MACHINE_CONFIG_START( hammer, driver_device )
720static MACHINE_CONFIG_START( hammer, midas_state )
706721
707722   /* basic machine hardware */
708723   MCFG_CPU_ADD("maincpu", M68000, XTAL_28MHz / 2)
src/mame/drivers/murogmbl.c
r10886r10887
3737#include "cpu/z80/z80.h"
3838#include "sound/dac.h"
3939
40static UINT8* murogmbl_video;
4140
41class murogmbl_state : public driver_device
42{
43public:
44   murogmbl_state(running_machine &machine, const driver_device_config_base &config)
45      : driver_device(machine, config) { }
46
47   UINT8* video;
48};
49
50
4251static PALETTE_INIT( murogmbl )
4352{
4453   int   bit0, bit1, bit2 , r, g, b;
r10886r10887
6877   AM_RANGE(0x0000, 0x1fFf) AM_ROM
6978   AM_RANGE(0x4000, 0x43ff) AM_RAM
7079   AM_RANGE(0x4800, 0x4bff) AM_RAM
71   AM_RANGE(0x5800, 0x5bff) AM_RAM AM_BASE(&murogmbl_video)
80   AM_RANGE(0x5800, 0x5bff) AM_RAM AM_BASE_MEMBER(murogmbl_state, video)
7281   AM_RANGE(0x5c00, 0x5fff) AM_RAM
7382   AM_RANGE(0x6000, 0x6000) AM_READ_PORT("IN0")
7483   AM_RANGE(0x6800, 0x6800) AM_READ_PORT("DSW")
r10886r10887
8392
8493static SCREEN_UPDATE(murogmbl)
8594{
95   murogmbl_state *state = screen->machine->driver_data<murogmbl_state>();
8696   const gfx_element *gfx = screen->machine->gfx[0];
8797   int count = 0;
8898
r10886r10887
92102   {
93103      for (x = 0; x < 32; x++)
94104      {
95         int tile = murogmbl_video[count];
105         int tile = state->video[count];
96106         drawgfx_opaque(bitmap, cliprect, gfx, tile, 0, 0, 0, x * 8, y * 8);
97107
98108         count++;
r10886r10887
166176   GFXDECODE_ENTRY( "gfx1", 0, layout8x8x2,  0x0, 1 )
167177GFXDECODE_END
168178
169static MACHINE_CONFIG_START( murogmbl, driver_device )
179static MACHINE_CONFIG_START( murogmbl, murogmbl_state )
170180   /* basic machine hardware */
171181   MCFG_CPU_ADD("maincpu", Z80, 1000000) /* Z80? */
172182   MCFG_CPU_PROGRAM_MAP(murogmbl_map)
src/mame/drivers/sothello.c
r10886r10887
4242#include "video/v9938.h"
4343#include "deprecat.h"
4444
45
46class sothello_state : public driver_device
47{
48public:
49   sothello_state(running_machine &machine, const driver_device_config_base &config)
50      : driver_device(machine, config) { }
51
52   int subcpu_status;
53   int soundcpu_busy;
54   int msm_data;
55};
56
57
4558#define VDP_MEM             0x40000
4659
4760#define MAINCPU_CLOCK       (XTAL_21_477MHz/6)
r10886r10887
5164#define SUBCPU_CLOCK        (XTAL_8MHz/4)
5265
5366
54static int subcpu_status=0;
55static int soundcpu_busy=0;
56static int msm_data = 0;
57
5867/* main Z80 */
5968
6069static WRITE8_HANDLER(bank_w)
r10886r10887
8493
8594static READ8_HANDLER( subcpu_halt_set )
8695{
96   sothello_state *state = space->machine->driver_data<sothello_state>();
8797    space->machine->scheduler().synchronize(FUNC(subcpu_suspend));
88    subcpu_status|=2;
98    state->subcpu_status|=2;
8999    return 0;
90100}
91101
92102static READ8_HANDLER( subcpu_halt_clear )
93103{
104   sothello_state *state = space->machine->driver_data<sothello_state>();
94105    space->machine->scheduler().synchronize(FUNC(subcpu_resume));
95    subcpu_status&=~1;
96    subcpu_status&=~2;
106    state->subcpu_status&=~1;
107    state->subcpu_status&=~2;
97108    return 0;
98109}
99110
100111static READ8_HANDLER(subcpu_comm_status )
101112{
102    return subcpu_status;
113   sothello_state *state = space->machine->driver_data<sothello_state>();
114    return state->subcpu_status;
103115}
104116
105117static READ8_HANDLER( soundcpu_status_r )
106118{
107    return soundcpu_busy;
119   sothello_state *state = space->machine->driver_data<sothello_state>();
120    return state->soundcpu_busy;
108121}
109122
110123static ADDRESS_MAP_START( maincpu_mem_map, ADDRESS_SPACE_PROGRAM, 8 )
r10886r10887
149162
150163static WRITE8_HANDLER( msm_data_w )
151164{
152    msm_data = data;
165   sothello_state *state = space->machine->driver_data<sothello_state>();
166    state->msm_data = data;
153167
154168}
155169
156170static WRITE8_HANDLER(soundcpu_busyflag_set_w)
157171{
158    soundcpu_busy=1;
172   sothello_state *state = space->machine->driver_data<sothello_state>();
173    state->soundcpu_busy=1;
159174}
160175
161176static WRITE8_HANDLER(soundcpu_busyflag_reset_w)
162177{
163    soundcpu_busy=0;
178   sothello_state *state = space->machine->driver_data<sothello_state>();
179    state->soundcpu_busy=0;
164180}
165181
166182static WRITE8_HANDLER(soundcpu_int_clear_w)
r10886r10887
187203
188204static void unlock_shared_ram(address_space *space)
189205{
206   sothello_state *state = space->machine->driver_data<sothello_state>();
190207    if(!space->machine->device<cpu_device>("sub")->suspended(SUSPEND_REASON_HALT))
191208    {
192        subcpu_status|=1;
209        state->subcpu_status|=1;
193210    }
194211    else
195212    {
r10886r10887
307324
308325static void adpcm_int(device_t *device)
309326{
327   sothello_state *state = device->machine->driver_data<sothello_state>();
310328    /* only 4 bits are used */
311    msm5205_data_w( device, msm_data & 0x0f );
329    msm5205_data_w( device, state->msm_data & 0x0f );
312330    cputag_set_input_line(device->machine, "soundcpu", 0, ASSERT_LINE );
313331}
314332
r10886r10887
344362    irqhandler
345363};
346364
347static MACHINE_CONFIG_START( sothello, driver_device )
365static MACHINE_CONFIG_START( sothello, sothello_state )
348366
349367    /* basic machine hardware */
350368
src/mame/drivers/tugboat.c
r10886r10887
2828#include "sound/ay8910.h"
2929
3030
31static UINT8 *tugboat_ram;
32//UINT8 *tugboat_score;
31class tugboat_state : public driver_device
32{
33public:
34   tugboat_state(running_machine &machine, const driver_device_config_base &config)
35      : driver_device(machine, config) { }
3336
37   UINT8 *ram;
38   UINT8 hd46505_0_reg[18];
39   UINT8 hd46505_1_reg[18];
40   int reg0;
41   int reg1;
42   int ctrl;
43};
3444
35static UINT8 hd46505_0_reg[18],hd46505_1_reg[18];
3645
37
3846/*  there isn't the usual resistor array anywhere near the color prom,
3947    just four 1k resistors. */
4048static PALETTE_INIT( tugboat )
r10886r10887
6371   because I need the start_addr register to handle scrolling */
6472static WRITE8_HANDLER( tugboat_hd46505_0_w )
6573{
66   static int reg;
67   if (offset == 0) reg = data & 0x0f;
68   else if (reg < 18) hd46505_0_reg[reg] = data;
74   tugboat_state *state = space->machine->driver_data<tugboat_state>();
75   if (offset == 0) state->reg0 = data & 0x0f;
76   else if (state->reg0 < 18) state->hd46505_0_reg[state->reg0] = data;
6977}
7078static WRITE8_HANDLER( tugboat_hd46505_1_w )
7179{
72   static int reg;
73   if (offset == 0) reg = data & 0x0f;
74   else if (reg < 18) hd46505_1_reg[reg] = data;
80   tugboat_state *state = space->machine->driver_data<tugboat_state>();
81   if (offset == 0) state->reg1 = data & 0x0f;
82   else if (state->reg1 < 18) state->hd46505_1_reg[state->reg1] = data;
7583}
7684
7785
7886static WRITE8_HANDLER( tugboat_score_w )
7987{
80      if (offset>=0x8) tugboat_ram[0x291d + 32*offset + 32*(1-8)] = data ^ 0x0f;
81      if (offset<0x8 ) tugboat_ram[0x291d + 32*offset + 32*9] = data ^ 0x0f;
88   tugboat_state *state = space->machine->driver_data<tugboat_state>();
89      if (offset>=0x8) state->ram[0x291d + 32*offset + 32*(1-8)] = data ^ 0x0f;
90      if (offset<0x8 ) state->ram[0x291d + 32*offset + 32*9] = data ^ 0x0f;
8291}
8392
8493static void draw_tilemap(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,
8594      int addr,int gfx0,int gfx1,int transparency)
8695{
96   tugboat_state *state = machine->driver_data<tugboat_state>();
8797   int x,y;
8898
8999   for (y = 0;y < 32;y++)
90100   {
91101      for (x = 0;x < 32;x++)
92102      {
93         int code = (tugboat_ram[addr + 0x400] << 8) | tugboat_ram[addr];
103         int code = (state->ram[addr + 0x400] << 8) | state->ram[addr];
94104         int color = (code & 0x3c00) >> 10;
95105         int rgn;
96106
r10886r10887
117127
118128static SCREEN_UPDATE( tugboat )
119129{
120   int startaddr0 = hd46505_0_reg[0x0c]*256 + hd46505_0_reg[0x0d];
121   int startaddr1 = hd46505_1_reg[0x0c]*256 + hd46505_1_reg[0x0d];
130   tugboat_state *state = screen->machine->driver_data<tugboat_state>();
131   int startaddr0 = state->hd46505_0_reg[0x0c]*256 + state->hd46505_0_reg[0x0d];
132   int startaddr1 = state->hd46505_1_reg[0x0c]*256 + state->hd46505_1_reg[0x0d];
122133
123134
124135   draw_tilemap(screen->machine, bitmap,cliprect,startaddr0,0,1,FALSE);
r10886r10887
127138}
128139
129140
130static int ctrl;
131141
132142static READ8_DEVICE_HANDLER( tugboat_input_r )
133143{
134   if (~ctrl & 0x80)
144   tugboat_state *state = device->machine->driver_data<tugboat_state>();
145   if (~state->ctrl & 0x80)
135146      return input_port_read(device->machine, "IN0");
136   else if (~ctrl & 0x40)
147   else if (~state->ctrl & 0x40)
137148      return input_port_read(device->machine, "IN1");
138   else if (~ctrl & 0x20)
149   else if (~state->ctrl & 0x20)
139150      return input_port_read(device->machine, "IN2");
140   else if (~ctrl & 0x10)
151   else if (~state->ctrl & 0x10)
141152      return input_port_read(device->machine, "IN3");
142153   else
143154      return input_port_read(device->machine, "IN4");
r10886r10887
145156
146157static READ8_DEVICE_HANDLER( tugboat_ctrl_r )
147158{
148   return ctrl;
159   tugboat_state *state = device->machine->driver_data<tugboat_state>();
160   return state->ctrl;
149161}
150162
151163static WRITE8_DEVICE_HANDLER( tugboat_ctrl_w )
152164{
153   ctrl = data;
165   tugboat_state *state = device->machine->driver_data<tugboat_state>();
166   state->ctrl = data;
154167}
155168
156169static const pia6821_interface pia0_intf =
r10886r10887
198211
199212
200213static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
201   AM_RANGE(0x0000, 0x01ff) AM_RAM AM_BASE(&tugboat_ram)
214   AM_RANGE(0x0000, 0x01ff) AM_RAM AM_BASE_MEMBER(tugboat_state, ram)
202215   AM_RANGE(0x1060, 0x1061) AM_DEVWRITE("aysnd", ay8910_address_data_w)
203216   AM_RANGE(0x10a0, 0x10a1) AM_WRITE(tugboat_hd46505_0_w)   /* scrolling is performed changing the start_addr register (0C/0D) */
204217   AM_RANGE(0x10c0, 0x10c1) AM_WRITE(tugboat_hd46505_1_w)
r10886r10887
313326GFXDECODE_END
314327
315328
316static MACHINE_CONFIG_START( tugboat, driver_device )
329static MACHINE_CONFIG_START( tugboat, tugboat_state )
317330   MCFG_CPU_ADD("maincpu", M6502, 2000000)   /* 2 MHz ???? */
318331   MCFG_CPU_PROGRAM_MAP(main_map)
319332   MCFG_CPU_VBLANK_INT("screen", nmi_line_pulse)
src/mame/drivers/gei.c
r10886r10887
7272#include "machine/nvram.h"
7373#include "sound/dac.h"
7474
75static UINT8 drawctrl[3];
76static UINT8 color[8];
7775
76class gei_state : public driver_device
77{
78public:
79   gei_state(running_machine &machine, const driver_device_config_base &config)
80      : driver_device(machine, config) { }
81
82   UINT8 drawctrl[3];
83   UINT8 color[8];
84   int prevoffset;
85   int yadd;
86   int signature_answer;
87   int signature_pos;
88};
89
90
7891static WRITE8_HANDLER( gei_drawctrl_w )
7992{
80   drawctrl[offset] = data;
93   gei_state *state = space->machine->driver_data<gei_state>();
94   state->drawctrl[offset] = data;
8195   if (offset == 2)
8296   {
8397      int i;
8498      for (i = 0; i < 8; i++)
85         if (BIT(drawctrl[1],i)) color[i] = drawctrl[0] & 7;
99         if (BIT(state->drawctrl[1],i)) state->color[i] = state->drawctrl[0] & 7;
86100   }
87101}
88102
89103static WRITE8_HANDLER( gei_bitmap_w )
90104{
105   gei_state *state = space->machine->driver_data<gei_state>();
91106   int sx,sy;
92   static int prevoffset, yadd;
93107   int i;
94108
95   yadd = (offset==prevoffset) ? (yadd+1):0;
96   prevoffset = offset;
109   state->yadd = (offset==state->prevoffset) ? (state->yadd+1):0;
110   state->prevoffset = offset;
97111
98112   sx = 8 * (offset % 64);
99113   sy = offset / 64;
100   sy = (sy + yadd) & 0xff;
114   sy = (sy + state->yadd) & 0xff;
101115
102116
103117   for (i = 0; i < 8; i++)
104      *BITMAP_ADDR16(space->machine->generic.tmpbitmap, sy, sx+i) = color[8-i-1];
118      *BITMAP_ADDR16(space->machine->generic.tmpbitmap, sy, sx+i) = state->color[8-i-1];
105119}
106120
107121static PALETTE_INIT(gei)
r10886r10887
332346}
333347
334348/* This signature is used to validate the ROMs in sportauth. Simple protection check? */
335static int signature_answer,signature_pos;
336349
337350static READ8_HANDLER( signature_r )
338351{
339   return signature_answer;
352   gei_state *state = space->machine->driver_data<gei_state>();
353   return state->signature_answer;
340354}
341355
342356static WRITE8_HANDLER( signature_w )
343357{
344   if (data == 0) signature_pos = 0;
358   gei_state *state = space->machine->driver_data<gei_state>();
359   if (data == 0) state->signature_pos = 0;
345360   else
346361   {
347362      static const UINT8 signature[8] = { 0xff, 0x01, 0xfd, 0x05, 0xf5, 0x15, 0xd5, 0x55 };
348363
349      signature_answer = signature[signature_pos++];
364      state->signature_answer = signature[state->signature_pos++];
350365
351      signature_pos &= 7;   /* safety; shouldn't happen */
366      state->signature_pos &= 7;   /* safety; shouldn't happen */
352367   }
353368}
354369
355370static WRITE8_HANDLER( signature2_w )
356371{
357   if (data == 0) signature_pos = 0;
372   gei_state *state = space->machine->driver_data<gei_state>();
373   if (data == 0) state->signature_pos = 0;
358374   else
359375   {
360376      static const UINT8 signature[8] = { 0xff, 0x01, 0xf7, 0x11, 0xd7, 0x51, 0x57, 0x51 };
361377
362      signature_answer = signature[signature_pos++];
378      state->signature_answer = signature[state->signature_pos++];
363379
364      signature_pos &= 7;   /* safety; shouldn't happen */
380      state->signature_pos &= 7;   /* safety; shouldn't happen */
365381   }
366382}
367383
r10886r10887
10471063   }
10481064};
10491065
1050static MACHINE_CONFIG_START( getrivia, driver_device )
1066static MACHINE_CONFIG_START( getrivia, gei_state )
10511067   MCFG_CPU_ADD("maincpu",Z80,4000000) /* 4 MHz */
10521068   MCFG_CPU_PROGRAM_MAP(getrivia_map)
10531069   MCFG_CPU_VBLANK_INT("screen", nmi_line_pulse)
src/mame/drivers/esh.c
r10886r10887
2727#include "machine/laserdsc.h"
2828#include "machine/nvram.h"
2929
30/* From daphne */
31#define PCB_CLOCK (18432000)
3230
31class esh_state : public driver_device
32{
33public:
34   esh_state(running_machine &machine, const driver_device_config_base &config)
35      : driver_device(machine, config) { }
3336
34/* Misc variables */
35static device_t *laserdisc;
37   device_t *laserdisc;
38   UINT8 *tile_ram;
39   UINT8 *tile_control_ram;
40   UINT8 ld_video_visible;
41};
3642
37static UINT8 *tile_ram;
38static UINT8 *tile_control_ram;
3943
40static UINT8 ld_video_visible;
44/* From daphne */
45#define PCB_CLOCK (18432000)
4146
47
4248/* VIDEO GOODS */
4349static SCREEN_UPDATE( esh )
4450{
51   esh_state *state = screen->machine->driver_data<esh_state>();
4552   int charx, chary;
4653
4754   /* clear */
r10886r10887
5461      {
5562         int current_screen_character = (chary*32) + charx;
5663
57         int palIndex  = (tile_control_ram[current_screen_character] & 0x0f);
58         int tileOffs  = (tile_control_ram[current_screen_character] & 0x10) >> 4;
59         //int blinkLine = (tile_control_ram[current_screen_character] & 0x40) >> 6;
60         //int blinkChar = (tile_control_ram[current_screen_character] & 0x80) >> 7;
64         int palIndex  = (state->tile_control_ram[current_screen_character] & 0x0f);
65         int tileOffs  = (state->tile_control_ram[current_screen_character] & 0x10) >> 4;
66         //int blinkLine = (state->tile_control_ram[current_screen_character] & 0x40) >> 6;
67         //int blinkChar = (state->tile_control_ram[current_screen_character] & 0x80) >> 7;
6168
6269         drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[0],
63               tile_ram[current_screen_character] + (0x100 * tileOffs),
70               state->tile_ram[current_screen_character] + (0x100 * tileOffs),
6471               palIndex,
6572               0, 0, charx*8, chary*8, 0);
6673      }
r10886r10887
7582/* MEMORY HANDLERS */
7683static READ8_HANDLER(ldp_read)
7784{
78   return laserdisc_data_r(laserdisc);
85   esh_state *state = space->machine->driver_data<esh_state>();
86   return laserdisc_data_r(state->laserdisc);
7987}
8088
8189static WRITE8_HANDLER(ldp_write)
8290{
83   laserdisc_data_w(laserdisc,data);
91   esh_state *state = space->machine->driver_data<esh_state>();
92   laserdisc_data_w(state->laserdisc,data);
8493}
8594
8695static WRITE8_HANDLER(misc_write)
8796{
97   esh_state *state = space->machine->driver_data<esh_state>();
8898   /* Bit 0 unknown */
8999
90100   if (data & 0x02)
91101      logerror("BEEP!\n");
92102
93103   /* Bit 2 unknown */
94   ld_video_visible = !((data & 0x08) >> 3);
104   state->ld_video_visible = !((data & 0x08) >> 3);
95105
96106   /* Bits 4-7 unknown */
97107   /* They cycle through a repeating pattern though */
r10886r10887
144154static ADDRESS_MAP_START( z80_0_mem, ADDRESS_SPACE_PROGRAM, 8 )
145155   AM_RANGE(0x0000,0x3fff) AM_ROM
146156   AM_RANGE(0xe000,0xe7ff) AM_RAM AM_SHARE("nvram")
147   AM_RANGE(0xf000,0xf3ff) AM_RAM AM_BASE(&tile_ram)
148   AM_RANGE(0xf400,0xf7ff) AM_RAM AM_BASE(&tile_control_ram)
157   AM_RANGE(0xf000,0xf3ff) AM_RAM AM_BASE_MEMBER(esh_state, tile_ram)
158   AM_RANGE(0xf400,0xf7ff) AM_RAM AM_BASE_MEMBER(esh_state, tile_control_ram)
149159ADDRESS_MAP_END
150160
151161
r10886r10887
273283
274284static MACHINE_START( esh )
275285{
276   laserdisc = machine->device("laserdisc");
286   esh_state *state = machine->driver_data<esh_state>();
287   state->laserdisc = machine->device("laserdisc");
277288}
278289
279290
280291/* DRIVER */
281static MACHINE_CONFIG_START( esh, driver_device )
292static MACHINE_CONFIG_START( esh, esh_state )
282293
283294   /* main cpu */
284295   MCFG_CPU_ADD("maincpu", Z80, PCB_CLOCK/6)                  /* The denominator is a Daphne guess based on PacMan's hardware */
src/mame/drivers/statriv2.c
r10886r10887
8383      : driver_device(machine, config) { }
8484
8585   UINT8 *videoram;
86   tilemap_t *tilemap;
87   UINT8 *question_offset;
88   UINT8 question_offset_low;
89   UINT8 question_offset_mid;
90   UINT8 question_offset_high;
91   UINT8 latched_coin;
92   UINT8 last_coin;
8693};
8794
8895
8996#define MASTER_CLOCK      12440000
9097
9198
92static tilemap_t *statriv2_tilemap;
93static UINT8 *question_offset;
94
95static UINT8 question_offset_low;
96static UINT8 question_offset_mid;
97static UINT8 question_offset_high;
98
99static UINT8 latched_coin;
100static UINT8 last_coin;
101
102
103
10499/*************************************
105100 *
106101 *  Tilemap callbacks
r10886r10887
148143
149144static VIDEO_START( horizontal )
150145{
151   statriv2_tilemap = tilemap_create(machine, horizontal_tile_info ,tilemap_scan_rows, 8,15, 64,16);
146   statriv2_state *state = machine->driver_data<statriv2_state>();
147   state->tilemap = tilemap_create(machine, horizontal_tile_info ,tilemap_scan_rows, 8,15, 64,16);
152148}
153149
154150static VIDEO_START( vertical )
155151{
156   statriv2_tilemap = tilemap_create(machine, vertical_tile_info, tilemap_scan_rows, 8,8, 32,32);
152   statriv2_state *state = machine->driver_data<statriv2_state>();
153   state->tilemap = tilemap_create(machine, vertical_tile_info, tilemap_scan_rows, 8,8, 32,32);
157154}
158155
159156
r10886r10887
169166   statriv2_state *state = space->machine->driver_data<statriv2_state>();
170167   UINT8 *videoram = state->videoram;
171168   videoram[offset] = data;
172   tilemap_mark_tile_dirty(statriv2_tilemap, offset & 0x3ff);
169   tilemap_mark_tile_dirty(state->tilemap, offset & 0x3ff);
173170}
174171
175172
r10886r10887
182179
183180static SCREEN_UPDATE( statriv2 )
184181{
182   statriv2_state *state = screen->machine->driver_data<statriv2_state>();
185183   if (tms9927_screen_reset(screen->machine->device("tms")))
186184      bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
187185   else
188      tilemap_draw(bitmap, cliprect, statriv2_tilemap, 0, 0);
186      tilemap_draw(bitmap, cliprect, state->tilemap, 0, 0);
189187   return 0;
190188}
191189
r10886r10887
199197
200198static INTERRUPT_GEN( statriv2_interrupt )
201199{
200   statriv2_state *state = device->machine->driver_data<statriv2_state>();
202201   UINT8 new_coin = input_port_read(device->machine, "COIN");
203202
204203   /* check the coin inputs once per frame */
205   latched_coin |= new_coin & (new_coin ^ last_coin);
206   last_coin = new_coin;
204   state->latched_coin |= new_coin & (new_coin ^ state->last_coin);
205   state->last_coin = new_coin;
207206
208207   cpu_set_input_line(device, I8085_RST75_LINE, ASSERT_LINE);
209208   cpu_set_input_line(device, I8085_RST75_LINE, CLEAR_LINE);
r10886r10887
219218
220219static READ8_HANDLER( question_data_r )
221220{
221   statriv2_state *state = space->machine->driver_data<statriv2_state>();
222222   const UINT8 *qrom = space->machine->region("questions")->base();
223223   UINT32 qromsize = space->machine->region("questions")->bytes();
224224   UINT32 address;
225225
226   if (question_offset_high == 0xff)
227      question_offset[question_offset_low]++;
226   if (state->question_offset_high == 0xff)
227      state->question_offset[state->question_offset_low]++;
228228
229   address = question_offset[question_offset_low];
230   address |= question_offset[question_offset_mid] << 8;
231   if (question_offset_high != 0xff)
232      address |= question_offset[question_offset_high] << 16;
229   address = state->question_offset[state->question_offset_low];
230   address |= state->question_offset[state->question_offset_mid] << 8;
231   if (state->question_offset_high != 0xff)
232      address |= state->question_offset[state->question_offset_high] << 16;
233233
234234   return (address < qromsize) ? qrom[address] : 0xff;
235235}
r10886r10887
244244
245245static CUSTOM_INPUT( latched_coin_r )
246246{
247   return latched_coin;
247   statriv2_state *state = field->port->machine->driver_data<statriv2_state>();
248   return state->latched_coin;
248249}
249250
250251
251252static WRITE8_DEVICE_HANDLER( ppi_portc_hi_w )
252253{
254   statriv2_state *state = device->machine->driver_data<statriv2_state>();
253255   data >>= 4;
254256   if (data != 0x0f)
255      latched_coin = 0;
257      state->latched_coin = 0;
256258}
257259
258260
r10886r10887
295297
296298static ADDRESS_MAP_START( statriv2_io_map, ADDRESS_SPACE_IO, 8 )
297299   AM_RANGE(0x20, 0x23) AM_DEVREADWRITE("ppi", ppi8255_r, ppi8255_w)
298   AM_RANGE(0x28, 0x2b) AM_READ(question_data_r) AM_WRITEONLY AM_BASE(&question_offset)
300   AM_RANGE(0x28, 0x2b) AM_READ(question_data_r) AM_WRITEONLY AM_BASE_MEMBER(statriv2_state, question_offset)
299301   AM_RANGE(0xb0, 0xb1) AM_DEVWRITE("aysnd", ay8910_address_data_w)
300302   AM_RANGE(0xb1, 0xb1) AM_DEVREAD("aysnd", ay8910_r)
301303   AM_RANGE(0xc0, 0xcf) AM_DEVREADWRITE("tms", tms9927_r, tms9927_w)
r10886r10887
10001002/* question address is stored as L/H/X (low/high/don't care) */
10011003static DRIVER_INIT( addr_lhx )
10021004{
1003   question_offset_low = 0;
1004   question_offset_mid = 1;
1005   question_offset_high = 0xff;
1005   statriv2_state *state = machine->driver_data<statriv2_state>();
1006   state->question_offset_low = 0;
1007   state->question_offset_mid = 1;
1008   state->question_offset_high = 0xff;
10061009}
10071010
10081011/* question address is stored as X/L/H (don't care/low/high) */
10091012static DRIVER_INIT( addr_xlh )
10101013{
1011   question_offset_low = 1;
1012   question_offset_mid = 2;
1013   question_offset_high = 0xff;
1014   statriv2_state *state = machine->driver_data<statriv2_state>();
1015   state->question_offset_low = 1;
1016   state->question_offset_mid = 2;
1017   state->question_offset_high = 0xff;
10141018}
10151019
10161020/* question address is stored as X/H/L (don't care/high/low) */
10171021static DRIVER_INIT( addr_xhl )
10181022{
1019   question_offset_low = 2;
1020   question_offset_mid = 1;
1021   question_offset_high = 0xff;
1023   statriv2_state *state = machine->driver_data<statriv2_state>();
1024   state->question_offset_low = 2;
1025   state->question_offset_mid = 1;
1026   state->question_offset_high = 0xff;
10221027}
10231028
10241029/* question address is stored as L/M/H (low/mid/high) */
10251030static DRIVER_INIT( addr_lmh )
10261031{
1027   question_offset_low = 0;
1028   question_offset_mid = 1;
1029   question_offset_high = 2;
1032   statriv2_state *state = machine->driver_data<statriv2_state>();
1033   state->question_offset_low = 0;
1034   state->question_offset_mid = 1;
1035   state->question_offset_high = 2;
10301036}
10311037
10321038static DRIVER_INIT( addr_lmhe )
src/mame/drivers/carrera.c
r10886r10887
5151#include "sound/ay8910.h"
5252#include "video/mc6845.h"
5353
54static UINT8* carrera_tileram;
5554
55class carrera_state : public driver_device
56{
57public:
58   carrera_state(running_machine &machine, const driver_device_config_base &config)
59      : driver_device(machine, config) { }
5660
61   UINT8* tileram;
62};
5763
64
5865static ADDRESS_MAP_START( carrera_map, ADDRESS_SPACE_PROGRAM, 8 )
5966   AM_RANGE(0x0000, 0x4fff) AM_ROM
6067   AM_RANGE(0xe000, 0xe7ff) AM_RAM
6168   AM_RANGE(0xe800, 0xe800) AM_DEVWRITE("crtc", mc6845_address_w)
6269   AM_RANGE(0xe801, 0xe801) AM_DEVWRITE("crtc", mc6845_register_w)
63   AM_RANGE(0xf000, 0xffff) AM_RAM AM_BASE(&carrera_tileram)
70   AM_RANGE(0xf000, 0xffff) AM_RAM AM_BASE_MEMBER(carrera_state, tileram)
6471ADDRESS_MAP_END
6572
6673static ADDRESS_MAP_START( io_map, ADDRESS_SPACE_IO, 8 )
r10886r10887
239246
240247static SCREEN_UPDATE(carrera)
241248{
249   carrera_state *state = screen->machine->driver_data<carrera_state>();
242250
243251   int x,y;
244252   int count = 0;
r10886r10887
247255   {
248256      for (x=0;x<64;x++)
249257      {
250         int tile = carrera_tileram[count&0x7ff] | carrera_tileram[(count&0x7ff)+0x800]<<8;
258         int tile = state->tileram[count&0x7ff] | state->tileram[(count&0x7ff)+0x800]<<8;
251259
252260         drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[0],tile,0,0,0,x*8,y*8);
253261         count++;
r10886r10887
313321};
314322
315323
316static MACHINE_CONFIG_START( carrera, driver_device )
324static MACHINE_CONFIG_START( carrera, carrera_state )
317325   /* basic machine hardware */
318326   MCFG_CPU_ADD("maincpu", Z80, MASTER_CLOCK / 6)
319327   MCFG_CPU_PROGRAM_MAP(carrera_map)
src/mame/drivers/ttchamp.c
r10886r10887
4444#include "emu.h"
4545#include "cpu/nec/nec.h"
4646
47static UINT16 *peno_vram;
4847
48class ttchamp_state : public driver_device
49{
50public:
51   ttchamp_state(running_machine &machine, const driver_device_config_base &config)
52      : driver_device(machine, config) { }
4953
54   UINT16 *peno_vram;
55   UINT16 paloff;
56};
57
58
5059static VIDEO_START(ttchamp)
5160{
5261}
5362
5463static SCREEN_UPDATE(ttchamp)
5564{
65   ttchamp_state *state = screen->machine->driver_data<ttchamp_state>();
5666   int y,x,count;
5767//  int i;
5868   static const int xxx=320,yyy=204;
r10886r10887
7585   {
7686      for(x=0;x<xxx;x++)
7787      {
78         /*if(hotblock_port0&0x40)*/*BITMAP_ADDR16(bitmap, y, x) = ((UINT8 *)peno_vram)[BYTE_XOR_LE(count)]+0x300;
88         /*if(hotblock_port0&0x40)*/*BITMAP_ADDR16(bitmap, y, x) = ((UINT8 *)state->peno_vram)[BYTE_XOR_LE(count)]+0x300;
7989            count++;
8090        }
8191    }
8292    return 0;
8393}
8494
85static UINT16 paloff;
8695
8796static WRITE16_HANDLER( paloff_w )
8897{
89    COMBINE_DATA(&paloff);
98   ttchamp_state *state = space->machine->driver_data<ttchamp_state>();
99    COMBINE_DATA(&state->paloff);
90100}
91101
92102#ifdef UNUSED_FUNCTION
r10886r10887
105115
106116static WRITE16_HANDLER( paldat_w )
107117{
108    palette_set_color_rgb(space->machine,paloff & 0x7fff,pal5bit(data>>0),pal5bit(data>>5),pal5bit(data>>10));
118   ttchamp_state *state = space->machine->driver_data<ttchamp_state>();
119    palette_set_color_rgb(space->machine,state->paloff & 0x7fff,pal5bit(data>>0),pal5bit(data>>5),pal5bit(data>>10));
109120}
110121
111122static READ16_HANDLER( peno_rand )
r10886r10887
122133
123134static ADDRESS_MAP_START( ttchamp_map, ADDRESS_SPACE_PROGRAM, 16 )
124135    AM_RANGE(0x00000, 0x0ffff) AM_RAM
125    AM_RANGE(0x10000, 0x1ffff) AM_RAM AM_BASE(&peno_vram)
136    AM_RANGE(0x10000, 0x1ffff) AM_RAM AM_BASE_MEMBER(ttchamp_state, peno_vram)
126137    AM_RANGE(0x20000, 0x7ffff) AM_ROMBANK("bank1") // ?
127138    AM_RANGE(0x80000, 0xfffff) AM_ROMBANK("bank2") // ?
128139ADDRESS_MAP_END
r10886r10887
222233   cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
223234}
224235
225static MACHINE_CONFIG_START( ttchamp, driver_device )
236static MACHINE_CONFIG_START( ttchamp, ttchamp_state )
226237   /* basic machine hardware */
227238   MCFG_CPU_ADD("maincpu", V30, 8000000)
228239   MCFG_CPU_PROGRAM_MAP(ttchamp_map)
src/mame/drivers/goldnpkr.c
r10886r10887
699699#include "goldnpkr.lh"
700700
701701
702class goldnpkr_state : public driver_device
703{
704public:
705   goldnpkr_state(running_machine &machine, const driver_device_config_base &config)
706      : driver_device(machine, config) { }
707
708   UINT8 *videoram;
709   UINT8 *colorram;
710   tilemap_t *bg_tilemap;
711   int mux_data;
712   UINT8 pia0_PA_data;
713};
714
715
702716/*********************************************
703717*               Video Hardware               *
704718*********************************************/
705719
706static UINT8 *videoram;
707static UINT8 *colorram;
708static tilemap_t *bg_tilemap;
709720
710721static WRITE8_HANDLER( goldnpkr_videoram_w )
711722{
712   videoram[offset] = data;
713   tilemap_mark_tile_dirty(bg_tilemap, offset);
723   goldnpkr_state *state = space->machine->driver_data<goldnpkr_state>();
724   state->videoram[offset] = data;
725   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
714726}
715727
716728static WRITE8_HANDLER( goldnpkr_colorram_w )
717729{
718   colorram[offset] = data;
719   tilemap_mark_tile_dirty(bg_tilemap, offset);
730   goldnpkr_state *state = space->machine->driver_data<goldnpkr_state>();
731   state->colorram[offset] = data;
732   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
720733}
721734
722735static TILE_GET_INFO( get_bg_tile_info )
723736{
737   goldnpkr_state *state = machine->driver_data<goldnpkr_state>();
724738/*  - bits -
725739    7654 3210
726740    --xx xx--   tiles color.
r10886r10887
729743    xx-- ----   unused.
730744*/
731745
732   int attr = colorram[tile_index];
733   int code = ((attr & 1) << 8) | videoram[tile_index];
746   int attr = state->colorram[tile_index];
747   int code = ((attr & 1) << 8) | state->videoram[tile_index];
734748   int bank = (attr & 0x02) >> 1;   /* bit 1 switch the gfx banks */
735749   int color = (attr & 0x3c) >> 2;   /* bits 2-3-4-5 for color */
736750
r10886r10887
739753
740754static TILE_GET_INFO( xtnd_get_bg_tile_info )
741755{
756   goldnpkr_state *state = machine->driver_data<goldnpkr_state>();
742757/* 3 graphics banks system for VK extended cards
743758
744759    - bits -
r10886r10887
748763    -x-- ---x   unused.
749764*/
750765
751   int attr = colorram[tile_index];
752   int code = ((attr & 1) << 8) | videoram[tile_index];
766   int attr = state->colorram[tile_index];
767   int code = ((attr & 1) << 8) | state->videoram[tile_index];
753768   int bank = ((attr & 0x02) >> 1) + ((attr & 0x80) >> 7);   /* bit 1 & 7 switch the gfx banks */
754769   int color = (attr & 0x3c) >> 2;   /* bits 2-3-4-5 for color */
755770
r10886r10887
758773
759774static VIDEO_START( goldnpkr )
760775{
761   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
776   goldnpkr_state *state = machine->driver_data<goldnpkr_state>();
777   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
762778}
763779
764780static VIDEO_START( wcrdxtnd )
765781{
766   bg_tilemap = tilemap_create(machine, xtnd_get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
782   goldnpkr_state *state = machine->driver_data<goldnpkr_state>();
783   state->bg_tilemap = tilemap_create(machine, xtnd_get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
767784}
768785
769786static SCREEN_UPDATE( goldnpkr )
770787{
771   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
788   goldnpkr_state *state = screen->machine->driver_data<goldnpkr_state>();
789   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
772790   return 0;
773791}
774792
r10886r10887
912930*               R/W Handlers               *
913931*******************************************/
914932
915static int mux_data = 0;
916static UINT8 pia0_PA_data;
917
918933/* Inputs (buttons) are multiplexed.
919934   There are 4 sets of 5 bits each and are connected to PIA0, portA.
920935   The selector bits are located in PIA1, portB (bits 4-7).
921936*/
922937static READ8_DEVICE_HANDLER( goldnpkr_mux_port_r )
923938{
924   switch( mux_data & 0xf0 )      /* bits 4-7 */
939   goldnpkr_state *state = device->machine->driver_data<goldnpkr_state>();
940   switch( state->mux_data & 0xf0 )      /* bits 4-7 */
925941   {
926942      case 0x10: return input_port_read(device->machine, "IN0-0");
927943      case 0x20: return input_port_read(device->machine, "IN0-1");
r10886r10887
933949
934950static READ8_DEVICE_HANDLER( pottnpkr_mux_port_r )
935951{
952   goldnpkr_state *state = device->machine->driver_data<goldnpkr_state>();
936953   UINT8 pa_0_4 = 0xff, pa_7;   /* Temporary place holder for bits 0 to 4 & 7 */
937954
938   switch( mux_data & 0xf0 )      /* bits 4-7 */
955   switch( state->mux_data & 0xf0 )      /* bits 4-7 */
939956   {
940957      case 0x10: return input_port_read(device->machine, "IN0-0");
941958      case 0x20: return input_port_read(device->machine, "IN0-1");
r10886r10887
943960      case 0x80: return input_port_read(device->machine, "IN0-3");
944961   }
945962
946   pa_7 = (pia0_PA_data >> 7) & 1;   /* To do: bit PA5 to pin CB1 */
963   pa_7 = (state->pia0_PA_data >> 7) & 1;   /* To do: bit PA5 to pin CB1 */
947964//  popmessage ("mux_port_r: %x ",((pa_0_4 & 0x3f) | (pa_7 << 6) | (pa_7 << 7))) ; /* Equates PA6 to PA7 */
948965
949966   return ( (pa_0_4 & 0x3f) | (pa_7 << 6) | (pa_7 << 7) ) ;
r10886r10887
951968
952969static WRITE8_DEVICE_HANDLER( mux_w )
953970{
954   mux_data = data ^ 0xff;   /* inverted */
971   goldnpkr_state *state = device->machine->driver_data<goldnpkr_state>();
972   state->mux_data = data ^ 0xff;   /* inverted */
955973}
956974
957975static WRITE8_DEVICE_HANDLER( mux_port_w )
958976{
959   pia0_PA_data = data;
977   goldnpkr_state *state = device->machine->driver_data<goldnpkr_state>();
978   state->pia0_PA_data = data;
960979}
961980
962981
r10886r10887
10631082   AM_RANGE(0x0801, 0x0801) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
10641083   AM_RANGE(0x0844, 0x0847) AM_DEVREADWRITE("pia0", pia6821_r, pia6821_w)
10651084   AM_RANGE(0x0848, 0x084b) AM_DEVREADWRITE("pia1", pia6821_r, pia6821_w)
1066   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(goldnpkr_videoram_w) AM_BASE(&videoram)
1067   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(goldnpkr_colorram_w) AM_BASE(&colorram)
1085   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(goldnpkr_videoram_w) AM_BASE_MEMBER(goldnpkr_state, videoram)
1086   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(goldnpkr_colorram_w) AM_BASE_MEMBER(goldnpkr_state, colorram)
10681087   AM_RANGE(0x2000, 0x7fff) AM_ROM /* superdbl uses 0x2000..0x3fff address space */
10691088ADDRESS_MAP_END
10701089
r10886r10887
10751094   AM_RANGE(0x0801, 0x0801) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
10761095   AM_RANGE(0x0844, 0x0847) AM_DEVREADWRITE("pia0", pia6821_r, pia6821_w)
10771096   AM_RANGE(0x0848, 0x084b) AM_DEVREADWRITE("pia1", pia6821_r, pia6821_w)
1078   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(goldnpkr_videoram_w) AM_BASE(&videoram)
1079   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(goldnpkr_colorram_w) AM_BASE(&colorram)
1097   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(goldnpkr_videoram_w) AM_BASE_MEMBER(goldnpkr_state, videoram)
1098   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(goldnpkr_colorram_w) AM_BASE_MEMBER(goldnpkr_state, colorram)
10801099   AM_RANGE(0x2000, 0x3fff) AM_ROM
10811100ADDRESS_MAP_END
10821101
r10886r10887
10871106   AM_RANGE(0x0801, 0x0801) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
10881107   AM_RANGE(0x0844, 0x0847) AM_DEVREADWRITE("pia0", pia6821_r, pia6821_w)
10891108   AM_RANGE(0x0848, 0x084b) AM_DEVREADWRITE("pia1", pia6821_r, pia6821_w)
1090   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(goldnpkr_videoram_w) AM_BASE(&videoram)
1091   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(goldnpkr_colorram_w) AM_BASE(&colorram)
1109   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(goldnpkr_videoram_w) AM_BASE_MEMBER(goldnpkr_state, videoram)
1110   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(goldnpkr_colorram_w) AM_BASE_MEMBER(goldnpkr_state, colorram)
10921111   AM_RANGE(0x2000, 0x2000) AM_READ_PORT("SW2")
10931112//  AM_RANGE(0x2108, 0x210b) AM_NOP /* unknown 40-pin device */
10941113   AM_RANGE(0x4000, 0x7fff) AM_ROM
r10886r10887
11111130   AM_RANGE(0x0000, 0x07ff) AM_RAM AM_SHARE("nvram")   /* battery backed RAM */
11121131   AM_RANGE(0x0844, 0x0847) AM_DEVREADWRITE("pia0", pia6821_r, pia6821_w)
11131132   AM_RANGE(0x0848, 0x084b) AM_DEVREADWRITE("pia1", pia6821_r, pia6821_w)
1114   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(goldnpkr_videoram_w) AM_BASE(&videoram)
1115   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(goldnpkr_colorram_w) AM_BASE(&colorram)
1133   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(goldnpkr_videoram_w) AM_BASE_MEMBER(goldnpkr_state, videoram)
1134   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(goldnpkr_colorram_w) AM_BASE_MEMBER(goldnpkr_state, colorram)
11161135   AM_RANGE(0x2000, 0x2000) AM_READ_PORT("SW2")
11171136   AM_RANGE(0x2100, 0x2100) AM_DEVWRITE("crtc", mc6845_address_w)
11181137   AM_RANGE(0x2101, 0x2101) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
r10886r10887
11261145   AM_RANGE(0x0801, 0x0801) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
11271146   AM_RANGE(0x0844, 0x0847) AM_DEVREADWRITE("pia0", pia6821_r, pia6821_w)
11281147   AM_RANGE(0x0848, 0x084b) AM_DEVREADWRITE("pia1", pia6821_r, pia6821_w)
1129   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(goldnpkr_videoram_w) AM_BASE(&videoram)
1130   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(goldnpkr_colorram_w) AM_BASE(&colorram)
1148   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(goldnpkr_videoram_w) AM_BASE_MEMBER(goldnpkr_state, videoram)
1149   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(goldnpkr_colorram_w) AM_BASE_MEMBER(goldnpkr_state, colorram)
11311150   AM_RANGE(0x2000, 0x2000) AM_READ_PORT("SW2")
11321151   AM_RANGE(0x2200, 0x27ff) AM_ROM   /* for VK set */
11331152   AM_RANGE(0x2800, 0x2fff) AM_RAM   /* for VK set */
r10886r10887
11471166   AM_RANGE(0x0801, 0x0801) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
11481167   AM_RANGE(0x0844, 0x0847) AM_DEVREADWRITE("pia0", pia6821_r, pia6821_w)
11491168   AM_RANGE(0x0848, 0x084b) AM_DEVREADWRITE("pia1", pia6821_r, pia6821_w)
1150   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(goldnpkr_videoram_w) AM_BASE(&videoram)
1151   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(goldnpkr_colorram_w) AM_BASE(&colorram)
1169   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(goldnpkr_videoram_w) AM_BASE_MEMBER(goldnpkr_state, videoram)
1170   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(goldnpkr_colorram_w) AM_BASE_MEMBER(goldnpkr_state, colorram)
11521171   AM_RANGE(0x2000, 0x2000) AM_READ_PORT("SW2")
11531172   AM_RANGE(0x2200, 0x27ff) AM_ROM   /* for VK hardware */
11541173   AM_RANGE(0x2800, 0x2fff) AM_RAM   AM_SHARE("nvram")   /* Dallas ds1210 + battery backed RAM */
r10886r10887
11661185   AM_RANGE(0x0000, 0x07ff) AM_RAM AM_SHARE("nvram")   /* battery backed RAM */
11671186   AM_RANGE(0x0844, 0x0847) AM_DEVREADWRITE("pia0", pia6821_r, pia6821_w)
11681187   AM_RANGE(0x0848, 0x084b) AM_DEVREADWRITE("pia1", pia6821_r, pia6821_w)
1169   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(goldnpkr_videoram_w) AM_BASE(&videoram)
1170   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(goldnpkr_colorram_w) AM_BASE(&colorram)
1188   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(goldnpkr_videoram_w) AM_BASE_MEMBER(goldnpkr_state, videoram)
1189   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(goldnpkr_colorram_w) AM_BASE_MEMBER(goldnpkr_state, colorram)
11711190   AM_RANGE(0x2000, 0x2000) AM_READ_PORT("SW2")
11721191   AM_RANGE(0x2100, 0x2100) AM_DEVWRITE("crtc", mc6845_address_w)
11731192   AM_RANGE(0x2101, 0x2101) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
r10886r10887
12011220   AM_RANGE(0x0801, 0x0801) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
12021221   AM_RANGE(0x0844, 0x0847) AM_DEVREADWRITE("pia0", pia6821_r, pia6821_w)
12031222   AM_RANGE(0x0848, 0x084b) AM_DEVREADWRITE("pia1", pia6821_r, pia6821_w)
1204   AM_RANGE(0x1000, 0x17ff) AM_RAM_WRITE(goldnpkr_videoram_w) AM_BASE(&videoram)
1205   AM_RANGE(0x1800, 0x1fff) AM_RAM_WRITE(goldnpkr_colorram_w) AM_BASE(&colorram)
1223   AM_RANGE(0x1000, 0x17ff) AM_RAM_WRITE(goldnpkr_videoram_w) AM_BASE_MEMBER(goldnpkr_state, videoram)
1224   AM_RANGE(0x1800, 0x1fff) AM_RAM_WRITE(goldnpkr_colorram_w) AM_BASE_MEMBER(goldnpkr_state, colorram)
12061225   AM_RANGE(0x2000, 0x3fff) AM_ROM
12071226ADDRESS_MAP_END
12081227
r10886r10887
28862905*              Machine Drivers               *
28872906*********************************************/
28882907
2889static MACHINE_CONFIG_START( goldnpkr_base, driver_device )
2908static MACHINE_CONFIG_START( goldnpkr_base, goldnpkr_state )
28902909
28912910   /* basic machine hardware */
28922911   MCFG_CPU_ADD("maincpu", M6502, CPU_CLOCK)
src/mame/drivers/tickee.c
r10886r10887
2828#include "sound/okim6295.h"
2929#include "machine/nvram.h"
3030
31#define CPU_CLOCK         XTAL_40MHz
32#define VIDEO_CLOCK         XTAL_14_31818MHz
33#define OKI_CLOCK         XTAL_1MHz
3431
32class tickee_state : public driver_device
33{
34public:
35   tickee_state(running_machine &machine, const driver_device_config_base &config)
36      : driver_device(machine, config) { }
3537
36/* local variables */
37static UINT16 *tickee_control;
38static UINT16 *tickee_vram;
39static emu_timer *setup_gun_timer;
38   UINT16 *control;
39   UINT16 *vram;
40   emu_timer *setup_gun_timer;
41   int beamxadd;
42   int beamyadd;
43   int palette_bank;
44   UINT8 gunx[2];
45};
4046
41static int beamxadd;
42static int beamyadd;
43static int palette_bank;
44static UINT8 gunx[2];
4547
48#define CPU_CLOCK         XTAL_40MHz
49#define VIDEO_CLOCK         XTAL_14_31818MHz
50#define OKI_CLOCK         XTAL_1MHz
4651
4752
4853/*************************************
r10886r10887
6974
7075static TIMER_CALLBACK( trigger_gun_interrupt )
7176{
77   tickee_state *state = machine->driver_data<tickee_state>();
7278   int which = param & 1;
7379   int beamx = (machine->primary_screen->hpos()/2)-58;
7480
7581   /* once we're ready to fire, set the X coordinate and assert the line */
76   gunx[which] = beamx;
82   state->gunx[which] = beamx;
7783
7884   /* fire the IRQ at the correct moment */
7985   cputag_set_input_line(machine, "maincpu", param, ASSERT_LINE);
r10886r10887
8995
9096static TIMER_CALLBACK( setup_gun_interrupts )
9197{
98   tickee_state *state = machine->driver_data<tickee_state>();
9299   int beamx, beamy;
93100
94101   /* set a timer to do this again next frame */
95   setup_gun_timer->adjust(machine->primary_screen->time_until_pos(0));
102   state->setup_gun_timer->adjust(machine->primary_screen->time_until_pos(0));
96103
97104   /* only do work if the palette is flashed */
98   if (tickee_control)
99      if (!tickee_control[2])
105   if (state->control)
106      if (!state->control[2])
100107         return;
101108
102109   /* generate interrupts for player 1's gun */
103110   get_crosshair_xy(machine, 0, &beamx, &beamy);
104   machine->scheduler().timer_set(machine->primary_screen->time_until_pos(beamy + beamyadd, beamx + beamxadd), FUNC(trigger_gun_interrupt), 0);
105   machine->scheduler().timer_set(machine->primary_screen->time_until_pos(beamy + beamyadd + 1, beamx + beamxadd), FUNC(clear_gun_interrupt), 0);
111   machine->scheduler().timer_set(machine->primary_screen->time_until_pos(beamy + state->beamyadd, beamx + state->beamxadd), FUNC(trigger_gun_interrupt), 0);
112   machine->scheduler().timer_set(machine->primary_screen->time_until_pos(beamy + state->beamyadd + 1, beamx + state->beamxadd), FUNC(clear_gun_interrupt), 0);
106113
107114   /* generate interrupts for player 2's gun */
108115   get_crosshair_xy(machine, 1, &beamx, &beamy);
109   machine->scheduler().timer_set(machine->primary_screen->time_until_pos(beamy + beamyadd, beamx + beamxadd), FUNC(trigger_gun_interrupt), 1);
110   machine->scheduler().timer_set(machine->primary_screen->time_until_pos(beamy + beamyadd + 1, beamx + beamxadd), FUNC(clear_gun_interrupt), 1);
116   machine->scheduler().timer_set(machine->primary_screen->time_until_pos(beamy + state->beamyadd, beamx + state->beamxadd), FUNC(trigger_gun_interrupt), 1);
117   machine->scheduler().timer_set(machine->primary_screen->time_until_pos(beamy + state->beamyadd + 1, beamx + state->beamxadd), FUNC(clear_gun_interrupt), 1);
111118}
112119
113120
r10886r10887
120127
121128static VIDEO_START( tickee )
122129{
130   tickee_state *state = machine->driver_data<tickee_state>();
123131   /* start a timer going on the first scanline of every frame */
124   setup_gun_timer = machine->scheduler().timer_alloc(FUNC(setup_gun_interrupts));
125   setup_gun_timer->adjust(machine->primary_screen->time_until_pos(0));
132   state->setup_gun_timer = machine->scheduler().timer_alloc(FUNC(setup_gun_interrupts));
133   state->setup_gun_timer->adjust(machine->primary_screen->time_until_pos(0));
126134}
127135
128136
r10886r10887
135143
136144static void scanline_update(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params)
137145{
138   UINT16 *src = &tickee_vram[(params->rowaddr << 8) & 0x3ff00];
146   tickee_state *state = screen.machine->driver_data<tickee_state>();
147   UINT16 *src = &state->vram[(params->rowaddr << 8) & 0x3ff00];
139148   UINT32 *dest = BITMAP_ADDR32(bitmap, scanline, 0);
140149   const rgb_t *pens = tlc34076_get_pens(screen.machine->device("tlc34076"));
141150   int coladdr = params->coladdr << 1;
142151   int x;
143152
144153   /* blank palette: fill with pen 255 */
145   if (tickee_control[2])
154   if (state->control[2])
146155   {
147156      for (x = params->heblnk; x < params->hsblnk; x++)
148157         dest[x] = pens[0xff];
r10886r10887
160169
161170static void rapidfir_scanline_update(screen_device &screen, bitmap_t *bitmap, int scanline, const tms34010_display_params *params)
162171{
163   UINT16 *src = &tickee_vram[(params->rowaddr << 8) & 0x3ff00];
172   tickee_state *state = screen.machine->driver_data<tickee_state>();
173   UINT16 *src = &state->vram[(params->rowaddr << 8) & 0x3ff00];
164174   UINT32 *dest = BITMAP_ADDR32(bitmap, scanline, 0);
165175   const rgb_t *pens = tlc34076_get_pens(screen.machine->device("tlc34076"));
166176   int coladdr = params->coladdr << 1;
167177   int x;
168178
169   if (palette_bank)
179   if (state->palette_bank)
170180   {
171181      /* blank palette: fill with pen 255 */
172182      for (x = params->heblnk; x < params->hsblnk; x += 2)
r10886r10887
196206
197207static MACHINE_RESET( tickee )
198208{
199   beamxadd = 50;
200   beamyadd = 0;
209   tickee_state *state = machine->driver_data<tickee_state>();
210   state->beamxadd = 50;
211   state->beamyadd = 0;
201212}
202213
203214static MACHINE_RESET( rapidfir )
204215{
205   beamxadd = 0;
206   beamyadd = -5;
216   tickee_state *state = machine->driver_data<tickee_state>();
217   state->beamxadd = 0;
218   state->beamyadd = -5;
207219}
208220
209221
r10886r10887
215227
216228static WRITE16_HANDLER( rapidfir_transparent_w )
217229{
230   tickee_state *state = space->machine->driver_data<tickee_state>();
218231   if (!(data & 0xff00)) mem_mask &= 0x00ff;
219232   if (!(data & 0x00ff)) mem_mask &= 0xff00;
220   COMBINE_DATA(&tickee_vram[offset]);
233   COMBINE_DATA(&state->vram[offset]);
221234}
222235
223236
224237static READ16_HANDLER( rapidfir_transparent_r )
225238{
226   return tickee_vram[offset];
239   tickee_state *state = space->machine->driver_data<tickee_state>();
240   return state->vram[offset];
227241}
228242
229243
230244static void rapidfir_to_shiftreg(address_space *space, UINT32 address, UINT16 *shiftreg)
231245{
246   tickee_state *state = space->machine->driver_data<tickee_state>();
232247   if (address < 0x800000)
233      memcpy(shiftreg, &tickee_vram[TOWORD(address)], TOBYTE(0x2000));
248      memcpy(shiftreg, &state->vram[TOWORD(address)], TOBYTE(0x2000));
234249}
235250
236251
237252static void rapidfir_from_shiftreg(address_space *space, UINT32 address, UINT16 *shiftreg)
238253{
254   tickee_state *state = space->machine->driver_data<tickee_state>();
239255   if (address < 0x800000)
240      memcpy(&tickee_vram[TOWORD(address)], shiftreg, TOBYTE(0x2000));
256      memcpy(&state->vram[TOWORD(address)], shiftreg, TOBYTE(0x2000));
241257}
242258
243259
r10886r10887
250266
251267static WRITE16_HANDLER( tickee_control_w )
252268{
253   UINT16 olddata = tickee_control[offset];
269   tickee_state *state = space->machine->driver_data<tickee_state>();
270   UINT16 olddata = state->control[offset];
254271
255272   /* offsets:
256273
r10886r10887
259276        6 = lamps? (changing all the time)
260277    */
261278
262   COMBINE_DATA(&tickee_control[offset]);
279   COMBINE_DATA(&state->control[offset]);
263280
264281   if (offset == 3)
265282   {
r10886r10887
267284      ticket_dispenser_w(space->machine->device("ticket2"), 0, (data & 4) << 5);
268285   }
269286
270   if (olddata != tickee_control[offset])
271      logerror("%08X:tickee_control_w(%d) = %04X (was %04X)\n", cpu_get_pc(space->cpu), offset, tickee_control[offset], olddata);
287   if (olddata != state->control[offset])
288      logerror("%08X:tickee_control_w(%d) = %04X (was %04X)\n", cpu_get_pc(space->cpu), offset, state->control[offset], olddata);
272289}
273290
274291
r10886r10887
287304
288305static READ16_HANDLER( rapidfir_gun1_r )
289306{
290   return gunx[0];
307   tickee_state *state = space->machine->driver_data<tickee_state>();
308   return state->gunx[0];
291309}
292310
293311
294312static READ16_HANDLER( rapidfir_gun2_r )
295313{
296   return gunx[1];
314   tickee_state *state = space->machine->driver_data<tickee_state>();
315   return state->gunx[1];
297316}
298317
299318
r10886r10887
310329
311330static WRITE16_HANDLER( rapidfir_control_w )
312331{
332   tickee_state *state = space->machine->driver_data<tickee_state>();
313333   /* other bits like control on tickee? */
314334   if (ACCESSING_BITS_0_7)
315      palette_bank = data & 1;
335      state->palette_bank = data & 1;
316336}
317337
318338
r10886r10887
358378 *************************************/
359379
360380static ADDRESS_MAP_START( tickee_map, ADDRESS_SPACE_PROGRAM, 16 )
361   AM_RANGE(0x00000000, 0x003fffff) AM_RAM AM_BASE(&tickee_vram)
381   AM_RANGE(0x00000000, 0x003fffff) AM_RAM AM_BASE_MEMBER(tickee_state, vram)
362382   AM_RANGE(0x02000000, 0x02ffffff) AM_ROM AM_REGION("user1", 0)
363383   AM_RANGE(0x04000000, 0x04003fff) AM_RAM AM_SHARE("nvram")
364384   AM_RANGE(0x04100000, 0x041000ff) AM_DEVREADWRITE8("tlc34076", tlc34076_r, tlc34076_w, 0x00ff)
r10886r10887
366386   AM_RANGE(0x04200000, 0x0420001f) AM_DEVWRITE8("ym1", ay8910_address_data_w, 0x00ff)
367387   AM_RANGE(0x04200100, 0x0420010f) AM_DEVREAD8("ym2", ay8910_r, 0x00ff)
368388   AM_RANGE(0x04200100, 0x0420011f) AM_DEVWRITE8("ym2", ay8910_address_data_w, 0x00ff)
369   AM_RANGE(0x04400000, 0x0440007f) AM_WRITE(tickee_control_w) AM_BASE(&tickee_control)
389   AM_RANGE(0x04400000, 0x0440007f) AM_WRITE(tickee_control_w) AM_BASE_MEMBER(tickee_state, control)
370390   AM_RANGE(0x04400040, 0x0440004f) AM_READ_PORT("IN2")
371391   AM_RANGE(0xc0000000, 0xc00001ff) AM_READWRITE(tms34010_io_register_r, tms34010_io_register_w)
372392   AM_RANGE(0xc0000240, 0xc000025f) AM_WRITENOP      /* seems to be a bug in their code */
r10886r10887
376396
377397/* addreses in the 04x range shifted slightly...*/
378398static ADDRESS_MAP_START( ghoshunt_map, ADDRESS_SPACE_PROGRAM, 16 )
379   AM_RANGE(0x00000000, 0x003fffff) AM_RAM AM_BASE(&tickee_vram)
399   AM_RANGE(0x00000000, 0x003fffff) AM_RAM AM_BASE_MEMBER(tickee_state, vram)
380400   AM_RANGE(0x02000000, 0x02ffffff) AM_ROM AM_REGION("user1", 0)
381401   AM_RANGE(0x04100000, 0x04103fff) AM_RAM AM_SHARE("nvram")
382402   AM_RANGE(0x04200000, 0x042000ff) AM_DEVREADWRITE8("tlc34076", tlc34076_r, tlc34076_w, 0x00ff)
r10886r10887
384404   AM_RANGE(0x04300000, 0x0430001f) AM_DEVWRITE8("ym1", ay8910_address_data_w, 0x00ff)
385405   AM_RANGE(0x04300100, 0x0430010f) AM_DEVREAD8("ym2", ay8910_r, 0x00ff)
386406   AM_RANGE(0x04300100, 0x0430011f) AM_DEVWRITE8("ym2", ay8910_address_data_w, 0x00ff)
387   AM_RANGE(0x04500000, 0x0450007f) AM_WRITE(tickee_control_w) AM_BASE(&tickee_control)
407   AM_RANGE(0x04500000, 0x0450007f) AM_WRITE(tickee_control_w) AM_BASE_MEMBER(tickee_state, control)
388408   AM_RANGE(0xc0000000, 0xc00001ff) AM_READWRITE(tms34010_io_register_r, tms34010_io_register_w)
389409   AM_RANGE(0xc0000240, 0xc000025f) AM_WRITENOP      /* seems to be a bug in their code */
390410   AM_RANGE(0xff000000, 0xffffffff) AM_ROM AM_REGION("user1", 0)
r10886r10887
392412
393413
394414static ADDRESS_MAP_START( mouseatk_map, ADDRESS_SPACE_PROGRAM, 16 )
395   AM_RANGE(0x00000000, 0x003fffff) AM_RAM AM_BASE(&tickee_vram)
415   AM_RANGE(0x00000000, 0x003fffff) AM_RAM AM_BASE_MEMBER(tickee_state, vram)
396416   AM_RANGE(0x02000000, 0x02ffffff) AM_ROM AM_REGION("user1", 0)
397417   AM_RANGE(0x04000000, 0x04003fff) AM_RAM AM_SHARE("nvram")
398418   AM_RANGE(0x04100000, 0x041000ff) AM_DEVREADWRITE8("tlc34076", tlc34076_r, tlc34076_w, 0x00ff)
399419   AM_RANGE(0x04200000, 0x0420000f) AM_DEVREAD8("ym", ay8910_r, 0x00ff)
400420   AM_RANGE(0x04200000, 0x0420000f) AM_DEVWRITE8("ym", ay8910_address_data_w, 0x00ff)
401421   AM_RANGE(0x04200100, 0x0420010f) AM_DEVREADWRITE8_MODERN("oki", okim6295_device, read, write, 0x00ff)
402   AM_RANGE(0x04400000, 0x0440007f) AM_WRITE(tickee_control_w) AM_BASE(&tickee_control)
422   AM_RANGE(0x04400000, 0x0440007f) AM_WRITE(tickee_control_w) AM_BASE_MEMBER(tickee_state, control)
403423   AM_RANGE(0x04400040, 0x0440004f) AM_READ_PORT("IN2") // ?
404424   AM_RANGE(0xc0000000, 0xc00001ff) AM_READWRITE(tms34010_io_register_r, tms34010_io_register_w)
405425   AM_RANGE(0xc0000240, 0xc000025f) AM_WRITENOP      /* seems to be a bug in their code */
r10886r10887
409429
410430/* newer hardware */
411431static ADDRESS_MAP_START( rapidfir_map, ADDRESS_SPACE_PROGRAM, 16 )
412   AM_RANGE(0x00000000, 0x007fffff) AM_RAM AM_BASE(&tickee_vram)
432   AM_RANGE(0x00000000, 0x007fffff) AM_RAM AM_BASE_MEMBER(tickee_state, vram)
413433   AM_RANGE(0x02000000, 0x027fffff) AM_READWRITE(rapidfir_transparent_r, rapidfir_transparent_w)
414434   AM_RANGE(0xc0000000, 0xc00001ff) AM_READWRITE(tms34010_io_register_r, tms34010_io_register_w)
415435   AM_RANGE(0xfc000000, 0xfc00000f) AM_READ(rapidfir_gun1_r)
r10886r10887
732752 *
733753 *************************************/
734754
735static MACHINE_CONFIG_START( tickee, driver_device )
755static MACHINE_CONFIG_START( tickee, tickee_state )
736756
737757   /* basic machine hardware */
738758   MCFG_CPU_ADD("maincpu", TMS34010, XTAL_40MHz)
r10886r10887
776796MACHINE_CONFIG_END
777797
778798
779static MACHINE_CONFIG_START( rapidfir, driver_device )
799static MACHINE_CONFIG_START( rapidfir, tickee_state )
780800
781801   /* basic machine hardware */
782802   MCFG_CPU_ADD("maincpu", TMS34010, XTAL_50MHz)
r10886r10887
804824MACHINE_CONFIG_END
805825
806826
807static MACHINE_CONFIG_START( mouseatk, driver_device )
827static MACHINE_CONFIG_START( mouseatk, tickee_state )
808828
809829   /* basic machine hardware */
810830   MCFG_CPU_ADD("maincpu", TMS34010, XTAL_40MHz)
src/mame/drivers/m92.c
r10886r10887
22342234GAME( 1992, uccopsar, uccops,   uccops,        uccops,   uccops,   ROT0,   "Irem",         "Undercover Cops (Alpha Renewal Version)", 0 )
22352235GAME( 1992, uccopsj,  uccops,   uccops,        uccops,   uccops,   ROT0,   "Irem",         "Undercover Cops (Japan)", 0 )
22362236GAME( 1992, mysticri, 0,        mysticri,      mysticri, mysticri, ROT0,   "Irem",         "Mystic Riders (World)", 0 )
2237GAME( 1992, gunhohki, mysticri, mysticri,      mysticri, mysticri, ROT0,   "Irem",         "Gun Hohki (Japan)", 0 )
2237GAME( 1992, gunhohki, mysticri, mysticri,      mysticri, mysticri, ROT0,   "Irem",         "Mahou Keibitai Gun Hohki (Japan)", 0 )
22382238// cheaply produced Korean board, has original chips, but lacks any proper labels
22392239// main code is also significantly different to the supported original set, so it might just be a legitimate early revision on a cheap board
22402240GAME( 1992, mysticrib,mysticri, mysticri,      mysticri, mysticri, ROT0,   "Irem",         "Mystic Riders (bootleg?)", 0)
src/mame/drivers/vcombat.c
r10886r10887
9090#include "machine/nvram.h"
9191
9292
93static UINT16* m68k_framebuffer[2];
94static UINT16* i860_framebuffer[2][2];
95static UINT16* framebuffer_ctrl;
93class vcombat_state : public driver_device
94{
95public:
96   vcombat_state(running_machine &machine, const driver_device_config_base &config)
97      : driver_device(machine, config) { }
9698
97static UINT16* vid_0_shared_RAM;
98static UINT16* vid_1_shared_RAM;
99   UINT16* m68k_framebuffer[2];
100   UINT16* i860_framebuffer[2][2];
101   UINT16* framebuffer_ctrl;
102   UINT16* vid_0_shared_RAM;
103   UINT16* vid_1_shared_RAM;
104   int crtc_select;
105};
99106
100static int crtc_select;
101107
102
103108static SCREEN_UPDATE( vcombat )
104109{
110   vcombat_state *state = screen->machine->driver_data<vcombat_state>();
105111   int y;
106112   const rgb_t *const pens = tlc34076_get_pens(screen->machine->device("tlc34076"));
107113   device_t *aux = screen->machine->device("aux");
108114
109   UINT16 *m68k_buf = m68k_framebuffer[(*framebuffer_ctrl & 0x20) ? 1 : 0];
110   UINT16 *i860_buf = i860_framebuffer[(screen == aux) ? 1 : 0][0];
115   UINT16 *m68k_buf = state->m68k_framebuffer[(*state->framebuffer_ctrl & 0x20) ? 1 : 0];
116   UINT16 *i860_buf = state->i860_framebuffer[(screen == aux) ? 1 : 0][0];
111117
112118   /* TODO: It looks like the leftmost chunk of the ground should really be on the right side? */
113119   /*       But the i860 draws the background correctly, so it may be an original game issue. */
r10886r10887
152158
153159static WRITE16_HANDLER( main_video_write )
154160{
155   int fb = (*framebuffer_ctrl & 0x20) ? 0 : 1;
156   UINT16 old_data = m68k_framebuffer[fb][offset];
161   vcombat_state *state = space->machine->driver_data<vcombat_state>();
162   int fb = (*state->framebuffer_ctrl & 0x20) ? 0 : 1;
163   UINT16 old_data = state->m68k_framebuffer[fb][offset];
157164
158165   /* Transparency mode? */
159   if (*framebuffer_ctrl & 0x40)
166   if (*state->framebuffer_ctrl & 0x40)
160167   {
161168      if (data == 0x0000)
162169         return;
r10886r10887
166173      if ((data & 0xff00) == 0)
167174         data = (data & 0x00ff) | (old_data & 0xff00);
168175
169      COMBINE_DATA(&m68k_framebuffer[fb][offset]);
176      COMBINE_DATA(&state->m68k_framebuffer[fb][offset]);
170177   }
171178   else
172179   {
173      COMBINE_DATA(&m68k_framebuffer[fb][offset]);
180      COMBINE_DATA(&state->m68k_framebuffer[fb][offset]);
174181   }
175182}
176183
r10886r10887
243250
244251static WRITE64_HANDLER( v0_fb_w )
245252{
253   vcombat_state *state = space->machine->driver_data<vcombat_state>();
246254   /* The frame buffer seems to sit on a 32-bit data bus, while the
247255       i860 uses a 64-bit data bus.  Adjust accordingly.  */
248   char *p = (char *)(i860_framebuffer[0][0]);
256   char *p = (char *)(state->i860_framebuffer[0][0]);
249257   int m = mem_mask;
250258   int o = (offset << 2);
251259   if (m & 0xff000000) {
r10886r10887
266274   framebuffer.  */
267275static WRITE64_HANDLER( v1_fb_w )
268276{
277   vcombat_state *state = space->machine->driver_data<vcombat_state>();
269278   /* The frame buffer seems to sit on a 32-bit data bus, while the
270279       i860 uses a 64-bit data bus.  Adjust accordingly.  */
271   char *p = (char *)(i860_framebuffer[1][0]);
280   char *p = (char *)(state->i860_framebuffer[1][0]);
272281   int m = mem_mask;
273282   int o = (offset << 2);
274283   if (m & 0xff000000) {
r10886r10887
287296
288297static WRITE16_HANDLER( crtc_w )
289298{
299   vcombat_state *state = space->machine->driver_data<vcombat_state>();
290300   device_t *crtc = space->machine->device("crtc");
291301
292302   if (crtc == NULL)
293303      return;
294304
295   if (crtc_select == 0)
305   if (state->crtc_select == 0)
296306      mc6845_address_w(crtc, 0, data >> 8);
297307   else
298308      mc6845_register_w(crtc, 0, data >> 8);
299309
300   crtc_select ^= 1;
310   state->crtc_select ^= 1;
301311}
302312
303313static WRITE16_DEVICE_HANDLER( vcombat_dac_w )
r10886r10887
311321   AM_RANGE(0x200000, 0x20ffff) AM_RAM
312322   AM_RANGE(0x300000, 0x30ffff) AM_WRITE(main_video_write)
313323
314   AM_RANGE(0x400000, 0x43ffff) AM_RAM AM_BASE(&vid_0_shared_RAM) AM_SHARE("share2")   /* First i860 shared RAM */
324   AM_RANGE(0x400000, 0x43ffff) AM_RAM AM_BASE_MEMBER(vcombat_state, vid_0_shared_RAM) AM_SHARE("share2")   /* First i860 shared RAM */
315325   AM_RANGE(0x440000, 0x440003) AM_RAM AM_SHARE("share6")      /* M0->P0 i860 #1 com 1 */
316326   AM_RANGE(0x480000, 0x480003) AM_RAM AM_SHARE("share7")      /* M0<-P0 i860 #1 com 2 */
317327   AM_RANGE(0x4c0000, 0x4c0003) AM_WRITE(wiggle_i860p0_pins_w)   /* i860 #1 stop/start/reset */
318328
319   AM_RANGE(0x500000, 0x53ffff) AM_RAM AM_BASE(&vid_1_shared_RAM) AM_SHARE("share3")   /* Second i860 shared RAM */
329   AM_RANGE(0x500000, 0x53ffff) AM_RAM AM_BASE_MEMBER(vcombat_state, vid_1_shared_RAM) AM_SHARE("share3")   /* Second i860 shared RAM */
320330   AM_RANGE(0x540000, 0x540003) AM_RAM AM_SHARE("share8")      /* M0->P1 i860 #2 com 1 */
321331   AM_RANGE(0x580000, 0x580003) AM_RAM AM_SHARE("share9")      /* M0<-P1 i860 #2 com 2 */
322332   AM_RANGE(0x5c0000, 0x5c0003) AM_WRITE(wiggle_i860p1_pins_w)   /* i860 #2 stop/start/reset */
r10886r10887
327337   AM_RANGE(0x60001c, 0x60001d) AM_NOP
328338
329339   AM_RANGE(0x60000c, 0x60000d) AM_WRITE(crtc_w)
330   AM_RANGE(0x600010, 0x600011) AM_RAM AM_BASE(&framebuffer_ctrl)
340   AM_RANGE(0x600010, 0x600011) AM_RAM AM_BASE_MEMBER(vcombat_state, framebuffer_ctrl)
331341   AM_RANGE(0x700000, 0x7007ff) AM_RAM AM_SHARE("nvram")
332342   AM_RANGE(0x701000, 0x701001) AM_READ(main_irqiack_r)
333343   AM_RANGE(0x702000, 0x702001) AM_READ(control_3_r)
r10886r10887
376386
377387static MACHINE_RESET( vcombat )
378388{
389   vcombat_state *state = machine->driver_data<vcombat_state>();
379390   i860_set_pin(machine->device("vid_0"), DEC_PIN_BUS_HOLD, 1);
380391   i860_set_pin(machine->device("vid_1"), DEC_PIN_BUS_HOLD, 1);
381392
382   crtc_select = 0;
393   state->crtc_select = 0;
383394}
384395
385396static MACHINE_RESET( shadfgtr )
386397{
398   vcombat_state *state = machine->driver_data<vcombat_state>();
387399   i860_set_pin(machine->device("vid_0"), DEC_PIN_BUS_HOLD, 1);
388400
389   crtc_select = 0;
401   state->crtc_select = 0;
390402}
391403
392404
393405DIRECT_UPDATE_HANDLER( vcombat_vid_0_direct_handler )
394406{
407   vcombat_state *state = machine->driver_data<vcombat_state>();
395408   if (address >= 0xfffc0000 && address <= 0xffffffff)
396409   {
397      direct.explicit_configure(0xfffc0000, 0xffffffff, 0x3ffff, vid_0_shared_RAM);
410      direct.explicit_configure(0xfffc0000, 0xffffffff, 0x3ffff, state->vid_0_shared_RAM);
398411      return ~0;
399412   }
400413   return address;
r10886r10887
402415
403416DIRECT_UPDATE_HANDLER( vcombat_vid_1_direct_handler )
404417{
418   vcombat_state *state = machine->driver_data<vcombat_state>();
405419   if (address >= 0xfffc0000 && address <= 0xffffffff)
406420   {
407      direct.explicit_configure(0xfffc0000, 0xffffffff, 0x3ffff, vid_1_shared_RAM);
421      direct.explicit_configure(0xfffc0000, 0xffffffff, 0x3ffff, state->vid_1_shared_RAM);
408422      return ~0;
409423   }
410424   return address;
r10886r10887
413427
414428static DRIVER_INIT( vcombat )
415429{
430   vcombat_state *state = machine->driver_data<vcombat_state>();
416431   UINT8 *ROM = machine->region("maincpu")->base();
417432
418433   /* The two i860s execute out of RAM */
r10886r10887
423438   space->set_direct_update_handler(direct_update_delegate_create_static(vcombat_vid_1_direct_handler, *machine));
424439
425440   /* Allocate the 68000 framebuffers */
426   m68k_framebuffer[0] = auto_alloc_array(machine, UINT16, 0x8000);
427   m68k_framebuffer[1] = auto_alloc_array(machine, UINT16, 0x8000);
441   state->m68k_framebuffer[0] = auto_alloc_array(machine, UINT16, 0x8000);
442   state->m68k_framebuffer[1] = auto_alloc_array(machine, UINT16, 0x8000);
428443
429444   /* First i860 */
430   i860_framebuffer[0][0] = auto_alloc_array(machine, UINT16, 0x8000);
431   i860_framebuffer[0][1] = auto_alloc_array(machine, UINT16, 0x8000);
445   state->i860_framebuffer[0][0] = auto_alloc_array(machine, UINT16, 0x8000);
446   state->i860_framebuffer[0][1] = auto_alloc_array(machine, UINT16, 0x8000);
432447
433448   /* Second i860 */
434   i860_framebuffer[1][0] = auto_alloc_array(machine, UINT16, 0x8000);
435   i860_framebuffer[1][1] = auto_alloc_array(machine, UINT16, 0x8000);
449   state->i860_framebuffer[1][0] = auto_alloc_array(machine, UINT16, 0x8000);
450   state->i860_framebuffer[1][1] = auto_alloc_array(machine, UINT16, 0x8000);
436451
437452   /* pc==4016 : jump 4038 ... There's something strange about how it waits at 402e (interrupts all masked out)
438453       I think what is happening here is that M0 snags the first time
r10886r10887
452467
453468static DRIVER_INIT( shadfgtr )
454469{
470   vcombat_state *state = machine->driver_data<vcombat_state>();
455471   /* Allocate th 68000 frame buffers */
456   m68k_framebuffer[0] = auto_alloc_array(machine, UINT16, 0x8000);
457   m68k_framebuffer[1] = auto_alloc_array(machine, UINT16, 0x8000);
472   state->m68k_framebuffer[0] = auto_alloc_array(machine, UINT16, 0x8000);
473   state->m68k_framebuffer[1] = auto_alloc_array(machine, UINT16, 0x8000);
458474
459475   /* Only one i860 */
460   i860_framebuffer[0][0] = auto_alloc_array(machine, UINT16, 0x8000);
461   i860_framebuffer[0][1] = auto_alloc_array(machine, UINT16, 0x8000);
462   i860_framebuffer[1][0] = NULL;
463   i860_framebuffer[1][1] = NULL;
476   state->i860_framebuffer[0][0] = auto_alloc_array(machine, UINT16, 0x8000);
477   state->i860_framebuffer[0][1] = auto_alloc_array(machine, UINT16, 0x8000);
478   state->i860_framebuffer[1][0] = NULL;
479   state->i860_framebuffer[1][1] = NULL;
464480
465481   /* The i860 executes out of RAM */
466482   address_space *space = machine->device<i860_device>("vid_0")->space(AS_PROGRAM);
r10886r10887
547563};
548564
549565
550static MACHINE_CONFIG_START( vcombat, driver_device )
566static MACHINE_CONFIG_START( vcombat, vcombat_state )
551567   MCFG_CPU_ADD("maincpu", M68000, XTAL_12MHz)
552568   MCFG_CPU_PROGRAM_MAP(main_map)
553569   MCFG_CPU_VBLANK_INT("screen", irq1_line_assert)
r10886r10887
597613MACHINE_CONFIG_END
598614
599615
600static MACHINE_CONFIG_START( shadfgtr, driver_device )
616static MACHINE_CONFIG_START( shadfgtr, vcombat_state )
601617   MCFG_CPU_ADD("maincpu", M68000, XTAL_12MHz)
602618   MCFG_CPU_PROGRAM_MAP(main_map)
603619   MCFG_CPU_VBLANK_INT("screen", irq1_line_assert)
src/mame/drivers/pkscram.c
r10886r10887
1616#include "sound/2203intf.h"
1717#include "machine/nvram.h"
1818
19static int interrupt_scanline=192;
2019
21static UINT16   out = 0;
22static UINT8   interrupt_line_active=0;
20class pkscram_state : public driver_device
21{
22public:
23   pkscram_state(running_machine &machine, const driver_device_config_base &config)
24      : driver_device(machine, config) { }
2325
24static UINT16* pkscramble_fgtilemap_ram;
25static UINT16* pkscramble_mdtilemap_ram;
26static UINT16* pkscramble_bgtilemap_ram;
26   UINT16 out;
27   UINT8 interrupt_line_active;
28   UINT16* pkscramble_fgtilemap_ram;
29   UINT16* pkscramble_mdtilemap_ram;
30   UINT16* pkscramble_bgtilemap_ram;
31   tilemap_t *fg_tilemap;
32   tilemap_t *md_tilemap;
33   tilemap_t *bg_tilemap;
34};
2735
28static tilemap_t *fg_tilemap, *md_tilemap, *bg_tilemap;
2936
37enum { interrupt_scanline=192 };
38
39
3040static WRITE16_HANDLER( pkscramble_fgtilemap_w )
3141{
32   COMBINE_DATA(&pkscramble_fgtilemap_ram[offset]);
33   tilemap_mark_tile_dirty(fg_tilemap, offset >> 1);
42   pkscram_state *state = space->machine->driver_data<pkscram_state>();
43   COMBINE_DATA(&state->pkscramble_fgtilemap_ram[offset]);
44   tilemap_mark_tile_dirty(state->fg_tilemap, offset >> 1);
3445}
3546
3647static WRITE16_HANDLER( pkscramble_mdtilemap_w )
3748{
38   COMBINE_DATA(&pkscramble_mdtilemap_ram[offset]);
39   tilemap_mark_tile_dirty(md_tilemap, offset >> 1);
49   pkscram_state *state = space->machine->driver_data<pkscram_state>();
50   COMBINE_DATA(&state->pkscramble_mdtilemap_ram[offset]);
51   tilemap_mark_tile_dirty(state->md_tilemap, offset >> 1);
4052}
4153
4254static WRITE16_HANDLER( pkscramble_bgtilemap_w )
4355{
44   COMBINE_DATA(&pkscramble_bgtilemap_ram[offset]);
45   tilemap_mark_tile_dirty(bg_tilemap, offset >> 1);
56   pkscram_state *state = space->machine->driver_data<pkscram_state>();
57   COMBINE_DATA(&state->pkscramble_bgtilemap_ram[offset]);
58   tilemap_mark_tile_dirty(state->bg_tilemap, offset >> 1);
4659}
4760
4861// input bit 0x20 in port1 should stay low until bit 0x20 is written here, then
4962// it should stay high for some time (currently we cheat keeping the input always active)
5063static WRITE16_HANDLER( pkscramble_output_w )
5164{
65   pkscram_state *state = space->machine->driver_data<pkscram_state>();
5266   // OUTPUT
5367   // BIT
5468   // 0x0001 -> STL
r10886r10887
6983   // 0x2000 -> vblank interrupt enable
7084   // 0x4000 -> set on every second frame - not used
7185
72   out = data;
86   state->out = data;
7387
74   if (!(out & 0x2000) && interrupt_line_active)
88   if (!(state->out & 0x2000) && state->interrupt_line_active)
7589   {
7690       cputag_set_input_line(space->machine, "maincpu", 1, CLEAR_LINE);
77      interrupt_line_active = 0;
91      state->interrupt_line_active = 0;
7892   }
7993
8094   coin_counter_w(space->machine, 0, data & 0x80);
r10886r10887
8599   AM_RANGE(0x000000, 0x01ffff) AM_ROM
86100   AM_RANGE(0x040000, 0x0400ff) AM_RAM AM_SHARE("nvram")
87101   AM_RANGE(0x041000, 0x043fff) AM_RAM // main ram
88   AM_RANGE(0x044000, 0x044fff) AM_RAM_WRITE(pkscramble_fgtilemap_w) AM_BASE(&pkscramble_fgtilemap_ram) // fg tilemap
89   AM_RANGE(0x045000, 0x045fff) AM_RAM_WRITE(pkscramble_mdtilemap_w) AM_BASE(&pkscramble_mdtilemap_ram) // md tilemap (just a copy of fg?)
90   AM_RANGE(0x046000, 0x046fff) AM_RAM_WRITE(pkscramble_bgtilemap_w) AM_BASE(&pkscramble_bgtilemap_ram) // bg tilemap
102   AM_RANGE(0x044000, 0x044fff) AM_RAM_WRITE(pkscramble_fgtilemap_w) AM_BASE_MEMBER(pkscram_state, pkscramble_fgtilemap_ram) // fg tilemap
103   AM_RANGE(0x045000, 0x045fff) AM_RAM_WRITE(pkscramble_mdtilemap_w) AM_BASE_MEMBER(pkscram_state, pkscramble_mdtilemap_ram) // md tilemap (just a copy of fg?)
104   AM_RANGE(0x046000, 0x046fff) AM_RAM_WRITE(pkscramble_bgtilemap_w) AM_BASE_MEMBER(pkscram_state, pkscramble_bgtilemap_ram) // bg tilemap
91105   AM_RANGE(0x047000, 0x047fff) AM_RAM // unused
92106   AM_RANGE(0x048000, 0x048fff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram)
93107   AM_RANGE(0x049000, 0x049001) AM_READ_PORT("DSW")
r10886r10887
169183
170184static TILE_GET_INFO( get_bg_tile_info )
171185{
172   int tile  = pkscramble_bgtilemap_ram[tile_index*2];
173   int color = pkscramble_bgtilemap_ram[tile_index*2 + 1] & 0x7f;
186   pkscram_state *state = machine->driver_data<pkscram_state>();
187   int tile  = state->pkscramble_bgtilemap_ram[tile_index*2];
188   int color = state->pkscramble_bgtilemap_ram[tile_index*2 + 1] & 0x7f;
174189
175190   SET_TILE_INFO(0,tile,color,0);
176191}
177192
178193static TILE_GET_INFO( get_md_tile_info )
179194{
180   int tile  = pkscramble_mdtilemap_ram[tile_index*2];
181   int color = pkscramble_mdtilemap_ram[tile_index*2 + 1] & 0x7f;
195   pkscram_state *state = machine->driver_data<pkscram_state>();
196   int tile  = state->pkscramble_mdtilemap_ram[tile_index*2];
197   int color = state->pkscramble_mdtilemap_ram[tile_index*2 + 1] & 0x7f;
182198
183199   SET_TILE_INFO(0,tile,color,0);
184200}
185201
186202static TILE_GET_INFO( get_fg_tile_info )
187203{
188   int tile  = pkscramble_fgtilemap_ram[tile_index*2];
189   int color = pkscramble_fgtilemap_ram[tile_index*2 + 1] & 0x7f;
204   pkscram_state *state = machine->driver_data<pkscram_state>();
205   int tile  = state->pkscramble_fgtilemap_ram[tile_index*2];
206   int color = state->pkscramble_fgtilemap_ram[tile_index*2 + 1] & 0x7f;
190207
191208   SET_TILE_INFO(0,tile,color,0);
192209}
193210
194211static TIMER_DEVICE_CALLBACK( scanline_callback )
195212{
213   pkscram_state *state = timer.machine->driver_data<pkscram_state>();
196214   if (param == interrupt_scanline)
197215   {
198       if (out & 0x2000)
216       if (state->out & 0x2000)
199217          cputag_set_input_line(timer.machine, "maincpu", 1, ASSERT_LINE);
200218      timer.adjust(timer.machine->primary_screen->time_until_pos(param + 1), param+1);
201      interrupt_line_active = 1;
219      state->interrupt_line_active = 1;
202220   }
203221   else
204222   {
205      if (interrupt_line_active)
223      if (state->interrupt_line_active)
206224          cputag_set_input_line(timer.machine, "maincpu", 1, CLEAR_LINE);
207225      timer.adjust(timer.machine->primary_screen->time_until_pos(interrupt_scanline), interrupt_scanline);
208      interrupt_line_active = 0;
226      state->interrupt_line_active = 0;
209227   }
210228}
211229
212230static VIDEO_START( pkscramble )
213231{
214   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8,32,32);
215   md_tilemap = tilemap_create(machine, get_md_tile_info, tilemap_scan_rows, 8, 8,32,32);
216   fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8,32,32);
232   pkscram_state *state = machine->driver_data<pkscram_state>();
233   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8,32,32);
234   state->md_tilemap = tilemap_create(machine, get_md_tile_info, tilemap_scan_rows, 8, 8,32,32);
235   state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8,32,32);
217236
218   tilemap_set_transparent_pen(md_tilemap,15);
219   tilemap_set_transparent_pen(fg_tilemap,15);
237   tilemap_set_transparent_pen(state->md_tilemap,15);
238   tilemap_set_transparent_pen(state->fg_tilemap,15);
220239}
221240
222241static SCREEN_UPDATE( pkscramble )
223242{
224   tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
225   tilemap_draw(bitmap,cliprect,md_tilemap,0,0);
226   tilemap_draw(bitmap,cliprect,fg_tilemap,0,0);
243   pkscram_state *state = screen->machine->driver_data<pkscram_state>();
244   tilemap_draw(bitmap,cliprect,state->bg_tilemap,0,0);
245   tilemap_draw(bitmap,cliprect,state->md_tilemap,0,0);
246   tilemap_draw(bitmap,cliprect,state->fg_tilemap,0,0);
227247   return 0;
228248}
229249
r10886r10887
245265
246266static void irqhandler(device_t *device, int irq)
247267{
248   if(out & 0x10)
268   pkscram_state *state = device->machine->driver_data<pkscram_state>();
269   if(state->out & 0x10)
249270      cputag_set_input_line(device->machine, "maincpu", 2, irq ? ASSERT_LINE : CLEAR_LINE);
250271}
251272
r10886r10887
261282
262283static MACHINE_START( pkscramble)
263284{
264   state_save_register_global(machine, out);
265   state_save_register_global(machine, interrupt_line_active);
285   pkscram_state *state = machine->driver_data<pkscram_state>();
286   state_save_register_global(machine, state->out);
287   state_save_register_global(machine, state->interrupt_line_active);
266288}
267289
268290static MACHINE_RESET( pkscramble)
269291{
270   out = 0;
271   interrupt_line_active=0;
292   pkscram_state *state = machine->driver_data<pkscram_state>();
293   state->out = 0;
294   state->interrupt_line_active=0;
272295   timer_device *scanline_timer = machine->device<timer_device>("scan_timer");
273296   scanline_timer->adjust(machine->primary_screen->time_until_pos(interrupt_scanline), interrupt_scanline);
274297}
275298
276static MACHINE_CONFIG_START( pkscramble, driver_device )
299static MACHINE_CONFIG_START( pkscramble, pkscram_state )
277300   /* basic machine hardware */
278301   MCFG_CPU_ADD("maincpu", M68000, 8000000 )
279302   MCFG_CPU_PROGRAM_MAP(pkscramble_map)
src/mame/drivers/fortecar.c
r10886r10887
3131#include "machine/8255ppi.h"
3232#include "video/mc6845.h"
3333
34static UINT8 *fortecar_ram;
35static int bank;
3634
35class fortecar_state : public driver_device
36{
37public:
38   fortecar_state(running_machine &machine, const driver_device_config_base &config)
39      : driver_device(machine, config) { }
40
41   UINT8 *ram;
42   int bank;
43};
44
45
3746static VIDEO_START(fortecar)
3847{
3948}
4049
4150static SCREEN_UPDATE(fortecar)
4251{
52   fortecar_state *state = screen->machine->driver_data<fortecar_state>();
4353   int x,y,count;
4454   count = 0;
4555
r10886r10887
4959      {
5060         int tile,color;
5161
52         tile = (fortecar_ram[(count*4)+1] | (fortecar_ram[(count*4)+2]<<8)) & 0xfff;
53         color = fortecar_ram[(count*4)+3] & 3;
62         tile = (state->ram[(count*4)+1] | (state->ram[(count*4)+2]<<8)) & 0xfff;
63         color = state->ram[(count*4)+3] & 3;
5464
5565         drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[0],tile,color,0,0,x*8,y*8);
5666         count++;
r10886r10887
117127   AM_RANGE(0x0000, 0xbfff) AM_ROM
118128   AM_RANGE(0xc000, 0xc7ff) AM_ROM
119129   AM_RANGE(0xd000, 0xd7ff) AM_RAM
120   AM_RANGE(0xd800, 0xffff) AM_RAM AM_BASE(&fortecar_ram)
130   AM_RANGE(0xd800, 0xffff) AM_RAM AM_BASE_MEMBER(fortecar_state, ram)
121131ADDRESS_MAP_END
122132
123133static ADDRESS_MAP_START( fortecar_ports, ADDRESS_SPACE_IO, 8 )
r10886r10887
244254
245255static MACHINE_RESET(fortecar)
246256{
247   bank = -1;
257   fortecar_state *state = machine->driver_data<fortecar_state>();
258   state->bank = -1;
248259}
249260
250261/* WRONG, just to see something */
r10886r10887
277288};
278289
279290//51f
280static MACHINE_CONFIG_START( fortecar, driver_device )
291static MACHINE_CONFIG_START( fortecar, fortecar_state )
281292   /* basic machine hardware */
282293   MCFG_CPU_ADD("maincpu", Z80,6000000)       /* ? MHz */
283294   MCFG_CPU_PROGRAM_MAP(fortecar_map)
src/mame/drivers/gunpey.c
r10886r10887
5050#include "sound/okim6295.h"
5151#include "sound/ymz280b.h"
5252
53static UINT16 *blit_buffer;
5453
54class gunpey_state : public driver_device
55{
56public:
57   gunpey_state(running_machine &machine, const driver_device_config_base &config)
58      : driver_device(machine, config) { }
59
60   UINT16 *blit_buffer;
61   UINT16 blit_ram[0x10];
62};
63
64
5565static VIDEO_START( gunpey )
5666{
57   blit_buffer = auto_alloc_array(machine, UINT16, 512*512);
67   gunpey_state *state = machine->driver_data<gunpey_state>();
68   state->blit_buffer = auto_alloc_array(machine, UINT16, 512*512);
5869}
5970
6071static SCREEN_UPDATE( gunpey )
6172{
73   gunpey_state *state = screen->machine->driver_data<gunpey_state>();
74   UINT16 *blit_buffer = state->blit_buffer;
6275   int x,y;
6376   int count;
6477
r10886r10887
115128
116129static WRITE8_HANDLER( gunpey_blitter_w )
117130{
118   static UINT16 blit_ram[0x10];
131   gunpey_state *state = space->machine->driver_data<gunpey_state>();
132   UINT16 *blit_buffer = state->blit_buffer;
133   UINT16 *blit_ram = state->blit_ram;
119134   UINT8 *blit_rom = space->machine->region("blit_data")->base();
120135   int x,y;
121136
r10886r10887
313328}
314329
315330/***************************************************************************************/
316static MACHINE_CONFIG_START( gunpey, driver_device )
331static MACHINE_CONFIG_START( gunpey, gunpey_state )
317332
318333   /* basic machine hardware */
319334   MCFG_CPU_ADD("maincpu", V30, 57242400 / 4)
src/mame/drivers/bingor.c
r10886r10887
442442#include "cpu/pic16c5x/pic16c5x.h"
443443#include "sound/saa1099.h"
444444
445static UINT16 *blit_ram;
446445
446class bingor_state : public driver_device
447{
448public:
449   bingor_state(running_machine &machine, const driver_device_config_base &config)
450      : driver_device(machine, config) { }
451
452   UINT16 *blit_ram;
453};
454
455
447456static VIDEO_START(bingor)
448457{
449
450458}
451459
452460static SCREEN_UPDATE(bingor)
453461{
462   bingor_state *state = screen->machine->driver_data<bingor_state>();
454463   int x,y,count;
455464
456465   bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
r10886r10887
463472      {
464473         UINT32 color;
465474
466         color = (blit_ram[count] & 0xf000)>>12;
475         color = (state->blit_ram[count] & 0xf000)>>12;
467476
468477         if((x+3)<screen->visible_area().max_x && ((y)+0)<screen->visible_area().max_y)
469478            *BITMAP_ADDR32(bitmap, y, x+3) = screen->machine->pens[color];
470479
471         color = (blit_ram[count] & 0x0f00)>>8;
480         color = (state->blit_ram[count] & 0x0f00)>>8;
472481
473482         if((x+2)<screen->visible_area().max_x && ((y)+0)<screen->visible_area().max_y)
474483            *BITMAP_ADDR32(bitmap, y, x+2) = screen->machine->pens[color];
475484
476         color = (blit_ram[count] & 0x00f0)>>4;
485         color = (state->blit_ram[count] & 0x00f0)>>4;
477486
478487         if((x+1)<screen->visible_area().max_x && ((y)+0)<screen->visible_area().max_y)
479488            *BITMAP_ADDR32(bitmap, y, x+1) = screen->machine->pens[color];
480489
481         color = (blit_ram[count] & 0x000f)>>0;
490         color = (state->blit_ram[count] & 0x000f)>>0;
482491
483492         if((x+0)<screen->visible_area().max_x && ((y)+0)<screen->visible_area().max_y)
484493            *BITMAP_ADDR32(bitmap, y, x+0) = screen->machine->pens[color];
r10886r10887
501510   AM_RANGE(0x00000, 0x0ffff) AM_RAM
502511   AM_RANGE(0x90000, 0x9ffff) AM_ROM AM_REGION("gfx", 0)
503512   AM_RANGE(0xa0300, 0xa031f) AM_RAM_WRITE(paletteram16_RRRRGGGGBBBBIIII_word_w) AM_BASE_GENERIC(paletteram) //wrong
504   AM_RANGE(0xa0000, 0xaffff) AM_RAM AM_BASE(&blit_ram)
513   AM_RANGE(0xa0000, 0xaffff) AM_RAM AM_BASE_MEMBER(bingor_state, blit_ram)
505514   AM_RANGE(0xe0000, 0xfffff) AM_ROM AM_REGION("boot_prg",0)
506515ADDRESS_MAP_END
507516
r10886r10887
602611GFXDECODE_END
603612
604613
605static MACHINE_CONFIG_START( bingor, driver_device )
614static MACHINE_CONFIG_START( bingor, bingor_state )
606615   MCFG_CPU_ADD("maincpu", I80186, 14000000 ) //?? Mhz
607616   MCFG_CPU_PROGRAM_MAP(bingor_map)
608617   MCFG_CPU_IO_MAP(bingor_io)
src/mame/drivers/rbmk.c
r10886r10887
5656#include "sound/2151intf.h"
5757#include "machine/eeprom.h"
5858
59static UINT16 *gms_vidram;
60static UINT16 *gms_vidram2;
6159
62static UINT16 tilebank=0;
60class rbmk_state : public driver_device
61{
62public:
63   rbmk_state(running_machine &machine, const driver_device_config_base &config)
64      : driver_device(machine, config) { }
6365
66   UINT16 *gms_vidram;
67   UINT16 *gms_vidram2;
68   UINT16 tilebank;
69   UINT8 mux_data;
70};
71
72
6473static READ16_HANDLER( gms_read )
6574{
6675   return space->machine->rand();
r10886r10887
7483
7584static WRITE16_HANDLER( gms_write2 )
7685{
77   tilebank=data;
86   rbmk_state *state = space->machine->driver_data<rbmk_state>();
87   state->tilebank=data;
7888}
7989
8090static WRITE16_HANDLER( gms_write3 )
r10886r10887
99109   AM_RANGE(0x000000, 0x07ffff) AM_ROM
100110   AM_RANGE(0x100000, 0x10ffff) AM_RAM
101111   AM_RANGE(0x500000, 0x50ffff) AM_RAM
102   AM_RANGE(0x940000, 0x940fff) AM_RAM AM_BASE(&gms_vidram2)
112   AM_RANGE(0x940000, 0x940fff) AM_RAM AM_BASE_MEMBER(rbmk_state, gms_vidram2)
103113   AM_RANGE(0x980300, 0x983fff) AM_RAM // 0x2048  words ???, byte access
104114   AM_RANGE(0x900000, 0x900fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
105   AM_RANGE(0x9c0000, 0x9c0fff) AM_RAM AM_BASE(&gms_vidram)
115   AM_RANGE(0x9c0000, 0x9c0fff) AM_RAM AM_BASE_MEMBER(rbmk_state, gms_vidram)
106116   AM_RANGE(0xb00000, 0xb00001) AM_DEVWRITE("eeprom", eeprom_w)
107117   AM_RANGE(0xC00000, 0xC00001) AM_READ_PORT("IN0") AM_WRITE(gms_write1)
108118   AM_RANGE(0xC08000, 0xC08001) AM_READ_PORT("IN1") AM_WRITE(gms_write2)
r10886r10887
112122   AM_RANGE(0xC28000, 0xC28001) AM_WRITE(gms_write3)
113123ADDRESS_MAP_END
114124
115static UINT8 mux_data;
116125
117126static ADDRESS_MAP_START( rbmk_mcu_mem, ADDRESS_SPACE_PROGRAM, 8 )
118127//  AM_RANGE(0x0000, 0x0fff) AM_ROM
r10886r10887
120129
121130static READ8_HANDLER( rbmk_mcu_io_r )
122131{
123   if(mux_data & 8)
132   rbmk_state *state = space->machine->driver_data<rbmk_state>();
133   if(state->mux_data & 8)
124134   {
125135      return ym2151_r(space->machine->device("ymsnd"), offset & 1);
126136   }
127   else if(mux_data & 4)
137   else if(state->mux_data & 4)
128138   {
129139      //printf("%02x R\n",offset);
130140      // ...
131141      return 0xff;
132142   }
133143   else
134      printf("Warning: mux data R = %02x",mux_data);
144      printf("Warning: mux data R = %02x",state->mux_data);
135145
136146   return 0xff;
137147}
138148
139149static WRITE8_HANDLER( rbmk_mcu_io_w )
140150{
141   if(mux_data & 8) { ym2151_w(space->machine->device("ymsnd"), offset & 1, data); }
142   else if(mux_data & 4)
151   rbmk_state *state = space->machine->driver_data<rbmk_state>();
152   if(state->mux_data & 8) { ym2151_w(space->machine->device("ymsnd"), offset & 1, data); }
153   else if(state->mux_data & 4)
143154   {
144155      //printf("%02x %02x W\n",offset,data);
145156      // ...
146157   }
147158   else
148      printf("Warning: mux data W = %02x",mux_data);
159      printf("Warning: mux data W = %02x",state->mux_data);
149160}
150161
151162static WRITE8_HANDLER( mcu_io_mux_w )
152163{
153   mux_data = ~data;
164   rbmk_state *state = space->machine->driver_data<rbmk_state>();
165   state->mux_data = ~data;
154166}
155167
156168static ADDRESS_MAP_START( rbmk_mcu_io, ADDRESS_SPACE_IO, 8 )
r10886r10887
480492
481493static SCREEN_UPDATE(rbmk)
482494{
495   rbmk_state *state = screen->machine->driver_data<rbmk_state>();
483496   int x,y;
484497   int count = 0;
485498
r10886r10887
487500   {
488501      for (x=0;x<64;x++)
489502      {
490         int tile = gms_vidram2[count+0x600];
491         drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[0],(tile&0xfff)+((tilebank&0x10)>>4)*0x1000,tile>>12,0,0,x*8,y*32);
503         int tile = state->gms_vidram2[count+0x600];
504         drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[0],(tile&0xfff)+((state->tilebank&0x10)>>4)*0x1000,tile>>12,0,0,x*8,y*32);
492505         count++;
493506      }
494507   }
r10886r10887
499512   {
500513      for (x=0;x<64;x++)
501514      {
502         int tile = gms_vidram[count];
503         drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[1],(tile&0xfff)+((tilebank>>1)&3)*0x1000,tile>>12,0,0,x*8,y*8,0);
515         int tile = state->gms_vidram[count];
516         drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[1],(tile&0xfff)+((state->tilebank>>1)&3)*0x1000,tile>>12,0,0,x*8,y*8,0);
504517         count++;
505518      }
506519   }
r10886r10887
512525   cputag_set_input_line(device->machine, "mcu", INPUT_LINE_NMI, PULSE_LINE);
513526}
514527
515static MACHINE_CONFIG_START( rbmk, driver_device )
528static MACHINE_CONFIG_START( rbmk, rbmk_state )
516529   MCFG_CPU_ADD("maincpu", M68000, 22000000 /2)
517530   MCFG_CPU_PROGRAM_MAP(rbmk_mem)
518531   MCFG_CPU_VBLANK_INT("screen", irq1_line_hold)
src/mame/drivers/trvmadns.c
r10886r10887
6464#include "cpu/z80/z80.h"
6565#include "sound/ay8910.h"
6666
67static tilemap_t *bg_tilemap;
68static UINT8 *trvmadns_gfxram;
69static UINT8 *trvmadns_tileram;
70static int old_data;
7167
68class trvmadns_state : public driver_device
69{
70public:
71   trvmadns_state(running_machine &machine, const driver_device_config_base &config)
72      : driver_device(machine, config) { }
73
74   tilemap_t *bg_tilemap;
75   UINT8 *gfxram;
76   UINT8 *tileram;
77   int old_data;
78};
79
80
7281static WRITE8_HANDLER( trvmadns_banking_w )
7382{
83   trvmadns_state *state = space->machine->driver_data<trvmadns_state>();
7484
7585   UINT8 *rom;
7686   int address = 0;
r10886r10887
102112   }
103113   else
104114   {
105         if(data != old_data)
115         if(data != state->old_data)
106116         {
107            old_data = data;
117            state->old_data = data;
108118            logerror("port80 = %02X\n",data);
109119            //logerror("port80 = %02X\n",data);
110120         }
r10886r10887
143153
144154static WRITE8_HANDLER( trvmadns_gfxram_w )
145155{
146   trvmadns_gfxram[offset] = data;
156   trvmadns_state *state = space->machine->driver_data<trvmadns_state>();
157   state->gfxram[offset] = data;
147158   gfx_element_mark_dirty(space->machine->gfx[0], offset/16);
148159}
149160
r10886r10887
180191
181192static WRITE8_HANDLER( trvmadns_tileram_w )
182193{
194   trvmadns_state *state = space->machine->driver_data<trvmadns_state>();
183195   if(offset==0)
184196   {
185197      if(cpu_get_previouspc(space->cpu)==0x29e9)// || cpu_get_previouspc(space->cpu)==0x1b3f) //29f5
r10886r10887
191203
192204   }
193205
194   trvmadns_tileram[offset] = data;
195   tilemap_mark_tile_dirty(bg_tilemap,offset >> 1);
206   state->tileram[offset] = data;
207   tilemap_mark_tile_dirty(state->bg_tilemap,offset >> 1);
196208}
197209
198210
r10886r10887
200212   AM_RANGE(0x0000, 0x5fff) AM_ROM
201213   AM_RANGE(0x6000, 0x6fff) AM_ROMBANK("bank1")
202214   AM_RANGE(0x7000, 0x7fff) AM_ROMBANK("bank2")
203   AM_RANGE(0x6000, 0x7fff) AM_WRITE(trvmadns_gfxram_w) AM_BASE(&trvmadns_gfxram)
215   AM_RANGE(0x6000, 0x7fff) AM_WRITE(trvmadns_gfxram_w) AM_BASE_MEMBER(trvmadns_state, gfxram)
204216   AM_RANGE(0x8000, 0x87ff) AM_RAM
205   AM_RANGE(0xa000, 0xa7ff) AM_RAM_WRITE(trvmadns_tileram_w) AM_BASE(&trvmadns_tileram)
217   AM_RANGE(0xa000, 0xa7ff) AM_RAM_WRITE(trvmadns_tileram_w) AM_BASE_MEMBER(trvmadns_state, tileram)
206218   AM_RANGE(0xc000, 0xc01f) AM_RAM_WRITE(trvmadns_palette_w) AM_BASE_GENERIC(paletteram)
207219   AM_RANGE(0xe000, 0xe000) AM_WRITE(w2)//NOP
208220   AM_RANGE(0xe004, 0xe004) AM_WRITE(w3)//NOP
r10886r10887
244256
245257static TILE_GET_INFO( get_bg_tile_info )
246258{
259   trvmadns_state *state = machine->driver_data<trvmadns_state>();
247260   int tile,attr,color,flag;
248261
249   attr = trvmadns_tileram[tile_index*2 + 0];
250   tile = trvmadns_tileram[tile_index*2 + 1] + ((attr & 0x01) << 8);
262   attr = state->tileram[tile_index*2 + 0];
263   tile = state->tileram[tile_index*2 + 1] + ((attr & 0x01) << 8);
251264   color = (attr & 0x18) >> 3;
252265   flag = TILE_FLIPXY((attr & 0x06) >> 1);
253266
r10886r10887
264277
265278static VIDEO_START( trvmadns )
266279{
267   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
280   trvmadns_state *state = machine->driver_data<trvmadns_state>();
281   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
268282
269283//  tilemap_set_transparent_pen(fg_tilemap,1);
270284
271   gfx_element_set_source(machine->gfx[0], trvmadns_gfxram);
285   gfx_element_set_source(machine->gfx[0], state->gfxram);
272286}
273287
274288static SCREEN_UPDATE( trvmadns )
275289{
290   trvmadns_state *state = screen->machine->driver_data<trvmadns_state>();
276291   int x,y,count;
277292   const gfx_element *gfx = screen->machine->gfx[0];
278293
r10886r10887
284299   {
285300      for (x=0;x<32;x++)
286301      {
287         int attr = trvmadns_tileram[count*2+0];
288         int tile = trvmadns_tileram[count*2+1] | ((attr & 0x01) << 8);
302         int attr = state->tileram[count*2+0];
303         int tile = state->tileram[count*2+1] | ((attr & 0x01) << 8);
289304         int color = (attr & 0x18) >> 3;
290305         int flipx = attr & 4;
291306         int flipy = attr & 2;
r10886r10887
302317   {
303318      for (x=0;x<32;x++)
304319      {
305         int attr = trvmadns_tileram[count*2+0];
306         int tile = trvmadns_tileram[count*2+1] | ((attr & 0x01) << 8);
320         int attr = state->tileram[count*2+0];
321         int tile = state->tileram[count*2+1] | ((attr & 0x01) << 8);
307322         int color = (attr & 0x18) >> 3;
308323         int flipx = attr & 4;
309324         int flipy = attr & 2;
r10886r10887
319334
320335static MACHINE_RESET( trvmadns )
321336{
322   old_data = -1;
337   trvmadns_state *state = machine->driver_data<trvmadns_state>();
338   state->old_data = -1;
323339}
324340
325static MACHINE_CONFIG_START( trvmadns, driver_device )
341static MACHINE_CONFIG_START( trvmadns, trvmadns_state )
326342   MCFG_CPU_ADD("maincpu", Z80,10000000/2) // ?
327343   MCFG_CPU_PROGRAM_MAP(cpu_map)
328344   MCFG_CPU_IO_MAP(io_map)
src/mame/drivers/cubeqst.c
r10886r10887
2525#include "machine/nvram.h"
2626
2727
28class cubeqst_state : public driver_device
29{
30public:
31   cubeqst_state(running_machine &machine, const driver_device_config_base &config)
32      : driver_device(machine, config) { }
33
34   UINT8 *depth_buffer;
35   int video_field;
36   UINT8 io_latch;
37   UINT8 reset_latch;
38   device_t *laserdisc;
39   rgb_t *colormap;
40};
41
42
43
2844/*************************************
2945 *
3046 *  Constants
r10886r10887
3854
3955/*************************************
4056 *
41 *  Statics
42 *
43 *************************************/
44
45static UINT8 *depth_buffer;
46static int video_field;
47
48static UINT8 io_latch;
49static UINT8 reset_latch;
50
51static device_t *laserdisc;
52static rgb_t *colormap;
53
54
55
56/*************************************
57 *
5857 *  Video (move to separate file)
5958 *
6059 *************************************/
r10886r10887
6362
6463static VIDEO_START( cubeqst )
6564{
66   video_field = 0;
67   depth_buffer = auto_alloc_array(machine, UINT8, 512);
65   cubeqst_state *state = machine->driver_data<cubeqst_state>();
66   state->video_field = 0;
67   state->depth_buffer = auto_alloc_array(machine, UINT8, 512);
6868}
6969
7070/* TODO: Use resistor values */
7171static PALETTE_INIT( cubeqst )
7272{
73   cubeqst_state *state = machine->driver_data<cubeqst_state>();
7374   int i;
7475
75   colormap = auto_alloc_array(machine, rgb_t, 65536);
76   state->colormap = auto_alloc_array(machine, rgb_t, 65536);
7677   for (i = 0; i < 65536; ++i)
7778   {
7879      UINT8 a, r, g, b, y;
r10886r10887
8384      r = (i >> 8) & 7;
8485      y = ((i >> 12) & 0xf) * 2;
8586
86      colormap[i] = MAKE_ARGB(a ? 0 : 255, y*r, y*g, y*b);
87      state->colormap[i] = MAKE_ARGB(a ? 0 : 255, y*r, y*g, y*b);
8788   }
8889}
8990
r10886r10887
9697/* TODO: This is a simplified version of what actually happens */
9798static SCREEN_UPDATE( cubeqst )
9899{
100   cubeqst_state *state = screen->machine->driver_data<cubeqst_state>();
99101   int y;
100102
101103   /*
r10886r10887
104106    */
105107
106108   /* Bit 3 selects LD/#GRAPHICS */
107   bitmap_fill(bitmap, cliprect, colormap[255]);
109   bitmap_fill(bitmap, cliprect, state->colormap[255]);
108110
109111   /* TODO: Add 1 for linebuffering? */
110112   for (y = cliprect->min_y; y <= cliprect->max_y; ++y)
r10886r10887
116118      UINT32 pen;
117119
118120      /* Zap the depth buffer */
119      memset(depth_buffer, 0xff, 512);
121      memset(state->depth_buffer, 0xff, 512);
120122
121123      /* Process all the spans on this scanline */
122124      if (y < 256)
r10886r10887
153155            }
154156
155157            /* Draw the span, testing for depth */
156            pen = colormap[screen->machine->generic.paletteram.u16[color]];
158            pen = state->colormap[screen->machine->generic.paletteram.u16[color]];
157159            for (x = h1; x <= h2; ++x)
158160            {
159               if (!(depth_buffer[x] < depth))
161               if (!(state->depth_buffer[x] < depth))
160162               {
161163                  dest[x] = pen;
162                  depth_buffer[x] = depth;
164                  state->depth_buffer[x] = depth;
163165               }
164166            }
165167         }
r10886r10887
177179
178180static INTERRUPT_GEN( vblank )
179181{
180   int int_level = video_field == 0 ? 5 : 6;
182   cubeqst_state *state = device->machine->driver_data<cubeqst_state>();
183   int int_level = state->video_field == 0 ? 5 : 6;
181184
182185   cpu_set_input_line(device, int_level, HOLD_LINE);
183186
184187   /* Update the laserdisc */
185   video_field ^= 1;
188   state->video_field ^= 1;
186189}
187190
188191
r10886r10887
194197
195198static WRITE16_HANDLER( laserdisc_w )
196199{
197   laserdisc_data_w(laserdisc, data & 0xff);
200   cubeqst_state *state = space->machine->driver_data<cubeqst_state>();
201   laserdisc_data_w(state->laserdisc, data & 0xff);
198202}
199203
200204/*
r10886r10887
203207*/
204208static READ16_HANDLER( laserdisc_r )
205209{
206   int ldp_command_flag = (laserdisc_line_r(laserdisc, LASERDISC_LINE_READY) == ASSERT_LINE) ? 0 : 1;
207   int ldp_seek_status = (laserdisc_line_r(laserdisc, LASERDISC_LINE_STATUS) == ASSERT_LINE) ? 1 : 0;
210   cubeqst_state *state = space->machine->driver_data<cubeqst_state>();
211   int ldp_command_flag = (laserdisc_line_r(state->laserdisc, LASERDISC_LINE_READY) == ASSERT_LINE) ? 0 : 1;
212   int ldp_seek_status = (laserdisc_line_r(state->laserdisc, LASERDISC_LINE_STATUS) == ASSERT_LINE) ? 1 : 0;
208213
209214   return (ldp_seek_status << 1) | ldp_command_flag;
210215}
r10886r10887
213218/* LDP audio squelch control */
214219static WRITE16_HANDLER( ldaud_w )
215220{
216   simutrek_set_audio_squelch(laserdisc, data & 1 ? ASSERT_LINE : CLEAR_LINE);
221   cubeqst_state *state = space->machine->driver_data<cubeqst_state>();
222   simutrek_set_audio_squelch(state->laserdisc, data & 1 ? ASSERT_LINE : CLEAR_LINE);
217223}
218224
219225/*
r10886r10887
228234*/
229235static WRITE16_HANDLER( control_w )
230236{
231   laserdisc_video_enable(laserdisc, data & 1);
237   cubeqst_state *state = space->machine->driver_data<cubeqst_state>();
238   laserdisc_video_enable(state->laserdisc, data & 1);
232239}
233240
234241
r10886r10887
264271*/
265272static WRITE16_HANDLER( reset_w )
266273{
274   cubeqst_state *state = space->machine->driver_data<cubeqst_state>();
267275   cputag_set_input_line(space->machine, "rotate_cpu", INPUT_LINE_RESET, data & 1 ? CLEAR_LINE : ASSERT_LINE);
268276   cputag_set_input_line(space->machine, "line_cpu", INPUT_LINE_RESET, data & 1 ? CLEAR_LINE : ASSERT_LINE);
269277   cputag_set_input_line(space->machine, "sound_cpu", INPUT_LINE_RESET, data & 2 ? CLEAR_LINE : ASSERT_LINE);
270278
271279   /* Swap stack and pointer RAM banks on rising edge of display reset */
272   if (!BIT(reset_latch, 0) && BIT(data, 0))
280   if (!BIT(state->reset_latch, 0) && BIT(data, 0))
273281      swap_linecpu_banks(space->machine);
274282
275283   if (!BIT(data, 2))
276      laserdisc->reset();
284      state->laserdisc->reset();
277285
278   reset_latch = data & 0xff;
286   state->reset_latch = data & 0xff;
279287}
280288
281289
r10886r10887
287295
288296static WRITE16_HANDLER( io_w )
289297{
298   cubeqst_state *state = space->machine->driver_data<cubeqst_state>();
290299   /*
291300       0: Spare lamp
292301       1: Spare driver
r10886r10887
299308    */
300309
301310   /* TODO: On rising edge of Q7, status LED latch is written */
302   if ( !BIT(io_latch, 7) && BIT(data, 7) )
311   if ( !BIT(state->io_latch, 7) && BIT(data, 7) )
303312   {
304313      /*
305314            0: Battery failure
r10886r10887
308317        */
309318   }
310319
311   io_latch = data;
320   state->io_latch = data;
312321}
313322
314323static READ16_HANDLER( io_r )
315324{
325   cubeqst_state *state = space->machine->driver_data<cubeqst_state>();
316326   UINT16 port_data = input_port_read(space->machine, "IO");
317327
318328   /*
r10886r10887
324334         10: Spare  / Trackball V data
325335    */
326336
327   if ( !BIT(io_latch, 7) )
337   if ( !BIT(state->io_latch, 7) )
328338      return port_data;
329339   else
330340      /* Return zeroes for the trackball signals for now */
r10886r10887
427437
428438static MACHINE_START( cubeqst )
429439{
430   laserdisc = machine->device("laserdisc");
440   cubeqst_state *state = machine->driver_data<cubeqst_state>();
441   state->laserdisc = machine->device("laserdisc");
431442}
432443
433444static MACHINE_RESET( cubeqst )
434445{
435   reset_latch = 0;
446   cubeqst_state *state = machine->driver_data<cubeqst_state>();
447   state->reset_latch = 0;
436448
437449   /* Auxillary CPUs are held in reset */
438450   cputag_set_input_line(machine, "sound_cpu", INPUT_LINE_RESET, ASSERT_LINE);
r10886r10887
493505 *
494506 *************************************/
495507
496static MACHINE_CONFIG_START( cubeqst, driver_device )
508static MACHINE_CONFIG_START( cubeqst, cubeqst_state )
497509   MCFG_CPU_ADD("main_cpu", M68000, XTAL_16MHz / 2)
498510   MCFG_CPU_PROGRAM_MAP(m68k_program_map)
499511   MCFG_CPU_VBLANK_INT("screen", vblank)
src/mame/drivers/ltcasino.c
r10886r10887
1717#include "cpu/m6502/m6502.h"
1818#include "sound/ay8910.h"
1919
20static UINT8 *ltcasino_tile_num_ram, *ltcasino_tile_atr_ram;
2120
22static tilemap_t *ltcasino_tilemap;
21class ltcasino_state : public driver_device
22{
23public:
24   ltcasino_state(running_machine &machine, const driver_device_config_base &config)
25      : driver_device(machine, config) { }
2326
27   UINT8 *tile_num_ram;
28   UINT8 *tile_atr_ram;
29   tilemap_t *tilemap;
30};
31
32
2433/* Video */
2534
2635static TILE_GET_INFO( get_ltcasino_tile_info )
2736{
37   ltcasino_state *state = machine->driver_data<ltcasino_state>();
2838   int tileno, colour;
2939
30   tileno = ltcasino_tile_num_ram[tile_index];
31   colour = ltcasino_tile_atr_ram[tile_index];
40   tileno = state->tile_num_ram[tile_index];
41   colour = state->tile_atr_ram[tile_index];
3242
3343   tileno += (colour & 0x80) << 1;
3444
r10886r10887
3747
3848static VIDEO_START(ltcasino)
3949{
40   ltcasino_tilemap = tilemap_create(machine, get_ltcasino_tile_info,tilemap_scan_rows,8, 8,64,32);
50   ltcasino_state *state = machine->driver_data<ltcasino_state>();
51   state->tilemap = tilemap_create(machine, get_ltcasino_tile_info,tilemap_scan_rows,8, 8,64,32);
4152}
4253
4354
4455static WRITE8_HANDLER( ltcasino_tile_num_w )
4556{
46   ltcasino_tile_num_ram[offset] = data;
47   tilemap_mark_tile_dirty(ltcasino_tilemap,offset);
57   ltcasino_state *state = space->machine->driver_data<ltcasino_state>();
58   state->tile_num_ram[offset] = data;
59   tilemap_mark_tile_dirty(state->tilemap,offset);
4860}
4961
5062static WRITE8_HANDLER( ltcasino_tile_atr_w )
5163{
52   ltcasino_tile_atr_ram[offset] = data;
53   tilemap_mark_tile_dirty(ltcasino_tilemap,offset);
64   ltcasino_state *state = space->machine->driver_data<ltcasino_state>();
65   state->tile_atr_ram[offset] = data;
66   tilemap_mark_tile_dirty(state->tilemap,offset);
5467}
5568
5669
5770static ADDRESS_MAP_START( ltcasino_map, ADDRESS_SPACE_PROGRAM, 8 )
5871   AM_RANGE(0x0000, 0x7fff) AM_RAM
5972   AM_RANGE(0x8000, 0xcfff) AM_ROM
60   AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(ltcasino_tile_num_w) AM_BASE(&ltcasino_tile_num_ram)
73   AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(ltcasino_tile_num_w) AM_BASE_MEMBER(ltcasino_state, tile_num_ram)
6174   AM_RANGE(0xd800, 0xdfff) AM_RAM
62   AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(ltcasino_tile_atr_w) AM_BASE(&ltcasino_tile_atr_ram)
75   AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(ltcasino_tile_atr_w) AM_BASE_MEMBER(ltcasino_state, tile_atr_ram)
6376   AM_RANGE(0xe800, 0xebff) AM_RAM
6477
6578   AM_RANGE(0xec00, 0xec00) AM_READ_PORT("IN0")
r10886r10887
621634
622635static SCREEN_UPDATE(ltcasino)
623636{
624   tilemap_draw(bitmap,cliprect,ltcasino_tilemap,0,0);
637   ltcasino_state *state = screen->machine->driver_data<ltcasino_state>();
638   tilemap_draw(bitmap,cliprect,state->tilemap,0,0);
625639   return 0;
626640}
627641
628642
629static MACHINE_CONFIG_START( ltcasino, driver_device )
643static MACHINE_CONFIG_START( ltcasino, ltcasino_state )
630644   /* basic machine hardware */
631645   MCFG_CPU_ADD("maincpu", M6502,2000000)       /* ? MHz */
632646   MCFG_CPU_PROGRAM_MAP(ltcasino_map)
src/mame/drivers/blitz.c
r10886r10887
292292#include "sound/discrete.h"
293293
294294
295class blitz_state : public driver_device
296{
297public:
298   blitz_state(running_machine &machine, const driver_device_config_base &config)
299      : driver_device(machine, config) { }
300
301   UINT8 *videoram;
302   UINT8 *colorram;
303   tilemap_t *bg_tilemap;
304   int mux_data;
305};
306
307
308
295309/*********************************************
296310*               Video Hardware               *
297311*********************************************/
298312
299static UINT8 *videoram;
300static UINT8 *colorram;
301static tilemap_t *bg_tilemap;
302313
303
304314static WRITE8_HANDLER( megadpkr_videoram_w )
305315{
306   videoram[offset] = data;
307   tilemap_mark_tile_dirty(bg_tilemap, offset);
316   blitz_state *state = space->machine->driver_data<blitz_state>();
317   state->videoram[offset] = data;
318   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
308319}
309320
310321static WRITE8_HANDLER( megadpkr_colorram_w )
311322{
312   colorram[offset] = data;
313   tilemap_mark_tile_dirty(bg_tilemap, offset);
323   blitz_state *state = space->machine->driver_data<blitz_state>();
324   state->colorram[offset] = data;
325   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
314326}
315327
316328
317329static TILE_GET_INFO( get_bg_tile_info )
318330{
331   blitz_state *state = machine->driver_data<blitz_state>();
319332/*  - bits -
320333    7654 3210
321334    --xx xx--   tiles color.
r10886r10887
324337    xx-- ----   unused.
325338*/
326339
327   int attr = colorram[tile_index];
328   int code = ((attr & 1) << 8) | videoram[tile_index];
340   int attr = state->colorram[tile_index];
341   int code = ((attr & 1) << 8) | state->videoram[tile_index];
329342   int bank = (attr & 0x02) >> 1;   /* bit 1 switch the gfx banks */
330343   int color = (attr & 0x3c) >> 2;   /* bits 2-3-4-5 for color */
331344
r10886r10887
335348
336349static VIDEO_START( megadpkr )
337350{
338   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
351   blitz_state *state = machine->driver_data<blitz_state>();
352   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
339353}
340354
341355static SCREEN_UPDATE( megadpkr )
342356{
343   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
357   blitz_state *state = screen->machine->driver_data<blitz_state>();
358   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
344359   return 0;
345360}
346361
r10886r10887
394409*               R/W Handlers               *
395410*******************************************/
396411
397static int mux_data = 0;
398412
399413/* Inputs (buttons) are multiplexed.
400414   There are 4 sets of 5 bits each and are connected to PIA0, portA.
r10886r10887
402416*/
403417static READ8_DEVICE_HANDLER( megadpkr_mux_port_r )
404418{
405   switch( mux_data & 0xf0 )      /* bits 4-7 */
419   blitz_state *state = device->machine->driver_data<blitz_state>();
420   switch( state->mux_data & 0xf0 )      /* bits 4-7 */
406421   {
407422      case 0x10: return input_port_read(device->machine, "IN0-0");
408423      case 0x20: return input_port_read(device->machine, "IN0-1");
r10886r10887
415430
416431static WRITE8_DEVICE_HANDLER( mux_w )
417432{
418   mux_data = data ^ 0xff;   /* inverted */
433   blitz_state *state = device->machine->driver_data<blitz_state>();
434   state->mux_data = data ^ 0xff;   /* inverted */
419435}
420436
421437
r10886r10887
469485    AM_RANGE(0x10f8, 0x10fb) AM_DEVREADWRITE("pia1", pia6821_r, pia6821_w)
470486*/
471487
472   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(megadpkr_videoram_w) AM_BASE(&videoram)
473   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(megadpkr_colorram_w) AM_BASE(&colorram)
488   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(megadpkr_videoram_w) AM_BASE_MEMBER(blitz_state, videoram)
489   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(megadpkr_colorram_w) AM_BASE_MEMBER(blitz_state, colorram)
474490
475491   AM_RANGE(0xc000, 0xffff) AM_ROM
476492ADDRESS_MAP_END
r10886r10887
767783*              Machine Drivers               *
768784*********************************************/
769785
770static MACHINE_CONFIG_START( megadpkr, driver_device )
786static MACHINE_CONFIG_START( megadpkr, blitz_state )
771787
772788   /* basic machine hardware */
773789   MCFG_CPU_ADD("maincpu", M6502, CPU_CLOCK)
src/mame/drivers/intrscti.c
r10886r10887
1414#include "emu.h"
1515#include "cpu/z80/z80.h"
1616
17
18class intrscti_state : public driver_device
19{
20public:
21   intrscti_state(running_machine &machine, const driver_device_config_base &config)
22      : driver_device(machine, config) { }
23
24   UINT8 *ram;
25};
26
27
1728static READ8_HANDLER( unk_r )
1829{
1930   return space->machine->rand();
2031}
2132
22static UINT8 *intrscti_ram;
23
2433static ADDRESS_MAP_START( intrscti_map, ADDRESS_SPACE_PROGRAM, 8 )
2534   AM_RANGE(0x0000, 0x1fff) AM_ROM
2635   AM_RANGE(0x6000, 0x67ff) AM_RAM
27   AM_RANGE(0x7000, 0x77ff) AM_RAM AM_BASE(&intrscti_ram) // video ram
36   AM_RANGE(0x7000, 0x77ff) AM_RAM AM_BASE_MEMBER(intrscti_state, ram) // video ram
2837   AM_RANGE(0x8000, 0x8fff) AM_ROM
2938ADDRESS_MAP_END
3039
r10886r10887
5968
6069static SCREEN_UPDATE(intrscti)
6170{
71   intrscti_state *state = screen->machine->driver_data<intrscti_state>();
6272   int y,x;
6373   int count;
6474
r10886r10887
7080      for (x=0;x<32;x++)
7181      {
7282         int dat;
73         dat = intrscti_ram[count];
83         dat = state->ram[count];
7484         drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[0],dat/*+0x100*/,0,0,0,x*8,y*8,0);
7585         count++;
7686      }
r10886r10887
8090   return 0;
8191}
8292
83static MACHINE_CONFIG_START( intrscti, driver_device )
93static MACHINE_CONFIG_START( intrscti, intrscti_state )
8494   /* basic machine hardware */
8595   MCFG_CPU_ADD("maincpu", Z80,4000000)       /* ? MHz */
8696   MCFG_CPU_PROGRAM_MAP(intrscti_map)
src/mame/drivers/photoply.c
r10886r10887
2626#include "machine/pckeybrd.h"
2727#include "machine/idectrl.h"
2828
29static UINT32 *vga_vram;
30static UINT8 vga_regs[0x19];
3129
30class photoply_state : public driver_device
31{
32public:
33   photoply_state(running_machine &machine, const driver_device_config_base &config)
34      : driver_device(machine, config) { }
35
36   UINT32 *vga_vram;
37   UINT8 vga_regs[0x19];
38   int dma_channel;
39   UINT8 dma_offset[2][4];
40   UINT8 at_pages[0x10];
41   UINT8 vga_address;
42   struct { int r,g,b,offs,offs_internal; } pal;
43
44   device_t   *pit8253;
45   device_t   *pic8259_1;
46   device_t   *pic8259_2;
47   device_t   *dma8237_1;
48   device_t   *dma8237_2;
49};
50
51
3252#define SET_VISIBLE_AREA(_x_,_y_) \
3353   { \
3454   rectangle visarea; \
r10886r10887
4868
4969static void cga_alphanumeric_tilemap(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,UINT16 size,UINT32 map_offs,UINT8 gfx_num)
5070{
51   static UINT32 offs,x,y,max_x,max_y;
71   photoply_state *state = machine->driver_data<photoply_state>();
72   UINT32 offs,x,y,max_x,max_y;
5273   int tile,color;
5374
5475   /*define the visible area*/
r10886r10887
6485         max_x = 80;
6586         max_y = 25;
6687         break;
88      default:
89         fatalerror("Unknown size");
6790   }
6891
6992   offs = map_offs;
r10886r10887
7194   for(y=0;y<max_y;y++)
7295      for(x=0;x<max_x;x+=2)
7396      {
74         tile =  (vga_vram[offs] & 0x00ff0000)>>16;
75         color = (vga_vram[offs] & 0xff000000)>>24;
97         tile =  (state->vga_vram[offs] & 0x00ff0000)>>16;
98         color = (state->vga_vram[offs] & 0xff000000)>>24;
7699
77100         drawgfx_opaque(bitmap,cliprect,machine->gfx[gfx_num],
78101               tile,
r10886r10887
81104               (x+1)*8,y*8);
82105
83106
84         tile =  (vga_vram[offs] & 0x000000ff);
85         color = (vga_vram[offs] & 0x0000ff00)>>8;
107         tile =  (state->vga_vram[offs] & 0x000000ff);
108         color = (state->vga_vram[offs] & 0x0000ff00)>>8;
86109
87110         drawgfx_opaque(bitmap,cliprect,machine->gfx[gfx_num],
88111               tile,
r10886r10887
102125   return 0;
103126}
104127
105static struct {
106   device_t   *pit8253;
107   device_t   *pic8259_1;
108   device_t   *pic8259_2;
109   device_t   *dma8237_1;
110   device_t   *dma8237_2;
111} photoply_devices;
112
113128/******************
114129DMA8237 Controller
115130******************/
116131
117static int dma_channel;
118static UINT8 dma_offset[2][4];
119static UINT8 at_pages[0x10];
120132
121133static WRITE_LINE_DEVICE_HANDLER( pc_dma_hrq_changed )
122134{
r10886r10887
129141
130142static READ8_HANDLER( pc_dma_read_byte )
131143{
132   offs_t page_offset = (((offs_t) dma_offset[0][dma_channel]) << 16)
144   photoply_state *state = space->machine->driver_data<photoply_state>();
145   offs_t page_offset = (((offs_t) state->dma_offset[0][state->dma_channel]) << 16)
133146      & 0xFF0000;
134147
135148   return space->read_byte(page_offset + offset);
r10886r10887
138151
139152static WRITE8_HANDLER( pc_dma_write_byte )
140153{
141   offs_t page_offset = (((offs_t) dma_offset[0][dma_channel]) << 16)
154   photoply_state *state = space->machine->driver_data<photoply_state>();
155   offs_t page_offset = (((offs_t) state->dma_offset[0][state->dma_channel]) << 16)
142156      & 0xFF0000;
143157
144158   space->write_byte(page_offset + offset, data);
r10886r10887
146160
147161static READ8_HANDLER(dma_page_select_r)
148162{
149   UINT8 data = at_pages[offset % 0x10];
163   photoply_state *state = space->machine->driver_data<photoply_state>();
164   UINT8 data = state->at_pages[offset % 0x10];
150165
151166   switch(offset % 8)
152167   {
153168   case 1:
154      data = dma_offset[(offset / 8) & 1][2];
169      data = state->dma_offset[(offset / 8) & 1][2];
155170      break;
156171   case 2:
157      data = dma_offset[(offset / 8) & 1][3];
172      data = state->dma_offset[(offset / 8) & 1][3];
158173      break;
159174   case 3:
160      data = dma_offset[(offset / 8) & 1][1];
175      data = state->dma_offset[(offset / 8) & 1][1];
161176      break;
162177   case 7:
163      data = dma_offset[(offset / 8) & 1][0];
178      data = state->dma_offset[(offset / 8) & 1][0];
164179      break;
165180   }
166181   return data;
r10886r10887
169184
170185static WRITE8_HANDLER(dma_page_select_w)
171186{
172   at_pages[offset % 0x10] = data;
187   photoply_state *state = space->machine->driver_data<photoply_state>();
188   state->at_pages[offset % 0x10] = data;
173189
174190   switch(offset % 8)
175191   {
176192   case 1:
177      dma_offset[(offset / 8) & 1][2] = data;
193      state->dma_offset[(offset / 8) & 1][2] = data;
178194      break;
179195   case 2:
180      dma_offset[(offset / 8) & 1][3] = data;
196      state->dma_offset[(offset / 8) & 1][3] = data;
181197      break;
182198   case 3:
183      dma_offset[(offset / 8) & 1][1] = data;
199      state->dma_offset[(offset / 8) & 1][1] = data;
184200      break;
185201   case 7:
186      dma_offset[(offset / 8) & 1][0] = data;
202      state->dma_offset[(offset / 8) & 1][0] = data;
187203      break;
188204   }
189205}
190206
191207static void set_dma_channel(device_t *device, int channel, int state)
192208{
193   if (!state) dma_channel = channel;
209   photoply_state *drvstate = device->machine->driver_data<photoply_state>();
210   if (!state) drvstate->dma_channel = channel;
194211}
195212
196213static WRITE_LINE_DEVICE_HANDLER( pc_dack0_w ) { set_dma_channel(device, 0, state); }
r10886r10887
242259
243260static IRQ_CALLBACK(irq_callback)
244261{
262   photoply_state *state = device->machine->driver_data<photoply_state>();
245263   int r = 0;
246   r = pic8259_acknowledge(photoply_devices.pic8259_2);
264   r = pic8259_acknowledge(state->pic8259_2);
247265   if (r==0)
248266   {
249      r = pic8259_acknowledge(photoply_devices.pic8259_1);
267      r = pic8259_acknowledge(state->pic8259_1);
250268   }
251269   return r;
252270}
253271
254272static WRITE_LINE_DEVICE_HANDLER( at_pit8254_out0_changed )
255273{
256   if ( photoply_devices.pic8259_1 )
274   photoply_state *drvstate = device->machine->driver_data<photoply_state>();
275   if ( drvstate->pic8259_1 )
257276   {
258      pic8259_ir0_w(photoply_devices.pic8259_1, state);
277      pic8259_ir0_w(drvstate->pic8259_1, state);
259278   }
260279}
261280
r10886r10887
287306
288307static ADDRESS_MAP_START( photoply_map, ADDRESS_SPACE_PROGRAM, 32 )
289308   AM_RANGE(0x00000000, 0x0009ffff) AM_RAM
290   AM_RANGE(0x000a0000, 0x000bffff) AM_RAM AM_BASE(&vga_vram)
309   AM_RANGE(0x000a0000, 0x000bffff) AM_RAM AM_BASE_MEMBER(photoply_state, vga_vram)
291310   AM_RANGE(0x000c0000, 0x000c7fff) AM_RAM AM_REGION("video_bios", 0) //???
292311   AM_RANGE(0x000c8000, 0x000cffff) AM_RAM AM_REGION("video_bios", 0)
293312   AM_RANGE(0x000d0000, 0x000dffff) AM_RAM AM_REGION("ex_bios", 0)
r10886r10887
303322/* 3c8-3c9 -> ramdac*/
304323static WRITE32_HANDLER( vga_ramdac_w )
305324{
306   static int pal_offs,r,g,b,internal_pal_offs;
307
325   photoply_state *state = space->machine->driver_data<photoply_state>();
308326   if (ACCESSING_BITS_0_7)
309327   {
310328      //printf("%02x X\n",data);
311      pal_offs = internal_pal_offs = data;
329      state->pal.offs = state->pal.offs_internal = data;
312330   }
313331   if (ACCESSING_BITS_8_15)
314332   {
315333      //printf("%02x\n",data);
316334      data>>=8;
317      switch(internal_pal_offs)
335      switch(state->pal.offs_internal)
318336      {
319337         case 0:
320            r = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
321            internal_pal_offs++;
338            state->pal.r = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
339            state->pal.offs_internal++;
322340            break;
323341         case 1:
324            g = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
325            internal_pal_offs++;
342            state->pal.g = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
343            state->pal.offs_internal++;
326344            break;
327345         case 2:
328            b = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
329            palette_set_color(space->machine, 0x200+pal_offs, MAKE_RGB(r, g, b));
330            internal_pal_offs = 0;
331            pal_offs++;
346            state->pal.b = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
347            palette_set_color(space->machine, 0x200+state->pal.offs, MAKE_RGB(state->pal.r, state->pal.g, state->pal.b));
348            state->pal.offs_internal = 0;
349            state->pal.offs++;
332350            break;
333351      }
334352   }
r10886r10887
336354
337355static WRITE32_HANDLER( vga_regs_w )
338356{
339   static UINT8 vga_address;
357   photoply_state *state = space->machine->driver_data<photoply_state>();
340358
341359   if (ACCESSING_BITS_0_7)
342      vga_address = data;
360      state->vga_address = data;
343361   if (ACCESSING_BITS_8_15)
344362   {
345      if(vga_address < 0x19)
363      if(state->vga_address < 0x19)
346364      {
347         vga_regs[vga_address] = data>>8;
348         logerror("VGA reg %02x with data %02x\n",vga_address,vga_regs[vga_address]);
365         state->vga_regs[state->vga_address] = data>>8;
366         logerror("VGA reg %02x with data %02x\n",state->vga_address,state->vga_regs[state->vga_address]);
349367      }
350368      else
351         logerror("Warning: used undefined VGA reg %02x with data %02x\n",vga_address,data>>8);
369         logerror("Warning: used undefined VGA reg %02x with data %02x\n",state->vga_address,data>>8);
352370   }
353371}
354372
r10886r10887
458476
459477static void photoply_set_keyb_int(running_machine *machine, int state)
460478{
461   pic8259_ir1_w(photoply_devices.pic8259_1, state);
479   photoply_state *drvstate = machine->driver_data<photoply_state>();
480   pic8259_ir1_w(drvstate->pic8259_1, state);
462481}
463482
464483
465484static MACHINE_START( photoply )
466485{
486   photoply_state *state = machine->driver_data<photoply_state>();
467487//  bank = -1;
468488//  lastvalue = -1;
469489//  hv_blank = 0;
470490   cpu_set_irq_callback(machine->device("maincpu"), irq_callback);
471   photoply_devices.pit8253 = machine->device( "pit8254" );
472   photoply_devices.pic8259_1 = machine->device( "pic8259_1" );
473   photoply_devices.pic8259_2 = machine->device( "pic8259_2" );
474   photoply_devices.dma8237_1 = machine->device( "dma8237_1" );
475   photoply_devices.dma8237_2 = machine->device( "dma8237_2" );
491   state->pit8253 = machine->device( "pit8254" );
492   state->pic8259_1 = machine->device( "pic8259_1" );
493   state->pic8259_2 = machine->device( "pic8259_2" );
494   state->dma8237_1 = machine->device( "dma8237_1" );
495   state->dma8237_2 = machine->device( "dma8237_2" );
476496
477497   init_pc_common(machine, PCCOMMON_KEYBOARD_AT, photoply_set_keyb_int);
478498}
r10886r10887
494514GFXDECODE_END
495515
496516
497static MACHINE_CONFIG_START( photoply, driver_device )
517static MACHINE_CONFIG_START( photoply, photoply_state )
498518   /* basic machine hardware */
499519   MCFG_CPU_ADD("maincpu", I486, 75000000)   /* I486DX4, 75 or 100 Mhz */
500520   MCFG_CPU_PROGRAM_MAP(photoply_map)
src/mame/drivers/sfbonus.c
r10886r10887
274274#include "pirpok2.lh"
275275
276276
277static bitmap_t *temp_reel_bitmap;
278static tilemap_t *sfbonus_tilemap;
279static tilemap_t *sfbonus_reel_tilemap;
280static tilemap_t *sfbonus_reel2_tilemap;
281static tilemap_t *sfbonus_reel3_tilemap;
282static tilemap_t *sfbonus_reel4_tilemap;
283static UINT8 *sfbonus_tilemap_ram;
284static UINT8 *sfbonus_reel_ram;
285static UINT8 *sfbonus_reel2_ram;
286static UINT8 *sfbonus_reel3_ram;
287static UINT8 *sfbonus_reel4_ram;
288static UINT8* sfbonus_videoram;
289static UINT8 *sfbonus_vregs;
290static UINT8 *nvram;
291static size_t nvram_size;
292static UINT8* sfbonus_1800_regs;
293static UINT8* sfbonus_3800_regs;
294static UINT8* sfbonus_3000_regs;
295static UINT8* sfbonus_2801_regs;
296static UINT8* sfbonus_2c01_regs;
277class sfbonus_state : public driver_device
278{
279public:
280   sfbonus_state(running_machine &machine, const driver_device_config_base &config)
281      : driver_device(machine, config) { }
297282
283   bitmap_t *temp_reel_bitmap;
284   tilemap_t *tilemap;
285   tilemap_t *reel_tilemap;
286   tilemap_t *reel2_tilemap;
287   tilemap_t *reel3_tilemap;
288   tilemap_t *reel4_tilemap;
289   UINT8 *tilemap_ram;
290   UINT8 *reel_ram;
291   UINT8 *reel2_ram;
292   UINT8 *reel3_ram;
293   UINT8 *reel4_ram;
294   UINT8* videoram;
295   UINT8 *vregs;
296   UINT8 *nvram;
297   size_t nvram_size;
298   UINT8* _1800_regs;
299   UINT8* _3800_regs;
300   UINT8* _3000_regs;
301   UINT8* _2801_regs;
302   UINT8* _2c01_regs;
303   struct { int r,g,b,offs,offs_internal; } pal;
304};
298305
306
299307/* 8-liners input define */
300308static INPUT_PORTS_START( amcoebase )
301309   PORT_START("KEY1")
r10886r10887
617625
618626static TILE_GET_INFO( get_sfbonus_tile_info )
619627{
620   int code = sfbonus_tilemap_ram[(tile_index*2)+0] | (sfbonus_tilemap_ram[(tile_index*2)+1]<<8);
621   int flipx = (sfbonus_tilemap_ram[(tile_index*2)+1] & 0x80)>>7;
622   int flipy = (sfbonus_tilemap_ram[(tile_index*2)+1] & 0x40)>>5;
628   sfbonus_state *state = machine->driver_data<sfbonus_state>();
629   int code = state->tilemap_ram[(tile_index*2)+0] | (state->tilemap_ram[(tile_index*2)+1]<<8);
630   int flipx = (state->tilemap_ram[(tile_index*2)+1] & 0x80)>>7;
631   int flipy = (state->tilemap_ram[(tile_index*2)+1] & 0x40)>>5;
623632
624633   SET_TILE_INFO(
625634         0,
r10886r10887
630639
631640static TILE_GET_INFO( get_sfbonus_reel_tile_info )
632641{
633   int code = sfbonus_reel_ram[(tile_index*2)+0] | (sfbonus_reel_ram[(tile_index*2)+1]<<8);
634   int flipx = (sfbonus_reel_ram[(tile_index*2)+1] & 0x80)>>7;
635   int flipy = 0;//(sfbonus_reel_ram[(tile_index*2)+1] & 0x40)>>5;
642   sfbonus_state *state = machine->driver_data<sfbonus_state>();
643   int code = state->reel_ram[(tile_index*2)+0] | (state->reel_ram[(tile_index*2)+1]<<8);
644   int flipx = (state->reel_ram[(tile_index*2)+1] & 0x80)>>7;
645   int flipy = 0;//(state->reel_ram[(tile_index*2)+1] & 0x40)>>5;
636646
637   int priority = (sfbonus_reel_ram[(tile_index*2)+1] & 0x40)>>6;
647   int priority = (state->reel_ram[(tile_index*2)+1] & 0x40)>>6;
638648
639649   SET_TILE_INFO(
640650         1,
r10886r10887
645655
646656static TILE_GET_INFO( get_sfbonus_reel2_tile_info )
647657{
648   int code = sfbonus_reel2_ram[(tile_index*2)+0] | (sfbonus_reel2_ram[(tile_index*2)+1]<<8);
649   int flipx = (sfbonus_reel2_ram[(tile_index*2)+1] & 0x80)>>7;
650   int flipy = 0;//(sfbonus_reel2_ram[(tile_index*2)+1] & 0x40)>>5;
658   sfbonus_state *state = machine->driver_data<sfbonus_state>();
659   int code = state->reel2_ram[(tile_index*2)+0] | (state->reel2_ram[(tile_index*2)+1]<<8);
660   int flipx = (state->reel2_ram[(tile_index*2)+1] & 0x80)>>7;
661   int flipy = 0;//(state->reel2_ram[(tile_index*2)+1] & 0x40)>>5;
651662
652   int priority = (sfbonus_reel2_ram[(tile_index*2)+1] & 0x40)>>6;
663   int priority = (state->reel2_ram[(tile_index*2)+1] & 0x40)>>6;
653664
654665   SET_TILE_INFO(
655666         1,
r10886r10887
660671
661672static TILE_GET_INFO( get_sfbonus_reel3_tile_info )
662673{
663   int code = sfbonus_reel3_ram[(tile_index*2)+0] | (sfbonus_reel3_ram[(tile_index*2)+1]<<8);
664   int flipx = (sfbonus_reel3_ram[(tile_index*2)+1] & 0x80)>>7;
665   int flipy = 0;//(sfbonus_reel3_ram[(tile_index*2)+1] & 0x40)>>5;
674   sfbonus_state *state = machine->driver_data<sfbonus_state>();
675   int code = state->reel3_ram[(tile_index*2)+0] | (state->reel3_ram[(tile_index*2)+1]<<8);
676   int flipx = (state->reel3_ram[(tile_index*2)+1] & 0x80)>>7;
677   int flipy = 0;//(state->reel3_ram[(tile_index*2)+1] & 0x40)>>5;
666678
667   int priority = (sfbonus_reel3_ram[(tile_index*2)+1] & 0x40)>>6;
679   int priority = (state->reel3_ram[(tile_index*2)+1] & 0x40)>>6;
668680
669681   SET_TILE_INFO(
670682         1,
r10886r10887
675687
676688static TILE_GET_INFO( get_sfbonus_reel4_tile_info )
677689{
678   int code = sfbonus_reel4_ram[(tile_index*2)+0] | (sfbonus_reel4_ram[(tile_index*2)+1]<<8);
679   int flipx = (sfbonus_reel4_ram[(tile_index*2)+1] & 0x80)>>7;
680   int flipy = 0;//(sfbonus_reel4_ram[(tile_index*2)+1] & 0x40)>>5;
690   sfbonus_state *state = machine->driver_data<sfbonus_state>();
691   int code = state->reel4_ram[(tile_index*2)+0] | (state->reel4_ram[(tile_index*2)+1]<<8);
692   int flipx = (state->reel4_ram[(tile_index*2)+1] & 0x80)>>7;
693   int flipy = 0;//(state->reel4_ram[(tile_index*2)+1] & 0x40)>>5;
681694
682   int priority = (sfbonus_reel4_ram[(tile_index*2)+1] & 0x40)>>6;
695   int priority = (state->reel4_ram[(tile_index*2)+1] & 0x40)>>6;
683696
684697   SET_TILE_INFO(
685698         1,
r10886r10887
691704
692705static WRITE8_HANDLER( sfbonus_videoram_w )
693706{
707   sfbonus_state *state = space->machine->driver_data<sfbonus_state>();
694708   if (offset<0x4000) /* 0x0000 - 0x3fff */
695709   {
696      sfbonus_tilemap_ram[offset] = data;
697      tilemap_mark_tile_dirty(sfbonus_tilemap,offset/2);
710      state->tilemap_ram[offset] = data;
711      tilemap_mark_tile_dirty(state->tilemap,offset/2);
698712   }
699713   else if (offset<0x4800) /* 0x4000 - 0x47ff */
700714   {
701715      offset-=0x4000;
702716
703      sfbonus_reel_ram[offset] = data;
704      tilemap_mark_tile_dirty(sfbonus_reel_tilemap,offset/2);
717      state->reel_ram[offset] = data;
718      tilemap_mark_tile_dirty(state->reel_tilemap,offset/2);
705719   }
706720   else if (offset<0x5000)  /* 0x4800 - 0x4fff */
707721   {
708722      offset-=0x4800;
709723
710      sfbonus_reel2_ram[offset] = data;
711      tilemap_mark_tile_dirty(sfbonus_reel2_tilemap,offset/2);
724      state->reel2_ram[offset] = data;
725      tilemap_mark_tile_dirty(state->reel2_tilemap,offset/2);
712726   }
713727   else if (offset<0x5800) /* 0x5000 - 0x57ff */
714728   {
715729      offset-=0x5000;
716730
717      sfbonus_reel3_ram[offset] = data;
718      tilemap_mark_tile_dirty(sfbonus_reel3_tilemap,offset/2);
731      state->reel3_ram[offset] = data;
732      tilemap_mark_tile_dirty(state->reel3_tilemap,offset/2);
719733   }
720734   else if (offset<0x6000) /* 0x5800 - 0x5fff */
721735   {
722736      offset-=0x5800;
723737
724      sfbonus_reel4_ram[offset] = data;
725      tilemap_mark_tile_dirty(sfbonus_reel4_tilemap,offset/2);
738      state->reel4_ram[offset] = data;
739      tilemap_mark_tile_dirty(state->reel4_tilemap,offset/2);
726740   }
727741   else if (offset<0x8000)
728742   {
729743      offset -=0x6000;
730744      // scroll regs etc.
731745      //logerror("access vram at [%04x] <- %02x\n",offset,data);
732      sfbonus_videoram[offset] = data;
746      state->videoram[offset] = data;
733747   }
734748   else
735749   {
r10886r10887
742756
743757static VIDEO_START(sfbonus)
744758{
745   temp_reel_bitmap = auto_bitmap_alloc(machine,1024,512,BITMAP_FORMAT_INDEXED16);
759   sfbonus_state *state = machine->driver_data<sfbonus_state>();
760   state->temp_reel_bitmap = auto_bitmap_alloc(machine,1024,512,BITMAP_FORMAT_INDEXED16);
746761
747   sfbonus_tilemap = tilemap_create(machine,get_sfbonus_tile_info,tilemap_scan_rows,8,8, 128, 64);
748   sfbonus_reel_tilemap = tilemap_create(machine,get_sfbonus_reel_tile_info,tilemap_scan_rows,8,32, 64, 16);
749   sfbonus_reel2_tilemap = tilemap_create(machine,get_sfbonus_reel2_tile_info,tilemap_scan_rows,8,32, 64, 16);
750   sfbonus_reel3_tilemap = tilemap_create(machine,get_sfbonus_reel3_tile_info,tilemap_scan_rows,8,32, 64, 16);
751   sfbonus_reel4_tilemap = tilemap_create(machine,get_sfbonus_reel4_tile_info,tilemap_scan_rows,8,32, 64, 16);
762   state->tilemap = tilemap_create(machine,get_sfbonus_tile_info,tilemap_scan_rows,8,8, 128, 64);
763   state->reel_tilemap = tilemap_create(machine,get_sfbonus_reel_tile_info,tilemap_scan_rows,8,32, 64, 16);
764   state->reel2_tilemap = tilemap_create(machine,get_sfbonus_reel2_tile_info,tilemap_scan_rows,8,32, 64, 16);
765   state->reel3_tilemap = tilemap_create(machine,get_sfbonus_reel3_tile_info,tilemap_scan_rows,8,32, 64, 16);
766   state->reel4_tilemap = tilemap_create(machine,get_sfbonus_reel4_tile_info,tilemap_scan_rows,8,32, 64, 16);
752767
753   tilemap_set_transparent_pen(sfbonus_tilemap,0);
754   tilemap_set_transparent_pen(sfbonus_reel_tilemap,255);
755   tilemap_set_transparent_pen(sfbonus_reel2_tilemap,255);
756   tilemap_set_transparent_pen(sfbonus_reel3_tilemap,255);
757   tilemap_set_transparent_pen(sfbonus_reel4_tilemap,255);
768   tilemap_set_transparent_pen(state->tilemap,0);
769   tilemap_set_transparent_pen(state->reel_tilemap,255);
770   tilemap_set_transparent_pen(state->reel2_tilemap,255);
771   tilemap_set_transparent_pen(state->reel3_tilemap,255);
772   tilemap_set_transparent_pen(state->reel4_tilemap,255);
758773
759   tilemap_set_scroll_rows(sfbonus_tilemap,64);
774   tilemap_set_scroll_rows(state->tilemap,64);
760775
761   tilemap_set_scroll_cols(sfbonus_reel_tilemap, 64);
762   tilemap_set_scroll_cols(sfbonus_reel2_tilemap, 64);
763   tilemap_set_scroll_cols(sfbonus_reel3_tilemap, 64);
764   tilemap_set_scroll_cols(sfbonus_reel4_tilemap, 64);
776   tilemap_set_scroll_cols(state->reel_tilemap, 64);
777   tilemap_set_scroll_cols(state->reel2_tilemap, 64);
778   tilemap_set_scroll_cols(state->reel3_tilemap, 64);
779   tilemap_set_scroll_cols(state->reel4_tilemap, 64);
765780
766781
767782}
768783
769784static void sfbonus_draw_reel_layer(screen_device *screen, bitmap_t *bitmap, const rectangle *cliprect, int catagory)
770785{
786   sfbonus_state *state = screen->machine->driver_data<sfbonus_state>();
771787   int zz;
772788   int i;
773789   int startclipmin;
774790   const rectangle &visarea = screen->visible_area();
775   UINT8* selectbase = &sfbonus_videoram[0x600];
776   UINT8* bg_scroll = &sfbonus_videoram[0x000];
777   UINT8* reels_rowscroll = &sfbonus_videoram[0x400];
778   int globalyscrollreels = (sfbonus_vregs[6] | sfbonus_vregs[7]<<8);
779   int globalxscrollreels = (sfbonus_vregs[4] | sfbonus_vregs[5]<<8);
791   UINT8* selectbase = &state->videoram[0x600];
792   UINT8* bg_scroll = &state->videoram[0x000];
793   UINT8* reels_rowscroll = &state->videoram[0x400];
794   int globalyscrollreels = (state->vregs[6] | state->vregs[7]<<8);
795   int globalxscrollreels = (state->vregs[4] | state->vregs[5]<<8);
780796   globalyscrollreels += 8;
781797   globalxscrollreels += 8;
782798
r10886r10887
786802   {
787803      int scroll;
788804      scroll = bg_scroll[(i*2)+0x000] | (bg_scroll[(i*2)+0x001]<<8);
789      tilemap_set_scrolly(sfbonus_reel_tilemap, i, scroll + globalyscrollreels );
805      tilemap_set_scrolly(state->reel_tilemap, i, scroll + globalyscrollreels );
790806
791807      scroll = bg_scroll[(i*2)+0x080] | (bg_scroll[(i*2)+0x081]<<8);
792      tilemap_set_scrolly(sfbonus_reel2_tilemap, i, scroll + globalyscrollreels);
808      tilemap_set_scrolly(state->reel2_tilemap, i, scroll + globalyscrollreels);
793809
794810      scroll = bg_scroll[(i*2)+0x100] | (bg_scroll[(i*2)+0x101]<<8);
795      tilemap_set_scrolly(sfbonus_reel3_tilemap, i, scroll + globalyscrollreels);
811      tilemap_set_scrolly(state->reel3_tilemap, i, scroll + globalyscrollreels);
796812
797813      scroll = bg_scroll[(i*2)+0x180] | (bg_scroll[(i*2)+0x181]<<8);
798      tilemap_set_scrolly(sfbonus_reel4_tilemap, i, scroll + globalyscrollreels);
814      tilemap_set_scrolly(state->reel4_tilemap, i, scroll + globalyscrollreels);
799815   }
800816
801817//  printf("------------\n");
r10886r10887
826842      {
827843         rowscroll = reels_rowscroll[((line/8)*2)+0x000] | (reels_rowscroll[((line/8)*2)+0x001]<<8);
828844         xxxscroll = globalxscrollreels + rowscroll;
829         tilemap_set_scrollx(sfbonus_reel_tilemap, 0, xxxscroll  );
830         tilemap_set_scrollx(sfbonus_reel2_tilemap, 0, xxxscroll );
831         tilemap_set_scrollx(sfbonus_reel3_tilemap, 0, xxxscroll );
832         tilemap_set_scrollx(sfbonus_reel4_tilemap, 0, xxxscroll );
845         tilemap_set_scrollx(state->reel_tilemap, 0, xxxscroll  );
846         tilemap_set_scrollx(state->reel2_tilemap, 0, xxxscroll );
847         tilemap_set_scrollx(state->reel3_tilemap, 0, xxxscroll );
848         tilemap_set_scrollx(state->reel4_tilemap, 0, xxxscroll );
833849      }
834850      else if (rowenable==0x1)
835851      {
836852         rowscroll = reels_rowscroll[((line/8)*2)+0x080] | (reels_rowscroll[((line/8)*2)+0x081]<<8);
837853         xxxscroll = globalxscrollreels + rowscroll;
838         tilemap_set_scrollx(sfbonus_reel_tilemap, 0, xxxscroll  );
839         tilemap_set_scrollx(sfbonus_reel2_tilemap, 0, xxxscroll );
840         tilemap_set_scrollx(sfbonus_reel3_tilemap, 0, xxxscroll );
841         tilemap_set_scrollx(sfbonus_reel4_tilemap, 0, xxxscroll );
854         tilemap_set_scrollx(state->reel_tilemap, 0, xxxscroll  );
855         tilemap_set_scrollx(state->reel2_tilemap, 0, xxxscroll );
856         tilemap_set_scrollx(state->reel3_tilemap, 0, xxxscroll );
857         tilemap_set_scrollx(state->reel4_tilemap, 0, xxxscroll );
842858      }
843859      else if (rowenable==0x2)
844860      {
845861         rowscroll = reels_rowscroll[((line/8)*2)+0x100] | (reels_rowscroll[((line/8)*2)+0x101]<<8);
846862         xxxscroll = globalxscrollreels + rowscroll;
847         tilemap_set_scrollx(sfbonus_reel_tilemap, 0, xxxscroll  );
848         tilemap_set_scrollx(sfbonus_reel2_tilemap, 0, xxxscroll );
849         tilemap_set_scrollx(sfbonus_reel3_tilemap, 0, xxxscroll );
850         tilemap_set_scrollx(sfbonus_reel4_tilemap, 0, xxxscroll );
863         tilemap_set_scrollx(state->reel_tilemap, 0, xxxscroll  );
864         tilemap_set_scrollx(state->reel2_tilemap, 0, xxxscroll );
865         tilemap_set_scrollx(state->reel3_tilemap, 0, xxxscroll );
866         tilemap_set_scrollx(state->reel4_tilemap, 0, xxxscroll );
851867      }
852868      else if (rowenable==0x3)
853869      {
854870         rowscroll = reels_rowscroll[((line/8)*2)+0x180] | (reels_rowscroll[((line/8)*2)+0x181]<<8);
855871         xxxscroll = globalxscrollreels + rowscroll;
856         tilemap_set_scrollx(sfbonus_reel_tilemap, 0, xxxscroll  );
857         tilemap_set_scrollx(sfbonus_reel2_tilemap, 0, xxxscroll );
858         tilemap_set_scrollx(sfbonus_reel3_tilemap, 0, xxxscroll );
859         tilemap_set_scrollx(sfbonus_reel4_tilemap, 0, xxxscroll );
872         tilemap_set_scrollx(state->reel_tilemap, 0, xxxscroll  );
873         tilemap_set_scrollx(state->reel2_tilemap, 0, xxxscroll );
874         tilemap_set_scrollx(state->reel3_tilemap, 0, xxxscroll );
875         tilemap_set_scrollx(state->reel4_tilemap, 0, xxxscroll );
860876      }
861877
862878      if (rowenable2==0)
863879      {
864         tilemap_draw(temp_reel_bitmap,&clip,sfbonus_reel_tilemap,TILEMAP_DRAW_CATEGORY(catagory),3);
880         tilemap_draw(state->temp_reel_bitmap,&clip,state->reel_tilemap,TILEMAP_DRAW_CATEGORY(catagory),3);
865881      }
866882      if (rowenable==0)
867883      {
868         tilemap_draw(temp_reel_bitmap,&clip,sfbonus_reel_tilemap,TILEMAP_DRAW_CATEGORY(catagory),3);
884         tilemap_draw(state->temp_reel_bitmap,&clip,state->reel_tilemap,TILEMAP_DRAW_CATEGORY(catagory),3);
869885      }
870886
871887      if (rowenable2==0x1)
872888      {
873         tilemap_draw(temp_reel_bitmap,&clip,sfbonus_reel2_tilemap,TILEMAP_DRAW_CATEGORY(catagory),2);
889         tilemap_draw(state->temp_reel_bitmap,&clip,state->reel2_tilemap,TILEMAP_DRAW_CATEGORY(catagory),2);
874890      }
875891      if (rowenable==0x1)
876892      {
877         tilemap_draw(temp_reel_bitmap,&clip,sfbonus_reel2_tilemap,TILEMAP_DRAW_CATEGORY(catagory),2);
893         tilemap_draw(state->temp_reel_bitmap,&clip,state->reel2_tilemap,TILEMAP_DRAW_CATEGORY(catagory),2);
878894      }
879895
880896      if (rowenable2==0x2)
881897      {
882         tilemap_draw(temp_reel_bitmap,&clip,sfbonus_reel3_tilemap,TILEMAP_DRAW_CATEGORY(catagory),1);
898         tilemap_draw(state->temp_reel_bitmap,&clip,state->reel3_tilemap,TILEMAP_DRAW_CATEGORY(catagory),1);
883899      }
884900      if (rowenable==0x2)
885901      {
886         tilemap_draw(temp_reel_bitmap,&clip,sfbonus_reel3_tilemap,TILEMAP_DRAW_CATEGORY(catagory),1);
902         tilemap_draw(state->temp_reel_bitmap,&clip,state->reel3_tilemap,TILEMAP_DRAW_CATEGORY(catagory),1);
887903      }
888904
889905      if (rowenable2==0x3)
890906      {
891         tilemap_draw(temp_reel_bitmap,&clip,sfbonus_reel4_tilemap,TILEMAP_DRAW_CATEGORY(catagory),4);
907         tilemap_draw(state->temp_reel_bitmap,&clip,state->reel4_tilemap,TILEMAP_DRAW_CATEGORY(catagory),4);
892908      }
893909      if (rowenable==0x3)
894910      {
895         tilemap_draw(temp_reel_bitmap,&clip,sfbonus_reel4_tilemap,TILEMAP_DRAW_CATEGORY(catagory),4);
911         tilemap_draw(state->temp_reel_bitmap,&clip,state->reel4_tilemap,TILEMAP_DRAW_CATEGORY(catagory),4);
896912      }
897913
898914
r10886r10887
906922
907923static SCREEN_UPDATE(sfbonus)
908924{
925   sfbonus_state *state = screen->machine->driver_data<sfbonus_state>();
909926
910   int globalyscroll = (sfbonus_vregs[2] | sfbonus_vregs[3]<<8);
911   int globalxscroll = (sfbonus_vregs[0] | sfbonus_vregs[1]<<8);
912   UINT8* front_rowscroll = &sfbonus_videoram[0x200];
927   int globalyscroll = (state->vregs[2] | state->vregs[3]<<8);
928   int globalxscroll = (state->vregs[0] | state->vregs[1]<<8);
929   UINT8* front_rowscroll = &state->videoram[0x200];
913930   const input_port_token *ipt;
914931   int i;
915932
r10886r10887
918935   globalxscroll += 8;
919936
920937   bitmap_fill(bitmap,cliprect,screen->machine->pens[0]);
921   bitmap_fill(temp_reel_bitmap,cliprect,screen->machine->pens[0]);
938   bitmap_fill(state->temp_reel_bitmap,cliprect,screen->machine->pens[0]);
922939
923940   /* render reels to bitmap */
924   sfbonus_draw_reel_layer(screen,temp_reel_bitmap,cliprect,0);
941   sfbonus_draw_reel_layer(screen,state->temp_reel_bitmap,cliprect,0);
925942
926943   {
927944      int y,x;
r10886r10887
930947      {
931948         for (x=0;x<512;x++)
932949         {
933            UINT16* src = BITMAP_ADDR16(temp_reel_bitmap, y, x);
950            UINT16* src = BITMAP_ADDR16(state->temp_reel_bitmap, y, x);
934951            UINT16* dst = BITMAP_ADDR16(bitmap, y, x);
935952
936953            if ((src[0]&0x100)==0x000)
r10886r10887
940957   }
941958
942959   /* Normal Tilemap */
943   tilemap_set_scrolly(sfbonus_tilemap, 0, globalyscroll );
960   tilemap_set_scrolly(state->tilemap, 0, globalyscroll );
944961   for (i=0;i<64;i++)
945962   {
946963      int scroll;
947964      scroll = front_rowscroll[(i*2)+0x000] | (front_rowscroll[(i*2)+0x001]<<8);
948      tilemap_set_scrollx(sfbonus_tilemap, i, scroll+globalxscroll );
965      tilemap_set_scrollx(state->tilemap, i, scroll+globalxscroll );
949966   }
950   tilemap_draw(bitmap,cliprect,sfbonus_tilemap,0,0);
967   tilemap_draw(bitmap,cliprect,state->tilemap,0,0);
951968
952969   {
953970      int y,x;
r10886r10887
956973      {
957974         for (x=0;x<512;x++)
958975         {
959            UINT16* src = BITMAP_ADDR16(temp_reel_bitmap, y, x);
976            UINT16* src = BITMAP_ADDR16(state->temp_reel_bitmap, y, x);
960977            UINT16* dst = BITMAP_ADDR16(bitmap, y, x);
961978
962979            if ((src[0]&0x100)==0x100)
r10886r10887
966983   }
967984#if 0
968985    popmessage("%02x %02x %02x %02x %02x %02x %02x %02x -- %02x -- %02x %02x -- %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",
969    sfbonus_3800_regs[0],
970    sfbonus_3800_regs[1],
971    sfbonus_3800_regs[2],
972    sfbonus_3800_regs[3],
973    sfbonus_3800_regs[4],
974    sfbonus_3800_regs[5],
975    sfbonus_3800_regs[6],
976    sfbonus_3800_regs[7],
977    sfbonus_3000_regs[0],
978    sfbonus_2801_regs[0],
979    sfbonus_2c01_regs[0],
980    sfbonus_vregs[8],
981    sfbonus_vregs[0],
982    sfbonus_vregs[10],
983    sfbonus_vregs[11],
984    sfbonus_vregs[12],
985    sfbonus_vregs[13],
986    sfbonus_vregs[14],
987    sfbonus_vregs[15],
988    sfbonus_vregs[16],
989    sfbonus_vregs[17],
990    sfbonus_vregs[18],
991    sfbonus_vregs[19],
992    sfbonus_vregs[20],
993    sfbonus_vregs[21],
994    sfbonus_vregs[22],
995    sfbonus_vregs[23],
996    sfbonus_vregs[24],
997    sfbonus_vregs[25],
998    sfbonus_vregs[26],
999    sfbonus_vregs[27],
1000    sfbonus_vregs[28],
1001    sfbonus_vregs[29],
1002    sfbonus_vregs[30],
1003    sfbonus_vregs[31]
986    state->_3800_regs[0],
987    state->_3800_regs[1],
988    state->_3800_regs[2],
989    state->_3800_regs[3],
990    state->_3800_regs[4],
991    state->_3800_regs[5],
992    state->_3800_regs[6],
993    state->_3800_regs[7],
994    state->_3000_regs[0],
995    state->_2801_regs[0],
996    state->_2c01_regs[0],
997    state->vregs[8],
998    state->vregs[0],
999    state->vregs[10],
1000    state->vregs[11],
1001    state->vregs[12],
1002    state->vregs[13],
1003    state->vregs[14],
1004    state->vregs[15],
1005    state->vregs[16],
1006    state->vregs[17],
1007    state->vregs[18],
1008    state->vregs[19],
1009    state->vregs[20],
1010    state->vregs[21],
1011    state->vregs[22],
1012    state->vregs[23],
1013    state->vregs[24],
1014    state->vregs[25],
1015    state->vregs[26],
1016    state->vregs[27],
1017    state->vregs[28],
1018    state->vregs[29],
1019    state->vregs[30],
1020    state->vregs[31]
10041021    );
10051022
10061023    popmessage("-- %02x %02x %02x %02x %02x %02x %02x %02x",
1007    sfbonus_1800_regs[0],
1008    sfbonus_1800_regs[1],
1009    sfbonus_1800_regs[2],
1010    sfbonus_1800_regs[3],
1011    sfbonus_1800_regs[4],
1012    sfbonus_1800_regs[5],
1013    sfbonus_1800_regs[6],
1014    sfbonus_1800_regs[7]);
1024    state->_1800_regs[0],
1025    state->_1800_regs[1],
1026    state->_1800_regs[2],
1027    state->_1800_regs[3],
1028    state->_1800_regs[4],
1029    state->_1800_regs[5],
1030    state->_1800_regs[6],
1031    state->_1800_regs[7]);
10151032#endif
10161033
10171034   ipt = screen->machine->gamedrv->ipt;
r10886r10887
10191036      || (ipt == INPUT_PORTS_NAME(amcoe2_poker)))
10201037   {
10211038      // based on pirpok2
1022      output_set_lamp_value(0, (sfbonus_1800_regs[6] & 0x1) >> 0);
1023      output_set_lamp_value(1, (sfbonus_1800_regs[6] & 0x4) >> 2);
1024      output_set_lamp_value(2, (sfbonus_1800_regs[5] & 0x4) >> 2);
1025      output_set_lamp_value(3, (sfbonus_1800_regs[5] & 0x1) >> 0);
1026      output_set_lamp_value(4, (sfbonus_1800_regs[4] & 0x4) >> 2);
1027      output_set_lamp_value(5, (sfbonus_1800_regs[4] & 0x1) >> 0);
1039      output_set_lamp_value(0, (state->_1800_regs[6] & 0x1) >> 0);
1040      output_set_lamp_value(1, (state->_1800_regs[6] & 0x4) >> 2);
1041      output_set_lamp_value(2, (state->_1800_regs[5] & 0x4) >> 2);
1042      output_set_lamp_value(3, (state->_1800_regs[5] & 0x1) >> 0);
1043      output_set_lamp_value(4, (state->_1800_regs[4] & 0x4) >> 2);
1044      output_set_lamp_value(5, (state->_1800_regs[4] & 0x1) >> 0);
10281045   }
10291046   else if ((ipt == INPUT_PORTS_NAME(amcoe1_reels3)) || (ipt == INPUT_PORTS_NAME(amcoe1_reels4))
10301047      || (ipt == INPUT_PORTS_NAME(amcoe1_poker)))
10311048   {
1032      output_set_lamp_value(0, (sfbonus_1800_regs[0] & 0x2) >> 1);
1033      output_set_lamp_value(1, (sfbonus_1800_regs[4] & 0x2) >> 1);
1034      output_set_lamp_value(2, (sfbonus_1800_regs[3] & 0x2) >> 1);
1035      output_set_lamp_value(3, (sfbonus_1800_regs[6] & 0x4) >> 2);
1036      output_set_lamp_value(4, (sfbonus_1800_regs[4] & 0x4) >> 2);
1037      output_set_lamp_value(5, (sfbonus_1800_regs[3] & 0x4) >> 2);
1049      output_set_lamp_value(0, (state->_1800_regs[0] & 0x2) >> 1);
1050      output_set_lamp_value(1, (state->_1800_regs[4] & 0x2) >> 1);
1051      output_set_lamp_value(2, (state->_1800_regs[3] & 0x2) >> 1);
1052      output_set_lamp_value(3, (state->_1800_regs[6] & 0x4) >> 2);
1053      output_set_lamp_value(4, (state->_1800_regs[4] & 0x4) >> 2);
1054      output_set_lamp_value(5, (state->_1800_regs[3] & 0x4) >> 2);
10381055   }
10391056
10401057   return 0;
r10886r10887
10431060
10441061static WRITE8_HANDLER( paletteram_io_w )
10451062{
1046   static int pal_offs,r,g,b,internal_pal_offs;
1047
1063   sfbonus_state *state = space->machine->driver_data<sfbonus_state>();
10481064   switch(offset)
10491065   {
10501066      case 0:
1051         pal_offs = data;
1067         state->pal.offs = data;
10521068         break;
10531069      case 2:
1054         internal_pal_offs = 0;
1070         state->pal.offs_internal = 0;
10551071         break;
10561072      case 1:
1057         switch(internal_pal_offs)
1073         switch(state->pal.offs_internal)
10581074         {
10591075            case 0:
1060               r = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
1061               internal_pal_offs++;
1076               state->pal.r = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
1077               state->pal.offs_internal++;
10621078               break;
10631079            case 1:
1064               g = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
1065               internal_pal_offs++;
1080               state->pal.g = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
1081               state->pal.offs_internal++;
10661082               break;
10671083            case 2:
1068               b = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
1069               palette_set_color(space->machine, pal_offs, MAKE_RGB(r, g, b));
1070               internal_pal_offs = 0;
1071               pal_offs++;
1084               state->pal.b = ((data & 0x3f) << 2) | ((data & 0x30) >> 4);
1085               palette_set_color(space->machine, state->pal.offs, MAKE_RGB(state->pal.r, state->pal.g, state->pal.b));
1086               state->pal.offs_internal = 0;
1087               state->pal.offs++;
10721088               break;
10731089         }
10741090
r10886r10887
10801096
10811097static ADDRESS_MAP_START( sfbonus_map, ADDRESS_SPACE_PROGRAM, 8 )
10821098   AM_RANGE(0x0000, 0xefff) AM_ROMBANK("bank1") AM_WRITE(sfbonus_videoram_w)
1083   AM_RANGE(0xf000, 0xffff) AM_RAM AM_BASE(&nvram) AM_SIZE(&nvram_size)
1099   AM_RANGE(0xf000, 0xffff) AM_RAM AM_BASE_MEMBER(sfbonus_state, nvram) AM_SIZE_MEMBER(sfbonus_state, nvram_size)
10841100ADDRESS_MAP_END
10851101
10861102static WRITE8_HANDLER( sfbonus_bank_w )
r10886r10887
11241140// lamps and coin counters
11251141static WRITE8_HANDLER( sfbonus_1800_w )
11261142{
1127   sfbonus_1800_regs[offset] = data;
1143   sfbonus_state *state = space->machine->driver_data<sfbonus_state>();
1144   state->_1800_regs[offset] = data;
11281145}
11291146
11301147static WRITE8_HANDLER( sfbonus_3800_w )
11311148{
1132   sfbonus_3800_regs[offset] = data;
1149   sfbonus_state *state = space->machine->driver_data<sfbonus_state>();
1150   state->_3800_regs[offset] = data;
11331151}
11341152
11351153static WRITE8_HANDLER( sfbonus_3000_w )
11361154{
1137   sfbonus_3000_regs[offset] = data;
1155   sfbonus_state *state = space->machine->driver_data<sfbonus_state>();
1156   state->_3000_regs[offset] = data;
11381157}
11391158
11401159static WRITE8_HANDLER( sfbonus_2801_w )
11411160{
1142   sfbonus_2801_regs[offset] = data;
1161   sfbonus_state *state = space->machine->driver_data<sfbonus_state>();
1162   state->_2801_regs[offset] = data;
11431163}
11441164
11451165static WRITE8_HANDLER( sfbonus_2c01_w )
11461166{
1147   sfbonus_2c01_regs[offset] = data;
1167   sfbonus_state *state = space->machine->driver_data<sfbonus_state>();
1168   state->_2c01_regs[offset] = data;
11481169}
11491170
11501171
r10886r10887
11631184
11641185   AM_RANGE(0x0c00, 0x0c03) AM_WRITE( paletteram_io_w )
11651186
1166   AM_RANGE(0x1800, 0x1807) AM_WRITE(sfbonus_1800_w) AM_BASE(&sfbonus_1800_regs) // lamps and coin counters
1187   AM_RANGE(0x1800, 0x1807) AM_WRITE(sfbonus_1800_w) AM_BASE_MEMBER(sfbonus_state, _1800_regs) // lamps and coin counters
11671188
1168   AM_RANGE(0x2400, 0x241f) AM_RAM AM_BASE(&sfbonus_vregs)
1189   AM_RANGE(0x2400, 0x241f) AM_RAM AM_BASE_MEMBER(sfbonus_state, vregs)
11691190
11701191   AM_RANGE(0x2800, 0x2800) AM_READ(sfbonus_2800_r)
1171   AM_RANGE(0x2801, 0x2801) AM_READ(sfbonus_2801_r) AM_WRITE(sfbonus_2801_w) AM_BASE(&sfbonus_2801_regs)
1192   AM_RANGE(0x2801, 0x2801) AM_READ(sfbonus_2801_r) AM_WRITE(sfbonus_2801_w) AM_BASE_MEMBER(sfbonus_state, _2801_regs)
11721193
11731194   AM_RANGE(0x2c00, 0x2c00) AM_READ(sfbonus_2c00_r)
1174   AM_RANGE(0x2c01, 0x2c01) AM_READ(sfbonus_2c01_r) AM_WRITE(sfbonus_2c01_w) AM_BASE(&sfbonus_2c01_regs)
1195   AM_RANGE(0x2c01, 0x2c01) AM_READ(sfbonus_2c01_r) AM_WRITE(sfbonus_2c01_w) AM_BASE_MEMBER(sfbonus_state, _2c01_regs)
11751196
1176   AM_RANGE(0x3000, 0x3000) AM_WRITE(sfbonus_3000_w) AM_BASE(&sfbonus_3000_regs)
1197   AM_RANGE(0x3000, 0x3000) AM_WRITE(sfbonus_3000_w) AM_BASE_MEMBER(sfbonus_state, _3000_regs)
11771198   AM_RANGE(0x3400, 0x3400) AM_WRITE(sfbonus_bank_w)
11781199   AM_RANGE(0x3800, 0x3800) AM_READ(sfbonus_3800_r)
11791200
1180   AM_RANGE(0x3800, 0x3807) AM_WRITE(sfbonus_3800_w) AM_BASE(&sfbonus_3800_regs)
1201   AM_RANGE(0x3800, 0x3807) AM_WRITE(sfbonus_3800_w) AM_BASE_MEMBER(sfbonus_state, _3800_regs)
11811202ADDRESS_MAP_END
11821203
11831204
r10886r10887
12241245
12251246static NVRAM_HANDLER( sfbonus )
12261247{
1248   sfbonus_state *state = machine->driver_data<sfbonus_state>();
12271249   if (read_or_write)
1228      file->write(nvram,nvram_size);
1250      file->write(state->nvram,state->nvram_size);
12291251   else
12301252   {
12311253      if (file)
12321254      {
1233         memset(nvram,0x00,nvram_size);
1234         file->read(nvram,nvram_size);
1255         memset(state->nvram,0x00,state->nvram_size);
1256         file->read(state->nvram,state->nvram_size);
12351257      }
12361258      else
12371259      {
12381260         UINT8* defaultram = machine->region("defaults")->base();
1239         memset(nvram,0x00,nvram_size);
1261         memset(state->nvram,0x00,state->nvram_size);
12401262
12411263         if (defaultram)
12421264            if ((defaultram[0x02]==0x00) && (defaultram[0x03]==0x00)) // hack! rom region optional regions get cleared with garbage if no rom is present, this is not good!
1243               memcpy(nvram, machine->region("defaults")->base(), machine->region("defaults")->bytes());
1265               memcpy(state->nvram, machine->region("defaults")->base(), machine->region("defaults")->bytes());
12441266      }
12451267   }
12461268}
12471269
12481270
1249static MACHINE_CONFIG_START( sfbonus, driver_device )
1271static MACHINE_CONFIG_START( sfbonus, sfbonus_state )
12501272   MCFG_CPU_ADD("maincpu", Z80, 6000000) // custom packaged z80 CPU ?? Mhz
12511273   MCFG_CPU_PROGRAM_MAP(sfbonus_map)
12521274   MCFG_CPU_IO_MAP(sfbonus_io)
r10886r10887
54445466
54455467static DRIVER_INIT( sfbonus_common)
54465468{
5447   sfbonus_tilemap_ram = auto_alloc_array(machine, UINT8, 0x4000);
5448   memset(sfbonus_tilemap_ram, 0xff, 0x4000);
5449   state_save_register_global_pointer(machine, sfbonus_tilemap_ram , 0x4000);
5469   sfbonus_state *state = machine->driver_data<sfbonus_state>();
5470   state->tilemap_ram = auto_alloc_array(machine, UINT8, 0x4000);
5471   memset(state->tilemap_ram, 0xff, 0x4000);
5472   state_save_register_global_pointer(machine, state->tilemap_ram , 0x4000);
54505473
5451   sfbonus_reel_ram = auto_alloc_array(machine, UINT8, 0x0800);
5452   memset(sfbonus_reel_ram, 0xff ,0x0800);
5453   state_save_register_global_pointer(machine, sfbonus_reel_ram , 0x0800);
5474   state->reel_ram = auto_alloc_array(machine, UINT8, 0x0800);
5475   memset(state->reel_ram, 0xff ,0x0800);
5476   state_save_register_global_pointer(machine, state->reel_ram , 0x0800);
54545477
5455   sfbonus_reel2_ram = auto_alloc_array(machine, UINT8, 0x0800);
5456   memset(sfbonus_reel2_ram, 0xff, 0x0800);
5457   state_save_register_global_pointer(machine, sfbonus_reel2_ram , 0x0800);
5478   state->reel2_ram = auto_alloc_array(machine, UINT8, 0x0800);
5479   memset(state->reel2_ram, 0xff, 0x0800);
5480   state_save_register_global_pointer(machine, state->reel2_ram , 0x0800);
54585481
5459   sfbonus_reel3_ram = auto_alloc_array(machine, UINT8, 0x0800);
5460   memset(sfbonus_reel3_ram, 0xff, 0x0800);
5461   state_save_register_global_pointer(machine, sfbonus_reel3_ram , 0x0800);
5482   state->reel3_ram = auto_alloc_array(machine, UINT8, 0x0800);
5483   memset(state->reel3_ram, 0xff, 0x0800);
5484   state_save_register_global_pointer(machine, state->reel3_ram , 0x0800);
54625485
5463   sfbonus_reel4_ram = auto_alloc_array(machine, UINT8, 0x0800);
5464   memset(sfbonus_reel4_ram, 0xff, 0x0800);
5465   state_save_register_global_pointer(machine, sfbonus_reel4_ram , 0x0800);
5486   state->reel4_ram = auto_alloc_array(machine, UINT8, 0x0800);
5487   memset(state->reel4_ram, 0xff, 0x0800);
5488   state_save_register_global_pointer(machine, state->reel4_ram , 0x0800);
54665489
54675490   // hack, because the debugger is broken
5468   sfbonus_videoram = machine->region("debugram")->base();
5469   if (!sfbonus_videoram)
5470      sfbonus_videoram = auto_alloc_array(machine, UINT8, 0x10000);
5491   state->videoram = machine->region("debugram")->base();
5492   if (!state->videoram)
5493      state->videoram = auto_alloc_array(machine, UINT8, 0x10000);
54715494
5472   memset(sfbonus_videoram, 0xff, 0x10000);
5495   memset(state->videoram, 0xff, 0x10000);
54735496
5474   state_save_register_global_pointer(machine, sfbonus_videoram, 0x10000);
5497   state_save_register_global_pointer(machine, state->videoram, 0x10000);
54755498
54765499   // dummy.rom helper
54775500   {
src/mame/drivers/rocnrope.c
r10886r10887
8484   /* "No Coin B" = coins produce sound, but no effect on coin counter */
8585
8686   PORT_START("DSW2")
87   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )
87   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )      PORT_DIPLOCATION("DSW2:1,2")
8888   PORT_DIPSETTING(    0x03, "3" )
8989   PORT_DIPSETTING(    0x02, "4" )
9090   PORT_DIPSETTING(    0x01, "5" )
9191   PORT_DIPSETTING(    0x00, "255 (Cheat)")
92   PORT_DIPNAME( 0x04, 0x00, DEF_STR( Cabinet ) )
92   PORT_DIPNAME( 0x04, 0x00, DEF_STR( Cabinet ) )      PORT_DIPLOCATION("DSW2:3")
9393   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
9494   PORT_DIPSETTING(    0x04, DEF_STR( Cocktail ) )
95   PORT_DIPNAME( 0x78, 0x78, DEF_STR( Difficulty ) )
95   PORT_DIPNAME( 0x78, 0x58, DEF_STR( Difficulty ) )   PORT_DIPLOCATION("DSW2:4,5,6,7")
9696   PORT_DIPSETTING(    0x78, "Easy 1" )
9797   PORT_DIPSETTING(    0x70, "Easy 2" )
9898   PORT_DIPSETTING(    0x68, "Easy 3" )
r10886r10887
109109   PORT_DIPSETTING(    0x10, "Difficult 2" )
110110   PORT_DIPSETTING(    0x08, "Difficult 3" )
111111   PORT_DIPSETTING(    0x00, "Difficult 4" )
112   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Demo_Sounds ) )
112   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Demo_Sounds ) )   PORT_DIPLOCATION("DSW2:8")
113113   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
114114   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
115115
116116   PORT_START("DSW3")
117   PORT_DIPNAME( 0x07, 0x07, "First Bonus" )
117   PORT_DIPNAME( 0x07, 0x07, "First Bonus" )      PORT_DIPLOCATION("DSW3:1,2,3")
118118   PORT_DIPSETTING(    0x07, "20000" )
119119   PORT_DIPSETTING(    0x05, "30000" )
120120   PORT_DIPSETTING(    0x04, "40000" )
r10886r10887
123123   PORT_DIPSETTING(    0x01, "70000" )
124124   PORT_DIPSETTING(    0x00, "80000" )
125125   /* 0x06 gives 20000 */
126   PORT_DIPNAME( 0x38, 0x38, "Repeated Bonus" )
126   PORT_DIPNAME( 0x38, 0x10, "Repeated Bonus" )      PORT_DIPLOCATION("DSW3:4,5,6")
127127   PORT_DIPSETTING(    0x38, "40000" )
128128   PORT_DIPSETTING(    0x18, "50000" )
129129   PORT_DIPSETTING(    0x10, "60000" )
130130   PORT_DIPSETTING(    0x08, "70000" )
131131   PORT_DIPSETTING(    0x00, "80000" )
132132   /* 0x20, 0x28 and 0x30 all gives 40000 */
133   PORT_DIPNAME( 0x40, 0x00, "Grant Repeated Bonus" )
133   PORT_DIPNAME( 0x40, 0x00, "Grant Repeated Bonus" )   PORT_DIPLOCATION("DSW3:7")
134134   PORT_DIPSETTING(    0x40, DEF_STR( No ) )
135135   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
136   PORT_DIPNAME( 0x80, 0x00, "Unknown DSW 8" )
137   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
138   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
136   PORT_DIPUNUSED_DIPLOC( 0x80, IP_ACTIVE_LOW, "DSW3:8" )
137//   PORT_DIPNAME( 0x80, 0x00, "Unknown DSW 8" )
138//   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
139//   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
139140INPUT_PORTS_END
140141
141142
r10886r10887
284285    ROM_LOAD( "h100.6g",      0x0000, 0x0001, NO_DUMP ) /* 20 Pin chip.  Appears to be a PAL.  Schematics obsfucated. */
285286ROM_END
286287
288/* Rope Man (a pirate of Roc'n'Rope)
287289
2904K files were 2732 and were on the sound board
2918K files were 2764
292The SUB devices were 82S153 PLS's
293G06 was a MMI PAL10L8CN
294A17 was a TBP18S030 read as an 82S123 and is probably the colour PROM.
295B16 was a TBP24S10  read as an 82S131
288296
297Very popular bootleg that was once in MAME and was taken out due to only being a gfx/copyright hack. */
298
299ROM_START( ropeman )
300   ROM_REGION( 0x10000, "maincpu", 0 )
301   ROM_LOAD( "j01_rm01.bin",  0x6000, 0x2000, CRC(6310a1fe) SHA1(7a32c5f24175b303bd40726c53c061951b9de594) )
302   ROM_LOAD( "j02_rm02.bin",  0x8000, 0x2000, CRC(75af8697) SHA1(70bb4b838cdafedf3d94425fad84f77815898d83) )
303   ROM_LOAD( "j03_rm03.bin",  0xa000, 0x2000, CRC(b21372b1) SHA1(c08ab3caaa646f4752f890d8339bce6b723864bb) )
304   ROM_LOAD( "j04_rm04.bin",  0xc000, 0x2000, CRC(7acb2a05) SHA1(93762d1890f40abc98372a2aa9fe0f63252b6389) )
305   ROM_LOAD( "j05_rm05.bin",  0xe000, 0x2000, CRC(150a6264) SHA1(930ccf8dcf4971d0a15f406d9114be5ecfaa1727) )
306
307   ROM_REGION( 0x10000, "tpsound", 0 )
308   ROM_LOAD( "j07_rm12.bin",  0x0000, 0x1000, CRC(75d2c4e2) SHA1(b701019b4e7b06b268be660ce7958b5367318c27) )
309   ROM_LOAD( "j08_rm13.bin",  0x1000, 0x1000, CRC(ca4325ae) SHA1(34ac035c0c2ed6bcafde1491d976bb9e9d2a2a7d) )
310
311   ROM_REGION( 0x8000, "gfx1", 0 )
312   ROM_LOAD( "a11_rm10.bin",  0x0000, 0x2000, CRC(afdaba5e) SHA1(27c090cb1c3767c997daeedbe1ba24786f9e78f1) )
313   ROM_LOAD( "a12_rm11.bin",  0x2000, 0x2000, CRC(054cafeb) SHA1(4c3cd850b347217af3dd5c9bb84bcff7b30689bd) )
314   ROM_LOAD( "a9_rm08.bin",   0x4000, 0x2000, CRC(9d2166b2) SHA1(42d2b05360e58b1b2b3ad06c98eb46d9da2b1c21) )
315   ROM_LOAD( "a10_rm09.bin",  0x6000, 0x2000, CRC(aff6e22f) SHA1(476d67821519feddc9f9c8537b46e6eede790035) )
316
317   ROM_REGION( 0x4000, "gfx2", 0 )
318   ROM_LOAD( "j12_rm07.bin",  0x0000, 0x2000, CRC(cd8ac4bf) SHA1(22bfd9ac0188bec6a1e8daa8ab915af1a5de7bd7) )
319   ROM_LOAD( "j11_rm06.bin",  0x2000, 0x2000, CRC(35891835) SHA1(9dc6795e336c61b5349cf7bf69a3dc9438ae9336) )
320
321   ROM_REGION( 0x0220, "proms", 0 )  /* Used from original board */
322   ROM_LOAD( "a17_prom.bin", 0x0000, 0x0020, CRC(22ad2c3e) SHA1(1c2198b286c75aa9e78d000432795b1ce86ad6b9) )
323   ROM_LOAD( "b16_prom.bin", 0x0020, 0x0100, CRC(750a9677) SHA1(7a5b4aed5f87180850657b8852bb3f3138d58b5b) )
324   ROM_LOAD( "rocnrope.pr3", 0x0120, 0x0100, CRC(b5c75a27) SHA1(923d6ccf015fd7458494416cc05426cc922a9238) )
325
326    ROM_REGION( 0x0001, "pal_cpuvidbd", 0 ) /* PAL located on the cpu/video board */
327    ROM_LOAD( "h100.6g",      0x0000, 0x0001, NO_DUMP ) /* 20 Pin chip.  Appears to be a PAL.  Schematics obsfucated. */
328ROM_END
329
289330/*************************************
290331 *
291332 *  Driver initialization
r10886r10887
313354
314355GAME( 1983, rocnrope, 0,        rocnrope, rocnrope, rocnrope, ROT270, "Konami", "Roc'n Rope", GAME_SUPPORTS_SAVE )
315356GAME( 1983, rocnropek,rocnrope, rocnrope, rocnrope, rocnropk, ROT270, "Konami / Kosuka", "Roc'n Rope (Kosuka)", GAME_SUPPORTS_SAVE )
357GAME( 1983, ropeman,  rocnrope, rocnrope, rocnrope, rocnrope, ROT270, "bootleg", "Ropeman (bootleg of Roc'n Rope)", GAME_SUPPORTS_SAVE )
src/mame/drivers/luckgrln.c
r10886r10887
8282#include "video/mc6845.h"
8383#include "luckgrln.lh"
8484
85static UINT8 *luck_vram1,*luck_vram2,*luck_vram3;
86static UINT8 nmi_enable;
87static tilemap_t *reel1_tilemap, *reel2_tilemap, *reel3_tilemap, *reel4_tilemap;
88static UINT8* reel1_ram;
89static UINT8* reel2_ram;
90static UINT8* reel3_ram;
91static UINT8* reel4_ram;
92static UINT8* reel1_scroll;
93static UINT8* reel2_scroll;
94static UINT8* reel3_scroll;
95static UINT8* reel4_scroll;
96static UINT8* reel1_attr;
97static UINT8* reel2_attr;
98static UINT8* reel3_attr;
99static UINT8* reel4_attr;
10085
86class luckgrln_state : public driver_device
87{
88public:
89   luckgrln_state(running_machine &machine, const driver_device_config_base &config)
90      : driver_device(machine, config) { }
10191
92   UINT8 *luck_vram1;
93   UINT8 *luck_vram2;
94   UINT8 *luck_vram3;
95   UINT8 nmi_enable;
96   tilemap_t *reel1_tilemap;
97   tilemap_t *reel2_tilemap;
98   tilemap_t *reel3_tilemap;
99   tilemap_t *reel4_tilemap;
100   UINT8* reel1_ram;
101   UINT8* reel2_ram;
102   UINT8* reel3_ram;
103   UINT8* reel4_ram;
104   UINT8* reel1_scroll;
105   UINT8* reel2_scroll;
106   UINT8* reel3_scroll;
107   UINT8* reel4_scroll;
108   UINT8* reel1_attr;
109   UINT8* reel2_attr;
110   UINT8* reel3_attr;
111   UINT8* reel4_attr;
112   int palette_count;
113   UINT8 palette_ram[0x10000];
114};
102115
116
103117static WRITE8_HANDLER( luckgrln_reel1_ram_w )
104118{
105   reel1_ram[offset] = data;
106   tilemap_mark_tile_dirty(reel1_tilemap,offset);
119   luckgrln_state *state = space->machine->driver_data<luckgrln_state>();
120   state->reel1_ram[offset] = data;
121   tilemap_mark_tile_dirty(state->reel1_tilemap,offset);
107122}
108123
109124static WRITE8_HANDLER( luckgrln_reel1_attr_w )
110125{
111   reel1_attr[offset] = data;
112   tilemap_mark_tile_dirty(reel1_tilemap,offset);
126   luckgrln_state *state = space->machine->driver_data<luckgrln_state>();
127   state->reel1_attr[offset] = data;
128   tilemap_mark_tile_dirty(state->reel1_tilemap,offset);
113129}
114130
115131
116132
117133static TILE_GET_INFO( get_luckgrln_reel1_tile_info )
118134{
119   int code = reel1_ram[tile_index];
120   int attr = reel1_attr[tile_index];
135   luckgrln_state *state = machine->driver_data<luckgrln_state>();
136   int code = state->reel1_ram[tile_index];
137   int attr = state->reel1_attr[tile_index];
121138   int col = (attr & 0x1f);
122139
123140   code |= (attr & 0xe0)<<3;
r10886r10887
133150
134151static WRITE8_HANDLER( luckgrln_reel2_ram_w )
135152{
136   reel2_ram[offset] = data;
137   tilemap_mark_tile_dirty(reel2_tilemap,offset);
153   luckgrln_state *state = space->machine->driver_data<luckgrln_state>();
154   state->reel2_ram[offset] = data;
155   tilemap_mark_tile_dirty(state->reel2_tilemap,offset);
138156}
139157
140158static WRITE8_HANDLER( luckgrln_reel2_attr_w )
141159{
142   reel2_attr[offset] = data;
143   tilemap_mark_tile_dirty(reel2_tilemap,offset);
160   luckgrln_state *state = space->machine->driver_data<luckgrln_state>();
161   state->reel2_attr[offset] = data;
162   tilemap_mark_tile_dirty(state->reel2_tilemap,offset);
144163}
145164
146165
147166static TILE_GET_INFO( get_luckgrln_reel2_tile_info )
148167{
149   int code = reel2_ram[tile_index];
150   int attr = reel2_attr[tile_index];
168   luckgrln_state *state = machine->driver_data<luckgrln_state>();
169   int code = state->reel2_ram[tile_index];
170   int attr = state->reel2_attr[tile_index];
151171   int col = (attr & 0x1f);
152172
153173   code |= (attr & 0xe0)<<3;
r10886r10887
162182
163183static WRITE8_HANDLER( luckgrln_reel3_ram_w )
164184{
165   reel3_ram[offset] = data;
166   tilemap_mark_tile_dirty(reel3_tilemap,offset);
185   luckgrln_state *state = space->machine->driver_data<luckgrln_state>();
186   state->reel3_ram[offset] = data;
187   tilemap_mark_tile_dirty(state->reel3_tilemap,offset);
167188}
168189
169190static WRITE8_HANDLER( luckgrln_reel3_attr_w )
170191{
171   reel3_attr[offset] = data;
172   tilemap_mark_tile_dirty(reel3_tilemap,offset);
192   luckgrln_state *state = space->machine->driver_data<luckgrln_state>();
193   state->reel3_attr[offset] = data;
194   tilemap_mark_tile_dirty(state->reel3_tilemap,offset);
173195}
174196
175197
176198static TILE_GET_INFO( get_luckgrln_reel3_tile_info )
177199{
178   int code = reel3_ram[tile_index];
179   int attr = reel3_attr[tile_index];
200   luckgrln_state *state = machine->driver_data<luckgrln_state>();
201   int code = state->reel3_ram[tile_index];
202   int attr = state->reel3_attr[tile_index];
180203   int col = (attr & 0x1f);
181204
182205   code |= (attr & 0xe0)<<3;
r10886r10887
190213
191214static WRITE8_HANDLER( luckgrln_reel4_ram_w )
192215{
193   reel4_ram[offset] = data;
194   tilemap_mark_tile_dirty(reel4_tilemap,offset);
216   luckgrln_state *state = space->machine->driver_data<luckgrln_state>();
217   state->reel4_ram[offset] = data;
218   tilemap_mark_tile_dirty(state->reel4_tilemap,offset);
195219}
196220
197221static WRITE8_HANDLER( luckgrln_reel4_attr_w )
198222{
199   reel4_attr[offset] = data;
200   tilemap_mark_tile_dirty(reel4_tilemap,offset);
223   luckgrln_state *state = space->machine->driver_data<luckgrln_state>();
224   state->reel4_attr[offset] = data;
225   tilemap_mark_tile_dirty(state->reel4_tilemap,offset);
201226}
202227
203228
204229static TILE_GET_INFO( get_luckgrln_reel4_tile_info )
205230{
206   int code = reel4_ram[tile_index];
207   int attr = reel4_attr[tile_index];
231   luckgrln_state *state = machine->driver_data<luckgrln_state>();
232   int code = state->reel4_ram[tile_index];
233   int attr = state->reel4_attr[tile_index];
208234   int col = (attr & 0x1f);
209235
210236   code |= (attr & 0xe0)<<3;
r10886r10887
218244
219245static VIDEO_START(luckgrln)
220246{
221   reel1_tilemap = tilemap_create(machine,get_luckgrln_reel1_tile_info,tilemap_scan_rows, 8, 32, 64, 8);
222   reel2_tilemap = tilemap_create(machine,get_luckgrln_reel2_tile_info,tilemap_scan_rows, 8, 32, 64, 8);
223   reel3_tilemap = tilemap_create(machine,get_luckgrln_reel3_tile_info,tilemap_scan_rows, 8, 32, 64, 8);
224   reel4_tilemap = tilemap_create(machine,get_luckgrln_reel4_tile_info,tilemap_scan_rows, 8, 32, 64, 8);
247   luckgrln_state *state = machine->driver_data<luckgrln_state>();
248   state->reel1_tilemap = tilemap_create(machine,get_luckgrln_reel1_tile_info,tilemap_scan_rows, 8, 32, 64, 8);
249   state->reel2_tilemap = tilemap_create(machine,get_luckgrln_reel2_tile_info,tilemap_scan_rows, 8, 32, 64, 8);
250   state->reel3_tilemap = tilemap_create(machine,get_luckgrln_reel3_tile_info,tilemap_scan_rows, 8, 32, 64, 8);
251   state->reel4_tilemap = tilemap_create(machine,get_luckgrln_reel4_tile_info,tilemap_scan_rows, 8, 32, 64, 8);
225252
226   tilemap_set_scroll_cols(reel1_tilemap, 64);
227   tilemap_set_scroll_cols(reel2_tilemap, 64);
228   tilemap_set_scroll_cols(reel3_tilemap, 64);
229   tilemap_set_scroll_cols(reel4_tilemap, 64);
253   tilemap_set_scroll_cols(state->reel1_tilemap, 64);
254   tilemap_set_scroll_cols(state->reel2_tilemap, 64);
255   tilemap_set_scroll_cols(state->reel3_tilemap, 64);
256   tilemap_set_scroll_cols(state->reel4_tilemap, 64);
230257
231   tilemap_set_transparent_pen( reel1_tilemap, 0 );
232   tilemap_set_transparent_pen( reel2_tilemap, 0 );
233   tilemap_set_transparent_pen( reel3_tilemap, 0 );
234   tilemap_set_transparent_pen( reel4_tilemap, 0 );
258   tilemap_set_transparent_pen( state->reel1_tilemap, 0 );
259   tilemap_set_transparent_pen( state->reel2_tilemap, 0 );
260   tilemap_set_transparent_pen( state->reel3_tilemap, 0 );
261   tilemap_set_transparent_pen( state->reel4_tilemap, 0 );
235262}
236263
237264static SCREEN_UPDATE(luckgrln)
238265{
266   luckgrln_state *state = screen->machine->driver_data<luckgrln_state>();
239267   int y,x;
240268   int count = 0;
241269   const rectangle &visarea = screen->visible_area();
r10886r10887
252280
253281   for (i= 0;i < 64;i++)
254282   {
255      tilemap_set_scrolly(reel1_tilemap, i, reel1_scroll[i]);
256      tilemap_set_scrolly(reel2_tilemap, i, reel2_scroll[i]);
257      tilemap_set_scrolly(reel3_tilemap, i, reel3_scroll[i]);
258      tilemap_set_scrolly(reel4_tilemap, i, reel4_scroll[i]);
283      tilemap_set_scrolly(state->reel1_tilemap, i, state->reel1_scroll[i]);
284      tilemap_set_scrolly(state->reel2_tilemap, i, state->reel2_scroll[i]);
285      tilemap_set_scrolly(state->reel3_tilemap, i, state->reel3_scroll[i]);
286      tilemap_set_scrolly(state->reel4_tilemap, i, state->reel4_scroll[i]);
259287   }
260288
261289
r10886r10887
269297
270298      for (x=0;x<64;x++)
271299      {
272         UINT16 tile = (luck_vram1[count] & 0xff);
273         UINT16 tile_high = (luck_vram2[count]);
274         UINT16 tileattr = (luck_vram3[count]);
300         UINT16 tile = (state->luck_vram1[count] & 0xff);
301         UINT16 tile_high = (state->luck_vram2[count]);
302         UINT16 tileattr = (state->luck_vram3[count]);
275303         UINT8 col = 0;
276304         UINT8 region = 0;
277305         UINT8 bgenable;
r10886r10887
283311         if (clip.max_x>visarea.max_x) clip.max_x = visarea.max_x;
284312
285313         /*
286              luck_vram1  tttt tttt   (t = low tile bits)
287              luck_vram2  tttt ppp?   (t = high tile bits) (p = pal select)?
314              state->luck_vram1  tttt tttt   (t = low tile bits)
315              state->luck_vram2  tttt ppp?   (t = high tile bits) (p = pal select)?
288316
289317
290318             */
r10886r10887
295323         // ?? low bit is used too
296324         col = tile_high&0xf;
297325
298         // --ss fbt-   luck_vram3
326         // --ss fbt-   state->luck_vram3
299327         // - = unused?
300328         // s = reel layer select for this 8x8 region
301329         // f = fg enabled for this 8x8 region (or priority?)
r10886r10887
307335#if 0 // treat bit as fg enable
308336         if (tileattr&0x04)
309337         {
310            if (bgenable==0) tilemap_draw(bitmap, &clip, reel1_tilemap, 0, 0);
311            if (bgenable==1) tilemap_draw(bitmap, &clip, reel2_tilemap, 0, 0);
312            if (bgenable==2) tilemap_draw(bitmap, &clip, reel3_tilemap, 0, 0);
313            if (bgenable==3) tilemap_draw(bitmap, &clip, reel4_tilemap, 0, 0);
338            if (bgenable==0) tilemap_draw(bitmap, &clip, state->reel1_tilemap, 0, 0);
339            if (bgenable==1) tilemap_draw(bitmap, &clip, state->reel2_tilemap, 0, 0);
340            if (bgenable==2) tilemap_draw(bitmap, &clip, state->reel3_tilemap, 0, 0);
341            if (bgenable==3) tilemap_draw(bitmap, &clip, state->reel4_tilemap, 0, 0);
314342         }
315343
316344         if (tileattr&0x08) drawgfx_transpen(bitmap,&clip,screen->machine->gfx[region],tile,col,0,0,x*8,y*8, 0);
r10886r10887
320348
321349         if (tileattr&0x04)
322350         {
323            if (bgenable==0) tilemap_draw(bitmap, &clip, reel1_tilemap, 0, 0);
324            if (bgenable==1) tilemap_draw(bitmap, &clip, reel2_tilemap, 0, 0);
325            if (bgenable==2) tilemap_draw(bitmap, &clip, reel3_tilemap, 0, 0);
326            if (bgenable==3) tilemap_draw(bitmap, &clip, reel4_tilemap, 0, 0);
351            if (bgenable==0) tilemap_draw(bitmap, &clip, state->reel1_tilemap, 0, 0);
352            if (bgenable==1) tilemap_draw(bitmap, &clip, state->reel2_tilemap, 0, 0);
353            if (bgenable==2) tilemap_draw(bitmap, &clip, state->reel3_tilemap, 0, 0);
354            if (bgenable==3) tilemap_draw(bitmap, &clip, state->reel4_tilemap, 0, 0);
327355         }
328356
329357         if ((tileattr&0x08)) drawgfx_transpen(bitmap,&clip,screen->machine->gfx[region],tile,col,0,0,x*8,y*8, 0);
r10886r10887
340368   AM_RANGE(0x10000, 0x1ffff) AM_ROM AM_REGION("rom_data",0x10000)
341369   AM_RANGE(0x20000, 0x2ffff) AM_ROM AM_REGION("rom_data",0x00000)
342370
343   AM_RANGE(0x0c000, 0x0c1ff) AM_RAM_WRITE(luckgrln_reel1_ram_w)  AM_BASE(&reel1_ram) // only written to half way
344   AM_RANGE(0x0c800, 0x0c9ff) AM_RAM_WRITE(luckgrln_reel1_attr_w) AM_BASE(&reel1_attr)
345   AM_RANGE(0x0d000, 0x0d03f) AM_RAM AM_BASE(&reel1_scroll) AM_MIRROR(0x000c0)
371   AM_RANGE(0x0c000, 0x0c1ff) AM_RAM_WRITE(luckgrln_reel1_ram_w)  AM_BASE_MEMBER(luckgrln_state, reel1_ram) // only written to half way
372   AM_RANGE(0x0c800, 0x0c9ff) AM_RAM_WRITE(luckgrln_reel1_attr_w) AM_BASE_MEMBER(luckgrln_state, reel1_attr)
373   AM_RANGE(0x0d000, 0x0d03f) AM_RAM AM_BASE_MEMBER(luckgrln_state, reel1_scroll) AM_MIRROR(0x000c0)
346374
347   AM_RANGE(0x0c200, 0x0c3ff) AM_RAM_WRITE(luckgrln_reel2_ram_w)  AM_BASE(&reel2_ram)
348   AM_RANGE(0x0ca00, 0x0cbff) AM_RAM_WRITE(luckgrln_reel2_attr_w) AM_BASE(&reel2_attr)
349   AM_RANGE(0x0d200, 0x0d23f) AM_RAM AM_BASE(&reel2_scroll) AM_MIRROR(0x000c0)
375   AM_RANGE(0x0c200, 0x0c3ff) AM_RAM_WRITE(luckgrln_reel2_ram_w)  AM_BASE_MEMBER(luckgrln_state, reel2_ram)
376   AM_RANGE(0x0ca00, 0x0cbff) AM_RAM_WRITE(luckgrln_reel2_attr_w) AM_BASE_MEMBER(luckgrln_state, reel2_attr)
377   AM_RANGE(0x0d200, 0x0d23f) AM_RAM AM_BASE_MEMBER(luckgrln_state, reel2_scroll) AM_MIRROR(0x000c0)
350378
351   AM_RANGE(0x0c400, 0x0c5ff) AM_RAM_WRITE(luckgrln_reel3_ram_w ) AM_BASE(&reel3_ram)
352   AM_RANGE(0x0cc00, 0x0cdff) AM_RAM_WRITE(luckgrln_reel3_attr_w) AM_BASE(&reel3_attr)
353   AM_RANGE(0x0d400, 0x0d43f) AM_RAM AM_BASE(&reel3_scroll) AM_MIRROR(0x000c0)
379   AM_RANGE(0x0c400, 0x0c5ff) AM_RAM_WRITE(luckgrln_reel3_ram_w ) AM_BASE_MEMBER(luckgrln_state, reel3_ram)
380   AM_RANGE(0x0cc00, 0x0cdff) AM_RAM_WRITE(luckgrln_reel3_attr_w) AM_BASE_MEMBER(luckgrln_state, reel3_attr)
381   AM_RANGE(0x0d400, 0x0d43f) AM_RAM AM_BASE_MEMBER(luckgrln_state, reel3_scroll) AM_MIRROR(0x000c0)
354382
355   AM_RANGE(0x0c600, 0x0c7ff) AM_RAM_WRITE(luckgrln_reel4_ram_w ) AM_BASE(&reel4_ram)
356   AM_RANGE(0x0ce00, 0x0cfff) AM_RAM_WRITE(luckgrln_reel4_attr_w) AM_BASE(&reel4_attr)
357   AM_RANGE(0x0d600, 0x0d63f) AM_RAM AM_BASE(&reel4_scroll)
383   AM_RANGE(0x0c600, 0x0c7ff) AM_RAM_WRITE(luckgrln_reel4_ram_w ) AM_BASE_MEMBER(luckgrln_state, reel4_ram)
384   AM_RANGE(0x0ce00, 0x0cfff) AM_RAM_WRITE(luckgrln_reel4_attr_w) AM_BASE_MEMBER(luckgrln_state, reel4_attr)
385   AM_RANGE(0x0d600, 0x0d63f) AM_RAM AM_BASE_MEMBER(luckgrln_state, reel4_scroll)
358386
359387//  AM_RANGE(0x0d200, 0x0d2ff) AM_RAM
360388
361389
362390   AM_RANGE(0x0d800, 0x0dfff) AM_RAM // nvram
363391
364   AM_RANGE(0x0e000, 0x0e7ff) AM_RAM AM_BASE(&luck_vram1)
365   AM_RANGE(0x0e800, 0x0efff) AM_RAM AM_BASE(&luck_vram2)
366   AM_RANGE(0x0f000, 0x0f7ff) AM_RAM AM_BASE(&luck_vram3)
392   AM_RANGE(0x0e000, 0x0e7ff) AM_RAM AM_BASE_MEMBER(luckgrln_state, luck_vram1)
393   AM_RANGE(0x0e800, 0x0efff) AM_RAM AM_BASE_MEMBER(luckgrln_state, luck_vram2)
394   AM_RANGE(0x0f000, 0x0f7ff) AM_RAM AM_BASE_MEMBER(luckgrln_state, luck_vram3)
367395
368396
369397   AM_RANGE(0x0f800, 0x0ffff) AM_RAM
r10886r10887
373401
374402static WRITE8_HANDLER( output_w )
375403{
404   luckgrln_state *state = space->machine->driver_data<luckgrln_state>();
376405   /* correct? */
377406   if (data==0x84)
378      nmi_enable = 0;
407      state->nmi_enable = 0;
379408   else if (data==0x85)
380      nmi_enable = 1;
409      state->nmi_enable = 1;
381410   else
382411      printf("output_w unk data %02x\n",data);
383412}
384413
385414
386static int palette_count = 0;
387static UINT8 palette_ram[0x10000];
388415
389416static WRITE8_HANDLER( palette_offset_low_w )
390417{
391   palette_count = data<<1;
418   luckgrln_state *state = space->machine->driver_data<luckgrln_state>();
419   state->palette_count = data<<1;
392420}
393421static WRITE8_HANDLER( palette_offset_high_w )
394422{
395   palette_count = palette_count | data<<9;
423   luckgrln_state *state = space->machine->driver_data<luckgrln_state>();
424   state->palette_count = state->palette_count | data<<9;
396425}
397426
398427
399428static WRITE8_HANDLER( palette_w )
400429{
401   palette_ram[palette_count] = data;
430   luckgrln_state *state = space->machine->driver_data<luckgrln_state>();
431   state->palette_ram[state->palette_count] = data;
402432
403433
404434   {
405435      int r,g,b;
406436      int offs;
407437      UINT16 dat;
408      offs = palette_count&~0x1;
409      dat = palette_ram[offs] | palette_ram[offs+1]<<8;
438      offs = state->palette_count&~0x1;
439      dat = state->palette_ram[offs] | state->palette_ram[offs+1]<<8;
410440
411441      r = (dat >> 0) & 0x1f;
412442      g = (dat >> 5) & 0x1f;
r10886r10887
416446
417447   }
418448
419   palette_count++;
449   state->palette_count++;
420450
421451}
422452
r10886r10887
811841
812842static INTERRUPT_GEN( luckgrln_irq )
813843{
814   if(nmi_enable)
844   luckgrln_state *state = device->machine->driver_data<luckgrln_state>();
845   if(state->nmi_enable)
815846      cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE);
816847}
817848
818static MACHINE_CONFIG_START( luckgrln, driver_device )
849static MACHINE_CONFIG_START( luckgrln, luckgrln_state )
819850   MCFG_CPU_ADD("maincpu", Z180,8000000)
820851   MCFG_CPU_PROGRAM_MAP(mainmap)
821852   MCFG_CPU_IO_MAP(portmap)
src/mame/drivers/calchase.c
r10886r10887
9797#include "machine/pckeybrd.h"
9898#include "machine/idectrl.h"
9999
100static void ide_interrupt(device_t *device, int state);
101100
102static UINT32 *bios_ram;
103static UINT32 *vga_vram;
101class calchase_state : public driver_device
102{
103public:
104   calchase_state(running_machine &machine, const driver_device_config_base &config)
105      : driver_device(machine, config) { }
104106
105static struct {
107   UINT32 *bios_ram;
108   UINT32 *vga_vram;
109   int dma_channel;
110   UINT8 dma_offset[2][4];
111   UINT8 at_pages[0x10];
112   UINT8 mxtc_config_reg[256];
113   UINT8 piix4_config_reg[4][256];
114
106115   device_t   *pit8254;
107116   device_t   *pic8259_1;
108117   device_t   *pic8259_2;
109118   device_t   *dma8237_1;
110119   device_t   *dma8237_2;
111} calchase_devices;
120};
112121
113122
123static void ide_interrupt(device_t *device, int state);
124
125
114126static VIDEO_START(calchase)
115127{
116
117128}
118129
119130static SCREEN_UPDATE(calchase)
120131{
132   calchase_state *state = screen->machine->driver_data<calchase_state>();
121133   int x,y,count,i;
122134
123135   bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
r10886r10887
132144         {
133145            UINT32 color;
134146
135            color = (vga_vram[count])>>(32-i) & 0x1;
147            color = (state->vga_vram[count])>>(32-i) & 0x1;
136148
137149            if((x+i)<screen->visible_area().max_x && ((y)+0)<screen->visible_area().max_y)
138150               *BITMAP_ADDR32(bitmap, y, x+(32-i)) = screen->machine->pens[color];
r10886r10887
166178   write32le_with_write8_device_handler(at_dma8237_2_w, device, offset, data, mem_mask);
167179}
168180
169static int dma_channel;
170static UINT8 dma_offset[2][4];
171static UINT8 at_pages[0x10];
172181
173182
174183static READ8_HANDLER(at_page8_r)
175184{
176   UINT8 data = at_pages[offset % 0x10];
185   calchase_state *state = space->machine->driver_data<calchase_state>();
186   UINT8 data = state->at_pages[offset % 0x10];
177187
178188   switch(offset % 8) {
179189   case 1:
180      data = dma_offset[(offset / 8) & 1][2];
190      data = state->dma_offset[(offset / 8) & 1][2];
181191      break;
182192   case 2:
183      data = dma_offset[(offset / 8) & 1][3];
193      data = state->dma_offset[(offset / 8) & 1][3];
184194      break;
185195   case 3:
186      data = dma_offset[(offset / 8) & 1][1];
196      data = state->dma_offset[(offset / 8) & 1][1];
187197      break;
188198   case 7:
189      data = dma_offset[(offset / 8) & 1][0];
199      data = state->dma_offset[(offset / 8) & 1][0];
190200      break;
191201   }
192202   return data;
r10886r10887
195205
196206static WRITE8_HANDLER(at_page8_w)
197207{
198   at_pages[offset % 0x10] = data;
208   calchase_state *state = space->machine->driver_data<calchase_state>();
209   state->at_pages[offset % 0x10] = data;
199210
200211   switch(offset % 8) {
201212   case 1:
202      dma_offset[(offset / 8) & 1][2] = data;
213      state->dma_offset[(offset / 8) & 1][2] = data;
203214      break;
204215   case 2:
205      dma_offset[(offset / 8) & 1][3] = data;
216      state->dma_offset[(offset / 8) & 1][3] = data;
206217      break;
207218   case 3:
208      dma_offset[(offset / 8) & 1][1] = data;
219      state->dma_offset[(offset / 8) & 1][1] = data;
209220      break;
210221   case 7:
211      dma_offset[(offset / 8) & 1][0] = data;
222      state->dma_offset[(offset / 8) & 1][0] = data;
212223      break;
213224   }
214225}
r10886r10887
225236
226237static READ8_HANDLER( pc_dma_read_byte )
227238{
228   offs_t page_offset = (((offs_t) dma_offset[0][dma_channel]) << 16)
239   calchase_state *state = space->machine->driver_data<calchase_state>();
240   offs_t page_offset = (((offs_t) state->dma_offset[0][state->dma_channel]) << 16)
229241      & 0xFF0000;
230242
231243   return space->read_byte(page_offset + offset);
r10886r10887
234246
235247static WRITE8_HANDLER( pc_dma_write_byte )
236248{
237   offs_t page_offset = (((offs_t) dma_offset[0][dma_channel]) << 16)
249   calchase_state *state = space->machine->driver_data<calchase_state>();
250   offs_t page_offset = (((offs_t) state->dma_offset[0][state->dma_channel]) << 16)
238251      & 0xFF0000;
239252
240253   space->write_byte(page_offset + offset, data);
r10886r10887
242255
243256static void set_dma_channel(device_t *device, int channel, int state)
244257{
245   if (!state) dma_channel = channel;
258   calchase_state *drvstate = device->machine->driver_data<calchase_state>();
259   if (!state) drvstate->dma_channel = channel;
246260}
247261
248262static WRITE_LINE_DEVICE_HANDLER( pc_dack0_w ) { set_dma_channel(device, 0, state); }
r10886r10887
305319}
306320
307321// Intel 82439TX System Controller (MXTC)
308static UINT8 mxtc_config_reg[256];
309322
310323static UINT8 mxtc_config_r(device_t *busdevice, device_t *device, int function, int reg)
311324{
325   calchase_state *state = busdevice->machine->driver_data<calchase_state>();
312326//  mame_printf_debug("MXTC: read %d, %02X\n", function, reg);
313327
314   return mxtc_config_reg[reg];
328   return state->mxtc_config_reg[reg];
315329}
316330
317331static void mxtc_config_w(device_t *busdevice, device_t *device, int function, int reg, UINT8 data)
318332{
333   calchase_state *state = busdevice->machine->driver_data<calchase_state>();
319334//  mame_printf_debug("%s:MXTC: write %d, %02X, %02X\n", machine->describe_context(), function, reg, data);
320335
321336   switch(reg)
r10886r10887
324339      {
325340         if (data & 0x10)      // enable RAM access to region 0xf0000 - 0xfffff
326341         {
327            memory_set_bankptr(busdevice->machine, "bank1", bios_ram);
342            memory_set_bankptr(busdevice->machine, "bank1", state->bios_ram);
328343         }
329344         else               // disable RAM access (reads go to BIOS ROM)
330345         {
r10886r10887
334349      }
335350   }
336351
337   mxtc_config_reg[reg] = data;
352   state->mxtc_config_reg[reg] = data;
338353}
339354
340static void intel82439tx_init(void)
355static void intel82439tx_init(running_machine *machine)
341356{
342   mxtc_config_reg[0x60] = 0x02;
343   mxtc_config_reg[0x61] = 0x02;
344   mxtc_config_reg[0x62] = 0x02;
345   mxtc_config_reg[0x63] = 0x02;
346   mxtc_config_reg[0x64] = 0x02;
347   mxtc_config_reg[0x65] = 0x02;
357   calchase_state *state = machine->driver_data<calchase_state>();
358   state->mxtc_config_reg[0x60] = 0x02;
359   state->mxtc_config_reg[0x61] = 0x02;
360   state->mxtc_config_reg[0x62] = 0x02;
361   state->mxtc_config_reg[0x63] = 0x02;
362   state->mxtc_config_reg[0x64] = 0x02;
363   state->mxtc_config_reg[0x65] = 0x02;
348364}
349365
350366static UINT32 intel82439tx_pci_r(device_t *busdevice, device_t *device, int function, int reg, UINT32 mem_mask)
r10886r10887
390406}
391407
392408// Intel 82371AB PCI-to-ISA / IDE bridge (PIIX4)
393static UINT8 piix4_config_reg[4][256];
394409
395410static UINT8 piix4_config_r(device_t *busdevice, device_t *device, int function, int reg)
396411{
412   calchase_state *state = busdevice->machine->driver_data<calchase_state>();
397413//  mame_printf_debug("PIIX4: read %d, %02X\n", function, reg);
398   return piix4_config_reg[function][reg];
414   return state->piix4_config_reg[function][reg];
399415}
400416
401417static void piix4_config_w(device_t *busdevice, device_t *device, int function, int reg, UINT8 data)
402418{
419   calchase_state *state = busdevice->machine->driver_data<calchase_state>();
403420//  mame_printf_debug("%s:PIIX4: write %d, %02X, %02X\n", machine->describe_context(), function, reg, data);
404   piix4_config_reg[function][reg] = data;
421   state->piix4_config_reg[function][reg] = data;
405422}
406423
407424static UINT32 intel82371ab_pci_r(device_t *busdevice, device_t *device, int function, int reg, UINT32 mem_mask)
r10886r10887
448465
449466static WRITE32_HANDLER(bios_ram_w)
450467{
451   if (mxtc_config_reg[0x59] & 0x20)      // write to RAM if this region is write-enabled
468   calchase_state *state = space->machine->driver_data<calchase_state>();
469   if (state->mxtc_config_reg[0x59] & 0x20)      // write to RAM if this region is write-enabled
452470   {
453      COMBINE_DATA(bios_ram + offset);
471      COMBINE_DATA(state->bios_ram + offset);
454472   }
455473}
456474
457475static ADDRESS_MAP_START( calchase_map, ADDRESS_SPACE_PROGRAM, 32 )
458476   AM_RANGE(0x00000000, 0x0009ffff) AM_RAM
459   AM_RANGE(0x000a0000, 0x000bffff) AM_RAM AM_BASE(&vga_vram)
477   AM_RANGE(0x000a0000, 0x000bffff) AM_RAM AM_BASE_MEMBER(calchase_state, vga_vram)
460478   AM_RANGE(0x000c0000, 0x000c7fff) AM_RAM AM_REGION("video_bios", 0)
461479   AM_RANGE(0x000e0000, 0x000effff) AM_RAM
462480   AM_RANGE(0x000f0000, 0x000fffff) AM_ROMBANK("bank1")
r10886r10887
547565
548566static IRQ_CALLBACK(irq_callback)
549567{
568   calchase_state *state = device->machine->driver_data<calchase_state>();
550569   int r = 0;
551   r = pic8259_acknowledge( calchase_devices.pic8259_2);
570   r = pic8259_acknowledge( state->pic8259_2);
552571   if (r==0)
553572   {
554      r = pic8259_acknowledge( calchase_devices.pic8259_1);
573      r = pic8259_acknowledge( state->pic8259_1);
555574   }
556575   return r;
557576}
558577
559578static MACHINE_START(calchase)
560579{
580   calchase_state *state = machine->driver_data<calchase_state>();
561581   cpu_set_irq_callback(machine->device("maincpu"), irq_callback);
562582
563   calchase_devices.pit8254 = machine->device( "pit8254" );
564   calchase_devices.pic8259_1 = machine->device( "pic8259_1" );
565   calchase_devices.pic8259_2 = machine->device( "pic8259_2" );
566   calchase_devices.dma8237_1 = machine->device( "dma8237_1" );
567   calchase_devices.dma8237_2 = machine->device( "dma8237_2" );
583   state->pit8254 = machine->device( "pit8254" );
584   state->pic8259_1 = machine->device( "pic8259_1" );
585   state->pic8259_2 = machine->device( "pic8259_2" );
586   state->dma8237_1 = machine->device( "dma8237_1" );
587   state->dma8237_2 = machine->device( "dma8237_2" );
568588}
569589
570590/*************************************************************
r10886r10887
626646
627647static void keyboard_interrupt(running_machine *machine, int state)
628648{
629   pic8259_ir1_w(calchase_devices.pic8259_1, state);
649   calchase_state *drvstate = machine->driver_data<calchase_state>();
650   pic8259_ir1_w(drvstate->pic8259_1, state);
630651}
631652
632653static void ide_interrupt(device_t *device, int state)
633654{
634   pic8259_ir6_w(calchase_devices.pic8259_2, state);
655   calchase_state *drvstate = device->machine->driver_data<calchase_state>();
656   pic8259_ir6_w(drvstate->pic8259_2, state);
635657}
636658
637static int calchase_get_out2(running_machine *machine) {
638   return pit8253_get_output(calchase_devices.pit8254, 2 );
659static int calchase_get_out2(running_machine *machine)
660{
661   calchase_state *state = machine->driver_data<calchase_state>();
662   return pit8253_get_output(state->pit8254, 2 );
639663}
640664
641665static const struct kbdc8042_interface at8042 =
r10886r10887
643667   KBDC8042_AT386, set_gate_a20, keyboard_interrupt, calchase_get_out2
644668};
645669
646static void calchase_set_keyb_int(running_machine *machine, int state) {
647   pic8259_ir1_w(calchase_devices.pic8259_1, state);
670static void calchase_set_keyb_int(running_machine *machine, int state)
671{
672   calchase_state *drvstate = machine->driver_data<calchase_state>();
673   pic8259_ir1_w(drvstate->pic8259_1, state);
648674}
649675
650676
651static MACHINE_CONFIG_START( calchase, driver_device )
677static MACHINE_CONFIG_START( calchase, calchase_state )
652678   MCFG_CPU_ADD("maincpu", PENTIUM, 200000000) // Cyrix 686MX-PR200 CPU
653679   MCFG_CPU_PROGRAM_MAP(calchase_map)
654680   MCFG_CPU_IO_MAP(calchase_io)
r10886r10887
683709
684710static DRIVER_INIT( calchase )
685711{
686   bios_ram = auto_alloc_array(machine, UINT32, 0x10000/4);
712   calchase_state *state = machine->driver_data<calchase_state>();
713   state->bios_ram = auto_alloc_array(machine, UINT32, 0x10000/4);
687714
688715   init_pc_common(machine, PCCOMMON_KEYBOARD_AT, calchase_set_keyb_int);
689716
690   intel82439tx_init();
717   intel82439tx_init(machine);
691718
692719   kbdc8042_init(machine, &at8042);
693720}
src/mame/drivers/play_1.c
r10886r10887
4444/-------------------------------------------------------------------*/
4545ROM_START(spcgambl)
4646   ROM_REGION(0x10000, "maincpu", 0)
47   ROM_LOAD("spcgamba.bin", 0x0000, 0x0400, CRC(da312699) SHA1(b1fabfe23d4e5d512623f9b0f3fa8dd38bdbba43))
48   ROM_LOAD("spcgambb.bin", 0x0400, 0x0400, NO_DUMP)
47   ROM_LOAD("spcgamba.bin", 0x0000, 0x0400, CRC(3b6e5287) SHA1(4d2fae779bb4117a99a9311b96ab79799f40067b))
48   ROM_LOAD("spcgambb.bin", 0x0400, 0x0400, CRC(5c61f25c) SHA1(44b2d74926bf5678146b6d2347b4147e8a29a660))
4949ROM_END
5050 
5151/*-------------------------------------------------------------------
src/mame/drivers/videopkr.c
r10886r10887
293293#include "babypkr.lh"
294294#include "babydad.lh"
295295
296#define DATA_NVRAM_SIZE     0x100
297296
298static UINT8 data_ram[0x100];
299static UINT8 video_ram[0x0400];
300static UINT8 color_ram[0x0400];
301static UINT16 p1, p2;
302static UINT8 t0_latch;
303static UINT16 n_offs;
297class videopkr_state : public driver_device
298{
299public:
300   videopkr_state(running_machine &machine, const driver_device_config_base &config)
301      : driver_device(machine, config) { }
304302
305static UINT8 vp_sound_p2;
306static UINT8 p24_data;
307static UINT8 sound_latch;
308static UINT8 baby_latch;
309static UINT8 sound_ant;
310static UINT8 dc_4020;
311static UINT8 dc_40103;
312static UINT8 te_40103;
313static UINT8 ld_40103;
303   UINT8 data_ram[0x100];
304   UINT8 video_ram[0x0400];
305   UINT8 color_ram[0x0400];
306   UINT16 p1;
307   UINT16 p2;
308   UINT8 t0_latch;
309   UINT16 n_offs;
310   UINT8 vp_sound_p2;
311   UINT8 p24_data;
312   UINT8 sound_latch;
313   UINT8 baby_latch;
314   UINT8 sound_ant;
315   UINT8 dc_4020;
316   UINT8 dc_40103;
317   UINT8 te_40103;
318   UINT8 ld_40103;
319   UINT8 ant_jckp;
320   UINT8 jckp;
321   UINT8 ant_cio;
322   UINT8 c_io;
323   UINT8 hp_1;
324   UINT8 hp_2;
325   UINT8 bell;
326   UINT8 aux3;
327   UINT8 dvrt;
328   unsigned long count0;
329   unsigned long count1;
330   unsigned long count2;
331   unsigned long count3;
332   unsigned long count4;
333   UINT8 sbp0;
334   UINT8 sbp2;
335   UINT8 sbp3;
336   tilemap_t *bg_tilemap;
337};
314338
315static UINT8 ant_jckp, jckp, ant_cio, c_io, hp_1, hp_2, bell, aux3, dvrt;
316static unsigned long count0, count1, count2, count3, count4;
317339
318/* Baby vars */
319static UINT8 sbp0, sbp2, sbp3;
340#define DATA_NVRAM_SIZE     0x100
320341
321
322342/*************************
323343*     Video Hardware     *
324344*************************/
325345
326static tilemap_t *bg_tilemap;
327346
328347/* BCD to Seven Segment Decoder */
329348static UINT8 dec_7seg(int data)
r10886r10887
450469
451470static TILE_GET_INFO( get_bg_tile_info )
452471{
472   videopkr_state *state = machine->driver_data<videopkr_state>();
453473   int offs = tile_index;
454   int attr = color_ram[offs] + input_port_read(machine, "IN2"); /* Color Switch Action */
455   int code = video_ram[offs];
474   int attr = state->color_ram[offs] + input_port_read(machine, "IN2"); /* Color Switch Action */
475   int code = state->video_ram[offs];
456476   int color = attr;
457477   SET_TILE_INFO(0, code, color, 0);
458478}
r10886r10887
460480
461481static VIDEO_START( videopkr )
462482{
463   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
483   videopkr_state *state = machine->driver_data<videopkr_state>();
484   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
464485}
465486
466487static VIDEO_START( vidadcba )
467488{
468   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 16, 8, 32, 32);
489   videopkr_state *state = machine->driver_data<videopkr_state>();
490   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 16, 8, 32, 32);
469491}
470492
471493
472494static SCREEN_UPDATE( videopkr )
473495{
474   tilemap_mark_all_tiles_dirty(bg_tilemap);
475   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
496   videopkr_state *state = screen->machine->driver_data<videopkr_state>();
497   tilemap_mark_all_tiles_dirty(state->bg_tilemap);
498   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
476499   return 0;
477500}
478501
r10886r10887
483506
484507static READ8_HANDLER( videopkr_io_r )
485508{
509   videopkr_state *state = space->machine->driver_data<videopkr_state>();
486510   UINT8 valor = 0, hf, co;
487511
488512   UINT16 kbdin;
489513
490   switch (p2)
514   switch (state->p2)
491515   {
492516      case 0xef:   /* inputs are multiplexed through a diode matrix */
493517      {
r10886r10887
525549
526550      case 0xdf:
527551      {
528         n_offs = ((p1 & 0xc0) << 2 ) + offset;
529         valor = data_ram[offset];
552         state->n_offs = ((state->p1 & 0xc0) << 2 ) + offset;
553         valor = state->data_ram[offset];
530554         break;
531555      }
532556
533557      case 0x5f:
534558      {
535         n_offs = ((p1 & 0xc0) << 2 ) + offset;
536         valor = data_ram[offset];
559         state->n_offs = ((state->p1 & 0xc0) << 2 ) + offset;
560         valor = state->data_ram[offset];
537561         break;
538562      }
539563
r10886r10887
542566      case 0x7e:
543567      case 0x7f:
544568      {
545         n_offs = ((p1 & 0xc0) << 2 ) + offset;
546         valor = color_ram[n_offs];
569         state->n_offs = ((state->p1 & 0xc0) << 2 ) + offset;
570         valor = state->color_ram[state->n_offs];
547571         break;
548572      }
549573
r10886r10887
552576      case 0xbe:
553577      case 0xbf:
554578      {
555         n_offs = ((p1 & 0xc0) << 2 ) + offset;
556         valor = video_ram[n_offs];
579         state->n_offs = ((state->p1 & 0xc0) << 2 ) + offset;
580         valor = state->video_ram[state->n_offs];
557581         break;
558582      }
559583   }
r10886r10887
563587
564588static WRITE8_HANDLER( videopkr_io_w )
565589{
566   switch (p2)
590   videopkr_state *state = space->machine->driver_data<videopkr_state>();
591   switch (state->p2)
567592   {
568593      case 0x3c:
569594      case 0x3d:
570595      case 0x3e:
571596      case 0x3f:
572597      {
573         n_offs = ((p1 & 0xc0) << 2 ) + offset;
574         color_ram[n_offs] = data & 0x0f;
575         video_ram[n_offs] = data;
576         tilemap_mark_tile_dirty(bg_tilemap, n_offs);
598         state->n_offs = ((state->p1 & 0xc0) << 2 ) + offset;
599         state->color_ram[state->n_offs] = data & 0x0f;
600         state->video_ram[state->n_offs] = data;
601         tilemap_mark_tile_dirty(state->bg_tilemap, state->n_offs);
577602         break;
578603      }
579604
580605      case 0xdf:
581606      {
582         data_ram[offset] = (data & 0x0f) + 0xf0;
607         state->data_ram[offset] = (data & 0x0f) + 0xf0;
583608         break;
584609      }
585610
r10886r10887
588613      case 0x7e:
589614      case 0x7f:
590615      {
591         n_offs = ((p1 & 0xc0) << 2 ) + offset;
592         color_ram[n_offs] = data & 0x0f;
593         tilemap_mark_tile_dirty(bg_tilemap, n_offs);
616         state->n_offs = ((state->p1 & 0xc0) << 2 ) + offset;
617         state->color_ram[state->n_offs] = data & 0x0f;
618         tilemap_mark_tile_dirty(state->bg_tilemap, state->n_offs);
594619         break;
595620      }
596621
r10886r10887
599624      case 0xbe:
600625      case 0xbf:
601626      {
602         n_offs = ((p1 & 0xc0) << 2 ) + offset;
603         video_ram[n_offs] = data;
604         tilemap_mark_tile_dirty(bg_tilemap, n_offs);
627         state->n_offs = ((state->p1 & 0xc0) << 2 ) + offset;
628         state->video_ram[state->n_offs] = data;
629         tilemap_mark_tile_dirty(state->bg_tilemap, state->n_offs);
605630         break;
606631      }
607632
r10886r10887
615640         output_set_lamp_value(5, ((data >> 5) & 1));   /* Hopper_1 */
616641         output_set_lamp_value(6, ((data >> 6) & 1));   /* Hopper_2 */
617642         output_set_lamp_value(7, ((data >> 7) & 1));   /* Diverter */
618         p24_data = data;
619         hp_1 = (~p24_data >> 6) & 1;
620         hp_2 = (~p24_data >> 5) & 1;
621         dvrt = (~p24_data >> 7) & 1;
643         state->p24_data = data;
644         state->hp_1 = (~state->p24_data >> 6) & 1;
645         state->hp_2 = (~state->p24_data >> 5) & 1;
646         state->dvrt = (~state->p24_data >> 7) & 1;
622647         break;
623648      }
624649
625650      case 0xff:
626651      {
627         t0_latch = t0_latch ^ 0x01;      /* fix the bookkeeping mode */
652         state->t0_latch = state->t0_latch ^ 0x01;      /* fix the bookkeeping mode */
628653         break;
629654      }
630655   }
r10886r10887
632657
633658static READ8_HANDLER( videopkr_p1_data_r )
634659{
635   return p1;
660   videopkr_state *state = space->machine->driver_data<videopkr_state>();
661   return state->p1;
636662}
637663
638664static READ8_HANDLER( videopkr_p2_data_r )
639665{
640   return p2;
666   videopkr_state *state = space->machine->driver_data<videopkr_state>();
667   return state->p2;
641668}
642669
643670static WRITE8_HANDLER( videopkr_p1_data_w )
644671{
645   p1 = data;
672   videopkr_state *state = space->machine->driver_data<videopkr_state>();
673   state->p1 = data;
646674
647675   output_set_lamp_value(8, (data & 1));         /* Aux_0 - Jackpot mech. counter (Baby Games)*/
648676   output_set_lamp_value(9, ((data >> 1) & 1));   /* Aux_1 - */
r10886r10887
651679   output_set_lamp_value(12, ((data >> 4) & 1));   /* Aux_4 - Bell */
652680   output_set_lamp_value(13, ((data >> 5) & 1));   /* Aux_5 - /CIO */
653681
654   jckp = p1 & 1;
682   state->jckp = state->p1 & 1;
655683
656   if ((~c_io & 1) & ant_cio & hp_1 & hp_2)
684   if ((~state->c_io & 1) & state->ant_cio & state->hp_1 & state->hp_2)
657685   {
658      ++count1;   /* Decoded Coin In Mech. Counter*/
686      ++state->count1;   /* Decoded Coin In Mech. Counter*/
659687   }
660688
661   if ((~c_io & 1) & ant_cio & (~hp_1 & 1) & (~hp_2 & 1))
689   if ((~state->c_io & 1) & state->ant_cio & (~state->hp_1 & 1) & (~state->hp_2 & 1))
662690   {
663      ++count2;   /* Decoded Coind Out Mech. Counter */
691      ++state->count2;   /* Decoded Coind Out Mech. Counter */
664692   }
665693
666   if (~c_io & ant_cio & hp_1 & hp_2 & ~dvrt)
694   if (~state->c_io & state->ant_cio & state->hp_1 & state->hp_2 & ~state->dvrt)
667695   {
668      ++count3;   /* Decoded Coin to Drop Mech. Counter */
696      ++state->count3;   /* Decoded Coin to Drop Mech. Counter */
669697   }
670698
671   if (~jckp & ant_jckp)
699   if (~state->jckp & state->ant_jckp)
672700   {
673      ++count4;   /* Decoded Jackpot Mech. Counter */
701      ++state->count4;   /* Decoded Jackpot Mech. Counter */
674702   }
675703
676   count_7dig(count1, 0);
677   count_7dig(count2, 7);
678   count_7dig(count3, 14);
679   count_7dig(count4, 21);
704   count_7dig(state->count1, 0);
705   count_7dig(state->count2, 7);
706   count_7dig(state->count3, 14);
707   count_7dig(state->count4, 21);
680708
681   ant_cio = c_io;
682   ant_jckp = jckp;
709   state->ant_cio = state->c_io;
710   state->ant_jckp = state->jckp;
683711}
684712
685713static WRITE8_HANDLER( videopkr_p2_data_w )
686714{
687   p2 = data;
715   videopkr_state *state = space->machine->driver_data<videopkr_state>();
716   state->p2 = data;
688717}
689718
690719static READ8_HANDLER( videopkr_t0_latch )
691720{
692   return t0_latch;
721   videopkr_state *state = space->machine->driver_data<videopkr_state>();
722   return state->t0_latch;
693723}
694724
695725static WRITE8_HANDLER( prog_w )
r10886r10887
736766
737767static READ8_HANDLER(sound_io_r)
738768{
739   switch (vp_sound_p2)
769   videopkr_state *state = space->machine->driver_data<videopkr_state>();
770   switch (state->vp_sound_p2)
740771   {
741772      case 0xbf:
742773      {
743         c_io = (p1 >> 5) & 1;
744         hp_1 = (~p24_data >> 6) & 1;
745         hp_2 = (~p24_data >> 5) & 1;
746         bell = (p1 >> 4) & 1;
747         aux3 = (p1 >> 3) & 1;
748         dvrt = (~p24_data >> 7) & 1;
749         sound_ant = sound_latch;
750         sound_latch = c_io + (hp_1 << 1) + (hp_2 << 2) + (bell << 3) + 0xf0;
774         state->c_io = (state->p1 >> 5) & 1;
775         state->hp_1 = (~state->p24_data >> 6) & 1;
776         state->hp_2 = (~state->p24_data >> 5) & 1;
777         state->bell = (state->p1 >> 4) & 1;
778         state->aux3 = (state->p1 >> 3) & 1;
779         state->dvrt = (~state->p24_data >> 7) & 1;
780         state->sound_ant = state->sound_latch;
781         state->sound_latch = state->c_io + (state->hp_1 << 1) + (state->hp_2 << 2) + (state->bell << 3) + 0xf0;
751782
752783         break;
753784      }
754785   }
755786
756   return sound_latch;
787   return state->sound_latch;
757788}
758789
759790static WRITE8_HANDLER(sound_io_w)
760791{
761   if (vp_sound_p2 == 0x5f || vp_sound_p2 == 0xdf)
792   videopkr_state *state = space->machine->driver_data<videopkr_state>();
793   if (state->vp_sound_p2 == 0x5f || state->vp_sound_p2 == 0xdf)
762794   {
763      dc_40103 = data;
764      dc_4020 = 0;
795      state->dc_40103 = data;
796      state->dc_4020 = 0;
765797   }
766798}
767799
768800static READ8_HANDLER(sound_p2_r)
769801{
770   return vp_sound_p2;
802   videopkr_state *state = space->machine->driver_data<videopkr_state>();
803   return state->vp_sound_p2;
771804}
772805
773806static WRITE8_HANDLER(sound_p2_w)
774807{
775   vp_sound_p2 = data;
808   videopkr_state *state = space->machine->driver_data<videopkr_state>();
809   state->vp_sound_p2 = data;
776810
777811   switch (data)
778812   {
779813      case 0x5f:
780814      {
781         te_40103 = 0;   /* p2.7 LOW */
782         ld_40103 = 0;   /* p2.5 LOW */
815         state->te_40103 = 0;   /* p2.7 LOW */
816         state->ld_40103 = 0;   /* p2.5 LOW */
783817         break;
784818      }
785819
786820      case 0x7f:
787821      {
788         te_40103 = 0;
789         ld_40103 = 1;
822         state->te_40103 = 0;
823         state->ld_40103 = 1;
790824         break;
791825      }
792826
793827      case 0xff:
794828      {
795         te_40103 = 1;
796         ld_40103 = 1;
829         state->te_40103 = 1;
830         state->ld_40103 = 1;
797831         break;
798832      }
799833   }
r10886r10887
804838
805839static READ8_HANDLER(baby_sound_p0_r)
806840{
807   return sbp0;
841   videopkr_state *state = space->machine->driver_data<videopkr_state>();
842   return state->sbp0;
808843}
809844
810845static WRITE8_HANDLER(baby_sound_p0_w)
811846{
812   sbp0 = data;
847   videopkr_state *state = space->machine->driver_data<videopkr_state>();
848   state->sbp0 = data;
813849}
814850
815851static READ8_HANDLER(baby_sound_p1_r)
816852{
817   c_io = (p1 >> 5) & 1;
818   hp_1 = (~p24_data >> 6) & 1;
819   hp_2 = (~p24_data >> 5) & 1;
820   bell = (p1 >> 4) & 1;
821   aux3 = (p1 >> 3) & 1;
822   baby_latch = c_io + (hp_1 << 1) + (hp_2 << 2) + (bell << 3) + (aux3 << 4) + 0xe0;
823   return baby_latch;
853   videopkr_state *state = space->machine->driver_data<videopkr_state>();
854   state->c_io = (state->p1 >> 5) & 1;
855   state->hp_1 = (~state->p24_data >> 6) & 1;
856   state->hp_2 = (~state->p24_data >> 5) & 1;
857   state->bell = (state->p1 >> 4) & 1;
858   state->aux3 = (state->p1 >> 3) & 1;
859   state->baby_latch = state->c_io + (state->hp_1 << 1) + (state->hp_2 << 2) + (state->bell << 3) + (state->aux3 << 4) + 0xe0;
860   return state->baby_latch;
824861}
825862
826863static WRITE8_HANDLER(baby_sound_p1_w)
827864{
828   baby_latch = baby_latch | data;
865   videopkr_state *state = space->machine->driver_data<videopkr_state>();
866   state->baby_latch = state->baby_latch | data;
829867}
830868
831869static READ8_HANDLER(baby_sound_p2_r)
832870{
833   return sbp2;
871   videopkr_state *state = space->machine->driver_data<videopkr_state>();
872   return state->sbp2;
834873}
835874
836875static WRITE8_DEVICE_HANDLER(baby_sound_p2_w)
837876{
838   sbp2 = data;
877   videopkr_state *state = device->machine->driver_data<videopkr_state>();
878   state->sbp2 = data;
839879   dac_data_w(device, data);
840880}
841881
842882static READ8_DEVICE_HANDLER(baby_sound_p3_r)
843883{
844   return sbp3;
884   videopkr_state *state = device->machine->driver_data<videopkr_state>();
885   return state->sbp3;
845886}
846887
847888static WRITE8_DEVICE_HANDLER(baby_sound_p3_w)
848889{
890   videopkr_state *state = device->machine->driver_data<videopkr_state>();
849891   UINT8 lmp_ports, ay_intf;
850   sbp3 = data;
851   lmp_ports = sbp3 >> 1 & 0x07;
892   state->sbp3 = data;
893   lmp_ports = state->sbp3 >> 1 & 0x07;
852894
853895   output_set_value("TOP_1", (lmp_ports >> 0) & 1);
854896   output_set_value("TOP_2", (lmp_ports >> 1) & 1);
855897   output_set_value("TOP_3", (lmp_ports >> 2) & 1);
856898
857   if (!(sbp3 & 0x10))
899   if (!(state->sbp3 & 0x10))
858900   {
859901      device->reset();
860902      logerror("AY3-8910: Reset\n");
861903   }
862904
863   ay_intf = (sbp3 >> 5) & 0x07;
905   ay_intf = (state->sbp3 >> 5) & 0x07;
864906
865907   switch (ay_intf)
866908   {
867909      case 0x00:   break;
868910      case 0x01:   break;
869911      case 0x02:   break;
870      case 0x03:   ay8910_data_w(device, 1, sbp0); break;
912      case 0x03:   ay8910_data_w(device, 1, state->sbp0); break;
871913      case 0x04:   break;
872      case 0x05:   sbp0 = ay8910_r(device, sbp0); break;
914      case 0x05:   state->sbp0 = ay8910_r(device, state->sbp0); break;
873915      case 0x06:   break;
874      case 0x07:   ay8910_address_w(device, 0, sbp0); break;
916      case 0x07:   ay8910_address_w(device, 0, state->sbp0); break;
875917   }
876918}
877919
878920
879921static TIMER_DEVICE_CALLBACK(sound_t1_callback)
880922{
881   if (te_40103 == 1)
923   videopkr_state *state = timer.machine->driver_data<videopkr_state>();
924   if (state->te_40103 == 1)
882925   {
883      dc_40103++;
926      state->dc_40103++;
884927
885      if (dc_40103 == 0)
928      if (state->dc_40103 == 0)
886929      {
887930         cputag_set_input_line(timer.machine, "soundcpu", 0, ASSERT_LINE);
888931      }
r10886r10887
11501193
11511194static MACHINE_START(videopkr)
11521195{
1153   vp_sound_p2 = 0xff;   /* default P2 latch value */
1154   sound_latch = 0xff;   /* default sound data latch value */
1155   p24_data = 0xff;
1156   p1 = 0xff;
1157   ant_cio = 0;
1158   count0 = 0;
1196   videopkr_state *state = machine->driver_data<videopkr_state>();
1197   state->vp_sound_p2 = 0xff;   /* default P2 latch value */
1198   state->sound_latch = 0xff;   /* default sound data latch value */
1199   state->p24_data = 0xff;
1200   state->p1 = 0xff;
1201   state->ant_cio = 0;
1202   state->count0 = 0;
11591203
1160   machine->device<nvram_device>("nvram")->set_base(data_ram, sizeof(data_ram));
1204   machine->device<nvram_device>("nvram")->set_base(state->data_ram, sizeof(state->data_ram));
11611205}
11621206
11631207static const ay8910_interface ay8910_config =
r10886r10887
11751219*    Machine Drivers    *
11761220************************/
11771221
1178static MACHINE_CONFIG_START( videopkr, driver_device )
1222static MACHINE_CONFIG_START( videopkr, videopkr_state )
11791223
11801224   /* basic machine hardware */
11811225   MCFG_CPU_ADD("maincpu", I8039, CPU_CLOCK)
src/mame/drivers/mil4000.c
r10886r10887
9191#include "mil4000.lh"
9292
9393
94static UINT16 *sc0_vram,*sc1_vram,*sc2_vram,*sc3_vram;
95static tilemap_t *sc0_tilemap,*sc1_tilemap,*sc2_tilemap,*sc3_tilemap;
94class mil4000_state : public driver_device
95{
96public:
97   mil4000_state(running_machine &machine, const driver_device_config_base &config)
98      : driver_device(machine, config) { }
9699
100   UINT16 *sc0_vram;
101   UINT16 *sc1_vram;
102   UINT16 *sc2_vram;
103   UINT16 *sc3_vram;
104   tilemap_t *sc0_tilemap;
105   tilemap_t *sc1_tilemap;
106   tilemap_t *sc2_tilemap;
107   tilemap_t *sc3_tilemap;
108   UINT16 vblank;
109   UINT16 hblank;
110};
111
112
97113static TILE_GET_INFO( get_sc0_tile_info )
98114{
99   UINT32 data = (sc0_vram[tile_index*2]<<16) | sc0_vram[tile_index*2+1];
115   mil4000_state *state = machine->driver_data<mil4000_state>();
116   UINT32 data = (state->sc0_vram[tile_index*2]<<16) | state->sc0_vram[tile_index*2+1];
100117   int tile = data >> 14;
101   int color = (sc0_vram[tile_index*2+1] & 0x1f)+0;
118   int color = (state->sc0_vram[tile_index*2+1] & 0x1f)+0;
102119
103120   SET_TILE_INFO(
104121         0,
r10886r10887
109126
110127static TILE_GET_INFO( get_sc1_tile_info )
111128{
112   UINT32 data = (sc1_vram[tile_index*2]<<16) | sc1_vram[tile_index*2+1];
129   mil4000_state *state = machine->driver_data<mil4000_state>();
130   UINT32 data = (state->sc1_vram[tile_index*2]<<16) | state->sc1_vram[tile_index*2+1];
113131   int tile = data >> 14;
114   int color = (sc1_vram[tile_index*2+1] & 0x1f)+0x10;
132   int color = (state->sc1_vram[tile_index*2+1] & 0x1f)+0x10;
115133
116134   SET_TILE_INFO(
117135         0,
r10886r10887
122140
123141static TILE_GET_INFO( get_sc2_tile_info )
124142{
125   UINT32 data = (sc2_vram[tile_index*2]<<16) | sc2_vram[tile_index*2+1];
143   mil4000_state *state = machine->driver_data<mil4000_state>();
144   UINT32 data = (state->sc2_vram[tile_index*2]<<16) | state->sc2_vram[tile_index*2+1];
126145   int tile = data >> 14;
127   int color = (sc2_vram[tile_index*2+1] & 0x1f)+0x20;
146   int color = (state->sc2_vram[tile_index*2+1] & 0x1f)+0x20;
128147
129148   SET_TILE_INFO(
130149         0,
r10886r10887
135154
136155static TILE_GET_INFO( get_sc3_tile_info )
137156{
138   UINT32 data = (sc3_vram[tile_index*2]<<16) | sc3_vram[tile_index*2+1];
157   mil4000_state *state = machine->driver_data<mil4000_state>();
158   UINT32 data = (state->sc3_vram[tile_index*2]<<16) | state->sc3_vram[tile_index*2+1];
139159   int tile = data >> 14;
140   int color = (sc3_vram[tile_index*2+1] & 0x1f)+0x30;
160   int color = (state->sc3_vram[tile_index*2+1] & 0x1f)+0x30;
141161
142162   SET_TILE_INFO(
143163         0,
r10886r10887
148168
149169static VIDEO_START(mil4000)
150170{
151   sc0_tilemap = tilemap_create(machine, get_sc0_tile_info,tilemap_scan_rows,8,8,64,64);
152   sc1_tilemap = tilemap_create(machine, get_sc1_tile_info,tilemap_scan_rows,8,8,64,64);
153   sc2_tilemap = tilemap_create(machine, get_sc2_tile_info,tilemap_scan_rows,8,8,64,64);
154   sc3_tilemap = tilemap_create(machine, get_sc3_tile_info,tilemap_scan_rows,8,8,64,64);
171   mil4000_state *state = machine->driver_data<mil4000_state>();
172   state->sc0_tilemap = tilemap_create(machine, get_sc0_tile_info,tilemap_scan_rows,8,8,64,64);
173   state->sc1_tilemap = tilemap_create(machine, get_sc1_tile_info,tilemap_scan_rows,8,8,64,64);
174   state->sc2_tilemap = tilemap_create(machine, get_sc2_tile_info,tilemap_scan_rows,8,8,64,64);
175   state->sc3_tilemap = tilemap_create(machine, get_sc3_tile_info,tilemap_scan_rows,8,8,64,64);
155176
156   tilemap_set_transparent_pen(sc1_tilemap,0);
157   tilemap_set_transparent_pen(sc2_tilemap,0);
158   tilemap_set_transparent_pen(sc3_tilemap,0);
177   tilemap_set_transparent_pen(state->sc1_tilemap,0);
178   tilemap_set_transparent_pen(state->sc2_tilemap,0);
179   tilemap_set_transparent_pen(state->sc3_tilemap,0);
159180}
160181
161182static SCREEN_UPDATE(mil4000)
162183{
163   tilemap_draw(bitmap,cliprect,sc0_tilemap,0,0);
164   tilemap_draw(bitmap,cliprect,sc1_tilemap,0,0);
165   tilemap_draw(bitmap,cliprect,sc2_tilemap,0,0);
166   tilemap_draw(bitmap,cliprect,sc3_tilemap,0,0);
184   mil4000_state *state = screen->machine->driver_data<mil4000_state>();
185   tilemap_draw(bitmap,cliprect,state->sc0_tilemap,0,0);
186   tilemap_draw(bitmap,cliprect,state->sc1_tilemap,0,0);
187   tilemap_draw(bitmap,cliprect,state->sc2_tilemap,0,0);
188   tilemap_draw(bitmap,cliprect,state->sc3_tilemap,0,0);
167189   return 0;
168190}
169191
170192/*TODO*/
171193static READ16_HANDLER( hvretrace_r )
172194{
173   static UINT16 res;
174   static UINT16 vblank = 0,hblank = 0;
195   mil4000_state *state = space->machine->driver_data<mil4000_state>();
196   UINT16 res;
175197
176198   res = 0;
177199
178   vblank^=1;
179   hblank^=1;
200   state->vblank^=1;
201   state->hblank^=1;
180202
181203   /*V-Blank*/
182   if (vblank)
204   if (state->vblank)
183205      res|= 0x80;
184206
185207   /*H-Blank*/
186   if (hblank)
208   if (state->hblank)
187209      res|= 0x40;
188210
189211   return res;
r10886r10887
192214
193215static WRITE16_HANDLER( sc0_vram_w )
194216{
195   sc0_vram[offset] = data;
196   tilemap_mark_tile_dirty(sc0_tilemap,offset/2);
217   mil4000_state *state = space->machine->driver_data<mil4000_state>();
218   state->sc0_vram[offset] = data;
219   tilemap_mark_tile_dirty(state->sc0_tilemap,offset/2);
197220}
198221
199222static WRITE16_HANDLER( sc1_vram_w )
200223{
201   sc1_vram[offset] = data;
202   tilemap_mark_tile_dirty(sc1_tilemap,offset/2);
224   mil4000_state *state = space->machine->driver_data<mil4000_state>();
225   state->sc1_vram[offset] = data;
226   tilemap_mark_tile_dirty(state->sc1_tilemap,offset/2);
203227}
204228
205229static WRITE16_HANDLER( sc2_vram_w )
206230{
207   sc2_vram[offset] = data;
208   tilemap_mark_tile_dirty(sc2_tilemap,offset/2);
231   mil4000_state *state = space->machine->driver_data<mil4000_state>();
232   state->sc2_vram[offset] = data;
233   tilemap_mark_tile_dirty(state->sc2_tilemap,offset/2);
209234}
210235
211236static WRITE16_HANDLER( sc3_vram_w )
212237{
213   sc3_vram[offset] = data;
214   tilemap_mark_tile_dirty(sc3_tilemap,offset/2);
238   mil4000_state *state = space->machine->driver_data<mil4000_state>();
239   state->sc3_vram[offset] = data;
240   tilemap_mark_tile_dirty(state->sc3_tilemap,offset/2);
215241}
216242
217243/*end of video stuff*/
r10886r10887
228254*/
229255static WRITE16_HANDLER( output_w )
230256{
231   static int i;
257   int i;
232258
233259   for(i=0;i<3;i++)
234260      coin_counter_w(space->machine, i, data & 0x2000);
r10886r10887
246272
247273static ADDRESS_MAP_START( mil4000_map, ADDRESS_SPACE_PROGRAM, 16 )
248274   AM_RANGE(0x000000, 0x03ffff) AM_ROM
249   AM_RANGE(0x500000, 0x503fff) AM_RAM_WRITE(sc0_vram_w) AM_BASE(&sc0_vram)   // CY62256L-70, U77
250   AM_RANGE(0x504000, 0x507fff) AM_RAM_WRITE(sc1_vram_w) AM_BASE(&sc1_vram)   // CY62256L-70, U77
251   AM_RANGE(0x508000, 0x50bfff) AM_RAM_WRITE(sc2_vram_w) AM_BASE(&sc2_vram)   // CY62256L-70, U78
252   AM_RANGE(0x50c000, 0x50ffff) AM_RAM_WRITE(sc3_vram_w) AM_BASE(&sc3_vram)   // CY62256L-70, U78
275   AM_RANGE(0x500000, 0x503fff) AM_RAM_WRITE(sc0_vram_w) AM_BASE_MEMBER(mil4000_state, sc0_vram)   // CY62256L-70, U77
276   AM_RANGE(0x504000, 0x507fff) AM_RAM_WRITE(sc1_vram_w) AM_BASE_MEMBER(mil4000_state, sc1_vram)   // CY62256L-70, U77
277   AM_RANGE(0x508000, 0x50bfff) AM_RAM_WRITE(sc2_vram_w) AM_BASE_MEMBER(mil4000_state, sc2_vram)   // CY62256L-70, U78
278   AM_RANGE(0x50c000, 0x50ffff) AM_RAM_WRITE(sc3_vram_w) AM_BASE_MEMBER(mil4000_state, sc3_vram)   // CY62256L-70, U78
253279
254280   AM_RANGE(0x708000, 0x708001) AM_READ_PORT("IN0")
255281   AM_RANGE(0x708002, 0x708003) AM_READ_PORT("IN1")
r10886r10887
337363GFXDECODE_END
338364
339365
340static MACHINE_CONFIG_START( mil4000, driver_device )
366static MACHINE_CONFIG_START( mil4000, mil4000_state )
341367   MCFG_CPU_ADD("maincpu", M68000, 12000000 )   // ?
342368   MCFG_CPU_PROGRAM_MAP(mil4000_map)
343369   // irq 2/4/5 point to the same place, others invalid
src/mame/drivers/namcona1.c
r10886r10887
165165#include "sound/c140.h"
166166#include "cpu/m37710/m37710.h"
167167
168static UINT16 *mpBank0, *mpBank1;
169static int mEnableInterrupts;
170static int namcona1_gametype;
171168
172169/*************************************************************************/
173170
r10886r10887
203200   0x00,0x02,0x00,0x00,0x00,0x01
204201}; /* CgangpzlDefaultNvMem */
205202
206static UINT8 namcona1_nvmem[NA1_NVRAM_SIZE];
207203
208204static NVRAM_HANDLER( namcosna1 )
209205{
206   namcona1_state *state = machine->driver_data<namcona1_state>();
210207   if( read_or_write )
211208   {
212      file->write( namcona1_nvmem, NA1_NVRAM_SIZE );
209      file->write( state->nvmem, NA1_NVRAM_SIZE );
213210   }
214211   else
215212   {
216213      if (file)
217214      {
218         file->read( namcona1_nvmem, NA1_NVRAM_SIZE );
215         file->read( state->nvmem, NA1_NVRAM_SIZE );
219216      }
220217      else
221218      {
222         memset( namcona1_nvmem, 0x00, NA1_NVRAM_SIZE );
219         memset( state->nvmem, 0x00, NA1_NVRAM_SIZE );
223220
224         switch( namcona1_gametype )
221         switch( state->gametype )
225222         {
226223         case NAMCO_EXBANIA:
227            memcpy( namcona1_nvmem, ExvaniaDefaultNvMem, sizeof(ExvaniaDefaultNvMem) );
224            memcpy( state->nvmem, ExvaniaDefaultNvMem, sizeof(ExvaniaDefaultNvMem) );
228225            break;
229226
230227         case NAMCO_QUIZTOU:
231            memcpy( namcona1_nvmem, QuiztouDefaultNvMem, sizeof(QuiztouDefaultNvMem) );
228            memcpy( state->nvmem, QuiztouDefaultNvMem, sizeof(QuiztouDefaultNvMem) );
232229            break;
233230
234231         case NAMCO_CGANGPZL:
235            memcpy( namcona1_nvmem, CgangpzlDefaultNvMem, sizeof(CgangpzlDefaultNvMem) );
232            memcpy( state->nvmem, CgangpzlDefaultNvMem, sizeof(CgangpzlDefaultNvMem) );
236233            break;
237234         }
238235      }
r10886r10887
241238
242239static READ16_HANDLER( namcona1_nvram_r )
243240{
244   return namcona1_nvmem[offset];
241   namcona1_state *state = space->machine->driver_data<namcona1_state>();
242   return state->nvmem[offset];
245243} /* namcona1_nvram_r */
246244
247245static WRITE16_HANDLER( namcona1_nvram_w )
248246{
247   namcona1_state *state = space->machine->driver_data<namcona1_state>();
249248   if( ACCESSING_BITS_0_7 )
250249   {
251      namcona1_nvmem[offset] = data&0xff;
250      state->nvmem[offset] = data&0xff;
252251   }
253252} /* namcona1_nvram_w */
254253
r10886r10887
372371/* FIXME: These two functions shouldn't be necessary? */
373372static void simulate_mcu( running_machine *machine )
374373{
375   namcona1_workram[0xf60/2] = 0x0000; /* mcu ready */
374   namcona1_state *state = machine->driver_data<namcona1_state>();
375   state->workram[0xf60/2] = 0x0000; /* mcu ready */
376376}
377377
378378
379379/* NA2 hardware sends a special command to the MCU, then tests to
380380 * see if the proper BIOS version string appears in shared memory.
381381 */
382static void write_version_info( void )
382static void write_version_info( namcona1_state *state )
383383{
384384   static const UINT16 source[0x8] =
385385   { /* "NSA-BIOS ver"... */
r10886r10887
388388   int i;
389389   for( i=0; i<8; i++ )
390390   {
391      namcona1_workram[0x1000/2+i] = source[i];
391      state->workram[0x1000/2+i] = source[i];
392392   }
393393}
394394
r10886r10887
403403 */
404404static READ16_HANDLER( custom_key_r )
405405{
406   static UINT16 count;
407   static UINT32 keyval;
406   namcona1_state *state = space->machine->driver_data<namcona1_state>();
408407   int old_count;
409408
410   old_count = count;
409   old_count = state->count;
411410   do
412411   {
413      count = space->machine->rand();
414   } while( old_count == count );
412      state->count = space->machine->rand();
413   } while( old_count == state->count );
415414
416   switch( namcona1_gametype )
415   switch( state->gametype )
417416   {
418417   case NAMCO_BKRTMAQ:
419418      if( offset==2 ) return 0x015c;
r10886r10887
421420
422421   case NAMCO_FA:
423422      if( offset==2 ) return 0x015d;
424      if( offset==4 ) return count;
423      if( offset==4 ) return state->count;
425424      break;
426425
427426   case NAMCO_EXBANIA:
r10886r10887
430429
431430   case NAMCO_CGANGPZL:
432431      if( offset==1 ) return 0x0164;
433      if( offset==2 ) return count;
432      if( offset==2 ) return state->count;
434433      break;
435434
436435   case NAMCO_SWCOURT:
437436      if( offset==1 ) return 0x0165;
438      if( offset==2 ) return count;
437      if( offset==2 ) return state->count;
439438      break;
440439
441440   case NAMCO_EMERALDA:
442441      if( offset==1 ) return 0x0166;
443      if( offset==2 ) return count;
442      if( offset==2 ) return state->count;
444443      break;
445444
446445   case NAMCO_NUMANATH:
447446      if( offset==1 ) return 0x0167;
448      if( offset==2 ) return count;
447      if( offset==2 ) return state->count;
449448      break;
450449
451450   case NAMCO_KNCKHEAD:
452451      if( offset==1 ) return 0x0168;
453      if( offset==2 ) return count;
452      if( offset==2 ) return state->count;
454453      break;
455454
456455   case NAMCO_QUIZTOU:
r10886r10887
459458
460459   case NAMCO_TINKLPIT:
461460      if( offset==7 ) return 0x016f;
462      if( offset==4 ) keyval = 0;
461      if( offset==4 ) state->keyval = 0;
463462      if( offset==3 )
464463      {
465464         UINT16 res;
466         res = BITSWAP16(keyval, 22,26,31,23,18,20,16,30,24,21,25,19,17,29,28,27);
465         res = BITSWAP16(state->keyval, 22,26,31,23,18,20,16,30,24,21,25,19,17,29,28,27);
467466
468         keyval >>= 1;
469//          printf("popcount(%08X) = %d\n", keyval & 0x58000c00, popcount(keyval & 0x58000c00));
470         if((!keyval) || (popcount(keyval & 0x58000c00) & 1))
471            keyval ^= 0x80000000;
467         state->keyval >>= 1;
468//          printf("popcount(%08X) = %d\n", state->keyval & 0x58000c00, popcount(state->keyval & 0x58000c00));
469         if((!state->keyval) || (popcount(state->keyval & 0x58000c00) & 1))
470            state->keyval ^= 0x80000000;
472471
473472         return res;
474473      }
r10886r10887
476475
477476   case NAMCO_XDAY2:
478477      if( offset==2 ) return 0x018a;
479      if( offset==3 ) return count;
478      if( offset==3 ) return state->count;
480479      break;
481480
482481   default:
r10886r10887
493492
494493static READ16_HANDLER( namcona1_vreg_r )
495494{
496   return namcona1_vreg[offset];
495   namcona1_state *state = space->machine->driver_data<namcona1_state>();
496   return state->vreg[offset];
497497} /* namcona1_vreg_r */
498498
499499static int transfer_dword( running_machine *machine, UINT32 dest, UINT32 source )
r10886r10887
504504
505505   if( source>=0x400000 && source<0xc00000 )
506506   {
507      data = mpBank1[(source-0x400000)/2];
507      data = state->mpBank1[(source-0x400000)/2];
508508   }
509509   else if( source>=0xc00000 && source<0xe00000 )
510510   {
511      data = mpBank0[(source-0xc00000)/2];
511      data = state->mpBank0[(source-0xc00000)/2];
512512   }
513513   else if( source<0x80000 && source>=0x1000 )
514514   {
515      data = namcona1_workram[source/2];
515      data = state->workram[source/2];
516516   }
517517   else
518518   {
r10886r10887
616616
617617static void namcona1_blit( running_machine *machine )
618618{
619   int src0 = namcona1_vreg[0x0];
620   int src1 = namcona1_vreg[0x1];
621   int src2 = namcona1_vreg[0x2];
619   namcona1_state *state = machine->driver_data<namcona1_state>();
620   int src0 = state->vreg[0x0];
621   int src1 = state->vreg[0x1];
622   int src2 = state->vreg[0x2];
622623
623   int dst0 = namcona1_vreg[0x3];
624   int dst1 = namcona1_vreg[0x4];
625   int dst2 = namcona1_vreg[0x5];
624   int dst0 = state->vreg[0x3];
625   int dst1 = state->vreg[0x4];
626   int dst2 = state->vreg[0x5];
626627
627   int gfxbank = namcona1_vreg[0x6];
628   int gfxbank = state->vreg[0x6];
628629
629630   /* dest and source are provided as dword offsets */
630   UINT32 src_baseaddr   = 2*(0xffffff&((namcona1_vreg[0x7]<<16)|namcona1_vreg[0x8]));
631   UINT32 dst_baseaddr   = 2*(0xffffff&((namcona1_vreg[0x9]<<16)|namcona1_vreg[0xa]));
631   UINT32 src_baseaddr   = 2*(0xffffff&((state->vreg[0x7]<<16)|state->vreg[0x8]));
632   UINT32 dst_baseaddr   = 2*(0xffffff&((state->vreg[0x9]<<16)|state->vreg[0xa]));
632633
633   int num_bytes = namcona1_vreg[0xb];
634   int num_bytes = state->vreg[0xb];
634635
635636   int dst_offset, src_offset;
636637   int dst_bytes_per_row, dst_pitch;
r10886r10887
693694
694695static WRITE16_HANDLER( namcona1_vreg_w )
695696{
696   COMBINE_DATA( &namcona1_vreg[offset] );
697   namcona1_state *state = space->machine->driver_data<namcona1_state>();
698   COMBINE_DATA( &state->vreg[offset] );
697699
698700   switch( offset )
699701   {
r10886r10887
703705      break;
704706
705707   case 0x1a/2:
706      mEnableInterrupts = 1;
708      state->mEnableInterrupts = 1;
707709      /* interrupt enable mask; 0 enables INT level */
708710      break;
709711   }
r10886r10887
712714/***************************************************************/
713715
714716// MCU "mailslot" handler - has 8 16-bit slots mirrored
715static UINT16 mcu_mailbox[8];
716717
717718static READ16_HANDLER( mcu_mailbox_r )
718719{
719   return mcu_mailbox[offset%8];
720   namcona1_state *state = space->machine->driver_data<namcona1_state>();
721   return state->mcu_mailbox[offset%8];
720722}
721723
722724static WRITE16_HANDLER( mcu_mailbox_w_68k )
723725{
726   namcona1_state *state = space->machine->driver_data<namcona1_state>();
724727//  logerror("mailbox_w_68k: %x @ %x\n", data, offset);
725728
726729   if (offset == 4)
727730      cputag_set_input_line(space->machine, "mcu", M37710_LINE_IRQ0, HOLD_LINE);
728731
729   COMBINE_DATA(&mcu_mailbox[offset%8]);
732   COMBINE_DATA(&state->mcu_mailbox[offset%8]);
730733
731734   /* FIXME: This shouldn't be necessary now that the C70 BIOS is implemented,
732735    but for some reason the MCU never responds to the version string command */
733   if ( (namcona1_gametype == NAMCO_NUMANATH) || (namcona1_gametype == NAMCO_KNCKHEAD) )
736   if ( (state->gametype == NAMCO_NUMANATH) || (state->gametype == NAMCO_KNCKHEAD) )
734737   {
735      if ((namcona1_workram[0xf72/2] >> 8) == 7)
736         write_version_info();
738      if ((state->workram[0xf72/2] >> 8) == 7)
739         write_version_info(state);
737740   }
738741}
739742
740743static WRITE16_HANDLER( mcu_mailbox_w_mcu )
741744{
742   COMBINE_DATA(&mcu_mailbox[offset%8]);
745   namcona1_state *state = space->machine->driver_data<namcona1_state>();
746   COMBINE_DATA(&state->mcu_mailbox[offset%8]);
743747}
744748
745749static ADDRESS_MAP_START( namcona1_main_map, ADDRESS_SPACE_PROGRAM, 16 )
746   AM_RANGE(0x000000, 0x07ffff) AM_RAM AM_BASE(&namcona1_workram)
750   AM_RANGE(0x000000, 0x07ffff) AM_RAM AM_BASE_MEMBER(namcona1_state, workram)
747751   AM_RANGE(0x3f8000, 0x3fffff) AM_READWRITE(mcu_mailbox_r, mcu_mailbox_w_68k)
748752   AM_RANGE(0x400000, 0xbfffff) AM_ROM AM_REGION("maincpu", 0x280000)   /* data */
749753   AM_RANGE(0xc00000, 0xdfffff) AM_ROM AM_REGION("maincpu", 0x080000)   /* code */
750754   AM_RANGE(0xe00000, 0xe00fff) AM_READWRITE(namcona1_nvram_r, namcona1_nvram_w)
751755   AM_RANGE(0xe40000, 0xe4000f) AM_READWRITE(custom_key_r, custom_key_w)
752   AM_RANGE(0xefff00, 0xefffff) AM_READWRITE(namcona1_vreg_r, namcona1_vreg_w) AM_BASE(&namcona1_vreg)
756   AM_RANGE(0xefff00, 0xefffff) AM_READWRITE(namcona1_vreg_r, namcona1_vreg_w) AM_BASE_MEMBER(namcona1_state, vreg)
753757   AM_RANGE(0xf00000, 0xf01fff) AM_READWRITE(namcona1_paletteram_r, namcona1_paletteram_w) AM_BASE_GENERIC(paletteram)
754758   AM_RANGE(0xf40000, 0xf7ffff) AM_READWRITE(namcona1_gfxram_r, namcona1_gfxram_w)
755759   AM_RANGE(0xff0000, 0xffbfff) AM_READWRITE(namcona1_videoram_r,    namcona1_videoram_w) AM_BASE_MEMBER(namcona1_state, videoram)
756760   AM_RANGE(0xffd000, 0xffdfff) AM_RAM /* unknown */
757   AM_RANGE(0xffe000, 0xffefff) AM_RAM   AM_BASE(&namcona1_scroll)      /* scroll registers */
761   AM_RANGE(0xffe000, 0xffefff) AM_RAM   AM_BASE_MEMBER(namcona1_state, scroll)      /* scroll registers */
758762   AM_RANGE(0xfff000, 0xffffff) AM_RAM   AM_BASE_MEMBER(namcona1_state, spriteram)         /* spriteram */
759763ADDRESS_MAP_END
760764
761765
762766static ADDRESS_MAP_START( namcona2_main_map, ADDRESS_SPACE_PROGRAM, 16 )
763   AM_RANGE(0x000000, 0x07ffff) AM_RAM AM_BASE(&namcona1_workram)
767   AM_RANGE(0x000000, 0x07ffff) AM_RAM AM_BASE_MEMBER(namcona1_state, workram)
764768   AM_RANGE(0x3f8000, 0x3fffff) AM_READWRITE(mcu_mailbox_r, mcu_mailbox_w_68k)
765769   AM_RANGE(0x400000, 0xbfffff) AM_ROM AM_REGION("maincpu", 0x280000)   /* data */
766770   AM_RANGE(0xd00000, 0xd00001) AM_WRITENOP /* xday: serial out? */
r10886r10887
771775   AM_RANGE(0xe00000, 0xe00fff) AM_READWRITE(namcona1_nvram_r, namcona1_nvram_w)
772776   /* xday: additional battery-backed ram at 00E024FA? */
773777   AM_RANGE(0xe40000, 0xe4000f) AM_READWRITE(custom_key_r, custom_key_w)
774   AM_RANGE(0xefff00, 0xefffff) AM_READWRITE(namcona1_vreg_r, namcona1_vreg_w) AM_BASE(&namcona1_vreg)
778   AM_RANGE(0xefff00, 0xefffff) AM_READWRITE(namcona1_vreg_r, namcona1_vreg_w) AM_BASE_MEMBER(namcona1_state, vreg)
775779   AM_RANGE(0xf00000, 0xf01fff) AM_READWRITE(namcona1_paletteram_r, namcona1_paletteram_w) AM_BASE_GENERIC(paletteram)
776780   AM_RANGE(0xf40000, 0xf7ffff) AM_READWRITE(namcona1_gfxram_r, namcona1_gfxram_w)
777781   AM_RANGE(0xff0000, 0xffbfff) AM_READWRITE(namcona1_videoram_r,    namcona1_videoram_w) AM_BASE_MEMBER(namcona1_state, videoram)
778782   AM_RANGE(0xffd000, 0xffdfff) AM_RAM /* unknown */
779   AM_RANGE(0xffe000, 0xffefff) AM_RAM   AM_BASE(&namcona1_scroll)      /* scroll registers */
783   AM_RANGE(0xffe000, 0xffefff) AM_RAM   AM_BASE_MEMBER(namcona1_state, scroll)      /* scroll registers */
780784   AM_RANGE(0xfff000, 0xffffff) AM_RAM   AM_BASE_MEMBER(namcona1_state, spriteram)         /* spriteram */
781785ADDRESS_MAP_END
782786
r10886r10887
785789
786790static READ16_HANDLER( na1mcu_shared_r )
787791{
792   namcona1_state *state = space->machine->driver_data<namcona1_state>();
788793   UINT16 data;
789794
790   data = namcona1_workram[offset];
795   data = state->workram[offset];
791796
792797#if 0
793798   if (offset >= 0x70000/2)
r10886r10887
801806
802807static WRITE16_HANDLER( na1mcu_shared_w )
803808{
809   namcona1_state *state = space->machine->driver_data<namcona1_state>();
804810   mem_mask = FLIPENDIAN_INT16(mem_mask);
805811   data = FLIPENDIAN_INT16(data);
806812
807   COMBINE_DATA(&namcona1_workram[offset]);
813   COMBINE_DATA(&state->workram[offset]);
808814}
809815
810816static READ16_DEVICE_HANDLER(snd_r)
r10886r10887
836842   AM_RANGE(0x200000, 0x27ffff) AM_READWRITE(na1mcu_shared_r, na1mcu_shared_w)   // shared work RAM
837843ADDRESS_MAP_END
838844
839static UINT8 mcu_port4, mcu_port5, mcu_port6, mcu_port8;
840845
841846// port 4: bit 3 (0x08) enables the 68000 (see the 68k launch code at c604 in swcourt's BIOS)
842847static READ8_HANDLER( port4_r )
843848{
844   return mcu_port4;
849   namcona1_state *state = space->machine->driver_data<namcona1_state>();
850   return state->mcu_port4;
845851}
846852
847853static WRITE8_HANDLER( port4_w )
848854{
849   if ((data & 0x08) && !(mcu_port4 & 0x08))
855   namcona1_state *state = space->machine->driver_data<namcona1_state>();
856   if ((data & 0x08) && !(state->mcu_port4 & 0x08))
850857   {
851858      logerror("launching 68k, PC=%x\n", cpu_get_pc(space->cpu));
852859
r10886r10887
854861      cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_RESET, CLEAR_LINE);
855862   }
856863
857   mcu_port4 = data;
864   state->mcu_port4 = data;
858865}
859866
860867// port 5: not sure yet, but MCU code requires this interaction at least
861868static READ8_HANDLER( port5_r )
862869{
863   return mcu_port5;
870   namcona1_state *state = space->machine->driver_data<namcona1_state>();
871   return state->mcu_port5;
864872}
865873
866874static WRITE8_HANDLER( port5_w )
867875{
868   mcu_port5 = data;
876   namcona1_state *state = space->machine->driver_data<namcona1_state>();
877   state->mcu_port5 = data;
869878
870879   // bit 0 must mirror bit 1 - this is checked at CCD3 in the C69 BIOS
871   mcu_port5 &= 0xfe;
872   mcu_port5 |= ((mcu_port5 & 0x2)>>1);
880   state->mcu_port5 &= 0xfe;
881   state->mcu_port5 |= ((state->mcu_port5 & 0x2)>>1);
873882}
874883
875884static READ8_HANDLER( port6_r )
r10886r10887
879888
880889static WRITE8_HANDLER( port6_w )
881890{
882   mcu_port6 = data;
891   namcona1_state *state = space->machine->driver_data<namcona1_state>();
892   state->mcu_port6 = data;
883893}
884894
885895static READ8_HANDLER( port7_r )
886896{
887   switch (mcu_port6 & 0xe0)
897   namcona1_state *state = space->machine->driver_data<namcona1_state>();
898   switch (state->mcu_port6 & 0xe0)
888899   {
889900      case 0x40:
890901         return input_port_read(space->machine, "P1");
r10886r10887
909920// port 8: bit 5 (0x20) toggles, watchdog?
910921static READ8_HANDLER( port8_r )
911922{
912   return mcu_port8;
923   namcona1_state *state = space->machine->driver_data<namcona1_state>();
924   return state->mcu_port8;
913925}
914926
915927static WRITE8_HANDLER( port8_w )
916928{
917   mcu_port8 = data;
929   namcona1_state *state = space->machine->driver_data<namcona1_state>();
930   state->mcu_port8 = data;
918931}
919932
920933
921934static MACHINE_START( namcona1 )
922935{
923   c140_set_base(machine->device("c140"), namcona1_workram);
936   namcona1_state *state = machine->driver_data<namcona1_state>();
937   c140_set_base(machine->device("c140"), state->workram);
924938}
925939
926940// for games with the MCU emulated, the MCU boots the 68000.  don't allow it before that.
927941static MACHINE_RESET( namcona1_mcu )
928942{
943   namcona1_state *state = machine->driver_data<namcona1_state>();
929944   cputag_set_input_line(machine, "maincpu", INPUT_LINE_RESET, ASSERT_LINE);
930945
931   mcu_port5 = 1;
946   state->mcu_port5 = 1;
932947}
933948
934949// "encrypt" player 3 inputs
r10886r10887
961976
962977static INTERRUPT_GEN( namcona1_interrupt )
963978{
979   namcona1_state *state = device->machine->driver_data<namcona1_state>();
964980   int level = cpu_getiloops(device); /* 0,1,2,3,4 */
965981   if( level==0 )
966982   {
967983      simulate_mcu( device->machine );
968984   }
969   if( mEnableInterrupts )
985   if( state->mEnableInterrupts )
970986   {
971      if( (namcona1_vreg[0x1a/2]&(1<<level))==0 )
987      if( (state->vreg[0x1a/2]&(1<<level))==0 )
972988      {
973989         if( level==2 )
974990         { // posirq used with dolphin in Emeraldia's "how to play" attract mode
975            int scanline = namcona1_vreg[0x8a/2]&0xff;
991            int scanline = state->vreg[0x8a/2]&0xff;
976992            if( scanline )
977993            {
978994               device->machine->primary_screen->update_partial(scanline );
r10886r10887
10681084
10691085static void init_namcona1( running_machine *machine, int gametype )
10701086{
1087   namcona1_state *state = machine->driver_data<namcona1_state>();
10711088   UINT16 *pMem = (UINT16 *)machine->region( "maincpu" )->base();
10721089
1073   namcona1_gametype = gametype;
1074   mpBank0 = &pMem[0x80000/2];
1075   mpBank1 = mpBank0 +  0x200000/2;
1090   state->gametype = gametype;
1091   state->mpBank0 = &pMem[0x80000/2];
1092   state->mpBank1 = state->mpBank0 +  0x200000/2;
10761093
1077   mEnableInterrupts = 0;
1094   state->mEnableInterrupts = 0;
10781095}
10791096
10801097static DRIVER_INIT( bkrtmaq ){      init_namcona1(machine, NAMCO_BKRTMAQ); }
src/mame/drivers/itgambl3.c
r10886r10887
4545#include "sound/okim6295.h"
4646
4747
48static int test_x, test_y, start_offs;
48class itgambl3_state : public driver_device
49{
50public:
51   itgambl3_state(running_machine &machine, const driver_device_config_base &config)
52      : driver_device(machine, config) { }
4953
54   int test_x;
55   int test_y;
56   int start_offs;
57};
58
59
5060/*************************
5161*     Video Hardware     *
5262*************************/
5363
5464static VIDEO_START( itgambl3 )
5565{
56   test_x = 256;
57   test_y = 256;
58   start_offs = 0;
66   itgambl3_state *state = machine->driver_data<itgambl3_state>();
67   state->test_x = 256;
68   state->test_y = 256;
69   state->start_offs = 0;
5970}
6071
6172/* (dirty) debug code for looking 8bpps blitter-based gfxs */
6273static SCREEN_UPDATE( itgambl3 )
6374{
75   itgambl3_state *state = screen->machine->driver_data<itgambl3_state>();
6476   int x,y,count;
6577   const UINT8 *blit_ram = screen->machine->region("gfx1")->base();
6678
6779   if(input_code_pressed(screen->machine, KEYCODE_Z))
68      test_x++;
80      state->test_x++;
6981
7082   if(input_code_pressed(screen->machine, KEYCODE_X))
71      test_x--;
83      state->test_x--;
7284
7385   if(input_code_pressed(screen->machine, KEYCODE_A))
74      test_y++;
86      state->test_y++;
7587
7688   if(input_code_pressed(screen->machine, KEYCODE_S))
77      test_y--;
89      state->test_y--;
7890
7991   if(input_code_pressed(screen->machine, KEYCODE_Q))
80      start_offs+=0x200;
92      state->start_offs+=0x200;
8193
8294   if(input_code_pressed(screen->machine, KEYCODE_W))
83      start_offs-=0x200;
95      state->start_offs-=0x200;
8496
8597   if(input_code_pressed(screen->machine, KEYCODE_E))
86      start_offs++;
98      state->start_offs++;
8799
88100   if(input_code_pressed(screen->machine, KEYCODE_R))
89      start_offs--;
101      state->start_offs--;
90102
91   popmessage("%d %d %04x",test_x,test_y,start_offs);
103   popmessage("%d %d %04x",state->test_x,state->test_y,state->start_offs);
92104
93105   bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
94106
95   count = (start_offs);
107   count = (state->start_offs);
96108
97   for(y=0;y<test_y;y++)
109   for(y=0;y<state->test_y;y++)
98110   {
99      for(x=0;x<test_x;x++)
111      for(x=0;x<state->test_x;x++)
100112      {
101113         UINT32 color;
102114
r10886r10887
236248*     Machine Drivers     *
237249**************************/
238250
239static MACHINE_CONFIG_START( itgambl3, driver_device )
251static MACHINE_CONFIG_START( itgambl3, itgambl3_state )
240252
241253    /* basic machine hardware */
242254   MCFG_CPU_ADD("maincpu", H83044, MAIN_CLOCK)   /* wrong CPU, but we have not a M16C core ATM */
src/mame/drivers/acefruit.c
r10886r10887
2222      : driver_device(machine, config) { }
2323
2424   UINT8 *spriteram;
25   UINT8 *colorram;
26   UINT8 *videoram;
27   emu_timer *refresh_timer;
2528};
2629
2730
28static UINT8 *colorram;
29static UINT8 *videoram;
3031
3132static void acefruit_update_irq(running_machine *machine, int vpos )
3233{
34   acefruit_state *state = machine->driver_data<acefruit_state>();
3335   int col;
3436   int row = vpos / 8;
3537
3638   for( col = 0; col < 32; col++ )
3739   {
3840      int tile_index = ( col * 32 ) + row;
39      int color = colorram[ tile_index ];
41      int color = state->colorram[ tile_index ];
4042
4143      switch( color )
4244      {
r10886r10887
4749   }
4850}
4951
50static emu_timer *acefruit_refresh_timer;
5152
5253static TIMER_CALLBACK( acefruit_refresh )
5354{
55   acefruit_state *state = machine->driver_data<acefruit_state>();
5456   int vpos = machine->primary_screen->vpos();
5557
5658   machine->primary_screen->update_partial(vpos );
r10886r10887
5860
5961   vpos = ( ( vpos / 8 ) + 1 ) * 8;
6062
61   acefruit_refresh_timer->adjust( machine->primary_screen->time_until_pos(vpos) );
63   state->refresh_timer->adjust( machine->primary_screen->time_until_pos(vpos) );
6264}
6365
6466static VIDEO_START( acefruit )
6567{
66   acefruit_refresh_timer = machine->scheduler().timer_alloc(FUNC(acefruit_refresh));
68   acefruit_state *state = machine->driver_data<acefruit_state>();
69   state->refresh_timer = machine->scheduler().timer_alloc(FUNC(acefruit_refresh));
6770}
6871
6972static INTERRUPT_GEN( acefruit_vblank )
7073{
74   acefruit_state *state = device->machine->driver_data<acefruit_state>();
7175   cpu_set_input_line(device, 0, HOLD_LINE );
72   acefruit_refresh_timer->adjust( attotime::zero );
76   state->refresh_timer->adjust( attotime::zero );
7377}
7478
7579static SCREEN_UPDATE( acefruit )
r10886r10887
8993      for( col = 0; col < 32; col++ )
9094      {
9195         int tile_index = ( col * 32 ) + row;
92         int code = videoram[ tile_index ];
93         int color = colorram[ tile_index ];
96         int code = state->videoram[ tile_index ];
97         int color = state->colorram[ tile_index ];
9498
9599         if( color < 0x4 )
96100         {
r10886r10887
213217
214218static WRITE8_HANDLER( acefruit_colorram_w )
215219{
216   colorram[ offset ] = data & 0xf;
220   acefruit_state *state = space->machine->driver_data<acefruit_state>();
221   state->colorram[ offset ] = data & 0xf;
217222}
218223
219224static WRITE8_HANDLER( acefruit_coin_w )
r10886r10887
272277static ADDRESS_MAP_START( acefruit_map, ADDRESS_SPACE_PROGRAM, 8 )
273278   AM_RANGE(0x0000, 0x1fff) AM_ROM
274279   AM_RANGE(0x2000, 0x20ff) AM_RAM AM_SHARE("nvram")
275   AM_RANGE(0x4000, 0x43ff) AM_RAM AM_BASE(&videoram)
276   AM_RANGE(0x4400, 0x47ff) AM_RAM_WRITE(acefruit_colorram_w) AM_BASE(&colorram)
280   AM_RANGE(0x4000, 0x43ff) AM_RAM AM_BASE_MEMBER(acefruit_state, videoram)
281   AM_RANGE(0x4400, 0x47ff) AM_RAM_WRITE(acefruit_colorram_w) AM_BASE_MEMBER(acefruit_state, colorram)
277282   AM_RANGE(0x8000, 0x8000) AM_READ_PORT("IN0")
278283   AM_RANGE(0x8001, 0x8001) AM_READ_PORT("IN1")
279284   AM_RANGE(0x8002, 0x8002) AM_READ_PORT("IN2")
src/mame/drivers/skylncr.c
r10886r10887
3838#include "machine/8255ppi.h"
3939#include "machine/nvram.h"
4040
41static tilemap_t *tmap;
4241
43static UINT8 *skylncr_videoram,*skylncr_colorram;
42class skylncr_state : public driver_device
43{
44public:
45   skylncr_state(running_machine &machine, const driver_device_config_base &config)
46      : driver_device(machine, config) { }
4447
45static UINT8* reeltiles_1_ram;
46static UINT8* reeltiles_2_ram;
47static UINT8* reeltiles_3_ram;
48static UINT8* reeltiles_4_ram;
49static UINT8* reeltileshigh_1_ram;
50static UINT8* reeltileshigh_2_ram;
51static UINT8* reeltileshigh_3_ram;
52static UINT8* reeltileshigh_4_ram;
53static tilemap_t *reel_1_tilemap;
54static tilemap_t *reel_2_tilemap;
55static tilemap_t *reel_3_tilemap;
56static tilemap_t *reel_4_tilemap;
57static UINT8* reelscroll1;
58static UINT8* reelscroll2;
59static UINT8* reelscroll3;
60static UINT8* reelscroll4;
48   tilemap_t *tmap;
49   UINT8 *videoram;
50   UINT8 *colorram;
51   UINT8* reeltiles_1_ram;
52   UINT8* reeltiles_2_ram;
53   UINT8* reeltiles_3_ram;
54   UINT8* reeltiles_4_ram;
55   UINT8* reeltileshigh_1_ram;
56   UINT8* reeltileshigh_2_ram;
57   UINT8* reeltileshigh_3_ram;
58   UINT8* reeltileshigh_4_ram;
59   tilemap_t *reel_1_tilemap;
60   tilemap_t *reel_2_tilemap;
61   tilemap_t *reel_3_tilemap;
62   tilemap_t *reel_4_tilemap;
63   UINT8* reelscroll1;
64   UINT8* reelscroll2;
65   UINT8* reelscroll3;
66   UINT8* reelscroll4;
67   UINT8 nmi_enable;
68   int color;
69   int color2;
70};
6171
62static UINT8 skylncr_nmi_enable;
6372
64
6573/**************************************
6674*           Video Hardware            *
6775**************************************/
6876
6977static WRITE8_HANDLER( skylncr_videoram_w )
7078{
71   skylncr_videoram[offset] = data;
72   tilemap_mark_tile_dirty(tmap, offset);
79   skylncr_state *state = space->machine->driver_data<skylncr_state>();
80   state->videoram[offset] = data;
81   tilemap_mark_tile_dirty(state->tmap, offset);
7382}
7483
7584static WRITE8_HANDLER( skylncr_colorram_w )
7685{
77   skylncr_colorram[offset] = data;
78   tilemap_mark_tile_dirty(tmap, offset);
86   skylncr_state *state = space->machine->driver_data<skylncr_state>();
87   state->colorram[offset] = data;
88   tilemap_mark_tile_dirty(state->tmap, offset);
7989}
8090
8191
8292static TILE_GET_INFO( get_tile_info )
8393{
84   UINT16 code = skylncr_videoram[ tile_index ] + (skylncr_colorram[ tile_index ] << 8);
94   skylncr_state *state = machine->driver_data<skylncr_state>();
95   UINT16 code = state->videoram[ tile_index ] + (state->colorram[ tile_index ] << 8);
8596   SET_TILE_INFO(0, code, 0, TILE_FLIPYX( 0 ));
8697}
8798
8899static TILE_GET_INFO( get_reel_1_tile_info )
89100{
90   UINT16 code = reeltiles_1_ram[ tile_index ] + (reeltileshigh_1_ram[ tile_index ] << 8);
101   skylncr_state *state = machine->driver_data<skylncr_state>();
102   UINT16 code = state->reeltiles_1_ram[ tile_index ] + (state->reeltileshigh_1_ram[ tile_index ] << 8);
91103   SET_TILE_INFO(1, code, 0, TILE_FLIPYX( 0 ));
92104}
93105
94106static TILE_GET_INFO( get_reel_2_tile_info )
95107{
96   UINT16 code = reeltiles_2_ram[ tile_index ] + (reeltileshigh_2_ram[ tile_index ] << 8);
108   skylncr_state *state = machine->driver_data<skylncr_state>();
109   UINT16 code = state->reeltiles_2_ram[ tile_index ] + (state->reeltileshigh_2_ram[ tile_index ] << 8);
97110   SET_TILE_INFO(1, code, 0, TILE_FLIPYX( 0 ));
98111}
99112
100113static TILE_GET_INFO( get_reel_3_tile_info )
101114{
102   UINT16 code = reeltiles_3_ram[ tile_index ] + (reeltileshigh_3_ram[ tile_index ] << 8);
115   skylncr_state *state = machine->driver_data<skylncr_state>();
116   UINT16 code = state->reeltiles_3_ram[ tile_index ] + (state->reeltileshigh_3_ram[ tile_index ] << 8);
103117   SET_TILE_INFO(1, code, 0, TILE_FLIPYX( 0 ));
104118}
105119
106120static TILE_GET_INFO( get_reel_4_tile_info )
107121{
108   UINT16 code = reeltiles_4_ram[ tile_index ] + (reeltileshigh_4_ram[ tile_index ] << 8);
122   skylncr_state *state = machine->driver_data<skylncr_state>();
123   UINT16 code = state->reeltiles_4_ram[ tile_index ] + (state->reeltileshigh_4_ram[ tile_index ] << 8);
109124   SET_TILE_INFO(1, code, 0, TILE_FLIPYX( 0 ));
110125}
111126
112127
113128static VIDEO_START( skylncr )
114129{
130   skylncr_state *state = machine->driver_data<skylncr_state>();
115131
116   tmap = tilemap_create(   machine, get_tile_info, tilemap_scan_rows, 8, 8, 0x40, 0x20   );
132   state->tmap = tilemap_create(   machine, get_tile_info, tilemap_scan_rows, 8, 8, 0x40, 0x20   );
117133
118   reel_1_tilemap = tilemap_create(machine, get_reel_1_tile_info, tilemap_scan_rows, 8, 32, 64, 8 );
119   reel_2_tilemap = tilemap_create(machine, get_reel_2_tile_info, tilemap_scan_rows, 8, 32, 64, 8 );
120   reel_3_tilemap = tilemap_create(machine, get_reel_3_tile_info, tilemap_scan_rows, 8, 32, 64, 8 );
121   reel_4_tilemap = tilemap_create(machine, get_reel_4_tile_info, tilemap_scan_rows, 8, 32, 64, 8 );
134   state->reel_1_tilemap = tilemap_create(machine, get_reel_1_tile_info, tilemap_scan_rows, 8, 32, 64, 8 );
135   state->reel_2_tilemap = tilemap_create(machine, get_reel_2_tile_info, tilemap_scan_rows, 8, 32, 64, 8 );
136   state->reel_3_tilemap = tilemap_create(machine, get_reel_3_tile_info, tilemap_scan_rows, 8, 32, 64, 8 );
137   state->reel_4_tilemap = tilemap_create(machine, get_reel_4_tile_info, tilemap_scan_rows, 8, 32, 64, 8 );
122138
123   tilemap_set_scroll_cols(reel_2_tilemap, 0x40);
124   tilemap_set_scroll_cols(reel_3_tilemap, 0x40);
125   tilemap_set_scroll_cols(reel_4_tilemap, 0x40);
139   tilemap_set_scroll_cols(state->reel_2_tilemap, 0x40);
140   tilemap_set_scroll_cols(state->reel_3_tilemap, 0x40);
141   tilemap_set_scroll_cols(state->reel_4_tilemap, 0x40);
126142
127   tilemap_set_transparent_pen(reel_2_tilemap, 0);
128   tilemap_set_transparent_pen(reel_3_tilemap, 0);
129   tilemap_set_transparent_pen(reel_4_tilemap, 0);
143   tilemap_set_transparent_pen(state->reel_2_tilemap, 0);
144   tilemap_set_transparent_pen(state->reel_3_tilemap, 0);
145   tilemap_set_transparent_pen(state->reel_4_tilemap, 0);
130146
131147
132   tilemap_set_transparent_pen(tmap, 0);
148   tilemap_set_transparent_pen(state->tmap, 0);
133149}
134150
135151// are these hardcoded, or registers?
r10886r10887
140156
141157static SCREEN_UPDATE( skylncr )
142158{
159   skylncr_state *state = screen->machine->driver_data<skylncr_state>();
143160   int i;
144161
145162   bitmap_fill(bitmap,cliprect,0);
146   tilemap_draw(bitmap,cliprect, reel_1_tilemap, 0, 0);
163   tilemap_draw(bitmap,cliprect, state->reel_1_tilemap, 0, 0);
147164
148165   for (i= 0;i < 64;i++)
149166   {
150      tilemap_set_scrolly(reel_2_tilemap, i, reelscroll2[i]);
151      tilemap_set_scrolly(reel_3_tilemap, i, reelscroll3[i]);
152      tilemap_set_scrolly(reel_4_tilemap, i, reelscroll4[i]);
167      tilemap_set_scrolly(state->reel_2_tilemap, i, state->reelscroll2[i]);
168      tilemap_set_scrolly(state->reel_3_tilemap, i, state->reelscroll3[i]);
169      tilemap_set_scrolly(state->reel_4_tilemap, i, state->reelscroll4[i]);
153170   }
154171
155   tilemap_draw(bitmap,&visible1,reel_2_tilemap, 0, 0);
156   tilemap_draw(bitmap,&visible2,reel_3_tilemap, 0, 0);
157   tilemap_draw(bitmap,&visible3,reel_4_tilemap, 0, 0);
172   tilemap_draw(bitmap,&visible1,state->reel_2_tilemap, 0, 0);
173   tilemap_draw(bitmap,&visible2,state->reel_3_tilemap, 0, 0);
174   tilemap_draw(bitmap,&visible3,state->reel_4_tilemap, 0, 0);
158175
159176
160   tilemap_draw(bitmap,cliprect, tmap, 0, 0);
177   tilemap_draw(bitmap,cliprect, state->tmap, 0, 0);
161178   return 0;
162179}
163180
164181static WRITE8_HANDLER( reeltiles_1_w )
165182{
166   reeltiles_1_ram[offset] = data;
167   tilemap_mark_tile_dirty(reel_1_tilemap, offset);
183   skylncr_state *state = space->machine->driver_data<skylncr_state>();
184   state->reeltiles_1_ram[offset] = data;
185   tilemap_mark_tile_dirty(state->reel_1_tilemap, offset);
168186}
169187
170188static WRITE8_HANDLER( reeltiles_2_w )
171189{
172   reeltiles_2_ram[offset] = data;
173   tilemap_mark_tile_dirty(reel_2_tilemap, offset);
190   skylncr_state *state = space->machine->driver_data<skylncr_state>();
191   state->reeltiles_2_ram[offset] = data;
192   tilemap_mark_tile_dirty(state->reel_2_tilemap, offset);
174193}
175194
176195static WRITE8_HANDLER( reeltiles_3_w )
177196{
178   reeltiles_3_ram[offset] = data;
179   tilemap_mark_tile_dirty(reel_3_tilemap, offset);
197   skylncr_state *state = space->machine->driver_data<skylncr_state>();
198   state->reeltiles_3_ram[offset] = data;
199   tilemap_mark_tile_dirty(state->reel_3_tilemap, offset);
180200}
181201
182202static WRITE8_HANDLER( reeltiles_4_w )
183203{
184   reeltiles_4_ram[offset] = data;
185   tilemap_mark_tile_dirty(reel_4_tilemap, offset);
204   skylncr_state *state = space->machine->driver_data<skylncr_state>();
205   state->reeltiles_4_ram[offset] = data;
206   tilemap_mark_tile_dirty(state->reel_4_tilemap, offset);
186207}
187208
188209static WRITE8_HANDLER( reeltileshigh_1_w )
189210{
190   reeltileshigh_1_ram[offset] = data;
191   tilemap_mark_tile_dirty(reel_1_tilemap, offset);
211   skylncr_state *state = space->machine->driver_data<skylncr_state>();
212   state->reeltileshigh_1_ram[offset] = data;
213   tilemap_mark_tile_dirty(state->reel_1_tilemap, offset);
192214}
193215
194216static WRITE8_HANDLER( reeltileshigh_2_w )
195217{
196   reeltileshigh_2_ram[offset] = data;
197   tilemap_mark_tile_dirty(reel_2_tilemap, offset);
218   skylncr_state *state = space->machine->driver_data<skylncr_state>();
219   state->reeltileshigh_2_ram[offset] = data;
220   tilemap_mark_tile_dirty(state->reel_2_tilemap, offset);
198221}
199222
200223static WRITE8_HANDLER( reeltileshigh_3_w )
201224{
202   reeltileshigh_3_ram[offset] = data;
203   tilemap_mark_tile_dirty(reel_3_tilemap, offset);
225   skylncr_state *state = space->machine->driver_data<skylncr_state>();
226   state->reeltileshigh_3_ram[offset] = data;
227   tilemap_mark_tile_dirty(state->reel_3_tilemap, offset);
204228}
205229
206230static WRITE8_HANDLER( reeltileshigh_4_w )
207231{
208   reeltileshigh_4_ram[offset] = data;
209   tilemap_mark_tile_dirty(reel_4_tilemap, offset);
232   skylncr_state *state = space->machine->driver_data<skylncr_state>();
233   state->reeltileshigh_4_ram[offset] = data;
234   tilemap_mark_tile_dirty(state->reel_4_tilemap, offset);
210235}
211236
212237
213238static WRITE8_HANDLER( skylncr_paletteram_w )
214239{
215   static int color;
240   skylncr_state *state = space->machine->driver_data<skylncr_state>();
216241
217242   if (offset == 0)
218243   {
219      color = data;
244      state->color = data;
220245   }
221246   else
222247   {
223248      int r,g,b;
224      space->machine->generic.paletteram.u8[color] = data;
249      space->machine->generic.paletteram.u8[state->color] = data;
225250
226      r = space->machine->generic.paletteram.u8[(color/3 * 3) + 0];
227      g = space->machine->generic.paletteram.u8[(color/3 * 3) + 1];
228      b = space->machine->generic.paletteram.u8[(color/3 * 3) + 2];
251      r = space->machine->generic.paletteram.u8[(state->color/3 * 3) + 0];
252      g = space->machine->generic.paletteram.u8[(state->color/3 * 3) + 1];
253      b = space->machine->generic.paletteram.u8[(state->color/3 * 3) + 2];
229254      r = (r << 2) | (r >> 4);
230255      g = (g << 2) | (g >> 4);
231256      b = (b << 2) | (b >> 4);
232257
233      palette_set_color(space->machine, color / 3, MAKE_RGB(r, g, b));
234      color = (color + 1) % (0x100 * 3);
258      palette_set_color(space->machine, state->color / 3, MAKE_RGB(r, g, b));
259      state->color = (state->color + 1) % (0x100 * 3);
235260   }
236261}
237262
238263static WRITE8_HANDLER( skylncr_paletteram2_w )
239264{
240   static int color;
265   skylncr_state *state = space->machine->driver_data<skylncr_state>();
241266
242267   if (offset == 0)
243268   {
244      color = data;
269      state->color2 = data;
245270   }
246271   else
247272   {
248273      int r,g,b;
249      space->machine->generic.paletteram2.u8[color] = data;
274      space->machine->generic.paletteram2.u8[state->color2] = data;
250275
251      r = space->machine->generic.paletteram2.u8[(color/3 * 3) + 0];
252      g = space->machine->generic.paletteram2.u8[(color/3 * 3) + 1];
253      b = space->machine->generic.paletteram2.u8[(color/3 * 3) + 2];
276      r = space->machine->generic.paletteram2.u8[(state->color2/3 * 3) + 0];
277      g = space->machine->generic.paletteram2.u8[(state->color2/3 * 3) + 1];
278      b = space->machine->generic.paletteram2.u8[(state->color2/3 * 3) + 2];
254279      r = (r << 2) | (r >> 4);
255280      g = (g << 2) | (g >> 4);
256281      b = (b << 2) | (b >> 4);
257282
258      palette_set_color(space->machine, 0x100 + color / 3, MAKE_RGB(r, g, b));
259      color = (color + 1) % (0x100 * 3);
283      palette_set_color(space->machine, 0x100 + state->color2 / 3, MAKE_RGB(r, g, b));
284      state->color2 = (state->color2 + 1) % (0x100 * 3);
260285   }
261286}
262287
263288static WRITE8_HANDLER( reelscroll1_w )
264289{
265   reelscroll1[offset] = data;
290   skylncr_state *state = space->machine->driver_data<skylncr_state>();
291   state->reelscroll1[offset] = data;
266292}
267293
268294static WRITE8_HANDLER( reelscroll2_w )
269295{
270   reelscroll2[offset] = data;
296   skylncr_state *state = space->machine->driver_data<skylncr_state>();
297   state->reelscroll2[offset] = data;
271298}
272299
273300static WRITE8_HANDLER( reelscroll3_w )
274301{
275   reelscroll3[offset] = data;
302   skylncr_state *state = space->machine->driver_data<skylncr_state>();
303   state->reelscroll3[offset] = data;
276304}
277305
278306static WRITE8_HANDLER( reelscroll4_w )
279307{
280   reelscroll4[offset] = data;
308   skylncr_state *state = space->machine->driver_data<skylncr_state>();
309   state->reelscroll4[offset] = data;
281310}
282311
283312
r10886r10887
304333
305334static WRITE8_HANDLER( skylncr_nmi_enable_w )
306335{
307   skylncr_nmi_enable = data & 0x10;
336   skylncr_state *state = space->machine->driver_data<skylncr_state>();
337   state->nmi_enable = data & 0x10;
308338}
309339
310340
r10886r10887
316346   AM_RANGE(0x0000, 0x7fff) AM_ROM
317347   AM_RANGE(0x8000, 0x87ff) AM_RAM AM_SHARE("nvram")
318348
319   AM_RANGE(0x8800, 0x8fff) AM_RAM_WRITE( skylncr_videoram_w ) AM_BASE( &skylncr_videoram )
320   AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE( skylncr_colorram_w ) AM_BASE( &skylncr_colorram )
349   AM_RANGE(0x8800, 0x8fff) AM_RAM_WRITE( skylncr_videoram_w ) AM_BASE_MEMBER(skylncr_state, videoram )
350   AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE( skylncr_colorram_w ) AM_BASE_MEMBER(skylncr_state, colorram )
321351
322   AM_RANGE(0x9800, 0x99ff) AM_RAM_WRITE( reeltiles_1_w ) AM_BASE( &reeltiles_1_ram )
323   AM_RANGE(0x9a00, 0x9bff) AM_RAM_WRITE( reeltiles_2_w ) AM_BASE( &reeltiles_2_ram )
324   AM_RANGE(0x9c00, 0x9dff) AM_RAM_WRITE( reeltiles_3_w ) AM_BASE( &reeltiles_3_ram )
325   AM_RANGE(0x9e00, 0x9fff) AM_RAM_WRITE( reeltiles_4_w ) AM_BASE( &reeltiles_4_ram )
326   AM_RANGE(0xa000, 0xa1ff) AM_RAM_WRITE( reeltileshigh_1_w ) AM_BASE( &reeltileshigh_1_ram )
327   AM_RANGE(0xa200, 0xa3ff) AM_RAM_WRITE( reeltileshigh_2_w ) AM_BASE( &reeltileshigh_2_ram )
328   AM_RANGE(0xa400, 0xa5ff) AM_RAM_WRITE( reeltileshigh_3_w ) AM_BASE( &reeltileshigh_3_ram )
329   AM_RANGE(0xa600, 0xa7ff) AM_RAM_WRITE( reeltileshigh_4_w ) AM_BASE( &reeltileshigh_4_ram )
352   AM_RANGE(0x9800, 0x99ff) AM_RAM_WRITE( reeltiles_1_w ) AM_BASE_MEMBER(skylncr_state, reeltiles_1_ram )
353   AM_RANGE(0x9a00, 0x9bff) AM_RAM_WRITE( reeltiles_2_w ) AM_BASE_MEMBER(skylncr_state, reeltiles_2_ram )
354   AM_RANGE(0x9c00, 0x9dff) AM_RAM_WRITE( reeltiles_3_w ) AM_BASE_MEMBER(skylncr_state, reeltiles_3_ram )
355   AM_RANGE(0x9e00, 0x9fff) AM_RAM_WRITE( reeltiles_4_w ) AM_BASE_MEMBER(skylncr_state, reeltiles_4_ram )
356   AM_RANGE(0xa000, 0xa1ff) AM_RAM_WRITE( reeltileshigh_1_w ) AM_BASE_MEMBER(skylncr_state, reeltileshigh_1_ram )
357   AM_RANGE(0xa200, 0xa3ff) AM_RAM_WRITE( reeltileshigh_2_w ) AM_BASE_MEMBER(skylncr_state, reeltileshigh_2_ram )
358   AM_RANGE(0xa400, 0xa5ff) AM_RAM_WRITE( reeltileshigh_3_w ) AM_BASE_MEMBER(skylncr_state, reeltileshigh_3_ram )
359   AM_RANGE(0xa600, 0xa7ff) AM_RAM_WRITE( reeltileshigh_4_w ) AM_BASE_MEMBER(skylncr_state, reeltileshigh_4_ram )
330360
331361   AM_RANGE(0xaa55, 0xaa55) AM_READ( ret_ff )
332362
333   AM_RANGE(0xb000, 0xb03f) AM_RAM_WRITE(reelscroll1_w) AM_BASE(&reelscroll1)
363   AM_RANGE(0xb000, 0xb03f) AM_RAM_WRITE(reelscroll1_w) AM_BASE_MEMBER(skylncr_state, reelscroll1)
334364   AM_RANGE(0xb040, 0xb07f) AM_RAM_WRITE(reelscroll1_w)
335365   AM_RANGE(0xb080, 0xb0bf) AM_RAM_WRITE(reelscroll1_w)
336366   AM_RANGE(0xb0c0, 0xb0ff) AM_RAM_WRITE(reelscroll1_w)
r10886r10887
339369   AM_RANGE(0xb180, 0xb1bf) AM_RAM_WRITE(reelscroll1_w)
340370   AM_RANGE(0xb1c0, 0xb1ff) AM_RAM_WRITE(reelscroll1_w)
341371
342   AM_RANGE(0xb200, 0xb23f) AM_RAM_WRITE(reelscroll2_w) AM_BASE(&reelscroll2)
372   AM_RANGE(0xb200, 0xb23f) AM_RAM_WRITE(reelscroll2_w) AM_BASE_MEMBER(skylncr_state, reelscroll2)
343373   AM_RANGE(0xb240, 0xb27f) AM_RAM_WRITE(reelscroll2_w)
344374   AM_RANGE(0xb280, 0xb2bf) AM_RAM_WRITE(reelscroll2_w)
345375   AM_RANGE(0xb2c0, 0xb2ff) AM_RAM_WRITE(reelscroll2_w)
r10886r10887
348378   AM_RANGE(0xb380, 0xb3bf) AM_RAM_WRITE(reelscroll2_w)
349379   AM_RANGE(0xb3c0, 0xb3ff) AM_RAM_WRITE(reelscroll2_w)
350380
351   AM_RANGE(0xb400, 0xb43f) AM_RAM_WRITE(reelscroll3_w) AM_BASE(&reelscroll3)
381   AM_RANGE(0xb400, 0xb43f) AM_RAM_WRITE(reelscroll3_w) AM_BASE_MEMBER(skylncr_state, reelscroll3)
352382   AM_RANGE(0xb440, 0xb47f) AM_RAM_WRITE(reelscroll3_w)
353383   AM_RANGE(0xb480, 0xb4bf) AM_RAM_WRITE(reelscroll3_w)
354384   AM_RANGE(0xb4c0, 0xb4ff) AM_RAM_WRITE(reelscroll3_w)
r10886r10887
357387   AM_RANGE(0xb580, 0xb5bf) AM_RAM_WRITE(reelscroll3_w)
358388   AM_RANGE(0xb5c0, 0xb5ff) AM_RAM_WRITE(reelscroll3_w)
359389
360   AM_RANGE(0xb600, 0xb63f) AM_RAM_WRITE(reelscroll4_w) AM_BASE(&reelscroll4)
390   AM_RANGE(0xb600, 0xb63f) AM_RAM_WRITE(reelscroll4_w) AM_BASE_MEMBER(skylncr_state, reelscroll4)
361391   AM_RANGE(0xb640, 0xb67f) AM_RAM_WRITE(reelscroll4_w)
362392   AM_RANGE(0xb680, 0xb6bf) AM_RAM_WRITE(reelscroll4_w)
363393   AM_RANGE(0xb6c0, 0xb6ff) AM_RAM_WRITE(reelscroll4_w)
r10886r10887
649679// It runs in IM 0, thus needs an opcode on the data bus
650680static INTERRUPT_GEN( skylncr_vblank_interrupt )
651681{
652   if (skylncr_nmi_enable) cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
682   skylncr_state *state = device->machine->driver_data<skylncr_state>();
683   if (state->nmi_enable) cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
653684}
654685
655686
r10886r10887
657688*           Machine Driver           *
658689*************************************/
659690
660static MACHINE_CONFIG_START( skylncr, driver_device )
691static MACHINE_CONFIG_START( skylncr, skylncr_state )
661692
662693   /* basic machine hardware */
663694   MCFG_CPU_ADD("maincpu", Z80, MASTER_CLOCK/4)
src/mame/drivers/limenko.c
r10886r10887
3939   UINT32 *spriteram;
4040   UINT32 *spriteram2;
4141   size_t spriteram_size;
42   tilemap_t *bg_tilemap;
43   tilemap_t *md_tilemap;
44   tilemap_t *fg_tilemap;
45   UINT32 *bg_videoram;
46   UINT32 *md_videoram;
47   UINT32 *fg_videoram;
48   UINT32 *videoreg;
49   UINT32 *mainram;
50   int spriteram_bit;
51   bitmap_t *sprites_bitmap;
52   bitmap_t *sprites_bitmap_pri;
53   int prev_sprites_count;
54   UINT8 spotty_sound_cmd;
4255};
4356
4457
45static tilemap_t *bg_tilemap, *md_tilemap, *fg_tilemap;
46static UINT32 *bg_videoram, *md_videoram, *fg_videoram, *limenko_videoreg;
47
48static UINT32 *mainram;
49static int spriteram_bit;
50
51static bitmap_t *sprites_bitmap;
52static bitmap_t *sprites_bitmap_pri;
53
54static int prev_sprites_count = 0;
55
5658static void draw_sprites(running_machine *machine, UINT32 *sprites, const rectangle *cliprect, int count);
5759
5860/*****************************************************************************************************
r10886r10887
8486
8587static WRITE32_HANDLER( bg_videoram_w )
8688{
87   COMBINE_DATA(&bg_videoram[offset]);
88   tilemap_mark_tile_dirty(bg_tilemap,offset);
89   limenko_state *state = space->machine->driver_data<limenko_state>();
90   COMBINE_DATA(&state->bg_videoram[offset]);
91   tilemap_mark_tile_dirty(state->bg_tilemap,offset);
8992}
9093
9194static WRITE32_HANDLER( md_videoram_w )
9295{
93   COMBINE_DATA(&md_videoram[offset]);
94   tilemap_mark_tile_dirty(md_tilemap,offset);
96   limenko_state *state = space->machine->driver_data<limenko_state>();
97   COMBINE_DATA(&state->md_videoram[offset]);
98   tilemap_mark_tile_dirty(state->md_tilemap,offset);
9599}
96100
97101static WRITE32_HANDLER( fg_videoram_w )
98102{
99   COMBINE_DATA(&fg_videoram[offset]);
100   tilemap_mark_tile_dirty(fg_tilemap,offset);
103   limenko_state *state = space->machine->driver_data<limenko_state>();
104   COMBINE_DATA(&state->fg_videoram[offset]);
105   tilemap_mark_tile_dirty(state->fg_tilemap,offset);
101106}
102107
103108static WRITE32_HANDLER( spotty_soundlatch_w )
r10886r10887
107112
108113static CUSTOM_INPUT( spriteram_bit_r )
109114{
110   return spriteram_bit;
115   limenko_state *state = field->port->machine->driver_data<limenko_state>();
116   return state->spriteram_bit;
111117}
112118
113119static WRITE32_HANDLER( spriteram_buffer_w )
r10886r10887
119125   clip.min_y = 0;
120126   clip.max_y = 239;
121127
122   bitmap_fill(sprites_bitmap_pri,&clip,0);
123   bitmap_fill(sprites_bitmap,&clip,0);
128   bitmap_fill(state->sprites_bitmap_pri,&clip,0);
129   bitmap_fill(state->sprites_bitmap,&clip,0);
124130
125131   // toggle spriterams location in the memory map
126   spriteram_bit ^= 1;
132   state->spriteram_bit ^= 1;
127133
128   if(spriteram_bit)
134   if(state->spriteram_bit)
129135   {
130136      // draw the sprites to the frame buffer
131      draw_sprites(space->machine,state->spriteram2,&clip,prev_sprites_count);
137      draw_sprites(space->machine,state->spriteram2,&clip,state->prev_sprites_count);
132138   }
133139   else
134140   {
135141      // draw the sprites to the frame buffer
136      draw_sprites(space->machine,state->spriteram,&clip,prev_sprites_count);
142      draw_sprites(space->machine,state->spriteram,&clip,state->prev_sprites_count);
137143   }
138144
139145   // buffer the next number of sprites to draw
140   prev_sprites_count = (limenko_videoreg[0] & 0x1ff0000) >> 16;
146   state->prev_sprites_count = (state->videoreg[0] & 0x1ff0000) >> 16;
141147}
142148
143149/*****************************************************************************************************
r10886r10887
145151*****************************************************************************************************/
146152
147153static ADDRESS_MAP_START( limenko_map, ADDRESS_SPACE_PROGRAM, 32 )
148   AM_RANGE(0x00000000, 0x001fffff) AM_RAM   AM_BASE(&mainram)
154   AM_RANGE(0x00000000, 0x001fffff) AM_RAM   AM_BASE_MEMBER(limenko_state, mainram)
149155   AM_RANGE(0x40000000, 0x403fffff) AM_ROM AM_REGION("user2",0)
150   AM_RANGE(0x80000000, 0x80007fff) AM_RAM_WRITE(fg_videoram_w) AM_BASE(&fg_videoram)
151   AM_RANGE(0x80008000, 0x8000ffff) AM_RAM_WRITE(md_videoram_w) AM_BASE(&md_videoram)
152   AM_RANGE(0x80010000, 0x80017fff) AM_RAM_WRITE(bg_videoram_w) AM_BASE(&bg_videoram)
156   AM_RANGE(0x80000000, 0x80007fff) AM_RAM_WRITE(fg_videoram_w) AM_BASE_MEMBER(limenko_state, fg_videoram)
157   AM_RANGE(0x80008000, 0x8000ffff) AM_RAM_WRITE(md_videoram_w) AM_BASE_MEMBER(limenko_state, md_videoram)
158   AM_RANGE(0x80010000, 0x80017fff) AM_RAM_WRITE(bg_videoram_w) AM_BASE_MEMBER(limenko_state, bg_videoram)
153159   AM_RANGE(0x80018000, 0x80018fff) AM_RAM AM_BASE_SIZE_MEMBER(limenko_state, spriteram, spriteram_size)
154160   AM_RANGE(0x80019000, 0x80019fff) AM_RAM AM_BASE_MEMBER(limenko_state, spriteram2)
155161   AM_RANGE(0x8001c000, 0x8001dfff) AM_RAM_WRITE(limenko_paletteram_w) AM_BASE_GENERIC(paletteram)
156162   AM_RANGE(0x8001e000, 0x8001ebff) AM_RAM // ? not used
157   AM_RANGE(0x8001ffec, 0x8001ffff) AM_RAM AM_BASE(&limenko_videoreg)
163   AM_RANGE(0x8001ffec, 0x8001ffff) AM_RAM AM_BASE_MEMBER(limenko_state, videoreg)
158164   AM_RANGE(0x8003e000, 0x8003e003) AM_WRITE(spriteram_buffer_w)
159165   AM_RANGE(0xffe00000, 0xffffffff) AM_ROM AM_REGION("user1",0)
160166ADDRESS_MAP_END
r10886r10887
172178/* Spotty memory map */
173179
174180static ADDRESS_MAP_START( spotty_map, ADDRESS_SPACE_PROGRAM, 32 )
175   AM_RANGE(0x00000000, 0x001fffff) AM_RAM   AM_BASE(&mainram)
181   AM_RANGE(0x00000000, 0x001fffff) AM_RAM   AM_BASE_MEMBER(limenko_state, mainram)
176182   AM_RANGE(0x40002000, 0x400024d3) AM_RAM //?
177   AM_RANGE(0x80000000, 0x80007fff) AM_RAM_WRITE(fg_videoram_w) AM_BASE(&fg_videoram)
178   AM_RANGE(0x80008000, 0x8000ffff) AM_RAM_WRITE(md_videoram_w) AM_BASE(&md_videoram)
179   AM_RANGE(0x80010000, 0x80017fff) AM_RAM_WRITE(bg_videoram_w) AM_BASE(&bg_videoram)
183   AM_RANGE(0x80000000, 0x80007fff) AM_RAM_WRITE(fg_videoram_w) AM_BASE_MEMBER(limenko_state, fg_videoram)
184   AM_RANGE(0x80008000, 0x8000ffff) AM_RAM_WRITE(md_videoram_w) AM_BASE_MEMBER(limenko_state, md_videoram)
185   AM_RANGE(0x80010000, 0x80017fff) AM_RAM_WRITE(bg_videoram_w) AM_BASE_MEMBER(limenko_state, bg_videoram)
180186   AM_RANGE(0x80018000, 0x80018fff) AM_RAM AM_BASE_SIZE_MEMBER(limenko_state, spriteram, spriteram_size)
181187   AM_RANGE(0x80019000, 0x80019fff) AM_RAM AM_BASE_MEMBER(limenko_state, spriteram2)
182188   AM_RANGE(0x8001c000, 0x8001dfff) AM_RAM_WRITE(limenko_paletteram_w) AM_BASE_GENERIC(paletteram)
183189   AM_RANGE(0x8001e000, 0x8001ebff) AM_RAM // ? not used
184   AM_RANGE(0x8001ffec, 0x8001ffff) AM_RAM AM_BASE(&limenko_videoreg)
190   AM_RANGE(0x8001ffec, 0x8001ffff) AM_RAM AM_BASE_MEMBER(limenko_state, videoreg)
185191   AM_RANGE(0x8003e000, 0x8003e003) AM_WRITE(spriteram_buffer_w)
186192   AM_RANGE(0xfff00000, 0xffffffff) AM_ROM AM_REGION("user1",0)
187193ADDRESS_MAP_END
r10886r10887
195201   AM_RANGE(0x5000, 0x5003) AM_WRITE(spotty_soundlatch_w)
196202ADDRESS_MAP_END
197203
198static UINT8 spotty_sound_cmd=0;
199204static WRITE8_HANDLER( spotty_sound_cmd_w )
200205{
201   spotty_sound_cmd = data;
206   limenko_state *state = space->machine->driver_data<limenko_state>();
207   state->spotty_sound_cmd = data;
202208}
203209
204210static READ8_HANDLER( spotty_sound_cmd_r )
r10886r10887
208214
209215static READ8_HANDLER( spotty_sound_r )
210216{
211   // check spotty_sound_cmd bits...
217   limenko_state *state = space->machine->driver_data<limenko_state>();
218   // check state->spotty_sound_cmd bits...
212219
213   if(spotty_sound_cmd == 0xf7)
220   if(state->spotty_sound_cmd == 0xf7)
214221      return soundlatch_r(space,0);
215222   else
216223      return space->machine->device<okim6295_device>("oki")->read(*space,0);
r10886r10887
227234
228235static TILE_GET_INFO( get_bg_tile_info )
229236{
230   int tile  = bg_videoram[tile_index] & 0x7ffff;
231   int color = (bg_videoram[tile_index]>>28) & 0xf;
237   limenko_state *state = machine->driver_data<limenko_state>();
238   int tile  = state->bg_videoram[tile_index] & 0x7ffff;
239   int color = (state->bg_videoram[tile_index]>>28) & 0xf;
232240   SET_TILE_INFO(0,tile,color,0);
233241}
234242
235243static TILE_GET_INFO( get_md_tile_info )
236244{
237   int tile  = md_videoram[tile_index] & 0x7ffff;
238   int color = (md_videoram[tile_index]>>28) & 0xf;
245   limenko_state *state = machine->driver_data<limenko_state>();
246   int tile  = state->md_videoram[tile_index] & 0x7ffff;
247   int color = (state->md_videoram[tile_index]>>28) & 0xf;
239248   SET_TILE_INFO(0,tile,color,0);
240249}
241250
242251static TILE_GET_INFO( get_fg_tile_info )
243252{
244   int tile  = fg_videoram[tile_index] & 0x7ffff;
245   int color = (fg_videoram[tile_index]>>28) & 0xf;
253   limenko_state *state = machine->driver_data<limenko_state>();
254   int tile  = state->fg_videoram[tile_index] & 0x7ffff;
255   int color = (state->fg_videoram[tile_index]>>28) & 0xf;
246256   SET_TILE_INFO(0,tile,color,0);
247257}
248258
r10886r10887
250260      UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy,
251261      int priority)
252262{
263   limenko_state *state = gfx->machine->driver_data<limenko_state>();
253264   int pal_base = gfx->color_base + gfx->color_granularity * (color % gfx->total_colors);
254265   const UINT8 *source_base = gfx_element_get_data(gfx, code % gfx->total_elements);
255266
r10886r10887
323334         {
324335            const UINT8 *source = source_base + (y_index>>16) * gfx->line_modulo;
325336            UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0);
326            UINT8 *pri = BITMAP_ADDR8(sprites_bitmap_pri, y, 0);
337            UINT8 *pri = BITMAP_ADDR8(state->sprites_bitmap_pri, y, 0);
327338
328339            int x, x_index = x_index_base;
329340            for( x=sx; x<ex; x++ )
r10886r10887
350361// sprites aren't tile based (except for 8x8 ones)
351362static void draw_sprites(running_machine *machine, UINT32 *sprites, const rectangle *cliprect, int count)
352363{
364   limenko_state *state = machine->driver_data<limenko_state>();
353365   int i;
354366
355367   UINT8 *base_gfx   = machine->region("gfx1")->base();
r10886r10887
393405      /* prepare GfxElement on the fly */
394406      gfx_element_build_temporary(&gfx, machine, gfxdata, width, height, width, 0, 256, 0);
395407
396      draw_single_sprite(sprites_bitmap,cliprect,&gfx,0,color,flipx,flipy,x,y,pri);
408      draw_single_sprite(state->sprites_bitmap,cliprect,&gfx,0,color,flipx,flipy,x,y,pri);
397409
398410      // wrap around x
399      draw_single_sprite(sprites_bitmap,cliprect,&gfx,0,color,flipx,flipy,x-512,y,pri);
411      draw_single_sprite(state->sprites_bitmap,cliprect,&gfx,0,color,flipx,flipy,x-512,y,pri);
400412
401413      // wrap around y
402      draw_single_sprite(sprites_bitmap,cliprect,&gfx,0,color,flipx,flipy,x,y-512,pri);
414      draw_single_sprite(state->sprites_bitmap,cliprect,&gfx,0,color,flipx,flipy,x,y-512,pri);
403415
404416      // wrap around x and y
405      draw_single_sprite(sprites_bitmap,cliprect,&gfx,0,color,flipx,flipy,x-512,y-512,pri);
417      draw_single_sprite(state->sprites_bitmap,cliprect,&gfx,0,color,flipx,flipy,x-512,y-512,pri);
406418   }
407419}
408420
409static void copy_sprites(bitmap_t *bitmap, bitmap_t *sprites_bitmap, bitmap_t *priority_bitmap, const rectangle *cliprect)
421static void copy_sprites(running_machine *machine, bitmap_t *bitmap, bitmap_t *sprites_bitmap, bitmap_t *priority_bitmap, const rectangle *cliprect)
410422{
423   limenko_state *state = machine->driver_data<limenko_state>();
411424   int y;
412425   for( y=cliprect->min_y; y<=cliprect->max_y; y++ )
413426   {
414427      UINT16 *source = BITMAP_ADDR16(sprites_bitmap, y, 0);
415428      UINT16 *dest = BITMAP_ADDR16(bitmap, y, 0);
416429      UINT8 *dest_pri = BITMAP_ADDR8(priority_bitmap, y, 0);
417      UINT8 *source_pri = BITMAP_ADDR8(sprites_bitmap_pri, y, 0);
430      UINT8 *source_pri = BITMAP_ADDR8(state->sprites_bitmap_pri, y, 0);
418431
419432      int x;
420433      for( x=cliprect->min_x; x<=cliprect->max_x; x++ )
r10886r10887
430443
431444static VIDEO_START( limenko )
432445{
433   bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_rows,8,8,128,64);
434   md_tilemap = tilemap_create(machine, get_md_tile_info,tilemap_scan_rows,8,8,128,64);
435   fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows,8,8,128,64);
446   limenko_state *state = machine->driver_data<limenko_state>();
447   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_rows,8,8,128,64);
448   state->md_tilemap = tilemap_create(machine, get_md_tile_info,tilemap_scan_rows,8,8,128,64);
449   state->fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows,8,8,128,64);
436450
437   tilemap_set_transparent_pen(md_tilemap,0);
438   tilemap_set_transparent_pen(fg_tilemap,0);
451   tilemap_set_transparent_pen(state->md_tilemap,0);
452   tilemap_set_transparent_pen(state->fg_tilemap,0);
439453
440   sprites_bitmap     = auto_bitmap_alloc(machine,384,240,BITMAP_FORMAT_INDEXED16);
441   sprites_bitmap_pri = auto_bitmap_alloc(machine,384,240,BITMAP_FORMAT_INDEXED8);
454   state->sprites_bitmap     = auto_bitmap_alloc(machine,384,240,BITMAP_FORMAT_INDEXED16);
455   state->sprites_bitmap_pri = auto_bitmap_alloc(machine,384,240,BITMAP_FORMAT_INDEXED8);
442456}
443457
444458static SCREEN_UPDATE( limenko )
445459{
446   // limenko_videoreg[4] ???? It always has this value: 0xffeffff8 (2 signed bytes? values: -17 and -8 ?)
460   limenko_state *state = screen->machine->driver_data<limenko_state>();
461   // state->videoreg[4] ???? It always has this value: 0xffeffff8 (2 signed bytes? values: -17 and -8 ?)
447462
448463   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
449464
450   tilemap_set_enable(bg_tilemap, limenko_videoreg[0] & 4);
451   tilemap_set_enable(md_tilemap, limenko_videoreg[0] & 2);
452   tilemap_set_enable(fg_tilemap, limenko_videoreg[0] & 1);
465   tilemap_set_enable(state->bg_tilemap, state->videoreg[0] & 4);
466   tilemap_set_enable(state->md_tilemap, state->videoreg[0] & 2);
467   tilemap_set_enable(state->fg_tilemap, state->videoreg[0] & 1);
453468
454   tilemap_set_scrolly(bg_tilemap, 0, limenko_videoreg[3] & 0xffff);
455   tilemap_set_scrolly(md_tilemap, 0, limenko_videoreg[2] & 0xffff);
456   tilemap_set_scrolly(fg_tilemap, 0, limenko_videoreg[1] & 0xffff);
469   tilemap_set_scrolly(state->bg_tilemap, 0, state->videoreg[3] & 0xffff);
470   tilemap_set_scrolly(state->md_tilemap, 0, state->videoreg[2] & 0xffff);
471   tilemap_set_scrolly(state->fg_tilemap, 0, state->videoreg[1] & 0xffff);
457472
458   tilemap_set_scrollx(bg_tilemap, 0, (limenko_videoreg[3] & 0xffff0000) >> 16);
459   tilemap_set_scrollx(md_tilemap, 0, (limenko_videoreg[2] & 0xffff0000) >> 16);
460   tilemap_set_scrollx(fg_tilemap, 0, (limenko_videoreg[1] & 0xffff0000) >> 16);
473   tilemap_set_scrollx(state->bg_tilemap, 0, (state->videoreg[3] & 0xffff0000) >> 16);
474   tilemap_set_scrollx(state->md_tilemap, 0, (state->videoreg[2] & 0xffff0000) >> 16);
475   tilemap_set_scrollx(state->fg_tilemap, 0, (state->videoreg[1] & 0xffff0000) >> 16);
461476
462   tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
463   tilemap_draw(bitmap,cliprect,md_tilemap,0,0);
464   tilemap_draw(bitmap,cliprect,fg_tilemap,0,1);
477   tilemap_draw(bitmap,cliprect,state->bg_tilemap,0,0);
478   tilemap_draw(bitmap,cliprect,state->md_tilemap,0,0);
479   tilemap_draw(bitmap,cliprect,state->fg_tilemap,0,1);
465480
466   if(limenko_videoreg[0] & 8)
467      copy_sprites(bitmap, sprites_bitmap, screen->machine->priority_bitmap, cliprect);
481   if(state->videoreg[0] & 8)
482      copy_sprites(screen->machine, bitmap, state->sprites_bitmap, screen->machine->priority_bitmap, cliprect);
468483
469484   return 0;
470485}
r10886r10887
981996
982997static READ32_HANDLER( dynabomb_speedup_r )
983998{
999   limenko_state *state = space->machine->driver_data<limenko_state>();
9841000   if(space->machine->firstcpu->pc() == 0xc25b8)
9851001   {
9861002      space->machine->firstcpu->eat_cycles(50);
9871003   }
9881004
989   return mainram[0xe2784/4];
1005   return state->mainram[0xe2784/4];
9901006}
9911007
9921008static READ32_HANDLER( legendoh_speedup_r )
9931009{
1010   limenko_state *state = space->machine->driver_data<limenko_state>();
9941011   if(space->machine->firstcpu->pc() == 0x23e32)
9951012   {
9961013      space->machine->firstcpu->eat_cycles(50);
9971014   }
9981015
999   return mainram[0x32ab0/4];
1016   return state->mainram[0x32ab0/4];
10001017}
10011018
10021019static READ32_HANDLER( sb2003_speedup_r )
10031020{
1021   limenko_state *state = space->machine->driver_data<limenko_state>();
10041022   if(space->machine->firstcpu->pc() == 0x26da4)
10051023   {
10061024      space->machine->firstcpu->eat_cycles(50);
10071025   }
10081026
1009   return mainram[0x135800/4];
1027   return state->mainram[0x135800/4];
10101028}
10111029
10121030static READ32_HANDLER( spotty_speedup_r )
10131031{
1032   limenko_state *state = space->machine->driver_data<limenko_state>();
10141033   if(space->machine->firstcpu->pc() == 0x8560)
10151034   {
10161035      space->machine->firstcpu->eat_cycles(50);
10171036   }
10181037
1019   return mainram[0x6626c/4];
1038   return state->mainram[0x6626c/4];
10201039}
10211040
10221041static DRIVER_INIT( dynabomb )
10231042{
1043   limenko_state *state = machine->driver_data<limenko_state>();
10241044   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xe2784, 0xe2787, 0, 0, dynabomb_speedup_r );
10251045
1026   spriteram_bit = 1;
1046   state->spriteram_bit = 1;
10271047}
10281048
10291049static DRIVER_INIT( legendoh )
10301050{
1051   limenko_state *state = machine->driver_data<limenko_state>();
10311052   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x32ab0, 0x32ab3, 0, 0, legendoh_speedup_r );
10321053
1033   spriteram_bit = 1;
1054   state->spriteram_bit = 1;
10341055}
10351056
10361057static DRIVER_INIT( sb2003 )
10371058{
1059   limenko_state *state = machine->driver_data<limenko_state>();
10381060   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x135800, 0x135803, 0, 0, sb2003_speedup_r );
10391061
1040   spriteram_bit = 1;
1062   state->spriteram_bit = 1;
10411063}
10421064
10431065static DRIVER_INIT( spotty )
10441066{
1067   limenko_state *state = machine->driver_data<limenko_state>();
10451068   UINT8 *dst    = machine->region("gfx1")->base();
10461069   UINT8 *src    = machine->region("user2")->base();
10471070   int x;
r10886r10887
10571080
10581081   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x6626c, 0x6626f, 0, 0, spotty_speedup_r );
10591082
1060   spriteram_bit = 1;
1083   state->spriteram_bit = 1;
10611084}
10621085
10631086GAME( 2000, dynabomb, 0,      limenko, sb2003,   dynabomb, ROT0, "Limenko", "Dynamite Bomber (Korea, Rev 1.5)",   GAME_NO_SOUND )
src/mame/drivers/poo.c
r10886r10887
4545#include "cpu/z80/z80.h"
4646#include "sound/ay8910.h"
4747
48static UINT8 *poo_vram, *poo_scrolly, *poo_sprites;
49static UINT8 vram_colbank;
5048
49class poo_state : public driver_device
50{
51public:
52   poo_state(running_machine &machine, const driver_device_config_base &config)
53      : driver_device(machine, config) { }
54
55   UINT8 *vram;
56   UINT8 *scrolly;
57   UINT8 *sprites;
58   UINT8 vram_colbank;
59};
60
61
5162static VIDEO_START(unclepoo)
5263{
53
5464}
5565
5666static SCREEN_UPDATE(unclepoo)
5767{
68   poo_state *state = screen->machine->driver_data<poo_state>();
5869   int y,x;
5970   int count;
6071   const gfx_element *gfx = screen->machine->gfx[0];
r10886r10887
6576   {
6677      for (y=0;y<32;y++)
6778      {
68         int tile = poo_vram[count+0x000] | ((poo_vram[count+0x400] & 3) <<8);
69         int color = (poo_vram[count+0x400] & 0x38) >> 3;
70         int scrolly = (poo_scrolly[x*4]);
79         int tile = state->vram[count+0x000] | ((state->vram[count+0x400] & 3) <<8);
80         int color = (state->vram[count+0x400] & 0x38) >> 3;
81         int scrolly = (state->scrolly[x*4]);
7182
72         drawgfx_opaque(bitmap,cliprect,gfx,tile,color+vram_colbank,0,0,x*8,256-(y*8)+scrolly);
73         drawgfx_opaque(bitmap,cliprect,gfx,tile,color+vram_colbank,0,0,x*8,0-(y*8)+scrolly);
83         drawgfx_opaque(bitmap,cliprect,gfx,tile,color+state->vram_colbank,0,0,x*8,256-(y*8)+scrolly);
84         drawgfx_opaque(bitmap,cliprect,gfx,tile,color+state->vram_colbank,0,0,x*8,0-(y*8)+scrolly);
7485
7586         count++;
7687      }
r10886r10887
8192
8293      for(i=0;i<0x80;i+=4)
8394      {
84         spr_offs = poo_sprites[i+2] | (poo_sprites[i+3] & 3) << 8;
85         y = poo_sprites[i+0]+8;
86         x = poo_sprites[i+1];
87         col = (poo_sprites[i+3] & 0xf8) >> 3;
95         spr_offs = state->sprites[i+2] | (state->sprites[i+3] & 3) << 8;
96         y = state->sprites[i+0]+8;
97         x = state->sprites[i+1];
98         col = (state->sprites[i+3] & 0xf8) >> 3;
8899         fx = 0;
89100         fy = 0;
90101
r10886r10887
130141
131142static WRITE8_HANDLER( poo_vregs_w )
132143{
144   poo_state *state = space->machine->driver_data<poo_state>();
133145   // bit 2 used, unknown purpose
134   vram_colbank = data & 0x18;
146   state->vram_colbank = data & 0x18;
135147}
136148
137149static ADDRESS_MAP_START( unclepoo_main_map, ADDRESS_SPACE_PROGRAM, 8 )
r10886r10887
140152   AM_RANGE(0x9000, 0x97ff) AM_RAM
141153   AM_RANGE(0x9800, 0x9801) AM_READ(unk_inp_r) //AM_WRITE( unk_w )
142154
143   AM_RANGE(0xb000, 0xb07f) AM_RAM AM_BASE(&poo_sprites)
144   AM_RANGE(0xb080, 0xb0ff) AM_RAM AM_BASE(&poo_scrolly)
155   AM_RANGE(0xb000, 0xb07f) AM_RAM AM_BASE_MEMBER(poo_state, sprites)
156   AM_RANGE(0xb080, 0xb0ff) AM_RAM AM_BASE_MEMBER(poo_state, scrolly)
145157
146158   AM_RANGE(0xb400, 0xb400) AM_WRITE(sound_cmd_w)
147159
r10886r10887
153165
154166   AM_RANGE(0xb700, 0xb700) AM_WRITE(poo_vregs_w)
155167
156   AM_RANGE(0xb800, 0xbfff) AM_RAM AM_BASE(&poo_vram)
168   AM_RANGE(0xb800, 0xbfff) AM_RAM AM_BASE_MEMBER(poo_state, vram)
157169
158170ADDRESS_MAP_END
159171
r10886r10887
310322   DEVCB_NULL
311323};
312324
313static MACHINE_CONFIG_START( unclepoo, driver_device )
325static MACHINE_CONFIG_START( unclepoo, poo_state )
314326   /* basic machine hardware */
315327   MCFG_CPU_ADD("maincpu", Z80,18000000/6)       /* ? MHz */
316328   MCFG_CPU_PROGRAM_MAP(unclepoo_main_map)
src/mame/drivers/galaxian.c
r10886r10887
26192619   irq_line = INPUT_LINE_NMI;
26202620   galaxian_frogger_adjust = FALSE;
26212621   galaxian_sfx_tilemap = FALSE;
2622   galaxian_sprite_clip_start = 16;
2623   galaxian_sprite_clip_end = 255;
26242622   galaxian_draw_bullet_ptr = (draw_bullet != NULL) ? draw_bullet : galaxian_draw_bullet;
26252623   galaxian_draw_background_ptr = (draw_background != NULL) ? draw_background : galaxian_draw_background;
26262624   galaxian_extend_tile_info_ptr = extend_tile_info;
r10886r10887
27912789
27922790   /* ...but coin lockout disabled/disconnected */
27932791   memory_install_write8_handler(space, 0x6002, 0x6002, 0, 0x7f8, (write8_space_func)artic_gfxbank_w);
2794
2795   /* also shift the sprite clip offset */
2796   galaxian_sprite_clip_start = 7;
2797   galaxian_sprite_clip_end = 246;
27982792}
27992793
28002794static READ8_HANDLER( tenspot_dsw_read )
src/mame/drivers/dgpix.c
r10886r10887
5252#include "emu.h"
5353#include "cpu/e132xs/e132xs.h"
5454
55static UINT32 *vram;
56static int vbuffer = 0;
5755
58static int flash_roms;
59static int old_vbuf;
60static UINT32 flash_cmd = 0;
61static INT32 first_offset;
56class dgpix_state : public driver_device
57{
58public:
59   dgpix_state(running_machine &machine, const driver_device_config_base &config)
60      : driver_device(machine, config) { }
6261
62   UINT32 *vram;
63   int vbuffer;
64   int flash_roms;
65   int old_vbuf;
66   UINT32 flash_cmd;
67   INT32 first_offset;
68};
69
70
6371static READ32_HANDLER( flash_r )
6472{
73   dgpix_state *state = space->machine->driver_data<dgpix_state>();
6574   UINT32 *ROM = (UINT32 *)space->machine->region("user1")->base();
6675
67   if(offset >= (0x2000000 - flash_roms * 0x400000) / 4)
76   if(offset >= (0x2000000 - state->flash_roms * 0x400000) / 4)
6877   {
69      if(flash_cmd == 0x90900000)
78      if(state->flash_cmd == 0x90900000)
7079      {
7180         //read maker ID and chip ID
7281         return 0x00890014;
7382      }
74      else if(flash_cmd == 0x00700000)
83      else if(state->flash_cmd == 0x00700000)
7584      {
7685         //read status
7786         return 0x80<<16;
7887      }
79      else if(flash_cmd == 0x70700000)
88      else if(state->flash_cmd == 0x70700000)
8089      {
8190         //read status and ?
8291         return 0x82<<16;
8392      }
84      else if(flash_cmd == 0xe8e80000)
93      else if(state->flash_cmd == 0xe8e80000)
8594      {
8695         //read status ?
8796         return 0x80<<16;
r10886r10887
93102
94103static WRITE32_HANDLER( flash_w )
95104{
96   if(flash_cmd == 0x20200000)
105   dgpix_state *state = space->machine->driver_data<dgpix_state>();
106   if(state->flash_cmd == 0x20200000)
97107   {
98108      // erase game settings
99109      if(data == 0xd0d00000)
r10886r10887
104114         // erase one block
105115         memset(rom, 0xff, 0x10000);
106116
107         flash_cmd = 0;
117         state->flash_cmd = 0;
108118      }
109119   }
110   else if(flash_cmd == 0x0f0f0000)
120   else if(state->flash_cmd == 0x0f0f0000)
111121   {
112      if(data == 0xd0d00000 && offset == first_offset)
122      if(data == 0xd0d00000 && offset == state->first_offset)
113123      {
114124         // finished
115         flash_cmd = 0;
116         first_offset = -1;
125         state->flash_cmd = 0;
126         state->first_offset = -1;
117127      }
118128      else
119129      {
r10886r10887
129139   }
130140   else
131141   {
132      flash_cmd = data;
142      state->flash_cmd = data;
133143
134      if(flash_cmd == 0x0f0f0000 && first_offset == -1)
144      if(state->flash_cmd == 0x0f0f0000 && state->first_offset == -1)
135145      {
136         first_offset = offset;
146         state->first_offset = offset;
137147      }
138148   }
139149}
140150
141151static WRITE32_HANDLER( vram_w )
142152{
143   UINT32 *dest = &vram[offset+(0x40000/4)*vbuffer];
153   dgpix_state *state = space->machine->driver_data<dgpix_state>();
154   UINT32 *dest = &state->vram[offset+(0x40000/4)*state->vbuffer];
144155
145156   if (mem_mask == 0xffffffff)
146157   {
r10886r10887
157168
158169static READ32_HANDLER( vram_r )
159170{
160   return vram[offset+(0x40000/4)*vbuffer];
171   dgpix_state *state = space->machine->driver_data<dgpix_state>();
172   return state->vram[offset+(0x40000/4)*state->vbuffer];
161173}
162174
163175static WRITE32_HANDLER( vbuffer_w )
164176{
165   if(old_vbuf == 3 && (data & 3) == 2)
177   dgpix_state *state = space->machine->driver_data<dgpix_state>();
178   if(state->old_vbuf == 3 && (data & 3) == 2)
166179   {
167      vbuffer ^= 1;
180      state->vbuffer ^= 1;
168181   }
169182
170   old_vbuf = data & 3;
183   state->old_vbuf = data & 3;
171184}
172185
173186static WRITE32_HANDLER( coin_w )
r10886r10887
268281
269282static VIDEO_START( dgpix )
270283{
271   vram = auto_alloc_array(machine, UINT32, 0x40000*2/4);
284   dgpix_state *state = machine->driver_data<dgpix_state>();
285   state->vram = auto_alloc_array(machine, UINT32, 0x40000*2/4);
272286}
273287
274288static SCREEN_UPDATE( dgpix )
275289{
290   dgpix_state *state = screen->machine->driver_data<dgpix_state>();
276291   int y;
277292
278293   for (y = 0; y < 240; y++)
279294   {
280295      int x;
281      UINT32 *src = &vram[(vbuffer ? 0 : 0x10000) | (y << 8)];
296      UINT32 *src = &state->vram[(state->vbuffer ? 0 : 0x10000) | (y << 8)];
282297      UINT16 *dest = BITMAP_ADDR16(bitmap, y, 0);
283298
284299      for (x = 0; x < 320; x += 2)
r10886r10887
296311
297312static MACHINE_RESET( dgpix )
298313{
299   vbuffer = 0;
300   flash_cmd = 0;
301   first_offset = -1;
302   old_vbuf = 3;
314   dgpix_state *state = machine->driver_data<dgpix_state>();
315   state->vbuffer = 0;
316   state->flash_cmd = 0;
317   state->first_offset = -1;
318   state->old_vbuf = 3;
303319}
304320
305321
306static MACHINE_CONFIG_START( dgpix, driver_device )
322static MACHINE_CONFIG_START( dgpix, dgpix_state )
307323   MCFG_CPU_ADD("maincpu", E132XT, 20000000*4)   /* 4x internal multiplier */
308324   MCFG_CPU_PROGRAM_MAP(cpu_map)
309325   MCFG_CPU_IO_MAP(io_map)
r10886r10887
556572
557573static DRIVER_INIT( xfiles )
558574{
575   dgpix_state *state = machine->driver_data<dgpix_state>();
559576   UINT8 *rom = (UINT8 *)machine->region("user1")->base() + 0x1c00000;
560577
561578   rom[BYTE4_XOR_BE(0x3aa92e)] = 3;
r10886r10887
568585//  protection related ?
569586//  memory_nop_read(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xf0c8b440, 0xf0c8b447, 0, 0);
570587
571   flash_roms = 2;
588   state->flash_roms = 2;
572589}
573590
574591static DRIVER_INIT( kdynastg )
575592{
593   dgpix_state *state = machine->driver_data<dgpix_state>();
576594   UINT8 *rom = (UINT8 *)machine->region("user1")->base() + 0x1c00000;
577595
578596   rom[BYTE4_XOR_BE(0x3aaa10)] = 3; // 129f0 - nopped call
r10886r10887
588606//  protection related ?
589607//  memory_nop_read(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x12341234, 0x12341243, 0, 0);
590608
591   flash_roms = 4;
609   state->flash_roms = 4;
592610}
593611
594612static DRIVER_INIT( fmaniac3 )
595613{
596   flash_roms = 2;
614   dgpix_state *state = machine->driver_data<dgpix_state>();
615   state->flash_roms = 2;
597616}
598617
599618GAME( 1999, xfiles,   0, dgpix, dgpix, xfiles,   ROT0, "dgPIX Entertainment Inc.", "X-Files",                           GAME_NO_SOUND )
src/mame/drivers/pachifev.c
r10886r10887
8989class pachifev_state : public driver_device
9090{
9191public:
92    pachifev_state(running_machine &machine, const driver_device_config_base &config)
92   pachifev_state(running_machine &machine, const driver_device_config_base &config)
9393      : driver_device(machine, config) { }
9494
95 /* controls related */
95   /* controls related */
96   int power;
97   int max_power;
98   int input_power;
99   int previous_power;
100   int cnt;
96101
97 int power;
98 int max_power;
99 int input_power;
100 int previous_power;
101 int cnt;
102
102   UINT32 adpcm_pos;
103   UINT8 adpcm_idle;
104   UINT8 trigger;
105   UINT8 adpcm_data;
103106};
104107
105108static WRITE8_HANDLER(controls_w)
r10886r10887
244247
245248#if USE_MSM
246249
247static UINT32 adpcm_pos;
248static UINT8 adpcm_idle=0;
249250
250251static void pf_adpcm_int(device_t *device)
251252{
252    static UINT8 trigger,adpcm_data;
253   pachifev_state *state = device->machine->driver_data<pachifev_state>();
253254
254    if (adpcm_pos >= 0x4000 || adpcm_idle)
255    if (state->adpcm_pos >= 0x4000 || state->adpcm_idle)
255256    {
256        adpcm_idle = 1;
257        state->adpcm_idle = 1;
257258        msm5205_reset_w(device,1);
258        trigger = 0;
259        state->trigger = 0;
259260    }
260261    else
261262    {
262263        UINT8 *ROM = device->machine->region("adpcm")->base();
263264
264        adpcm_data = ((trigger ? (ROM[adpcm_pos] & 0x0f) : (ROM[adpcm_pos] & 0xf0)>>4) );
265        msm5205_data_w(device,adpcm_data & 0xf);
266        trigger^=1;
267        if(trigger == 0)
265        state->adpcm_data = ((state->trigger ? (ROM[state->adpcm_pos] & 0x0f) : (ROM[state->adpcm_pos] & 0xf0)>>4) );
266        msm5205_data_w(device,state->adpcm_data & 0xf);
267        state->trigger^=1;
268        if(state->trigger == 0)
268269        {
269            adpcm_pos++;
270            if((ROM[adpcm_pos] & 0xff) == 0xff)
271              adpcm_idle = 1;
270            state->adpcm_pos++;
271            if((ROM[state->adpcm_pos] & 0xff) == 0xff)
272              state->adpcm_idle = 1;
272273        }
273274    }
274275}
r10886r10887
292293    state->cnt=0;
293294
294295#if USE_MSM
295    adpcm_pos = 0;
296    state->adpcm_pos = 0;
296297#endif
297298}
298299
src/mame/drivers/pcat_nit.c
r10886r10887
9191#include "video/pc_vga.h"
9292#include "video/pc_video.h"
9393
94static UINT8 *banked_nvram;
9594
95class pcat_nit_state : public driver_device
96{
97public:
98   pcat_nit_state(running_machine &machine, const driver_device_config_base &config)
99      : driver_device(machine, config) { }
100
101   UINT8 *banked_nvram;
102};
103
104
96105static void pcat_nit_microtouch_tx_callback(running_machine *machine, UINT8 data)
97106{
98107   ins8250_receive(machine->device("ns16450_0"), data);
r10886r10887
126135
127136static WRITE8_HANDLER(pcat_nit_rombank_w)
128137{
138   pcat_nit_state *state = space->machine->driver_data<pcat_nit_state>();
129139   logerror( "rom bank #%02x at PC=%08X\n", data, cpu_get_pc(space->cpu) );
130140   if ( data & 0x40 )
131141   {
r10886r10887
149159
150160      memory_install_readwrite_bank(space, 0x000d8000, 0x000d9fff, 0, 0, "nvrambank" );
151161
152      memory_set_bankptr(space->machine, "nvrambank", banked_nvram);
162      memory_set_bankptr(space->machine, "nvrambank", state->banked_nvram);
153163
154164   }
155165}
r10886r10887
223233   microtouch_init(machine, pcat_nit_microtouch_tx_callback, NULL);
224234}
225235
226static MACHINE_CONFIG_START( pcat_nit, driver_device )
236static MACHINE_CONFIG_START( pcat_nit, pcat_nit_state )
227237   /* basic machine hardware */
228238   MCFG_CPU_ADD("maincpu", I386, 14318180*2)   /* I386 ?? Mhz */
229239   MCFG_CPU_PROGRAM_MAP(pcat_map)
r10886r10887
379389
380390static DRIVER_INIT(pcat_nit)
381391{
382   banked_nvram = auto_alloc_array(machine, UINT8, 0x2000);
392   pcat_nit_state *state = machine->driver_data<pcat_nit_state>();
393   state->banked_nvram = auto_alloc_array(machine, UINT8, 0x2000);
383394
384395   pc_vga_init(machine, &vga_interface, NULL);
385396}
src/mame/drivers/magic10.c
r10886r10887
8484#include "sgsafari.lh"
8585#include "musicsrt.lh"
8686
87static tilemap_t *layer0_tilemap, *layer1_tilemap, *layer2_tilemap;
88static UINT16 *layer0_videoram, *layer1_videoram, *layer2_videoram;
89static int layer2_offset[2];
90static UINT16 *magic10_vregs;
9187
88class magic10_state : public driver_device
89{
90public:
91   magic10_state(running_machine &machine, const driver_device_config_base &config)
92      : driver_device(machine, config) { }
9293
94   tilemap_t *layer0_tilemap;
95   tilemap_t *layer1_tilemap;
96   tilemap_t *layer2_tilemap;
97   UINT16 *layer0_videoram;
98   UINT16 *layer1_videoram;
99   UINT16 *layer2_videoram;
100   int layer2_offset[2];
101   UINT16 *vregs;
102   UINT16 magic102_ret;
103};
104
105
93106/***************************
94107*      Video Hardware      *
95108***************************/
96109
97110static WRITE16_HANDLER( layer0_videoram_w )
98111{
99   COMBINE_DATA(&layer0_videoram[offset]);
100   tilemap_mark_tile_dirty( layer0_tilemap, offset >> 1);
112   magic10_state *state = space->machine->driver_data<magic10_state>();
113   COMBINE_DATA(&state->layer0_videoram[offset]);
114   tilemap_mark_tile_dirty( state->layer0_tilemap, offset >> 1);
101115}
102116
103117static WRITE16_HANDLER( layer1_videoram_w )
104118{
105   COMBINE_DATA(&layer1_videoram[offset]);
106   tilemap_mark_tile_dirty( layer1_tilemap, offset >> 1);
119   magic10_state *state = space->machine->driver_data<magic10_state>();
120   COMBINE_DATA(&state->layer1_videoram[offset]);
121   tilemap_mark_tile_dirty( state->layer1_tilemap, offset >> 1);
107122}
108123
109124static WRITE16_HANDLER( layer2_videoram_w )
110125{
111   COMBINE_DATA(&layer2_videoram[offset]);
112   tilemap_mark_tile_dirty( layer2_tilemap, offset >> 1);
126   magic10_state *state = space->machine->driver_data<magic10_state>();
127   COMBINE_DATA(&state->layer2_videoram[offset]);
128   tilemap_mark_tile_dirty( state->layer2_tilemap, offset >> 1);
113129}
114130
115131static WRITE16_HANDLER( paletteram_w )
r10886r10887
121137
122138static TILE_GET_INFO( get_layer0_tile_info )
123139{
140   magic10_state *state = machine->driver_data<magic10_state>();
124141   SET_TILE_INFO
125142   (
126143      1,
127      layer0_videoram[tile_index * 2],
128      layer0_videoram[tile_index * 2 + 1] & 0x0f,
129      TILE_FLIPYX((layer0_videoram[tile_index * 2 + 1] & 0xc0) >> 6)
144      state->layer0_videoram[tile_index * 2],
145      state->layer0_videoram[tile_index * 2 + 1] & 0x0f,
146      TILE_FLIPYX((state->layer0_videoram[tile_index * 2 + 1] & 0xc0) >> 6)
130147   );
131148}
132149
133150static TILE_GET_INFO( get_layer1_tile_info )
134151{
152   magic10_state *state = machine->driver_data<magic10_state>();
135153   SET_TILE_INFO
136154   (
137155      1,
138      layer1_videoram[tile_index * 2],
139      layer1_videoram[tile_index * 2 + 1] & 0x0f,
140      TILE_FLIPYX((layer1_videoram[tile_index * 2 + 1] & 0xc0) >> 6)
156      state->layer1_videoram[tile_index * 2],
157      state->layer1_videoram[tile_index * 2 + 1] & 0x0f,
158      TILE_FLIPYX((state->layer1_videoram[tile_index * 2 + 1] & 0xc0) >> 6)
141159   );
142160}
143161
144162static TILE_GET_INFO( get_layer2_tile_info )
145163{
164   magic10_state *state = machine->driver_data<magic10_state>();
146165   SET_TILE_INFO
147166   (
148167      0,
149      layer2_videoram[tile_index * 2],
150      layer2_videoram[tile_index * 2 + 1] & 0x0f,
168      state->layer2_videoram[tile_index * 2],
169      state->layer2_videoram[tile_index * 2 + 1] & 0x0f,
151170      0
152171   );
153172}
r10886r10887
155174
156175static VIDEO_START( magic10 )
157176{
158   layer0_tilemap = tilemap_create(machine, get_layer0_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
159   layer1_tilemap = tilemap_create(machine, get_layer1_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
160   layer2_tilemap = tilemap_create(machine, get_layer2_tile_info, tilemap_scan_rows, 8, 8, 64, 64);
177   magic10_state *state = machine->driver_data<magic10_state>();
178   state->layer0_tilemap = tilemap_create(machine, get_layer0_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
179   state->layer1_tilemap = tilemap_create(machine, get_layer1_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
180   state->layer2_tilemap = tilemap_create(machine, get_layer2_tile_info, tilemap_scan_rows, 8, 8, 64, 64);
161181
162   tilemap_set_transparent_pen(layer1_tilemap, 0);
163   tilemap_set_transparent_pen(layer2_tilemap, 0);
182   tilemap_set_transparent_pen(state->layer1_tilemap, 0);
183   tilemap_set_transparent_pen(state->layer2_tilemap, 0);
164184}
165185
166186static SCREEN_UPDATE( magic10 )
167187{
188   magic10_state *state = screen->machine->driver_data<magic10_state>();
168189   /*TODO: understand where this comes from. */
169   tilemap_set_scrollx(layer2_tilemap, 0, layer2_offset[0]);
170   tilemap_set_scrolly(layer2_tilemap, 0, layer2_offset[1]);
190   tilemap_set_scrollx(state->layer2_tilemap, 0, state->layer2_offset[0]);
191   tilemap_set_scrolly(state->layer2_tilemap, 0, state->layer2_offset[1]);
171192
172193   /*
173194    4 and 6 are y/x global register writes.
174195    0 and 2 are y/x writes for the scrolling layer.
175196    */
176   tilemap_set_scrolly(layer1_tilemap, 0, (magic10_vregs[0/2] - magic10_vregs[4/2])+0);
177   tilemap_set_scrollx(layer1_tilemap, 0, (magic10_vregs[2/2] - magic10_vregs[6/2])+4);
197   tilemap_set_scrolly(state->layer1_tilemap, 0, (state->vregs[0/2] - state->vregs[4/2])+0);
198   tilemap_set_scrollx(state->layer1_tilemap, 0, (state->vregs[2/2] - state->vregs[6/2])+4);
178199
179   tilemap_draw(bitmap, cliprect, layer0_tilemap, 0, 0);
180   tilemap_draw(bitmap, cliprect, layer1_tilemap, 0, 0);
181   tilemap_draw(bitmap, cliprect, layer2_tilemap, 0, 0);
200   tilemap_draw(bitmap, cliprect, state->layer0_tilemap, 0, 0);
201   tilemap_draw(bitmap, cliprect, state->layer1_tilemap, 0, 0);
202   tilemap_draw(bitmap, cliprect, state->layer2_tilemap, 0, 0);
182203
183204   return 0;
184205}
r10886r10887
190211
191212static READ16_HANDLER( magic102_r )
192213{
193   static UINT16 ret = 0;
194   ret ^= 0x20;
195   return ret;
214   magic10_state *state = space->machine->driver_data<magic10_state>();
215   state->magic102_ret ^= 0x20;
216   return state->magic102_ret;
196217}
197218
198219static READ16_HANDLER( hotslot_copro_r )
199220{
200   static UINT16 ret = 0x0080;
201   return ret;
221   return 0x80;
202222}
203223
204224static WRITE16_HANDLER( hotslot_copro_w )
r10886r10887
264284
265285static ADDRESS_MAP_START( magic10_map, ADDRESS_SPACE_PROGRAM, 16 )
266286   AM_RANGE(0x000000, 0x03ffff) AM_ROM
267   AM_RANGE(0x100000, 0x100fff) AM_RAM_WRITE(layer1_videoram_w) AM_BASE(&layer1_videoram)
268   AM_RANGE(0x101000, 0x101fff) AM_RAM_WRITE(layer0_videoram_w) AM_BASE(&layer0_videoram)
269   AM_RANGE(0x102000, 0x103fff) AM_RAM_WRITE(layer2_videoram_w) AM_BASE(&layer2_videoram)
287   AM_RANGE(0x100000, 0x100fff) AM_RAM_WRITE(layer1_videoram_w) AM_BASE_MEMBER(magic10_state, layer1_videoram)
288   AM_RANGE(0x101000, 0x101fff) AM_RAM_WRITE(layer0_videoram_w) AM_BASE_MEMBER(magic10_state, layer0_videoram)
289   AM_RANGE(0x102000, 0x103fff) AM_RAM_WRITE(layer2_videoram_w) AM_BASE_MEMBER(magic10_state, layer2_videoram)
270290   AM_RANGE(0x200000, 0x2007ff) AM_RAM AM_SHARE("nvram")
271291   AM_RANGE(0x300000, 0x3001ff) AM_RAM_WRITE(paletteram_w) AM_BASE_GENERIC(paletteram)
272292   AM_RANGE(0x400000, 0x400001) AM_READ_PORT("INPUTS")
r10886r10887
274294   AM_RANGE(0x400008, 0x400009) AM_WRITE(magic10_out_w)
275295   AM_RANGE(0x40000a, 0x40000b) AM_DEVREADWRITE8_MODERN("oki", okim6295_device, read, write, 0x00ff)
276296   AM_RANGE(0x40000e, 0x40000f) AM_WRITENOP
277   AM_RANGE(0x400080, 0x400087) AM_RAM AM_BASE(&magic10_vregs)
297   AM_RANGE(0x400080, 0x400087) AM_RAM AM_BASE_MEMBER(magic10_state, vregs)
278298   AM_RANGE(0x600000, 0x603fff) AM_RAM
279299ADDRESS_MAP_END
280300
281301static ADDRESS_MAP_START( magic10a_map, ADDRESS_SPACE_PROGRAM, 16 )
282302   AM_RANGE(0x000000, 0x03ffff) AM_ROM
283   AM_RANGE(0x100000, 0x100fff) AM_RAM_WRITE(layer1_videoram_w) AM_BASE(&layer1_videoram)
284   AM_RANGE(0x101000, 0x101fff) AM_RAM_WRITE(layer0_videoram_w) AM_BASE(&layer0_videoram)
285   AM_RANGE(0x102000, 0x103fff) AM_RAM_WRITE(layer2_videoram_w) AM_BASE(&layer2_videoram)
303   AM_RANGE(0x100000, 0x100fff) AM_RAM_WRITE(layer1_videoram_w) AM_BASE_MEMBER(magic10_state, layer1_videoram)
304   AM_RANGE(0x101000, 0x101fff) AM_RAM_WRITE(layer0_videoram_w) AM_BASE_MEMBER(magic10_state, layer0_videoram)
305   AM_RANGE(0x102000, 0x103fff) AM_RAM_WRITE(layer2_videoram_w) AM_BASE_MEMBER(magic10_state, layer2_videoram)
286306   AM_RANGE(0x200000, 0x2007ff) AM_RAM AM_SHARE("nvram")
287307   AM_RANGE(0x300000, 0x3001ff) AM_RAM_WRITE(paletteram_w) AM_BASE_GENERIC(paletteram)
288308   AM_RANGE(0x500000, 0x500001) AM_READ_PORT("INPUTS")
r10886r10887
290310   AM_RANGE(0x500008, 0x500009) AM_WRITE(magic10_out_w)
291311   AM_RANGE(0x50000a, 0x50000b) AM_DEVREADWRITE8_MODERN("oki", okim6295_device, read, write, 0x00ff)
292312   AM_RANGE(0x50000e, 0x50000f) AM_WRITENOP
293   AM_RANGE(0x500080, 0x500087) AM_RAM AM_BASE(&magic10_vregs)   // video registers?
313   AM_RANGE(0x500080, 0x500087) AM_RAM AM_BASE_MEMBER(magic10_state, vregs)   // video registers?
294314   AM_RANGE(0x600000, 0x603fff) AM_RAM
295315ADDRESS_MAP_END
296316
297317static ADDRESS_MAP_START( magic102_map, ADDRESS_SPACE_PROGRAM, 16 )
298318   AM_RANGE(0x000000, 0x03ffff) AM_ROM
299   AM_RANGE(0x100000, 0x100fff) AM_RAM_WRITE(layer1_videoram_w) AM_BASE(&layer1_videoram)
300   AM_RANGE(0x101000, 0x101fff) AM_RAM_WRITE(layer0_videoram_w) AM_BASE(&layer0_videoram)
301   AM_RANGE(0x102000, 0x103fff) AM_RAM_WRITE(layer2_videoram_w) AM_BASE(&layer2_videoram)
319   AM_RANGE(0x100000, 0x100fff) AM_RAM_WRITE(layer1_videoram_w) AM_BASE_MEMBER(magic10_state, layer1_videoram)
320   AM_RANGE(0x101000, 0x101fff) AM_RAM_WRITE(layer0_videoram_w) AM_BASE_MEMBER(magic10_state, layer0_videoram)
321   AM_RANGE(0x102000, 0x103fff) AM_RAM_WRITE(layer2_videoram_w) AM_BASE_MEMBER(magic10_state, layer2_videoram)
302322   AM_RANGE(0x200000, 0x2007ff) AM_RAM AM_SHARE("nvram")
303323   AM_RANGE(0x400000, 0x4001ff) AM_RAM_WRITE(paletteram_w) AM_BASE_GENERIC(paletteram)
304324   AM_RANGE(0x500000, 0x500001) AM_READ(magic102_r)
r10886r10887
310330   AM_RANGE(0x500002, 0x50001f) AM_WRITENOP
311331   AM_RANGE(0x600000, 0x603fff) AM_RAM
312332   AM_RANGE(0x700000, 0x700001) AM_DEVREADWRITE8_MODERN("oki", okim6295_device, read, write, 0x00ff)
313   AM_RANGE(0x700080, 0x700087) AM_RAM AM_BASE(&magic10_vregs)   // video registers?
333   AM_RANGE(0x700080, 0x700087) AM_RAM AM_BASE_MEMBER(magic10_state, vregs)   // video registers?
314334ADDRESS_MAP_END
315335
316336static ADDRESS_MAP_START( hotslot_map, ADDRESS_SPACE_PROGRAM, 16 )
317337   AM_RANGE(0x000000, 0x03ffff) AM_ROM
318   AM_RANGE(0x100000, 0x100fff) AM_RAM_WRITE(layer1_videoram_w) AM_BASE(&layer1_videoram)
319   AM_RANGE(0x101000, 0x101fff) AM_RAM_WRITE(layer0_videoram_w) AM_BASE(&layer0_videoram)
320   AM_RANGE(0x102000, 0x103fff) AM_RAM_WRITE(layer2_videoram_w) AM_BASE(&layer2_videoram)
338   AM_RANGE(0x100000, 0x100fff) AM_RAM_WRITE(layer1_videoram_w) AM_BASE_MEMBER(magic10_state, layer1_videoram)
339   AM_RANGE(0x101000, 0x101fff) AM_RAM_WRITE(layer0_videoram_w) AM_BASE_MEMBER(magic10_state, layer0_videoram)
340   AM_RANGE(0x102000, 0x103fff) AM_RAM_WRITE(layer2_videoram_w) AM_BASE_MEMBER(magic10_state, layer2_videoram)
321341   AM_RANGE(0x200000, 0x2007ff) AM_RAM AM_SHARE("nvram")
322342   AM_RANGE(0x400000, 0x4001ff) AM_RAM_WRITE(paletteram_w) AM_BASE_GENERIC(paletteram)
323343   AM_RANGE(0x500004, 0x500005) AM_READWRITE(hotslot_copro_r, hotslot_copro_w)   // copro comm
r10886r10887
329349   AM_RANGE(0x50001a, 0x50001d) AM_WRITENOP
330350   AM_RANGE(0x600000, 0x603fff) AM_RAM
331351   AM_RANGE(0x70000a, 0x70000b) AM_DEVREADWRITE8_MODERN("oki", okim6295_device, read, write, 0x00ff)
332   AM_RANGE(0x700080, 0x700087) AM_RAM AM_BASE(&magic10_vregs)
352   AM_RANGE(0x700080, 0x700087) AM_RAM AM_BASE_MEMBER(magic10_state, vregs)
333353ADDRESS_MAP_END
334354
335355static ADDRESS_MAP_START( sgsafari_map, ADDRESS_SPACE_PROGRAM, 16 )
336356   AM_RANGE(0x000000, 0x03ffff) AM_ROM
337   AM_RANGE(0x100000, 0x100fff) AM_RAM_WRITE(layer1_videoram_w) AM_BASE(&layer1_videoram)
338   AM_RANGE(0x101000, 0x101fff) AM_RAM_WRITE(layer0_videoram_w) AM_BASE(&layer0_videoram)
339   AM_RANGE(0x102000, 0x103fff) AM_RAM_WRITE(layer2_videoram_w) AM_BASE(&layer2_videoram)
357   AM_RANGE(0x100000, 0x100fff) AM_RAM_WRITE(layer1_videoram_w) AM_BASE_MEMBER(magic10_state, layer1_videoram)
358   AM_RANGE(0x101000, 0x101fff) AM_RAM_WRITE(layer0_videoram_w) AM_BASE_MEMBER(magic10_state, layer0_videoram)
359   AM_RANGE(0x102000, 0x103fff) AM_RAM_WRITE(layer2_videoram_w) AM_BASE_MEMBER(magic10_state, layer2_videoram)
340360   AM_RANGE(0x200000, 0x203fff) AM_RAM AM_SHARE("nvram")
341361   AM_RANGE(0x300000, 0x3001ff) AM_RAM_WRITE(paletteram_w) AM_BASE_GENERIC(paletteram)
342362   AM_RANGE(0x500002, 0x500003) AM_READ_PORT("DSW1")
343363   AM_RANGE(0x500008, 0x500009) AM_WRITE(magic10_out_w)
344364   AM_RANGE(0x50000a, 0x50000b) AM_DEVREADWRITE8_MODERN("oki", okim6295_device, read, write, 0x00ff)
345365   AM_RANGE(0x50000e, 0x50000f) AM_READ_PORT("IN0")
346   AM_RANGE(0x500080, 0x500087) AM_RAM AM_BASE(&magic10_vregs)   // video registers?
366   AM_RANGE(0x500080, 0x500087) AM_RAM AM_BASE_MEMBER(magic10_state, vregs)   // video registers?
347367   AM_RANGE(0x600000, 0x603fff) AM_RAM
348368ADDRESS_MAP_END
349369/*
r10886r10887
693713*      Machine Drivers      *
694714****************************/
695715
696static MACHINE_CONFIG_START( magic10, driver_device )
716static MACHINE_CONFIG_START( magic10, magic10_state )
697717   /* basic machine hardware */
698718   MCFG_CPU_ADD("maincpu", M68000, 10000000) // ?
699719   MCFG_CPU_PROGRAM_MAP(magic10_map)
r10886r10887
11841204
11851205static DRIVER_INIT( magic10 )
11861206{
1187   layer2_offset[0] = 32;
1188   layer2_offset[1] = 2;
1207   magic10_state *state = machine->driver_data<magic10_state>();
1208   state->layer2_offset[0] = 32;
1209   state->layer2_offset[1] = 2;
11891210}
11901211
11911212static DRIVER_INIT( magic102 )
11921213{
1193   layer2_offset[0] = 8;
1194   layer2_offset[1] = 20;
1214   magic10_state *state = machine->driver_data<magic10_state>();
1215   state->layer2_offset[0] = 8;
1216   state->layer2_offset[1] = 20;
11951217}
11961218
11971219static DRIVER_INIT( suprpool )
11981220{
1199   layer2_offset[0] = 8;
1200   layer2_offset[1] = 16;
1221   magic10_state *state = machine->driver_data<magic10_state>();
1222   state->layer2_offset[0] = 8;
1223   state->layer2_offset[1] = 16;
12011224}
12021225
12031226static DRIVER_INIT( hotslot )
12041227{
1228   magic10_state *state = machine->driver_data<magic10_state>();
12051229/*  a value of -56 center the playfield, but displace the intro and initial screen.
12061230    a value of -64 center the intro and initial screen, but displace the playfield.
12071231*/
1208   layer2_offset[0] = -56;   // X offset.
1209   layer2_offset[1] = 0;   // Y offset.
1232   state->layer2_offset[0] = -56;   // X offset.
1233   state->layer2_offset[1] = 0;   // Y offset.
12101234}
12111235
12121236static DRIVER_INIT( sgsafari )
12131237{
1214   layer2_offset[0] = 16;
1215   layer2_offset[1] = 20;
1238   magic10_state *state = machine->driver_data<magic10_state>();
1239   state->layer2_offset[0] = 16;
1240   state->layer2_offset[1] = 20;
12161241}
12171242
12181243
src/mame/drivers/vpoker.c
r10886r10887
119119      : driver_device(machine, config) { }
120120
121121   UINT8 *videoram;
122   UINT8 blit_ram[8];
122123};
123124
124125
r10886r10887
164165{
165166   vpoker_state *state = space->machine->driver_data<vpoker_state>();
166167   UINT8 *videoram = state->videoram;
167   static UINT8 blit_ram[8];
168168
169   blit_ram[offset] = data;
169   state->blit_ram[offset] = data;
170170
171171   if(offset == 2)
172172   {
173173      int blit_offs;
174174
175      blit_offs = (blit_ram[1] & 0x01)<<8|(blit_ram[2] & 0xff);
175      blit_offs = (state->blit_ram[1] & 0x01)<<8|(state->blit_ram[2] & 0xff);
176176
177      videoram[blit_offs] = blit_ram[0];
178//      printf("%02x %02x %02x %02x %02x %02x %02x %02x\n",blit_ram[0],blit_ram[1],blit_ram[2],blit_ram[3],blit_ram[4],blit_ram[5],blit_ram[6],blit_ram[7]);
177      videoram[blit_offs] = state->blit_ram[0];
178//      printf("%02x %02x %02x %02x %02x %02x %02x %02x\n",state->blit_ram[0],state->blit_ram[1],state->blit_ram[2],state->blit_ram[3],state->blit_ram[4],state->blit_ram[5],state->blit_ram[6],state->blit_ram[7]);
179179   }
180180}
181181
src/mame/drivers/blitz68k.c
r10886r10887
4343      : driver_device(machine, config),
4444        m_nvram(*this, "nvram") { }
4545
46   required_shared_ptr<UINT16>   m_nvram;
46   optional_shared_ptr<UINT16>   m_nvram;
47   UINT8 *blit_buffer;
48   UINT16 *frame_buffer;
49   struct { int r,g,b,offs,offs_internal; } pal;
50   struct { UINT8 r, g, b, offs, offs_internal, ram[256*3]; } btpal;
51   UINT16 *blit_romaddr;
52   UINT16 *blit_attr1_ram;
53   UINT16 *blit_dst_ram_loword;
54   UINT16 *blit_attr2_ram;
55   UINT16 *blit_dst_ram_hiword;
56   UINT16 *blit_vregs;
57   UINT16 *blit_transpen;
4758};
4859
4960/*************************************************************************************************************
r10886r10887
5263
5364*************************************************************************************************************/
5465
55static UINT8 *blit_buffer;
56
5766struct blit_t
5867{
5968   UINT8 x, y;
r10886r10887
6978
7079static VIDEO_START(blitz68k)
7180{
72   blit_buffer = auto_alloc_array(machine, UINT8, 512*256);
81   blitz68k_state *state = machine->driver_data<blitz68k_state>();
82   state->blit_buffer = auto_alloc_array(machine, UINT8, 512*256);
7383   blit.addr_factor = 2;
7484}
7585
r10886r10887
8191
8292static SCREEN_UPDATE(blitz68k)
8393{
94   blitz68k_state *state = screen->machine->driver_data<blitz68k_state>();
8495   int x,y;
8596
86   UINT8 *src = blit_buffer;
97   UINT8 *src = state->blit_buffer;
8798
8899   for(y = 0; y < 256; y++)
89100   {
r10886r10887
98109
99110// Blitter-less board (SPI-68K)
100111
101static UINT16 *frame_buffer;
102112
103113static SCREEN_UPDATE(blitz68k_noblit)
104114{
115   blitz68k_state *state = screen->machine->driver_data<blitz68k_state>();
105116   int x,y;
106117
107   UINT16 *src = frame_buffer;
118   UINT16 *src = state->frame_buffer;
108119
109120   for(y = 0; y < 256; y++)
110121   {
r10886r10887
129140
130141static WRITE16_HANDLER( paletteram_io_w )
131142{
132   static int pal_offs,r,g,b,internal_pal_offs,pal_data;
143   blitz68k_state *state = space->machine->driver_data<blitz68k_state>();
144   int pal_data;
133145
134146   switch(offset*2)
135147   {
136148      case 0:
137         pal_offs = (data & 0xff00) >> 8;
149         state->pal.offs = (data & 0xff00) >> 8;
138150         break;
139151      case 4:
140         internal_pal_offs = 0;
152         state->pal.offs_internal = 0;
141153         break;
142154      case 2:
143         switch(internal_pal_offs)
155         switch(state->pal.offs_internal)
144156         {
145157            case 0:
146158               pal_data = (data & 0xff00) >> 8;
147               r = ((pal_data & 0x3f) << 2) | ((pal_data & 0x30) >> 4);
148               internal_pal_offs++;
159               state->pal.r = ((pal_data & 0x3f) << 2) | ((pal_data & 0x30) >> 4);
160               state->pal.offs_internal++;
149161               break;
150162            case 1:
151163               pal_data = (data & 0xff00) >> 8;
152               g = ((pal_data & 0x3f) << 2) | ((pal_data & 0x30) >> 4);
153               internal_pal_offs++;
164               state->pal.g = ((pal_data & 0x3f) << 2) | ((pal_data & 0x30) >> 4);
165               state->pal.offs_internal++;
154166               break;
155167            case 2:
156168               pal_data = (data & 0xff00) >> 8;
157               b = ((pal_data & 0x3f) << 2) | ((pal_data & 0x30) >> 4);
158               palette_set_color(space->machine, pal_offs, MAKE_RGB(r, g, b));
159               internal_pal_offs = 0;
160               pal_offs++;
169               state->pal.b = ((pal_data & 0x3f) << 2) | ((pal_data & 0x30) >> 4);
170               palette_set_color(space->machine, state->pal.offs, MAKE_RGB(state->pal.r, state->pal.g, state->pal.b));
171               state->pal.offs_internal = 0;
172               state->pal.offs++;
161173               break;
162174         }
163175
r10886r10887
172184
173185*************************************************************************************************************/
174186
175static UINT8 pal_ram[256*3];
176static UINT8 pal_offs, internal_pal_offs, r, g, b;
177187
178188static WRITE8_HANDLER( paletteram_bt476_w )
179189{
190   blitz68k_state *state = space->machine->driver_data<blitz68k_state>();
180191   switch(offset)
181192   {
182193      case 0:
183         pal_offs = data;
184         internal_pal_offs = 0;
194         state->btpal.offs = data;
195         state->btpal.offs_internal = 0;
185196         break;
186197      case 2:
187         pal_offs = data;
188         internal_pal_offs = 0;
198         state->btpal.offs = data;
199         state->btpal.offs_internal = 0;
189200         break;
190201      case 1:
191202         data &= 0x3f;
192         pal_ram[pal_offs * 3 + internal_pal_offs] = data;
193         switch(internal_pal_offs)
203         state->btpal.ram[state->btpal.offs * 3 + state->btpal.offs_internal] = data;
204         switch(state->btpal.offs_internal)
194205         {
195206            case 0:
196               r = data << 2;
197               internal_pal_offs++;
207               state->btpal.r = data << 2;
208               state->btpal.offs_internal++;
198209               break;
199210            case 1:
200               g = data << 2;
201               internal_pal_offs++;
211               state->btpal.g = data << 2;
212               state->btpal.offs_internal++;
202213               break;
203214            case 2:
204               b = data << 2;
205               palette_set_color(space->machine, pal_offs, MAKE_RGB(r, g, b));
206               internal_pal_offs = 0;
207               pal_offs++;
215               state->btpal.b = data << 2;
216               palette_set_color(space->machine, state->btpal.offs, MAKE_RGB(state->btpal.r, state->btpal.g, state->btpal.b));
217               state->btpal.offs_internal = 0;
218               state->btpal.offs++;
208219               break;
209220         }
210221         break;
r10886r10887
213224
214225static READ8_HANDLER( paletteram_bt476_r )
215226{
227   blitz68k_state *state = space->machine->driver_data<blitz68k_state>();
216228   UINT8 ret = 0xff;
217229
218230   switch(offset)
219231   {
220232      case 0:
221         ret = pal_offs;
233         ret = state->btpal.offs;
222234         break;
223235
224236      case 1:
225         ret = pal_ram[pal_offs * 3 + internal_pal_offs];
226         internal_pal_offs++;
227         if (internal_pal_offs >= 3)
237         ret = state->btpal.ram[state->btpal.offs * 3 + state->btpal.offs_internal];
238         state->btpal.offs_internal++;
239         if (state->btpal.offs_internal >= 3)
228240         {
229            internal_pal_offs = 0;
230            pal_offs++;
241            state->btpal.offs_internal = 0;
242            state->btpal.offs++;
231243         }
232244         break;
233245   }
r10886r10887
252264
253265*************************************************************************************************************/
254266
255static UINT16 *blit_romaddr,*blit_attr1_ram,*blit_dst_ram_loword,*blit_attr2_ram,*blit_dst_ram_hiword,*blit_vregs,*blit_transpen;
256267
257268static WRITE16_HANDLER( blit_copy_w )
258269{
270   blitz68k_state *state = space->machine->driver_data<blitz68k_state>();
259271   UINT8 *blit_rom = space->machine->region("blitter")->base();
260272   UINT32 blit_dst_xpos;
261273   UINT32 blit_dst_ypos;
262274   int x,y,x_size,y_size;
263275   UINT32 src;
264276
265   logerror("blit copy %04x %04x %04x %04x %04x\n", blit_romaddr[0], blit_attr1_ram[0], blit_dst_ram_loword[0], blit_attr2_ram[0], blit_dst_ram_hiword[0] );
266   logerror("blit vregs %04x %04x %04x %04x\n",blit_vregs[0/2],blit_vregs[2/2],blit_vregs[4/2],blit_vregs[6/2]);
267   logerror("blit transpen %04x %04x %04x %04x %04x %04x %04x %04x\n",blit_transpen[0/2],blit_transpen[2/2],blit_transpen[4/2],blit_transpen[6/2],
268                                                                  blit_transpen[8/2],blit_transpen[10/2],blit_transpen[12/2],blit_transpen[14/2]);
277   logerror("blit copy %04x %04x %04x %04x %04x\n", state->blit_romaddr[0], state->blit_attr1_ram[0], state->blit_dst_ram_loword[0], state->blit_attr2_ram[0], state->blit_dst_ram_hiword[0] );
278   logerror("blit vregs %04x %04x %04x %04x\n",state->blit_vregs[0/2],state->blit_vregs[2/2],state->blit_vregs[4/2],state->blit_vregs[6/2]);
279   logerror("blit transpen %04x %04x %04x %04x %04x %04x %04x %04x\n",state->blit_transpen[0/2],state->blit_transpen[2/2],state->blit_transpen[4/2],state->blit_transpen[6/2],
280                                                                  state->blit_transpen[8/2],state->blit_transpen[10/2],state->blit_transpen[12/2],state->blit_transpen[14/2]);
269281
270   blit_dst_xpos = (blit_dst_ram_loword[0] & 0x00ff)*2;
271   blit_dst_ypos = ((blit_dst_ram_loword[0] & 0xff00)>>8);
282   blit_dst_xpos = (state->blit_dst_ram_loword[0] & 0x00ff)*2;
283   blit_dst_ypos = ((state->blit_dst_ram_loword[0] & 0xff00)>>8);
272284
273   y_size = (0x100-((blit_attr2_ram[0] & 0xff00)>>8));
274   x_size = (blit_attr2_ram[0] & 0x00ff)*2;
285   y_size = (0x100-((state->blit_attr2_ram[0] & 0xff00)>>8));
286   x_size = (state->blit_attr2_ram[0] & 0x00ff)*2;
275287
276288   /* rounding around for 0 size */
277289   if(x_size == 0) { x_size = 0x200; }
r10886r10887
279291   /* TODO: used by steaser "Game Over" msg on attract mode*/
280292//  if(y_size == 1) { y_size = 32; }
281293
282   src = blit_romaddr[0] | (blit_attr1_ram[0] & 0x1f00)<<8;
283//  src|= (blit_transpen[0xc/2] & 0x0100)<<12;
294   src = state->blit_romaddr[0] | (state->blit_attr1_ram[0] & 0x1f00)<<8;
295//  src|= (state->blit_transpen[0xc/2] & 0x0100)<<12;
284296
285297   for(y=0;y<y_size;y++)
286298   {
r10886r10887
288300      {
289301         int drawx = (blit_dst_xpos+x)&0x1ff;
290302         int drawy = (blit_dst_ypos+y)&0x0ff;
291         if(blit_transpen[0x8/2] & 0x100)
292            blit_buffer[drawy*512+drawx] = ((blit_vregs[0] & 0xf00)>>8);
303         if(state->blit_transpen[0x8/2] & 0x100)
304            state->blit_buffer[drawy*512+drawx] = ((state->blit_vregs[0] & 0xf00)>>8);
293305         else
294306         {
295307            UINT8 pen_helper;
296308
297309            pen_helper = blit_rom[src] & 0xff;
298            if(blit_transpen[0xa/2] & 0x100) //pen is opaque register
310            if(state->blit_transpen[0xa/2] & 0x100) //pen is opaque register
299311            {
300312               if(pen_helper)
301                  blit_buffer[drawy*512+drawx] = ((pen_helper & 0xff) <= 3) ? ((blit_vregs[pen_helper] & 0xf00)>>8) : blit_rom[src];
313                  state->blit_buffer[drawy*512+drawx] = ((pen_helper & 0xff) <= 3) ? ((state->blit_vregs[pen_helper] & 0xf00)>>8) : blit_rom[src];
302314            }
303315            else
304               blit_buffer[drawy*512+drawx] = ((pen_helper & 0xff) <= 3) ? ((blit_vregs[pen_helper] & 0xf00)>>8) : blit_rom[src];
316               state->blit_buffer[drawy*512+drawx] = ((pen_helper & 0xff) <= 3) ? ((state->blit_vregs[pen_helper] & 0xf00)>>8) : blit_rom[src];
305317         }
306318
307319         src++;
r10886r10887
444456
445457static WRITE8_HANDLER( blit_draw_w )
446458{
459   blitz68k_state *state = space->machine->driver_data<blitz68k_state>();
447460   UINT8 *blit_rom  = space->machine->region("blitter")->base();
448461   int blit_romsize = space->machine->region("blitter")->bytes();
449462   UINT32 blit_dst_xpos;
r10886r10887
498511            if (pen <= 3)
499512               pen = blit.pen[pen] & 0xf;
500513
501            blit_buffer[drawy * 512 + drawx] = pen;
514            state->blit_buffer[drawy * 512 + drawx] = pen;
502515         }
503516      }
504517   }
r10886r10887
590603//  AM_RANGE(0x880000, 0x880001) AM_READ(test_r)
591604
592605   AM_RANGE(0x900000, 0x900005) AM_WRITE( paletteram_io_w ) //RAMDAC
593   AM_RANGE(0x980000, 0x98000f) AM_RAM AM_BASE(&blit_transpen) //video registers for the blitter write
594   AM_RANGE(0x990000, 0x990007) AM_RAM AM_BASE(&blit_vregs) //pens
595   AM_RANGE(0x998000, 0x998001) AM_RAM AM_BASE(&blit_romaddr)
596   AM_RANGE(0x9a0000, 0x9a0001) AM_RAM AM_BASE(&blit_attr1_ram)
597   AM_RANGE(0x9a8000, 0x9a8001) AM_RAM AM_BASE(&blit_dst_ram_loword)
598   AM_RANGE(0x9b0000, 0x9b0001) AM_RAM AM_BASE(&blit_attr2_ram)
599   AM_RANGE(0x9b8000, 0x9b8001) AM_RAM_WRITE( blit_copy_w ) AM_BASE(&blit_dst_ram_hiword)
606   AM_RANGE(0x980000, 0x98000f) AM_RAM AM_BASE_MEMBER(blitz68k_state, blit_transpen) //video registers for the blitter write
607   AM_RANGE(0x990000, 0x990007) AM_RAM AM_BASE_MEMBER(blitz68k_state, blit_vregs) //pens
608   AM_RANGE(0x998000, 0x998001) AM_RAM AM_BASE_MEMBER(blitz68k_state, blit_romaddr)
609   AM_RANGE(0x9a0000, 0x9a0001) AM_RAM AM_BASE_MEMBER(blitz68k_state, blit_attr1_ram)
610   AM_RANGE(0x9a8000, 0x9a8001) AM_RAM AM_BASE_MEMBER(blitz68k_state, blit_dst_ram_loword)
611   AM_RANGE(0x9b0000, 0x9b0001) AM_RAM AM_BASE_MEMBER(blitz68k_state, blit_attr2_ram)
612   AM_RANGE(0x9b8000, 0x9b8001) AM_RAM_WRITE( blit_copy_w ) AM_BASE_MEMBER(blitz68k_state, blit_dst_ram_hiword)
600613   AM_RANGE(0x9e0000, 0x9e0001) AM_READ(blitter_status_r)
601614
602615   AM_RANGE(0xc00000, 0xc00001) AM_WRITE(lamps_w)
r10886r10887
618631
619632   AM_RANGE(0x900000, 0x900005) AM_WRITE( paletteram_io_w ) //RAMDAC
620633   AM_RANGE(0x940000, 0x940001) AM_WRITENOP //? Seems a dword write for some read, written consecutively
621   AM_RANGE(0x980000, 0x98000f) AM_RAM AM_BASE(&blit_transpen)//probably transparency pens
622   AM_RANGE(0x990000, 0x990005) AM_RAM AM_BASE(&blit_vregs)
623   AM_RANGE(0x998000, 0x998001) AM_RAM AM_BASE(&blit_romaddr)
624   AM_RANGE(0x9a0000, 0x9a0001) AM_RAM AM_BASE(&blit_attr1_ram)
625   AM_RANGE(0x9a8000, 0x9a8001) AM_RAM AM_BASE(&blit_dst_ram_loword)
626   AM_RANGE(0x9b0000, 0x9b0001) AM_RAM AM_BASE(&blit_attr2_ram)
627   AM_RANGE(0x9b8000, 0x9b8001) AM_RAM_WRITE( blit_copy_w ) AM_BASE(&blit_dst_ram_hiword)
634   AM_RANGE(0x980000, 0x98000f) AM_RAM AM_BASE_MEMBER(blitz68k_state, blit_transpen)//probably transparency pens
635   AM_RANGE(0x990000, 0x990005) AM_RAM AM_BASE_MEMBER(blitz68k_state, blit_vregs)
636   AM_RANGE(0x998000, 0x998001) AM_RAM AM_BASE_MEMBER(blitz68k_state, blit_romaddr)
637   AM_RANGE(0x9a0000, 0x9a0001) AM_RAM AM_BASE_MEMBER(blitz68k_state, blit_attr1_ram)
638   AM_RANGE(0x9a8000, 0x9a8001) AM_RAM AM_BASE_MEMBER(blitz68k_state, blit_dst_ram_loword)
639   AM_RANGE(0x9b0000, 0x9b0001) AM_RAM AM_BASE_MEMBER(blitz68k_state, blit_attr2_ram)
640   AM_RANGE(0x9b8000, 0x9b8001) AM_RAM_WRITE( blit_copy_w ) AM_BASE_MEMBER(blitz68k_state, blit_dst_ram_hiword)
628641   AM_RANGE(0x9c0002, 0x9c0003) AM_READNOP //pen control?
629642   AM_RANGE(0x9d0000, 0x9d0001) AM_READNOP //?
630643   AM_RANGE(0x9e0000, 0x9e0001) AM_READ(blitter_status_r)
r10886r10887
12311244   AM_RANGE(0x000000, 0x03ffff) AM_ROM
12321245   AM_RANGE(0x200000, 0x20ffff) AM_RAM
12331246
1234   AM_RANGE(0x400000, 0x40ffff) AM_RAM AM_BASE(&frame_buffer)
1247   AM_RANGE(0x400000, 0x40ffff) AM_RAM AM_BASE_MEMBER(blitz68k_state, frame_buffer)
12351248
12361249   AM_RANGE(0x30000c, 0x30000d) AM_WRITENOP   // 0->1 (IRQ3 ack.?)
12371250   AM_RANGE(0x30000e, 0x30000f) AM_WRITENOP   // 1->0 (MCU related?)
r10886r10887
17691782MACHINE_CONFIG_END
17701783
17711784
1772static MACHINE_CONFIG_START( bankrob, driver_device )
1785static MACHINE_CONFIG_START( bankrob, blitz68k_state )
17731786   MCFG_CPU_ADD("maincpu", M68000, XTAL_11_0592MHz)
17741787   MCFG_CPU_PROGRAM_MAP(bankrob_map)
17751788   MCFG_CPU_VBLANK_INT("screen", irq3_line_hold)   // protection prevents correct irq frequency by crtc
r10886r10887
18011814MACHINE_CONFIG_END
18021815
18031816
1804static MACHINE_CONFIG_START( bankroba, driver_device )
1817static MACHINE_CONFIG_START( bankroba, blitz68k_state )
18051818   MCFG_CPU_ADD("maincpu", M68000, XTAL_11_0592MHz )
18061819   MCFG_CPU_PROGRAM_MAP(bankroba_map)
18071820   MCFG_CPU_VBLANK_INT("screen", irq5_line_hold)   // protection prevents correct irq frequency by crtc
r10886r10887
18311844MACHINE_CONFIG_END
18321845
18331846
1834static MACHINE_CONFIG_START( deucesw2, driver_device )
1847static MACHINE_CONFIG_START( deucesw2, blitz68k_state )
18351848   MCFG_CPU_ADD("maincpu", M68000, XTAL_22_1184MHz / 2)
18361849   MCFG_CPU_PROGRAM_MAP(deucesw2_map)
18371850   // irq 2 reads from MCUs
r10886r10887
18601873MACHINE_CONFIG_END
18611874
18621875
1863static MACHINE_CONFIG_START( dualgame, driver_device )
1876static MACHINE_CONFIG_START( dualgame, blitz68k_state )
18641877   MCFG_CPU_ADD("maincpu", M68000, XTAL_11_0592MHz )
18651878   MCFG_CPU_PROGRAM_MAP(dualgame_map)
18661879   MCFG_CPU_VBLANK_INT("screen", irq2_line_hold) // lev 2 = MCUs, lev 3 = vblank
r10886r10887
18911904MACHINE_CONFIG_END
18921905
18931906
1894static MACHINE_CONFIG_START( hermit, driver_device )
1907static MACHINE_CONFIG_START( hermit, blitz68k_state )
18951908   MCFG_CPU_ADD("maincpu", M68000, XTAL_22_1184MHz/2 )
18961909   MCFG_CPU_PROGRAM_MAP(hermit_map)
18971910   MCFG_CPU_VBLANK_INT("screen", irq1_line_hold)   // protection prevents correct irq frequency by crtc
r10886r10887
19201933MACHINE_CONFIG_END
19211934
19221935
1923static MACHINE_CONFIG_START( maxidbl, driver_device )
1936static MACHINE_CONFIG_START( maxidbl, blitz68k_state )
19241937   MCFG_CPU_ADD("maincpu", M68000, XTAL_11_0592MHz)
19251938   MCFG_CPU_PROGRAM_MAP(maxidbl_map)
19261939   MCFG_CPU_VBLANK_INT("screen", irq3_line_hold)   // protection prevents correct irq frequency by crtc
src/mame/drivers/cb2001.c
r10886r10887
4646#include "machine/8255ppi.h"
4747#include "deprecat.h"
4848
49
50class cb2001_state : public driver_device
51{
52public:
53   cb2001_state(running_machine &machine, const driver_device_config_base &config)
54      : driver_device(machine, config) { }
55
56   UINT16 *vram_fg;
57   UINT16* vram_bg;
58   int videobank;
59   int videomode;
60   tilemap_t *reel1_tilemap;
61   tilemap_t *reel2_tilemap;
62   tilemap_t *reel3_tilemap;
63   int other1;
64   int other2;
65};
66
67
4968#define xxxx 0x90 /* Unknown */
5069
5170static const UINT8 cb2001_decryption_table[256] = {
r10886r10887
302321
303322*/
304323
305static UINT16 *cb2001_vram_fg;
306static UINT16* cb2001_vram_bg;
307static int cb2001_videobank;
308static int cb2001_videomode;
309324
310static tilemap_t *reel1_tilemap, *reel2_tilemap, *reel3_tilemap;
311
312
313325// these areas are wrong
314326static const rectangle visible1 = { 0*8, (14+48)*8-1,  3*8,  (3+7)*8-1 };
315327static const rectangle visible2 = { 0*8, (14+48)*8-1, 10*8, (10+7)*8-1 };
316328static const rectangle visible3 = { 0*8, (14+48)*8-1, 17*8, (17+7)*8-1 };
317static int other1,other2;
318329
319330static SCREEN_UPDATE(cb2001)
320331{
332   cb2001_state *state = screen->machine->driver_data<cb2001_state>();
321333   int count,x,y;
322334   bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
323335
324336   count = 0x0000;
325337
326338   // render bg as 8x8 tilemaps
327   if (other1 & 0x02)
339   if (state->other1 & 0x02)
328340   {
329      if (!(other1 & 0x04))
341      if (!(state->other1 & 0x04))
330342      {
331343         for (y=0;y<32;y++)
332344         {
r10886r10887
335347               int tile;
336348               int colour;
337349
338               tile = (cb2001_vram_bg[count] & 0x0fff);
339               colour = (cb2001_vram_bg[count] & 0xf000)>>12;
340               tile += cb2001_videobank*0x2000;
350               tile = (state->vram_bg[count] & 0x0fff);
351               colour = (state->vram_bg[count] & 0xf000)>>12;
352               tile += state->videobank*0x2000;
341353
342354
343355               drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[0],tile,colour,0,0,x*8,y*8);
r10886r10887
354366         {
355367            UINT16 scroll;
356368
357            scroll = cb2001_vram_bg[0xa00/2 + i/2];
369            scroll = state->vram_bg[0xa00/2 + i/2];
358370            if (i&1)
359371               scroll >>=8;
360372            scroll &=0xff;
361373
362            tilemap_set_scrolly(reel2_tilemap, i, scroll);
374            tilemap_set_scrolly(state->reel2_tilemap, i, scroll);
363375
364            scroll = cb2001_vram_bg[0x800/2 + i/2];
376            scroll = state->vram_bg[0x800/2 + i/2];
365377            if (i&1)
366378               scroll >>=8;
367379            scroll &=0xff;
368380
369            tilemap_set_scrolly(reel1_tilemap, i, scroll);
381            tilemap_set_scrolly(state->reel1_tilemap, i, scroll);
370382
371            scroll = cb2001_vram_bg[0xc00/2 + i/2];
383            scroll = state->vram_bg[0xc00/2 + i/2];
372384            if (i&1)
373385               scroll >>=8;
374386            scroll &=0xff;
375387
376            tilemap_set_scrolly(reel3_tilemap, i, scroll);
388            tilemap_set_scrolly(state->reel3_tilemap, i, scroll);
377389
378390         }
379391
380         tilemap_draw(bitmap, &visible1, reel1_tilemap, 0, 0);
381         tilemap_draw(bitmap, &visible2, reel2_tilemap, 0, 0);
382         tilemap_draw(bitmap, &visible3, reel3_tilemap, 0, 0);
392         tilemap_draw(bitmap, &visible1, state->reel1_tilemap, 0, 0);
393         tilemap_draw(bitmap, &visible2, state->reel2_tilemap, 0, 0);
394         tilemap_draw(bitmap, &visible3, state->reel3_tilemap, 0, 0);
383395      }
384396   }
385397
r10886r10887
392404         int tile;
393405         int colour;
394406
395         tile = (cb2001_vram_fg[count] & 0x0fff);
396         colour = (cb2001_vram_fg[count] & 0xf000)>>12;
397         tile += cb2001_videobank*0x2000;
407         tile = (state->vram_fg[count] & 0x0fff);
408         colour = (state->vram_fg[count] & 0xf000)>>12;
409         tile += state->videobank*0x2000;
398410
399         if (other2 & 0x4)
411         if (state->other2 & 0x4)
400412         {
401413            tile += 0x1000;
402414         }
r10886r10887
406418      }
407419   }
408420
409   popmessage("%02x %02x %02x %02x\n",cb2001_videobank,cb2001_videomode, other1, other2);
421   popmessage("%02x %02x %02x %02x\n",state->videobank,state->videomode, state->other1, state->other2);
410422
411423   return 0;
412424}
r10886r10887
417429   is being executed incorrectly */
418430WRITE16_HANDLER( cb2001_vidctrl_w )
419431{
432   cb2001_state *state = space->machine->driver_data<cb2001_state>();
420433   if (mem_mask&0xff00) // video control?
421434   {
422435      printf("cb2001_vidctrl_w %04x %04x\n", data, mem_mask);
423      cb2001_videobank = (data & 0x0800)>>11;
436      state->videobank = (data & 0x0800)>>11;
424437   }
425438   else // something else
426      other1 = data & 0x00ff;
439      state->other1 = data & 0x00ff;
427440}
428441
429442WRITE16_HANDLER( cb2001_vidctrl2_w )
430443{
444   cb2001_state *state = space->machine->driver_data<cb2001_state>();
431445   if (mem_mask&0xff00) // video control?
432446   {
433447      printf("cb2001_vidctrl2_w %04x %04x\n", data, mem_mask); // i think this switches to 'reels' mode
434      cb2001_videomode = (data>>8) & 0x03; // which bit??
448      state->videomode = (data>>8) & 0x03; // which bit??
435449   }
436450   else // something else
437      other2 = data & 0x00ff;
451      state->other2 = data & 0x00ff;
438452
439453//      printf("cb2001_vidctrl2_w %04x %04x\n", data, mem_mask); // bank could be here instead
440454}
r10886r10887
442456
443457static TILE_GET_INFO( get_cb2001_reel1_tile_info )
444458{
445   int code = cb2001_vram_bg[(0x0000/2) + tile_index/2];
459   cb2001_state *state = machine->driver_data<cb2001_state>();
460   int code = state->vram_bg[(0x0000/2) + tile_index/2];
446461
447462   if (tile_index&1)
448463      code >>=8;
r10886r10887
460475
461476static TILE_GET_INFO( get_cb2001_reel2_tile_info )
462477{
463   int code = cb2001_vram_bg[(0x0200/2) + tile_index/2];
478   cb2001_state *state = machine->driver_data<cb2001_state>();
479   int code = state->vram_bg[(0x0200/2) + tile_index/2];
464480
465481   if (tile_index&1)
466482      code >>=8;
r10886r10887
479495
480496static TILE_GET_INFO( get_cb2001_reel3_tile_info )
481497{
482   int code = cb2001_vram_bg[(0x0400/2) + tile_index/2];
498   cb2001_state *state = machine->driver_data<cb2001_state>();
499   int code = state->vram_bg[(0x0400/2) + tile_index/2];
483500   int colour = 0;//(cb2001_out_c&0x7) + 8;
484501
485502   if (tile_index&1)
r10886r10887
497514
498515static VIDEO_START(cb2001)
499516{
500   reel1_tilemap = tilemap_create(machine,get_cb2001_reel1_tile_info,tilemap_scan_rows, 8, 32, 64, 8);
501   reel2_tilemap = tilemap_create(machine,get_cb2001_reel2_tile_info,tilemap_scan_rows, 8, 32, 64, 8);
502   reel3_tilemap = tilemap_create(machine,get_cb2001_reel3_tile_info,tilemap_scan_rows, 8, 32, 64, 8);
517   cb2001_state *state = machine->driver_data<cb2001_state>();
518   state->reel1_tilemap = tilemap_create(machine,get_cb2001_reel1_tile_info,tilemap_scan_rows, 8, 32, 64, 8);
519   state->reel2_tilemap = tilemap_create(machine,get_cb2001_reel2_tile_info,tilemap_scan_rows, 8, 32, 64, 8);
520   state->reel3_tilemap = tilemap_create(machine,get_cb2001_reel3_tile_info,tilemap_scan_rows, 8, 32, 64, 8);
503521
504   tilemap_set_scroll_cols(reel1_tilemap, 64);
505   tilemap_set_scroll_cols(reel2_tilemap, 64);
506   tilemap_set_scroll_cols(reel3_tilemap, 64);
522   tilemap_set_scroll_cols(state->reel1_tilemap, 64);
523   tilemap_set_scroll_cols(state->reel2_tilemap, 64);
524   tilemap_set_scroll_cols(state->reel3_tilemap, 64);
507525}
508526
509527WRITE16_HANDLER( cb2001_bg_w )
510528{
511   COMBINE_DATA(&cb2001_vram_bg[offset]);
529   cb2001_state *state = space->machine->driver_data<cb2001_state>();
530   COMBINE_DATA(&state->vram_bg[offset]);
512531
513532   // also used for the reel tilemaps in a different mode
514533/*
515534    if (offset<0x200/2)
516535    {
517        tilemap_mark_tile_dirty(reel1_tilemap,(offset&0xff)/2);
536        tilemap_mark_tile_dirty(state->reel1_tilemap,(offset&0xff)/2);
518537    }
519538    else if (offset<0x400/2)
520539    {
521        tilemap_mark_tile_dirty(reel2_tilemap,(offset&0xff)/2);
540        tilemap_mark_tile_dirty(state->reel2_tilemap,(offset&0xff)/2);
522541    }
523542    else if (offset<0x600/2)
524543    {
525        tilemap_mark_tile_dirty(reel3_tilemap,(offset&0xff)/2);
544        tilemap_mark_tile_dirty(state->reel3_tilemap,(offset&0xff)/2);
526545    }
527546    else if (offset<0x800/2)
528547    {
529548    //  tilemap_mark_tile_dirty(reel4_tilemap,(offset&0xff)/2);
530549    }
531550*/
532   tilemap_mark_all_tiles_dirty (reel1_tilemap);
533   tilemap_mark_all_tiles_dirty (reel2_tilemap);
534   tilemap_mark_all_tiles_dirty (reel3_tilemap);
551   tilemap_mark_all_tiles_dirty (state->reel1_tilemap);
552   tilemap_mark_all_tiles_dirty (state->reel2_tilemap);
553   tilemap_mark_all_tiles_dirty (state->reel3_tilemap);
535554
536555
537556}
538557
539558static ADDRESS_MAP_START( cb2001_map, ADDRESS_SPACE_PROGRAM, 16 )
540559   AM_RANGE(0x00000, 0x1ffff) AM_RAM
541   AM_RANGE(0x20000, 0x20fff) AM_RAM AM_BASE(&cb2001_vram_fg)
542   AM_RANGE(0x21000, 0x21fff) AM_RAM_WRITE(&cb2001_bg_w) AM_BASE(&cb2001_vram_bg)
560   AM_RANGE(0x20000, 0x20fff) AM_RAM AM_BASE_MEMBER(cb2001_state, vram_fg)
561   AM_RANGE(0x21000, 0x21fff) AM_RAM_WRITE(&cb2001_bg_w) AM_BASE_MEMBER(cb2001_state, vram_bg)
543562   AM_RANGE(0xc0000, 0xfffff) AM_ROM AM_REGION("boot_prg",0)
544563ADDRESS_MAP_END
545564
r10886r10887
812831};
813832
814833static const nec_config cb2001_config = { cb2001_decryption_table, };
815static MACHINE_CONFIG_START( cb2001, driver_device )
834static MACHINE_CONFIG_START( cb2001, cb2001_state )
816835   MCFG_CPU_ADD("maincpu", V35, 20000000) // CPU91A-011-0016JK004; encrypted cpu like nec v25/35 used in some irem game
817836   MCFG_CPU_CONFIG(cb2001_config)
818837   MCFG_CPU_PROGRAM_MAP(cb2001_map)
r10886r10887
872891
873892GAME( 2001, cb2001,    0,      cb2001,      cb2001,   0, ROT0,  "Dyna", "Cherry Bonus 2001", GAME_NOT_WORKING|GAME_NO_SOUND )
874893GAME( 2001, scherrym,  0,      cb2001,      cb2001,   0, ROT0,  "Dyna", "Super Cherry Master", GAME_NOT_WORKING|GAME_NO_SOUND ) // 2001 version? (we have bootlegs running on z80 hw of a 1996 version)
875
876
877
878
879
880
881
882
src/mame/drivers/neoprint.c
r10886r10887
2525#include "sound/2610intf.h"
2626#include "machine/pd4990a.h"
2727
28static UINT16* npvidram;
29static UINT16* npvidregs;
30static UINT8 audio_result;
31static UINT8 bank_val;
3228
29class neoprint_state : public driver_device
30{
31public:
32   neoprint_state(running_machine &machine, const driver_device_config_base &config)
33      : driver_device(machine, config) { }
34
35   UINT16* npvidram;
36   UINT16* npvidregs;
37   UINT8 audio_result;
38   UINT8 bank_val;
39   UINT8 vblank;
40};
41
42
3343VIDEO_START(neoprint)
3444{
35
3645}
3746
3847/*
r10886r10887
4655
4756static void draw_layer(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int layer,int data_shift)
4857{
58   neoprint_state *state = machine->driver_data<neoprint_state>();
4959   int i, y, x;
5060   const gfx_element *gfx = machine->gfx[0];
5161   INT16 scrollx, scrolly;
5262
53   i = (npvidregs[((layer*8)+0x06)/2] & 7) * 0x1000/4;
54   scrollx = ((npvidregs[((layer*8)+0x00)/2] - (0xd8 + layer*4)) & 0x03ff);
55   scrolly = ((npvidregs[((layer*8)+0x02)/2] - 0xffeb) & 0x03ff);
63   i = (state->npvidregs[((layer*8)+0x06)/2] & 7) * 0x1000/4;
64   scrollx = ((state->npvidregs[((layer*8)+0x00)/2] - (0xd8 + layer*4)) & 0x03ff);
65   scrolly = ((state->npvidregs[((layer*8)+0x02)/2] - 0xffeb) & 0x03ff);
5666
5767   scrollx/=2;
5868   scrolly/=2;
r10886r10887
6171   {
6272      for (x=0;x<32;x++)
6373      {
64         UINT16 dat = npvidram[i*2] >> data_shift; // a video register?
74         UINT16 dat = state->npvidram[i*2] >> data_shift; // a video register?
6575         UINT16 color;
66         if(npvidram[i*2+1] & 0x0020) // TODO: 8bpp switch?
67            color = ((npvidram[i*2+1] & 0x8000) << 1) | 0x200 | ((npvidram[i*2+1] & 0xff00) >> 7);
76         if(state->npvidram[i*2+1] & 0x0020) // TODO: 8bpp switch?
77            color = ((state->npvidram[i*2+1] & 0x8000) << 1) | 0x200 | ((state->npvidram[i*2+1] & 0xff00) >> 7);
6878         else
69            color = ((npvidram[i*2+1] & 0xff00) >> 8) | ((npvidram[i*2+1] & 0x0010) << 4);
70         UINT8 fx = (npvidram[i*2+1] & 0x0040);
71         UINT8 fy = (npvidram[i*2+1] & 0x0080);
79            color = ((state->npvidram[i*2+1] & 0xff00) >> 8) | ((state->npvidram[i*2+1] & 0x0010) << 4);
80         UINT8 fx = (state->npvidram[i*2+1] & 0x0040);
81         UINT8 fy = (state->npvidram[i*2+1] & 0x0080);
7282
7383         drawgfx_transpen(bitmap,cliprect,gfx,dat,color,fx,fy,x*16+scrollx,y*16-scrolly,0);
7484         drawgfx_transpen(bitmap,cliprect,gfx,dat,color,fx,fy,x*16+scrollx-512,y*16-scrolly,0);
r10886r10887
118128
119129static READ8_HANDLER( neoprint_unk_r )
120130{
121   static UINT8 vblank;
131   neoprint_state *state = space->machine->driver_data<neoprint_state>();
122132
123133   /* ---x ---- tested in irq routine, odd/even field number? */
124134   /* ---- xx-- one of these two must be high */
125135   /* ---- --xx checked right before entering into attract mode, presumably printer/camera related */
126136
127   vblank = (space->machine->primary_screen->frame_number() & 0x1) ? 0x10 : 0x00;
137   state->vblank = (space->machine->primary_screen->frame_number() & 0x1) ? 0x10 : 0x00;
128138
129139   //if(cpu_get_pc(space->cpu) != 0x1504 && cpu_get_pc(space->cpu) != 0x5f86 && cpu_get_pc(space->cpu) != 0x5f90)
130140   //  printf("%08x\n",cpu_get_pc(space->cpu));
131141
132   return vblank| 4 | 3;
142   return state->vblank| 4 | 3;
133143}
134144
135145static READ16_HANDLER( neoprint_audio_result_r )
136146{
137   return (audio_result << 8) | 0x00;
147   neoprint_state *state = space->machine->driver_data<neoprint_state>();
148   return (state->audio_result << 8) | 0x00;
138149}
139150
140151static void audio_cpu_assert_nmi(running_machine *machine)
r10886r10887
181192
182193static WRITE8_HANDLER( audio_result_w )
183194{
195   neoprint_state *state = space->machine->driver_data<neoprint_state>();
184196   //neogeo_state *state = space->machine->driver_data<neogeo_state>();
185197
186198   //if (LOG_CPU_COMM && (state->audio_result != data)) logerror(" AUD CPU PC   %04x: audio_result_w %02x\n", cpu_get_pc(space->cpu), data);
187199
188   audio_result = data;
200   state->audio_result = data;
189201}
190202
191203static ADDRESS_MAP_START( neoprint_map, ADDRESS_SPACE_PROGRAM, 16 )
r10886r10887
193205/*  AM_RANGE(0x100000, 0x17ffff) multi-cart or banking, some writes points here if anything lies there too */
194206   AM_RANGE(0x200000, 0x20ffff) AM_RAM
195207   AM_RANGE(0x300000, 0x30ffff) AM_RAM AM_SHARE("nvram")
196   AM_RANGE(0x400000, 0x43ffff) AM_RAM AM_BASE(&npvidram)
208   AM_RANGE(0x400000, 0x43ffff) AM_RAM AM_BASE_MEMBER(neoprint_state, npvidram)
197209   AM_RANGE(0x500000, 0x51ffff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
198210   AM_RANGE(0x600000, 0x600001) AM_READWRITE(neoprint_audio_result_r,audio_command_w)
199211   AM_RANGE(0x600002, 0x600003) AM_READWRITE(neoprint_calendar_r,neoprint_calendar_w)
r10886r10887
204216   AM_RANGE(0x60000c, 0x60000d) AM_READ_PORT("DSW2")
205217   AM_RANGE(0x60000e, 0x60000f) AM_WRITENOP
206218
207   AM_RANGE(0x700000, 0x70001b) AM_RAM AM_BASE(&npvidregs)
219   AM_RANGE(0x700000, 0x70001b) AM_RAM AM_BASE_MEMBER(neoprint_state, npvidregs)
208220
209221   AM_RANGE(0x70001e, 0x70001f) AM_WRITENOP //watchdog
210222ADDRESS_MAP_END
r10886r10887
238250
239251static WRITE8_HANDLER( nprsp_bank_w )
240252{
253   neoprint_state *state = space->machine->driver_data<neoprint_state>();
241254   /* this register seems flip-flop based ... */
242255
243256   if((data & 0xf0) == 0x20)
244257   {
245258      if((data & 0xf) == 0x1)
246         bank_val = 1;
259         state->bank_val = 1;
247260      if((data & 0xf) == 0x2)
248         bank_val = 0;
261         state->bank_val = 0;
249262   }
250263}
251264
252265static READ16_HANDLER( rom_window_r )
253266{
267   neoprint_state *state = space->machine->driver_data<neoprint_state>();
254268   UINT16 *rom = (UINT16 *)space->machine->region("maincpu")->base();
255269
256   return rom[offset | 0x80000/2 | bank_val*0x40000/2];
270   return rom[offset | 0x80000/2 | state->bank_val*0x40000/2];
257271}
258272
259273static ADDRESS_MAP_START( nprsp_map, ADDRESS_SPACE_PROGRAM, 16 )
r10886r10887
268282   AM_RANGE(0x20000c, 0x20000d) AM_READ_PORT("DSW2")
269283   AM_RANGE(0x20000e, 0x20000f) AM_WRITENOP
270284
271   AM_RANGE(0x240000, 0x24001b) AM_RAM AM_BASE(&npvidregs)
285   AM_RANGE(0x240000, 0x24001b) AM_RAM AM_BASE_MEMBER(neoprint_state, npvidregs)
272286   AM_RANGE(0x24001e, 0x24001f) AM_WRITENOP //watchdog
273287
274288   AM_RANGE(0x300000, 0x33ffff) AM_RAM AM_SHARE("nvram")
275289   AM_RANGE(0x380000, 0x38ffff) AM_RAM
276   AM_RANGE(0x400000, 0x43ffff) AM_RAM AM_BASE(&npvidram)
290   AM_RANGE(0x400000, 0x43ffff) AM_RAM AM_BASE_MEMBER(neoprint_state, npvidram)
277291   AM_RANGE(0x500000, 0x57ffff) AM_RAM_WRITE(nprsp_palette_w) AM_BASE_GENERIC(paletteram)
278292ADDRESS_MAP_END
279293
r10886r10887
421435   GFXDECODE_ENTRY( "gfx1", 0, neoprint_layout,   0x0, 0x1000 )
422436GFXDECODE_END
423437
424class neoprint_state : public driver_device
425{
426public:
427   neoprint_state(running_machine &machine, const driver_device_config_base &config)
428      : driver_device(machine, config) { }
429};
430
431438static void audio_cpu_irq(device_t *device, int assert)
432439{
433440   cputag_set_input_line(device->machine, "audiocpu", 0, assert ? ASSERT_LINE : CLEAR_LINE);
r10886r10887
478485
479486static MACHINE_RESET( nprsp )
480487{
481   bank_val = 0;
488   neoprint_state *state = machine->driver_data<neoprint_state>();
489   state->bank_val = 0;
482490}
483491
484492static MACHINE_CONFIG_START( nprsp, neoprint_state )
src/mame/drivers/jubilee.c
r10886r10887
9090#include "video/mc6845.h"
9191
9292
93class jubilee_state : public driver_device
94{
95public:
96   jubilee_state(running_machine &machine, const driver_device_config_base &config)
97      : driver_device(machine, config) { }
9398
99   UINT8 *videoram;
100   tilemap_t *bg_tilemap;
101};
102
103
94104/*************************
95105*     Video Hardware     *
96106*************************/
97107
98static UINT8 *videoram;
99static tilemap_t *bg_tilemap;
100108
101
102109static WRITE8_HANDLER( jubileep_videoram_w )
103110{
104   videoram[offset] = data;
105   tilemap_mark_tile_dirty(bg_tilemap, offset);
111   jubilee_state *state = space->machine->driver_data<jubilee_state>();
112   state->videoram[offset] = data;
113   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
106114}
107115
108116
109117static TILE_GET_INFO( get_bg_tile_info )
110118{
111   int code = videoram[tile_index];
119   jubilee_state *state = machine->driver_data<jubilee_state>();
120   int code = state->videoram[tile_index];
112121
113122   SET_TILE_INFO( 0, code, 0, 0);
114123}
r10886r10887
117126
118127static VIDEO_START( jubileep )
119128{
120   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
129   jubilee_state *state = machine->driver_data<jubilee_state>();
130   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
121131}
122132
123133
124134static SCREEN_UPDATE( jubileep )
125135{
126   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
136   jubilee_state *state = screen->machine->driver_data<jubilee_state>();
137   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
127138   return 0;
128139}
129140
r10886r10887
152163static ADDRESS_MAP_START( jubileep_map, ADDRESS_SPACE_PROGRAM, 8 )
153164   ADDRESS_MAP_GLOBAL_MASK(0x3fff)
154165   AM_RANGE(0x0000, 0x2fff) AM_ROM
155   AM_RANGE(0x3000, 0x30ff) AM_WRITE(jubileep_videoram_w) AM_BASE(&videoram)   /* wrong... just placed somewhere */
166   AM_RANGE(0x3000, 0x30ff) AM_WRITE(jubileep_videoram_w) AM_BASE_MEMBER(jubilee_state, videoram)   /* wrong... just placed somewhere */
156167   AM_RANGE(0x3100, 0x3fff) AM_RAM
157168ADDRESS_MAP_END
158169
r10886r10887
397408*    Machine Drivers     *
398409*************************/
399410
400static MACHINE_CONFIG_START( jubileep, driver_device )
411static MACHINE_CONFIG_START( jubileep, jubilee_state )
401412
402413   /* basic machine hardware */
403414   MCFG_CPU_ADD("maincpu", TMS9980, MASTER_CLOCK/2)   /* guess */
src/mame/drivers/goldngam.c
r10886r10887
237237#include "sound/ay8910.h"
238238
239239
240static UINT16 *videoram;
240class goldngam_state : public driver_device
241{
242public:
243   goldngam_state(running_machine &machine, const driver_device_config_base &config)
244      : driver_device(machine, config) { }
241245
246   UINT16 *videoram;
247};
248
249
242250/*************************
243251*     Video Hardware     *
244252*************************/
r10886r10887
250258
251259static SCREEN_UPDATE( goldngam )
252260{
261   goldngam_state *state = screen->machine->driver_data<goldngam_state>();
253262
254263   int x, y;
255264
256   UINT8 *tmp = (UINT8 *) videoram;
265   UINT8 *tmp = (UINT8 *) state->videoram;
257266   int index = 0;
258267
259268   for(y = 0; y < 512; ++y)
r10886r10887
297306   AM_RANGE(0x402000, 0x402001) AM_DEVREAD8("aysnd", ay8910_r, 0x00ff)
298307   AM_RANGE(0x402000, 0x402003) AM_DEVWRITE8("aysnd", ay8910_address_data_w, 0x00ff) //wrong
299308
300   AM_RANGE(0xc00000, 0xc3ffff) AM_RAM AM_BASE(&videoram)
309   AM_RANGE(0xc00000, 0xc3ffff) AM_RAM AM_BASE_MEMBER(goldngam_state, videoram)
301310   AM_RANGE(0x500200, 0x50020f) AM_RAM //?
302311   AM_RANGE(0x503000, 0x503001) AM_RAM //int ack ?
303312   AM_RANGE(0x503002, 0x503003) AM_RAM //int ack ?
r10886r10887
341350static ADDRESS_MAP_START( moviecrd_map, ADDRESS_SPACE_PROGRAM, 16 )
342351   AM_RANGE(0x000000, 0x07ffff) AM_ROM
343352   AM_RANGE(0x200000, 0x20ffff) AM_RAM
344   AM_RANGE(0xc00000, 0xc3ffff) AM_RAM AM_BASE(&videoram)
353   AM_RANGE(0xc00000, 0xc3ffff) AM_RAM AM_BASE_MEMBER(goldngam_state, videoram)
345354   AM_RANGE(0x503000, 0x5031ff) AM_RAM //int ack ?
346355ADDRESS_MAP_END
347356
r10886r10887
541550   DEVCB_NULL
542551};
543552
544static MACHINE_CONFIG_START( swisspkr, driver_device )
553static MACHINE_CONFIG_START( swisspkr, goldngam_state )
545554
546555   /* basic machine hardware */
547556   MCFG_CPU_ADD("maincpu", M68000, MASTER_CLOCK)
src/mame/drivers/kingpin.c
r10886r10887
2525#include "sound/ay8910.h"
2626#include "machine/nvram.h"
2727
28
29class kingpin_state : public driver_device
30{
31public:
32   kingpin_state(running_machine &machine, const driver_device_config_base &config)
33      : driver_device(machine, config) { }
34
35   UINT8 *code_base;
36};
37
38
2839static READ8_HANDLER( io_read_missing_dips )
2940{
3041   return 0x00;
r10886r10887
139150   vdp_interrupt
140151};
141152
142static MACHINE_CONFIG_START( kingpin, driver_device )
153static MACHINE_CONFIG_START( kingpin, kingpin_state )
143154/*  MAIN CPU */
144155   MCFG_CPU_ADD("maincpu", Z80, 3579545)
145156   MCFG_CPU_PROGRAM_MAP(kingpin_program_map)
r10886r10887
173184
174185static DRIVER_INIT( kingpin )
175186{
176   static UINT8 *code_base;
187   kingpin_state *state = machine->driver_data<kingpin_state>();
177188
178189   TMS9928A_configure(&tms9928a_interface);
179190
180191   /* Hacks to keep the emu a'runnin */
181   code_base = machine->region("maincpu")->base();
182   code_base[0x17d4] = 0xc3;   /* Maybe sound related? */
192   state->code_base = machine->region("maincpu")->base();
193   state->code_base[0x17d4] = 0xc3;   /* Maybe sound related? */
183194}
184195
185196ROM_START( kingpin )
src/mame/drivers/tattack.c
r10886r10887
2222#include "cpu/z80/z80.h"
2323
2424
25static UINT8 *videoram;
26static UINT8 *colorram;
27static tilemap_t *tmap;
25class tattack_state : public driver_device
26{
27public:
28   tattack_state(running_machine &machine, const driver_device_config_base &config)
29      : driver_device(machine, config) { }
2830
31   UINT8 *videoram;
32   UINT8 *colorram;
33   tilemap_t *tmap;
34};
35
36
37
2938static TILE_GET_INFO( get_tile_info )
3039{
31   int code = videoram[tile_index];
32   int color = colorram[tile_index];
40   tattack_state *state = machine->driver_data<tattack_state>();
41   int code = state->videoram[tile_index];
42   int color = state->colorram[tile_index];
3343
3444   if((color&1 ) || (color>15) )
3545      logerror("COLOR %i\n",color);
r10886r10887
4555
4656static SCREEN_UPDATE( tattack )
4757{
48   tilemap_mark_all_tiles_dirty(tmap);
49   tilemap_draw(bitmap,cliprect,tmap, 0,0);
58   tattack_state *state = screen->machine->driver_data<tattack_state>();
59   tilemap_mark_all_tiles_dirty(state->tmap);
60   tilemap_draw(bitmap,cliprect,state->tmap, 0,0);
5061   return 0;
5162}
5263
5364static VIDEO_START( tattack )
5465{
55      tmap = tilemap_create( machine, get_tile_info,tilemap_scan_rows,8,8,32,32 );
66   tattack_state *state = machine->driver_data<tattack_state>();
67      state->tmap = tilemap_create( machine, get_tile_info,tilemap_scan_rows,8,8,32,32 );
5668}
5769
5870static ADDRESS_MAP_START( mem, ADDRESS_SPACE_PROGRAM, 8 )
5971   AM_RANGE(0x0000, 0x0fff) AM_ROM
6072//  AM_RANGE(0x4000, 0x4000) AM_READNOP $315
61   AM_RANGE(0x5000, 0x53ff) AM_RAM AM_BASE(&videoram)
62   AM_RANGE(0x7000, 0x73ff) AM_RAM AM_BASE(&colorram)   // color map ? something else .. only bits 1-3 are used
73   AM_RANGE(0x5000, 0x53ff) AM_RAM AM_BASE_MEMBER(tattack_state, videoram)
74   AM_RANGE(0x7000, 0x73ff) AM_RAM AM_BASE_MEMBER(tattack_state, colorram)   // color map ? something else .. only bits 1-3 are used
6375   AM_RANGE(0x6000, 0x6000) AM_READ_PORT("DSW2")
6476   AM_RANGE(0xa000, 0xa000) AM_READ_PORT("DSW1")      // dsw ? something else ?
6577   AM_RANGE(0xc000, 0xc000) AM_READ_PORT("INPUTS") AM_WRITENOP
r10886r10887
180192}
181193
182194
183static MACHINE_CONFIG_START( tattack, driver_device )
195static MACHINE_CONFIG_START( tattack, tattack_state )
184196
185197   /* basic machine hardware */
186198   MCFG_CPU_ADD("maincpu", Z80, 8000000 / 2)   /* 4 MHz ? */
src/mame/drivers/blackt96.c
r10886r10887
5252#include "cpu/m68000/m68000.h"
5353#include "sound/okim6295.h"
5454
55
56class blackt96_state : public driver_device
57{
58public:
59   blackt96_state(running_machine &machine, const driver_device_config_base &config)
60      : driver_device(machine, config) { }
61
62   UINT16* tilemapram;
63   UINT16* tilemapram2;
64};
65
66
5567static VIDEO_START( blackt96 )
5668{
57
5869}
5970
60static UINT16* blackt96_tilemapram;
61static UINT16* blackt96_tilemapram2;
62
6371static void draw_strip(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int stripnum, int xbase, int ybase, int bg)
6472{
73   blackt96_state *state = machine->driver_data<blackt96_state>();
6574   const gfx_element *gfxspr = machine->gfx[1];
6675   const gfx_element *gfxbg = machine->gfx[0];
6776
r10886r10887
7180
7281   for (y=0;y<32;y++)
7382   {
74      UINT16 tile = (blackt96_tilemapram2[count*2 + (base/2)+1]&0x3fff);
75      UINT16 flipx = (blackt96_tilemapram2[count*2 + (base/2)+1]&0x4000);
76      UINT16 colour = (blackt96_tilemapram2[count*2 + (base/2)]&0x00ff);
83      UINT16 tile = (state->tilemapram2[count*2 + (base/2)+1]&0x3fff);
84      UINT16 flipx = (state->tilemapram2[count*2 + (base/2)+1]&0x4000);
85      UINT16 colour = (state->tilemapram2[count*2 + (base/2)]&0x00ff);
7786
7887      if (tile&0x2000)
7988      {
r10886r10887
91100
92101static void draw_main(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int bg)
93102{
103   blackt96_state *state = machine->driver_data<blackt96_state>();
94104
95105   int x;
96106
r10886r10887
101111      int yy;
102112      int s = 0;
103113
104      xx=  ((blackt96_tilemapram2[x+0]&0x001f)<<4) | (blackt96_tilemapram2[x+1]&0xf000)>>12;
105      yy = ((blackt96_tilemapram2[x+1]&0x1ff));
114      xx=  ((state->tilemapram2[x+0]&0x001f)<<4) | (state->tilemapram2[x+1]&0xf000)>>12;
115      yy = ((state->tilemapram2[x+1]&0x1ff));
106116
107117      if (xx&0x100) xx-=0x200;
108118      yy = 0x1ff-yy;
r10886r10887
120130
121131static SCREEN_UPDATE( blackt96 )
122132{
133   blackt96_state *state = screen->machine->driver_data<blackt96_state>();
123134   int count;
124135   int x,y;
125136   const gfx_element *gfx = screen->machine->gfx[2];
r10886r10887
135146   {
136147      for (y=0;y<32;y++)
137148      {
138         UINT16 tile = (blackt96_tilemapram[count*2]&0x7ff)+0x800; // +0xc00 for korean text
149         UINT16 tile = (state->tilemapram[count*2]&0x7ff)+0x800; // +0xc00 for korean text
139150         drawgfx_transpen(bitmap,cliprect,gfx,tile,0,0,0,x*8,-16+y*8,0);
140151         count++;
141152      }
r10886r10887
166177   AM_RANGE(0x0f0000, 0x0f0001) AM_READ_PORT("DSW1")
167178   AM_RANGE(0x0f0008, 0x0f0009) AM_READ_PORT("DSW2")
168179
169   AM_RANGE(0x100000, 0x100fff) AM_RAM AM_BASE(&blackt96_tilemapram) // text tilemap
170   AM_RANGE(0x200000, 0x207fff) AM_RAM AM_BASE(&blackt96_tilemapram2)// sprite list + sprite tilemaps
180   AM_RANGE(0x100000, 0x100fff) AM_RAM AM_BASE_MEMBER(blackt96_state, tilemapram) // text tilemap
181   AM_RANGE(0x200000, 0x207fff) AM_RAM AM_BASE_MEMBER(blackt96_state, tilemapram2)// sprite list + sprite tilemaps
171182   AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(paletteram16_xxxxRRRRGGGGBBBB_word_w) AM_BASE_GENERIC(paletteram)
172183   AM_RANGE(0xc00000, 0xc03fff) AM_RAM // main ram
173184
r10886r10887
471482
472483
473484
474static MACHINE_CONFIG_START( blackt96, driver_device )
485static MACHINE_CONFIG_START( blackt96, blackt96_state )
475486   MCFG_CPU_ADD("maincpu", M68000, 18000000 /2)
476487   MCFG_CPU_PROGRAM_MAP(blackt96_map)
477488   MCFG_CPU_VBLANK_INT("screen", irq1_line_hold)
src/mame/drivers/astrocde.c
r10886r10887
104104    DIP locations verified for:
105105    - seawolf2 (manual)
106106    - wow (manual)
107    - spacezap (manual)
107108    - gorf (manual)
108109    - robby (manual)
109110    - profpac (manual)
r10886r10887
119120#include "sound/samples.h"
120121#include "sound/astrocde.h"
121122#include "sound/ay8910.h"
123
122124#include "tenpindx.lh"
123125#include "gorf.lh"
124126
r10886r10887
833835INPUT_PORTS_END
834836
835837
838static INPUT_CHANGED( spacezap_monitor )
839{
840   if (newval)
841      astrocade_video_config &= ~AC_MONITOR_BW;
842   else
843      astrocade_video_config |= AC_MONITOR_BW;
844}
845
836846static INPUT_PORTS_START( spacezap )
837847   PORT_START("P1HANDLE")
838   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
848   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )   // manual says this dip is unused on cocktail cabs
839849   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
840850   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_TILT )
841851   PORT_SERVICE( 0x08, IP_ACTIVE_LOW )
r10886r10887
844854   PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
845855
846856   PORT_START("P2HANDLE")
847   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY PORT_COCKTAIL
848   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_COCKTAIL
849   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_COCKTAIL
850   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_COCKTAIL
857   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL PORT_NAME("P2 Aim Up")
858   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_COCKTAIL PORT_NAME("P2 Aim Down")
859   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_COCKTAIL PORT_NAME("P2 Aim Left")
860   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_COCKTAIL PORT_NAME("P2 Aim Right")
851861   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
852862   PORT_DIPUNUSED_DIPLOC( 0x20, 0x20, "JU:1" )
853863   PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
854864
855865   PORT_START("P3HANDLE")
856   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY
857   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY
858   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY
859   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY
866   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("P1 Aim Up") PORT_CODE(KEYCODE_UP)
867   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("P1 Aim Down") PORT_CODE(KEYCODE_DOWN)
868   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("P1 Aim Left") PORT_CODE(KEYCODE_LEFT)
869   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("P1 Aim Right") PORT_CODE(KEYCODE_RIGHT)
860870   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
861871   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Cabinet ) )   PORT_DIPLOCATION("JU:2")
862872   PORT_DIPSETTING(    0x20, DEF_STR( Upright ) )
r10886r10887
877887   PORT_DIPUNUSED_DIPLOC( 0x20, 0x00, "S1:6" )
878888   PORT_DIPUNUSED_DIPLOC( 0x40, 0x00, "S1:7" )
879889   PORT_DIPUNUSED_DIPLOC( 0x80, 0x00, "S1:8" )
890
891   PORT_START("FAKE")
892   /* Dedicated cabinets had a B/W monitor and color overlay,
893      some (unofficial/repaired?) cabinets had a color monitor. */
894   PORT_CONFNAME( 0x01, 0x00, "Monitor" ) PORT_CHANGED(spacezap_monitor, 0)
895   PORT_CONFSETTING(    0x00, "B/W" )
896   PORT_CONFSETTING(    0x01, "Color" )
880897INPUT_PORTS_END
881898
882899
r10886r10887
17281745
17291746static DRIVER_INIT( spacezap )
17301747{
1731   astrocade_video_config = AC_SOUND_PRESENT;
1748   astrocade_video_config = AC_SOUND_PRESENT | AC_MONITOR_BW;
17321749   memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x13, 0x13, 0x03ff, 0xff00, spacezap_io_r);
17331750}
17341751
src/mame/drivers/galaga.c
r10886r10887
32723272GAME( 1981, galagamf, galaga,  galaga,  galaga,   galaga,  ROT90, "Namco (Midway license)", "Galaga (Midway set 1 with fast shoot hack)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS )
32733273
32743274GAME( 1982, xevious,  0,       xevious, xevious,  xevious, ROT90, "Namco", "Xevious (Namco)", GAME_SUPPORTS_SAVE )
3275GAME( 1982, xeviousa, xevious, xevious, xeviousa, xevious, ROT90, "Namco (Atari license)", "Xevious (Atari set 1)", GAME_SUPPORTS_SAVE )
3276GAME( 1982, xeviousb, xevious, xevious, xeviousb, xevious, ROT90, "Namco (Atari license)", "Xevious (Atari set 2)", GAME_SUPPORTS_SAVE )
3277GAME( 1982, xeviousc, xevious, xevious, xeviousa, xevious, ROT90, "Namco (Atari license)", "Xevious (Atari set 3)", GAME_SUPPORTS_SAVE )
3275GAME( 1982, xeviousa, xevious, xevious, xeviousa, xevious, ROT90, "Namco (Atari license)", "Xevious (Atari, harder)", GAME_SUPPORTS_SAVE )
3276GAME( 1982, xeviousb, xevious, xevious, xeviousb, xevious, ROT90, "Namco (Atari license)", "Xevious (Atari)", GAME_SUPPORTS_SAVE )
3277GAME( 1982, xeviousc, xevious, xevious, xeviousa, xevious, ROT90, "Namco (Atari license)", "Xevious (Atari, Namco PCB)", GAME_SUPPORTS_SAVE )
32783278GAME( 1984, sxevious, xevious, xevious, sxevious, xevious, ROT90, "Namco", "Super Xevious", GAME_SUPPORTS_SAVE )
32793279GAME( 1984, sxeviousj,xevious, xevious, sxevious, xevious, ROT90, "Namco", "Super Xevious (Japan)", GAME_SUPPORTS_SAVE )
32803280
src/mame/drivers/istellar.c
r10886r10887
2424#include "render.h"
2525#include "machine/laserdsc.h"
2626
27/* There is only 1 crystal on the stack of 3 boards - speed is unknown, the following is Daphne's guess */
28#define GUESSED_CLOCK (3072000)
2927
28class istellar_state : public driver_device
29{
30public:
31   istellar_state(running_machine &machine, const driver_device_config_base &config)
32      : driver_device(machine, config) { }
3033
31/* Misc variables */
32static device_t *laserdisc;
34   device_t *laserdisc;
35   UINT8 *tile_ram;
36   UINT8 *tile_control_ram;
37   UINT8 *sprite_ram;
38   UINT8 ldp_latch1;
39   UINT8 ldp_latch2;
40   UINT8 z80_2_nmi_enable;
41};
3342
34static UINT8 *tile_ram;
35static UINT8 *tile_control_ram;
36static UINT8 *sprite_ram;
3743
38static UINT8 ldp_latch1;
39static UINT8 ldp_latch2;
44/* There is only 1 crystal on the stack of 3 boards - speed is unknown, the following is Daphne's guess */
45#define GUESSED_CLOCK (3072000)
4046
41static UINT8 z80_2_nmi_enable;
4247
4348/* VIDEO GOODS */
4449static SCREEN_UPDATE( istellar )
4550{
51   istellar_state *state = screen->machine->driver_data<istellar_state>();
4652   int charx, chary;
4753
4854   /* clear */
r10886r10887
5258   /*
5359    for (charx = 0; charx < 0x400; charx ++)
5460    {
55        printf ("%x ", sprite_ram[charx]) ;
61        printf ("%x ", state->sprite_ram[charx]) ;
5662    }
5763    printf("\n\n\n");
5864    */
r10886r10887
6571         int current_screen_character = (chary*32) + charx;
6672
6773         drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[0],
68               tile_ram[current_screen_character],
69               (tile_control_ram[current_screen_character] & 0x0f),
74               state->tile_ram[current_screen_character],
75               (state->tile_control_ram[current_screen_character] & 0x0f),
7076               0, 0, charx*8, chary*8, 0);
7177      }
7278   }
r10886r10887
8086
8187static MACHINE_START( istellar )
8288{
83   laserdisc = machine->device("laserdisc");
89   istellar_state *state = machine->driver_data<istellar_state>();
90   state->laserdisc = machine->device("laserdisc");
8491}
8592
8693
r10886r10887
8996/* Z80 0 R/W */
9097static READ8_HANDLER(z80_0_latch1_read)
9198{
92   /*logerror("CPU0 : reading LDP status latch (%x)\n", ldp_latch1);*/
93   return ldp_latch1;
99   istellar_state *state = space->machine->driver_data<istellar_state>();
100   /*logerror("CPU0 : reading LDP status latch (%x)\n", state->ldp_latch1);*/
101   return state->ldp_latch1;
94102}
95103
96104static WRITE8_HANDLER(z80_0_latch2_write)
97105{
106   istellar_state *state = space->machine->driver_data<istellar_state>();
98107   /*logerror("CPU0 : writing cpu_latch2 (%x).  Potentially followed by an IRQ.\n", data);*/
99   ldp_latch2 = data;
108   state->ldp_latch2 = data;
100109
101110   /* A CPU2 NMI */
102   if (z80_2_nmi_enable)
111   if (state->z80_2_nmi_enable)
103112   {
104113      logerror("Executing an NMI on CPU2\n");
105114      cputag_set_input_line(space->machine, "sub", INPUT_LINE_NMI, PULSE_LINE);      /* Maybe this is a ASSERT_LINE, CLEAR_LINE combo? */
106      z80_2_nmi_enable = 0;
115      state->z80_2_nmi_enable = 0;
107116   }
108117}
109118
r10886r10887
114123/* Z80 2 R/W */
115124static READ8_HANDLER(z80_2_ldp_read)
116125{
117   UINT8 readResult = laserdisc_data_r(laserdisc);
126   istellar_state *state = space->machine->driver_data<istellar_state>();
127   UINT8 readResult = laserdisc_data_r(state->laserdisc);
118128   logerror("CPU2 : reading LDP : %x\n", readResult);
119129   return readResult;
120130}
121131
122132static READ8_HANDLER(z80_2_latch2_read)
123133{
124   logerror("CPU2 : reading latch2 (%x)\n", ldp_latch2);
125   return ldp_latch2;
134   istellar_state *state = space->machine->driver_data<istellar_state>();
135   logerror("CPU2 : reading latch2 (%x)\n", state->ldp_latch2);
136   return state->ldp_latch2;
126137}
127138
128139static READ8_HANDLER(z80_2_nmienable)
129140{
141   istellar_state *state = space->machine->driver_data<istellar_state>();
130142   logerror("CPU2 : ENABLING NMI\n");
131   z80_2_nmi_enable = 1;
143   state->z80_2_nmi_enable = 1;
132144   return 0x00;
133145}
134146
r10886r10887
140152
141153static WRITE8_HANDLER(z80_2_latch1_write)
142154{
155   istellar_state *state = space->machine->driver_data<istellar_state>();
143156   logerror("CPU2 : writing latch1 (%x)\n", data);
144   ldp_latch1 = data;
157   state->ldp_latch1 = data;
145158}
146159
147160static WRITE8_HANDLER(z80_2_ldp_write)
148161{
162   istellar_state *state = space->machine->driver_data<istellar_state>();
149163   logerror("CPU2 : writing LDP : 0x%x\n", data);
150   laserdisc_data_w(laserdisc,data);
164   laserdisc_data_w(state->laserdisc,data);
151165}
152166
153167
r10886r10887
156170static ADDRESS_MAP_START( z80_0_mem, ADDRESS_SPACE_PROGRAM, 8 )
157171   AM_RANGE(0x0000,0x9fff) AM_ROM
158172   AM_RANGE(0xa000,0xa7ff) AM_RAM
159   AM_RANGE(0xa800,0xabff) AM_RAM AM_BASE(&tile_ram)
160   AM_RANGE(0xac00,0xafff) AM_RAM AM_BASE(&tile_control_ram)
161   AM_RANGE(0xb000,0xb3ff) AM_RAM AM_BASE(&sprite_ram)
173   AM_RANGE(0xa800,0xabff) AM_RAM AM_BASE_MEMBER(istellar_state, tile_ram)
174   AM_RANGE(0xac00,0xafff) AM_RAM AM_BASE_MEMBER(istellar_state, tile_control_ram)
175   AM_RANGE(0xb000,0xb3ff) AM_RAM AM_BASE_MEMBER(istellar_state, sprite_ram)
162176ADDRESS_MAP_END
163177
164178static ADDRESS_MAP_START( z80_1_mem, ADDRESS_SPACE_PROGRAM, 8 )
r10886r10887
321335
322336
323337/* DRIVER */
324static MACHINE_CONFIG_START( istellar, driver_device )
338static MACHINE_CONFIG_START( istellar, istellar_state )
325339   /* main cpu */
326340   MCFG_CPU_ADD("maincpu", Z80, GUESSED_CLOCK)
327341   MCFG_CPU_PROGRAM_MAP(z80_0_mem)
r10886r10887
397411
398412static DRIVER_INIT( istellar )
399413{
400   z80_2_nmi_enable = 0;
414   istellar_state *state = machine->driver_data<istellar_state>();
415   state->z80_2_nmi_enable = 0;
401416}
402417
403418/*    YEAR  NAME    PARENT   MACHINE  INPUT    INIT    MONITOR  COMPANY          FULLNAME                       FLAGS) */
src/mame/drivers/8080bw.c
r10886r10887
27612761   ROM_LOAD( "univgw6.3",    0x0c00, 0x0400, CRC(7b7d22ff) SHA1(74364cf2b04dcfbbc8e0131fa12c0e574f693d34) )
27622762   ROM_LOAD( "univgw1.4",    0x4000, 0x0400, CRC(0871156e) SHA1(3726d0bfe153a0afc62ea56737662074986064b0) )
27632763   ROM_LOAD( "univgw2.5",    0x4400, 0x0400, CRC(6036d7bf) SHA1(36c2ad2ffdb47bbecc40fd67ced6ab51a5cd2f3e) )
2764
2765   ROM_REGION( 0x0800, "proms", 0 )      /* color maps player 1/player 2 */
2766   /* !! not dumped yet, these were taken from sisv/intruder */
2767   ROM_LOAD( "01.bin",       0x0000, 0x0400, BAD_DUMP CRC(aac24f34) SHA1(ad110e776547fb48baac568bb50d61854537ca34) )
2768   ROM_LOAD( "02.bin",       0x0400, 0x0400, BAD_DUMP CRC(2bdf83a0) SHA1(01ffbd43964c41987e7d44816271308f9a70802b) )
27642769ROM_END
27652770
27662771ROM_START( galxwars2 )
27672772   ROM_REGION( 0x10000, "maincpu", 0 )
27682773   ROM_LOAD( "3192.h6",      0x0000, 0x1000, CRC(bde6860b) SHA1(e04b8add32d8f7ea588fae6d6a387f1d40495f1b) )
27692774   ROM_LOAD( "3193.h7",      0x4000, 0x1000, CRC(a17cd507) SHA1(554ab0e8bdc0e7af4a30b0ddc8aa053c8e70255c) ) /* 2nd half unused */
2775
2776   ROM_REGION( 0x0800, "proms", 0 )      /* color maps player 1/player 2 */
2777   /* !! not dumped yet, these were taken from sisv/intruder */
2778   ROM_LOAD( "01.bin",       0x0000, 0x0400, BAD_DUMP CRC(aac24f34) SHA1(ad110e776547fb48baac568bb50d61854537ca34) )
2779   ROM_LOAD( "02.bin",       0x0400, 0x0400, BAD_DUMP CRC(2bdf83a0) SHA1(01ffbd43964c41987e7d44816271308f9a70802b) )
27702780ROM_END
27712781
27722782ROM_START( galxwarst )
r10886r10887
27772787   ROM_LOAD( "galxwars.3",   0x0c00, 0x0400, CRC(c88f886c) SHA1(4d705fbb97e3868c3f6c90c5e5753ad17cfbf5d6) )
27782788   ROM_LOAD( "galxwars.4",   0x4000, 0x0400, CRC(ae4fe8fb) SHA1(494f44167dc84e4515b769c12f6e24419461dce4) )
27792789   ROM_LOAD( "galxwars.5",   0x4400, 0x0400, CRC(37708a35) SHA1(df6fd521ddfa146ef93e390e47741bdbfda1e7ba) )
2790
2791   ROM_REGION( 0x0800, "proms", 0 )      /* color maps player 1/player 2 */
2792   /* !! not dumped yet, these were taken from sisv/intruder */
2793   ROM_LOAD( "01.bin",       0x0000, 0x0400, BAD_DUMP CRC(aac24f34) SHA1(ad110e776547fb48baac568bb50d61854537ca34) )
2794   ROM_LOAD( "02.bin",       0x0400, 0x0400, BAD_DUMP CRC(2bdf83a0) SHA1(01ffbd43964c41987e7d44816271308f9a70802b) )
27802795ROM_END
27812796
27822797ROM_START( starw )
r10886r10887
33793394GAME( 1979, sicv,     invaders, invadpt2, sicv,     0, ROT270, "Taito", "Space Invaders (CV Version)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
33803395GAME( 1978, sisv,     invaders, invadpt2, sicv,     0, ROT270, "Taito", "Space Invaders (SV Version)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
33813396GAME( 1978, sisv2,    invaders, invadpt2, sicv,     0, ROT270, "Taito", "Space Invaders (SV Version 2)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
3382GAMEL(1979, galxwars, 0,        invaders, galxwars, 0, ROT270, "Universal", "Galaxy Wars (Universal set 1)", GAME_SUPPORTS_SAVE, layout_invaders )
3383GAMEL(1979, galxwars2,galxwars, invaders, galxwars, 0, ROT270, "Universal", "Galaxy Wars (Universal set 2)", GAME_SUPPORTS_SAVE, layout_invaders )
3384GAMEL(1979, galxwarst,galxwars, invaders, galxwars, 0, ROT270, "Universal (Taito license?)", "Galaxy Wars (Taito?)" , GAME_SUPPORTS_SAVE, layout_invaders) /* Copyright Not Displayed */
3385GAMEL(1979, starw,    galxwars, invaders, galxwars, 0, ROT270, "bootleg", "Star Wars", GAME_SUPPORTS_SAVE, layout_invaders )
3397GAME( 1979, galxwars, 0,        invadpt2, galxwars, 0, ROT270, "Universal", "Galaxy Wars (Universal set 1)", GAME_WRONG_COLORS | GAME_SUPPORTS_SAVE )
3398GAME( 1979, galxwars2,galxwars, invadpt2, galxwars, 0, ROT270, "Universal", "Galaxy Wars (Universal set 2)", GAME_WRONG_COLORS | GAME_SUPPORTS_SAVE )
3399GAME( 1979, galxwarst,galxwars, invadpt2, galxwars, 0, ROT270, "Universal (Taito license?)", "Galaxy Wars (Taito?)" , GAME_WRONG_COLORS | GAME_SUPPORTS_SAVE ) /* Copyright Not Displayed */
3400GAME( 1979, starw,    galxwars, invaders, galxwars, 0, ROT270, "bootleg", "Star Wars", GAME_SUPPORTS_SAVE )
33863401GAME( 1979, lrescue,  0,        lrescue,  lrescue,  0, ROT270, "Taito", "Lunar Rescue", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND )
33873402GAME( 1980, mlander,  lrescue,  invaders, lrescue,  0, ROT270, "bootleg (Leisure Time Electronics)", "Moon Lander (bootleg of Lunar Rescue)", GAME_SUPPORTS_SAVE )
33883403GAME( 1978, lrescuem, lrescue,  lrescue,  lrescue,  0, ROT270, "bootleg (Model Racing)", "Lunar Rescue (Model Racing bootleg)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND )
src/mame/drivers/ettrivia.c
r10886r10887
3131#include "includes/naughtyb.h"
3232
3333
34static int palreg = 0;
35static int gfx_bank = 0;
36static int question_bank = 0;
34class ettrivia_state : public driver_device
35{
36public:
37   ettrivia_state(running_machine &machine, const driver_device_config_base &config)
38      : driver_device(machine, config) { }
3739
38static int b000_val = 0;
39static int b000_ret = 0;
40static int b800_prev = 0;
40   int palreg;
41   int gfx_bank;
42   int question_bank;
43   int b000_val;
44   int b000_ret;
45   int b800_prev;
46   UINT8 *bg_videoram;
47   UINT8 *fg_videoram;
48   tilemap_t *bg_tilemap;
49   tilemap_t *fg_tilemap;
50};
4151
42static UINT8 *bg_videoram, *fg_videoram;
43static tilemap_t *bg_tilemap, *fg_tilemap;
4452
4553static WRITE8_HANDLER( ettrivia_fg_w )
4654{
47   fg_videoram[offset] = data;
48   tilemap_mark_tile_dirty(fg_tilemap,offset);
55   ettrivia_state *state = space->machine->driver_data<ettrivia_state>();
56   state->fg_videoram[offset] = data;
57   tilemap_mark_tile_dirty(state->fg_tilemap,offset);
4958}
5059
5160static WRITE8_HANDLER( ettrivia_bg_w )
5261{
53   bg_videoram[offset] = data;
54   tilemap_mark_tile_dirty(bg_tilemap,offset);
62   ettrivia_state *state = space->machine->driver_data<ettrivia_state>();
63   state->bg_videoram[offset] = data;
64   tilemap_mark_tile_dirty(state->bg_tilemap,offset);
5565}
5666
5767static WRITE8_HANDLER( ettrivia_control_w )
5868{
69   ettrivia_state *state = space->machine->driver_data<ettrivia_state>();
5970   tilemap_mark_all_tiles_dirty_all(space->machine);
6071
61   palreg  = (data >> 1) & 3;
62   gfx_bank = (data >> 2) & 1;
72   state->palreg  = (data >> 1) & 3;
73   state->gfx_bank = (data >> 2) & 1;
6374
64   question_bank = (data >> 3) & 3;
75   state->question_bank = (data >> 3) & 3;
6576
6677   coin_counter_w(space->machine, 0, data & 0x80);
6778
r10886r10887
7081
7182static READ8_HANDLER( ettrivia_question_r )
7283{
84   ettrivia_state *state = space->machine->driver_data<ettrivia_state>();
7385   UINT8 *QUESTIONS = space->machine->region("user1")->base();
74   return QUESTIONS[offset + 0x10000 * question_bank];
86   return QUESTIONS[offset + 0x10000 * state->question_bank];
7587}
7688
7789static WRITE8_HANDLER( b000_w )
7890{
79   b000_val = data;
91   ettrivia_state *state = space->machine->driver_data<ettrivia_state>();
92   state->b000_val = data;
8093}
8194
8295static READ8_HANDLER( b000_r )
8396{
84   if(b800_prev)
85      return b000_ret;
97   ettrivia_state *state = space->machine->driver_data<ettrivia_state>();
98   if(state->b800_prev)
99      return state->b000_ret;
86100   else
87      return b000_val;
101      return state->b000_val;
88102}
89103
90104static WRITE8_HANDLER( b800_w )
91105{
106   ettrivia_state *state = space->machine->driver_data<ettrivia_state>();
92107   switch(data)
93108   {
94109      /* special case to return the value written to 0xb000 */
95110      /* does it reset the chips too ? */
96111      case 0:   break;
97      case 0xc4: b000_ret = ay8910_r(space->machine->device("ay1"), 0);   break;
98      case 0x94: b000_ret = ay8910_r(space->machine->device("ay2"), 0);   break;
99      case 0x86: b000_ret = ay8910_r(space->machine->device("ay3"), 0);   break;
112      case 0xc4: state->b000_ret = ay8910_r(space->machine->device("ay1"), 0);   break;
113      case 0x94: state->b000_ret = ay8910_r(space->machine->device("ay2"), 0);   break;
114      case 0x86: state->b000_ret = ay8910_r(space->machine->device("ay3"), 0);   break;
100115
101116      case 0x80:
102         switch(b800_prev)
117         switch(state->b800_prev)
103118         {
104            case 0xe0: ay8910_address_w(space->machine->device("ay1"),0,b000_val);   break;
105            case 0x98: ay8910_address_w(space->machine->device("ay2"),0,b000_val);   break;
106            case 0x83: ay8910_address_w(space->machine->device("ay3"),0,b000_val);   break;
119            case 0xe0: ay8910_address_w(space->machine->device("ay1"),0,state->b000_val);   break;
120            case 0x98: ay8910_address_w(space->machine->device("ay2"),0,state->b000_val);   break;
121            case 0x83: ay8910_address_w(space->machine->device("ay3"),0,state->b000_val);   break;
107122
108            case 0xa0: ay8910_data_w(space->machine->device("ay1"),0,b000_val);   break;
109            case 0x88: ay8910_data_w(space->machine->device("ay2"),0,b000_val);   break;
110            case 0x81: ay8910_data_w(space->machine->device("ay3"),0,b000_val);   break;
123            case 0xa0: ay8910_data_w(space->machine->device("ay1"),0,state->b000_val);   break;
124            case 0x88: ay8910_data_w(space->machine->device("ay2"),0,state->b000_val);   break;
125            case 0x81: ay8910_data_w(space->machine->device("ay3"),0,state->b000_val);   break;
111126
112127         }
113128      break;
114129   }
115130
116   b800_prev = data;
131   state->b800_prev = data;
117132}
118133
119134static ADDRESS_MAP_START( cpu_map, ADDRESS_SPACE_PROGRAM, 8 )
r10886r10887
124139   AM_RANGE(0xa000, 0xa000) AM_WRITENOP
125140   AM_RANGE(0xb000, 0xb000) AM_READ(b000_r) AM_WRITE(b000_w)
126141   AM_RANGE(0xb800, 0xb800) AM_WRITE(b800_w)
127   AM_RANGE(0xc000, 0xc7ff) AM_RAM_WRITE(ettrivia_fg_w) AM_BASE(&fg_videoram)
128   AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(ettrivia_bg_w) AM_BASE(&bg_videoram)
142   AM_RANGE(0xc000, 0xc7ff) AM_RAM_WRITE(ettrivia_fg_w) AM_BASE_MEMBER(ettrivia_state, fg_videoram)
143   AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(ettrivia_bg_w) AM_BASE_MEMBER(ettrivia_state, bg_videoram)
129144ADDRESS_MAP_END
130145
131146static ADDRESS_MAP_START( io_map, ADDRESS_SPACE_IO, 8 )
r10886r10887
175190
176191INLINE void get_tile_info(running_machine *machine, tile_data *tileinfo, int tile_index, UINT8 *vidram, int gfx_code)
177192{
193   ettrivia_state *state = machine->driver_data<ettrivia_state>();
178194   int code = vidram[tile_index];
179   int color = (code >> 5) + 8 * palreg;
195   int color = (code >> 5) + 8 * state->palreg;
180196
181   code += gfx_bank * 0x100;
197   code += state->gfx_bank * 0x100;
182198
183199   SET_TILE_INFO(gfx_code,code,color,0);
184200}
185201
186202static TILE_GET_INFO( get_tile_info_bg )
187203{
188   get_tile_info(machine, tileinfo, tile_index, bg_videoram, 0);
204   ettrivia_state *state = machine->driver_data<ettrivia_state>();
205   get_tile_info(machine, tileinfo, tile_index, state->bg_videoram, 0);
189206}
190207
191208static TILE_GET_INFO( get_tile_info_fg )
192209{
193   get_tile_info(machine, tileinfo, tile_index, fg_videoram, 1);
210   ettrivia_state *state = machine->driver_data<ettrivia_state>();
211   get_tile_info(machine, tileinfo, tile_index, state->fg_videoram, 1);
194212}
195213
196214static VIDEO_START( ettrivia )
197215{
198   bg_tilemap = tilemap_create( machine, get_tile_info_bg,tilemap_scan_rows,8,8,64,32 );
199   fg_tilemap = tilemap_create( machine, get_tile_info_fg,tilemap_scan_rows,8,8,64,32 );
216   ettrivia_state *state = machine->driver_data<ettrivia_state>();
217   state->bg_tilemap = tilemap_create( machine, get_tile_info_bg,tilemap_scan_rows,8,8,64,32 );
218   state->fg_tilemap = tilemap_create( machine, get_tile_info_fg,tilemap_scan_rows,8,8,64,32 );
200219
201   tilemap_set_transparent_pen(fg_tilemap,0);
220   tilemap_set_transparent_pen(state->fg_tilemap,0);
202221}
203222
204223static SCREEN_UPDATE( ettrivia )
205224{
206   tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
207   tilemap_draw(bitmap,cliprect,fg_tilemap,0,0);
225   ettrivia_state *state = screen->machine->driver_data<ettrivia_state>();
226   tilemap_draw(bitmap,cliprect,state->bg_tilemap,0,0);
227   tilemap_draw(bitmap,cliprect,state->fg_tilemap,0,0);
208228   return 0;
209229}
210230
r10886r10887
237257      cpu_set_input_line(device, 0, HOLD_LINE);
238258}
239259
240static MACHINE_CONFIG_START( ettrivia, driver_device )
260static MACHINE_CONFIG_START( ettrivia, ettrivia_state )
241261   MCFG_CPU_ADD("maincpu", Z80,12000000/4-48000) //should be ok, it gives the 300 interrupts expected
242262   MCFG_CPU_PROGRAM_MAP(cpu_map)
243263   MCFG_CPU_IO_MAP(io_map)
src/mame/drivers/thayers.c
r10886r10887
1717#include "cpu/cop400/cop400.h"
1818//#include "dlair.lh"
1919
20extern const char layout_dlair[];
2120
22static device_t *laserdisc;
23static UINT8 laserdisc_data;
21struct ssi263_t
22{
23   UINT8 dr;
24   UINT8 p;
25   UINT16 i;
26   UINT8 r;
27   UINT8 t;
28   UINT8 c;
29   UINT8 a;
30   UINT8 f;
31   UINT8 mode;
32};
2433
25static int rx_bit;
26static int keylatch;
34class thayers_state : public driver_device
35{
36public:
37   thayers_state(running_machine &machine, const driver_device_config_base &config)
38      : driver_device(machine, config) { }
2739
28static UINT8 cop_data_latch;
29static int cop_data_latch_enable;
30static UINT8 cop_l;
31static UINT8 cop_cmd_latch;
40   device_t *laserdisc;
41   UINT8 laserdisc_data;
42   int rx_bit;
43   int keylatch;
44   UINT8 cop_data_latch;
45   int cop_data_latch_enable;
46   UINT8 cop_l;
47   UINT8 cop_cmd_latch;
48   int timer_int;
49   int data_rdy_int;
50   int ssi_data_request;
51   int cart_present;
52   int pr7820_enter;
53   struct ssi263_t ssi263;
54};
3255
33static int timer_int;
34static int data_rdy_int;
35static int ssi_data_request;
3656
37static int cart_present;
38static int pr7820_enter;
57extern const char layout_dlair[];
3958
59
60
4061static const UINT8 led_map[16] = { 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7c, 0x07, 0x7f, 0x67, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x00 };
4162
4263/* Interrupts */
4364
4465static void check_interrupt(running_machine *machine)
4566{
46   if (!timer_int || !data_rdy_int || !ssi_data_request)
67   thayers_state *state = machine->driver_data<thayers_state>();
68   if (!state->timer_int || !state->data_rdy_int || !state->ssi_data_request)
4769   {
4870      cputag_set_input_line(machine, "maincpu", INPUT_LINE_IRQ0, HOLD_LINE);
4971   }
r10886r10887
6991
7092static READ8_HANDLER( irqstate_r )
7193{
94   thayers_state *state = space->machine->driver_data<thayers_state>();
7295   /*
7396
7497        bit     description
r10886r10887
84107
85108    */
86109
87   return (data_rdy_int << 5) | (timer_int << 4) | 0x08 | (ssi_data_request << 2);
110   return (state->data_rdy_int << 5) | (state->timer_int << 4) | 0x08 | (state->ssi_data_request << 2);
88111}
89112
90113static WRITE8_HANDLER( timer_int_ack_w )
91114{
92   timer_int = 1;
115   thayers_state *state = space->machine->driver_data<thayers_state>();
116   state->timer_int = 1;
93117
94118   check_interrupt(space->machine);
95119}
96120
97121static WRITE8_HANDLER( data_rdy_int_ack_w )
98122{
99   data_rdy_int = 1;
123   thayers_state *state = space->machine->driver_data<thayers_state>();
124   state->data_rdy_int = 1;
100125
101126   check_interrupt(space->machine);
102127}
103128
104129static WRITE8_HANDLER( cop_d_w )
105130{
131   thayers_state *state = space->machine->driver_data<thayers_state>();
106132   /*
107133
108134        bit     description
r10886r10887
116142
117143   if (!BIT(data, 0))
118144   {
119      timer_int = 0;
145      state->timer_int = 0;
120146   }
121147
122148   if (!BIT(data, 1))
123149   {
124      data_rdy_int = 0;
150      state->data_rdy_int = 0;
125151   }
126152
127153   check_interrupt(space->machine);
r10886r10887
131157
132158static READ8_HANDLER( cop_data_r )
133159{
134   if (!cop_data_latch_enable)
160   thayers_state *state = space->machine->driver_data<thayers_state>();
161   if (!state->cop_data_latch_enable)
135162   {
136      return cop_data_latch;
163      return state->cop_data_latch;
137164   }
138165   else
139166   {
140      return cop_l;
167      return state->cop_l;
141168   }
142169}
143170
144171static WRITE8_HANDLER( cop_data_w )
145172{
146   cop_data_latch = data;
173   thayers_state *state = space->machine->driver_data<thayers_state>();
174   state->cop_data_latch = data;
147175}
148176
149177static READ8_HANDLER( cop_l_r )
150178{
151   if (!cop_data_latch_enable)
179   thayers_state *state = space->machine->driver_data<thayers_state>();
180   if (!state->cop_data_latch_enable)
152181   {
153      return cop_data_latch;
182      return state->cop_data_latch;
154183   }
155184   else
156185   {
r10886r10887
160189
161190static WRITE8_HANDLER( cop_l_w )
162191{
163   cop_l = data;
192   thayers_state *state = space->machine->driver_data<thayers_state>();
193   state->cop_l = data;
164194}
165195
166196static READ8_HANDLER( cop_g_r )
167197{
198   thayers_state *state = space->machine->driver_data<thayers_state>();
168199   /*
169200
170201        bit     description
r10886r10887
176207
177208    */
178209
179   return cop_cmd_latch;
210   return state->cop_cmd_latch;
180211}
181212
182213static WRITE8_HANDLER( control_w )
183214{
215   thayers_state *state = space->machine->driver_data<thayers_state>();
184216   /*
185217
186218        bit     description
r10886r10887
196228
197229    */
198230
199   cop_cmd_latch = (data >> 5) & 0x07;
231   state->cop_cmd_latch = (data >> 5) & 0x07;
200232}
201233
202234static WRITE8_HANDLER( cop_g_w )
203235{
236   thayers_state *state = space->machine->driver_data<thayers_state>();
204237   /*
205238
206239        bit     description
r10886r10887
212245
213246    */
214247
215   cop_data_latch_enable = BIT(data, 3);
248   state->cop_data_latch_enable = BIT(data, 3);
216249}
217250
218251/* Keyboard */
219252
220253static READ8_HANDLER(cop_si_r)
221254{
255   thayers_state *state = space->machine->driver_data<thayers_state>();
222256   /* keyboard data */
223257
224258   /*
r10886r10887
229263
230264    */
231265
232   switch (rx_bit)
266   switch (state->rx_bit)
233267   {
234268   case 0:
235269   case 1:
r10886r10887
237271      return 1;
238272
239273   case 4:
240      return (keylatch == 9);
274      return (state->keylatch == 9);
241275
242276   case 5:
243277   case 6:
r10886r10887
247281         UINT8 data;
248282         char port[4];
249283
250         sprintf(port, "R%d", keylatch);
284         sprintf(port, "R%d", state->keylatch);
251285
252         data = BIT(input_port_read(space->machine, port), rx_bit - 5);
286         data = BIT(input_port_read(space->machine, port), state->rx_bit - 5);
253287
254288         return data;
255289      }
r10886r10887
261295
262296static WRITE8_HANDLER( cop_so_w )
263297{
298   thayers_state *state = space->machine->driver_data<thayers_state>();
264299   /* keyboard clock */
265300
266301   if (data)
267302   {
268      rx_bit++;
303      state->rx_bit++;
269304
270      if (rx_bit == 10)
305      if (state->rx_bit == 10)
271306      {
272         rx_bit = 0;
307         state->rx_bit = 0;
273308
274         keylatch++;
309         state->keylatch++;
275310
276         if (keylatch == 10)
311         if (state->keylatch == 10)
277312         {
278            keylatch = 0;
313            state->keylatch = 0;
279314         }
280315      }
281316   }
r10886r10887
285320
286321static WRITE8_HANDLER( control2_w )
287322{
323   thayers_state *state = space->machine->driver_data<thayers_state>();
288324   /*
289325
290326        bit     description
r10886r10887
300336
301337    */
302338
303   if ((!BIT(data, 2)) & cart_present)
339   if ((!BIT(data, 2)) & state->cart_present)
304340   {
305341      cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_NMI, HOLD_LINE);
306342   }
r10886r10887
313349
314350static READ8_HANDLER( laserdsc_data_r )
315351{
316   return laserdisc_data_r(laserdisc);
352   thayers_state *state = space->machine->driver_data<thayers_state>();
353   return laserdisc_data_r(state->laserdisc);
317354}
318355
319356static WRITE8_HANDLER( laserdsc_data_w )
320357{
321   laserdisc_data = data;
358   thayers_state *state = space->machine->driver_data<thayers_state>();
359   state->laserdisc_data = data;
322360}
323361
324362static WRITE8_HANDLER( laserdsc_control_w )
325363{
364   thayers_state *state = space->machine->driver_data<thayers_state>();
326365   /*
327366
328367        bit     description
r10886r10887
342381
343382   if (BIT(data, 5))
344383   {
345      laserdisc_data_w(laserdisc, laserdisc_data);
384      laserdisc_data_w(state->laserdisc, state->laserdisc_data);
346385   }
347386
348   switch (laserdisc_get_type(laserdisc))
387   switch (laserdisc_get_type(state->laserdisc))
349388   {
350389      case LASERDISC_TYPE_PIONEER_PR7820:
351         pr7820_enter = BIT(data, 6) ? CLEAR_LINE : ASSERT_LINE;
390         state->pr7820_enter = BIT(data, 6) ? CLEAR_LINE : ASSERT_LINE;
352391
353         laserdisc_line_w(laserdisc, LASERDISC_LINE_ENTER, pr7820_enter);
392         laserdisc_line_w(state->laserdisc, LASERDISC_LINE_ENTER, state->pr7820_enter);
354393
355394         // BIT(data, 7) is INT/_EXT, but there is no such input line in laserdsc.h
356395         break;
357396
358397      case LASERDISC_TYPE_PIONEER_LDV1000:
359         laserdisc_line_w(laserdisc, LASERDISC_LINE_ENTER, BIT(data, 7) ? CLEAR_LINE : ASSERT_LINE);
398         laserdisc_line_w(state->laserdisc, LASERDISC_LINE_ENTER, BIT(data, 7) ? CLEAR_LINE : ASSERT_LINE);
360399         break;
361400   }
362401}
r10886r10887
419458   "L", "L1", "LF", "W", "B", "D", "KV", "P", "T", "K", "HV", "HVC", "HF", "HFC", "HN", "Z", "S", "J", "SCH", "V", "F", "THV", "TH", "M", "N", "NG", ":A", ":OH", ":U", ":UH", "E2", "LB"
420459};
421460
422static struct SSI263
423{
424   UINT8 dr;
425   UINT8 p;
426   UINT16 i;
427   UINT8 r;
428   UINT8 t;
429   UINT8 c;
430   UINT8 a;
431   UINT8 f;
432   UINT8 mode;
433} ssi263;
434
435461static TIMER_CALLBACK( ssi263_phoneme_tick )
436462{
437   ssi_data_request = 0;
463   thayers_state *state = machine->driver_data<thayers_state>();
464   state->ssi_data_request = 0;
438465   check_interrupt(machine);
439466}
440467
441468static WRITE8_HANDLER( ssi263_register_w )
442469{
470   thayers_state *state = space->machine->driver_data<thayers_state>();
471   struct ssi263_t &ssi263 = state->ssi263;
443472   switch (offset)
444473   {
445474   case 0:
r10886r10887
451480      ssi263.dr = (data >> 5) & 0x03;
452481      ssi263.p = data & 0x3f;
453482
454      ssi_data_request = 1;
483      state->ssi_data_request = 1;
455484      check_interrupt(space->machine);
456485
457486      switch (ssi263.mode)
r10886r10887
541570
542571static READ8_HANDLER( ssi263_register_r )
543572{
573   thayers_state *state = space->machine->driver_data<thayers_state>();
544574   // D7 becomes an output, as the inverted state of A/_R. The register address bits are ignored.
545575
546   return !ssi_data_request << 7;
576   return !state->ssi_data_request << 7;
547577}
548578
549579/* Memory Maps */
r10886r10887
584614
585615static CUSTOM_INPUT( laserdisc_enter_r )
586616{
587   switch (laserdisc_get_type(laserdisc))
617   thayers_state *state = field->port->machine->driver_data<thayers_state>();
618   switch (laserdisc_get_type(state->laserdisc))
588619   {
589620      case LASERDISC_TYPE_PIONEER_PR7820:
590         return pr7820_enter;
621         return state->pr7820_enter;
591622
592623      case LASERDISC_TYPE_PIONEER_LDV1000:
593         return (laserdisc_line_r(laserdisc, LASERDISC_LINE_STATUS) == ASSERT_LINE) ? 0 : 1;
624         return (laserdisc_line_r(state->laserdisc, LASERDISC_LINE_STATUS) == ASSERT_LINE) ? 0 : 1;
594625   }
595626
596627   return 0;
r10886r10887
598629
599630static CUSTOM_INPUT( laserdisc_ready_r )
600631{
601   switch (laserdisc_get_type(laserdisc))
632   thayers_state *state = field->port->machine->driver_data<thayers_state>();
633   switch (laserdisc_get_type(state->laserdisc))
602634   {
603635      case LASERDISC_TYPE_PIONEER_PR7820:
604         return (laserdisc_line_r(laserdisc, LASERDISC_LINE_READY) == ASSERT_LINE) ? 0 : 1;
636         return (laserdisc_line_r(state->laserdisc, LASERDISC_LINE_READY) == ASSERT_LINE) ? 0 : 1;
605637
606638      case LASERDISC_TYPE_PIONEER_LDV1000:
607         return (laserdisc_line_r(laserdisc, LASERDISC_LINE_COMMAND) == ASSERT_LINE) ? 0 : 1;
639         return (laserdisc_line_r(state->laserdisc, LASERDISC_LINE_COMMAND) == ASSERT_LINE) ? 0 : 1;
608640   }
609641
610642   return 0;
r10886r10887
715747
716748static MACHINE_START( thayers )
717749{
718   laserdisc = machine->device("laserdisc");
719   memset(&ssi263, 0, sizeof(ssi263));
750   thayers_state *state = machine->driver_data<thayers_state>();
751   state->laserdisc = machine->device("laserdisc");
752   memset(&state->ssi263, 0, sizeof(state->ssi263));
720753}
721754
722755static MACHINE_RESET( thayers )
723756{
757   thayers_state *state = machine->driver_data<thayers_state>();
724758   int newtype;
725759
726   laserdisc_data = 0;
760   state->laserdisc_data = 0;
727761
728   rx_bit = 0;
729   keylatch = 0;
762   state->rx_bit = 0;
763   state->keylatch = 0;
730764
731   cop_data_latch = 0;
732   cop_data_latch_enable = 0;
733   cop_l = 0;
734   cop_cmd_latch = 0;
765   state->cop_data_latch = 0;
766   state->cop_data_latch_enable = 0;
767   state->cop_l = 0;
768   state->cop_cmd_latch = 0;
735769
736   timer_int = 1;
737   data_rdy_int = 1;
738   ssi_data_request = 1;
770   state->timer_int = 1;
771   state->data_rdy_int = 1;
772   state->ssi_data_request = 1;
739773
740   cart_present = 0;
741   pr7820_enter = 0;
774   state->cart_present = 0;
775   state->pr7820_enter = 0;
742776
743777   newtype = (input_port_read(machine, "DSWB") & 0x18) ? LASERDISC_TYPE_PIONEER_LDV1000 : LASERDISC_TYPE_PIONEER_PR7820;
744   laserdisc_set_type(laserdisc, newtype);
778   laserdisc_set_type(state->laserdisc, newtype);
745779}
746780
747781/* COP400 Interface */
r10886r10887
755789
756790/* Machine Driver */
757791
758static MACHINE_CONFIG_START( thayers, driver_device )
792static MACHINE_CONFIG_START( thayers, thayers_state )
759793   /* basic machine hardware */
760794   MCFG_CPU_ADD("maincpu", Z80, XTAL_4MHz)
761795   MCFG_CPU_PROGRAM_MAP(thayers_map)
src/mame/drivers/sms.c
r10886r10887
219219#include "machine/8255ppi.h"
220220#include "machine/nvram.h"
221221
222
223class sms_state : public driver_device
224{
225public:
226   sms_state(running_machine &machine, const driver_device_config_base &config)
227      : driver_device(machine, config) { }
228
229   UINT8 communication_port[4];
230   UINT8 communication_port_status;
231   bitmap_t *bitmap;
232   UINT8 vid_regs[7];
233};
234
235
222236/*************************************
223237 *
224238 *  Bankswitching (for trivia question roms)
r10886r10887
236250 *
237251 *************************************/
238252
239static UINT8 communication_port[4];
240static UINT8 communication_port_status = 0;
241
242253static READ8_HANDLER(link_r)
243254{
255   sms_state *state = space->machine->driver_data<sms_state>();
244256   switch(offset)
245257   {
246258      case 0:
247         communication_port_status &= ~0x01;
248         return communication_port[0];
259         state->communication_port_status &= ~0x01;
260         return state->communication_port[0];
249261      case 1:
250         communication_port_status &= ~0x02;
251         return communication_port[1];
262         state->communication_port_status &= ~0x02;
263         return state->communication_port[1];
252264      case 2:
253         return communication_port_status;
265         return state->communication_port_status;
254266   }
255267   return 0;
256268};
257269
258270static WRITE8_HANDLER(link_w)
259271{
272   sms_state *state = space->machine->driver_data<sms_state>();
260273   switch(offset)
261274   {
262275      case 0:
263         communication_port_status |= 0x08;
264         communication_port[3] = data;
276         state->communication_port_status |= 0x08;
277         state->communication_port[3] = data;
265278         break;
266279      case 1:
267         communication_port_status |= 0x04;
268         communication_port[2] = data;
280         state->communication_port_status |= 0x04;
281         state->communication_port[2] = data;
269282         break;
270283   }
271284}
272285
273286static READ8_HANDLER(z80_8088_r)
274287{
275   return communication_port_status;
288   sms_state *state = space->machine->driver_data<sms_state>();
289   return state->communication_port_status;
276290}
277291
278292static READ8_HANDLER(p03_r)
279293{
294   sms_state *state = space->machine->driver_data<sms_state>();
280295   switch(offset)
281296   {
282297      case 0:
283         communication_port_status &= ~0x08;
284         return communication_port[3];
298         state->communication_port_status &= ~0x08;
299         return state->communication_port[3];
285300      case 1:
286         communication_port_status &= ~0x04;
287         return communication_port[2];
301         state->communication_port_status &= ~0x04;
302         return state->communication_port[2];
288303   }
289304   return 0;
290305}
291306
292307static WRITE8_HANDLER(p03_w)
293308{
309   sms_state *state = space->machine->driver_data<sms_state>();
294310   switch(offset)
295311   {
296312      case 0:
297         communication_port_status |= 0x01;
298         communication_port[0] = data;
313         state->communication_port_status |= 0x01;
314         state->communication_port[0] = data;
299315         break;
300316      case 1:
301         communication_port_status |= 0x02;
302         communication_port[1] = data;
317         state->communication_port_status |= 0x02;
318         state->communication_port[1] = data;
303319         break;
304320   }
305321}
r10886r10887
416432 *
417433 *************************************/
418434
419static bitmap_t *sms_bitmap;
420
421static UINT8 vid_regs[7];
422
423435static WRITE8_HANDLER(video_w)
424436{
425   vid_regs[offset] = data;
437   sms_state *state = space->machine->driver_data<sms_state>();
438   state->vid_regs[offset] = data;
426439   if ( offset == 5 )
427440   {
428441      int x,y;
429      int xstart = vid_regs[0] + vid_regs[1]*256;
430      int width = vid_regs[2];
431      int ystart = vid_regs[3];
432      int height = vid_regs[4];
433      int color = vid_regs[5];
442      int xstart = state->vid_regs[0] + state->vid_regs[1]*256;
443      int width = state->vid_regs[2];
444      int ystart = state->vid_regs[3];
445      int height = state->vid_regs[4];
446      int color = state->vid_regs[5];
434447
435448      if ( height == 0 )
436449         height = 256;
r10886r10887
443456         for ( x = xstart; x < xstart + width; x++ )
444457         {
445458            if ( y < 256 )
446            *BITMAP_ADDR16(sms_bitmap, y, x) = color;
459            *BITMAP_ADDR16(state->bitmap, y, x) = color;
447460         }
448461      }
449462   }
r10886r10887
451464
452465static VIDEO_START( sms )
453466{
454   sms_bitmap = machine->primary_screen->alloc_compatible_bitmap();
467   sms_state *state = machine->driver_data<sms_state>();
468   state->bitmap = machine->primary_screen->alloc_compatible_bitmap();
455469
456   state_save_register_global_array(machine, vid_regs);
457   state_save_register_global_bitmap(machine, sms_bitmap);
470   state_save_register_global_array(machine, state->vid_regs);
471   state_save_register_global_bitmap(machine, state->bitmap);
458472}
459473
460474static SCREEN_UPDATE( sms )
461475{
462   copybitmap(bitmap, sms_bitmap, 0, 0, 0, 0, cliprect);
476   sms_state *state = screen->machine->driver_data<sms_state>();
477   copybitmap(bitmap, state->bitmap, 0, 0, 0, 0, cliprect);
463478   return 0;
464479}
465480
r10886r10887
516531
517532static MACHINE_START( sms )
518533{
534   sms_state *state = machine->driver_data<sms_state>();
519535   memory_configure_bank(machine, "bank1", 0, 16, machine->region("questions")->base(), 0x4000);
520536
521   state_save_register_global(machine, communication_port_status);
522   state_save_register_global_array(machine, communication_port);
537   state_save_register_global(machine, state->communication_port_status);
538   state_save_register_global_array(machine, state->communication_port);
523539}
524540
525541static MACHINE_START( sureshot )
526542{
527   state_save_register_global(machine, communication_port_status);
528   state_save_register_global_array(machine, communication_port);
543   sms_state *state = machine->driver_data<sms_state>();
544   state_save_register_global(machine, state->communication_port_status);
545   state_save_register_global_array(machine, state->communication_port);
529546}
530547
531548static MACHINE_RESET( sms )
532549{
533   communication_port_status = 0;
550   sms_state *state = machine->driver_data<sms_state>();
551   state->communication_port_status = 0;
534552}
535553
536static MACHINE_CONFIG_START( sms, driver_device )
554static MACHINE_CONFIG_START( sms, sms_state )
537555   MCFG_CPU_ADD("maincpu", I8088, XTAL_24MHz/8)
538556   MCFG_CPU_PROGRAM_MAP(sms_map)
539557
src/mame/drivers/thedeep.c
r10886r10887
3737
3838***************************************************************************/
3939
40static int nmi_enable;
4140
4241static WRITE8_HANDLER( thedeep_nmi_w )
4342{
44   nmi_enable = data;
43   thedeep_state *state = space->machine->driver_data<thedeep_state>();
44   state->nmi_enable = data;
4545}
4646
4747static WRITE8_HANDLER( thedeep_sound_w )
r10886r10887
5050   cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
5151}
5252
53static UINT8 protection_command, protection_data;
54static int protection_index, protection_irq;
55static int rombank;
5653
5754static MACHINE_RESET( thedeep )
5855{
56   thedeep_state *state = machine->driver_data<thedeep_state>();
5957   memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x10000 + 0 * 0x4000);
60   thedeep_scroll[0] = 0;
61   thedeep_scroll[1] = 0;
62   thedeep_scroll[2] = 0;
63   thedeep_scroll[3] = 0;
64   protection_command = 0;
65   protection_index = -1;
66   protection_irq = 0;
67   rombank = -1;
58   state->scroll[0] = 0;
59   state->scroll[1] = 0;
60   state->scroll[2] = 0;
61   state->scroll[3] = 0;
62   state->protection_command = 0;
63   state->protection_index = -1;
64   state->protection_irq = 0;
65   state->rombank = -1;
6866}
6967
7068static WRITE8_HANDLER( thedeep_protection_w )
7169{
72   protection_command = data;
73   switch (protection_command)
70   thedeep_state *state = space->machine->driver_data<thedeep_state>();
71   state->protection_command = data;
72   switch (state->protection_command)
7473   {
7574      case 0x11:
7675         flip_screen_set(space->machine, 1);
r10886r10887
8685      case 0x33:
8786      {
8887         UINT8 *rom;
89         int new_rombank = protection_command & 3;
90         if (rombank == new_rombank)   break;
91         rombank = new_rombank;
88         int new_rombank = state->protection_command & 3;
89         if (state->rombank == new_rombank)   break;
90         state->rombank = new_rombank;
9291         rom = space->machine->region("maincpu")->base();
93         memory_set_bankptr(space->machine, "bank1", rom + 0x10000 + rombank * 0x4000);
92         memory_set_bankptr(space->machine, "bank1", rom + 0x10000 + state->rombank * 0x4000);
9493         /* there's code which falls through from the fixed ROM to bank #1, I have to */
9594         /* copy it there otherwise the CPU bank switching support will not catch it. */
96         memcpy(rom + 0x08000, rom + 0x10000 + rombank * 0x4000, 0x4000);
95         memcpy(rom + 0x08000, rom + 0x10000 + state->rombank * 0x4000, 0x4000);
9796      }
9897      break;
9998
10099      case 0x59:
101100      {
102         if (protection_index < 0)
103            protection_index = 0;
101         if (state->protection_index < 0)
102            state->protection_index = 0;
104103
105         if ( protection_index < 0x19b )
104         if ( state->protection_index < 0x19b )
106105// d000-d00c:   hl += a * b
107106// d00d-d029:   input a (e.g. $39) output hl (e.g. h=$03 l=$09).
108107//              Replace trainling 0's with space ($10). 00 -> '  '
r10886r10887
119118// d166-d174:   hl = (hl + 2*a)
120119// d175-d181:   hl *= e (e must be non zero)
121120// d182-d19a:   hl /= de
122            protection_data = space->machine->region("cpu3")->base()[0x185+protection_index++];
121            state->protection_data = space->machine->region("cpu3")->base()[0x185+state->protection_index++];
123122         else
124            protection_data = 0xc9;
123            state->protection_data = 0xc9;
125124
126         protection_irq  = 1;
125         state->protection_irq  = 1;
127126      }
128127      break;
129128
130129      default:
131         logerror( "pc %04x: protection_command %02x\n", cpu_get_pc(space->cpu),protection_command);
130         logerror( "pc %04x: protection_command %02x\n", cpu_get_pc(space->cpu),state->protection_command);
132131   }
133132}
134133
135134static READ8_HANDLER( thedeep_e004_r )
136135{
137   return protection_irq ? 1 : 0;
136   thedeep_state *state = space->machine->driver_data<thedeep_state>();
137   return state->protection_irq ? 1 : 0;
138138}
139139
140140static READ8_HANDLER( thedeep_protection_r )
141141{
142   protection_irq = 0;
143   return protection_data;
142   thedeep_state *state = space->machine->driver_data<thedeep_state>();
143   state->protection_irq = 0;
144   return state->protection_data;
144145}
145146
146147static WRITE8_HANDLER( thedeep_e100_w )
r10886r10887
162163   AM_RANGE(0xe00b, 0xe00b) AM_READ_PORT("e00b")         // DSW2
163164   AM_RANGE(0xe00c, 0xe00c) AM_WRITE(thedeep_sound_w      )   // To Sound CPU
164165   AM_RANGE(0xe100, 0xe100) AM_WRITE(thedeep_e100_w      )   // ?
165   AM_RANGE(0xe210, 0xe213) AM_WRITEONLY AM_BASE(&thedeep_scroll            )   // Scroll
166   AM_RANGE(0xe210, 0xe213) AM_WRITEONLY AM_BASE_MEMBER(thedeep_state, scroll            )   // Scroll
166167   AM_RANGE(0xe400, 0xe7ff) AM_RAM AM_BASE_SIZE_MEMBER(thedeep_state, spriteram, spriteram_size)   // Sprites
167   AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(thedeep_vram_1_w) AM_BASE(&thedeep_vram_1      )   // Text Layer
168   AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(thedeep_vram_0_w) AM_BASE(&thedeep_vram_0      )   // Background Layer
169   AM_RANGE(0xf800, 0xf83f) AM_RAM AM_BASE(&thedeep_scroll2            )   // Column Scroll
168   AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(thedeep_vram_1_w) AM_BASE_MEMBER(thedeep_state, vram_1      )   // Text Layer
169   AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(thedeep_vram_0_w) AM_BASE_MEMBER(thedeep_state, vram_0      )   // Background Layer
170   AM_RANGE(0xf800, 0xf83f) AM_RAM AM_BASE_MEMBER(thedeep_state, scroll2            )   // Column Scroll
170171   AM_RANGE(0xf840, 0xffff) AM_RAM
171172ADDRESS_MAP_END
172173
r10886r10887
323324
324325static INTERRUPT_GEN( thedeep_interrupt )
325326{
327   thedeep_state *state = device->machine->driver_data<thedeep_state>();
326328   if (cpu_getiloops(device))
327329   {
328      if (protection_command != 0x59)
330      if (state->protection_command != 0x59)
329331      {
330332         int coins = input_port_read(device->machine, "MCU");
331         if      (coins & 1)   protection_data = 1;
332         else if   (coins & 2)   protection_data = 2;
333         else if   (coins & 4)   protection_data = 3;
334         else            protection_data = 0;
333         if      (coins & 1)   state->protection_data = 1;
334         else if   (coins & 2)   state->protection_data = 2;
335         else if   (coins & 4)   state->protection_data = 3;
336         else            state->protection_data = 0;
335337
336         if (protection_data)
337            protection_irq = 1;
338         if (state->protection_data)
339            state->protection_irq = 1;
338340      }
339      if (protection_irq)
341      if (state->protection_irq)
340342         cpu_set_input_line(device, 0, HOLD_LINE);
341343   }
342344   else
343345   {
344      if (nmi_enable)
346      if (state->nmi_enable)
345347      {
346348         cpu_set_input_line(device, INPUT_LINE_NMI, ASSERT_LINE);
347349         cpu_set_input_line(device, INPUT_LINE_NMI, CLEAR_LINE);
src/mame/drivers/ksys573.c
r10886r10887
439439
440440   int tank_shutter_position;
441441   int cable_holder_release;
442   double pad_position[ 6 ];
442443};
443444
444445INLINE void ATTR_PRINTF(3,4) verboselog( running_machine *machine, int n_level, const char *s_fmt, ... )
r10886r10887
26252626
26262627/* punch mania */
26272628
2628static double pad_position[ 6 ];
26292629
26302630static double punchmania_inputs_callback( device_t *device, UINT8 input )
26312631{
2632   ksys573_state *state = device->machine->driver_data<ksys573_state>();
2633   double *pad_position = state->pad_position;
26322634   int pads = input_port_read(device->machine, "PADS");
26332635   for( int i = 0; i < 6; i++ )
26342636   {
r10886r10887
26642666
26652667static void punchmania_output_callback( running_machine *machine, int offset, int data )
26662668{
2669   ksys573_state *state = machine->driver_data<ksys573_state>();
2670   double *pad_position = state->pad_position;
26672671   char pad[ 7 ];
26682672
26692673   switch( offset )
src/mame/drivers/re900.c
r10886r10887
8181#include "machine/nvram.h"
8282#include "re900.lh"
8383
84static UINT8 *re900_rom;
85static UINT8 psg_pa, psg_pb, mux_data, ledant, player, stat_a;
8684
85class re900_state : public driver_device
86{
87public:
88   re900_state(running_machine &machine, const driver_device_config_base &config)
89      : driver_device(machine, config) { }
8790
91   UINT8 *rom;
92   UINT8 psg_pa;
93   UINT8 psg_pb;
94   UINT8 mux_data;
95   UINT8 ledant;
96   UINT8 player;
97   UINT8 stat_a;
98};
99
100
88101/****************
89102* Read Handlers *
90103****************/
r10886r10887
106119
107120static READ8_DEVICE_HANDLER (re_psg_portB_r)
108121{
122   re900_state *state = device->machine->driver_data<re900_state>();
109123   UINT8 retval = 0xff;
110124   logerror("llamada a re_psg_portB_r\n");
111125   /* This is a hack to select the active player due to Keyboard size restrictions  */
112126
113   output_set_lamp_value(player,1);
127   output_set_lamp_value(state->player,1);
114128
115129   if (input_port_read(device->machine, "IN_S"))
116130   {
117      if (!stat_a)
131      if (!state->stat_a)
118132      {
119133         output_set_lamp_value(1, 0);
120134         output_set_lamp_value(2, 0);
r10886r10887
122136         output_set_lamp_value(4, 0);
123137         output_set_lamp_value(5, 0);
124138         output_set_lamp_value(6, 0);
125         player++;
139         state->player++;
126140
127         if (player == 7)
141         if (state->player == 7)
128142         {
129            player = 1;
143            state->player = 1;
130144         }
131145
132         output_set_lamp_value(player, 1); /* It shows active player via layout buttons   */
133         stat_a = 1;
146         output_set_lamp_value(state->player, 1); /* It shows active player via layout buttons   */
147         state->stat_a = 1;
134148      }
135149   }
136150
137151   else
138152   {
139      stat_a = 0;
153      state->stat_a = 0;
140154   }
141155   /* End of Select Player Hack */
142156
143157   /* "INA": Unified port to share the player Keys among all players - Key In & Key Out have their own buttons on keyboard. */
144   switch( mux_data )
158   switch( state->mux_data )
145159   {
146      case 0x01: retval = (input_port_read(device->machine, "IN6") | 0x80 ) - (( player == 6 ) ? (input_port_read(device->machine, "INA") | 0x80 ) ^ 0xff: 0x00 ); break; /* Player 6 */
147      case 0x02: retval = (input_port_read(device->machine, "IN5") | 0x80 ) - (( player == 5 ) ? (input_port_read(device->machine, "INA") | 0x80 ) ^ 0xff: 0x00 ); break; /* Player 5 */
148      case 0x04: retval = (input_port_read(device->machine, "IN4") | 0x80 ) - (( player == 4 ) ? (input_port_read(device->machine, "INA") | 0x80 ) ^ 0xff: 0x00 ); break; /* Player 4 */
149      case 0x08: retval = (input_port_read(device->machine, "IN3") | 0x80 ) - (( player == 3 ) ? (input_port_read(device->machine, "INA") | 0x80 ) ^ 0xff: 0x00 ); break; /* Player 3 */
150      case 0x10: retval = (input_port_read(device->machine, "IN2") | 0x80 ) - (( player == 2 ) ? (input_port_read(device->machine, "INA") | 0x80 ) ^ 0xff: 0x00 ); break; /* Player 2 */
151      case 0x20: retval = (input_port_read(device->machine, "IN1") | 0x80 ) - (( player == 1 ) ? (input_port_read(device->machine, "INA") | 0x80 ) ^ 0xff: 0x00 ); break; /* Player 1 */
160      case 0x01: retval = (input_port_read(device->machine, "IN6") | 0x80 ) - (( state->player == 6 ) ? (input_port_read(device->machine, "INA") | 0x80 ) ^ 0xff: 0x00 ); break; /* Player 6 */
161      case 0x02: retval = (input_port_read(device->machine, "IN5") | 0x80 ) - (( state->player == 5 ) ? (input_port_read(device->machine, "INA") | 0x80 ) ^ 0xff: 0x00 ); break; /* Player 5 */
162      case 0x04: retval = (input_port_read(device->machine, "IN4") | 0x80 ) - (( state->player == 4 ) ? (input_port_read(device->machine, "INA") | 0x80 ) ^ 0xff: 0x00 ); break; /* Player 4 */
163      case 0x08: retval = (input_port_read(device->machine, "IN3") | 0x80 ) - (( state->player == 3 ) ? (input_port_read(device->machine, "INA") | 0x80 ) ^ 0xff: 0x00 ); break; /* Player 3 */
164      case 0x10: retval = (input_port_read(device->machine, "IN2") | 0x80 ) - (( state->player == 2 ) ? (input_port_read(device->machine, "INA") | 0x80 ) ^ 0xff: 0x00 ); break; /* Player 2 */
165      case 0x20: retval = (input_port_read(device->machine, "IN1") | 0x80 ) - (( state->player == 1 ) ? (input_port_read(device->machine, "INA") | 0x80 ) ^ 0xff: 0x00 ); break; /* Player 1 */
152166   }
153167
154168   return retval;
r10886r10887
156170
157171static READ8_HANDLER (rom_r)
158172{
159   return re900_rom[offset];
173   re900_state *state = space->machine->driver_data<re900_state>();
174   return state->rom[offset];
160175}
161176
162177
r10886r10887
166181
167182static WRITE8_DEVICE_HANDLER (re_mux_port_A_w)
168183{
169   psg_pa = data;
170   mux_data = ((data >> 2) & 0x3f) ^ 0x3f;
184   re900_state *state = device->machine->driver_data<re900_state>();
185   state->psg_pa = data;
186   state->mux_data = ((data >> 2) & 0x3f) ^ 0x3f;
171187}
172188
173189static WRITE8_DEVICE_HANDLER (re_mux_port_B_w)
174190{
191   re900_state *state = device->machine->driver_data<re900_state>();
175192   UINT8 led;
176   psg_pb = data;
177   led = (psg_pa >> 2) & 0x3f;
193   state->psg_pb = data;
194   led = (state->psg_pa >> 2) & 0x3f;
178195
179196   if (data == 0x7f)
180197   {
181198      output_set_lamp_value(20 + led, 1);
182199
183      if (led != ledant)
200      if (led != state->ledant)
184201      {
185         output_set_lamp_value(20 + ledant, 0);
186         ledant = led;
202         output_set_lamp_value(20 + state->ledant, 0);
203         state->ledant = led;
187204      }
188205   }
189206}
r10886r10887
205222*******************************/
206223
207224static ADDRESS_MAP_START( mem_prg, ADDRESS_SPACE_PROGRAM, 8 )
208   AM_RANGE(0x0000, 0xffff) AM_ROM AM_BASE(&re900_rom)
225   AM_RANGE(0x0000, 0xffff) AM_ROM AM_BASE_MEMBER(re900_state, rom)
209226ADDRESS_MAP_END
210227
211228static ADDRESS_MAP_START( mem_io, ADDRESS_SPACE_IO, 8 )
r10886r10887
388405*      Machine Driver      *
389406***************************/
390407
391static MACHINE_CONFIG_START( re900, driver_device )
408static MACHINE_CONFIG_START( re900, re900_state )
392409
393410   /* basic machine hardware */
394411   MCFG_CPU_ADD("maincpu", I8051, MAIN_CLOCK)
r10886r10887
440457
441458static DRIVER_INIT( re900 )
442459{
460   re900_state *state = machine->driver_data<re900_state>();
443461   TMS9928A_configure(&tms9928a_interface);
444   player = 1;
445   stat_a = 1;
446   psg_pa = psg_pb = mux_data = ledant = 0;
462   state->player = 1;
463   state->stat_a = 1;
464   state->psg_pa = state->psg_pb = state->mux_data = state->ledant = 0;
447465}
448466
449467
src/mame/drivers/jackpool.c
r10886r10887
2121#include "machine/eeprom.h"
2222
2323
24static UINT16 *jackpool_vram;
25static UINT8 map_vreg;
26static UINT16 *jackpool_io;
24class jackpool_state : public driver_device
25{
26public:
27   jackpool_state(running_machine &machine, const driver_device_config_base &config)
28      : driver_device(machine, config) { }
2729
30   UINT16 *vram;
31   UINT8 map_vreg;
32   UINT16 *io;
33};
2834
35
2936static VIDEO_START(jackpool)
3037{
3138}
3239
3340static SCREEN_UPDATE(jackpool)
3441{
42   jackpool_state *state = screen->machine->driver_data<jackpool_state>();
3543   const gfx_element *gfx = screen->machine->gfx[0];
3644   int count;// = 0x00000/2;
3745
3846   int y,x;
3947
4048   {
41      count = map_vreg*(0x4000/2);
49      count = state->map_vreg*(0x4000/2);
4250      for (y=0;y<32;y++)
4351      {
4452         for (x=0;x<64;x++)
4553         {
46            int tile = (jackpool_vram[count+(0x2000/2)] & 0x7fff);
47            int attr = (jackpool_vram[count+(0x2000/2)+0x800] & 0x1f00)>>8;
54            int tile = (state->vram[count+(0x2000/2)] & 0x7fff);
55            int attr = (state->vram[count+(0x2000/2)+0x800] & 0x1f00)>>8;
4856
4957            drawgfx_opaque(bitmap,cliprect,gfx,tile,attr,0,0,x*8,y*8);
5058            count++;
5159         }
5260      }
5361
54      count = map_vreg*(0x4000/2);
62      count = state->map_vreg*(0x4000/2);
5563      for (y=0;y<32;y++)
5664      {
5765         for (x=0;x<64;x++)
5866         {
59            int tile = (jackpool_vram[count] & 0x7fff);
67            int tile = (state->vram[count] & 0x7fff);
6068
6169            if(tile != 0)
6270            {
63               int attr = (jackpool_vram[count+0x800] & 0x1f00)>>8;
64               int t_pen = (jackpool_vram[count+0x800] & 0x1000);
71               int attr = (state->vram[count+0x800] & 0x1f00)>>8;
72               int t_pen = (state->vram[count+0x800] & 0x1000);
6573
6674               drawgfx_transpen(bitmap,cliprect,gfx,tile,attr,0,0,x*8,y*8,(t_pen) ? 0 : -1);
6775            }
r10886r10887
8290
8391static READ16_HANDLER( jackpool_io_r )
8492{
93   jackpool_state *state = space->machine->driver_data<jackpool_state>();
8594   switch(offset*2)
8695   {
8796      case 0x00: return input_port_read(space->machine,"COIN1");
r10886r10887
106115   }
107116
108117//  printf("R %02x\n",offset*2);
109   return jackpool_io[offset];
118   return state->io[offset];
110119}
111120
112121static WRITE16_HANDLER( jackpool_io_w )
113122{
114   COMBINE_DATA(&jackpool_io[offset]);
123   jackpool_state *state = space->machine->driver_data<jackpool_state>();
124   COMBINE_DATA(&state->io[offset]);
115125
116126   switch(offset*2)
117127   {
r10886r10887
127137      case 0x46: /* ---- ---x coin counter */break;
128138      case 0x4a: /* ---- ---x Ticket motor */break;
129139      case 0x4c: /* ---- ---x Hopper motor */break;
130      case 0x4e: map_vreg = data & 1;        break;
140      case 0x4e: state->map_vreg = data & 1;        break;
131141      case 0x50: eeprom_set_cs_line(space->machine->device("eeprom"), (data & 1) ? CLEAR_LINE : ASSERT_LINE ); break;
132142      case 0x52: eeprom_set_clock_line(space->machine->device("eeprom"), (data & 1) ? ASSERT_LINE : CLEAR_LINE ); break;
133143      case 0x54: eeprom_write_bit(space->machine->device("eeprom"), data & 1); break;
r10886r10887
160170   AM_RANGE(0x000000, 0x03ffff) AM_ROM
161171   AM_RANGE(0x100000, 0x10ffff) AM_RAM
162172   AM_RANGE(0x120000, 0x1200ff) AM_RAM
163   AM_RANGE(0x340000, 0x347fff) AM_RAM AM_BASE(&jackpool_vram)
173   AM_RANGE(0x340000, 0x347fff) AM_RAM AM_BASE_MEMBER(jackpool_state, vram)
164174   AM_RANGE(0x348000, 0x34ffff) AM_RAM //<- vram banks 2 & 3?
165175
166176   AM_RANGE(0x360000, 0x3603ff) AM_RAM_WRITE(paletteram16_xxxxBBBBGGGGRRRR_word_w) AM_BASE_GENERIC(paletteram)
167   AM_RANGE(0x380000, 0x380061) AM_READWRITE(jackpool_io_r,jackpool_io_w) AM_BASE(&jackpool_io)//AM_READ(jackpool_io_r)
177   AM_RANGE(0x380000, 0x380061) AM_READWRITE(jackpool_io_r,jackpool_io_w) AM_BASE_MEMBER(jackpool_state, io)//AM_READ(jackpool_io_r)
168178
169179   AM_RANGE(0x800000, 0x80000f) AM_READ(jackpool_ff_r) AM_WRITENOP //UART
170180   AM_RANGE(0xa00000, 0xa00001) AM_DEVREADWRITE8_MODERN("oki", okim6295_device, read, write, 0x00ff)
r10886r10887
239249}
240250
241251
242static MACHINE_CONFIG_START( jackpool, driver_device )
252static MACHINE_CONFIG_START( jackpool, jackpool_state )
243253   MCFG_CPU_ADD("maincpu", M68000, 12000000) // ?
244254   MCFG_CPU_PROGRAM_MAP(jackpool_mem)
245255   MCFG_CPU_VBLANK_INT("screen",jackpool_interrupt)  // ?
src/mame/drivers/pntnpuzl.c
r10886r10887
125125#include "machine/eeprom.h"
126126
127127
128class pntnpuzl_state : public driver_device
129{
130public:
131   pntnpuzl_state(running_machine &machine, const driver_device_config_base &config)
132      : driver_device(machine, config) { }
133
134   UINT16 eeprom;
135   UINT16* _3a0000ram;
136   UINT16* bank;
137   int indx;
138   int sub;
139   int rgb[3];
140   UINT16 pntpzl_200000;
141   UINT16 serial;
142   UINT16 serial_out;
143   UINT16 read_count;
144   int touchscr[5];
145};
146
147
128148static const eeprom_interface eeprom_intf =
129149{
130150   6,            /* address bits */
r10886r10887
136156   "*10011xxxx"   /* unlock command */
137157};
138158
139static UINT16 pntnpuzl_eeprom;
140159
141160static READ16_DEVICE_HANDLER( pntnpuzl_eeprom_r )
142161{
162   pntnpuzl_state *state = device->machine->driver_data<pntnpuzl_state>();
143163   /* bit 11 is EEPROM data */
144   return (pntnpuzl_eeprom & 0xf4ff) | (eeprom_read_bit(device)<<11) | (input_port_read(device->machine, "IN1") & 0x0300);
164   return (state->eeprom & 0xf4ff) | (eeprom_read_bit(device)<<11) | (input_port_read(device->machine, "IN1") & 0x0300);
145165}
146166
147167static WRITE16_DEVICE_HANDLER( pntnpuzl_eeprom_w )
148168{
149   pntnpuzl_eeprom = data;
169   pntnpuzl_state *state = device->machine->driver_data<pntnpuzl_state>();
170   state->eeprom = data;
150171
151172   /* bit 12 is data */
152173   /* bit 13 is clock (active high) */
r10886r10887
160181
161182
162183
163static UINT16* pntnpuzl_3a0000ram;
164static UINT16* pntnpuzl_bank;
165184/* vid */
166185static VIDEO_START( pntnpuzl )
167186{
168   pntnpuzl_3a0000ram=auto_alloc_array(machine, UINT16, 0x100000/2);
187   pntnpuzl_state *state = machine->driver_data<pntnpuzl_state>();
188   state->_3a0000ram=auto_alloc_array(machine, UINT16, 0x100000/2);
169189}
170190
171191static SCREEN_UPDATE( pntnpuzl )
172192{
193   pntnpuzl_state *state = screen->machine->driver_data<pntnpuzl_state>();
173194   int x,y;
174195   int count;
175196#if 0
r10886r10887
225246   {
226247      for(x=0;x<xxx;x+=2)
227248      {
228         *BITMAP_ADDR16(bitmap, y, x) = (pntnpuzl_3a0000ram[count]&0x1f00)>>8;
229         *BITMAP_ADDR16(bitmap, y, x+1) = (pntnpuzl_3a0000ram[count]&0x001f)>>0;
249         *BITMAP_ADDR16(bitmap, y, x) = (state->_3a0000ram[count]&0x1f00)>>8;
250         *BITMAP_ADDR16(bitmap, y, x+1) = (state->_3a0000ram[count]&0x001f)>>0;
230251         count++;
231252      }
232253   }
r10886r10887
235256
236257static WRITE16_HANDLER( pntnpuzl_palette_w )
237258{
238   static int indx,sub,rgb[3];
259   pntnpuzl_state *state = space->machine->driver_data<pntnpuzl_state>();
239260
240261   if (ACCESSING_BITS_8_15)
241262   {
242      indx = data >> 8;
243      sub = 0;
263      state->indx = data >> 8;
264      state->sub = 0;
244265   }
245266   if (ACCESSING_BITS_0_7)
246267   {
247      rgb[sub++] = data & 0xff;
248      if (sub == 3)
268      state->rgb[state->sub++] = data & 0xff;
269      if (state->sub == 3)
249270      {
250         palette_set_color_rgb(space->machine,indx++,pal6bit(rgb[0]),pal6bit(rgb[1]),pal6bit(rgb[2]));
251         sub = 0;
252         if (indx == 256) indx = 0;
271         palette_set_color_rgb(space->machine,state->indx++,pal6bit(state->rgb[0]),pal6bit(state->rgb[1]),pal6bit(state->rgb[2]));
272         state->sub = 0;
273         if (state->indx == 256) state->indx = 0;
253274      }
254275   }
255276}
r10886r10887
265286
266287static READ16_HANDLER( pntnpuzl_vid_r )
267288{
268//  logerror("read_videoram: pc = %06x : offset %04x reg %04x\n",cpu_get_pc(space->cpu),offset*2, pntnpuzl_bank[0]);
269   return pntnpuzl_3a0000ram[offset+ (pntnpuzl_bank[0]&0x0001)*0x8000 ];
289   pntnpuzl_state *state = space->machine->driver_data<pntnpuzl_state>();
290//  logerror("read_videoram: pc = %06x : offset %04x reg %04x\n",cpu_get_pc(space->cpu),offset*2, state->bank[0]);
291   return state->_3a0000ram[offset+ (state->bank[0]&0x0001)*0x8000 ];
270292}
271293
272294static WRITE16_HANDLER( pntnpuzl_vid_w )
273295{
274//  logerror("write_to_videoram: pc = %06x : offset %04x data %04x reg %04x\n",cpu_get_pc(space->cpu),offset*2, data, pntnpuzl_bank[0]);
275   COMBINE_DATA(&pntnpuzl_3a0000ram[offset+ (pntnpuzl_bank[0]&0x0001)*0x8000 ]);
296   pntnpuzl_state *state = space->machine->driver_data<pntnpuzl_state>();
297//  logerror("write_to_videoram: pc = %06x : offset %04x data %04x reg %04x\n",cpu_get_pc(space->cpu),offset*2, data, state->bank[0]);
298   COMBINE_DATA(&state->_3a0000ram[offset+ (state->bank[0]&0x0001)*0x8000 ]);
276299}
277300
278301static READ16_HANDLER( pntnpuzl_vblank_r )
r10886r10887
30332601 53 45 32 0d                       ---> 80 0c
30432701 03 46 31 38 0d                    ---> 80 0c
305328*/
306static UINT16 pntpzl_200000, serial, serial_out,read_count;
307329
308330static WRITE16_HANDLER( pntnpuzl_200000_w )
309331{
332   pntnpuzl_state *state = space->machine->driver_data<pntnpuzl_state>();
310333// logerror("200000: %04x\n",data);
311334   // bit 12: set to 1 when going to serial output to 280018
312   if ((pntpzl_200000 & 0x1000) && !(data & 0x1000))
335   if ((state->pntpzl_200000 & 0x1000) && !(data & 0x1000))
313336   {
314      serial_out = (serial>>1) & 0xff;
315      read_count = 0;
316      logerror("serial out: %02x\n",serial_out);
337      state->serial_out = (state->serial>>1) & 0xff;
338      state->read_count = 0;
339      logerror("serial out: %02x\n",state->serial_out);
317340   }
318341
319   pntpzl_200000 = data;
342   state->pntpzl_200000 = data;
320343}
321344
322345static WRITE16_HANDLER( pntnpuzl_280018_w )
323346{
347   pntnpuzl_state *state = space->machine->driver_data<pntnpuzl_state>();
324348// logerror("%04x: 280018: %04x\n",cpu_get_pc(space->cpu),data);
325   serial >>= 1;
349   state->serial >>= 1;
326350   if (data & 0x2000)
327      serial |= 0x400;
351      state->serial |= 0x400;
328352}
329353
330354static READ16_HANDLER( pntnpuzl_280014_r )
331355{
356   pntnpuzl_state *state = space->machine->driver_data<pntnpuzl_state>();
332357   static const int startup[3] = { 0x80, 0x0c, 0x00 };
333358   int res;
334359
335   if (serial_out == 0x11)
360   if (state->serial_out == 0x11)
336361   {
337      static int touchscr[5];
338362      if (input_port_read(space->machine, "IN0") & 0x10)
339363      {
340         touchscr[0] = 0x1b;
341         touchscr[2] = BITSWAP8(input_port_read(space->machine, "TOUCHX"),0,1,2,3,4,5,6,7);
342         touchscr[4] = BITSWAP8(input_port_read(space->machine, "TOUCHY"),0,1,2,3,4,5,6,7);
364         state->touchscr[0] = 0x1b;
365         state->touchscr[2] = BITSWAP8(input_port_read(space->machine, "TOUCHX"),0,1,2,3,4,5,6,7);
366         state->touchscr[4] = BITSWAP8(input_port_read(space->machine, "TOUCHY"),0,1,2,3,4,5,6,7);
343367      }
344368      else
345         touchscr[0] = 0;
369         state->touchscr[0] = 0;
346370
347      if (read_count >= 10) read_count = 0;
348      res = touchscr[read_count/2];
349      read_count++;
371      if (state->read_count >= 10) state->read_count = 0;
372      res = state->touchscr[state->read_count/2];
373      state->read_count++;
350374   }
351375   else
352376   {
353      if (read_count >= 6) read_count = 0;
354      res = startup[read_count/2];
355      read_count++;
377      if (state->read_count >= 6) state->read_count = 0;
378      res = startup[state->read_count/2];
379      state->read_count++;
356380   }
357381   logerror("read 280014: %02x\n",res);
358382   return res << 8;
r10886r10887
386410
387411   /* standard VGA */
388412   AM_RANGE(0x3a0000, 0x3affff) AM_READWRITE(pntnpuzl_vid_r, pntnpuzl_vid_w)
389   AM_RANGE(0x3c03c4, 0x3c03c5) AM_RAM AM_BASE(&pntnpuzl_bank)//??
413   AM_RANGE(0x3c03c4, 0x3c03c5) AM_RAM AM_BASE_MEMBER(pntnpuzl_state, bank)//??
390414   AM_RANGE(0x3c03c8, 0x3c03c9) AM_WRITE(pntnpuzl_palette_w)
391415   AM_RANGE(0x3c03da, 0x3c03db) AM_READ(pntnpuzl_vblank_r)
392416
r10886r10887
436460
437461
438462
439static MACHINE_CONFIG_START( pntnpuzl, driver_device )
463static MACHINE_CONFIG_START( pntnpuzl, pntnpuzl_state )
440464   MCFG_CPU_ADD("maincpu", M68000, 12000000)//??
441465   MCFG_CPU_PROGRAM_MAP(pntnpuzl_map)
442466   MCFG_CPU_VBLANK_INT("screen", pntnpuzl_irq)   // irq1 = coin irq2 = service irq4 = coin
src/mame/drivers/mirax.c
r10886r10887
8282      : driver_device(machine, config) { }
8383
8484   UINT8 *spriteram;
85   UINT8 nAyCtrl;
86   UINT8 nAyData;
87   UINT8 nmi_mask;
88   UINT8 *videoram;
89   UINT8 *colorram;
8590};
8691
8792
88static UINT8 nAyCtrl, nAyData;
89static UINT8 nmi_mask;
90static UINT8 *videoram;
91static UINT8 *colorram;
92
9393static VIDEO_START(mirax)
9494{
9595}
r10886r10887
124124
125125static SCREEN_UPDATE(mirax)
126126{
127   mirax_state *state = screen->machine->driver_data<mirax_state>();
127128   const gfx_element *gfx = screen->machine->gfx[0];
128129   int count = 0x00000;
129130   int y,x;
r10886r10887
132133   {
133134      for (x=0;x<32;x++)
134135      {
135         int tile = videoram[count];
136         int color = (colorram[x*2]<<8) | (colorram[(x*2)+1]);
136         int tile = state->videoram[count];
137         int color = (state->colorram[x*2]<<8) | (state->colorram[(x*2)+1]);
137138         int x_scroll = (color & 0xff00)>>8;
138139         tile |= ((color & 0xe0)<<3);
139140
r10886r10887
154155   {
155156      for (x=0;x<32;x++)
156157      {
157         int tile = videoram[count];
158         int color = (colorram[x*2]<<8) | (colorram[(x*2)+1]);
158         int tile = state->videoram[count];
159         int color = (state->colorram[x*2]<<8) | (state->colorram[(x*2)+1]);
159160         int x_scroll = (color & 0xff00)>>8;
160161         tile |= ((color & 0xe0)<<3);
161162
r10886r10887
176177
177178static SOUND_START(mirax)
178179{
179   nAyCtrl = 0x00;
180   nAyData = 0x00;
180   mirax_state *state = machine->driver_data<mirax_state>();
181   state->nAyCtrl = 0x00;
182   state->nAyData = 0x00;
181183}
182184
183185static WRITE8_HANDLER(audio_w)
184186{
187   mirax_state *state = space->machine->driver_data<mirax_state>();
185188   if(cpu_get_previouspc(space->cpu)==0x2fd)
186189   {
187      nAyCtrl=offset;
188      nAyData=data;
190      state->nAyCtrl=offset;
191      state->nAyData=data;
189192   }
190193}
191194
192195static WRITE8_DEVICE_HANDLER(ay_sel)
193196{
197   mirax_state *state = device->machine->driver_data<mirax_state>();
194198   if(cpu_get_previouspc(device->machine->device("audiocpu"))==0x309)
195199   {
196      ay8910_address_w(device,0,nAyCtrl);
197      ay8910_data_w(device,0,nAyData);
200      ay8910_address_w(device,0,state->nAyCtrl);
201      ay8910_data_w(device,0,state->nAyData);
198202   }
199203}
200204
r10886r10887
205209
206210static WRITE8_HANDLER( nmi_mask_w )
207211{
208   nmi_mask = data & 1;
212   mirax_state *state = space->machine->driver_data<mirax_state>();
213   state->nmi_mask = data & 1;
209214   if(data & 0xfe)
210215      printf("Warning: %02x written at $f501\n",data);
211216}
r10886r10887
219224static ADDRESS_MAP_START( mirax_main_map, ADDRESS_SPACE_PROGRAM, 8 )
220225   AM_RANGE(0x0000, 0xbfff) AM_ROM
221226   AM_RANGE(0xc800, 0xd7ff) AM_RAM
222   AM_RANGE(0xe000, 0xe3ff) AM_RAM AM_BASE(&videoram)
227   AM_RANGE(0xe000, 0xe3ff) AM_RAM AM_BASE_MEMBER(mirax_state, videoram)
223228   AM_RANGE(0xe800, 0xe9ff) AM_RAM AM_BASE_MEMBER(mirax_state, spriteram)
224   AM_RANGE(0xea00, 0xea3f) AM_RAM AM_BASE(&colorram) //per-column color + bank bits for the videoram
229   AM_RANGE(0xea00, 0xea3f) AM_RAM AM_BASE_MEMBER(mirax_state, colorram) //per-column color + bank bits for the videoram
225230   AM_RANGE(0xf000, 0xf000) AM_READ_PORT("P1")
226231   AM_RANGE(0xf100, 0xf100) AM_READ_PORT("P2")
227232   AM_RANGE(0xf200, 0xf200) AM_READ_PORT("DSW1")
r10886r10887
384389
385390static INTERRUPT_GEN( mirax_vblank_irq )
386391{
387   if(nmi_mask)
392   mirax_state *state = device->machine->driver_data<mirax_state>();
393   if(state->nmi_mask)
388394      cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
389395}
390396
src/mame/drivers/ssfindo.c
r10886r10887
211211   MAXIO=128
212212};
213213
214static UINT32 PS7500_IO[MAXIO];
215static UINT32 PS7500_FIFO[256];
216static UINT32 *vram;
217static UINT32 flashAdr,flashOffset,adrLatch,flashType,flashN;
218214
219static void PS7500_startTimer0(void);
220static void PS7500_startTimer1(void);
215class ssfindo_state : public driver_device
216{
217public:
218   ssfindo_state(running_machine &machine, const driver_device_config_base &config)
219      : driver_device(machine, config) { }
221220
222static emu_timer *PS7500timer0;
223static emu_timer *PS7500timer1;
221   UINT32 PS7500_IO[MAXIO];
222   UINT32 PS7500_FIFO[256];
223   UINT32 *vram;
224   UINT32 flashAdr;
225   UINT32 flashOffset;
226   UINT32 adrLatch;
227   UINT32 flashType;
228   UINT32 flashN;
229   emu_timer *PS7500timer0;
230   emu_timer *PS7500timer1;
231   int iocr_hack;
232};
224233
225static int iocr_hack;
226234
235static void PS7500_startTimer0(running_machine *machine);
236static void PS7500_startTimer1(running_machine *machine);
237
238
227239static SCREEN_UPDATE(ssfindo)
228240{
241   ssfindo_state *state = screen->machine->driver_data<ssfindo_state>();
229242   int s,x,y;
230243
231   if( PS7500_IO[VIDCR]&0x20) //video DMA enabled
244   if( state->PS7500_IO[VIDCR]&0x20) //video DMA enabled
232245   {
233      s=( (PS7500_IO[VIDINITA]&0x1fffffff)-0x10000000)/4;
246      s=( (state->PS7500_IO[VIDINITA]&0x1fffffff)-0x10000000)/4;
234247
235248      if(s>=0 && s<(0x10000000/4))
236249      {
237250         for(y=0;y<256;y++)
238251            for(x=0;x<320;x+=4)
239252            {
240               *BITMAP_ADDR16(bitmap, y, x+0) = vram[s]&0xff;
241               *BITMAP_ADDR16(bitmap, y, x+1) = (vram[s]>>8)&0xff;
242               *BITMAP_ADDR16(bitmap, y, x+2) = (vram[s]>>16)&0xff;
243               *BITMAP_ADDR16(bitmap, y, x+3) = (vram[s]>>24)&0xff;
253               *BITMAP_ADDR16(bitmap, y, x+0) = state->vram[s]&0xff;
254               *BITMAP_ADDR16(bitmap, y, x+1) = (state->vram[s]>>8)&0xff;
255               *BITMAP_ADDR16(bitmap, y, x+2) = (state->vram[s]>>16)&0xff;
256               *BITMAP_ADDR16(bitmap, y, x+3) = (state->vram[s]>>24)&0xff;
244257               s++;
245258            }
246259      }
r10886r10887
251264
252265static WRITE32_HANDLER(FIFO_w)
253266{
254   PS7500_FIFO[data>>28]=data;
267   ssfindo_state *state = space->machine->driver_data<ssfindo_state>();
268   state->PS7500_FIFO[data>>28]=data;
255269
256270   if(!(data>>28))
257271   {
258      palette_set_color_rgb(space->machine, PS7500_FIFO[1]&0xff, data&0xff,(data>>8)&0xff,(data>>16)&0xff);
259      PS7500_FIFO[1]++; //autoinc
272      palette_set_color_rgb(space->machine, state->PS7500_FIFO[1]&0xff, data&0xff,(data>>8)&0xff,(data>>16)&0xff);
273      state->PS7500_FIFO[1]++; //autoinc
260274   }
261275}
262276static TIMER_CALLBACK( PS7500_Timer0_callback )
263277{
264   PS7500_IO[IRQSTA]|=0x20;
265   if(PS7500_IO[IRQMSKA]&0x20)
278   ssfindo_state *state = machine->driver_data<ssfindo_state>();
279   state->PS7500_IO[IRQSTA]|=0x20;
280   if(state->PS7500_IO[IRQMSKA]&0x20)
266281   {
267282      generic_pulse_irq_line(machine->device("maincpu"), ARM7_IRQ_LINE);
268283   }
269284}
270285
271static void PS7500_startTimer0(void)
286static void PS7500_startTimer0(running_machine *machine)
272287{
273   int val=((PS7500_IO[T0low]&0xff)|((PS7500_IO[T0high]&0xff)<<8))>>1;
288   ssfindo_state *state = machine->driver_data<ssfindo_state>();
289   int val=((state->PS7500_IO[T0low]&0xff)|((state->PS7500_IO[T0high]&0xff)<<8))>>1;
274290
275291   if(val==0)
276      PS7500timer0->adjust(attotime::never);
292      state->PS7500timer0->adjust(attotime::never);
277293   else
278      PS7500timer0->adjust(attotime::from_usec(val ), 0, attotime::from_usec(val ));
294      state->PS7500timer0->adjust(attotime::from_usec(val ), 0, attotime::from_usec(val ));
279295}
280296
281297static TIMER_CALLBACK( PS7500_Timer1_callback )
282298{
283   PS7500_IO[IRQSTA]|=0x40;
284   if(PS7500_IO[IRQMSKA]&0x40)
299   ssfindo_state *state = machine->driver_data<ssfindo_state>();
300   state->PS7500_IO[IRQSTA]|=0x40;
301   if(state->PS7500_IO[IRQMSKA]&0x40)
285302   {
286303      generic_pulse_irq_line(machine->device("maincpu"), ARM7_IRQ_LINE);
287304   }
288305}
289306
290static void PS7500_startTimer1(void)
307static void PS7500_startTimer1(running_machine *machine)
291308{
292   int val=((PS7500_IO[T1low]&0xff)|((PS7500_IO[T1high]&0xff)<<8))>>1;
309   ssfindo_state *state = machine->driver_data<ssfindo_state>();
310   int val=((state->PS7500_IO[T1low]&0xff)|((state->PS7500_IO[T1high]&0xff)<<8))>>1;
293311   if(val==0)
294      PS7500timer1->adjust(attotime::never);
312      state->PS7500timer1->adjust(attotime::never);
295313   else
296      PS7500timer1->adjust(attotime::from_usec(val ), 0, attotime::from_usec(val ));
314      state->PS7500timer1->adjust(attotime::from_usec(val ), 0, attotime::from_usec(val ));
297315}
298316
299317static INTERRUPT_GEN( ssfindo_interrupt )
300318{
301   PS7500_IO[IRQSTA]|=0x08;
302      if(PS7500_IO[IRQMSKA]&0x08)
319   ssfindo_state *state = device->machine->driver_data<ssfindo_state>();
320   state->PS7500_IO[IRQSTA]|=0x08;
321      if(state->PS7500_IO[IRQMSKA]&0x08)
303322      {
304323         generic_pulse_irq_line(device, ARM7_IRQ_LINE);
305324      }
306325}
307326
308static void PS7500_reset(void)
327static void PS7500_reset(running_machine *machine)
309328{
310      PS7500_IO[IOCR]         =   0x3f;
311      PS7500_IO[VIDCR]      =   0;
329   ssfindo_state *state = machine->driver_data<ssfindo_state>();
330      state->PS7500_IO[IOCR]         =   0x3f;
331      state->PS7500_IO[VIDCR]      =   0;
312332
313      PS7500timer0->adjust( attotime::never);
314      PS7500timer1->adjust( attotime::never);
333      state->PS7500timer0->adjust( attotime::never);
334      state->PS7500timer1->adjust( attotime::never);
315335}
316336
317337typedef void (*ssfindo_speedup_func)(address_space *space);
r10886r10887
336356
337357static READ32_HANDLER(PS7500_IO_r)
338358{
359   ssfindo_state *state = space->machine->driver_data<ssfindo_state>();
339360   switch(offset)
340361   {
341362      case MSECR:
r10886r10887
346367      mame_printf_debug("IOLINESR %i @%x\n", offset, cpu_get_pc(space->cpu));
347368#endif
348369
349      if(flashType == 1)
370      if(state->flashType == 1)
350371         return 0;
351372      else
352373         return space->machine->rand();
353374
354375      case IRQSTA:
355         return (PS7500_IO[offset] & (~2)) | 0x80;
376         return (state->PS7500_IO[offset] & (~2)) | 0x80;
356377
357378      case IRQRQA:
358         return (PS7500_IO[IRQSTA] & PS7500_IO[IRQMSKA]) | 0x80;
379         return (state->PS7500_IO[IRQSTA] & state->PS7500_IO[IRQMSKA]) | 0x80;
359380
360381      case IOCR: //TODO: nINT1, OD[n] p.81
361382         if (ssfindo_speedup) ssfindo_speedup(space);
362383         
363         if( iocr_hack)
384         if( state->iocr_hack)
364385         {
365386            return (input_port_read(space->machine, "PS7500") & 0x80) | 0x34 | (space->machine->rand()&3); //eeprom read ?
366387         }
r10886r10887
368389         return (input_port_read(space->machine, "PS7500") & 0x80) | 0x37;
369390
370391      case VIDCR:
371         return (PS7500_IO[offset] | 0x50) & 0xfffffff0;
392         return (state->PS7500_IO[offset] | 0x50) & 0xfffffff0;
372393
373394      case T1low:
374395      case T0low:
r10886r10887
379400      case VIDSTART:
380401      case VIDINITA: //TODO: bits 29 ("equal") and 30 (last bit)  p.105
381402
382         return PS7500_IO[offset];
403         return state->PS7500_IO[offset];
383404
384405
385406   }
386   return space->machine->rand();//PS7500_IO[offset];
407   return space->machine->rand();//state->PS7500_IO[offset];
387408}
388409
389410static WRITE32_HANDLER(PS7500_IO_w)
390411{
391   UINT32 temp=PS7500_IO[offset];
412   ssfindo_state *state = space->machine->driver_data<ssfindo_state>();
413   UINT32 temp=state->PS7500_IO[offset];
392414
393415   COMBINE_DATA(&temp);
394416
395417   switch(offset)
396418   {
397419      case IOLINES: //TODO: eeprom  24c01
398         PS7500_IO[offset]=data;
420         state->PS7500_IO[offset]=data;
399421            if(data&0xc0)
400               adrLatch=0;
422               state->adrLatch=0;
401423
402         if(cpu_get_pc(space->cpu) == 0xbac0 && flashType == 1)
424         if(cpu_get_pc(space->cpu) == 0xbac0 && state->flashType == 1)
403425         {
404            flashN=data&1;
426            state->flashN=data&1;
405427         }
406428
407429#if 0
r10886r10887
410432         break;
411433
412434      case IRQRQA:
413         PS7500_IO[IRQSTA]&=~temp;
435         state->PS7500_IO[IRQSTA]&=~temp;
414436      break;
415437
416438      case IRQMSKA:
417         PS7500_IO[IRQMSKA]=(temp&(~2))|0x80;
439         state->PS7500_IO[IRQMSKA]=(temp&(~2))|0x80;
418440      break;
419441
420442      case T1GO:
421            PS7500_startTimer1();
443            PS7500_startTimer1(space->machine);
422444         break;
423445
424446      case T0GO:
425         PS7500_startTimer0();
447         PS7500_startTimer0(space->machine);
426448      break;
427449
428450      case VIDEND:
429451      case VIDSTART:
430         COMBINE_DATA(&PS7500_IO[offset]);
431         PS7500_IO[offset]&=0xfffffff0; // qword align
452         COMBINE_DATA(&state->PS7500_IO[offset]);
453         state->PS7500_IO[offset]&=0xfffffff0; // qword align
432454      break;
433455
434456      case IOCR:
r10886r10887
444466      case T0high:
445467      case VIDCR:
446468      case VIDINITA: //TODO: bit 30 (last bit) p.105
447               COMBINE_DATA(&PS7500_IO[offset]);
469               COMBINE_DATA(&state->PS7500_IO[offset]);
448470      break;
449471     
450472     
r10886r10887
454476
455477static READ32_HANDLER(io_r)
456478{
479   ssfindo_state *state = space->machine->driver_data<ssfindo_state>();
457480   UINT16 *FLASH = (UINT16 *)space->machine->region("user2")->base(); //16 bit - WORD access
458481
459   int adr=flashAdr*0x200+(flashOffset);
482   int adr=state->flashAdr*0x200+(state->flashOffset);
460483
461484
462   switch(flashType)
485   switch(state->flashType)
463486   {
464487      case 0:
465         if(PS7500_IO[IOLINES]&1) //bit 0 of IOLINES  = flash select ( 5/6 or 3/2 )
488         if(state->PS7500_IO[IOLINES]&1) //bit 0 of IOLINES  = flash select ( 5/6 or 3/2 )
466489            adr+=0x400000;
467490      break;
468491
469492      case 1:
470         adr+=0x400000*flashN;
493         adr+=0x400000*state->flashN;
471494      break;
472495   }
473496
474497   if(adr<0x400000*2)
475498   {
476      flashOffset++;
499      state->flashOffset++;
477500      return FLASH[adr];
478501   }
479502   return 0;
r10886r10887
481504
482505static WRITE32_HANDLER(io_w)
483506{
507   ssfindo_state *state = space->machine->driver_data<ssfindo_state>();
484508   UINT32 temp = 0;
485509   COMBINE_DATA(&temp);
486510
487511#if 0
488   logerror("[io_w] = %x @%x [latch=%x]\n",data,cpu_get_pc(space->cpu),adrLatch);
512   logerror("[io_w] = %x @%x [latch=%x]\n",data,cpu_get_pc(space->cpu),state->adrLatch);
489513#endif
490514
491   if(adrLatch==1)
492      flashAdr=(temp>>16)&0xff;
493   if(adrLatch==2)
515   if(state->adrLatch==1)
516      state->flashAdr=(temp>>16)&0xff;
517   if(state->adrLatch==2)
494518   {
495      flashAdr|=(temp>>16)&0xff00;
496      flashOffset=0;
519      state->flashAdr|=(temp>>16)&0xff00;
520      state->flashOffset=0;
497521   }
498   adrLatch=(adrLatch+1)%3;
522   state->adrLatch=(state->adrLatch+1)%3;
499523}
500524
501525static WRITE32_HANDLER(debug_w)
r10886r10887
535559   AM_RANGE(0x0324f000, 0x0324f003) AM_READ(SIMPLEIO_r)
536560   AM_RANGE(0x03245000, 0x03245003) AM_WRITENOP /* sound ? */
537561   AM_RANGE(0x03400000, 0x03400003) AM_WRITE(FIFO_w)
538   AM_RANGE(0x10000000, 0x11ffffff) AM_RAM AM_BASE (&vram)
562   AM_RANGE(0x10000000, 0x11ffffff) AM_RAM AM_BASE_MEMBER(ssfindo_state, vram)
539563ADDRESS_MAP_END
540564
541565static ADDRESS_MAP_START( ppcar_map, ADDRESS_SPACE_PROGRAM, 32 )
r10886r10887
550574   AM_RANGE(0x033c0000, 0x033c0003) AM_READ(io_r) AM_WRITE(io_w)
551575   AM_RANGE(0x03400000, 0x03400003) AM_WRITE(FIFO_w)
552576   AM_RANGE(0x08000000, 0x08ffffff) AM_RAM
553   AM_RANGE(0x10000000, 0x10ffffff) AM_RAM AM_BASE (&vram)
577   AM_RANGE(0x10000000, 0x10ffffff) AM_RAM AM_BASE_MEMBER(ssfindo_state, vram)
554578ADDRESS_MAP_END
555579
556580static READ32_HANDLER(tetfight_unk_r)
r10886r10887
572596   AM_RANGE(0x03240004, 0x03240007) AM_READ_PORT("IN0")
573597   AM_RANGE(0x03240008, 0x0324000b) AM_READ_PORT("DSW2")
574598   AM_RANGE(0x03240020, 0x03240023) AM_READWRITE( tetfight_unk_r, tetfight_unk_w)
575   AM_RANGE(0x10000000, 0x14ffffff) AM_RAM AM_BASE (&vram)
599   AM_RANGE(0x10000000, 0x14ffffff) AM_RAM AM_BASE_MEMBER(ssfindo_state, vram)
576600ADDRESS_MAP_END
577601
578602static MACHINE_RESET( ssfindo )
579603{
580   PS7500_reset();
604   PS7500_reset(machine);
581605}
582606
583607static INPUT_PORTS_START( ssfindo )
r10886r10887
716740INPUT_PORTS_END
717741
718742
719static MACHINE_CONFIG_START( ssfindo, driver_device )
743static MACHINE_CONFIG_START( ssfindo, ssfindo_state )
720744
721745   /* basic machine hardware */
722746   MCFG_CPU_ADD("maincpu", ARM7, 54000000) // guess...
r10886r10887
823847
824848static DRIVER_INIT(common)
825849{
850   ssfindo_state *state = machine->driver_data<ssfindo_state>();
826851   ssfindo_speedup = 0;
827   PS7500timer0 = machine->scheduler().timer_alloc(FUNC(PS7500_Timer0_callback));
828   PS7500timer1 = machine->scheduler().timer_alloc(FUNC(PS7500_Timer1_callback));
852   state->PS7500timer0 = machine->scheduler().timer_alloc(FUNC(PS7500_Timer0_callback));
853   state->PS7500timer1 = machine->scheduler().timer_alloc(FUNC(PS7500_Timer1_callback));
829854
830855}
831856
832857static DRIVER_INIT(ssfindo)
833858{
859   ssfindo_state *state = machine->driver_data<ssfindo_state>();
834860   DRIVER_INIT_CALL(common);
835   flashType=0;
861   state->flashType=0;
836862   ssfindo_speedup = ssfindo_speedups;
837   iocr_hack=0;
863   state->iocr_hack=0;
838864}
839865
840866static DRIVER_INIT(ppcar)
841867{
868   ssfindo_state *state = machine->driver_data<ssfindo_state>();
842869   DRIVER_INIT_CALL(common);
843   flashType=1;
870   state->flashType=1;
844871   ssfindo_speedup = ppcar_speedups;
845   iocr_hack=0;
872   state->iocr_hack=0;
846873}
847874
848875static DRIVER_INIT(tetfight)
849876{
877   ssfindo_state *state = machine->driver_data<ssfindo_state>();
850878   DRIVER_INIT_CALL(common);
851   flashType=0;
852   iocr_hack=1;
879   state->flashType=0;
880   state->iocr_hack=1;
853881}
854882
855883GAME( 1999, ssfindo, 0,        ssfindo,  ssfindo,  ssfindo,   ROT0, "Icarus", "See See Find Out", GAME_NO_SOUND )
src/mame/drivers/peplus.c
r10886r10887
184184
185185   UINT8 *videoram;
186186   required_shared_ptr<UINT8> cmos_ram;
187   UINT16 autohold_addr;
188   tilemap_t *bg_tilemap;
189   UINT8 wingboard;
190   UINT8 jumper_e16_e17;
191   UINT8 *program_ram;
192   UINT8 *s3000_ram;
193   UINT8 *s5000_ram;
194   UINT8 *s7000_ram;
195   UINT8 *sb000_ram;
196   UINT8 *sd000_ram;
197   UINT8 *sf000_ram;
198   UINT16 vid_address;
199   UINT8 *palette_ram;
200   UINT8 *palette_ram2;
201   UINT8 *io_port;
202   UINT64 last_cycles;
203   UINT8 coin_state;
204   UINT64 last_door;
205   UINT8 door_open;
206   UINT64 last_coin_out;
207   UINT8 coin_out_state;
208   int sda_dir;
187209};
188210
189211
r10886r10887
192214#define MC6845_CLOCK      ((MASTER_CLOCK)/8/3)
193215#define SOUND_CLOCK         ((MASTER_CLOCK)/12)
194216
195static UINT16 autohold_addr; /* address to patch in program RAM to enable autohold feature */
196217
197static tilemap_t *bg_tilemap;
198static UINT8 wingboard;
199static UINT8 jumper_e16_e17; /* Set this to TRUE when CG chips are 27c512 instead of 27c256 */
200
201/* Pointers to External RAM */
202static UINT8 *program_ram;
203static UINT8 *s3000_ram;
204static UINT8 *s5000_ram;
205static UINT8 *s7000_ram;
206static UINT8 *sb000_ram;
207static UINT8 *sd000_ram;
208static UINT8 *sf000_ram;
209
210/* Variables used instead of CRTC6845 system */
211static UINT16 vid_address = 0;
212
213/* Holds upper video address, palette number and jumper_e16_e17 flag */
214static UINT8 *palette_ram;
215static UINT8 *palette_ram2;
216
217/* IO Ports */
218static UINT8 *io_port;
219
220/* Coin, Door, Hopper and EEPROM States */
221static UINT64 last_cycles;
222static UINT8 coin_state = 0;
223static UINT64 last_door;
224static UINT8 door_open = 0;
225static UINT64 last_coin_out;
226static UINT8 coin_out_state = 0;
227static int sda_dir = 0;
228
229/* Static Variables */
230218#define eeprom_NVRAM_SIZE   0x200 // 4k Bit
231219
232220/* EEPROM is a X2404P 4K-bit Serial I2C Bus */
r10886r10887
260248
261249static void peplus_load_superdata(running_machine *machine, const char *bank_name)
262250{
251   peplus_state *state = machine->driver_data<peplus_state>();
263252    UINT8 *super_data = machine->region(bank_name)->base();
264253
265254    /* Distribute Superboard Data */
266    memcpy(s3000_ram, &super_data[0x3000], 0x1000);
267    memcpy(s5000_ram, &super_data[0x5000], 0x1000);
268    memcpy(s7000_ram, &super_data[0x7000], 0x1000);
269    memcpy(sb000_ram, &super_data[0xb000], 0x1000);
270    memcpy(sd000_ram, &super_data[0xd000], 0x1000);
271    memcpy(sf000_ram, &super_data[0xf000], 0x1000);
255    memcpy(state->s3000_ram, &super_data[0x3000], 0x1000);
256    memcpy(state->s5000_ram, &super_data[0x5000], 0x1000);
257    memcpy(state->s7000_ram, &super_data[0x7000], 0x1000);
258    memcpy(state->sb000_ram, &super_data[0xb000], 0x1000);
259    memcpy(state->sd000_ram, &super_data[0xd000], 0x1000);
260    memcpy(state->sf000_ram, &super_data[0xf000], 0x1000);
272261}
273262
274263
r10886r10887
311300
312301static MC6845_ON_UPDATE_ADDR_CHANGED(crtc_addr)
313302{
314   vid_address = address;
303   peplus_state *state = device->machine->driver_data<peplus_state>();
304   state->vid_address = address;
315305}
316306
317307static WRITE8_DEVICE_HANDLER( peplus_crtc_mode_w )
r10886r10887
347337{
348338   peplus_state *state = device->machine->driver_data<peplus_state>();
349339   UINT8 *videoram = state->videoram;
350   videoram[vid_address] = data;
351   palette_ram[vid_address] = io_port[1];
352   palette_ram2[vid_address] = io_port[3];
340   videoram[state->vid_address] = data;
341   state->palette_ram[state->vid_address] = state->io_port[1];
342   state->palette_ram2[state->vid_address] = state->io_port[3];
353343
354   tilemap_mark_tile_dirty(bg_tilemap, vid_address);
344   tilemap_mark_tile_dirty(state->bg_tilemap, state->vid_address);
355345
356346   /* An access here triggers a device read !*/
357347   (void) mc6845_register_r(device, 0);
r10886r10887
359349
360350static WRITE8_HANDLER( peplus_io_w )
361351{
362   io_port[offset] = data;
352   peplus_state *state = space->machine->driver_data<peplus_state>();
353   state->io_port[offset] = data;
363354}
364355
365356static WRITE8_HANDLER( peplus_duart_w )
r10886r10887
373364   char bank_name[6];
374365
375366   /* Test for Wingboard PAL Trigger Condition */
376   if (offset == 0x1fff && wingboard && data < 5)
367   if (offset == 0x1fff && state->wingboard && data < 5)
377368   {
378369      sprintf(bank_name, "user%d", data + 1);
379370      peplus_load_superdata(space->machine, bank_name);
r10886r10887
384375
385376static WRITE8_HANDLER( peplus_s3000_w )
386377{
387   s3000_ram[offset] = data;
378   peplus_state *state = space->machine->driver_data<peplus_state>();
379   state->s3000_ram[offset] = data;
388380}
389381
390382static WRITE8_HANDLER( peplus_s5000_w )
391383{
392   s5000_ram[offset] = data;
384   peplus_state *state = space->machine->driver_data<peplus_state>();
385   state->s5000_ram[offset] = data;
393386}
394387
395388static WRITE8_HANDLER( peplus_s7000_w )
396389{
397   s7000_ram[offset] = data;
390   peplus_state *state = space->machine->driver_data<peplus_state>();
391   state->s7000_ram[offset] = data;
398392}
399393
400394static WRITE8_HANDLER( peplus_sb000_w )
401395{
402   sb000_ram[offset] = data;
396   peplus_state *state = space->machine->driver_data<peplus_state>();
397   state->sb000_ram[offset] = data;
403398}
404399
405400static WRITE8_HANDLER( peplus_sd000_w )
406401{
407   sd000_ram[offset] = data;
402   peplus_state *state = space->machine->driver_data<peplus_state>();
403   state->sd000_ram[offset] = data;
408404}
409405
410406static WRITE8_HANDLER( peplus_sf000_w )
411407{
412   sf000_ram[offset] = data;
408   peplus_state *state = space->machine->driver_data<peplus_state>();
409   state->sf000_ram[offset] = data;
413410}
414411
415412static WRITE8_HANDLER( peplus_output_bank_a_w )
416413{
414   peplus_state *state = space->machine->driver_data<peplus_state>();
417415   output_set_value("pe_bnka0",(data >> 0) & 1); /* Coin Lockout */
418416   output_set_value("pe_bnka1",(data >> 1) & 1); /* Diverter */
419417   output_set_value("pe_bnka2",(data >> 2) & 1); /* Bell */
r10886r10887
423421   output_set_value("pe_bnka6",(data >> 6) & 1); /* specific to a kind of machine */
424422   output_set_value("pe_bnka7",(data >> 7) & 1); /* specific to a kind of machine */
425423
426    coin_out_state = 0;
424    state->coin_out_state = 0;
427425    if(((data >> 4) & 1) || ((data >> 5) & 1))
428        coin_out_state = 3;
426        state->coin_out_state = 3;
429427}
430428
431429static WRITE8_HANDLER( peplus_output_bank_b_w )
r10886r10887
454452
455453static WRITE8_DEVICE_HANDLER(i2c_nvram_w)
456454{
455   peplus_state *state = device->machine->driver_data<peplus_state>();
457456   i2cmem_scl_write(device,BIT(data, 2));
458   sda_dir = BIT(data, 1);
457   state->sda_dir = BIT(data, 1);
459458   i2cmem_sda_write(device,BIT(data, 0));
460459}
461460
r10886r10887
466465
467466static READ8_HANDLER( peplus_io_r )
468467{
469    return io_port[offset];
468   peplus_state *state = space->machine->driver_data<peplus_state>();
469    return state->io_port[offset];
470470}
471471
472472static READ8_HANDLER( peplus_duart_r )
r10886r10887
483483
484484static READ8_HANDLER( peplus_s3000_r )
485485{
486   return s3000_ram[offset];
486   peplus_state *state = space->machine->driver_data<peplus_state>();
487   return state->s3000_ram[offset];
487488}
488489
489490static READ8_HANDLER( peplus_s5000_r )
490491{
491   return s5000_ram[offset];
492   peplus_state *state = space->machine->driver_data<peplus_state>();
493   return state->s5000_ram[offset];
492494}
493495
494496static READ8_HANDLER( peplus_s7000_r )
495497{
496   return s7000_ram[offset];
498   peplus_state *state = space->machine->driver_data<peplus_state>();
499   return state->s7000_ram[offset];
497500}
498501
499502static READ8_HANDLER( peplus_sb000_r )
500503{
501   return sb000_ram[offset];
504   peplus_state *state = space->machine->driver_data<peplus_state>();
505   return state->sb000_ram[offset];
502506}
503507
504508static READ8_HANDLER( peplus_sd000_r )
505509{
506   return sd000_ram[offset];
510   peplus_state *state = space->machine->driver_data<peplus_state>();
511   return state->sd000_ram[offset];
507512}
508513
509514static READ8_HANDLER( peplus_sf000_r )
510515{
511   return sf000_ram[offset];
516   peplus_state *state = space->machine->driver_data<peplus_state>();
517   return state->sf000_ram[offset];
512518}
513519
514520/* Last Color in Every Palette is bgcolor */
r10886r10887
529535
530536static READ8_DEVICE_HANDLER( peplus_input_bank_a_r )
531537{
538   peplus_state *state = device->machine->driver_data<peplus_state>();
532539/*
533540        Bit 0 = COIN DETECTOR A
534541        Bit 1 = COIN DETECTOR B
r10886r10887
546553   UINT16 door_wait = 500;
547554
548555   UINT8 sda = 0;
549   if(!sda_dir)
556   if(!state->sda_dir)
550557   {
551558      sda = i2cmem_sda_read(device);
552559   }
553560
554   if ((input_port_read_safe(device->machine, "SENSOR",0x00) & 0x01) == 0x01 && coin_state == 0) {
555      coin_state = 1; // Start Coin Cycle
556      last_cycles = device->machine->firstcpu->total_cycles();
561   if ((input_port_read_safe(device->machine, "SENSOR",0x00) & 0x01) == 0x01 && state->coin_state == 0) {
562      state->coin_state = 1; // Start Coin Cycle
563      state->last_cycles = device->machine->firstcpu->total_cycles();
557564   } else {
558565      /* Process Next Coin Optic State */
559      if (curr_cycles - last_cycles > 600000/6 && coin_state != 0) {
560         coin_state++;
561         if (coin_state > 5)
562            coin_state = 0;
563         last_cycles = device->machine->firstcpu->total_cycles();
566      if (curr_cycles - state->last_cycles > 600000/6 && state->coin_state != 0) {
567         state->coin_state++;
568         if (state->coin_state > 5)
569            state->coin_state = 0;
570         state->last_cycles = device->machine->firstcpu->total_cycles();
564571      }
565572   }
566573
567   switch (coin_state)
574   switch (state->coin_state)
568575   {
569576      case 0x00: // No Coin
570577         coin_optics = 0x00;
r10886r10887
586593         break;
587594   }
588595
589   if (wingboard)
596   if (state->wingboard)
590597      door_wait = 12345;
591598
592   if (curr_cycles - last_door > door_wait) {
599   if (curr_cycles - state->last_door > door_wait) {
593600      if ((input_port_read_safe(device->machine, "DOOR",0xff) & 0x01) == 0x01) {
594         door_open = (!door_open & 0x01);
601         state->door_open = (!state->door_open & 0x01);
595602      } else {
596         door_open = 1;
603         state->door_open = 1;
597604      }
598      last_door = device->machine->firstcpu->total_cycles();
605      state->last_door = device->machine->firstcpu->total_cycles();
599606   }
600607
601   if (curr_cycles - last_coin_out > 600000/12 && coin_out_state != 0) { // Guessing with 600000
602      if (coin_out_state != 2) {
603            coin_out_state = 2; // Coin-Out Off
608   if (curr_cycles - state->last_coin_out > 600000/12 && state->coin_out_state != 0) { // Guessing with 600000
609      if (state->coin_out_state != 2) {
610            state->coin_out_state = 2; // Coin-Out Off
604611        } else {
605            coin_out_state = 3; // Coin-Out On
612            state->coin_out_state = 3; // Coin-Out On
606613        }
607614
608      last_coin_out = device->machine->firstcpu->total_cycles();
615      state->last_coin_out = device->machine->firstcpu->total_cycles();
609616   }
610617
611    switch (coin_out_state)
618    switch (state->coin_out_state)
612619    {
613620        case 0x00: // No Coin-Out
614621           coin_out = 0x00;
r10886r10887
624631           break;
625632    }
626633
627   bank_a = (sda<<7) | bank_a | (door_open<<5) | coin_optics | coin_out;
634   bank_a = (sda<<7) | bank_a | (state->door_open<<5) | coin_optics | coin_out;
628635
629636   return bank_a;
630637}
r10886r10887
638645{
639646   peplus_state *state = machine->driver_data<peplus_state>();
640647   UINT8 *videoram = state->videoram;
641   int pr = palette_ram[tile_index];
642   int pr2 = palette_ram2[tile_index];
648   int pr = state->palette_ram[tile_index];
649   int pr2 = state->palette_ram2[tile_index];
643650   int vr = videoram[tile_index];
644651
645652   int code = ((pr & 0x0f)*256) | vr;
646653   int color = (pr>>4) & 0x0f;
647654
648655   // Access 2nd Half of CGs and CAP
649   if (jumper_e16_e17 && (pr2 & 0x10) == 0x10)
656   if (state->jumper_e16_e17 && (pr2 & 0x10) == 0x10)
650657   {
651658      code += 0x1000;
652659      color += 0x10;
r10886r10887
657664
658665static VIDEO_START( peplus )
659666{
660   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 40, 25);
661   palette_ram = auto_alloc_array(machine, UINT8, 0x3000);
662   memset(palette_ram, 0, 0x3000);
663   palette_ram2 = auto_alloc_array(machine, UINT8, 0x3000);
664   memset(palette_ram2, 0, 0x3000);
667   peplus_state *state = machine->driver_data<peplus_state>();
668   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 40, 25);
669   state->palette_ram = auto_alloc_array(machine, UINT8, 0x3000);
670   memset(state->palette_ram, 0, 0x3000);
671   state->palette_ram2 = auto_alloc_array(machine, UINT8, 0x3000);
672   memset(state->palette_ram2, 0, 0x3000);
665673}
666674
667675static SCREEN_UPDATE( peplus )
668676{
669   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
677   peplus_state *state = screen->machine->driver_data<peplus_state>();
678   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
670679
671680   return 0;
672681}
r10886r10887
722731*************************/
723732
724733static ADDRESS_MAP_START( peplus_map, ADDRESS_SPACE_PROGRAM, 8 )
725   AM_RANGE(0x0000, 0xffff) AM_ROM AM_BASE(&program_ram)
734   AM_RANGE(0x0000, 0xffff) AM_ROM AM_BASE_MEMBER(peplus_state, program_ram)
726735ADDRESS_MAP_END
727736
728737static ADDRESS_MAP_START( peplus_iomap, ADDRESS_SPACE_IO, 8 )
r10886r10887
736745   AM_RANGE(0x2083, 0x2083) AM_DEVREADWRITE("crtc", mc6845_register_r, peplus_crtc_display_w)
737746
738747    // Superboard Data
739   AM_RANGE(0x3000, 0x3fff) AM_READWRITE(peplus_s3000_r, peplus_s3000_w) AM_BASE(&s3000_ram)
748   AM_RANGE(0x3000, 0x3fff) AM_READWRITE(peplus_s3000_r, peplus_s3000_w) AM_BASE_MEMBER(peplus_state, s3000_ram)
740749
741750   // Sound and Dipswitches
742751   AM_RANGE(0x4000, 0x4000) AM_DEVWRITE("aysnd", ay8910_address_w)
743752   AM_RANGE(0x4004, 0x4004) AM_READ_PORT("SW1")/* likely ay8910 input port, not direct */ AM_DEVWRITE("aysnd", ay8910_data_w)
744753
745754    // Superboard Data
746   AM_RANGE(0x5000, 0x5fff) AM_READWRITE(peplus_s5000_r, peplus_s5000_w) AM_BASE(&s5000_ram)
755   AM_RANGE(0x5000, 0x5fff) AM_READWRITE(peplus_s5000_r, peplus_s5000_w) AM_BASE_MEMBER(peplus_state, s5000_ram)
747756
748757   // Background Color Latch
749758   AM_RANGE(0x6000, 0x6000) AM_READ(peplus_bgcolor_r) AM_WRITE(peplus_bgcolor_w)
r10886r10887
752761   AM_RANGE(0x06001, 0x06400) AM_RAM AM_BASE_MEMBER(peplus_state, videoram)
753762
754763    // Superboard Data
755   AM_RANGE(0x7000, 0x7fff) AM_READWRITE(peplus_s7000_r, peplus_s7000_w) AM_BASE(&s7000_ram)
764   AM_RANGE(0x7000, 0x7fff) AM_READWRITE(peplus_s7000_r, peplus_s7000_w) AM_BASE_MEMBER(peplus_state, s7000_ram)
756765
757766   // Input Bank A, Output Bank C
758767   AM_RANGE(0x8000, 0x8000) AM_DEVREAD("i2cmem",peplus_input_bank_a_r) AM_WRITE(peplus_output_bank_c_w)
r10886r10887
764773   AM_RANGE(0xa000, 0xa000) AM_READ_PORT("IN0") AM_WRITE(peplus_output_bank_b_w)
765774
766775    // Superboard Data
767   AM_RANGE(0xb000, 0xbfff) AM_READWRITE(peplus_sb000_r, peplus_sb000_w) AM_BASE(&sb000_ram)
776   AM_RANGE(0xb000, 0xbfff) AM_READWRITE(peplus_sb000_r, peplus_sb000_w) AM_BASE_MEMBER(peplus_state, sb000_ram)
768777
769778   // Output Bank A
770779   AM_RANGE(0xc000, 0xc000) AM_READ(peplus_watchdog_r) AM_WRITE(peplus_output_bank_a_w)
771780
772781    // Superboard Data
773   AM_RANGE(0xd000, 0xdfff) AM_READWRITE(peplus_sd000_r, peplus_sd000_w) AM_BASE(&sd000_ram)
782   AM_RANGE(0xd000, 0xdfff) AM_READWRITE(peplus_sd000_r, peplus_sd000_w) AM_BASE_MEMBER(peplus_state, sd000_ram)
774783
775784   // DUART
776785   AM_RANGE(0xe000, 0xe00f) AM_READWRITE(peplus_duart_r, peplus_duart_w)
777786
778787    // Superboard Data
779   AM_RANGE(0xf000, 0xffff) AM_READWRITE(peplus_sf000_r, peplus_sf000_w) AM_BASE(&sf000_ram)
788   AM_RANGE(0xf000, 0xffff) AM_READWRITE(peplus_sf000_r, peplus_sf000_w) AM_BASE_MEMBER(peplus_state, sf000_ram)
780789
781790   /* Ports start here */
782   AM_RANGE(MCS51_PORT_P0, MCS51_PORT_P3) AM_READ(peplus_io_r) AM_WRITE(peplus_io_w) AM_BASE(&io_port)
791   AM_RANGE(MCS51_PORT_P0, MCS51_PORT_P3) AM_READ(peplus_io_r) AM_WRITE(peplus_io_w) AM_BASE_MEMBER(peplus_state, io_port)
783792ADDRESS_MAP_END
784793
785794
r10886r10887
987996
988997static MACHINE_RESET( peplus )
989998{
990/*
991    AutoHold Feature Currently Disabled
999   /* AutoHold Feature Currently Disabled */
1000#if 0
1001   peplus_state *state = machine->driver_data<peplus_state>();
9921002
993    // pepp0158
994    program_ram[0xa19f] = 0x22; // RET - Disable Memory Test
995    program_ram[0xddea] = 0x22; // RET - Disable Program Checksum
996    autohold_addr = 0x5ffe; // AutoHold Address
1003   // pepp0158
1004   state->program_ram[0xa19f] = 0x22; // RET - Disable Memory Test
1005   state->program_ram[0xddea] = 0x22; // RET - Disable Program Checksum
1006   state->autohold_addr = 0x5ffe; // AutoHold Address
9971007
998    // pepp0188
999    program_ram[0x9a8d] = 0x22; // RET - Disable Memory Test
1000    program_ram[0xf429] = 0x22; // RET - Disable Program Checksum
1001    autohold_addr = 0x742f; // AutoHold Address
1008   // pepp0188
1009   state->program_ram[0x9a8d] = 0x22; // RET - Disable Memory Test
1010   state->program_ram[0xf429] = 0x22; // RET - Disable Program Checksum
1011   state->autohold_addr = 0x742f; // AutoHold Address
10021012
1003    // pepp0516
1004    program_ram[0x9a24] = 0x22; // RET - Disable Memory Test
1005    program_ram[0xd61d] = 0x22; // RET - Disable Program Checksum
1006    autohold_addr = 0x5e7e; // AutoHold Address
1013   // pepp0516
1014   state->program_ram[0x9a24] = 0x22; // RET - Disable Memory Test
1015   state->program_ram[0xd61d] = 0x22; // RET - Disable Program Checksum
1016   state->autohold_addr = 0x5e7e; // AutoHold Address
10071017
1008    if (autohold_addr)
1009        program_ram[autohold_addr] = input_port_read_safe(machine, "AUTOHOLD",0x00) & 0x01;
1010*/
1018   if (state->autohold_addr)
1019      state->program_ram[state->autohold_addr] = input_port_read_safe(machine, "AUTOHOLD",0x00) & 0x01;
1020#endif
10111021}
10121022
10131023
r10886r10887
10561066/* Normal board */
10571067static void peplus_init(running_machine *machine)
10581068{
1069   peplus_state *state = machine->driver_data<peplus_state>();
10591070   /* default : no address to patch in program RAM to enable autohold feature */
1060   autohold_addr = 0;
1071   state->autohold_addr = 0;
10611072}
10621073
10631074
r10886r10887
10681079/* Normal board */
10691080static DRIVER_INIT( peplus )
10701081{
1071   wingboard = FALSE;
1072   jumper_e16_e17 = FALSE;
1082   peplus_state *state = machine->driver_data<peplus_state>();
1083   state->wingboard = FALSE;
1084   state->jumper_e16_e17 = FALSE;
10731085   peplus_init(machine);
10741086}
10751087
10761088/* Superboard */
10771089static DRIVER_INIT( peplussb )
10781090{
1079   wingboard = FALSE;
1080   jumper_e16_e17 = FALSE;
1091   peplus_state *state = machine->driver_data<peplus_state>();
1092   state->wingboard = FALSE;
1093   state->jumper_e16_e17 = FALSE;
10811094   peplus_load_superdata(machine, "user1");
10821095
10831096   peplus_init(machine);
r10886r10887
10861099/* Superboard with Attached Wingboard */
10871100static DRIVER_INIT( peplussbw )
10881101{
1089   wingboard = TRUE;
1090   jumper_e16_e17 = TRUE;
1102   peplus_state *state = machine->driver_data<peplus_state>();
1103   state->wingboard = TRUE;
1104   state->jumper_e16_e17 = TRUE;
10911105   peplus_load_superdata(machine, "user1");
10921106
10931107   peplus_init(machine);
src/mame/drivers/combatsc.c
r10886r10887
2424  Execution timing of the Z80 is important because it maintains music tempo
2525  by polling the 2203's second timer. Even when working alone with no
2626  context-switch the chip shouldn't be running at 1.5MHz otherwise it won't
27  keep the right pace. Similar Konmai games from the same period(mainevt,
27  keep the right pace. Similar Konami games from the same period(mainevt,
2828  battlnts, flkatck...etc.) all have a 3.579545MHz Z80 for sound.
2929
3030  In spite of adjusting clock speed polling is deemed inaccurate when
src/mame/drivers/jokrwild.c
r10886r10887
9797#include "machine/nvram.h"
9898
9999
100class jokrwild_state : public driver_device
101{
102public:
103   jokrwild_state(running_machine &machine, const driver_device_config_base &config)
104      : driver_device(machine, config) { }
105
106   UINT8 *videoram;
107   UINT8 *colorram;
108   tilemap_t *bg_tilemap;
109};
110
111
100112/*************************
101113*     Video Hardware     *
102114*************************/
103115
104static UINT8 *videoram;
105static UINT8 *colorram;
106static tilemap_t *bg_tilemap;
107116
108
109117static WRITE8_HANDLER( jokrwild_videoram_w )
110118{
111   videoram[offset] = data;
112   tilemap_mark_tile_dirty(bg_tilemap, offset);
119   jokrwild_state *state = space->machine->driver_data<jokrwild_state>();
120   state->videoram[offset] = data;
121   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
113122}
114123
115124
116125static WRITE8_HANDLER( jokrwild_colorram_w )
117126{
118   colorram[offset] = data;
119   tilemap_mark_tile_dirty(bg_tilemap, offset);
127   jokrwild_state *state = space->machine->driver_data<jokrwild_state>();
128   state->colorram[offset] = data;
129   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
120130}
121131
122132
123133static TILE_GET_INFO( get_bg_tile_info )
124134{
135   jokrwild_state *state = machine->driver_data<jokrwild_state>();
125136/*  - bits -
126137    7654 3210
127138    xx-- ----   bank select.
128139    ---- xxxx   color code.
129140*/
130   int attr = colorram[tile_index];
131   int code = videoram[tile_index] | ((attr & 0xc0) << 2);
141   int attr = state->colorram[tile_index];
142   int code = state->videoram[tile_index] | ((attr & 0xc0) << 2);
132143   int color = (attr & 0x0f);
133144
134145   SET_TILE_INFO( 0, code , color , 0);
r10886r10887
137148
138149static VIDEO_START( jokrwild )
139150{
140   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 24, 26);
151   jokrwild_state *state = machine->driver_data<jokrwild_state>();
152   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 24, 26);
141153}
142154
143155
144156static SCREEN_UPDATE( jokrwild )
145157{
146   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
158   jokrwild_state *state = screen->machine->driver_data<jokrwild_state>();
159   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
147160   return 0;
148161}
149162
r10886r10887
179192*************************/
180193
181194static ADDRESS_MAP_START( jokrwild_map, ADDRESS_SPACE_PROGRAM, 8 )
182   AM_RANGE(0x0000, 0x03ff) AM_RAM_WRITE(jokrwild_videoram_w) AM_BASE(&videoram)
195   AM_RANGE(0x0000, 0x03ff) AM_RAM_WRITE(jokrwild_videoram_w) AM_BASE_MEMBER(jokrwild_state, videoram)
183196   AM_RANGE(0x0400, 0x07ff) AM_RAM //FIXME: backup RAM
184   AM_RANGE(0x2000, 0x23ff) AM_RAM_WRITE(jokrwild_colorram_w) AM_BASE(&colorram)
197   AM_RANGE(0x2000, 0x23ff) AM_RAM_WRITE(jokrwild_colorram_w) AM_BASE_MEMBER(jokrwild_state, colorram)
185198   AM_RANGE(0x2400, 0x27ff) AM_RAM //stack RAM
186199   AM_RANGE(0x4004, 0x4007) AM_DEVREADWRITE("pia0", pia6821_r, pia6821_w)
187200   AM_RANGE(0x4008, 0x400b) AM_DEVREADWRITE("pia1", pia6821_r, pia6821_w) //optical sensor is here
r10886r10887
455468*    Machine Drivers     *
456469*************************/
457470
458static MACHINE_CONFIG_START( jokrwild, driver_device )
471static MACHINE_CONFIG_START( jokrwild, jokrwild_state )
459472
460473   /* basic machine hardware */
461474   MCFG_CPU_ADD("maincpu", M6809, MASTER_CLOCK/2)   /* guess */
src/mame/drivers/poker72.c
r10886r10887
1414#include "cpu/z80/z80.h"
1515#include "sound/ay8910.h"
1616
17static UINT8 *poker72_vram,*poker72_pal;
18static UINT8 tile_bank;
1917
18class poker72_state : public driver_device
19{
20public:
21   poker72_state(running_machine &machine, const driver_device_config_base &config)
22      : driver_device(machine, config) { }
23
24   UINT8 *vram;
25   UINT8 *pal;
26   UINT8 tile_bank;
27};
28
29
2030static VIDEO_START(poker72)
2131{
22
2332}
2433
2534static SCREEN_UPDATE(poker72)
2635{
36   poker72_state *state = screen->machine->driver_data<poker72_state>();
2737   int x,y,count;
2838
2939   count = 0;
r10886r10887
3242   {
3343      for (x=0;x<64;x++)
3444      {
35         int tile = ((poker72_vram[count+1] & 0x0f) << 8 ) | (poker72_vram[count+0] & 0xff); //TODO: tile bank
36         int fx = (poker72_vram[count+1] & 0x10);
37         int fy = (poker72_vram[count+1] & 0x20);
38         int color = (poker72_vram[count+1] & 0xc0) >> 6;
45         int tile = ((state->vram[count+1] & 0x0f) << 8 ) | (state->vram[count+0] & 0xff); //TODO: tile bank
46         int fx = (state->vram[count+1] & 0x10);
47         int fy = (state->vram[count+1] & 0x20);
48         int color = (state->vram[count+1] & 0xc0) >> 6;
3949
40         tile|= tile_bank << 12;
50         tile|= state->tile_bank << 12;
4151
4252         drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[0],tile,color,fx,fy,x*8,y*8);
4353
r10886r10887
5060
5161static WRITE8_HANDLER( poker72_paletteram_w )
5262{
63   poker72_state *state = space->machine->driver_data<poker72_state>();
5364   int r,g,b;
54   poker72_pal[offset] = data;
65   state->pal[offset] = data;
5566
56   r = poker72_pal[(offset & 0x3ff)+0x000] & 0x3f;
57   g = poker72_pal[(offset & 0x3ff)+0x400] & 0x3f;
58   b = poker72_pal[(offset & 0x3ff)+0x800] & 0x3f;
67   r = state->pal[(offset & 0x3ff)+0x000] & 0x3f;
68   g = state->pal[(offset & 0x3ff)+0x400] & 0x3f;
69   b = state->pal[(offset & 0x3ff)+0x800] & 0x3f;
5970
6071   palette_set_color_rgb( space->machine, offset & 0x3ff, pal6bit(r), pal6bit(g), pal6bit(b));
6172}
r10886r10887
7788
7889static WRITE8_HANDLER( tile_bank_w )
7990{
80   tile_bank = (data & 4) >> 2;
91   poker72_state *state = space->machine->driver_data<poker72_state>();
92   state->tile_bank = (data & 4) >> 2;
8193}
8294
8395static ADDRESS_MAP_START( poker72_map, ADDRESS_SPACE_PROGRAM, 8 )
8496   AM_RANGE(0x0000, 0xbfff) AM_ROMBANK("bank1")
8597   AM_RANGE(0xc000, 0xdfff) AM_RAM //work ram
86   AM_RANGE(0xe000, 0xefff) AM_RAM AM_BASE(&poker72_vram)
87   AM_RANGE(0xf000, 0xfbff) AM_RAM_WRITE(poker72_paletteram_w) AM_BASE(&poker72_pal)
98   AM_RANGE(0xe000, 0xefff) AM_RAM AM_BASE_MEMBER(poker72_state, vram)
99   AM_RANGE(0xf000, 0xfbff) AM_RAM_WRITE(poker72_paletteram_w) AM_BASE_MEMBER(poker72_state, pal)
88100   AM_RANGE(0xfc00, 0xfdff) AM_RAM //???
89101   AM_RANGE(0xfe08, 0xfe08) AM_READ_PORT("IN0")
90102   AM_RANGE(0xfe09, 0xfe09) AM_READ_PORT("IN1")
r10886r10887
329341   memory_set_bankptr(machine, "bank1", &ROM[0]);
330342}
331343
332static MACHINE_CONFIG_START( poker72, driver_device )
344static MACHINE_CONFIG_START( poker72, poker72_state )
333345
334346
335347   /* basic machine hardware */
src/mame/drivers/gamecstl.c
r10886r10887
7373#include "machine/pckeybrd.h"
7474#include "machine/idectrl.h"
7575
76static void ide_interrupt(device_t *device, int state);
7776
78static UINT32 *cga_ram;
79static UINT32 *bios_ram;
77class gamecstl_state : public driver_device
78{
79public:
80   gamecstl_state(running_machine &machine, const driver_device_config_base &config)
81      : driver_device(machine, config) { }
8082
81static struct {
83   UINT32 *cga_ram;
84   UINT32 *bios_ram;
85   UINT8 mxtc_config_reg[256];
86   UINT8 piix4_config_reg[4][256];
87   int dma_channel;
88   UINT8 dma_offset[2][4];
89   UINT8 at_pages[0x10];
90
8291   device_t   *pit8254;
8392   device_t   *pic8259_1;
8493   device_t   *pic8259_2;
8594   device_t   *dma8237_1;
8695   device_t   *dma8237_2;
87} gamecstl_devices;
96};
8897
8998
99static void ide_interrupt(device_t *device, int state);
100
101
90102static const rgb_t cga_palette[16] =
91103{
92104   MAKE_RGB( 0x00, 0x00, 0x00 ), MAKE_RGB( 0x00, 0x00, 0xaa ), MAKE_RGB( 0x00, 0xaa, 0x00 ), MAKE_RGB( 0x00, 0xaa, 0xaa ),
r10886r10887
126138
127139static SCREEN_UPDATE(gamecstl)
128140{
141   gamecstl_state *state = screen->machine->driver_data<gamecstl_state>();
129142   int i, j;
130143   const gfx_element *gfx = screen->machine->gfx[0];
131   UINT32 *cga = cga_ram;
144   UINT32 *cga = state->cga_ram;
132145   int index = 0;
133146
134147   bitmap_fill(bitmap, cliprect, 0);
r10886r10887
173186
174187
175188// Intel 82439TX System Controller (MXTC)
176static UINT8 mxtc_config_reg[256];
177189
178190static UINT8 mxtc_config_r(device_t *busdevice, device_t *device, int function, int reg)
179191{
192   gamecstl_state *state = busdevice->machine->driver_data<gamecstl_state>();
180193//  mame_printf_debug("MXTC: read %d, %02X\n", function, reg);
181194
182   return mxtc_config_reg[reg];
195   return state->mxtc_config_reg[reg];
183196}
184197
185198static void mxtc_config_w(device_t *busdevice, device_t *device, int function, int reg, UINT8 data)
186199{
200   gamecstl_state *state = busdevice->machine->driver_data<gamecstl_state>();
187201//  mame_printf_debug("%s:MXTC: write %d, %02X, %02X\n", busdevice->machine->describe_context(), function, reg, data);
188202
189203   switch(reg)
r10886r10887
192206      {
193207         if (data & 0x10)      // enable RAM access to region 0xf0000 - 0xfffff
194208         {
195            memory_set_bankptr(busdevice->machine, "bank1", bios_ram);
209            memory_set_bankptr(busdevice->machine, "bank1", state->bios_ram);
196210         }
197211         else               // disable RAM access (reads go to BIOS ROM)
198212         {
r10886r10887
202216      }
203217   }
204218
205   mxtc_config_reg[reg] = data;
219   state->mxtc_config_reg[reg] = data;
206220}
207221
208static void intel82439tx_init(void)
222static void intel82439tx_init(running_machine *machine)
209223{
210   mxtc_config_reg[0x60] = 0x02;
211   mxtc_config_reg[0x61] = 0x02;
212   mxtc_config_reg[0x62] = 0x02;
213   mxtc_config_reg[0x63] = 0x02;
214   mxtc_config_reg[0x64] = 0x02;
215   mxtc_config_reg[0x65] = 0x02;
224   gamecstl_state *state = machine->driver_data<gamecstl_state>();
225   state->mxtc_config_reg[0x60] = 0x02;
226   state->mxtc_config_reg[0x61] = 0x02;
227   state->mxtc_config_reg[0x62] = 0x02;
228   state->mxtc_config_reg[0x63] = 0x02;
229   state->mxtc_config_reg[0x64] = 0x02;
230   state->mxtc_config_reg[0x65] = 0x02;
216231}
217232
218233static UINT32 intel82439tx_pci_r(device_t *busdevice, device_t *device, int function, int reg, UINT32 mem_mask)
r10886r10887
258273}
259274
260275// Intel 82371AB PCI-to-ISA / IDE bridge (PIIX4)
261static UINT8 piix4_config_reg[4][256];
262276
263277static UINT8 piix4_config_r(device_t *busdevice, device_t *device, int function, int reg)
264278{
279   gamecstl_state *state = busdevice->machine->driver_data<gamecstl_state>();
265280//  mame_printf_debug("PIIX4: read %d, %02X\n", function, reg);
266   return piix4_config_reg[function][reg];
281   return state->piix4_config_reg[function][reg];
267282}
268283
269284static void piix4_config_w(device_t *busdevice, device_t *device, int function, int reg, UINT8 data)
270285{
286   gamecstl_state *state = busdevice->machine->driver_data<gamecstl_state>();
271287//  mame_printf_debug("%s:PIIX4: write %d, %02X, %02X\n", busdevice->machine->describe_context(), function, reg, data);
272   piix4_config_reg[function][reg] = data;
288   state->piix4_config_reg[function][reg] = data;
273289}
274290
275291static UINT32 intel82371ab_pci_r(device_t *busdevice, device_t *device, int function, int reg, UINT32 mem_mask)
r10886r10887
358374
359375static WRITE32_HANDLER(bios_ram_w)
360376{
361   if (mxtc_config_reg[0x59] & 0x20)      // write to RAM if this region is write-enabled
377   gamecstl_state *state = space->machine->driver_data<gamecstl_state>();
378   if (state->mxtc_config_reg[0x59] & 0x20)      // write to RAM if this region is write-enabled
362379   {
363      COMBINE_DATA(bios_ram + offset);
380      COMBINE_DATA(state->bios_ram + offset);
364381   }
365382}
366383
r10886r10887
371388 *
372389 *************************************************************************/
373390
374static int dma_channel;
375static UINT8 dma_offset[2][4];
376static UINT8 at_pages[0x10];
377391
378392
379393static READ8_HANDLER(at_page8_r)
380394{
381   UINT8 data = at_pages[offset % 0x10];
395   gamecstl_state *state = space->machine->driver_data<gamecstl_state>();
396   UINT8 data = state->at_pages[offset % 0x10];
382397
383398   switch(offset % 8)
384399   {
385400   case 1:
386      data = dma_offset[(offset / 8) & 1][2];
401      data = state->dma_offset[(offset / 8) & 1][2];
387402      break;
388403   case 2:
389      data = dma_offset[(offset / 8) & 1][3];
404      data = state->dma_offset[(offset / 8) & 1][3];
390405      break;
391406   case 3:
392      data = dma_offset[(offset / 8) & 1][1];
407      data = state->dma_offset[(offset / 8) & 1][1];
393408      break;
394409   case 7:
395      data = dma_offset[(offset / 8) & 1][0];
410      data = state->dma_offset[(offset / 8) & 1][0];
396411      break;
397412   }
398413   return data;
r10886r10887
401416
402417static WRITE8_HANDLER(at_page8_w)
403418{
404   at_pages[offset % 0x10] = data;
419   gamecstl_state *state = space->machine->driver_data<gamecstl_state>();
420   state->at_pages[offset % 0x10] = data;
405421
406422   switch(offset % 8)
407423   {
408424   case 1:
409      dma_offset[(offset / 8) & 1][2] = data;
425      state->dma_offset[(offset / 8) & 1][2] = data;
410426      break;
411427   case 2:
412      dma_offset[(offset / 8) & 1][3] = data;
428      state->dma_offset[(offset / 8) & 1][3] = data;
413429      break;
414430   case 3:
415      dma_offset[(offset / 8) & 1][1] = data;
431      state->dma_offset[(offset / 8) & 1][1] = data;
416432      break;
417433   case 7:
418      dma_offset[(offset / 8) & 1][0] = data;
434      state->dma_offset[(offset / 8) & 1][0] = data;
419435      break;
420436   }
421437}
r10886r10887
432448
433449static READ8_HANDLER( pc_dma_read_byte )
434450{
435   offs_t page_offset = (((offs_t) dma_offset[0][dma_channel]) << 16)
451   gamecstl_state *state = space->machine->driver_data<gamecstl_state>();
452   offs_t page_offset = (((offs_t) state->dma_offset[0][state->dma_channel]) << 16)
436453      & 0xFF0000;
437454
438455   return space->read_byte(page_offset + offset);
r10886r10887
441458
442459static WRITE8_HANDLER( pc_dma_write_byte )
443460{
444   offs_t page_offset = (((offs_t) dma_offset[0][dma_channel]) << 16)
461   gamecstl_state *state = space->machine->driver_data<gamecstl_state>();
462   offs_t page_offset = (((offs_t) state->dma_offset[0][state->dma_channel]) << 16)
445463      & 0xFF0000;
446464
447465   space->write_byte(page_offset + offset, data);
r10886r10887
449467
450468static void set_dma_channel(device_t *device, int channel, int state)
451469{
452   if (!state) dma_channel = channel;
470   gamecstl_state *drvstate = device->machine->driver_data<gamecstl_state>();
471   if (!state) drvstate->dma_channel = channel;
453472}
454473
455474static WRITE_LINE_DEVICE_HANDLER( pc_dack0_w ) { set_dma_channel(device, 0, state); }
r10886r10887
496515static ADDRESS_MAP_START( gamecstl_map, ADDRESS_SPACE_PROGRAM, 32 )
497516   AM_RANGE(0x00000000, 0x0009ffff) AM_RAM
498517   AM_RANGE(0x000a0000, 0x000affff) AM_RAM
499   AM_RANGE(0x000b0000, 0x000b7fff) AM_RAM AM_BASE(&cga_ram)
518   AM_RANGE(0x000b0000, 0x000b7fff) AM_RAM AM_BASE_MEMBER(gamecstl_state, cga_ram)
500519   AM_RANGE(0x000e0000, 0x000effff) AM_RAM
501520   AM_RANGE(0x000f0000, 0x000fffff) AM_ROMBANK("bank1")
502521   AM_RANGE(0x000f0000, 0x000fffff) AM_WRITE(bios_ram_w)
r10886r10887
583602
584603static IRQ_CALLBACK(irq_callback)
585604{
605   gamecstl_state *state = device->machine->driver_data<gamecstl_state>();
586606   int r = 0;
587   r = pic8259_acknowledge(gamecstl_devices.pic8259_2);
607   r = pic8259_acknowledge(state->pic8259_2);
588608   if (r==0)
589609   {
590      r = pic8259_acknowledge(gamecstl_devices.pic8259_1);
610      r = pic8259_acknowledge(state->pic8259_1);
591611   }
592612   return r;
593613}
594614
595615static MACHINE_START(gamecstl)
596616{
597   gamecstl_devices.pit8254 = machine->device( "pit8254" );
598   gamecstl_devices.pic8259_1 = machine->device( "pic8259_1" );
599   gamecstl_devices.pic8259_2 = machine->device( "pic8259_2" );
600   gamecstl_devices.dma8237_1 = machine->device( "dma8237_1" );
601   gamecstl_devices.dma8237_2 = machine->device( "dma8237_2" );
617   gamecstl_state *state = machine->driver_data<gamecstl_state>();
618   state->pit8254 = machine->device( "pit8254" );
619   state->pic8259_1 = machine->device( "pic8259_1" );
620   state->pic8259_2 = machine->device( "pic8259_2" );
621   state->dma8237_1 = machine->device( "dma8237_1" );
622   state->dma8237_2 = machine->device( "dma8237_2" );
602623}
603624
604625static MACHINE_RESET(gamecstl)
r10886r10887
656677   }
657678};
658679
659static MACHINE_CONFIG_START( gamecstl, driver_device )
680static MACHINE_CONFIG_START( gamecstl, gamecstl_state )
660681
661682   /* basic machine hardware */
662683   MCFG_CPU_ADD("maincpu", PENTIUM, 200000000)
r10886r10887
707728
708729static void keyboard_interrupt(running_machine *machine, int state)
709730{
710   pic8259_ir1_w(gamecstl_devices.pic8259_1, state);
731   gamecstl_state *drvstate = machine->driver_data<gamecstl_state>();
732   pic8259_ir1_w(drvstate->pic8259_1, state);
711733}
712734
713735static void ide_interrupt(device_t *device, int state)
714736{
715   pic8259_ir6_w(gamecstl_devices.pic8259_2, state);
737   gamecstl_state *drvstate = device->machine->driver_data<gamecstl_state>();
738   pic8259_ir6_w(drvstate->pic8259_2, state);
716739}
717740
718741static int gamecstl_get_out2(running_machine *machine)
719742{
720   return pit8253_get_output( gamecstl_devices.pit8254, 2 );
743   gamecstl_state *state = machine->driver_data<gamecstl_state>();
744   return pit8253_get_output( state->pit8254, 2 );
721745}
722746
723747static const struct kbdc8042_interface at8042 =
r10886r10887
727751
728752static void gamecstl_set_keyb_int(running_machine *machine, int state)
729753{
730   pic8259_ir1_w(gamecstl_devices.pic8259_1, state);
754   gamecstl_state *drvstate = machine->driver_data<gamecstl_state>();
755   pic8259_ir1_w(drvstate->pic8259_1, state);
731756}
732757
733758static DRIVER_INIT( gamecstl )
734759{
735   bios_ram = auto_alloc_array(machine, UINT32, 0x10000/4);
760   gamecstl_state *state = machine->driver_data<gamecstl_state>();
761   state->bios_ram = auto_alloc_array(machine, UINT32, 0x10000/4);
736762
737763   init_pc_common(machine, PCCOMMON_KEYBOARD_AT, gamecstl_set_keyb_int);
738764
739   intel82439tx_init();
765   intel82439tx_init(machine);
740766
741767   kbdc8042_init(machine, &at8042);
742768}
src/mame/drivers/wldarrow.c
r10886r10887
2525#include "machine/nvram.h"
2626
2727
28#define NUM_PENS   (8)
28class wldarrow_state : public driver_device
29{
30public:
31   wldarrow_state(running_machine &machine, const driver_device_config_base &config)
32      : driver_device(machine, config) { }
2933
34   UINT8 *videoram_0;
35   UINT8 *videoram_1;
36   UINT8 *videoram_2;
37   size_t videoram_size;
38};
3039
31static UINT8 *wldarrow_videoram_0;
32static UINT8 *wldarrow_videoram_1;
33static UINT8 *wldarrow_videoram_2;
34static size_t wldarrow_videoram_size;
3540
41#define NUM_PENS   (8)
3642
3743
3844/*************************************
r10886r10887
5460
5561static SCREEN_UPDATE( wldarrow )
5662{
63   wldarrow_state *state = screen->machine->driver_data<wldarrow_state>();
5764   pen_t pens[NUM_PENS];
5865   offs_t offs;
5966
6067   get_pens(pens);
6168
62   for (offs = 0; offs < wldarrow_videoram_size; offs++)
69   for (offs = 0; offs < state->videoram_size; offs++)
6370   {
6471      int i;
6572
6673      UINT8 y = offs >> 5;
6774      UINT8 x = offs << 3;
6875
69      UINT8 data0 = wldarrow_videoram_0[offs];
70      UINT8 data1 = wldarrow_videoram_1[offs];
71      UINT8 data2 = wldarrow_videoram_2[offs];
76      UINT8 data0 = state->videoram_0[offs];
77      UINT8 data1 = state->videoram_1[offs];
78      UINT8 data2 = state->videoram_2[offs];
7279
7380      /* weird equations, but it matches every flyer screenshot -
7481           perhaphs they used a look-up PROM? */
r10886r10887
167174static ADDRESS_MAP_START( wldarrow_map, ADDRESS_SPACE_PROGRAM, 8 )
168175   AM_RANGE(0x0000, 0x37ff) AM_ROM
169176   AM_RANGE(0x3800, 0x3800) AM_READ_PORT("IN0")
170   AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE(&wldarrow_videoram_0) AM_SIZE(&wldarrow_videoram_size)
171   AM_RANGE(0x6000, 0x7fff) AM_RAM AM_BASE(&wldarrow_videoram_1)
172   AM_RANGE(0x8000, 0x9fff) AM_RAM AM_BASE(&wldarrow_videoram_2)
177   AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE_MEMBER(wldarrow_state, videoram_0) AM_SIZE_MEMBER(wldarrow_state, videoram_size)
178   AM_RANGE(0x6000, 0x7fff) AM_RAM AM_BASE_MEMBER(wldarrow_state, videoram_1)
179   AM_RANGE(0x8000, 0x9fff) AM_RAM AM_BASE_MEMBER(wldarrow_state, videoram_2)
173180   AM_RANGE(0xcd00, 0xcdff) AM_RAM AM_SHARE("nvram")
174181   AM_RANGE(0xf000, 0xf000) AM_READ_PORT("BITSW") AM_DEVWRITE("dac", wldarrow_dac_1_w)
175182   AM_RANGE(0xf004, 0xf004) AM_READ_PORT("IN1") AM_WRITE(lights_1_w)
r10886r10887
345352 *
346353 *************************************/
347354
348static MACHINE_CONFIG_START( wldarrow, driver_device )
355static MACHINE_CONFIG_START( wldarrow, wldarrow_state )
349356
350357   /* basic machine hardware */
351358   MCFG_CPU_ADD("maincpu", I8080, 2000000)
src/mame/drivers/taito_f3.c
r10886r10887
4242#include "audio/taito_en.h"
4343#include "sound/okim6295.h"
4444
45static UINT32 coin_word[2], *f3_ram;
46int f3_game;
4745
48
4946/******************************************************************************/
5047
5148static CUSTOM_INPUT( f3_analog_r )
r10886r10887
6057
6158static CUSTOM_INPUT( f3_coin_r )
6259{
60   taito_f3_state *state = field->port->machine->driver_data<taito_f3_state>();
6361   int num = (FPTR)param;
64   return coin_word[num];
62   return state->coin_word[num];
6563}
6664
6765static READ32_HANDLER( f3_control_r )
r10886r10887
7775
7876static WRITE32_HANDLER( f3_control_w )
7977{
78   taito_f3_state *state = space->machine->driver_data<taito_f3_state>();
8079   switch (offset)
8180   {
8281      case 0x00: /* Watchdog */
r10886r10887
9089            coin_lockout_w(space->machine, 1,~data & 0x02000000);
9190            coin_counter_w(space->machine, 0, data & 0x04000000);
9291            coin_counter_w(space->machine, 1, data & 0x08000000);
93            coin_word[0]=(data>>16)&0xffff;
92            state->coin_word[0]=(data>>16)&0xffff;
9493         }
9594         return;
9695
r10886r10887
108107            coin_lockout_w(space->machine, 3,~data & 0x02000000);
109108            coin_counter_w(space->machine, 2, data & 0x04000000);
110109            coin_counter_w(space->machine, 3, data & 0x08000000);
111            coin_word[1]=(data>>16)&0xffff;
110            state->coin_word[1]=(data>>16)&0xffff;
112111         }
113112         return;
114113   }
r10886r10887
127126
128127static WRITE32_HANDLER( f3_sound_bankswitch_w )
129128{
130   if (f3_game==KIRAMEKI) {
129   taito_f3_state *state = space->machine->driver_data<taito_f3_state>();
130   if (state->f3_game==KIRAMEKI) {
131131      UINT16 *rom = (UINT16 *)space->machine->region("audiocpu")->base();
132132      UINT32 idx;
133133
r10886r10887
152152static ADDRESS_MAP_START( f3_map, ADDRESS_SPACE_PROGRAM, 32 )
153153   AM_RANGE(0x000000, 0x1fffff) AM_ROM
154154   AM_RANGE(0x300000, 0x30007f) AM_WRITE(f3_sound_bankswitch_w)
155   AM_RANGE(0x400000, 0x41ffff) AM_MIRROR(0x20000) AM_RAM AM_BASE(&f3_ram)
155   AM_RANGE(0x400000, 0x41ffff) AM_MIRROR(0x20000) AM_RAM AM_BASE_MEMBER(taito_f3_state, f3_ram)
156156   AM_RANGE(0x440000, 0x447fff) AM_RAM_WRITE(f3_palette_24bit_w) AM_BASE_GENERIC(paletteram)
157157   AM_RANGE(0x4a0000, 0x4a001f) AM_READWRITE(f3_control_r,  f3_control_w)
158158   AM_RANGE(0x600000, 0x60ffff) AM_RAM AM_BASE_SIZE_MEMBER(taito_f3_state, spriteram, spriteram_size)
159   AM_RANGE(0x610000, 0x61bfff) AM_RAM_WRITE(f3_pf_data_w) AM_BASE(&f3_pf_data)
159   AM_RANGE(0x610000, 0x61bfff) AM_RAM_WRITE(f3_pf_data_w) AM_BASE_MEMBER(taito_f3_state, f3_pf_data)
160160   AM_RANGE(0x61c000, 0x61dfff) AM_RAM_WRITE(f3_videoram_w) AM_BASE_MEMBER(taito_f3_state, videoram)
161   AM_RANGE(0x61e000, 0x61ffff) AM_RAM_WRITE(f3_vram_w) AM_BASE(&f3_vram)
162   AM_RANGE(0x620000, 0x62ffff) AM_RAM_WRITE(f3_lineram_w) AM_BASE(&f3_line_ram)
163   AM_RANGE(0x630000, 0x63ffff) AM_RAM_WRITE(f3_pivot_w) AM_BASE(&f3_pivot_ram)
161   AM_RANGE(0x61e000, 0x61ffff) AM_RAM_WRITE(f3_vram_w) AM_BASE_MEMBER(taito_f3_state, f3_vram)
162   AM_RANGE(0x620000, 0x62ffff) AM_RAM_WRITE(f3_lineram_w) AM_BASE_MEMBER(taito_f3_state, f3_line_ram)
163   AM_RANGE(0x630000, 0x63ffff) AM_RAM_WRITE(f3_pivot_w) AM_BASE_MEMBER(taito_f3_state, f3_pivot_ram)
164164   AM_RANGE(0x660000, 0x66000f) AM_WRITE(f3_control_0_w)
165165   AM_RANGE(0x660010, 0x66001f) AM_WRITE(f3_control_1_w)
166166   AM_RANGE(0xc00000, 0xc007ff) AM_RAM AM_SHARE("f3_shared")
r10886r10887
385385
386386static MACHINE_START(f3)
387387{
388   state_save_register_global_array(machine, coin_word);
388   taito_f3_state *state = machine->driver_data<taito_f3_state>();
389   state_save_register_global_array(machine, state->coin_word);
389390}
390391
391392static MACHINE_CONFIG_START( f3, taito_f3_state )
r10886r10887
35553556
35563557static DRIVER_INIT( ringrage )
35573558{
3558   f3_game=RINGRAGE;
3559   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3560   state->f3_game=RINGRAGE;
35593561   tile_decode(machine);
35603562}
35613563
35623564static DRIVER_INIT( arabianm )
35633565{
3564   f3_game=ARABIANM;
3566   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3567   state->f3_game=ARABIANM;
35653568   tile_decode(machine);
35663569}
35673570
35683571static DRIVER_INIT( ridingf )
35693572{
3570   f3_game=RIDINGF;
3573   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3574   state->f3_game=RIDINGF;
35713575   tile_decode(machine);
35723576}
35733577
35743578static DRIVER_INIT( gseeker )
35753579{
3576   f3_game=GSEEKER;
3580   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3581   state->f3_game=GSEEKER;
35773582   tile_decode(machine);
35783583}
35793584
35803585static DRIVER_INIT( gunlock )
35813586{
3582   f3_game=GUNLOCK;
3587   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3588   state->f3_game=GUNLOCK;
35833589   tile_decode(machine);
35843590}
35853591
35863592static DRIVER_INIT( elvactr )
35873593{
3588   f3_game=EACTION2;
3594   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3595   state->f3_game=EACTION2;
35893596   tile_decode(machine);
35903597}
35913598
35923599static DRIVER_INIT( cupfinal )
35933600{
3594   f3_game=SCFINALS;
3601   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3602   state->f3_game=SCFINALS;
35953603   tile_decode(machine);
35963604}
35973605
35983606static DRIVER_INIT( trstaroj )
35993607{
3600   f3_game=TRSTAR;
3608   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3609   state->f3_game=TRSTAR;
36013610   tile_decode(machine);
36023611}
36033612
36043613static DRIVER_INIT( scfinals )
36053614{
3615   taito_f3_state *state = machine->driver_data<taito_f3_state>();
36063616   UINT32 *RAM = (UINT32 *)machine->region("maincpu")->base();
36073617
36083618   /* Doesn't boot without this - eprom related? */
r10886r10887
36113621   /* Rom checksum error */
36123622   RAM[0xdd0/4]=0x4e750000;
36133623
3614   f3_game=SCFINALS;
3624   state->f3_game=SCFINALS;
36153625   tile_decode(machine);
36163626}
36173627
36183628static DRIVER_INIT( lightbr )
36193629{
3620   f3_game=LIGHTBR;
3630   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3631   state->f3_game=LIGHTBR;
36213632   tile_decode(machine);
36223633}
36233634
36243635static DRIVER_INIT( kaiserkn )
36253636{
3626   f3_game=KAISERKN;
3637   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3638   state->f3_game=KAISERKN;
36273639   tile_decode(machine);
36283640}
36293641
36303642static DRIVER_INIT( dariusg )
36313643{
3632   f3_game=DARIUSG;
3644   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3645   state->f3_game=DARIUSG;
36333646   tile_decode(machine);
36343647}
36353648
36363649static DRIVER_INIT( spcinvdj )
36373650{
3638   f3_game=SPCINVDX;
3651   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3652   state->f3_game=SPCINVDX;
36393653   tile_decode(machine);
36403654}
36413655
36423656static DRIVER_INIT( qtheater )
36433657{
3644   f3_game=QTHEATER;
3658   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3659   state->f3_game=QTHEATER;
36453660   tile_decode(machine);
36463661}
36473662
36483663static DRIVER_INIT( spcinv95 )
36493664{
3650   f3_game=SPCINV95;
3665   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3666   state->f3_game=SPCINV95;
36513667   tile_decode(machine);
36523668}
36533669
36543670static DRIVER_INIT( gekirido )
36553671{
3656   f3_game=GEKIRIDO;
3672   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3673   state->f3_game=GEKIRIDO;
36573674   tile_decode(machine);
36583675}
36593676
36603677static DRIVER_INIT( ktiger2 )
36613678{
3662   f3_game=KTIGER2;
3679   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3680   state->f3_game=KTIGER2;
36633681   tile_decode(machine);
36643682}
36653683
36663684static DRIVER_INIT( bubsymph )
36673685{
3668   f3_game=BUBSYMPH;
3686   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3687   state->f3_game=BUBSYMPH;
36693688   tile_decode(machine);
36703689}
36713690
r10886r10887
36953714
36963715static DRIVER_INIT( bubsympb )
36973716{
3698   f3_game=BUBSYMPH;
3717   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3718   state->f3_game=BUBSYMPH;
36993719   //tile_decode(machine);
37003720
37013721   /* expand gfx rom */
r10886r10887
37243744
37253745static DRIVER_INIT( bubblem )
37263746{
3727   f3_game=BUBBLEM;
3747   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3748   state->f3_game=BUBBLEM;
37283749   tile_decode(machine);
37293750}
37303751
37313752static DRIVER_INIT( cleopatr )
37323753{
3733   f3_game=CLEOPATR;
3754   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3755   state->f3_game=CLEOPATR;
37343756   tile_decode(machine);
37353757}
37363758
37373759static DRIVER_INIT( popnpop )
37383760{
3739   f3_game=POPNPOP;
3761   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3762   state->f3_game=POPNPOP;
37403763   tile_decode(machine);
37413764}
37423765
37433766static DRIVER_INIT( landmakr )
37443767{
3745   f3_game=LANDMAKR;
3768   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3769   state->f3_game=LANDMAKR;
37463770   tile_decode(machine);
37473771}
37483772
37493773static DRIVER_INIT( landmkrp )
37503774{
3775   taito_f3_state *state = machine->driver_data<taito_f3_state>();
37513776   UINT32 *RAM = (UINT32 *)machine->region("maincpu")->base();
37523777
37533778   /* For some reason the least significant byte in the last 2 long words of
r10886r10887
37573782   RAM[0x1ffff8/4]=0xffffffff; /* From 0xffffff03 */
37583783   RAM[0x1ffffc/4]=0xffff0003; /* From 0xffff00ff */
37593784
3760   f3_game=LANDMAKR;
3785   state->f3_game=LANDMAKR;
37613786   tile_decode(machine);
37623787}
37633788
37643789static DRIVER_INIT( pbobble3 )
37653790{
3766   f3_game=PBOBBLE3;
3791   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3792   state->f3_game=PBOBBLE3;
37673793   tile_decode(machine);
37683794}
37693795
37703796static DRIVER_INIT( pbobble4 )
37713797{
3772   f3_game=PBOBBLE4;
3798   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3799   state->f3_game=PBOBBLE4;
37733800   tile_decode(machine);
37743801}
37753802
37763803static DRIVER_INIT( quizhuhu )
37773804{
3778   f3_game=QUIZHUHU;
3805   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3806   state->f3_game=QUIZHUHU;
37793807   tile_decode(machine);
37803808}
37813809
37823810static DRIVER_INIT( pbobble2 )
37833811{
3784   f3_game=PBOBBLE2;
3812   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3813   state->f3_game=PBOBBLE2;
37853814   tile_decode(machine);
37863815}
37873816
37883817static DRIVER_INIT( pbobbl2p )
37893818{
3819   taito_f3_state *state = machine->driver_data<taito_f3_state>();
37903820   // has 040092: beq     $30000; (2+)
37913821   // which eventually causes the game to crash
37923822   //  -- protection check?? or some kind of checksum fail?
r10886r10887
37973827    ROM[0x40090/4]=0x00004e71|(ROM[0x40090/4]&0xffff0000);
37983828    ROM[0x40094/4]=0x4e714e71;
37993829
3800   f3_game=PBOBBLE2;
3830   state->f3_game=PBOBBLE2;
38013831   tile_decode(machine);
38023832}
38033833
r10886r10887
38053835
38063836static DRIVER_INIT( pbobbl2x )
38073837{
3808   f3_game=PBOBBLE2;
3838   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3839   state->f3_game=PBOBBLE2;
38093840   tile_decode(machine);
38103841}
38113842
38123843static DRIVER_INIT( hthero95 )
38133844{
3814   f3_game=HTHERO95;
3845   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3846   state->f3_game=HTHERO95;
38153847   tile_decode(machine);
38163848}
38173849
38183850static DRIVER_INIT( kirameki )
38193851{
3820   f3_game=KIRAMEKI;
3852   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3853   state->f3_game=KIRAMEKI;
38213854   tile_decode(machine);
38223855}
38233856
38243857static DRIVER_INIT( puchicar )
38253858{
3826   f3_game=PUCHICAR;
3859   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3860   state->f3_game=PUCHICAR;
38273861   tile_decode(machine);
38283862}
38293863
38303864static DRIVER_INIT( twinqix )
38313865{
3832   f3_game=TWINQIX;
3866   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3867   state->f3_game=TWINQIX;
38333868   tile_decode(machine);
38343869}
38353870
38363871static DRIVER_INIT( arkretrn )
38373872{
3838   f3_game=ARKRETRN;
3873   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3874   state->f3_game=ARKRETRN;
38393875   tile_decode(machine);
38403876}
38413877
38423878static DRIVER_INIT( intcup94 )
38433879{
3844   f3_game=SCFINALS;
3880   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3881   state->f3_game=SCFINALS;
38453882   tile_decode(machine);
38463883}
38473884
38483885static DRIVER_INIT( recalh )
38493886{
3850   f3_game=RECALH;
3887   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3888   state->f3_game=RECALH;
38513889   tile_decode(machine);
38523890}
38533891
38543892static DRIVER_INIT( commandw )
38553893{
3856   f3_game=COMMANDW;
3894   taito_f3_state *state = machine->driver_data<taito_f3_state>();
3895   state->f3_game=COMMANDW;
38573896   tile_decode(machine);
38583897}
38593898
src/mame/drivers/megasys1.c
r10886r10887
130130#include "includes/megasys1.h"
131131
132132
133/* Variables only used here: */
134
135static UINT16 ip_select, ip_select_values[5];
136static UINT8 megasys1_ignore_oki_status = 0;   /* used in MACHINE_RESET */
137
138
139133static MACHINE_RESET( megasys1 )
140134{
141   megasys1_ignore_oki_status = 1;   /* ignore oki status due 'protection' */
142   ip_select = 0;   /* reset protection */
135   megasys1_state *state = machine->driver_data<megasys1_state>();
136   state->ignore_oki_status = 1;   /* ignore oki status due 'protection' */
137   state->ip_select = 0;   /* reset protection */
143138}
144139
145140static MACHINE_RESET( megasys1_hachoo )
146141{
147   megasys1_ignore_oki_status = 0;   /* strangely hachoo need real oki status */
148   ip_select = 0;   /* reset protection */
142   megasys1_state *state = machine->driver_data<megasys1_state>();
143   state->ignore_oki_status = 0;   /* strangely hachoo need real oki status */
144   state->ip_select = 0;   /* reset protection */
149145}
150146
151147
r10886r10887
180176   AM_RANGE(0x080004, 0x080005) AM_READ_PORT("P2")
181177   AM_RANGE(0x080006, 0x080007) AM_READ_PORT("DSW")
182178   AM_RANGE(0x080008, 0x080009) AM_READ(soundlatch2_word_r)   /* from sound cpu */
183   AM_RANGE(0x084000, 0x0843ff) AM_RAM_WRITE(megasys1_vregs_A_w) AM_BASE(&megasys1_vregs)
179   AM_RANGE(0x084000, 0x0843ff) AM_RAM_WRITE(megasys1_vregs_A_w) AM_BASE_MEMBER(megasys1_state, vregs)
184180   AM_RANGE(0x088000, 0x0887ff) AM_RAM_WRITE(paletteram16_RRRRGGGGBBBBRGBx_word_w) AM_BASE_GENERIC(paletteram)
185   AM_RANGE(0x08e000, 0x08ffff) AM_RAM AM_BASE(&megasys1_objectram)
186   AM_RANGE(0x090000, 0x093fff) AM_RAM_WRITE(megasys1_scrollram_0_w) AM_BASE(&megasys1_scrollram[0])
187   AM_RANGE(0x094000, 0x097fff) AM_RAM_WRITE(megasys1_scrollram_1_w) AM_BASE(&megasys1_scrollram[1])
188   AM_RANGE(0x098000, 0x09bfff) AM_RAM_WRITE(megasys1_scrollram_2_w) AM_BASE(&megasys1_scrollram[2])
189   AM_RANGE(0x0f0000, 0x0fffff) AM_RAM AM_BASE(&megasys1_ram)
181   AM_RANGE(0x08e000, 0x08ffff) AM_RAM AM_BASE_MEMBER(megasys1_state, objectram)
182   AM_RANGE(0x090000, 0x093fff) AM_RAM_WRITE(megasys1_scrollram_0_w) AM_BASE_MEMBER(megasys1_state, scrollram[0])
183   AM_RANGE(0x094000, 0x097fff) AM_RAM_WRITE(megasys1_scrollram_1_w) AM_BASE_MEMBER(megasys1_state, scrollram[1])
184   AM_RANGE(0x098000, 0x09bfff) AM_RAM_WRITE(megasys1_scrollram_2_w) AM_BASE_MEMBER(megasys1_state, scrollram[2])
185   AM_RANGE(0x0f0000, 0x0fffff) AM_RAM AM_BASE_MEMBER(megasys1_state, ram)
190186ADDRESS_MAP_END
191187
192188
r10886r10887
218214
219215static READ16_HANDLER( ip_select_r )
220216{
217   megasys1_state *state = space->machine->driver_data<megasys1_state>();
221218   int i;
222219
223220//  Coins   P1      P2      DSW1    DSW2
r10886r10887
230227
231228
232229   /* f(x) = ((x*x)>>4)&0xFF ; f(f($D)) == 6 */
233   if ((ip_select & 0xF0) == 0xF0) return 0x000D;
230   if ((state->ip_select & 0xF0) == 0xF0) return 0x000D;
234231
235   for (i = 0; i < 5; i++)   if (ip_select == ip_select_values[i]) break;
232   for (i = 0; i < 5; i++)   if (state->ip_select == state->ip_select_values[i]) break;
236233
237234   switch (i)
238235   {
r10886r10887
247244
248245static WRITE16_HANDLER( ip_select_w )
249246{
250   COMBINE_DATA(&ip_select);
247   megasys1_state *state = space->machine->driver_data<megasys1_state>();
248   COMBINE_DATA(&state->ip_select);
251249   cputag_set_input_line(space->machine, "maincpu", 2, HOLD_LINE);
252250}
253251
r10886r10887
255253static ADDRESS_MAP_START( megasys1B_map, ADDRESS_SPACE_PROGRAM, 16 )
256254   ADDRESS_MAP_GLOBAL_MASK(0xfffff)
257255   AM_RANGE(0x000000, 0x03ffff) AM_ROM
258   AM_RANGE(0x044000, 0x0443ff) AM_RAM_WRITE(megasys1_vregs_A_w) AM_BASE(&megasys1_vregs)
256   AM_RANGE(0x044000, 0x0443ff) AM_RAM_WRITE(megasys1_vregs_A_w) AM_BASE_MEMBER(megasys1_state, vregs)
259257   AM_RANGE(0x048000, 0x0487ff) AM_RAM_WRITE(paletteram16_RRRRGGGGBBBBRGBx_word_w) AM_BASE_GENERIC(paletteram)
260   AM_RANGE(0x04e000, 0x04ffff) AM_RAM AM_BASE(&megasys1_objectram)
261   AM_RANGE(0x050000, 0x053fff) AM_RAM_WRITE(megasys1_scrollram_0_w) AM_BASE(&megasys1_scrollram[0])
262   AM_RANGE(0x054000, 0x057fff) AM_RAM_WRITE(megasys1_scrollram_1_w) AM_BASE(&megasys1_scrollram[1])
263   AM_RANGE(0x058000, 0x05bfff) AM_RAM_WRITE(megasys1_scrollram_2_w) AM_BASE(&megasys1_scrollram[2])
264   AM_RANGE(0x060000, 0x07ffff) AM_RAM AM_BASE(&megasys1_ram)
258   AM_RANGE(0x04e000, 0x04ffff) AM_RAM AM_BASE_MEMBER(megasys1_state, objectram)
259   AM_RANGE(0x050000, 0x053fff) AM_RAM_WRITE(megasys1_scrollram_0_w) AM_BASE_MEMBER(megasys1_state, scrollram[0])
260   AM_RANGE(0x054000, 0x057fff) AM_RAM_WRITE(megasys1_scrollram_1_w) AM_BASE_MEMBER(megasys1_state, scrollram[1])
261   AM_RANGE(0x058000, 0x05bfff) AM_RAM_WRITE(megasys1_scrollram_2_w) AM_BASE_MEMBER(megasys1_state, scrollram[2])
262   AM_RANGE(0x060000, 0x07ffff) AM_RAM AM_BASE_MEMBER(megasys1_state, ram)
265263   AM_RANGE(0x080000, 0x0bffff) AM_ROM
266264   AM_RANGE(0x0e0000, 0x0e0001) AM_READWRITE(ip_select_r,ip_select_w)
267265ADDRESS_MAP_END
r10886r10887
278276static ADDRESS_MAP_START( megasys1C_map, ADDRESS_SPACE_PROGRAM, 16 )
279277   ADDRESS_MAP_GLOBAL_MASK(0x1fffff)
280278   AM_RANGE(0x000000, 0x07ffff) AM_ROM
281   AM_RANGE(0x0c0000, 0x0cffff) AM_READWRITE(megasys1_vregs_C_r,megasys1_vregs_C_w) AM_BASE(&megasys1_vregs)
282   AM_RANGE(0x0d2000, 0x0d3fff) AM_RAM AM_BASE(&megasys1_objectram)
283   AM_RANGE(0x0e0000, 0x0e3fff) AM_RAM_WRITE(megasys1_scrollram_0_w) AM_BASE(&megasys1_scrollram[0])
284   AM_RANGE(0x0e8000, 0x0ebfff) AM_RAM_WRITE(megasys1_scrollram_1_w) AM_BASE(&megasys1_scrollram[1])
285   AM_RANGE(0x0f0000, 0x0f3fff) AM_RAM_WRITE(megasys1_scrollram_2_w) AM_BASE(&megasys1_scrollram[2])
279   AM_RANGE(0x0c0000, 0x0cffff) AM_READWRITE(megasys1_vregs_C_r,megasys1_vregs_C_w) AM_BASE_MEMBER(megasys1_state, vregs)
280   AM_RANGE(0x0d2000, 0x0d3fff) AM_RAM AM_BASE_MEMBER(megasys1_state, objectram)
281   AM_RANGE(0x0e0000, 0x0e3fff) AM_RAM_WRITE(megasys1_scrollram_0_w) AM_BASE_MEMBER(megasys1_state, scrollram[0])
282   AM_RANGE(0x0e8000, 0x0ebfff) AM_RAM_WRITE(megasys1_scrollram_1_w) AM_BASE_MEMBER(megasys1_state, scrollram[1])
283   AM_RANGE(0x0f0000, 0x0f3fff) AM_RAM_WRITE(megasys1_scrollram_2_w) AM_BASE_MEMBER(megasys1_state, scrollram[2])
286284   AM_RANGE(0x0f8000, 0x0f87ff) AM_RAM_WRITE(paletteram16_RRRRGGGGBBBBRGBx_word_w) AM_BASE_GENERIC(paletteram)
287285   AM_RANGE(0x0d8000, 0x0d8001) AM_READWRITE(ip_select_r,ip_select_w)
288   AM_RANGE(0x1f0000, 0x1fffff) AM_RAM AM_BASE(&megasys1_ram)
286   AM_RANGE(0x1f0000, 0x1fffff) AM_RAM AM_BASE_MEMBER(megasys1_state, ram)
289287ADDRESS_MAP_END
290288
291289
r10886r10887
300298
301299static ADDRESS_MAP_START( megasys1D_map, ADDRESS_SPACE_PROGRAM, 16 )
302300   AM_RANGE(0x000000, 0x03ffff) AM_ROM
303   AM_RANGE(0x0c0000, 0x0c9fff) AM_RAM_WRITE(megasys1_vregs_D_w) AM_BASE(&megasys1_vregs)
304   AM_RANGE(0x0ca000, 0x0cbfff) AM_RAM AM_BASE(&megasys1_objectram)
305   AM_RANGE(0x0d0000, 0x0d3fff) AM_RAM_WRITE(megasys1_scrollram_1_w) AM_BASE(&megasys1_scrollram[1])
306   AM_RANGE(0x0d4000, 0x0d7fff) AM_RAM_WRITE(megasys1_scrollram_2_w) AM_BASE(&megasys1_scrollram[2])
301   AM_RANGE(0x0c0000, 0x0c9fff) AM_RAM_WRITE(megasys1_vregs_D_w) AM_BASE_MEMBER(megasys1_state, vregs)
302   AM_RANGE(0x0ca000, 0x0cbfff) AM_RAM AM_BASE_MEMBER(megasys1_state, objectram)
303   AM_RANGE(0x0d0000, 0x0d3fff) AM_RAM_WRITE(megasys1_scrollram_1_w) AM_BASE_MEMBER(megasys1_state, scrollram[1])
304   AM_RANGE(0x0d4000, 0x0d7fff) AM_RAM_WRITE(megasys1_scrollram_2_w) AM_BASE_MEMBER(megasys1_state, scrollram[2])
307305   AM_RANGE(0x0d8000, 0x0d87ff) AM_MIRROR(0x3000) AM_RAM_WRITE(paletteram16_RRRRRGGGGGBBBBBx_word_w) AM_BASE_GENERIC(paletteram)
308306   AM_RANGE(0x0e0000, 0x0e0001) AM_READ_PORT("DSW")
309   AM_RANGE(0x0e8000, 0x0ebfff) AM_RAM_WRITE(megasys1_scrollram_0_w) AM_BASE(&megasys1_scrollram[0])
307   AM_RANGE(0x0e8000, 0x0ebfff) AM_RAM_WRITE(megasys1_scrollram_0_w) AM_BASE_MEMBER(megasys1_state, scrollram[0])
310308   AM_RANGE(0x0f0000, 0x0f0001) AM_READ_PORT("SYSTEM")
311309   AM_RANGE(0x0f8000, 0x0f8001) AM_DEVREADWRITE8_MODERN("oki1", okim6295_device, read, write, 0x00ff)
312310//  AM_RANGE(0x100000, 0x100001) // protection
313   AM_RANGE(0x1f0000, 0x1fffff) AM_RAM AM_BASE(&megasys1_ram)
311   AM_RANGE(0x1f0000, 0x1fffff) AM_RAM AM_BASE_MEMBER(megasys1_state, ram)
314312ADDRESS_MAP_END
315313
316314
r10886r10887
380378
381379static READ8_DEVICE_HANDLER( oki_status_r )
382380{
383   if (megasys1_ignore_oki_status == 1)
381   megasys1_state *state = device->machine->driver_data<megasys1_state>();
382   if (state->ignore_oki_status == 1)
384383      return 0;
385384   else
386385      return downcast<okim6295_device *>(device)->read_status();
r10886r10887
13581357 *
13591358 *************************************/
13601359
1361static UINT16 protection_val;
13621360
13631361/* Read the input ports, through a protection device */
13641362static READ16_HANDLER( protection_peekaboo_r )
13651363{
1366   switch (protection_val)
1364   megasys1_state *state = space->machine->driver_data<megasys1_state>();
1365   switch (state->protection_val)
13671366   {
13681367      case 0x02:   return 0x03;
13691368      case 0x51:   return input_port_read(space->machine, "P1");
13701369      case 0x52:   return input_port_read(space->machine, "P2");
1371      default:   return protection_val;
1370      default:   return state->protection_val;
13721371   }
13731372}
13741373
13751374static WRITE16_HANDLER( protection_peekaboo_w )
13761375{
1377   static int bank;
1376   megasys1_state *state = space->machine->driver_data<megasys1_state>();
13781377
1379   COMBINE_DATA(&protection_val);
1378   COMBINE_DATA(&state->protection_val);
13801379
1381   if ((protection_val & 0x90) == 0x90)
1380   if ((state->protection_val & 0x90) == 0x90)
13821381   {
13831382      UINT8 *RAM = space->machine->region("oki1")->base();
1384      int new_bank = (protection_val & 0x7) % 7;
1383      int new_bank = (state->protection_val & 0x7) % 7;
13851384
1386      if (bank != new_bank)
1385      if (state->bank != new_bank)
13871386      {
13881387         memcpy(&RAM[0x20000],&RAM[0x40000 + 0x20000*new_bank],0x20000);
1389         bank = new_bank;
1388         state->bank = new_bank;
13901389      }
13911390   }
13921391
r10886r10887
36183617
36193618static DRIVER_INIT( 64street )
36203619{
3620   megasys1_state *state = machine->driver_data<megasys1_state>();
36213621//  UINT16 *RAM = (UINT16 *) machine->region("maincpu")->base();
36223622//  RAM[0x006b8/2] = 0x6004;        // d8001 test
36233623//  RAM[0x10EDE/2] = 0x6012;        // watchdog
36243624
3625   ip_select_values[0] = 0x57;
3626   ip_select_values[1] = 0x53;
3627   ip_select_values[2] = 0x54;
3628   ip_select_values[3] = 0x55;
3629   ip_select_values[4] = 0x56;
3625   state->ip_select_values[0] = 0x57;
3626   state->ip_select_values[1] = 0x53;
3627   state->ip_select_values[2] = 0x54;
3628   state->ip_select_values[3] = 0x55;
3629   state->ip_select_values[4] = 0x56;
36303630}
36313631
36323632static DRIVER_INIT( astyanax )
r10886r10887
36413641
36423642static DRIVER_INIT( avspirit )
36433643{
3644   ip_select_values[0] = 0x37;
3645   ip_select_values[1] = 0x35;
3646   ip_select_values[2] = 0x36;
3647   ip_select_values[3] = 0x33;
3648   ip_select_values[4] = 0x34;
3644   megasys1_state *state = machine->driver_data<megasys1_state>();
3645   state->ip_select_values[0] = 0x37;
3646   state->ip_select_values[1] = 0x35;
3647   state->ip_select_values[2] = 0x36;
3648   state->ip_select_values[3] = 0x33;
3649   state->ip_select_values[4] = 0x34;
36493650
36503651   /* kludge: avspirit has 0x10000 bytes of RAM while edf has 0x20000. The */
36513652   /* following is needed to make vh_start() pick the correct address */
36523653   /* for spriteram16. */
3653   megasys1_ram += 0x10000/2;
3654   state->ram += 0x10000/2;
36543655}
36553656
36563657static DRIVER_INIT( bigstrik )
36573658{
3658   ip_select_values[0] = 0x58;
3659   ip_select_values[1] = 0x54;
3660   ip_select_values[2] = 0x55;
3661   ip_select_values[3] = 0x56;
3662   ip_select_values[4] = 0x57;
3659   megasys1_state *state = machine->driver_data<megasys1_state>();
3660   state->ip_select_values[0] = 0x58;
3661   state->ip_select_values[1] = 0x54;
3662   state->ip_select_values[2] = 0x55;
3663   state->ip_select_values[3] = 0x56;
3664   state->ip_select_values[4] = 0x57;
36633665}
36643666
36653667static DRIVER_INIT( chimerab )
36663668{
3669   megasys1_state *state = machine->driver_data<megasys1_state>();
36673670   /* same as cybattlr */
3668   ip_select_values[0] = 0x56;
3669   ip_select_values[1] = 0x52;
3670   ip_select_values[2] = 0x53;
3671   ip_select_values[3] = 0x54;
3672   ip_select_values[4] = 0x55;
3671   state->ip_select_values[0] = 0x56;
3672   state->ip_select_values[1] = 0x52;
3673   state->ip_select_values[2] = 0x53;
3674   state->ip_select_values[3] = 0x54;
3675   state->ip_select_values[4] = 0x55;
36733676}
36743677
36753678static DRIVER_INIT( cybattlr )
36763679{
3677   ip_select_values[0] = 0x56;
3678   ip_select_values[1] = 0x52;
3679   ip_select_values[2] = 0x53;
3680   ip_select_values[3] = 0x54;
3681   ip_select_values[4] = 0x55;
3680   megasys1_state *state = machine->driver_data<megasys1_state>();
3681   state->ip_select_values[0] = 0x56;
3682   state->ip_select_values[1] = 0x52;
3683   state->ip_select_values[2] = 0x53;
3684   state->ip_select_values[3] = 0x54;
3685   state->ip_select_values[4] = 0x55;
36823686}
36833687
36843688static DRIVER_INIT( edf )
36853689{
3686   ip_select_values[0] = 0x20;
3687   ip_select_values[1] = 0x21;
3688   ip_select_values[2] = 0x22;
3689   ip_select_values[3] = 0x23;
3690   ip_select_values[4] = 0x24;
3690   megasys1_state *state = machine->driver_data<megasys1_state>();
3691   state->ip_select_values[0] = 0x20;
3692   state->ip_select_values[1] = 0x21;
3693   state->ip_select_values[2] = 0x22;
3694   state->ip_select_values[3] = 0x23;
3695   state->ip_select_values[4] = 0x24;
36913696}
36923697
36933698static READ16_HANDLER( edfbl_input_r )
r10886r10887
37133718
37143719static DRIVER_INIT( hayaosi1 )
37153720{
3716   ip_select_values[0] = 0x51;
3717   ip_select_values[1] = 0x52;
3718   ip_select_values[2] = 0x53;
3719   ip_select_values[3] = 0x54;
3720   ip_select_values[4] = 0x55;
3721   megasys1_state *state = machine->driver_data<megasys1_state>();
3722   state->ip_select_values[0] = 0x51;
3723   state->ip_select_values[1] = 0x52;
3724   state->ip_select_values[2] = 0x53;
3725   state->ip_select_values[3] = 0x54;
3726   state->ip_select_values[4] = 0x55;
37213727}
37223728
37233729static DRIVER_INIT( iganinju )
r10886r10887
38373843
38383844static DRIVER_INIT( monkelf )
38393845{
3846   megasys1_state *state = machine->driver_data<megasys1_state>();
38403847   UINT16 *ROM = (UINT16*)machine->region("maincpu")->base();
38413848   ROM[0x00744/2] = 0x4e71;
38423849
38433850   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xe0000, 0xe000f, 0, 0, monkelf_input_r);
38443851
3845   megasys1_ram += 0x10000/2;
3852   state->ram += 0x10000/2;
38463853
38473854}
38483855
r10886r10887
38663873GAME( 1989, hachoo,   0,        system_A_hachoo,   hachoo,   hachoo,   ROT0,   "Jaleco", "Hachoo!", 0 )
38673874GAME( 1989, jitsupro, 0,        system_A,          jitsupro, jitsupro, ROT0,   "Jaleco", "Jitsuryoku!! Pro Yakyuu (Japan)", 0 )
38683875GAME( 1989, plusalph, 0,        system_A,          plusalph, plusalph, ROT270, "Jaleco", "Plus Alpha", 0 )
3869GAME( 1989, stdragon, 0,        system_A,          stdragon, stdragon, ROT0,   "Jaleco", "Saint Dragon", 0 )
3876GAME( 1989, stdragon, 0,        system_A,          stdragon, stdragon, ROT0,   "Jaleco", "Tensei Ryuu Saint Dragon", 0 )
38703877GAME( 1990, rodland,  0,        system_A,          rodland,  rodland,  ROT0,   "Jaleco", "Rod-Land (World)", 0 )
38713878GAME( 1990, rodlandj, rodland,  system_A,          rodland,  rodlandj, ROT0,   "Jaleco", "Rod-Land (Japan)", 0 )
38723879GAME( 1990, rodlandjb,rodland,  system_A,          rodland,  0,        ROT0,   "bootleg","Rod-Land (Japan bootleg)", 0 )
src/mame/drivers/bwing.c
r10886r10887
200200   AM_RANGE(0x0800, 0x0fff) AM_RAM
201201   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(bwing_videoram_w) AM_BASE_MEMBER(bwing_state, videoram)
202202   AM_RANGE(0x1400, 0x17ff) AM_RAM
203   AM_RANGE(0x1800, 0x19ff) AM_RAM_WRITE(bwing_spriteram_w) AM_BASE_GENERIC(buffered_spriteram)
203   AM_RANGE(0x1800, 0x19ff) AM_RAM_WRITE(bwing_spriteram_w) AM_BASE_MEMBER(bwing_state, spriteram)
204204   AM_RANGE(0x1a00, 0x1aff) AM_RAM_WRITE(bwing_paletteram_w) AM_BASE_MEMBER(bwing_state, paletteram)
205205   AM_RANGE(0x1b00, 0x1b07) AM_RAM_WRITE(bwing_scrollreg_w)
206206   AM_RANGE(0x1c00, 0x1c07) AM_RAM_WRITE(bwp1_ctrl_w)
src/mame/drivers/slotcarn.c
r10886r10887
2929#define NUM_PENS            (16)
3030#define RAM_PALETTE_SIZE      (1024)
3131
32static pen_t pens[NUM_PENS];
3332
34static UINT8 *ram_attr;
35static UINT8 *ram_video;
36static UINT8 *ram_palette;
37static UINT8 *backup_ram;
33class slotcarn_state : public driver_device
34{
35public:
36   slotcarn_state(running_machine &machine, const driver_device_config_base &config)
37      : driver_device(machine, config) { }
3838
39   pen_t pens[NUM_PENS];
40   UINT8 *ram_attr;
41   UINT8 *ram_video;
42   UINT8 *ram_palette;
43   UINT8 *backup_ram;
44};
45
46
3947/*
4048
4149  b800-b803 = PPI (9b) III mode0 all.
r10886r10887
4856
4957static READ8_HANDLER( palette_r )
5058{
59   slotcarn_state *state = space->machine->driver_data<slotcarn_state>();
5160   int co;
5261
53   co = ((ram_attr[offset] & 0x7F) << 3) | (offset & 0x07);
54   return ram_palette[co];
62   co = ((state->ram_attr[offset] & 0x7F) << 3) | (offset & 0x07);
63   return state->ram_palette[co];
5564}
5665
5766static WRITE8_HANDLER( palette_w )
5867{
68   slotcarn_state *state = space->machine->driver_data<slotcarn_state>();
5969   int co;
6070
6171   space->machine->primary_screen->update_now();
6272   data &= 0x0f;
6373
64   co = ((ram_attr[offset] & 0x7F) << 3) | (offset & 0x07);
65   ram_palette[co] = data;
74   co = ((state->ram_attr[offset] & 0x7F) << 3) | (offset & 0x07);
75   state->ram_palette[co] = data;
6676
6777}
6878
6979
7080static MC6845_BEGIN_UPDATE( begin_update )
7181{
82   slotcarn_state *state = device->machine->driver_data<slotcarn_state>();
7283   int i;
7384   int dim, bit0, bit1, bit2;
7485
r10886r10887
7889      bit0 = BIT(i,0);
7990      bit1 = BIT(i,1);
8091      bit2 = BIT(i,2);
81      pens[i] = MAKE_RGB(dim*bit0, dim*bit1, dim*bit2);
92      state->pens[i] = MAKE_RGB(dim*bit0, dim*bit1, dim*bit2);
8293   }
8394
84   return pens;
95   return state->pens;
8596}
8697
8798
8899static MC6845_UPDATE_ROW( update_row )
89100{
101   slotcarn_state *state = device->machine->driver_data<slotcarn_state>();
90102   int extra_video_bank_bit = 0; // not used?
91103   int lscnblk = 0; // not used?
92104
r10886r10887
105117   for (cx = 0; cx < x_count; cx++)
106118   {
107119      int i;
108      int attr = ram_attr[ma & 0x7ff];
120      int attr = state->ram_attr[ma & 0x7ff];
109121      int region = (attr & 0x40) >> 6;
110      int addr = ((ram_video[ma & 0x7ff] | ((attr & 0x80) << 1) | (extra_video_bank_bit)) << 4) | (ra & 0x0f);
122      int addr = ((state->ram_video[ma & 0x7ff] | ((attr & 0x80) << 1) | (extra_video_bank_bit)) << 4) | (ra & 0x0f);
111123      int colour = (attr & 0x7f) << 3;
112124      UINT8   *data;
113125
r10886r10887
127139         else
128140            col |= 0x03;
129141
130         col = ram_palette[col & 0x3ff];
142         col = state->ram_palette[col & 0x3ff];
131143         *BITMAP_ADDR32(bitmap, y, x) = pens[col ? col : (lscnblk ? 8 : 0)];
132144
133145         x++;
r10886r10887
169181
170182static ADDRESS_MAP_START( slotcarn_map, ADDRESS_SPACE_PROGRAM, 8 )
171183   AM_RANGE(0x0000, 0x5fff) AM_ROM
172   AM_RANGE(0x6000, 0x67ff) AM_RAM AM_BASE(&backup_ram)
184   AM_RANGE(0x6000, 0x67ff) AM_RAM AM_BASE_MEMBER(slotcarn_state, backup_ram)
173185   AM_RANGE(0x6800, 0x6fff) AM_RAM // spielbud
174186   AM_RANGE(0x7000, 0xafff) AM_ROM // spielbud
175187
r10886r10887
189201   AM_RANGE(0xe000, 0xe000) AM_DEVWRITE("crtc", mc6845_address_w)
190202   AM_RANGE(0xe001, 0xe001) AM_DEVWRITE("crtc", mc6845_register_w)
191203
192   AM_RANGE(0xe800, 0xefff) AM_RAM AM_BASE(&ram_attr)
193   AM_RANGE(0xf000, 0xf7ff) AM_RAM AM_BASE(&ram_video)
204   AM_RANGE(0xe800, 0xefff) AM_RAM AM_BASE_MEMBER(slotcarn_state, ram_attr)
205   AM_RANGE(0xf000, 0xf7ff) AM_RAM AM_BASE_MEMBER(slotcarn_state, ram_video)
194206   AM_RANGE(0xf800, 0xfbff) AM_READWRITE(palette_r, palette_w)
195207ADDRESS_MAP_END
196208
r10886r10887
534546
535547static MACHINE_START(merit)
536548{
537   ram_palette = auto_alloc_array(machine, UINT8, RAM_PALETTE_SIZE);
538   state_save_register_global_pointer(machine, ram_palette, RAM_PALETTE_SIZE);
549   slotcarn_state *state = machine->driver_data<slotcarn_state>();
550   state->ram_palette = auto_alloc_array(machine, UINT8, RAM_PALETTE_SIZE);
551   state_save_register_global_pointer(machine, state->ram_palette, RAM_PALETTE_SIZE);
539552}
540553
541554
r10886r10887
591604*          Machine Driver          *
592605***********************************/
593606
594static MACHINE_CONFIG_START( slotcarn, driver_device )
607static MACHINE_CONFIG_START( slotcarn, slotcarn_state )
595608
596609   /* basic machine hardware */
597610   MCFG_CPU_ADD("maincpu", Z80, CPU_CLOCK) // 2.5 Mhz?
src/mame/drivers/hvyunit.c
r10886r10887
716716   ROM_LOAD( "b73_01.1b",  0x140000, 0x010000, CRC(3a8a4489) SHA1(a01d7300015f90ce6dd571ad93e7a58270a99e47) )
717717   ROM_LOAD( "b73_02.1c",  0x160000, 0x010000, CRC(025c536c) SHA1(075e95cc39e792049ae656404e7f7440df064391) )
718718   ROM_LOAD( "b73_03.1d",  0x180000, 0x010000, CRC(ec6020cf) SHA1(2973aa2dc3deb2f27c9f1bad07a7664bad95b3f2) )
719   /*                      0x190000, 0x010000  no data */
719720   ROM_LOAD( "b73_04.1f",  0x1a0000, 0x010000, CRC(f7badbb2) SHA1(d824ab4aba94d7ca02401f4f6f34213143c282ec) )
721   /*                      0x1b0000, 0x010000  no data */
720722   ROM_LOAD( "b73_05.1h",  0x1c0000, 0x010000, CRC(b8e829d2) SHA1(31102358500d7b58173d4f18647decf5db744416) )
721723
722724   ROM_REGION( 0x80000, "gfx2", 0 )
r10886r10887
736738   ROM_REGION( 0x1000, "mermaid", 0 )
737739   ROM_LOAD( "mermaid.bin",  0x0000, 0x0e00, CRC(88c5dd27) SHA1(5043fed7fd192891be7e4096f2c5daaae1538bc4) )
738740
739   ROM_REGION( 0x200000, "gfx1", 0 )
741   ROM_REGION( 0x200000, "gfx1", 0 ) /* note, the rom ordering on this is different to the other Japan set */
740742   ROM_LOAD( "b73_08.2f",  0x000000, 0x080000, CRC(f83dd808) SHA1(09d5f1e86fad3a0d2d3ac1845103d3f2833c6793) )
741743   ROM_LOAD( "b73_07.2c",  0x100000, 0x010000, CRC(5cffa42c) SHA1(687e047345039479b35d5099e56dbc1d57284ed9) )
742744   ROM_LOAD( "b73_06.2b",  0x110000, 0x010000, CRC(a98e4aea) SHA1(560fef03ad818894c9c7578c6282d55b646e8129) )
r10886r10887
750752   ROM_LOAD( "b73_09.2p",  0x000000, 0x080000, CRC(537c647f) SHA1(941c0f4e251bc68e53d62e70b033a3a6c145bb7e) )
751753ROM_END
752754
753ROM_START( hvyunito )
755ROM_START( hvyunitjo )
754756   ROM_REGION( 0x20000, "master", 0 )
755757   ROM_LOAD( "b73_13.5c",  0x00000, 0x20000, CRC(e2874601) SHA1(7f7f3287113b8622eb365d04135d2d9c35d70554) )
756758
r10886r10887
770772   ROM_LOAD( "b73_01.1b",  0x140000, 0x010000, CRC(3a8a4489) SHA1(a01d7300015f90ce6dd571ad93e7a58270a99e47) )
771773   ROM_LOAD( "b73_02.1c",  0x160000, 0x010000, CRC(025c536c) SHA1(075e95cc39e792049ae656404e7f7440df064391) )
772774   ROM_LOAD( "b73_03.1d",  0x180000, 0x010000, CRC(ec6020cf) SHA1(2973aa2dc3deb2f27c9f1bad07a7664bad95b3f2) )
775   /*                      0x190000, 0x010000  no data */
773776   ROM_LOAD( "b73_04.1f",  0x1a0000, 0x010000, CRC(f7badbb2) SHA1(d824ab4aba94d7ca02401f4f6f34213143c282ec) )
777   /*                      0x1b0000, 0x010000  no data */
774778   ROM_LOAD( "b73_05.1h",  0x1c0000, 0x010000, CRC(b8e829d2) SHA1(31102358500d7b58173d4f18647decf5db744416) )
775779
776780   ROM_REGION( 0x80000, "gfx2", 0 )
777781   ROM_LOAD( "b73_09.2p",  0x000000, 0x080000, CRC(537c647f) SHA1(941c0f4e251bc68e53d62e70b033a3a6c145bb7e) )
778782ROM_END
779783
784ROM_START( hvyunitu )
785   ROM_REGION( 0x20000, "master", 0 )
786   ROM_LOAD( "b73_34.5c",  0x00000, 0x20000, CRC(05c30a90) SHA1(97cc0ded2896e0945d790247c284e5058c28c735) )
780787
788   ROM_REGION( 0x10000, "slave", 0 )
789   ROM_LOAD( "b73_35.6p",  0x00000, 0x10000, CRC(aed1669d) SHA1(d0539261d6128fa2d58b529e8383b6d1f3ccac77) )
790
791   ROM_REGION( 0x10000, "soundcpu", 0 )
792   ROM_LOAD( "b73_12.7e",  0x000000, 0x010000, CRC(d1d24fab) SHA1(ed0312535d0b136d79aa885b9e6eea19ebde6409) )
793
794   ROM_REGION( 0x1000, "mermaid", 0 )
795   ROM_LOAD( "mermaid.bin",  0x0000, 0x0e00, CRC(88c5dd27) SHA1(5043fed7fd192891be7e4096f2c5daaae1538bc4) )
796
797   ROM_REGION( 0x200000, "gfx1", 0 )
798   ROM_LOAD( "b73_08.2f",  0x000000, 0x080000, CRC(f83dd808) SHA1(09d5f1e86fad3a0d2d3ac1845103d3f2833c6793) )
799   ROM_LOAD( "b73_28.2c",  0x100000, 0x020000, CRC(a02e08d6) SHA1(72764d4e8474aaac0674fd1c20278a706da7ade2) )
800   ROM_LOAD( "b73_27.2b",  0x120000, 0x020000, CRC(8708f97c) SHA1(ccddc7f2fa53c5e35345c2db0520f515c512b723) )
801   ROM_LOAD( "b73_25.0b",  0x140000, 0x020000, CRC(2f13f81e) SHA1(9d9c1869bf582a0bc0581cdf5b65237124b9e456) ) /* the data in first half of this actually differs slightly to the other sets, a 0x22 fill is replaced by 0xff on empty tiles */
802   ROM_LOAD( "b73_26.0c",  0x160000, 0x010000, CRC(b8e829d2) SHA1(31102358500d7b58173d4f18647decf5db744416) ) /* == b73_05.1h, despite the different label */
803
804   ROM_REGION( 0x80000, "gfx2", 0 )
805   ROM_LOAD( "b73_09.2p",  0x000000, 0x080000, CRC(537c647f) SHA1(941c0f4e251bc68e53d62e70b033a3a6c145bb7e) )
806ROM_END
807
808
781809/*************************************
782810 *
783811 *  Game driver(s)
r10886r10887
786814
787815GAME( 1988, hvyunit, 0,        hvyunit, hvyunit,  0, ROT0, "Kaneko / Taito", "Heavy Unit (World)", GAME_NO_COCKTAIL )
788816GAME( 1988, hvyunitj, hvyunit, hvyunit, hvyunitj, 0, ROT0, "Kaneko / Taito", "Heavy Unit (Japan, Newer)", GAME_NO_COCKTAIL )
789GAME( 1988, hvyunito, hvyunit, hvyunit, hvyunitj, 0, ROT0, "Kaneko / Taito", "Heavy Unit (Japan, Older)", GAME_NO_COCKTAIL )
817GAME( 1988, hvyunitjo,hvyunit, hvyunit, hvyunitj, 0, ROT0, "Kaneko / Taito", "Heavy Unit (Japan, Older)", GAME_NO_COCKTAIL )
818GAME( 1988, hvyunitu, hvyunit, hvyunit, hvyunitj, 0, ROT0, "Kaneko / Taito", "Heavy Unit -U.S.A. Version- (US)", GAME_NO_COCKTAIL )
src/mame/drivers/nmk16.c
r10886r10887
244244      {
245245         0x82,0xc7,0x00,0x2c,0x6c,0x00,0x9f,0xc7,0x00,0x29,0x69,0x00,0x8b,0xc7,0x00
246246      };
247      static int prot_count;
248247
249248      int res;
250249
r10886r10887
252251      else if (cpu_get_pc(space->cpu)==0x8ce) res = (state->mainram[0x9064/2])|0x60; /* Task Force Harrier */
253252      else
254253      {
255         res = to_main[prot_count++];
256         if (prot_count > sizeof(to_main))
257            prot_count = 0;
254         res = to_main[state->prot_count++];
255         if (state->prot_count > sizeof(to_main))
256            state->prot_count = 0;
258257      }
259258
260259      return res << 8;
r10886r10887
736735static void mcu_run(running_machine *machine, UINT8 dsw_setting)
737736{
738737   nmk16_state *state = machine->driver_data<nmk16_state>();
739   static UINT8 input_pressed;
740738   UINT16 coin_input;
741739   UINT8 dsw[2];
742   static UINT8 start_helper = 0;
743   static UINT8 coin_count[2],coin_count_frac[2];
744740   UINT8 i;
745741
746742   /*Accept the start button but needs some m68k processing first,otherwise you can't start a play with 1 credit inserted*/
747   if(start_helper & 1 && state->mainram[0x9000/2] & 0x0200) /*start 1 */
743   if(state->start_helper & 1 && state->mainram[0x9000/2] & 0x0200) /*start 1 */
748744   {
749745      state->mainram[0xef00/2]--;
750      start_helper = start_helper & 2;
746      state->start_helper = state->start_helper & 2;
751747   }
752   if(start_helper & 2 && state->mainram[0x9000/2] & 0x0100) /*start 2*/
748   if(state->start_helper & 2 && state->mainram[0x9000/2] & 0x0100) /*start 2*/
753749   {
754750      state->mainram[0xef00/2]--;
755      start_helper = start_helper & 1;
751      state->start_helper = state->start_helper & 1;
756752   }
757753
758754   /*needed because of the uncompatibility of the dsw settings.*/
r10886r10887
765761         switch(dsw[i] & 7)
766762         {
767763            case 0: state->mainram[0x9000/2]|=0x4000; break; //free play
768            case 1: coin_count_frac[i] = 1; coin_count[i] = 4; break;
769            case 2: coin_count_frac[i] = 1; coin_count[i] = 3; break;
770            case 3: coin_count_frac[i] = 1; coin_count[i] = 2; break;
771            case 4: coin_count_frac[i] = 4; coin_count[i] = 1; break;
772            case 5: coin_count_frac[i] = 3; coin_count[i] = 1; break;
773            case 6: coin_count_frac[i] = 2; coin_count[i] = 1; break;
774            case 7: coin_count_frac[i] = 1; coin_count[i] = 1; break;
764            case 1: state->coin_count_frac[i] = 1; state->coin_count[i] = 4; break;
765            case 2: state->coin_count_frac[i] = 1; state->coin_count[i] = 3; break;
766            case 3: state->coin_count_frac[i] = 1; state->coin_count[i] = 2; break;
767            case 4: state->coin_count_frac[i] = 4; state->coin_count[i] = 1; break;
768            case 5: state->coin_count_frac[i] = 3; state->coin_count[i] = 1; break;
769            case 6: state->coin_count_frac[i] = 2; state->coin_count[i] = 1; break;
770            case 7: state->coin_count_frac[i] = 1; state->coin_count[i] = 1; break;
775771         }
776772      }
777773   }
r10886r10887
784780         switch(dsw[i] & 7)
785781         {
786782            case 0: state->mainram[0x9000/2]|=0x4000; break; //free play
787            case 1: coin_count_frac[i] = 4; coin_count[i] = 1; break;
788            case 2: coin_count_frac[i] = 3; coin_count[i] = 1; break;
789            case 3: coin_count_frac[i] = 2; coin_count[i] = 1; break;
790            case 4: coin_count_frac[i] = 1; coin_count[i] = 4; break;
791            case 5: coin_count_frac[i] = 1; coin_count[i] = 3; break;
792            case 6: coin_count_frac[i] = 1; coin_count[i] = 2; break;
793            case 7: coin_count_frac[i] = 1; coin_count[i] = 1; break;
783            case 1: state->coin_count_frac[i] = 4; state->coin_count[i] = 1; break;
784            case 2: state->coin_count_frac[i] = 3; state->coin_count[i] = 1; break;
785            case 3: state->coin_count_frac[i] = 2; state->coin_count[i] = 1; break;
786            case 4: state->coin_count_frac[i] = 1; state->coin_count[i] = 4; break;
787            case 5: state->coin_count_frac[i] = 1; state->coin_count[i] = 3; break;
788            case 6: state->coin_count_frac[i] = 1; state->coin_count[i] = 2; break;
789            case 7: state->coin_count_frac[i] = 1; state->coin_count[i] = 1; break;
794790         }
795791      }
796792   }
r10886r10887
800796
801797   if(coin_input & 0x01)//coin 1
802798   {
803      if((input_pressed & 0x01) == 0)
799      if((state->input_pressed & 0x01) == 0)
804800      {
805         if(coin_count_frac[0] != 1)
801         if(state->coin_count_frac[0] != 1)
806802         {
807            state->mainram[0xef02/2]+=coin_count[0];
808            if(coin_count_frac[0] == state->mainram[0xef02/2])
803            state->mainram[0xef02/2]+=state->coin_count[0];
804            if(state->coin_count_frac[0] == state->mainram[0xef02/2])
809805            {
810               state->mainram[0xef00/2]+=coin_count[0];
806               state->mainram[0xef00/2]+=state->coin_count[0];
811807               state->mainram[0xef02/2] = 0;
812808            }
813809         }
814810         else
815            state->mainram[0xef00/2]+=coin_count[0];
811            state->mainram[0xef00/2]+=state->coin_count[0];
816812      }
817      input_pressed = (input_pressed & 0xfe) | 1;
813      state->input_pressed = (state->input_pressed & 0xfe) | 1;
818814   }
819815   else
820      input_pressed = (input_pressed & 0xfe);
816      state->input_pressed = (state->input_pressed & 0xfe);
821817
822818   if(coin_input & 0x02)//coin 2
823819   {
824      if((input_pressed & 0x02) == 0)
820      if((state->input_pressed & 0x02) == 0)
825821      {
826         if(coin_count_frac[1] != 1)
822         if(state->coin_count_frac[1] != 1)
827823         {
828            state->mainram[0xef02/2]+=coin_count[1];
829            if(coin_count_frac[1] == state->mainram[0xef02/2])
824            state->mainram[0xef02/2]+=state->coin_count[1];
825            if(state->coin_count_frac[1] == state->mainram[0xef02/2])
830826            {
831               state->mainram[0xef00/2]+=coin_count[1];
827               state->mainram[0xef00/2]+=state->coin_count[1];
832828               state->mainram[0xef02/2] = 0;
833829            }
834830         }
835831         else
836            state->mainram[0xef00/2]+=coin_count[1];
832            state->mainram[0xef00/2]+=state->coin_count[1];
837833      }
838      input_pressed = (input_pressed & 0xfd) | 2;
834      state->input_pressed = (state->input_pressed & 0xfd) | 2;
839835   }
840836   else
841      input_pressed = (input_pressed & 0xfd);
837      state->input_pressed = (state->input_pressed & 0xfd);
842838
843839   if(coin_input & 0x04)//service 1
844840   {
845      if((input_pressed & 0x04) == 0)
841      if((state->input_pressed & 0x04) == 0)
846842         state->mainram[0xef00/2]++;
847      input_pressed = (input_pressed & 0xfb) | 4;
843      state->input_pressed = (state->input_pressed & 0xfb) | 4;
848844   }
849845   else
850      input_pressed = (input_pressed & 0xfb);
846      state->input_pressed = (state->input_pressed & 0xfb);
851847
852848   /*The 0x9000 ram address is the status */
853849   if(state->mainram[0xef00/2] > 0 && state->mainram[0x9000/2] & 0x8000) //enable start button
854850   {
855851      if(coin_input & 0x08)//start 1
856852      {
857         if((input_pressed & 0x08) == 0 && (!(state->mainram[0x9000/2] & 0x0200))) //start 1
858            start_helper = 1;
853         if((state->input_pressed & 0x08) == 0 && (!(state->mainram[0x9000/2] & 0x0200))) //start 1
854            state->start_helper = 1;
859855
860         input_pressed = (input_pressed & 0xf7) | 8;
856         state->input_pressed = (state->input_pressed & 0xf7) | 8;
861857      }
862858      else
863         input_pressed = (input_pressed & 0xf7);
859         state->input_pressed = (state->input_pressed & 0xf7);
864860
865861      if(coin_input & 0x10)//start 2
866862      {
867863         /*Decrease two coins to let two players play with one start 2 button and two credits inserted at the insert coin screen.*/
868         if((input_pressed & 0x10) == 0 && (!(state->mainram[0x9000/2] & 0x0100))) // start 2
869            start_helper = (state->mainram[0x9000/2] == 0x8000) ? (3) : (2);
864         if((state->input_pressed & 0x10) == 0 && (!(state->mainram[0x9000/2] & 0x0100))) // start 2
865            state->start_helper = (state->mainram[0x9000/2] == 0x8000) ? (3) : (2);
870866
871         input_pressed = (input_pressed & 0xef) | 0x10;
867         state->input_pressed = (state->input_pressed & 0xef) | 0x10;
872868      }
873869      else
874         input_pressed = (input_pressed & 0xef);
870         state->input_pressed = (state->input_pressed & 0xef);
875871   }
876872}
877873
src/mame/drivers/miniboy7.c
r10886r10887
152152#include "machine/nvram.h"
153153
154154
155class miniboy7_state : public driver_device
156{
157public:
158   miniboy7_state(running_machine &machine, const driver_device_config_base &config)
159      : driver_device(machine, config) { }
160
161   UINT8 *videoram;
162   UINT8 *colorram;
163   tilemap_t *bg_tilemap;
164};
165
166
155167/***********************************
156168*          Video Hardware          *
157169***********************************/
158170
159static UINT8 *videoram;
160static UINT8 *colorram;
161static tilemap_t *bg_tilemap;
162
163171static WRITE8_HANDLER( miniboy7_videoram_w )
164172{
165   videoram[offset] = data;
166   tilemap_mark_tile_dirty(bg_tilemap, offset);
173   miniboy7_state *state = space->machine->driver_data<miniboy7_state>();
174   state->videoram[offset] = data;
175   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
167176}
168177
169178static WRITE8_HANDLER( miniboy7_colorram_w )
170179{
171   colorram[offset] = data;
172   tilemap_mark_tile_dirty(bg_tilemap, offset);
180   miniboy7_state *state = space->machine->driver_data<miniboy7_state>();
181   state->colorram[offset] = data;
182   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
173183}
174184
175185static TILE_GET_INFO( get_bg_tile_info )
176186{
187   miniboy7_state *state = machine->driver_data<miniboy7_state>();
177188/*  - bits -
178189    7654 3210
179190    --xx xx--   tiles color?.
180191    ---- --x-   tiles bank.
181192    xx-- ---x   seems unused. */
182193
183   int attr = colorram[tile_index];
184   int code = videoram[tile_index];
194   int attr = state->colorram[tile_index];
195   int code = state->videoram[tile_index];
185196   int bank = (attr & 0x02) >> 1;   /* bit 1 switch the gfx banks */
186197   int color = (attr & 0x3c);   /* bits 2-3-4-5 for color? */
187198
r10886r10887
193204
194205static VIDEO_START( miniboy7 )
195206{
196   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 37, 37);
207   miniboy7_state *state = machine->driver_data<miniboy7_state>();
208   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 37, 37);
197209}
198210
199211static SCREEN_UPDATE( miniboy7 )
200212{
201   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
213   miniboy7_state *state = screen->machine->driver_data<miniboy7_state>();
214   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
202215   return 0;
203216}
204217
r10886r10887
255268
256269static ADDRESS_MAP_START( miniboy7_map, ADDRESS_SPACE_PROGRAM, 8 )
257270   AM_RANGE(0x0000, 0x07ff) AM_RAM   AM_SHARE("nvram") /* battery backed RAM? */
258   AM_RANGE(0x0800, 0x0fff) AM_RAM_WRITE(miniboy7_videoram_w) AM_BASE(&videoram)
259   AM_RANGE(0x1000, 0x17ff) AM_RAM_WRITE(miniboy7_colorram_w) AM_BASE(&colorram)
271   AM_RANGE(0x0800, 0x0fff) AM_RAM_WRITE(miniboy7_videoram_w) AM_BASE_MEMBER(miniboy7_state, videoram)
272   AM_RANGE(0x1000, 0x17ff) AM_RAM_WRITE(miniboy7_colorram_w) AM_BASE_MEMBER(miniboy7_state, colorram)
260273   AM_RANGE(0x1800, 0x25ff) AM_RAM   /* looks like videoram */
261274   AM_RANGE(0x2600, 0x27ff) AM_RAM
262275   AM_RANGE(0x2800, 0x2800) AM_DEVWRITE("crtc", mc6845_address_w)
r10886r10887
429442*         Machine Drivers          *
430443***********************************/
431444
432static MACHINE_CONFIG_START( miniboy7, driver_device )
445static MACHINE_CONFIG_START( miniboy7, miniboy7_state )
433446
434447   /* basic machine hardware */
435448   MCFG_CPU_ADD("maincpu", M6502, MASTER_CLOCK/16)   /* guess */
src/emu/cpu/m6805/6805ops.c
r10886r10887
3434   if (r&bit) {
3535      SEC;
3636      PC+=SIGNED(t);
37
38      if (t==0xfd)
39      {
40         /* speed up busy loops */
41         if(cpustate->iCount > 0)
42            cpustate->iCount = 0;
43      }
4437   }
4538}
4639
r10886r10887
5649   if (!(r&bit)) {
5750      CLC;
5851      PC+=SIGNED(t);
59
60      if (t==0xfd)
61      {
62         /* speed up busy loops */
63         if(cpustate->iCount > 0)
64            cpustate->iCount = 0;
65       }
6652   }
6753}
6854
r10886r10887
8874   UINT8 t;
8975   IMMBYTE(t);
9076   PC+=SIGNED(t);
91   if (t==0xfe)
92   {
93      /* speed up busy loops */
94      if(cpustate->iCount > 0)
95         cpustate->iCount = 0;
96    }
9777}
9878
9979/* $21 BRN relative ---- */
src/emu/cpu/m6809/m6809.c
r10886r10887
664664   case 0x85: EA=X+SIGNED(B);                                 break;
665665   case 0x86: EA=X+SIGNED(A);                                 break;
666666   case 0x87: EA=0;                                       break; /*   ILLEGAL*/
667   case 0x88: IMMBYTE(EA);    EA=X+SIGNED(EA);                  break; /* this is a hack to make Vectrex work. It should be m68_state->icount-=1. Dunno where the cycle was lost :( */
667   case 0x88: IMMBYTE(EA);    EA=X+SIGNED(EA);                  break;
668668   case 0x89: IMMWORD(EAP);   EA+=X;                           break;
669669   case 0x8a: EA=0;                                       break; /*   IIError*/
670670   case 0x8b: EA=X+D;                                       break;
src/emu/cpu/m6809/6809ops.c
r10886r10887
195195{
196196   IMMWORD(EAP);
197197   PC += EA;
198
199   if ( EA == 0xfffd )  /* EHC 980508 speed up busy loop */
200      if ( m68_state->icount > 0)
201         m68_state->icount = 0;
202198}
203199
204200/* $17 LBSR relative ----- */
r10886r10887
372368   UINT8 t;
373369   IMMBYTE(t);
374370   PC += SIGNED(t);
375   /* JB 970823 - speed up busy loops */
376   if( t == 0xfe )
377      if( m68_state->icount > 0 ) m68_state->icount = 0;
378371}
379372
380373/* $21 BRN relative ----- */
src/emu/cpu/hd6309/6309ops.c
r10886r10887
271271{
272272   IMMWORD(EAP);
273273   PC += EA;
274
275   if ( EA == 0xfffd )  /* EHC 980508 speed up busy loop */
276      if ( m68_state->icount > 0)
277         m68_state->icount = 0;
278274}
279275
280276/* $17 LBSR relative ----- */
r10886r10887
479475   UINT8 t;
480476   IMMBYTE(t);
481477   PC += SIGNED(t);
482   /* JB 970823 - speed up busy loops */
483   if( t == 0xfe )
484      if( m68_state->icount > 0 ) m68_state->icount = 0;
485478}
486479
487480/* $21 BRN relative ----- */
src/emu/cpu/pps4/pps4.c
r10886r10887
3535   UINT8   FF2; // Flip-flop 2
3636
3737   legacy_cpu_device *device;
38   const address_space *program;
38   address_space *program;
3939   direct_read_data *direct;
40   const address_space *data;
41   const address_space *io;
40   address_space *data;
41   address_space *io;
4242
4343   int               icount;
4444};
src/emu/cpu/m6800/6800ops.c
r10886r10887
230230   UINT8 t;
231231   IMMBYTE(t);
232232   PC+=SIGNED(t);
233   /* speed up busy loops */
234   if (t==0xfe) EAT_CYCLES;
235233}
236234
237235/* $21 BRN relative ----- */
src/emu/cpu/konami/konamops.c
r10886r10887
191191{
192192   IMMWORD(cpustate, cpustate->ea);
193193   PC += EA;
194
195   /* EHC 980508 speed up busy loop */
196   if( EA == 0xfffd && cpustate->icount > 0 )
197      cpustate->icount = 0;
198194}
199195
200196/* $17 LBSR relative ----- */
r10886r10887
301297   UINT8 t;
302298   IMMBYTE(cpustate, t);
303299   PC += SIGNED(t);
304   /* JB 970823 - speed up busy loops */
305   if( t == 0xfe && cpustate->icount > 0 )
306      cpustate->icount = 0;
307300}
308301
309302/* $21 BRN relative ----- */
src/emu/video/resnet.h
r10886r10887
8787
8888/* Some aliases */
8989
90#define RES_NET_VIN_MB7051         RES_NET_VIN_TTL_OUT
9091#define RES_NET_VIN_MB7052         RES_NET_VIN_TTL_OUT
9192#define RES_NET_VIN_MB7053         RES_NET_VIN_TTL_OUT
9293#define RES_NET_VIN_28S42         RES_NET_VIN_TTL_OUT
src/emu/memory.c
r10886r10887
232232{
233233   STATIC_INVALID = 0,                           // invalid - should never be used
234234   STATIC_BANK1 = 1,                           // first memory bank
235   STATIC_BANKMAX = 122,                        // last memory bank
236   STATIC_RAM,                                 // RAM - reads/writes map to dynamic banks
237   STATIC_ROM,                                 // ROM - reads = RAM; writes = UNMAP
235   STATIC_BANKMAX = 124,                        // last memory bank
238236   STATIC_NOP,                                 // NOP - reads = unmapped value; writes = no-op
239237   STATIC_UNMAP,                              // unmapped - same as NOP except we log errors
240238   STATIC_WATCHPOINT,                           // watchpoint - used internally
r10886r10887
10731071      const handler_entry_read &handler = m_read.handler_read(entry);
10741072
10751073      // 8-bit case: RAM/ROM
1076      if (entry >= STATIC_RAM)
1074      if (entry > STATIC_BANKMAX)
10771075         return NULL;
10781076      return handler.ramptr(handler.byteoffset(byteaddress));
10791077   }
r10886r10887
10871085      const handler_entry_write &handler = m_write.handler_write(entry);
10881086
10891087      // 8-bit case: RAM/ROM
1090      if (entry >= STATIC_RAM)
1088      if (entry > STATIC_BANKMAX)
10911089         return NULL;
10921090      return handler.ramptr(handler.byteoffset(byteaddress));
10931091   }
r10886r10887
11071105      // either read directly from RAM, or call the delegate
11081106      offset = handler.byteoffset(byteaddress);
11091107      _NativeType result;
1110      if (entry < STATIC_RAM) result = *reinterpret_cast<_NativeType *>(handler.ramptr(offset));
1108      if (entry <= STATIC_BANKMAX) result = *reinterpret_cast<_NativeType *>(handler.ramptr(offset));
11111109      else if (sizeof(_NativeType) == 1) result = handler.read8(*this, offset, mask);
11121110      else if (sizeof(_NativeType) == 2) result = handler.read16(*this, offset >> 1, mask);
11131111      else if (sizeof(_NativeType) == 4) result = handler.read32(*this, offset >> 2, mask);
r10886r10887
11321130      // either read directly from RAM, or call the delegate
11331131      offset = handler.byteoffset(byteaddress);
11341132      _NativeType result;
1135      if (entry < STATIC_RAM) result = *reinterpret_cast<_NativeType *>(handler.ramptr(offset));
1133      if (entry <= STATIC_BANKMAX) result = *reinterpret_cast<_NativeType *>(handler.ramptr(offset));
11361134      else if (sizeof(_NativeType) == 1) result = handler.read8(*this, offset, 0xff);
11371135      else if (sizeof(_NativeType) == 2) result = handler.read16(*this, offset >> 1, 0xffff);
11381136      else if (sizeof(_NativeType) == 4) result = handler.read32(*this, offset >> 2, 0xffffffff);
r10886r10887
11541152
11551153      // either write directly to RAM, or call the delegate
11561154      offset = handler.byteoffset(byteaddress);
1157      if (entry < STATIC_RAM)
1155      if (entry <= STATIC_BANKMAX)
11581156      {
11591157         _NativeType *dest = reinterpret_cast<_NativeType *>(handler.ramptr(offset));
11601158         *dest = (*dest & ~mask) | (data & mask);
r10886r10887
11791177
11801178      // either write directly to RAM, or call the delegate
11811179      offset = handler.byteoffset(byteaddress);
1182      if (entry < STATIC_RAM) *reinterpret_cast<_NativeType *>(handler.ramptr(offset)) = data;
1180      if (entry <= STATIC_BANKMAX) *reinterpret_cast<_NativeType *>(handler.ramptr(offset)) = data;
11831181      else if (sizeof(_NativeType) == 1) handler.write8(*this, offset, data, 0xff);
11841182      else if (sizeof(_NativeType) == 2) handler.write16(*this, offset >> 1, data, 0xffff);
11851183      else if (sizeof(_NativeType) == 4) handler.write32(*this, offset >> 2, data, 0xffffffff);
r10886r10887
31833181         throw emu_fatalerror("Out of handler entries in address table");
31843182   }
31853183
3186   // configure the entry to our parameters
3184   // configure the entry to our parameters (but not for static non-banked cases)
31873185   handler_entry &curentry = handler(entry);
3188   curentry.configure(bytestart, byteend, bytemask);
3186   if (entry <= STATIC_BANKMAX || entry >= STATIC_COUNT)
3187      curentry.configure(bytestart, byteend, bytemask);
31893188
31903189   // populate it
31913190   populate_range_mirrored(bytestart, byteend, bytemirror, entry);
r10886r10887
39313930   direct_range *range = find_range(overrideaddress, m_entry);
39323931
39333932   // if we don't map to a bank, return FALSE
3934   if (m_entry < STATIC_BANK1 || m_entry >= STATIC_RAM)
3933   if (m_entry < STATIC_BANK1 || m_entry > STATIC_BANKMAX)
39353934   {
39363935      // ensure future updates to land here as well until we get back into a bank
39373936      m_byteend = 0;
src/emu/memory.h
r10886r10887
351351   int spacenum() const { return m_spacenum; }
352352   address_map *map() const { return m_map; }
353353
354   direct_read_data &direct() const { return const_cast<direct_read_data &>(m_direct); }
354   direct_read_data &direct() const { return m_direct; }
355355
356356   int data_width() const { return m_config.data_width(); }
357357   int addr_width() const { return m_config.addr_width(); }
r10886r10887
620620
621621// wrappers for dynamic read handler installation
622622#define memory_install_read8_handler(space, start, end, mask, mirror, rhandler) \
623   const_cast<address_space *>(space)->install_legacy_handler(start, end, mask, mirror, rhandler, #rhandler)
623   (space)->install_legacy_handler(start, end, mask, mirror, rhandler, #rhandler)
624624#define memory_install_read16_handler(space, start, end, mask, mirror, rhandler) \
625   const_cast<address_space *>(space)->install_legacy_handler(start, end, mask, mirror, rhandler, #rhandler)
625   (space)->install_legacy_handler(start, end, mask, mirror, rhandler, #rhandler)
626626#define memory_install_read32_handler(space, start, end, mask, mirror, rhandler) \
627   const_cast<address_space *>(space)->install_legacy_handler(start, end, mask, mirror, rhandler, #rhandler)
627   (space)->install_legacy_handler(start, end, mask, mirror, rhandler, #rhandler)
628628#define memory_install_read64_handler(space, start, end, mask, mirror, rhandler) \
629   const_cast<address_space *>(space)->install_legacy_handler(start, end, mask, mirror, rhandler, #rhandler)
629   (space)->install_legacy_handler(start, end, mask, mirror, rhandler, #rhandler)
630630
631631#define memory_install_read8_device_handler(space, device, start, end, mask, mirror, rhandler) \
632   const_cast<address_space *>(space)->install_legacy_handler(*(device), start, end, mask, mirror, rhandler, #rhandler)
632   (space)->install_legacy_handler(*(device), start, end, mask, mirror, rhandler, #rhandler)
633633#define memory_install_read16_device_handler(space, device, start, end, mask, mirror, rhandler) \
634   const_cast<address_space *>(space)->install_legacy_handler(*(device), start, end, mask, mirror, rhandler, #rhandler)
634   (space)->install_legacy_handler(*(device), start, end, mask, mirror, rhandler, #rhandler)
635635#define memory_install_read32_device_handler(space, device, start, end, mask, mirror, rhandler) \
636   const_cast<address_space *>(space)->install_legacy_handler(*(device), start, end, mask, mirror, rhandler, #rhandler)
636   (space)->install_legacy_handler(*(device), start, end, mask, mirror, rhandler, #rhandler)
637637#define memory_install_read64_device_handler(space, device, start, end, mask, mirror, rhandler) \
638   const_cast<address_space *>(space)->install_legacy_handler(*(device), start, end, mask, mirror, rhandler, #rhandler)
638   (space)->install_legacy_handler(*(device), start, end, mask, mirror, rhandler, #rhandler)
639639
640640#define memory_install_read_port(space, start, end, mask, mirror, rtag) \
641   const_cast<address_space *>(space)->install_port(start, end, mask, mirror, rtag, NULL)
641   (space)->install_port(start, end, mask, mirror, rtag, NULL)
642642#define memory_install_read_bank(space, start, end, mask, mirror, rtag) \
643   const_cast<address_space *>(space)->install_bank(start, end, mask, mirror, rtag, NULL)
643   (space)->install_bank(start, end, mask, mirror, rtag, NULL)
644644#define memory_install_rom(space, start, end, mask, mirror, baseptr) \
645   const_cast<address_space *>(space)->install_ram(start, end, mask, mirror, ROW_READ, baseptr)
645   (space)->install_ram(start, end, mask, mirror, ROW_READ, baseptr)
646646#define memory_unmap_read(space, start, end, mask, mirror) \
647   const_cast<address_space *>(space)->unmap(start, end, mask, mirror, ROW_READ, false)
647   (space)->unmap(start, end, mask, mirror, ROW_READ, false)
648648#define memory_nop_read(space, start, end, mask, mirror) \
649   const_cast<address_space *>(space)->unmap(start, end, mask, mirror, ROW_READ, true)
649   (space)->unmap(start, end, mask, mirror, ROW_READ, true)
650650
651651// wrappers for dynamic write handler installation
652652#define memory_install_write8_handler(space, start, end, mask, mirror, whandler) \
653   const_cast<address_space *>(space)->install_legacy_handler(start, end, mask, mirror, whandler, #whandler)
653   (space)->install_legacy_handler(start, end, mask, mirror, whandler, #whandler)
654654#define memory_install_write16_handler(space, start, end, mask, mirror, whandler) \
655   const_cast<address_space *>(space)->install_legacy_handler(start, end, mask, mirror, whandler, #whandler)
655   (space)->install_legacy_handler(start, end, mask, mirror, whandler, #whandler)
656656#define memory_install_write32_handler(space, start, end, mask, mirror, whandler) \
657   const_cast<address_space *>(space)->install_legacy_handler(start, end, mask, mirror, whandler, #whandler)
657   (space)->install_legacy_handler(start, end, mask, mirror, whandler, #whandler)
658658#define memory_install_write64_handler(space, start, end, mask, mirror, whandler) \
659   const_cast<address_space *>(space)->install_legacy_handler(start, end, mask, mirror, whandler, #whandler)
659   (space)->install_legacy_handler(start, end, mask, mirror, whandler, #whandler)
660660
661661#define memory_install_write8_device_handler(space, device, start, end, mask, mirror, whandler) \
662   const_cast<address_space *>(space)->install_legacy_handler(*(device), start, end, mask, mirror, whandler, #whandler)
662   (space)->install_legacy_handler(*(device), start, end, mask, mirror, whandler, #whandler)
663663#define memory_install_write16_device_handler(space, device, start, end, mask, mirror, whandler) \
664   const_cast<address_space *>(space)->install_legacy_handler(*(device), start, end, mask, mirror, whandler, #whandler)
664   (space)->install_legacy_handler(*(device), start, end, mask, mirror, whandler, #whandler)
665665#define memory_install_write32_device_handler(space, device, start, end, mask, mirror, whandler) \
666   const_cast<address_space *>(space)->install_legacy_handler(*(device), start, end, mask, mirror, whandler, #whandler)
666   (space)->install_legacy_handler(*(device), start, end, mask, mirror, whandler, #whandler)
667667#define memory_install_write64_device_handler(space, device, start, end, mask, mirror, whandler) \
668   const_cast<address_space *>(space)->install_legacy_handler(*(device), start, end, mask, mirror, whandler, #whandler)
668   (space)->install_legacy_handler(*(device), start, end, mask, mirror, whandler, #whandler)
669669
670670#define memory_install_write_port(space, start, end, mask, mirror, wtag) \
671   const_cast<address_space *>(space)->install_port(start, end, mask, mirror, NULL, wtag)
671   (space)->install_port(start, end, mask, mirror, NULL, wtag)
672672#define memory_install_write_bank(space, start, end, mask, mirror, wtag) \
673   const_cast<address_space *>(space)->install_bank(start, end, mask, mirror, NULL, wtag)
673   (space)->install_bank(start, end, mask, mirror, NULL, wtag)
674674#define memory_install_writeonly(space, start, end, mask, mirror, baseptr) \
675   const_cast<address_space *>(space)->install_ram(start, end, mask, mirror, ROW_WRITE, baseptr)
675   (space)->install_ram(start, end, mask, mirror, ROW_WRITE, baseptr)
676676#define memory_unmap_write(space, start, end, mask, mirror) \
677   const_cast<address_space *>(space)->unmap(start, end, mask, mirror, ROW_WRITE, false)
677   (space)->unmap(start, end, mask, mirror, ROW_WRITE, false)
678678#define memory_nop_write(space, start, end, mask, mirror) \
679   const_cast<address_space *>(space)->unmap(start, end, mask, mirror, ROW_WRITE, true)
679   (space)->unmap(start, end, mask, mirror, ROW_WRITE, true)
680680
681681// wrappers for dynamic read/write handler installation
682682#define memory_install_readwrite8_handler(space, start, end, mask, mirror, rhandler, whandler) \
683   const_cast<address_space *>(space)->install_legacy_handler(start, end, mask, mirror, rhandler, #rhandler, whandler, #whandler)
683   (space)->install_legacy_handler(start, end, mask, mirror, rhandler, #rhandler, whandler, #whandler)
684684#define memory_install_readwrite16_handler(space, start, end, mask, mirror, rhandler, whandler) \
685   const_cast<address_space *>(space)->install_legacy_handler(start, end, mask, mirror, rhandler, #rhandler, whandler, #whandler)
685   (space)->install_legacy_handler(start, end, mask, mirror, rhandler, #rhandler, whandler, #whandler)
686686#define memory_install_readwrite32_handler(space, start, end, mask, mirror, rhandler, whandler) \
687   const_cast<address_space *>(space)->install_legacy_handler(start, end, mask, mirror, rhandler, #rhandler, whandler, #whandler)
687   (space)->install_legacy_handler(start, end, mask, mirror, rhandler, #rhandler, whandler, #whandler)
688688#define memory_install_readwrite64_handler(space, start, end, mask, mirror, rhandler, whandler) \
689   const_cast<address_space *>(space)->install_legacy_handler(start, end, mask, mirror, rhandler, #rhandler, whandler, #whandler)
689   (space)->install_legacy_handler(start, end, mask, mirror, rhandler, #rhandler, whandler, #whandler)
690690
691691#define memory_install_readwrite8_device_handler(space, device, start, end, mask, mirror, rhandler, whandler) \
692   const_cast<address_space *>(space)->install_legacy_handler(*(device), start, end, mask, mirror, rhandler, #rhandler, whandler, #whandler)
692   (space)->install_legacy_handler(*(device), start, end, mask, mirror, rhandler, #rhandler, whandler, #whandler)
693693#define memory_install_readwrite16_device_handler(space, device, start, end, mask, mirror, rhandler, whandler) \
694   const_cast<address_space *>(space)->install_legacy_handler(*(device), start, end, mask, mirror, rhandler, #rhandler, whandler, #whandler)
694   (space)->install_legacy_handler(*(device), start, end, mask, mirror, rhandler, #rhandler, whandler, #whandler)
695695#define memory_install_readwrite32_device_handler(space, device, start, end, mask, mirror, rhandler, whandler) \
696   const_cast<address_space *>(space)->install_legacy_handler(*(device), start, end, mask, mirror, rhandler, #rhandler, whandler, #whandler)
696   (space)->install_legacy_handler(*(device), start, end, mask, mirror, rhandler, #rhandler, whandler, #whandler)
697697#define memory_install_readwrite64_device_handler(space, device, start, end, mask, mirror, rhandler, whandler) \
698   const_cast<address_space *>(space)->install_legacy_handler(*(device), start, end, mask, mirror, rhandler, #rhandler, whandler, #whandler)
698   (space)->install_legacy_handler(*(device), start, end, mask, mirror, rhandler, #rhandler, whandler, #whandler)
699699
700700#define memory_install_readwrite_port(space, start, end, mask, mirror, rtag, wtag) \
701   const_cast<address_space *>(space)->install_port(start, end, mask, mirror, rtag, wtag)
701   (space)->install_port(start, end, mask, mirror, rtag, wtag)
702702#define memory_install_readwrite_bank(space, start, end, mask, mirror, tag) \
703   const_cast<address_space *>(space)->install_bank(start, end, mask, mirror, tag, tag)
703   (space)->install_bank(start, end, mask, mirror, tag, tag)
704704#define memory_install_ram(space, start, end, mask, mirror, baseptr) \
705   const_cast<address_space *>(space)->install_ram(start, end, mask, mirror, ROW_READWRITE, baseptr)
705   (space)->install_ram(start, end, mask, mirror, ROW_READWRITE, baseptr)
706706#define memory_unmap_readwrite(space, start, end, mask, mirror) \
707   const_cast<address_space *>(space)->unmap(start, end, mask, mirror, ROW_READWRITE, false)
707   (space)->unmap(start, end, mask, mirror, ROW_READWRITE, false)
708708#define memory_nop_readwrite(space, start, end, mask, mirror) \
709   const_cast<address_space *>(space)->unmap(start, end, mask, mirror, ROW_READWRITE, true)
709   (space)->unmap(start, end, mask, mirror, ROW_READWRITE, true)
710710
711711
712712
src/emu/machine/s3c2400.c
r10886r10887
4545
4646DEVICE_START( s3c2400 )
4747{
48   const address_space *space = cputag_get_address_space( device->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
48   address_space *space = cputag_get_address_space( device->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
4949   DEVICE_START_CALL(s3c24xx);
5050   memory_install_readwrite32_device_handler( space, device, 0x14000000, 0x1400003b, 0, 0, s3c24xx_memcon_r, s3c24xx_memcon_w);
5151   memory_install_readwrite32_device_handler( space, device, 0x14200000, 0x1420005b, 0, 0, s3c24xx_usb_host_r, s3c24xx_usb_host_w);
src/emu/machine/s3c2410.c
r10886r10887
4545
4646DEVICE_START( s3c2410 )
4747{
48   const address_space *space = cputag_get_address_space( device->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
48   address_space *space = cputag_get_address_space( device->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
4949   DEVICE_START_CALL(s3c24xx);
5050   memory_install_readwrite32_device_handler( space, device, 0x48000000, 0x4800003b, 0, 0, s3c24xx_memcon_r, s3c24xx_memcon_w);
5151   memory_install_readwrite32_device_handler( space, device, 0x49000000, 0x4900005b, 0, 0, s3c24xx_usb_host_r, s3c24xx_usb_host_w);
src/emu/machine/s3c2440.c
r10886r10887
4545
4646DEVICE_START( s3c2440 )
4747{
48   const address_space *space = cputag_get_address_space( device->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
48   address_space *space = cputag_get_address_space( device->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
4949   memory_install_readwrite32_device_handler( space, device, 0x48000000, 0x4800003b, 0, 0, s3c24xx_memcon_r, s3c24xx_memcon_w);
5050   memory_install_readwrite32_device_handler( space, device, 0x49000000, 0x4900005b, 0, 0, s3c24xx_usb_host_r, s3c24xx_usb_host_w);
5151   memory_install_readwrite32_device_handler( space, device, 0x4a000000, 0x4a00001f, 0, 0, s3c24xx_irq_r, s3c24xx_irq_w);
src/mess/drivers/vixen.c
r10886r10887
767767
768768void vixen_state::machine_reset()
769769{
770   const address_space *program = cpu_get_address_space(m_maincpu, ADDRESS_SPACE_PROGRAM);
770   address_space *program = cpu_get_address_space(m_maincpu, ADDRESS_SPACE_PROGRAM);
771771
772772   memory_install_read_bank(program, 0x0000, 0xefff, 0xfff, 0, "bank1");
773773   memory_install_write_bank(program, 0x0000, 0xefff, 0xfff, 0, "bank2");
r10886r10887
870870   {
871871      if (state->m_reset)
872872      {
873         const address_space *program = cpu_get_address_space(state->m_maincpu, ADDRESS_SPACE_PROGRAM);
873         address_space *program = cpu_get_address_space(state->m_maincpu, ADDRESS_SPACE_PROGRAM);
874874
875875         memory_install_read_bank(program, 0x0000, 0xefff, 0, 0, "bank1");
876876         memory_install_write_bank(program, 0x0000, 0xefff, 0, 0, "bank2");

Previous 15994 Revisions Next


© 1998-2018 The MESS Team