comparison blastem.c @ 975:c6b19939da7b

Fixed loading of SMD format ROMs
author Michael Pavone <pavone@retrodev.com>
date Sat, 23 Apr 2016 01:08:43 -0700
parents e28f365605da
children 34b811ea1e7c
comparison
equal deleted inserted replaced
974:fd7702bcc034 975:c6b19939da7b
70 { 70 {
71 uint8_t block[SMD_BLOCK_SIZE]; 71 uint8_t block[SMD_BLOCK_SIZE];
72 filesize -= SMD_HEADER_SIZE; 72 filesize -= SMD_HEADER_SIZE;
73 fseek(f, SMD_HEADER_SIZE, SEEK_SET); 73 fseek(f, SMD_HEADER_SIZE, SEEK_SET);
74 74
75 uint16_t * dst = cart; 75 uint16_t * dst = cart = malloc(nearest_pow2(filesize));
76 int rom_size = filesize; 76 int rom_size = filesize;
77 while (filesize > 0) { 77 while (filesize > 0) {
78 fread(block, 1, SMD_BLOCK_SIZE, f); 78 fread(block, 1, SMD_BLOCK_SIZE, f);
79 for (uint8_t *low = block, *high = (block+SMD_BLOCK_SIZE/2), *end = block+SMD_BLOCK_SIZE; high < end; high++, low++) { 79 for (uint8_t *low = block, *high = (block+SMD_BLOCK_SIZE/2), *end = block+SMD_BLOCK_SIZE; high < end; high++, low++) {
80 *(dst++) = *low << 8 | *high; 80 *(dst++) = *low << 8 | *high;
81 } 81 }
82 filesize -= SMD_BLOCK_SIZE; 82 filesize -= SMD_BLOCK_SIZE;
83 } 83 }
84 return filesize; 84 return rom_size;
85 } 85 }
86 86
87 void byteswap_rom(int filesize) 87 void byteswap_rom(int filesize)
88 { 88 {
89 for(unsigned short * cur = cart; cur - cart < filesize/2; ++cur) 89 for(unsigned short * cur = cart; cur - cart < filesize/2; ++cur)