VRAMLoad + CGRAMLoad updates

Yesterday I returned to the PPU.c code. I knew that the VRAMLoad and CGRAMLoad needed to be reworked. The DMA transfer routine we were always getting data from bank $01. Since I start to having lots of ressource, I got stuck while implementing the score/status board. Here is the revised code :

void VRAMLoad(word far *src, word vramDst, word size) {
	// set address in VRam for read or write ($2116) 
	// + block size transfer ($2115)
	*(byte*)0x2115 = 0x80;
	*(word*)0x2116 = vramDst;
	// set DMA control register (1 word inc)
	// and destination ($21xx xx -> 0x18)
	*(word*)0x4300 = 0x1801;	

	// DMA channel x source address offset 
	// (low $4302 and high $4303 optimisation)
	lda %%src;					
	sta $4302;					
	// DMA channel x source address bank
	lda %%src+2;				
	sta $4304;

	// DMA channel x transfer size 
	// (low $4305 and high $4306 optimisation)
	*(word*)0x4305 = size;	

	// Turn on DMA transfer for this channel
	*(byte*)0x420b = 0x01;

I’m now using far pointer, here is a part of the ressource.h :

extern word far score_pic[];
extern word far score_pal[];
extern word far score_map[];

So now I can copy from anywhere in ROM to VRAM or CGRAM  without any problem.

++ Lint

Comments are closed.