[Coco] Help with some HiRes CoCo 3 MMU settings

Glen Hewlett glen.hewlett at sympatico.ca
Wed Dec 7 15:58:31 EST 2016


Hi Robert,

Thanks for looking at the code, I’ve been trying so many things to figure out why I’m having my problem that I’ve changed code without updating the comments many times...  I should have gone back and looked through my code and comments a little better last night before posting.  I was just at that point where I was getting really frustrated and really tired.  I was going to wait before posting but I figured it would mean at least another day before getting any help.

I actually noticed the INIT0_Register0 entry today myself and changed it to the proper INIT1_Register1 so my code will use MMU Bank 0 (%00100000 stored at $FF91).

I was using pages $30 & $31 originally (which is what I eventually want to use) but had changed them to $38 & $39 to see if putting them back to normal would stop the swapping out that seems to be happening while my program is running.  But it didn’t help.

I think my problem might not be with the RAM and MMU configuration and setup.  But more to do with my program using the IRQ.  But I was wondering if there was something I might have missed that is needed for the basic setup of the graphics memory on the CoCo 3.

The current program I’m working on is specifically so I get get a grasp on Interrupts more.  I’ve done a lot of programming on my old CoCo and Coco 3 in assembly so I’m comfortable in my coding but I’ve never really understood Interrupts.  Since I listened to John Linville talk about the hardware of the 6809 on the CoCo Crew podcast that I thought I really should get a grasp on this.

Currently I’m 

SetIRQs ORCC    #$50                    * Disable All the IRQs (Interrupts)
        LDA     #$00                    * Vertical border interrupt Enabled        STA     IRQENR                  * Timer interrupt Enabled
        STA     IRQENR
        LDA     #$00                    *
        STA     FIRQENR                 * FIRQ are all disabled

        CLR     Timer_register_LSB      * Set the Timer to 0
        CLR     Timer_register_MSB      * The Timer Interrupt will activate whenever the timer counts down to zero
        LDA     #$7E                    * Setup IRQ jump location, Opcode for JMP instruction
        STA     IRQ_Jump_position       * Store it at FEF7 which is the address the the IRQ will jump to
        LDX     #My_IRQ		        * the actual address that will run when an IRQ hits (C2F9)
        STX     IRQ_Start_Address       * Store the program start at the IRQ Address (FEF8) 

Later in my code to enable only the IRQ so I can do stuff with the Timer I use:
		ANDCC	#$EF

The program runs for about 10 seconds then it seems like the CoCo is still doing something on its own in the background (bank switching) while my program is running and it’s erasing my data.
Here is the little test IRQ command that just increments a byte on the screen so I can see it working.  

My_IRQ
        ORCC    #$10                    * Disable the IRQ Interrupt
	INC	$100			; See on screen if IRQ is doing something
        LDA     IRQENR                  * IRQENR - Interrupt request enable register
        BITA    #$20                    * Test Timer interrupt (TMR)
	BNE	TestIRQ
	ANDCC   #$EF                    * Restore Condition Codes to re-enable IRQ Interrupt
        RTI

TestIRQ	
	LDD     #$0FFF                  *C336: 86 95          Set Timer to Max of 4095
        STD     Timer_register_MSB      *C33D: B7 FF 94       Store Timer in FF94 Timer register
	ANDCC   #$EF                    * Restore Condition Codes to re-enable IRQ Interrupt
        RTI

I’d appreciate any pointers or things you know that might be causing my problem.

Sorry for the long post,
Glen.

> On Dec 7, 2016, at 10:02 AM, Robert Gault <robert.gault at att.net> wrote:
> 
> Glen Hewlett wrote:
>> Hi All,
>> 
>> I’ve been fighting for days trying to figure out why the program I’ve written is crashing.  I think it’s the MMU doing some bank switching in the background while my program is running.
>> 
>> My program disables all the interrupts the sets up the graphic mode in my case a 256x225 2 colour screen.  I’m trying to use blocks 0 ($0000 to $1fff) and block 1 ($2000 to $3fff) for my graphics output screen and variables.  My program code is running at $4000 and the stack is at $7FFF.
>> 
>> While testing my program with the MAME emulator in debug mode, my program shows some graphics on the screen and runs along for a about 10 seconds then blamo, it crashes.  As far as I can tell the bank memory is coming into play somehow.  With Mame’s debugger I can see the banks of memory have wiped out my graphics screen and my program and filled it all with a bunch of $CD values in my RAM.  Does this sound familiar to anyone maybe you know what I’m missing or doing wrong that would cause such a thing to happen.
>> 
>> I looked all over the internet to see if anyone has some example code for  setting up graphics modes and the MMU in assembly.  All I’ve been able to find is tons and tons of technical manuals that do a great job of explaining what all the values do, but there aren’t any real world examples that I could find.  If someone has some nice code that they want to share that would be awesome…
>> 
>> Below is the initializing code that I’ve written and plan to use over and over for future programs.
>> 
>> Thanks for looking,
>> Glen
>> 
> 
> Glen,
> 
> There are several things that likely are not right.
> 
> 1) As already mentioned, you did not set the Task register but rather sent a second value to $FF90. The value sent would have caused the Task register to use a 279nsec clock and not Task#1. Should be %00000001
> 
> 2) Your comments and values do not match.
> * Load GIME pages $30 & $31 into CPU RAM $0000-$1FFF & $2000-$4000
>        LDA     #$38                    * Start at Hi-Res page #1
> 	STA	$FFA0
> 	LDA	#$39
> 	STA	$FFA1
> 
> With these changes, MESS does not crash.
> 
> Robert
> 
> 
> -- 
> Coco mailing list
> Coco at maltedmedia.com <mailto:Coco at maltedmedia.com>
> https://pairlist5.pair.net/mailman/listinfo/coco <https://pairlist5.pair.net/mailman/listinfo/coco>


More information about the Coco mailing list