diff --git a/.gitattributes b/.gitattributes index 4ed0a9c55e1..b1ea27ee23c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5527,8 +5527,14 @@ src/mame/video/jedi.c svneol=native#text/plain src/mame/video/jpmimpct.c svneol=native#text/plain src/mame/video/k05324x.c svneol=native#text/plain src/mame/video/k05324x.h svneol=native#text/plain +src/mame/video/k053936.c svneol=native#text/plain +src/mame/video/k053936.h svneol=native#text/plain +src/mame/video/k054000.c svneol=native#text/plain +src/mame/video/k054000.h svneol=native#text/plain src/mame/video/k054156_k054157_k056832.c svneol=native#text/plain src/mame/video/k054156_k054157_k056832.h svneol=native#text/plain +src/mame/video/k054338.c svneol=native#text/plain +src/mame/video/k054338.h svneol=native#text/plain src/mame/video/k055555.c svneol=native#text/plain src/mame/video/k055555.h svneol=native#text/plain src/mame/video/kan_panb.c svneol=native#text/plain @@ -5552,8 +5558,6 @@ src/mame/video/kncljoe.c svneol=native#text/plain src/mame/video/konami_helper.c svneol=native#text/plain src/mame/video/konami_helper.h svneol=native#text/plain src/mame/video/konamigx.c svneol=native#text/plain -src/mame/video/konamiic.c svneol=native#text/plain -src/mame/video/konamiic.h svneol=native#text/plain src/mame/video/konicdev.c svneol=native#text/plain src/mame/video/konicdev.h svneol=native#text/plain src/mame/video/kopunch.c svneol=native#text/plain diff --git a/src/mame/drivers/konamigx.c b/src/mame/drivers/konamigx.c index 9cd07a1dcbe..962eea61011 100644 --- a/src/mame/drivers/konamigx.c +++ b/src/mame/drivers/konamigx.c @@ -102,7 +102,6 @@ #include "sound/k054539.h" #include "includes/konamigx.h" #include "machine/adc083x.h" -#include "video/konamiic.h" #include "rendlay.h" #define GX_DEBUG 0 diff --git a/src/mame/drivers/mystwarr.c b/src/mame/drivers/mystwarr.c index 192ff19ca2c..14cbf33e8a5 100644 --- a/src/mame/drivers/mystwarr.c +++ b/src/mame/drivers/mystwarr.c @@ -22,7 +22,6 @@ */ #include "emu.h" -#include "video/konamiic.h" #include "video/k053250.h" #include "includes/konamigx.h" #include "cpu/m68000/m68000.h" diff --git a/src/mame/includes/konamigx.h b/src/mame/includes/konamigx.h index 719218ba6da..b372ad4617c 100644 --- a/src/mame/includes/konamigx.h +++ b/src/mame/includes/konamigx.h @@ -3,7 +3,8 @@ #include "video/k054156_k054157_k056832.h" #include "video/k05324x.h" #include "video/k055555.h" - +#include "video/k054338.h" +#include "video/k053936.h" class konamigx_state : public driver_device { diff --git a/src/mame/includes/mystwarr.h b/src/mame/includes/mystwarr.h index 27417816b54..b51895b97b3 100644 --- a/src/mame/includes/mystwarr.h +++ b/src/mame/includes/mystwarr.h @@ -1,6 +1,7 @@ #include "sound/k054539.h" #include "machine/k053252.h" #include "video/k055555.h" +#include "video/k054000.h" class mystwarr_state : public konamigx_state { diff --git a/src/mame/machine/konamigx.c b/src/mame/machine/konamigx.c index 96e37d29303..19baeae382b 100644 --- a/src/mame/machine/konamigx.c +++ b/src/mame/machine/konamigx.c @@ -5,7 +5,6 @@ */ #include "emu.h" -#include "video/konamiic.h" #include "includes/konamigx.h" /***************************************************************************/ diff --git a/src/mame/mame.mak b/src/mame/mame.mak index c25386bf828..3fe5ed22612 100644 --- a/src/mame/mame.mak +++ b/src/mame/mame.mak @@ -1225,7 +1225,10 @@ $(MAMEOBJ)/konami.a: \ $(VIDEO)/k054156_k054157_k056832.o \ $(VIDEO)/k05324x.o \ $(VIDEO)/k055555.o \ - $(VIDEO)/konamiic.o $(VIDEO)/konicdev.o \ + $(VIDEO)/k054000.o \ + $(VIDEO)/k054338.o \ + $(VIDEO)/k053936.o \ + $(VIDEO)/konicdev.o \ $(MAMEOBJ)/maygay.a: \ $(DRIVERS)/maygay1b.o \ diff --git a/src/mame/video/k05324x.h b/src/mame/video/k05324x.h index fba790f59ce..291888029c9 100644 --- a/src/mame/video/k05324x.h +++ b/src/mame/video/k05324x.h @@ -216,11 +216,7 @@ void K053246_set_OBJCHA_line(int state); int K053246_is_IRQ_enabled(void); int K053246_read_register(int regnum); -extern UINT16 *K053936_0_ctrl,*K053936_0_linectrl; -//extern UINT16 *K053936_1_ctrl,*K053936_1_linectrl; -void K053936_0_zoom_draw(bitmap_ind16 &bitmap,const rectangle &cliprect,tilemap_t *tmap,int flags,UINT32 priority, int glfgreat_hack); -void K053936_wraparound_enable(int chip, int status); -void K053936_set_offset(int chip, int xoffs, int yoffs); + diff --git a/src/mame/video/k053936.c b/src/mame/video/k053936.c new file mode 100644 index 00000000000..3c568b29e33 --- /dev/null +++ b/src/mame/video/k053936.c @@ -0,0 +1,166 @@ +/* */ + +#include "emu.h" +#include "k053936.h" + +#define VERBOSE 0 +#define LOG(x) do { if (VERBOSE) logerror x; } while (0) + + + +/***************************************************************************/ +/* */ +/* 053936 */ +/* */ +/***************************************************************************/ + +#define K053936_MAX_CHIPS 2 + +static int K053936_offset[K053936_MAX_CHIPS][2]; +static int K053936_wraparound[K053936_MAX_CHIPS]; + +// there is another implementation of this in machine/konamigx.c (!) +// why? + +static void K053936_zoom_draw(int chip,UINT16 *ctrl,UINT16 *linectrl, bitmap_ind16 &bitmap,const rectangle &cliprect,tilemap_t *tmap,int flags,UINT32 priority, int glfgreat_hack) +{ + if (!tmap) + return; + + if (ctrl[0x07] & 0x0040) + { + UINT32 startx,starty; + int incxx,incxy; + rectangle my_clip; + int y,maxy; + + // Racin' Force will get to here if glfgreat_hack is enabled, and it ends + // up setting a maximum y value of '13', thus causing nothing to be drawn. + // It looks like the roz output should be flipped somehow as it seems to be + // displaying the wrong areas of the tilemap and is rendered upside down, + // although due to the additional post-processing the voxel renderer performs + // it's difficult to know what the output SHOULD be. (hold W in Racin' Force + // to see the chip output) + + if (((ctrl[0x07] & 0x0002) && ctrl[0x09]) && (glfgreat_hack)) /* wrong, but fixes glfgreat */ + { + my_clip.min_x = ctrl[0x08] + K053936_offset[chip][0]+2; + my_clip.max_x = ctrl[0x09] + K053936_offset[chip][0]+2 - 1; + if (my_clip.min_x < cliprect.min_x) + my_clip.min_x = cliprect.min_x; + if (my_clip.max_x > cliprect.max_x) + my_clip.max_x = cliprect.max_x; + + y = ctrl[0x0a] + K053936_offset[chip][1]-2; + if (y < cliprect.min_y) + y = cliprect.min_y; + maxy = ctrl[0x0b] + K053936_offset[chip][1]-2 - 1; + if (maxy > cliprect.max_y) + maxy = cliprect.max_y; + } + else + { + my_clip.min_x = cliprect.min_x; + my_clip.max_x = cliprect.max_x; + + y = cliprect.min_y; + maxy = cliprect.max_y; + } + + while (y <= maxy) + { + UINT16 *lineaddr = linectrl + 4*((y - K053936_offset[chip][1]) & 0x1ff); + my_clip.min_y = my_clip.max_y = y; + + + + startx = 256 * (INT16)(lineaddr[0] + ctrl[0x00]); + starty = 256 * (INT16)(lineaddr[1] + ctrl[0x01]); + incxx = (INT16)(lineaddr[2]); + incxy = (INT16)(lineaddr[3]); + + if (ctrl[0x06] & 0x8000) incxx *= 256; + if (ctrl[0x06] & 0x0080) incxy *= 256; + + startx -= K053936_offset[chip][0] * incxx; + starty -= K053936_offset[chip][0] * incxy; + + tmap->draw_roz(bitmap, my_clip, startx << 5,starty << 5, + incxx << 5,incxy << 5,0,0, + K053936_wraparound[chip], + flags,priority); + + y++; + } + } + else /* "simple" mode */ + { + UINT32 startx,starty; + int incxx,incxy,incyx,incyy; + + startx = 256 * (INT16)(ctrl[0x00]); + starty = 256 * (INT16)(ctrl[0x01]); + incyx = (INT16)(ctrl[0x02]); + incyy = (INT16)(ctrl[0x03]); + incxx = (INT16)(ctrl[0x04]); + incxy = (INT16)(ctrl[0x05]); + + if (ctrl[0x06] & 0x4000) { incyx *= 256; incyy *= 256; } + if (ctrl[0x06] & 0x0040) { incxx *= 256; incxy *= 256; } + + startx -= K053936_offset[chip][1] * incyx; + starty -= K053936_offset[chip][1] * incyy; + + startx -= K053936_offset[chip][0] * incxx; + starty -= K053936_offset[chip][0] * incxy; + + tmap->draw_roz(bitmap, cliprect, startx << 5,starty << 5, + incxx << 5,incxy << 5,incyx << 5,incyy << 5, + K053936_wraparound[chip], + flags,priority); + } + +#if 0 +if (machine.input().code_pressed(KEYCODE_D)) + popmessage("%04x %04x %04x %04x\n%04x %04x %04x %04x\n%04x %04x %04x %04x\n%04x %04x %04x %04x", + ctrl[0x00], + ctrl[0x01], + ctrl[0x02], + ctrl[0x03], + ctrl[0x04], + ctrl[0x05], + ctrl[0x06], + ctrl[0x07], + ctrl[0x08], + ctrl[0x09], + ctrl[0x0a], + ctrl[0x0b], + ctrl[0x0c], + ctrl[0x0d], + ctrl[0x0e], + ctrl[0x0f]); +#endif +} + + +void K053936_0_zoom_draw(bitmap_ind16 &bitmap,const rectangle &cliprect,tilemap_t *tmap,int flags,UINT32 priority, int glfgreat_hack) +{ + UINT16 *ctrl = reinterpret_cast(tmap->machine().root_device().memshare("k053936_0_ctrl")->ptr()); + UINT16 *linectrl = reinterpret_cast(tmap->machine().root_device().memshare("k053936_0_line")->ptr()); + K053936_zoom_draw(0,ctrl,linectrl,bitmap,cliprect,tmap,flags,priority, glfgreat_hack); +} + +void K053936_wraparound_enable(int chip, int status) +{ + K053936_wraparound[chip] = status; +} + + +void K053936_set_offset(int chip, int xoffs, int yoffs) +{ + K053936_offset[chip][0] = xoffs; + K053936_offset[chip][1] = yoffs; +} + + + diff --git a/src/mame/video/k053936.h b/src/mame/video/k053936.h new file mode 100644 index 00000000000..f87a50e0682 --- /dev/null +++ b/src/mame/video/k053936.h @@ -0,0 +1,18 @@ +#pragma once +#ifndef __K053936_H__ +#define __K053936_H__ + + +/* */ + + + + + +extern UINT16 *K053936_0_ctrl,*K053936_0_linectrl; +//extern UINT16 *K053936_1_ctrl,*K053936_1_linectrl; +void K053936_0_zoom_draw(bitmap_ind16 &bitmap,const rectangle &cliprect,tilemap_t *tmap,int flags,UINT32 priority, int glfgreat_hack); +void K053936_wraparound_enable(int chip, int status); +void K053936_set_offset(int chip, int xoffs, int yoffs); + +#endif diff --git a/src/mame/video/k054000.c b/src/mame/video/k054000.c new file mode 100644 index 00000000000..d81ae9189fe --- /dev/null +++ b/src/mame/video/k054000.c @@ -0,0 +1,74 @@ + +#include "emu.h" +#include "k054000.h" + + +#define VERBOSE 0 +#define LOG(x) do { if (VERBOSE) logerror x; } while (0) + +/***************************************************************************/ +/* */ +/* 054000 */ +/* */ +/***************************************************************************/ + +static UINT8 K054000_ram[0x20]; + +static WRITE8_HANDLER( K054000_w ) +{ +//logerror("%04x: write %02x to 054000 address %02x\n",space.device().safe_pc(),data,offset); + + K054000_ram[offset] = data; +} + +static READ8_HANDLER( K054000_r ) +{ + int Acx,Acy,Aax,Aay; + int Bcx,Bcy,Bax,Bay; + +//logerror("%04x: read 054000 address %02x\n",space.device().safe_pc(),offset); + + if (offset != 0x18) return 0; + + Acx = (K054000_ram[0x01] << 16) | (K054000_ram[0x02] << 8) | K054000_ram[0x03]; + Acy = (K054000_ram[0x09] << 16) | (K054000_ram[0x0a] << 8) | K054000_ram[0x0b]; +/* TODO: this is a hack to make thndrx2 pass the startup check. It is certainly wrong. */ +if (K054000_ram[0x04] == 0xff) Acx+=3; +if (K054000_ram[0x0c] == 0xff) Acy+=3; + Aax = K054000_ram[0x06] + 1; + Aay = K054000_ram[0x07] + 1; + + Bcx = (K054000_ram[0x15] << 16) | (K054000_ram[0x16] << 8) | K054000_ram[0x17]; + Bcy = (K054000_ram[0x11] << 16) | (K054000_ram[0x12] << 8) | K054000_ram[0x13]; + Bax = K054000_ram[0x0e] + 1; + Bay = K054000_ram[0x0f] + 1; + + if (Acx + Aax < Bcx - Bax) + return 1; + + if (Bcx + Bax < Acx - Aax) + return 1; + + if (Acy + Aay < Bcy - Bay) + return 1; + + if (Bcy + Bay < Acy - Aay) + return 1; + + return 0; +} + +READ16_HANDLER( K054000_lsb_r ) +{ + return K054000_r(space, offset, mem_mask & 0xff); +} + +WRITE16_HANDLER( K054000_lsb_w ) +{ + if (ACCESSING_BITS_0_7) + K054000_w(space, offset, data & 0xff, mem_mask & 0xff); +} + + + + diff --git a/src/mame/video/k054000.h b/src/mame/video/k054000.h new file mode 100644 index 00000000000..ca4a3266090 --- /dev/null +++ b/src/mame/video/k054000.h @@ -0,0 +1,10 @@ + +#pragma once +#ifndef __K054000_H__ +#define __K054000_H__ + + +DECLARE_WRITE16_HANDLER( K054000_lsb_w ); +DECLARE_READ16_HANDLER( K054000_lsb_r ); + +#endif diff --git a/src/mame/video/k054338.c b/src/mame/video/k054338.c new file mode 100644 index 00000000000..947febe0cac --- /dev/null +++ b/src/mame/video/k054338.c @@ -0,0 +1,215 @@ + +#include "emu.h" +#include "k054338.h" +#include "k055555.h" + + +#define VERBOSE 0 +#define LOG(x) do { if (VERBOSE) logerror x; } while (0) + +/***************************************************************************/ +/* */ +/* 054338 */ +/* */ +/***************************************************************************/ + +static UINT16 k54338_regs[32]; +static int K054338_shdRGB[9]; +static int K054338_alphainverted; + + +// K054338 alpha blend / final mixer (normally used with the 55555) +// because the implementation is video dependant, this is just a +// register-handling shell. +void K054338_vh_start(running_machine &machine) +{ + memset(k54338_regs, 0, sizeof(UINT16)*32); + memset(K054338_shdRGB, 0, sizeof(int)*9); + K054338_alphainverted = 1; + + machine.save().save_item(NAME(k54338_regs)); +} + +WRITE16_HANDLER( K054338_word_w ) +{ + COMBINE_DATA(k54338_regs + offset); +} + +WRITE32_HANDLER( K054338_long_w ) +{ + offset <<= 1; + K054338_word_w(space, offset, data>>16, mem_mask>>16); + K054338_word_w(space, offset+1, data, mem_mask); +} + +// returns a 16-bit '338 register +int K054338_read_register(int reg) +{ + return k54338_regs[reg]; +} + +void K054338_update_all_shadows(running_machine &machine, int rushingheroes_hack) +{ + int i, d; + int noclip = k54338_regs[K338_REG_CONTROL] & K338_CTL_CLIPSL; + + for (i=0; i<9; i++) + { + d = k54338_regs[K338_REG_SHAD1R+i] & 0x1ff; + if (d >= 0x100) d -= 0x200; + K054338_shdRGB[i] = d; + } + + if (!rushingheroes_hack) + { + palette_set_shadow_dRGB32(machine, 0, K054338_shdRGB[0], K054338_shdRGB[1], K054338_shdRGB[2], noclip); + palette_set_shadow_dRGB32(machine, 1, K054338_shdRGB[3], K054338_shdRGB[4], K054338_shdRGB[5], noclip); + palette_set_shadow_dRGB32(machine, 2, K054338_shdRGB[6], K054338_shdRGB[7], K054338_shdRGB[8], noclip); + } + else // rushing heroes seems to specify shadows in another format, or it's not being interpreted properly. + { + palette_set_shadow_dRGB32(machine, 0, -80, -80, -80, 0); + palette_set_shadow_dRGB32(machine, 1, -80, -80, -80, 0); + palette_set_shadow_dRGB32(machine, 2, -80, -80, -80, 0); + } +} + +// Unified K054338/K055555 BG color fill +void K054338_fill_backcolor(running_machine &machine, bitmap_rgb32 &bitmap, int mode) // (see p.67) +{ + int clipx, clipy, clipw, cliph, i, dst_pitch; + int BGC_CBLK, BGC_SET; + UINT32 *dst_ptr, *pal_ptr; + int bgcolor; + const rectangle &visarea = machine.primary_screen->visible_area(); + driver_device *state = machine.driver_data(); + + clipx = visarea.min_x & ~3; + clipy = visarea.min_y; + clipw = (visarea.max_x - clipx + 4) & ~3; + cliph = visarea.max_y - clipy + 1; + + dst_ptr = &bitmap.pix32(clipy); + dst_pitch = bitmap.rowpixels(); + dst_ptr += clipx; + + BGC_SET = 0; + pal_ptr = state->m_generic_paletteram_32; + + if (!mode) + { + // single color output from CLTC + bgcolor = (int)(k54338_regs[K338_REG_BGC_R]&0xff)<<16 | (int)k54338_regs[K338_REG_BGC_GB]; + } + else + { + BGC_CBLK = K055555_read_register(0); + BGC_SET = K055555_read_register(1); + pal_ptr += BGC_CBLK << 9; + + // single color output from PCU2 + if (!(BGC_SET & 2)) { bgcolor = *pal_ptr; mode = 0; } else bgcolor = 0; + } + + if (!mode) + { + // single color fill + dst_ptr += clipw; + i = clipw = -clipw; + do + { + do { dst_ptr[i] = dst_ptr[i+1] = dst_ptr[i+2] = dst_ptr[i+3] = bgcolor; } while (i += 4); + dst_ptr += dst_pitch; + i = clipw; + } + while (--cliph); + } + else + { + if (!(BGC_SET & 1)) + { + // vertical gradient fill + pal_ptr += clipy; + dst_ptr += clipw; + bgcolor = *pal_ptr++; + i = clipw = -clipw; + do + { + do { dst_ptr[i] = dst_ptr[i+1] = dst_ptr[i+2] = dst_ptr[i+3] = bgcolor; } while (i += 4); + dst_ptr += dst_pitch; + bgcolor = *pal_ptr++; + i = clipw; + } + while (--cliph); + } + else + { + // horizontal gradient fill + pal_ptr += clipx; + clipw <<= 2; + do + { + memcpy(dst_ptr, pal_ptr, clipw); + dst_ptr += dst_pitch; + } + while (--cliph); + } + } +} + +// addition blending unimplemented (requires major changes to drawgfx and tilemap.c) +int K054338_set_alpha_level(int pblend) +{ + UINT16 *regs; + int ctrl, mixpri, mixset, mixlv; + + if (pblend <= 0 || pblend > 3) + { + return(255); + } + + regs = k54338_regs; + ctrl = k54338_regs[K338_REG_CONTROL]; + mixpri = ctrl & K338_CTL_MIXPRI; + mixset = regs[K338_REG_PBLEND + (pblend>>1 & 1)] >> (~pblend<<3 & 8); + mixlv = mixset & 0x1f; + + if (K054338_alphainverted) mixlv = 0x1f - mixlv; + + if (!(mixset & 0x20)) + { + mixlv = mixlv<<3 | mixlv>>2; + } + else + { + if (!mixpri) + { + // source x alpha + target (clipped at 255) + } + else + { + // source + target x alpha (clipped at 255) + } + + // DUMMY + if (mixlv && mixlv<0x1f) mixlv = 0x10; + mixlv = mixlv<<3 | mixlv>>2; + + if (VERBOSE) + popmessage("MIXSET%1d %s addition mode: %02x",pblend,(mixpri)?"dst":"src",mixset&0x1f); + } + + return(mixlv); +} + +void K054338_invert_alpha(int invert) +{ + K054338_alphainverted = invert; +} + +void K054338_export_config(int **shdRGB) +{ + *shdRGB = K054338_shdRGB; +} + + diff --git a/src/mame/video/konamiic.h b/src/mame/video/k054338.h similarity index 59% rename from src/mame/video/konamiic.h rename to src/mame/video/k054338.h index 56e8d2d6916..86a07b2141f 100644 --- a/src/mame/video/konamiic.h +++ b/src/mame/video/k054338.h @@ -1,23 +1,7 @@ - -/* - Note: K053251_w() automatically does a ALL_TILEMAPS->mark_all_dirty() - when some palette index changes. If ALL_TILEMAPS is too expensive, use - K053251_set_tilemaps() to indicate which tilemap is associated with each index. - */ -DECLARE_WRITE8_HANDLER( K053251_w ); -DECLARE_WRITE16_HANDLER( K053251_lsb_w ); -DECLARE_WRITE16_HANDLER( K053251_msb_w ); -enum { OLD_K053251_CI0=0,OLD_K053251_CI1,OLD_K053251_CI2,OLD_K053251_CI3,OLD_K053251_CI4 }; -int K053251_get_priority(int ci); -int K053251_get_palette_index(int ci); -void K053251_set_tilemaps(tilemap_t *ci0,tilemap_t *ci1,tilemap_t *ci2,tilemap_t *ci3,tilemap_t *ci4); -void K053251_vh_start(running_machine &machine); - - -DECLARE_WRITE16_HANDLER( K054000_lsb_w ); -DECLARE_READ16_HANDLER( K054000_lsb_r ); - +#pragma once +#ifndef __K054338_H__ +#define __K054338_H__ /* K054338 mixer/alpha blender */ void K054338_vh_start(running_machine &machine); @@ -45,5 +29,7 @@ void K054338_export_config(int **shdRGB); #define K338_CTL_WAILSL 0x10 #define K338_CTL_CLIPSL 0x20 -// K053252 CRT and interrupt control unit -DECLARE_WRITE16_HANDLER( K053252_word_w ); +#endif + + + diff --git a/src/mame/video/konamigx.c b/src/mame/video/konamigx.c index 2984e330470..762790553fb 100644 --- a/src/mame/video/konamigx.c +++ b/src/mame/video/konamigx.c @@ -4,7 +4,6 @@ */ #include "emu.h" -#include "video/konamiic.h" #include "video/k053250.h" #include "includes/konamigx.h" diff --git a/src/mame/video/konamiic.c b/src/mame/video/konamiic.c deleted file mode 100644 index 7bae9366f24..00000000000 --- a/src/mame/video/konamiic.c +++ /dev/null @@ -1,480 +0,0 @@ -/*************************************************************************** - - all the information from here was copy+pasted into - konicdev.c - -***************************************************************************/ - -#include "emu.h" -#include "video/konamiic.h" -#include "video/k055555.h" - - -#define VERBOSE 0 -#define LOG(x) do { if (VERBOSE) logerror x; } while (0) - - - -/***************************************************************************/ -/* */ -/* 053936 */ -/* */ -/***************************************************************************/ - -#define K053936_MAX_CHIPS 2 - -static int K053936_offset[K053936_MAX_CHIPS][2]; -static int K053936_wraparound[K053936_MAX_CHIPS]; - -// there is another implementation of this in machine/konamigx.c (!) -// why? - -static void K053936_zoom_draw(int chip,UINT16 *ctrl,UINT16 *linectrl, bitmap_ind16 &bitmap,const rectangle &cliprect,tilemap_t *tmap,int flags,UINT32 priority, int glfgreat_hack) -{ - if (!tmap) - return; - - if (ctrl[0x07] & 0x0040) - { - UINT32 startx,starty; - int incxx,incxy; - rectangle my_clip; - int y,maxy; - - // Racin' Force will get to here if glfgreat_hack is enabled, and it ends - // up setting a maximum y value of '13', thus causing nothing to be drawn. - // It looks like the roz output should be flipped somehow as it seems to be - // displaying the wrong areas of the tilemap and is rendered upside down, - // although due to the additional post-processing the voxel renderer performs - // it's difficult to know what the output SHOULD be. (hold W in Racin' Force - // to see the chip output) - - if (((ctrl[0x07] & 0x0002) && ctrl[0x09]) && (glfgreat_hack)) /* wrong, but fixes glfgreat */ - { - my_clip.min_x = ctrl[0x08] + K053936_offset[chip][0]+2; - my_clip.max_x = ctrl[0x09] + K053936_offset[chip][0]+2 - 1; - if (my_clip.min_x < cliprect.min_x) - my_clip.min_x = cliprect.min_x; - if (my_clip.max_x > cliprect.max_x) - my_clip.max_x = cliprect.max_x; - - y = ctrl[0x0a] + K053936_offset[chip][1]-2; - if (y < cliprect.min_y) - y = cliprect.min_y; - maxy = ctrl[0x0b] + K053936_offset[chip][1]-2 - 1; - if (maxy > cliprect.max_y) - maxy = cliprect.max_y; - } - else - { - my_clip.min_x = cliprect.min_x; - my_clip.max_x = cliprect.max_x; - - y = cliprect.min_y; - maxy = cliprect.max_y; - } - - while (y <= maxy) - { - UINT16 *lineaddr = linectrl + 4*((y - K053936_offset[chip][1]) & 0x1ff); - my_clip.min_y = my_clip.max_y = y; - - - - startx = 256 * (INT16)(lineaddr[0] + ctrl[0x00]); - starty = 256 * (INT16)(lineaddr[1] + ctrl[0x01]); - incxx = (INT16)(lineaddr[2]); - incxy = (INT16)(lineaddr[3]); - - if (ctrl[0x06] & 0x8000) incxx *= 256; - if (ctrl[0x06] & 0x0080) incxy *= 256; - - startx -= K053936_offset[chip][0] * incxx; - starty -= K053936_offset[chip][0] * incxy; - - tmap->draw_roz(bitmap, my_clip, startx << 5,starty << 5, - incxx << 5,incxy << 5,0,0, - K053936_wraparound[chip], - flags,priority); - - y++; - } - } - else /* "simple" mode */ - { - UINT32 startx,starty; - int incxx,incxy,incyx,incyy; - - startx = 256 * (INT16)(ctrl[0x00]); - starty = 256 * (INT16)(ctrl[0x01]); - incyx = (INT16)(ctrl[0x02]); - incyy = (INT16)(ctrl[0x03]); - incxx = (INT16)(ctrl[0x04]); - incxy = (INT16)(ctrl[0x05]); - - if (ctrl[0x06] & 0x4000) { incyx *= 256; incyy *= 256; } - if (ctrl[0x06] & 0x0040) { incxx *= 256; incxy *= 256; } - - startx -= K053936_offset[chip][1] * incyx; - starty -= K053936_offset[chip][1] * incyy; - - startx -= K053936_offset[chip][0] * incxx; - starty -= K053936_offset[chip][0] * incxy; - - tmap->draw_roz(bitmap, cliprect, startx << 5,starty << 5, - incxx << 5,incxy << 5,incyx << 5,incyy << 5, - K053936_wraparound[chip], - flags,priority); - } - -#if 0 -if (machine.input().code_pressed(KEYCODE_D)) - popmessage("%04x %04x %04x %04x\n%04x %04x %04x %04x\n%04x %04x %04x %04x\n%04x %04x %04x %04x", - ctrl[0x00], - ctrl[0x01], - ctrl[0x02], - ctrl[0x03], - ctrl[0x04], - ctrl[0x05], - ctrl[0x06], - ctrl[0x07], - ctrl[0x08], - ctrl[0x09], - ctrl[0x0a], - ctrl[0x0b], - ctrl[0x0c], - ctrl[0x0d], - ctrl[0x0e], - ctrl[0x0f]); -#endif -} - - -void K053936_0_zoom_draw(bitmap_ind16 &bitmap,const rectangle &cliprect,tilemap_t *tmap,int flags,UINT32 priority, int glfgreat_hack) -{ - UINT16 *ctrl = reinterpret_cast(tmap->machine().root_device().memshare("k053936_0_ctrl")->ptr()); - UINT16 *linectrl = reinterpret_cast(tmap->machine().root_device().memshare("k053936_0_line")->ptr()); - K053936_zoom_draw(0,ctrl,linectrl,bitmap,cliprect,tmap,flags,priority, glfgreat_hack); -} - -void K053936_wraparound_enable(int chip, int status) -{ - K053936_wraparound[chip] = status; -} - - -void K053936_set_offset(int chip, int xoffs, int yoffs) -{ - K053936_offset[chip][0] = xoffs; - K053936_offset[chip][1] = yoffs; -} - -/***************************************************************************/ -/* */ -/* 054000 */ -/* */ -/***************************************************************************/ - -static UINT8 K054000_ram[0x20]; - -static WRITE8_HANDLER( K054000_w ) -{ -//logerror("%04x: write %02x to 054000 address %02x\n",space.device().safe_pc(),data,offset); - - K054000_ram[offset] = data; -} - -static READ8_HANDLER( K054000_r ) -{ - int Acx,Acy,Aax,Aay; - int Bcx,Bcy,Bax,Bay; - -//logerror("%04x: read 054000 address %02x\n",space.device().safe_pc(),offset); - - if (offset != 0x18) return 0; - - Acx = (K054000_ram[0x01] << 16) | (K054000_ram[0x02] << 8) | K054000_ram[0x03]; - Acy = (K054000_ram[0x09] << 16) | (K054000_ram[0x0a] << 8) | K054000_ram[0x0b]; -/* TODO: this is a hack to make thndrx2 pass the startup check. It is certainly wrong. */ -if (K054000_ram[0x04] == 0xff) Acx+=3; -if (K054000_ram[0x0c] == 0xff) Acy+=3; - Aax = K054000_ram[0x06] + 1; - Aay = K054000_ram[0x07] + 1; - - Bcx = (K054000_ram[0x15] << 16) | (K054000_ram[0x16] << 8) | K054000_ram[0x17]; - Bcy = (K054000_ram[0x11] << 16) | (K054000_ram[0x12] << 8) | K054000_ram[0x13]; - Bax = K054000_ram[0x0e] + 1; - Bay = K054000_ram[0x0f] + 1; - - if (Acx + Aax < Bcx - Bax) - return 1; - - if (Bcx + Bax < Acx - Aax) - return 1; - - if (Acy + Aay < Bcy - Bay) - return 1; - - if (Bcy + Bay < Acy - Aay) - return 1; - - return 0; -} - -READ16_HANDLER( K054000_lsb_r ) -{ - return K054000_r(space, offset, mem_mask & 0xff); -} - -WRITE16_HANDLER( K054000_lsb_w ) -{ - if (ACCESSING_BITS_0_7) - K054000_w(space, offset, data & 0xff, mem_mask & 0xff); -} - - - - - - -/***************************************************************************/ -/* */ -/* 054338 */ -/* */ -/***************************************************************************/ - -static UINT16 k54338_regs[32]; -static int K054338_shdRGB[9]; -static int K054338_alphainverted; - - -// K054338 alpha blend / final mixer (normally used with the 55555) -// because the implementation is video dependant, this is just a -// register-handling shell. -void K054338_vh_start(running_machine &machine) -{ - memset(k54338_regs, 0, sizeof(UINT16)*32); - memset(K054338_shdRGB, 0, sizeof(int)*9); - K054338_alphainverted = 1; - - machine.save().save_item(NAME(k54338_regs)); -} - -WRITE16_HANDLER( K054338_word_w ) -{ - COMBINE_DATA(k54338_regs + offset); -} - -WRITE32_HANDLER( K054338_long_w ) -{ - offset <<= 1; - K054338_word_w(space, offset, data>>16, mem_mask>>16); - K054338_word_w(space, offset+1, data, mem_mask); -} - -// returns a 16-bit '338 register -int K054338_read_register(int reg) -{ - return k54338_regs[reg]; -} - -void K054338_update_all_shadows(running_machine &machine, int rushingheroes_hack) -{ - int i, d; - int noclip = k54338_regs[K338_REG_CONTROL] & K338_CTL_CLIPSL; - - for (i=0; i<9; i++) - { - d = k54338_regs[K338_REG_SHAD1R+i] & 0x1ff; - if (d >= 0x100) d -= 0x200; - K054338_shdRGB[i] = d; - } - - if (!rushingheroes_hack) - { - palette_set_shadow_dRGB32(machine, 0, K054338_shdRGB[0], K054338_shdRGB[1], K054338_shdRGB[2], noclip); - palette_set_shadow_dRGB32(machine, 1, K054338_shdRGB[3], K054338_shdRGB[4], K054338_shdRGB[5], noclip); - palette_set_shadow_dRGB32(machine, 2, K054338_shdRGB[6], K054338_shdRGB[7], K054338_shdRGB[8], noclip); - } - else // rushing heroes seems to specify shadows in another format, or it's not being interpreted properly. - { - palette_set_shadow_dRGB32(machine, 0, -80, -80, -80, 0); - palette_set_shadow_dRGB32(machine, 1, -80, -80, -80, 0); - palette_set_shadow_dRGB32(machine, 2, -80, -80, -80, 0); - } -} - -#ifdef UNUSED_FUNCTION -// K054338 BG color fill -void K054338_fill_solid_bg(bitmap_ind16 &bitmap) -{ - UINT32 bgcolor; - UINT32 *pLine; - int x, y; - - bgcolor = (K054338_read_register(K338_REG_BGC_R)&0xff)<<16; - bgcolor |= K054338_read_register(K338_REG_BGC_GB); - - /* and fill the screen with it */ - for (y = 0; y < bitmap.height; y++) - { - pLine = (UINT32 *)bitmap.base; - pLine += (bitmap.rowpixels*y); - for (x = 0; x < bitmap.width; x++) - *pLine++ = bgcolor; - } -} -#endif - -// Unified K054338/K055555 BG color fill -void K054338_fill_backcolor(running_machine &machine, bitmap_rgb32 &bitmap, int mode) // (see p.67) -{ - int clipx, clipy, clipw, cliph, i, dst_pitch; - int BGC_CBLK, BGC_SET; - UINT32 *dst_ptr, *pal_ptr; - int bgcolor; - const rectangle &visarea = machine.primary_screen->visible_area(); - driver_device *state = machine.driver_data(); - - clipx = visarea.min_x & ~3; - clipy = visarea.min_y; - clipw = (visarea.max_x - clipx + 4) & ~3; - cliph = visarea.max_y - clipy + 1; - - dst_ptr = &bitmap.pix32(clipy); - dst_pitch = bitmap.rowpixels(); - dst_ptr += clipx; - - BGC_SET = 0; - pal_ptr = state->m_generic_paletteram_32; - - if (!mode) - { - // single color output from CLTC - bgcolor = (int)(k54338_regs[K338_REG_BGC_R]&0xff)<<16 | (int)k54338_regs[K338_REG_BGC_GB]; - } - else - { - BGC_CBLK = K055555_read_register(0); - BGC_SET = K055555_read_register(1); - pal_ptr += BGC_CBLK << 9; - - // single color output from PCU2 - if (!(BGC_SET & 2)) { bgcolor = *pal_ptr; mode = 0; } else bgcolor = 0; - } - - if (!mode) - { - // single color fill - dst_ptr += clipw; - i = clipw = -clipw; - do - { - do { dst_ptr[i] = dst_ptr[i+1] = dst_ptr[i+2] = dst_ptr[i+3] = bgcolor; } while (i += 4); - dst_ptr += dst_pitch; - i = clipw; - } - while (--cliph); - } - else - { - if (!(BGC_SET & 1)) - { - // vertical gradient fill - pal_ptr += clipy; - dst_ptr += clipw; - bgcolor = *pal_ptr++; - i = clipw = -clipw; - do - { - do { dst_ptr[i] = dst_ptr[i+1] = dst_ptr[i+2] = dst_ptr[i+3] = bgcolor; } while (i += 4); - dst_ptr += dst_pitch; - bgcolor = *pal_ptr++; - i = clipw; - } - while (--cliph); - } - else - { - // horizontal gradient fill - pal_ptr += clipx; - clipw <<= 2; - do - { - memcpy(dst_ptr, pal_ptr, clipw); - dst_ptr += dst_pitch; - } - while (--cliph); - } - } -} - -// addition blending unimplemented (requires major changes to drawgfx and tilemap.c) -int K054338_set_alpha_level(int pblend) -{ - UINT16 *regs; - int ctrl, mixpri, mixset, mixlv; - - if (pblend <= 0 || pblend > 3) - { - return(255); - } - - regs = k54338_regs; - ctrl = k54338_regs[K338_REG_CONTROL]; - mixpri = ctrl & K338_CTL_MIXPRI; - mixset = regs[K338_REG_PBLEND + (pblend>>1 & 1)] >> (~pblend<<3 & 8); - mixlv = mixset & 0x1f; - - if (K054338_alphainverted) mixlv = 0x1f - mixlv; - - if (!(mixset & 0x20)) - { - mixlv = mixlv<<3 | mixlv>>2; - } - else - { - if (!mixpri) - { - // source x alpha + target (clipped at 255) - } - else - { - // source + target x alpha (clipped at 255) - } - - // DUMMY - if (mixlv && mixlv<0x1f) mixlv = 0x10; - mixlv = mixlv<<3 | mixlv>>2; - - if (VERBOSE) - popmessage("MIXSET%1d %s addition mode: %02x",pblend,(mixpri)?"dst":"src",mixset&0x1f); - } - - return(mixlv); -} - -void K054338_invert_alpha(int invert) -{ - K054338_alphainverted = invert; -} - -void K054338_export_config(int **shdRGB) -{ - *shdRGB = K054338_shdRGB; -} - - -/***************************************************************************/ -/* */ -/* 053252 */ -/* */ -/***************************************************************************/ - -// K053252 CRT and interrupt control unit -static UINT16 K053252_regs[16]; - -WRITE16_HANDLER( K053252_word_w ) -{ - COMBINE_DATA(K053252_regs + offset); -} diff --git a/src/mame/video/mystwarr.c b/src/mame/video/mystwarr.c index b05f0db9c0f..d3e6b9c44d6 100644 --- a/src/mame/video/mystwarr.c +++ b/src/mame/video/mystwarr.c @@ -6,7 +6,6 @@ */ #include "emu.h" -#include "video/konamiic.h" #include "includes/konamigx.h" #include "includes/mystwarr.h"