Cart start-up: cold boot "DK" carts; wire up "Cart Interrupt Disabled"
A cart loaded after boot in Multi-Pak slot 3 made CART toggle every CPU cycle forever -- the autostart of a program pak, whose CART pin is tied to Q. A disk-style ROM (HDB-DOS, Disk BASIC) never drives CART; BASIC starts it from the "DK" signature at power-on. Under the toggling, FujiNet's CFGLOAD.BIN (which re-enables the CART interrupt) hung in an endless FIRQ after 17 DriveWire reads; an OSD reset cleared it. - A cart whose first two bytes are "DK" now gets a cold boot (the existing AMW/EE_Cold_Bt path) instead of the autostart interrupt. - OSD "Cart Interrupt Disabled" (status[16] -> SWITCH[4]) was not connected; it now suppresses the slot-3 autostart interrupt. - Program paks are unchanged: Arkanoid loaded after boot still autostarts. Verified in the Verilator sim with the hardware sequence (cart loaded after boot, slot 3, no reset): the FujiNet S3 cart now reads all 98 sectors of CONFIG, matching the MiSTer after a manual reset. Regression tests unchanged. The sim gains --cart-frame N to load the cart after boot, as the OSD and MGL do; loading it before reset had hidden the problem. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
1 parent
874f4f3083
commit
72a50a16bb
4 files changed
+52
-7
No files matched your search
+25
-3
@@ -1206,10 +1206,13 @@ wire AMW_End;
|
||||
|
||||
assign AMW_ACK = AMW_End;
|
||||
|
||||
// Cart start-up state; see the cart_firq_enable block below.
|
||||
reg cart_dk_0, cart_is_dk, cart_coldboot;
|
||||
|
||||
AMW coco_AMW (
|
||||
.CLK(clk_sys),
|
||||
.RESET_N(RESET_N),
|
||||
.Trigger(AMW_Trigger),
|
||||
.Trigger(AMW_Trigger | cart_coldboot), // OSD cold boot, MPI/memory change, or a "DK" cart load
|
||||
.Restart(1'b0),
|
||||
.Cycle_Run(AMW_WR),
|
||||
.AMW_Adrs(AMW_Adrs),
|
||||
@@ -1786,6 +1789,13 @@ reg cart_firq_enable;
|
||||
reg firq_trig;
|
||||
reg cart_lock;
|
||||
|
||||
// A cart loaded after boot is started one of two ways, as on a real CoCo:
|
||||
// - a program pak ties CART to Q, so it gets the autostart FIRQ below
|
||||
// (cart_firq_enable low: CART toggles every cycle while in slot 3);
|
||||
// - a disk-style ROM (HDB-DOS, Disk BASIC: "DK" at $C000) never drives CART,
|
||||
// and BASIC starts it from the signature at power-on. Such a cart gets a
|
||||
// cold boot instead. Toggling CART under it made software that re-enables
|
||||
// the CART interrupt -- FujiNet's CFGLOAD -- hang in an endless FIRQ.
|
||||
always @(negedge clk_sys or negedge RESET_N)
|
||||
begin
|
||||
if(!RESET_N)
|
||||
@@ -1793,17 +1803,29 @@ begin
|
||||
firq_trig <= 1'b0;
|
||||
cart_firq_enable <= 1'b1;
|
||||
cart_lock <= 1'b0;
|
||||
cart_dk_0 <= 1'b0;
|
||||
cart_is_dk <= 1'b0;
|
||||
cart_coldboot <= 1'b0;
|
||||
end
|
||||
else
|
||||
begin
|
||||
if ((ioctl_index[5:0] == 6'd1) & ioctl_download)
|
||||
firq_trig <= 1'b1;
|
||||
|
||||
if ((ioctl_index[5:0] == 6'd1) & ioctl_wr)
|
||||
begin
|
||||
if (ioctl_addr == 25'd0) cart_dk_0 <= (ioctl_data == 8'h44); // 'D'
|
||||
if (ioctl_addr == 25'd1) cart_is_dk <= cart_dk_0 & (ioctl_data == 8'h4B); // 'K'
|
||||
end
|
||||
|
||||
if (firq_trig)
|
||||
if (!ioctl_download)
|
||||
begin
|
||||
cart_firq_enable <= 1'b0;
|
||||
cart_lock <= 1'b1;
|
||||
if (cart_is_dk)
|
||||
cart_coldboot <= 1'b1; // start it the way BASIC would: cold boot
|
||||
else
|
||||
cart_firq_enable <= 1'b0; // program pak: autostart FIRQ
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1828,7 +1850,7 @@ begin
|
||||
2'b01:
|
||||
CART_INT_IN_N <= (SER_IRQ);
|
||||
2'b10:
|
||||
CART_INT_IN_N <= (!CART_INT_IN_N | cart_firq_enable);
|
||||
CART_INT_IN_N <= (!CART_INT_IN_N | cart_firq_enable | SWITCH[4]); // SWITCH[4]: OSD "Cart Interrupt Disabled"
|
||||
2'b11:
|
||||
CART_INT_IN_N <= (SER_IRQ);
|
||||
endcase
|
||||
|
||||
Reference in new issue
Block a user