src/mess/formats/ti85_ser.c
| r6323 | r6324 | |
| 112 | 112 | INLINE ti85serial_state *get_token(const device_config *device) |
| 113 | 113 | { |
| 114 | 114 | assert(device != NULL); |
| 115 | | assert(device->type == TI85SERIAL); |
| 115 | assert((device->type == TI85SERIAL) || (device->type == TI86SERIAL)); |
| 116 | 116 | return (ti85serial_state *) device->token; |
| 117 | 117 | } |
| 118 | 118 | |
| r6323 | r6324 | |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | |
| 317 | | static int ti85_convert_file_data_to_serial_stream (const device_config *device, const UINT8* file_data, unsigned int file_size, ti85_serial_data* serial_data, char* calc_type) |
| 317 | static int ti85_convert_file_data_to_serial_stream (const device_config *device, const UINT8* file_data, unsigned int file_size, ti85_serial_data* serial_data) |
| 318 | 318 | { |
| 319 | 319 | ti85serial_state *ti85serial = get_token( device ); |
| 320 | 320 | UINT16 i; |
| r6323 | r6324 | |
| 325 | 325 | UINT8* temp_data_to_convert = NULL; |
| 326 | 326 | UINT16 checksum; |
| 327 | 327 | |
| 328 | | if (!strncmp(calc_type, "ti85", 4)) |
| 328 | if (device->type == TI85SERIAL) |
| 329 | 329 | if (strncmp((char *) file_data, (char *) ti85_file_signature, 11)) |
| 330 | 330 | return 0; |
| 331 | | if (!strncmp(calc_type, "ti86", 4)) |
| 331 | if (device->type == TI86SERIAL) |
| 332 | 332 | if (strncmp((char *) file_data, (char *) ti86_file_signature, 11)) |
| 333 | 333 | return 0; |
| 334 | 334 | |
| r6323 | r6324 | |
| 417 | 417 | } |
| 418 | 418 | serial_data->variables[i].header_size = (10+ti85_entries[i].name_size)*8; |
| 419 | 419 | |
| 420 | | if (!strncmp(calc_type, "ti85", 4)) |
| 420 | if (device->type == TI85SERIAL) |
| 421 | 421 | temp_data_to_convert[0] = 0x05; //PC to TI-85 |
| 422 | | if (!strncmp(calc_type, "ti86", 4)) |
| 422 | if (device->type == TI86SERIAL) |
| 423 | 423 | temp_data_to_convert[0] = 0x06; //PC to TI-86 |
| 424 | 424 | temp_data_to_convert[1] = 0x06; //header |
| 425 | 425 | temp_data_to_convert[2] = (4+ti85_entries[i].name_size)&0x00ff; |
| r6323 | r6324 | |
| 443 | 443 | free (ti85_entries); |
| 444 | 444 | return 0; |
| 445 | 445 | } |
| 446 | | if (!strncmp(calc_type, "ti85", 4)) |
| 446 | if (device->type == TI85SERIAL) |
| 447 | 447 | ti85_convert_data_to_stream(ti85_pc_ok_packet, TI85_PC_OK_PACKET_SIZE, serial_data->variables[i].ok); |
| 448 | | if (!strncmp(calc_type, "ti86", 4)) |
| 448 | if (device->type == TI86SERIAL) |
| 449 | 449 | ti85_convert_data_to_stream(ti86_pc_ok_packet, TI85_PC_OK_PACKET_SIZE, serial_data->variables[i].ok); |
| 450 | 450 | serial_data->variables[i].ok_size = TI85_PC_OK_PACKET_SIZE*8; |
| 451 | 451 | |
| r6323 | r6324 | |
| 465 | 465 | } |
| 466 | 466 | serial_data->variables[i].data_size = (6+ti85_entries[i].data_size)*8; |
| 467 | 467 | |
| 468 | | if (!strncmp(calc_type, "ti85", 4)) |
| 468 | if (device->type == TI85SERIAL) |
| 469 | 469 | temp_data_to_convert[0] = 0x05; //PC to TI-85 |
| 470 | | if (!strncmp(calc_type, "ti86", 4)) |
| 470 | if (device->type == TI86SERIAL) |
| 471 | 471 | temp_data_to_convert[0] = 0x06; //PC to TI-86 |
| 472 | 472 | temp_data_to_convert[1] = 0x15; //data |
| 473 | 473 | temp_data_to_convert[2] = (ti85_entries[i].data_size)&0x00ff; |
| r6323 | r6324 | |
| 491 | 491 | free (ti85_entries); |
| 492 | 492 | return 0; |
| 493 | 493 | } |
| 494 | | if (!strncmp(calc_type, "ti85", 4)) |
| 494 | if (device->type == TI85SERIAL) |
| 495 | 495 | ti85_convert_data_to_stream(ti85_pc_end_packet, TI85_PC_END_PACKET_SIZE, serial_data->end); |
| 496 | | if (!strncmp(calc_type, "ti86", 4)) |
| 496 | if (device->type == TI86SERIAL) |
| 497 | 497 | ti85_convert_data_to_stream(ti86_pc_end_packet, TI85_PC_END_PACKET_SIZE, serial_data->end); |
| 498 | 498 | serial_data->end_size = TI85_PC_END_PACKET_SIZE*8; |
| 499 | 499 | |
| r6323 | r6324 | |
| 1278 | 1278 | ti85serial->receive_data_counter = 0; |
| 1279 | 1279 | ti85serial->send_data_counter = 0; |
| 1280 | 1280 | ti85_free_serial_data_memory(device); |
| 1281 | | // ti85_PCR = 0xc0; |
| 1282 | 1281 | ti85serial->red_in = 0; |
| 1283 | 1282 | ti85serial->white_in = 0; |
| 1284 | 1283 | ti85serial->red_out = 1; |
| r6323 | r6324 | |
| 1310 | 1309 | file_data = auto_alloc_array(image->machine, UINT8, file_size); |
| 1311 | 1310 | image_fread(image, file_data, file_size); |
| 1312 | 1311 | |
| 1313 | | if(!ti85_convert_file_data_to_serial_stream(image, file_data, file_size, &ti85serial->stream, (char*)image->machine->gamedrv->name)) |
| 1312 | if(!ti85_convert_file_data_to_serial_stream(image, file_data, file_size, &ti85serial->stream)) |
| 1314 | 1313 | { |
| 1315 | 1314 | ti85_free_serial_stream (&ti85serial->stream); |
| 1316 | 1315 | return INIT_FAIL; |