About Laser Squad
@WildW &
@dragon Now we need a program do these with sector routine from duke (save/load is another history to look).
Finally re-visited this game.
Version attached that works on M4 (only) and supports 64KB computers.
run"ls"
@dragon I took a simpler approach, when single stepping with WinApe (so nice to hack these days, thanks to this wonderful debugger!).
sub_routine &57FE = load or save tracks.
D = Last track
E = First track
HL = destination address
Memory address (&57FD) = read or write.
It will read sectors c1 to c8 of each track.
I replaced &57FE with M4 sector reading & writing (requires M4 v1.1.0 beta 11).
And added a little startup function to retrieve the rom number of M4 and init M4 rom to setup its workspace.
Here is the patch, maybe useful for another time. I didn't clean it up (could be optimized):
; init
org &260
ld a,1
call &bc0e ; set mode 1
ld hl,(&BC78)
inc hl
inc hl
ld a,(hl)
ld (rom_no+1),a
ld c,a
ld hl,&260 ; himem
ld de,&40 ; lomem
call &bcce ; init m4 rom (just needs 272 bytes without amsdos)
jp &363 ; jump to game init
; track read/write replacement
org &57FE
ld bc,&7F85 ; upper rom sel + mode 1
out (c),c
ld bc,&DF00
rom_no:
ld a,&6 ; set on startup
out (c),a ; select rom
ld c,&c1 ; start sector
read_loop:
push de
push bc
ld d,e ; track
ld e,0 ; drive
push hl
ld a,(&BC78)
push af
ld a,&a4
ld (&BC78),a ; force m4 "current" device detection
ld a,(&57FD) ; read or write ?
or a
jr nz,write_sec
call &c03c ; bios sector read
jr over
write_sec:
call &c03f ; bios sector write
over:
pop af
ld (&BC78),a ; restore real value
pop hl
ld bc,&200 ; size
add hl,bc ; increase addr
pop bc ; c = sector
pop de
ld a,e ; current track
cp d ; last track?
jr nz, not_last
inc c ; increase sector?
ld a,&c9
cp c ; last sector ?
jr nz,read_loop
jr done
not_last:
inc c ; increase sector
ld a,&c9
cp c ; C9 = last sector of track ?
jr nz, read_loop
inc e ; increase current track
ld c,&c1 ; re-start sector
jr read_loop
done:
ld bc,&7F8D ; deselect m4 rom, mode 1
out (c),c
ret
I haven't tested all levels or saving, I am not really much into games (and have no idea what this is about)
A nice improvement would be to do my patch ONLY if run from M4 and leave the FDC code, but since I patched it up already.....