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

Firmware does not set drive number when booting #5

Closed
rb6502 opened this issue Aug 21, 2021 · 7 comments
Closed

Firmware does not set drive number when booting #5

rb6502 opened this issue Aug 21, 2021 · 7 comments

Comments

@rb6502
Copy link

rb6502 commented Aug 21, 2021

Hi Florian,

I've been working on supporting AppleIISd as an optional expansion card in the MAME emulator, and I've noticed that the boot firmware does not initialize zero page location $43 (what you call DSNUMBER). The fill pattern we use in MAME to avoid issues with some buggy A2 games has $FF there, for instance, so GETBLOCK thinks we're looking for drive 2 and adds $10000 to the block number. This probably causes weird problems on real hardware as well, since not all Apple IIs have clear RAM on a cold start, and $43 could contain anything on a Ctrl-Open Apple-Reset restart.

Cheers,
-RB

@freitz85
Copy link
Owner

Thank you, RB for this comment!
I remember being unsure if I should do anything with those ZP locations when I started this project. Do I need to clear all ZP locations used by my firmware or just $43? I originally thought it was only written to by ProDOS.

Some time ago, I too had the idea to "include" my card in an emulator, but I never came around to do so. This could make debugging some outstanding Smartport issues much easier. Maybe your fix and two others I found while working on my 6502 branch will get us a little further.

Regards, Florian

@rb6502
Copy link
Author

rb6502 commented Aug 22, 2021

ProDOS itself does initialize all of the ZP locations necessary, but when booting from the AppleIISd your slot firmware doesn't set all of the locations. It's this code:

; load disk blocks 0 and 1 to $800 and $A00
@BOOT:      LDA   #$08        ; load to $800
            STA   BUFFER+1    ; buffer hi
            STZ   BUFFER      ; buffer lo
            STZ   BLOCKNUM+1  ; block hi
            STZ   BLOCKNUM    ; block lo
            JSR   READ

There needs to be an STZ DSNUMBER too. My SDCard emulation needs more work before I can commit the support to MAME, but it already boots and runs Total Replay and various ProDOS 8-based images fine. I suspect this may be what's causing issue #3.

@freitz85
Copy link
Owner

I have made changes to the code in 99eebeb. Please see if it works now.
Anyway, DSNUMBER being not initialized on boot is a nice bug and it is interesting to see that it worked in the first place ;-)

@rb6502
Copy link
Author

rb6502 commented Aug 24, 2021

I just tried it and it didn't work. Looking at the disassembly, the setting of DSNUMBER is missing in the AppleIISd.bin firmware image. Could you double-check what's going on?

Edit: Error was on my end, loading the correct binary now and it works. You might suggest the people with issue #3 try out the new version too then.

@freitz85
Copy link
Owner

I have just pushed another fix when I realized that BIT may not work in some situations.
Are you sure you are using the correct build_image.* from the Firmware folder to build the AppleIISd.bin file? If you used the one from the Software folder, this only builds the Flasher program.

I probably will change the whole build process to a CMake based one, with ROM code and flasher as subprojects. "Install" could then create the image for the flasher.

@rb6502
Copy link
Author

rb6502 commented Aug 24, 2021

Yeah, it was my error. I forgot that our AT28C64B class actually saves the contents and uses those in preference to the original ROM image so that you can run the flasher and have it take effect. With the latest firmware image it works fine in the emulation and properly sets DSNUMBER.

@freitz85
Copy link
Owner

Glad to hear that! I will close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants