src/mess/machine/pokemini.c
| r7916 | r7917 | |
| 1399 | 1399 | return data; |
| 1400 | 1400 | } |
| 1401 | 1401 | |
| 1402 | | DEVICE_START( pokemini_cart ) |
| 1403 | | { |
| 1404 | | } |
| 1405 | | |
| 1406 | 1402 | DEVICE_IMAGE_LOAD( pokemini_cart ) |
| 1407 | 1403 | { |
| 1408 | | int size = image_length( image ); |
| 1409 | | |
| 1410 | | /* Verify that the image is big enough */ |
| 1411 | | if ( size <= 0x2100 ) |
| 1404 | if (image_software_entry(image) == NULL) |
| 1412 | 1405 | { |
| 1413 | | image_seterror( image, IMAGE_ERROR_UNSPECIFIED, "Invalid ROM image: ROM image is too small" ); |
| 1414 | | return INIT_FAIL; |
| 1415 | | } |
| 1406 | int size = image_length(image); |
| 1416 | 1407 | |
| 1417 | | /* Verify that the image is not too big */ |
| 1418 | | if ( size > 0x1FFFFF ) |
| 1419 | | { |
| 1420 | | image_seterror( image, IMAGE_ERROR_UNSPECIFIED, "Invalid ROM image: ROM image is too big" ); |
| 1421 | | return INIT_FAIL; |
| 1422 | | } |
| 1408 | /* Verify that the image is big enough */ |
| 1409 | if (size <= 0x2100) |
| 1410 | { |
| 1411 | image_seterror(image, IMAGE_ERROR_UNSPECIFIED, "Invalid ROM image: ROM image is too small"); |
| 1412 | return INIT_FAIL; |
| 1413 | } |
| 1423 | 1414 | |
| 1424 | | /* Skip the first 0x2100 bytes */ |
| 1425 | | image_fseek( image, 0x2100, SEEK_SET ); |
| 1426 | | size -= 0x2100; |
| 1415 | /* Verify that the image is not too big */ |
| 1416 | if (size > 0x1FFFFF) |
| 1417 | { |
| 1418 | image_seterror(image, IMAGE_ERROR_UNSPECIFIED, "Invalid ROM image: ROM image is too big"); |
| 1419 | return INIT_FAIL; |
| 1420 | } |
| 1427 | 1421 | |
| 1428 | | if ( size != image_fread( image, memory_region(image->machine, "maincpu") + 0x2100, size ) ) |
| 1422 | /* Skip the first 0x2100 bytes */ |
| 1423 | image_fseek(image, 0x2100, SEEK_SET); |
| 1424 | size -= 0x2100; |
| 1425 | |
| 1426 | if (size != image_fread(image, memory_region(image->machine, "maincpu") + 0x2100, size)) |
| 1427 | { |
| 1428 | image_seterror(image, IMAGE_ERROR_UNSPECIFIED, "Error occured while reading ROM image"); |
| 1429 | return INIT_FAIL; |
| 1430 | } |
| 1431 | } |
| 1432 | else |
| 1429 | 1433 | { |
| 1430 | | image_seterror( image, IMAGE_ERROR_UNSPECIFIED, "Error occured while reading ROM image" ); |
| 1431 | | return INIT_FAIL; |
| 1434 | UINT8 *cart_rom = image_get_software_region(image, "rom"); |
| 1435 | UINT32 cart_rom_size = image_get_software_region_length(image, "rom"); |
| 1436 | memcpy(memory_region(image->machine, "maincpu") + 0x2100, cart_rom + 0x2100, cart_rom_size - 0x2100); |
| 1432 | 1437 | } |
| 1433 | 1438 | |
| 1434 | 1439 | return INIT_PASS; |
src/mess/machine/gamecom.c
| r7916 | r7917 | |
| 702 | 702 | { |
| 703 | 703 | UINT32 filesize; |
| 704 | 704 | UINT32 load_offset = 0; |
| 705 | | UINT32 bytes_read; |
| 706 | 705 | |
| 707 | 706 | cartridge1 = memory_region(image->machine, "user2"); |
| 708 | 707 | |
| 709 | | filesize = image_length( image ); |
| 710 | | switch( filesize ) |
| 708 | if (image_software_entry(image) == NULL) |
| 709 | filesize = image_length(image); |
| 710 | else |
| 711 | filesize = image_get_software_region_length(image, "rom"); |
| 712 | |
| 713 | switch(filesize) |
| 711 | 714 | { |
| 712 | | case 0x008000: load_offset = 0; break; /* 32 KB */ |
| 713 | | case 0x040000: load_offset = 0; break; /* 256KB */ |
| 714 | | case 0x080000: load_offset = 0; break; /* 512KB */ |
| 715 | | case 0x100000: load_offset = 0; break; /* 1 MB */ |
| 716 | | case 0x1c0000: load_offset = 0x040000; break; /* 1.8MB */ |
| 717 | | case 0x200000: load_offset = 0; break; /* 2 MB */ |
| 718 | | default: /* otherwise */ |
| 719 | | logerror( "Error loading cartridge: Invalid file size 0x%X\n",filesize ); |
| 720 | | image_seterror( image, IMAGE_ERROR_UNSPECIFIED, "Unhandled cart size" ); |
| 721 | | return INIT_FAIL; |
| 715 | case 0x008000: load_offset = 0; break; /* 32 KB */ |
| 716 | case 0x040000: load_offset = 0; break; /* 256KB */ |
| 717 | case 0x080000: load_offset = 0; break; /* 512KB */ |
| 718 | case 0x100000: load_offset = 0; break; /* 1 MB */ |
| 719 | case 0x1c0000: load_offset = 0x040000; break; /* 1.8MB */ |
| 720 | case 0x200000: load_offset = 0; break; /* 2 MB */ |
| 721 | default: /* otherwise */ |
| 722 | logerror("Error loading cartridge: Invalid file size 0x%X\n", filesize); |
| 723 | image_seterror(image, IMAGE_ERROR_UNSPECIFIED, "Unhandled cart size"); |
| 724 | return INIT_FAIL; |
| 722 | 725 | } |
| 723 | | bytes_read = image_fread( image, cartridge1 + load_offset, filesize ); |
| 724 | | if (bytes_read != filesize ) |
| 726 | |
| 727 | if (image_software_entry(image) == NULL) |
| 725 | 728 | { |
| 726 | | logerror( "Error loading cartridge: Read 0x%X, should have been 0x%X\n",bytes_read,filesize ); |
| 727 | | image_seterror( image, IMAGE_ERROR_UNSPECIFIED, "Unable to load all of the cart" ); |
| 728 | | return INIT_FAIL; |
| 729 | if (image_fread(image, cartridge1 + load_offset, filesize) != filesize) |
| 730 | { |
| 731 | image_seterror(image, IMAGE_ERROR_UNSPECIFIED, "Unable to load all of the cart"); |
| 732 | return INIT_FAIL; |
| 733 | } |
| 729 | 734 | } |
| 730 | | if ( filesize < 0x010000 ) { memcpy( cartridge1 + 0x008000, cartridge1, 0x008000 ); } /* ->64KB */ |
| 731 | | if ( filesize < 0x020000 ) { memcpy( cartridge1 + 0x010000, cartridge1, 0x010000 ); } /* ->128KB */ |
| 732 | | if ( filesize < 0x040000 ) { memcpy( cartridge1 + 0x020000, cartridge1, 0x020000 ); } /* ->256KB */ |
| 733 | | if ( filesize < 0x080000 ) { memcpy( cartridge1 + 0x040000, cartridge1, 0x040000 ); } /* ->512KB */ |
| 734 | | if ( filesize < 0x100000 ) { memcpy( cartridge1 + 0x080000, cartridge1, 0x080000 ); } /* ->1MB */ |
| 735 | | if ( filesize < 0x1c0000 ) { memcpy( cartridge1 + 0x100000, cartridge1, 0x100000 ); } /* -> >=1.8MB */ |
| 735 | else |
| 736 | memcpy(cartridge1 + load_offset, image_get_software_region(image, "rom"), filesize); |
| 737 | |
| 738 | if (filesize < 0x010000) { memcpy(cartridge1 + 0x008000, cartridge1, 0x008000); } /* ->64KB */ |
| 739 | if (filesize < 0x020000) { memcpy(cartridge1 + 0x010000, cartridge1, 0x010000); } /* ->128KB */ |
| 740 | if (filesize < 0x040000) { memcpy(cartridge1 + 0x020000, cartridge1, 0x020000); } /* ->256KB */ |
| 741 | if (filesize < 0x080000) { memcpy(cartridge1 + 0x040000, cartridge1, 0x040000); } /* ->512KB */ |
| 742 | if (filesize < 0x100000) { memcpy(cartridge1 + 0x080000, cartridge1, 0x080000); } /* ->1MB */ |
| 743 | if (filesize < 0x1c0000) { memcpy(cartridge1 + 0x100000, cartridge1, 0x100000); } /* -> >=1.8MB */ |
| 736 | 744 | return INIT_PASS; |
| 737 | 745 | } |
| 738 | 746 | |
src/mess/drivers/advision.c
| r7916 | r7917 | |
| 59 | 59 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1) PORT_8WAY |
| 60 | 60 | INPUT_PORTS_END |
| 61 | 61 | |
| 62 | /* Cartridge (+ Software List) */ |
| 63 | |
| 64 | static DEVICE_IMAGE_LOAD( advision_cart ) |
| 65 | { |
| 66 | UINT8 *cart_rom; |
| 67 | UINT32 cart_rom_size; |
| 68 | |
| 69 | if (image_software_entry(image) == NULL) |
| 70 | { |
| 71 | cart_rom = memory_region(image->machine, "cart"); |
| 72 | cart_rom_size = image_length(image); |
| 73 | |
| 74 | if (cart_rom_size > memory_region_length(image->machine, "cart")) |
| 75 | { |
| 76 | image_seterror(image, IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); |
| 77 | return INIT_FAIL; |
| 78 | } |
| 79 | |
| 80 | if (image_fread(image, cart_rom, cart_rom_size) != cart_rom_size) |
| 81 | { |
| 82 | image_seterror(image, IMAGE_ERROR_UNSPECIFIED, "Unable to fully read from file"); |
| 83 | return INIT_FAIL; |
| 84 | } |
| 85 | |
| 86 | } |
| 87 | else |
| 88 | { |
| 89 | cart_rom = image_get_software_region(image, "rom"); |
| 90 | cart_rom_size = image_get_software_region_length(image, "rom"); |
| 91 | } |
| 92 | |
| 93 | memcpy(memory_region(image->machine, I8048_TAG), cart_rom, cart_rom_size); |
| 94 | |
| 95 | return INIT_PASS; |
| 96 | } |
| 97 | |
| 62 | 98 | /* Machine Driver */ |
| 63 | 99 | |
| 64 | 100 | static COP400_INTERFACE( advision_cop411_interface ) |
| r7916 | r7917 | |
| 106 | 142 | MDRV_CARTSLOT_ADD("cart") |
| 107 | 143 | MDRV_CARTSLOT_EXTENSION_LIST("bin") |
| 108 | 144 | MDRV_CARTSLOT_MANDATORY |
| 145 | MDRV_CARTSLOT_INTERFACE("advision_cart") |
| 146 | MDRV_CARTSLOT_LOAD(advision_cart) |
| 147 | |
| 148 | /* Software lists */ |
| 149 | MDRV_SOFTWARE_LIST_ADD("advision") |
| 109 | 150 | MACHINE_DRIVER_END |
| 110 | 151 | |
| 111 | 152 | /* ROMs */ |
| 112 | 153 | |
| 113 | 154 | ROM_START( advision ) |
| 114 | | ROM_REGION( 0x1000, I8048_TAG, 0 ) |
| 115 | | ROM_CART_LOAD( "cart", 0x0000, 0x1000, ROM_NOMIRROR | ROM_FULLSIZE ) |
| 155 | ROM_REGION( 0x1000, I8048_TAG, ROMREGION_ERASE00 ) |
| 116 | 156 | |
| 117 | 157 | ROM_REGION( 0x400, "bios", 0 ) |
| 118 | 158 | ROM_LOAD( "avbios.u5", 0x000, 0x400, CRC(279e33d1) SHA1(bf7b0663e9125c9bfb950232eab627d9dbda8460) ) |
| 119 | 159 | |
| 120 | 160 | ROM_REGION( 0x200, COP411_TAG, 0 ) |
| 121 | 161 | ROM_LOAD( "avsound.u8", 0x000, 0x200, CRC(81e95975) SHA1(8b6f8c30dd3e9d8e43f1ea20fba2361b383790eb) ) |
| 162 | |
| 163 | ROM_REGION( 0x1000, "cart", ROMREGION_ERASE00 ) |
| 122 | 164 | ROM_END |
| 123 | 165 | |
| 124 | 166 | /* Game Driver */ |
src/mess/drivers/gmaster.c
| r7916 | r7917 | |
| 3 | 3 | ******************************************************************************/ |
| 4 | 4 | |
| 5 | 5 | #include "emu.h" |
| 6 | | //#include "vidhrdw/generic.h" |
| 7 | 6 | #include "cpu/upd7810/upd7810.h" |
| 8 | 7 | #include "devices/cartslot.h" |
| 9 | 8 | |
| r7916 | r7917 | |
| 180 | 179 | { |
| 181 | 180 | int i; |
| 182 | 181 | |
| 183 | | for ( i = 0; i < 2; i++ ) |
| 182 | for (i = 0; i < 2; i++) |
| 184 | 183 | { |
| 185 | 184 | palette_set_color_rgb(machine, i, gmaster_palette[i][0], gmaster_palette[i][1], gmaster_palette[i][2]); |
| 186 | 185 | } |
| r7916 | r7917 | |
| 198 | 197 | UINT16 *line; |
| 199 | 198 | |
| 200 | 199 | line = BITMAP_ADDR16(bitmap, (y * 8), x); |
| 201 | | line[0] = (d >> 0) & 1; |
| 200 | line[0] = BIT(d, 0); |
| 202 | 201 | line = BITMAP_ADDR16(bitmap, (y * 8 + 1), x); |
| 203 | | line[0] = (d >> 1) & 1; |
| 202 | line[0] = BIT(d, 1); |
| 204 | 203 | line = BITMAP_ADDR16(bitmap, (y * 8 + 2), x); |
| 205 | | line[0] = (d >> 2) & 1; |
| 204 | line[0] = BIT(d, 2); |
| 206 | 205 | line = BITMAP_ADDR16(bitmap, (y * 8 + 3), x); |
| 207 | | line[0] = (d >> 3) & 1; |
| 206 | line[0] = BIT(d, 3); |
| 208 | 207 | line = BITMAP_ADDR16(bitmap, (y * 8 + 4), x); |
| 209 | | line[0] = (d >> 4) & 1; |
| 208 | line[0] = BIT(d, 4); |
| 210 | 209 | line = BITMAP_ADDR16(bitmap, (y * 8 + 5), x); |
| 211 | | line[0] = (d >> 5) & 1; |
| 210 | line[0] = BIT(d, 5); |
| 212 | 211 | line = BITMAP_ADDR16(bitmap, (y * 8 + 6), x); |
| 213 | | line[0] = (d >> 6) & 1; |
| 212 | line[0] = BIT(d, 6); |
| 214 | 213 | line = BITMAP_ADDR16(bitmap, (y * 8 + 7), x); |
| 215 | | line[0] = (d >> 7) & 1; |
| 214 | line[0] = BIT(d, 7); |
| 216 | 215 | } |
| 217 | 216 | } |
| 218 | 217 | return 0; |
| 219 | 218 | } |
| 220 | 219 | |
| 220 | static DEVICE_IMAGE_LOAD( gmaster_cart ) |
| 221 | { |
| 222 | UINT8 *cart_rom; |
| 223 | UINT32 cart_rom_size; |
| 224 | |
| 225 | if (image_software_entry(image) == NULL) |
| 226 | { |
| 227 | cart_rom = memory_region(image->machine, "cart"); |
| 228 | cart_rom_size = image_length(image); |
| 229 | |
| 230 | if (cart_rom_size > memory_region_length(image->machine, "cart")) |
| 231 | { |
| 232 | image_seterror(image, IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size"); |
| 233 | return INIT_FAIL; |
| 234 | } |
| 235 | |
| 236 | if (image_fread(image, cart_rom, cart_rom_size) != cart_rom_size) |
| 237 | { |
| 238 | image_seterror(image, IMAGE_ERROR_UNSPECIFIED, "Unable to fully read from file"); |
| 239 | return INIT_FAIL; |
| 240 | } |
| 241 | |
| 242 | } |
| 243 | else |
| 244 | { |
| 245 | cart_rom = image_get_software_region(image, "rom"); |
| 246 | cart_rom_size = image_get_software_region_length(image, "rom"); |
| 247 | } |
| 248 | |
| 249 | memcpy(memory_region(image->machine, "maincpu") + 0x8000, cart_rom, cart_rom_size); |
| 250 | |
| 251 | return INIT_PASS; |
| 252 | } |
| 253 | |
| 221 | 254 | static INTERRUPT_GEN( gmaster_interrupt ) |
| 222 | 255 | { |
| 223 | 256 | cputag_set_input_line(device->machine, "maincpu", UPD7810_INTFE1, ASSERT_LINE); |
| r7916 | r7917 | |
| 251 | 284 | MDRV_SOUND_ROUTE(0, "speaker", 0.50) |
| 252 | 285 | |
| 253 | 286 | MDRV_CARTSLOT_ADD("cart") |
| 287 | MDRV_CARTSLOT_EXTENSION_LIST("bin") |
| 288 | MDRV_CARTSLOT_MANDATORY |
| 289 | MDRV_CARTSLOT_INTERFACE("gmaster_cart") |
| 290 | MDRV_CARTSLOT_LOAD(gmaster_cart) |
| 291 | MDRV_SOFTWARE_LIST_ADD("gmaster") |
| 254 | 292 | MACHINE_DRIVER_END |
| 255 | 293 | |
| 256 | 294 | |
| r7916 | r7917 | |
| 258 | 296 | ROM_REGION(0x10000,"maincpu", 0) |
| 259 | 297 | ROM_LOAD("gmaster.bin", 0x0000, 0x1000, CRC(05cc45e5) SHA1(05d73638dea9657ccc2791c0202d9074a4782c1e) ) |
| 260 | 298 | // ROM_CART_LOAD(0, "bin", 0x8000, 0x7f00, 0) |
| 261 | | ROM_CART_LOAD("cart", 0x8000, 0x8000, 0) |
| 299 | |
| 300 | ROM_REGION( 0x8000, "cart", ROMREGION_ERASE00 ) |
| 262 | 301 | ROM_END |
| 263 | 302 | |
| 264 | 303 | static DRIVER_INIT( gmaster ) |
| r7916 | r7917 | |
| 266 | 305 | memset(&gmaster_video, 0, sizeof(gmaster_video)); |
| 267 | 306 | } |
| 268 | 307 | |
| 269 | | #if 0 |
| 270 | | static int gmaster_load_rom(running_machine *machine, int id) |
| 271 | | { |
| 272 | | FILE *cartfile; |
| 273 | | UINT8 *rom = memory_region(machine, "maincpu"); |
| 274 | | int size; |
| 275 | | |
| 276 | | if (device_filename(IO_CARTSLOT, id) == NULL) |
| 277 | | { |
| 278 | | printf("%s requires Cartridge!\n", machine->gamedrv->name); |
| 279 | | return 0; |
| 280 | | } |
| 281 | | |
| 282 | | if (!(cartfile = (FILE*)image_fopen(IO_CARTSLOT, id, OSD_FILETYPE_IMAGE_R, 0))) |
| 283 | | { |
| 284 | | logerror("%s not found\n",device_filename(IO_CARTSLOT,id)); |
| 285 | | return 1; |
| 286 | | } |
| 287 | | size=osd_fsize(cartfile); |
| 288 | | if (size>0x8000) |
| 289 | | { |
| 290 | | logerror("%s: size %d not yet supported\n",device_filename(IO_CARTSLOT,id), size); |
| 291 | | return 1; |
| 292 | | } |
| 293 | | |
| 294 | | if (osd_fread(cartfile, rom+0x8000, size)!=size) |
| 295 | | { |
| 296 | | logerror("%s load error\n",device_filename(IO_CARTSLOT,id)); |
| 297 | | osd_fclose(cartfile); |
| 298 | | return 1; |
| 299 | | } |
| 300 | | // memcpy(rom+0x0000, rom+0x8000, 0x4000); |
| 301 | | osd_fclose(cartfile); |
| 302 | | return 0; |
| 303 | | } |
| 304 | | #endif |
| 305 | | |
| 306 | 308 | /* YEAR NAME PARENT MACHINE INPUT INIT COMPANY FULLNAME */ |
| 307 | 309 | CONS( 1990, gmaster, 0, 0, gmaster, gmaster, gmaster, "Hartung", "Game Master", GAME_IMPERFECT_SOUND) |