118
118
sub_state(running_machine &machine, const driver_device_config_base &config)
119
119
: driver_device(machine, config) { }
129
129
static VIDEO_START(sub)
133
static VIDEO_UPDATE(sub)
133
static SCREEN_UPDATE(sub)
135
sub_state *state = screen->machine->driver_data<sub_state>();
136
const gfx_element *gfx = screen->machine->gfx[0];
137
const gfx_element *gfx_1 = screen->machine->gfx[1];
135
sub_state *state = screen->machine().driver_data<sub_state>();
136
const gfx_element *gfx = screen->machine().gfx[0];
137
const gfx_element *gfx_1 = screen->machine().gfx[1];
143
143
for (x=0;x<32;x++)
145
UINT16 tile = state->vid[count];
145
UINT16 tile = state->m_vid[count];
147
UINT8 y_offs = state->scrolly[x];
147
UINT8 y_offs = state->m_scrolly[x];
149
tile += (state->attr[count]&0xe0)<<3;
150
col = (state->attr[count]&0x1f);
149
tile += (state->m_attr[count]&0xe0)<<3;
150
col = (state->m_attr[count]&0x1f);
152
152
drawgfx_opaque(bitmap,cliprect,gfx,tile,col+0x40,0,0,x*8,(y*8)-y_offs);
153
153
drawgfx_opaque(bitmap,cliprect,gfx,tile,col+0x40,0,0,x*8,(y*8)-y_offs+256);
168
168
1 --cc cccc color
171
UINT8 *spriteram = state->spriteram;
172
UINT8 *spriteram_2 = state->spriteram2;
171
UINT8 *spriteram = state->m_spriteram;
172
UINT8 *spriteram_2 = state->m_spriteram2;
173
173
UINT8 x,y,spr_offs,i,col,fx,fy;
175
175
for(i=0;i<0x40;i+=2)
194
194
for (x=0;x<32;x++)
196
UINT16 tile = state->vid[count];
196
UINT16 tile = state->m_vid[count];
198
UINT8 y_offs = state->scrolly[x];
198
UINT8 y_offs = state->m_scrolly[x];
200
tile += (state->attr[count]&0xe0)<<3;
201
col = (state->attr[count]&0x1f);
200
tile += (state->m_attr[count]&0xe0)<<3;
201
col = (state->m_attr[count]&0x1f);
216
static ADDRESS_MAP_START( subm_map, ADDRESS_SPACE_PROGRAM, 8 )
216
static ADDRESS_MAP_START( subm_map, AS_PROGRAM, 8 )
217
217
AM_RANGE(0x0000, 0xafff) AM_ROM
218
218
AM_RANGE(0xb000, 0xbfff) AM_RAM
219
AM_RANGE(0xc000, 0xc3ff) AM_RAM AM_BASE_MEMBER(sub_state,attr)
220
AM_RANGE(0xc400, 0xc7ff) AM_RAM AM_BASE_MEMBER(sub_state,vid)
221
AM_RANGE(0xd000, 0xd03f) AM_RAM AM_BASE_MEMBER(sub_state,spriteram)
222
AM_RANGE(0xd800, 0xd83f) AM_RAM AM_BASE_MEMBER(sub_state,spriteram2)
223
AM_RANGE(0xd840, 0xd85f) AM_RAM AM_BASE_MEMBER(sub_state,scrolly)
219
AM_RANGE(0xc000, 0xc3ff) AM_RAM AM_BASE_MEMBER(sub_state,m_attr)
220
AM_RANGE(0xc400, 0xc7ff) AM_RAM AM_BASE_MEMBER(sub_state,m_vid)
221
AM_RANGE(0xd000, 0xd03f) AM_RAM AM_BASE_MEMBER(sub_state,m_spriteram)
222
AM_RANGE(0xd800, 0xd83f) AM_RAM AM_BASE_MEMBER(sub_state,m_spriteram2)
223
AM_RANGE(0xd840, 0xd85f) AM_RAM AM_BASE_MEMBER(sub_state,m_scrolly)
225
225
AM_RANGE(0xe000, 0xe000) AM_NOP
226
226
AM_RANGE(0xe800, 0xe800) AM_NOP
238
238
static WRITE8_HANDLER( subm_to_sound_w )
240
240
soundlatch_w(space, 0, data & 0xff);
241
cputag_set_input_line(space->machine, "soundcpu", 0, HOLD_LINE);
241
cputag_set_input_line(space->machine(), "soundcpu", 0, HOLD_LINE);
244
244
static WRITE8_HANDLER( nmi_mask_w )
246
sub_state *state = space->machine->driver_data<sub_state>();
246
sub_state *state = space->machine().driver_data<sub_state>();
248
state->nmi_en = data & 1;
248
state->m_nmi_en = data & 1;
251
static ADDRESS_MAP_START( subm_io, ADDRESS_SPACE_IO, 8 )
251
static ADDRESS_MAP_START( subm_io, AS_IO, 8 )
252
252
ADDRESS_MAP_GLOBAL_MASK(0xff)
253
253
AM_RANGE(0x00, 0x00) AM_READWRITE(soundlatch2_r, subm_to_sound_w) // to/from sound CPU
256
static ADDRESS_MAP_START( subm_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
256
static ADDRESS_MAP_START( subm_sound_map, AS_PROGRAM, 8 )
257
257
AM_RANGE(0x0000, 0x3fff) AM_ROM
258
258
AM_RANGE(0x4000, 0x47ff) AM_RAM
259
259
AM_RANGE(0x6000, 0x6000) AM_WRITE(nmi_mask_w)
262
static ADDRESS_MAP_START( subm_sound_io, ADDRESS_SPACE_IO, 8 )
262
static ADDRESS_MAP_START( subm_sound_io, AS_IO, 8 )
263
263
ADDRESS_MAP_GLOBAL_MASK(0xff)
264
264
AM_RANGE(0x00, 0x00) AM_READWRITE(soundlatch_r, soundlatch2_w) // to/from main CPU
265
265
AM_RANGE(0x40, 0x41) AM_DEVREADWRITE("ay1", ay8910_r, ay8910_address_data_w)
381
381
static PALETTE_INIT( sub )
384
UINT8* lookup = machine->region("proms2")->base();
384
UINT8* lookup = machine.region("proms2")->base();
386
386
/* allocate the colortable */
387
machine->colortable = colortable_alloc(machine, 0x100);
387
machine.colortable = colortable_alloc(machine, 0x100);
389
389
for (i = 0;i < 0x100;i++)
393
393
g = (color_prom[0x100] >> 0);
394
394
b = (color_prom[0x200] >> 0);
396
//colortable_palette_set_color(machine->colortable, i, MAKE_RGB(r, g, b));
397
colortable_palette_set_color(machine->colortable, i, MAKE_RGB(pal4bit(r), pal4bit(g), pal4bit(b)));
396
//colortable_palette_set_color(machine.colortable, i, MAKE_RGB(r, g, b));
397
colortable_palette_set_color(machine.colortable, i, MAKE_RGB(pal4bit(r), pal4bit(g), pal4bit(b)));
403
403
for (i = 0;i < 0x400;i++)
405
405
UINT8 ctabentry = lookup[i+0x400] | (lookup[i+0x000] << 4);
406
colortable_entry_set_value(machine->colortable, i, ctabentry);
406
colortable_entry_set_value(machine.colortable, i, ctabentry);
412
412
static INTERRUPT_GEN( subm_sound_irq )
414
sub_state *state = device->machine->driver_data<sub_state>();
414
sub_state *state = device->machine().driver_data<sub_state>();
417
cputag_set_input_line(device->machine, "soundcpu", INPUT_LINE_NMI, PULSE_LINE);
417
cputag_set_input_line(device->machine(), "soundcpu", INPUT_LINE_NMI, PULSE_LINE);
420
420
static MACHINE_CONFIG_START( sub, sub_state )
438
438
MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
439
439
MCFG_SCREEN_SIZE(256, 256)
440
440
MCFG_SCREEN_VISIBLE_AREA(0, 256-1, 16, 256-16-1)
441
MCFG_SCREEN_UPDATE(sub)
442
443
MCFG_GFXDECODE(sub)
443
444
MCFG_PALETTE_LENGTH(0x400)
444
445
MCFG_PALETTE_INIT(sub)
446
447
MCFG_VIDEO_START(sub)
447
MCFG_VIDEO_UPDATE(sub)
449
449
/* sound hardware */
450
450
MCFG_SPEAKER_STANDARD_MONO("mono")