directRectangle


#1

directRectangle seems to be broken, only drawing a single line and with artifacts
game.display.directRectangle(10,10,100,100,0xFFFF);

please check for yourselfs first, but i think this might be the fix

void Pokitto::lcdRectangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color) {
int16_t temp;
if (x0>x1) {temp=x0;x0=x1;x1=temp;}
if (y0>y1) {temp=y0;y0=y1;y1=temp;}
if (x0 > POK_LCD_W) return;
if (y0 > POK_LCD_H) return;
if (x1 > POK_LCD_W) x1=POK_LCD_W;
if (y1 > POK_LCD_H) y1=POK_LCD_H;
if (x0 < 0) x0=0;
if (y0 < 0) y0=0;

int16_t x,y;

for (y=y0; y<=y1;y++) {

write_command(0x20); // Horizontal DRAM Address (=y on pokitto screen)

write_data(y);

write_command(0x21); // Vertical DRAM Address (=x on pokitto screen)

write_data(x0);

write_command(0x22); // write data to DRAM

CLR_CS_SET_CD_RD_WR; // go to vram write mode

for (x=x0; x<x1;x++) {

setup_data_16(color); // setup the data (flat color = no change between pixels)

CLR_WR;SET_WR; //CLR_WR;SET_WR;//toggle writeline, pokitto screen writes a column up to down

}

}

}


#2

What screen mode are you using?


#3

#define PROJ_HIRES 0
low resolution fast mode (110x88) the default but direct commands should run independant from screen modes since they draw straight to the screen


#4

Most modes now draw in rows (left to right, top to bottom).
That might affect the direct methods that were meant to draw in columns (top to bottom, left to right). :thinking:


#5

ok so a #ifdef around the function and have both?


#6

That’s one way to do it.

Another would be to have Pokitto::Display manage the draw orientation. Maybe add something like Display::columnOrder() and Display::rowOrder(). These functions could check the current orientation and switch if necessary.

On the other hand:
The display modes all make sure the orientation is correct before copying to the LCD, so you can switch whenever you like without breaking anything.