1 // license:BSD-3-Clause 2 // copyright-holders:R. Belmont, Acho A. Tang, Phil Stroffolino, Olivier Galibert 3 #ifndef MAME_INCLUDES_KONAMIGX_H 4 #define MAME_INCLUDES_KONAMIGX_H 5 6 #pragma once 7 8 #include "cpu/tms57002/tms57002.h" 9 #include "machine/adc083x.h" 10 #include "machine/k053252.h" 11 #include "machine/timer.h" 12 #include "sound/k056800.h" 13 #include "sound/k054539.h" 14 #include "video/k053246_k053247_k055673.h" 15 #include "video/k053250.h" 16 #include "video/k053936.h" 17 #include "video/k054156_k054157_k056832.h" 18 #include "video/k054338.h" 19 #include "video/k055555.h" 20 #include "emupal.h" 21 #include "screen.h" 22 #include "tilemap.h" 23 24 class konamigx_state : public driver_device 25 { 26 public: konamigx_state(const machine_config & mconfig,device_type type,const char * tag)27 konamigx_state(const machine_config &mconfig, device_type type, const char *tag) 28 : driver_device(mconfig, type, tag) 29 , m_maincpu(*this,"maincpu") 30 , m_soundcpu(*this, "soundcpu") 31 , m_dasp(*this, "dasp") 32 , m_k053252(*this, "k053252") 33 , m_k055673(*this, "k055673") 34 , m_k055555(*this, "k055555") 35 , m_k056832(*this, "k056832") 36 , m_k054338(*this, "k054338") 37 , m_k056800(*this, "k056800") 38 , m_k054539_1(*this, "k054539_1") 39 , m_k054539_2(*this, "k054539_2") 40 , m_k053250_1(*this, "k053250_1") 41 , m_k053250_2(*this, "k053250_2") 42 , m_gfxdecode(*this, "gfxdecode") 43 , m_screen(*this, "screen") 44 , m_palette(*this, "palette") 45 , m_workram(*this, "workram") 46 , m_psacram(*this, "psacram") 47 , m_subpaletteram32(*this, "subpaletteram") 48 , m_k053936_0_ctrl(*this, "k053936_0_ctrl", 32) 49 , m_k053936_0_linectrl(*this, "k053936_0_line", 32) 50 , m_k053936_0_ctrl_16(*this, "k053936_0_ct16", 16) 51 , m_k053936_0_linectrl_16(*this, "k053936_0_li16", 16) 52 , m_generic_paletteram_32(*this, "paletteram") 53 , m_an0(*this, "AN0") 54 , m_an1(*this, "AN1") 55 , m_light0_x(*this, "LIGHT0_X") 56 , m_light0_y(*this, "LIGHT0_Y") 57 , m_light1_x(*this, "LIGHT1_X") 58 , m_light1_y(*this, "LIGHT1_Y") 59 , m_eepromout(*this, "EEPROMOUT") 60 , m_use_68020_post_clock_hack(0) 61 , m_lamp(*this, "lamp0") 62 { } 63 64 void esc_w(address_space &space, uint32_t data); 65 void eeprom_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); 66 void control_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); 67 uint32_t le2_gun_H_r(); 68 uint32_t le2_gun_V_r(); 69 uint32_t type1_roz_r1(offs_t offset); 70 uint32_t type1_roz_r2(offs_t offset); 71 uint32_t type3_sync_r(); 72 void type4_prot_w(address_space &space, offs_t offset, uint32_t data); 73 void type1_cablamps_w(uint32_t data); 74 uint16_t tms57002_status_word_r(); 75 void tms57002_control_word_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 76 uint16_t K055550_word_r(offs_t offset); 77 void K055550_word_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 78 void K053990_martchmp_word_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 79 void fantjour_dma_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); 80 void type3_bank_w(offs_t offset, uint8_t data); 81 void konamigx_tilebank_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); 82 void konamigx_t1_psacmap_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); 83 void konamigx_t4_psacmap_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); 84 DECLARE_WRITE_LINE_MEMBER(vblank_irq_ack_w); 85 DECLARE_WRITE_LINE_MEMBER(hblank_irq_ack_w); 86 DECLARE_CUSTOM_INPUT_MEMBER(gx_rdport1_3_r); 87 void init_konamigx(); 88 TILE_GET_INFO_MEMBER(get_gx_psac_tile_info); 89 TILE_GET_INFO_MEMBER(get_gx_psac3_tile_info); 90 TILE_GET_INFO_MEMBER(get_gx_psac3_alt_tile_info); 91 TILE_GET_INFO_MEMBER(get_gx_psac1a_tile_info); 92 TILE_GET_INFO_MEMBER(get_gx_psac1b_tile_info); 93 DECLARE_MACHINE_START(konamigx); 94 DECLARE_MACHINE_RESET(konamigx); 95 DECLARE_VIDEO_START(konamigx_5bpp); 96 DECLARE_VIDEO_START(dragoonj); 97 DECLARE_VIDEO_START(le2); 98 DECLARE_VIDEO_START(konamigx_6bpp); 99 DECLARE_VIDEO_START(opengolf); 100 DECLARE_VIDEO_START(racinfrc); 101 DECLARE_VIDEO_START(konamigx_type3); 102 DECLARE_VIDEO_START(konamigx_type4); 103 DECLARE_VIDEO_START(konamigx_type4_vsn); 104 DECLARE_VIDEO_START(konamigx_type4_sd2); 105 uint32_t screen_update_konamigx(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 106 uint32_t screen_update_konamigx_left(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 107 uint32_t screen_update_konamigx_right(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 108 INTERRUPT_GEN_MEMBER(konamigx_type2_vblank_irq); 109 TIMER_DEVICE_CALLBACK_MEMBER(konamigx_type2_scanline); 110 TIMER_DEVICE_CALLBACK_MEMBER(konamigx_type4_scanline); 111 DECLARE_WRITE_LINE_MEMBER(k054539_irq_gen); 112 TIMER_CALLBACK_MEMBER(dmaend_callback); 113 TIMER_CALLBACK_MEMBER(boothack_callback); 114 double adc0834_callback(uint8_t input); 115 K056832_CB_MEMBER(type2_tile_callback); 116 K056832_CB_MEMBER(alpha_tile_callback); 117 K055673_CB_MEMBER(type2_sprite_callback); 118 K055673_CB_MEMBER(dragoonj_sprite_callback); 119 K055673_CB_MEMBER(salmndr2_sprite_callback); 120 K055673_CB_MEMBER(le2_sprite_callback); 121 122 void common_init(); 123 uint32_t k_6bpp_rom_long_r(offs_t offset, uint32_t mem_mask = ~0); 124 void konamigx_mixer (screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect,tilemap_t *sub1, int sub1flags,tilemap_t *sub2, int sub2flags,int mixerflags, bitmap_ind16 *extra_bitmap, int rushingheroes_hack); 125 void konamigx_mixer_draw(screen_device &Screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, 126 tilemap_t *sub1, int sub1flags, 127 tilemap_t *sub2, int sub2flags, 128 int mixerflags, bitmap_ind16 *extra_bitmap, int rushingheroes_hack, 129 struct GX_OBJ *objpool, 130 int *objbuf, 131 int nobj 132 ); 133 134 135 void gx_draw_basic_tilemaps(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int mixerflags, int code); 136 void gx_draw_basic_extended_tilemaps_1(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int mixerflags, int code, tilemap_t *sub1, int sub1flags, int rushingheroes_hack, int offs); 137 void gx_draw_basic_extended_tilemaps_2(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int mixerflags, int code, tilemap_t *sub2, int sub2flags, bitmap_ind16 *extra_bitmap, int offs); 138 139 void konamigx_esc_alert(uint32_t *srcbase, int srcoffs, int count, int mode); 140 void konamigx_precache_registers(void); 141 142 void wipezbuf(int noshadow); 143 144 void dmastart_callback(int data); 145 146 void konamigx_mixer_init(screen_device &screen, int objdma); 147 void konamigx_objdma(void); 148 void generate_sprites(address_space &space, uint32_t src, uint32_t spr, int count); 149 150 void fantjour_dma_install(); 151 152 void konamigx_mixer_primode(int mode); 153 154 typedef void (konamigx_state::*esc_cb)(address_space &space, uint32_t p1, uint32_t p2, uint32_t p3, uint32_t p4); 155 156 void tkmmpzdm_esc(address_space &space, uint32_t p1, uint32_t p2, uint32_t p3, uint32_t p4); 157 void dragoonj_esc(address_space &space, uint32_t p1, uint32_t p2, uint32_t p3, uint32_t p4); 158 void sal2_esc(address_space &space, uint32_t p1, uint32_t p2, uint32_t p3, uint32_t p4); 159 void sexyparo_esc(address_space &space, uint32_t p1, uint32_t p2, uint32_t p3, uint32_t p4); 160 void tbyahhoo_esc(address_space &space, uint32_t p1, uint32_t p2, uint32_t p3, uint32_t p4); 161 void daiskiss_esc(address_space &space, uint32_t p1, uint32_t p2, uint32_t p3, uint32_t p4); 162 163 inline int K053247GX_combine_c18(int attrib); 164 inline int K055555GX_decode_objcolor(int c18); 165 inline int K055555GX_decode_inpri(int c18); 166 int K055555GX_decode_vmixcolor(int layer, int *color); 167 168 void init_posthack(); 169 void konamigx_6bpp(machine_config &config); 170 void gxtype4(machine_config &config); 171 void gxtype4_vsn(machine_config &config); 172 void racinfrc(machine_config &config); 173 void gxtype4sd2(machine_config &config); 174 void konamigx_bios(machine_config &config); 175 void gxtype3(machine_config &config); 176 void opengolf(machine_config &config); 177 void winspike(machine_config &config); 178 void le2(machine_config &config); 179 void konamigx(machine_config &config); 180 void dragoonj(machine_config &config); 181 void salmndr2(machine_config &config); 182 void tbyahhoo(machine_config &config); 183 void gokuparo(machine_config &config); 184 void sexyparo(machine_config &config); 185 void gx_base_memmap(address_map &map); 186 void racinfrc_map(address_map &map); 187 void gx_type1_map(address_map &map); 188 void gx_type2_map(address_map &map); 189 void gx_type3_map(address_map &map); 190 void gx_type4_map(address_map &map); 191 void gxsndmap(address_map &map); 192 void gxtmsmap(address_map &map); 193 194 protected: 195 required_device<cpu_device> m_maincpu; 196 optional_device<cpu_device> m_soundcpu; 197 optional_device<tms57002_device> m_dasp; 198 required_device<k053252_device> m_k053252; 199 required_device<k055673_device> m_k055673; 200 required_device<k055555_device> m_k055555; 201 required_device<k056832_device> m_k056832; 202 optional_device<k054338_device> m_k054338; 203 optional_device<k056800_device> m_k056800; 204 optional_device<k054539_device> m_k054539_1; 205 optional_device<k054539_device> m_k054539_2; 206 optional_device<k053250_device> m_k053250_1; 207 optional_device<k053250_device> m_k053250_2; 208 optional_device<gfxdecode_device> m_gfxdecode; 209 required_device<screen_device> m_screen; 210 required_device<palette_device> m_palette; 211 212 optional_shared_ptr<uint32_t> m_workram; 213 optional_shared_ptr<uint32_t> m_psacram; 214 optional_shared_ptr<uint32_t> m_subpaletteram32; 215 optional_shared_ptr<uint16_t> m_k053936_0_ctrl; 216 optional_shared_ptr<uint16_t> m_k053936_0_linectrl; 217 optional_shared_ptr<uint16_t> m_k053936_0_ctrl_16; 218 optional_shared_ptr<uint16_t> m_k053936_0_linectrl_16; 219 optional_shared_ptr<uint32_t> m_generic_paletteram_32; 220 221 optional_ioport m_an0, m_an1, m_light0_x, m_light0_y, m_light1_x, m_light1_y, m_eepromout; 222 223 uint8_t m_sound_ctrl; 224 uint8_t m_sound_intck; 225 uint32_t m_fantjour_dma[8]; 226 int m_konamigx_current_frame; 227 int m_gx_objdma, m_gx_primode; 228 emu_timer *m_dmadelay_timer; 229 emu_timer *m_boothack_timer; 230 int m_gx_rdport1_3, m_gx_syncen; 231 int m_gx_cfgport; 232 int m_suspension_active, m_resume_trigger; 233 int m_last_prot_op, m_last_prot_clk; 234 u16 m_last_prot_param; 235 uint8_t m_prev_pixel_clock; 236 237 uint8_t m_esc_program[4096]; 238 esc_cb m_esc_cb; 239 240 uint16_t m_prot_data[0x20]; 241 242 uint16_t *m_gx_spriteram; 243 244 // mirrored K054338 settings 245 int *m_K054338_shdRGB; 246 247 // 1st-Tier GX/MW Variables 248 // frequently used registers 249 int m_k053247_vrcbk[4]; 250 int m_k053247_coreg, m_k053247_coregshift, m_k053247_opset; 251 int m_opri, m_oinprion; 252 int m_vcblk[6], m_ocblk; 253 int m_vinmix, m_vmixon, m_osinmix, m_osmixon; 254 uint8_t m_gx_wrport1_0, m_gx_wrport1_1; 255 uint16_t m_gx_wrport2; 256 257 // 2nd-Tier GX/MW Graphics Variables 258 uint8_t *m_gx_objzbuf; 259 std::unique_ptr<uint8_t[]> m_gx_shdzbuf; 260 int m_layer_colorbase[4]; 261 int32_t m_gx_tilebanks[8], m_gx_oldbanks[8]; 262 int m_gx_tilemode, m_gx_rozenable, m_psac_colorbase, m_last_psac_colorbase; 263 int m_gx_specialrozenable; // type 1 roz, with voxel height-map, rendered from 2 source tilemaps (which include height data) to temp bitmap for further processing 264 int m_gx_rushingheroes_hack; 265 266 tilemap_t *m_gx_psac_tilemap, *m_gx_psac_tilemap2; 267 std::unique_ptr<bitmap_ind16> m_type3_roz_temp_bitmap; 268 tilemap_t *m_gx_psac_tilemap_alt; 269 int m_konamigx_has_dual_screen; 270 int m_konamigx_palformat; 271 std::unique_ptr<bitmap_rgb32> m_dualscreen_left_tempbitmap; 272 std::unique_ptr<bitmap_rgb32> m_dualscreen_right_tempbitmap; 273 274 /* On Type-1 the K053936 output is rendered to these temporary bitmaps as raw data 275 the 'voxel' effect to give the pixels height is a post-process operation on the 276 output of the K053936 (this can clearly be seen in videos as large chunks of 277 scenary flicker when in the distance due to single pixels in the K053936 output 278 becoming visible / invisible due to drawing precision. 279 280 -- however, progress on this has stalled as our K053936 doesn't seem to give 281 the right output for post processing, I suspect the game is using some 282 unsupported flipping modes (probably due to the way it's hooked up to the 283 rest of the chips) which is causing entirely the wrong output. 284 285 -- furthermore video\k053936.cpp contains an implementation of 286 the K053936_zoom_draw named K053936GP_zoom_draw that's only used in konamigx ... 287 288 289 */ 290 std::unique_ptr<bitmap_ind16> m_gxtype1_roz_dstbitmap; 291 std::unique_ptr<bitmap_ind16> m_gxtype1_roz_dstbitmap2; 292 rectangle m_gxtype1_roz_dstbitmapclip; 293 294 u8 m_type3_psac2_bank; 295 u8 m_type3_spriteram_bank; 296 //int m_konamigx_type3_psac2_actual_last_bank = 0; 297 int m_use_68020_post_clock_hack; 298 output_finder<> m_lamp; 299 }; 300 301 // Sprite Callbacks 302 303 /* callbacks should return color codes in this format: 304 fedcba9876543210fedcba9876543210 305 ----------------xxxxxxxxxxxxxxxx (bit 00-15: color) 306 --------------xx---------------- (bit 16-17: blend code) 307 ------------xx------------------ (bit 18-19: brightness code) 308 -x------------------------------ (bit 30 : skip shadow) 309 x------------------------------- (bit 31 : full shadow) 310 */ 311 #define K055555_COLORMASK 0x0000ffff 312 #define K055555_MIXSHIFT 16 313 #define K055555_BRTSHIFT 18 314 #define K055555_SKIPSHADOW 0x40000000 315 #define K055555_FULLSHADOW 0x80000000 316 317 318 319 // Centralized Sprites and Layer Blitter 320 321 /* Mixer Flags 322 fedcba9876543210fedcba9876543210 323 --------------------FFEEDDCCBBAA (layer A-F blend modes) 324 ----------------DCBA------------ (layer A-D line/row scroll disables) 325 ----FFEEDDCCBBAA---------------- (layer A-F mix codes in forced blending) 326 ---x---------------------------- (disable shadows) 327 --x----------------------------- (disable z-buffering) 328 */ 329 #define GXMIX_BLEND_AUTO 0 // emulate all blend effects 330 #define GXMIX_BLEND_NONE 1 // disable all blend effects 331 #define GXMIX_BLEND_FAST 2 // simulate translucency 332 #define GXMIX_BLEND_FORCE 3 // force mix code on selected layer(s) 333 #define GXMIX_NOLINESCROLL 0x1000 // disable linescroll on selected layer(s) 334 #define GXMIX_NOSHADOW 0x10000000 // disable all shadows (shadow pens will be skipped) 335 #define GXMIX_NOZBUF 0x20000000 // disable z-buffering (shadow pens will be drawn as solid) 336 337 // Sub Layer Flags 338 #define GXSUB_K053250 0x10 // chip type: 0=K053936 ROZ+, 1=K053250 LVC 339 #define GXSUB_4BPP 0x04 // 16 colors 340 #define GXSUB_5BPP 0x05 // 32 colors 341 #define GXSUB_8BPP 0x08 // 256 colors 342 343 #endif // MAME_INCLUDES_KONAMIGX_H 344