190
197
UINT32* m_sprite_regs32_1;
191
198
UINT32* m_sprite_regs32_2;
192
199
int m_irq_sub_enable;
193
UINT16 *m_spriteram_1;
195
UINT16 *m_spriteram_2;
197
UINT16 *m_mainsub_shared_ram;
200
required_shared_ptr<UINT16> m_spriteram_1;
201
required_shared_ptr<UINT16> m_sprregs_1;
202
required_shared_ptr<UINT16> m_spriteram_2;
203
required_shared_ptr<UINT16> m_sprregs_2;
204
required_shared_ptr<UINT16> m_mainsub_shared_ram;
198
205
UINT8 m_nvram_data[128];
206
required_shared_ptr<UINT16> m_mcu_ram;
200
207
UINT16 m_mcu_com[4];
208
required_shared_ptr<UINT16> m_ctrl;
203
210
required_device<cpu_device> m_maincpu;
204
211
required_device<cpu_device> m_subcpu;
205
212
sknsspr_device* m_spritegen1;
206
213
sknsspr_device* m_spritegen2;
214
DECLARE_WRITE16_MEMBER(jchan_mcu_com0_w);
215
DECLARE_WRITE16_MEMBER(jchan_mcu_com1_w);
216
DECLARE_WRITE16_MEMBER(jchan_mcu_com2_w);
217
DECLARE_WRITE16_MEMBER(jchan_mcu_com3_w);
218
DECLARE_READ16_MEMBER(jchan_mcu_status_r);
219
DECLARE_WRITE16_MEMBER(jchan_ctrl_w);
220
DECLARE_READ16_MEMBER(jchan_ctrl_r);
221
DECLARE_WRITE16_MEMBER(main2sub_cmd_w);
222
DECLARE_WRITE16_MEMBER(sub2main_cmd_w);
223
DECLARE_WRITE16_MEMBER(jchan_suprnova_sprite32_1_w);
224
DECLARE_WRITE16_MEMBER(jchan_suprnova_sprite32regs_1_w);
225
DECLARE_WRITE16_MEMBER(jchan_suprnova_sprite32_2_w);
226
DECLARE_WRITE16_MEMBER(jchan_suprnova_sprite32regs_2_w);
277
297
jchan_mcu_run(space->machine());
280
static WRITE16_HANDLER( jchan_mcu_com0_w ) { jchan_mcu_com_w(space, offset, data, mem_mask, 0); }
281
static WRITE16_HANDLER( jchan_mcu_com1_w ) { jchan_mcu_com_w(space, offset, data, mem_mask, 1); }
282
static WRITE16_HANDLER( jchan_mcu_com2_w ) { jchan_mcu_com_w(space, offset, data, mem_mask, 2); }
283
static WRITE16_HANDLER( jchan_mcu_com3_w ) { jchan_mcu_com_w(space, offset, data, mem_mask, 3); }
300
WRITE16_MEMBER(jchan_state::jchan_mcu_com0_w){ jchan_mcu_com_w(&space, offset, data, mem_mask, 0); }
301
WRITE16_MEMBER(jchan_state::jchan_mcu_com1_w){ jchan_mcu_com_w(&space, offset, data, mem_mask, 1); }
302
WRITE16_MEMBER(jchan_state::jchan_mcu_com2_w){ jchan_mcu_com_w(&space, offset, data, mem_mask, 2); }
303
WRITE16_MEMBER(jchan_state::jchan_mcu_com3_w){ jchan_mcu_com_w(&space, offset, data, mem_mask, 3); }
285
static READ16_HANDLER( jchan_mcu_status_r )
305
READ16_MEMBER(jchan_state::jchan_mcu_status_r)
287
logerror("cpu '%s' (PC=%06X): read mcu status\n", space->device().tag(), cpu_get_previouspc(&space->device()));
307
logerror("cpu '%s' (PC=%06X): read mcu status\n", space.device().tag(), cpu_get_previouspc(&space.device()));
444
463
***************************************************************************/
446
465
/* communications - hacky! */
447
static WRITE16_HANDLER( main2sub_cmd_w )
466
WRITE16_MEMBER(jchan_state::main2sub_cmd_w)
449
jchan_state *state = space->machine().driver_data<jchan_state>();
450
COMBINE_DATA(&state->m_mainsub_shared_ram[0x03ffe/2]);
451
cputag_set_input_line(space->machine(), "sub", 4, HOLD_LINE);
469
COMBINE_DATA(&m_mainsub_shared_ram[0x03ffe/2]);
470
cputag_set_input_line(machine(), "sub", 4, HOLD_LINE);
454
473
// is this called?
455
static WRITE16_HANDLER( sub2main_cmd_w )
474
WRITE16_MEMBER(jchan_state::sub2main_cmd_w)
457
jchan_state *state = space->machine().driver_data<jchan_state>();
458
COMBINE_DATA(&state->m_mainsub_shared_ram[0x0000/2]);
459
cputag_set_input_line(space->machine(), "maincpu", 3, HOLD_LINE);
477
COMBINE_DATA(&m_mainsub_shared_ram[0x0000/2]);
478
cputag_set_input_line(machine(), "maincpu", 3, HOLD_LINE);
462
481
/* ram convert for suprnova (requires 32-bit stuff) */
463
static WRITE16_HANDLER( jchan_suprnova_sprite32_1_w )
465
jchan_state *state = space->machine().driver_data<jchan_state>();
466
COMBINE_DATA(&state->m_spriteram_1[offset]);
468
state->m_sprite_ram32_1[offset]=(state->m_spriteram_1[offset*2+1]<<16) | (state->m_spriteram_1[offset*2]);
471
static WRITE16_HANDLER( jchan_suprnova_sprite32regs_1_w )
473
jchan_state *state = space->machine().driver_data<jchan_state>();
474
COMBINE_DATA(&state->m_sprregs_1[offset]);
476
state->m_sprite_regs32_1[offset]=(state->m_sprregs_1[offset*2+1]<<16) | (state->m_sprregs_1[offset*2]);
479
static WRITE16_HANDLER( jchan_suprnova_sprite32_2_w )
481
jchan_state *state = space->machine().driver_data<jchan_state>();
482
COMBINE_DATA(&state->m_spriteram_2[offset]);
484
state->m_sprite_ram32_2[offset]=(state->m_spriteram_2[offset*2+1]<<16) | (state->m_spriteram_2[offset*2]);
487
static WRITE16_HANDLER( jchan_suprnova_sprite32regs_2_w )
489
jchan_state *state = space->machine().driver_data<jchan_state>();
490
COMBINE_DATA(&state->m_sprregs_2[offset]);
492
state->m_sprite_regs32_2[offset]=(state->m_sprregs_2[offset*2+1]<<16) | (state->m_sprregs_2[offset*2]);
496
static ADDRESS_MAP_START( jchan_main, AS_PROGRAM, 16 )
482
WRITE16_MEMBER(jchan_state::jchan_suprnova_sprite32_1_w)
485
COMBINE_DATA(&m_spriteram_1[offset]);
487
m_sprite_ram32_1[offset]=(m_spriteram_1[offset*2+1]<<16) | (m_spriteram_1[offset*2]);
490
WRITE16_MEMBER(jchan_state::jchan_suprnova_sprite32regs_1_w)
493
COMBINE_DATA(&m_sprregs_1[offset]);
495
m_sprite_regs32_1[offset]=(m_sprregs_1[offset*2+1]<<16) | (m_sprregs_1[offset*2]);
498
WRITE16_MEMBER(jchan_state::jchan_suprnova_sprite32_2_w)
501
COMBINE_DATA(&m_spriteram_2[offset]);
503
m_sprite_ram32_2[offset]=(m_spriteram_2[offset*2+1]<<16) | (m_spriteram_2[offset*2]);
506
WRITE16_MEMBER(jchan_state::jchan_suprnova_sprite32regs_2_w)
509
COMBINE_DATA(&m_sprregs_2[offset]);
511
m_sprite_regs32_2[offset]=(m_sprregs_2[offset*2+1]<<16) | (m_sprregs_2[offset*2]);
515
static ADDRESS_MAP_START( jchan_main, AS_PROGRAM, 16, jchan_state )
497
516
AM_RANGE(0x000000, 0x1fffff) AM_ROM
498
517
AM_RANGE(0x200000, 0x20ffff) AM_RAM // Work RAM - [A] grid tested, cleared ($9d6-$a54)
500
AM_RANGE(0x300000, 0x30ffff) AM_RAM AM_BASE_MEMBER(jchan_state, m_mcu_ram) // MCU [G] grid tested, cleared ($a5a-$ad8)
519
AM_RANGE(0x300000, 0x30ffff) AM_RAM AM_SHARE("mcu_ram") // MCU [G] grid tested, cleared ($a5a-$ad8)
501
520
AM_RANGE(0x330000, 0x330001) AM_WRITE(jchan_mcu_com0_w) // _[ these 2 are set to 0xFFFF
502
521
AM_RANGE(0x340000, 0x340001) AM_WRITE(jchan_mcu_com1_w) // [ to trigger mcu to run cmd ?
503
522
AM_RANGE(0x350000, 0x350001) AM_WRITE(jchan_mcu_com2_w) // _[ these 2 are set to 0xFFFF
504
523
AM_RANGE(0x360000, 0x360001) AM_WRITE(jchan_mcu_com3_w) // [ for mcu to return its status ?
505
524
AM_RANGE(0x370000, 0x370001) AM_READ(jchan_mcu_status_r)
507
AM_RANGE(0x400000, 0x403fff) AM_RAM AM_BASE_MEMBER(jchan_state, m_mainsub_shared_ram) AM_SHARE("share1")
526
AM_RANGE(0x400000, 0x403fff) AM_RAM AM_SHARE("mainsub_shared")
509
528
/* 1st sprite layer */
510
AM_RANGE(0x500000, 0x503fff) AM_RAM_WRITE(jchan_suprnova_sprite32_1_w) AM_BASE_MEMBER(jchan_state, m_spriteram_1)
511
AM_RANGE(0x600000, 0x60003f) AM_RAM_WRITE(jchan_suprnova_sprite32regs_1_w) AM_BASE_MEMBER(jchan_state, m_sprregs_1)
513
AM_RANGE(0x700000, 0x70ffff) AM_RAM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE_GENERIC(paletteram) // palette for sprites?
515
AM_RANGE(0xf00000, 0xf00007) AM_READWRITE(jchan_ctrl_r, jchan_ctrl_w) AM_BASE_MEMBER(jchan_state, m_ctrl)
529
AM_RANGE(0x500000, 0x503fff) AM_RAM_WRITE(jchan_suprnova_sprite32_1_w) AM_SHARE("spriteram_1")
530
AM_RANGE(0x600000, 0x60003f) AM_RAM_WRITE(jchan_suprnova_sprite32regs_1_w) AM_SHARE("sprregs_1")
532
AM_RANGE(0x700000, 0x70ffff) AM_RAM_WRITE(paletteram_xGGGGGRRRRRBBBBB_word_w) AM_SHARE("paletteram") // palette for sprites?
534
AM_RANGE(0xf00000, 0xf00007) AM_READWRITE(jchan_ctrl_r, jchan_ctrl_w) AM_SHARE("ctrl")
517
536
AM_RANGE(0xf80000, 0xf80001) AM_READWRITE(watchdog_reset16_r, watchdog_reset16_w) // watchdog
521
static ADDRESS_MAP_START( jchan_sub, AS_PROGRAM, 16 )
540
static ADDRESS_MAP_START( jchan_sub, AS_PROGRAM, 16, jchan_state )
522
541
AM_RANGE(0x000000, 0x0fffff) AM_ROM
523
542
AM_RANGE(0x100000, 0x10ffff) AM_RAM // Work RAM - grid tested, cleared ($612-$6dc)
525
AM_RANGE(0x400000, 0x403fff) AM_RAM AM_BASE_MEMBER(jchan_state, m_mainsub_shared_ram) AM_SHARE("share1")
544
AM_RANGE(0x400000, 0x403fff) AM_RAM AM_SHARE("mainsub_shared")
527
546
/* VIEW2 Tilemap - [D] grid tested, cleared ($1d84), also cleared at startup ($810-$826) */
528
AM_RANGE(0x500000, 0x500fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_BASE_MEMBER(jchan_state, m_vram[1]) // Layers 0
529
AM_RANGE(0x501000, 0x501fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_BASE_MEMBER(jchan_state, m_vram[0]) //
530
AM_RANGE(0x502000, 0x502fff) AM_RAM AM_BASE_MEMBER(jchan_state, m_vscroll[1]) //
531
AM_RANGE(0x503000, 0x503fff) AM_RAM AM_BASE_MEMBER(jchan_state, m_vscroll[0]) //
532
AM_RANGE(0x600000, 0x60001f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_BASE_MEMBER(jchan_state, m_layers_0_regs) // Layers 0 Regs
547
AM_RANGE(0x500000, 0x500fff) AM_RAM_WRITE(kaneko16_vram_1_w) AM_SHARE("vram.1") // Layers 0
548
AM_RANGE(0x501000, 0x501fff) AM_RAM_WRITE(kaneko16_vram_0_w) AM_SHARE("vram.0") //
549
AM_RANGE(0x502000, 0x502fff) AM_RAM AM_SHARE("vscroll.1") //
550
AM_RANGE(0x503000, 0x503fff) AM_RAM AM_SHARE("vscroll.0") //
551
AM_RANGE(0x600000, 0x60001f) AM_RAM_WRITE(kaneko16_layers_0_regs_w) AM_SHARE("layers_0_regs") // Layers 0 Regs
534
553
/* background prites */
535
AM_RANGE(0x700000, 0x703fff) AM_RAM_WRITE(jchan_suprnova_sprite32_2_w) AM_BASE_MEMBER(jchan_state, m_spriteram_2)
536
AM_RANGE(0x780000, 0x78003f) AM_RAM_WRITE(jchan_suprnova_sprite32regs_2_w) AM_BASE_MEMBER(jchan_state, m_sprregs_2)
554
AM_RANGE(0x700000, 0x703fff) AM_RAM_WRITE(jchan_suprnova_sprite32_2_w) AM_SHARE("spriteram_2")
555
AM_RANGE(0x780000, 0x78003f) AM_RAM_WRITE(jchan_suprnova_sprite32regs_2_w) AM_SHARE("sprregs_2")
538
AM_RANGE(0x800000, 0x800003) AM_DEVWRITE8("ymz", ymz280b_w, 0x00ff) // sound
557
AM_RANGE(0x800000, 0x800003) AM_DEVWRITE8_LEGACY("ymz", ymz280b_w, 0x00ff) // sound
540
559
AM_RANGE(0xa00000, 0xa00001) AM_READWRITE(watchdog_reset16_r, watchdog_reset16_w) // watchdog
597
616
PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
599
618
PORT_START("EXTRA") /* $f00006.b */
600
PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(1) PORT_CONDITION("DSW",0x8000,PORTCOND_EQUALS,0x8000)
601
PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_CONDITION("DSW",0x8000,PORTCOND_EQUALS,0x8000)
602
PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(2) PORT_CONDITION("DSW",0x8000,PORTCOND_EQUALS,0x8000)
603
PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_CONDITION("DSW",0x8000,PORTCOND_EQUALS,0x8000)
604
PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) PORT_CONDITION("DSW",0x8000,PORTCOND_EQUALS,0x0000)
605
PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(1) PORT_CONDITION("DSW",0x8000,PORTCOND_EQUALS,0x0000)
606
PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2) PORT_CONDITION("DSW",0x8000,PORTCOND_EQUALS,0x0000)
607
PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(2) PORT_CONDITION("DSW",0x8000,PORTCOND_EQUALS,0x0000)
619
PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(1) PORT_CONDITION("DSW",0x8000,EQUALS,0x8000)
620
PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_CONDITION("DSW",0x8000,EQUALS,0x8000)
621
PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(2) PORT_CONDITION("DSW",0x8000,EQUALS,0x8000)
622
PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_CONDITION("DSW",0x8000,EQUALS,0x8000)
623
PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) PORT_CONDITION("DSW",0x8000,EQUALS,0x0000)
624
PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(1) PORT_CONDITION("DSW",0x8000,EQUALS,0x0000)
625
PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2) PORT_CONDITION("DSW",0x8000,EQUALS,0x0000)
626
PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(2) PORT_CONDITION("DSW",0x8000,EQUALS,0x0000)
608
627
PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* duplicated Player 1 Button 4 (whatever the layout is) */
609
628
PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* duplicated Player 2 Button 4 (whatever the layout is) */
610
629
PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )