[Coco] Help with speeding up sprite rendering

William Astle lost at l-w.ca
Fri Mar 17 10:32:24 EDT 2017


A couple of points:

First, "andcc #0" does not disable interrupts. It actually enables them. 
You need "orcc #$50" to disable interrupts. (That disables both IRQ and 
FIRQ.)

Second, as others have noted, as soon as the PULS runs, you're changing 
the value of CC which might enable the interrupts again. Thus, you have 
to arrange for no interrupts to be possible while you're doing this.

Depending on how you have the system set up, that could mean simply 
disabling the IRQ and FIRQ in the GIME (clearing the enable bits in 
FF90) or clearing the interrupt enable bits in the PIAs or both. Since 
IRQ and FIRQ are level triggered, disabling the interrupt sources should 
clear any pending interrupt.

Also, you definitely want to disable interrupts anyway when doing the 
stack trick because you've repurposed S and you definitely don't want an 
IRQ firing while S is not pointing at a proper stack location - it could 
trash your sprite data. Also, since you're messing with DP, if your 
interrupt routine depends on its value, you could have even more excitement.

Also, there is nothing magical about running during an interrupt service 
routine. When the IRQ routine starts, CC will have the IRQ bit set 
(meaning IRQs are masked). (When FIRQ starts, both I and F are set, 
masking both IRQ and FIRQ.) The "RTI" at the end restores the original 
CC value. There is no hardware handshake anywhere that prevents 
interrupts between interrupt service starting and RTI so you don't even 
need to bother with RTI if you're doing something really clever. Your 
problems using CC are purely down to the IRQ/FIRQ mask flags getting 
messed with.

Finally, given the complexity of dealing with interrupt sources, it 
might not be worth the confusion to try to use CC. If you move around 
enough sprites all at once, it might be a win, though. You have to 
balance that with the cost of turning off the interrupt sources, then 
turning them on again.

On 2017-03-17 12:03 AM, Glen Hewlett wrote:
> Hi All,
>
> I’m working on some routines to draw sprites on the screen faster and I have a lot of it working fine.
> If I use PULS and PSHU commands I can really improve the speed of my sprite rendering.
>
> For example instead of using a bunch of
> LDD		,X++
> STD		,U++
> ...
> I’m using
> PULS	A,B,X,Y,DP
> PSHU	A,B,X,Y,DP
>>
> That’s all great for sprites that are 7 bytes wide, but I also need to move sprites that are 8 bytes wide.  I’ve read on the net about using the condition code (CC) in the same way I described above but it breaks my program.  I couldn’t find some example code, just some talk about doing it.
>
> I’ve tried:
> ANDCC	#$00
> PULS	A,B,X,Y,DP,CC
> PSHU	A,B,X,Y,DP,CC
>> ANDCC	#$EF	- re-enable the IRQ
>
> I’m not sure what this is doing, as the computer is still running and the IRQ is triggering but it’s not generating the sprites when I do this.  In fact the computer seems to be stuck in the IRQ loop.
>
> Normally my program is moving the sprites around while in the IRQ routine, is this the part of the problem when using the CC register?  Or am I just handling the CC register improperly?
>
> If anyone has some sample code or can offer some advice I sure would appreciate it.
>
> Cheers,
> Glen.
>



More information about the Coco mailing list