02-12-2022, 09:33 AM
(02-11-2022, 08:49 PM)sodthor Wrote: a bit of asm in your c code ?
Personally, I use asm for hblank code, sometimes using also bank register switch (incf, decf or ldf)
Do you know ldir(w) and lddr(w) ? (check asm doc: e_900h_chap3_cpu_4.pdf)
something like:
void moveRam(void*dst,void*src,u32 count)
{
__ASM(" ld xbc,(xsp+12) ");
__ASM(" ld xhl,(xsp+8) ");
__ASM(" ld xde,(xsp+4) ");
__ASM(" ldirw (xde+),(xhl+) ");
}
can be improved without using a function and direct access to global var to init dst & src (maybe you can use DMA for async mem transfert)
Most of the time, -O3 is better than my own asm "optimizations", that's why I often add a -S to check how it's compiled.
It appears my makefile has always had -O3. I can barely stumble my way through ASM, but I am attempting to learn.
In my case, everything needed by hblank is known during vblank.
Here is my hblank code that references some global variables. I added notes where the pain point is for performance.
Code:
void __interrupt myHBL()
{
u8 y = RAS_Y;
myHBCounter++;
if(y==8){
if(showHUD){
SCR1_Y=plane1.planeY;
SCR1_X=plane1.planeX;
SPR_Y=0;
if(currentLevel.isBossRoom)SCR2_Y=plane2.planeY;
}
}
//everything above works fine
//everything below kills performance
//performance suffers is screenSplit is true
else if (screenSplit){
if(y==60) SCR2_X=split1;
else if(y==100) SCR2_X=split2;
}
}What is the best way to shift this to ASM?

