[Coco] ASM Coders - Round two!

Robert Gault robert.gault at worldnet.att.net
Tue Aug 29 19:16:00 EDT 2006


David Roper wrote:
><snip> 
> I was only clearing half the screen in the code I posted because this 
> happened flawlessly. The "garbage" I referred to was more of a 
> "corruption of the existing garbage", as the bottom half of the screen 
> presented the same pattern of garbage data (alternating vertical green 
> and black lines) every time I ran the (working) code. This pattern was 
> corrupted when I mapped LDA #$32, STA $FFA3

This should be impossible and does not happen for me when I test your 
code. Your routine clears one byte at a time for a total of $3E80 bytes. 
This falls within the first two MMU blocks at $2000 - $5FFF and does not 
care what the setting is for $FFA3. Remapping $FFA3 changes $6000 - 
$7FFF and can't have any effect on your program, the screen, or IRQ 
routines. If you remap $FFA4 with the interrupts on, the Coco3 or MESS 
Coco3 emulation will crash and you will indeed have garbage over the 
entire screen.

> 
> So, the questions:
> 
> a) To achieve 32k of contiguous memory (whether the physical ram is 
> contiguous or not is irrelevent, as long as it's mapped to be 
> contiguous), where can you recommend I map this to?

Since you are not using the ROM code and if you keep IRQs turned off, 
you can map the screen to any 4 contiguous MMU blocks that don't overlap 
your program address.

> 
> b) can i simply disable interrupts and leave them disabled for the 
> entire code, without side effects?

Yes, you can. There may be some reason for which you want to use the 
IRQs in the future. You can either restore the MMU blocks before 
restarting the IRQs or point the IRQ vectors to your own routines. Just 
make sure the vectors don't point to a switched out MMU block.

> 
> Thanks!
> 
> 
> 
> 

By the way, as you will want to make your code as fast as possible, 
consider that you can set more than one byte of the screen per loop. As 
an example,

clrscrn	ldx	#HRESSCRN
	ldu	#HSCLEN
	ldd	#PATTERN
	ldy	#PATTERN
clrloop	std	,x++
	sty	,x++
	leau	-4,u
	bne	clrloop
endloop	bra	endloop
HRESSCRN equ	$2000
HSCLEN	equ	$3E80
PATTERN	equ	$xxxx	or any 2 byte value you want

You can make the routine faster still by pointing either regS or regU at 
the bottom of the screen and pushing 8 bytes of data at a time. In this 
case you don't use a counter but compare the stack to the start of the 
screen.

In short, as you reduce the number of passes through the loop, the 
process speeds up.



More information about the Coco mailing list