src/mess/drivers/gba.c
| r10190 | r10191 | |
| 55 | 55 | device_image_interface *image = dynamic_cast<device_image_interface *>(state->nvimage); |
| 56 | 56 | image->battery_save(state->nvptr, state->nvsize); |
| 57 | 57 | } |
| 58 | |
| 59 | if (state->flash_size > 0) |
| 60 | { |
| 61 | device_image_interface *image = dynamic_cast<device_image_interface *>(state->nvimage); |
| 62 | UINT8 *nvram = auto_alloc_array( &machine, UINT8, state->flash_size); |
| 63 | for (int i = 0; i < state->flash_size; i++) |
| 64 | { |
| 65 | nvram[i] = state->mFlashDev->read_raw( i); |
| 66 | } |
| 67 | image->battery_save( nvram, state->flash_size); |
| 68 | auto_free( &machine, nvram); |
| 69 | } |
| 58 | 70 | } |
| 59 | 71 | |
| 60 | 72 | static PALETTE_INIT( gba ) |
| r10190 | r10191 | |
| 2095 | 2107 | dac_signed_data_w(gb_a_r, 0x80); |
| 2096 | 2108 | dac_signed_data_w(gb_b_l, 0x80); |
| 2097 | 2109 | dac_signed_data_w(gb_b_r, 0x80); |
| 2110 | |
| 2111 | if (state->flash_battery_load != 0) |
| 2112 | { |
| 2113 | device_image_interface *image = dynamic_cast<device_image_interface *>(state->nvimage); |
| 2114 | UINT8 *nvram = auto_alloc_array( machine, UINT8, state->flash_size); |
| 2115 | image->battery_load( nvram, state->flash_size, 0xff); |
| 2116 | for (int i = 0; i < state->flash_size; i++) |
| 2117 | { |
| 2118 | state->mFlashDev->write_raw( i, nvram[i]); |
| 2119 | } |
| 2120 | auto_free( machine, nvram); |
| 2121 | state->flash_battery_load = 0; |
| 2122 | } |
| 2098 | 2123 | } |
| 2099 | 2124 | |
| 2100 | 2125 | static MACHINE_START( gba ) |
| r10190 | r10191 | |
| 2514 | 2539 | state->nvsize = 0; |
| 2515 | 2540 | state->flash_size = 0; |
| 2516 | 2541 | state->nvptr = (UINT8 *)NULL; |
| 2542 | state->flash_battery_load = 0; |
| 2517 | 2543 | |
| 2518 | 2544 | if (image.software_entry() == NULL) |
| 2519 | 2545 | { |
| r10190 | r10191 | |
| 2617 | 2643 | state->mFlashDev = image.device().machine->device<intelfsh8_device>("pflash"); |
| 2618 | 2644 | else |
| 2619 | 2645 | state->mFlashDev = image.device().machine->device<intelfsh8_device>("sflash"); |
| 2646 | state->flash_battery_load = 1; |
| 2647 | state->nvimage = image; |
| 2620 | 2648 | } |
| 2621 | 2649 | |
| 2622 | 2650 | // mirror the ROM |