X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=mx%2Flinux%2Fmx_flasher.c;h=9cb5e3c5c49d49aae8dcd9c20f6dce3f75d9ae6f;hb=318e20ff882dfeb2a8176e89f2343f1c3d60bc1d;hp=e831d3c4abf7cb2036d0354b6908f7f181740d56;hpb=fa45c6d9d1be59d152ce7775297436fba6d15de4;p=megadrive.git diff --git a/mx/linux/mx_flasher.c b/mx/linux/mx_flasher.c index e831d3c..9cb5e3c 100644 --- a/mx/linux/mx_flasher.c +++ b/mx/linux/mx_flasher.c @@ -45,7 +45,7 @@ static const struct { { 0x03eb, 0x202d, "32MX+UF Game Device" }, }; -#define VERSION "0.9" +#define VERSION "0.91" #define IO_BLK_SIZE 0x2000 /* 8K */ #define IO_RAM_BLK_SIZE 256 @@ -490,7 +490,7 @@ static int read_write_rom(struct usb_dev_handle *dev, u32 addr, void *buffer, in print_progress(total_bytes, total_bytes); } - if (count & 1) + if ((count & 1) && !is_write) /* work around rw_dev_block() limitation 3 (works for reads only?) */ rw_dev_block(dev, 0, dummy, sizeof(dummy), 0); @@ -1013,6 +1013,19 @@ breakloop: if (ret < 0) return 1; + /* align size to 64 */ + ret = (w_fsize + 63) & ~63; + if (w_fsize != ret) { + printf("ROM image size is %d, padding to %d\n", w_fsize, ret); + w_fdata = realloc(w_fdata, ret); + if (w_fdata == NULL) { + fprintf(stderr, "low mem\n"); + return 1; + } + memset((char *)w_fdata + w_fsize, 0, ret - w_fsize); + w_fsize = ret; + } + if (do_erase_size < w_fsize) do_erase_size = w_fsize; }