mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 08:24:32 -08:00
[fb] Use rep stosl for screen fill
This is mostly cleanup after fighting the double buffering bug - bring back rep stosl for screen fill, and move draw_pixel to be an inline function.
This commit is contained in:
@@ -9,7 +9,8 @@ screen::screen(volatile void *addr, unsigned hres, unsigned vres, unsigned scanl
|
|||||||
m_resx(hres),
|
m_resx(hres),
|
||||||
m_resy(vres)
|
m_resy(vres)
|
||||||
{
|
{
|
||||||
m_back = reinterpret_cast<pixel_t*>(malloc(scanline*vres*sizeof(pixel_t)));
|
const size_t size = scanline * vres;
|
||||||
|
m_back = reinterpret_cast<pixel_t*>(malloc(size * sizeof(pixel_t)));
|
||||||
}
|
}
|
||||||
|
|
||||||
screen::pixel_t
|
screen::pixel_t
|
||||||
@@ -33,15 +34,9 @@ screen::color(uint8_t r, uint8_t g, uint8_t b) const
|
|||||||
void
|
void
|
||||||
screen::fill(pixel_t color)
|
screen::fill(pixel_t color)
|
||||||
{
|
{
|
||||||
const size_t len = m_resx * m_resy;
|
const size_t len = m_scanline * m_resy;
|
||||||
for (size_t i = 0; i < len; ++i)
|
asm volatile ( "rep stosl" : :
|
||||||
m_back[i] = color;
|
"a"(color), "c"(len), "D"(m_back) );
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
screen::draw_pixel(unsigned x, unsigned y, pixel_t color)
|
|
||||||
{
|
|
||||||
m_back[x + y * m_resx] = color;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -17,7 +17,11 @@ public:
|
|||||||
pixel_t color(uint8_t r, uint8_t g, uint8_t b) const;
|
pixel_t color(uint8_t r, uint8_t g, uint8_t b) const;
|
||||||
|
|
||||||
void fill(pixel_t color);
|
void fill(pixel_t color);
|
||||||
void draw_pixel(unsigned x, unsigned y, pixel_t color);
|
|
||||||
|
inline void draw_pixel(unsigned x, unsigned y, pixel_t color) {
|
||||||
|
const size_t index = x + y * m_scanline;
|
||||||
|
m_back[index] = color;
|
||||||
|
}
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user