; ; trackdisk.device CMD_READ patch to spoof regular bootblock for ; A1000 kickstart floppies. ; ; Copyright © 2007 Harry Sintonen ; ; This source code is provided for reference purposes. If you wish to ; reuse parts of it, please contact the author for permission. ; include "exec/io.i" include "devices/trackdisk.i" ; ; This routine is copied inside the KS ROM and trackdisk.device ; CMD_READ routine is hooked to jump into this code instead. ; I didn't want to erase any existing code in the ROM, and choose ; a location that only contains unused strings (the KS ROM beginning). ; As a result the code must be as short as possible, which again ; makes the code somewhat obfuscated. Don't worry if this code ; doesn't look obvious to you. ; cmd_read move.l a1,-(sp) jsr $fc0000 ; call original CMD_READ routine move.l (sp)+,a1 lea IO_ERROR(a1),a1 tst.b (a1)+ ; did error occur? bne.b .exit ; yep, don't bother with it move.l (a1),d0 ; get IO_ACTUAL moveq #-49-1,d1 addq.l #IO_DATA-IO_ACTUAL,a1 add.l d0,d1 ; actual-49-1 = loop count for 0-fill below move.l (a1)+,a0 ; get IO_DATA pointer for KICK compare below add.l (a1),d0 ; IO_OFFSET (offset + actual) cmp.l #1024,d0 ; did the operation involve first 2 blocks? bhi.b .exit ; nope, don't bother with it ; There's a small bug here: ; Reading at offset 512 length 512 ; doesn't return 0-bytes for KICK ; disk. Unfortunately there's no ; room for a fix... cmp.l #'KICK',(a0) ; KICK disk? bne.b .exit ; nope, don't bother with it ; fill in ks 1.x bootblock lea boot(pc),a1 moveq #49-1,d0 .copy move.b (a1)+,(a0)+ dbf d0,.copy .clr clr.b (a0)+ dbf d1,.clr .exit rts ; the industry standard KS 1.x bootblock boot dc.l 'DOS'<<8 dc.l $C0200F19 ; chksum dc.l 880 ; root dc.l $43FA0018 dc.l $4EAEFFA0 dc.l $4A80670A dc.l $20402068 dc.l $00167000 dc.l $4E7570FF dc.l $60FA646F dc.l $732E6C69 dc.l $62726172 dc.b $79