[Coco] Writing a program for a cartridge

Barry Nelson Barry.Nelson at amobiledevice.com
Mon Jan 25 10:38:59 EST 2016


Well, first off I fixed one silly mistake, the BEQ instruction should have been BGT. Aside from that, the routine still does not work right. I am still debugging so I will probably post more details later. To answer some of your other questions:

 

Ø  Why do you want to JMP [$FFFE] when you already have the correct rom bank addressed? Don't you want to JMP $C000 since the correct rom bank in the cart will now addressed at $C000?

The new bank being addressed contains a disk controller ROM, so instead of activating the CART line and jumping to $C000 with an interrupt, it should go through the routine in BASIC that links in Disk Extended Color BASIC.

 

Ø  Depending on what your actual rom intends, you may not want to reactivate cpu to interrupts with the andcc #$af. That can wait until your intended 

rom does a setup of memory and any new interrupt routines.

That is a good tip, I will remove the ANDCC #$AF instruction.

 

Some more notes:

FF58 is a hardware register on the cartridge in question that connects or disconnects the CART line from the cartridge.

FF59 and FF5A are hardware registers on the cartridge that control what sections of the ROM on the cartridge are mapped to $C000, each bank is 2k in size. My code below starts running with bank 0 mapped at $C000, bank 1 mapped at $C800, bank 2 mapped at $D000 and bank 3 mapped at $D800, with both FF59 and FF5A containing a 0, storing a 4 into FF59 changes the mapping so that bank 4 is mapped at $C000, bank5 is mapped at $C800, bank6 mapped at $D000, and bank 7 is mapped at $D800. FF5A contains the high number bits of the starting bank to map in at $C000, FF59 contains the low number bits, so storing a 4 into FF59 with FF5A being 0 causes bank 4 to map at $C000, with the sequentially higher banks mapping at the adjacent addresses. The idea is to setup the CART line as disconnected as it would be on a disk controller, map in the proper ROMs at $C000 containing the disk controller ROM code, and cause the machine to cold start. I jump to the reset vector at FFFE and not directly to the startup routine because I don’t know if this code will be running on a CoCo 1, 2, or 3 and the reset vector on a CoCo 3 is different so by doing an indirect jump I always call the right startup routine, or at least that’s the theory. J

 

>        Robert Gault robert.gault at att.net  <mailto:coco%40maltedmedia.com?Subject=Re%3A%20%5BCoco%5D%20Writing%20a%20program%20for%20a%20cartridge&In-Reply-To=%3C56A62B17.8070304%40att.net%3E> 
Mon Jan 25 09:03:03 EST 2016 

 

>        Barry Nelson wrote:

Ø   Ok, I'm trying to write a program that will manipulate some hardware registers in a cartridge and change the rom that is mapped at $C000 and then cold start the computer once the new rom is mapped in. This is what is have…
>         > 
>         >          ORG        $C000
>         > START   ORCC       #$50   Disable interrupts
>         >          LEAX       TORAM,PCR
>         >          LDY        $3000
>         > LOOP    CMPX       ENDRT  Copy code at TORAM into ram
>         >          BEQ        EXIT
>         >          LDA        ,X+
>         >          STA        ,Y+
>         >          BRA        LOOP
>         > EXIT    JMP        $3000  Jump to copied code
>         > TORAM   ORCC       #$50   Disable interrupts
Ø   CLRA
>         >          STA        >$0071  Clear flag to indicate cold start
>         >          STA        $FF58   Clear cart interrupt flag, This disables the CART line
>         >          STA        $FF5A   Clear bank # high bits for selecting the rom bank #
>         >          LDA        #4
>         >          STA        $FF59   Set bank # to 4
>         >          STA        $FFDE   Turn on the ROM in the memory map
>         >          ANDCC      #$AF   Enable interrupts
>         >          JMP        [$FFFE] Do restart
>         > ENDRT   EQU        *
>         >          END        START
>         > 
 
>         Barry,
 
>         Why do you want to JMP [$FFFE] when you already have the correct rom bank 
>         addressed? Don't you want to JMP $C000 since the correct rom bank in the cart 
>         will now addressed at $C000?
>         Depending on what your actual rom intends, you may not want to reactivate cpu 
>         response to interrupts with the andcc #$af. That can wait until your intended 
>         rom does a setup of memory and any new interrupt routines.
 
>         Robert

 



More information about the Coco mailing list