From b1bd0465941326c1f57e0f0ec513d67939877d14 Mon Sep 17 00:00:00 2001 From: chrisly42 Date: Wed, 9 Oct 2024 00:38:45 +0200 Subject: [PATCH] Framework fixes: - Initial memory allocation was using MEMF_LARGEST and did some unnecessary error checking and alignment. - Trackloader skipped over the MFM gap between the end of the track and the start as optimization. However, it turns out that the gap can be smaller when written with non-Amiga controllers or faster rotation speeds. Reduced the skip from 300 words to 200 words, so it will work in these cases. - There was a stupid bug in the trackloader that made the buffer-end detection non-functional. --- source/framework/framework_trackloader.asm | 19 ++++++++++++++----- source/framework/trackmo_startupcode.asm | 7 +------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/source/framework/framework_trackloader.asm b/source/framework/framework_trackloader.asm index f121542..4e9584a 100644 --- a/source/framework/framework_trackloader.asm +++ b/source/framework/framework_trackloader.asm @@ -819,13 +819,13 @@ fw_DecodeMfmTrack: clr.l fw_TrackChecksum(a6) .decode .findsyncword - lea MFMBUFSIZE(a1),a2 + lea MFMBUFSIZE(a1),a3 .syncloop PUTMSG 70,<"LW %lx">,(a1) cmp.w #MFMsync,(a1)+ ; search for a sync word bne.s .syncloop PUTMSG 60,<"Sync %lx at %p">,(a1),a1 - cmp.l a1,a2 ; check for end of buffer + cmp.l a1,a3 ; check for end of buffer beq .diskerror ; no more sync found cmp.b (a1),d3 ; search for 0-nibble bne.s .syncloop @@ -869,11 +869,20 @@ fw_DecodeMfmTrack: cmp.b #1,d4 bne.s .nogapskip PUTMSG 60,<"Skipping much of gap after decoding"> - lea 300*2(a2),a2 ; gap of 300 words should be safe (340 is about normal) + ; a gap of 300 words should be safe (340 is about normal), + ; HOWEVER some drives (Greaseweazle?) may write with 2µs pulse length + ; instead of the Amiga's 1.97356µs or faster rotational speeds, + ; so the gap may become smaller! + ; This broke some configurations apparently. Sorry. + lea 200*2(a2),a2 ; skip 200 words .nogapskip - lea 6(a2),a1 cmp.w #(1<<11)-1,d7 - bne .findsyncword ; decode until the bitmap is complete + beq .allsecsfound ; decode until the bitmap is complete + lea 6(a2),a1 + cmp.l a1,a3 ; check for past end of buffer + bhi .findsyncword ; continue seeking sync word + bra .diskerror ; ooops, we're past the end of the buffer +.allsecsfound PUTMSG 50,<"Track Checksum %lx">,fw_TrackChecksum(a6) tst.l fw_TrackChecksum(a6) ; track total chksum OK? bne .diskerror ; no, then retry diff --git a/source/framework/trackmo_startupcode.asm b/source/framework/trackmo_startupcode.asm index 121b6a7..0057963 100644 --- a/source/framework/trackmo_startupcode.asm +++ b/source/framework/trackmo_startupcode.asm @@ -40,7 +40,7 @@ trackmo_AppInit: CALL AvailMem move.l d0,d2 beq.s .nofast - move.l #(MEMF_LARGEST|MEMF_FAST|MEMF_CLEAR),d1 + move.l #MEMF_FAST|MEMF_CLEAR,d1 CALL AllocMem move.l d0,fw_FastMemStack(a4) bne.s .goodmem @@ -51,20 +51,15 @@ trackmo_AppInit: move.l #(MEMF_LARGEST|MEMF_CHIP),d1 CALL AvailMem move.l d0,d2 - beq.s .memerr move.l #(MEMF_CHIP|MEMF_CLEAR),d1 CALL AllocMem - addq.l #7,d0 - and.w #-8,d0 move.l d0,fw_ChipMemStack(a4) - and.w #-8,d2 add.l d2,d0 move.l d0,fw_ChipMemStackEnd(a4) move.l #(MEMF_LARGEST|MEMF_ANY),d1 CALL AvailMem move.l d0,d2 - beq.s .memerr move.l #MEMF_CLEAR,d1 CALL AllocMem move.l d0,fw_FastMemStack(a4)