src/mess/machine/msx.c
| r12476 | r12477 | |
| 111 | 111 | return IMAGE_INIT_FAIL; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | | size = image.length (); |
| 115 | | if (size < 0x2000) { |
| 116 | | logerror ("cart #%d: error: file is smaller than 2kb, too small " |
| 117 | | "to be true!\n", id); |
| 118 | | return IMAGE_INIT_FAIL; |
| 119 | | } |
| 114 | if ( image.software_entry() != NULL ) |
| 115 | { |
| 116 | /* Load software from software list */ |
| 117 | /* TODO: Add proper SRAM (size) handling */ |
| 120 | 118 | |
| 121 | | /* allocate memory and load */ |
| 122 | | size_aligned = 0x2000; |
| 123 | | while (size_aligned < size) { |
| 124 | | size_aligned *= 2; |
| 125 | | } |
| 126 | | mem = auto_alloc_array(image.device().machine(),UINT8,size_aligned); |
| 127 | | if (!mem) { |
| 128 | | logerror ("cart #%d: error: failed to allocate memory for cartridge\n", |
| 129 | | id); |
| 130 | | return IMAGE_INIT_FAIL; |
| 131 | | } |
| 132 | | if (size < size_aligned) { |
| 133 | | memset (mem, 0xff, size_aligned); |
| 134 | | } |
| 135 | | if (image.fread(mem, size) != size) { |
| 136 | | logerror ("cart #%d: %s: can't read full %d bytes\n", |
| 137 | | id, image.filename (), size); |
| 138 | | return IMAGE_INIT_FAIL; |
| 139 | | } |
| 119 | const char *mapper = software_part_get_feature( (software_part*)image.part_entry(), "mapper" ); |
| 140 | 120 | |
| 141 | | /* see if msx.crc will tell us more */ |
| 142 | | extra = hashfile_extrainfo(image); |
| 121 | if ( mapper != NULL ) |
| 122 | { |
| 123 | static const struct { const char *mapper_name; int mapper_type; } mapper_types[] = |
| 124 | { |
| 125 | { "M60002-0125SP", SLOT_ASCII8 }, |
| 126 | { "LZ93A13", SLOT_ASCII8 } |
| 127 | }; |
| 143 | 128 | |
| 144 | | if (!extra) |
| 145 | | { |
| 146 | | logerror("cart #%d: warning: no information in crc file\n", id); |
| 147 | | type = -1; |
| 129 | type = -1; |
| 130 | for ( int i = 0; i < ARRAY_LENGTH(mapper_types) && type < 0; i++ ) |
| 131 | { |
| 132 | if ( !mame_stricmp( mapper, mapper_types[i].mapper_name ) ) |
| 133 | { |
| 134 | type = mapper_types[i].mapper_type; |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | if ( -1 == type ) |
| 139 | { |
| 140 | logerror( "Mapper '%s' not recognized!\n", mapper ); |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | UINT8 *rom_region = image.get_software_region( "rom" ); |
| 145 | size = size_aligned = image.get_software_region_length( "rom" ); |
| 146 | |
| 147 | mem = auto_alloc_array( image.device().machine(), UINT8, size_aligned ); |
| 148 | memcpy( mem, rom_region, size_aligned ); |
| 148 | 149 | } |
| 149 | | else if ((1 != sscanf(extra, "%d", &type) ) || |
| 150 | | type < 0 || type > SLOT_LAST_CARTRIDGE_TYPE) |
| 151 | | { |
| 152 | | logerror("cart #%d: warning: information in crc file not valid\n", id); |
| 153 | | type = -1; |
| 154 | | } |
| 155 | 150 | else |
| 156 | 151 | { |
| 157 | | logerror ("cart #%d: info: cart extra info: '%s' = %s\n", id, extra, |
| 158 | | msx_slot_list[type].name); |
| 159 | | } |
| 152 | /* Old style image loading */ |
| 160 | 153 | |
| 161 | | /* if not, attempt autodetection */ |
| 162 | | if (type < 0) |
| 163 | | { |
| 164 | | type = msx_probe_type (mem, size); |
| 154 | size = image.length (); |
| 155 | if (size < 0x2000) { |
| 156 | logerror ("cart #%d: error: file is smaller than 2kb, too small " |
| 157 | "to be true!\n", id); |
| 158 | return IMAGE_INIT_FAIL; |
| 159 | } |
| 165 | 160 | |
| 166 | | if (mem[0] != 'A' || mem[1] != 'B') { |
| 167 | | logerror("cart #%d: %s: May not be a valid ROM file\n", |
| 168 | | id, image.filename ()); |
| 161 | /* allocate memory and load */ |
| 162 | size_aligned = 0x2000; |
| 163 | while (size_aligned < size) { |
| 164 | size_aligned *= 2; |
| 169 | 165 | } |
| 166 | mem = auto_alloc_array(image.device().machine(),UINT8,size_aligned); |
| 167 | if (!mem) { |
| 168 | logerror ("cart #%d: error: failed to allocate memory for cartridge\n", |
| 169 | id); |
| 170 | return IMAGE_INIT_FAIL; |
| 171 | } |
| 172 | if (size < size_aligned) { |
| 173 | memset (mem, 0xff, size_aligned); |
| 174 | } |
| 175 | if (image.fread(mem, size) != size) { |
| 176 | logerror ("cart #%d: %s: can't read full %d bytes\n", |
| 177 | id, image.filename (), size); |
| 178 | return IMAGE_INIT_FAIL; |
| 179 | } |
| 170 | 180 | |
| 171 | | logerror("cart #%d: Probed cartridge mapper %d/%s\n", id, |
| 172 | | type, msx_slot_list[type].name); |
| 181 | /* see if msx.crc will tell us more */ |
| 182 | extra = hashfile_extrainfo(image); |
| 183 | |
| 184 | if (!extra) |
| 185 | { |
| 186 | logerror("cart #%d: warning: no information in crc file\n", id); |
| 187 | type = -1; |
| 188 | } |
| 189 | else if ((1 != sscanf(extra, "%d", &type) ) || |
| 190 | type < 0 || type > SLOT_LAST_CARTRIDGE_TYPE) |
| 191 | { |
| 192 | logerror("cart #%d: warning: information in crc file not valid\n", id); |
| 193 | type = -1; |
| 194 | } |
| 195 | else |
| 196 | { |
| 197 | logerror ("cart #%d: info: cart extra info: '%s' = %s\n", id, extra, |
| 198 | msx_slot_list[type].name); |
| 199 | } |
| 200 | |
| 201 | /* if not, attempt autodetection */ |
| 202 | if (type < 0) |
| 203 | { |
| 204 | type = msx_probe_type (mem, size); |
| 205 | |
| 206 | if (mem[0] != 'A' || mem[1] != 'B') { |
| 207 | logerror("cart #%d: %s: May not be a valid ROM file\n", |
| 208 | id, image.filename ()); |
| 209 | } |
| 210 | |
| 211 | logerror("cart #%d: Probed cartridge mapper %d/%s\n", id, |
| 212 | type, msx_slot_list[type].name); |
| 213 | } |
| 173 | 214 | } |
| 174 | 215 | |
| 175 | 216 | /* mapper type 0 always needs 64kB */ |
src/mess/drivers/msx.c
| r12476 | r12477 | |
| 1033 | 1033 | MCFG_CARTSLOT_ADD("cart1") |
| 1034 | 1034 | MCFG_CARTSLOT_EXTENSION_LIST("mx1,rom") |
| 1035 | 1035 | MCFG_CARTSLOT_NOT_MANDATORY |
| 1036 | MCFG_CARTSLOT_INTERFACE("msx_cart") |
| 1036 | 1037 | MCFG_CARTSLOT_LOAD(msx_cart) |
| 1037 | 1038 | MCFG_CARTSLOT_UNLOAD(msx_cart) |
| 1038 | 1039 | |
| 1039 | 1040 | MCFG_CARTSLOT_ADD("cart2") |
| 1040 | 1041 | MCFG_CARTSLOT_EXTENSION_LIST("mx1,rom") |
| 1041 | 1042 | MCFG_CARTSLOT_NOT_MANDATORY |
| 1043 | MCFG_CARTSLOT_INTERFACE("msx_cart") |
| 1042 | 1044 | MCFG_CARTSLOT_LOAD(msx_cart) |
| 1043 | 1045 | MCFG_CARTSLOT_UNLOAD(msx_cart) |
| 1044 | 1046 | MACHINE_CONFIG_END |
| r12476 | r12477 | |
| 1080 | 1082 | MCFG_LEGACY_FLOPPY_2_DRIVES_ADD(msx_floppy_interface) |
| 1081 | 1083 | |
| 1082 | 1084 | MCFG_FRAGMENT_ADD(msx_cartslot) |
| 1085 | |
| 1086 | /* Software lists */ |
| 1087 | MCFG_SOFTWARE_LIST_ADD("cart_list","msx1_cart") |
| 1083 | 1088 | MACHINE_CONFIG_END |
| 1084 | 1089 | |
| 1085 | 1090 | |
| r12476 | r12477 | |
| 1190 | 1195 | MCFG_LEGACY_FLOPPY_2_DRIVES_ADD(msx_floppy_interface) |
| 1191 | 1196 | |
| 1192 | 1197 | MCFG_FRAGMENT_ADD(msx_cartslot) |
| 1198 | |
| 1199 | /* Software lists */ |
| 1200 | MCFG_SOFTWARE_LIST_ADD("cart_list","msx2_cart") |
| 1193 | 1201 | MACHINE_CONFIG_END |
| 1194 | 1202 | |
| 1195 | 1203 | |