Hey Mr cadet
So I made changes to how I handle the Left and right side of a horizontal line that is shorter than 16. I called it a partial bar.
I've optimized it as much as I can ( I think and if there is a better way I'd like to hear about it).
this is what the code looks like more or less:
function partialbar( x1, y1, x2, y2, startmm, endmm){
...
let startmm[0]= startmm[0] | ((arrMask[x1 & 15]) & (~(arrMask[(x2 & 15) +1])));
///////////////////
//alternatively...
//do Memory.poke( startmm, Memory.peek(startmm) | ((arrMask[x1 & 15]) & (~(arrMask[(x2 & 15) +1]))));
//////////////////
....
}
where startmm and endmm represent a specific Memory map of screen. ie 16384
where arrMask is an array that holds specific values used for masking
ie
arrMask[0] = xFFFF;
arrMask[1] = xFFFE;
arrMask[1] = xFFFC;
...
arrMask[15] = x8000
arrMask[16] = x0000
--------------------------------
I have also taken measures to make the other parts of rectangle drawing better. Such as ensuring multiplication is used as few times as possible.
This is my implementation of rectangle:
function void drawRectangle(int x1, int y1, int x2, int y2) {
...
let startmm = Screen.screenBase() + ( TLY << 5) + ( TLX >> 4);
let endmm = Screen.screenBase() + ( TRY << 5) + ( TRX >> 4);
while ( ~(TLY > BLY)){
if( (endmm - startmm) > 1){
do Screen.drawMultBars( startmm + 1, endmm -1);
}
do Screen.drawPartialBar( TLX, TLY, TRX, TRY, startmm, endmm);
let startmm = startmm + 32; //there are 32 bars per rows, this will bring it down a row
let endmm = endmm + 32;
let TLY = TLY + 1;
}
...
}
where drawMultbars simply makes the entire range of MemoryMaps equal to either -1 or or 0
where TLX and TLY stand for the top left point
where TRX and TRY stand for the top right point
where BLY stand for the bottom left row
where lines are always drawn LEFT to RIGHT ( or startmm to endmm respectively)
This link will show you a video where i am comparing the vigor of my implementation verse the given version ( mine is on the left)
clickHereps: graphical speed is very important. Especially when I try to make tetris!
pss: it is weird how the center of the square sparkles when it shrinks or grows in size. No Idea what is causing that