diff --git a/src/system/boot/platform/atari_m68k/fixup_tos_floppy_chksum.c b/src/system/boot/platform/atari_m68k/fixup_tos_floppy_chksum.c index 8e410e6e22..ca44b403e1 100644 --- a/src/system/boot/platform/atari_m68k/fixup_tos_floppy_chksum.c +++ b/src/system/boot/platform/atari_m68k/fixup_tos_floppy_chksum.c @@ -1,27 +1,29 @@ #include -#include -#include +#include +#include - -uint8 sector[512]; +uint8_t sector[512]; int main(int argc, char **argv) { int fd, i; - uint16 sum; - uint16 *p = (uint16 *)sector; + uint16_t sum; + uint8_t *p = sector; fd = open(argv[1], O_RDWR); if (fd < 0) { return 1; } - if (read(fd, sector, 512-2) < 512) { + if (read(fd, sector, 512-2) < 512-2) { perror("read"); return 1; } - for (sum = 0, i = 0; i < (512-2)/2; i++) { - sum += B_LENDIAN_TO_HOST_INT16(p[i]); + for (sum = 0, i = 0; i < (512-2); i++) { + sum += p[i]; } - p[(512-2)/2] = B_HOST_TO_BENDIAN_INT16(0x1234 - sum); + sum = 0x1234 - sum; + // big endian + p[512-2] = (uint8_t)(sum >> 8); + p[512-1] = (uint8_t)sum; //lseek(fd, 0LL, SEEK_SET); write(fd, §or[512-2], 2); return 0; diff --git a/src/system/boot/platform/atari_m68k/shell.S b/src/system/boot/platform/atari_m68k/shell.S index 2ae1fea74b..ab3ea363e1 100644 --- a/src/system/boot/platform/atari_m68k/shell.S +++ b/src/system/boot/platform/atari_m68k/shell.S @@ -75,7 +75,7 @@ floppy_start: jsr puts bra spin flopy_done: - jmp #ATARI_ZBEOS_BASE+512 + bra #ATARI_ZBEOS_BASE+512 /** Loads %d2 sectors from floppy disk, starting at head XXX %dh, sector %cx. * The data is loaded to %a2.