trunk/src/mess/machine/thomson.c
| r20861 | r20862 | |
| 403 | 403 | { |
| 404 | 404 | int i,j; |
| 405 | 405 | UINT8* pos = image.device().machine().root_device().memregion("maincpu" )->base() + 0x10000; |
| 406 | | offs_t size = image.length(); |
| 406 | offs_t size; |
| 407 | 407 | char name[129]; |
| 408 | 408 | |
| 409 | if (image.software_entry() == NULL) |
| 410 | size = image.length(); |
| 411 | else |
| 412 | size = image.get_software_region_length("rom"); |
| 413 | |
| 409 | 414 | /* get size & number of 16-KB banks */ |
| 410 | 415 | if ( size <= 0x04000 ) |
| 411 | 416 | thom_cart_nb_banks = 1; |
| r20861 | r20862 | |
| 415 | 420 | thom_cart_nb_banks = 4; |
| 416 | 421 | else |
| 417 | 422 | { |
| 418 | | logerror( "to7_cartridge_load: invalid cartridge size %i\n", size ); |
| 423 | astring errmsg; |
| 424 | errmsg.printf("Invalid cartridge size %u", size); |
| 425 | image.seterror(IMAGE_ERROR_UNSUPPORTED, errmsg.cstr()); |
| 419 | 426 | return IMAGE_INIT_FAIL; |
| 420 | 427 | } |
| 421 | 428 | |
| 422 | | if ( image.fread( pos, size ) != size ) |
| 429 | if (image.software_entry() == NULL) |
| 423 | 430 | { |
| 424 | | logerror( "to7_cartridge_load: read error\n" ); |
| 425 | | return IMAGE_INIT_FAIL; |
| 431 | if ( image.fread( pos, size ) != size ) |
| 432 | { |
| 433 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Read error"); |
| 434 | return IMAGE_INIT_FAIL; |
| 435 | } |
| 426 | 436 | } |
| 437 | else |
| 438 | { |
| 439 | memcpy(pos, image.get_software_region("rom"), size); |
| 440 | } |
| 427 | 441 | |
| 428 | 442 | /* extract name */ |
| 429 | 443 | for ( i = 0; i < size && pos[i] != ' '; i++ ); |
| r20861 | r20862 | |
| 1945 | 1959 | DEVICE_IMAGE_LOAD_MEMBER( thomson_state, mo5_cartridge ) |
| 1946 | 1960 | { |
| 1947 | 1961 | UINT8* pos = image.device().machine().root_device().memregion("maincpu")->base() + 0x10000; |
| 1948 | | UINT64 size = image.length(); |
| 1962 | UINT64 size; |
| 1949 | 1963 | int i,j; |
| 1950 | 1964 | char name[129]; |
| 1951 | 1965 | |
| 1966 | if (image.software_entry() == NULL) |
| 1967 | size = image.length(); |
| 1968 | else |
| 1969 | size = image.get_software_region_length("rom"); |
| 1970 | |
| 1952 | 1971 | /* get size & number of 16-KB banks */ |
| 1953 | 1972 | if ( size > 32 && size <= 0x04000 ) |
| 1954 | 1973 | thom_cart_nb_banks = 1; |
| r20861 | r20862 | |
| 1958 | 1977 | thom_cart_nb_banks = 4; |
| 1959 | 1978 | else |
| 1960 | 1979 | { |
| 1961 | | logerror( "mo5_cartridge_load: invalid cartridge size %u\n", (unsigned) size ); |
| 1980 | astring errmsg; |
| 1981 | errmsg.printf("Invalid cartridge size "I64FMT, size); |
| 1982 | image.seterror(IMAGE_ERROR_UNSUPPORTED, errmsg.cstr()); |
| 1962 | 1983 | return IMAGE_INIT_FAIL; |
| 1963 | 1984 | } |
| 1964 | 1985 | |
| 1965 | | if ( image.fread(pos, size ) != size ) |
| 1986 | if (image.software_entry() == NULL) |
| 1966 | 1987 | { |
| 1967 | | logerror( "mo5_cartridge_load: read error\n" ); |
| 1968 | | return IMAGE_INIT_FAIL; |
| 1988 | if ( image.fread(pos, size ) != size ) |
| 1989 | { |
| 1990 | image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Read error"); |
| 1991 | return IMAGE_INIT_FAIL; |
| 1992 | } |
| 1969 | 1993 | } |
| 1994 | else |
| 1995 | { |
| 1996 | memcpy(pos, image.get_software_region("rom"), size); |
| 1997 | } |
| 1970 | 1998 | |
| 1971 | 1999 | /* extract name */ |
| 1972 | 2000 | i = size - 32; |