Getting files back from sector

By Meits

Scribe (5387)

Meits's picture

06-03-2019, 12:07

In case of TL;DR, go below the line Wink

Back in the day we did a few music disks which were totally sector based. When everything worked we wiped the complete fat so nothing remained on disk. Well for the eye that is.
A while ago LarsThe18th helped me out getting my music data back from Jarretenk and Near Dark 2.5. Maybe Near Dark (1) as well, but I'm not sure cuz I can't find any of it.

Now I could ask him again to just do my dirty work, but I did try some myself. The music data turned out to be easy to fetch. I put a DSK file of Near Dark in a hex editor and searched for the title which I wrote in Moonblaster. From there to the obvious end of the file I made a selection which I saved as MBM file. Sure there was some poop at the end, but that doesn't hurt the file when loading it in Moonblaster. Saving it again in Moonblaster takes care of the extra junk.
Since Moonblaster turns out not to have a solid file header, it's impossible to search on just that. So to find the exact start of the file I loaded an MBM file as well to see how much in front of the song title still belonged to the file.

So big hurray on the song data. Now the sample kits. After loading a few MBK files into the hex editor and found out those files don't share a common header either. And since there's no obvious song title embedded in the file there's nothing to search for. So that's a no go (with the knowledge I have now).
Just resetting the ccomputer and boot Moonblaster after the song has played in the music disk is a no go either, cuz well, ADPCM hates us all. Moonblaster has variabel start/end addresses for the samples (where FAC soundtracker didn't) and setting them by ear is flat out impossible. Changing the start address of a known good sample already destroys it.
The third option I had was unusable as well. This is a little tool I once got from MTC (90s Dutch MSX celeb). This tool can restore the sample addresses after resetting the computer during playback, but only for Fuzzy Logic's (hi ro Running Naked in a Field of Flowers ) f-kernel stuff (MB Muzax, Most Umax games). Why it does work for that system and not for any other is a mystery to me. MTC probably told me (23 years ago), but then again, maybe not Wink

----------------------------

How to get my Moonblaster samplekits back from sector on NEARDARK.DSK?

Login or register to post comments

By Pencioner

Paladin (895)

Pencioner's picture

06-03-2019, 15:42

Maybe, use emulator? You might have options to break on disk operations for example, or maybe (not sure if there's support in openMSX from the box, but i think you can get help from someone experienced in TCL) to catch all the I/O with OPL4 and extract that data btw

By wouter_

Champion (409)

wouter_'s picture

06-03-2019, 18:50

I created this script for openMSX. It only works on Philips machines with the FDC in slot 3-3 (e.g. a Philips_NMS_8255) and with normally formatted double sided disks.

debug set_watchpoint write_mem 0x7ff8 {[pc_in_slot 3 3]} fdc_cmd

proc fdc_cmd {} {
	# check for read-sector command
	if {($::wp_last_value & 0x80) != 0x80} return

	# read CHS
	set cylinder [debug read "slotted memory" 0xf7ff9]
	set head     [debug read "slotted memory" 0xf7ffc]
	set sector   [debug read "slotted memory" 0xf7ffa]
	#puts stderr "C=$cylinder H=$head S=$sector"

	# convert CHS to logical sector number
	set sector [expr {18 * $cylinder + 9 * $head + $sector - 1}]
	puts stderr "Read sector $sector"
}

Save this to a file (e.g. sector.tcl) and then start openMSX from a terminal like this
openmsx -machine Philips_NMS_8255 mydisk.dsk sector.tcl
Now each time the MSX reads a sector from disk, the sector number will be printed in the terminal.

By zeilemaker54

Master (243)

zeilemaker54's picture

06-03-2019, 20:05

Nice script

But why this hardware depended script ? I guess it would be easier to set a breakpoint on 04010h (DSKIO) on the slot of the fdc. Then you need only to read the z80 registers.

wouter_ wrote:

I created this script for openMSX. It only works on Philips machines with the FDC in slot 3-3 (e.g. a Philips_NMS_8255) and with normally formatted double sided disks.

debug set_watchpoint write_mem 0x7ff8 {[pc_in_slot 3 3]} fdc_cmd

proc fdc_cmd {} {
	# check for read-sector command
	if {($::wp_last_value & 0x80) != 0x80} return

	# read CHS
	set cylinder [debug read "slotted memory" 0xf7ff9]
	set head     [debug read "slotted memory" 0xf7ffc]
	set sector   [debug read "slotted memory" 0xf7ffa]
	#puts stderr "C=$cylinder H=$head S=$sector"

	# convert CHS to logical sector number
	set sector [expr {18 * $cylinder + 9 * $head + $sector - 1}]
	puts stderr "Read sector $sector"
}

Save this to a file (e.g. sector.tcl) and then start openMSX from a terminal like this
openmsx -machine Philips_NMS_8255 mydisk.dsk sector.tcl
Now each time the MSX reads a sector from disk, the sector number will be printed in the terminal.

By wouter_

Champion (409)

wouter_'s picture

06-03-2019, 20:18

zeilemaker54 wrote:

But why this hardware depended script ? I guess it would be easier to set a breakpoint on 04010h (DSKIO) on the slot of the fdc. Then you need only to read the z80 registers.

Right, that'll work too, and is indeed simpler.

By NYYRIKKI

Enlighted (5271)

NYYRIKKI's picture

07-03-2019, 00:23

Meits wrote:

Back in the day we did a few music disks which were totally sector based. When everything worked we wiped the complete fat so nothing remained on disk.

... and you failed miserably. :-9 I guess your aim was a bit off as your FAT seems completely healthy... you even have a backup copy of it on the disk, so no worries, your data is safe. Smile I would bet that the files your are looking for are those 32KB files staring from sectors 94, 160, 226, 292 and 358.

By NYYRIKKI

Enlighted (5271)

NYYRIKKI's picture

07-03-2019, 01:18

BTW most easy way to recover those files is to start MSX-DOS and run CHKDSK /F to the disk.

By Meits

Scribe (5387)

Meits's picture

07-03-2019, 01:56

Always great to fail. I can just use the excuse that I was told to write zeroes and be victorious Big smile

I'll see what I can do with the options mentioned above... Thanks guys Smile

By NYYRIKKI

Enlighted (5271)

NYYRIKKI's picture

07-03-2019, 08:36

Meits wrote:

Always great to fail. I can just use the excuse that I was told to write zeroes and be victorious Big smile

Well... you managed to destroy the directory, so the file names, dates and exact sizes (last 10bits) are gone for good.

If you ever want to do this kind of "hybrid disk" (disk that has sector loader, but also some files) again, let me give you few hints... These FAT disks are designed relatively fail safe. By default they contain FAT two times in case on of them fail. The number of copies etc. information is recorded to the boot sector (sector 0) In this case the FAT#1 was on sector 1 and FAT#2 was on sector 5. These were followed by the directory that you successfully erased.

Best way to construct such a disk is to first copy the files that you want to hide for good, then mark all used (not zero) clusters except the first two ones (root directory) as "Bad clusters" (-9), copy this FAT over possible backup copies and fill the root directory sectors with 0 as you did earlier. This will make the disk look totally fine empty disk and make sure that any OS will not touch your now hidden data again. Only thing that gives away that there is something fishy going on is that there is now less free capacity than normally on a empty disk... After this you can copy the files that you want to be visible and give the disk forward.

By Meits

Scribe (5387)

Meits's picture

07-03-2019, 13:50

This is a knowledge our former 90s coder mastered. I never went that far and I bet I'll never have the ambition to dive that deep. In modern days I rather have instant access from prompt in stead of disk images and flashing and what not Smile

By Meits

Scribe (5387)

Meits's picture

13-03-2019, 19:42

Now I've had one week to type chkdsk /f and HA! If only I knew. This is too silly Big smile