diff options
| author | 2009-12-22 14:49:27 +0000 | |
|---|---|---|
| committer | 2009-12-22 14:49:27 +0000 | |
| commit | ff7213f6f104b2547cbb45df82ff23735371258b (patch) | |
| tree | f26f612c01a1e3a147657a68e1517045ae8c0b02 | |
| parent | 30dff4284af06e651c5d1302e7b359d02cc8695d (diff) | |
Added save states to ics2115 sound device
Added driver data struct and save states to psikyo.c and pgm.c
Added driver data struct to psikyo4.c and psikyosh.c
| -rw-r--r-- | .gitattributes | 2 | ||||
| -rw-r--r-- | src/emu/sound/ics2115.c | 195 | ||||
| -rw-r--r-- | src/mame/drivers/pgm.c | 2018 | ||||
| -rw-r--r-- | src/mame/drivers/psikyo.c | 978 | ||||
| -rw-r--r-- | src/mame/drivers/psikyo4.c | 354 | ||||
| -rw-r--r-- | src/mame/drivers/psikyosh.c | 231 | ||||
| -rw-r--r-- | src/mame/includes/pgm.h | 91 | ||||
| -rw-r--r-- | src/mame/includes/psikyo.h | 53 | ||||
| -rw-r--r-- | src/mame/includes/psikyo4.h | 37 | ||||
| -rw-r--r-- | src/mame/includes/psikyosh.h | 55 | ||||
| -rw-r--r-- | src/mame/machine/pgmprot.c | 663 | ||||
| -rw-r--r-- | src/mame/video/pgm.c | 280 | ||||
| -rw-r--r-- | src/mame/video/psikyo.c | 610 | ||||
| -rw-r--r-- | src/mame/video/psikyo4.c | 70 | ||||
| -rw-r--r-- | src/mame/video/psikyosh.c | 704 |
15 files changed, 3361 insertions, 2980 deletions
diff --git a/.gitattributes b/.gitattributes index e5d0741c3f6..18439c0621e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2637,6 +2637,8 @@ src/mame/includes/policetr.h svneol=native#text/plain src/mame/includes/polyplay.h svneol=native#text/plain src/mame/includes/poolshrk.h svneol=native#text/plain src/mame/includes/popper.h svneol=native#text/plain +src/mame/includes/psikyo.h svneol=native#text/plain +src/mame/includes/psikyo4.h svneol=native#text/plain src/mame/includes/psikyosh.h svneol=native#text/plain src/mame/includes/psx.h svneol=native#text/plain src/mame/includes/qix.h svneol=native#text/plain diff --git a/src/emu/sound/ics2115.c b/src/emu/sound/ics2115.c index ea217f60eeb..175017945c6 100644 --- a/src/emu/sound/ics2115.c +++ b/src/emu/sound/ics2115.c @@ -80,15 +80,16 @@ INLINE ics2115_state *get_safe_token(const device_config *device) static void recalc_irq(ics2115_state *chip) { int i; - int irq = 0; - if(chip->irq_en & chip->irq_pend) + int irq = 0; + if (chip->irq_en & chip->irq_pend) irq = 1; - for(i=0; !irq && i<32; i++) - if(chip->voice[i].state & V_DONE) + for (i = 0; !irq && i<32; i++) + if (chip->voice[i].state & V_DONE) irq = 1; - if(irq != chip->irq_on) { + if (irq != chip->irq_on) + { chip->irq_on = irq; - if(chip->intf->irq_cb) + if (chip->intf->irq_cb) chip->intf->irq_cb(chip->device, irq ? ASSERT_LINE : CLEAR_LINE); } } @@ -103,8 +104,9 @@ static STREAM_UPDATE( update ) memset(outputs[0], 0, samples*sizeof(*outputs[0])); memset(outputs[1], 0, samples*sizeof(*outputs[0])); - for(osc = 0; osc < 32; osc++) - if(chip->voice[osc].state & V_ON) { + for (osc = 0; osc < 32; osc++) + if (chip->voice[osc].state & V_ON) + { UINT32 adr = (chip->voice[osc].addrh << 16) | chip->voice[osc].addrl; UINT32 end = (chip->voice[osc].endh << 16) | (chip->voice[osc].endl << 8); UINT32 loop = (chip->voice[osc].strth << 16) | (chip->voice[osc].strtl << 8); @@ -117,9 +119,10 @@ static STREAM_UPDATE( update ) if (ICS2115LOGERROR) logerror("ICS2115: KEYRUN %02d adr=%08x end=%08x delta=%08x\n", osc, adr, end, delta); - for(i=0; i<samples; i++) { + for (i = 0; i < samples; i++) + { INT32 v = chip->rom[badr|(adr >> 12)]; - if(conf & 1) + if (conf & 1) v = chip->ulaw[v]; else v = ((INT8)v) << 6; @@ -128,7 +131,8 @@ static STREAM_UPDATE( update ) outputs[0][i] += v; outputs[1][i] += v; adr += delta; - if(adr >= end) { + if (adr >= end) + { if (ICS2115LOGERROR) logerror("ICS2115: KEYDONE %2d\n", osc); adr -= (end-loop); chip->voice[osc].state &= ~V_ON; @@ -140,24 +144,24 @@ static STREAM_UPDATE( update ) chip->voice[osc].addrh = adr >> 16; chip->voice[osc].addrl = adr; } - if(rec_irq) + if (rec_irq) recalc_irq(chip); } static void keyon(ics2115_state *chip, int osc) { if (ICS2115LOGERROR) logerror("ICS2115: KEYON %2d conf:%02x vctl:%02x a:%07x.%03x l:%05x.%x e:%05x.%x v:%03x f:%d\n", - osc, - chip->voice[chip->osc].conf, - chip->voice[chip->osc].vctl, - (chip->voice[osc].saddr << 20)|(chip->voice[osc].addrh << 4)|(chip->voice[osc].addrl >> 12), - (chip->voice[osc].addrl >> 3) & 0x1ff, - (chip->voice[osc].strth << 4)|(chip->voice[osc].strtl >> 4), - chip->voice[osc].strtl & 0xf, - (chip->voice[osc].endh << 4)|(chip->voice[osc].endl >> 4), - chip->voice[osc].endl & 0xf, - chip->voice[osc].volacc>>4, - (chip->voice[chip->osc].fc*33075+512)/1024); + osc, + chip->voice[chip->osc].conf, + chip->voice[chip->osc].vctl, + (chip->voice[osc].saddr << 20)|(chip->voice[osc].addrh << 4)|(chip->voice[osc].addrl >> 12), + (chip->voice[osc].addrl >> 3) & 0x1ff, + (chip->voice[osc].strth << 4)|(chip->voice[osc].strtl >> 4), + chip->voice[osc].strtl & 0xf, + (chip->voice[osc].endh << 4)|(chip->voice[osc].endl >> 4), + chip->voice[osc].endl & 0xf, + chip->voice[osc].volacc>>4, + (chip->voice[chip->osc].fc*33075+512)/1024); chip->voice[osc].state |= V_ON; } @@ -179,9 +183,10 @@ static TIMER_CALLBACK( timer_cb_1 ) static void recalc_timer(ics2115_state *chip, int timer) { UINT64 period = 1000000000 * chip->timer[timer].scale*chip->timer[timer].preset / 33868800; - if(period) + if (period) period = 1000000000/62.8206; - if(period) + + if (period) { if (ICS2115LOGERROR) logerror("ICS2115: timer %d freq=%fHz\n", timer, 1.0/(period / 1000000000.0)); } @@ -190,9 +195,10 @@ static void recalc_timer(ics2115_state *chip, int timer) if (ICS2115LOGERROR) logerror("ICS2115: timer %d off\n", timer); } - if(chip->timer[timer].period != period) { + if (chip->timer[timer].period != period) + { chip->timer[timer].period = period; - if(period) + if (period) timer_adjust_periodic(chip->timer[timer].timer, ATTOTIME_IN_NSEC(period), 0, ATTOTIME_IN_NSEC(period)); else timer_adjust_oneshot(chip->timer[timer].timer, attotime_never, 0); @@ -204,9 +210,11 @@ static void ics2115_reg_w(ics2115_state *chip, UINT8 reg, UINT8 data, int msb) { running_machine *machine = chip->device->machine; - switch(reg) { + switch (reg) + { case 0x00: // [osc] Oscillator Configuration - if(msb) { + if (msb) + { chip->voice[chip->osc].conf = data; if (ICS2115LOGERROR) logerror("%s:ICS2115: %2d: conf = %02x\n", cpuexec_describe_context(machine), chip->osc, chip->voice[chip->osc].conf); @@ -215,7 +223,7 @@ static void ics2115_reg_w(ics2115_state *chip, UINT8 reg, UINT8 data, int msb) case 0x01: // [osc] Wavesample frequency // freq = fc*33075/1024 in 32 voices mode, fc*44100/1024 in 24 voices mode - if(msb) + if (msb) chip->voice[chip->osc].fc = (chip->voice[chip->osc].fc & 0xff)|(data << 8); else chip->voice[chip->osc].fc = (chip->voice[chip->osc].fc & 0xff00)|data; @@ -224,7 +232,7 @@ static void ics2115_reg_w(ics2115_state *chip, UINT8 reg, UINT8 data, int msb) break; case 0x02: // [osc] Wavesample loop start address 19-4 - if(msb) + if (msb) chip->voice[chip->osc].strth = (chip->voice[chip->osc].strth & 0xff)|(data << 8); else chip->voice[chip->osc].strth = (chip->voice[chip->osc].strth & 0xff00)|data; @@ -233,7 +241,8 @@ static void ics2115_reg_w(ics2115_state *chip, UINT8 reg, UINT8 data, int msb) break; case 0x03: // [osc] Wavesample loop start address 3-0.3-0 - if(msb) { + if (msb) + { chip->voice[chip->osc].strtl = data; if (ICS2115LOGERROR) logerror("%s:ICS2115: %2d: strtl = %02x\n", cpuexec_describe_context(machine), chip->osc, chip->voice[chip->osc].strtl); @@ -241,7 +250,7 @@ static void ics2115_reg_w(ics2115_state *chip, UINT8 reg, UINT8 data, int msb) break; case 0x04: // [osc] Wavesample loop end address 19-4 - if(msb) + if (msb) chip->voice[chip->osc].endh = (chip->voice[chip->osc].endh & 0xff)|(data << 8); else chip->voice[chip->osc].endh = (chip->voice[chip->osc].endh & 0xff00)|data; @@ -250,7 +259,8 @@ static void ics2115_reg_w(ics2115_state *chip, UINT8 reg, UINT8 data, int msb) break; case 0x05: // [osc] Wavesample loop end address 3-0.3-0 - if(msb) { + if (msb) + { chip->voice[chip->osc].endl = data; if (ICS2115LOGERROR) logerror("%s:ICS2115: %2d: endl = %02x\n", cpuexec_describe_context(machine), chip->osc, chip->voice[chip->osc].endl); @@ -258,7 +268,8 @@ static void ics2115_reg_w(ics2115_state *chip, UINT8 reg, UINT8 data, int msb) break; case 0x07: // [osc] Volume Start - if(msb) { + if (msb) + { chip->voice[chip->osc].vstart = data; if (ICS2115LOGERROR) logerror("%s:ICS2115: %2d: vstart = %02x\n", cpuexec_describe_context(machine), chip->osc, chip->voice[chip->osc].vstart); @@ -266,7 +277,8 @@ static void ics2115_reg_w(ics2115_state *chip, UINT8 reg, UINT8 data, int msb) break; case 0x08: // [osc] Volume End - if(msb) { + if (msb) + { chip->voice[chip->osc].vend = data; if (ICS2115LOGERROR) logerror("%s:ICS2115: %2d: vend = %02x\n", cpuexec_describe_context(machine), chip->osc, chip->voice[chip->osc].vend); @@ -274,7 +286,7 @@ static void ics2115_reg_w(ics2115_state *chip, UINT8 reg, UINT8 data, int msb) break; case 0x09: // [osc] Volume accumulator - if(msb) + if (msb) chip->voice[chip->osc].volacc = (chip->voice[chip->osc].volacc & 0xff)|(data << 8); else chip->voice[chip->osc].volacc = (chip->voice[chip->osc].volacc & 0xff00)|data; @@ -283,7 +295,7 @@ static void ics2115_reg_w(ics2115_state *chip, UINT8 reg, UINT8 data, int msb) break; case 0x0a: // [osc] Wavesample address 19-4 - if(msb) + if (msb) chip->voice[chip->osc].addrh = (chip->voice[chip->osc].addrh & 0xff)|(data << 8); else chip->voice[chip->osc].addrh = (chip->voice[chip->osc].addrh & 0xff00)|data; @@ -292,7 +304,7 @@ static void ics2115_reg_w(ics2115_state *chip, UINT8 reg, UINT8 data, int msb) break; case 0x0b: // [osc] Wavesample address 3-0.8-0 - if(msb) + if (msb) chip->voice[chip->osc].addrl = (chip->voice[chip->osc].addrl & 0xff)|(data << 8); else chip->voice[chip->osc].addrl = (chip->voice[chip->osc].addrl & 0xff00)|data; @@ -302,7 +314,8 @@ static void ics2115_reg_w(ics2115_state *chip, UINT8 reg, UINT8 data, int msb) case 0x0c: // [osc] Pan - if(msb) { + if (msb) + { chip->voice[chip->osc].pan = data; if (ICS2115LOGERROR) logerror("%s:ICS2115: %2d: pan = %02x\n", cpuexec_describe_context(machine), chip->osc, chip->voice[chip->osc].pan); @@ -310,7 +323,8 @@ static void ics2115_reg_w(ics2115_state *chip, UINT8 reg, UINT8 data, int msb) break; case 0x0d: // [osc] Volume Enveloppe Control - if(msb) { + if (msb) + { chip->voice[chip->osc].vctl = data; if (ICS2115LOGERROR) logerror("%s:ICS2115: %2d: vctl = %02x\n", cpuexec_describe_context(machine), chip->osc, chip->voice[chip->osc].vctl); @@ -318,17 +332,19 @@ static void ics2115_reg_w(ics2115_state *chip, UINT8 reg, UINT8 data, int msb) break; case 0x10: // [osc] Oscillator Control - if(msb) { + if (msb) + { chip->voice[chip->osc].ctl = data; if (ICS2115LOGERROR) logerror("%s:ICS2115: %2d: ctl = %02x\n", cpuexec_describe_context(machine), chip->osc, chip->voice[chip->osc].ctl); - if(data == 0) + if (data == 0) keyon(chip, chip->osc); } break; case 0x11: // [osc] Wavesample static address 27-20 - if(msb) { + if (msb) + { chip->voice[chip->osc].saddr = data; if (ICS2115LOGERROR) logerror("%s:ICS2115: %2d: saddr = %02x\n", cpuexec_describe_context(machine), chip->osc, chip->voice[chip->osc].saddr); @@ -336,7 +352,8 @@ static void ics2115_reg_w(ics2115_state *chip, UINT8 reg, UINT8 data, int msb) break; case 0x40: // Timer 1 Preset - if(!msb) { + if (!msb) + { chip->timer[0].preset = data; if (ICS2115LOGERROR) logerror("%s:ICS2115: t1preset = %d\n", cpuexec_describe_context(machine), chip->timer[0].preset); recalc_timer(chip, 0); @@ -344,7 +361,8 @@ static void ics2115_reg_w(ics2115_state *chip, UINT8 reg, UINT8 data, int msb) break; case 0x41: // Timer 2 Preset - if(!msb) { + if (!msb) + { chip->timer[1].preset = data; if (ICS2115LOGERROR) logerror("%s:ICS2115: t2preset = %d\n", cpuexec_describe_context(machine), chip->timer[1].preset); recalc_timer(chip, 1); @@ -352,7 +370,8 @@ static void ics2115_reg_w(ics2115_state *chip, UINT8 reg, UINT8 data, int msb) break; case 0x42: // Timer 1 Prescaler - if(!msb) { + if (!msb) + { chip->timer[0].scale = data; if (ICS2115LOGERROR) logerror("%s:ICS2115: t1scale = %d\n", cpuexec_describe_context(machine), chip->timer[0].scale); recalc_timer(chip, 0); @@ -360,7 +379,8 @@ static void ics2115_reg_w(ics2115_state *chip, UINT8 reg, UINT8 data, int msb) break; case 0x43: // Timer 2 Prescaler - if(!msb) { + if (!msb) + { chip->timer[1].scale = data; if (ICS2115LOGERROR) logerror("%s:ICS2115: t2scale = %d\n", cpuexec_describe_context(machine), chip->timer[1].scale); recalc_timer(chip, 1); @@ -368,7 +388,8 @@ static void ics2115_reg_w(ics2115_state *chip, UINT8 reg, UINT8 data, int msb) break; case 0x4a: // IRQ Enable - if(!msb) { + if (!msb) + { chip->irq_en = data; if (ICS2115LOGERROR) logerror("%s:ICS2115: irq_en = %02x\n", cpuexec_describe_context(machine), chip->irq_en); recalc_irq(chip); @@ -376,7 +397,8 @@ static void ics2115_reg_w(ics2115_state *chip, UINT8 reg, UINT8 data, int msb) break; case 0x4f: // Oscillator Address being Programmed - if(!msb) { + if (!msb) + { chip->osc = data & 31; if (ICS2115LOGERROR) logerror("%s:ICS2115: oscnumber = %d\n", cpuexec_describe_context(machine), chip->osc); } @@ -391,7 +413,8 @@ static UINT16 ics2115_reg_r(ics2115_state *chip, UINT8 reg) { running_machine *machine = chip->device->machine; - switch(reg) { + switch (reg) + { case 0x0d: // [osc] Volume Enveloppe Control if (ICS2115LOGERROR) logerror("%s:ICS2115: %2d: read vctl\n", cpuexec_describe_context(machine), chip->osc); // res = chip->voice[chip->osc].vctl << 8; @@ -402,8 +425,9 @@ static UINT16 ics2115_reg_r(ics2115_state *chip, UINT8 reg) case 0x0f:{// [osc] Interrupt source/oscillator int osc; UINT8 res = 0xff; - for(osc = 0; osc < 32; osc++) - if(chip->voice[osc].state & V_DONE) { + for (osc = 0; osc < 32; osc++) + if (chip->voice[osc].state & V_DONE) + { chip->voice[osc].state &= ~V_DONE; if (ICS2115LOGERROR) logerror("ICS2115: KEYOFF %2d\n", osc); recalc_irq(chip); @@ -452,7 +476,7 @@ static UINT16 ics2115_reg_r(ics2115_state *chip, UINT8 reg) static DEVICE_START( ics2115 ) { ics2115_state *chip = get_safe_token(device); - int i; + int i, vv; chip->device = device; chip->intf = (const ics2115_interface *)device->static_config; @@ -462,32 +486,68 @@ static DEVICE_START( ics2115 ) chip->ulaw = auto_alloc_array(device->machine, INT16, 256); chip->stream = stream_create(device, 0, 2, 33075, chip, update); - for(i=0; i<256; i++) { + for (i = 0; i < 256; i++) + { UINT8 c = ~i; int v; v = ((c & 15) << 1) + 33; v <<= ((c & 0x70) >> 4); - if(c & 0x80) - v = 33-v; + if (c & 0x80) + v = 33 - v; else - v = v-33; + v = v - 33; chip->ulaw[i] = v; } + + state_save_register_device_item(device, 0, chip->timer[0].period); + state_save_register_device_item(device, 0, chip->timer[0].scale); + state_save_register_device_item(device, 0, chip->timer[0].preset); + state_save_register_device_item(device, 0, chip->timer[1].period); + state_save_register_device_item(device, 0, chip->timer[1].scale); + state_save_register_device_item(device, 0, chip->reg); + state_save_register_device_item(device, 0, chip->osc); + state_save_register_device_item(device, 0, chip->irq_en); + state_save_register_device_item(device, 0, chip->irq_pend); + state_save_register_device_item(device, 0, chip->irq_on); + + for (vv = 0; vv < 32; vv++) + { + state_save_register_device_item(device, vv, chip->voice[vv].fc); + state_save_register_device_item(device, vv, chip->voice[vv].addrh); + state_save_register_device_item(device, vv, chip->voice[vv].addrl); + state_save_register_device_item(device, vv, chip->voice[vv].strth); + state_save_register_device_item(device, vv, chip->voice[vv].endh); + state_save_register_device_item(device, vv, chip->voice[vv].volacc); + state_save_register_device_item(device, vv, chip->voice[vv].strtl); + state_save_register_device_item(device, vv, chip->voice[vv].endl); + state_save_register_device_item(device, vv, chip->voice[vv].saddr); + state_save_register_device_item(device, vv, chip->voice[vv].pan); + state_save_register_device_item(device, vv, chip->voice[vv].conf); + state_save_register_device_item(device, vv, chip->voice[vv].ctl); + state_save_register_device_item(device, vv, chip->voice[vv].vstart); + state_save_register_device_item(device, vv, chip->voice[vv].vend); + state_save_register_device_item(device, vv, chip->voice[vv].vctl); + state_save_register_device_item(device, vv, chip->voice[vv].state); + } } READ8_DEVICE_HANDLER( ics2115_r ) { ics2115_state *chip = get_safe_token(device); - switch(offset) { - case 0: { + switch (offset) + { + case 0: + { UINT8 res = 0; - if(chip->irq_on) { + if (chip->irq_on) + { int i; res |= 0x80; - if(chip->irq_en & chip->irq_pend & 3) + if (chip->irq_en & chip->irq_pend & 3) res |= 1; // Timer irq - for(i=0; i<32; i++) - if(chip->voice[i].state & V_DONE) { + for (i = 0; i < 32; i++) + if (chip->voice[i].state & V_DONE) + { res |= 2; break; } @@ -497,7 +557,7 @@ READ8_DEVICE_HANDLER( ics2115_r ) return res; } case 1: - return chip->reg; + return chip->reg; case 2: return ics2115_reg_r(chip, chip->reg); case 3: @@ -509,7 +569,8 @@ READ8_DEVICE_HANDLER( ics2115_r ) WRITE8_DEVICE_HANDLER( ics2115_w ) { ics2115_state *chip = get_safe_token(device); - switch(offset) { + switch (offset) + { case 1: chip->reg = data; break; @@ -537,8 +598,6 @@ static DEVICE_RESET( ics2115 ) } - - /************************************************************************** * Generic get_info **************************************************************************/ diff --git a/src/mame/drivers/pgm.c b/src/mame/drivers/pgm.c index 9bf62714033..c38c3c3a056 100644 --- a/src/mame/drivers/pgm.c +++ b/src/mame/drivers/pgm.c @@ -291,111 +291,137 @@ Notes: #include "cpu/arm7/arm7core.h" #include "includes/pgm.h" - -UINT16 *pgm_mainram, *pgm_bg_videoram, *pgm_tx_videoram, *pgm_videoregs, *pgm_rowscrollram; -static UINT16 *pgm_videoram; -static UINT8 *z80_mainram; -static UINT32 *arm7_shareram; -static UINT32 *svg_shareram[2]; //for 5585G MACHINE -static UINT32 kov2_latchdata_68k_w; -static UINT32 kov2_latchdata_arm_w; - +UINT16 *pgm_mainram; static WRITE16_HANDLER( pgm_videoram_w ) { - if (offset<0x4000/2) + pgm_state *state = (pgm_state *)space->machine->driver_data; + + if (offset < 0x4000 / 2) pgm_bg_videoram_w(space, offset, data, mem_mask); - else if (offset<0x7000/2) - pgm_tx_videoram_w(space, offset-0x4000/2, data, mem_mask); - else COMBINE_DATA(&pgm_videoram[offset/2]); + else if (offset < 0x7000 / 2) + pgm_tx_videoram_w(space, offset - 0x4000 / 2, data, mem_mask); + else + COMBINE_DATA(&state->videoram[offset / 2]); } static READ16_HANDLER ( z80_ram_r ) { - return (z80_mainram[offset*2] << 8)|z80_mainram[offset*2+1]; + pgm_state *state = (pgm_state *)space->machine->driver_data; + return (state->z80_mainram[offset * 2] << 8) | state->z80_mainram[offset * 2 + 1]; } static READ32_HANDLER( arm7_latch_arm_r ) { - if (PGMARM7LOGERROR) logerror("ARM7: Latch read: %08x (%08x) (%06x)\n", kov2_latchdata_68k_w, mem_mask, cpu_get_pc(space->cpu) ); - return kov2_latchdata_68k_w; + pgm_state *state = (pgm_state *)space->machine->driver_data; + + if (PGMARM7LOGERROR) + logerror("ARM7: Latch read: %08x (%08x) (%06x)\n", state->kov2_latchdata_68k_w, mem_mask, cpu_get_pc(space->cpu)); + return state->kov2_latchdata_68k_w; } static WRITE32_HANDLER( arm7_latch_arm_w ) { - if (PGMARM7LOGERROR) logerror("ARM7: Latch write: %08x (%08x) (%06x)\n", data, mem_mask, cpu_get_pc(space->cpu) ); - COMBINE_DATA(&kov2_latchdata_arm_w); + pgm_state *state = (pgm_state *)space->machine->driver_data; + + if (PGMARM7LOGERROR) + logerror("ARM7: Latch write: %08x (%08x) (%06x)\n", data, mem_mask, cpu_get_pc(space->cpu)); + + COMBINE_DATA(&state->kov2_latchdata_arm_w); } static READ32_HANDLER( arm7_shareram_r ) { - if (PGMARM7LOGERROR) logerror("ARM7: ARM7 Shared RAM Read: %04x = %08x (%08x) (%06x)\n", offset << 2, arm7_shareram[offset], mem_mask, cpu_get_pc(space->cpu) ); - return arm7_shareram[offset]; + pgm_state *state = (pgm_state *)space->machine->driver_data; + + if (PGMARM7LOGERROR) + logerror("ARM7: ARM7 Shared RAM Read: %04x = %08x (%08x) (%06x)\n", offset << 2, state->arm7_shareram[offset], mem_mask, cpu_get_pc(space->cpu)); + return state->arm7_shareram[offset]; } static WRITE32_HANDLER( arm7_shareram_w ) { - if (PGMARM7LOGERROR) logerror("ARM7: ARM7 Shared RAM Write: %04x = %08x (%08x) (%06x)\n", offset << 2, data, mem_mask, cpu_get_pc(space->cpu) ); - COMBINE_DATA(&arm7_shareram[offset]); + pgm_state *state = (pgm_state *)space->machine->driver_data; + + if (PGMARM7LOGERROR) + logerror("ARM7: ARM7 Shared RAM Write: %04x = %08x (%08x) (%06x)\n", offset << 2, data, mem_mask, cpu_get_pc(space->cpu)); + COMBINE_DATA(&state->arm7_shareram[offset]); } static READ16_HANDLER( arm7_latch_68k_r ) { - if (PGMARM7LOGERROR) logerror("M68K: Latch read: %04x (%04x) (%06x)\n", kov2_latchdata_arm_w & 0x0000ffff, mem_mask, cpu_get_pc(space->cpu) ); - return kov2_latchdata_arm_w; + pgm_state *state = (pgm_state *)space->machine->driver_data; + + if (PGMARM7LOGERROR) + logerror("M68K: Latch read: %04x (%04x) (%06x)\n", state->kov2_latchdata_arm_w & 0x0000ffff, mem_mask, cpu_get_pc(space->cpu)); + return state->kov2_latchdata_arm_w; } static WRITE16_HANDLER( arm7_latch_68k_w ) { - if (PGMARM7LOGERROR) logerror("M68K: Latch write: %04x (%04x) (%06x)\n", data & 0x0000ffff, mem_mask, cpu_get_pc(space->cpu) ); - COMBINE_DATA(&kov2_latchdata_68k_w); + pgm_state *state = (pgm_state *)space->machine->driver_data; + + if (PGMARM7LOGERROR) + logerror("M68K: Latch write: %04x (%04x) (%06x)\n", data & 0x0000ffff, mem_mask, cpu_get_pc(space->cpu)); + COMBINE_DATA(&state->kov2_latchdata_68k_w); - generic_pulse_irq_line(cputag_get_cpu(space->machine, "prot"), ARM7_FIRQ_LINE); + generic_pulse_irq_line(state->prot, ARM7_FIRQ_LINE); cpuexec_boost_interleave(space->machine, attotime_zero, ATTOTIME_IN_USEC(200)); - cpu_spinuntil_time(space->cpu, cputag_clocks_to_attotime(space->machine, "prot", 200)); // give the arm time to respond (just boosting the interleave doesn't help) + cpu_spinuntil_time(space->cpu, cpu_clocks_to_attotime(state->prot, 200)); // give the arm time to respond (just boosting the interleave doesn't help) } static READ16_HANDLER( arm7_ram_r ) { - UINT16 *share16 = (UINT16 *)arm7_shareram; - if (PGMARM7LOGERROR) logerror("M68K: ARM7 Shared RAM Read: %04x = %04x (%08x) (%06x)\n", BYTE_XOR_LE(offset), share16[BYTE_XOR_LE(offset)], mem_mask, cpu_get_pc(space->cpu) ); + pgm_state *state = (pgm_state *)space->machine->driver_data; + UINT16 *share16 = (UINT16 *)state->arm7_shareram; + + if (PGMARM7LOGERROR) + logerror("M68K: ARM7 Shared RAM Read: %04x = %04x (%08x) (%06x)\n", BYTE_XOR_LE(offset), share16[BYTE_XOR_LE(offset)], mem_mask, cpu_get_pc(space->cpu)); return share16[BYTE_XOR_LE(offset)]; } static WRITE16_HANDLER( arm7_ram_w ) { - UINT16 *share16 = (UINT16 *)arm7_shareram; - if (PGMARM7LOGERROR) logerror("M68K: ARM7 Shared RAM Write: %04x = %04x (%04x) (%06x)\n", BYTE_XOR_LE(offset), data, mem_mask, cpu_get_pc(space->cpu) ); + pgm_state *state = (pgm_state *)space->machine->driver_data; + UINT16 *share16 = (UINT16 *)state->arm7_shareram; + if (PGMARM7LOGERROR) + logerror("M68K: ARM7 Shared RAM Write: %04x = %04x (%04x) (%06x)\n", BYTE_XOR_LE(offset), data, mem_mask, cpu_get_pc(space->cpu)); COMBINE_DATA(&share16[BYTE_XOR_LE(offset)]); } static WRITE16_HANDLER ( z80_ram_w ) { + pgm_state *state = (pgm_state *)space->machine->driver_data; int pc = cpu_get_pc(space->cpu); - if(ACCESSING_BITS_8_15) - z80_mainram[offset*2] = data >> 8; - if(ACCESSING_BITS_0_7) - z80_mainram[offset*2+1] = data; - if(pc != 0xf12 && pc != 0xde2 && pc != 0x100c50 && pc != 0x100b20) - if (PGMLOGERROR) logerror("Z80: write %04x, %04x @ %04x (%06x)\n", offset*2, data, mem_mask, cpu_get_pc(space->cpu)); + if (ACCESSING_BITS_8_15) + state->z80_mainram[offset * 2] = data >> 8; + if (ACCESSING_BITS_0_7) + state->z80_mainram[offset * 2 + 1] = data; + + if (pc != 0xf12 && pc != 0xde2 && pc != 0x100c50 && pc != 0x100b20) + if (PGMLOGERROR) + logerror("Z80: write %04x, %04x @ %04x (%06x)\n", offset * 2, data, mem_mask, cpu_get_pc(space->cpu)); } static WRITE16_HANDLER ( z80_reset_w ) { - if (PGMLOGERROR) logerror("Z80: reset %04x @ %04x (%06x)\n", data, mem_mask, cpu_get_pc(space->cpu)); + pgm_state *state = (pgm_state *)space->machine->driver_data; + + if (PGMLOGERROR) + logerror("Z80: reset %04x @ %04x (%06x)\n", data, mem_mask, cpu_get_pc(space->cpu)); - if(data == 0x5050) + if (data == 0x5050) { - devtag_reset(space->machine, "ics"); - cputag_set_input_line(space->machine, "soundcpu", INPUT_LINE_HALT, CLEAR_LINE); - cputag_set_input_line(space->machine, "soundcpu", INPUT_LINE_RESET, PULSE_LINE); + device_reset(state->ics); + cpu_set_input_line(state->soundcpu, INPUT_LINE_HALT, CLEAR_LINE); + cpu_set_input_line(state->soundcpu, INPUT_LINE_RESET, PULSE_LINE); if(0) { FILE *out; out = fopen("z80ram.bin", "wb"); - fwrite(z80_mainram, 1, 65536, out); + fwrite(state->z80_mainram, 1, 65536, out); fclose(out); } } @@ -403,115 +429,120 @@ static WRITE16_HANDLER ( z80_reset_w ) { /* this might not be 100% correct, but several of the games (ddp2, puzzli2 etc. expect the z80 to be turned off during data uploads, they write here before the upload */ - cputag_set_input_line(space->machine, "soundcpu", INPUT_LINE_HALT, ASSERT_LINE); + cpu_set_input_line(state->soundcpu, INPUT_LINE_HALT, ASSERT_LINE); } } static WRITE16_HANDLER ( z80_ctrl_w ) { - if (PGMLOGERROR) logerror("Z80: ctrl %04x @ %04x (%06x)\n", data, mem_mask, cpu_get_pc(space->cpu)); + if (PGMLOGERROR) + logerror("Z80: ctrl %04x @ %04x (%06x)\n", data, mem_mask, cpu_get_pc(space->cpu)); } static WRITE16_HANDLER ( m68k_l1_w ) { + pgm_state *state = (pgm_state *)space->machine->driver_data; + if(ACCESSING_BITS_0_7) { - if (PGMLOGERROR) logerror("SL 1 m68.w %02x (%06x) IRQ\n", data & 0xff, cpu_get_pc(space->cpu)); + if (PGMLOGERROR) + logerror("SL 1 m68.w %02x (%06x) IRQ\n", data & 0xff, cpu_get_pc(space->cpu)); soundlatch_w(space, 0, data); - cputag_set_input_line(space->machine, "soundcpu", INPUT_LINE_NMI, PULSE_LINE ); + cpu_set_input_line(state->soundcpu, INPUT_LINE_NMI, PULSE_LINE ); } } static WRITE8_HANDLER( z80_l3_w ) { - if (PGMLOGERROR) logerror("SL 3 z80.w %02x (%04x)\n", data, cpu_get_pc(space->cpu)); + if (PGMLOGERROR) + logerror("SL 3 z80.w %02x (%04x)\n", data, cpu_get_pc(space->cpu)); soundlatch3_w(space, 0, data); } -static void sound_irq(const device_config *device, int level) +static void sound_irq( const device_config *device, int level ) { - cputag_set_input_line(device->machine, "soundcpu", 0, level); + pgm_state *state = (pgm_state *)device->machine->driver_data; + cpu_set_input_line(state->soundcpu, 0, level); } -static const ics2115_interface pgm_ics2115_interface = { +static const ics2115_interface pgm_ics2115_interface = +{ sound_irq }; -/* Calendar Emulation */ -static UINT8 CalVal, CalMask, CalCom=0, CalCnt=0; +/* Calendar Emulation */ -static UINT8 bcd(UINT8 data) +static UINT8 bcd( UINT8 data ) { return ((data / 10) << 4) | (data % 10); } static READ16_HANDLER( pgm_calendar_r ) { - UINT8 calr; - calr = (CalVal & CalMask) ? 1 : 0; - CalMask <<= 1; + pgm_state *state = (pgm_state *)space->machine->driver_data; + UINT8 calr = (state->cal_val & state->cal_mask) ? 1 : 0; + + state->cal_mask <<= 1; return calr; } static WRITE16_HANDLER( pgm_calendar_w ) { - static mame_system_time systime; + pgm_state *state = (pgm_state *)space->machine->driver_data; - mame_get_base_datetime(space->machine, &systime); + mame_get_base_datetime(space->machine, &state->systime); - // initialize the time, otherwise it crashes - if( !systime.time ) - mame_get_base_datetime(space->machine, &systime); + state->cal_com <<= 1; + state->cal_com |= data & 1; + ++state->cal_cnt; - CalCom <<= 1; - CalCom |= data & 1; - ++CalCnt; - if(CalCnt==4) + if (state->cal_cnt == 4) { - CalMask = 1; - CalVal = 1; - CalCnt = 0; - switch(CalCom & 0xf) + state->cal_mask = 1; + state->cal_val = 1; + state->cal_cnt = 0; + + switch (state->cal_com & 0xf) { case 1: case 3: case 5: case 7: case 9: case 0xb: case 0xd: - CalVal++; + state->cal_val++; break; case 0: - CalVal=bcd(systime.local_time.weekday); //?? + state->cal_val = bcd(state->systime.local_time.weekday); //?? break; case 2: //Hours - CalVal=bcd(systime.local_time.hour); + state->cal_val = bcd(state->systime.local_time.hour); break; case 4: //Seconds - CalVal=bcd(systime.local_time.second); + state->cal_val = bcd(state->systime.local_time.second); break; case 6: //Month - CalVal=bcd(systime.local_time.month + 1); //?? not bcd in MVS + state->cal_val = bcd(state->systime.local_time.month + 1); //?? not bcd in MVS break; case 8: - CalVal=0; //Controls blinking speed, maybe milliseconds + state->cal_val = 0; //Controls blinking speed, maybe milliseconds break; case 0xa: //Day - CalVal=bcd(systime.local_time.mday); + state->cal_val = bcd(state->systime.local_time.mday); break; case 0xc: //Minute - CalVal=bcd(systime.local_time.minute); + state->cal_val = bcd(state->systime.local_time.minute); break; case 0xe: //Year - CalVal=bcd(systime.local_time.year % 100); + state->cal_val = bcd(state->systime.local_time.year % 100); break; case 0xf: //Load Date - mame_get_base_datetime(space->machine, &systime); + mame_get_base_datetime(space->machine, &state->systime); break; } } @@ -542,12 +573,12 @@ static ADDRESS_MAP_START( pgm_mem, ADDRESS_SPACE_PROGRAM, 16) AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) /* Main Ram */ -// AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE(&pgm_bg_videoram) /* Backgrounds */ -// AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE(&pgm_tx_videoram) /* Text Layer */ -// AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE(&pgm_rowscrollram) - AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE(&pgm_videoram) /* IGS023 VIDEO CHIP */ +// AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE_MEMBER(pgm_state, bg_videoram) /* Backgrounds */ +// AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE_MEMBER(pgm_state, tx_videoram) /* Text Layer */ +// AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE_MEMBER(pgm_state, rowscrollram) + AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE_MEMBER(pgm_state, videoram) /* IGS023 VIDEO CHIP */ AM_RANGE(0xa00000, 0xa011ff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE(&pgm_videoregs) /* Video Regs inc. Zoom Table */ + AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE_MEMBER(pgm_state, videoregs) /* Video Regs inc. Zoom Table */ AM_RANGE(0xc00002, 0xc00003) AM_READWRITE(soundlatch_word_r, m68k_l1_w) AM_RANGE(0xc00004, 0xc00005) AM_READWRITE(soundlatch2_word_r, soundlatch2_word_w) @@ -564,23 +595,21 @@ static ADDRESS_MAP_START( pgm_mem, ADDRESS_SPACE_PROGRAM, 16) AM_RANGE(0xc10000, 0xc1ffff) AM_READWRITE(z80_ram_r, z80_ram_w) /* Z80 Program */ ADDRESS_MAP_END -static UINT16 *killbld_sharedprotram; - static ADDRESS_MAP_START( killbld_mem, ADDRESS_SPACE_PROGRAM, 16) AM_RANGE(0x000000, 0x01ffff) AM_ROM /* BIOS ROM */ AM_RANGE(0x100000, 0x2fffff) AM_ROMBANK("bank1") /* Game ROM */ - AM_RANGE(0x300000, 0x303fff) AM_RAM AM_BASE(&killbld_sharedprotram) // Shared with protection device + AM_RANGE(0x300000, 0x303fff) AM_RAM AM_BASE_MEMBER(pgm_state, sharedprotram) // Shared with protection device AM_RANGE(0x700006, 0x700007) AM_WRITENOP // Watchdog? AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) /* Main Ram */ -// AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE(&pgm_bg_videoram) /* Backgrounds */ -// AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE(&pgm_tx_videoram) /* Text Layer */ -// AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE(&pgm_rowscrollram) - AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE(&pgm_videoram) /* IGS023 VIDEO CHIP */ +// AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE_MEMBER(pgm_state, bg_videoram) /* Backgrounds */ +// AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE_MEMBER(pgm_state, tx_videoram) /* Text Layer */ +// AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE_MEMBER(pgm_state, rowscrollram) + AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE_MEMBER(pgm_state, videoram) /* IGS023 VIDEO CHIP */ AM_RANGE(0xa00000, 0xa011ff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE(&pgm_videoregs) /* Video Regs inc. Zoom Table */ + AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE_MEMBER(pgm_state, videoregs) /* Video Regs inc. Zoom Table */ AM_RANGE(0xc00002, 0xc00003) AM_READWRITE(soundlatch_word_r, m68k_l1_w) AM_RANGE(0xc00004, 0xc00005) AM_READWRITE(soundlatch2_word_r, soundlatch2_word_w) @@ -597,23 +626,21 @@ static ADDRESS_MAP_START( killbld_mem, ADDRESS_SPACE_PROGRAM, 16) AM_RANGE(0xc10000, 0xc1ffff) AM_READWRITE(z80_ram_r, z80_ram_w) /* Z80 Program */ ADDRESS_MAP_END -static UINT16 *olds_sharedprotram; - static ADDRESS_MAP_START( olds_mem, ADDRESS_SPACE_PROGRAM, 16) AM_RANGE(0x000000, 0x01ffff) AM_ROM /* BIOS ROM */ AM_RANGE(0x100000, 0x3fffff) AM_ROMBANK("bank1") /* Game ROM */ - AM_RANGE(0x400000, 0x403fff) AM_RAM AM_BASE(&olds_sharedprotram) // Shared with protection device + AM_RANGE(0x400000, 0x403fff) AM_RAM AM_BASE_MEMBER(pgm_state, sharedprotram) // Shared with protection device AM_RANGE(0x700006, 0x700007) AM_WRITENOP // Watchdog? AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) /* Main Ram */ -// AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE(&pgm_bg_videoram) /* Backgrounds */ -// AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE(&pgm_tx_videoram) /* Text Layer */ -// AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE(&pgm_rowscrollram) - AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE(&pgm_videoram) /* IGS023 VIDEO CHIP */ +// AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE_MEMBER(pgm_state, bg_videoram) /* Backgrounds */ +// AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE_MEMBER(pgm_state, tx_videoram) /* Text Layer */ +// AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE_MEMBER(pgm_state, rowscrollram) + AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE_MEMBER(pgm_state, videoram) /* IGS023 VIDEO CHIP */ AM_RANGE(0xa00000, 0xa011ff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE(&pgm_videoregs) /* Video Regs inc. Zoom Table */ + AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE_MEMBER(pgm_state, videoregs) /* Video Regs inc. Zoom Table */ AM_RANGE(0xc00002, 0xc00003) AM_READWRITE(soundlatch_word_r, m68k_l1_w) AM_RANGE(0xc00004, 0xc00005) AM_READWRITE(soundlatch2_word_r, soundlatch2_word_w) @@ -638,12 +665,12 @@ static ADDRESS_MAP_START( kov2_mem, ADDRESS_SPACE_PROGRAM, 16) AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) /* Main Ram */ -// AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE(&pgm_bg_videoram) /* Backgrounds */ -// AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE(&pgm_tx_videoram) /* Text Layer */ -// AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE(&pgm_rowscrollram) - AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE(&pgm_videoram) /* IGS023 VIDEO CHIP */ +// AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE_MEMBER(pgm_state, bg_videoram) /* Backgrounds */ +// AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE_MEMBER(pgm_state, tx_videoram) /* Text Layer */ +// AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE_MEMBER(pgm_state, rowscrollram) + AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE_MEMBER(pgm_state, videoram) /* IGS023 VIDEO CHIP */ AM_RANGE(0xa00000, 0xa011ff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE(&pgm_videoregs) /* Video Regs inc. Zoom Table */ + AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE_MEMBER(pgm_state, videoregs) /* Video Regs inc. Zoom Table */ AM_RANGE(0xc00002, 0xc00003) AM_READWRITE(soundlatch_word_r, m68k_l1_w) AM_RANGE(0xc00004, 0xc00005) AM_READWRITE(soundlatch2_word_r, soundlatch2_word_w) @@ -666,18 +693,18 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( cavepgm_mem, ADDRESS_SPACE_PROGRAM, 16) AM_RANGE(0x000000, 0x07ffff) AM_ROM /* larger BIOS ROM */ AM_RANGE(0xfffffe, 0xffffff) AM_ROMBANK("bank1") /* Game ROM (unmapped for now, might not even have it) */ - AM_RANGE(0x400000, 0x4fffff) AM_RAM AM_BASE(&olds_sharedprotram) // Shared with protection device + AM_RANGE(0x400000, 0x4fffff) AM_RAM AM_BASE_MEMBER(pgm_state, sharedprotram) // Shared with protection device AM_RANGE(0x700006, 0x700007) AM_WRITENOP // Watchdog? AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) /* Main Ram */ -// AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE(&pgm_bg_videoram) /* Backgrounds */ -// AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE(&pgm_tx_videoram) /* Text Layer */ -// AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE(&pgm_rowscrollram) - AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE(&pgm_videoram) /* IGS023 VIDEO CHIP */ +// AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE_MEMBER(pgm_state, bg_videoram) /* Backgrounds */ +// AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE_MEMBER(pgm_state, tx_videoram) /* Text Layer */ +// AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE_MEMBER(pgm_state, rowscrollram) + AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE_MEMBER(pgm_state, videoram) /* IGS023 VIDEO CHIP */ AM_RANGE(0xa00000, 0xa011ff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE(&pgm_videoregs) /* Video Regs inc. Zoom Table */ + AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE_MEMBER(pgm_state, videoregs) /* Video Regs inc. Zoom Table */ AM_RANGE(0xc00002, 0xc00003) AM_READWRITE(soundlatch_word_r, m68k_l1_w) AM_RANGE(0xc00004, 0xc00005) AM_READWRITE(soundlatch2_word_r, soundlatch2_word_w) @@ -696,7 +723,7 @@ ADDRESS_MAP_END #endif static ADDRESS_MAP_START( z80_mem, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0xffff) AM_RAM AM_BASE(&z80_mainram) + AM_RANGE(0x0000, 0xffff) AM_RAM AM_BASE_MEMBER(pgm_state, z80_mainram) ADDRESS_MAP_END static ADDRESS_MAP_START( z80_io, ADDRESS_SPACE_IO, 8 ) @@ -712,83 +739,89 @@ static ADDRESS_MAP_START( arm7_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x10000000, 0x100003ff) AM_RAM AM_RANGE(0x18000000, 0x1800ffff) AM_RAM AM_RANGE(0x38000000, 0x38000003) AM_READWRITE(arm7_latch_arm_r, arm7_latch_arm_w) /* 68k Latch */ - AM_RANGE(0x48000000, 0x4800ffff) AM_READWRITE(arm7_shareram_r, arm7_shareram_w) AM_BASE(&arm7_shareram) + AM_RANGE(0x48000000, 0x4800ffff) AM_READWRITE(arm7_shareram_r, arm7_shareram_w) AM_BASE_MEMBER(pgm_state, arm7_shareram) AM_RANGE(0x50000000, 0x500003ff) AM_RAM ADDRESS_MAP_END /* Kov Superheroes */ -static UINT16 kovsh_highlatch_arm_w, kovsh_lowlatch_arm_w; -static UINT16 kovsh_highlatch_68k_w, kovsh_lowlatch_68k_w; - static READ32_HANDLER( kovsh_arm7_protlatch_r ) { + pgm_state *state = (pgm_state *)space->machine->driver_data; + timer_call_after_resynch(space->machine, NULL, 0, 0); // force resync - return (kovsh_highlatch_68k_w << 16) | (kovsh_lowlatch_68k_w); + return (state->kovsh_highlatch_68k_w << 16) | (state->kovsh_lowlatch_68k_w); } static WRITE32_HANDLER( kovsh_arm7_protlatch_w ) { + pgm_state *state = (pgm_state *)space->machine->driver_data; + timer_call_after_resynch(space->machine, NULL, 0, 0); // force resync if (ACCESSING_BITS_16_31) { - kovsh_highlatch_arm_w = data>>16; - kovsh_highlatch_68k_w = 0; + state->kovsh_highlatch_arm_w = data >> 16; + state->kovsh_highlatch_68k_w = 0; } if (ACCESSING_BITS_0_15) { - kovsh_lowlatch_arm_w = data; - kovsh_lowlatch_68k_w = 0; + state->kovsh_lowlatch_arm_w = data; + state->kovsh_lowlatch_68k_w = 0; } } static READ16_HANDLER( kovsh_68k_protlatch_r ) { + pgm_state *state = (pgm_state *)space->machine->driver_data; + timer_call_after_resynch(space->machine, NULL, 0, 0); // force resync switch (offset) { - case 1: return kovsh_highlatch_arm_w; - case 0: return kovsh_lowlatch_arm_w; + case 1: return state->kovsh_highlatch_arm_w; + case 0: return state->kovsh_lowlatch_arm_w; } return -1; } static WRITE16_HANDLER( kovsh_68k_protlatch_w ) { + pgm_state *state = (pgm_state *)space->machine->driver_data; + timer_call_after_resynch(space->machine, NULL, 0, 0); // force resync switch (offset) { case 1: - { - kovsh_highlatch_68k_w = data; - } + state->kovsh_highlatch_68k_w = data; break; case 0: - { - kovsh_lowlatch_68k_w = data; - } + state->kovsh_lowlatch_68k_w = data; break; } } static READ16_HANDLER( kovsh_arm7_ram_r ) { - UINT16 *share16 = (UINT16 *)arm7_shareram; - if (PGMARM7LOGERROR) logerror("M68K: ARM7 Shared RAM Read: %04x = %04x (%08x) (%06x)\n", BYTE_XOR_LE(offset), share16[BYTE_XOR_LE(offset)], mem_mask, cpu_get_pc(space->cpu) ); - return share16[BYTE_XOR_LE(offset<<1)]; + pgm_state *state = (pgm_state *)space->machine->driver_data; + UINT16 *share16 = (UINT16 *)state->arm7_shareram; + + if (PGMARM7LOGERROR) + logerror("M68K: ARM7 Shared RAM Read: %04x = %04x (%08x) (%06x)\n", BYTE_XOR_LE(offset), share16[BYTE_XOR_LE(offset)], mem_mask, cpu_get_pc(space->cpu)); + return share16[BYTE_XOR_LE(offset << 1)]; } static WRITE16_HANDLER( kovsh_arm7_ram_w ) { - UINT16 *share16 = (UINT16 *)arm7_shareram; - if (PGMARM7LOGERROR) logerror("M68K: ARM7 Shared RAM Write: %04x = %04x (%04x) (%06x)\n", BYTE_XOR_LE(offset), data, mem_mask, cpu_get_pc(space->cpu) ); + pgm_state *state = (pgm_state *)space->machine->driver_data; + UINT16 *share16 = (UINT16 *)state->arm7_shareram; - COMBINE_DATA(&share16[BYTE_XOR_LE(offset<<1)]); + if (PGMARM7LOGERROR) + logerror("M68K: ARM7 Shared RAM Write: %04x = %04x (%04x) (%06x)\n", BYTE_XOR_LE(offset), data, mem_mask, cpu_get_pc(space->cpu)); + COMBINE_DATA(&share16[BYTE_XOR_LE(offset << 1)]); } static ADDRESS_MAP_START( kovsh_mem, ADDRESS_SPACE_PROGRAM, 16) @@ -799,12 +832,12 @@ static ADDRESS_MAP_START( kovsh_mem, ADDRESS_SPACE_PROGRAM, 16) AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) /* Main Ram */ -// AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE(&pgm_bg_videoram) /* Backgrounds */ -// AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE(&pgm_tx_videoram) /* Text Layer */ -// AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE(&pgm_rowscrollram) - AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE(&pgm_videoram) /* IGS023 VIDEO CHIP */ +// AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE_MEMBER(pgm_state, bg_videoram) /* Backgrounds */ +// AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE_MEMBER(pgm_state, tx_videoram) /* Text Layer */ +// AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE_MEMBER(pgm_state, rowscrollram) + AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE_MEMBER(pgm_state, videoram) /* IGS023 VIDEO CHIP */ AM_RANGE(0xa00000, 0xa011ff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE(&pgm_videoregs) /* Video Regs inc. Zoom Table */ + AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE_MEMBER(pgm_state, videoregs) /* Video Regs inc. Zoom Table */ AM_RANGE(0xc00002, 0xc00003) AM_READWRITE(soundlatch_word_r, m68k_l1_w) AM_RANGE(0xc00004, 0xc00005) AM_READWRITE(soundlatch2_word_r, soundlatch2_word_w) @@ -823,11 +856,11 @@ static ADDRESS_MAP_START( kovsh_mem, ADDRESS_SPACE_PROGRAM, 16) AM_RANGE(0x500000, 0x500005) AM_READWRITE(kovsh_68k_protlatch_r, kovsh_68k_protlatch_w) /* ARM7 Latch */ ADDRESS_MAP_END -static UINT32 kovsh_counter; static READ32_HANDLER( kovsh_arm7_unk_r ) { - return kovsh_counter++; + pgm_state *state = (pgm_state *)space->machine->driver_data; + return state->kovsh_counter++; } static READ32_HANDLER( kovsh_exrom_r ) @@ -839,46 +872,49 @@ static ADDRESS_MAP_START( kovsh_arm7_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x00000000, 0x00003fff) AM_ROM AM_RANGE(0x08100000, 0x083fffff) AM_READ(kovsh_exrom_r) // unpopulated, returns 0 to keep checksum happy AM_RANGE(0x10000000, 0x100003ff) AM_RAM // internal ram for asic - AM_RANGE(0x40000000, 0x40000003) AM_READ(kovsh_arm7_protlatch_r) AM_WRITE(kovsh_arm7_protlatch_w) + AM_RANGE(0x40000000, 0x40000003) AM_READWRITE(kovsh_arm7_protlatch_r, kovsh_arm7_protlatch_w) AM_RANGE(0x40000008, 0x4000000b) AM_WRITENOP // ? AM_RANGE(0x4000000c, 0x4000000f) AM_READ(kovsh_arm7_unk_r) - AM_RANGE(0x50800000, 0x5080003f) AM_READWRITE(arm7_shareram_r, arm7_shareram_w) AM_BASE(&arm7_shareram) + AM_RANGE(0x50800000, 0x5080003f) AM_READWRITE(arm7_shareram_r, arm7_shareram_w) AM_BASE_MEMBER(pgm_state, arm7_shareram) AM_RANGE(0x50000000, 0x500003ff) AM_RAM // uploads xor table to decrypt 68k rom here ADDRESS_MAP_END //5585G -static unsigned char svg_ram_sel; static WRITE32_HANDLER( svg_arm7_ram_sel_w ) { - svg_ram_sel=data&1; + pgm_state *state = (pgm_state *)space->machine->driver_data; + state->svg_ram_sel = data & 1; } static READ32_HANDLER( svg_arm7_shareram_r ) { - unsigned char ram_sel=svg_ram_sel&1; - - return svg_shareram[ram_sel][offset]; + pgm_state *state = (pgm_state *)space->machine->driver_data; + return state->svg_shareram[state->svg_ram_sel & 1][offset]; } static WRITE32_HANDLER( svg_arm7_shareram_w ) { - unsigned char ram_sel=svg_ram_sel&1; - COMBINE_DATA(&svg_shareram[ram_sel][offset]); + pgm_state *state = (pgm_state *)space->machine->driver_data; + COMBINE_DATA(&state->svg_shareram[state->svg_ram_sel & 1][offset]); } static READ16_HANDLER( svg_m68k_ram_r ) { - unsigned char ram_sel=(svg_ram_sel&1)^1; - UINT16 *share16 = (UINT16 *)(svg_shareram[ram_sel]); + pgm_state *state = (pgm_state *)space->machine->driver_data; + int ram_sel = (state->svg_ram_sel & 1) ^ 1; + UINT16 *share16 = (UINT16 *)(state->svg_shareram[ram_sel & 1]); + return share16[BYTE_XOR_LE(offset)]; } static WRITE16_HANDLER( svg_m68k_ram_w ) { - unsigned char ram_sel=(svg_ram_sel&1)^1; - UINT16 *share16 = (UINT16 *)(svg_shareram[ram_sel]); + pgm_state *state = (pgm_state *)space->machine->driver_data; + int ram_sel = (state->svg_ram_sel & 1) ^ 1; + UINT16 *share16 = (UINT16 *)(state->svg_shareram[ram_sel & 1]); + COMBINE_DATA(&share16[BYTE_XOR_LE(offset)]); } @@ -889,15 +925,18 @@ static READ16_HANDLER( svg_68k_nmi_r ) static WRITE16_HANDLER( svg_68k_nmi_w ) { - generic_pulse_irq_line(cputag_get_cpu(space->machine, "prot"), ARM7_FIRQ_LINE); + pgm_state *state = (pgm_state *)space->machine->driver_data; + generic_pulse_irq_line(state->prot, ARM7_FIRQ_LINE); cpuexec_boost_interleave(space->machine, attotime_zero, ATTOTIME_IN_USEC(200)); - cpu_spinuntil_time(space->cpu, cputag_clocks_to_attotime(space->machine, "prot", 200)); // give the arm time to respond (just boosting the interleave doesn't help) + cpu_spinuntil_time(space->cpu, cpu_clocks_to_attotime(state->prot, 200)); // give the arm time to respond (just boosting the interleave doesn't help) } static WRITE16_HANDLER( svg_latch_68k_w ) { - if (PGMARM7LOGERROR) logerror("M68K: Latch write: %04x (%04x) (%06x)\n", data & 0x0000ffff, mem_mask, cpu_get_pc(space->cpu) ); - COMBINE_DATA(&kov2_latchdata_68k_w); + pgm_state *state = (pgm_state *)space->machine->driver_data; + if (PGMARM7LOGERROR) + logerror("M68K: Latch write: %04x (%04x) (%06x)\n", data & 0x0000ffff, mem_mask, cpu_get_pc(space->cpu)); + COMBINE_DATA(&state->kov2_latchdata_68k_w); } static ADDRESS_MAP_START( svg_68k_mem, ADDRESS_SPACE_PROGRAM, 16) @@ -908,12 +947,12 @@ static ADDRESS_MAP_START( svg_68k_mem, ADDRESS_SPACE_PROGRAM, 16) AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) /* Main Ram */ -// AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE(&pgm_bg_videoram) /* Backgrounds */ -// AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE(&pgm_tx_videoram) /* Text Layer */ -// AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE(&pgm_rowscrollram) - AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE(&pgm_videoram) /* IGS023 VIDEO CHIP */ +// AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE_MEMBER(pgm_state, bg_videoram) /* Backgrounds */ +// AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE_MEMBER(pgm_state, tx_videoram) /* Text Layer */ +// AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE_MEMBER(pgm_state, rowscrollram) + AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE_MEMBER(pgm_state, videoram) /* IGS023 VIDEO CHIP */ AM_RANGE(0xa00000, 0xa011ff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE(&pgm_videoregs) /* Video Regs inc. Zoom Table */ + AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE_MEMBER(pgm_state, videoregs) /* Video Regs inc. Zoom Table */ AM_RANGE(0xc00002, 0xc00003) AM_READWRITE(soundlatch_word_r, m68k_l1_w) AM_RANGE(0xc00004, 0xc00005) AM_READWRITE(soundlatch2_word_r, soundlatch2_word_w) @@ -1265,19 +1304,45 @@ GFXDECODE_END is the source? maybe the protection device? */ static INTERRUPT_GEN( drgw_interrupt ) { - if( cpu_getiloops(device) == 0 ) + if (cpu_getiloops(device) == 0) cpu_set_input_line(device, 6, HOLD_LINE); else cpu_set_input_line(device, 4, HOLD_LINE); } -static MACHINE_RESET ( pgm ) +static MACHINE_START( pgm ) +{ + pgm_state *state = (pgm_state *)machine->driver_data; + + mame_get_base_datetime(machine, &state->systime); + + state->soundcpu = devtag_get_device(machine, "soundcpu"); + state->prot = devtag_get_device(machine, "prot"); + state->ics = devtag_get_device(machine, "ics"); + + state_save_register_global(machine, state->cal_val); + state_save_register_global(machine, state->cal_mask); + state_save_register_global(machine, state->cal_com); + state_save_register_global(machine, state->cal_cnt); +} + +static MACHINE_RESET( pgm ) { + pgm_state *state = (pgm_state *)machine->driver_data; + cputag_set_input_line(machine, "soundcpu", INPUT_LINE_HALT, ASSERT_LINE); + + state->cal_val = 0; + state->cal_mask = 0; + state->cal_com = 0; + state->cal_cnt = 0; } static MACHINE_DRIVER_START( pgm ) + /* driver data */ + MDRV_DRIVER_DATA(pgm_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000, 20000000) /* 20 mhz! verified on real board */ MDRV_CPU_PROGRAM_MAP(pgm_mem) @@ -1287,10 +1352,9 @@ static MACHINE_DRIVER_START( pgm ) MDRV_CPU_PROGRAM_MAP(z80_mem) MDRV_CPU_IO_MAP(z80_io) - MDRV_SPEAKER_STANDARD_MONO("mono") - MDRV_SOUND_ADD("ics", ICS2115, 0) - MDRV_SOUND_CONFIG(pgm_ics2115_interface) - MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 5.0) + MDRV_MACHINE_START( pgm ) + MDRV_MACHINE_RESET( pgm ) + MDRV_NVRAM_HANDLER( pgm ) /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) @@ -1302,12 +1366,16 @@ static MACHINE_DRIVER_START( pgm ) MDRV_GFXDECODE(pgm) MDRV_PALETTE_LENGTH(0x1200/2) - MDRV_MACHINE_RESET ( pgm ) - MDRV_NVRAM_HANDLER ( pgm ) MDRV_VIDEO_START(pgm) MDRV_VIDEO_EOF(pgm) MDRV_VIDEO_UPDATE(pgm) + + /*sound hardware */ + MDRV_SPEAKER_STANDARD_MONO("mono") + MDRV_SOUND_ADD("ics", ICS2115, 0) + MDRV_SOUND_CONFIG(pgm_ics2115_interface) + MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 5.0) MACHINE_DRIVER_END static MACHINE_DRIVER_START( drgw2 ) @@ -1388,700 +1456,6 @@ MACHINE_DRIVER_END #endif -/*** Init Stuff **************************************************************/ - -/* This function expands the 32x32 5-bit data into a format which is easier to - decode in MAME */ - -static void expand_32x32x5bpp(running_machine *machine) -{ - UINT8 *src = memory_region ( machine, "gfx1" ); - UINT8 *dst = memory_region ( machine, "gfx2" ); - size_t srcsize = memory_region_length( machine, "gfx1" ); - int cnt, pix; - - for (cnt = 0; cnt < srcsize/5 ; cnt ++) - { - pix = ((src[0+5*cnt] >> 0)& 0x1f ); dst[0+8*cnt]=pix; - pix = ((src[0+5*cnt] >> 5)& 0x07) | ((src[1+5*cnt] << 3) & 0x18);dst[1+8*cnt]=pix; - pix = ((src[1+5*cnt] >> 2)& 0x1f ); dst[2+8*cnt]=pix; - pix = ((src[1+5*cnt] >> 7)& 0x01) | ((src[2+5*cnt] << 1) & 0x1e);dst[3+8*cnt]=pix; - pix = ((src[2+5*cnt] >> 4)& 0x0f) | ((src[3+5*cnt] << 4) & 0x10);dst[4+8*cnt]=pix; - pix = ((src[3+5*cnt] >> 1)& 0x1f ); dst[5+8*cnt]=pix; - pix = ((src[3+5*cnt] >> 6)& 0x03) | ((src[4+5*cnt] << 2) & 0x1c);dst[6+8*cnt]=pix; - pix = ((src[4+5*cnt] >> 3)& 0x1f ); dst[7+8*cnt]=pix; - } -} - -/* This function expands the sprite colour data (in the A Roms) from 3 pixels - in each word to a byte per pixel making it easier to use */ - -UINT8 *pgm_sprite_a_region; -size_t pgm_sprite_a_region_allocate; - -static void expand_colourdata(running_machine *machine) -{ - UINT8 *src = memory_region ( machine, "gfx3" ); - size_t srcsize = memory_region_length( machine, "gfx3" ); - int cnt; - size_t needed = srcsize / 2 * 3; - - /* work out how much ram we need to allocate to expand the sprites into - and be able to mask the offset */ - pgm_sprite_a_region_allocate = 1; - while (pgm_sprite_a_region_allocate < needed) - pgm_sprite_a_region_allocate = pgm_sprite_a_region_allocate <<1; - - pgm_sprite_a_region = auto_alloc_array(machine, UINT8, pgm_sprite_a_region_allocate); - - - for (cnt = 0 ; cnt < srcsize/2 ; cnt++) - { - UINT16 colpack; - - colpack = ((src[cnt*2]) | (src[cnt*2+1] << 8)); - pgm_sprite_a_region[cnt*3+0] = (colpack >> 0 ) & 0x1f; - pgm_sprite_a_region[cnt*3+1] = (colpack >> 5 ) & 0x1f; - pgm_sprite_a_region[cnt*3+2] = (colpack >> 10) & 0x1f; - } -} - -static void pgm_basic_init(running_machine *machine) -{ - UINT8 *ROM = memory_region(machine, "maincpu"); - memory_set_bankptr(machine, "bank1",&ROM[0x100000]); - - expand_32x32x5bpp(machine); - expand_colourdata(machine); - - pgm_bg_videoram = &pgm_videoram[0]; - pgm_tx_videoram = &pgm_videoram[0x4000/2]; - pgm_rowscrollram = &pgm_videoram[0x7000/2]; - kovsh_counter = 1; -} - -static DRIVER_INIT( pgm ) -{ - pgm_basic_init(machine); -} - -/* Oriental Legend INIT */ - -static DRIVER_INIT( orlegend ) -{ - pgm_basic_init(machine); - - memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xC0400e, 0xC0400f, 0, 0, pgm_asic3_r, pgm_asic3_w); - memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xC04000, 0xC04001, 0, 0, pgm_asic3_reg_w); -} - -static void drgwld2_common_init(running_machine *machine) -{ - pgm_basic_init(machine); - pgm_dw2_decrypt(machine); - /* - Info from Elsemi - Here is how to "bypass" the dw2 hang protection, it fixes the mode - select and after failing in the 2nd stage (probably there are other checks - out there). - */ - memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xd80000, 0xd80003, 0, 0, dw2_d80000_r); -} - -static DRIVER_INIT( drgw2 ) -{ /* incomplete? */ - UINT16 *mem16 = (UINT16 *)memory_region(machine, "maincpu"); - drgwld2_common_init(machine); - /* These ROM patches are not hacks, the protection device - overlays the normal ROM code, this has been confirmed on a real PCB - although some addresses may be missing */ - mem16[0x131098/2]=0x4e93; - mem16[0x13113e/2]=0x4e93; - mem16[0x1311ce/2]=0x4e93; -} - -static DRIVER_INIT( drgw2c ) -{ - UINT16 *mem16 = (UINT16 *)memory_region(machine, "maincpu"); - drgwld2_common_init(machine); - /* These ROM patches are not hacks, the protection device - overlays the normal ROM code, this has been confirmed on a real PCB - although some addresses may be missing */ - mem16[0x1303bc/2]=0x4e93; - mem16[0x130462/2]=0x4e93; - mem16[0x1304F2/2]=0x4e93; -} - -static DRIVER_INIT( drgw2j ) -{ - UINT16 *mem16 = (UINT16 *)memory_region(machine, "maincpu"); - drgwld2_common_init(machine); - /* These ROM patches are not hacks, the protection device - overlays the normal ROM code, this has been confirmed on a real PCB - although some addresses may be missing */ - mem16[0x1302C0/2]=0x4e93; - mem16[0x130366/2]=0x4e93; - mem16[0x1303F6/2]=0x4e93; -} - -static DRIVER_INIT( kov ) -{ - pgm_basic_init(machine); - pgm_kov_decrypt(machine); -} - -static DRIVER_INIT( pstar ) -{ - pgm_basic_init(machine); - pgm_pstar_decrypt(machine); -} - -static DRIVER_INIT( djlzz ) -{ - pgm_basic_init(machine); - pgm_djlzz_decrypt(machine); -} - -static DRIVER_INIT( kovsh ) -{ - pgm_basic_init(machine); - pgm_kovsh_decrypt(machine); -} - -static DRIVER_INIT( kovshp ) -{ - pgm_basic_init(machine); - pgm_kovshp_decrypt(machine); -} - -static DRIVER_INIT( oldsplus ) -{ - pgm_basic_init(machine); - pgm_oldsplus_decrypt(machine); -} - -static DRIVER_INIT( kov2 ) -{ - pgm_basic_init(machine); - pgm_kov2_decrypt(machine); -} - -static DRIVER_INIT( kov2p ) -{ - pgm_basic_init(machine); - pgm_kov2p_decrypt(machine); -} - -static DRIVER_INIT( martmast ) -{ - pgm_basic_init(machine); - pgm_mm_decrypt(machine); -} - -static DRIVER_INIT( ddp2 ) -{ - pgm_basic_init(machine); - pgm_ddp2_decrypt(machine); -} - -static void svg_basic_init(running_machine *machine) -{ - pgm_basic_init(machine); - svg_shareram[0]=auto_alloc_array(machine, UINT32, 0x10000/4); - svg_shareram[1]=auto_alloc_array(machine, UINT32, 0x10000/4); - svg_ram_sel=0; -} - -static DRIVER_INIT( theglad ) -{ - svg_basic_init(machine); - pgm_theglad_decrypt(machine); -} - -static DRIVER_INIT( svg ) -{ - svg_basic_init(machine); - pgm_svg_decrypt(machine); -} - -static DRIVER_INIT( killbldp ) -{ - svg_basic_init(machine); - pgm_killbldp_decrypt(machine); -} - -static DRIVER_INIT( dmnfrnt ) -{ - svg_basic_init(machine); - pgm_dfront_decrypt(machine); -} - -static DRIVER_INIT( dw3 ) -{ - pgm_basic_init(machine); - -// memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xda0000, 0xdaffff, 0, 0, dw3_prot_r, dw3_prot_w); - - pgm_dw3_decrypt(machine); -} - -/* Killing Blade uses some kind of DMA protection device which can copy data from a data rom. The - MCU appears to have an internal ROM as if you remove the data ROM then the shared ram is filled - with a constant value. - - The device can perform various decryption operations on the data it copies. for now we're just - using a dump of the shared RAM instead. This will be improved later. -*/ - -static int kb_cmd; -static int reg; -static int ptr=0; - -static WRITE16_HANDLER( killbld_prot_w ) -{ -// mame_printf_debug("killbrd prot r\n"); -// return 0; - offset&=0xf; - - if(offset==0) - kb_cmd=data; - else //offset==2 - { - logerror("%06X: ASIC25 W CMD %X VAL %X",cpu_get_pc(space->cpu),kb_cmd,data); - if(kb_cmd==0) - reg=data; - else if(kb_cmd==2) - { - - if(data==1) //Execute cmd - { - UINT16 cmd=killbld_sharedprotram[0x200/2]; - //mame_printf_debug("command %04x\n",cmd); - if(cmd==0x6d) //Store values to asic ram - { - UINT32 p1=(killbld_sharedprotram[0x298/2] << 16) | killbld_sharedprotram[0x29a/2]; - UINT32 p2=(killbld_sharedprotram[0x29c/2] << 16) | killbld_sharedprotram[0x29e/2]; - static UINT32 Regs[0x10]; - if((p2&0xFFFF)==0x9) //Set value - { - int reg=(p2>>16)&0xFFFF; - if(reg&0x200) - Regs[reg&0xFF]=p1; - } - if((p2&0xFFFF)==0x6) //Add value - { - int src1=(p1>>16)&0xFF; - int src2=(p1>>0)&0xFF; - int dst=(p2>>16)&0xFF; - Regs[dst]=Regs[src2]-Regs[src1]; - } - if((p2&0xFFFF)==0x1) //Add Imm? - { - int reg=(p2>>16)&0xFF; - int imm=(p1>>0)&0xFFFF; - Regs[reg]+=imm; - } - if((p2&0xFFFF)==0xa) //Get value - { - int reg=(p1>>16)&0xFF; - killbld_sharedprotram[0x29c/2] = (Regs[reg]>>16)&0xffff; - killbld_sharedprotram[0x29e/2] = Regs[reg]&0xffff; - } - } - if(cmd==0x4f) //memcpy with encryption / scrambling - { - UINT16 src=killbld_sharedprotram[0x290/2]>>1; // ? - UINT32 dst=killbld_sharedprotram[0x292/2]; - UINT16 size=killbld_sharedprotram[0x294/2]; - UINT16 mode=killbld_sharedprotram[0x296/2]; - - - // int a=1; - // if(src==0x580) - // int a=1; - /* - P_SRC =0x300290 (offset from prot rom base) - P_DST =0x300292 (words from 0x300000) - P_SIZE=0x300294 (words) - P_MODE=0x300296 - - Mode 5 direct - Mode 6 swap nibbles and bytes - - 1,2,3 unk. - */ - - //mame_printf_debug("src %04x dst %04x size %04x mode %04x\n",src,dst,size,mode); - - //if (src&1) mame_printf_debug("odd offset\n"); - - mode &=0xf; // what are the other bits? - - if (mode == 1 || mode == 2 || mode == 3) - { - /* for now, cheat -- the scramble isn't understood, it might - be state based */ - int x; - UINT16 *RAMDUMP = (UINT16*)memory_region(space->machine, "user2"); - for (x=0;x<size;x++) - { - UINT16 dat; - - dat = RAMDUMP[dst+x]; - killbld_sharedprotram[dst+x] = dat; - } - } - else if (mode == 5) - { - /* mode 5 seems to be a straight copy */ - int x; - UINT16 *RAMDUMP = (UINT16*)memory_region(space->machine, "user2"); - UINT16 *PROTROM = (UINT16*)memory_region(space->machine, "user1"); - for (x=0;x<size;x++) - { - UINT16 dat; - dat = PROTROM[src+x]; - - if (RAMDUMP[dst+x] != dat) - mame_printf_debug("Mismatch! %04x %04x\n", RAMDUMP[dst+x], dat); - - killbld_sharedprotram[dst+x] = dat; - } - } - else if (mode == 6) - { - /* mode 6 seems to swap bytes and nibbles */ - int x; - UINT16 *RAMDUMP = (UINT16*)memory_region(space->machine, "user2"); - UINT16 *PROTROM = (UINT16*)memory_region(space->machine, "user1"); - for (x=0;x<size;x++) - { - UINT16 dat; - dat = PROTROM[src+x]; - - dat = ((dat & 0xf000) >> 12)| - ((dat & 0x0f00) >> 4)| - ((dat & 0x00f0) << 4)| - ((dat & 0x000f) << 12); - - - if (RAMDUMP[dst+x] != dat) - mame_printf_debug("Mismatch! Mode 6 %04x %04x\n", RAMDUMP[dst+x], dat); - - killbld_sharedprotram[dst+x] = dat; - } - } - else - { - mame_printf_debug("unknown copy mode!\n"); - } - /* hack.. it jumps here but there isn't valid code even when we do - use what was in ram.. probably some more protection as the game - still doesn't behave 100% correctly :-/ - - the code is copied in 'mode 3' but even the code put here on - the real ram dump is corrupt??? something _very_ strange is - going on.. maybe more rom overlays, or ram overlays too?? - - */ - killbld_sharedprotram[0x2600/2]=0x4e75; - - - } - reg++; - } - } - else if(kb_cmd==4) - ptr=data; - else if(kb_cmd==0x20) - ptr++; - } -} - -static READ16_HANDLER( killbld_prot_r ) -{ -// mame_printf_debug("killbld prot w\n"); - UINT16 res ; - - offset&=0xf; - res=0; - - if(offset==1) - { - if(kb_cmd==1) - { - res=reg&0x7f; - } - else if(kb_cmd==5) - { - UINT32 protvalue; - protvalue = 0x89911400|input_port_read(space->machine, "Region"); - res=(protvalue>>(8*(ptr-1)))&0xff; - } - } - logerror("%06X: ASIC25 R CMD %X VAL %X",cpu_get_pc(space->cpu),kb_cmd,res); - return res; -} - -static MACHINE_RESET( killbld ) -{ - int i; - - MACHINE_RESET_CALL(pgm); - - /* fill the protection ram with a5 */ - for (i = 0;i < 0x4000/2;i++) - killbld_sharedprotram[i] = 0xa5a5; -} - - -static DRIVER_INIT( killbld ) -{ - UINT16 *mem16 = (UINT16 *)memory_region(machine, "maincpu"); - - pgm_basic_init(machine); - pgm_killbld_decrypt(machine); - - /* this isn't a hack.. doing a rom dump while the game is running shows the - rom space to look like this.. there may be more overlays / enables tho */ - - /* the game actually performs a CRC check of the rom during the 'Please Wait' - screen, the checksum expected is that of the patched rom. if the checksum - fails the please wait screen doesn't last as long and the region supplied - by the protection device is ignored and the attract sequence appears out - of order */ - mem16[0x108a2c/2]=0xB6AA; - mem16[0x108a30/2]=0x6610; - mem16[0x108a32/2]=0x13c2; - mem16[0x108a34/2]=0x0080; - mem16[0x108a36/2]=0x9c76; - mem16[0x108a38/2]=0x23c3; - mem16[0x108a3a/2]=0x0080; - mem16[0x108a3c/2]=0x9c78; - mem16[0x108a3e/2]=0x1002; - mem16[0x108a40/2]=0x6054; - mem16[0x108a42/2]=0x5202; - mem16[0x108a44/2]=0x0c02; - - memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xd40000, 0xd40003, 0, 0, killbld_prot_r, killbld_prot_w); -} - -static DRIVER_INIT( puzzli2 ) -{ - /* this protection emulation is wrong - it uses an arm with no external rom - an acts in a similar way to kov etc. */ - - UINT16 *mem16 = (UINT16 *)memory_region(machine, "maincpu"); - - pgm_basic_init(machine); - - memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x500000, 0x500003, 0, 0, ASIC28_r16, ASIC28_w16); - - /* 0x4f0000 - ? is actually ram shared with the protection device, - the protection device provides the region code */ - memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x4f0000, 0x4fffff, 0, 0, sango_protram_r); - - pgm_puzzli2_decrypt(machine); - - /* protection related? */ - mem16[0x1548ec/2]=0x4e71; - mem16[0x1548fc/2]=0x4e71; - mem16[0x1549FA/2]=0x4e71; - mem16[0x154A0A/2]=0x4e71; - mem16[0x15496A/2]=0x4e71; - mem16[0x14cee0/2]=0x4e71; - mem16[0x1268c0/2]=0x4e71; - mem16[0x1268c2/2]=0x4e71; - mem16[0x1268c4/2]=0x4e71; - mem16[0x154948/2]=0x4e71; - mem16[0x13877a/2]=0x662c; - - /* patch irq4 vector (irq4 should be disabled on this game? how?) */ -// mem16[0x100070/2]=0x0012; -// mem16[0x100072/2]=0x5D78; -} - -static UINT16 olds_bs,olds_cmd3; - -static UINT32 olds_prot_addr( UINT16 addr) -{ - UINT32 mode = addr&0xff; - UINT32 offset = addr >> 8; - UINT32 realaddr; - - switch(mode) - { - case 0: - case 5: - case 0xA: - realaddr= 0x402A00+(offset<<2); - break; - - case 2: - case 8: - realaddr= 0x402E00+(offset<<2); - break; - - case 1: - realaddr= 0x40307E; - break; - - case 3: - realaddr= 0x403090; - break; - - case 4: - realaddr= 0x40309A; - break; - - case 6: - realaddr= 0x4030A4; - break; - - case 7: - realaddr= 0x403000; - break; - - case 9: - realaddr= 0x40306E; - break; - - default: - realaddr= 0; - } - return realaddr; -} - -static UINT32 olds_read_reg( UINT16 addr) -{ - UINT32 protaddr = (olds_prot_addr(addr)-0x400000)/2; - return olds_sharedprotram[protaddr]<<16|olds_sharedprotram[protaddr+1]; -} - -static void olds_write_reg( UINT16 addr, UINT32 val) -{ - olds_sharedprotram[(olds_prot_addr(addr)-0x400000)/2]=val>>16; - olds_sharedprotram[(olds_prot_addr(addr)-0x400000)/2+1]=val&0xffff; -} - -static MACHINE_RESET( olds ) -{ - UINT16 *mem16 = (UINT16 *)memory_region(machine, "user2"); - int i; - - MACHINE_RESET_CALL(pgm); - - /* populate shared protection ram with data read from pcb .. */ - - for(i=0;i<0x4000/2;i++) - { - olds_sharedprotram[i] = mem16[i]; - } - - //ROM:004008B4 .word 0xFBA5 - for(i=0;i<0x4000/2;i++) - { - if(olds_sharedprotram[i]==(0xffff-i)) - olds_sharedprotram[i]=0x4e75; - } -} - -static READ16_HANDLER( olds_r16 ) -{ - UINT16 res ; - res = 0; - - if(offset == 1) - { - if(kb_cmd == 1) - res = reg&0x7f; - if(kb_cmd == 2) - res = olds_bs|0x80; - if(kb_cmd == 3) - res = olds_cmd3; - else if(kb_cmd == 5) - { - UINT32 protvalue = 0x900000 | input_port_read(space->machine, "Region"); // region from protection device. - res = (protvalue>>(8 * (ptr-1))) & 0xff; // includes region 1 = taiwan , 2 = china, 3 = japan (title = orlegend special), 4 = korea, 5 = hongkong, 6 = world - - } - } - logerror("%06X: ASIC25 R CMD %X VAL %X\n",cpu_get_pc(space->cpu),kb_cmd,res); - return res; -} - -static WRITE16_HANDLER( olds_w16 ) -{ - if(offset==0) - kb_cmd=data; - else //offset==2 - { - logerror("%06X: ASIC25 W CMD %X VAL %X\n",cpu_get_pc(space->cpu),kb_cmd,data); - if(kb_cmd==0) - reg=data; - else if(kb_cmd==2) //a bitswap= - { - int reg=0; - if(data&0x01) - reg|=0x40; - if(data&0x02) - reg|=0x80; - if(data&0x04) - reg|=0x20; - if(data&0x08) - reg|=0x10; - olds_bs=reg; - } - else if(kb_cmd==3) - { - UINT16 cmd=olds_sharedprotram[0x3026/2]; - switch(cmd) - { - case 0x11: - case 0x12: - break; - case 0x64: - { - UINT16 cmd0 = olds_sharedprotram[0x3082/2]; - UINT16 val0 = olds_sharedprotram[0x3050/2]; //CMD_FORMAT - { - if((cmd0&0xff)==0x2) - olds_write_reg(val0,olds_read_reg(val0)+0x10000); - } - break; - } - - default: - break; - } - olds_cmd3=((data>>4)+1)&0x3; - } - else if(kb_cmd==4) - ptr=data; - else if(kb_cmd==0x20) - ptr++; - } -} - -static READ16_HANDLER( olds_prot_swap_r16 ) -{ - - if(cpu_get_pc(space->cpu)<0x100000) //bios - return pgm_mainram[0x178F4/2]; - else //game - return pgm_mainram[0x178D8/2]; - -} - -static DRIVER_INIT( olds ) -{ - pgm_basic_init(machine); - - memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xdcb400, 0xdcb403, 0, 0, olds_r16, olds_w16); - memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8178f4, 0x8178f5, 0, 0, olds_prot_swap_r16); -} - /*** Rom Loading *************************************************************/ /* take note of "gfx2" needed for expanding the 32x32x5bpp data and @@ -4172,53 +3546,877 @@ ROM_END +/*** Init Stuff **************************************************************/ + +/* This function expands the 32x32 5-bit data into a format which is easier to + decode in MAME */ + +static void expand_32x32x5bpp(running_machine *machine) +{ + UINT8 *src = memory_region( machine, "gfx1" ); + UINT8 *dst = memory_region( machine, "gfx2" ); + size_t srcsize = memory_region_length( machine, "gfx1" ); + int cnt, pix; + + for (cnt = 0; cnt < srcsize/5 ; cnt ++) + { + pix = ((src[0 + 5 * cnt] >> 0)& 0x1f ); + dst[0 + 8 * cnt]=pix; + pix = ((src[0 + 5 * cnt] >> 5)& 0x07) | ((src[1 + 5 * cnt] << 3) & 0x18); + dst[1 + 8 * cnt]=pix; + pix = ((src[1 + 5 * cnt] >> 2)& 0x1f ); + dst[2 + 8 * cnt]=pix; + pix = ((src[1 + 5 * cnt] >> 7)& 0x01) | ((src[2 + 5 * cnt] << 1) & 0x1e); + dst[3 + 8 * cnt]=pix; + pix = ((src[2 + 5 * cnt] >> 4)& 0x0f) | ((src[3 + 5 * cnt] << 4) & 0x10); + dst[4 + 8 * cnt]=pix; + pix = ((src[3 + 5 * cnt] >> 1)& 0x1f ); + dst[5 + 8 * cnt]=pix; + pix = ((src[3 + 5 * cnt] >> 6)& 0x03) | ((src[4 + 5 * cnt] << 2) & 0x1c); + dst[6 + 8 * cnt]=pix; + pix = ((src[4 + 5 * cnt] >> 3)& 0x1f ); + dst[7 + 8 * cnt]=pix; + } +} + +/* This function expands the sprite colour data (in the A Roms) from 3 pixels + in each word to a byte per pixel making it easier to use */ + +static void expand_colourdata( running_machine *machine ) +{ + pgm_state *state = (pgm_state *)machine->driver_data; + UINT8 *src = memory_region( machine, "gfx3" ); + size_t srcsize = memory_region_length( machine, "gfx3" ); + int cnt; + size_t needed = srcsize / 2 * 3; + + /* work out how much ram we need to allocate to expand the sprites into + and be able to mask the offset */ + state->sprite_a_region_size = 1; + while (state->sprite_a_region_size < needed) + state->sprite_a_region_size <<= 1; + + state->sprite_a_region = auto_alloc_array(machine, UINT8, state->sprite_a_region_size); + + for (cnt = 0 ; cnt < srcsize / 2 ; cnt++) + { + UINT16 colpack; + + colpack = ((src[cnt * 2]) | (src[cnt * 2 + 1] << 8)); + state->sprite_a_region[cnt * 3 + 0] = (colpack >> 0 ) & 0x1f; + state->sprite_a_region[cnt * 3 + 1] = (colpack >> 5 ) & 0x1f; + state->sprite_a_region[cnt * 3 + 2] = (colpack >> 10) & 0x1f; + } +} + +static void pgm_basic_init( running_machine *machine ) +{ + pgm_state *state = (pgm_state *)machine->driver_data; + UINT8 *ROM = memory_region(machine, "maincpu"); + memory_set_bankptr(machine, "bank1", &ROM[0x100000]); + + expand_32x32x5bpp(machine); + expand_colourdata(machine); + + state->bg_videoram = &state->videoram[0]; + state->tx_videoram = &state->videoram[0x4000/2]; + state->rowscrollram = &state->videoram[0x7000/2]; +} + +static DRIVER_INIT( pgm ) +{ + pgm_basic_init(machine); +} + +/* Oriental Legend INIT */ + +static DRIVER_INIT( orlegend ) +{ + pgm_state *state = (pgm_state *)machine->driver_data; + pgm_basic_init(machine); + + memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xC0400e, 0xC0400f, 0, 0, pgm_asic3_r, pgm_asic3_w); + memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xC04000, 0xC04001, 0, 0, pgm_asic3_reg_w); + + state->asic3_reg = 0; + state->asic3_latch[0] = 0; + state->asic3_latch[1] = 0; + state->asic3_latch[2] = 0; + state->asic3_x = 0; + state->asic3_y = 0; + state->asic3_z = 0; + state->asic3_h1 = 0; + state->asic3_h2 = 0; + state->asic3_hold = 0; + + state_save_register_global(machine, state->asic3_reg); + state_save_register_global_array(machine, state->asic3_latch); + state_save_register_global(machine, state->asic3_x); + state_save_register_global(machine, state->asic3_y); + state_save_register_global(machine, state->asic3_z); + state_save_register_global(machine, state->asic3_h1); + state_save_register_global(machine, state->asic3_h2); + state_save_register_global(machine, state->asic3_hold); +} + +static void drgwld2_common_init(running_machine *machine) +{ + pgm_basic_init(machine); + pgm_dw2_decrypt(machine); + /* + Info from Elsemi + Here is how to "bypass" the dw2 hang protection, it fixes the mode + select and after failing in the 2nd stage (probably there are other checks + out there). + */ + memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xd80000, 0xd80003, 0, 0, dw2_d80000_r); +} + +static DRIVER_INIT( drgw2 ) +{ /* incomplete? */ + UINT16 *mem16 = (UINT16 *)memory_region(machine, "maincpu"); + drgwld2_common_init(machine); + /* These ROM patches are not hacks, the protection device + overlays the normal ROM code, this has been confirmed on a real PCB + although some addresses may be missing */ + mem16[0x131098 / 2] = 0x4e93; + mem16[0x13113e / 2] = 0x4e93; + mem16[0x1311ce / 2] = 0x4e93; +} + +static DRIVER_INIT( drgw2c ) +{ + UINT16 *mem16 = (UINT16 *)memory_region(machine, "maincpu"); + drgwld2_common_init(machine); + /* These ROM patches are not hacks, the protection device + overlays the normal ROM code, this has been confirmed on a real PCB + although some addresses may be missing */ + mem16[0x1303bc / 2] = 0x4e93; + mem16[0x130462 / 2] = 0x4e93; + mem16[0x1304f2 / 2] = 0x4e93; +} + +static DRIVER_INIT( drgw2j ) +{ + UINT16 *mem16 = (UINT16 *)memory_region(machine, "maincpu"); + drgwld2_common_init(machine); + /* These ROM patches are not hacks, the protection device + overlays the normal ROM code, this has been confirmed on a real PCB + although some addresses may be missing */ + mem16[0x1302c0 / 2] = 0x4e93; + mem16[0x130366 / 2] = 0x4e93; + mem16[0x1303f6 / 2] = 0x4e93; +} + +static void kovsh_latch_init( running_machine *machine ) +{ + pgm_state *state = (pgm_state *)machine->driver_data; + + state->kovsh_highlatch_arm_w = 0; + state->kovsh_lowlatch_arm_w = 0; + state->kovsh_highlatch_68k_w = 0; + state->kovsh_lowlatch_68k_w = 0; + state->kovsh_counter = 1; + + state_save_register_global(machine, state->kovsh_highlatch_arm_w); + state_save_register_global(machine, state->kovsh_lowlatch_arm_w); + state_save_register_global(machine, state->kovsh_highlatch_68k_w); + state_save_register_global(machine, state->kovsh_lowlatch_68k_w); + state_save_register_global(machine, state->kovsh_counter); +} + +static DRIVER_INIT( kov ) +{ + pgm_basic_init(machine); + pgm_kov_decrypt(machine); + kovsh_latch_init(machine); +} + +static DRIVER_INIT( pstar ) +{ + pgm_state *state = (pgm_state *)machine->driver_data; + + pgm_basic_init(machine); + pgm_pstar_decrypt(machine); + kovsh_latch_init(machine); + + state->pstars_key = 0; + state->pstars_int[0] = 0; + state->pstars_int[1] = 0; + state->pstars_val = 0; + state->pstar_e7 = 0; + state->pstar_b1 = 0; + state->pstar_ce = 0; + state->pstar_ram[0] = 0; + state->pstar_ram[1] = 0; + state->pstar_ram[2] = 0; + memset(state->pstars_regs, 0, 16); + + state_save_register_global(machine, state->pstars_key); + state_save_register_global_array(machine, state->pstars_int); + state_save_register_global_array(machine, state->pstars_regs); + state_save_register_global(machine, state->pstars_val); + state_save_register_global(machine, state->pstar_e7); + state_save_register_global(machine, state->pstar_b1); + state_save_register_global(machine, state->pstar_ce); + state_save_register_global_array(machine, state->pstar_ram); +} + +static DRIVER_INIT( djlzz ) +{ + pgm_basic_init(machine); + pgm_djlzz_decrypt(machine); + kovsh_latch_init(machine); +} + +static DRIVER_INIT( kovsh ) +{ + pgm_basic_init(machine); + pgm_kovsh_decrypt(machine); + kovsh_latch_init(machine); +} + +static DRIVER_INIT( kovshp ) +{ + pgm_basic_init(machine); + pgm_kovshp_decrypt(machine); + kovsh_latch_init(machine); +} + +static DRIVER_INIT( oldsplus ) +{ + pgm_basic_init(machine); + pgm_oldsplus_decrypt(machine); + kovsh_latch_init(machine); +} + +static void kov2_latch_init( running_machine *machine ) +{ + pgm_state *state = (pgm_state *)machine->driver_data; + + state->kov2_latchdata_68k_w = 0; + state->kov2_latchdata_arm_w = 0; + + state_save_register_global(machine, state->kov2_latchdata_68k_w); + state_save_register_global(machine, state->kov2_latchdata_arm_w); +} + +static DRIVER_INIT( kov2 ) +{ + pgm_basic_init(machine); + pgm_kov2_decrypt(machine); + kov2_latch_init(machine); +} + +static DRIVER_INIT( kov2p ) +{ + pgm_basic_init(machine); + pgm_kov2p_decrypt(machine); + kov2_latch_init(machine); +} + +static DRIVER_INIT( martmast ) +{ + pgm_basic_init(machine); + pgm_mm_decrypt(machine); + kov2_latch_init(machine); +} + +static DRIVER_INIT( ddp2 ) +{ + pgm_basic_init(machine); + pgm_ddp2_decrypt(machine); + kov2_latch_init(machine); +} + +static void svg_basic_init(running_machine *machine) +{ + pgm_state *state = (pgm_state *)machine->driver_data; + + pgm_basic_init(machine); + state->svg_shareram[0] = auto_alloc_array(machine, UINT32, 0x10000 / 4); + state->svg_shareram[1] = auto_alloc_array(machine, UINT32, 0x10000 / 4); + state->svg_ram_sel = 0; + + state_save_register_global_pointer(machine, state->svg_shareram[0], 0x10000 / 4); + state_save_register_global_pointer(machine, state->svg_shareram[1], 0x10000 / 4); + state_save_register_global(machine, state->svg_ram_sel); +} + +static DRIVER_INIT( theglad ) +{ + svg_basic_init(machine); + pgm_theglad_decrypt(machine); + kov2_latch_init(machine); +} + +static DRIVER_INIT( svg ) +{ + svg_basic_init(machine); + pgm_svg_decrypt(machine); + kov2_latch_init(machine); +} + +static DRIVER_INIT( killbldp ) +{ + svg_basic_init(machine); + pgm_killbldp_decrypt(machine); + kov2_latch_init(machine); +} + +static DRIVER_INIT( dmnfrnt ) +{ + svg_basic_init(machine); + pgm_dfront_decrypt(machine); + kov2_latch_init(machine); +} + +static DRIVER_INIT( dw3 ) +{ + pgm_basic_init(machine); + +// memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xda0000, 0xdaffff, 0, 0, dw3_prot_r, dw3_prot_w); + + pgm_dw3_decrypt(machine); +} + +/* Killing Blade uses some kind of DMA protection device which can copy data from a data rom. The + MCU appears to have an internal ROM as if you remove the data ROM then the shared ram is filled + with a constant value. + + The device can perform various decryption operations on the data it copies. for now we're just + using a dump of the shared RAM instead. This will be improved later. +*/ + + +static WRITE16_HANDLER( killbld_prot_w ) +{ +// mame_printf_debug("killbrd prot r\n"); +// return 0; + pgm_state *state = (pgm_state *)space->machine->driver_data; + offset &= 0xf; + + if (offset == 0) + state->kb_cmd = data; + else //offset==2 + { + logerror("%06X: ASIC25 W CMD %X VAL %X", cpu_get_pc(space->cpu), state->kb_cmd, data); + if (state->kb_cmd == 0) + state->kb_reg = data; + else if (state->kb_cmd == 2) + { + if (data == 1) //Execute cmd + { + UINT16 cmd = state->sharedprotram[0x200/2]; + //mame_printf_debug("command %04x\n", cmd); + if (cmd == 0x6d) //Store values to asic ram + { + UINT32 p1 = (state->sharedprotram[0x298/2] << 16) | state->sharedprotram[0x29a/2]; + UINT32 p2 = (state->sharedprotram[0x29c/2] << 16) | state->sharedprotram[0x29e/2]; + + if ((p2 & 0xffff) == 0x9) //Set value + { + int reg = (p2 >> 16) & 0xffff; + if (reg & 0x200) + state->kb_regs[reg & 0xff] = p1; + } + if ((p2 & 0xffff) == 0x6) //Add value + { + int src1 = (p1 >> 16) & 0xff; + int src2 = (p1 >> 0) & 0xff; + int dst = (p2 >> 16) & 0xff; + state->kb_regs[dst] = state->kb_regs[src2] - state->kb_regs[src1]; + } + if ((p2 & 0xffff) == 0x1) //Add Imm? + { + int reg = (p2 >> 16) & 0xff; + int imm = (p1 >> 0) & 0xffff; + state->kb_regs[reg] += imm; + } + if ((p2 & 0xffff) == 0xa) //Get value + { + int reg = (p1 >> 16) & 0xFF; + state->sharedprotram[0x29c/2] = (state->kb_regs[reg] >> 16) & 0xffff; + state->sharedprotram[0x29e/2] = state->kb_regs[reg] & 0xffff; + } + } + if(cmd == 0x4f) //memcpy with encryption / scrambling + { + UINT16 src = state->sharedprotram[0x290 / 2] >> 1; // ? + UINT32 dst = state->sharedprotram[0x292 / 2]; + UINT16 size = state->sharedprotram[0x294 / 2]; + UINT16 mode = state->sharedprotram[0x296 / 2]; + + + // int a=1; + // if(src==0x580) + // int a=1; + /* + P_SRC =0x300290 (offset from prot rom base) + P_DST =0x300292 (words from 0x300000) + P_SIZE=0x300294 (words) + P_MODE=0x300296 + + Mode 5 direct + Mode 6 swap nibbles and bytes + + 1,2,3 unk. + */ + + //mame_printf_debug("src %04x dst %04x size %04x mode %04x\n", src, dst, size, mode); + + //if (src&1) mame_printf_debug("odd offset\n"); + + mode &=0xf; // what are the other bits? + + if (mode == 1 || mode == 2 || mode == 3) + { + /* for now, cheat -- the scramble isn't understood, it might + be state based */ + int x; + UINT16 *RAMDUMP = (UINT16*)memory_region(space->machine, "user2"); + for (x = 0; x < size; x++) + { + UINT16 dat; + + dat = RAMDUMP[dst + x]; + state->sharedprotram[dst + x] = dat; + } + } + else if (mode == 5) + { + /* mode 5 seems to be a straight copy */ + int x; + UINT16 *RAMDUMP = (UINT16*)memory_region(space->machine, "user2"); + UINT16 *PROTROM = (UINT16*)memory_region(space->machine, "user1"); + for (x = 0; x < size; x++) + { + UINT16 dat = PROTROM[src + x]; + + if (RAMDUMP[dst + x] != dat) + mame_printf_debug("Mismatch! %04x %04x\n", RAMDUMP[dst + x], dat); + + state->sharedprotram[dst + x] = dat; + } + } + else if (mode == 6) + { + /* mode 6 seems to swap bytes and nibbles */ + int x; + UINT16 *RAMDUMP = (UINT16*)memory_region(space->machine, "user2"); + UINT16 *PROTROM = (UINT16*)memory_region(space->machine, "user1"); + for (x = 0; x < size; x++) + { + UINT16 dat = PROTROM[src + x]; + + dat = ((dat & 0xf000) >> 12)| + ((dat & 0x0f00) >> 4)| + ((dat & 0x00f0) << 4)| + ((dat & 0x000f) << 12); + + if (RAMDUMP[dst + x] != dat) + mame_printf_debug("Mismatch! Mode 6 %04x %04x\n", RAMDUMP[dst + x], dat); + + state->sharedprotram[dst + x] = dat; + } + } + else + { + mame_printf_debug("unknown copy mode!\n"); + } + /* hack.. it jumps here but there isn't valid code even when we do + use what was in ram.. probably some more protection as the game + still doesn't behave 100% correctly :-/ + + the code is copied in 'mode 3' but even the code put here on + the real ram dump is corrupt??? something _very_ strange is + going on.. maybe more rom overlays, or ram overlays too?? + + */ + state->sharedprotram[0x2600 / 2] = 0x4e75; + + + } + state->kb_reg++; + } + } + else if (state->kb_cmd == 4) + state->kb_ptr = data; + else if (state->kb_cmd == 0x20) + state->kb_ptr++; + } +} + +static READ16_HANDLER( killbld_prot_r ) +{ +// mame_printf_debug("killbld prot w\n"); + pgm_state *state = (pgm_state *)space->machine->driver_data; + UINT16 res ; + + offset &= 0xf; + res = 0; + + if (offset == 1) + { + if (state->kb_cmd == 1) + { + res = state->kb_reg & 0x7f; + } + else if (state->kb_cmd == 5) + { + UINT32 protvalue = 0x89911400 | input_port_read(space->machine, "Region"); + res = (protvalue >> (8 * (state->kb_ptr - 1))) & 0xff; + } + } + logerror("%06X: ASIC25 R CMD %X VAL %X", cpu_get_pc(space->cpu), state->kb_cmd, res); + return res; +} + +static MACHINE_RESET( killbld ) +{ + pgm_state *state = (pgm_state *)machine->driver_data; + int i; + + MACHINE_RESET_CALL(pgm); + + /* fill the protection ram with a5 */ + for (i = 0; i < 0x4000/2; i++) + state->sharedprotram[i] = 0xa5a5; +} + + +static DRIVER_INIT( killbld ) +{ + pgm_state *state = (pgm_state *)machine->driver_data; + UINT16 *mem16 = (UINT16 *)memory_region(machine, "maincpu"); + + pgm_basic_init(machine); + pgm_killbld_decrypt(machine); + + /* this isn't a hack.. doing a rom dump while the game is running shows the + rom space to look like this.. there may be more overlays / enables tho */ + + /* the game actually performs a CRC check of the rom during the 'Please Wait' + screen, the checksum expected is that of the patched rom. if the checksum + fails the please wait screen doesn't last as long and the region supplied + by the protection device is ignored and the attract sequence appears out + of order */ + mem16[0x108a2c / 2] = 0xb6aa; + mem16[0x108a30 / 2] = 0x6610; + mem16[0x108a32 / 2] = 0x13c2; + mem16[0x108a34 / 2] = 0x0080; + mem16[0x108a36 / 2] = 0x9c76; + mem16[0x108a38 / 2] = 0x23c3; + mem16[0x108a3a / 2] = 0x0080; + mem16[0x108a3c / 2] = 0x9c78; + mem16[0x108a3e / 2] = 0x1002; + mem16[0x108a40 / 2] = 0x6054; + mem16[0x108a42 / 2] = 0x5202; + mem16[0x108a44 / 2] = 0x0c02; + + memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xd40000, 0xd40003, 0, 0, killbld_prot_r, killbld_prot_w); + + state->kb_cmd = 0; + state->kb_reg = 0; + state->kb_ptr = 0; + memset(state->kb_regs, 0, 0x10); + + state_save_register_global(machine, state->kb_cmd); + state_save_register_global(machine, state->kb_reg); + state_save_register_global(machine, state->kb_ptr); + state_save_register_global_array(machine, state->kb_regs); +} + +static DRIVER_INIT( puzzli2 ) +{ + /* this protection emulation is wrong + it uses an arm with no external rom + an acts in a similar way to kov etc. */ + + pgm_state *state = (pgm_state *)machine->driver_data; + UINT16 *mem16 = (UINT16 *)memory_region(machine, "maincpu"); + + pgm_basic_init(machine); + kovsh_latch_init(machine); + + memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x500000, 0x500003, 0, 0, asic28_r, asic28_w); + + /* 0x4f0000 - ? is actually ram shared with the protection device, + the protection device provides the region code */ + memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x4f0000, 0x4fffff, 0, 0, sango_protram_r); + + pgm_puzzli2_decrypt(machine); + + /* protection related? */ + mem16[0x1548ec / 2] = 0x4e71; + mem16[0x1548fc / 2] = 0x4e71; + mem16[0x1549fa / 2] = 0x4e71; + mem16[0x154a0a / 2] = 0x4e71; + mem16[0x15496a / 2] = 0x4e71; + mem16[0x14cee0 / 2] = 0x4e71; + mem16[0x1268c0 / 2] = 0x4e71; + mem16[0x1268c2 / 2] = 0x4e71; + mem16[0x1268c4 / 2] = 0x4e71; + mem16[0x154948 / 2] = 0x4e71; + mem16[0x13877a / 2] = 0x662c; + + /* patch irq4 vector (irq4 should be disabled on this game? how?) */ +// mem16[0x100070 / 2] = 0x0012; +// mem16[0x100072 / 2] = 0x5d78; + + state->asic28_key = 0; + state->asic28_rcnt = 0; + memset(state->asic28_regs, 0, 10); + memset(state->asic_params, 0, 256); + memset(state->eoregs, 0, 16); + + state_save_register_global(machine, state->asic28_key); + state_save_register_global(machine, state->asic28_rcnt); + state_save_register_global_array(machine, state->asic28_regs); + state_save_register_global_array(machine, state->asic_params); + state_save_register_global_array(machine, state->eoregs); +} + +static UINT32 olds_prot_addr( UINT16 addr ) +{ + UINT32 mode = addr & 0xff; + UINT32 offset = addr >> 8; + UINT32 realaddr; + + switch(mode) + { + case 0x0: + case 0x5: + case 0xa: + realaddr = 0x402a00 + (offset << 2); + break; + + case 0x2: + case 0x8: + realaddr = 0x402e00 + (offset << 2); + break; + + case 0x1: + realaddr = 0x40307e; + break; + + case 0x3: + realaddr = 0x403090; + break; + + case 0x4: + realaddr = 0x40309a; + break; + + case 0x6: + realaddr = 0x4030a4; + break; + + case 0x7: + realaddr = 0x403000; + break; + + case 0x9: + realaddr = 0x40306e; + break; + + default: + realaddr = 0; + } + return realaddr; +} + +static UINT32 olds_read_reg( running_machine *machine, UINT16 addr ) +{ + pgm_state *state = (pgm_state *)machine->driver_data; + UINT32 protaddr = (olds_prot_addr(addr) - 0x400000) / 2; + return state->sharedprotram[protaddr] << 16 | state->sharedprotram[protaddr + 1]; +} + +static void olds_write_reg( running_machine *machine, UINT16 addr, UINT32 val ) +{ + pgm_state *state = (pgm_state *)machine->driver_data; + state->sharedprotram[(olds_prot_addr(addr) - 0x400000) / 2] = val >> 16; + state->sharedprotram[(olds_prot_addr(addr) - 0x400000) / 2 + 1] = val & 0xffff; +} + +static MACHINE_RESET( olds ) +{ + pgm_state *state = (pgm_state *)machine->driver_data; + UINT16 *mem16 = (UINT16 *)memory_region(machine, "user2"); + int i; + + MACHINE_RESET_CALL(pgm); + + /* populate shared protection ram with data read from pcb .. */ + for (i = 0; i < 0x4000 / 2; i++) + { + state->sharedprotram[i] = mem16[i]; + } + + //ROM:004008B4 .word 0xFBA5 + for(i = 0; i < 0x4000 / 2; i++) + { + if (state->sharedprotram[i] == (0xffff - i)) + state->sharedprotram[i] = 0x4e75; + } +} + +static READ16_HANDLER( olds_r ) +{ + pgm_state *state = (pgm_state *)space->machine->driver_data; + UINT16 res = 0; + + if (offset == 1) + { + if (state->kb_cmd == 1) + res = state->kb_reg & 0x7f; + if (state->kb_cmd == 2) + res = state->olds_bs | 0x80; + if (state->kb_cmd == 3) + res = state->olds_cmd3; + else if (state->kb_cmd == 5) + { + UINT32 protvalue = 0x900000 | input_port_read(space->machine, "Region"); // region from protection device. + res = (protvalue >> (8 * (state->kb_ptr - 1))) & 0xff; // includes region 1 = taiwan , 2 = china, 3 = japan (title = orlegend special), 4 = korea, 5 = hongkong, 6 = world + + } + } + logerror("%06X: ASIC25 R CMD %X VAL %X\n", cpu_get_pc(space->cpu), state->kb_cmd, res); + return res; +} + +static WRITE16_HANDLER( olds_w ) +{ + pgm_state *state = (pgm_state *)space->machine->driver_data; + if (offset == 0) + state->kb_cmd = data; + else //offset==2 + { + logerror("%06X: ASIC25 W CMD %X VAL %X\n",cpu_get_pc(space->cpu), state->kb_cmd, data); + if (state->kb_cmd == 0) + state->kb_reg = data; + else if(state->kb_cmd == 2) //a bitswap= + { + int reg = 0; + if (data & 0x01) + reg |= 0x40; + if (data & 0x02) + reg |= 0x80; + if (data & 0x04) + reg |= 0x20; + if (data & 0x08) + reg |= 0x10; + state->olds_bs = reg; + } + else if (state->kb_cmd == 3) + { + UINT16 cmd = state->sharedprotram[0x3026 / 2]; + switch (cmd) + { + case 0x11: + case 0x12: + break; + case 0x64: + { + UINT16 cmd0 = state->sharedprotram[0x3082 / 2]; + UINT16 val0 = state->sharedprotram[0x3050 / 2]; //CMD_FORMAT + { + if ((cmd0 & 0xff) == 0x2) + olds_write_reg(space->machine, val0, olds_read_reg(space->machine, val0) + 0x10000); + } + break; + } + + default: + break; + } + state->olds_cmd3 = ((data >> 4) + 1) & 0x3; + } + else if (state->kb_cmd == 4) + state->kb_ptr = data; + else if(state->kb_cmd == 0x20) + state->kb_ptr++; + } +} + +static READ16_HANDLER( olds_prot_swap_r ) +{ + if (cpu_get_pc(space->cpu) < 0x100000) //bios + return pgm_mainram[0x178f4 / 2]; + else //game + return pgm_mainram[0x178d8 / 2]; + +} + +static DRIVER_INIT( olds ) +{ + pgm_state *state = (pgm_state *)machine->driver_data; + pgm_basic_init(machine); + + memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xdcb400, 0xdcb403, 0, 0, olds_r, olds_w); + memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8178f4, 0x8178f5, 0, 0, olds_prot_swap_r); + + state->kb_cmd = 0; + state->kb_reg = 0; + state->kb_ptr = 0; + state->olds_bs = 0; + state->olds_cmd3 = 0; + + state_save_register_global(machine, state->kb_cmd); + state_save_register_global(machine, state->kb_reg); + state_save_register_global(machine, state->kb_ptr); + state_save_register_global(machine, state->olds_bs); + state_save_register_global(machine, state->olds_cmd3); +} + /*** GAME ********************************************************************/ GAME( 1997, pgm, 0, pgm, pgm, pgm, ROT0, "IGS", "PGM (Polygame Master) System BIOS", GAME_IS_BIOS_ROOT ) -GAME( 1997, orlegend, pgm, pgm, pgm, orlegend, ROT0, "IGS", "Oriental Legend / Xi You Shi E Zhuan (ver. 126)", GAME_IMPERFECT_SOUND ) -GAME( 1997, orlegende, orlegend, pgm, pgm, orlegend, ROT0, "IGS", "Oriental Legend / Xi You Shi E Zhuan (ver. 112)", GAME_IMPERFECT_SOUND ) -GAME( 1997, orlegendc, orlegend, pgm, pgm, orlegend, ROT0, "IGS", "Oriental Legend / Xi You Shi E Zhuan (ver. 112, Chinese Board)", GAME_IMPERFECT_SOUND ) -GAME( 1997, orlegend111c, orlegend, pgm, pgm, orlegend, ROT0, "IGS", "Oriental Legend / Xi You Shi E Zhuan (ver. 111, Chinese Board)", GAME_IMPERFECT_SOUND ) -GAME( 1997, orlegend105k, orlegend, pgm, orld105k, orlegend, ROT0, "IGS", "Oriental Legend / Xi You Shi E Zhuan (ver. 105, Korean Board)", GAME_IMPERFECT_SOUND ) -GAME( 1997, drgw2c, drgw2, drgw2, pgm, drgw2c, ROT0, "IGS", "Zhong Guo Long II (ver. 100C, China)", GAME_IMPERFECT_SOUND ) -GAME( 1999, photoy2k, pgm, kov, photoy2k, djlzz, ROT0, "IGS", "Photo Y2K (ver. 104)", GAME_IMPERFECT_SOUND ) /* region provided by protection device */ -GAME( 1999, raf102j, photoy2k, kov, photoy2k, djlzz, ROT0, "IGS", "Real and Fake / Photo Y2K (ver. 102, Japanese Board)", GAME_IMPERFECT_SOUND ) /* region provided by protection device */ -GAME( 1999, kovsh, kov, kov, sango, kovsh, ROT0, "IGS", "Knights of Valour Super Heroes / Sangoku Senki Super Heroes (ver. 104)", GAME_IMPERFECT_SOUND ) -GAME( 2000, kov2, pgm, kov2, sango, kov2, ROT0, "IGS", "Knights of Valour 2 / Sangoku Senki 2 (ver. 100)", GAME_IMPERFECT_SOUND ) -GAME( 2000, kov2106, kov2, kov2, sango, kov2, ROT0, "IGS", "Knights of Valour 2 / Sangoku Senki 2 (ver. 106)", GAME_IMPERFECT_SOUND ) -GAME( 2001, martmast, pgm, kov2, sango, martmast, ROT0, "IGS", "Martial Masters (ver. 102)", GAME_IMPERFECT_SOUND ) -GAME( 2001, martmastc,martmast, kov2, sango, martmast, ROT0, "IGS", "Martial Masters (ver. 101, Chinese Board)", GAME_IMPERFECT_SOUND ) +GAME( 1997, orlegend, pgm, pgm, pgm, orlegend, ROT0, "IGS", "Oriental Legend / Xi You Shi E Zhuan (ver. 126)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 1997, orlegende, orlegend, pgm, pgm, orlegend, ROT0, "IGS", "Oriental Legend / Xi You Shi E Zhuan (ver. 112)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 1997, orlegendc, orlegend, pgm, pgm, orlegend, ROT0, "IGS", "Oriental Legend / Xi You Shi E Zhuan (ver. 112, Chinese Board)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 1997, orlegend111c, orlegend, pgm, pgm, orlegend, ROT0, "IGS", "Oriental Legend / Xi You Shi E Zhuan (ver. 111, Chinese Board)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 1997, orlegend105k, orlegend, pgm, orld105k, orlegend, ROT0, "IGS", "Oriental Legend / Xi You Shi E Zhuan (ver. 105, Korean Board)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 1997, drgw2c, drgw2, drgw2, pgm, drgw2c, ROT0, "IGS", "Zhong Guo Long II (ver. 100C, China)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 1999, photoy2k, pgm, kov, photoy2k, djlzz, ROT0, "IGS", "Photo Y2K (ver. 104)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) /* region provided by protection device */ +GAME( 1999, raf102j, photoy2k, kov, photoy2k, djlzz, ROT0, "IGS", "Real and Fake / Photo Y2K (ver. 102, Japanese Board)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) /* region provided by protection device */ +GAME( 1999, kovsh, kov, kov, sango, kovsh, ROT0, "IGS", "Knights of Valour Super Heroes / Sangoku Senki Super Heroes (ver. 104)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 2000, kov2, pgm, kov2, sango, kov2, ROT0, "IGS", "Knights of Valour 2 / Sangoku Senki 2 (ver. 100)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 2000, kov2106, kov2, kov2, sango, kov2, ROT0, "IGS", "Knights of Valour 2 / Sangoku Senki 2 (ver. 106)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 2001, martmast, pgm, kov2, sango, martmast, ROT0, "IGS", "Martial Masters (ver. 102)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 2001, martmastc,martmast, kov2, sango, martmast, ROT0, "IGS", "Martial Masters (ver. 101, Chinese Board)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) /* Playable but maybe imperfect protection emulation */ -GAME( 1997, drgw2, pgm, drgw2, pgm, drgw2, ROT0, "IGS", "Dragon World II (ver. 110X, Export)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) -GAME( 1997, drgw2j, drgw2, drgw2, pgm, drgw2j, ROT0, "IGS", "Chuugokuryuu II (ver. 100J, Japan)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) -GAME( 1998, killbldt, killbld, killbld, killbld, killbld, ROT0, "IGS", "The Killing Blade (ver. 109, Chinese Board)", GAME_IMPERFECT_SOUND ) // it's playable, but there are some things unclear about the protection -GAME( 1998, olds, pgm, olds, olds, olds, ROT0, "IGS", "Oriental Legend Special / Xi You Shi E Zhuan Super (ver. 101, Korean Board)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) -GAME( 1998, olds100, olds, olds, olds, olds, ROT0, "IGS", "Oriental Legend Special / Xi You Shi E Zhuan Super (ver. 100)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) -GAME( 1998, olds100a, olds, olds, olds, olds, ROT0, "IGS", "Oriental Legend Special / Xi You Shi E Zhuan Super (alt ver. 100)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) // grashes on some bosses, high score table etc. +GAME( 1997, drgw2, pgm, drgw2, pgm, drgw2, ROT0, "IGS", "Dragon World II (ver. 110X, Export)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) +GAME( 1997, drgw2j, drgw2, drgw2, pgm, drgw2j, ROT0, "IGS", "Chuugokuryuu II (ver. 100J, Japan)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) +GAME( 1998, killbldt, killbld, killbld, killbld, killbld, ROT0, "IGS", "The Killing Blade (ver. 109, Chinese Board)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) // it's playable, but there are some things unclear about the protection +GAME( 1998, olds, pgm, olds, olds, olds, ROT0, "IGS", "Oriental Legend Special / Xi You Shi E Zhuan Super (ver. 101, Korean Board)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) +GAME( 1998, olds100, olds, olds, olds, olds, ROT0, "IGS", "Oriental Legend Special / Xi You Shi E Zhuan Super (ver. 100)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) +GAME( 1998, olds100a, olds, olds, olds, olds, ROT0, "IGS", "Oriental Legend Special / Xi You Shi E Zhuan Super (alt ver. 100)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) // grashes on some bosses, high score table etc. /* not working */ -GAME( 1998, drgw3, pgm, pgm, sango, dw3, ROT0, "IGS", "Dragon World 3 (ver. 100)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) -GAME( 1998, drgw3k, drgw3, pgm, sango, dw3, ROT0, "IGS", "Dragon World 3 (ver. 106, Korean Board)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) -GAME( 1998, killbld, pgm, killbld, killbld, killbld, ROT0, "IGS", "The Killing Blade (ver. 104)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) -GAME( 1999, kov, pgm, kov, sango, kov, ROT0, "IGS", "Knights of Valour / Sangoku Senki (ver. 117)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */ -GAME( 1999, kov115, kov, kov, sango, kov, ROT0, "IGS", "Knights of Valour / Sangoku Senki (ver. 115)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */ -GAME( 1999, kovj, kov, kov, sango, kov, ROT0, "IGS", "Knights of Valour / Sangoku Senki (ver. 100, Japanese Board)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */ -GAME( 1999, kovplus, kov, kov, sango, kov, ROT0, "IGS", "Knights of Valour Plus / Sangoku Senki Plus (ver. 119)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */ -GAME( 1999, kovplusa, kov, kov, sango, kov, ROT0, "IGS", "Knights of Valour Plus / Sangoku Senki Plus (alt ver. 119)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */ -GAME( 1999, puzlstar, pgm, kov, sango, pstar, ROT0, "IGS", "Puzzle Star (ver. 100MG)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */ -GAME( 2001, kov2p, kov2, kov2, sango, kov2p, ROT0, "IGS", "Knights of Valour 2 Plus - Nine Dragons / Sangoku Senki 2 Plus - Nine Dragons (ver. M204XX)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */ -GAME( 2001, kov2p205, kov2, kov2, sango, kov2p, ROT0, "IGS", "Knights of Valour 2 Plus - Nine Dragons / Sangoku Senki 2 Plus - Nine Dragons (ver. M205XX)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */ -GAME( 2001, ddp2, pgm, kov2, ddp2, ddp2, ROT270, "IGS", "Bee Storm - DoDonPachi II (ver. 100)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */ -GAME( 2001, ddp2a, ddp2, kov2, ddp2, ddp2, ROT270, "IGS", "Bee Storm - DoDonPachi II (ver. 102)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */ -GAME( 2001, puzzli2, pgm, kov, sango, puzzli2, ROT0, "IGS", "Puzzli 2 Super (ver. 200)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) -GAME( 2002, dmnfrnt, pgm, svg, sango, dmnfrnt, ROT0, "IGS", "Demon Front (ver. 102)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */ -GAME( 2002, dmnfrnta, dmnfrnt, svg, sango, dmnfrnt, ROT0, "IGS", "Demon Front (ver. 105)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */ -GAME( 2003, theglad, pgm, svg, sango, theglad, ROT0, "IGS", "The Gladiator (ver. 100)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */ -GAME( 2003, theglada, theglad, svg, sango, theglad, ROT0, "IGS", "The Gladiator (ver. 101)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */ -GAME( 2004, oldsplus, pgm, kov, olds, oldsplus, ROT0, "IGS", "Oriental Legend Special Plus / Xi You Shi E Zhuan Super Plus", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */ -GAME( 2004, kovshp, kov, kov, sango, kovshp, ROT0, "IGS", "Knights of Valour Super Heroes Plus / Sangoku Senki Super Heroes Plus (ver. 100)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */ -GAME( 2005, killbldp, pgm, svg, sango, killbldp, ROT0, "IGS", "The Killing Blade Plus (ver. 300)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */ -GAME( 2004, happy6, pgm, svg, sango, svg, ROT0, "IGS", "Happy 6-in-1 (ver. 101CN)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */ -GAME( 2005, svg, pgm, svg, sango, svg, ROT0, "IGS", "S.V.G. - Spectral vs Generation (ver. 200)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */ +GAME( 1998, drgw3, pgm, pgm, sango, dw3, ROT0, "IGS", "Dragon World 3 (ver. 100)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) +GAME( 1998, drgw3k, drgw3, pgm, sango, dw3, ROT0, "IGS", "Dragon World 3 (ver. 106, Korean Board)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) +GAME( 1998, killbld, pgm, killbld, killbld, killbld, ROT0, "IGS", "The Killing Blade (ver. 104)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) +GAME( 1999, kov, pgm, kov, sango, kov, ROT0, "IGS", "Knights of Valour / Sangoku Senki (ver. 117)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */ +GAME( 1999, kov115, kov, kov, sango, kov, ROT0, "IGS", "Knights of Valour / Sangoku Senki (ver. 115)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */ +GAME( 1999, kovj, kov, kov, sango, kov, ROT0, "IGS", "Knights of Valour / Sangoku Senki (ver. 100, Japanese Board)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */ +GAME( 1999, kovplus, kov, kov, sango, kov, ROT0, "IGS", "Knights of Valour Plus / Sangoku Senki Plus (ver. 119)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */ +GAME( 1999, kovplusa, kov, kov, sango, kov, ROT0, "IGS", "Knights of Valour Plus / Sangoku Senki Plus (alt ver. 119)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */ +GAME( 1999, puzlstar, pgm, kov, sango, pstar, ROT0, "IGS", "Puzzle Star (ver. 100MG)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */ +GAME( 2001, kov2p, kov2, kov2, sango, kov2p, ROT0, "IGS", "Knights of Valour 2 Plus - Nine Dragons / Sangoku Senki 2 Plus - Nine Dragons (ver. M204XX)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */ +GAME( 2001, kov2p205, kov2, kov2, sango, kov2p, ROT0, "IGS", "Knights of Valour 2 Plus - Nine Dragons / Sangoku Senki 2 Plus - Nine Dragons (ver. M205XX)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */ +GAME( 2001, ddp2, pgm, kov2, ddp2, ddp2, ROT270, "IGS", "Bee Storm - DoDonPachi II (ver. 100)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */ +GAME( 2001, ddp2a, ddp2, kov2, ddp2, ddp2, ROT270, "IGS", "Bee Storm - DoDonPachi II (ver. 102)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */ +GAME( 2001, puzzli2, pgm, kov, sango, puzzli2, ROT0, "IGS", "Puzzli 2 Super (ver. 200)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) +GAME( 2002, dmnfrnt, pgm, svg, sango, dmnfrnt, ROT0, "IGS", "Demon Front (ver. 102)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */ +GAME( 2002, dmnfrnta, dmnfrnt, svg, sango, dmnfrnt, ROT0, "IGS", "Demon Front (ver. 105)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */ +GAME( 2003, theglad, pgm, svg, sango, theglad, ROT0, "IGS", "The Gladiator (ver. 100)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */ +GAME( 2003, theglada, theglad, svg, sango, theglad, ROT0, "IGS", "The Gladiator (ver. 101)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */ +GAME( 2004, oldsplus, pgm, kov, olds, oldsplus, ROT0, "IGS", "Oriental Legend Special Plus / Xi You Shi E Zhuan Super Plus", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */ +GAME( 2004, kovshp, kov, kov, sango, kovshp, ROT0, "IGS", "Knights of Valour Super Heroes Plus / Sangoku Senki Super Heroes Plus (ver. 100)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */ +GAME( 2005, killbldp, pgm, svg, sango, killbldp, ROT0, "IGS", "The Killing Blade Plus (ver. 300)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */ +GAME( 2004, happy6, pgm, svg, sango, svg, ROT0, "IGS", "Happy 6-in-1 (ver. 101CN)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */ +GAME( 2005, svg, pgm, svg, sango, svg, ROT0, "IGS", "S.V.G. - Spectral vs Generation (ver. 200)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */ diff --git a/src/mame/drivers/psikyo.c b/src/mame/drivers/psikyo.c index dc6691ae088..5631e54f3a0 100644 --- a/src/mame/drivers/psikyo.c +++ b/src/mame/drivers/psikyo.c @@ -66,36 +66,7 @@ This was pointed out by Bart Puype #include "sound/2610intf.h" #include "sound/ymf278b.h" #include "sound/okim6295.h" - - -/* Variables defined in video */ - -extern UINT32 *psikyo_vram_0, *psikyo_vram_1, *psikyo_vregs; -extern int psikyo_ka302c_banking; -extern UINT32* psikyo_bootleg_spritebuffer; - -/* Functions defined in video */ - -WRITE32_HANDLER( psikyo_vram_0_w ); -WRITE32_HANDLER( psikyo_vram_1_w ); - -VIDEO_START( psikyo ); -VIDEO_EOF( psikyo ); -VIDEO_UPDATE( psikyo ); -VIDEO_START( sngkace ); -VIDEO_UPDATE( psikyo_bootleg ); - -extern void psikyo_switch_banks( int tmap, int bank ); - -/* Variables only used here */ - -static UINT8 psikyo_soundlatch; -static int z80_nmi, mcu_status; - -static MACHINE_RESET( psikyo ) -{ - z80_nmi = mcu_status = 0; -} +#include "includes/psikyo.h" /*************************************************************************** @@ -108,9 +79,10 @@ static MACHINE_RESET( psikyo ) static CUSTOM_INPUT( z80_nmi_r ) { + psikyo_state *state = (psikyo_state *)field->port->machine->driver_data; int ret = 0x00; - if (z80_nmi) + if (state->z80_nmi) { ret = 0x01; @@ -125,6 +97,7 @@ static CUSTOM_INPUT( z80_nmi_r ) static CUSTOM_INPUT( mcu_status_r ) { + psikyo_state *state = (psikyo_state *)field->port->machine->driver_data; int ret = 0x00; /* Don't know exactly what this bit is, but s1945 and tengai @@ -141,43 +114,44 @@ static CUSTOM_INPUT( mcu_status_r ) Interestingly, s1945jn has the code that spins on this bit, but said code is never reached. Prototype? */ - if (mcu_status) + if (state->mcu_status) ret = 0x01; - mcu_status = !mcu_status; /* hack */ + state->mcu_status = !state->mcu_status; /* hack */ return ret; } static READ32_HANDLER( sngkace_input_r ) { - switch(offset) + switch (offset) { case 0x0: return input_port_read(space->machine, "P1_P2"); case 0x1: return input_port_read(space->machine, "DSW"); case 0x2: return input_port_read(space->machine, "COIN"); default: logerror("PC %06X - Read input %02X !\n", cpu_get_pc(space->cpu), offset * 2); - return 0; + return 0; } } static READ32_HANDLER( gunbird_input_r ) { - switch(offset) + switch (offset) { case 0x0: return input_port_read(space->machine, "P1_P2"); case 0x1: return input_port_read(space->machine, "DSW"); - default: logerror("PC %06X - Read input %02X !\n", cpu_get_pc(space->cpu), offset*2); - return 0; + default: logerror("PC %06X - Read input %02X !\n", cpu_get_pc(space->cpu), offset * 2); + return 0; } } static TIMER_CALLBACK( psikyo_soundlatch_callback ) { - psikyo_soundlatch = param; - cputag_set_input_line(machine, "audiocpu", INPUT_LINE_NMI, ASSERT_LINE); - z80_nmi = 1; + psikyo_state *state = (psikyo_state *)machine->driver_data; + state->soundlatch = param; + cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, ASSERT_LINE); + state->z80_nmi = 1; } static WRITE32_HANDLER( psikyo_soundlatch_w ) @@ -214,79 +188,69 @@ static const UINT8 s1945j_table[256] = { 0x00, 0x00, 0x32, 0x90, 0x00, 0x00, 0xac, 0x64, 0x00, 0x00, 0x2b, 0xc0 }; -static UINT8 s1945_mcu_direction, s1945_mcu_latch1, s1945_mcu_latch2, s1945_mcu_inlatch, s1945_mcu_index; -static UINT8 s1945_mcu_latching, s1945_mcu_mode, s1945_mcu_control, s1945_mcu_bctrl; -static const UINT8 *s1945_mcu_table; - -static void s1945_mcu_init(const UINT8 *mcu_table) -{ - s1945_mcu_direction = 0x00; - s1945_mcu_inlatch = 0xff; - s1945_mcu_latch1 = 0xff; - s1945_mcu_latch2 = 0xff; - s1945_mcu_latching = 0x5; - s1945_mcu_control = 0xff; - s1945_mcu_index = 0; - s1945_mcu_mode = 0; - s1945_mcu_table = mcu_table; - s1945_mcu_bctrl = 0x00; -} - static WRITE32_HANDLER( s1945_mcu_w ) { + psikyo_state *state = (psikyo_state *)space->machine->driver_data; + // Accesses are always bytes, so resolve it int suboff; - for(suboff=0; suboff < 3; suboff++) - if((0xff << (8*suboff)) & mem_mask) + + for (suboff = 0; suboff < 3; suboff++) + if ((0xff << (8 * suboff)) & mem_mask) break; - data >>= 8*suboff; - offset = offset*4+4+(3-suboff); + data >>= 8 * suboff; + offset = offset * 4 + 4 + (3 - suboff); - switch(offset) { + switch (offset) + { case 0x06: - s1945_mcu_inlatch = data; + state->s1945_mcu_inlatch = data; break; case 0x08: - s1945_mcu_control = data; + state->s1945_mcu_control = data; break; case 0x09: - s1945_mcu_direction = data; + state->s1945_mcu_direction = data; break; case 0x07: - psikyo_switch_banks(1, (data >> 6) & 3); - psikyo_switch_banks(0, (data >> 4) & 3); - s1945_mcu_bctrl = data; + psikyo_switch_banks(space->machine, 1, (data >> 6) & 3); + psikyo_switch_banks(space->machine, 0, (data >> 4) & 3); + state->s1945_mcu_bctrl = data; break; case 0x0b: - switch(data | (s1945_mcu_direction ? 0x100 : 0)) { + switch (data | (state->s1945_mcu_direction ? 0x100 : 0)) + { case 0x11c: - s1945_mcu_latching = 5; - s1945_mcu_index = s1945_mcu_inlatch; + state->s1945_mcu_latching = 5; + state->s1945_mcu_index = state->s1945_mcu_inlatch; break; case 0x013: -// logerror("MCU: Table read index %02x\n", s1945_mcu_index); - s1945_mcu_latching = 1; - s1945_mcu_latch1 = s1945_mcu_table[s1945_mcu_index]; +// logerror("MCU: Table read index %02x\n", state->s1945_mcu_index); + state->s1945_mcu_latching = 1; + state->s1945_mcu_latch1 = state->s1945_mcu_table[state->s1945_mcu_index]; break; case 0x113: - s1945_mcu_mode = s1945_mcu_inlatch; - if(s1945_mcu_mode == 1) { - s1945_mcu_latching &= ~1; - s1945_mcu_latch2 = 0x55; - } else { + state->s1945_mcu_mode = state->s1945_mcu_inlatch; + if (state->s1945_mcu_mode == 1) + { + state->s1945_mcu_latching &= ~1; + state->s1945_mcu_latch2 = 0x55; + } + else + { // Go figure. - s1945_mcu_latching &= ~1; - s1945_mcu_latching |= 2; + state->s1945_mcu_latching &= ~1; + state->s1945_mcu_latching |= 2; } - s1945_mcu_latching &= ~4; - s1945_mcu_latch1 = s1945_mcu_inlatch; + state->s1945_mcu_latching &= ~4; + state->s1945_mcu_latch1 = state->s1945_mcu_inlatch; break; case 0x010: case 0x110: - s1945_mcu_latching |= 4; + state->s1945_mcu_latching |= 4; break; default: -// logerror("MCU: function %02x, direction %02x, latch1 %02x, latch2 %02x (%x)\n", data, s1945_mcu_direction, s1945_mcu_latch1, s1945_mcu_latch2, cpu_get_pc(space->cpu)); +// logerror("MCU: function %02x, direction %02x, latch1 %02x, latch2 %02x (%x)\n", data, state->s1945_mcu_direction, state->s1945_mcu_latch1, state->s1945_mcu_latch2, cpu_get_pc(space->cpu)); break; } break; @@ -298,33 +262,40 @@ static WRITE32_HANDLER( s1945_mcu_w ) static READ32_HANDLER( s1945_mcu_r ) { - switch(offset) { - case 0: { + psikyo_state *state = (psikyo_state *)space->machine->driver_data; + + switch (offset) + { + case 0: + { UINT32 res; - if(s1945_mcu_control & 16) { - res = s1945_mcu_latching & 4 ? 0x0000ff00 : s1945_mcu_latch1 << 8; - s1945_mcu_latching |= 4; - } else { - res = s1945_mcu_latching & 1 ? 0x0000ff00 : s1945_mcu_latch2 << 8; - s1945_mcu_latching |= 1; + if (state->s1945_mcu_control & 16) + { + res = state->s1945_mcu_latching & 4 ? 0x0000ff00 : state->s1945_mcu_latch1 << 8; + state->s1945_mcu_latching |= 4; + } + else + { + res = state->s1945_mcu_latching & 1 ? 0x0000ff00 : state->s1945_mcu_latch2 << 8; + state->s1945_mcu_latching |= 1; } - res |= s1945_mcu_bctrl & 0xf0; + res |= state->s1945_mcu_bctrl & 0xf0; return res; } case 1: - return (s1945_mcu_latching << 24) | 0x08000000; + return (state->s1945_mcu_latching << 24) | 0x08000000; } return 0; } static READ32_HANDLER( s1945_input_r ) { - switch(offset) + switch (offset) { case 0x0: return input_port_read(space->machine, "P1_P2"); - case 0x1: return (input_port_read(space->machine, "DSW") & 0xffff000f) | s1945_mcu_r(space, offset-1, mem_mask); - case 0x2: return s1945_mcu_r(space, offset-1, mem_mask); - default: logerror("PC %06X - Read input %02X !\n", cpu_get_pc(space->cpu), offset*2); + case 0x1: return (input_port_read(space->machine, "DSW") & 0xffff000f) | s1945_mcu_r(space, offset - 1, mem_mask); + case 0x2: return s1945_mcu_r(space, offset - 1, mem_mask); + default: logerror("PC %06X - Read input %02X !\n", cpu_get_pc(space->cpu), offset * 2); return 0; } } @@ -341,18 +312,18 @@ static READ32_HANDLER( s1945_input_r ) static WRITE32_HANDLER( paletteram32_xRRRRRGGGGGBBBBB_dword_w ) { if (ACCESSING_BITS_16_31) - paletteram16_xRRRRRGGGGGBBBBB_word_w(space, offset*2, data >> 16, mem_mask >> 16); + paletteram16_xRRRRRGGGGGBBBBB_word_w(space, offset * 2, data >> 16, mem_mask >> 16); if (ACCESSING_BITS_0_15) - paletteram16_xRRRRRGGGGGBBBBB_word_w(space, offset*2+1, data, mem_mask); + paletteram16_xRRRRRGGGGGBBBBB_word_w(space, offset * 2 + 1, data, mem_mask); } static ADDRESS_MAP_START( psikyo_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x000000, 0x0fffff) AM_ROM // ROM (not all used) AM_RANGE(0x400000, 0x401fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) // Sprites, buffered by two frames (list buffered + fb buffered) AM_RANGE(0x600000, 0x601fff) AM_RAM_WRITE(paletteram32_xRRRRRGGGGGBBBBB_dword_w) AM_BASE_GENERIC(paletteram) // Palette - AM_RANGE(0x800000, 0x801fff) AM_RAM_WRITE(psikyo_vram_0_w) AM_BASE(&psikyo_vram_0) // Layer 0 - AM_RANGE(0x802000, 0x803fff) AM_RAM_WRITE(psikyo_vram_1_w) AM_BASE(&psikyo_vram_1) // Layer 1 - AM_RANGE(0x804000, 0x807fff) AM_RAM AM_BASE(&psikyo_vregs) // RAM + Vregs + AM_RANGE(0x800000, 0x801fff) AM_RAM_WRITE(psikyo_vram_0_w) AM_BASE_MEMBER(psikyo_state, vram_0) // Layer 0 + AM_RANGE(0x802000, 0x803fff) AM_RAM_WRITE(psikyo_vram_1_w) AM_BASE_MEMBER(psikyo_state, vram_1) // Layer 1 + AM_RANGE(0x804000, 0x807fff) AM_RAM AM_BASE_MEMBER(psikyo_state, vregs) // RAM + Vregs // AM_RANGE(0xc00000, 0xc0000b) AM_READ(psikyo_input_r) // Depends on board, see DRIVER_INIT // AM_RANGE(0xc00004, 0xc0000b) AM_WRITE(s1945_mcu_w) // MCU on sh404, see DRIVER_INIT // AM_RANGE(0xc00010, 0xc00013) AM_WRITE(psikyo_soundlatch_w) // Depends on board, see DRIVER_INIT @@ -361,31 +332,28 @@ ADDRESS_MAP_END READ32_DEVICE_HANDLER( s1945bl_oki_r ) { - UINT8 dat = okim6295_r(device,0); + UINT8 dat = okim6295_r(device, 0); return dat << 24; } static WRITE32_DEVICE_HANDLER( s1945bl_oki_w ) { if (ACCESSING_BITS_24_31) - { - okim6295_w(device,0,data>>24); - } + okim6295_w(device, 0, data >> 24); + if (ACCESSING_BITS_16_23) { // not at all sure about this, it seems to write 0 too often - UINT8 bank = (data & 0x00ff0000)>>16; - if (bank<4) - memory_set_bankptr(device->machine, "okibank", memory_region(device->machine,"oki")+0x30000+0x10000*bank); + UINT8 bank = (data & 0x00ff0000) >> 16; + if (bank < 4) + memory_set_bank(device->machine, "okibank", bank); } + if (ACCESSING_BITS_8_15) - { - printf("ACCESSING_BITS_8_15 ?? %08x %08x\n",data&0x00ff0000,mem_mask); - } + printf("ACCESSING_BITS_8_15 ?? %08x %08x\n", data & 0x00ff0000, mem_mask); + if (ACCESSING_BITS_0_7) - { - printf("ACCESSING_BITS_0_7 ?? %08x %08x\n",data&0x00ff0000,mem_mask); - } + printf("ACCESSING_BITS_0_7 ?? %08x %08x\n", data & 0x00ff0000, mem_mask); } static ADDRESS_MAP_START( s1945bl_oki_map, 0, 8 ) @@ -395,13 +363,13 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( psikyo_bootleg_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x000000, 0x0fffff) AM_ROM // ROM (not all used) - AM_RANGE(0x200000, 0x200fff) AM_RAM AM_BASE(&psikyo_bootleg_spritebuffer) // RAM (it copies the spritelist here, the HW probably doesn't have automatic buffering like the originals? + AM_RANGE(0x200000, 0x200fff) AM_RAM AM_BASE_MEMBER(psikyo_state, bootleg_spritebuffer) // RAM (it copies the spritelist here, the HW probably doesn't have automatic buffering like the originals? AM_RANGE(0x400000, 0x401fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) // Sprites, buffered by two frames (list buffered + fb buffered) AM_RANGE(0x600000, 0x601fff) AM_RAM_WRITE(paletteram32_xRRRRRGGGGGBBBBB_dword_w) AM_BASE_GENERIC(paletteram) // Palette - AM_RANGE(0x800000, 0x801fff) AM_RAM_WRITE(psikyo_vram_0_w) AM_BASE(&psikyo_vram_0) // Layer 0 - AM_RANGE(0x802000, 0x803fff) AM_RAM_WRITE(psikyo_vram_1_w) AM_BASE(&psikyo_vram_1) // Layer 1 - AM_RANGE(0x804000, 0x807fff) AM_RAM AM_BASE(&psikyo_vregs) // RAM + Vregs + AM_RANGE(0x800000, 0x801fff) AM_RAM_WRITE(psikyo_vram_0_w) AM_BASE_MEMBER(psikyo_state, vram_0) // Layer 0 + AM_RANGE(0x802000, 0x803fff) AM_RAM_WRITE(psikyo_vram_1_w) AM_BASE_MEMBER(psikyo_state, vram_1) // Layer 1 + AM_RANGE(0x804000, 0x807fff) AM_RAM AM_BASE_MEMBER(psikyo_state, vregs) // RAM + Vregs // AM_RANGE(0xc00000, 0xc0000b) AM_READ(psikyo_input_r) // Depends on board, see DRIVER_INIT // AM_RANGE(0xc00004, 0xc0000b) AM_WRITE(s1945_mcu_w) // MCU on sh404, see DRIVER_INIT // AM_RANGE(0xc00010, 0xc00013) AM_WRITE(psikyo_soundlatch_w) // Depends on board, see DRIVER_INIT @@ -422,18 +390,21 @@ ADDRESS_MAP_END static void sound_irq( const device_config *device, int irq ) { - cputag_set_input_line(device->machine, "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE); + psikyo_state *state = (psikyo_state *)device->machine->driver_data; + cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE); } static READ8_HANDLER( psikyo_soundlatch_r ) { - return psikyo_soundlatch; + psikyo_state *state = (psikyo_state *)space->machine->driver_data; + return state->soundlatch; } static WRITE8_HANDLER( psikyo_clear_nmi_w ) { - cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, CLEAR_LINE); - z80_nmi = 0; + psikyo_state *state = (psikyo_state *)space->machine->driver_data; + cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, CLEAR_LINE); + state->z80_nmi = 0; } @@ -443,9 +414,7 @@ static WRITE8_HANDLER( psikyo_clear_nmi_w ) static WRITE8_HANDLER( sngkace_sound_bankswitch_w ) { - UINT8 *RAM = memory_region(space->machine, "audiocpu"); - int bank = data & 3; - memory_set_bankptr(space->machine, "bank1", &RAM[bank * 0x8000 + 0x10000]); + memory_set_bank(space->machine, "bank1", data & 0x03); } static ADDRESS_MAP_START( sngkace_sound_map, ADDRESS_SPACE_PROGRAM, 8 ) @@ -469,13 +438,7 @@ ADDRESS_MAP_END static WRITE8_HANDLER( gunbird_sound_bankswitch_w ) { - UINT8 *RAM = memory_region(space->machine, "audiocpu"); - int bank = (data >> 4) & 3; - - /* The banked rom is seen at 8200-ffff, so the last 0x200 bytes - of the rom not reachable. */ - - memory_set_bankptr(space->machine, "bank1", &RAM[bank * 0x8000 + 0x10000 + 0x200]); + memory_set_bank(space->machine, "bank1", (data >> 4) & 0x03); } static ADDRESS_MAP_START( gunbird_sound_map, ADDRESS_SPACE_PROGRAM, 8 ) @@ -513,25 +476,73 @@ ADDRESS_MAP_END ***************************************************************************/ -#define PSIKYO_PORT_PLAYER1 \ - PORT_BIT( 0x01000000, IP_ACTIVE_LOW, IPT_START1 ) \ - PORT_BIT( 0x02000000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) \ - PORT_BIT( 0x04000000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) \ - PORT_BIT( 0x08000000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) \ - PORT_BIT( 0x10000000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1) \ - PORT_BIT( 0x20000000, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1) \ - PORT_BIT( 0x40000000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1) \ - PORT_BIT( 0x80000000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1) +static INPUT_PORTS_START( psikyo_common ) + PORT_START("P1_P2") /* c00000&1 */ + PORT_BIT( 0x0000ffff, IP_ACTIVE_LOW, IPT_UNUSED ) // these depends by the games + PORT_BIT( 0x00010000, IP_ACTIVE_LOW, IPT_START2 ) + PORT_BIT( 0x00020000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2) + PORT_BIT( 0x00040000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) + PORT_BIT( 0x00080000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) + PORT_BIT( 0x00100000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2) + PORT_BIT( 0x00200000, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2) + PORT_BIT( 0x00400000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2) + PORT_BIT( 0x00800000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2) + PORT_BIT( 0x01000000, IP_ACTIVE_LOW, IPT_START1 ) + PORT_BIT( 0x02000000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) + PORT_BIT( 0x04000000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) + PORT_BIT( 0x08000000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) + PORT_BIT( 0x10000000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1) + PORT_BIT( 0x20000000, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1) + PORT_BIT( 0x40000000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1) + PORT_BIT( 0x80000000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1) -#define PSIKYO_PORT_PLAYER2 \ - PORT_BIT( 0x00010000, IP_ACTIVE_LOW, IPT_START2 ) \ - PORT_BIT( 0x00020000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2) \ - PORT_BIT( 0x00040000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) \ - PORT_BIT( 0x00080000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) \ - PORT_BIT( 0x00100000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2) \ - PORT_BIT( 0x00200000, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2) \ - PORT_BIT( 0x00400000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2) \ - PORT_BIT( 0x00800000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2) + PORT_START("DSW") /* c00004 -> c00007 */ + PORT_BIT( 0x0000ffff, IP_ACTIVE_LOW, IPT_UNUSED ) // these depends by the games + PORT_DIPNAME( 0x00010000, 0x00010000, DEF_STR( Flip_Screen ) ) + PORT_DIPSETTING( 0x00010000, DEF_STR( Off ) ) + PORT_DIPSETTING( 0x00000000, DEF_STR( On ) ) + PORT_DIPNAME( 0x00020000, 0x00000000, DEF_STR( Demo_Sounds ) ) + PORT_DIPSETTING( 0x00020000, DEF_STR( Off ) ) + PORT_DIPSETTING( 0x00000000, DEF_STR( On ) ) + PORT_DIPNAME( 0x000c0000, 0x000c0000, DEF_STR( Difficulty ) ) + PORT_DIPSETTING( 0x00080000, DEF_STR( Easy ) ) + PORT_DIPSETTING( 0x000c0000, DEF_STR( Normal ) ) + PORT_DIPSETTING( 0x00040000, DEF_STR( Hard ) ) + PORT_DIPSETTING( 0x00000000, DEF_STR( Hardest ) ) + PORT_DIPNAME( 0x00300000, 0x00300000, DEF_STR( Lives ) ) + PORT_DIPSETTING( 0x00200000, "1" ) + PORT_DIPSETTING( 0x00100000, "2" ) + PORT_DIPSETTING( 0x00300000, "3" ) + PORT_DIPSETTING( 0x00000000, "4" ) + PORT_DIPNAME( 0x00400000, 0x00400000, DEF_STR( Bonus_Life ) ) + PORT_DIPSETTING( 0x00400000, "400K" ) + PORT_DIPSETTING( 0x00000000, "600K" ) + PORT_SERVICE( 0x00800000, IP_ACTIVE_LOW ) + PORT_DIPNAME( 0x01000000, 0x01000000, "Credits/Coinage" ) // [Free Play] on all for free play + PORT_DIPSETTING( 0x01000000, "A+B/A&B" ) + PORT_DIPSETTING( 0x00000000, "A&B/A [Free Play]" ) + PORT_DIPNAME( 0x0e000000, 0x0e000000, DEF_STR( Coin_A ) ) + PORT_DIPSETTING( 0x0a000000, DEF_STR( 3C_1C ) ) + PORT_DIPSETTING( 0x0c000000, DEF_STR( 2C_1C ) ) + PORT_DIPSETTING( 0x0e000000, DEF_STR( 1C_1C ) ) + PORT_DIPSETTING( 0x08000000, DEF_STR( 1C_2C ) ) + PORT_DIPSETTING( 0x06000000, DEF_STR( 1C_3C ) ) + PORT_DIPSETTING( 0x04000000, DEF_STR( 1C_4C ) ) + PORT_DIPSETTING( 0x02000000, DEF_STR( 1C_5C ) ) + PORT_DIPSETTING( 0x00000000, "1C 6C [Free Play]" ) + PORT_DIPNAME( 0x70000000, 0x70000000, DEF_STR( Coin_B ) ) + PORT_DIPSETTING( 0x50000000, DEF_STR( 3C_1C ) ) + PORT_DIPSETTING( 0x60000000, DEF_STR( 2C_1C ) ) + PORT_DIPSETTING( 0x70000000, DEF_STR( 1C_1C ) ) + PORT_DIPSETTING( 0x40000000, DEF_STR( 1C_2C ) ) + PORT_DIPSETTING( 0x30000000, DEF_STR( 1C_3C ) ) + PORT_DIPSETTING( 0x20000000, DEF_STR( 1C_4C ) ) + PORT_DIPSETTING( 0x10000000, DEF_STR( 1C_5C ) ) + PORT_DIPSETTING( 0x00000000, "1C 6C [Free Play]" ) + PORT_DIPNAME( 0x80000000, 0x80000000, "2C Start, 1C Continue" ) + PORT_DIPSETTING( 0x80000000, DEF_STR( Off ) ) + PORT_DIPSETTING( 0x00000000, "On [Free Play]" ) // Forces 1C_1C +INPUT_PORTS_END @@ -540,10 +551,7 @@ ADDRESS_MAP_END ***************************************************************************/ static INPUT_PORTS_START( samuraia ) - PORT_START("P1_P2") /* c00000&1 */ - PORT_BIT( 0x0000ffff, IP_ACTIVE_LOW, IPT_UNUSED ) - PSIKYO_PORT_PLAYER2 - PSIKYO_PORT_PLAYER1 + PORT_INCLUDE(psikyo_common) PORT_START("COIN") PORT_BIT( 0x00000001, IP_ACTIVE_LOW, IPT_VBLANK ) // vblank @@ -571,16 +579,9 @@ static INPUT_PORTS_START( samuraia ) PORT_SERVICE_NO_TOGGLE( 0x00200000, IP_ACTIVE_LOW ) PORT_BIT( 0x00400000, IP_ACTIVE_LOW, IPT_TILT ) PORT_BIT( 0x00800000, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(z80_nmi_r, NULL) // From Sound CPU - PORT_BIT( 0x01000000, IP_ACTIVE_LOW, IPT_UNKNOWN ) // unused? - PORT_BIT( 0x02000000, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x04000000, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x08000000, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x10000000, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x20000000, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x40000000, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x80000000, IP_ACTIVE_LOW, IPT_UNKNOWN ) + PORT_BIT( 0xff000000, IP_ACTIVE_LOW, IPT_UNKNOWN ) // unused? - PORT_START("DSW") /* c00004 -> c00007 */ + PORT_MODIFY("DSW") /* c00004 -> c00007 */ /*********************************************** This Dip port is bit based: @@ -600,59 +601,7 @@ static INPUT_PORTS_START( samuraia ) PORT_DIPSETTING( 0x000000df, "Korea" ) PORT_DIPSETTING( 0x000000bf, "Hong Kong" ) PORT_DIPSETTING( 0x0000007f, "Taiwan" ) - PORT_BIT( 0x00000100, IP_ACTIVE_LOW, IPT_UNKNOWN ) // unused? - PORT_BIT( 0x00000200, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00000400, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00000800, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00001000, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00002000, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00004000, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00008000, IP_ACTIVE_LOW, IPT_UNKNOWN ) - - PORT_DIPNAME( 0x00010000, 0x00010000, DEF_STR( Flip_Screen ) ) - PORT_DIPSETTING( 0x00010000, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x00000000, DEF_STR( On ) ) - PORT_DIPNAME( 0x00020000, 0x00000000, DEF_STR( Demo_Sounds ) ) - PORT_DIPSETTING( 0x00020000, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x00000000, DEF_STR( On ) ) - PORT_DIPNAME( 0x000c0000, 0x000c0000, DEF_STR( Difficulty ) ) - PORT_DIPSETTING( 0x00080000, DEF_STR( Easy ) ) - PORT_DIPSETTING( 0x000c0000, DEF_STR( Normal ) ) - PORT_DIPSETTING( 0x00040000, DEF_STR( Hard ) ) - PORT_DIPSETTING( 0x00000000, DEF_STR( Hardest ) ) - PORT_DIPNAME( 0x00300000, 0x00300000, DEF_STR( Lives ) ) - PORT_DIPSETTING( 0x00200000, "1" ) - PORT_DIPSETTING( 0x00100000, "2" ) - PORT_DIPSETTING( 0x00300000, "3" ) - PORT_DIPSETTING( 0x00000000, "4" ) - PORT_DIPNAME( 0x00400000, 0x00400000, DEF_STR( Bonus_Life ) ) - PORT_DIPSETTING( 0x00400000, "400K" ) - PORT_DIPSETTING( 0x00000000, "600K" ) - PORT_SERVICE( 0x00800000, IP_ACTIVE_LOW ) - PORT_DIPNAME( 0x01000000, 0x01000000, "Credits/Coinage" ) // [Free Play] on all for free play - PORT_DIPSETTING( 0x01000000, "A+B/A&B" ) - PORT_DIPSETTING( 0x00000000, "A&B/A [Free Play]" ) - PORT_DIPNAME( 0x0e000000, 0x0e000000, DEF_STR( Coin_A ) ) - PORT_DIPSETTING( 0x0a000000, DEF_STR( 3C_1C ) ) - PORT_DIPSETTING( 0x0c000000, DEF_STR( 2C_1C ) ) - PORT_DIPSETTING( 0x0e000000, DEF_STR( 1C_1C ) ) - PORT_DIPSETTING( 0x08000000, DEF_STR( 1C_2C ) ) - PORT_DIPSETTING( 0x06000000, DEF_STR( 1C_3C ) ) - PORT_DIPSETTING( 0x04000000, DEF_STR( 1C_4C ) ) - PORT_DIPSETTING( 0x02000000, DEF_STR( 1C_5C ) ) - PORT_DIPSETTING( 0x00000000, "1C 6C [Free Play]" ) - PORT_DIPNAME( 0x70000000, 0x70000000, DEF_STR( Coin_B ) ) - PORT_DIPSETTING( 0x50000000, DEF_STR( 3C_1C ) ) - PORT_DIPSETTING( 0x60000000, DEF_STR( 2C_1C ) ) - PORT_DIPSETTING( 0x70000000, DEF_STR( 1C_1C ) ) - PORT_DIPSETTING( 0x40000000, DEF_STR( 1C_2C ) ) - PORT_DIPSETTING( 0x30000000, DEF_STR( 1C_3C ) ) - PORT_DIPSETTING( 0x20000000, DEF_STR( 1C_4C ) ) - PORT_DIPSETTING( 0x10000000, DEF_STR( 1C_5C ) ) - PORT_DIPSETTING( 0x00000000, "1C 6C [Free Play]" ) - PORT_DIPNAME( 0x80000000, 0x80000000, "2C Start, 1C Continue" ) - PORT_DIPSETTING( 0x80000000, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x00000000, "On [Free Play]" ) // Forces 1C_1C + PORT_BIT( 0x0000ff00, IP_ACTIVE_LOW, IPT_UNKNOWN ) // unused? INPUT_PORTS_END static INPUT_PORTS_START( sngkace ) @@ -689,7 +638,9 @@ INPUT_PORTS_END ***************************************************************************/ static INPUT_PORTS_START( btlkroad ) - PORT_START("P1_P2") /* c00000 -> c00003 */ + PORT_INCLUDE(psikyo_common) + + PORT_MODIFY("P1_P2") /* c00000 -> c00003 */ PORT_BIT( 0x00000001, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x00000002, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x00000004, IP_ACTIVE_HIGH, IPT_SPECIAL ) @@ -706,10 +657,8 @@ static INPUT_PORTS_START( btlkroad ) PORT_BIT( 0x00002000, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_PLAYER(1) PORT_BIT( 0x00004000, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_PLAYER(1) PORT_BIT( 0x00008000, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(1) - PSIKYO_PORT_PLAYER2 - PSIKYO_PORT_PLAYER1 - PORT_START("DSW") /* c00004 -> c00007 */ + PORT_MODIFY("DSW") /* c00004 -> c00007 */ /*********************************************** Bit 0 1 2 3 @@ -759,17 +708,6 @@ static INPUT_PORTS_START( btlkroad ) PORT_DIPSETTING( 0x00008000, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00000000, DEF_STR( On ) ) - PORT_DIPNAME( 0x00010000, 0x00010000, DEF_STR( Flip_Screen ) ) - PORT_DIPSETTING( 0x00010000, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x00000000, DEF_STR( On ) ) - PORT_DIPNAME( 0x00020000, 0x00000000, DEF_STR( Demo_Sounds ) ) - PORT_DIPSETTING( 0x00020000, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x00000000, DEF_STR( On ) ) - PORT_DIPNAME( 0x000c0000, 0x000c0000, DEF_STR( Difficulty ) ) - PORT_DIPSETTING( 0x00080000, DEF_STR( Easy ) ) - PORT_DIPSETTING( 0x000c0000, DEF_STR( Normal ) ) - PORT_DIPSETTING( 0x00040000, DEF_STR( Hard ) ) - PORT_DIPSETTING( 0x00000000, DEF_STR( Hardest ) ) PORT_DIPNAME( 0x00100000, 0x00100000, "Unknown 2-4" ) // used PORT_DIPSETTING( 0x00100000, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00000000, DEF_STR( On ) ) @@ -779,31 +717,6 @@ static INPUT_PORTS_START( btlkroad ) PORT_DIPNAME( 0x00400000, 0x00400000, "Use DSW 3 (Debug)" ) PORT_DIPSETTING( 0x00400000, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00000000, DEF_STR( On ) ) - PORT_SERVICE( 0x00800000, IP_ACTIVE_LOW ) - PORT_DIPNAME( 0x01000000, 0x01000000, "Credits/Coinage" ) // [Free Play] on all for free play - PORT_DIPSETTING( 0x01000000, "A+B/A&B" ) - PORT_DIPSETTING( 0x00000000, "A&B/A [Free Play]" ) - PORT_DIPNAME( 0x0e000000, 0x0e000000, DEF_STR( Coin_A ) ) - PORT_DIPSETTING( 0x0a000000, DEF_STR( 3C_1C ) ) - PORT_DIPSETTING( 0x0c000000, DEF_STR( 2C_1C ) ) - PORT_DIPSETTING( 0x0e000000, DEF_STR( 1C_1C ) ) - PORT_DIPSETTING( 0x08000000, DEF_STR( 1C_2C ) ) - PORT_DIPSETTING( 0x06000000, DEF_STR( 1C_3C ) ) - PORT_DIPSETTING( 0x04000000, DEF_STR( 1C_4C ) ) - PORT_DIPSETTING( 0x02000000, DEF_STR( 1C_5C ) ) - PORT_DIPSETTING( 0x00000000, "1C 6C [Free Play]" ) - PORT_DIPNAME( 0x70000000, 0x70000000, DEF_STR( Coin_B ) ) - PORT_DIPSETTING( 0x50000000, DEF_STR( 3C_1C ) ) - PORT_DIPSETTING( 0x60000000, DEF_STR( 2C_1C ) ) - PORT_DIPSETTING( 0x70000000, DEF_STR( 1C_1C ) ) - PORT_DIPSETTING( 0x40000000, DEF_STR( 1C_2C ) ) - PORT_DIPSETTING( 0x30000000, DEF_STR( 1C_3C ) ) - PORT_DIPSETTING( 0x20000000, DEF_STR( 1C_4C ) ) - PORT_DIPSETTING( 0x10000000, DEF_STR( 1C_5C ) ) - PORT_DIPSETTING( 0x00000000, "1C 6C [Free Play]" ) - PORT_DIPNAME( 0x80000000, 0x80000000, "2C Start, 1C Continue" ) - PORT_DIPSETTING( 0x80000000, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x00000000, "On [Free Play]" ) // Forces 1C_1C INPUT_PORTS_END @@ -812,7 +725,9 @@ INPUT_PORTS_END ***************************************************************************/ static INPUT_PORTS_START( gunbird ) - PORT_START("P1_P2") /* c00000 -> c00003 */ + PORT_INCLUDE(psikyo_common) + + PORT_MODIFY("P1_P2") /* c00000 -> c00003 */ PORT_BIT( 0x00000001, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x00000002, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x00000004, IP_ACTIVE_HIGH, IPT_SPECIAL ) @@ -821,18 +736,9 @@ static INPUT_PORTS_START( gunbird ) PORT_SERVICE_NO_TOGGLE( 0x00000020, IP_ACTIVE_LOW ) PORT_BIT( 0x00000040, IP_ACTIVE_LOW, IPT_TILT ) PORT_BIT( 0x00000080, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(z80_nmi_r, NULL) // From Sound CPU - PORT_BIT( 0x00000100, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00000200, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00000400, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00000800, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00001000, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00002000, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00004000, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00008000, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PSIKYO_PORT_PLAYER2 - PSIKYO_PORT_PLAYER1 + PORT_BIT( 0x0000ff00, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_START("DSW") /* c00004 -> c00007 */ + PORT_MODIFY("DSW") /* c00004 -> c00007 */ /*********************************************** This Dip port is bit based: @@ -870,51 +776,6 @@ static INPUT_PORTS_START( gunbird ) PORT_BIT( 0x00002000, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x00004000, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x00008000, IP_ACTIVE_LOW, IPT_UNKNOWN ) // tested! - - PORT_DIPNAME( 0x00010000, 0x00010000, DEF_STR( Flip_Screen ) ) - PORT_DIPSETTING( 0x00010000, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x00000000, DEF_STR( On ) ) - PORT_DIPNAME( 0x00020000, 0x00000000, DEF_STR( Demo_Sounds ) ) - PORT_DIPSETTING( 0x00020000, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x00000000, DEF_STR( On ) ) - PORT_DIPNAME( 0x000c0000, 0x000c0000, DEF_STR( Difficulty ) ) - PORT_DIPSETTING( 0x00080000, DEF_STR( Easy ) ) - PORT_DIPSETTING( 0x000c0000, DEF_STR( Normal ) ) - PORT_DIPSETTING( 0x00040000, DEF_STR( Hard ) ) - PORT_DIPSETTING( 0x00000000, DEF_STR( Hardest ) ) - PORT_DIPNAME( 0x00300000, 0x00300000, DEF_STR( Lives ) ) - PORT_DIPSETTING( 0x00200000, "1" ) - PORT_DIPSETTING( 0x00100000, "2" ) - PORT_DIPSETTING( 0x00300000, "3" ) - PORT_DIPSETTING( 0x00000000, "4" ) - PORT_DIPNAME( 0x00400000, 0x00400000, DEF_STR( Bonus_Life ) ) - PORT_DIPSETTING( 0x00400000, "400K" ) - PORT_DIPSETTING( 0x00000000, "600K" ) - PORT_SERVICE( 0x00800000, IP_ACTIVE_LOW ) - PORT_DIPNAME( 0x01000000, 0x01000000, "Credits/Coinage" ) // [Free Play] on all for free play - PORT_DIPSETTING( 0x01000000, "A+B/A&B" ) - PORT_DIPSETTING( 0x00000000, "A&B/A [Free Play]" ) - PORT_DIPNAME( 0x0e000000, 0x0e000000, DEF_STR( Coin_A ) ) - PORT_DIPSETTING( 0x0a000000, DEF_STR( 3C_1C ) ) - PORT_DIPSETTING( 0x0c000000, DEF_STR( 2C_1C ) ) - PORT_DIPSETTING( 0x0e000000, DEF_STR( 1C_1C ) ) - PORT_DIPSETTING( 0x08000000, DEF_STR( 1C_2C ) ) - PORT_DIPSETTING( 0x06000000, DEF_STR( 1C_3C ) ) - PORT_DIPSETTING( 0x04000000, DEF_STR( 1C_4C ) ) - PORT_DIPSETTING( 0x02000000, DEF_STR( 1C_5C ) ) - PORT_DIPSETTING( 0x00000000, "1C 6C [Free Play]" ) - PORT_DIPNAME( 0x70000000, 0x70000000, DEF_STR( Coin_B ) ) - PORT_DIPSETTING( 0x50000000, DEF_STR( 3C_1C ) ) - PORT_DIPSETTING( 0x60000000, DEF_STR( 2C_1C ) ) - PORT_DIPSETTING( 0x70000000, DEF_STR( 1C_1C ) ) - PORT_DIPSETTING( 0x40000000, DEF_STR( 1C_2C ) ) - PORT_DIPSETTING( 0x30000000, DEF_STR( 1C_3C ) ) - PORT_DIPSETTING( 0x20000000, DEF_STR( 1C_4C ) ) - PORT_DIPSETTING( 0x10000000, DEF_STR( 1C_5C ) ) - PORT_DIPSETTING( 0x00000000, "1C 6C [Free Play]" ) - PORT_DIPNAME( 0x80000000, 0x80000000, "2C Start, 1C Continue" ) - PORT_DIPSETTING( 0x80000000, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x00000000, "On [Free Play]" ) // Forces 1C_1C INPUT_PORTS_END static INPUT_PORTS_START( gunbirdj ) @@ -933,7 +794,9 @@ INPUT_PORTS_END ***************************************************************************/ static INPUT_PORTS_START( s1945 ) - PORT_START("P1_P2") /* c00000 -> c00003 */ + PORT_INCLUDE(psikyo_common) + + PORT_MODIFY("P1_P2") /* c00000 -> c00003 */ PORT_BIT( 0x00000001, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x00000002, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x00000004, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(mcu_status_r, NULL) @@ -942,18 +805,9 @@ static INPUT_PORTS_START( s1945 ) PORT_SERVICE_NO_TOGGLE( 0x00000020, IP_ACTIVE_LOW ) PORT_BIT( 0x00000040, IP_ACTIVE_LOW, IPT_TILT ) PORT_BIT( 0x00000080, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(z80_nmi_r, NULL) // From Sound CPU - PORT_BIT( 0x00000100, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00000200, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00000400, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00000800, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00001000, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00002000, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00004000, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00008000, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PSIKYO_PORT_PLAYER2 - PSIKYO_PORT_PLAYER1 + PORT_BIT( 0x0000ff00, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_START("DSW") /* c00004 -> c00007 */ + PORT_MODIFY("DSW") /* c00004 -> c00007 */ /*********************************************** This Dip port is bit based: @@ -993,29 +847,9 @@ static INPUT_PORTS_START( s1945 ) PORT_BIT( 0x00004000, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x00008000, IP_ACTIVE_LOW, IPT_UNKNOWN ) // tested! - PORT_DIPNAME( 0x00010000, 0x00010000, DEF_STR( Flip_Screen ) ) - PORT_DIPSETTING( 0x00010000, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x00000000, DEF_STR( On ) ) - PORT_DIPNAME( 0x00020000, 0x00000000, DEF_STR( Demo_Sounds ) ) - PORT_DIPSETTING( 0x00020000, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x00000000, DEF_STR( On ) ) - PORT_DIPNAME( 0x000c0000, 0x000c0000, DEF_STR( Difficulty ) ) - PORT_DIPSETTING( 0x00080000, DEF_STR( Easy ) ) - PORT_DIPSETTING( 0x000c0000, DEF_STR( Normal ) ) - PORT_DIPSETTING( 0x00040000, DEF_STR( Hard ) ) - PORT_DIPSETTING( 0x00000000, DEF_STR( Hardest ) ) - PORT_DIPNAME( 0x00300000, 0x00300000, DEF_STR( Lives ) ) - PORT_DIPSETTING( 0x00200000, "1" ) - PORT_DIPSETTING( 0x00100000, "2" ) - PORT_DIPSETTING( 0x00300000, "3" ) - PORT_DIPSETTING( 0x00000000, "4" ) PORT_DIPNAME( 0x00400000, 0x00400000, DEF_STR( Bonus_Life ) ) PORT_DIPSETTING( 0x00400000, "600K" ) PORT_DIPSETTING( 0x00000000, "800K" ) - PORT_SERVICE( 0x00800000, IP_ACTIVE_LOW ) - PORT_DIPNAME( 0x01000000, 0x01000000, "Credits/Coinage" ) // No freeplay for s1945 - PORT_DIPSETTING( 0x01000000, "A+B/A&B" ) - PORT_DIPSETTING( 0x00000000, "A&B/A" ) PORT_DIPNAME( 0x0e000000, 0x0e000000, DEF_STR( Coin_A ) ) PORT_DIPSETTING( 0x0a000000, DEF_STR( 3C_1C ) ) PORT_DIPSETTING( 0x0c000000, DEF_STR( 2C_1C ) ) @@ -1084,7 +918,9 @@ INPUT_PORTS_END ***************************************************************************/ static INPUT_PORTS_START( tengai ) - PORT_START("P1_P2") /* c00000 -> c00003 */ + PORT_INCLUDE(psikyo_common) + + PORT_MODIFY("P1_P2") /* c00000 -> c00003 */ PORT_BIT( 0x00000001, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x00000002, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x00000004, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(mcu_status_r, NULL) @@ -1093,18 +929,9 @@ static INPUT_PORTS_START( tengai ) PORT_SERVICE_NO_TOGGLE( 0x00000020, IP_ACTIVE_LOW ) PORT_BIT( 0x00000040, IP_ACTIVE_LOW, IPT_TILT ) PORT_BIT( 0x00000080, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(z80_nmi_r, NULL) // From Sound CPU - PORT_BIT( 0x00000100, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00000200, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00000400, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00000800, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00001000, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00002000, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00004000, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_BIT( 0x00008000, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PSIKYO_PORT_PLAYER2 - PSIKYO_PORT_PLAYER1 + PORT_BIT( 0x0000ff00, IP_ACTIVE_LOW, IPT_UNKNOWN ) - PORT_START("DSW") /* c00004 -> c00007 */ + PORT_MODIFY("DSW") /* c00004 -> c00007 */ /*********************************************** This Dip port is bit based: @@ -1136,50 +963,9 @@ static INPUT_PORTS_START( tengai ) PORT_BIT( 0x00004000, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_BIT( 0x00008000, IP_ACTIVE_LOW, IPT_UNKNOWN ) // tested! - PORT_DIPNAME( 0x00010000, 0x00010000, DEF_STR( Flip_Screen ) ) - PORT_DIPSETTING( 0x00010000, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x00000000, DEF_STR( On ) ) - PORT_DIPNAME( 0x00020000, 0x00000000, DEF_STR( Demo_Sounds ) ) - PORT_DIPSETTING( 0x00020000, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x00000000, DEF_STR( On ) ) - PORT_DIPNAME( 0x000c0000, 0x000c0000, DEF_STR( Difficulty ) ) - PORT_DIPSETTING( 0x00080000, DEF_STR( Easy ) ) - PORT_DIPSETTING( 0x000c0000, DEF_STR( Normal ) ) - PORT_DIPSETTING( 0x00040000, DEF_STR( Hard ) ) - PORT_DIPSETTING( 0x00000000, DEF_STR( Hardest ) ) - PORT_DIPNAME( 0x00300000, 0x00300000, DEF_STR( Lives ) ) - PORT_DIPSETTING( 0x00200000, "1" ) - PORT_DIPSETTING( 0x00100000, "2" ) - PORT_DIPSETTING( 0x00300000, "3" ) - PORT_DIPSETTING( 0x00000000, "4" ) PORT_DIPNAME( 0x00400000, 0x00400000, DEF_STR( Bonus_Life ) ) PORT_DIPSETTING( 0x00400000, "600K" ) PORT_DIPSETTING( 0x00000000, "800K" ) - PORT_SERVICE( 0x00800000, IP_ACTIVE_LOW ) - PORT_DIPNAME( 0x01000000, 0x01000000, "Credits/Coinage" ) // [Free Play] on all for free play - PORT_DIPSETTING( 0x01000000, "A+B/A&B" ) - PORT_DIPSETTING( 0x00000000, "A&B/A [Free Play]" ) - PORT_DIPNAME( 0x0e000000, 0x0e000000, DEF_STR( Coin_A ) ) - PORT_DIPSETTING( 0x0a000000, DEF_STR( 3C_1C ) ) - PORT_DIPSETTING( 0x0c000000, DEF_STR( 2C_1C ) ) - PORT_DIPSETTING( 0x0e000000, DEF_STR( 1C_1C ) ) - PORT_DIPSETTING( 0x08000000, DEF_STR( 1C_2C ) ) - PORT_DIPSETTING( 0x06000000, DEF_STR( 1C_3C ) ) - PORT_DIPSETTING( 0x04000000, DEF_STR( 1C_4C ) ) - PORT_DIPSETTING( 0x02000000, DEF_STR( 1C_5C ) ) - PORT_DIPSETTING( 0x00000000, "1C 6C [Free Play]" ) - PORT_DIPNAME( 0x70000000, 0x70000000, DEF_STR( Coin_B ) ) - PORT_DIPSETTING( 0x50000000, DEF_STR( 3C_1C ) ) - PORT_DIPSETTING( 0x60000000, DEF_STR( 2C_1C ) ) - PORT_DIPSETTING( 0x70000000, DEF_STR( 1C_1C ) ) - PORT_DIPSETTING( 0x40000000, DEF_STR( 1C_2C ) ) - PORT_DIPSETTING( 0x30000000, DEF_STR( 1C_3C ) ) - PORT_DIPSETTING( 0x20000000, DEF_STR( 1C_4C ) ) - PORT_DIPSETTING( 0x10000000, DEF_STR( 1C_5C ) ) - PORT_DIPSETTING( 0x00000000, "1C 6C [Free Play]" ) - PORT_DIPNAME( 0x80000000, 0x80000000, "2C Start, 1C Continue" ) - PORT_DIPSETTING( 0x80000000, DEF_STR( Off ) ) - PORT_DIPSETTING( 0x00000000, "On [Free Play]" ) // Forces 1C_1C INPUT_PORTS_END static INPUT_PORTS_START( tengaij ) @@ -1238,6 +1024,29 @@ GFXDECODE_END ***************************************************************************/ +static MACHINE_START( psikyo ) +{ + psikyo_state *state = (psikyo_state *)machine->driver_data; + + state->audiocpu = devtag_get_device(machine, "audiocpu"); + + state_save_register_global(machine, state->soundlatch); + state_save_register_global(machine, state->z80_nmi); + state_save_register_global(machine, state->mcu_status); + state_save_register_global(machine, state->tilemap_0_bank); + state_save_register_global(machine, state->tilemap_1_bank); +} + +static MACHINE_RESET( psikyo ) +{ + psikyo_state *state = (psikyo_state *)machine->driver_data; + + state->soundlatch = 0; + state->z80_nmi = 0; + state->mcu_status = 0; +} + + /*************************************************************************** Samurai Ace / Sengoku Aces ***************************************************************************/ @@ -1250,6 +1059,9 @@ static const ym2610_interface sngkace_ym2610_interface = static MACHINE_DRIVER_START( sngkace ) + /* driver data */ + MDRV_DRIVER_DATA(psikyo_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68EC020, XTAL_32MHz/2) /* verified on pcb */ MDRV_CPU_PROGRAM_MAP(psikyo_map) @@ -1259,6 +1071,7 @@ static MACHINE_DRIVER_START( sngkace ) MDRV_CPU_PROGRAM_MAP(sngkace_sound_map) MDRV_CPU_IO_MAP(sngkace_sound_io_map) + MDRV_MACHINE_START(psikyo) MDRV_MACHINE_RESET(psikyo) /* video hardware */ @@ -1301,6 +1114,9 @@ static const ym2610_interface gunbird_ym2610_interface = static MACHINE_DRIVER_START( gunbird ) + /* driver data */ + MDRV_DRIVER_DATA(psikyo_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68EC020, 16000000) MDRV_CPU_PROGRAM_MAP(psikyo_map) @@ -1310,6 +1126,7 @@ static MACHINE_DRIVER_START( gunbird ) MDRV_CPU_PROGRAM_MAP(gunbird_sound_map) MDRV_CPU_IO_MAP(gunbird_sound_io_map) + MDRV_MACHINE_START(psikyo) MDRV_MACHINE_RESET(psikyo) /* video hardware */ @@ -1340,11 +1157,15 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( s1945bl ) /* Bootleg hardware based on the unprotected Japanese Strikers 1945 set */ + /* driver data */ + MDRV_DRIVER_DATA(psikyo_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68EC020, 16000000) MDRV_CPU_PROGRAM_MAP(psikyo_bootleg_map) MDRV_CPU_VBLANK_INT("screen", irq1_line_hold) + MDRV_MACHINE_START(psikyo) MDRV_MACHINE_RESET(psikyo) /* video hardware */ @@ -1378,12 +1199,10 @@ MACHINE_DRIVER_END ***************************************************************************/ -static void irqhandler(const device_config *device, int linestate) +static void irqhandler( const device_config *device, int linestate ) { - if (linestate) - cputag_set_input_line(device->machine, "audiocpu", 0, ASSERT_LINE); - else - cputag_set_input_line(device->machine, "audiocpu", 0, CLEAR_LINE); + psikyo_state *state = (psikyo_state *)device->machine->driver_data; + cpu_set_input_line(state->audiocpu, 0, linestate ? ASSERT_LINE : CLEAR_LINE); } static const ymf278b_interface ymf278b_config = @@ -1393,6 +1212,9 @@ static const ymf278b_interface ymf278b_config = static MACHINE_DRIVER_START( s1945 ) + /* driver data */ + MDRV_DRIVER_DATA(psikyo_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68EC020, 16000000) MDRV_CPU_PROGRAM_MAP(psikyo_map) @@ -1404,6 +1226,7 @@ static MACHINE_DRIVER_START( s1945 ) /* MCU should go here */ + MDRV_MACHINE_START(psikyo) MDRV_MACHINE_RESET(psikyo) /* video hardware */ @@ -1508,43 +1331,6 @@ ROM_START( sngkace ) ROM_END -static DRIVER_INIT( sngkace ) -{ - { - UINT8 *RAM = memory_region(machine, "ymsnd"); - int len = memory_region_length(machine, "ymsnd"); - int i; - - /* Bit 6&7 of the samples are swapped. Naughty, naughty... */ - for (i = 0; i < len; i++) - { - int x = RAM[i]; - RAM[i] = ((x & 0x40) << 1) | ((x & 0x80) >> 1) | (x & 0x3f); - } - } - - /* input ports */ - memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, sngkace_input_r); - - /* sound latch */ - memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, psikyo_soundlatch_w); - - psikyo_ka302c_banking = 0; // SH201B doesn't have any gfx banking - - /* Enable other regions */ -#if 0 - if (!strcmp(machine->gamedrv->name,"sngkace")) - { - UINT8 *ROM = memory_region(machine, "maincpu"); - ROM[0x995] = 0x4e; - ROM[0x994] = 0x71; - ROM[0x997] = 0x4e; - ROM[0x996] = 0x71; - - } -#endif -} - /*************************************************************************** @@ -1689,20 +1475,6 @@ ROM_START( btlkroad ) ROM_END - - -static DRIVER_INIT( gunbird ) -{ - /* input ports */ - memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, gunbird_input_r); - - /* sound latch */ - memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, psikyo_soundlatch_w); - - psikyo_ka302c_banking = 1; -} - - /*************************************************************************** Strikers 1945 (Japan, unprotected) @@ -1774,18 +1546,6 @@ ROM_START( s1945bl ) ROM_LOAD( "27c512", 0x000000, 0x010000, CRC(0da8db45) SHA1(7d5bd71c5b0b28ff74c732edd7c662f46f2ab25b) ) ROM_END -static DRIVER_INIT( s1945jn ) -{ - /* input ports */ - memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, gunbird_input_r); - - /* sound latch */ - memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, s1945_soundlatch_w); - - psikyo_ka302c_banking = 1; -} - - /*************************************************************************** Strikers 1945 @@ -1981,51 +1741,6 @@ ROM_START( s1945k ) /* Same MCU as the current parent set, region dip has no eff ROM_END -static DRIVER_INIT( s1945 ) -{ - /* input ports */ - memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, s1945_input_r); - - /* sound latch */ - memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, s1945_soundlatch_w); - - /* protection and tile bank switching */ - memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00004, 0xc0000b, 0, 0, s1945_mcu_w); - s1945_mcu_init(s1945_table); - - psikyo_ka302c_banking = 0; // Banking is controlled by mcu -} - -static DRIVER_INIT( s1945a ) -{ - /* input ports */ - memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, s1945_input_r); - - /* sound latch */ - memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, s1945_soundlatch_w); - - /* protection and tile bank switching */ - memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00004, 0xc0000b, 0, 0, s1945_mcu_w); - s1945_mcu_init(s1945a_table); - - psikyo_ka302c_banking = 0; // Banking is controlled by mcu -} - -static DRIVER_INIT( s1945j ) -{ - /* input ports*/ - memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, s1945_input_r); - - /* sound latch */ - memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, s1945_soundlatch_w); - - /* protection and tile bank switching */ - memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00004, 0xc0000b, 0, 0, s1945_mcu_w); - s1945_mcu_init(s1945j_table); - - psikyo_ka302c_banking = 0; // Banking is controlled by mcu -} - /*************************************************************************** @@ -2108,8 +1823,84 @@ ROM_START( tengaij ) ROM_END +/*************************************************************************** + + + Driver Initialization + + +***************************************************************************/ + +static DRIVER_INIT( sngkace ) +{ + psikyo_state *state = (psikyo_state *)machine->driver_data; + + { + UINT8 *RAM = memory_region(machine, "ymsnd"); + int len = memory_region_length(machine, "ymsnd"); + int i; + + /* Bit 6&7 of the samples are swapped. Naughty, naughty... */ + for (i = 0; i < len; i++) + { + int x = RAM[i]; + RAM[i] = ((x & 0x40) << 1) | ((x & 0x80) >> 1) | (x & 0x3f); + } + } + + /* input ports */ + memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, sngkace_input_r); + + /* sound latch */ + memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, psikyo_soundlatch_w); + + state->ka302c_banking = 0; // SH201B doesn't have any gfx banking + + /* setup audiocpu banks */ + memory_configure_bank(machine, "bank1", 0, 4, memory_region(machine, "audiocpu") + 0x10000, 0x8000); + + /* Enable other regions */ +#if 0 + if (!strcmp(machine->gamedrv->name,"sngkace")) + { + UINT8 *ROM = memory_region(machine, "maincpu"); + ROM[0x995] = 0x4e; + ROM[0x994] = 0x71; + ROM[0x997] = 0x4e; + ROM[0x996] = 0x71; + + } +#endif +} + +static void s1945_mcu_init( running_machine *machine ) +{ + psikyo_state *state = (psikyo_state *)machine->driver_data; + state->s1945_mcu_direction = 0x00; + state->s1945_mcu_inlatch = 0xff; + state->s1945_mcu_latch1 = 0xff; + state->s1945_mcu_latch2 = 0xff; + state->s1945_mcu_latching = 0x5; + state->s1945_mcu_control = 0xff; + state->s1945_mcu_index = 0; + state->s1945_mcu_mode = 0; + state->s1945_mcu_bctrl = 0x00; + + state_save_register_global(machine, state->s1945_mcu_direction); + state_save_register_global(machine, state->s1945_mcu_inlatch); + state_save_register_global(machine, state->s1945_mcu_latch1); + state_save_register_global(machine, state->s1945_mcu_latch2); + state_save_register_global(machine, state->s1945_mcu_latching); + state_save_register_global(machine, state->s1945_mcu_control); + state_save_register_global(machine, state->s1945_mcu_index); + state_save_register_global(machine, state->s1945_mcu_mode); + state_save_register_global(machine, state->s1945_mcu_bctrl); +} + static DRIVER_INIT( tengai ) { + psikyo_state *state = (psikyo_state *)machine->driver_data; + /* input ports */ memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, s1945_input_r); @@ -2118,16 +1909,135 @@ static DRIVER_INIT( tengai ) /* protection */ memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00004, 0xc0000b, 0, 0, s1945_mcu_w); - s1945_mcu_init(0); - psikyo_ka302c_banking = 0; // Banking is controlled by mcu + s1945_mcu_init(machine); + state->s1945_mcu_table = 0; + + state->ka302c_banking = 0; // Banking is controlled by mcu + + /* setup audiocpu banks */ + /* The banked rom is seen at 8200-ffff, so the last 0x200 bytes of the rom not reachable. */ + memory_configure_bank(machine, "bank1", 0, 4, memory_region(machine, "audiocpu") + 0x10000 + 0x200, 0x8000); +} + +static DRIVER_INIT( gunbird ) +{ + psikyo_state *state = (psikyo_state *)machine->driver_data; + + /* input ports */ + memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, gunbird_input_r); + + /* sound latch */ + memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, psikyo_soundlatch_w); + + state->ka302c_banking = 1; + + /* setup audiocpu banks */ + /* The banked rom is seen at 8200-ffff, so the last 0x200 bytes of the rom not reachable. */ + memory_configure_bank(machine, "bank1", 0, 4, memory_region(machine, "audiocpu") + 0x10000 + 0x200, 0x8000); +} + + +static DRIVER_INIT( s1945 ) +{ + psikyo_state *state = (psikyo_state *)machine->driver_data; + + /* input ports */ + memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, s1945_input_r); + + /* sound latch */ + memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, s1945_soundlatch_w); + + /* protection and tile bank switching */ + memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00004, 0xc0000b, 0, 0, s1945_mcu_w); + + s1945_mcu_init(machine); + state->s1945_mcu_table = s1945_table; + + state->ka302c_banking = 0; // Banking is controlled by mcu + + /* setup audiocpu banks */ + /* The banked rom is seen at 8200-ffff, so the last 0x200 bytes of the rom not reachable. */ + memory_configure_bank(machine, "bank1", 0, 4, memory_region(machine, "audiocpu") + 0x10000 + 0x200, 0x8000); +} + +static DRIVER_INIT( s1945a ) +{ + psikyo_state *state = (psikyo_state *)machine->driver_data; + + /* input ports */ + memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, s1945_input_r); + + /* sound latch */ + memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, s1945_soundlatch_w); + + /* protection and tile bank switching */ + memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00004, 0xc0000b, 0, 0, s1945_mcu_w); + + s1945_mcu_init(machine); + state->s1945_mcu_table = s1945a_table; + + state->ka302c_banking = 0; // Banking is controlled by mcu + + /* setup audiocpu banks */ + /* The banked rom is seen at 8200-ffff, so the last 0x200 bytes of the rom not reachable. */ + memory_configure_bank(machine, "bank1", 0, 4, memory_region(machine, "audiocpu") + 0x10000 + 0x200, 0x8000); +} + +static DRIVER_INIT( s1945j ) +{ + psikyo_state *state = (psikyo_state *)machine->driver_data; + + /* input ports*/ + memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, s1945_input_r); + + /* sound latch */ + memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, s1945_soundlatch_w); + + /* protection and tile bank switching */ + memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00004, 0xc0000b, 0, 0, s1945_mcu_w); + + s1945_mcu_init(machine); + state->s1945_mcu_table = s1945j_table; + + state->ka302c_banking = 0; // Banking is controlled by mcu + + /* setup audiocpu banks */ + /* The banked rom is seen at 8200-ffff, so the last 0x200 bytes of the rom not reachable. */ + memory_configure_bank(machine, "bank1", 0, 4, memory_region(machine, "audiocpu") + 0x10000 + 0x200, 0x8000); +} + +static DRIVER_INIT( s1945jn ) +{ + psikyo_state *state = (psikyo_state *)machine->driver_data; + + /* input ports */ + memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, gunbird_input_r); + + /* sound latch */ + memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, s1945_soundlatch_w); + + state->ka302c_banking = 1; + + /* setup audiocpu banks */ + /* The banked rom is seen at 8200-ffff, so the last 0x200 bytes of the rom not reachable. */ + memory_configure_bank(machine, "bank1", 0, 4, memory_region(machine, "audiocpu") + 0x10000 + 0x200, 0x8000); } static DRIVER_INIT( s1945bl ) { - DRIVER_INIT_CALL( s1945jn ); + psikyo_state *state = (psikyo_state *)machine->driver_data; + + /* input ports */ + memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, gunbird_input_r); + + /* sound latch */ + memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, s1945_soundlatch_w); + + state->ka302c_banking = 1; - memory_set_bankptr(machine, "okibank", memory_region(machine,"oki")+0x30000); + memory_configure_bank(machine, "okibank", 0, 4, memory_region(machine, "oki") + 0x30000, 0x10000); + memory_set_bank(machine, "okibank", 0); } @@ -2140,17 +2050,17 @@ static DRIVER_INIT( s1945bl ) ***************************************************************************/ /* Working Games */ -GAME( 1993, samuraia, 0, sngkace, samuraia, sngkace, ROT270, "Psikyo", "Samurai Aces (World)", 0) // Banpresto? -GAME( 1993, sngkace, samuraia, sngkace, sngkace, sngkace, ROT270, "Psikyo", "Sengoku Ace (Japan)", 0) // Banpresto? -GAME( 1994, gunbird, 0, gunbird, gunbird, gunbird, ROT270, "Psikyo", "Gunbird (World)", 0 ) -GAME( 1994, gunbirdk, gunbird, gunbird, gunbirdj, gunbird, ROT270, "Psikyo", "Gunbird (Korea)", 0 ) -GAME( 1994, gunbirdj, gunbird, gunbird, gunbirdj, gunbird, ROT270, "Psikyo", "Gunbird (Japan)", 0 ) -GAME( 1994, btlkroad, 0, gunbird, btlkroad, gunbird, ROT0, "Psikyo", "Battle K-Road", 0 ) -GAME( 1995, s1945, 0, s1945, s1945, s1945, ROT270, "Psikyo", "Strikers 1945 (World)", 0 ) -GAME( 1995, s1945a, s1945, s1945, s1945a, s1945a, ROT270, "Psikyo", "Strikers 1945 (Japan / World)", 0) // Region dip - 0x0f=Japan, anything else=World -GAME( 1995, s1945j, s1945, s1945, s1945j, s1945j, ROT270, "Psikyo", "Strikers 1945 (Japan)", 0 ) -GAME( 1995, s1945jn, s1945, gunbird, s1945j, s1945jn, ROT270, "Psikyo", "Strikers 1945 (Japan, unprotected)", 0 ) -GAME( 1995, s1945k, s1945, s1945, s1945j, s1945, ROT270, "Psikyo", "Strikers 1945 (Korea)", 0 ) -GAME( 1995, s1945bl, s1945, s1945bl, s1945bl, s1945bl, ROT270, "Psikyo", "Strikers 1945 (Hong Kong, bootleg)", 0 ) -GAME( 1996, tengai, 0, s1945, tengai, tengai, ROT0, "Psikyo", "Tengai (World)", 0 ) -GAME( 1996, tengaij, tengai, s1945, tengaij, tengai, ROT0, "Psikyo", "Sengoku Blade: Sengoku Ace Episode II / Tengai", 0 ) // Region dip - 0x0f=Japan, anything else=World +GAME( 1993, samuraia, 0, sngkace, samuraia, sngkace, ROT270, "Psikyo", "Samurai Aces (World)", GAME_SUPPORTS_SAVE ) // Banpresto? +GAME( 1993, sngkace, samuraia, sngkace, sngkace, sngkace, ROT270, "Psikyo", "Sengoku Ace (Japan)", GAME_SUPPORTS_SAVE ) // Banpresto? +GAME( 1994, gunbird, 0, gunbird, gunbird, gunbird, ROT270, "Psikyo", "Gunbird (World)", GAME_SUPPORTS_SAVE ) +GAME( 1994, gunbirdk, gunbird, gunbird, gunbirdj, gunbird, ROT270, "Psikyo", "Gunbird (Korea)", GAME_SUPPORTS_SAVE ) +GAME( 1994, gunbirdj, gunbird, gunbird, gunbirdj, gunbird, ROT270, "Psikyo", "Gunbird (Japan)", GAME_SUPPORTS_SAVE ) +GAME( 1994, btlkroad, 0, gunbird, btlkroad, gunbird, ROT0, "Psikyo", "Battle K-Road", GAME_SUPPORTS_SAVE ) +GAME( 1995, s1945, 0, s1945, s1945, s1945, ROT270, "Psikyo", "Strikers 1945 (World)", GAME_SUPPORTS_SAVE ) +GAME( 1995, s1945a, s1945, s1945, s1945a, s1945a, ROT270, "Psikyo", "Strikers 1945 (Japan / World)", GAME_SUPPORTS_SAVE ) // Region dip - 0x0f=Japan, anything else=World +GAME( 1995, s1945j, s1945, s1945, s1945j, s1945j, ROT270, "Psikyo", "Strikers 1945 (Japan)", GAME_SUPPORTS_SAVE ) +GAME( 1995, s1945jn, s1945, gunbird, s1945j, s1945jn, ROT270, "Psikyo", "Strikers 1945 (Japan, unprotected)", GAME_SUPPORTS_SAVE ) +GAME( 1995, s1945k, s1945, s1945, s1945j, s1945, ROT270, "Psikyo", "Strikers 1945 (Korea)", GAME_SUPPORTS_SAVE ) +GAME( 1995, s1945bl, s1945, s1945bl, s1945bl, s1945bl, ROT270, "Psikyo", "Strikers 1945 (Hong Kong, bootleg)", GAME_SUPPORTS_SAVE ) +GAME( 1996, tengai, 0, s1945, tengai, tengai, ROT0, "Psikyo", "Tengai (World)", GAME_SUPPORTS_SAVE ) +GAME( 1996, tengaij, tengai, s1945, tengaij, tengai, ROT0, "Psikyo", "Sengoku Blade: Sengoku Ace Episode II / Tengai", GAME_SUPPORTS_SAVE ) // Region dip - 0x0f=Japan, anything else=World diff --git a/src/mame/drivers/psikyo4.c b/src/mame/drivers/psikyo4.c index 9ce45b9381e..fb3b47d5fcb 100644 --- a/src/mame/drivers/psikyo4.c +++ b/src/mame/drivers/psikyo4.c @@ -132,18 +132,10 @@ ROMs - #include "machine/eeprom.h" #include "sound/ymf278b.h" #include "rendlay.h" +#include "includes/psikyo4.h" #define ROMTEST 1 /* Does necessary stuff to perform rom test, uses RAM as it doesn't dispose of GFX after decoding */ -UINT32 *psikyo4_vidregs; -static UINT32 *ps4_ram, *ps4_io_select; -static UINT32 *bgpen_1, *bgpen_2; - -#define MASTER_CLOCK 57272700 // main oscillator frequency - -/* defined in video/psikyo4.c */ -VIDEO_START( psikyo4 ); -VIDEO_UPDATE( psikyo4 ); static const gfx_layout layout_16x16x8 = { @@ -235,8 +227,9 @@ static CUSTOM_INPUT( system_port_r ) static CUSTOM_INPUT( mahjong_ctrl_r ) /* used by hotgmck/hgkairak */ { + psikyo4_state *state = (psikyo4_state *)field->port->machine->driver_data; int player = (FPTR)param; - int sel = (ps4_io_select[0] & 0x0000ff00) >> 8; + int sel = (state->io_select[0] & 0x0000ff00) >> 8; int ret = 0xff; if (sel & 1) ret &= input_port_read(field->port->machine, player ? "KEY4" : "KEY0" ); @@ -249,61 +242,69 @@ static CUSTOM_INPUT( mahjong_ctrl_r ) /* used by hotgmck/hgkairak */ static WRITE32_HANDLER( ps4_paletteram32_RRRRRRRRGGGGGGGGBBBBBBBBxxxxxxxx_dword_w ) { - int r,g,b; - COMBINE_DATA(&space->machine->generic.paletteram.u32[offset]); + psikyo4_state *state = (psikyo4_state *)space->machine->driver_data; + int r, g, b; + COMBINE_DATA(&state->paletteram[offset]); - b = ((space->machine->generic.paletteram.u32[offset] & 0x0000ff00) >>8); - g = ((space->machine->generic.paletteram.u32[offset] & 0x00ff0000) >>16); - r = ((space->machine->generic.paletteram.u32[offset] & 0xff000000) >>24); + b = ((state->paletteram[offset] & 0x0000ff00) >> 8); + g = ((state->paletteram[offset] & 0x00ff0000) >> 16); + r = ((state->paletteram[offset] & 0xff000000) >> 24); - palette_set_color(space->machine,offset,MAKE_RGB(r,g,b)); - palette_set_color(space->machine,offset+0x800,MAKE_RGB(r,g,b)); // For screen 2 + palette_set_color(space->machine, offset, MAKE_RGB(r, g, b)); + palette_set_color(space->machine, offset + 0x800, MAKE_RGB(r, g, b)); // For screen 2 } static WRITE32_HANDLER( ps4_bgpen_1_dword_w ) { - int r,g,b; - COMBINE_DATA(&bgpen_1[0]); + psikyo4_state *state = (psikyo4_state *)space->machine->driver_data; + int r, g, b; + COMBINE_DATA(&state->bgpen_1[0]); - b = ((bgpen_1[0] & 0x0000ff00) >>8); - g = ((bgpen_1[0] & 0x00ff0000) >>16); - r = ((bgpen_1[0] & 0xff000000) >>24); + b = ((state->bgpen_1[0] & 0x0000ff00) >>8); + g = ((state->bgpen_1[0] & 0x00ff0000) >>16); + r = ((state->bgpen_1[0] & 0xff000000) >>24); - palette_set_color(space->machine,0x1000,MAKE_RGB(r,g,b)); // Clear colour for screen 1 + palette_set_color(space->machine, 0x1000, MAKE_RGB(r, g, b)); // Clear colour for screen 1 } static WRITE32_HANDLER( ps4_bgpen_2_dword_w ) { - int r,g,b; - COMBINE_DATA(&bgpen_2[0]); + psikyo4_state *state = (psikyo4_state *)space->machine->driver_data; + int r, g, b; + COMBINE_DATA(&state->bgpen_2[0]); - b = ((bgpen_2[0] & 0x0000ff00) >>8); - g = ((bgpen_2[0] & 0x00ff0000) >>16); - r = ((bgpen_2[0] & 0xff000000) >>24); + b = ((state->bgpen_2[0] & 0x0000ff00) >>8); + g = ((state->bgpen_2[0] & 0x00ff0000) >>16); + r = ((state->bgpen_2[0] & 0xff000000) >>24); - palette_set_color(space->machine,0x1001,MAKE_RGB(r,g,b)); // Clear colour for screen 2 + palette_set_color(space->machine, 0x1001, MAKE_RGB(r, g, b)); // Clear colour for screen 2 } static WRITE32_HANDLER( ps4_screen1_brt_w ) { - if(ACCESSING_BITS_0_7) { + psikyo4_state *state = (psikyo4_state *)space->machine->driver_data; + + if (ACCESSING_BITS_0_7) + { /* Need seperate brightness for both screens if displaying together */ double brt1 = data & 0xff; - static double oldbrt1; - if (brt1>0x7f) brt1 = 0x7f; /* I reckon values must be clamped to 0x7f */ + if (brt1 > 0x7f) + brt1 = 0x7f; /* I reckon values must be clamped to 0x7f */ brt1 = (0x7f - brt1) / 127.0; - if (oldbrt1 != brt1) + if (state->oldbrt1 != brt1) { int i; for (i = 0; i < 0x800; i++) - palette_set_pen_contrast(space->machine,i,brt1); + palette_set_pen_contrast(space->machine, i, brt1); - oldbrt1 = brt1; + state->oldbrt1 = brt1; } - } else { + } + else + { /* I believe this to be seperate rgb brightness due to strings in hotdebut, unused in 4 dumped games */ if((data & mem_mask) != 0) logerror("Unk Scr 1 rgb? brt write %08x mask %08x\n", data, mem_mask); @@ -312,25 +313,30 @@ static WRITE32_HANDLER( ps4_screen1_brt_w ) static WRITE32_HANDLER( ps4_screen2_brt_w ) { - if(ACCESSING_BITS_0_7) { + psikyo4_state *state = (psikyo4_state *)space->machine->driver_data; + + if (ACCESSING_BITS_0_7) + { /* Need seperate brightness for both screens if displaying together */ double brt2 = data & 0xff; - static double oldbrt2; - if (brt2>0x7f) brt2 = 0x7f; /* I reckon values must be clamped to 0x7f */ + if (brt2 > 0x7f) + brt2 = 0x7f; /* I reckon values must be clamped to 0x7f */ brt2 = (0x7f - brt2) / 127.0; - if (oldbrt2 != brt2) + if (state->oldbrt2 != brt2) { int i; for (i = 0x800; i < 0x1000; i++) - palette_set_pen_contrast(space->machine,i,brt2); + palette_set_pen_contrast(space->machine, i, brt2); - oldbrt2 = brt2; + state->oldbrt2 = brt2; } - } else { + } + else + { /* I believe this to be seperate rgb brightness due to strings in hotdebut, unused in 4 dumped games */ if((data & mem_mask) != 0) logerror("Unk Scr 2 rgb? brt write %08x mask %08x\n", data, mem_mask); @@ -339,34 +345,34 @@ static WRITE32_HANDLER( ps4_screen2_brt_w ) static WRITE32_HANDLER( ps4_vidregs_w ) { - COMBINE_DATA(&psikyo4_vidregs[offset]); + psikyo4_state *state = (psikyo4_state *)space->machine->driver_data; + COMBINE_DATA(&state->vidregs[offset]); #if ROMTEST - if(offset==2) /* Configure bank for gfx test */ + if (offset == 2) /* Configure bank for gfx test */ { if (ACCESSING_BITS_0_15) // Bank { - UINT8 *ROM = memory_region(space->machine, "gfx1"); - memory_set_bankptr(space->machine, "bank2",&ROM[0x2000 * (psikyo4_vidregs[offset]&0x1fff)]); /* Bank comes from vidregs */ - } +// memory_set_bank(space->machine, "bank2", state->vidregs[offset] & 0x1fff); /* Bank comes from vidregs */ + memory_set_bankptr(space->machine, "bank2", memory_region(space->machine, "gfx1") + 0x2000 * (state->vidregs[offset] & 0x1fff)); /* Bank comes from vidregs */ } } #endif } #if ROMTEST -static UINT32 sample_offs = 0; - static READ32_HANDLER( ps4_sample_r ) /* Send sample data for test */ { + psikyo4_state *state = (psikyo4_state *)space->machine->driver_data; UINT8 *ROM = memory_region(space->machine, "ymf"); - return ROM[sample_offs++]<<16; + return ROM[state->sample_offs++] << 16; } #endif -#define PCM_BANK_NO(n) ((ps4_io_select[0] >> (n * 4 + 24)) & 0x07) +#define PCM_BANK_NO(n) ((state->io_select[0] >> (n * 4 + 24)) & 0x07) -static void set_hotgmck_pcm_bank(running_machine *machine, int n) +static void set_hotgmck_pcm_bank( running_machine *machine, int n ) { + psikyo4_state *state = (psikyo4_state *)machine->driver_data; UINT8 *ymf_pcmbank = memory_region(machine, "ymf") + 0x200000; UINT8 *pcm_rom = memory_region(machine, "ymfsource"); @@ -375,11 +381,12 @@ static void set_hotgmck_pcm_bank(running_machine *machine, int n) static WRITE32_HANDLER( hotgmck_pcm_bank_w ) { + psikyo4_state *state = (psikyo4_state *)space->machine->driver_data; int old_bank0 = PCM_BANK_NO(0); int old_bank1 = PCM_BANK_NO(1); int new_bank0, new_bank1; - COMBINE_DATA(&ps4_io_select[0]); + COMBINE_DATA(&state->io_select[0]); new_bank0 = PCM_BANK_NO(0); new_bank1 = PCM_BANK_NO(1); @@ -394,23 +401,23 @@ static WRITE32_HANDLER( hotgmck_pcm_bank_w ) static ADDRESS_MAP_START( ps4_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x00000000, 0x000fffff) AM_ROM // program ROM (1 meg) AM_RANGE(0x02000000, 0x021fffff) AM_ROMBANK("bank1") // data ROM - AM_RANGE(0x03000000, 0x030037ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) + AM_RANGE(0x03000000, 0x030037ff) AM_RAM AM_BASE_SIZE_MEMBER(psikyo4_state, spriteram, spriteram_size) AM_RANGE(0x03003fe0, 0x03003fe3) AM_READWRITE(ps4_eeprom_r,ps4_eeprom_w) AM_RANGE(0x03003fe4, 0x03003fe7) AM_READNOP // also writes to this address - might be vblank? // AM_RANGE(0x03003fe4, 0x03003fe7) AM_WRITENOP // might be vblank? - AM_RANGE(0x03003fe4, 0x03003fef) AM_RAM_WRITE(ps4_vidregs_w) AM_BASE(&psikyo4_vidregs) // vid regs? + AM_RANGE(0x03003fe4, 0x03003fef) AM_RAM_WRITE(ps4_vidregs_w) AM_BASE_MEMBER(psikyo4_state, vidregs) // vid regs? AM_RANGE(0x03003ff0, 0x03003ff3) AM_WRITE(ps4_screen1_brt_w) // screen 1 brightness - AM_RANGE(0x03003ff4, 0x03003ff7) AM_WRITE(ps4_bgpen_1_dword_w) AM_BASE(&bgpen_1) // screen 1 clear colour + AM_RANGE(0x03003ff4, 0x03003ff7) AM_WRITE(ps4_bgpen_1_dword_w) AM_BASE_MEMBER(psikyo4_state, bgpen_1) // screen 1 clear colour AM_RANGE(0x03003ff8, 0x03003ffb) AM_WRITE(ps4_screen2_brt_w) // screen 2 brightness - AM_RANGE(0x03003ffc, 0x03003fff) AM_WRITE(ps4_bgpen_2_dword_w) AM_BASE(&bgpen_2) // screen 2 clear colour - AM_RANGE(0x03004000, 0x03005fff) AM_RAM_WRITE(ps4_paletteram32_RRRRRRRRGGGGGGGGBBBBBBBBxxxxxxxx_dword_w) AM_BASE_GENERIC(paletteram) // palette + AM_RANGE(0x03003ffc, 0x03003fff) AM_WRITE(ps4_bgpen_2_dword_w) AM_BASE_MEMBER(psikyo4_state, bgpen_2) // screen 2 clear colour + AM_RANGE(0x03004000, 0x03005fff) AM_RAM_WRITE(ps4_paletteram32_RRRRRRRRGGGGGGGGBBBBBBBBxxxxxxxx_dword_w) AM_BASE_MEMBER(psikyo4_state, paletteram) // palette AM_RANGE(0x05000000, 0x05000003) AM_DEVREAD8("ymf", ymf278b_r, 0xffffffff) // read YMF status AM_RANGE(0x05000000, 0x05000007) AM_DEVWRITE8("ymf", ymf278b_w, 0xffffffff) AM_RANGE(0x05800000, 0x05800003) AM_READ_PORT("P1_P2") AM_RANGE(0x05800004, 0x05800007) AM_READ_PORT("P3_P4") - AM_RANGE(0x05800008, 0x0580000b) AM_WRITEONLY AM_BASE(&ps4_io_select) // Used by Mahjong games to choose input (also maps normal loderndf inputs to offsets) + AM_RANGE(0x05800008, 0x0580000b) AM_WRITEONLY AM_BASE_MEMBER(psikyo4_state, io_select) // Used by Mahjong games to choose input (also maps normal loderndf inputs to offsets) - AM_RANGE(0x06000000, 0x060fffff) AM_RAM AM_BASE(&ps4_ram) // main RAM (1 meg) + AM_RANGE(0x06000000, 0x060fffff) AM_RAM AM_BASE_MEMBER(psikyo4_state, ram) // main RAM (1 meg) #if ROMTEST AM_RANGE(0x05000004, 0x05000007) AM_READ(ps4_sample_r) // data for rom tests (Used to verify Sample rom) @@ -418,69 +425,6 @@ static ADDRESS_MAP_START( ps4_map, ADDRESS_SPACE_PROGRAM, 32 ) #endif ADDRESS_MAP_END -static void irqhandler(const device_config *device, int linestate) -{ - if (linestate) - cputag_set_input_line(device->machine, "maincpu", 12, ASSERT_LINE); - else - cputag_set_input_line(device->machine, "maincpu", 12, CLEAR_LINE); -} - -static const ymf278b_interface ymf278b_config = -{ - irqhandler -}; - -static MACHINE_DRIVER_START( ps4big ) - /* basic machine hardware */ - MDRV_CPU_ADD("maincpu", SH2, MASTER_CLOCK/2) - MDRV_CPU_PROGRAM_MAP(ps4_map) - MDRV_CPU_VBLANK_INT("lscreen", psikyosh_interrupt) - - MDRV_NVRAM_HANDLER(93C56) - - /* video hardware */ - MDRV_GFXDECODE(ps4) - MDRV_PALETTE_LENGTH((0x2000/4)*2 + 2) /* 0x2000/4 for each screen. 1 for each screen clear colour */ - MDRV_DEFAULT_LAYOUT(layout_dualhsxs) - - MDRV_SCREEN_ADD("lscreen", RASTER) - MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) - MDRV_SCREEN_REFRESH_RATE(60) - MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) - MDRV_SCREEN_SIZE(40*8, 32*8) - MDRV_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 0*8, 28*8-1) - - MDRV_SCREEN_ADD("rscreen", RASTER) - MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) - MDRV_SCREEN_REFRESH_RATE(60) - MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) - MDRV_SCREEN_SIZE(40*8, 32*8) - MDRV_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 0*8, 28*8-1) - - MDRV_VIDEO_START(psikyo4) - MDRV_VIDEO_UPDATE(psikyo4) - - /* sound hardware */ - MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - - MDRV_SOUND_ADD("ymf", YMF278B, MASTER_CLOCK/2) - MDRV_SOUND_CONFIG(ymf278b_config) - MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) - MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) -MACHINE_DRIVER_END - -static MACHINE_DRIVER_START( ps4small ) - /* basic machine hardware */ - MDRV_IMPORT_FROM(ps4big) - - MDRV_SCREEN_MODIFY("lscreen") - MDRV_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 0*8, 30*8-1) - - MDRV_SCREEN_MODIFY("rscreen") - MDRV_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 0*8, 30*8-1) -MACHINE_DRIVER_END - static INPUT_PORTS_START( hotgmck ) PORT_START("P1_P2") @@ -764,6 +708,104 @@ static INPUT_PORTS_START( hotdebut ) PORT_BIT( 0x00100000, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL) INPUT_PORTS_END + +static void irqhandler( const device_config *device, int linestate ) +{ + psikyo4_state *state = (psikyo4_state *)device->machine->driver_data; + cpu_set_input_line(state->maincpu, 12, linestate ? ASSERT_LINE : CLEAR_LINE); +} + +static const ymf278b_interface ymf278b_config = +{ + irqhandler +}; + + +static MACHINE_START( psikyo4 ) +{ + psikyo4_state *state = (psikyo4_state *)machine->driver_data; + + state->maincpu = devtag_get_device(machine, "maincpu"); + +#if ROMTEST +// FIXME: Too many banks! it cannot be handled in this way, currently +// memory_configure_bank(machine, "bank2", 0, 0x2000, memory_region(machine, "gfx1"), 0x2000); + + state->sample_offs = 0; + state_save_register_global(machine, state->sample_offs); +#endif + + state_save_register_global(machine, state->oldbrt1); + state_save_register_global(machine, state->oldbrt2); +} + +static MACHINE_RESET( psikyo4 ) +{ + psikyo4_state *state = (psikyo4_state *)machine->driver_data; + + state->oldbrt1 = -1; + state->oldbrt2 = -1; +} + +static MACHINE_DRIVER_START( ps4big ) + + /* driver data */ + MDRV_DRIVER_DATA(psikyo4_state) + + /* basic machine hardware */ + MDRV_CPU_ADD("maincpu", SH2, MASTER_CLOCK/2) + MDRV_CPU_PROGRAM_MAP(ps4_map) + MDRV_CPU_VBLANK_INT("lscreen", psikyosh_interrupt) + + MDRV_MACHINE_START(psikyo4) + MDRV_MACHINE_RESET(psikyo4) + + MDRV_NVRAM_HANDLER(93C56) + + /* video hardware */ + MDRV_GFXDECODE(ps4) + MDRV_PALETTE_LENGTH((0x2000/4)*2 + 2) /* 0x2000/4 for each screen. 1 for each screen clear colour */ + MDRV_DEFAULT_LAYOUT(layout_dualhsxs) + + MDRV_SCREEN_ADD("lscreen", RASTER) + MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) + MDRV_SCREEN_REFRESH_RATE(60) + MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) + MDRV_SCREEN_SIZE(40*8, 32*8) + MDRV_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 0*8, 28*8-1) + + MDRV_SCREEN_ADD("rscreen", RASTER) + MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) + MDRV_SCREEN_REFRESH_RATE(60) + MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) + MDRV_SCREEN_SIZE(40*8, 32*8) + MDRV_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 0*8, 28*8-1) + + MDRV_VIDEO_START(psikyo4) + MDRV_VIDEO_UPDATE(psikyo4) + + /* sound hardware */ + MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") + + MDRV_SOUND_ADD("ymf", YMF278B, MASTER_CLOCK/2) + MDRV_SOUND_CONFIG(ymf278b_config) + MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) + MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) +MACHINE_DRIVER_END + +static MACHINE_DRIVER_START( ps4small ) + /* basic machine hardware */ + MDRV_IMPORT_FROM(ps4big) + + MDRV_SCREEN_MODIFY("lscreen") + MDRV_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 0*8, 30*8-1) + + MDRV_SCREEN_MODIFY("rscreen") + MDRV_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 0*8, 30*8-1) +MACHINE_DRIVER_END + + + ROM_START( hotgmck ) /* main program */ ROM_REGION( 0x300000, "maincpu", 0) @@ -852,38 +894,38 @@ ROM_START( hotgm4ev ) ROM_REGION( 0x500000, "maincpu", 0) ROM_LOAD32_WORD_SWAP( "2.u22", 0x000000, 0x080000, CRC(3334c21e) SHA1(8d825448e40bc50d670ab8587a40df6b27ac918e) ) ROM_LOAD32_WORD_SWAP( "1.u23", 0x000002, 0x080000, CRC(b1a1c643) SHA1(1912a2d231e97ffbe9b668ca7f25cf406664f3ba) ) - ROM_LOAD16_WORD_SWAP( "prog.u1", 0x100000, 0x400000, CRC(ad556d8e) SHA1(d3dc3c5cbe939b6fc28f861e4132c5485ba89f50) ) // no test + ROM_LOAD16_WORD_SWAP( "prog.u1", 0x100000, 0x400000, CRC(ad556d8e) SHA1(d3dc3c5cbe939b6fc28f861e4132c5485ba89f50) ) // no test ROM_REGION( 0x8000000, "gfx1", 0 ) /* Sprites */ - ROM_LOAD32_WORD( "0l.u2", 0x0000000, 0x400000, CRC(f65986f7) SHA1(3824a7ea7f14ef3f319b07bd1224847131f6cac0) ) // ok + ROM_LOAD32_WORD( "0l.u2", 0x0000000, 0x400000, CRC(f65986f7) SHA1(3824a7ea7f14ef3f319b07bd1224847131f6cac0) ) // ok ROM_LOAD32_WORD( "0h.u11", 0x0000002, 0x400000, CRC(51fd07a9) SHA1(527097a376fc0ecb23aa8707eb5e029ec1126873) ) // ok - ROM_LOAD32_WORD( "1l.u3", 0x0800000, 0x400000, CRC(f59d21d7) SHA1(05a1b93f2926b419ff5e031a25fd227706d66050) ) // ok - ROM_LOAD32_WORD( "1h.u12", 0x0800002, 0x400000, CRC(60ea4797) SHA1(5da4a26496ac986ba0bdefde63040634775132dc) ) // ok - ROM_LOAD32_WORD( "2l.u4", 0x1000000, 0x400000, CRC(fbaf05e3) SHA1(ce929f1e87b05324e5e863bdb8baafef3d73f781) ) // ok - ROM_LOAD32_WORD( "2h.u13", 0x1000002, 0x400000, CRC(61281612) SHA1(88af33aa9348044c3620dd7a89e992f3812f45a8) ) // ok - ROM_LOAD32_WORD( "3l.u5", 0x1800000, 0x400000, CRC(e2e1bd9f) SHA1(8078bbffd6bf3abae6a3b36ae26628eb53ee5dc2) ) // ok - ROM_LOAD32_WORD( "3h.u14", 0x1800002, 0x400000, CRC(c4426542) SHA1(660e0fc3f641034cc0b2a8398951de0579b35d77) ) // ok - ROM_LOAD32_WORD( "4l.u6", 0x2000000, 0x400000, CRC(7298a242) SHA1(f1987a466bc1cb569d1b5f918ef6690b24479b3b) ) // ok - ROM_LOAD32_WORD( "4h.u15", 0x2000002, 0x400000, CRC(fe91b459) SHA1(18d0dc1c9f9103d505110dbc1a44f805597037d9) ) // ok - ROM_LOAD32_WORD( "5l.u7", 0x2800000, 0x400000, CRC(cc714a7d) SHA1(933c08fb34b138279d5ee7783d1b4865b2d4520a) ) // ok - ROM_LOAD32_WORD( "5h.u16", 0x2800002, 0x400000, CRC(2f149cf9) SHA1(598c3e606e3cd87938ccfc3c5e08d88c6044b393) ) // ok - ROM_LOAD32_WORD( "6l.u8", 0x3000000, 0x400000, CRC(bfe97dfe) SHA1(f249258a620188d0d7c3858cfb36af5d67ba94b2) ) // ok - ROM_LOAD32_WORD( "6h.u17", 0x3000002, 0x400000, CRC(3473052a) SHA1(897987422885a19a53a02257a9dde6348ec42f9f) ) // ok - ROM_LOAD32_WORD( "7l.u9", 0x3800000, 0x400000, CRC(022a8a31) SHA1(a21dbf36f56e144f9817c7255866546367dda2f6) ) // ok - ROM_LOAD32_WORD( "7h.u18", 0x3800002, 0x400000, CRC(77e47409) SHA1(0e1deb01dd1250c90fc3eed776becd51899f0b5f) ) // ok + ROM_LOAD32_WORD( "1l.u3", 0x0800000, 0x400000, CRC(f59d21d7) SHA1(05a1b93f2926b419ff5e031a25fd227706d66050) ) // ok + ROM_LOAD32_WORD( "1h.u12", 0x0800002, 0x400000, CRC(60ea4797) SHA1(5da4a26496ac986ba0bdefde63040634775132dc) ) // ok + ROM_LOAD32_WORD( "2l.u4", 0x1000000, 0x400000, CRC(fbaf05e3) SHA1(ce929f1e87b05324e5e863bdb8baafef3d73f781) ) // ok + ROM_LOAD32_WORD( "2h.u13", 0x1000002, 0x400000, CRC(61281612) SHA1(88af33aa9348044c3620dd7a89e992f3812f45a8) ) // ok + ROM_LOAD32_WORD( "3l.u5", 0x1800000, 0x400000, CRC(e2e1bd9f) SHA1(8078bbffd6bf3abae6a3b36ae26628eb53ee5dc2) ) // ok + ROM_LOAD32_WORD( "3h.u14", 0x1800002, 0x400000, CRC(c4426542) SHA1(660e0fc3f641034cc0b2a8398951de0579b35d77) ) // ok + ROM_LOAD32_WORD( "4l.u6", 0x2000000, 0x400000, CRC(7298a242) SHA1(f1987a466bc1cb569d1b5f918ef6690b24479b3b) ) // ok + ROM_LOAD32_WORD( "4h.u15", 0x2000002, 0x400000, CRC(fe91b459) SHA1(18d0dc1c9f9103d505110dbc1a44f805597037d9) ) // ok + ROM_LOAD32_WORD( "5l.u7", 0x2800000, 0x400000, CRC(cc714a7d) SHA1(933c08fb34b138279d5ee7783d1b4865b2d4520a) ) // ok + ROM_LOAD32_WORD( "5h.u16", 0x2800002, 0x400000, CRC(2f149cf9) SHA1(598c3e606e3cd87938ccfc3c5e08d88c6044b393) ) // ok + ROM_LOAD32_WORD( "6l.u8", 0x3000000, 0x400000, CRC(bfe97dfe) SHA1(f249258a620188d0d7c3858cfb36af5d67ba94b2) ) // ok + ROM_LOAD32_WORD( "6h.u17", 0x3000002, 0x400000, CRC(3473052a) SHA1(897987422885a19a53a02257a9dde6348ec42f9f) ) // ok + ROM_LOAD32_WORD( "7l.u9", 0x3800000, 0x400000, CRC(022a8a31) SHA1(a21dbf36f56e144f9817c7255866546367dda2f6) ) // ok + ROM_LOAD32_WORD( "7h.u18", 0x3800002, 0x400000, CRC(77e47409) SHA1(0e1deb01dd1250c90fc3eed776becd51899f0b5f) ) // ok ROM_REGION( 0x400000, "ymf", ROMREGION_ERASE00 ) ROM_REGION( 0x800000, "ymfsource", 0 ) - ROM_LOAD( "snd0.u10", 0x000000, 0x400000, CRC(051e2fed) SHA1(ee8073332801982549b3c142fba114e27733a756) ) // ok - ROM_LOAD( "snd1.u19", 0x400000, 0x400000, CRC(0de0232d) SHA1(c600fe1d3c6c05e451ae7ef249bb92e8fc9cec3a) ) // ok (but fails rom test due to banking error in emulation) + ROM_LOAD( "snd0.u10", 0x000000, 0x400000, CRC(051e2fed) SHA1(ee8073332801982549b3c142fba114e27733a756) ) // ok + ROM_LOAD( "snd1.u19", 0x400000, 0x400000, CRC(0de0232d) SHA1(c600fe1d3c6c05e451ae7ef249bb92e8fc9cec3a) ) // ok (but fails rom test due to banking error in emulation) ROM_END ROM_START( hotgmcki ) ROM_REGION( 0x500000, "maincpu", 0) ROM_LOAD32_WORD_SWAP( "2.u22", 0x000000, 0x080000, CRC(abc192dd) SHA1(674c2b8814319605c1b6221bbe18588a98dda093) ) ROM_LOAD32_WORD_SWAP( "1.u23", 0x000002, 0x080000, CRC(8be896d0) SHA1(5d677dede4ec18cbfc54acae95fe0f10bfc4d566) ) - ROM_LOAD16_WORD_SWAP( "prog.u1", 0x100000, 0x200000, CRC(9017ae8e) SHA1(0879198606095a2d209df059538ce1c73460b30e) ) // no test + ROM_LOAD16_WORD_SWAP( "prog.u1", 0x100000, 0x200000, CRC(9017ae8e) SHA1(0879198606095a2d209df059538ce1c73460b30e) ) // no test ROM_RELOAD(0x300000,0x200000) /* Roms have to be mirrored with ROM_RELOAD for rom tests to pass */ @@ -894,7 +936,7 @@ ROM_START( hotgmcki ) ROM_RELOAD( 0x0400002, 0x200000 ) ROM_LOAD32_WORD( "1l.u3", 0x0800000, 0x200000, CRC(27576360) SHA1(ed9d6f5b9934e8ddae3f3ca146e99f42dbd495de) ) // ok ROM_RELOAD( 0x0c00000, 0x200000 ) - ROM_LOAD32_WORD( "1h.u12", 0x0800002, 0x200000, CRC(7439a63f) SHA1(c9a74e5e81a2c94ce7a9b3b487f54ac5b3635744) ) // ok + ROM_LOAD32_WORD( "1h.u12", 0x0800002, 0x200000, CRC(7439a63f) SHA1(c9a74e5e81a2c94ce7a9b3b487f54ac5b3635744) ) // ok ROM_RELOAD( 0x0c00002, 0x200000 ) ROM_LOAD32_WORD( "2l.u4", 0x1000000, 0x200000, CRC(fda64e24) SHA1(e8788b5f0e8b0f90c9942f9f4cbcee02be8afd09) ) // ok ROM_RELOAD( 0x1400000, 0x200000 ) @@ -992,9 +1034,12 @@ PC :00001B44: MOV.L @R1,R2 PC :00001B46: TST R2,R2 PC :00001B48: BT $00001B3C */ + psikyo4_state *state = (psikyo4_state *)space->machine->driver_data; + + if (cpu_get_pc(space->cpu) == 0x00001b3e) + cpu_spinuntil_int(space->cpu); - if (cpu_get_pc(space->cpu)==0x00001B3E) cpu_spinuntil_int(space->cpu); - return ps4_ram[0x000020/4]; + return state->ram[0x000020 / 4]; } static READ32_HANDLER( loderdfa_speedup_r ) @@ -1008,9 +1053,12 @@ PC :00001B50: MOV.L @R1,R2 PC :00001B52: TST R2,R2 PC :00001B54: BT $00001B48 */ + psikyo4_state *state = (psikyo4_state *)space->machine->driver_data; - if (cpu_get_pc(space->cpu)==0x00001B4A) cpu_spinuntil_int(space->cpu); - return ps4_ram[0x000020/4]; + if (cpu_get_pc(space->cpu) == 0x00001b4a) + cpu_spinuntil_int(space->cpu); + + return state->ram[0x000020 / 4]; } static READ32_HANDLER( hotdebut_speedup_r ) @@ -1024,9 +1072,12 @@ PC :000029F4: MOV.L @R1,R3 PC :000029F6: TST R3,R3 PC :000029F8: BT $000029EC */ + psikyo4_state *state = (psikyo4_state *)space->machine->driver_data; + + if (cpu_get_pc(space->cpu) == 0x000029ee) + cpu_spinuntil_int(space->cpu); - if (cpu_get_pc(space->cpu)==0x000029EE) cpu_spinuntil_int(space->cpu); - return ps4_ram[0x00001c/4]; + return state->ram[0x00001c / 4]; } static STATE_POSTLOAD( hotgmck_pcm_bank_postload ) @@ -1036,12 +1087,13 @@ static STATE_POSTLOAD( hotgmck_pcm_bank_postload ) static void install_hotgmck_pcm_bank(running_machine *machine) { + psikyo4_state *state = (psikyo4_state *)machine->driver_data; UINT8 *ymf_pcm = memory_region(machine, "ymf"); UINT8 *pcm_rom = memory_region(machine, "ymfsource"); memcpy(ymf_pcm, pcm_rom, 0x200000); - ps4_io_select[0] = (ps4_io_select[0] & 0x00ffffff) | 0x32000000; + state->io_select[0] = (state->io_select[0] & 0x00ffffff) | 0x32000000; set_hotgmck_pcm_bank(machine, 0); set_hotgmck_pcm_bank(machine, 1); diff --git a/src/mame/drivers/psikyosh.c b/src/mame/drivers/psikyosh.c index b88c6cf016b..5d329b3f186 100644 --- a/src/mame/drivers/psikyosh.c +++ b/src/mame/drivers/psikyosh.c @@ -288,9 +288,6 @@ static const UINT8 mjgtaste_eeprom[16] = { 0x00,0x00,0x00,0x01,0x01,0x00,0x01,0x static int use_factory_eeprom; -UINT32 *psikyosh_bgram, *psikyosh_zoomram, *psikyosh_vidregs; -static UINT32 *psh_ram; - static const gfx_layout layout_16x16x4 = { 16,16, @@ -433,48 +430,47 @@ static INTERRUPT_GEN(psikyosh_interrupt) // bit 0 controls game speed on readback, mechanism is a little weird static WRITE32_HANDLER( psikyosh_irqctrl_w ) { + psikyosh_state *state = (psikyosh_state *)space->machine->driver_data; if (!(data & 0x00c00000)) { - cputag_set_input_line(space->machine, "maincpu", 4, CLEAR_LINE); + cpu_set_input_line(state->maincpu, 4, CLEAR_LINE); } } static WRITE32_HANDLER( paletteram32_RRRRRRRRGGGGGGGGBBBBBBBBxxxxxxxx_dword_w ) { - int r,g,b; - COMBINE_DATA(&space->machine->generic.paletteram.u32[offset]); /* is this ok .. */ + psikyosh_state *state = (psikyosh_state *)space->machine->driver_data; + int r, g, b; + COMBINE_DATA(&state->paletteram[offset]); /* is this ok .. */ - b = ((space->machine->generic.paletteram.u32[offset] & 0x0000ff00) >>8); - g = ((space->machine->generic.paletteram.u32[offset] & 0x00ff0000) >>16); - r = ((space->machine->generic.paletteram.u32[offset] & 0xff000000) >>24); + b = ((state->paletteram[offset] & 0x0000ff00) >>8); + g = ((state->paletteram[offset] & 0x00ff0000) >>16); + r = ((state->paletteram[offset] & 0xff000000) >>24); - palette_set_color(space->machine,offset,MAKE_RGB(r,g,b)); + palette_set_color(space->machine, offset, MAKE_RGB(r, g, b)); } static WRITE32_HANDLER( psikyosh_vidregs_w ) { - COMBINE_DATA(&psikyosh_vidregs[offset]); + psikyosh_state *state = (psikyosh_state *)space->machine->driver_data; + COMBINE_DATA(&state->vidregs[offset]); #if ROMTEST - if(offset==4) /* Configure bank for gfx test */ + if (offset == 4) /* Configure bank for gfx test */ { if (ACCESSING_BITS_0_15) // Bank - { - UINT8 *ROM = memory_region(space->machine, "gfx1"); - memory_set_bankptr(space->machine, "bank2",&ROM[0x20000 * (psikyosh_vidregs[offset]&0xfff)]); /* Bank comes from vidregs */ - } + memory_set_bank(space->machine, "bank2", state->vidregs[offset] & 0xfff); } #endif } #if ROMTEST -static UINT32 sample_offs = 0; - static READ32_HANDLER( psh_sample_r ) /* Send sample data for test */ { + psikyosh_state *state = (psikyosh_state *)space->machine->driver_data; UINT8 *ROM = memory_region(space->machine, "ymf"); - return ROM[sample_offs++]<<16; + return ROM[state->sample_offs++] << 16; } #endif @@ -483,16 +479,16 @@ static ADDRESS_MAP_START( ps3v1_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x00000000, 0x000fffff) AM_ROM // program ROM (1 meg) AM_RANGE(0x02000000, 0x021fffff) AM_ROMBANK("bank1") // data ROM AM_RANGE(0x03000000, 0x03003fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) // sprites (might be a bit longer) - AM_RANGE(0x03004000, 0x0300ffff) AM_RAM AM_BASE(&psikyosh_bgram) // backgrounds - AM_RANGE(0x03040000, 0x03044fff) AM_RAM_WRITE(paletteram32_RRRRRRRRGGGGGGGGBBBBBBBBxxxxxxxx_dword_w) AM_BASE_GENERIC(paletteram) // palette.. - AM_RANGE(0x03050000, 0x030501ff) AM_RAM AM_BASE(&psikyosh_zoomram) // a gradient sometimes ... + AM_RANGE(0x03004000, 0x0300ffff) AM_RAM AM_BASE_MEMBER(psikyosh_state, bgram) // backgrounds + AM_RANGE(0x03040000, 0x03044fff) AM_RAM_WRITE(paletteram32_RRRRRRRRGGGGGGGGBBBBBBBBxxxxxxxx_dword_w) AM_BASE_MEMBER(psikyosh_state, paletteram) // palette.. + AM_RANGE(0x03050000, 0x030501ff) AM_RAM AM_BASE_MEMBER(psikyosh_state, zoomram) // a gradient sometimes ... AM_RANGE(0x0305ffdc, 0x0305ffdf) AM_READNOP AM_WRITE(psikyosh_irqctrl_w) // also writes to this address - might be vblank reads? - AM_RANGE(0x0305ffe0, 0x0305ffff) AM_RAM_WRITE(psikyosh_vidregs_w) AM_BASE(&psikyosh_vidregs) // video registers + AM_RANGE(0x0305ffe0, 0x0305ffff) AM_RAM_WRITE(psikyosh_vidregs_w) AM_BASE_MEMBER(psikyosh_state, vidregs) // video registers AM_RANGE(0x05000000, 0x05000003) AM_DEVREAD8("ymf", ymf278b_r, 0xffffffff) // read YMF status AM_RANGE(0x05000000, 0x05000007) AM_DEVWRITE8("ymf", ymf278b_w, 0xffffffff) AM_RANGE(0x05800000, 0x05800003) AM_READ_PORT("INPUTS") - AM_RANGE(0x05800004, 0x05800007) AM_READWRITE(psh_eeprom_r,psh_eeprom_w) - AM_RANGE(0x06000000, 0x060fffff) AM_RAM AM_BASE(&psh_ram) // main RAM (1 meg) + AM_RANGE(0x05800004, 0x05800007) AM_READWRITE(psh_eeprom_r, psh_eeprom_w) + AM_RANGE(0x06000000, 0x060fffff) AM_RAM AM_BASE_MEMBER(psikyosh_state, ram) // main RAM (1 meg) #if ROMTEST AM_RANGE(0x05000004, 0x05000007) AM_READ(psh_sample_r) // data for rom tests (Used to verify Sample rom) @@ -508,13 +504,13 @@ static ADDRESS_MAP_START( ps5_map, ADDRESS_SPACE_PROGRAM, 32 ) AM_RANGE(0x03100000, 0x03100003) AM_DEVREAD8("ymf", ymf278b_r, 0xffffffff) AM_RANGE(0x03100000, 0x03100007) AM_DEVWRITE8("ymf", ymf278b_w, 0xffffffff) AM_RANGE(0x04000000, 0x04003fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) - AM_RANGE(0x04004000, 0x0400ffff) AM_RAM AM_BASE(&psikyosh_bgram) // backgrounds - AM_RANGE(0x04040000, 0x04044fff) AM_RAM_WRITE(paletteram32_RRRRRRRRGGGGGGGGBBBBBBBBxxxxxxxx_dword_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0x04050000, 0x040501ff) AM_RAM AM_BASE(&psikyosh_zoomram) + AM_RANGE(0x04004000, 0x0400ffff) AM_RAM AM_BASE_MEMBER(psikyosh_state, bgram) // backgrounds + AM_RANGE(0x04040000, 0x04044fff) AM_RAM_WRITE(paletteram32_RRRRRRRRGGGGGGGGBBBBBBBBxxxxxxxx_dword_w) AM_BASE_MEMBER(psikyosh_state, paletteram) + AM_RANGE(0x04050000, 0x040501ff) AM_RAM AM_BASE_MEMBER(psikyosh_state, zoomram) AM_RANGE(0x0405ffdc, 0x0405ffdf) AM_READNOP AM_WRITE(psikyosh_irqctrl_w) // also writes to this address - might be vblank reads? - AM_RANGE(0x0405ffe0, 0x0405ffff) AM_RAM_WRITE(psikyosh_vidregs_w) AM_BASE(&psikyosh_vidregs) // video registers + AM_RANGE(0x0405ffe0, 0x0405ffff) AM_RAM_WRITE(psikyosh_vidregs_w) AM_BASE_MEMBER(psikyosh_state, vidregs) // video registers AM_RANGE(0x05000000, 0x0507ffff) AM_ROMBANK("bank1") // data ROM - AM_RANGE(0x06000000, 0x060fffff) AM_RAM AM_BASE(&psh_ram) + AM_RANGE(0x06000000, 0x060fffff) AM_RAM AM_BASE_MEMBER(psikyosh_state, ram) #if ROMTEST AM_RANGE(0x03100004, 0x03100007) AM_READ(psh_sample_r) // data for rom tests (Used to verify Sample rom) @@ -523,73 +519,6 @@ static ADDRESS_MAP_START( ps5_map, ADDRESS_SPACE_PROGRAM, 32 ) ADDRESS_MAP_END -static void irqhandler(const device_config *device, int linestate) -{ - if (linestate) - cputag_set_input_line(device->machine, "maincpu", 12, ASSERT_LINE); - else - cputag_set_input_line(device->machine, "maincpu", 12, CLEAR_LINE); -} - -static const ymf278b_interface ymf278b_config = -{ - irqhandler -}; - -static MACHINE_DRIVER_START( psikyo3v1 ) - /* basic machine hardware */ - MDRV_CPU_ADD("maincpu", SH2, MASTER_CLOCK/2) - MDRV_CPU_PROGRAM_MAP(ps3v1_map) - MDRV_CPU_VBLANK_INT("screen", psikyosh_interrupt) - - MDRV_NVRAM_HANDLER(93C56) - - /* video hardware */ - MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM ) /* If using alpha */ - - MDRV_SCREEN_ADD("screen", RASTER) - MDRV_SCREEN_REFRESH_RATE(60) - MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) - MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) - MDRV_SCREEN_SIZE(64*8, 32*8) - MDRV_SCREEN_VISIBLE_AREA(0, 40*8-1, 0, 28*8-1) - - MDRV_GFXDECODE(psikyosh) - MDRV_PALETTE_LENGTH(0x5000/4) - - MDRV_VIDEO_START(psikyosh) - MDRV_VIDEO_EOF(psikyosh) - MDRV_VIDEO_UPDATE(psikyosh) - - /* sound hardware */ - MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - - MDRV_SOUND_ADD("ymf", YMF278B, MASTER_CLOCK/2) - MDRV_SOUND_CONFIG(ymf278b_config) - MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) - MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) -MACHINE_DRIVER_END - -static MACHINE_DRIVER_START( psikyo5 ) - /* basic machine hardware */ - MDRV_IMPORT_FROM(psikyo3v1) - - MDRV_CPU_MODIFY("maincpu") - MDRV_CPU_PROGRAM_MAP(ps5_map) -MACHINE_DRIVER_END - -static MACHINE_DRIVER_START( psikyo5_240 ) - /* basic machine hardware */ - MDRV_IMPORT_FROM(psikyo3v1) - - MDRV_CPU_MODIFY("maincpu") - MDRV_CPU_PROGRAM_MAP(ps5_map) - - /* It probably has a register to change visarea */ - MDRV_SCREEN_MODIFY("screen") - MDRV_SCREEN_VISIBLE_AREA(0, 40*8-1, 0, 30*8-1) -MACHINE_DRIVER_END - static INPUT_PORTS_START( common ) PORT_START("INPUTS") PORT_BIT( 0x00000001, IP_ACTIVE_LOW, IPT_COIN1 ) @@ -762,6 +691,94 @@ static INPUT_PORTS_START( mjgtaste ) /* This will need the Mahjong inputs */ INPUT_PORTS_END +static void irqhandler(const device_config *device, int linestate) +{ + psikyosh_state *state = (psikyosh_state *)device->machine->driver_data; + cpu_set_input_line(state->maincpu, 12, linestate ? ASSERT_LINE : CLEAR_LINE); +} + +static const ymf278b_interface ymf278b_config = +{ + irqhandler +}; + + +static MACHINE_START( psikyosh ) +{ + psikyosh_state *state = (psikyosh_state *)machine->driver_data; + + state->maincpu = devtag_get_device(machine, "maincpu"); + +#if ROMTEST + memory_configure_bank(machine, "bank2", 0, 0x1000, memory_region(machine, "gfx1"), 0x20000); + + state->sample_offs = 0; + state_save_register_global(machine, state->sample_offs); +#endif +} + + +static MACHINE_DRIVER_START( psikyo3v1 ) + + /* driver data */ + MDRV_DRIVER_DATA(psikyosh_state) + + /* basic machine hardware */ + MDRV_CPU_ADD("maincpu", SH2, MASTER_CLOCK/2) + MDRV_CPU_PROGRAM_MAP(ps3v1_map) + MDRV_CPU_VBLANK_INT("screen", psikyosh_interrupt) + + MDRV_MACHINE_START(psikyosh) + + MDRV_NVRAM_HANDLER(93C56) + + /* video hardware */ + MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM ) /* If using alpha */ + + MDRV_SCREEN_ADD("screen", RASTER) + MDRV_SCREEN_REFRESH_RATE(60) + MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) + MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) + MDRV_SCREEN_SIZE(64*8, 32*8) + MDRV_SCREEN_VISIBLE_AREA(0, 40*8-1, 0, 28*8-1) + + MDRV_GFXDECODE(psikyosh) + MDRV_PALETTE_LENGTH(0x5000/4) + + MDRV_VIDEO_START(psikyosh) + MDRV_VIDEO_EOF(psikyosh) + MDRV_VIDEO_UPDATE(psikyosh) + + /* sound hardware */ + MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") + + MDRV_SOUND_ADD("ymf", YMF278B, MASTER_CLOCK/2) + MDRV_SOUND_CONFIG(ymf278b_config) + MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0) + MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0) +MACHINE_DRIVER_END + +static MACHINE_DRIVER_START( psikyo5 ) + /* basic machine hardware */ + MDRV_IMPORT_FROM(psikyo3v1) + + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_PROGRAM_MAP(ps5_map) +MACHINE_DRIVER_END + +static MACHINE_DRIVER_START( psikyo5_240 ) + /* basic machine hardware */ + MDRV_IMPORT_FROM(psikyo3v1) + + MDRV_CPU_MODIFY("maincpu") + MDRV_CPU_PROGRAM_MAP(ps5_map) + + /* It probably has a register to change visarea */ + MDRV_SCREEN_MODIFY("screen") + MDRV_SCREEN_VISIBLE_AREA(0, 40*8-1, 0, 30*8-1) +MACHINE_DRIVER_END + + /* PS3 */ ROM_START( soldivid ) @@ -1067,13 +1084,13 @@ ROM_END static DRIVER_INIT( soldivid ) { - sh2drc_set_options(cputag_get_cpu(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS); + sh2drc_set_options(devtag_get_device(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS); use_factory_eeprom = eeprom_0; } static DRIVER_INIT( s1945ii ) { - sh2drc_set_options(cputag_get_cpu(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS); + sh2drc_set_options(devtag_get_device(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS); use_factory_eeprom = eeprom_DEFAULT; } @@ -1081,13 +1098,13 @@ static DRIVER_INIT( daraku ) { UINT8 *RAM = memory_region(machine, "maincpu"); memory_set_bankptr(machine, "bank1", &RAM[0x100000]); - sh2drc_set_options(cputag_get_cpu(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS); + sh2drc_set_options(devtag_get_device(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS); use_factory_eeprom = eeprom_DARAKU; } static DRIVER_INIT( sbomberb ) { - sh2drc_set_options(cputag_get_cpu(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS); + sh2drc_set_options(devtag_get_device(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS); use_factory_eeprom = eeprom_DEFAULT; } @@ -1095,7 +1112,7 @@ static DRIVER_INIT( gunbird2 ) { UINT8 *RAM = memory_region(machine, "maincpu"); memory_set_bankptr(machine, "bank1", &RAM[0x100000]); - sh2drc_set_options(cputag_get_cpu(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS); + sh2drc_set_options(devtag_get_device(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS); use_factory_eeprom = eeprom_DEFAULT; } @@ -1103,31 +1120,31 @@ static DRIVER_INIT( s1945iii ) { UINT8 *RAM = memory_region(machine, "maincpu"); memory_set_bankptr(machine, "bank1", &RAM[0x100000]); - sh2drc_set_options(cputag_get_cpu(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS); + sh2drc_set_options(devtag_get_device(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS); use_factory_eeprom = eeprom_S1945III; } static DRIVER_INIT( dragnblz ) { - sh2drc_set_options(cputag_get_cpu(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS); + sh2drc_set_options(devtag_get_device(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS); use_factory_eeprom = eeprom_DRAGNBLZ; } static DRIVER_INIT( gnbarich ) { - sh2drc_set_options(cputag_get_cpu(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS); + sh2drc_set_options(devtag_get_device(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS); use_factory_eeprom = eeprom_GNBARICH; } static DRIVER_INIT( tgm2 ) { - sh2drc_set_options(cputag_get_cpu(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS); + sh2drc_set_options(devtag_get_device(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS); use_factory_eeprom = eeprom_USER1; } static DRIVER_INIT( mjgtaste ) { - sh2drc_set_options(cputag_get_cpu(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS); + sh2drc_set_options(devtag_get_device(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS); use_factory_eeprom = eeprom_MJGTASTE; /* needs to install mahjong controls too (can select joystick in test mode tho) */ } diff --git a/src/mame/includes/pgm.h b/src/mame/includes/pgm.h index 486ef184fdc..f3370b509e7 100644 --- a/src/mame/includes/pgm.h +++ b/src/mame/includes/pgm.h @@ -1,14 +1,75 @@ -/*----------- defined in drivers/pgm.c -----------*/ - -extern UINT16 *pgm_mainram, *pgm_bg_videoram, *pgm_tx_videoram, *pgm_videoregs, *pgm_rowscrollram; - -extern UINT8 *pgm_sprite_a_region; -extern size_t pgm_sprite_a_region_allocate; +typedef struct _pgm_state pgm_state; +struct _pgm_state +{ + /* memory pointers */ +// UINT16 * mainram; // currently this is also used by nvram handler + UINT16 * bg_videoram; + UINT16 * tx_videoram; + UINT16 * videoregs; + UINT16 * rowscrollram; + UINT16 * videoram; + UINT8 * z80_mainram; + UINT32 * arm7_shareram; + UINT32 * svg_shareram[2]; //for 5585G MACHINE + UINT16 * sharedprotram; // killbld & olds + UINT8 * sprite_a_region; + size_t sprite_a_region_size; + UINT16 * spritebufferram; // buffered spriteram +// UINT16 * paletteram; // currently this uses generic palette handling + + /* video-related */ + tilemap *bg_tilemap, *tx_tilemap; + UINT16 *sprite_temp_render; + bitmap_t *tmppgmbitmap; + + /* misc */ + // kov2 + UINT32 kov2_latchdata_68k_w; + UINT32 kov2_latchdata_arm_w; + // kovsh + UINT16 kovsh_highlatch_arm_w, kovsh_lowlatch_arm_w; + UINT16 kovsh_highlatch_68k_w, kovsh_lowlatch_68k_w; + UINT32 kovsh_counter; + // svg + int svg_ram_sel; + // killbld & olds + int kb_cmd; + int kb_reg; + int kb_ptr; + UINT32 kb_regs[0x10]; + UINT16 olds_bs, olds_cmd3; + // pstars + UINT16 pstars_key; + UINT16 pstars_int[2]; + UINT32 pstars_regs[16]; + UINT32 pstars_val; + UINT16 pstar_e7, pstar_b1, pstar_ce; + UINT16 pstar_ram[3]; + // ASIC 3 (oriental legends protection) + UINT8 asic3_reg, asic3_latch[3], asic3_x, asic3_y, asic3_z, asic3_h1, asic3_h2; + UINT16 asic3_hold; + // ASIC28 + UINT16 asic28_key; + UINT16 asic28_regs[10]; + UINT16 asic_params[256]; + UINT16 asic28_rcnt; + UINT32 eoregs[16]; + + /* calendar */ + UINT8 cal_val, cal_mask, cal_com, cal_cnt; + mame_system_time systime; + + /* devices */ + const device_config *soundcpu; + const device_config *prot; + const device_config *ics; +}; + +extern UINT16 *pgm_mainram; // used by nvram handler, we cannot move it to driver data struct /*----------- defined in machine/pgmcrypt.c -----------*/ - void pgm_kov_decrypt(running_machine *machine); void pgm_kovsh_decrypt(running_machine *machine); void pgm_kov2_decrypt(running_machine *machine); @@ -31,26 +92,26 @@ void pgm_svg_decrypt(running_machine *machine); /*----------- defined in machine/pgmprot.c -----------*/ -READ16_HANDLER (PSTARS_protram_r); -READ16_HANDLER ( PSTARS_r16 ); -WRITE16_HANDLER( PSTARS_w16 ); +READ16_HANDLER( pstars_protram_r ); +READ16_HANDLER( pstars_r ); +WRITE16_HANDLER( pstars_w ); READ16_HANDLER( pgm_asic3_r ); WRITE16_HANDLER( pgm_asic3_w ); WRITE16_HANDLER( pgm_asic3_reg_w ); -READ16_HANDLER (sango_protram_r); -READ16_HANDLER (ASIC28_r16); -WRITE16_HANDLER (ASIC28_w16); +READ16_HANDLER( sango_protram_r ); +READ16_HANDLER( asic28_r ); +WRITE16_HANDLER( asic28_w ); -READ16_HANDLER (dw2_d80000_r ); +READ16_HANDLER( dw2_d80000_r ); /*----------- defined in video/pgm.c -----------*/ - WRITE16_HANDLER( pgm_tx_videoram_w ); WRITE16_HANDLER( pgm_bg_videoram_w ); + VIDEO_START( pgm ); VIDEO_EOF( pgm ); VIDEO_UPDATE( pgm ); diff --git a/src/mame/includes/psikyo.h b/src/mame/includes/psikyo.h new file mode 100644 index 00000000000..45052566af7 --- /dev/null +++ b/src/mame/includes/psikyo.h @@ -0,0 +1,53 @@ +/************************************************************************* + + Psikyo Games + +*************************************************************************/ + +typedef struct _psikyo_state psikyo_state; +struct _psikyo_state +{ + /* memory pointers */ + UINT32 * vram_0; + UINT32 * vram_1; + UINT32 * vregs; + UINT32 * spritebuf1; + UINT32 * spritebuf2; + UINT32 * bootleg_spritebuffer; +// UINT32 * paletteram; // currently this uses generic palette handling +// UINT32 * spriteram; // currently this uses generic buffered spriteram +// size_t spriteram_size; + + /* video-related */ + tilemap *tilemap_0_size0, *tilemap_0_size1, *tilemap_0_size2, *tilemap_0_size3; + tilemap *tilemap_1_size0, *tilemap_1_size1, *tilemap_1_size2, *tilemap_1_size3; + int tilemap_0_bank, tilemap_1_bank; + int ka302c_banking; + + /* misc */ + UINT8 soundlatch; + int z80_nmi, mcu_status; + + /* devices */ + const device_config *audiocpu; + + /* game-specific */ + // 1945 MCU + UINT8 s1945_mcu_direction, s1945_mcu_latch1, s1945_mcu_latch2, s1945_mcu_inlatch, s1945_mcu_index; + UINT8 s1945_mcu_latching, s1945_mcu_mode, s1945_mcu_control, s1945_mcu_bctrl; + const UINT8 *s1945_mcu_table; +}; + + +/*----------- defined in video/psikyo.c -----------*/ + +void psikyo_switch_banks(running_machine *machine, int tmap, int bank); + +WRITE32_HANDLER( psikyo_vram_0_w ); +WRITE32_HANDLER( psikyo_vram_1_w ); + +VIDEO_START( sngkace ); +VIDEO_START( psikyo ); +VIDEO_UPDATE( psikyo ); +VIDEO_UPDATE( psikyo_bootleg ); +VIDEO_EOF( psikyo ); diff --git a/src/mame/includes/psikyo4.h b/src/mame/includes/psikyo4.h new file mode 100644 index 00000000000..5e4621d9dc0 --- /dev/null +++ b/src/mame/includes/psikyo4.h @@ -0,0 +1,37 @@ +/************************************************************************* + + Psikyo PS6807 (PS4) + +*************************************************************************/ + +#define MASTER_CLOCK 57272700 // main oscillator frequency + + +typedef struct _psikyo4_state psikyo4_state; +struct _psikyo4_state +{ + /* memory pointers */ + UINT32 * vidregs; + UINT32 * paletteram; + UINT32 * ram; + UINT32 * io_select; + UINT32 * bgpen_1; + UINT32 * bgpen_2; + UINT32 * spriteram; + size_t spriteram_size; + + /* video-related */ + double oldbrt1, oldbrt2; + + /* misc */ + UINT32 sample_offs; // only used if ROMTEST = 1 + + /* devices */ + const device_config *maincpu; +}; + + +/*----------- defined in video/psikyo4.c -----------*/ + +VIDEO_START( psikyo4 ); +VIDEO_UPDATE( psikyo4 ); diff --git a/src/mame/includes/psikyosh.h b/src/mame/includes/psikyosh.h index 711d7aaf3ea..7b400547f40 100644 --- a/src/mame/includes/psikyosh.h +++ b/src/mame/includes/psikyosh.h @@ -1,25 +1,14 @@ -/*----------- defined in drivers/psikyosh.c -----------*/ #define MASTER_CLOCK 57272700 // main oscillator frequency -extern UINT32 *psikyosh_bgram, *psikyosh_zoomram, *psikyosh_vidregs; - -/*----------- defined in video/psikyosh.c -----------*/ - -VIDEO_START( psikyosh ); -VIDEO_UPDATE( psikyosh ); -VIDEO_EOF( psikyosh ); - -enum { eeprom_0=0, eeprom_DEFAULT=1, eeprom_DARAKU, eeprom_S1945III, eeprom_DRAGNBLZ, eeprom_GNBARICH, eeprom_USER1, eeprom_MJGTASTE }; - /* Psikyo PS6406B */ -#define FLIPSCREEN (((psikyosh_vidregs[3] & 0x0000c000) == 0x0000c000) ? 1:0) -#define DISPLAY_DISABLE (((psikyosh_vidregs[2] & 0x0000000f) == 0x00000006) ? 1:0) -#define BG_LARGE(n) (((psikyosh_vidregs[7] << (4*n)) & 0x00001000 ) ? 1:0) -#define BG_DEPTH_8BPP(n) (((psikyosh_vidregs[7] << (4*n)) & 0x00004000 ) ? 1:0) -#define BG_LAYER_ENABLE(n) (((psikyosh_vidregs[7] << (4*n)) & 0x00008000 ) ? 1:0) +#define FLIPSCREEN (((state->vidregs[3] & 0x0000c000) == 0x0000c000) ? 1:0) +#define DISPLAY_DISABLE (((state->vidregs[2] & 0x0000000f) == 0x00000006) ? 1:0) +#define BG_LARGE(n) (((state->vidregs[7] << (4*n)) & 0x00001000 ) ? 1:0) +#define BG_DEPTH_8BPP(n) (((state->vidregs[7] << (4*n)) & 0x00004000 ) ? 1:0) +#define BG_LAYER_ENABLE(n) (((state->vidregs[7] << (4*n)) & 0x00008000 ) ? 1:0) -#define BG_TYPE(n) (((psikyosh_vidregs[6] << (8*n)) & 0x7f000000 ) >> 24) +#define BG_TYPE(n) (((state->vidregs[6] << (8*n)) & 0x7f000000 ) >> 24) #define BG_NORMAL 0x0a #define BG_NORMAL_ALT 0x0b /* Same as above but with different location for scroll/priority reg */ @@ -27,3 +16,35 @@ enum { eeprom_0=0, eeprom_DEFAULT=1, eeprom_DARAKU, eeprom_S1945III, eeprom_DRAG #define BG_SCROLL_0C 0x0c /* 224 v/h scroll values in bank 0x0c; Used in daraku, for text */ #define BG_SCROLL_0D 0x0d /* 224 v/h scroll values in bank 0x0d; Used in daraku, for alternate characters of text */ #define BG_SCROLL_ZOOM 0x0e /* 224 v/h scroll values in bank 0x0e-0x1f; Used in s1945ii, s1945iii */ + +enum { eeprom_0=0, eeprom_DEFAULT=1, eeprom_DARAKU, eeprom_S1945III, eeprom_DRAGNBLZ, eeprom_GNBARICH, eeprom_USER1, eeprom_MJGTASTE }; + + +typedef struct _psikyosh_state psikyosh_state; +struct _psikyosh_state +{ + /* memory pointers */ + UINT32 * bgram; + UINT32 * zoomram; + UINT32 * vidregs; + UINT32 * ram; + UINT32 * paletteram; +// UINT32 * spriteram; // currently this uses generic buffered spriteram +// size_t spriteram_size; + + /* video-related */ + bitmap_t *zoom_bitmap, *z_bitmap; +// UINT8 alphatable[256]; + + /* misc */ + UINT32 sample_offs; // only used if ROMTEST = 1 + + /* devices */ + const device_config *maincpu; +}; + +/*----------- defined in video/psikyosh.c -----------*/ + +VIDEO_START( psikyosh ); +VIDEO_UPDATE( psikyosh ); +VIDEO_EOF( psikyosh ); diff --git a/src/mame/machine/pgmprot.c b/src/mame/machine/pgmprot.c index f34617ce132..1b3613c02ba 100644 --- a/src/mame/machine/pgmprot.c +++ b/src/mame/machine/pgmprot.c @@ -6,49 +6,40 @@ /*** ASIC27a (Puzzle Star) -- ARM but with no external rom? behaves a bit like KOV ***/ +/*** (pstarS) ***/ - -/*** (PSTARS) ***/ -static UINT16 PSTARSKEY; -static UINT16 PSTARSINT[2]; -static UINT32 PSTARS_REGS[16]; -static UINT32 PSTARS_VAL; - -static UINT16 pstar_e7,pstar_b1,pstar_ce; -static UINT16 pstar_ram[3]; - -static const int Pstar_ba[0x1E]={ +static const int pstar_ba[0x1E]={ 0x02,0x00,0x00,0x01,0x00,0x03,0x00,0x00, //0 0x02,0x00,0x06,0x00,0x22,0x04,0x00,0x03, //8 0x00,0x00,0x06,0x00,0x20,0x07,0x00,0x03, //10 0x00,0x21,0x01,0x00,0x00,0x63 }; -static const int Pstar_b0[0x10]={ +static const int pstar_b0[0x10]={ 0x09,0x0A,0x0B,0x00,0x01,0x02,0x03,0x04, 0x05,0x06,0x07,0x08,0x00,0x00,0x00,0x00 }; -static const int Pstar_ae[0x10]={ +static const int pstar_ae[0x10]={ 0x5D,0x86,0x8C ,0x8B,0xE0,0x8B,0x62,0xAF, 0xB6,0xAF,0x10A,0xAF,0x00,0x00,0x00,0x00 }; -static const int Pstar_a0[0x10]={ +static const int pstar_a0[0x10]={ 0x02,0x03,0x04,0x05,0x06,0x01,0x0A,0x0B, 0x0C,0x0D,0x0E,0x09,0x00,0x00,0x00,0x00, }; -static const int Pstar_9d[0x10]={ +static const int pstar_9d[0x10]={ 0x05,0x03,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }; -static const int Pstar_90[0x10]={ +static const int pstar_90[0x10]={ 0x0C,0x10,0x0E,0x0C,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; -static const int Pstar_8c[0x23]={ +static const int pstar_8c[0x23]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02, @@ -56,7 +47,7 @@ static const int Pstar_8c[0x23]={ 0x03,0x03,0x03 }; -static const int Pstar_80[0x1a3]={ +static const int pstar_80[0x1a3]={ 0x03,0x03,0x04,0x04,0x04,0x04,0x05,0x05, 0x05,0x05,0x06,0x06,0x03,0x03,0x04,0x04, 0x05,0x05,0x05,0x05,0x06,0x06,0x07,0x07, @@ -115,190 +106,166 @@ static const int Pstar_80[0x1a3]={ -READ16_HANDLER (PSTARS_protram_r) +READ16_HANDLER( pstars_protram_r ) { + pgm_state *state = (pgm_state *)space->machine->driver_data; + if (offset == 4) //region return input_port_read(space->machine, "Region"); else if (offset >= 0x10) //timer { - logerror("PSTARS ACCESS COUNTER %6X\n",pstar_ram[offset-0x10]); - return pstar_ram[offset-0x10]--; + logerror("PSTARS ACCESS COUNTER %6X\n", state->pstar_ram[offset - 0x10]); + return state->pstar_ram[offset - 0x10]--; } return 0x0000; } -READ16_HANDLER (PSTARS_r16) +READ16_HANDLER( pstars_r ) { - if(offset==0) + pgm_state *state = (pgm_state *)space->machine->driver_data; + + if (offset == 0) { - UINT16 d=PSTARS_VAL&0xffff; - UINT16 realkey; - realkey=PSTARSKEY>>8; - realkey|=PSTARSKEY; - d^=realkey; -// logerror("PSTARS A27 R %6X\n",PSTARS_VAL); + UINT16 d = state->pstars_val & 0xffff; + UINT16 realkey = state->pstars_key >> 8; + realkey |= state->pstars_key; + d ^= realkey; +// logerror("PSTARS A27 R %6X\n", state->pstars_val); return d; } - else if(offset==1) + else if (offset == 1) { - UINT16 d=PSTARS_VAL>>16; - UINT16 realkey; - realkey=PSTARSKEY>>8; - realkey|=PSTARSKEY; - d^=realkey; + UINT16 d = state->pstars_val >> 16; + UINT16 realkey = state->pstars_key >> 8; + realkey |= state->pstars_key; + d ^= realkey; return d; } return 0xff; } -WRITE16_HANDLER (PSTARS_w16) +WRITE16_HANDLER( pstars_w ) { - if(offset==0) + pgm_state *state = (pgm_state *)space->machine->driver_data; + + if (offset == 0) { - PSTARSINT[0]=data; + state->pstars_int[0] = data; return; } - if(offset==1) + if (offset == 1) { UINT16 realkey; - if((data>>8)==0xff) - PSTARSKEY=0xff00; - realkey=PSTARSKEY>>8; - realkey|=PSTARSKEY; + if ((data >> 8) == 0xff) + state->pstars_key = 0xff00; + realkey = state->pstars_key >> 8; + realkey |= state->pstars_key; { - PSTARSKEY+=0x100; - PSTARSKEY&=0xff00; - if(PSTARSKEY==0xff00)PSTARSKEY=0x100; - } - data^=realkey; - PSTARSINT[1]=data; - PSTARSINT[0]^=realkey; - - switch(PSTARSINT[1]&0xff) - { - case 0x99: - { - PSTARSKEY=0x100; - PSTARS_VAL=0x880000; - - } - break; - - case 0xE0: - { - PSTARS_VAL=0xa00000+(PSTARSINT[0]<<6); - } - break; - case 0xDC: - { - PSTARS_VAL=0xa00800+(PSTARSINT[0]<<6); - } - break; - case 0xD0: - { - PSTARS_VAL=0xa01000+(PSTARSINT[0]<<5); - } - break; - - case 0xb1: - { - pstar_b1=PSTARSINT[0]; - PSTARS_VAL=0x890000; - } - break; - case 0xbf: - { - PSTARS_VAL=pstar_b1*PSTARSINT[0]; - } - break; - - case 0xc1: //TODO:TIMER 0,1,2,FIX TO 0 should be OK? - { - PSTARS_VAL=0; - } - break; - case 0xce: //TODO:TIMER 0,1,2 - { - pstar_ce=PSTARSINT[0]; - PSTARS_VAL=0x890000; - } - break; - case 0xcf: //TODO:TIMER 0,1,2 - { - pstar_ram[pstar_ce]=PSTARSINT[0]; - PSTARS_VAL=0x890000; - } - break; - - - case 0xe7: - { - pstar_e7=(PSTARSINT[0]>>12)&0xf; - PSTARS_REGS[pstar_e7]&=0xffff; - PSTARS_REGS[pstar_e7]|=(PSTARSINT[0]&0xff)<<16; - PSTARS_VAL=0x890000; - } - break; - case 0xe5: - { - - PSTARS_REGS[pstar_e7]&=0xff0000; - PSTARS_REGS[pstar_e7]|=PSTARSINT[0]; - PSTARS_VAL=0x890000; - } - break; - case 0xf8: //@73C - { - PSTARS_VAL=PSTARS_REGS[PSTARSINT[0]&0xf]&0xffffff; - } - break; - - - case 0xba: - { - PSTARS_VAL=Pstar_ba[PSTARSINT[0]]; - } - break; - case 0xb0: - { - PSTARS_VAL=Pstar_b0[PSTARSINT[0]]; - } - break; - case 0xae: - { - PSTARS_VAL=Pstar_ae[PSTARSINT[0]]; - } - break; - case 0xa0: - { - PSTARS_VAL=Pstar_a0[PSTARSINT[0]]; - } - break; - case 0x9d: - { - PSTARS_VAL=Pstar_9d[PSTARSINT[0]]; - } - break; - case 0x90: - { - PSTARS_VAL=Pstar_90[PSTARSINT[0]]; - } - break; - case 0x8c: - { - PSTARS_VAL=Pstar_8c[PSTARSINT[0]]; - } - break; - case 0x80: - { - PSTARS_VAL=Pstar_80[PSTARSINT[0]]; - } - break; - default: - PSTARS_VAL=0x890000; - logerror("PSTARS PC(%06x) UNKNOWN %4X %4X\n",cpu_get_pc(space->cpu),PSTARSINT[1],PSTARSINT[0]); + state->pstars_key += 0x100; + state->pstars_key &= 0xff00; + if (state->pstars_key == 0xff00) + state->pstars_key = 0x100; + } + data ^= realkey; + state->pstars_int[1] = data; + state->pstars_int[0] ^= realkey; + + switch (state->pstars_int[1] & 0xff) + { + case 0x99: + state->pstars_key = 0x100; + state->pstars_val = 0x880000; + break; + + case 0xe0: + state->pstars_val = 0xa00000 + (state->pstars_int[0] << 6); + break; + + case 0xdc: + state->pstars_val = 0xa00800 + (state->pstars_int[0] << 6); + break; + + case 0xd0: + state->pstars_val = 0xa01000 + (state->pstars_int[0] << 5); + break; + + case 0xb1: + state->pstar_b1 = state->pstars_int[0]; + state->pstars_val = 0x890000; + break; + + case 0xbf: + state->pstars_val = state->pstar_b1 * state->pstars_int[0]; + break; + + case 0xc1: //TODO:TIMER 0,1,2,FIX TO 0 should be OK? + state->pstars_val = 0; + break; + + case 0xce: //TODO:TIMER 0,1,2 + state->pstar_ce = state->pstars_int[0]; + state->pstars_val=0x890000; + break; + + case 0xcf: //TODO:TIMER 0,1,2 + state->pstar_ram[state->pstar_ce] = state->pstars_int[0]; + state->pstars_val = 0x890000; + break; + + case 0xe7: + state->pstar_e7 = (state->pstars_int[0] >> 12) & 0xf; + state->pstars_regs[state->pstar_e7] &= 0xffff; + state->pstars_regs[state->pstar_e7] |= (state->pstars_int[0] & 0xff) << 16; + state->pstars_val = 0x890000; + break; + + case 0xe5: + state->pstars_regs[state->pstar_e7] &= 0xff0000; + state->pstars_regs[state->pstar_e7] |= state->pstars_int[0]; + state->pstars_val = 0x890000; + break; + + case 0xf8: //@73C + state->pstars_val = state->pstars_regs[state->pstars_int[0] & 0xf] & 0xffffff; + break; + + case 0xba: + state->pstars_val = pstar_ba[state->pstars_int[0]]; + break; + + case 0xb0: + state->pstars_val = pstar_b0[state->pstars_int[0]]; + break; + + case 0xae: + state->pstars_val = pstar_ae[state->pstars_int[0]]; + break; + + case 0xa0: + state->pstars_val = pstar_a0[state->pstars_int[0]]; + break; + + case 0x9d: + state->pstars_val = pstar_9d[state->pstars_int[0]]; + break; + + case 0x90: + state->pstars_val = pstar_90[state->pstars_int[0]]; + break; + + case 0x8c: + state->pstars_val = pstar_8c[state->pstars_int[0]]; + break; + + case 0x80: + state->pstars_val = pstar_80[state->pstars_int[0]]; + break; + + default: + state->pstars_val = 0x890000; + logerror("PSTARS PC(%06x) UNKNOWN %4X %4X\n", cpu_get_pc(space->cpu), state->pstars_int[1], state->pstars_int[0]); } @@ -307,66 +274,63 @@ WRITE16_HANDLER (PSTARS_w16) /*** ASIC 3 (oriental legends protection) ****************************************/ -static UINT8 asic3_reg, asic3_latch[3], asic3_x, asic3_y, asic3_z, asic3_h1, asic3_h2; -static UINT16 asic3_hold; - -static UINT32 bt(UINT32 v, int bit) -{ - return (v & (1<<bit)) != 0; -} - static void asic3_compute_hold(running_machine *machine) { - // The mode is dependant on the region + pgm_state *state = (pgm_state *)machine->driver_data; + + // The mode is dependent on the region static const int modes[4] = { 1, 1, 3, 2 }; int mode = modes[input_port_read(machine, "Region") & 3]; - switch(mode) { + switch (mode) + { case 1: - asic3_hold = - (asic3_hold << 1) - ^0x2bad - ^bt(asic3_hold, 15)^bt(asic3_hold, 10)^bt(asic3_hold, 8)^bt(asic3_hold, 5) - ^bt(asic3_z, asic3_y) - ^(bt(asic3_x, 0) << 1)^(bt(asic3_x, 1) << 6)^(bt(asic3_x, 2) << 10)^(bt(asic3_x, 3) << 14); + state->asic3_hold = + (state->asic3_hold << 1) + ^ 0x2bad + ^ BIT(state->asic3_hold, 15) ^ BIT(state->asic3_hold, 10) ^ BIT(state->asic3_hold, 8) ^ BIT(state->asic3_hold, 5) + ^ BIT(state->asic3_z, state->asic3_y) + ^ (BIT(state->asic3_x, 0) << 1) ^ (BIT(state->asic3_x, 1) << 6) ^ (BIT(state->asic3_x, 2) << 10) ^ (BIT(state->asic3_x, 3) << 14); break; case 2: - asic3_hold = - (asic3_hold << 1) - ^0x2bad - ^bt(asic3_hold, 15)^bt(asic3_hold, 7)^bt(asic3_hold, 6)^bt(asic3_hold, 5) - ^bt(asic3_z, asic3_y) - ^(bt(asic3_x, 0) << 4)^(bt(asic3_x, 1) << 6)^(bt(asic3_x, 2) << 10)^(bt(asic3_x, 3) << 12); + state->asic3_hold = + (state->asic3_hold << 1) + ^ 0x2bad + ^ BIT(state->asic3_hold, 15) ^ BIT(state->asic3_hold, 7) ^ BIT(state->asic3_hold, 6) ^ BIT(state->asic3_hold, 5) + ^ BIT(state->asic3_z, state->asic3_y) + ^ (BIT(state->asic3_x, 0) << 4) ^ (BIT(state->asic3_x, 1) << 6) ^ (BIT(state->asic3_x, 2) << 10) ^ (BIT(state->asic3_x, 3) << 12); break; case 3: - asic3_hold = - (asic3_hold << 1) - ^0x2bad - ^bt(asic3_hold, 15)^bt(asic3_hold, 10)^bt(asic3_hold, 8)^bt(asic3_hold, 5) - ^bt(asic3_z, asic3_y) - ^(bt(asic3_x, 0) << 4)^(bt(asic3_x, 1) << 6)^(bt(asic3_x, 2) << 10)^(bt(asic3_x, 3) << 12); + state->asic3_hold = + (state->asic3_hold << 1) + ^ 0x2bad + ^ BIT(state->asic3_hold, 15) ^ BIT(state->asic3_hold, 10) ^ BIT(state->asic3_hold, 8) ^ BIT(state->asic3_hold, 5) + ^ BIT(state->asic3_z, state->asic3_y) + ^ (BIT(state->asic3_x, 0) << 4) ^ (BIT(state->asic3_x, 1) << 6) ^ (BIT(state->asic3_x, 2) << 10) ^ (BIT(state->asic3_x, 3) << 12); break; } } READ16_HANDLER( pgm_asic3_r ) { + pgm_state *state = (pgm_state *)space->machine->driver_data; UINT8 res = 0; /* region is supplied by the protection device */ - switch(asic3_reg) { - case 0x00: res = (asic3_latch[0] & 0xf7) | ((input_port_read(space->machine, "Region") << 3) & 0x08); break; - case 0x01: res = asic3_latch[1]; break; - case 0x02: res = (asic3_latch[2] & 0x7f) | ((input_port_read(space->machine, "Region") << 6) & 0x80); break; + switch (state->asic3_reg) + { + case 0x00: res = (state->asic3_latch[0] & 0xf7) | ((input_port_read(space->machine, "Region") << 3) & 0x08); break; + case 0x01: res = state->asic3_latch[1]; break; + case 0x02: res = (state->asic3_latch[2] & 0x7f) | ((input_port_read(space->machine, "Region") << 6) & 0x80); break; case 0x03: - res = (bt(asic3_hold, 15) << 0) - | (bt(asic3_hold, 12) << 1) - | (bt(asic3_hold, 13) << 2) - | (bt(asic3_hold, 10) << 3) - | (bt(asic3_hold, 7) << 4) - | (bt(asic3_hold, 9) << 5) - | (bt(asic3_hold, 2) << 6) - | (bt(asic3_hold, 5) << 7); + res = (BIT(state->asic3_hold, 15) << 0) + | (BIT(state->asic3_hold, 12) << 1) + | (BIT(state->asic3_hold, 13) << 2) + | (BIT(state->asic3_hold, 10) << 3) + | (BIT(state->asic3_hold, 7) << 4) + | (BIT(state->asic3_hold, 9) << 5) + | (BIT(state->asic3_hold, 2) << 6) + | (BIT(state->asic3_hold, 5) << 7); break; case 0x20: res = 0x49; break; case 0x21: res = 0x47; break; @@ -393,28 +357,35 @@ READ16_HANDLER( pgm_asic3_r ) WRITE16_HANDLER( pgm_asic3_w ) { + pgm_state *state = (pgm_state *)space->machine->driver_data; + if(ACCESSING_BITS_0_7) { - if(asic3_reg < 3) - asic3_latch[asic3_reg] = data << 1; - else if(asic3_reg == 0xa0) { - asic3_hold = 0; - } else if(asic3_reg == 0x40) { - asic3_h2 = asic3_h1; - asic3_h1 = data; - } else if(asic3_reg == 0x48) { - asic3_x = 0; - if(!(asic3_h2 & 0x0a)) - asic3_x |= 8; - if(!(asic3_h2 & 0x90)) - asic3_x |= 4; - if(!(asic3_h1 & 0x06)) - asic3_x |= 2; - if(!(asic3_h1 & 0x90)) - asic3_x |= 1; - } else if(asic3_reg >= 0x80 && asic3_reg <= 0x87) { - asic3_y = asic3_reg & 7; - asic3_z = data; + if (state->asic3_reg < 3) + state->asic3_latch[state->asic3_reg] = data << 1; + else if (state->asic3_reg == 0xa0) + state->asic3_hold = 0; + else if (state->asic3_reg == 0x40) + { + state->asic3_h2 = state->asic3_h1; + state->asic3_h1 = data; + } + else if (state->asic3_reg == 0x48) + { + state->asic3_x = 0; + if (!(state->asic3_h2 & 0x0a)) + state->asic3_x |= 8; + if (!(state->asic3_h2 & 0x90)) + state->asic3_x |= 4; + if (!(state->asic3_h1 & 0x06)) + state->asic3_x |= 2; + if (!(state->asic3_h1 & 0x90)) + state->asic3_x |= 1; + } + else if(state->asic3_reg >= 0x80 && state->asic3_reg <= 0x87) + { + state->asic3_y = state->asic3_reg & 7; + state->asic3_z = data; asic3_compute_hold(space->machine); } } @@ -422,17 +393,15 @@ WRITE16_HANDLER( pgm_asic3_w ) WRITE16_HANDLER( pgm_asic3_reg_w ) { + pgm_state *state = (pgm_state *)space->machine->driver_data; + if(ACCESSING_BITS_0_7) - asic3_reg = data & 0xff; + state->asic3_reg = data & 0xff; } /*** Knights of Valour / Sango / PhotoY2k Protection (from ElSemi) (ASIC28) ***/ -static UINT16 ASIC28KEY; -static UINT16 ASIC28REGS[10]; -static UINT16 ASICPARAMS[256]; -static UINT16 ASIC28RCNT=0; -static const UINT32 B0TABLE[16]={2,0,1,4,3}; //maps char portraits to tables +static const UINT32 B0TABLE[16] = {2, 0, 1, 4, 3}; //maps char portraits to tables // photo2yk bonus stage static const UINT32 AETABLE[16]={0x00,0x0a,0x14, @@ -448,13 +417,10 @@ static const UINT32 BATABLE[0x40]= 0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c, 0x9e,0xa3,0xd4,0xa9,0xaf,0xb5,0xbb,0xc1}; -static UINT32 E0REGS[16]; -READ16_HANDLER (sango_protram_r) +READ16_HANDLER( sango_protram_r ) { - - // at offset == 4 is region (supplied by device) // 0 = china // 1 = taiwan @@ -463,7 +429,8 @@ READ16_HANDLER (sango_protram_r) // 4 = hong kong // 5 = world - if (offset == 4) return input_port_read(space->machine, "Region"); + if (offset == 4) + return input_port_read(space->machine, "Region"); // otherwise it doesn't seem to use the ram for anything important, we return 0 to avoid test mode corruption // kovplus reads from offset 000e a lot ... why? @@ -486,202 +453,186 @@ READ16_HANDLER (sango_protram_r) (BIT(val, B0) << 0)) -READ16_HANDLER (ASIC28_r16) -//UINT16 ASIC28_r16(UINT32 addr) +READ16_HANDLER( asic28_r ) { - UINT32 val=(ASIC28REGS[1]<<16)|(ASIC28REGS[0]); + pgm_state *state = (pgm_state *)space->machine->driver_data; + UINT32 val = (state->asic28_regs[1] << 16) | (state->asic28_regs[0]); -//logerror("Asic28 Read PC = %06x Command = %02x ??\n",cpu_get_pc(space->cpu), ASIC28REGS[1]); + //logerror("Asic28 Read PC = %06x Command = %02x ??\n", cpu_get_pc(space->cpu), state->asic28_regs[1]); - switch(ASIC28REGS[1]&0xff) + switch (state->asic28_regs[1] & 0xff) { case 0x99: - val=0x880000; + val = 0x880000; break; case 0x9d: // spr palette - val=0xa00000+((ASIC28REGS[0]&0x1f)<<6); + val = 0xa00000 + ((state->asic28_regs[0] & 0x1f) << 6); break; case 0xb0: - val=B0TABLE[ASIC28REGS[0]&0xf]; + val = B0TABLE[state->asic28_regs[0] & 0xf]; break; case 0xb4: { - int v2=ASIC28REGS[0]&0x0f; - int v1=(ASIC28REGS[0]&0x0f00)>>8; -// UINT16 tmp=E0REGS[v2]; - //E0REGS[v2]=E0REGS[v1]; - //E0REGS[v1]=tmp; - if(ASIC28REGS[0]==0x102) - E0REGS[1]=E0REGS[0]; + //UINT16 tmp = state->eoregs[v2]; + int v2 = state->asic28_regs[0] & 0x0f; + int v1 = (state->asic28_regs[0] & 0x0f00) >> 8; + //state->eoregs[v2] = state->eoregs[v1]; + //state->eoregs[v1] = tmp; + if (state->asic28_regs[0] == 0x102) + state->eoregs[1] = state->eoregs[0]; else - E0REGS[v1]=E0REGS[v2]; + state->eoregs[v1] = state->eoregs[v2]; - val=0x880000; + val = 0x880000; } break; case 0xba: - val=BATABLE[ASIC28REGS[0]&0x3f]; - if(ASIC28REGS[0]>0x2f) - { -// PutMessage("Unmapped BA com, report ElSemi",60); - popmessage ("Unmapped BA com %02x, contact ElSemi / MameDev", ASIC28REGS[0]); - } + val = BATABLE[state->asic28_regs[0] & 0x3f]; + if (state->asic28_regs[0] > 0x2f) + popmessage("Unmapped BA com %02x, contact ElSemi / MameDev", state->asic28_regs[0]); break; case 0xc0: - val=0x880000; + val = 0x880000; break; case 0xc3: //TXT tile position Uses C0 to select column - { - val=0x904000+(ASICPARAMS[0xc0]+ASICPARAMS[0xc3]*64)*4; - } + val = 0x904000 + (state->asic_params[0xc0] + state->asic_params[0xc3] * 64) * 4; break; case 0xcb: - val=0x880000; + val = 0x880000; break; case 0xcc: //BG { - int y=ASICPARAMS[0xcc]; - if(y&0x400) //y is signed (probably x too and it also applies to TXT, but I've never seen it used) - y=-(0x400-(y&0x3ff)); - val=0x900000+(((ASICPARAMS[0xcb]+(y)*64)*4)/*&0x1fff*/); + int y = state->asic_params[0xcc]; + if (y & 0x400) //y is signed (probably x too and it also applies to TXT, but I've never seen it used) + y =- (0x400 - (y & 0x3ff)); + val = 0x900000 + (((state->asic_params[0xcb] + (y) * 64) * 4) /*&0x1fff*/); } break; case 0xd0: //txt palette - val=0xa01000+(ASIC28REGS[0]<<5); + val = 0xa01000 + (state->asic28_regs[0] << 5); break; case 0xd6: //???? check it { - int v2=ASIC28REGS[0]&0xf; -// int v1=(ASIC28REGS[0]&0xf0)>>4; - E0REGS[0]=E0REGS[v2]; - //E0REGS[v2]=0; - val=0x880000; + int v2 = state->asic28_regs[0] & 0xf; + //int v1 = (state->asic28_regs[0] & 0xf0) >> 4; + state->eoregs[0] = state->eoregs[v2]; + //state->eoregs[v2] = 0; + val = 0x880000; } break; case 0xdc: //bg palette - val=0xa00800+(ASIC28REGS[0]<<6); + val = 0xa00800 + (state->asic28_regs[0] << 6); break; case 0xe0: //spr palette - val=0xa00000+((ASIC28REGS[0]&0x1f)<<6); + val = 0xa00000 + ((state->asic28_regs[0] & 0x1f) << 6); break; case 0xe5: - val=0x880000; + val = 0x880000; break; case 0xe7: - val=0x880000; + val = 0x880000; break; case 0xf0: - { - val=0x00C000; - } + val = 0x00C000; break; case 0xf8: - val=E0REGS[ASIC28REGS[0]&0xf]&0xffffff; + val = state->eoregs[state->asic28_regs[0] & 0xf] & 0xffffff; break; case 0xfc: //Adjust damage level to char experience level { - val=(ASICPARAMS[0xfc]*ASICPARAMS[0xfe])>>6; + val = (state->asic_params[0xfc] * state->asic_params[0xfe]) >> 6; break; } case 0xfe: //todo - val=0x880000; + val = 0x880000; break; default: - { - val=0x880000; - } + val = 0x880000; } -// if(addr==0x500000) - if(offset==0) + if(offset == 0) { - UINT16 d=val&0xffff; - UINT16 realkey; - realkey=ASIC28KEY>>8; - realkey|=ASIC28KEY; - d^=realkey; + UINT16 d = val & 0xffff; + UINT16 realkey = state->asic28_key >> 8; + realkey |= state->asic28_key; + d ^= realkey; return d; } -// else if(addr==0x500002) - else if(offset==1) + else if (offset == 1) { - UINT16 d=val>>16; - UINT16 realkey; - realkey=ASIC28KEY>>8; - realkey|=ASIC28KEY; - d^=realkey; - ASIC28RCNT++; - if(!(ASIC28RCNT&0xf)) + UINT16 d = val >> 16; + UINT16 realkey = state->asic28_key >> 8; + realkey |= state->asic28_key; + d ^= realkey; + state->asic28_rcnt++; + if (!(state->asic28_rcnt & 0xf)) { - ASIC28KEY+=0x100; - ASIC28KEY&=0xFF00; + state->asic28_key += 0x100; + state->asic28_key &= 0xff00; } return d; } return 0xff; } -WRITE16_HANDLER (ASIC28_w16) -//void ASIC28_w16(UINT32 addr,UINT16 data) +WRITE16_HANDLER( asic28_w ) { -// if(addr==0x500000) - if(offset==0) + pgm_state *state = (pgm_state *)space->machine->driver_data; + + if (offset == 0) { - UINT16 realkey; - realkey=ASIC28KEY>>8; - realkey|=ASIC28KEY; - data^=realkey; - ASIC28REGS[0]=data; + UINT16 realkey =state->asic28_key >> 8; + realkey |= state->asic28_key; + data ^= realkey; + state->asic28_regs[0] = data; return; } -// if(addr==0x500002) - if(offset==1) + if (offset == 1) { UINT16 realkey; - ASIC28KEY=data&0xff00; + state->asic28_key = data & 0xff00; - realkey=ASIC28KEY>>8; - realkey|=ASIC28KEY; - data^=realkey; - ASIC28REGS[1]=data; -// ErrorLogMessage("ASIC28 CMD %X PARAM %X",ASIC28REGS[1],ASIC28REGS[0]); - logerror("ASIC28 CMD %04x PARAM %04x\n",ASIC28REGS[1],ASIC28REGS[0]); + realkey = state->asic28_key >> 8; + realkey |= state->asic28_key; + data ^= realkey; + state->asic28_regs[1] = data; + logerror("ASIC28 CMD %04x PARAM %04x\n", state->asic28_regs[1], state->asic28_regs[0]); - ASICPARAMS[ASIC28REGS[1]&0xff]=ASIC28REGS[0]; - if(ASIC28REGS[1]==0xE7) + state->asic_params[state->asic28_regs[1] & 0xff] = state->asic28_regs[0]; + if (state->asic28_regs[1] == 0xE7) { - UINT32 E0R=(ASICPARAMS[0xE7]>>12)&0xf; - E0REGS[E0R]&=0xffff; - E0REGS[E0R]|=ASIC28REGS[0]<<16; + UINT32 E0R = (state->asic_params[0xe7] >> 12) & 0xf; + state->eoregs[E0R] &= 0xffff; + state->eoregs[E0R] |= state->asic28_regs[0] << 16; } - if(ASIC28REGS[1]==0xE5) + if (state->asic28_regs[1]==0xE5) { - UINT32 E0R=(ASICPARAMS[0xE7]>>12)&0xf; - E0REGS[E0R]&=0xff0000; - E0REGS[E0R]|=ASIC28REGS[0]; + UINT32 E0R = (state->asic_params[0xe7] >> 12) & 0xf; + state->eoregs[E0R] &= 0xff0000; + state->eoregs[E0R] |= state->asic28_regs[0]; } - ASIC28RCNT=0; + state->asic28_rcnt = 0; } } @@ -689,23 +640,23 @@ WRITE16_HANDLER (ASIC28_w16) #define DW2BITSWAP(s,d,bs,bd) d=((d&(~(1<<bd)))|(((s>>bs)&1)<<bd)) //Use this handler for reading from 0xd80000-0xd80002 -READ16_HANDLER (dw2_d80000_r ) +READ16_HANDLER( dw2_d80000_r ) { -//addr&=0xff; +// addr&=0xff; // if(dw2reg<0x20) //NOT SURE!! { //The value at 0x80EECE is computed in the routine at 0x107c18 - UINT16 d=pgm_mainram[0xEECE/2]; - UINT16 d2=0; - d=(d>>8)|(d<<8); - DW2BITSWAP(d,d2,7 ,0); - DW2BITSWAP(d,d2,4 ,1); - DW2BITSWAP(d,d2,5 ,2); - DW2BITSWAP(d,d2,2 ,3); - DW2BITSWAP(d,d2,15,4); - DW2BITSWAP(d,d2,1 ,5); - DW2BITSWAP(d,d2,10,6); - DW2BITSWAP(d,d2,13,7); + UINT16 d = pgm_mainram[0xEECE/2]; + UINT16 d2 = 0; + d = (d >> 8) | (d << 8); + DW2BITSWAP(d, d2, 7, 0); + DW2BITSWAP(d, d2, 4, 1); + DW2BITSWAP(d, d2, 5, 2); + DW2BITSWAP(d, d2, 2, 3); + DW2BITSWAP(d, d2, 15, 4); + DW2BITSWAP(d, d2, 1, 5); + DW2BITSWAP(d, d2, 10, 6); + DW2BITSWAP(d, d2, 13, 7); // ... missing bitswaps here (8-15) there is not enough data to know them // the code only checks the lowest 8 bytes return d2; @@ -794,5 +745,3 @@ void dw3_w32(UINT32 addr,UINT32 val) } #endif - - diff --git a/src/mame/video/pgm.c b/src/mame/video/pgm.c index 9eea9725500..8b05939387b 100644 --- a/src/mame/video/pgm.c +++ b/src/mame/video/pgm.c @@ -4,59 +4,59 @@ #include "driver.h" #include "includes/pgm.h" -static tilemap *pgm_tx_tilemap, *pgm_bg_tilemap; -static UINT16 *pgm_spritebufferram; // buffered spriteram -static UINT16 *sprite_temp_render; -static bitmap_t *tmppgmbitmap; - /* Sprites - These are a pain! */ /* this decodes one of the funky sprites to a bitmap so we can draw it more easily -- slow but easier to use*/ -static void pgm_prepare_sprite(running_machine *machine, int wide, int high,int palt, int boffset) +static void pgm_prepare_sprite( running_machine *machine, int wide, int high, int palt, int boffset ) { - UINT8 *bdata = memory_region ( machine, "gfx4" ); - size_t bdatasize = memory_region_length( machine, "gfx4" )-1; - UINT8 *adata = pgm_sprite_a_region; - size_t adatasize = pgm_sprite_a_region_allocate-1; + pgm_state *state = (pgm_state *)machine->driver_data; + UINT8 *bdata = memory_region(machine, "gfx4"); + size_t bdatasize = memory_region_length(machine, "gfx4") - 1; + UINT8 *adata = state->sprite_a_region; + size_t adatasize = state->sprite_a_region_size - 1; int xcnt, ycnt; UINT32 aoffset; UINT16 msk; - aoffset = (bdata[(boffset+3) & bdatasize] << 24) | (bdata[(boffset+2) & bdatasize] << 16) | (bdata[(boffset+1) & bdatasize] << 8) | (bdata[(boffset+0) & bdatasize] << 0); + aoffset = (bdata[(boffset + 3) & bdatasize] << 24) | (bdata[(boffset + 2) & bdatasize] << 16) | + (bdata[(boffset + 1) & bdatasize] << 8) | (bdata[(boffset + 0) & bdatasize] << 0); aoffset = aoffset >> 2; aoffset *= 3; boffset += 4; /* because the first dword is the a data offset */ - for (ycnt = 0 ; ycnt < high ; ycnt++) { - for (xcnt = 0 ; xcnt < wide ; xcnt++) { + for (ycnt = 0 ; ycnt < high ; ycnt++) + { + for (xcnt = 0 ; xcnt < wide ; xcnt++) + { int x; - msk = (( bdata[(boffset+1) & bdatasize] << 8) |( bdata[(boffset+0) & bdatasize] << 0) ); + msk = ((bdata[(boffset + 1) & bdatasize] << 8) |( bdata[(boffset + 0) & bdatasize] << 0)); - for (x=0;x<16;x++) + for (x = 0; x < 16; x++) { if (!(msk & 0x0001)) { - sprite_temp_render[(ycnt*(wide*16))+(xcnt*16+x)] = adata[aoffset & adatasize]+ palt*32; + state->sprite_temp_render[(ycnt * (wide * 16))+(xcnt * 16 + x)] = adata[aoffset & adatasize] + palt * 32; aoffset++; } else { - sprite_temp_render[(ycnt*(wide*16))+(xcnt*16+x)] = 0x8000; + state->sprite_temp_render[(ycnt * (wide * 16)) + (xcnt * 16 + x)] = 0x8000; } - msk >>=1; + msk >>= 1; } - boffset+=2; + boffset += 2; } } } // in the dest bitmap 0x10000 is used to mark 'used pixel' and 0x8000 is used to mark 'high priority' -static void draw_sprite_line(int wide, UINT32* dest, int xzoom, int xgrow, int yoffset, int flip, int xpos, int pri) +static void draw_sprite_line( running_machine *machine, int wide, UINT32* dest, int xzoom, int xgrow, int yoffset, int flip, int xpos, int pri ) { + pgm_state *state = (pgm_state *)machine->driver_data; int xcnt,xcntdraw; int xzoombit; int xoffset; @@ -64,53 +64,61 @@ static void draw_sprite_line(int wide, UINT32* dest, int xzoom, int xgrow, int y xcnt = 0; xcntdraw = 0; - while (xcnt < wide*16) + while (xcnt < wide * 16) { UINT32 srcdat; - if (!(flip&0x01)) xoffset = xcnt; - else xoffset = (wide*16)-xcnt-1; + if (!(flip & 0x01)) + xoffset = xcnt; + else + xoffset = (wide * 16) - xcnt - 1; - srcdat = sprite_temp_render[yoffset+xoffset]; - xzoombit = (xzoom >> (xcnt&0x1f))&1; + srcdat = state->sprite_temp_render[yoffset + xoffset]; + xzoombit = (xzoom >> (xcnt & 0x1f)) & 1; - if (xzoombit == 1 && xgrow ==1) + if (xzoombit == 1 && xgrow == 1) { // double this column xdrawpos = xpos + xcntdraw; - if (!(srcdat&0x8000)) + if (!(srcdat & 0x8000)) { if ((xdrawpos >= 0) && (xdrawpos < 448)) { - if (pri) dest[xdrawpos] = srcdat | 0x8000 | 0x10000; - else dest[xdrawpos] = srcdat | 0x10000; + if (pri) + dest[xdrawpos] = srcdat | 0x8000 | 0x10000; + else + dest[xdrawpos] = srcdat | 0x10000; } } xcntdraw++; xdrawpos = xpos + xcntdraw; - if (!(srcdat&0x8000)) + if (!(srcdat & 0x8000)) { if ((xdrawpos >= 0) && (xdrawpos < 448)) { - if (pri) dest[xdrawpos] = srcdat | 0x8000 | 0x10000; - else dest[xdrawpos] = srcdat | 0x10000; + if (pri) + dest[xdrawpos] = srcdat | 0x8000 | 0x10000; + else + dest[xdrawpos] = srcdat | 0x10000; } } xcntdraw++; } - else if (xzoombit ==1 && xgrow ==0) + else if (xzoombit == 1 && xgrow == 0) { /* skip this column */ } else //normal column { xdrawpos = xpos + xcntdraw; - if (!(srcdat&0x8000)) + if (!(srcdat & 0x8000)) { if ((xdrawpos >= 0) && (xdrawpos < 448)) { - if (pri) dest[xdrawpos] = srcdat | 0x8000 | 0x10000; - else dest[xdrawpos] = srcdat | 0x10000; + if (pri) + dest[xdrawpos] = srcdat | 0x8000 | 0x10000; + else + dest[xdrawpos] = srcdat | 0x10000; } } xcntdraw++; @@ -122,7 +130,7 @@ static void draw_sprite_line(int wide, UINT32* dest, int xzoom, int xgrow, int y } } /* this just loops over our decoded bitmap and puts it on the screen */ -static void draw_sprite_new_zoomed(running_machine *machine, int wide, int high, int xpos, int ypos, int palt, int boffset, int flip, bitmap_t* bitmap, UINT32 xzoom, int xgrow, UINT32 yzoom, int ygrow, int pri ) +static void draw_sprite_new_zoomed( running_machine *machine, int wide, int high, int xpos, int ypos, int palt, int boffset, int flip, bitmap_t* bitmap, UINT32 xzoom, int xgrow, UINT32 yzoom, int ygrow, int pri ) { int ycnt; int ydrawpos; @@ -131,41 +139,48 @@ static void draw_sprite_new_zoomed(running_machine *machine, int wide, int high, int ycntdraw; int yzoombit; - pgm_prepare_sprite( machine, wide,high, palt, boffset ); + pgm_prepare_sprite(machine, wide,high, palt, boffset); /* now draw it */ ycnt = 0; ycntdraw = 0; while (ycnt < high) { - yzoombit = (yzoom >> (ycnt&0x1f))&1; + yzoombit = (yzoom >> (ycnt & 0x1f)) & 1; if (yzoombit == 1 && ygrow == 1) // double this line { ydrawpos = ypos + ycntdraw; - if (!(flip&0x02)) yoffset = (ycnt*(wide*16)); - else yoffset = ( (high-ycnt-1)*(wide*16)); + if (!(flip & 0x02)) + yoffset = (ycnt * (wide * 16)); + else + yoffset = ((high - ycnt - 1) * (wide * 16)); + if ((ydrawpos >= 0) && (ydrawpos < 224)) { dest = BITMAP_ADDR32(bitmap, ydrawpos, 0); - draw_sprite_line(wide, dest, xzoom, xgrow, yoffset, flip, xpos, pri); + draw_sprite_line(machine, wide, dest, xzoom, xgrow, yoffset, flip, xpos, pri); } ycntdraw++; ydrawpos = ypos + ycntdraw; - if (!(flip&0x02)) yoffset = (ycnt*(wide*16)); - else yoffset = ( (high-ycnt-1)*(wide*16)); + if (!(flip & 0x02)) + yoffset = (ycnt * (wide * 16)); + else + yoffset = ((high - ycnt - 1) * (wide * 16)); + if ((ydrawpos >= 0) && (ydrawpos < 224)) { dest = BITMAP_ADDR32(bitmap, ydrawpos, 0); - draw_sprite_line(wide, dest, xzoom, xgrow, yoffset, flip, xpos, pri); + draw_sprite_line(machine, wide, dest, xzoom, xgrow, yoffset, flip, xpos, pri); } ycntdraw++; - if (ydrawpos ==224) ycnt = high; + if (ydrawpos ==224) + ycnt = high; } - else if (yzoombit ==1 && ygrow == 0) + else if (yzoombit == 1 && ygrow == 0) { /* skip this line */ /* we should process anyway if we don't do the pre-decode.. */ @@ -174,16 +189,20 @@ static void draw_sprite_new_zoomed(running_machine *machine, int wide, int high, { ydrawpos = ypos + ycntdraw; - if (!(flip&0x02)) yoffset = (ycnt*(wide*16)); - else yoffset = ( (high-ycnt-1)*(wide*16)); + if (!(flip & 0x02)) + yoffset = (ycnt * (wide * 16)); + else + yoffset = ((high - ycnt - 1) * (wide * 16)); + if ((ydrawpos >= 0) && (ydrawpos < 224)) { dest = BITMAP_ADDR32(bitmap, ydrawpos, 0); - draw_sprite_line(wide, dest, xzoom, xgrow, yoffset, flip, xpos, pri); + draw_sprite_line(machine, wide, dest, xzoom, xgrow, yoffset, flip, xpos, pri); } ycntdraw++; - if (ydrawpos ==224) ycnt = high; + if (ydrawpos == 224) + ycnt = high; } ycnt++; @@ -191,9 +210,7 @@ static void draw_sprite_new_zoomed(running_machine *machine, int wide, int high, } -static UINT16 *pgm_sprite_source; - -static void draw_sprites(running_machine *machine, bitmap_t* spritebitmap) +static void draw_sprites( running_machine *machine, bitmap_t* spritebitmap, UINT16 *sprite_source ) { /* ZZZZ Zxxx xxxx xxxx zzzz z-yy yyyy yyyy @@ -203,41 +220,42 @@ static void draw_sprites(running_machine *machine, bitmap_t* spritebitmap) */ - const UINT16 *finish = pgm_spritebufferram+(0xa00/2); + pgm_state *state = (pgm_state *)machine->driver_data; + const UINT16 *finish = state->spritebufferram + (0xa00 / 2); - while( pgm_sprite_source<finish ) + while (sprite_source < finish) { - int xpos = pgm_sprite_source[0] & 0x07ff; - int ypos = pgm_sprite_source[1] & 0x03ff; - int xzom = (pgm_sprite_source[0] & 0x7800) >> 11; - int xgrow = (pgm_sprite_source[0] & 0x8000) >> 15; - int yzom = (pgm_sprite_source[1] & 0x7800) >> 11; - int ygrow = (pgm_sprite_source[1] & 0x8000) >> 15; - int palt = (pgm_sprite_source[2] & 0x1f00) >> 8; - int flip = (pgm_sprite_source[2] & 0x6000) >> 13; - int boff = ((pgm_sprite_source[2] & 0x007f) << 16) | (pgm_sprite_source[3] & 0xffff); - int wide = (pgm_sprite_source[4] & 0x7e00) >> 9; - int high = pgm_sprite_source[4] & 0x01ff; - int pri = (pgm_sprite_source[2] & 0x0080) >> 7; + int xpos = sprite_source[0] & 0x07ff; + int ypos = sprite_source[1] & 0x03ff; + int xzom = (sprite_source[0] & 0x7800) >> 11; + int xgrow = (sprite_source[0] & 0x8000) >> 15; + int yzom = (sprite_source[1] & 0x7800) >> 11; + int ygrow = (sprite_source[1] & 0x8000) >> 15; + int palt = (sprite_source[2] & 0x1f00) >> 8; + int flip = (sprite_source[2] & 0x6000) >> 13; + int boff = ((sprite_source[2] & 0x007f) << 16) | (sprite_source[3] & 0xffff); + int wide = (sprite_source[4] & 0x7e00) >> 9; + int high = sprite_source[4] & 0x01ff; + int pri = (sprite_source[2] & 0x0080) >> 7; UINT32 xzoom, yzoom; - UINT16* pgm_sprite_zoomtable = &pgm_videoregs[0x1000/2]; + UINT16* sprite_zoomtable = &state->videoregs[0x1000 / 2]; if (xgrow) { - // xzom = 0xf-xzom; // would make more sense but everything gets zoomed slightly in dragon world 2 ?! - xzom = 0x10-xzom; // this way it doesn't but there is a bad line when zooming after the level select? + // xzom = 0xf - xzom; // would make more sense but everything gets zoomed slightly in dragon world 2 ?! + xzom = 0x10 - xzom; // this way it doesn't but there is a bad line when zooming after the level select? } if (ygrow) { - // yzom = 0xf-yzom; // see comment above - yzom = 0x10-yzom; + // yzom = 0xf - yzom; // see comment above + yzom = 0x10 - yzom; } - xzoom = (pgm_sprite_zoomtable[xzom*2]<<16)|pgm_sprite_zoomtable[xzom*2+1]; - yzoom = (pgm_sprite_zoomtable[yzom*2]<<16)|pgm_sprite_zoomtable[yzom*2+1]; + xzoom = (sprite_zoomtable[xzom * 2] << 16) | sprite_zoomtable[xzom * 2 + 1]; + yzoom = (sprite_zoomtable[yzom * 2] << 16) | sprite_zoomtable[yzom * 2 + 1]; boff *= 2; if (xpos > 0x3ff) xpos -=0x800; @@ -247,18 +265,18 @@ static void draw_sprites(running_machine *machine, bitmap_t* spritebitmap) //if ((priority == 1) && (pri == 0)) break; - draw_sprite_new_zoomed(machine, wide, high, xpos, ypos, palt, boff, flip, spritebitmap, xzoom,xgrow, yzoom,ygrow, pri); + draw_sprite_new_zoomed(machine, wide, high, xpos, ypos, palt, boff, flip, spritebitmap, xzoom, xgrow, yzoom, ygrow, pri); - pgm_sprite_source += 5; + sprite_source += 5; } } /* TX Layer */ - WRITE16_HANDLER( pgm_tx_videoram_w ) { - pgm_tx_videoram[offset] = data; - tilemap_mark_tile_dirty(pgm_tx_tilemap,offset/2); + pgm_state *state = (pgm_state *)space->machine->driver_data; + state->tx_videoram[offset] = data; + tilemap_mark_tile_dirty(state->tx_tilemap, offset / 2); } static TILE_GET_INFO( get_pgm_tx_tilemap_tile_info ) @@ -278,11 +296,12 @@ static TILE_GET_INFO( get_pgm_tx_tilemap_tile_info ) p = palette f = flip */ - int tileno,colour,flipyx; //,game; + pgm_state *state = (pgm_state *)machine->driver_data; + int tileno, colour, flipyx; //,game; - tileno = pgm_tx_videoram[tile_index *2] & 0xffff; - colour = (pgm_tx_videoram[tile_index*2+1] & 0x3e) >> 1; - flipyx = (pgm_tx_videoram[tile_index*2+1] & 0xc0) >> 6; + tileno = state->tx_videoram[tile_index * 2] & 0xffff; + colour = (state->tx_videoram[tile_index * 2 + 1] & 0x3e) >> 1; + flipyx = (state->tx_videoram[tile_index * 2 + 1] & 0xc0) >> 6; if (tileno > 0xbfff) { tileno -= 0xc000 ; tileno += 0x20000; } /* not sure about this */ @@ -293,20 +312,23 @@ static TILE_GET_INFO( get_pgm_tx_tilemap_tile_info ) WRITE16_HANDLER( pgm_bg_videoram_w ) { - pgm_bg_videoram[offset] = data; - tilemap_mark_tile_dirty(pgm_bg_tilemap,offset/2); + pgm_state *state = (pgm_state *)space->machine->driver_data; + state->bg_videoram[offset] = data; + tilemap_mark_tile_dirty(state->bg_tilemap, offset / 2); } static TILE_GET_INFO( get_pgm_bg_tilemap_tile_info ) { /* pretty much the same as tx layer */ - int tileno,colour,flipyx; + pgm_state *state = (pgm_state *)machine->driver_data; + int tileno, colour, flipyx; - tileno = pgm_bg_videoram[tile_index *2] & 0xffff; - if (tileno > 0x7ff) tileno+=0x1000; /* Tiles 0x800+ come from the GAME Roms */ - colour = (pgm_bg_videoram[tile_index*2+1] & 0x3e) >> 1; - flipyx = (pgm_bg_videoram[tile_index*2+1] & 0xc0) >> 6; + tileno = state->bg_videoram[tile_index *2] & 0xffff; + if (tileno > 0x7ff) + tileno += 0x1000; /* Tiles 0x800+ come from the GAME Roms */ + colour = (state->bg_videoram[tile_index * 2 + 1] & 0x3e) >> 1; + flipyx = (state->bg_videoram[tile_index * 2 + 1] & 0xc0) >> 6; SET_TILE_INFO(1,tileno,colour,TILE_FLIPYX(flipyx)); } @@ -317,88 +339,92 @@ static TILE_GET_INFO( get_pgm_bg_tilemap_tile_info ) VIDEO_START( pgm ) { + pgm_state *state = (pgm_state *)machine->driver_data; int i; - pgm_tx_tilemap= tilemap_create(machine, get_pgm_tx_tilemap_tile_info,tilemap_scan_rows, 8, 8,64,32); - tilemap_set_transparent_pen(pgm_tx_tilemap,15); + state->tx_tilemap = tilemap_create(machine, get_pgm_tx_tilemap_tile_info, tilemap_scan_rows, 8, 8, 64, 32); + tilemap_set_transparent_pen(state->tx_tilemap, 15); - pgm_bg_tilemap = tilemap_create(machine, get_pgm_bg_tilemap_tile_info,tilemap_scan_rows, 32, 32,64,64); - tilemap_set_transparent_pen(pgm_bg_tilemap,31); - tilemap_set_scroll_rows(pgm_bg_tilemap,64*32); + state->bg_tilemap = tilemap_create(machine, get_pgm_bg_tilemap_tile_info, tilemap_scan_rows, 32, 32, 64, 64); + tilemap_set_transparent_pen(state->bg_tilemap, 31); + tilemap_set_scroll_rows(state->bg_tilemap, 64 * 32); - tmppgmbitmap = auto_bitmap_alloc(machine,448,224,BITMAP_FORMAT_RGB32); + state->tmppgmbitmap = auto_bitmap_alloc(machine, 448, 224, BITMAP_FORMAT_RGB32); - for (i=0; i < 0x1200/2; i++) + for (i = 0; i < 0x1200 / 2; i++) palette_set_color(machine, i, MAKE_RGB(0, 0, 0)); - pgm_spritebufferram = auto_alloc_array(machine, UINT16, 0xa00/2); + state->spritebufferram = auto_alloc_array(machine, UINT16, 0xa00/2); /* we render each sprite to a bitmap then copy the bitmap to screen bitmap with zooming */ /* easier this way because of the funky sprite format */ - sprite_temp_render = auto_alloc_array(machine, UINT16, 0x400*0x200); + state->sprite_temp_render = auto_alloc_array(machine, UINT16, 0x400*0x200); + + state_save_register_global_pointer(machine, state->spritebufferram, 0xa00/2); + state_save_register_global_pointer(machine, state->sprite_temp_render, 0x400*0x200); + state_save_register_global_bitmap(machine, state->tmppgmbitmap); } VIDEO_UPDATE( pgm ) { + pgm_state *state = (pgm_state *)screen->machine->driver_data; int y; - bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine)); - bitmap_fill(tmppgmbitmap, cliprect, 0x00000000); - + bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine)); + bitmap_fill(state->tmppgmbitmap, cliprect, 0x00000000); - pgm_sprite_source = pgm_spritebufferram; - draw_sprites(screen->machine, tmppgmbitmap); + draw_sprites(screen->machine, state->tmppgmbitmap, state->spritebufferram); - tilemap_set_scrolly(pgm_bg_tilemap,0, pgm_videoregs[0x2000/2]); + tilemap_set_scrolly(state->bg_tilemap,0, state->videoregs[0x2000/2]); for (y = 0; y < 224; y++) - tilemap_set_scrollx(pgm_bg_tilemap,(y+pgm_videoregs[0x2000/2])&0x7ff, pgm_videoregs[0x3000/2]+pgm_rowscrollram[y]); + tilemap_set_scrollx(state->bg_tilemap, (y + state->videoregs[0x2000 / 2]) & 0x7ff, state->videoregs[0x3000 / 2] + state->rowscrollram[y]); { - int y,x; + int y, x; - for (y=0;y<224;y++) + for (y = 0; y < 224; y++) { - UINT32* src = BITMAP_ADDR32(tmppgmbitmap, y, 0); + UINT32* src = BITMAP_ADDR32(state->tmppgmbitmap, y, 0); UINT16* dst = BITMAP_ADDR16(bitmap, y, 0); - for (x=0;x<448;x++) + for (x = 0; x < 448; x++) { - if (src[x]&0x10000) - if ((src[x]&0x8000)==0x8000) - dst[x] = src[x]&0x7fff; + if (src[x] & 0x10000) + if ((src[x] & 0x8000) == 0x8000) + dst[x] = src[x] & 0x7fff; } } } - - tilemap_draw(bitmap,cliprect,pgm_bg_tilemap,0,0); - + tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0); { - int y,x; + int y, x; - for (y=0;y<224;y++) + for (y = 0; y < 224; y++) { - UINT32* src = BITMAP_ADDR32(tmppgmbitmap, y, 0); + UINT32* src = BITMAP_ADDR32(state->tmppgmbitmap, y, 0); UINT16* dst = BITMAP_ADDR16(bitmap, y, 0); - for (x=0;x<448;x++) + for (x = 0; x < 448; x++) { - if (src[x]&0x10000) - if ((src[x]&0x8000)==0x0000) + if (src[x] & 0x10000) + if ((src[x] & 0x8000) == 0x0000) dst[x] = src[x]; } } } - tilemap_set_scrolly(pgm_tx_tilemap,0, pgm_videoregs[0x5000/2]); - tilemap_set_scrollx(pgm_tx_tilemap,0, pgm_videoregs[0x6000/2]); // Check - tilemap_draw(bitmap,cliprect,pgm_tx_tilemap,0,0); + tilemap_set_scrolly(state->tx_tilemap, 0, state->videoregs[0x5000/2]); + tilemap_set_scrollx(state->tx_tilemap, 0, state->videoregs[0x6000/2]); // Check + tilemap_draw(bitmap, cliprect, state->tx_tilemap, 0, 0); return 0; } VIDEO_EOF( pgm ) { + pgm_state *state = (pgm_state *)machine->driver_data; + /* first 0xa00 of main ram = sprites, seems to be buffered, DMA? */ - memcpy(pgm_spritebufferram,pgm_mainram,0xa00); + memcpy(state->spritebufferram, pgm_mainram, 0xa00); } diff --git a/src/mame/video/psikyo.c b/src/mame/video/psikyo.c index 65c3cd811c1..bc06a287a02 100644 --- a/src/mame/video/psikyo.c +++ b/src/mame/video/psikyo.c @@ -55,19 +55,8 @@ Note: if MAME_DEBUG is defined, pressing Z with: **************************************************************************/ #include "driver.h" +#include "includes/psikyo.h" -/* Variables that driver has access to: */ - -UINT32 *psikyo_vram_0, *psikyo_vram_1, *psikyo_vregs; -int psikyo_ka302c_banking; -UINT32* psikyo_bootleg_spritebuffer; - -/* Variables only used here: */ - -static tilemap *tilemap_0_size0, *tilemap_0_size1, *tilemap_0_size2, *tilemap_0_size3, - *tilemap_1_size0, *tilemap_1_size1, *tilemap_1_size2, *tilemap_1_size3; -static UINT8 tilemap_0_bank, tilemap_1_bank; -static UINT32 *spritebuf1, *spritebuf2; /*************************************************************************** @@ -84,20 +73,22 @@ Offset: static TILE_GET_INFO( get_tile_info_0 ) { - UINT16 code = ((UINT16 *)psikyo_vram_0)[BYTE_XOR_BE(tile_index)]; + psikyo_state *state = (psikyo_state *)machine->driver_data; + UINT16 code = ((UINT16 *)state->vram_0)[BYTE_XOR_BE(tile_index)]; SET_TILE_INFO( 1, - (code & 0x1fff) + 0x2000*tilemap_0_bank, + (code & 0x1fff) + 0x2000 * state->tilemap_0_bank, (code >> 13) & 7, 0); } static TILE_GET_INFO( get_tile_info_1 ) { - UINT16 code = ((UINT16 *)psikyo_vram_1)[BYTE_XOR_BE(tile_index)]; + psikyo_state *state = (psikyo_state *)machine->driver_data; + UINT16 code = ((UINT16 *)state->vram_1)[BYTE_XOR_BE(tile_index)]; SET_TILE_INFO( 1, - (code & 0x1fff) + 0x2000*tilemap_1_bank, + (code & 0x1fff) + 0x2000 * state->tilemap_1_bank, ((code >> 13) & 7) + 0x40, // So we only have to decode the gfx once. 0); } @@ -105,151 +96,125 @@ static TILE_GET_INFO( get_tile_info_1 ) WRITE32_HANDLER( psikyo_vram_0_w ) { - COMBINE_DATA(&psikyo_vram_0[offset]); + psikyo_state *state = (psikyo_state *)space->machine->driver_data; + + COMBINE_DATA(&state->vram_0[offset]); if (ACCESSING_BITS_16_31) { - tilemap_mark_tile_dirty(tilemap_0_size0, offset*2); - tilemap_mark_tile_dirty(tilemap_0_size1, offset*2); - tilemap_mark_tile_dirty(tilemap_0_size2, offset*2); - tilemap_mark_tile_dirty(tilemap_0_size3, offset*2); + tilemap_mark_tile_dirty(state->tilemap_0_size0, offset * 2); + tilemap_mark_tile_dirty(state->tilemap_0_size1, offset * 2); + tilemap_mark_tile_dirty(state->tilemap_0_size2, offset * 2); + tilemap_mark_tile_dirty(state->tilemap_0_size3, offset * 2); } if (ACCESSING_BITS_0_15) { - tilemap_mark_tile_dirty(tilemap_0_size0, offset*2+1); - tilemap_mark_tile_dirty(tilemap_0_size1, offset*2+1); - tilemap_mark_tile_dirty(tilemap_0_size2, offset*2+1); - tilemap_mark_tile_dirty(tilemap_0_size3, offset*2+1); + tilemap_mark_tile_dirty(state->tilemap_0_size0, offset * 2 + 1); + tilemap_mark_tile_dirty(state->tilemap_0_size1, offset * 2 + 1); + tilemap_mark_tile_dirty(state->tilemap_0_size2, offset * 2 + 1); + tilemap_mark_tile_dirty(state->tilemap_0_size3, offset * 2 + 1); } } WRITE32_HANDLER( psikyo_vram_1_w ) { - COMBINE_DATA(&psikyo_vram_1[offset]); + psikyo_state *state = (psikyo_state *)space->machine->driver_data; + + COMBINE_DATA(&state->vram_1[offset]); if (ACCESSING_BITS_16_31) { - tilemap_mark_tile_dirty(tilemap_1_size0, offset*2); - tilemap_mark_tile_dirty(tilemap_1_size1, offset*2); - tilemap_mark_tile_dirty(tilemap_1_size2, offset*2); - tilemap_mark_tile_dirty(tilemap_1_size3, offset*2); + tilemap_mark_tile_dirty(state->tilemap_1_size0, offset * 2); + tilemap_mark_tile_dirty(state->tilemap_1_size1, offset * 2); + tilemap_mark_tile_dirty(state->tilemap_1_size2, offset * 2); + tilemap_mark_tile_dirty(state->tilemap_1_size3, offset * 2); } if (ACCESSING_BITS_0_15) { - tilemap_mark_tile_dirty(tilemap_1_size0, offset*2+1); - tilemap_mark_tile_dirty(tilemap_1_size1, offset*2+1); - tilemap_mark_tile_dirty(tilemap_1_size2, offset*2+1); - tilemap_mark_tile_dirty(tilemap_1_size3, offset*2+1); + tilemap_mark_tile_dirty(state->tilemap_1_size0, offset * 2 + 1); + tilemap_mark_tile_dirty(state->tilemap_1_size1, offset * 2 + 1); + tilemap_mark_tile_dirty(state->tilemap_1_size2, offset * 2 + 1); + tilemap_mark_tile_dirty(state->tilemap_1_size3, offset * 2 + 1); } } -void psikyo_switch_banks( int tmap, int bank ) +void psikyo_switch_banks( running_machine *machine, int tmap, int bank ) { - if((tmap==0) && (bank != tilemap_0_bank)) + psikyo_state *state = (psikyo_state *)machine->driver_data; + + if ((tmap == 0) && (bank != state->tilemap_0_bank)) { - tilemap_0_bank = bank; - tilemap_mark_all_tiles_dirty(tilemap_0_size0); - tilemap_mark_all_tiles_dirty(tilemap_0_size1); - tilemap_mark_all_tiles_dirty(tilemap_0_size2); - tilemap_mark_all_tiles_dirty(tilemap_0_size3); + state->tilemap_0_bank = bank; + tilemap_mark_all_tiles_dirty(state->tilemap_0_size0); + tilemap_mark_all_tiles_dirty(state->tilemap_0_size1); + tilemap_mark_all_tiles_dirty(state->tilemap_0_size2); + tilemap_mark_all_tiles_dirty(state->tilemap_0_size3); } - else if((tmap==1) && (bank != tilemap_1_bank)) + else if ((tmap == 1) && (bank != state->tilemap_1_bank)) { - tilemap_1_bank = bank; - tilemap_mark_all_tiles_dirty(tilemap_1_size0); - tilemap_mark_all_tiles_dirty(tilemap_1_size1); - tilemap_mark_all_tiles_dirty(tilemap_1_size2); - tilemap_mark_all_tiles_dirty(tilemap_1_size3); + state->tilemap_1_bank = bank; + tilemap_mark_all_tiles_dirty(state->tilemap_1_size0); + tilemap_mark_all_tiles_dirty(state->tilemap_1_size1); + tilemap_mark_all_tiles_dirty(state->tilemap_1_size2); + tilemap_mark_all_tiles_dirty(state->tilemap_1_size3); } } VIDEO_START( psikyo ) { + psikyo_state *state = (psikyo_state *)machine->driver_data; + /* The Hardware is Capable of Changing the Dimensions of the Tilemaps, its safer to create the various sized tilemaps now as opposed to later */ - tilemap_0_size0 = tilemap_create( machine, get_tile_info_0, - tilemap_scan_rows, - - 16,16, - 0x20, 0x80 ); - tilemap_0_size1 = tilemap_create( machine, get_tile_info_0, - tilemap_scan_rows, - - 16,16, - 0x40, 0x40 ); - - tilemap_0_size2 = tilemap_create( machine, get_tile_info_0, - tilemap_scan_rows, - - 16,16, - 0x80, 0x20 ); - - tilemap_0_size3 = tilemap_create( machine, get_tile_info_0, - tilemap_scan_rows, - - 16,16, - 0x100, 0x10 ); - - tilemap_1_size0 = tilemap_create( machine, get_tile_info_1, - tilemap_scan_rows, + state->tilemap_0_size0 = tilemap_create(machine, get_tile_info_0, tilemap_scan_rows, 16, 16, 0x20, 0x80); + state->tilemap_0_size1 = tilemap_create(machine, get_tile_info_0, tilemap_scan_rows, 16, 16, 0x40, 0x40); + state->tilemap_0_size2 = tilemap_create(machine, get_tile_info_0, tilemap_scan_rows, 16, 16, 0x80, 0x20); + state->tilemap_0_size3 = tilemap_create(machine, get_tile_info_0, tilemap_scan_rows, 16, 16, 0x100, 0x10); - 16,16, - 0x20, 0x80 ); + state->tilemap_1_size0 = tilemap_create(machine, get_tile_info_1, tilemap_scan_rows, 16, 16, 0x20, 0x80); + state->tilemap_1_size1 = tilemap_create(machine, get_tile_info_1, tilemap_scan_rows, 16, 16, 0x40, 0x40); + state->tilemap_1_size2 = tilemap_create(machine, get_tile_info_1, tilemap_scan_rows, 16, 16, 0x80, 0x20); + state->tilemap_1_size3 = tilemap_create(machine, get_tile_info_1, tilemap_scan_rows, 16, 16, 0x100, 0x10); - tilemap_1_size1 = tilemap_create( machine, get_tile_info_1, - tilemap_scan_rows, + state->spritebuf1 = auto_alloc_array(machine, UINT32, 0x2000 / 4); + state->spritebuf2 = auto_alloc_array(machine, UINT32, 0x2000 / 4); - 16,16, - 0x40, 0x40 ); + tilemap_set_scroll_rows(state->tilemap_0_size0, 0x80 * 16); // line scrolling + tilemap_set_scroll_cols(state->tilemap_0_size0, 1); - tilemap_1_size2 = tilemap_create( machine, get_tile_info_1, - tilemap_scan_rows, + tilemap_set_scroll_rows(state->tilemap_0_size1, 0x40 * 16); // line scrolling + tilemap_set_scroll_cols(state->tilemap_0_size1, 1); - 16,16, - 0x80, 0x20 ); + tilemap_set_scroll_rows(state->tilemap_0_size2, 0x20 * 16); // line scrolling + tilemap_set_scroll_cols(state->tilemap_0_size2, 1); - tilemap_1_size3 = tilemap_create( machine, get_tile_info_1, - tilemap_scan_rows, + tilemap_set_scroll_rows(state->tilemap_0_size3, 0x10 * 16); // line scrolling + tilemap_set_scroll_cols(state->tilemap_0_size3, 1); - 16,16, - 0x100, 0x10 ); + tilemap_set_scroll_rows(state->tilemap_1_size0, 0x80 * 16); // line scrolling + tilemap_set_scroll_cols(state->tilemap_1_size0, 1); - spritebuf1 = auto_alloc_array(machine, UINT32, 0x2000/4); - spritebuf2 = auto_alloc_array(machine, UINT32, 0x2000/4); + tilemap_set_scroll_rows(state->tilemap_1_size1, 0x40 * 16); // line scrolling + tilemap_set_scroll_cols(state->tilemap_1_size1, 1); - tilemap_set_scroll_rows(tilemap_0_size0,0x80*16); // line scrolling - tilemap_set_scroll_cols(tilemap_0_size0,1); + tilemap_set_scroll_rows(state->tilemap_1_size2, 0x20 * 16); // line scrolling + tilemap_set_scroll_cols(state->tilemap_1_size2, 1); - tilemap_set_scroll_rows(tilemap_0_size1,0x40*16); // line scrolling - tilemap_set_scroll_cols(tilemap_0_size1,1); + tilemap_set_scroll_rows(state->tilemap_1_size3, 0x10 * 16); // line scrolling + tilemap_set_scroll_cols(state->tilemap_1_size3, 1); - tilemap_set_scroll_rows(tilemap_0_size2,0x20*16); // line scrolling - tilemap_set_scroll_cols(tilemap_0_size2,1); - - tilemap_set_scroll_rows(tilemap_0_size3,0x10*16); // line scrolling - tilemap_set_scroll_cols(tilemap_0_size3,1); - - tilemap_set_scroll_rows(tilemap_1_size0,0x80*16); // line scrolling - tilemap_set_scroll_cols(tilemap_1_size0,1); - - tilemap_set_scroll_rows(tilemap_1_size1,0x40*16); // line scrolling - tilemap_set_scroll_cols(tilemap_1_size1,1); - - tilemap_set_scroll_rows(tilemap_1_size2,0x20*16); // line scrolling - tilemap_set_scroll_cols(tilemap_1_size2,1); - - tilemap_set_scroll_rows(tilemap_1_size3,0x10*16); // line scrolling - tilemap_set_scroll_cols(tilemap_1_size3,1); + state_save_register_global_pointer(machine, state->spritebuf1, 0x2000 / 4); + state_save_register_global_pointer(machine, state->spritebuf2, 0x2000 / 4); } VIDEO_START( sngkace ) { VIDEO_START_CALL( psikyo ); - psikyo_switch_banks(0, 0); // sngkace / samuraia don't use banking - psikyo_switch_banks(1, 1); // They share "gfx2" to save memory on other boards + psikyo_switch_banks(machine, 0, 0); // sngkace / samuraia don't use banking + psikyo_switch_banks(machine, 1, 1); // They share "gfx2" to save memory on other boards } @@ -298,96 +263,96 @@ Note: Not all sprites are displayed: in the top part of spriteram ***************************************************************************/ -static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int trans_pen) +static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int trans_pen ) { + psikyo_state *state = (psikyo_state *)machine->driver_data; + /* tile layers 0 & 1 have priorities 1 & 2 */ static const int pri[] = { 0, 0xfc, 0xff, 0xff }; - int offs; - - UINT16 *spritelist = (UINT16 *)(spritebuf2 + 0x1800/4); - - UINT8 *TILES = memory_region(machine, "spritelut"); // Sprites LUT - int TILES_LEN = memory_region_length(machine, "spritelut"); + UINT16 *spritelist = (UINT16 *)(state->spritebuf2 + 0x1800 / 4); + UINT8 *TILES = memory_region(machine, "spritelut"); // Sprites LUT + int TILES_LEN = memory_region_length(machine, "spritelut"); int width = video_screen_get_width(machine->primary_screen); int height = video_screen_get_height(machine->primary_screen); /* Exit if sprites are disabled */ - if ( spritelist[ BYTE_XOR_BE((0x800-2)/2) ] & 1 ) return; + if (spritelist[BYTE_XOR_BE((0x800 - 2) / 2)] & 1) return; /* Look for "end of sprites" marker in the sprites list */ - for ( offs = 0/2 ; offs < (0x800-2)/2 ; offs += 2/2 ) // skip last "sprite" + for (offs = 0/2 ; offs < (0x800 - 2)/2 ; offs += 2/2) // skip last "sprite" { - UINT16 sprite = spritelist[ BYTE_XOR_BE(offs) ]; - if (sprite == 0xffff) break; + UINT16 sprite = spritelist[BYTE_XOR_BE(offs)]; + if (sprite == 0xffff) + break; } offs -= 2/2; // fprintf(stderr, "\n"); - for ( ; offs >= 0/2 ; offs -= 2/2 ) + for ( ; offs >= 0/2 ; offs -= 2/2) { UINT32 *source; - int sprite; + int sprite; - int x,y, attr,code, flipx,flipy, nx,ny, zoomx,zoomy; - int dx,dy, xstart,ystart, xend,yend, xinc,yinc; + int x, y, attr, code, flipx, flipy, nx, ny, zoomx, zoomy; + int dx, dy, xstart, ystart, xend, yend, xinc, yinc; /* Get next entry in the list */ - sprite = spritelist[ BYTE_XOR_BE(offs) ]; + sprite = spritelist[BYTE_XOR_BE(offs)]; - sprite %= 0x300; - source = &spritebuf2[ sprite*8/4 ]; + sprite %= 0x300; + source = &state->spritebuf2[sprite * 8 / 4]; /* Draw this sprite */ - y = source[ 0/4 ] >> 16; - x = source[ 0/4 ] & 0xffff; - attr = source[ 4/4 ] >> 16; - code = source[ 4/4 ] & 0x1ffff; + y = source[0 / 4] >> 16; + x = source[0 / 4] & 0xffff; + attr = source[4 / 4] >> 16; + code = source[4 / 4] & 0x1ffff; flipx = attr & 0x4000; flipy = attr & 0x8000; zoomx = ((x & 0xf000) >> 12); zoomy = ((y & 0xf000) >> 12); - nx = ((x & 0x0e00) >> 9) + 1; - ny = ((y & 0x0e00) >> 9) + 1; - x = ((x & 0x01ff)); - y = ((y & 0x00ff)) - (y & 0x100); + nx = ((x & 0x0e00) >> 9) + 1; + ny = ((y & 0x0e00) >> 9) + 1; + x = ((x & 0x01ff)); + y = ((y & 0x00ff)) - (y & 0x100); /* 180-1ff are negative coordinates. Note that $80 pixels is the maximum extent of a sprite, which can therefore be moved out of screen without problems */ - if (x >= 0x180) x -= 0x200; + if (x >= 0x180) + x -= 0x200; - x += (nx*zoomx+2)/4; - y += (ny*zoomy+2)/4; + x += (nx * zoomx + 2) / 4; + y += (ny * zoomy + 2) / 4; zoomx = 32 - zoomx; zoomy = 32 - zoomy; - if (flip_screen_get(machine)) { - x = width - x - (nx * zoomx)/2; - y = height - y - (ny * zoomy)/2; + x = width - x - (nx * zoomx) / 2; + y = height - y - (ny * zoomy) / 2; flipx = !flipx; flipy = !flipy; } - if (flipx) { xstart = nx-1; xend = -1; xinc = -1; } - else { xstart = 0; xend = nx; xinc = +1; } + if (flipx) { xstart = nx - 1; xend = -1; xinc = -1; } + else { xstart = 0; xend = nx; xinc = +1; } - if (flipy) { ystart = ny-1; yend = -1; yinc = -1; } - else { ystart = 0; yend = ny; yinc = +1; } + if (flipy) { ystart = ny - 1; yend = -1; yinc = -1; } + else { ystart = 0; yend = ny; yinc = +1; } for (dy = ystart; dy != yend; dy += yinc) { for (dx = xstart; dx != xend; dx += xinc) { - int addr = (code*2) & (TILES_LEN-1); + int addr = (code * 2) & (TILES_LEN - 1); if (zoomx == 32 && zoomy == 32) pdrawgfx_transpen(bitmap,cliprect,machine->gfx[0], @@ -417,74 +382,78 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta // until I work out why it makes a partial copy of the sprite list, and how best to apply it // sprite placement of the explosion graphic seems incorrect compared to the original sets? (no / different zoom support?) // it might be a problem with the actual bootleg -static void draw_sprites_bootleg(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int trans_pen) +static void draw_sprites_bootleg( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int trans_pen ) { + psikyo_state *state = (psikyo_state *)machine->driver_data; + /* tile layers 0 & 1 have priorities 1 & 2 */ static const int pri[] = { 0, 0xfc, 0xff, 0xff }; - int offs; // UINT16 *spritelist = (UINT16 *)(machine->generic.spriteram.u32 + 0x1800/4); - UINT16 *spritelist = (UINT16 *)(spritebuf2 + 0x1800/4); + UINT16 *spritelist = (UINT16 *)(state->spritebuf2 + 0x1800 / 4); - UINT8 *TILES = memory_region(machine, "spritelut"); // Sprites LUT - int TILES_LEN = memory_region_length(machine, "spritelut"); + UINT8 *TILES = memory_region(machine, "spritelut"); // Sprites LUT + int TILES_LEN = memory_region_length(machine, "spritelut"); int width = video_screen_get_width(machine->primary_screen); int height = video_screen_get_height(machine->primary_screen); /* Exit if sprites are disabled */ - if ( spritelist[ BYTE_XOR_BE((0x800-2)/2) ] & 1 ) return; + if (spritelist[BYTE_XOR_BE((0x800 - 2) / 2)] & 1) + return; /* Look for "end of sprites" marker in the sprites list */ - for ( offs = 0/2 ; offs < (0x800-2)/2 ; offs += 2/2 ) // skip last "sprite" + for (offs = 0/2 ; offs < (0x800 - 2)/2 ; offs += 2/2) // skip last "sprite" { - UINT16 sprite = spritelist[ BYTE_XOR_BE(offs) ]; - if (sprite == 0xffff) break; + UINT16 sprite = spritelist[BYTE_XOR_BE(offs)]; + if (sprite == 0xffff) + break; } offs -= 2/2; // fprintf(stderr, "\n"); - for ( ; offs >= 0/2 ; offs -= 2/2 ) + for ( ; offs >= 0/2 ; offs -= 2/2) { UINT32 *source; - int sprite; + int sprite; - int x,y, attr,code, flipx,flipy, nx,ny, zoomx,zoomy; - int dx,dy, xstart,ystart, xend,yend, xinc,yinc; + int x, y, attr, code, flipx, flipy, nx, ny, zoomx, zoomy; + int dx, dy, xstart, ystart, xend, yend, xinc, yinc; /* Get next entry in the list */ - sprite = spritelist[ BYTE_XOR_BE(offs) ]; + sprite = spritelist[BYTE_XOR_BE(offs)]; - sprite %= 0x300; -// source = &psikyo_bootleg_spritebuffer[ sprite*8/4 ]; - source = &spritebuf2[ sprite*8/4 ]; + sprite %= 0x300; +// source = &state->bootleg_spritebuffer[sprite * 8 / 4]; + source = &state->spritebuf2[sprite * 8 / 4]; /* Draw this sprite */ - y = source[ 0 ] >> 16; - x = source[ 0 ] & 0xffff; - attr = source[ 1 ] >> 16; - code = source[ 1 ] & 0x1ffff; + y = source[0] >> 16; + x = source[0] & 0xffff; + attr = source[1] >> 16; + code = source[1] & 0x1ffff; flipx = attr & 0x4000; flipy = attr & 0x8000; zoomx = ((x & 0xf000) >> 12); zoomy = ((y & 0xf000) >> 12); - nx = ((x & 0x0e00) >> 9) + 1; - ny = ((y & 0x0e00) >> 9) + 1; - x = ((x & 0x01ff)); - y = ((y & 0x00ff)) - (y & 0x100); + nx = ((x & 0x0e00) >> 9) + 1; + ny = ((y & 0x0e00) >> 9) + 1; + x = ((x & 0x01ff)); + y = ((y & 0x00ff)) - (y & 0x100); /* 180-1ff are negative coordinates. Note that $80 pixels is the maximum extent of a sprite, which can therefore be moved out of screen without problems */ - if (x >= 0x180) x -= 0x200; + if (x >= 0x180) + x -= 0x200; - x += (nx*zoomx+2)/4; - y += (ny*zoomy+2)/4; + x += (nx * zoomx + 2) / 4; + y += (ny * zoomy + 2) / 4; zoomx = 32 - zoomx; zoomy = 32 - zoomy; @@ -492,23 +461,23 @@ static void draw_sprites_bootleg(running_machine *machine, bitmap_t *bitmap, con if (flip_screen_get(machine)) { - x = width - x - (nx * zoomx)/2; - y = height - y - (ny * zoomy)/2; + x = width - x - (nx * zoomx) / 2; + y = height - y - (ny * zoomy) / 2; flipx = !flipx; flipy = !flipy; } - if (flipx) { xstart = nx-1; xend = -1; xinc = -1; } - else { xstart = 0; xend = nx; xinc = +1; } + if (flipx) { xstart = nx - 1; xend = -1; xinc = -1; } + else { xstart = 0; xend = nx; xinc = +1; } - if (flipy) { ystart = ny-1; yend = -1; yinc = -1; } - else { ystart = 0; yend = ny; yinc = +1; } + if (flipy) { ystart = ny - 1; yend = -1; yinc = -1; } + else { ystart = 0; yend = ny; yinc = +1; } for (dy = ystart; dy != yend; dy += yinc) { for (dx = xstart; dx != xend; dx += xinc) { - int addr = (code*2) & (TILES_LEN-1); + int addr = (code * 2) & (TILES_LEN-1); if (zoomx == 32 && zoomy == 32) pdrawgfx_transpen(bitmap,cliprect,machine->gfx[0], @@ -545,23 +514,28 @@ static void draw_sprites_bootleg(running_machine *machine, bitmap_t *bitmap, con static int tilemap_width( int size ) { - if(size==0) return 0x80*16; - else if(size==1) return 0x40*16; - else if(size==2) return 0x20*16; - else return 0x10*16; + if (size == 0) + return 0x80 * 16; + else if(size == 1) + return 0x40 * 16; + else if(size == 2) + return 0x20 * 16; + else + return 0x10 * 16; } VIDEO_UPDATE( psikyo ) { + psikyo_state *state = (psikyo_state *)screen->machine->driver_data; int i, layers_ctrl = -1; UINT32 tm0size, tm1size; UINT32 layer0_scrollx, layer0_scrolly; UINT32 layer1_scrollx, layer1_scrolly; - UINT32 layer0_ctrl = psikyo_vregs[ 0x412/4 ]; - UINT32 layer1_ctrl = psikyo_vregs[ 0x416/4 ]; - UINT32 spr_ctrl = spritebuf2[ 0x1ffe/4 ]; + UINT32 layer0_ctrl = state->vregs[0x412 / 4]; + UINT32 layer1_ctrl = state->vregs[0x416 / 4]; + UINT32 spr_ctrl = state->spritebuf2[0x1ffe / 4]; tilemap *tmptilemap0, *tmptilemap1; @@ -598,68 +572,61 @@ VIDEO_UPDATE( psikyo ) */ /* For gfx banking for s1945jn/gunbird/btlkroad */ - if(psikyo_ka302c_banking) + if (state->ka302c_banking) { - psikyo_switch_banks(0, (layer0_ctrl&0x400)>>10); - psikyo_switch_banks(1, (layer1_ctrl&0x400)>>10); + psikyo_switch_banks(screen->machine, 0, (layer0_ctrl & 0x400) >> 10); + psikyo_switch_banks(screen->machine, 1, (layer1_ctrl & 0x400) >> 10); } - switch((layer0_ctrl & 0x00c0)>>6) { - case 0: - tm0size=1; - break; - case 1: - tm0size=2; - break; - case 2: - tm0size=3; - break; - default: - tm0size=0; - break; + switch ((layer0_ctrl & 0x00c0) >> 6) + { + case 0: tm0size = 1; break; + case 1: tm0size = 2; break; + case 2: tm0size = 3; break; + default: tm0size = 0; break; } - switch((layer1_ctrl & 0x00c0)>>6) { - case 0: - tm1size=1; - break; - case 1: - tm1size=2; - break; - case 2: - tm1size=3; - break; - default: - tm1size=0; - break; + switch ((layer1_ctrl & 0x00c0) >> 6) + { + case 0: tm1size = 1; break; + case 1: tm1size = 2; break; + case 2: tm1size = 3; break; + default: tm1size = 0; break; } - if(tm0size==0) tmptilemap0 = tilemap_0_size0; - else if (tm0size==1) tmptilemap0 = tilemap_0_size1; - else if (tm0size==2) tmptilemap0 = tilemap_0_size2; - else tmptilemap0 = tilemap_0_size3; - - if(tm1size==0) tmptilemap1 = tilemap_1_size0; - else if (tm1size==1) tmptilemap1 = tilemap_1_size1; - else if (tm1size==2) tmptilemap1 = tilemap_1_size2; - else tmptilemap1 = tilemap_1_size3; + if (tm0size == 0) + tmptilemap0 = state->tilemap_0_size0; + else if (tm0size == 1) + tmptilemap0 = state->tilemap_0_size1; + else if (tm0size == 2) + tmptilemap0 = state->tilemap_0_size2; + else + tmptilemap0 = state->tilemap_0_size3; + + if (tm1size == 0) + tmptilemap1 = state->tilemap_1_size0; + else if (tm1size == 1) + tmptilemap1 = state->tilemap_1_size1; + else if (tm1size == 2) + tmptilemap1 = state->tilemap_1_size2; + else + tmptilemap1 = state->tilemap_1_size3; tilemap_set_enable(tmptilemap0, ~layer0_ctrl & 1); - tilemap_set_enable(tmptilemap1, ~layer1_ctrl & 1); /* Layers scrolling */ - layer0_scrolly = psikyo_vregs[ 0x402/4 ]; - layer0_scrollx = psikyo_vregs[ 0x406/4 ]; - layer1_scrolly = psikyo_vregs[ 0x40a/4 ]; - layer1_scrollx = psikyo_vregs[ 0x40e/4 ]; + layer0_scrolly = state->vregs[0x402 / 4]; + layer0_scrollx = state->vregs[0x406 / 4]; + layer1_scrolly = state->vregs[0x40a / 4]; + layer1_scrollx = state->vregs[0x40e / 4]; - tilemap_set_scrolly(tmptilemap0, 0, layer0_scrolly ); + tilemap_set_scrolly(tmptilemap0, 0, layer0_scrolly); - tilemap_set_scrolly(tmptilemap1, 0, layer1_scrolly ); + tilemap_set_scrolly(tmptilemap1, 0, layer1_scrolly); - for (i=0; i<256; i++) /* 256 screen lines */ + for (i = 0; i < 256; i++) /* 256 screen lines */ { int x0 = 0, x1 = 0; @@ -668,15 +635,15 @@ VIDEO_UPDATE( psikyo ) { if (layer0_ctrl & 0x0200) /* per-tile rowscroll */ - x0 = ((UINT16 *)psikyo_vregs)[BYTE_XOR_BE(0x000/2 + i/16)]; + x0 = ((UINT16 *)state->vregs)[BYTE_XOR_BE(0x000/2 + i/16)]; else /* per-line rowscroll */ - x0 = ((UINT16 *)psikyo_vregs)[BYTE_XOR_BE(0x000/2 + i)]; + x0 = ((UINT16 *)state->vregs)[BYTE_XOR_BE(0x000/2 + i)]; } tilemap_set_scrollx( tmptilemap0, - (i+layer0_scrolly) % tilemap_width(tm0size), + (i + layer0_scrolly) % tilemap_width(tm0size), layer0_scrollx + x0 ); @@ -685,40 +652,40 @@ VIDEO_UPDATE( psikyo ) { if (layer1_ctrl & 0x0200) /* per-tile rowscroll */ - x1 = ((UINT16 *)psikyo_vregs)[BYTE_XOR_BE(0x200/2 + i/16)]; + x1 = ((UINT16 *)state->vregs)[BYTE_XOR_BE(0x200/2 + i/16)]; else /* per-line rowscroll */ - x1 = ((UINT16 *)psikyo_vregs)[BYTE_XOR_BE(0x200/2 + i)]; + x1 = ((UINT16 *)state->vregs)[BYTE_XOR_BE(0x200/2 + i)]; } tilemap_set_scrollx( tmptilemap1, - (i+layer1_scrolly) % tilemap_width(tm1size), + (i + layer1_scrolly) % tilemap_width(tm1size), layer1_scrollx + x1 ); } - tilemap_set_transparent_pen(tilemap_0_size0,(layer0_ctrl & 8 ?0:15)); - tilemap_set_transparent_pen(tilemap_0_size1,(layer0_ctrl & 8 ?0:15)); - tilemap_set_transparent_pen(tilemap_0_size2,(layer0_ctrl & 8 ?0:15)); - tilemap_set_transparent_pen(tilemap_0_size3,(layer0_ctrl & 8 ?0:15)); + tilemap_set_transparent_pen(state->tilemap_0_size0, (layer0_ctrl & 8 ? 0 : 15)); + tilemap_set_transparent_pen(state->tilemap_0_size1, (layer0_ctrl & 8 ? 0 : 15)); + tilemap_set_transparent_pen(state->tilemap_0_size2, (layer0_ctrl & 8 ? 0 : 15)); + tilemap_set_transparent_pen(state->tilemap_0_size3, (layer0_ctrl & 8 ? 0 : 15)); - tilemap_set_transparent_pen(tilemap_1_size0,(layer1_ctrl & 8 ?0:15)); - tilemap_set_transparent_pen(tilemap_1_size1,(layer1_ctrl & 8 ?0:15)); - tilemap_set_transparent_pen(tilemap_1_size2,(layer1_ctrl & 8 ?0:15)); - tilemap_set_transparent_pen(tilemap_1_size3,(layer1_ctrl & 8 ?0:15)); + tilemap_set_transparent_pen(state->tilemap_1_size0, (layer1_ctrl & 8 ? 0 : 15)); + tilemap_set_transparent_pen(state->tilemap_1_size1, (layer1_ctrl & 8 ? 0 : 15)); + tilemap_set_transparent_pen(state->tilemap_1_size2, (layer1_ctrl & 8 ? 0 : 15)); + tilemap_set_transparent_pen(state->tilemap_1_size3, (layer1_ctrl & 8 ? 0 : 15)); - bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine)); + bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine)); - bitmap_fill(screen->machine->priority_bitmap,cliprect,0); + bitmap_fill(screen->machine->priority_bitmap, cliprect, 0); if (layers_ctrl & 1) - tilemap_draw(bitmap,cliprect,tmptilemap0, layer0_ctrl & 2 ? TILEMAP_DRAW_OPAQUE : 0, 1); + tilemap_draw(bitmap, cliprect, tmptilemap0, layer0_ctrl & 2 ? TILEMAP_DRAW_OPAQUE : 0, 1); if (layers_ctrl & 2) - tilemap_draw(bitmap,cliprect,tmptilemap1, layer1_ctrl & 2 ? TILEMAP_DRAW_OPAQUE : 0, 2); + tilemap_draw(bitmap, cliprect, tmptilemap1, layer1_ctrl & 2 ? TILEMAP_DRAW_OPAQUE : 0, 2); if (layers_ctrl & 4) - draw_sprites(screen->machine, bitmap,cliprect,(spr_ctrl & 4 ? 0 : 15)); + draw_sprites(screen->machine, bitmap, cliprect, (spr_ctrl & 4 ? 0 : 15)); return 0; } @@ -733,15 +700,16 @@ VIDEO_UPDATE( psikyo ) VIDEO_UPDATE( psikyo_bootleg ) { + psikyo_state *state = (psikyo_state *)screen->machine->driver_data; int i, layers_ctrl = -1; UINT32 tm0size, tm1size; UINT32 layer0_scrollx, layer0_scrolly; UINT32 layer1_scrollx, layer1_scrolly; - UINT32 layer0_ctrl = psikyo_vregs[ 0x412/4 ]; - UINT32 layer1_ctrl = psikyo_vregs[ 0x416/4 ]; - UINT32 spr_ctrl = spritebuf2[ 0x1ffe/4 ]; + UINT32 layer0_ctrl = state->vregs[0x412 / 4]; + UINT32 layer1_ctrl = state->vregs[0x416 / 4]; + UINT32 spr_ctrl = state->spritebuf2[0x1ffe / 4]; tilemap *tmptilemap0, *tmptilemap1; @@ -778,68 +746,61 @@ VIDEO_UPDATE( psikyo_bootleg ) */ /* For gfx banking for s1945jn/gunbird/btlkroad */ - if(psikyo_ka302c_banking) + if (state->ka302c_banking) { - psikyo_switch_banks(0, (layer0_ctrl&0x400)>>10); - psikyo_switch_banks(1, (layer1_ctrl&0x400)>>10); + psikyo_switch_banks(screen->machine, 0, (layer0_ctrl & 0x400) >> 10); + psikyo_switch_banks(screen->machine, 1, (layer1_ctrl & 0x400) >> 10); } - switch((layer0_ctrl & 0x00c0)>>6) { - case 0: - tm0size=1; - break; - case 1: - tm0size=2; - break; - case 2: - tm0size=3; - break; - default: - tm0size=0; - break; + switch ((layer0_ctrl & 0x00c0) >> 6) + { + case 0: tm0size = 1; break; + case 1: tm0size = 2; break; + case 2: tm0size = 3; break; + default: tm0size = 0; break; } - switch((layer1_ctrl & 0x00c0)>>6) { - case 0: - tm1size=1; - break; - case 1: - tm1size=2; - break; - case 2: - tm1size=3; - break; - default: - tm1size=0; - break; + switch ((layer1_ctrl & 0x00c0) >> 6) + { + case 0: tm1size = 1; break; + case 1: tm1size = 2; break; + case 2: tm1size = 3; break; + default: tm1size = 0; break; } - if(tm0size==0) tmptilemap0 = tilemap_0_size0; - else if (tm0size==1) tmptilemap0 = tilemap_0_size1; - else if (tm0size==2) tmptilemap0 = tilemap_0_size2; - else tmptilemap0 = tilemap_0_size3; - - if(tm1size==0) tmptilemap1 = tilemap_1_size0; - else if (tm1size==1) tmptilemap1 = tilemap_1_size1; - else if (tm1size==2) tmptilemap1 = tilemap_1_size2; - else tmptilemap1 = tilemap_1_size3; + if (tm0size == 0) + tmptilemap0 = state->tilemap_0_size0; + else if (tm0size == 1) + tmptilemap0 = state->tilemap_0_size1; + else if (tm0size == 2) + tmptilemap0 = state->tilemap_0_size2; + else + tmptilemap0 = state->tilemap_0_size3; + + if (tm1size == 0) + tmptilemap1 = state->tilemap_1_size0; + else if (tm1size == 1) + tmptilemap1 = state->tilemap_1_size1; + else if (tm1size == 2) + tmptilemap1 = state->tilemap_1_size2; + else + tmptilemap1 = state->tilemap_1_size3; tilemap_set_enable(tmptilemap0, ~layer0_ctrl & 1); - tilemap_set_enable(tmptilemap1, ~layer1_ctrl & 1); /* Layers scrolling */ - layer0_scrolly = psikyo_vregs[ 0x402/4 ]; - layer0_scrollx = psikyo_vregs[ 0x406/4 ]; - layer1_scrolly = psikyo_vregs[ 0x40a/4 ]; - layer1_scrollx = psikyo_vregs[ 0x40e/4 ]; + layer0_scrolly = state->vregs[0x402 / 4]; + layer0_scrollx = state->vregs[0x406 / 4]; + layer1_scrolly = state->vregs[0x40a / 4]; + layer1_scrollx = state->vregs[0x40e / 4]; - tilemap_set_scrolly(tmptilemap0, 0, layer0_scrolly ); + tilemap_set_scrolly(tmptilemap0, 0, layer0_scrolly); - tilemap_set_scrolly(tmptilemap1, 0, layer1_scrolly ); + tilemap_set_scrolly(tmptilemap1, 0, layer1_scrolly); - for (i=0; i<256; i++) /* 256 screen lines */ + for (i = 0; i < 256; i++) /* 256 screen lines */ { int x0 = 0, x1 = 0; @@ -848,15 +809,15 @@ VIDEO_UPDATE( psikyo_bootleg ) { if (layer0_ctrl & 0x0200) /* per-tile rowscroll */ - x0 = ((UINT16 *)psikyo_vregs)[BYTE_XOR_BE(0x000/2 + i/16)]; + x0 = ((UINT16 *)state->vregs)[BYTE_XOR_BE(0x000/2 + i/16)]; else /* per-line rowscroll */ - x0 = ((UINT16 *)psikyo_vregs)[BYTE_XOR_BE(0x000/2 + i)]; + x0 = ((UINT16 *)state->vregs)[BYTE_XOR_BE(0x000/2 + i)]; } tilemap_set_scrollx( tmptilemap0, - (i+layer0_scrolly) % tilemap_width(tm0size), + (i + layer0_scrolly) % tilemap_width(tm0size), layer0_scrollx + x0 ); @@ -865,40 +826,40 @@ VIDEO_UPDATE( psikyo_bootleg ) { if (layer1_ctrl & 0x0200) /* per-tile rowscroll */ - x1 = ((UINT16 *)psikyo_vregs)[BYTE_XOR_BE(0x200/2 + i/16)]; + x1 = ((UINT16 *)state->vregs)[BYTE_XOR_BE(0x200/2 + i/16)]; else /* per-line rowscroll */ - x1 = ((UINT16 *)psikyo_vregs)[BYTE_XOR_BE(0x200/2 + i)]; + x1 = ((UINT16 *)state->vregs)[BYTE_XOR_BE(0x200/2 + i)]; } tilemap_set_scrollx( tmptilemap1, - (i+layer1_scrolly) % tilemap_width(tm1size), + (i + layer1_scrolly) % tilemap_width(tm1size), layer1_scrollx + x1 ); } - tilemap_set_transparent_pen(tilemap_0_size0,(layer0_ctrl & 8 ?0:15)); - tilemap_set_transparent_pen(tilemap_0_size1,(layer0_ctrl & 8 ?0:15)); - tilemap_set_transparent_pen(tilemap_0_size2,(layer0_ctrl & 8 ?0:15)); - tilemap_set_transparent_pen(tilemap_0_size3,(layer0_ctrl & 8 ?0:15)); + tilemap_set_transparent_pen(state->tilemap_0_size0, (layer0_ctrl & 8 ? 0 : 15)); + tilemap_set_transparent_pen(state->tilemap_0_size1, (layer0_ctrl & 8 ? 0 : 15)); + tilemap_set_transparent_pen(state->tilemap_0_size2, (layer0_ctrl & 8 ? 0 : 15)); + tilemap_set_transparent_pen(state->tilemap_0_size3, (layer0_ctrl & 8 ? 0 : 15)); - tilemap_set_transparent_pen(tilemap_1_size0,(layer1_ctrl & 8 ?0:15)); - tilemap_set_transparent_pen(tilemap_1_size1,(layer1_ctrl & 8 ?0:15)); - tilemap_set_transparent_pen(tilemap_1_size2,(layer1_ctrl & 8 ?0:15)); - tilemap_set_transparent_pen(tilemap_1_size3,(layer1_ctrl & 8 ?0:15)); + tilemap_set_transparent_pen(state->tilemap_1_size0, (layer1_ctrl & 8 ? 0 : 15)); + tilemap_set_transparent_pen(state->tilemap_1_size1, (layer1_ctrl & 8 ? 0 : 15)); + tilemap_set_transparent_pen(state->tilemap_1_size2, (layer1_ctrl & 8 ? 0 : 15)); + tilemap_set_transparent_pen(state->tilemap_1_size3, (layer1_ctrl & 8 ? 0 : 15)); bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine)); - bitmap_fill(screen->machine->priority_bitmap,cliprect,0); + bitmap_fill(screen->machine->priority_bitmap, cliprect, 0); if (layers_ctrl & 1) - tilemap_draw(bitmap,cliprect,tmptilemap0, layer0_ctrl & 2 ? TILEMAP_DRAW_OPAQUE : 0, 1); + tilemap_draw(bitmap, cliprect, tmptilemap0, layer0_ctrl & 2 ? TILEMAP_DRAW_OPAQUE : 0, 1); if (layers_ctrl & 2) - tilemap_draw(bitmap,cliprect,tmptilemap1, layer1_ctrl & 2 ? TILEMAP_DRAW_OPAQUE : 0, 2); + tilemap_draw(bitmap, cliprect, tmptilemap1, layer1_ctrl & 2 ? TILEMAP_DRAW_OPAQUE : 0, 2); if (layers_ctrl & 4) - draw_sprites_bootleg(screen->machine, bitmap,cliprect,(spr_ctrl & 4 ? 0 : 15)); + draw_sprites_bootleg(screen->machine, bitmap, cliprect, (spr_ctrl & 4 ? 0 : 15)); return 0; } @@ -906,6 +867,7 @@ VIDEO_UPDATE( psikyo_bootleg ) VIDEO_EOF( psikyo ) { - memcpy(spritebuf2, spritebuf1, 0x2000); - memcpy(spritebuf1, machine->generic.spriteram.u32, 0x2000); + psikyo_state *state = (psikyo_state *)machine->driver_data; + memcpy(state->spritebuf2, state->spritebuf1, 0x2000); + memcpy(state->spritebuf1, machine->generic.spriteram.u32, 0x2000); } diff --git a/src/mame/video/psikyo4.c b/src/mame/video/psikyo4.c index 5c60d2663b6..0de9f7feb34 100644 --- a/src/mame/video/psikyo4.c +++ b/src/mame/video/psikyo4.c @@ -27,12 +27,11 @@ HgKairak: 86010000 1f201918 a0000000 Large Screen */ #include "driver.h" +#include "includes/psikyo4.h" -/* defined in drivers/psikyo4.c */ -extern UINT32 *psikyo4_vidregs; /* --- SPRITES --- */ -static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT32 scr ) +static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT32 scr ) { /*- Sprite Format 0x0000 - 0x2bff -** @@ -53,16 +52,17 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta **- End Sprite Format -*/ + psikyo4_state *state = (psikyo4_state *)machine->driver_data; const gfx_element *gfx = machine->gfx[0]; - UINT32 *source = machine->generic.spriteram.u32; - UINT16 *list = (UINT16 *)machine->generic.spriteram.u32 + 0x2c00/2 + 0x04/2; /* 0x2c00/0x2c02 what are these for, pointers? one for each screen */ - UINT16 listlen=(0xc00/2 - 0x04/2), listcntr=0; + UINT32 *source = state->spriteram; + UINT16 *list = (UINT16 *)state->spriteram + 0x2c00/2 + 0x04/2; /* 0x2c00/0x2c02 what are these for, pointers? one for each screen */ + UINT16 listlen = (0xc00/2 - 0x04/2), listcntr = 0; int flipscreen1, flipscreen2; - flipscreen1 = (((psikyo4_vidregs[1]>>30)&2) == 2) ? 1 : 0; - flipscreen2 = (((psikyo4_vidregs[1]>>22)&2) == 2) ? 1 : 0; + flipscreen1 = (((state->vidregs[1] >> 30) & 2) == 2) ? 1 : 0; + flipscreen2 = (((state->vidregs[1] >> 22) & 2) == 2) ? 1 : 0; - while( listcntr < listlen ) + while (listcntr < listlen) { UINT16 listdat, sprnum, thisscreen; @@ -75,51 +75,55 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta /* start drawing */ if (!(listdat & 0x8000) && thisscreen) /* draw only selected screen */ { - int loopnum=0, i, j; + int loopnum = 0, i, j; UINT32 xpos, ypos, tnum, wide, high, colr, flipx, flipy; int xstart, ystart, xend, yend, xinc, yinc; - ypos = (source[sprnum+0] & 0x03ff0000) >> 16; - xpos = (source[sprnum+0] & 0x000003ff) >> 00; + ypos = (source[sprnum + 0] & 0x03ff0000) >> 16; + xpos = (source[sprnum + 0] & 0x000003ff) >> 00; - high = ((source[sprnum+0] & 0xf0000000) >> (12+16)) + 1; - wide = ((source[sprnum+0] & 0x0000f000) >> 12) + 1; + high = ((source[sprnum + 0] & 0xf0000000) >> (12 + 16)) + 1; + wide = ((source[sprnum + 0] & 0x0000f000) >> 12) + 1; - tnum = (source[sprnum+1] & 0x0007ffff) >> 00; + tnum = (source[sprnum + 1] & 0x0007ffff) >> 00; - colr = (source[sprnum+1] & 0x3f000000) >> 24; - if(scr) colr += 0x40; /* Use second copy of palette which is dimmed appropriately */ + colr = (source[sprnum + 1] & 0x3f000000) >> 24; + if (scr) + colr += 0x40; /* Use second copy of palette which is dimmed appropriately */ - flipx = (source[sprnum+1] & 0x40000000); - flipy = (source[sprnum+1] & 0x80000000); /* Guess */ + flipx = (source[sprnum + 1] & 0x40000000); + flipy = (source[sprnum + 1] & 0x80000000); /* Guess */ - if(ypos & 0x200) ypos -= 0x400; - if(xpos & 0x200) xpos -= 0x400; + if (ypos & 0x200) ypos -= 0x400; + if (xpos & 0x200) xpos -= 0x400; - if((!scr && flipscreen1) || (scr && flipscreen2)) + if ((!scr && flipscreen1) || (scr && flipscreen2)) { - ypos = video_screen_get_visible_area(machine->primary_screen)->max_y+1 - ypos - high*16; /* Screen Height depends on game */ - xpos = 40*8 - xpos - wide*16; + ypos = video_screen_get_visible_area(machine->primary_screen)->max_y + 1 - ypos - high * 16; /* Screen Height depends on game */ + xpos = 40 * 8 - xpos - wide * 16; flipx = !flipx; flipy = !flipy; } - if (flipx) { xstart = wide-1; xend = -1; xinc = -1; } - else { xstart = 0; xend = wide; xinc = +1; } + if (flipx) { xstart = wide - 1; xend = -1; xinc = -1; } + else { xstart = 0; xend = wide; xinc = +1; } - if (flipy) { ystart = high-1; yend = -1; yinc = -1; } - else { ystart = 0; yend = high; yinc = +1; } + if (flipy) { ystart = high - 1; yend = -1; yinc = -1; } + else { ystart = 0; yend = high; yinc = +1; } - for (j = ystart; j != yend; j += yinc) { - for (i = xstart; i != xend; i += xinc) { - drawgfx_transpen(bitmap,cliprect,gfx,tnum+loopnum,colr,flipx,flipy,xpos+16*i,ypos+16*j,0); + for (j = ystart; j != yend; j += yinc) + { + for (i = xstart; i != xend; i += xinc) + { + drawgfx_transpen(bitmap, cliprect, gfx, tnum + loopnum, colr, flipx, flipy, xpos + 16 * i, ypos + 16 * j, 0); loopnum++; } } } /* end drawing */ listcntr++; - if (listdat & 0x4000) break; + if (listdat & 0x4000) + break; } } @@ -143,5 +147,5 @@ VIDEO_UPDATE( psikyo4 ) VIDEO_START( psikyo4 ) { - machine->gfx[0]->color_granularity=32; /* 256 colour sprites with palette selectable on 32 colour boundaries */ + machine->gfx[0]->color_granularity = 32; /* 256 colour sprites with palette selectable on 32 colour boundaries */ } diff --git a/src/mame/video/psikyosh.c b/src/mame/video/psikyosh.c index d902c370895..49e496fc202 100644 --- a/src/mame/video/psikyosh.c +++ b/src/mame/video/psikyosh.c @@ -42,9 +42,9 @@ c 6000 General Purpose banks for either tilemaps (can optionally use two co /* BG Scroll/Priority/Zoom/Alpha/Tilebank: -Either at 0x30053f0/4/8 (For 0a/0c/0d), 0x3005bf0/4/8 (For 0b) Or per-line in a bank (For 0e-1f) +Either at 0x30053f0 / 4/8 (For 0a/0c/0d), 0x3005bf0 / 4/8 (For 0b) Or per-line in a bank (For 0e-1f) 0x?vvv?xxx - v = vertical scroll - x = x scroll -Either at 0x30057f0/4/8 (For 0a/0c/0d), 0x3005ff0/4/8 (For 0b) Or per-line in a bank (For 0e-1f) +Either at 0x30057f0 / 4/8 (For 0a/0c/0d), 0x3005ff0 / 4/8 (For 0b) Or per-line in a bank (For 0e-1f) 0xppzzaabb - p = priority, z = zoom/expand(00 is none), a = alpha value/effect, b = tilebank (used when register below = 0x0a) @@ -91,24 +91,22 @@ sol divide doesn't seem to make much use of tilemaps at all, it uses them to fad #include "driver.h" #include "profiler.h" -#include "includes/psikyosh.h" #include "drawgfxm.h" - -/* Needed for psikyosh_drawgfxzoom */ -static bitmap_t *zoom_bitmap, *z_bitmap; -static UINT8 alphatable[256]; +#include "includes/psikyosh.h" /* Psikyo PS6406B */ /* --- BACKGROUNDS --- */ -#define PIXEL_OP_REMAP_TRANS0_ALPHATABLE32(DEST, PRIORITY, SOURCE) \ -do \ -{ \ +static UINT8 alphatable[256]; // this might be moved to psikyosh_state, if we ever add a *machine parameter to drawgfxm.h macros + +#define PIXEL_OP_REMAP_TRANS0_ALPHATABLE32(DEST, PRIORITY, SOURCE) \ +do \ +{ \ UINT32 srcdata = (SOURCE); \ if (srcdata != 0) \ (DEST) = alpha_blend_r32((DEST), paldata[srcdata], alphatable[srcdata]); \ -} \ -while (0) \ +} \ +while (0) \ static void drawgfx_alphatable(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx, UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty, @@ -145,59 +143,62 @@ static void drawgfx_alphatable(bitmap_t *dest, const rectangle *cliprect, const /* 'Normal' layers, no line/columnscroll. No per-line effects */ -static void draw_bglayer(running_machine *machine, int layer, bitmap_t *bitmap, const rectangle *cliprect ) +static void draw_bglayer( running_machine *machine, int layer, bitmap_t *bitmap, const rectangle *cliprect ) { + psikyosh_state *state = (psikyosh_state *)machine->driver_data; gfx_element *gfx; - int offs=0, sx, sy; + int offs = 0, sx, sy; int scrollx, scrolly, bank, alpha, alphamap, size, width; - if ( BG_TYPE(layer) == BG_NORMAL_ALT ) + if (BG_TYPE(layer) == BG_NORMAL_ALT) { - bank = (psikyosh_bgram[0x1ff0/4 + (layer*0x04)/4] & 0x000000ff) >> 0; - alpha = (psikyosh_bgram[0x1ff0/4 + (layer*0x04)/4] & 0x00003f00) >> 8; - alphamap =(psikyosh_bgram[0x1ff0/4 + (layer*0x04)/4] & 0x00008000) >> 15; - scrollx = (psikyosh_bgram[0x1bf0/4 + (layer*0x04)/4] & 0x000001ff) >> 0; - scrolly = (psikyosh_bgram[0x1bf0/4 + (layer*0x04)/4] & 0x03ff0000) >> 16; + bank = (state->bgram[0x1ff0 / 4 + (layer * 0x04) / 4] & 0x000000ff) >> 0; + alpha = (state->bgram[0x1ff0 / 4 + (layer * 0x04) / 4] & 0x00003f00) >> 8; + alphamap = (state->bgram[0x1ff0 / 4 + (layer * 0x04) / 4] & 0x00008000) >> 15; + scrollx = (state->bgram[0x1bf0 / 4 + (layer * 0x04) / 4] & 0x000001ff) >> 0; + scrolly = (state->bgram[0x1bf0 / 4 + (layer * 0x04) / 4] & 0x03ff0000) >> 16; } else /* BG_NORMAL */ { - bank = (psikyosh_bgram[0x17f0/4 + (layer*0x04)/4] & 0x000000ff) >> 0; - alpha = (psikyosh_bgram[0x17f0/4 + (layer*0x04)/4] & 0x00003f00) >> 8; - alphamap =(psikyosh_bgram[0x17f0/4 + (layer*0x04)/4] & 0x00008000) >> 15; - scrollx = (psikyosh_bgram[0x13f0/4 + (layer*0x04)/4] & 0x000001ff) >> 0; - scrolly = (psikyosh_bgram[0x13f0/4 + (layer*0x04)/4] & 0x03ff0000) >> 16; + bank = (state->bgram[0x17f0 / 4 + (layer * 0x04) / 4] & 0x000000ff) >> 0; + alpha = (state->bgram[0x17f0 / 4 + (layer * 0x04) / 4] & 0x00003f00) >> 8; + alphamap = (state->bgram[0x17f0 / 4 + (layer * 0x04) / 4] & 0x00008000) >> 15; + scrollx = (state->bgram[0x13f0 / 4 + (layer * 0x04) / 4] & 0x000001ff) >> 0; + scrolly = (state->bgram[0x13f0 / 4 + (layer * 0x04) / 4] & 0x03ff0000) >> 16; } - if ( BG_TYPE(layer) == BG_SCROLL_0D ) scrollx += 0x08; /* quick kludge until using rowscroll */ + if (BG_TYPE(layer) == BG_SCROLL_0D) + scrollx += 0x08; /* quick kludge until using rowscroll */ gfx = BG_DEPTH_8BPP(layer) ? machine->gfx[1] : machine->gfx[0]; size = BG_LARGE(layer) ? 32 : 16; width = BG_LARGE(layer) ? 0x200 : 0x100; - if(alphamap) { /* alpha values are per-pen */ + if (alphamap) /* alpha values are per-pen */ alpha = -1; - } else { - alpha = ((0x3f-alpha)*0xff)/0x3f; /* 0x3f-0x00 maps to 0x00-0xff */ - } + else + alpha = ((0x3f - alpha) * 0xff) / 0x3f; /* 0x3f-0x00 maps to 0x00-0xff */ - if((bank>=0x0c) && (bank<=0x1f)) /* shouldn't happen, 20 banks of 0x800 bytes */ + + if ((bank >= 0x0c) && (bank <= 0x1f)) /* shouldn't happen, 20 banks of 0x800 bytes */ { - for (sy=0; sy<size; sy++) + for (sy = 0; sy < size; sy++) { - for (sx=0; sx<32; sx++) + for (sx = 0; sx < 32; sx++) { int tileno, colour; - tileno = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */ - colour = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0xff000000) >> 24; + tileno = (state->bgram[(bank * 0x800) / 4 + offs - 0x4000 / 4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */ + colour = (state->bgram[(bank * 0x800) / 4 + offs - 0x4000 / 4] & 0xff000000) >> 24; + + drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, (16 * sx + scrollx) & 0x1ff, ((16 * sy + scrolly) & (width - 1)), alpha); /* normal */ - drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1)),alpha); /* normal */ - if(scrollx) - drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1)),alpha); /* wrap x */ - if(scrolly) - drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap y */ - if(scrollx && scrolly) - drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap xy */ + if (scrollx) + drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, ((16 * sx + scrollx) & 0x1ff) - 0x200, ((16 * sy + scrolly) & (width - 1)), alpha); /* wrap x */ + if (scrolly) + drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, (16 * sx + scrollx) & 0x1ff, ((16 * sy + scrolly) & (width - 1)) - width, alpha); /* wrap y */ + if (scrollx && scrolly) + drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, ((16 * sx + scrollx) & 0x1ff) - 0x200, ((16 * sy + scrolly) & (width - 1)) - width, alpha); /* wrap xy */ offs++; } @@ -207,11 +208,12 @@ static void draw_bglayer(running_machine *machine, int layer, bitmap_t *bitmap, /* This is a complete bodge for the daraku text layers. There is not enough info to be sure how it is supposed to work */ /* It appears that there are row/column scroll values for 2 seperate layers, just drawing it twice using one of each of the sets of values for now */ -static void draw_bglayertext(running_machine *machine, int layer, bitmap_t *bitmap, const rectangle *cliprect ) +static void draw_bglayertext( running_machine *machine, int layer, bitmap_t *bitmap, const rectangle *cliprect ) { + psikyosh_state *state = (psikyosh_state *)machine->driver_data; gfx_element *gfx; int offs, sx, sy; - int scrollx, scrolly, bank, size, width, scrollbank,alpha,alphamap; + int scrollx, scrolly, bank, size, width, scrollbank, alpha, alphamap; scrollbank = BG_TYPE(layer); /* Scroll bank appears to be same as layer type */ @@ -220,77 +222,87 @@ static void draw_bglayertext(running_machine *machine, int layer, bitmap_t *bitm width = BG_LARGE(layer) ? 0x200 : 0x100; /* Use first values from the first set of scroll values */ - bank = (psikyosh_bgram[(scrollbank*0x800)/4 + 0x400/4 - 0x4000/4] & 0x000000ff) >> 0; - alpha = (psikyosh_bgram[(scrollbank*0x800)/4 + 0x400/4 - 0x4000/4] & 0x00003f00) >> 8; - alphamap =(psikyosh_bgram[(scrollbank*0x800)/4 + 0x400/4 - 0x4000/4] & 0x00008000) >> 15; - scrollx = (psikyosh_bgram[(scrollbank*0x800)/4 - 0x4000/4] & 0x000001ff) >> 0; - scrolly = (psikyosh_bgram[(scrollbank*0x800)/4 - 0x4000/4] & 0x03ff0000) >> 16; + bank = (state->bgram[(scrollbank * 0x800) / 4 + 0x400 / 4 - 0x4000 / 4] & 0x000000ff) >> 0; + alpha = (state->bgram[(scrollbank * 0x800) / 4 + 0x400 / 4 - 0x4000 / 4] & 0x00003f00) >> 8; + alphamap = (state->bgram[(scrollbank * 0x800) / 4 + 0x400 / 4 - 0x4000 / 4] & 0x00008000) >> 15; + scrollx = (state->bgram[(scrollbank * 0x800) / 4 - 0x4000 / 4] & 0x000001ff) >> 0; + scrolly = (state->bgram[(scrollbank * 0x800) / 4 - 0x4000 / 4] & 0x03ff0000) >> 16; - if(alphamap) { /* alpha values are per-pen */ + if (alphamap) /* alpha values are per-pen */ alpha = -1; - } else { - alpha = ((0x3f-alpha)*0xff)/0x3f; /* 0x3f-0x00 maps to 0x00-0xff */ - } + else + alpha = ((0x3f - alpha) * 0xff) / 0x3f; /* 0x3f-0x00 maps to 0x00-0xff */ - - if((bank>=0x0c) && (bank<=0x1f)) { /* shouldn't happen, 20 banks of 0x800 bytes */ - offs=0; - for ( sy=0; sy<size; sy++) { - for (sx=0; sx<32; sx++) { + if ((bank >= 0x0c) && (bank <= 0x1f)) /* shouldn't happen, 20 banks of 0x800 bytes */ + { + offs = 0; + for (sy = 0; sy < size; sy++) + { + for (sx = 0; sx < 32; sx++) + { int tileno, colour; - tileno = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */ - colour = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0xff000000) >> 24; + tileno = (state->bgram[(bank * 0x800) / 4 + offs - 0x4000 / 4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */ + colour = (state->bgram[(bank * 0x800) / 4 + offs - 0x4000 / 4] & 0xff000000) >> 24; + + drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, (16 * sx + scrollx) & 0x1ff, ((16 * sy + scrolly) & (width - 1)), alpha); /* normal */ - drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1)),alpha); /* normal */ - if(scrollx) - drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1)),alpha); /* wrap x */ - if(scrolly) - drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap y */ - if(scrollx && scrolly) - drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap xy */ + if (scrollx) + drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, ((16 * sx + scrollx) & 0x1ff) - 0x200, ((16 * sy + scrolly) & (width - 1)), alpha); /* wrap x */ + if (scrolly) + drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, (16 * sx + scrollx) & 0x1ff, ((16 * sy + scrolly) & (width - 1)) - width, alpha); /* wrap y */ + if (scrollx && scrolly) + drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, ((16 * sx + scrollx) & 0x1ff) - 0x200, ((16 * sy + scrolly) & (width - 1)) - width, alpha); /* wrap xy */ offs++; - }}} + } + } + } /* Use first values from the second set of scroll values */ - bank = (psikyosh_bgram[(scrollbank*0x800)/4 + 0x400/4 + 0x20/4 - 0x4000/4] & 0x000000ff) >> 0; - alpha = (psikyosh_bgram[(scrollbank*0x800)/4 + 0x400/4 + 0x20/4 - 0x4000/4] & 0x00003f00) >> 8; - alphamap =(psikyosh_bgram[(scrollbank*0x800)/4 + 0x400/4 + 0x20/4 - 0x4000/4] & 0x00008000) >> 15; - scrollx = (psikyosh_bgram[(scrollbank*0x800)/4 - 0x4000/4 + 0x20/4] & 0x000001ff) >> 0; - scrolly = (psikyosh_bgram[(scrollbank*0x800)/4 - 0x4000/4 + 0x20/4] & 0x03ff0000) >> 16; + bank = (state->bgram[(scrollbank * 0x800) / 4 + 0x400 / 4 + 0x20 / 4 - 0x4000 / 4] & 0x000000ff) >> 0; + alpha = (state->bgram[(scrollbank * 0x800) / 4 + 0x400 / 4 + 0x20 / 4 - 0x4000 / 4] & 0x00003f00) >> 8; + alphamap = (state->bgram[(scrollbank * 0x800) / 4 + 0x400 / 4 + 0x20 / 4 - 0x4000 / 4] & 0x00008000) >> 15; + scrollx = (state->bgram[(scrollbank * 0x800) / 4 - 0x4000 / 4 + 0x20 / 4] & 0x000001ff) >> 0; + scrolly = (state->bgram[(scrollbank * 0x800) / 4 - 0x4000 / 4 + 0x20 / 4] & 0x03ff0000) >> 16; - if(alphamap) { /* alpha values are per-pen */ + if (alphamap) /* alpha values are per-pen */ alpha = -1; - } else { - alpha = ((0x3f-alpha)*0xff)/0x3f; /* 0x3f-0x00 maps to 0x00-0xff */ - } + else + alpha = ((0x3f - alpha) * 0xff) / 0x3f; /* 0x3f-0x00 maps to 0x00-0xff */ - if((bank>=0x0c) && (bank<=0x1f)) { /* shouldn't happen, 20 banks of 0x800 bytes */ - offs=0; - for ( sy=0; sy<size; sy++) { - for (sx=0; sx<32; sx++) { + if ((bank >= 0x0c) && (bank <= 0x1f)) /* shouldn't happen, 20 banks of 0x800 bytes */ + { + offs = 0; + for (sy = 0; sy < size; sy++) + { + for (sx = 0; sx < 32; sx++) + { int tileno, colour; - tileno = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */ - colour = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0xff000000) >> 24; + tileno = (state->bgram[(bank * 0x800) / 4 + offs - 0x4000 / 4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */ + colour = (state->bgram[(bank * 0x800) / 4 + offs - 0x4000 / 4] & 0xff000000) >> 24; + + drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, (16 * sx + scrollx) & 0x1ff, ((16 * sy + scrolly) & (width - 1)), alpha); /* normal */ - drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1)),alpha); /* normal */ - if(scrollx) - drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1)),alpha); /* wrap x */ - if(scrolly) - drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap y */ - if(scrollx && scrolly) - drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap xy */ + if (scrollx) + drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, ((16 * sx + scrollx) & 0x1ff) - 0x200, ((16 * sy + scrolly) & (width - 1)), alpha); /* wrap x */ + if (scrolly) + drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, (16 * sx + scrollx) & 0x1ff, ((16 * sy + scrolly) & (width - 1)) - width, alpha); /* wrap y */ + if (scrollx && scrolly) + drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, ((16 * sx + scrollx) & 0x1ff) - 0x200, ((16 * sy + scrolly) & (width - 1)) - width, alpha); /* wrap xy */ offs++; - }}} + } + } + } } /* Row Scroll and/or Column Scroll/Zoom, has per-column Alpha/Bank/Priority. This isn't correct, just testing */ /* For now I'm just using the first alpha/bank/priority values and sodding the rest of it */ -static void draw_bglayerscroll(running_machine *machine, int layer, bitmap_t *bitmap, const rectangle *cliprect ) +static void draw_bglayerscroll( running_machine *machine, int layer, bitmap_t *bitmap, const rectangle *cliprect ) { + psikyosh_state *state = (psikyosh_state *)machine->driver_data; gfx_element *gfx; int offs, sx, sy; int scrollx, scrolly, bank, alpha, alphamap, size, width, scrollbank; @@ -300,71 +312,72 @@ static void draw_bglayerscroll(running_machine *machine, int layer, bitmap_t *bi // bank = BG_TYPE(layer) - 0x02; /* This is an assumption which seems to hold true so far, although the bank seems to be selectable per-line */ /* Take the following details from the info for the first row, the same for every row in all cases so far */ - bank = (psikyosh_bgram[(scrollbank*0x800)/4 + 0x400/4 - 0x4000/4] & 0x000000ff) >> 0; - alpha = (psikyosh_bgram[(scrollbank*0x800)/4 + 0x400/4 - 0x4000/4] & 0x00003f00) >> 8; - alphamap =(psikyosh_bgram[(scrollbank*0x800)/4 + 0x400/4 - 0x4000/4] & 0x00008000) >> 15; + bank = (state->bgram[(scrollbank * 0x800) / 4 + 0x400 / 4 - 0x4000 / 4] & 0x000000ff) >> 0; + alpha = (state->bgram[(scrollbank * 0x800) / 4 + 0x400 / 4 - 0x4000 / 4] & 0x00003f00) >> 8; + alphamap =(state->bgram[(scrollbank * 0x800) / 4 + 0x400 / 4 - 0x4000 / 4] & 0x00008000) >> 15; /* Just to get things moving :) */ - scrollx =(psikyosh_bgram[(scrollbank*0x800)/4 - 0x4000/4] & 0x000001ff) >> 0; + scrollx =(state->bgram[(scrollbank * 0x800) / 4 - 0x4000 / 4] & 0x000001ff) >> 0; scrolly = 0; // ColumnZoom is combined with ColumnScroll values :( gfx = BG_DEPTH_8BPP(layer) ? machine->gfx[1] : machine->gfx[0]; size = BG_LARGE(layer) ? 32 : 16; width = BG_LARGE(layer) ? 0x200 : 0x100; - if(alphamap) { /* alpha values are per-pen */ + if (alphamap) /* alpha values are per-pen */ alpha = -1; - } else { - alpha = ((0x3f-alpha)*0xff)/0x3f; /* 0x3f-0x00 maps to 0x00-0xff */ - } + else + alpha = ((0x3f - alpha) * 0xff) / 0x3f; /* 0x3f-0x00 maps to 0x00-0xff */ - if((bank>=0x0c) && (bank<=0x1f)) /* shouldn't happen, 20 banks of 0x800 bytes */ + if ((bank >= 0x0c) && (bank <= 0x1f)) /* shouldn't happen, 20 banks of 0x800 bytes */ { /* Looks better with blending and one scroll value than with 1D linescroll and no zoom */ #if 0 int bg_scrollx[256], bg_scrolly[512]; - bitmap_fill(zoom_bitmap, NULL, get_black_pen(screen->machine)); - for (offs=0; offs<(0x400/4); offs++) /* 224 values for each */ + bitmap_fill(state->zoom_bitmap, NULL, get_black_pen(screen->machine)); + for (offs = 0; offs < (0x400 / 4); offs++) /* 224 values for each */ { - bg_scrollx[offs] = (psikyosh_bgram[(scrollbank*0x800)/4 + offs - 0x4000/4] & 0x000001ff) >> 0; - bg_scrolly[2*offs] = (psikyosh_bgram[(scrollbank*0x800)/4 + offs - 0x4000/4] & 0x03ff0000) >> 16; - bg_scrolly[2*offs+1] = (psikyosh_bgram[(scrollbank*0x800)/4 + offs - 0x4000/4] & 0x03ff0000) >> 16; + bg_scrollx[offs] = (state->bgram[(scrollbank * 0x800) / 4 + offs - 0x4000 / 4] & 0x000001ff) >> 0; + bg_scrolly[2 * offs] = (state->bgram[(scrollbank * 0x800) / 4 + offs - 0x4000 / 4] & 0x03ff0000) >> 16; + bg_scrolly[2 * offs + 1] = (state->bgram[(scrollbank * 0x800) / 4 + offs - 0x4000 / 4] & 0x03ff0000) >> 16; } #endif - offs=0; - for ( sy=0; sy<size; sy++) + offs = 0; + for (sy = 0; sy < size; sy++) { - for (sx=0; sx<32; sx++) + for (sx = 0; sx < 32; sx++) { int tileno, colour; - tileno = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */ - colour = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0xff000000) >> 24; + tileno = (state->bgram[(bank * 0x800) / 4 + offs - 0x4000 / 4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */ + colour = (state->bgram[(bank * 0x800) / 4 + offs - 0x4000 / 4] & 0xff000000) >> 24; + +// drawgfx_transpen(state->zoom_bitmap, NULL, gfx, tileno, colour, 0, 0, (16 * sx) & 0x1ff, ((16 * sy) & (width - 1)), 0); -// drawgfx_transpen(zoom_bitmap,NULL,gfx,tileno,colour,0,0,(16*sx)&0x1ff,((16*sy)&(width-1)),0); + drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, (16 * sx + scrollx) & 0x1ff, ((16 * sy + scrolly) & (width - 1)), alpha); /* normal */ - drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1)),alpha); /* normal */ - if(scrollx) - drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1)),alpha); /* wrap x */ - if(scrolly) - drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap y */ - if(scrollx && scrolly) - drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap xy */ + if (scrollx) + drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, ((16 * sx + scrollx) & 0x1ff) - 0x200, ((16 * sy + scrolly) & (width - 1)), alpha); /* wrap x */ + if (scrolly) + drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, (16 * sx + scrollx) & 0x1ff, ((16 * sy + scrolly) & (width - 1)) - width, alpha); /* wrap y */ + if (scrollx && scrolly) + drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, ((16 * sx + scrollx) & 0x1ff) - 0x200, ((16 * sy + scrolly) & (width - 1)) - width, alpha); /* wrap xy */ offs++; } } /* Only ever seems to use one linescroll value, ok for now */ /* Disabled for now, as they doesn't even support alpha :( */ -// copyscrollbitmap_trans(bitmap,zoom_bitmap,1,bg_scrollx,512,bg_scrolly,cliprect,0); -// copyscrollbitmap_trans(bitmap,zoom_bitmap,256,bg_scrollx,0,bg_scrolly,cliprect,0); +// copyscrollbitmap_trans(bitmap, state->zoom_bitmap, 1, bg_scrollx, 512, bg_scrolly, cliprect, 0); +// copyscrollbitmap_trans(bitmap, state->zoom_bitmap, 256, bg_scrollx, 0, bg_scrolly, cliprect, 0); } } /* 3 BG layers, with priority */ -static void draw_background(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8 req_pri ) +static void draw_background( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8 req_pri ) { + psikyosh_state *state = (psikyosh_state *)machine->driver_data; int i; #if 0 @@ -377,24 +390,24 @@ static void draw_background(running_machine *machine, bitmap_t *bitmap, const re #endif /* 1st-3rd layers */ - for(i=0; i<3; i++) + for (i = 0; i < 3; i++) { - if ( !BG_LAYER_ENABLE(i) ) + if (!BG_LAYER_ENABLE(i)) continue; - switch(BG_TYPE(i)) + switch (BG_TYPE(i)) { case BG_NORMAL: - if(((psikyosh_bgram[0x17f0/4 + (i*0x04)/4] & 0xff000000) >> 24) == req_pri) + if (((state->bgram[0x17f0 / 4 + (i * 0x04) / 4] & 0xff000000) >> 24) == req_pri) draw_bglayer(machine, i, bitmap, cliprect); break; case BG_NORMAL_ALT: - if(((psikyosh_bgram[0x1ff0/4 + (i*0x04)/4] & 0xff000000) >> 24) == req_pri) + if (((state->bgram[0x1ff0 / 4 + (i * 0x04) / 4] & 0xff000000) >> 24) == req_pri) draw_bglayer(machine, i, bitmap, cliprect); break; case BG_SCROLL_0C: // Using normal for now case BG_SCROLL_0D: // Using normal for now - if(((psikyosh_bgram[(BG_TYPE(i)*0x800)/4 + 0x400/4 - 0x4000/4] & 0xff000000) >> 24) == req_pri) + if (((state->bgram[(BG_TYPE(i) * 0x800) / 4 + 0x400 / 4 - 0x4000 / 4] & 0xff000000) >> 24) == req_pri) draw_bglayertext(machine, i, bitmap, cliprect); break; case BG_SCROLL_ZOOM: @@ -403,7 +416,7 @@ static void draw_background(running_machine *machine, bitmap_t *bitmap, const re case 0x14: case 0x15: case 0x16: case 0x17: case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f: - if(((psikyosh_bgram[(BG_TYPE(i)*0x800)/4 + 0x400/4 - 0x4000/4] & 0xff000000) >> 24) == req_pri) + if (((state->bgram[(BG_TYPE(i) * 0x800) / 4 + 0x400 / 4 - 0x4000 / 4] & 0xff000000) >> 24) == req_pri) draw_bglayerscroll(machine, i, bitmap, cliprect); break; default: @@ -421,24 +434,26 @@ static void draw_background(running_machine *machine, bitmap_t *bitmap, const re /* sx and sy is top-left of entire sprite regardless of flip */ /* Note that Level 5-4 of sbomberb boss is perfect! (Alpha blended zoomed) as well as S1945II logo */ /* pixel is only plotted if z is >= priority_buffer[y][x] */ -static void psikyosh_drawgfxzoom( +static void psikyosh_drawgfxzoom( running_machine *machine, bitmap_t *dest_bmp,const rectangle *clip,const gfx_element *gfx, UINT32 code,UINT32 color,int flipx,int flipy,int offsx,int offsy, int alpha, int zoomx, int zoomy, int wide, int high, UINT32 z) { + psikyosh_state *state = (psikyosh_state *)machine->driver_data; rectangle myclip; /* Clip to screen boundaries */ int code_offset = 0; int xtile, ytile, xpixel, ypixel; - if (!zoomx || !zoomy) return; + if (!zoomx || !zoomy) + return; profiler_mark_start(PROFILER_DRAWGFX); assert(dest_bmp->bpp == 32); /* KW 991012 -- Added code to force clip to bitmap boundary */ - if(clip) + if (clip) { myclip.min_x = clip->min_x; myclip.max_x = clip->max_x; @@ -446,11 +461,11 @@ static void psikyosh_drawgfxzoom( myclip.max_y = clip->max_y; if (myclip.min_x < 0) myclip.min_x = 0; - if (myclip.max_x >= dest_bmp->width) myclip.max_x = dest_bmp->width-1; + if (myclip.max_x >= dest_bmp->width) myclip.max_x = dest_bmp->width - 1; if (myclip.min_y < 0) myclip.min_y = 0; if (myclip.max_y >= dest_bmp->height) myclip.max_y = dest_bmp->height-1; - clip=&myclip; + clip = &myclip; } /* Temporary fallback for non-zoomed, needs z-buffer. Note that this is probably a lot slower than drawgfx.c, especially if there was seperate code for flipped cases */ @@ -458,89 +473,89 @@ static void psikyosh_drawgfxzoom( { int xstart, ystart, xend, yend, xinc, yinc; - if (flipx) { xstart = wide-1; xend = -1; xinc = -1; } - else { xstart = 0; xend = wide; xinc = +1; } + if (flipx) { xstart = wide - 1; xend = -1; xinc = -1; } + else { xstart = 0; xend = wide; xinc = +1; } - if (flipy) { ystart = high-1; yend = -1; yinc = -1; } - else { ystart = 0; yend = high; yinc = +1; } + if (flipy) { ystart = high - 1; yend = -1; yinc = -1; } + else { ystart = 0; yend = high; yinc = +1; } /* Start drawing */ - if( gfx ) + if (gfx) { - for (ytile = ystart; ytile != yend; ytile += yinc ) + for (ytile = ystart; ytile != yend; ytile += yinc) { - for (xtile = xstart; xtile != xend; xtile += xinc ) + for (xtile = xstart; xtile != xend; xtile += xinc) { const pen_t *pal = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)]; const UINT8 *code_base = gfx_element_get_data(gfx, (code + code_offset++) % gfx->total_elements); int x_index_base, y_index, sx, sy, ex, ey; - if (flipx) { x_index_base = gfx->width-1; } + if (flipx) { x_index_base = gfx->width - 1; } else { x_index_base = 0; } if (flipy) { y_index = gfx->height-1; } else { y_index = 0; } /* start coordinates */ - sx = offsx + xtile*gfx->width; - sy = offsy + ytile*gfx->height; + sx = offsx + xtile * gfx->width; + sy = offsy + ytile * gfx->height; /* end coordinates */ ex = sx + gfx->width; ey = sy + gfx->height; - if( clip ) + if (clip) { - if( sx < clip->min_x) + if (sx < clip->min_x) { /* clip left */ - int pixels = clip->min_x-sx; + int pixels = clip->min_x - sx; sx += pixels; - x_index_base += xinc*pixels; + x_index_base += xinc * pixels; } - if( sy < clip->min_y ) + if (sy < clip->min_y) { /* clip top */ - int pixels = clip->min_y-sy; + int pixels = clip->min_y - sy; sy += pixels; - y_index += yinc*pixels; + y_index += yinc * pixels; } /* NS 980211 - fixed incorrect clipping */ - if( ex > clip->max_x+1 ) + if (ex > clip->max_x + 1) { /* clip right */ - int pixels = ex-clip->max_x-1; + int pixels = ex - clip->max_x - 1; ex -= pixels; } - if( ey > clip->max_y+1 ) + if (ey > clip->max_y + 1) { /* clip bottom */ - int pixels = ey-clip->max_y-1; + int pixels = ey - clip->max_y - 1; ey -= pixels; } } - if( ex>sx ) + if (ex > sx) { /* skip if inner loop doesn't draw anything */ int y; /* case 1: no alpha */ if (alpha == 0xff) { - if( z > 0 ) + if (z > 0) { - const UINT8 *source = code_base + (y_index)*gfx->line_modulo + x_index_base; - UINT32 *dest = (UINT32 *)dest_bmp->base + sy*dest_bmp->rowpixels + sx; - UINT16 *pri = (UINT16 *)z_bitmap->base + sy*z_bitmap->rowpixels + sx; - int src_modulo = yinc*gfx->line_modulo - xinc*(ex-sx); - int dst_modulo = dest_bmp->rowpixels - (ex-sx); + const UINT8 *source = code_base + (y_index) * gfx->line_modulo + x_index_base; + UINT32 *dest = (UINT32 *)dest_bmp->base + sy * dest_bmp->rowpixels + sx; + UINT16 *pri = (UINT16 *)state->z_bitmap->base + sy * state->z_bitmap->rowpixels + sx; + int src_modulo = yinc * gfx->line_modulo - xinc * (ex - sx); + int dst_modulo = dest_bmp->rowpixels - (ex - sx); - for( y=sy; y<ey; y++ ) + for (y = sy; y < ey; y++) { int x; - for( x=sx; x<ex; x++ ) + for (x = sx; x < ex; x++) { - if(z >= *pri) + if (z >= *pri) { int c = *source; - if( c != 0 ) + if (c != 0) { *dest = pal[c]; *pri = z; @@ -557,18 +572,19 @@ static void psikyosh_drawgfxzoom( } else { - const UINT8 *source = code_base + y_index*gfx->line_modulo + x_index_base; - UINT32 *dest = (UINT32 *)dest_bmp->base + sy*dest_bmp->rowpixels + sx; - int src_modulo = yinc*gfx->line_modulo - xinc*(ex-sx); - int dst_modulo = dest_bmp->rowpixels - (ex-sx); + const UINT8 *source = code_base + y_index * gfx->line_modulo + x_index_base; + UINT32 *dest = (UINT32 *)dest_bmp->base + sy * dest_bmp->rowpixels + sx; + int src_modulo = yinc * gfx->line_modulo - xinc * (ex - sx); + int dst_modulo = dest_bmp->rowpixels - (ex - sx); - for( y=sy; y<ey; y++ ) + for (y = sy; y < ey; y++) { int x; - for( x=sx; x<ex; x++ ) + for (x = sx; x < ex; x++) { int c = *source; - if( c != 0 ) *dest = pal[c]; + if (c != 0) + *dest = pal[c]; dest++; source += xinc; @@ -582,23 +598,23 @@ static void psikyosh_drawgfxzoom( /* case 6: alpha-blended */ else if (alpha >= 0) { - if ( z > 0 ) + if (z > 0) { - const UINT8 *source = code_base + y_index*gfx->line_modulo + x_index_base; - UINT32 *dest = (UINT32 *)dest_bmp->base + sy*dest_bmp->rowpixels + sx; - UINT16 *pri = (UINT16 *)z_bitmap->base + sy*z_bitmap->rowpixels + sx; - int src_modulo = yinc*gfx->line_modulo - xinc*(ex-sx); - int dst_modulo = dest_bmp->rowpixels - (ex-sx); + const UINT8 *source = code_base + y_index * gfx->line_modulo + x_index_base; + UINT32 *dest = (UINT32 *)dest_bmp->base + sy * dest_bmp->rowpixels + sx; + UINT16 *pri = (UINT16 *)state->z_bitmap->base + sy * state->z_bitmap->rowpixels + sx; + int src_modulo = yinc * gfx->line_modulo - xinc * (ex - sx); + int dst_modulo = dest_bmp->rowpixels - (ex - sx); - for( y=sy; y<ey; y++ ) + for (y = sy; y < ey; y++) { int x; - for( x=sx; x<ex; x++ ) + for (x = sx; x < ex; x++) { - if(z >= *pri) + if (z >= *pri) { int c = *source; - if( c != 0 ) + if (c != 0) { *dest = alpha_blend_r32(*dest, pal[c], alpha); *pri = z; @@ -615,18 +631,19 @@ static void psikyosh_drawgfxzoom( } else { - const UINT8 *source = code_base + y_index*gfx->line_modulo + x_index_base; - UINT32 *dest = (UINT32 *)dest_bmp->base + sy*dest_bmp->rowpixels + sx; - int src_modulo = yinc*gfx->line_modulo - xinc*(ex-sx); - int dst_modulo = dest_bmp->rowpixels - (ex-sx); + const UINT8 *source = code_base + y_index * gfx->line_modulo + x_index_base; + UINT32 *dest = (UINT32 *)dest_bmp->base + sy * dest_bmp->rowpixels + sx; + int src_modulo = yinc * gfx->line_modulo - xinc * (ex - sx); + int dst_modulo = dest_bmp->rowpixels - (ex - sx); - for( y=sy; y<ey; y++ ) + for (y = sy; y < ey; y++) { int x; - for( x=sx; x<ex; x++ ) + for (x = sx; x < ex; x++) { int c = *source; - if( c != 0 ) *dest = alpha_blend_r32(*dest, pal[c], alpha); + if (c != 0) + *dest = alpha_blend_r32(*dest, pal[c], alpha); dest++; source += xinc; @@ -641,25 +658,25 @@ static void psikyosh_drawgfxzoom( /* case 7: TRANSPARENCY_ALPHARANGE */ else { - if ( z > 0 ) + if (z > 0) { - const UINT8 *source = code_base + y_index*gfx->line_modulo + x_index_base; - UINT32 *dest = (UINT32 *)dest_bmp->base + sy*dest_bmp->rowpixels + sx; - UINT16 *pri = (UINT16 *)z_bitmap->base + sy*z_bitmap->rowpixels + sx; - int src_modulo = yinc*gfx->line_modulo - xinc*(ex-sx); - int dst_modulo = dest_bmp->rowpixels - (ex-sx); + const UINT8 *source = code_base + y_index * gfx->line_modulo + x_index_base; + UINT32 *dest = (UINT32 *)dest_bmp->base + sy * dest_bmp->rowpixels + sx; + UINT16 *pri = (UINT16 *)state->z_bitmap->base + sy * state->z_bitmap->rowpixels + sx; + int src_modulo = yinc * gfx->line_modulo - xinc * (ex - sx); + int dst_modulo = dest_bmp->rowpixels - (ex - sx); - for( y=sy; y<ey; y++ ) + for (y = sy; y < ey; y++) { int x; - for( x=sx; x<ex; x++ ) + for (x = sx; x < ex; x++) { - if(z >= *pri) + if (z >= *pri) { int c = *source; - if( c != 0 ) + if (c != 0) { - if( alphatable[c] == 0xff ) + if (alphatable[c] == 0xff) *dest = pal[c]; else *dest = alpha_blend_r32(*dest, pal[c], alphatable[c]); @@ -678,20 +695,20 @@ static void psikyosh_drawgfxzoom( } else { - const UINT8 *source = code_base + y_index*gfx->line_modulo + x_index_base; - UINT32 *dest = (UINT32 *)dest_bmp->base + sy*dest_bmp->rowpixels + sx; - int src_modulo = yinc*gfx->line_modulo - xinc*(ex-sx); - int dst_modulo = dest_bmp->rowpixels - (ex-sx); + const UINT8 *source = code_base + y_index * gfx->line_modulo + x_index_base; + UINT32 *dest = (UINT32 *)dest_bmp->base + sy * dest_bmp->rowpixels + sx; + int src_modulo = yinc * gfx->line_modulo - xinc * (ex - sx); + int dst_modulo = dest_bmp->rowpixels - (ex - sx); - for( y=sy; y<ey; y++ ) + for (y = sy; y < ey; y++) { int x; - for( x=sx; x<ex; x++ ) + for (x = sx; x < ex; x++) { int c = *source; - if( c != 0 ) + if (c != 0) { - if( alphatable[c] == 0xff ) + if (alphatable[c] == 0xff) *dest = pal[c]; else *dest = alpha_blend_r32(*dest, pal[c], alphatable[c]); @@ -714,17 +731,17 @@ static void psikyosh_drawgfxzoom( { /* Make a copy of complete sprite at top-left of zoom_bitmap */ /* Because I'm too slow to get it to work on the fly */ - for(ytile=0; ytile<high; ytile++) + for (ytile = 0; ytile < high; ytile++) { - for(xtile=0; xtile<wide; xtile++) + for (xtile = 0; xtile < wide; xtile++) { const UINT8 *code_base = gfx_element_get_data(gfx, (code + code_offset++) % gfx->total_elements); - for( ypixel=0; ypixel<gfx->height; ypixel++ ) + for (ypixel = 0; ypixel < gfx->height; ypixel++) { const UINT8 *source = code_base + ypixel * gfx->line_modulo; - UINT8 *dest = BITMAP_ADDR8(zoom_bitmap, ypixel + ytile*gfx->height, 0); + UINT8 *dest = BITMAP_ADDR8(state->zoom_bitmap, ypixel + ytile*gfx->height, 0); - for( xpixel=0; xpixel<gfx->width; xpixel++ ) + for (xpixel = 0; xpixel < gfx->width; xpixel++) { dest[xpixel + xtile*gfx->width] = source[xpixel]; } @@ -733,12 +750,12 @@ static void psikyosh_drawgfxzoom( } /* Start drawing */ - if( gfx ) + if (gfx) { const pen_t *pal = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)]; - int sprite_screen_height = ((high*gfx->height*(0x400*0x400))/zoomy + 0x200)>>10; /* Round up to nearest pixel */ - int sprite_screen_width = ((wide*gfx->width*(0x400*0x400))/zoomx + 0x200)>>10; + int sprite_screen_height = ((high * gfx->height * (0x400 * 0x400)) / zoomy + 0x200) >> 10; /* Round up to nearest pixel */ + int sprite_screen_width = ((wide * gfx->width * (0x400 * 0x400)) / zoomx + 0x200) >> 10; if (sprite_screen_width && sprite_screen_height) { @@ -755,40 +772,40 @@ static void psikyosh_drawgfxzoom( int dx, dy; - if( flipx ) { x_index_base = (sprite_screen_width-1)*zoomx; dx = -zoomx; } + if (flipx) { x_index_base = (sprite_screen_width - 1) * zoomx; dx = -zoomx; } else { x_index_base = 0; dx = zoomx; } - if( flipy ) { y_index = (sprite_screen_height-1)*zoomy; dy = -zoomy; } + if (flipy) { y_index = (sprite_screen_height - 1) * zoomy; dy = -zoomy; } else { y_index = 0; dy = zoomy; } - if( clip ) + if (clip) { - if( sx < clip->min_x) + if (sx < clip->min_x) { /* clip left */ - int pixels = clip->min_x-sx; + int pixels = clip->min_x - sx; sx += pixels; - x_index_base += pixels*dx; + x_index_base += pixels * dx; } - if( sy < clip->min_y ) + if (sy < clip->min_y) { /* clip top */ - int pixels = clip->min_y-sy; + int pixels = clip->min_y - sy; sy += pixels; - y_index += pixels*dy; + y_index += pixels * dy; } /* NS 980211 - fixed incorrect clipping */ - if( ex > clip->max_x+1 ) + if (ex > clip->max_x + 1) { /* clip right */ - int pixels = ex-clip->max_x-1; + int pixels = ex-clip->max_x - 1; ex -= pixels; } - if( ey > clip->max_y+1 ) + if (ey > clip->max_y + 1) { /* clip bottom */ - int pixels = ey-clip->max_y-1; + int pixels = ey-clip->max_y - 1; ey -= pixels; } } - if( ex>sx ) + if (ex > sx) { /* skip if inner loop doesn't draw anything */ int y; @@ -796,21 +813,21 @@ static void psikyosh_drawgfxzoom( /* Note: adjusted to >>10 and draws from zoom_bitmap not gfx */ if (alpha == 0xff) { - if( z > 0 ) + if (z > 0) { - for( y=sy; y<ey; y++ ) + for (y = sy; y < ey; y++) { - UINT8 *source = BITMAP_ADDR8(zoom_bitmap, y_index>>10, 0); + UINT8 *source = BITMAP_ADDR8(state->zoom_bitmap, y_index >> 10, 0); UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0); - UINT16 *pri = BITMAP_ADDR16(z_bitmap, y, 0); + UINT16 *pri = BITMAP_ADDR16(state->z_bitmap, y, 0); int x, x_index = x_index_base; - for( x=sx; x<ex; x++ ) + for (x = sx; x < ex; x++) { - if(z >= pri[x]) + if (z >= pri[x]) { - int c = source[x_index>>10]; - if( c != 0 ) + int c = source[x_index >> 10]; + if (c != 0) { dest[x] = pal[c]; pri[x] = z; @@ -824,16 +841,17 @@ static void psikyosh_drawgfxzoom( } else { - for( y=sy; y<ey; y++ ) + for (y = sy; y < ey; y++) { - UINT8 *source = BITMAP_ADDR8(zoom_bitmap, y_index>>10, 0); + UINT8 *source = BITMAP_ADDR8(state->zoom_bitmap, y_index >> 10, 0); UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0); int x, x_index = x_index_base; - for( x=sx; x<ex; x++ ) + for (x = sx; x < ex; x++) { - int c = source[x_index>>10]; - if( c != 0 ) dest[x] = pal[c]; + int c = source[x_index >> 10]; + if (c != 0) + dest[x] = pal[c]; x_index += dx; } @@ -845,21 +863,21 @@ static void psikyosh_drawgfxzoom( /* case 6: alpha-blended */ else if (alpha >= 0) { - if( z > 0 ) + if (z > 0) { - for( y=sy; y<ey; y++ ) + for (y = sy; y < ey; y++) { - UINT8 *source = BITMAP_ADDR8(zoom_bitmap, y_index>>10, 0); + UINT8 *source = BITMAP_ADDR8(state->zoom_bitmap, y_index >> 10, 0); UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0); - UINT16 *pri = BITMAP_ADDR16(z_bitmap, y, 0); + UINT16 *pri = BITMAP_ADDR16(state->z_bitmap, y, 0); int x, x_index = x_index_base; - for( x=sx; x<ex; x++ ) + for (x = sx; x < ex; x++) { - if(z >= pri[x]) + if (z >= pri[x]) { - int c = source[x_index>>10]; - if( c != 0 ) + int c = source[x_index >> 10]; + if (c != 0) { dest[x] = alpha_blend_r32(dest[x], pal[c], alpha); pri[x] = z; @@ -873,16 +891,16 @@ static void psikyosh_drawgfxzoom( } else { - for( y=sy; y<ey; y++ ) + for (y = sy; y < ey; y++) { - UINT8 *source = BITMAP_ADDR8(zoom_bitmap, y_index>>10, 0); + UINT8 *source = BITMAP_ADDR8(state->zoom_bitmap, y_index >> 10, 0); UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0); int x, x_index = x_index_base; - for( x=sx; x<ex; x++ ) + for (x = sx; x < ex; x++) { - int c = source[x_index>>10]; - if( c != 0 ) dest[x] = alpha_blend_r32(dest[x], pal[c], alpha); + int c = source[x_index >> 10]; + if (c != 0) dest[x] = alpha_blend_r32(dest[x], pal[c], alpha); x_index += dx; } @@ -894,23 +912,23 @@ static void psikyosh_drawgfxzoom( /* case 7: TRANSPARENCY_ALPHARANGE */ else { - if( z > 0 ) + if (z > 0) { - for( y=sy; y<ey; y++ ) + for (y = sy; y < ey; y++) { - UINT8 *source = BITMAP_ADDR8(zoom_bitmap, y_index>>10, 0); + UINT8 *source = BITMAP_ADDR8(state->zoom_bitmap, y_index >> 10, 0); UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0); - UINT16 *pri = BITMAP_ADDR16(z_bitmap, y, 0); + UINT16 *pri = BITMAP_ADDR16(state->z_bitmap, y, 0); int x, x_index = x_index_base; - for( x=sx; x<ex; x++ ) + for (x = sx; x < ex; x++) { - if(z >= pri[x]) + if (z >= pri[x]) { - int c = source[x_index>>10]; - if( c != 0 ) + int c = source[x_index >> 10]; + if (c != 0) { - if( alphatable[c] == 0xff ) + if (alphatable[c] == 0xff) dest[x] = pal[c]; else dest[x] = alpha_blend_r32(dest[x], pal[c], alphatable[c]); @@ -926,18 +944,18 @@ static void psikyosh_drawgfxzoom( } else { - for( y=sy; y<ey; y++ ) + for (y = sy; y < ey; y++) { - UINT8 *source = BITMAP_ADDR8(zoom_bitmap, y_index>>10, 0); + UINT8 *source = BITMAP_ADDR8(state->zoom_bitmap, y_index >> 10, 0); UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0); int x, x_index = x_index_base; - for( x=sx; x<ex; x++ ) + for (x = sx; x < ex; x++) { - int c = source[x_index>>10]; - if( c != 0 ) + int c = source[x_index >> 10]; + if (c != 0) { - if( alphatable[c] == 0xff ) + if (alphatable[c] == 0xff) dest[x] = pal[c]; else dest[x] = alpha_blend_r32(dest[x], pal[c], alphatable[c]); @@ -956,7 +974,7 @@ static void psikyosh_drawgfxzoom( profiler_mark_end(); } -#define SPRITE_PRI(n) (((psikyosh_vidregs[2] << (4*n)) & 0xf0000000 ) >> 28) +#define SPRITE_PRI(n) (((state->vidregs[2] << (4*n)) & 0xf0000000 ) >> 28) static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8 req_pri ) { @@ -990,14 +1008,15 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta **- End Sprite Format -*/ + psikyosh_state *state = (psikyosh_state *)machine->driver_data; const gfx_element *gfx; UINT32 *src = machine->generic.buffered_spriteram.u32; /* Use buffered spriteram */ - UINT16 *list = (UINT16 *)src + 0x3800/2; - UINT16 listlen=0x800/2, listcntr=0; - UINT16 *zoom_table = (UINT16 *)psikyosh_zoomram; - UINT8 *alpha_table = (UINT8 *)psikyosh_vidregs; + UINT16 *list = (UINT16 *)src + 0x3800 / 2; + UINT16 listlen = 0x800/2, listcntr = 0; + UINT16 *zoom_table = (UINT16 *)state->zoomram; + UINT8 *alpha_table = (UINT8 *)state->vidregs; - while( listcntr < listlen ) + while (listcntr < listlen) { UINT32 listdat, sprnum, xpos, ypos, high, wide, flpx, flpy, zoomx, zoomy, tnum, colr, dpth; UINT32 pri, alphamap; @@ -1006,47 +1025,46 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta listdat = list[BYTE_XOR_BE(listcntr)]; sprnum = (listdat & 0x03ff) * 4; - pri = (src[sprnum+1] & 0x00003000) >> 12; // & 0x00007000/0x00003000 ? + pri = (src[sprnum + 1] & 0x00003000) >> 12; // & 0x00007000/0x00003000 ? pri = SPRITE_PRI(pri); - if(pri == req_pri) + if (pri == req_pri) { - ypos = (src[sprnum+0] & 0x03ff0000) >> 16; - xpos = (src[sprnum+0] & 0x000003ff) >> 00; + ypos = (src[sprnum + 0] & 0x03ff0000) >> 16; + xpos = (src[sprnum + 0] & 0x000003ff) >> 00; - if(ypos & 0x200) ypos -= 0x400; - if(xpos & 0x200) xpos -= 0x400; + if (ypos & 0x200) ypos -= 0x400; + if (xpos & 0x200) xpos -= 0x400; - high = ((src[sprnum+1] & 0x0f000000) >> 24) + 1; - wide = ((src[sprnum+1] & 0x00000f00) >> 8) + 1; + high = ((src[sprnum + 1] & 0x0f000000) >> 24) + 1; + wide = ((src[sprnum + 1] & 0x00000f00) >> 8) + 1; - flpy = (src[sprnum+1] & 0x80000000) >> 31; - flpx = (src[sprnum+1] & 0x00008000) >> 15; + flpy = (src[sprnum + 1] & 0x80000000) >> 31; + flpx = (src[sprnum + 1] & 0x00008000) >> 15; - zoomy = (src[sprnum+1] & 0x00ff0000) >> 16; - zoomx = (src[sprnum+1] & 0x000000ff) >> 00; + zoomy = (src[sprnum + 1] & 0x00ff0000) >> 16; + zoomx = (src[sprnum + 1] & 0x000000ff) >> 00; - tnum = (src[sprnum+2] & 0x0007ffff) >> 00; - dpth = (src[sprnum+2] & 0x00800000) >> 23; - colr = (src[sprnum+2] & 0xff000000) >> 24; + tnum = (src[sprnum + 2] & 0x0007ffff) >> 00; + dpth = (src[sprnum + 2] & 0x00800000) >> 23; + colr = (src[sprnum + 2] & 0xff000000) >> 24; - alpha = (src[sprnum+2] & 0x00700000) >> 20; + alpha = (src[sprnum + 2] & 0x00700000) >> 20; alphamap = (alpha_table[BYTE4_XOR_BE(alpha)] & 0x80)? 1:0; alpha = alpha_table[BYTE4_XOR_BE(alpha)] & 0x3f; gfx = dpth ? machine->gfx[1] : machine->gfx[0]; - if(alphamap) { /* alpha values are per-pen */ + if (alphamap) /* alpha values are per-pen */ alpha = -1; - } else { - alpha = ((0x3f-alpha)*0xff)/0x3f; /* 0x3f-0x00 maps to 0x00-0xff */ - } + else + alpha = ((0x3f - alpha) * 0xff) / 0x3f; /* 0x3f-0x00 maps to 0x00-0xff */ /* start drawing */ - if( zoom_table[BYTE_XOR_BE(zoomy)] && zoom_table[BYTE_XOR_BE(zoomx)] ) /* Avoid division-by-zero when table contains 0 (Uninitialised/Bug) */ + if (zoom_table[BYTE_XOR_BE(zoomy)] && zoom_table[BYTE_XOR_BE(zoomx)]) /* Avoid division-by-zero when table contains 0 (Uninitialised/Bug) */ { - psikyosh_drawgfxzoom(bitmap,cliprect,gfx,tnum,colr,flpx,flpy,xpos,ypos,alpha, + psikyosh_drawgfxzoom(machine, bitmap, cliprect, gfx, tnum, colr, flpx, flpy, xpos, ypos, alpha, (UINT32)zoom_table[BYTE_XOR_BE(zoomx)], (UINT32)zoom_table[BYTE_XOR_BE(zoomy)], wide, high, listcntr); #if 0 @@ -1057,11 +1075,13 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta int x, y; sprintf(buf, "%X",xdim/16); /* Display Zoom in 16.16 */ - if (machine->gamedrv->flags & ORIENTATION_SWAP_XY) { + if (machine->gamedrv->flags & ORIENTATION_SWAP_XY) + { x = ypos; y = video_screen_get_visible_area(machine->primary_screen)->max_x - xpos; /* ORIENTATION_FLIP_Y */ } - else { + else + { x = xpos; y = ypos; } @@ -1079,36 +1099,41 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta VIDEO_START( psikyosh ) { + psikyosh_state *state = (psikyosh_state *)machine->driver_data; int width = video_screen_get_width(machine->primary_screen); int height = video_screen_get_height(machine->primary_screen); - z_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); + state->z_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16); /* Need 16-bit z-buffer */ - zoom_bitmap = auto_bitmap_alloc(machine, 16*16, 16*16, BITMAP_FORMAT_INDEXED8); + state->zoom_bitmap = auto_bitmap_alloc(machine, 16*16, 16*16, BITMAP_FORMAT_INDEXED8); - machine->gfx[1]->color_granularity=16; /* 256 colour sprites with palette selectable on 16 colour boundaries */ + machine->gfx[1]->color_granularity = 16; /* 256 colour sprites with palette selectable on 16 colour boundaries */ { /* Pens 0xc0-0xff have a gradient of alpha values associated with them */ int i; - for (i=0; i<0xc0; i++) + for (i = 0; i < 0xc0; i++) alphatable[i] = 0xff; - for (i=0; i<0x40; i++) { - int alpha = ((0x3f-i)*0xff)/0x3f; - alphatable[i+0xc0] = alpha; + for (i = 0; i < 0x40; i++) + { + int alpha = ((0x3f - i) * 0xff) / 0x3f; + alphatable[i + 0xc0] = alpha; } } + state_save_register_global_bitmap(machine, state->z_bitmap); + state_save_register_global_bitmap(machine, state->zoom_bitmap); } -static void psikyosh_prelineblend( bitmap_t *bitmap, const rectangle *cliprect ) +static void psikyosh_prelineblend( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ) { /* There are 224 values for pre-lineblending. Using one for every row currently */ /* I suspect that it should be blended against black by the amount specified as gnbarich sets the 0x000000ff to 0x7f in test mode whilst the others use 0x80. As it's only used in testmode I'll just leave it as a toggle for now */ + psikyosh_state *state = (psikyosh_state *)machine->driver_data; UINT32 *dstline; - UINT32 *linefill = psikyosh_bgram; /* Per row */ - int x,y; + UINT32 *linefill = state->bgram; /* Per row */ + int x, y; assert(bitmap->bpp == 32); @@ -1117,19 +1142,20 @@ static void psikyosh_prelineblend( bitmap_t *bitmap, const rectangle *cliprect ) dstline = BITMAP_ADDR32(bitmap, y, 0); - if(linefill[y]&0xff) /* Row */ + if (linefill[y] & 0xff) /* Row */ for (x = cliprect->min_x; x <= cliprect->max_x; x += 1) - dstline[x] = linefill[y]>>8; + dstline[x] = linefill[y] >> 8; } profiler_mark_end(); } -static void psikyosh_postlineblend( bitmap_t *bitmap, const rectangle *cliprect ) +static void psikyosh_postlineblend( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ) { /* There are 224 values for post-lineblending. Using one for every row currently */ + psikyosh_state *state = (psikyosh_state *)machine->driver_data; UINT32 *dstline; - UINT32 *lineblend = psikyosh_bgram+0x400/4; /* Per row */ - int x,y; + UINT32 *lineblend = state->bgram + 0x400 / 4; /* Per row */ + int x, y; assert(bitmap->bpp == 32); @@ -1138,15 +1164,15 @@ static void psikyosh_postlineblend( bitmap_t *bitmap, const rectangle *cliprect dstline = BITMAP_ADDR32(bitmap, y, 0); - if(lineblend[y]&0x80) /* Row */ + if (lineblend[y] & 0x80) /* Row */ { for (x = cliprect->min_x; x <= cliprect->max_x; x += 1) - dstline[x] = lineblend[y]>>8; + dstline[x] = lineblend[y] >> 8; } - else if(lineblend[y]&0x7f) /* Row */ + else if (lineblend[y] & 0x7f) /* Row */ { for (x = cliprect->min_x; x <= cliprect->max_x; x += 1) - dstline[x] = alpha_blend_r32(dstline[x], lineblend[y]>>8, 2*(lineblend[y]&0x7f)); + dstline[x] = alpha_blend_r32(dstline[x], lineblend[y] >> 8, 2 * (lineblend[y] & 0x7f)); } } profiler_mark_end(); @@ -1154,17 +1180,21 @@ static void psikyosh_postlineblend( bitmap_t *bitmap, const rectangle *cliprect VIDEO_UPDATE( psikyosh ) /* Note the z-buffer on each sprite to get correct priority */ { - int i; - bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine)); - bitmap_fill(z_bitmap,cliprect,0); /* z-buffer */ + psikyosh_state *state = (psikyosh_state *)screen->machine->driver_data; + int i; - psikyosh_prelineblend(bitmap, cliprect); + bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine)); + bitmap_fill(state->z_bitmap, cliprect, 0); /* z-buffer */ - for (i=0; i<=7; i++) { + psikyosh_prelineblend(screen->machine, bitmap, cliprect); + + for (i = 0; i <= 7; i++) + { draw_sprites(screen->machine, bitmap, cliprect, i); // When same priority bg's have higher pri draw_background(screen->machine, bitmap, cliprect, i); - if((psikyosh_vidregs[2]&0xf) == i) psikyosh_postlineblend(bitmap, cliprect); - } + if ((state->vidregs[2] & 0xf) == i) + psikyosh_postlineblend(screen->machine, bitmap, cliprect); + } return 0; } @@ -1172,17 +1202,17 @@ VIDEO_EOF( psikyosh ) { const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); - buffer_spriteram32_w(space,0,0,0xffffffff); + buffer_spriteram32_w(space, 0, 0, 0xffffffff); } /*popmessage ("Regs %08x %08x %08x\n %08x %08x %08x", - psikyosh_bgram[0x17f0/4], psikyosh_bgram[0x17f4/4], psikyosh_bgram[0x17f8/4], - psikyosh_bgram[0x1ff0/4], psikyosh_bgram[0x1ff4/4], psikyosh_bgram[0x1ff8/4]);*/ + state->bgram[0x17f0 / 4], state->bgram[0x17f4 / 4], state->bgram[0x17f8 / 4], + state->bgram[0x1ff0 / 4], state->bgram[0x1ff4 / 4], state->bgram[0x1ff8 / 4]);*/ /*popmessage ("Regs %08x %08x %08x\n %08x %08x %08x", - psikyosh_bgram[0x13f0/4], psikyosh_bgram[0x13f4/4], psikyosh_bgram[0x13f8/4], - psikyosh_bgram[0x1bf0/4], psikyosh_bgram[0x1bf4/4], psikyosh_bgram[0x1bf8/4]);*/ + state->bgram[0x13f0 / 4], state->bgram[0x13f4 / 4], state->bgram[0x13f8 / 4], + state->bgram[0x1bf0 / 4], state->bgram[0x1bf4 / 4], state->bgram[0x1bf8 / 4]);*/ /*popmessage ("Regs %08x %08x %08x %08x %08x %08x %08x %08x", - psikyosh_vidregs[0], psikyosh_vidregs[1], - psikyosh_vidregs[2], psikyosh_vidregs[3], - psikyosh_vidregs[4], psikyosh_vidregs[5], - psikyosh_vidregs[6], psikyosh_vidregs[7]);*/ + state->vidregs[0], state->vidregs[1], + state->vidregs[2], state->vidregs[3], + state->vidregs[4], state->vidregs[5], + state->vidregs[6], state->vidregs[7]);*/ |
