src/mess/drivers/sg1000.c
| r3788 | r3789 | |
| 53 | 53 | |
| 54 | 54 | TODO: |
| 55 | 55 | |
| 56 | - move variables to driver state |
| 56 | 57 | - OMV keyboard |
| 57 | 58 | - SC-3000 return instruction referenced by R when reading ports 60-7f,e0-ff |
| 58 | 59 | - connect the PSG /READY signal |
| r3788 | r3789 | |
| 76 | 77 | #include "sound/sn76496.h" |
| 77 | 78 | #include "video/tms9928a.h" |
| 78 | 79 | |
| 80 | #define IS_CARTRIDGE_TV_DRAW(ptr) \ |
| 81 | (!strncmp("annakmn", (const char *)&##ptr[0x13b3], 7)) |
| 82 | |
| 83 | #define IS_CARTRIDGE_THE_CASTLE(ptr) \ |
| 84 | (!strncmp("ASCII 1986", (const char *)&##ptr[0x1cc3], 10)) |
| 85 | |
| 86 | #define IS_CARTRIDGE_BASIC_LEVEL_III(ptr) \ |
| 87 | (!strncmp("SC-3000 BASIC Level 3 ver 1.0", (const char *)&##ptr[0x6a20], 29)) |
| 88 | |
| 89 | #define IS_CARTRIDGE_MUSIC_EDITOR(ptr) \ |
| 90 | (!strncmp("PIANO", (const char *)&##ptr[0x0841], 5)) |
| 91 | |
| 79 | 92 | static const device_config *cassette_device_image(running_machine *machine) |
| 80 | 93 | { |
| 81 | | return device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette" ); |
| 94 | return devtag_get_device(machine, CASSETTE, "cassette"); |
| 82 | 95 | } |
| 83 | 96 | |
| 84 | 97 | /* Terebi Oekaki (TV Draw) */ |
| r3788 | r3789 | |
| 453 | 466 | { |
| 454 | 467 | UINT8 *rom = memory_region(machine, "main"); |
| 455 | 468 | |
| 456 | | if (!strncmp("annakmn", (const char *)&rom[0x13b3], 7)) |
| 469 | if (IS_CARTRIDGE_TV_DRAW(rom)) |
| 457 | 470 | { |
| 458 | 471 | /* enable crosshair for TV Draw */ |
| 459 | 472 | crosshair_set_screen(machine, 0, CROSSHAIR_SCREEN_ALL); |
| r3788 | r3789 | |
| 811 | 824 | MDRV_MACHINE_START( sf7000 ) |
| 812 | 825 | MDRV_MACHINE_RESET( sf7000 ) |
| 813 | 826 | |
| 814 | | MDRV_DEVICE_ADD( "ppi8255_0", PPI8255 ) |
| 815 | | MDRV_DEVICE_CONFIG( sf7000_ppi8255_intf[0] ) |
| 827 | MDRV_DEVICE_ADD("ppi8255_0", PPI8255) |
| 828 | MDRV_DEVICE_CONFIG( sf7000_ppi8255_intf[0]) |
| 816 | 829 | |
| 817 | | MDRV_DEVICE_ADD( "ppi8255_1", PPI8255 ) |
| 818 | | MDRV_DEVICE_CONFIG( sf7000_ppi8255_intf[1] ) |
| 830 | MDRV_DEVICE_ADD("ppi8255_1", PPI8255) |
| 831 | MDRV_DEVICE_CONFIG( sf7000_ppi8255_intf[1]) |
| 819 | 832 | |
| 820 | 833 | /* video hardware */ |
| 821 | 834 | MDRV_IMPORT_FROM(tms9928a) |
| r3788 | r3789 | |
| 833 | 846 | MDRV_DEVICE_ADD("sp400", PRINTER) |
| 834 | 847 | |
| 835 | 848 | /* cassette */ |
| 836 | | MDRV_CASSETTE_ADD( "cassette", sc3000_cassette_config ) |
| 849 | MDRV_CASSETTE_ADD("cassette", sc3000_cassette_config) |
| 837 | 850 | |
| 838 | 851 | /* uart */ |
| 839 | 852 | MDRV_DEVICE_ADD("uart", MSM8251) |
| r3788 | r3789 | |
| 876 | 889 | |
| 877 | 890 | static void sg1000_map_cartridge_memory(running_machine *machine, UINT8 *ptr, int size) |
| 878 | 891 | { |
| 879 | | const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 892 | const address_space *program = cputag_get_address_space(machine, "main", ADDRESS_SPACE_PROGRAM); |
| 880 | 893 | |
| 881 | 894 | switch (size) |
| 882 | 895 | { |
| 883 | 896 | case 40 * 1024: |
| 884 | | memory_install_readwrite8_handler(space, 0x8000, 0x9fff, 0, 0, SMH_BANK1, SMH_UNMAP); |
| 897 | memory_install_readwrite8_handler(program, 0x8000, 0x9fff, 0, 0, SMH_BANK1, SMH_UNMAP); |
| 885 | 898 | memory_configure_bank(machine, 1, 0, 1, memory_region(machine, "main") + 0x8000, 0); |
| 886 | 899 | memory_set_bank(machine, 1, 0); |
| 887 | 900 | break; |
| 888 | 901 | |
| 889 | 902 | case 48 * 1024: |
| 890 | | memory_install_readwrite8_handler(space, 0x8000, 0xbfff, 0, 0, SMH_BANK1, SMH_UNMAP); |
| 903 | memory_install_readwrite8_handler(program, 0x8000, 0xbfff, 0, 0, SMH_BANK1, SMH_UNMAP); |
| 891 | 904 | memory_configure_bank(machine, 1, 0, 1, memory_region(machine, "main") + 0x8000, 0); |
| 892 | 905 | memory_set_bank(machine, 1, 0); |
| 893 | 906 | break; |
| 894 | 907 | |
| 895 | 908 | default: |
| 896 | | if (!strncmp("annakmn", (const char *)&ptr[0x13b3], 7)) |
| 909 | if (IS_CARTRIDGE_TV_DRAW(ptr)) |
| 897 | 910 | { |
| 898 | | /* Terebi Oekaki */ |
| 899 | | memory_install_write8_handler(space, 0x6000, 0x6000, 0, 0, &tvdraw_axis_w); |
| 900 | | memory_install_read8_handler(space, 0x8000, 0x8000, 0, 0, &tvdraw_status_r); |
| 901 | | memory_install_readwrite8_handler(space, 0xa000, 0xa000, 0, 0, &tvdraw_data_r, SMH_NOP); |
| 911 | memory_install_write8_handler(program, 0x6000, 0x6000, 0, 0, &tvdraw_axis_w); |
| 912 | memory_install_read8_handler(program, 0x8000, 0x8000, 0, 0, &tvdraw_status_r); |
| 913 | memory_install_readwrite8_handler(program, 0xa000, 0xa000, 0, 0, &tvdraw_data_r, SMH_NOP); |
| 902 | 914 | } |
| 903 | | else if (!strncmp("ASCII 1986", (const char *)&ptr[0x1cc3], 10)) |
| 915 | else if (IS_CARTRIDGE_THE_CASTLE(ptr)) |
| 904 | 916 | { |
| 905 | | /* The Castle */ |
| 906 | | memory_install_readwrite8_handler(space, 0x8000, 0x9fff, 0, 0, SMH_BANK1, SMH_BANK1); |
| 917 | memory_install_readwrite8_handler(program, 0x8000, 0x9fff, 0, 0, SMH_BANK1, SMH_BANK1); |
| 907 | 918 | } |
| 908 | 919 | break; |
| 909 | 920 | } |
| r3788 | r3789 | |
| 911 | 922 | |
| 912 | 923 | static DEVICE_IMAGE_LOAD( sg1000_cart ) |
| 913 | 924 | { |
| 925 | const address_space *program = cputag_get_address_space(image->machine, "main", ADDRESS_SPACE_PROGRAM); |
| 914 | 926 | int size = image_length(image); |
| 915 | 927 | UINT8 *ptr = memory_region(image->machine, "main"); |
| 916 | 928 | |
| r3788 | r3789 | |
| 923 | 935 | sg1000_map_cartridge_memory(image->machine, ptr, size); |
| 924 | 936 | |
| 925 | 937 | /* work RAM banking */ |
| 926 | | memory_install_readwrite8_handler(cpu_get_address_space(image->machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xc000, 0xc3ff, 0, 0x3c00, SMH_BANK2, SMH_BANK2); |
| 938 | memory_install_readwrite8_handler(program, 0xc000, 0xc3ff, 0, 0x3c00, SMH_BANK2, SMH_BANK2); |
| 927 | 939 | |
| 928 | 940 | return INIT_PASS; |
| 929 | 941 | } |
| r3788 | r3789 | |
| 948 | 960 | |
| 949 | 961 | static void sc3000_map_cartridge_memory(running_machine *machine, UINT8 *ptr, int size) |
| 950 | 962 | { |
| 963 | const address_space *program = cputag_get_address_space(machine, "main", ADDRESS_SPACE_PROGRAM); |
| 964 | |
| 951 | 965 | /* include SG-1000 mapping */ |
| 952 | 966 | sg1000_map_cartridge_memory(machine, ptr, size); |
| 953 | 967 | |
| 954 | | if (!strncmp("SC-3000 BASIC Level 3 ver 1.0", (const char *)&ptr[0x6a20], 29)) |
| 968 | if (IS_CARTRIDGE_BASIC_LEVEL_III(ptr)) |
| 955 | 969 | { |
| 956 | | /* SC-3000 BASIC Level III */ |
| 957 | | memory_install_readwrite8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x8000, 0xbfff, 0, 0, SMH_BANK1, SMH_BANK1); |
| 958 | | memory_install_readwrite8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xc000, 0xffff, 0, 0, SMH_BANK2, SMH_BANK2); |
| 970 | memory_install_readwrite8_handler(program, 0x8000, 0xbfff, 0, 0, SMH_BANK1, SMH_BANK1); |
| 971 | memory_install_readwrite8_handler(program, 0xc000, 0xffff, 0, 0, SMH_BANK2, SMH_BANK2); |
| 959 | 972 | } |
| 960 | | else if (!strncmp("PIANO", (const char *)&ptr[0x0841], 5)) |
| 973 | else if (IS_CARTRIDGE_MUSIC_EDITOR(ptr)) |
| 961 | 974 | { |
| 962 | | /* Sega SC-3000 Music Editor */ |
| 963 | | memory_install_readwrite8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x8000, 0x9fff, 0, 0, SMH_BANK1, SMH_BANK1); |
| 964 | | memory_install_readwrite8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xc000, 0xc7ff, 0, 0x3800, SMH_BANK2, SMH_BANK2); |
| 975 | memory_install_readwrite8_handler(program, 0x8000, 0x9fff, 0, 0, SMH_BANK1, SMH_BANK1); |
| 976 | memory_install_readwrite8_handler(program, 0xc000, 0xc7ff, 0, 0x3800, SMH_BANK2, SMH_BANK2); |
| 965 | 977 | } |
| 966 | 978 | else |
| 967 | 979 | { |
| 968 | 980 | /* regular cartridges */ |
| 969 | | memory_install_readwrite8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xc000, 0xc7ff, 0, 0x3800, SMH_BANK2, SMH_BANK2); |
| 981 | memory_install_readwrite8_handler(program, 0xc000, 0xc7ff, 0, 0x3800, SMH_BANK2, SMH_BANK2); |
| 970 | 982 | } |
| 971 | 983 | } |
| 972 | 984 | |
| 973 | 985 | static DEVICE_IMAGE_LOAD( sc3000_cart ) |
| 974 | 986 | { |
| 987 | const address_space *program = cputag_get_address_space(image->machine, "main", ADDRESS_SPACE_PROGRAM); |
| 975 | 988 | int size = image_length(image); |
| 976 | 989 | UINT8 *ptr = memory_region(image->machine, "main"); |
| 977 | 990 | |