src/mess/machine/sms.c
| r6326 | r6327 | |
| 76 | 76 | /* Data needed for SegaScope (3D glasses) */ |
| 77 | 77 | UINT8 sscope_state; |
| 78 | 78 | |
| 79 | /* Data needed for Terebi Oekaki (TV Draw) */ |
| 80 | UINT8 tvdraw_data; |
| 81 | |
| 79 | 82 | /* Cartridge slot info */ |
| 80 | 83 | UINT8 current_cartridge; |
| 81 | 84 | struct |
| r6326 | r6327 | |
| 156 | 159 | |
| 157 | 160 | static TIMER_CALLBACK( lightgun_tick ) |
| 158 | 161 | { |
| 162 | /* is there a Light Phaser in P1 port? */ |
| 159 | 163 | if ((input_port_read_safe(machine, "CTRLSEL", 0x00) & 0x0f) == 0x01) |
| 160 | | { |
| 161 | | /* enable crosshair */ |
| 162 | | crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_ALL); |
| 163 | | } |
| 164 | crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_ALL); /* enable crosshair */ |
| 164 | 165 | else |
| 165 | | { |
| 166 | | /* disable crosshair */ |
| 167 | | crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_NONE); |
| 168 | | } |
| 166 | crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_NONE); /* disable crosshair */ |
| 169 | 167 | |
| 168 | /* is there a Light Phaser in P2 port? */ |
| 170 | 169 | if ((input_port_read_safe(machine, "CTRLSEL", 0x00) & 0xf0) == 0x10) |
| 171 | | { |
| 172 | | /* enable crosshair */ |
| 173 | | crosshair_set_screen(machine, 1, CROSSHAIR_SCREEN_ALL); |
| 174 | | } |
| 170 | crosshair_set_screen(machine, 1, CROSSHAIR_SCREEN_ALL); /* enable crosshair */ |
| 175 | 171 | else |
| 176 | | { |
| 177 | | /* disable crosshair */ |
| 178 | | crosshair_set_screen(machine, 1, CROSSHAIR_SCREEN_NONE); |
| 179 | | } |
| 172 | crosshair_set_screen(machine, 1, CROSSHAIR_SCREEN_NONE); /* disable crosshair */ |
| 180 | 173 | } |
| 181 | 174 | |
| 182 | 175 | |
| r6326 | r6327 | |
| 621 | 614 | return sms_state.mapper[offset]; |
| 622 | 615 | } |
| 623 | 616 | |
| 617 | /* Terebi Oekaki */ |
| 618 | /* The following code comes from sg1000.c. We should eventually merge these TV Draw implementations */ |
| 619 | static WRITE8_HANDLER( sms_tvdraw_axis_w ) |
| 620 | { |
| 621 | UINT8 tvboard_on = input_port_read_safe(space->machine, "TVDRAW", 0x00); |
| 622 | if (data & 0x01) |
| 623 | { |
| 624 | sms_state.tvdraw_data = tvboard_on ? input_port_read(space->machine, "TVDRAW_X") : 0x80; |
| 624 | 625 | |
| 626 | if (sms_state.tvdraw_data < 4) sms_state.tvdraw_data = 4; |
| 627 | if (sms_state.tvdraw_data > 251) sms_state.tvdraw_data = 251; |
| 628 | } |
| 629 | else |
| 630 | { |
| 631 | sms_state.tvdraw_data = tvboard_on ? input_port_read(space->machine, "TVDRAW_Y") + 0x20 : 0x80; |
| 632 | } |
| 633 | } |
| 634 | |
| 635 | static READ8_HANDLER( sms_tvdraw_status_r ) |
| 636 | { |
| 637 | UINT8 tvboard_on = input_port_read_safe(space->machine, "TVDRAW", 0x00); |
| 638 | return tvboard_on ? input_port_read(space->machine, "TVDRAW_PEN") : 0x01; |
| 639 | } |
| 640 | |
| 641 | static READ8_HANDLER( sms_tvdraw_data_r ) |
| 642 | { |
| 643 | return sms_state.tvdraw_data; |
| 644 | } |
| 645 | |
| 646 | |
| 625 | 647 | WRITE8_HANDLER( sms_mapper_w ) |
| 626 | 648 | { |
| 627 | 649 | int page; |
| r6326 | r6327 | |
| 1133 | 1155 | return 0; |
| 1134 | 1156 | } |
| 1135 | 1157 | |
| 1158 | |
| 1159 | static int detect_tvdraw( UINT8 *rom ) |
| 1160 | { |
| 1161 | static const UINT8 terebi_oekaki[7] = { 0x61, 0x6e, 0x6e, 0x61, 0x6b, 0x6d, 0x6e }; // "annakmn" |
| 1162 | |
| 1163 | if (!memcmp(&rom[0x13b3], terebi_oekaki, 7)) |
| 1164 | return 1; |
| 1165 | |
| 1166 | return 0; |
| 1167 | } |
| 1168 | |
| 1169 | |
| 1136 | 1170 | static int detect_lphaser_xoffset( UINT8 *rom ) |
| 1137 | 1171 | { |
| 1138 | 1172 | static const UINT8 signatures[6][16] = |
| r6326 | r6327 | |
| 1291 | 1325 | sms_state.cartridge[index].features |= CF_GG_SMS_MODE; |
| 1292 | 1326 | |
| 1293 | 1327 | /* Check for 93C46 eeprom */ |
| 1294 | | if (strstr( extrainfo, "93C46")) |
| 1328 | if (strstr(extrainfo, "93C46")) |
| 1295 | 1329 | sms_state.cartridge[index].features |= CF_93C46_EEPROM; |
| 1296 | 1330 | |
| 1297 | 1331 | /* Check for 8KB on-cart RAM */ |
| r6326 | r6327 | |
| 1336 | 1370 | /* For Light Phaser games, we have to detect the x offset */ |
| 1337 | 1371 | sms_state.lphaser_x_offs = detect_lphaser_xoffset(sms_state.cartridge[index].ROM); |
| 1338 | 1372 | |
| 1373 | /* Terebi Oekaki (TV Draw) is a SG1000 game with special input device which is compatible with SG1000 Mark III */ |
| 1374 | if ((detect_tvdraw(sms_state.cartridge[index].ROM)) && sms_state.is_region_japan) |
| 1375 | { |
| 1376 | const address_space *program = cputag_get_address_space(image->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 1377 | memory_install_write8_handler(program, 0x6000, 0x6000, 0, 0, &sms_tvdraw_axis_w); |
| 1378 | memory_install_read8_handler(program, 0x8000, 0x8000, 0, 0, &sms_tvdraw_status_r); |
| 1379 | memory_install_readwrite8_handler(program, 0xa000, 0xa000, 0, 0, &sms_tvdraw_data_r, SMH_NOP); |
| 1380 | } |
| 1381 | |
| 1339 | 1382 | /* Load battery backed RAM, if available */ |
| 1340 | 1383 | image_battery_load(image, sms_state.cartridge[index].cartSRAM, sizeof(UINT8) * NVRAM_SIZE); |
| 1341 | 1384 | |
| r6326 | r6327 | |
| 1467 | 1510 | |
| 1468 | 1511 | sms_state.sscope_state = 0; |
| 1469 | 1512 | |
| 1513 | sms_state.tvdraw_data = 0; |
| 1514 | |
| 1470 | 1515 | /* Check if lightgun has been chosen as input: if so, enable crosshair */ |
| 1471 | 1516 | timer_set(space->machine, attotime_zero, NULL, 0, lightgun_tick); |
| 1472 | 1517 | } |
src/mess/drivers/sms.c
| r6326 | r6327 | |
| 252 | 252 | PORT_CONFSETTING( 0x01, DEF_STR( On ) ) |
| 253 | 253 | INPUT_PORTS_END |
| 254 | 254 | |
| 255 | static INPUT_PORTS_START( smsj ) |
| 256 | PORT_INCLUDE( sms1 ) |
| 257 | |
| 258 | PORT_START("TVDRAW") |
| 259 | PORT_CONFNAME( 0x01, 0x00, "Terebi Oekaki Graphics Tablet" ) |
| 260 | PORT_CONFSETTING( 0x00, DEF_STR( Off ) ) |
| 261 | PORT_CONFSETTING( 0x01, DEF_STR( On ) ) |
| 262 | |
| 263 | PORT_START("TVDRAW_X") |
| 264 | PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_X ) PORT_NAME("Tablet - X Axis") PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(50) PORT_KEYDELTA(10) PORT_PLAYER(1) |
| 265 | PORT_CONDITION("TVDRAW", 0x01, PORTCOND_EQUALS, 0x01) |
| 266 | |
| 267 | PORT_START("TVDRAW_Y") |
| 268 | PORT_BIT( 0xff, 0x60, IPT_LIGHTGUN_Y ) PORT_NAME("Tablet - Y Axis") PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_MINMAX(0, 191) PORT_SENSITIVITY(50) PORT_KEYDELTA(10) PORT_PLAYER(1) |
| 269 | PORT_CONDITION("TVDRAW", 0x01, PORTCOND_EQUALS, 0x01) |
| 270 | |
| 271 | PORT_START("TVDRAW_PEN") |
| 272 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Tablet - Pen") PORT_CONDITION("TVDRAW", 0x01, PORTCOND_EQUALS, 0x01) |
| 273 | INPUT_PORTS_END |
| 274 | |
| 255 | 275 | static INPUT_PORTS_START( gg ) |
| 256 | 276 | PORT_START("PORT_DC") |
| 257 | 277 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1) PORT_8WAY |
| r6326 | r6327 | |
| 796 | 816 | ***************************************************************************/ |
| 797 | 817 | |
| 798 | 818 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS */ |
| 799 | | CONS( 1984, sg1000m3, sms, 0, sg1000m3, sms1, sg1000m3, 0, "Sega", "SG-1000 Mark III", 0 ) |
| 819 | CONS( 1984, sg1000m3, sms, 0, sg1000m3, smsj, sg1000m3, 0, "Sega", "SG-1000 Mark III", 0 ) |
| 800 | 820 | CONS( 1986, sms1, sms, 0, sms1_ntsc, sms1, sms1, 0, "Sega", "Master System I", 0 ) |
| 801 | 821 | CONS( 1986, sms1pal, sms, 0, sms1_pal, sms1, sms1, 0, "Sega", "Master System I (PAL)" , 0 ) |
| 802 | 822 | CONS( 1986, smssdisp, sms, 0, sms_sdisp, sms, smssdisp, 0, "Sega", "Master System Store Display Unit", GAME_NOT_WORKING ) |
| 803 | | CONS( 1987, smsj, sms, 0, sms_fm, sms1, smsj, 0, "Sega", "Master System (Japan)", 0 ) |
| 823 | CONS( 1987, smsj, sms, 0, sms_fm, smsj, smsj, 0, "Sega", "Master System (Japan)", 0 ) |
| 804 | 824 | CONS( 1990, sms, 0, 0, sms2_ntsc, sms, sms1, 0, "Sega", "Master System II", 0 ) |
| 805 | 825 | CONS( 1990, smspal, sms, 0, sms2_pal, sms, sms1, 0, "Sega", "Master System II (PAL)", 0 ) |
| 806 | 826 | CONS( 1990, sms2kr, sms, 0, sms2_fm, sms, sms2kr, 0, "Samsung", "Gam*Boy II (Korea)", 0 ) |