src/mess/machine/sms.c
| r14911 | r14912 | |
| 734 | 734 | WRITE8_HANDLER( sms_io_control_w ) |
| 735 | 735 | { |
| 736 | 736 | sms_state *state = space->machine().driver_data<sms_state>(); |
| 737 | bool hcount_latch = false; |
| 737 | 738 | |
| 738 | 739 | if (data & 0x08) |
| 739 | 740 | { |
| 740 | 741 | /* check if TH pin level is high (1) and was low last time */ |
| 741 | 742 | if (data & 0x80 && !(state->m_ctrl_reg & 0x80)) |
| 742 | 743 | { |
| 743 | | sms_vdp_hcount_latch(space); |
| 744 | hcount_latch = true; |
| 744 | 745 | } |
| 745 | 746 | sms_input_write(space, 0, (data & 0x20) >> 5); |
| 746 | 747 | } |
| r14911 | r14912 | |
| 749 | 750 | { |
| 750 | 751 | if (data & 0x20 && !(state->m_ctrl_reg & 0x20)) |
| 751 | 752 | { |
| 752 | | sms_vdp_hcount_latch(space); |
| 753 | hcount_latch = true; |
| 753 | 754 | } |
| 754 | 755 | sms_input_write(space, 1, (data & 0x80) >> 7); |
| 755 | 756 | } |
| 756 | 757 | |
| 758 | if (hcount_latch) |
| 759 | { |
| 760 | sms_vdp_hcount_latch(space); |
| 761 | } |
| 762 | |
| 757 | 763 | state->m_ctrl_reg = data; |
| 758 | 764 | } |
| 759 | 765 | |
| r14911 | r14912 | |
| 2213 | 2219 | } |
| 2214 | 2220 | |
| 2215 | 2221 | |
| 2216 | | static void sms_black_bitmap( const screen_device &screen, bitmap_rgb32 &bitmap ) |
| 2217 | | { |
| 2218 | | const int width = screen.width(); |
| 2219 | | const int height = screen.height(); |
| 2220 | | int x, y; |
| 2221 | | |
| 2222 | | for (y = 0; y < height; y++) |
| 2223 | | for (x = 0; x < width; x++) |
| 2224 | | bitmap.pix32(y, x) = MAKE_RGB(0,0,0); |
| 2225 | | } |
| 2226 | | |
| 2227 | 2222 | VIDEO_START( sms1 ) |
| 2228 | 2223 | { |
| 2229 | 2224 | sms_state *state = machine.driver_data<sms_state>(); |
| r14911 | r14912 | |
| 2238 | 2233 | SCREEN_UPDATE_RGB32( sms1 ) |
| 2239 | 2234 | { |
| 2240 | 2235 | sms_state *state = screen.machine().driver_data<sms_state>(); |
| 2241 | | UINT8 sscope = input_port_read_safe(screen.machine(), "SEGASCOPE", 0x00); |
| 2242 | | UINT8 sscope_binocular_hack = input_port_read_safe(screen.machine(), "SSCOPE_BINOCULAR", 0x00); |
| 2236 | UINT8 sscope = 0; |
| 2237 | UINT8 sscope_binocular_hack; |
| 2243 | 2238 | UINT8 occluded_view = 0; |
| 2244 | 2239 | |
| 2245 | | // without SegaScope, both LCDs for glasses go black |
| 2246 | | if ((&screen != state->m_main_scr) && !sscope) |
| 2247 | | occluded_view = 1; |
| 2240 | if (&screen != state->m_main_scr) |
| 2241 | { |
| 2242 | sscope = input_port_read_safe(screen.machine(), "SEGASCOPE", 0x00); |
| 2243 | if (!sscope) |
| 2244 | { |
| 2245 | occluded_view = 1; |
| 2246 | } |
| 2247 | else if (&screen == state->m_left_lcd) |
| 2248 | { |
| 2249 | // with SegaScope, sscope_state 0 = left screen OFF, right screen ON |
| 2250 | if (!(state->m_sscope_state & 0x01)) |
| 2251 | occluded_view = 1; |
| 2252 | } |
| 2253 | else // it's right LCD |
| 2254 | { |
| 2255 | // with SegaScope, sscope_state 1 = left screen ON, right screen OFF |
| 2256 | if (state->m_sscope_state & 0x01) |
| 2257 | occluded_view = 1; |
| 2258 | } |
| 2259 | } |
| 2248 | 2260 | |
| 2249 | | // with SegaScope, sscope_state 0 = left screen OFF, right screen ON |
| 2250 | | if (!(state->m_sscope_state & 0x01) && (&screen == state->m_left_lcd)) |
| 2251 | | occluded_view = 1; |
| 2252 | | |
| 2253 | | // with SegaScope, sscope_state 1 = left screen ON, right screen OFF |
| 2254 | | if ((state->m_sscope_state & 0x01) && (&screen == state->m_right_lcd)) |
| 2255 | | occluded_view = 1; |
| 2256 | | |
| 2257 | 2261 | if (!occluded_view) |
| 2258 | 2262 | { |
| 2259 | 2263 | state->m_vdp->screen_update(screen, bitmap, cliprect); |
| 2260 | 2264 | |
| 2261 | 2265 | // HACK: fake 3D->2D handling (if enabled, it repeats each frame twice on the selected lens) |
| 2262 | 2266 | // save a copy of current bitmap for the binocular hack |
| 2263 | | if (sscope && (&screen == state->m_left_lcd) && (sscope_binocular_hack & 0x01)) |
| 2264 | | copybitmap(state->m_prevleft_bitmap, bitmap, 0, 0, 0, 0, cliprect); |
| 2265 | | if (sscope && (&screen == state->m_right_lcd) && (sscope_binocular_hack & 0x02)) |
| 2266 | | copybitmap(state->m_prevright_bitmap, bitmap, 0, 0, 0, 0, cliprect); |
| 2267 | if (sscope) |
| 2268 | { |
| 2269 | sscope_binocular_hack = input_port_read_safe(screen.machine(), "SSCOPE_BINOCULAR", 0x00); |
| 2270 | |
| 2271 | if (&screen == state->m_left_lcd) |
| 2272 | { |
| 2273 | if (sscope_binocular_hack & 0x01) |
| 2274 | copybitmap(state->m_prevleft_bitmap, bitmap, 0, 0, 0, 0, cliprect); |
| 2275 | } |
| 2276 | else // it's right LCD |
| 2277 | { |
| 2278 | if (sscope_binocular_hack & 0x02) |
| 2279 | copybitmap(state->m_prevright_bitmap, bitmap, 0, 0, 0, 0, cliprect); |
| 2280 | } |
| 2281 | } |
| 2267 | 2282 | } |
| 2268 | 2283 | else |
| 2269 | 2284 | { |
| 2270 | | sms_black_bitmap(screen, bitmap); |
| 2271 | | |
| 2272 | 2285 | // HACK: fake 3D->2D handling (if enabled, it repeats each frame twice on the selected lens) |
| 2273 | 2286 | // use the copied bitmap for the binocular hack |
| 2274 | | if (sscope && (&screen == state->m_left_lcd) && (sscope_binocular_hack & 0x01)) |
| 2275 | | copybitmap(bitmap, state->m_prevleft_bitmap, 0, 0, 0, 0, cliprect); |
| 2276 | | if (sscope && (&screen == state->m_right_lcd) && (sscope_binocular_hack & 0x02)) |
| 2277 | | copybitmap(bitmap, state->m_prevright_bitmap, 0, 0, 0, 0, cliprect); |
| 2287 | if (sscope) |
| 2288 | { |
| 2289 | sscope_binocular_hack = input_port_read_safe(screen.machine(), "SSCOPE_BINOCULAR", 0x00); |
| 2290 | |
| 2291 | if (&screen == state->m_left_lcd) |
| 2292 | { |
| 2293 | if (sscope_binocular_hack & 0x01) |
| 2294 | { |
| 2295 | copybitmap(bitmap, state->m_prevleft_bitmap, 0, 0, 0, 0, cliprect); |
| 2296 | return 0; |
| 2297 | } |
| 2298 | } |
| 2299 | else // it's right LCD |
| 2300 | { |
| 2301 | if (sscope_binocular_hack & 0x02) |
| 2302 | { |
| 2303 | copybitmap(bitmap, state->m_prevright_bitmap, 0, 0, 0, 0, cliprect); |
| 2304 | return 0; |
| 2305 | } |
| 2306 | } |
| 2307 | } |
| 2308 | bitmap.fill(RGB_BLACK); |
| 2278 | 2309 | } |
| 2279 | 2310 | |
| 2280 | 2311 | return 0; |
| r14911 | r14912 | |
| 2293 | 2324 | screen_device *screen = machine.first_screen(); |
| 2294 | 2325 | |
| 2295 | 2326 | screen->register_screen_bitmap(state->m_prev_bitmap); |
| 2296 | | screen->register_screen_bitmap(state->m_tmp_bitmap); |
| 2297 | 2327 | state->save_item(NAME(state->m_prev_bitmap)); |
| 2298 | 2328 | } |
| 2299 | 2329 | |
| r14911 | r14912 | |
| 2304 | 2334 | int height = screen.height(); |
| 2305 | 2335 | int x, y; |
| 2306 | 2336 | |
| 2307 | | state->m_vdp->screen_update(screen, state->m_tmp_bitmap, cliprect); |
| 2337 | bitmap_rgb32 &vdp_bitmap = state->m_vdp->get_bitmap(); |
| 2308 | 2338 | |
| 2309 | 2339 | // HACK: fake LCD persistence effect |
| 2310 | 2340 | // (it would be better to generalize this in the core, to be used for all LCD systems) |
| 2311 | 2341 | for (y = 0; y < height; y++) |
| 2312 | 2342 | { |
| 2313 | | UINT32 *line0 = &state->m_tmp_bitmap.pix32(y); |
| 2343 | UINT32 *linedst = &bitmap.pix32(y); |
| 2344 | UINT32 *line0 = &vdp_bitmap.pix32(y); |
| 2314 | 2345 | UINT32 *line1 = &state->m_prev_bitmap.pix32(y); |
| 2315 | 2346 | for (x = 0; x < width; x++) |
| 2316 | 2347 | { |
| r14911 | r14912 | |
| 2325 | 2356 | UINT8 r = (UINT8)((r0 + r1) >> 1); |
| 2326 | 2357 | UINT8 g = (UINT8)((g0 + g1) >> 1); |
| 2327 | 2358 | UINT8 b = (UINT8)((b0 + b1) >> 1); |
| 2328 | | bitmap.pix32(y, x) = (r << 16) | (g << 8) | b; |
| 2359 | linedst[x] = (r << 16) | (g << 8) | b; |
| 2329 | 2360 | } |
| 2330 | 2361 | } |
| 2331 | | copybitmap(state->m_prev_bitmap, state->m_tmp_bitmap, 0, 0, 0, 0, cliprect); |
| 2362 | copybitmap(state->m_prev_bitmap, vdp_bitmap, 0, 0, 0, 0, cliprect); |
| 2332 | 2363 | |
| 2333 | 2364 | return 0; |
| 2334 | 2365 | } |