Firmware: fix loading of partial-size BS dumps

This commit is contained in:
Maximilian Rehkopf 2013-10-18 15:32:42 +02:00
parent c380ce9503
commit c8b24a9618
3 changed files with 11 additions and 1 deletions

View File

@ -210,7 +210,7 @@ uint32_t load_rom(uint8_t* filename, uint32_t base_addr, uint8_t flags) {
printf("reconfigure FPGA with %s...\n", romprops.fpga_conf);
fpga_pgm((uint8_t*)romprops.fpga_conf);
}
set_mcu_addr(base_addr);
set_mcu_addr(base_addr + romprops.load_address);
file_open(filename, FA_READ);
ff_sd_offload=1;
sd_offload_tgt=0;

View File

@ -59,6 +59,7 @@ void smc_id(snes_romprops_t* props) {
uint8_t score, maxscore=1, score_idx=2; /* assume LoROM */
snes_header_t* header = &(props->header);
props->load_address = 0;
props->has_dspx = 0;
props->has_st0010 = 0;
props->has_cx4 = 0;
@ -95,6 +96,14 @@ void smc_id(snes_romprops_t* props) {
props->expramsize_bytes = 0;
props->mapper_id = 3; /* BS-X Memory Map */
props->region = 0; /* BS-X only existed in Japan */
uint8_t alloc = header->name[0x10];
if(alloc) {
while(!(alloc & 0x01)) {
props->load_address += 0x20000;
alloc >>= 1;
}
}
printf("load address: %lx\n", props->load_address);
return;
}
}

View File

@ -84,6 +84,7 @@ typedef struct _snes_romprops {
uint8_t has_cx4; /* CX4 presence flag */
uint8_t fpga_features; /* feature/peripheral enable bits*/
uint8_t region; /* game region (derived from destination code) */
uint32_t load_address; /* where to load the ROM image */
snes_header_t header; /* original header from ROM image */
} snes_romprops_t;