[Coco] ASM Coders - Round two!

David Roper dave at ebonhost.com
Tue Aug 29 19:24:41 EDT 2006


Hi William,

Thanks for this code, too - the tip about mapping the start of gfx to 
$0000 to avoid adding offsets is a great idea - taa!

- David

William Astle wrote:
> David Roper wrote:
>   
>> 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?
>>     
>
> Once you've disabled interrupts, you should be able to use any mapping
> you like. You might want to take a memory map like follows:
>
> $0000-$7FFF: Hires screen
> $8000-$9FFF: heat effects
> $A000-$FDFF: available for other uses
>
> To make this work, you will need to load your code somewhere, say $6000,
> then play a few games with the MMU to move it out of the way of your new
> memory map. I'll take a stab at how to do this off the cuff (Warning:
> Mailer Code (tm)):
>
> 	ORG $6000
> START	ORCC #$50
> 	LDA #$3B
> 	STA $FFA5
> 	JMP LAUNCH+$4000
> LAUNCH	LDD #$3031
> 	STD $FFA0
> 	LDD #$3233
> 	STD $FFA2
> 	* now initialize the graphics screen, etc.
> 	END START
>
> Theoretically, you can then do LOADM:EXEC in sequence and the program
> will launch. (You can make it autolaunch with LOADM but that's an
> exercise for another day. You can even make the whole thing launch from
> a floppy with the DOS command.)
>
> What that code does is as follows:
>
> 1. disable interrupts
> 2. puts the block normally at $6000 into place at $A000 (it will still
> be at $6000)
> 3. jumps to the next instruction, but in the instance of the block at $A000
> 4. puts the hires screen blocks in starting at $0000 in the logical space
>
> Why it should work:
>
> The absolute origin means we know where we are in the memory space and
> the rest of the code assumes the standard BASIC memory mapping. We know
> that the offset from the base address of the block is the same no matter
> where in memory the block resides. That means if we are at $600A and we
> have a mirror of the block starting at $A000, the value at $A00A is the
> same as at $600A as far as the CPU is concerned. Neat trick, eh?
>
> Why put the screen at $0000?
>
> This way you never need to add an offset after calculating the pixel
> byte location and it should save you a few cycles if you are plotting
> pixels, etc., rather a lot.
>
> Additional notes:
>
> You can then choose any RAM block other than $30,$31,$32,$33,$3B for the
> heat data and put it at $8000 by storing the number at $FFA4. You might
> use, say, $3A (the block ordinarily at $4000-$5FFF), for example.
>
> As you can see, the MMU can make your brain explode as you try to work
> out just what is going on.
>
>   
>> b) can i simply disable interrupts and leave them disabled for the
>> entire code, without side effects?
>>     
>
> You should be able to since you don't need the system to do anything
> else while your demo is running.
>
>   




More information about the Coco mailing list