branches/kale/src/emu/bus/sega8/sega8_slot.c
| r244572 | r244573 | |
| 253 | 253 | { |
| 254 | 254 | if (!memcmp(&rom[0x7ff0], signatures[0], 16) || !memcmp(&rom[0x7ff0], signatures[1], 16)) |
| 255 | 255 | xoff = 26; |
| 256 | | |
| 257 | | if (!memcmp(&rom[0x7ff0], signatures[2], 16)) |
| 256 | else if (!memcmp(&rom[0x7ff0], signatures[2], 16)) |
| 258 | 257 | xoff = 36; |
| 259 | | |
| 260 | | if (!memcmp(&rom[0x7ff0], signatures[3], 16)) |
| 258 | else if (!memcmp(&rom[0x7ff0], signatures[3], 16)) |
| 261 | 259 | xoff = 32; |
| 262 | | |
| 263 | | if (!memcmp(&rom[0x7ff0], signatures[4], 16)) |
| 260 | else if (!memcmp(&rom[0x7ff0], signatures[4], 16)) |
| 264 | 261 | xoff = 30; |
| 265 | | |
| 266 | | if (!memcmp(&rom[0x7ff0], signatures[5], 16)) |
| 262 | else if (!memcmp(&rom[0x7ff0], signatures[5], 16)) |
| 267 | 263 | xoff = 39; |
| 268 | | |
| 269 | | if (!memcmp(&rom[0x7ff0], signatures[6], 16)) |
| 264 | else if (!memcmp(&rom[0x7ff0], signatures[6], 16)) |
| 270 | 265 | xoff = 38; |
| 271 | 266 | } |
| 272 | 267 | |
branches/kale/src/emu/bus/sms_ctrl/lphaser.c
| r244572 | r244573 | |
| 137 | 137 | { |
| 138 | 138 | const int r_x_r = LGUN_RADIUS * LGUN_RADIUS; |
| 139 | 139 | const rectangle &visarea = m_screen->visible_area(); |
| 140 | rectangle aim_area; |
| 140 | 141 | int beam_x = m_screen->hpos(); |
| 141 | 142 | int beam_y = m_screen->vpos(); |
| 142 | | int dx, dy; |
| 143 | | int result = 1; |
| 144 | | int pos_changed = 0; |
| 143 | int beam_x_orig = beam_x; |
| 144 | int beam_y_orig = beam_y; |
| 145 | int dy, result = 1; |
| 145 | 146 | double dx_radius; |
| 147 | bool new_check_point = false; |
| 146 | 148 | |
| 147 | | while (1) |
| 149 | aim_area.min_y = MAX(lgun_y - LGUN_RADIUS, visarea.min_y); |
| 150 | aim_area.max_y = MIN(lgun_y + LGUN_RADIUS, visarea.max_y); |
| 151 | |
| 152 | while (!new_check_point) |
| 148 | 153 | { |
| 149 | | /* If beam's y isn't at a line where the aim area is, change it |
| 150 | | the next line it enters that area. */ |
| 151 | | dy = abs(beam_y - lgun_y); |
| 152 | | if (dy > LGUN_RADIUS || beam_y < visarea.min_y || beam_y > visarea.max_y) |
| 154 | /* If beam's y doesn't point to a line where the aim area is, |
| 155 | change it to the first line where the beam enters that area. */ |
| 156 | if (beam_y < aim_area.min_y || beam_y > aim_area.max_y) |
| 153 | 157 | { |
| 154 | | beam_y = lgun_y - LGUN_RADIUS; |
| 155 | | if (beam_y < visarea.min_y) |
| 156 | | beam_y = visarea.min_y; |
| 157 | | dy = abs(beam_y - lgun_y); |
| 158 | | pos_changed = 1; |
| 158 | beam_y = aim_area.min_y; |
| 159 | 159 | } |
| 160 | dy = abs(beam_y - lgun_y); |
| 160 | 161 | |
| 161 | 162 | /* Caculate distance in x of the radius, relative to beam's y distance. |
| 162 | 163 | First try some shortcuts. */ |
| r244572 | r244573 | |
| 175 | 176 | dx_radius = ceil((float) sqrt((float) (r_x_r - (dy * dy)))); |
| 176 | 177 | } |
| 177 | 178 | |
| 178 | | /* If beam's x isn't in the circular aim area, change it |
| 179 | | to the next point it enters that area. */ |
| 180 | | dx = abs(beam_x - lgun_x); |
| 181 | | if (dx > dx_radius || beam_x < visarea.min_x || beam_x > visarea.max_x) |
| 179 | aim_area.min_x = MAX(lgun_x - dx_radius, visarea.min_x); |
| 180 | aim_area.max_x = MIN(lgun_x + dx_radius, visarea.max_x); |
| 181 | |
| 182 | while (!new_check_point) |
| 182 | 183 | { |
| 183 | | /* If beam's x has passed the aim area, advance to |
| 184 | | next line and recheck y/x coordinates. */ |
| 185 | | if (beam_x > lgun_x) |
| 184 | /* If beam's x has passed the aim area, change it to the |
| 185 | next line and go back to recheck y/x coordinates. */ |
| 186 | if (beam_x > aim_area.max_x) |
| 186 | 187 | { |
| 187 | | beam_x = 0; |
| 188 | beam_x = visarea.min_x; |
| 188 | 189 | beam_y++; |
| 189 | | continue; |
| 190 | break; |
| 190 | 191 | } |
| 191 | | beam_x = lgun_x - dx_radius; |
| 192 | | if (beam_x < visarea.min_x) |
| 193 | | beam_x = visarea.min_x; |
| 194 | | pos_changed = 1; |
| 195 | | } |
| 196 | 192 | |
| 197 | | if (pos_changed) |
| 198 | | break; |
| 193 | /* If beam's x isn't in the aim area, change it to the |
| 194 | next point where the beam enters that area. */ |
| 195 | if (beam_x < aim_area.min_x) |
| 196 | { |
| 197 | beam_x = aim_area.min_x; |
| 198 | } |
| 199 | 199 | |
| 200 | | if (m_sensor_last_state == 0) /* sensor is on */ |
| 201 | | { |
| 202 | | /* keep sensor on until out of the aim area */ |
| 203 | | result = 0; |
| 204 | | } |
| 205 | | else |
| 206 | | { |
| 207 | | rgb_t color; |
| 208 | | UINT8 brightness; |
| 209 | | /* brightness of the lightgray color in the frame drawn by Light Phaser games */ |
| 210 | | const UINT8 sensor_min_brightness = 0x7f; |
| 200 | if (beam_x_orig != beam_x || beam_y_orig != beam_y) |
| 201 | { |
| 202 | /* adopt the new coordinates to adjust the timer */ |
| 203 | new_check_point = true; |
| 204 | break; |
| 205 | } |
| 211 | 206 | |
| 212 | | color = m_port->pixel_r(); |
| 207 | if (m_sensor_last_state == 0) |
| 208 | { |
| 209 | /* sensor is already on */ |
| 210 | /* keep sensor on until out of the aim area */ |
| 211 | result = 0; |
| 212 | } |
| 213 | else |
| 214 | { |
| 215 | rgb_t color; |
| 216 | UINT8 brightness; |
| 217 | /* brightness of the lightgray color in the frame drawn by Light Phaser games */ |
| 218 | const UINT8 sensor_min_brightness = 0x7f; |
| 213 | 219 | |
| 214 | | /* reference: http://www.w3.org/TR/AERT#color-contrast */ |
| 215 | | brightness = (color.r() * 0.299) + (color.g() * 0.587) + (color.b() * 0.114); |
| 216 | | //printf ("color brightness: %2X for x %d y %d\n", brightness, beam_x, beam_y); |
| 220 | color = m_port->pixel_r(); |
| 217 | 221 | |
| 218 | | result = (brightness >= sensor_min_brightness) ? 0 : 1; |
| 219 | | } |
| 222 | /* reference: http://www.w3.org/TR/AERT#color-contrast */ |
| 223 | brightness = (color.r() * 0.299) + (color.g() * 0.587) + (color.b() * 0.114); |
| 224 | //printf ("color brightness: %2X for x %d y %d\n", brightness, beam_x, beam_y); |
| 220 | 225 | |
| 221 | | if (result == 0) |
| 222 | | { |
| 223 | | /* Set next check for when sensor will be off */ |
| 224 | | beam_x = lgun_x + dx_radius + 1; |
| 225 | | if (beam_x > visarea.max_x) |
| 226 | | beam_x = visarea.max_x + 1; |
| 227 | | break; |
| 226 | result = (brightness >= sensor_min_brightness) ? 0 : 1; |
| 227 | } |
| 228 | |
| 229 | if (result == 0) /* sensor on */ |
| 230 | { |
| 231 | /* Set next check for when sensor will be off */ |
| 232 | beam_x = aim_area.max_x + 1; |
| 233 | |
| 234 | /* adopt the new coordinates to adjust the timer */ |
| 235 | new_check_point = true; |
| 236 | } |
| 237 | else |
| 238 | { |
| 239 | /* Next check will happen after the minimum interval */ |
| 240 | beam_x += LGUN_X_INTERVAL; |
| 241 | } |
| 228 | 242 | } |
| 229 | | else |
| 230 | | { |
| 231 | | /* Next check after the minimum interval */ |
| 232 | | beam_x += LGUN_X_INTERVAL; |
| 233 | | pos_changed = 1; |
| 234 | | } |
| 235 | 243 | } |
| 244 | |
| 236 | 245 | timer->adjust(m_screen->time_until_pos(beam_y, beam_x)); |
| 237 | | |
| 238 | 246 | return result; |
| 239 | 247 | } |
| 240 | 248 | |
branches/kale/src/emu/video/315_5124.c
| r244572 | r244573 | |
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | set_frame_timing(); |
| 258 | m_cram_dirty = 1; |
| 259 | } |
| 260 | |
| 261 | |
| 262 | void sega315_5124_device::set_frame_timing() |
| 263 | { |
| 257 | 264 | switch (m_y_pixels) |
| 258 | 265 | { |
| 259 | | case 192: |
| 260 | | m_frame_timing = (m_is_pal) ? pal_192 : ntsc_192; |
| 261 | | break; |
| 266 | case 192: |
| 267 | m_frame_timing = (m_is_pal) ? pal_192 : ntsc_192; |
| 268 | break; |
| 262 | 269 | |
| 263 | | case 224: |
| 264 | | m_frame_timing = (m_is_pal) ? pal_224 : ntsc_224; |
| 265 | | break; |
| 270 | case 224: |
| 271 | m_frame_timing = (m_is_pal) ? pal_224 : ntsc_224; |
| 272 | break; |
| 266 | 273 | |
| 267 | | case 240: |
| 268 | | m_frame_timing = (m_is_pal) ? pal_240 : ntsc_240; |
| 269 | | break; |
| 274 | case 240: |
| 275 | m_frame_timing = (m_is_pal) ? pal_240 : ntsc_240; |
| 276 | break; |
| 270 | 277 | } |
| 271 | | m_cram_dirty = 1; |
| 272 | 278 | } |
| 273 | 279 | |
| 274 | 280 | |
| r244572 | r244573 | |
| 675 | 681 | case 2: /* VDP register write */ |
| 676 | 682 | reg_num = data & 0x0f; |
| 677 | 683 | m_reg[reg_num] = m_addr & 0xff; |
| 678 | | //logerror("%s: %s: setting register %x to %02x\n", machine().describe_context(), tag(), reg_num, m_addr & 0xf ); |
| 684 | //logerror("%s: %s: setting register %x to %02x\n", machine().describe_context(), tag(), reg_num, m_addr & 0xff); |
| 679 | 685 | |
| 680 | 686 | switch (reg_num) |
| 681 | 687 | { |
| r244572 | r244573 | |
| 1441 | 1447 | { |
| 1442 | 1448 | int i; |
| 1443 | 1449 | |
| 1444 | | /* Exit if palette is has no changes */ |
| 1450 | /* Exit if palette has no changes */ |
| 1445 | 1451 | if (m_cram_dirty == 0) |
| 1446 | 1452 | { |
| 1447 | 1453 | return; |
| r244572 | r244573 | |
| 1468 | 1474 | { |
| 1469 | 1475 | int i; |
| 1470 | 1476 | |
| 1471 | | /* Exit if palette is has no changes */ |
| 1477 | /* Exit if palette has no changes */ |
| 1472 | 1478 | if (m_cram_dirty == 0) |
| 1473 | 1479 | { |
| 1474 | 1480 | return; |
| r244572 | r244573 | |
| 1557 | 1563 | |
| 1558 | 1564 | void sega315_5124_device::vdp_postload() |
| 1559 | 1565 | { |
| 1560 | | switch (m_y_pixels) |
| 1561 | | { |
| 1562 | | case 192: |
| 1563 | | m_frame_timing = (m_is_pal) ? pal_192 : ntsc_192; |
| 1564 | | break; |
| 1565 | | |
| 1566 | | case 224: |
| 1567 | | m_frame_timing = (m_is_pal) ? pal_224 : ntsc_224; |
| 1568 | | break; |
| 1569 | | |
| 1570 | | case 240: |
| 1571 | | m_frame_timing = (m_is_pal) ? pal_240 : ntsc_240; |
| 1572 | | break; |
| 1573 | | } |
| 1566 | set_frame_timing(); |
| 1574 | 1567 | } |
| 1575 | 1568 | |
| 1576 | 1569 | void sega315_5124_device::device_start() |
branches/kale/src/mess/includes/sms.h
| r244572 | r244573 | |
| 19 | 19 | #define CONTROL1_TAG "ctrl1" |
| 20 | 20 | #define CONTROL2_TAG "ctrl2" |
| 21 | 21 | |
| 22 | #include "bus/sega8/sega8_slot.h" |
| 23 | #include "bus/sms_exp/smsexp.h" |
| 24 | #include "bus/sms_ctrl/smsctrl.h" |
| 22 | 25 | #include "bus/gamegear/ggext.h" |
| 23 | | #include "bus/sms_ctrl/smsctrl.h" |
| 24 | | #include "bus/sms_exp/smsexp.h" |
| 25 | | #include "bus/sega8/sega8_slot.h" |
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | class sms_state : public driver_device |
| r244572 | r244573 | |
| 32 | 32 | : driver_device(mconfig, type, tag), |
| 33 | 33 | m_maincpu(*this, "maincpu"), |
| 34 | 34 | m_vdp(*this, "sms_vdp"), |
| 35 | m_main_scr(*this, "screen"), |
| 35 | 36 | m_ym(*this, "ym2413"), |
| 36 | | m_main_scr(*this, "screen"), |
| 37 | | m_region_maincpu(*this, "maincpu"), |
| 38 | 37 | m_port_ctrl1(*this, CONTROL1_TAG), |
| 39 | 38 | m_port_ctrl2(*this, CONTROL2_TAG), |
| 40 | 39 | m_port_gg_ext(*this, "ext"), |
| r244572 | r244573 | |
| 45 | 44 | m_port_scope(*this, "SEGASCOPE"), |
| 46 | 45 | m_port_scope_binocular(*this, "SSCOPE_BINOCULAR"), |
| 47 | 46 | m_port_persist(*this, "PERSISTENCE"), |
| 47 | m_region_maincpu(*this, "maincpu"), |
| 48 | 48 | m_mainram(NULL), |
| 49 | 49 | m_is_gamegear(0), |
| 50 | 50 | m_is_gg_region_japan(0), |
| r244572 | r244573 | |
| 61 | 61 | // devices |
| 62 | 62 | required_device<cpu_device> m_maincpu; |
| 63 | 63 | required_device<sega315_5124_device> m_vdp; |
| 64 | required_device<screen_device> m_main_scr; |
| 64 | 65 | optional_device<ym2413_device> m_ym; |
| 65 | | required_device<screen_device> m_main_scr; |
| 66 | | required_memory_region m_region_maincpu; |
| 67 | 66 | optional_device<sms_control_port_device> m_port_ctrl1; |
| 68 | 67 | optional_device<sms_control_port_device> m_port_ctrl2; |
| 69 | 68 | optional_device<gg_ext_port_device> m_port_gg_ext; |
| 69 | |
| 70 | 70 | optional_ioport m_port_gg_dc; |
| 71 | 71 | optional_ioport m_port_pause; |
| 72 | 72 | optional_ioport m_port_reset; |
| r244572 | r244573 | |
| 75 | 75 | optional_ioport m_port_scope_binocular; |
| 76 | 76 | optional_ioport m_port_persist; |
| 77 | 77 | |
| 78 | required_memory_region m_region_maincpu; |
| 78 | 79 | address_space *m_space; |
| 79 | 80 | UINT8 *m_mainram; |
| 80 | 81 | UINT8 *m_BIOS; |
| r244572 | r244573 | |
| 121 | 122 | UINT8 m_gg_sio[5]; |
| 122 | 123 | int m_paused; |
| 123 | 124 | |
| 124 | | // Data needed for Light Phaser |
| 125 | 125 | UINT8 m_ctrl1_th_state; |
| 126 | 126 | UINT8 m_ctrl2_th_state; |
| 127 | 127 | UINT8 m_ctrl1_th_latch; |
| 128 | 128 | UINT8 m_ctrl2_th_latch; |
| 129 | |
| 130 | // Data needed for Light Phaser |
| 129 | 131 | int m_lphaser_x_offs; /* Needed to 'calibrate' lphaser; set at cart loading */ |
| 130 | 132 | |
| 131 | 133 | // Data needed for SegaScope (3D glasses) |
| r244572 | r244573 | |
| 160 | 162 | DECLARE_READ8_MEMBER(sms_input_port_dc_r); |
| 161 | 163 | DECLARE_READ8_MEMBER(sms_input_port_dd_r); |
| 162 | 164 | DECLARE_READ8_MEMBER(gg_input_port_00_r); |
| 165 | DECLARE_READ8_MEMBER(gg_sio_r); |
| 163 | 166 | DECLARE_WRITE8_MEMBER(gg_sio_w); |
| 164 | | DECLARE_READ8_MEMBER(gg_sio_r); |
| 167 | DECLARE_READ8_MEMBER(sms_fm_detect_r); |
| 165 | 168 | DECLARE_WRITE8_MEMBER(sms_fm_detect_w); |
| 166 | | DECLARE_READ8_MEMBER(sms_fm_detect_r); |
| 167 | 169 | DECLARE_WRITE8_MEMBER(sms_ym2413_register_port_w); |
| 168 | 170 | DECLARE_WRITE8_MEMBER(sms_ym2413_data_port_w); |
| 169 | 171 | DECLARE_READ8_MEMBER(sms_sscope_r); |