GideonZ / 1541ultimate

Official GIT archive of 1541 ultimate II sources
GNU General Public License v3.0
181 stars 46 forks source link

ACIA and C128 crt type 1, subtype 2 (and likely also 1) #283

Open bvl1999 opened 2 years ago

bvl1999 commented 2 years ago

C128DCR with UII+, firmware 3.10c (recent build from git)

C128 crt type 1, subtype 2 should allow for ACIA at DE00.

When having such a crt active, enabling ACIA has the expected result (ACIA becomes visible at DE00) Saving this, and power cycling the machine results in ACIA also being available

However, using the 'reboot 64' option in the f5 menu results in ACIA being inhibited by the crt according to the overview in f4, and it is indeed not visible at de00

When trying to disable and re-enable ACIA, this at times results in it being active and inhibited at the same time, and this often crashes the UII+ application.

While this crt type won't work on a c64 obviously, you can still configure one, and should be able to reproduce the problem that way.

An example crt can be found at https://www.bartsplace.net/download/c128dm_u2-200-alpha-20906.crt

markusC64 commented 2 years ago

software/io/c64/c64_crt.cc is the position where this is inhibited:

`

    case CART_C128_STD_IO:
        cart_type = CART_TYPE_128 | VARIANT_3; // with IO

        if (crt_header[CRTHDR_SUBTYPE] == 1) {
            prohibit = CART_PROHIBIT_ALL_BUT_REU;
            require = CART_UCI;
        } else if (crt_header[CRTHDR_SUBTYPE] == 2) {
            prohibit = CART_PROHIBIT_ALL_BUT_REU;
            require = CART_UCI;
            cart_type = CART_TYPE_128 | VARIANT_7; // with IO and ROM banking
        } else {
            prohibit = CART_PROHIBIT_IO;
        }
        break;

`

Instead of "prohibit = CART_PROHIBIT_ALL_BUT_REU" you may consider "prohibit = CART_SAMPLER" (that is "Map Ultimate Audio $DF20-DFFF") or even no prohibit at all - cannot tell if Ultimate Audio is compatible to that cartridge type. Yes, a huge cartridge ROM does not occupy I/O Area on C128 mode necessarily. So in generall you only have to block it if the cartridge itself does something in the I/O Area. Like additional RAM or bank switching.

bvl1999 commented 2 years ago

software/io/c64/c64_crt.cc is the position where this is inhibited:

` ``` case CART_C128_STD_IO: cart_type = CART_TYPE_128 | VARIANT_3; // with IO if (crt_header[CRTHDR_SUBTYPE] == 1) { prohibit = CART_PROHIBIT_ALL_BUT_REU; require = CART_UCI; } else if (crt_header[CRTHDR_SUBTYPE] == 2) { prohibit = CART_PROHIBIT_ALL_BUT_REU; require = CART_UCI; cart_type = CART_TYPE_128 | VARIANT_7; // with IO and ROM banking } else { prohibit = CART_PROHIBIT_IO; } break; ``` ` Instead of "prohibit = CART_PROHIBIT_ALL_BUT_REU" you may consider "prohibit = CART_SAMPLER" (that is "Map Ultimate Audio $DF20-DFFF") or even no prohibit at all - cannot tell if Ultimate Audio is compatible to that cartridge type. Yes, a huge cartridge ROM does not occupy I/O Area on C128 mode necessarily. So in generall you only have to block it if the cartridge itself does something in the I/O Area. Like additional RAM or bank switching.

It does bankswitching, also has cartridge ram, and has rom mirrored to the de00-df7f range but leaves 'holes' for acia, reu and uci, and has 2 registers for selecting rom and ram banks.

It is not compatible with the audio interface/sampler.

Anyway, making sure ACIA at de00 gets allowed isn't very difficult, inconsistent behavior between power cycle and 'reboot c64', and being able to crash the application suggests the en/disabling acia based on the cartridge isn't working as it should.

bvl1999 commented 2 years ago

So.. reboot c64 was the only one behaving as it should.

A small patch to no longer forbid ACIA_DE for this cartridge type lets it remain enabled after reboot, so that behavior is correct, and also shows being able to en/disable acia without it caring about if it is actually allowed, and at boot it also doesn't seem to care (which makes me suspect set_cartridge runs before acia gets enabled.. but why does it work correctly at reboot c64?)

I think part of the problem is the check on if acia is allowed being done during set_cartridge, which if acia is enabled while it is not allowed will cause it to disable itself. I didn't find such checks on if acia is allowed by the currenct cartridge when changing the acia settings, but I might have missed something there, regardless, it allows it anyway even when it shouldn't.