src/mess/machine/28f008sa.c
| r1157 | r1158 | |
| 1 | | /*******************************************/ |
| 2 | | /* Intel 28F008SA 5 Volt Flash-File Memory */ |
| 3 | | |
| 4 | | #include "driver.h" |
| 5 | | |
| 6 | | #include "includes/28f008sa.h" |
| 7 | | |
| 8 | | /* commands */ |
| 9 | | #define FLASH_COMMAND_READ_ARRAY_OR_RESET 0x00FF |
| 10 | | #define FLASH_COMMAND_INTELLIGENT_IDENTIFIER 0x0090 |
| 11 | | #define FLASH_COMMAND_READ_STATUS_REGISTER 0x0070 |
| 12 | | #define FLASH_COMMAND_CLEAR_STATUS_REGISTER 0x0050 |
| 13 | | #define FLASH_COMMAND_ERASE_SETUP_OR_ERASE_CONFIRM 0x0020 |
| 14 | | #define FLASH_COMMAND_ERASE_SUSPEND_OR_ERASE_RESUME 0x00b0 |
| 15 | | #define FLASH_COMMAND_BYTE_WRITE_SETUP_OR_WRITE 0x0040 |
| 16 | | #define FLASH_COMMAND_ALTERNATIVE_BYTE_WRITE_SETUP_OR_WRITE 0x0010 |
| 17 | | #define FLASH_COMMAND_ERASE_CONFIRM 0x00d0 |
| 18 | | |
| 19 | | /* status bits */ |
| 20 | | #define FLASH_STATUS_WRITE_STATE_MACHINE_STATUS_READY 0x0080 |
| 21 | | #define FLASH_STATUS_WRITE_STATE_MACHINE_STATUS_BUSY 0x0000 |
| 22 | | |
| 23 | | #define FLASH_STATUS_ERASE_SUSPEND_STATUS_SUSPENDED 0x0040 |
| 24 | | #define FLASH_STATUS_ERASE_SUSPEND_STATUS_ERASE_IN_PROGRESS_OR_COMPLETED 0x0000 |
| 25 | | |
| 26 | | #define FLASH_STATUS_ERASE_STATUS_ERROR_IN_BLOCK 0x0020 |
| 27 | | #define FLASH_STATUS_ERASE_STATUS_SUCCESSFUL_BLOCK_ERASE 0x0000 |
| 28 | | |
| 29 | | #define FLASH_STATUS_BYTE_WRITE_STATUS_ERROR 0x0010 |
| 30 | | #define FLASH_STATUS_BYTE_WRITE_STATUS_SUCCESSFUL 0x0000 |
| 31 | | |
| 32 | | #define FLASH_STATUS_VPP_STATUS_LOW_OPERATION_ABORTED 0x0008 |
| 33 | | #define FLASH_STATUS_VPP_STATUS_HIGH 0x0000 |
| 34 | | |
| 35 | | #define FLASH_STATUS_RESERVED (0x0004 | 0x0002 | 0x0001) |
| 36 | | |
| 37 | | #define FLASH_MANUFACTURER_CODE 0x089 |
| 38 | | #define FLASH_DEVICE_CODE 0x0a2 |
| 39 | | |
| 40 | | /* setup command has been issued */ |
| 41 | | #define FLASH_ERASE_STATUS_SETUP 0x001 |
| 42 | | /* suspended */ |
| 43 | | #define FLASH_ERASE_STATUS_SUSPENDED 0x002 |
| 44 | | /* nothing */ |
| 45 | | #define FLASH_ERASE_STATUS_NONE 0x000 |
| 46 | | /* erase in progress */ |
| 47 | | #define FLASH_ERASE_STATUS_ERASING 0x003 |
| 48 | | |
| 49 | | /* datasheet states that a block will be erase typically in 1.6 seconds */ |
| 50 | | #define FLASH_TIME_PER_BLOCK_SECS (1.6f) |
| 51 | | #define FLASH_TIME_PER_BYTE_IN_SECS (FLASH_TIME_PER_BLOCK_SECS/65536.0f) |
| 52 | | |
| 53 | | typedef struct FLASH_FILE_MEMORY |
| 54 | | { |
| 55 | | /* internal status register */ |
| 56 | | unsigned long flash_status; |
| 57 | | /* command */ |
| 58 | | unsigned long flash_command; |
| 59 | | /* number of command cycles required */ |
| 60 | | unsigned long flash_command_parameters_required; |
| 61 | | |
| 62 | | /* index of 64k block to erase */ |
| 63 | | unsigned long flash_erase_block; |
| 64 | | |
| 65 | | /* offset we were last suspended at, or offset the erase procedure started at*/ |
| 66 | | unsigned long flash_offset; |
| 67 | | |
| 68 | | void *flash_timer; |
| 69 | | |
| 70 | | int flash_erase_status; |
| 71 | | |
| 72 | | /* address of 1mb data */ |
| 73 | | char *base; |
| 74 | | } FLASH_FILE_MEMORY; |
| 75 | | |
| 76 | | #define MAX_FLASH_DEVICES 4 |
| 77 | | |
| 78 | | static FLASH_FILE_MEMORY flash[MAX_FLASH_DEVICES]; |
| 79 | | |
| 80 | | char *flash_get_base(int index1) |
| 81 | | { |
| 82 | | return flash[index1].base; |
| 83 | | } |
| 84 | | |
| 85 | | static void flash_check_complete_erase(int index1) |
| 86 | | { |
| 87 | | if (flash[index1].flash_offset>=65536) |
| 88 | | { |
| 89 | | |
| 90 | | flash[index1].flash_status = (FLASH_STATUS_WRITE_STATE_MACHINE_STATUS_READY | |
| 91 | | FLASH_STATUS_ERASE_SUSPEND_STATUS_ERASE_IN_PROGRESS_OR_COMPLETED); |
| 92 | | |
| 93 | | /* set erase state to none */ |
| 94 | | flash[index1].flash_erase_status = FLASH_ERASE_STATUS_NONE; |
| 95 | | } |
| 96 | | } |
| 97 | | |
| 98 | | |
| 99 | | /* callback for flash erase - if it gets to here, the erase procedure is completed */ |
| 100 | | static TIMER_CALLBACK(flash_timer_callback) |
| 101 | | { |
| 102 | | int index1 = param; |
| 103 | | if (flash[index1].flash_offset<65536) |
| 104 | | { |
| 105 | | /* complete erase */ |
| 106 | | memset(flash[index1].base + (flash[index1].flash_erase_block<<16) + flash[index1].flash_offset, 0x0ff,65536-flash[index1].flash_offset); |
| 107 | | flash[index1].flash_offset = 65536; |
| 108 | | } |
| 109 | | |
| 110 | | flash_check_complete_erase(index1); |
| 111 | | |
| 112 | | /* stop timer from activating again, and do not let |
| 113 | | MAME sub-system remove it from the list */ |
| 114 | | mame_timer_reset(flash[index1].flash_timer, time_never); |
| 115 | | } |
| 116 | | |
| 117 | | /* suspend erase operation */ |
| 118 | | static void flash_suspend_erase(int index1) |
| 119 | | { |
| 120 | | /* suspend */ |
| 121 | | flash[index1].flash_status = FLASH_STATUS_ERASE_SUSPEND_STATUS_SUSPENDED | |
| 122 | | FLASH_STATUS_WRITE_STATE_MACHINE_STATUS_READY; |
| 123 | | |
| 124 | | |
| 125 | | if (flash[index1].flash_timer!=0) |
| 126 | | { |
| 127 | | int num_bytes; |
| 128 | | double time_elapsed; |
| 129 | | |
| 130 | | /* get time passed */ |
| 131 | | time_elapsed = mame_time_to_double(mame_timer_timeelapsed(flash[index1].flash_timer)); |
| 132 | | |
| 133 | | /* at this point in time, I don't believe it is necessary to know number of bits that have |
| 134 | | been erased*/ |
| 135 | | |
| 136 | | /* num bytes that have been erased in that time */ |
| 137 | | num_bytes = time_elapsed/FLASH_TIME_PER_BYTE_IN_SECS; |
| 138 | | |
| 139 | | /* this should not happen, but check anyway */ |
| 140 | | if (num_bytes>65536) |
| 141 | | { |
| 142 | | num_bytes = 65536; |
| 143 | | } |
| 144 | | |
| 145 | | if (num_bytes!=0) |
| 146 | | { |
| 147 | | /* back-fill from previous suspend point with erase data (fills up to this point)*/ |
| 148 | | memset(flash[index1].base + (flash[index1].flash_erase_block<<16) + flash[index1].flash_offset, 0x0ff, num_bytes); |
| 149 | | } |
| 150 | | /* update offset */ |
| 151 | | flash[index1].flash_offset += num_bytes; |
| 152 | | |
| 153 | | /* remove timer */ |
| 154 | | mame_timer_reset(flash[index1].flash_timer, time_never); |
| 155 | | |
| 156 | | /* set erase state to suspended */ |
| 157 | | flash[index1].flash_erase_status = FLASH_ERASE_STATUS_SUSPENDED; |
| 158 | | } |
| 159 | | |
| 160 | | flash_check_complete_erase(index1); |
| 161 | | } |
| 162 | | |
| 163 | | static void flash_resume_erase(int index1) |
| 164 | | { |
| 165 | | int num_bytes_remaining; |
| 166 | | |
| 167 | | flash[index1].flash_status = (FLASH_STATUS_WRITE_STATE_MACHINE_STATUS_BUSY | |
| 168 | | FLASH_STATUS_ERASE_SUSPEND_STATUS_ERASE_IN_PROGRESS_OR_COMPLETED); |
| 169 | | |
| 170 | | flash[index1].flash_erase_status = FLASH_ERASE_STATUS_ERASING; |
| 171 | | |
| 172 | | /* calc number of bytes remaining to erase */ |
| 173 | | num_bytes_remaining = 65536-flash[index1].flash_offset; |
| 174 | | |
| 175 | | /* issue a timer for this */ |
| 176 | | mame_timer_adjust(flash[index1].flash_timer, double_to_mame_time((FLASH_TIME_PER_BYTE_IN_SECS*num_bytes_remaining)), index1, time_zero); |
| 177 | | } |
| 178 | | |
| 179 | | |
| 180 | | void flash_init(int index1) |
| 181 | | { |
| 182 | | flash[index1].flash_timer = mame_timer_alloc(flash_timer_callback); |
| 183 | | |
| 184 | | /* 1mb ram */ |
| 185 | | flash[index1].base = (char *) auto_malloc(1024*1024); |
| 186 | | memset(flash[index1].base, 0x080, 1024*1024); |
| 187 | | flash_reset(index1); |
| 188 | | /* no erase state */ |
| 189 | | flash[index1].flash_erase_status = FLASH_ERASE_STATUS_NONE; |
| 190 | | } |
| 191 | | |
| 192 | | void flash_finish(int index1) |
| 193 | | { |
| 194 | | if (flash[index1].base!=NULL) |
| 195 | | flash[index1].base = NULL; |
| 196 | | } |
| 197 | | |
| 198 | | void flash_store(int index1, const char *flash_name) |
| 199 | | { |
| 200 | | file_error filerr; |
| 201 | | mame_file *file; |
| 202 | | |
| 203 | | if (flash[index1].base!=NULL) |
| 204 | | { |
| 205 | | filerr = mame_fopen(SEARCHPATH_MEMCARD, flash_name, OPEN_FLAG_WRITE, &file); |
| 206 | | |
| 207 | | if (filerr == FILERR_NONE) |
| 208 | | { |
| 209 | | mame_fwrite(file, flash[index1].base, (1024*1024)); |
| 210 | | |
| 211 | | mame_fclose(file); |
| 212 | | } |
| 213 | | } |
| 214 | | } |
| 215 | | |
| 216 | | |
| 217 | | |
| 218 | | void flash_restore(int index1, const char *flash_name) |
| 219 | | { |
| 220 | | file_error filerr; |
| 221 | | mame_file *file; |
| 222 | | |
| 223 | | if (flash[index1].base!=NULL) |
| 224 | | { |
| 225 | | filerr = mame_fopen(SEARCHPATH_MEMCARD, flash_name, OPEN_FLAG_READ, &file); |
| 226 | | |
| 227 | | if (filerr == FILERR_NONE) |
| 228 | | { |
| 229 | | mame_fread(file, flash[index1].base, (1024*1024)); |
| 230 | | |
| 231 | | mame_fclose(file); |
| 232 | | } |
| 233 | | } |
| 234 | | } |
| 235 | | |
| 236 | | |
| 237 | | void flash_reset(int index1) |
| 238 | | { |
| 239 | | flash[index1].flash_status = FLASH_STATUS_WRITE_STATE_MACHINE_STATUS_READY; |
| 240 | | flash[index1].flash_command = FLASH_COMMAND_READ_ARRAY_OR_RESET; |
| 241 | | flash[index1].flash_erase_status = FLASH_ERASE_STATUS_NONE; |
| 242 | | mame_timer_reset(flash[index1].flash_timer, time_never); |
| 243 | | } |
| 244 | | |
| 245 | | |
| 246 | | /* flash read - offset is offset within flash-file (offset within 1mb)*/ |
| 247 | | int flash_bank_handler_r(int index1, int offset) |
| 248 | | { |
| 249 | | switch (flash[index1].flash_command) |
| 250 | | { |
| 251 | | /* read mode, return flash-rom data */ |
| 252 | | case FLASH_COMMAND_READ_ARRAY_OR_RESET: |
| 253 | | return flash[index1].base[offset]; |
| 254 | | |
| 255 | | /* read intelligent identifier */ |
| 256 | | case FLASH_COMMAND_INTELLIGENT_IDENTIFIER: |
| 257 | | { |
| 258 | | /* offset/address zero returns manufacturer code */ |
| 259 | | if (offset==0) |
| 260 | | return FLASH_MANUFACTURER_CODE; |
| 261 | | /* offset/address one returns device code */ |
| 262 | | if (offset==1) |
| 263 | | return FLASH_DEVICE_CODE; |
| 264 | | } |
| 265 | | break; |
| 266 | | |
| 267 | | /* read status */ |
| 268 | | case FLASH_COMMAND_BYTE_WRITE_SETUP_OR_WRITE: |
| 269 | | case FLASH_COMMAND_ALTERNATIVE_BYTE_WRITE_SETUP_OR_WRITE: |
| 270 | | case FLASH_COMMAND_ERASE_SETUP_OR_ERASE_CONFIRM: |
| 271 | | case FLASH_COMMAND_READ_STATUS_REGISTER: |
| 272 | | case FLASH_COMMAND_CLEAR_STATUS_REGISTER: |
| 273 | | case FLASH_COMMAND_ERASE_SUSPEND_OR_ERASE_RESUME: |
| 274 | | case FLASH_COMMAND_ERASE_CONFIRM: |
| 275 | | return flash[index1].flash_status; |
| 276 | | |
| 277 | | } |
| 278 | | |
| 279 | | return 0x0ff; |
| 280 | | } |
| 281 | | |
| 282 | | /* flash write - offset is offset within flash-file (offset within 1mb)*/ |
| 283 | | void flash_bank_handler_w(int index1, int offset, int data) |
| 284 | | { |
| 285 | | /* for commands requiring more than one cycle */ |
| 286 | | if (flash[index1].flash_command_parameters_required!=0) |
| 287 | | { |
| 288 | | switch (flash[index1].flash_command) |
| 289 | | { |
| 290 | | case FLASH_COMMAND_BYTE_WRITE_SETUP_OR_WRITE: |
| 291 | | case FLASH_COMMAND_ALTERNATIVE_BYTE_WRITE_SETUP_OR_WRITE: |
| 292 | | { |
| 293 | | /* ready, with no errors */ |
| 294 | | flash[index1].flash_status &= FLASH_STATUS_ERASE_SUSPEND_STATUS_SUSPENDED; |
| 295 | | flash[index1].flash_status |= FLASH_STATUS_WRITE_STATE_MACHINE_STATUS_READY; |
| 296 | | flash[index1].base[offset] = data; |
| 297 | | |
| 298 | | /* no parameters required */ |
| 299 | | flash[index1].flash_command_parameters_required = 0; |
| 300 | | } |
| 301 | | return; |
| 302 | | |
| 303 | | default: |
| 304 | | break; |
| 305 | | } |
| 306 | | |
| 307 | | } |
| 308 | | |
| 309 | | |
| 310 | | flash[index1].flash_command_parameters_required = 0; |
| 311 | | /* set command */ |
| 312 | | flash[index1].flash_command = data; |
| 313 | | |
| 314 | | switch (data) |
| 315 | | { |
| 316 | | case FLASH_COMMAND_READ_ARRAY_OR_RESET: |
| 317 | | case FLASH_COMMAND_INTELLIGENT_IDENTIFIER: |
| 318 | | case FLASH_COMMAND_READ_STATUS_REGISTER: |
| 319 | | case FLASH_COMMAND_CLEAR_STATUS_REGISTER: |
| 320 | | { |
| 321 | | /* if clear status register */ |
| 322 | | if (data == FLASH_COMMAND_CLEAR_STATUS_REGISTER) |
| 323 | | { |
| 324 | | /* clear it */ |
| 325 | | flash[index1].flash_status &=FLASH_STATUS_ERASE_SUSPEND_STATUS_SUSPENDED; |
| 326 | | } |
| 327 | | } |
| 328 | | break; |
| 329 | | |
| 330 | | case FLASH_COMMAND_BYTE_WRITE_SETUP_OR_WRITE: |
| 331 | | case FLASH_COMMAND_ALTERNATIVE_BYTE_WRITE_SETUP_OR_WRITE: |
| 332 | | { |
| 333 | | /* expecting a parameter */ |
| 334 | | flash[index1].flash_command_parameters_required = 1; |
| 335 | | } |
| 336 | | break; |
| 337 | | |
| 338 | | /* setup an erase */ |
| 339 | | case FLASH_COMMAND_ERASE_SETUP_OR_ERASE_CONFIRM: |
| 340 | | { |
| 341 | | flash[index1].flash_erase_status = FLASH_ERASE_STATUS_SETUP; |
| 342 | | } |
| 343 | | break; |
| 344 | | |
| 345 | | case FLASH_COMMAND_ERASE_SUSPEND_OR_ERASE_RESUME: |
| 346 | | { |
| 347 | | /* is it suspended? */ |
| 348 | | if ((flash[index1].flash_status & FLASH_STATUS_ERASE_SUSPEND_STATUS_SUSPENDED)==0) |
| 349 | | { |
| 350 | | /* no */ |
| 351 | | |
| 352 | | /* suspend it */ |
| 353 | | flash_suspend_erase(index1); |
| 354 | | } |
| 355 | | } |
| 356 | | break; |
| 357 | | |
| 358 | | |
| 359 | | case FLASH_COMMAND_ERASE_CONFIRM: |
| 360 | | { |
| 361 | | switch (flash[index1].flash_erase_status) |
| 362 | | { |
| 363 | | /* suspended? */ |
| 364 | | case FLASH_ERASE_STATUS_SUSPENDED: |
| 365 | | { |
| 366 | | /* has the erase procedure completed? */ |
| 367 | | |
| 368 | | /* if suspended.. and not completed */ |
| 369 | | /* confirm start erase */ |
| 370 | | |
| 371 | | /* no longer suspended */ |
| 372 | | flash_resume_erase(index1); |
| 373 | | } |
| 374 | | break; |
| 375 | | |
| 376 | | /* setup? */ |
| 377 | | case FLASH_ERASE_STATUS_SETUP: |
| 378 | | { |
| 379 | | /* get block we are erasing */ |
| 380 | | flash[index1].flash_erase_block = offset>>16; |
| 381 | | |
| 382 | | /* set initial offset */ |
| 383 | | flash[index1].flash_offset = 0; |
| 384 | | |
| 385 | | /* start the timer for erase */ |
| 386 | | flash_resume_erase(index1); |
| 387 | | } |
| 388 | | break; |
| 389 | | |
| 390 | | default: |
| 391 | | break; |
| 392 | | } |
| 393 | | } |
| 394 | | break; |
| 395 | | |
| 396 | | default: |
| 397 | | break; |
| 398 | | |
| 399 | | } |
| 400 | | |
| 401 | | } |
| 402 | | |
| 403 | | /*******************************************/ |
src/mess/machine/am29f080.c
| r1157 | r1158 | |
| 1 | | /*******************************************/ |
| 2 | | /* Intel 28F008SA 5 Volt Flash-File Memory */ |
| 3 | | |
| 4 | | #include "driver.h" |
| 5 | | |
| 6 | | #include "includes/am29f080.h" |
| 7 | | |
| 8 | | /* commands */ |
| 9 | | |
| 10 | | enum |
| 11 | | { |
| 12 | | AMD_FLASH_MODE_READ_ARRAY, |
| 13 | | AMD_FLASH_MODE_AUTOSELECT, |
| 14 | | AMD_FLASH_MODE_BYTE_PROGRAM, |
| 15 | | AMD_FLASH_MODE_WAITING_ERASE_TYPE |
| 16 | | }; |
| 17 | | |
| 18 | | |
| 19 | | #define AMD_FLASH_COMMAND_RESET 0x0F0 |
| 20 | | #define AMD_FLASH_COMMAND_ERASE_SUSPEND 0x0B0 |
| 21 | | #define AMD_FLASH_COMMAND_ERASE_RESUME 0x030 |
| 22 | | #define AMD_FLASH_COMMAND_AUTOSELECT 0x090 |
| 23 | | #define AMD_FLASH_COMMAND_ERASE 0x080 |
| 24 | | #define AMD_FLASH_COMMAND_BYTE_PROGRAM 0x0A0 |
| 25 | | #define AMD_FLASH_COMMAND_ERASE_CHIP 0x010 |
| 26 | | #define AMD_FLASH_COMMAND_ERASE_SECTOR 0x030 |
| 27 | | |
| 28 | | #define AMD_FLASH_MANUFACTURER_CODE 0x001 |
| 29 | | #define AMD_FLASH_DEVICE_CODE 0x0d5 |
| 30 | | |
| 31 | | struct amd_flash_interface |
| 32 | | { |
| 33 | | /* ready/busy# output callback */ |
| 34 | | void (*amd_flash_ry_by_output)(int state); |
| 35 | | }; |
| 36 | | |
| 37 | | |
| 38 | | |
| 39 | | typedef struct AMD_FLASH_FILE_MEMORY |
| 40 | | { |
| 41 | | unsigned long amd_autoselect_state; |
| 42 | | unsigned long mode; |
| 43 | | unsigned char sector_group_protection; |
| 44 | | |
| 45 | | // /* internal status register */ |
| 46 | | // unsigned long flash_status; |
| 47 | | // /* command */ |
| 48 | | // unsigned long flash_command; |
| 49 | | // /* number of command cycles required */ |
| 50 | | // unsigned long flash_command_parameters_required; |
| 51 | | // |
| 52 | | // /* index of 64k block to erase */ |
| 53 | | // unsigned long flash_erase_block; |
| 54 | | // |
| 55 | | // /* offset we were last suspended at, or offset the erase procedure started at*/ |
| 56 | | // unsigned long flash_offset; |
| 57 | | |
| 58 | | void *flash_timer; |
| 59 | | |
| 60 | | int flash_erase_status; |
| 61 | | |
| 62 | | /* address of 1mb data */ |
| 63 | | char *base; |
| 64 | | |
| 65 | | struct amd_flash_interface interface; |
| 66 | | } AMD_FLASH_FILE_MEMORY; |
| 67 | | |
| 68 | | |
| 69 | | #define MAX_FLASH_DEVICES 4 |
| 70 | | |
| 71 | | static AMD_FLASH_FILE_MEMORY amd_flash[MAX_FLASH_DEVICES]; |
| 72 | | |
| 73 | | |
| 74 | | #if 0 |
| 75 | | void amd_flash_set_interface(int index1, struct amd_flash_interface *interface) |
| 76 | | { |
| 77 | | if ((index1<0) || (index1>=MAX_FLASH_DEVICES)) |
| 78 | | return; |
| 79 | | |
| 80 | | memcpy(&amd_flash[index1].interface, interface, sizeof(struct amd_flash_interface)); |
| 81 | | } |
| 82 | | |
| 83 | | /* set sector group protection status */ |
| 84 | | void amd_flash_set_sector_group_protection(int index1, int group_index, int is_protected) |
| 85 | | { |
| 86 | | if ((index1<0) || (index1>=MAX_FLASH_DEVICES)) |
| 87 | | return; |
| 88 | | |
| 89 | | if ((group_index<0) || (group_index>=7)) |
| 90 | | return; |
| 91 | | |
| 92 | | amd_flash[index1].sector_group_protection &= ~(1<<group_index); |
| 93 | | |
| 94 | | if (is_protected) |
| 95 | | { |
| 96 | | amd_flash[index1].sector_group_protection |= (1<<group_index); |
| 97 | | } |
| 98 | | } |
| 99 | | #endif |
| 100 | | |
| 101 | | |
| 102 | | |
| 103 | | char *amd_flash_get_base(int index1) |
| 104 | | { |
| 105 | | return amd_flash[index1].base; |
| 106 | | } |
| 107 | | |
| 108 | | |
| 109 | | void amd_flash_reset(int index1) |
| 110 | | { |
| 111 | | amd_flash[index1].mode = AMD_FLASH_MODE_READ_ARRAY; |
| 112 | | amd_flash[index1].amd_autoselect_state = 0; |
| 113 | | } |
| 114 | | |
| 115 | | void amd_flash_init(int index1) |
| 116 | | { |
| 117 | | /* all groups are write enabled! */ |
| 118 | | amd_flash[index1].sector_group_protection = 0; |
| 119 | | |
| 120 | | /* 1mb ram */ |
| 121 | | amd_flash[index1].base = (char *)malloc(1024*1024); |
| 122 | | if (amd_flash[index1].base!=NULL) |
| 123 | | { |
| 124 | | memset(amd_flash[index1].base, 0x080, 1024*1024); |
| 125 | | } |
| 126 | | amd_flash_reset(index1); |
| 127 | | } |
| 128 | | |
| 129 | | void amd_flash_finish(int index1) |
| 130 | | { |
| 131 | | if (amd_flash[index1].base!=NULL) |
| 132 | | { |
| 133 | | free(amd_flash[index1].base); |
| 134 | | amd_flash[index1].base = NULL; |
| 135 | | } |
| 136 | | } |
| 137 | | |
| 138 | | void amd_flash_store(int index1, const char *flash_name) |
| 139 | | { |
| 140 | | file_error filerr; |
| 141 | | mame_file *file; |
| 142 | | |
| 143 | | if (amd_flash[index1].base!=NULL) |
| 144 | | { |
| 145 | | filerr = mame_fopen(SEARCHPATH_MEMCARD, flash_name, OPEN_FLAG_WRITE, &file); |
| 146 | | if (filerr == FILERR_NONE) |
| 147 | | { |
| 148 | | mame_fwrite(file, amd_flash[index1].base, (1024*1024)); |
| 149 | | mame_fclose(file); |
| 150 | | } |
| 151 | | } |
| 152 | | } |
| 153 | | |
| 154 | | |
| 155 | | |
| 156 | | void amd_flash_restore(int index1, const char *flash_name) |
| 157 | | { |
| 158 | | file_error filerr; |
| 159 | | mame_file *file; |
| 160 | | |
| 161 | | if (amd_flash[index1].base!=NULL) |
| 162 | | { |
| 163 | | filerr = mame_fopen(SEARCHPATH_MEMCARD, flash_name, OPEN_FLAG_READ, &file); |
| 164 | | if (filerr == FILERR_NONE) |
| 165 | | { |
| 166 | | mame_fread(file, amd_flash[index1].base, (1024*1024)); |
| 167 | | mame_fclose(file); |
| 168 | | } |
| 169 | | } |
| 170 | | } |
| 171 | | |
| 172 | | |
| 173 | | |
| 174 | | /* flash read - offset is offset within flash-file (offset within 1mb)*/ |
| 175 | | int amd_flash_bank_handler_r(int index1, int offset) |
| 176 | | { |
| 177 | | |
| 178 | | switch (amd_flash[index1].mode) |
| 179 | | { |
| 180 | | /* read byte */ |
| 181 | | case AMD_FLASH_MODE_READ_ARRAY: |
| 182 | | return amd_flash[index1].base[offset]; |
| 183 | | |
| 184 | | case AMD_FLASH_MODE_AUTOSELECT: |
| 185 | | { |
| 186 | | logerror("amd flash read: offs: %04x\n",offset); |
| 187 | | |
| 188 | | switch (offset & 0x03) |
| 189 | | { |
| 190 | | /* get manufacturer code */ |
| 191 | | case 0: |
| 192 | | return AMD_FLASH_MANUFACTURER_CODE; |
| 193 | | /* get device code */ |
| 194 | | case 1: |
| 195 | | return AMD_FLASH_DEVICE_CODE; |
| 196 | | |
| 197 | | /* get sector protection. 01 = write protected, 00 = write enabled */ |
| 198 | | /* write protection applies to a group of sectors. Each sector is 64k, and |
| 199 | | each group identifies two consecutive sectors. group 0 contains sector 0 and sector 1 */ |
| 200 | | case 2: |
| 201 | | { |
| 202 | | /* A19, A18, A17 define sector group */ |
| 203 | | unsigned long sector_group = (offset>>17) & 0x07; |
| 204 | | |
| 205 | | /* return bit indicating protection status */ |
| 206 | | return (amd_flash[index1].sector_group_protection>>sector_group) & 0x01; |
| 207 | | } |
| 208 | | break; |
| 209 | | |
| 210 | | /* 3 - not defined! */ |
| 211 | | default: |
| 212 | | break; |
| 213 | | } |
| 214 | | |
| 215 | | } |
| 216 | | break; |
| 217 | | } |
| 218 | | |
| 219 | | return 0x0ff; |
| 220 | | } |
| 221 | | |
| 222 | | |
| 223 | | static void amd_autoselect_sequence_update(int index1, int offset, int data) |
| 224 | | { |
| 225 | | switch (amd_flash[index1].amd_autoselect_state) |
| 226 | | { |
| 227 | | case 0: |
| 228 | | { |
| 229 | | int addr = offset & 0x07ff; |
| 230 | | if ((addr==0x0555) && (data==0x0aa)) |
| 231 | | { |
| 232 | | logerror("amd flash: recognised address 0x0555 and data 0x0aa\n"); |
| 233 | | amd_flash[index1].amd_autoselect_state++; |
| 234 | | } |
| 235 | | else |
| 236 | | { |
| 237 | | amd_flash[index1].amd_autoselect_state = 0; |
| 238 | | } |
| 239 | | } |
| 240 | | break; |
| 241 | | |
| 242 | | case 1: |
| 243 | | { |
| 244 | | int addr = offset & 0x07ff; |
| 245 | | if ((addr==0x02aa) && (data==0x055)) |
| 246 | | { |
| 247 | | logerror("amd flash: recognised address 0x02aa and data 0x055\n"); |
| 248 | | amd_flash[index1].amd_autoselect_state++; |
| 249 | | amd_flash[index1].mode = AMD_FLASH_MODE_AUTOSELECT; |
| 250 | | } |
| 251 | | else |
| 252 | | { |
| 253 | | amd_flash[index1].amd_autoselect_state = 0; |
| 254 | | } |
| 255 | | } |
| 256 | | break; |
| 257 | | |
| 258 | | case 2: |
| 259 | | { |
| 260 | | int addr = offset & 0x07ff; |
| 261 | | amd_flash[index1].amd_autoselect_state = 0; |
| 262 | | |
| 263 | | if (addr==0x0555) |
| 264 | | { |
| 265 | | logerror("amd flash: recognised address 0x0555, command: %02x\n",data); |
| 266 | | |
| 267 | | switch (data) |
| 268 | | { |
| 269 | | /* not sure if this is correct for amd flash! */ |
| 270 | | case AMD_FLASH_COMMAND_RESET: |
| 271 | | { |
| 272 | | /* return to read array */ |
| 273 | | amd_flash[index1].mode = AMD_FLASH_MODE_READ_ARRAY; |
| 274 | | amd_flash[index1].amd_autoselect_state = 0; |
| 275 | | } |
| 276 | | break; |
| 277 | | |
| 278 | | case AMD_FLASH_COMMAND_AUTOSELECT: |
| 279 | | { |
| 280 | | amd_flash[index1].mode = AMD_FLASH_MODE_AUTOSELECT; |
| 281 | | } |
| 282 | | break; |
| 283 | | |
| 284 | | case AMD_FLASH_COMMAND_BYTE_PROGRAM: |
| 285 | | { |
| 286 | | amd_flash[index1].mode = AMD_FLASH_MODE_BYTE_PROGRAM; |
| 287 | | } |
| 288 | | break; |
| 289 | | |
| 290 | | case AMD_FLASH_COMMAND_ERASE: |
| 291 | | { |
| 292 | | /* reset state */ |
| 293 | | amd_flash[index1].amd_autoselect_state = 0; |
| 294 | | amd_flash[index1].mode = AMD_FLASH_MODE_WAITING_ERASE_TYPE; |
| 295 | | } |
| 296 | | break; |
| 297 | | } |
| 298 | | } |
| 299 | | } |
| 300 | | break; |
| 301 | | } |
| 302 | | } |
| 303 | | |
| 304 | | |
| 305 | | /* flash write - offset is offset within flash-file (offset within 1mb)*/ |
| 306 | | void amd_flash_bank_handler_w(int index1, int offset, int data) |
| 307 | | { |
| 308 | | logerror("amd flash write: offs: %04x data: %02x\n",offset,data); |
| 309 | | |
| 310 | | // /* reset? */ |
| 311 | | // if (data==AMD_FLASH_COMMAND_RESET) |
| 312 | | // { |
| 313 | | // /* return to read array */ |
| 314 | | // amd_flash[index1].mode = AMD_FLASH_MODE_READ_ARRAY; |
| 315 | | // amd_flash[index1].amd_autoselect_state = 0; |
| 316 | | // return; |
| 317 | | // } |
| 318 | | |
| 319 | | amd_autoselect_sequence_update(index1, offset, data); |
| 320 | | |
| 321 | | switch (amd_flash[index1].mode) |
| 322 | | { |
| 323 | | case AMD_FLASH_MODE_BYTE_PROGRAM: |
| 324 | | { |
| 325 | | /* cannot turn a 0 into 1! */ |
| 326 | | |
| 327 | | /* write the byte */ |
| 328 | | amd_flash[index1].base[offset] &=data; |
| 329 | | } |
| 330 | | break; |
| 331 | | |
| 332 | | default: |
| 333 | | break; |
| 334 | | } |
| 335 | | |
| 336 | | } |
| 337 | | |
| 338 | | /*******************************************/ |
src/mess/drivers/pcw16.c
| r1157 | r1158 | |
| 106 | 106 | // pcw/pcw16 beeper |
| 107 | 107 | #include "sound/beep.h" |
| 108 | 108 | |
| 109 | | #include "includes/28f008sa.h" |
| 109 | #include "machine/intelfsh.h" |
| 110 | 110 | |
| 111 | | static void pcw16_machine_stop(running_machine *machine); |
| 112 | | |
| 113 | 111 | // interrupt counter |
| 114 | 112 | unsigned long pcw16_interrupt_counter; |
| 115 | 113 | // video control |
| r1157 | r1158 | |
| 200 | 198 | /* PCW16 Flash interface */ |
| 201 | 199 | /* PCW16 can have two 1mb flash chips */ |
| 202 | 200 | |
| 201 | static NVRAM_HANDLER( pcw16 ) |
| 202 | { |
| 203 | nvram_handler_intelflash( machine, 0, file, read_or_write ); |
| 204 | nvram_handler_intelflash( machine, 1, file, read_or_write ); |
| 205 | } |
| 206 | |
| 203 | 207 | /* read flash0 */ |
| 204 | 208 | static int pcw16_flash0_bank_handler_r(int bank, int offset) |
| 205 | 209 | { |
| 206 | 210 | int flash_offset = (pcw16_banks[bank]<<14) | offset; |
| 207 | 211 | |
| 208 | | return flash_bank_handler_r(0, flash_offset); |
| 212 | return intelflash_read(0, flash_offset); |
| 209 | 213 | } |
| 210 | 214 | |
| 211 | 215 | /* read flash1 */ |
| r1157 | r1158 | |
| 213 | 217 | { |
| 214 | 218 | int flash_offset = ((pcw16_banks[bank]&0x03f)<<14) | offset; |
| 215 | 219 | |
| 216 | | return flash_bank_handler_r(1, flash_offset); |
| 220 | return intelflash_read(1, flash_offset); |
| 217 | 221 | } |
| 218 | 222 | |
| 219 | 223 | /* flash 0 */ |
| r1157 | r1158 | |
| 279 | 283 | { |
| 280 | 284 | int flash_offset = (pcw16_banks[bank]<<14) | offset; |
| 281 | 285 | |
| 282 | | flash_bank_handler_w(0, flash_offset, data); |
| 286 | intelflash_write(0, flash_offset, data); |
| 283 | 287 | } |
| 284 | 288 | |
| 285 | 289 | /* read flash1 */ |
| r1157 | r1158 | |
| 287 | 291 | { |
| 288 | 292 | int flash_offset = ((pcw16_banks[bank]&0x03f)<<14) | offset; |
| 289 | 293 | |
| 290 | | flash_bank_handler_w(1, flash_offset,data); |
| 294 | intelflash_write(1, flash_offset,data); |
| 291 | 295 | } |
| 292 | 296 | |
| 293 | 297 | /* flash 0 */ |
| r1157 | r1158 | |
| 438 | 442 | /* nvram */ |
| 439 | 443 | if ((bank_id & 0x040)==0) |
| 440 | 444 | { |
| 441 | | mem_ptr = (unsigned char *)flash_get_base(0); |
| 445 | mem_ptr = (unsigned char *)intelflash_getmemptr(0); |
| 442 | 446 | } |
| 443 | 447 | else |
| 444 | 448 | { |
| 445 | | mem_ptr = (unsigned char *)flash_get_base(1); |
| 449 | mem_ptr = (unsigned char *)intelflash_getmemptr(1); |
| 446 | 450 | } |
| 447 | 451 | } |
| 448 | 452 | |
| r1157 | r1158 | |
| 1325 | 1329 | pcw16_keyboard_init(); |
| 1326 | 1330 | uart8250_reset(0); |
| 1327 | 1331 | uart8250_reset(1); |
| 1328 | | flash_reset(0); |
| 1329 | | flash_reset(1); |
| 1330 | 1332 | } |
| 1331 | 1333 | |
| 1332 | 1334 | |
| r1157 | r1158 | |
| 1345 | 1347 | |
| 1346 | 1348 | static MACHINE_RESET( pcw16 ) |
| 1347 | 1349 | { |
| 1348 | | /* flash 0 */ |
| 1349 | | flash_init(0); |
| 1350 | | flash_restore(0, "pcw16f1.nv"); |
| 1351 | | |
| 1352 | | /* flash 1 */ |
| 1353 | | flash_init(1); |
| 1354 | | flash_restore(1, "pcw16f2.nv"); |
| 1355 | | |
| 1356 | 1350 | pcw16_system_status = 0; |
| 1357 | 1351 | pcw16_interrupt_counter = 0; |
| 1358 | 1352 | |
| r1157 | r1158 | |
| 1384 | 1378 | |
| 1385 | 1379 | beep_set_state(0,0); |
| 1386 | 1380 | beep_set_frequency(0,3750); |
| 1387 | | |
| 1388 | | add_exit_callback(machine, pcw16_machine_stop); |
| 1389 | 1381 | } |
| 1390 | 1382 | |
| 1391 | | static void pcw16_machine_stop(running_machine *machine) |
| 1392 | | { |
| 1393 | | /* flash 0 */ |
| 1394 | | flash_store(0,"pcw16f1.nv"); |
| 1395 | | flash_finish(0); |
| 1396 | | |
| 1397 | | flash_store(1,"pcw16f2.nv"); |
| 1398 | | flash_finish(1); |
| 1399 | | } |
| 1400 | | |
| 1401 | 1383 | INPUT_PORTS_START(pcw16) |
| 1402 | 1384 | PORT_START |
| 1403 | 1385 | /* vblank */ |
| r1157 | r1158 | |
| 1424 | 1406 | MDRV_INTERLEAVE(1) |
| 1425 | 1407 | |
| 1426 | 1408 | MDRV_MACHINE_RESET( pcw16 ) |
| 1409 | MDRV_NVRAM_HANDLER( pcw16 ) |
| 1427 | 1410 | |
| 1428 | 1411 | /* video hardware */ |
| 1429 | 1412 | MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER) |
| r1157 | r1158 | |
| 1444 | 1427 | MACHINE_DRIVER_END |
| 1445 | 1428 | |
| 1446 | 1429 | |
| 1430 | static DRIVER_INIT( pcw16 ) |
| 1431 | { |
| 1432 | /* init flashes */ |
| 1433 | intelflash_init(0, FLASH_INTEL_E28F008SA, NULL); |
| 1434 | intelflash_init(1, FLASH_INTEL_E28F008SA, NULL); |
| 1435 | } |
| 1436 | |
| 1447 | 1437 | /*************************************************************************** |
| 1448 | 1438 | |
| 1449 | 1439 | Game driver(s) |
| r1157 | r1158 | |
| 1493 | 1483 | SYSTEM_CONFIG_END |
| 1494 | 1484 | |
| 1495 | 1485 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG, COMPANY FULLNAME */ |
| 1496 | | COMP( 1995, pcw16, 0, 0, pcw16, pcw16, 0, pcw16, "Amstrad plc", "PCW16", 0) |
| 1486 | COMP( 1995, pcw16, 0, 0, pcw16, pcw16, pcw16, pcw16, "Amstrad plc", "PCW16", 0) |
src/mess/drivers/avigo.c
| r1157 | r1158 | |
| 39 | 39 | ******************************************************************************/ |
| 40 | 40 | #include "driver.h" |
| 41 | 41 | #include "includes/avigo.h" |
| 42 | | #include "includes/am29f080.h" |
| 42 | #include "machine/intelfsh.h" |
| 43 | 43 | #include "includes/tc8521.h" |
| 44 | 44 | #include "machine/uart8250.h" |
| 45 | 45 | #include "sound/speaker.h" |
| r1157 | r1158 | |
| 81 | 81 | static int avigo_flash_at_0x8000; |
| 82 | 82 | static void *avigo_banked_opbase[4]; |
| 83 | 83 | |
| 84 | static NVRAM_HANDLER( avigo ) |
| 85 | { |
| 86 | int i; |
| 87 | |
| 88 | for (i = 0; i < 3; i++) |
| 89 | { |
| 90 | nvram_handler_intelflash( machine, i, file, read_or_write ); |
| 91 | } |
| 92 | } |
| 93 | |
| 84 | 94 | static void avigo_setbank(int bank, void *address, read8_handler rh, write8_handler wh) |
| 85 | 95 | { |
| 86 | 96 | if (address) |
| r1157 | r1158 | |
| 104 | 114 | /* memory 0x0000-0x03fff */ |
| 105 | 115 | static READ8_HANDLER(avigo_flash_0x0000_read_handler) |
| 106 | 116 | { |
| 107 | | int flash_offset = offset; |
| 108 | | return amd_flash_bank_handler_r(0, flash_offset); |
| 117 | return intelflash_read(0, offset); |
| 109 | 118 | } |
| 110 | 119 | |
| 111 | 120 | /* memory 0x04000-0x07fff */ |
| 112 | 121 | static READ8_HANDLER(avigo_flash_0x4000_read_handler) |
| 113 | 122 | { |
| 114 | | |
| 115 | | int flash_offset = (avigo_rom_bank_l<<14) | offset; |
| 116 | | |
| 117 | | // logerror("flash offset: %04x offset: %04x\n",flash_offset, offset); |
| 118 | | |
| 119 | | |
| 120 | | return amd_flash_bank_handler_r(avigo_flash_at_0x4000, flash_offset); |
| 123 | return intelflash_read(avigo_flash_at_0x4000, (avigo_rom_bank_l<<14) | offset); |
| 121 | 124 | } |
| 122 | 125 | |
| 123 | 126 | /* memory 0x0000-0x03fff */ |
| 124 | 127 | static WRITE8_HANDLER(avigo_flash_0x0000_write_handler) |
| 125 | 128 | { |
| 126 | | |
| 127 | | int flash_offset = offset; |
| 128 | | |
| 129 | | amd_flash_bank_handler_w(0, flash_offset, data); |
| 129 | intelflash_write(0, offset, data); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /* memory 0x04000-0x07fff */ |
| 133 | 133 | static WRITE8_HANDLER(avigo_flash_0x4000_write_handler) |
| 134 | 134 | { |
| 135 | | |
| 136 | | int flash_offset = (avigo_rom_bank_l<<14) | offset; |
| 137 | | |
| 138 | | // logerror("flash offset: %04x offset: %04x\n",flash_offset, offset); |
| 139 | | |
| 140 | | amd_flash_bank_handler_w(avigo_flash_at_0x4000, flash_offset, data); |
| 135 | intelflash_write(avigo_flash_at_0x4000, (avigo_rom_bank_l<<14) | offset, data); |
| 141 | 136 | } |
| 142 | 137 | |
| 143 | 138 | /* memory 0x08000-0x0bfff */ |
| 144 | 139 | static READ8_HANDLER(avigo_flash_0x8000_read_handler) |
| 145 | 140 | { |
| 146 | | |
| 147 | | int flash_offset = (avigo_ram_bank_l<<14) | offset; |
| 148 | | |
| 149 | | // logerror("flash offset: %04x offset: %04x\n",flash_offset, offset); |
| 150 | | |
| 151 | | return amd_flash_bank_handler_r(avigo_flash_at_0x8000, flash_offset); |
| 141 | return intelflash_read(avigo_flash_at_0x8000, (avigo_rom_bank_l<<14) | offset); |
| 152 | 142 | } |
| 153 | 143 | |
| 154 | 144 | #ifdef UNUSED_FUNCTION |
| 155 | 145 | /* memory 0x08000-0x0bfff */ |
| 156 | 146 | static WRITE8_HANDLER(avigo_flash_0x8000_write_handler) |
| 157 | 147 | { |
| 158 | | |
| 159 | | int flash_offset = (avigo_ram_bank_l<<14) | offset; |
| 160 | | |
| 161 | | // logerror("flash offset: %04x offset: %04x\n",flash_offset, offset); |
| 162 | | |
| 163 | | amd_flash_bank_handler_w(avigo_flash_at_0x8000, flash_offset, data); |
| 148 | intelflash_write(avigo_flash_at_0x8000, (avigo_rom_bank_l<<14) | offset, data); |
| 164 | 149 | } |
| 165 | 150 | #endif |
| 166 | 151 | |
| r1157 | r1158 | |
| 327 | 312 | break; |
| 328 | 313 | } |
| 329 | 314 | |
| 330 | | addr = (unsigned char *)amd_flash_get_base(avigo_flash_at_0x4000); |
| 315 | addr = (unsigned char *)intelflash_getmemptr(avigo_flash_at_0x4000); |
| 331 | 316 | addr = addr + (avigo_rom_bank_l<<14); |
| 332 | 317 | avigo_setbank(1, addr, avigo_flash_0x4000_read_handler, avigo_flash_0x4000_write_handler); |
| 333 | 318 | |
| r1157 | r1158 | |
| 351 | 336 | avigo_flash_at_0x8000 = 1; |
| 352 | 337 | |
| 353 | 338 | |
| 354 | | addr = (unsigned char *)amd_flash_get_base(avigo_flash_at_0x8000); |
| 339 | addr = (unsigned char *)intelflash_getmemptr(avigo_flash_at_0x8000); |
| 355 | 340 | addr = addr + (avigo_ram_bank_l<<14); |
| 356 | 341 | avigo_setbank(2, addr, avigo_flash_0x8000_read_handler, |
| 357 | 342 | MWA8_NOP /* avigo_flash_0x8000_write_handler */); |
| r1157 | r1158 | |
| 360 | 345 | case 0x07: |
| 361 | 346 | avigo_flash_at_0x8000 = 0; |
| 362 | 347 | |
| 363 | | addr = (unsigned char *)amd_flash_get_base(avigo_flash_at_0x8000); |
| 348 | addr = (unsigned char *)intelflash_getmemptr(avigo_flash_at_0x8000); |
| 364 | 349 | addr = addr + (avigo_ram_bank_l<<14); |
| 365 | 350 | avigo_setbank(2, addr, avigo_flash_0x8000_read_handler, |
| 366 | 351 | MWA8_NOP /* avigo_flash_0x8000_write_handler */); |
| r1157 | r1158 | |
| 419 | 404 | memset(avigo_banked_opbase, 0, sizeof(avigo_banked_opbase)); |
| 420 | 405 | |
| 421 | 406 | /* initialise flash memory */ |
| 422 | | amd_flash_init(0); |
| 423 | | amd_flash_init(1); |
| 424 | | amd_flash_init(2); |
| 407 | intelflash_init(0, FLASH_INTEL_E28F008SA, memory_region(REGION_CPU1)+0x10000); |
| 408 | intelflash_init(1, FLASH_INTEL_E28F008SA, memory_region(REGION_CPU1)+0x100000); |
| 409 | intelflash_init(2, FLASH_INTEL_E28F008SA, NULL); |
| 425 | 410 | |
| 426 | | /* install os into flash from rom image data */ |
| 427 | | { |
| 428 | | /* get base of rom data */ |
| 429 | | char *rom = (char *)memory_region(REGION_CPU1)+0x010000; |
| 430 | | char *flash; |
| 431 | | |
| 432 | | if (rom!=NULL) |
| 433 | | { |
| 434 | | /* copy first 1mb into first flash */ |
| 435 | | flash = (char *)amd_flash_get_base(0); |
| 436 | | if (flash) |
| 437 | | memcpy(flash, rom, 0x0100000); |
| 438 | | |
| 439 | | /* copy second 1mb into second flash */ |
| 440 | | flash = (char *)amd_flash_get_base(1); |
| 441 | | if (flash) |
| 442 | | memcpy(flash, rom+0x0100000, 0x0150000-0x0100000); |
| 443 | | } |
| 444 | | } |
| 445 | | |
| 446 | | |
| 447 | 411 | stylus_marker_x = AVIGO_SCREEN_WIDTH>>1; |
| 448 | 412 | stylus_marker_y = AVIGO_SCREEN_HEIGHT>>1; |
| 449 | 413 | stylus_press_x = 0; |
| 450 | 414 | stylus_press_y = 0; |
| 451 | 415 | avigo_vh_set_stylus_marker_position(stylus_marker_x, stylus_marker_y); |
| 452 | 416 | |
| 453 | | /* if these files exist, they will overwrite the os installed |
| 454 | | from the rom in the code above. |
| 455 | | |
| 456 | | This is ok. These files will be created by this driver and they will |
| 457 | | contain the OS data in them! Since these files are in the flash |
| 458 | | memory they can be written to. */ |
| 459 | | |
| 460 | | |
| 461 | | amd_flash_restore(0, "avigof1.nv"); |
| 462 | | amd_flash_reset(0); |
| 463 | | |
| 464 | | amd_flash_restore(1, "avigof2.nv"); |
| 465 | | amd_flash_reset(1); |
| 466 | | |
| 467 | | amd_flash_restore(2, "avigof3.nv"); |
| 468 | | amd_flash_reset(2); |
| 469 | | |
| 470 | 417 | /* initialise settings for port data */ |
| 471 | 418 | for (i=0; i<4; i++) |
| 472 | 419 | { |
| r1157 | r1158 | |
| 493 | 440 | |
| 494 | 441 | memory_set_opbase_handler(0, avigo_opbase_handler); |
| 495 | 442 | |
| 496 | | addr = (unsigned char *)amd_flash_get_base(0); |
| 443 | addr = (unsigned char *)intelflash_getmemptr(0); |
| 497 | 444 | avigo_setbank(0, addr, avigo_flash_0x0000_read_handler, avigo_flash_0x0000_write_handler); |
| 498 | 445 | |
| 499 | 446 | avigo_setbank(3, mess_ram, NULL, NULL); |
| r1157 | r1158 | |
| 502 | 449 | avigo_refresh_memory(); |
| 503 | 450 | } |
| 504 | 451 | |
| 505 | | static void avigo_machine_stop(running_machine *machine) |
| 506 | | { |
| 507 | | /* store and free flash memory */ |
| 508 | | amd_flash_store(0, "avigof1.nv"); |
| 509 | | amd_flash_finish(0); |
| 510 | | |
| 511 | | amd_flash_store(1, "avigof2.nv"); |
| 512 | | amd_flash_finish(1); |
| 513 | | |
| 514 | | amd_flash_store(2, "avigof3.nv"); |
| 515 | | amd_flash_finish(2); |
| 516 | | } |
| 517 | | |
| 518 | 452 | static MACHINE_START( avigo ) |
| 519 | 453 | { |
| 520 | 454 | /* a timer used to check status of pen */ |
| r1157 | r1158 | |
| 522 | 456 | mame_timer_pulse(MAME_TIME_IN_HZ(50), 0, avigo_dummy_timer_callback); |
| 523 | 457 | |
| 524 | 458 | add_reset_callback(machine, avigo_machine_reset); |
| 525 | | add_exit_callback(machine, avigo_machine_stop); |
| 526 | 459 | } |
| 527 | 460 | |
| 528 | 461 | |
| r1157 | r1158 | |
| 935 | 868 | MDRV_INTERLEAVE(1) |
| 936 | 869 | |
| 937 | 870 | MDRV_MACHINE_START( avigo ) |
| 871 | MDRV_NVRAM_HANDLER( avigo ) |
| 938 | 872 | |
| 939 | 873 | /* video hardware */ |
| 940 | 874 | MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER) |