[Coco] auto-starting game paks

William Astle lost at l-w.ca
Mon Jan 19 22:57:20 EST 2009


Roger Taylor wrote:
> I've got a little question.
> 
> What keeps an auto-starting ROM Pak (Q signal tied to CART) from 
> continuously looping to $C000 instead of running the ROM code?
> 
> If BASIC is responsible for resetting the FIRQ behavior before jumping 
> into the ROM, I can understand how this would work right, but if the CPU 
> itself is responsible by using the upper hardware vectors to jump 
> directly to $C000 before BASIC even gets a chance to start, then if the 
> ROM code doesn't start with ORCC #80 (mask IRQ/FIRQ), then I can't see 
> the code ever getting past the first instruction, which in some cases is 
> a NOP.
> 
> Any ideas?

When the CPU starts the FIRQ service, it automatically disables both IRQ 
and FIRQ (implicit ORCC #$50). The FIRQ routine in BASIC is at $A0F6 
where it checks for a PIA cartridge interrupt and if it isn't, it 
returns. If it is, it vectors to the basic initialization code with the 
reset vector set to $A108. Then basic does its usualy initialization of 
the PIAs and vectors to $A108 which clears the restart flag (to force a 
cold start on reset) and jumps to the pack.

At no point along there does the code re-enable interrupts which means 
when the pack gets control at $C000, interrupts are disabled. This 
allows the pack to do whatever initialization it needs, probably 
including disabling the PIA cartridge interrupt, before re-enabling 
interrupts.

Additionally, interrupts are not enabled by the basic ROM until it sets 
up the vectors in low RAM ($10C...). Thus, the entire process is under 
the control of the basic ROM.

-- 
William Astle
lost at l-w.ca



More information about the Coco mailing list