src/mame/video/stvvdp2.c
| r12458 | r12459 | |
| 1 | 1 | /* Sega Saturn VDP2 */ |
| 2 | 2 | |
| 3 | 3 | #define DEBUG_MODE 0 |
| 4 | #define TEST_FUNCTIONS 0 |
| 4 | 5 | |
| 5 | 6 | /* |
| 6 | 7 | |
| r12458 | r12459 | |
| 371 | 372 | |
| 372 | 373 | #define STV_VDP2_MZCTL ((state->m_vdp2_regs[0x020/4] >> 0)&0x0000ffff) |
| 373 | 374 | |
| 375 | #define STV_VDP2_MZSZV ((STV_VDP2_MZCTL & 0xf000) >> 12) |
| 376 | #define STV_VDP2_MZSZH ((STV_VDP2_MZCTL & 0x0f00) >> 8) |
| 374 | 377 | #define STV_VDP2_R0MZE ((STV_VDP2_MZCTL & 0x0010) >> 4) |
| 375 | 378 | #define STV_VDP2_N3MZE ((STV_VDP2_MZCTL & 0x0008) >> 3) |
| 376 | 379 | #define STV_VDP2_N2MZE ((STV_VDP2_MZCTL & 0x0004) >> 2) |
| r12458 | r12459 | |
| 2138 | 2141 | UINT8 window_control; |
| 2139 | 2142 | |
| 2140 | 2143 | UINT8 line_screen_enabled; |
| 2144 | UINT8 mosaic_screen_enabled; |
| 2141 | 2145 | |
| 2142 | 2146 | // UINT8 real_map_offset[16]; |
| 2143 | 2147 | |
| r12458 | r12459 | |
| 4234 | 4238 | } |
| 4235 | 4239 | } |
| 4236 | 4240 | |
| 4241 | static void stv_vdp2_draw_mosaic(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8 is_roz) |
| 4242 | { |
| 4243 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 4244 | int x,y,xi,yi; |
| 4245 | UINT8 h_size,v_size; |
| 4246 | UINT16 pix; |
| 4247 | |
| 4248 | h_size = STV_VDP2_MZSZH+1; |
| 4249 | v_size = STV_VDP2_MZSZV+1; |
| 4250 | |
| 4251 | if(is_roz) |
| 4252 | v_size = 1; |
| 4253 | |
| 4254 | if(h_size == 1 && v_size == 1) |
| 4255 | return; // don't bother |
| 4256 | |
| 4257 | if(STV_VDP2_LSMD == 3) |
| 4258 | v_size <<= 1; |
| 4259 | |
| 4260 | for(y=cliprect->min_y;y<=cliprect->max_y;y+=v_size) |
| 4261 | { |
| 4262 | for(x=cliprect->min_x;x<=cliprect->max_x;x+=h_size) |
| 4263 | { |
| 4264 | pix = *BITMAP_ADDR16(bitmap, y,x); |
| 4265 | |
| 4266 | for(yi=0;yi<v_size;yi++) |
| 4267 | for(xi=0;xi<h_size;xi++) |
| 4268 | *BITMAP_ADDR16(bitmap, y+yi, x+xi) = pix; |
| 4269 | } |
| 4270 | } |
| 4271 | } |
| 4272 | |
| 4237 | 4273 | static void stv_vdp2_check_tilemap(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect) |
| 4238 | 4274 | { |
| 4239 | 4275 | /* the idea is here we check the tilemap capabilities / whats enabled and call an appropriate tilemap drawing routine, or |
| r12458 | r12459 | |
| 4271 | 4307 | stv_vdp2_draw_basic_tilemap(machine, bitmap, &mycliprect); |
| 4272 | 4308 | } |
| 4273 | 4309 | |
| 4274 | | if(stv2_current_tilemap.line_screen_enabled) |
| 4310 | /* post-processing functions (TODO: needs layer bitmaps to be individual planes to work correctly) */ |
| 4311 | if(stv2_current_tilemap.line_screen_enabled && TEST_FUNCTIONS) |
| 4275 | 4312 | stv_vdp2_draw_line(machine,bitmap,cliprect); |
| 4276 | 4313 | |
| 4314 | if(stv2_current_tilemap.mosaic_screen_enabled && TEST_FUNCTIONS) |
| 4315 | stv_vdp2_draw_mosaic(machine,bitmap,cliprect,stv2_current_tilemap.layer_name & 0x80); |
| 4277 | 4316 | |
| 4317 | |
| 4278 | 4318 | { |
| 4279 | 4319 | /* Capcom Collection Dai 2 - Choh Makaimura (Duh!) */ |
| 4280 | 4320 | if(STV_VDP2_MZCTL & 0x1f && 0) |
| 4281 | 4321 | popmessage("Mosaic control enabled = %04x\n",STV_VDP2_MZCTL); |
| 4282 | 4322 | |
| 4283 | 4323 | /* Bio Hazard bit 1 */ |
| 4324 | /* Airs Adventure 0x3e */ |
| 4284 | 4325 | if(STV_VDP2_LNCLEN & ~2) |
| 4285 | 4326 | popmessage("Line Colour screen enabled %04x %08x, contact MAMEdev",STV_VDP2_LNCLEN,STV_VDP2_LCTAU<<16|STV_VDP2_LCTAL); |
| 4286 | 4327 | |
| r12458 | r12459 | |
| 4290 | 4331 | if(STV_VDP2_CCCR & 0xf000) |
| 4291 | 4332 | popmessage("Gradation enabled %04x, contact MAMEdev",STV_VDP2_CCCR); |
| 4292 | 4333 | |
| 4293 | | /* Advanced VG, Shining Force 3 */ |
| 4334 | /* Advanced VG, Shining Force III */ |
| 4294 | 4335 | if(STV_VDP2_SFCCMD && 0) |
| 4295 | 4336 | popmessage("Special Color Calculation enable %04x, contact MAMEdev",STV_VDP2_SFCCMD); |
| 4296 | 4337 | |
| r12458 | r12459 | |
| 4300 | 4341 | if(STV_VDP2_SFSEL) |
| 4301 | 4342 | popmessage("Special Function Code Select enable %04x %04x, contact MAMEdev",STV_VDP2_SFSEL,STV_VDP2_SFCODE); |
| 4302 | 4343 | |
| 4344 | /* Albert Odyssey Gaiden 0x0001 */ |
| 4345 | /* Asuka 120% (doesn't make sense?) 0x0101 */ |
| 4303 | 4346 | if(STV_VDP2_ZMCTL) |
| 4304 | 4347 | popmessage("Reduction enable %04x, contact MAMEdev",STV_VDP2_ZMCTL); |
| 4305 | 4348 | |
| 4306 | 4349 | if(STV_VDP2_SCRCTL & 0x0101) |
| 4307 | 4350 | popmessage("Vertical cell scroll enable %04x, contact MAMEdev",STV_VDP2_SCRCTL); |
| 4308 | 4351 | |
| 4309 | | if(STV_VDP2_WCTLD & 0x2606) |
| 4352 | /* Magical Drop III 0x200 -> color calculation window */ |
| 4353 | if(STV_VDP2_WCTLD & 0x200a) |
| 4310 | 4354 | popmessage("Special window enabled %04x, contact MAMEdev",STV_VDP2_WCTLD); |
| 4311 | 4355 | |
| 4312 | 4356 | /* Shining Force III, After Burner 2 (doesn't make a proper use tho?) */ |
| 4313 | 4357 | if(STV_VDP2_W0LWE || STV_VDP2_W1LWE) |
| 4314 | 4358 | popmessage("Line Window %s %08x enabled, contact MAMEdev",STV_VDP2_W0LWE ? "0" : "1",STV_VDP2_W0LWTA); |
| 4315 | 4359 | |
| 4316 | | if(STV_VDP2_SFPRMD) |
| 4360 | /* Akumajou Dracula, bits 2-4 */ |
| 4361 | /* Arcana Strikes bit 5*/ |
| 4362 | /* Choh Makai Mura 0x0055 */ |
| 4363 | if(STV_VDP2_SFPRMD & ~0x0055) |
| 4317 | 4364 | popmessage("Special Priority Mode enabled %04x, contact MAMEdev",STV_VDP2_SFPRMD); |
| 4318 | 4365 | } |
| 4319 | 4366 | } |
| r12458 | r12459 | |
| 4796 | 4843 | (STV_VDP2_N0SWA << 6); |
| 4797 | 4844 | |
| 4798 | 4845 | stv2_current_tilemap.line_screen_enabled = STV_VDP2_N0LCEN; |
| 4846 | stv2_current_tilemap.mosaic_screen_enabled = STV_VDP2_N0MZE; |
| 4799 | 4847 | |
| 4800 | | stv2_current_tilemap.layer_name=0; |
| 4848 | stv2_current_tilemap.layer_name=(STV_VDP2_R1ON) ? 0x81 : 0; |
| 4801 | 4849 | |
| 4802 | 4850 | if ( stv2_current_tilemap.enabled && (!(STV_VDP2_R1ON))) /* TODO: check cycle pattern for RBG1 */ |
| 4803 | 4851 | { |
| r12458 | r12459 | |
| 4896 | 4944 | (STV_VDP2_N1SWA << 6); |
| 4897 | 4945 | |
| 4898 | 4946 | stv2_current_tilemap.line_screen_enabled = STV_VDP2_N1LCEN; |
| 4947 | stv2_current_tilemap.mosaic_screen_enabled = STV_VDP2_N1MZE; |
| 4899 | 4948 | |
| 4900 | 4949 | stv2_current_tilemap.layer_name=1; |
| 4901 | 4950 | |
| r12458 | r12459 | |
| 4998 | 5047 | (STV_VDP2_N2SWA << 6); |
| 4999 | 5048 | |
| 5000 | 5049 | stv2_current_tilemap.line_screen_enabled = STV_VDP2_N2LCEN; |
| 5050 | stv2_current_tilemap.mosaic_screen_enabled = STV_VDP2_N2MZE; |
| 5001 | 5051 | |
| 5002 | 5052 | stv2_current_tilemap.layer_name=2; |
| 5003 | 5053 | |
| r12458 | r12459 | |
| 5101 | 5151 | (STV_VDP2_N3SWA << 6); |
| 5102 | 5152 | |
| 5103 | 5153 | stv2_current_tilemap.line_screen_enabled = STV_VDP2_N3LCEN; |
| 5154 | stv2_current_tilemap.mosaic_screen_enabled = STV_VDP2_N3MZE; |
| 5104 | 5155 | |
| 5105 | 5156 | stv2_current_tilemap.layer_name=3; |
| 5106 | 5157 | |
| r12458 | r12459 | |
| 5375 | 5426 | stv2_current_tilemap.linezoom_enable = 0; |
| 5376 | 5427 | |
| 5377 | 5428 | stv2_current_tilemap.line_screen_enabled = STV_VDP2_R0LCEN; |
| 5429 | stv2_current_tilemap.mosaic_screen_enabled = STV_VDP2_R0MZE; |
| 5378 | 5430 | |
| 5379 | 5431 | /*Use 0x80 as a normal/rotate switch*/ |
| 5380 | 5432 | stv2_current_tilemap.layer_name=0x80; |
| r12458 | r12459 | |
| 5686 | 5738 | |
| 5687 | 5739 | if(state->m_vdp2.old_crmd != STV_VDP2_CRMD) |
| 5688 | 5740 | { |
| 5689 | | printf("%02x %02x\n",state->m_vdp2.old_crmd,STV_VDP2_CRMD); |
| 5690 | 5741 | state->m_vdp2.old_crmd = STV_VDP2_CRMD; |
| 5691 | 5742 | refresh_palette_data(space->machine()); |
| 5692 | 5743 | } |
| r12458 | r12459 | |
| 5844 | 5895 | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(stv_vdp2_exit), &machine)); |
| 5845 | 5896 | |
| 5846 | 5897 | state->m_vdp2_regs = auto_alloc_array_clear(machine, UINT32, 0x040000/4 ); |
| 5847 | | state->m_vdp2_vram = auto_alloc_array_clear(machine, UINT32, 0x100000/4 ); // actually we only need half of it since we don't emulate extra 4mbit ram cart. |
| 5898 | state->m_vdp2_vram = auto_alloc_array_clear(machine, UINT32, 0x100000/4 ); |
| 5848 | 5899 | state->m_vdp2_cram = auto_alloc_array_clear(machine, UINT32, 0x080000/4 ); |
| 5849 | 5900 | state->m_vdp2.gfx_decode = auto_alloc_array(machine, UINT8, 0x100000 ); |
| 5850 | 5901 | |