Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simon The Sorcerer: Strange HDF size #674

Closed
dirkwhoffmann opened this issue Mar 31, 2022 · 7 comments
Closed

Simon The Sorcerer: Strange HDF size #674

dirkwhoffmann opened this issue Mar 31, 2022 · 7 comments
Labels
Bug Something isn't working v2.0

Comments

@dirkwhoffmann
Copy link
Owner

I've been trying to attach Simon The Sorceror (1994)(Adventure Soft).hdf (PlanetEmu, HDF section) in vAmiga without success.

The HDF is a DOS0 disk (OFS), has no RDB, and the file size is 12000000.

Observations:

  • 12000000 is not dividable by 512.
  • UAE assigns a disk geometry of 732 / 1 / 32, but 732 * 32 * 512 is less than 12000000.

Conclusion:

  • There is some real magic going on here.
@dirkwhoffmann
Copy link
Owner Author

More findings: After hard-coding the drive geometry, I can load the game. So the quest is to find some magic function that maps 12000000 to (732,1,32).

Unfortunately, the game itself doesn't look as expected 😕:

Bildschirmfoto 2022-03-31 um 17 32 52

Maybe it's the AGA version? I tried to double-check in UAE, but I am not smart enough to mount an HDF there. The hard drive does not appear on the workbench screen. There are tons of controllers to select from and another myriad of checkboxes to enable or disable. I could try all combinations, but that would take another myriad of years.

@emoon
Copy link
Sponsor

emoon commented Mar 31, 2022

You can likely check if it's the AGA version if it tries to enable 8 bitplanes or so.

@dirkwhoffmann
Copy link
Owner Author

Taking a step back: My old geometry code works as follows:

  • numBlocks := HDF file size / 512
  • Find some c,h,s satisfying c x h x s = numBlocks

Simon teaches us to not derive the number of blocks from the file size.

Proposal for a new approach. We know that the location of the root block is calculated by

highKey = c * h * s - 1
rootKey = INT (numReserved + highKey) / 2

Hence, we could

  • Search for the root block inside the HDF.
  • Use the location to compute highKey.
  • Map highKey to some suitable c, h, s.

@mras0
Copy link

mras0 commented Mar 31, 2022

For raw HDFs, I just follow UAEs lead (as far as I understand the program logic for "small" disks) and hardcode H=1, S=32 and derive C as filesize / (H * S * sector_size_bytes /*512*/) thus also ending with C=732. (Had to disable check that filesize % sector_size_bytes == 0 for this one). You could probably do that, and check if you get a root block that way, and only if that doesn't work fall back to more complicated logic?

As for the corrupted display, I don't think that's related to the HDF. It works fine in my (as you know bad, OCS only) emulator as well as WinUAE (standard A500 ECS config). How did you start the game? Since HDF isn't bootable I used WB1.3 floppy and started it manually from WB.

EDIT: As for testing in WinUAE: Select a profile from Quickstart (e.g. A500 + "Most compatible"), Hardware->CD & Hard drives->Add hardfile... (Press ... next to "Path" and find the file), Floppy -> Insert WB1.3 disk. Start.

If HD doesn't show up maybe you have it open in another application (vAmiga?), it won't mount if it can't get R/W access

@dirkwhoffmann
Copy link
Owner Author

As for testing in WinUAE

Got it to work now. I had to use the uaehf device. It was set to IDE before which didn't work.

Bildschirmfoto 2022-04-01 um 09 23 56

@dirkwhoffmann
Copy link
Owner Author

You could probably do that, and check if you get a root block that way, and only if that doesn't work fall back to more complicated logic?

Yes, my new code does it this way. It first seeks the root block. After that, it tries to predict the number of blocks via different heuristics and verifies the outcome by comparing the predicted location of the root block with the actual location.

   auto match = [&]() {
        return (numReserved + highKey) / 2 == rootKey;
    };

   if (auto root = seekRB(); root) {
        
        rootKey = isize(root - data.ptr) / bsize();
        
        // Predict block count by analyzing the file size
        highKey = data.size / bsize() - 1;
        if (match()) return highKey + 1;
        
        // Predict block count by assuming a 32 sector standard geometry
        highKey = 32 * (data.size / (32 * bsize())) - 1;
        if (match()) return highKey + 1;

        // Predict by faking the numbers to fit
        highKey = 2 * rootKey - numReserved;
        if (match()) return highKey + 1;

        fatalError;
    }

Regarding the graphics issue, I've found out that it does work with Kickstart 1.3 in vAmiga, but doesn't with Kickstart 2.04. I'll open up another issue for that...

Bildschirmfoto 2022-04-01 um 09 05 23

@dirkwhoffmann dirkwhoffmann added Bug Something isn't working v2.0 labels Apr 1, 2022
@dirkwhoffmann
Copy link
Owner Author

Fixed in v2.0b2 which is now online.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working v2.0
Projects
None yet
Development

No branches or pull requests

3 participants