src/mess/machine/kc.c
| r12439 | r12440 | |
| 57 | 57 | if (datasize!=0) |
| 58 | 58 | { |
| 59 | 59 | /* malloc memory for this data */ |
| 60 | | data = (unsigned char *)malloc(datasize); |
| 60 | data = (unsigned char *)auto_alloc_array(image.device().machine(), unsigned char, datasize); |
| 61 | 61 | |
| 62 | 62 | if (data!=NULL) |
| 63 | 63 | { |
| r12439 | r12440 | |
| 83 | 83 | unsigned char anzahl; |
| 84 | 84 | unsigned char load_address_l; |
| 85 | 85 | unsigned char load_address_h; |
| 86 | | unsigned char length_l; |
| 87 | | unsigned char length_h; |
| 88 | | unsigned short execution_address; |
| 86 | unsigned char end_address_l; |
| 87 | unsigned char end_address_h; |
| 88 | unsigned char execution_address_l; |
| 89 | unsigned char execution_address_h; |
| 89 | 90 | unsigned char pad[128-2-2-2-1-16]; |
| 90 | 91 | }; |
| 91 | 92 | |
| r12439 | r12440 | |
| 100 | 101 | struct kcc_header *header; |
| 101 | 102 | int addr; |
| 102 | 103 | int datasize; |
| 104 | int execution_address; |
| 103 | 105 | int i; |
| 104 | 106 | |
| 105 | 107 | if (!kc_load(image, &data)) |
| 106 | 108 | return IMAGE_INIT_FAIL; |
| 107 | 109 | |
| 108 | 110 | header = (struct kcc_header *) data; |
| 109 | | datasize = (header->length_l & 0x0ff) | ((header->length_h & 0x0ff)<<8); |
| 110 | | datasize = datasize-128; |
| 111 | 111 | addr = (header->load_address_l & 0x0ff) | ((header->load_address_h & 0x0ff)<<8); |
| 112 | datasize = ((header->end_address_l & 0x0ff) | ((header->end_address_h & 0x0ff)<<8)) - addr; |
| 113 | execution_address = (header->execution_address_l & 0x0ff) | ((header->execution_address_h & 0x0ff)<<8); |
| 112 | 114 | |
| 115 | if (datasize + 128 > image.length()) |
| 116 | { |
| 117 | mame_printf_info("Invalid snapshot size: expected 0x%04x, found 0x%04x\n", datasize, (UINT32)image.length() - 128); |
| 118 | datasize = image.length() - 128; |
| 119 | } |
| 120 | |
| 113 | 121 | for (i=0; i<datasize; i++) |
| 114 | 122 | ram_get_ptr(image.device().machine().device(RAM_TAG))[(addr+i) & 0x0ffff] = data[i+128]; |
| 123 | |
| 124 | auto_free(image.device().machine(), data); |
| 125 | |
| 126 | logerror("Snapshot loaded at: 0x%04x-0x%04x, execution address: 0x%04x\n", addr, addr + datasize - 1, execution_address); |
| 127 | |
| 115 | 128 | return IMAGE_INIT_PASS; |
| 116 | 129 | } |
| 117 | 130 | |