Closed peteri closed 4 months ago
Thanks @peteri - I will try to take a look in the coming days.
No problem, my only real questions were if adding GetImageSizeInBlocks should be part of the ImageInfo class and if I'd done the right thing with the using the global CmdLine instance. I think this fixes the 1033 issues, but I haven't extensively tested everything (just Pascal 1.3 and one of the game images for slot 5.
I have a concern about the HDD firmware and backwards compatiblity:
Is it back-compat? ie. the 16-bit value at $C7FC (number of blocks in device)
Saving the state when the PC=$C7nn (using AppleWin built with the old firmware) and then loading the state (using AppleWin with the new firmware) could result in undefined behaviour, as the running code may've changed.
HarddiskInterfaceCard::LoadSnapshot()
kUNIT_VERSION
to 4, and the version check in HarddiskInterfaceCard::LoadSnapshot()
to 3, to throw the error "HDD card: 6502 is running old HDD firmware".My preference is to retain the current HDD firmware in AppleWin as a fallback measure (eg. selectable via a command line option).
Can you put your new firmware into a new folder "Firmware/HDDv2".
IDR_HDDRVR_V2_FW FIRMWARE "Hddrvr-v2.bin"
#define IDR_HDDRVR_V2_FW 155
(just add to the end after IDR_BASE64A_VIDEO_ROM)kUNIT_VERSION
to 4 (but leave the version check in HarddiskInterfaceCard::LoadSnapshot()
at 2).A minor thing about the cmd line switch: "-harddisknumblocks"
Can you add a setter function to Harddisk.h, eg. void SetUserNumBlocks(UINT numBlocks)
and a new private member m_userNumBlocks
.
This way, the HarddiskInterfaceCard
class doesn't need to include CmdLine.h, and doesn't need to access g_cmdLine
.
Then you'll need to query every slot if it's of type CT_GenericHDD
to call this setter function - so just extend this loop to do this too:
https://github.com/AppleWin/AppleWin/blob/fcd216bb45e7640bbd3c0c66758bc48e65a38195/source/Windows/AppleWin.cpp#L801
Note the Config UI also allows HDC cards to be inserted.
So in CPropertySheetHelper::SetSlot()
for cards of type CT_GenericHDD
, we should also call this setter function with the cmd line specified value.
Thanks for the comments, I hadn't thought about the save state so I'll get the points you've raised cleaned up.
The block size being zero does mean that code should call the status to get the size and this is the functionality in the original Profile hard disk ROM from Feb 1984 (see page 43 in https://www.bitsavers.org/pdf/apple/disk/profile/appleII_interface/AII_Profile_Boot_Prom_198402.pdf ) so I'd expect most software to make the call.
...so I'd expect most software to make the call.
Set a watchpoint on $C7FC-FD with bpm c7fc,2
91CB:A0 FC LDY #$FC
91CD:B1 E9 LDA (HGR.SH+1),Y
91CF:AA TAX
91D0:C8 INY
91D1:B1 E9 LDA (HGR.SH+1),Y
91D3:A8 TAY
91D4:D0 09 BNE $91DF
91D6:E0 00 CPX #$00
91D8:D0 05 BNE $91DF
91DA:A9 00 LDA #$00 ; STATUS command
91DC:20 F9 A1 JSR $A1F9 ; Post: Y:X = num blocks
91DF:18 CLC
91E0:60 RTS
So yes, this software from 1990 does make the call.
This gives me (some) increased confidence, and lessens my back-compat. concern I raised above. Ideally I'd check with more software, eg. ProDOS, Pascal, CP/M.
I've just had a quick look at the oldest version of ProDOS I can find online (1.0 Nov 83) and it has a similar size check in FILER
so I'm happy (at $4250-$429c).
Just a quick comment to say I've not forgotten about this, just been a bit busy at work. I'm hoping to get the suggestions incorporated over the weekend.
Okay, got a bit of time.... I'm not entirely convinced the change to CPropertySheetHelper::SetSlot is needed as adding or removing the controller causes a restart of AppleWin, is there an edge case I'm not aware of? (Or I missed something in the lifecycle of the controller card)
This PR looks good.
I'm not entirely convinced the change to CPropertySheetHelper::SetSlot is needed as adding or removing the controller causes a restart of AppleWin,
Yes, you're I right - so that code in SetSlot()
can go.
Thanks.
Reverted the change to the PropertySheetHelper....
Thanks for being so patient with my changes.
My notes:
When growing an image (ie. appending a block to the end), then CImageBase::WriteBlock()
updates the ImageInfo
object with the new uImageSize
. So subsequent calls to GetImageSizeInBlocks()
will return the new size (unless m_userNumBlocks
has been set).
GetImageSizeInBlocks()
returns numberOfBlocks
by just dividing by HD_BLOCK_SIZE
(512), when perhaps it should round up (ie. add 511) before dividing. Unlikely to be an issue since the image size should (must?) always be a multiple of 512.
Neither are a concern, but just making a note here.
@peteri - thanks for your PR. It's now merged into the main line.
@peteri - here's a new AppleWin 1.30.18.0 release that includes your PR work.
ProDOS HDD Driver modified to support returning the volume size in the X/Y registers. New command line option to force a size for autoexpanding use. Fixes issue #1264 and #1033 for Pascal 1.3