diff --git a/src/main/hwvideo/hwroad.cpp b/src/main/hwvideo/hwroad.cpp
old mode 100644
new mode 100755
index 8b34ec4..3e2d475
--- a/src/main/hwvideo/hwroad.cpp
+++ b/src/main/hwvideo/hwroad.cpp
@@ -189,6 +189,7 @@ void HWRoad::decode_road(const uint8_t* src_road)
}
// Writes go to RAM, but we read from the RAM Buffer.
+/* defined Inline...
void HWRoad::write16(uint32_t adr, const uint16_t data)
{
ram[(adr >> 1) & 0x7FF] = data;
@@ -208,6 +209,7 @@ void HWRoad::write32(uint32_t* adr, const uint32_t data)
ram[((a >> 1) + 1) & 0x7FF] = data & 0xFFFF;
*adr += 4;
}
+*/
uint16_t HWRoad::read_road_control()
{
@@ -225,10 +227,12 @@ uint16_t HWRoad::read_road_control()
return 0xffff;
}
+/* Inlined... see .hpp
void HWRoad::write_road_control(const uint8_t road_control)
{
this->road_control = road_control;
}
+*/
// ------------------------------------------------------------------------------------------------
// Road Rendering: Lores Version
@@ -283,6 +287,7 @@ void HWRoad::render_background_lores(uint32_t* pixels)
for (x = 0; x < config.s16_width; x++)
*(pPixel)++ = color;
+
}
}
}
@@ -355,8 +360,9 @@ void HWRoad::render_foreground_lores(uint32_t* pixels)
hpos0 = (hpos0 - (s16_x + x_offset)) & 0xfff;
for (x = 0; x < config.s16_width; x++)
{
- int pix0 = (hpos0 < 0x200) ? src0[hpos0] : 3;
- pPixel[x] = color_table[0x00 + pix0];
+ /*int pix0 = (hpos0 < 0x200) ? src0[hpos0] : 3;
+ *(pPixel++) = color_table[0x00 + pix0];*/
+ *(pPixel++) = color_table[0x00 + (hpos0 < 0x200) ? src0[hpos0] : 3];
hpos0 = (hpos0 + 1) & 0xfff;
}
break;
@@ -369,9 +375,9 @@ void HWRoad::render_foreground_lores(uint32_t* pixels)
int pix0 = (hpos0 < 0x200) ? src0[hpos0] : 3;
int pix1 = (hpos1 < 0x200) ? src1[hpos1] : 3;
if (((priority_map[0][pix0] >> pix1) & 1) != 0)
- pPixel[x] = color_table[0x10 + pix1];
+ *(pPixel++) = color_table[0x10 + pix1];
else
- pPixel[x] = color_table[0x00 + pix0];
+ *(pPixel++) = color_table[0x00 + pix0];
hpos0 = (hpos0 + 1) & 0xfff;
hpos1 = (hpos1 + 1) & 0xfff;
@@ -386,9 +392,9 @@ void HWRoad::render_foreground_lores(uint32_t* pixels)
int pix0 = (hpos0 < 0x200) ? src0[hpos0] : 3;
int pix1 = (hpos1 < 0x200) ? src1[hpos1] : 3;
if (((priority_map[1][pix0] >> pix1) & 1) != 0)
- pPixel[x] = color_table[0x10 + pix1];
+ *(pPixel++) = color_table[0x10 + pix1];
else
- pPixel[x] = color_table[0x00 + pix0];
+ *(pPixel++) = color_table[0x00 + pix0];
hpos0 = (hpos0 + 1) & 0xfff;
hpos1 = (hpos1 + 1) & 0xfff;
@@ -401,8 +407,9 @@ void HWRoad::render_foreground_lores(uint32_t* pixels)
hpos1 = (hpos1 - (s16_x + x_offset)) & 0xfff;
for (x = 0; x < config.s16_width; x++)
{
- int pix1 = (hpos1 < 0x200) ? src1[hpos1] : 3;
- pPixel[x] = color_table[0x10 + pix1];
+ /*int pix1 = (hpos1 < 0x200) ? src1[hpos1] : 3;
+ *(pPixel++) = color_table[0x10 + pix1];*/
+ *(pPixel++) = color_table[0x10 + (hpos1 < 0x200) ? src1[hpos1] : 3];
hpos1 = (hpos1 + 1) & 0xfff;
}
break;
@@ -571,7 +578,7 @@ void HWRoad::render_foreground_hires(uint32_t* pixels)
// Shift road dependent on whether we are in widescreen mode or not
uint16_t s16_x = 0x5f8 + config.s16_x_off;
- uint32_t* const pPixel = pixels + (y * config.s16_width);
+ uint32_t* pPixel = pixels + (y * config.s16_width);
// draw the road
switch (road_control & 3)
@@ -580,11 +587,12 @@ void HWRoad::render_foreground_hires(uint32_t* pixels)
if (data0 & 0x800)
continue;
hpos0 = (hpos0 - (s16_x + x_offset)) & 0xfff;
- for (x = 0; x < config.s16_width; x++)
+ for (x = 0; x < config.s16_width; x+=2)
{
int pix0 = (hpos0 < 0x200) ? src0[hpos0] : 3;
- pPixel[x] = color_table[0x00 + pix0];
- if (x & 1)
+ *(pPixel++) = color_table[0x00 + pix0];
+ *(pPixel++) = color_table[0x00 + pix0];
+// if (x & 1)
hpos0 = (hpos0 + 1) & 0xfff;
}
break;
@@ -592,40 +600,46 @@ void HWRoad::render_foreground_hires(uint32_t* pixels)
case 1:
hpos0 = (hpos0 - (s16_x + x_offset)) & 0xfff;
hpos1 = (hpos1 - (s16_x + x_offset)) & 0xfff;
- for (x = 0; x < config.s16_width; x++)
+ for (x = 0; x < config.s16_width; x+=2)
{
int pix0 = (hpos0 < 0x200) ? src0[hpos0] : 3;
int pix1 = (hpos1 < 0x200) ? src1[hpos1] : 3;
- if (((priority_map[0][pix0] >> pix1) & 1) != 0)
- pPixel[x] = color_table[0x10 + pix1];
- else
- pPixel[x] = color_table[0x00 + pix0];
-
- if (x & 1)
- {
+ if (((priority_map[0][pix0] >> pix1) & 1) != 0) {
+ *(pPixel++) = color_table[0x10 + pix1];
+ *(pPixel++) = color_table[0x10 + pix1];
+ } else {
+ *(pPixel++) = color_table[0x10 + pix0];
+ *(pPixel++) = color_table[0x10 + pix0];
+ }
+
+ /*if (x & 1)
+ {*/
hpos0 = (hpos0 + 1) & 0xfff;
hpos1 = (hpos1 + 1) & 0xfff;
- }
+ /*}*/
}
break;
case 2:
hpos0 = (hpos0 - (s16_x + x_offset)) & 0xfff;
hpos1 = (hpos1 - (s16_x + x_offset)) & 0xfff;
- for (x = 0; x < config.s16_width; x++)
+ for (x = 0; x < config.s16_width; x+=2)
{
int pix0 = (hpos0 < 0x200) ? src0[hpos0] : 3;
int pix1 = (hpos1 < 0x200) ? src1[hpos1] : 3;
- if (((priority_map[1][pix0] >> pix1) & 1) != 0)
- pPixel[x] = color_table[0x10 + pix1];
- else
- pPixel[x] = color_table[0x00 + pix0];
+ if (((priority_map[1][pix0] >> pix1) & 1) != 0) {
+ *(pPixel++) = color_table[0x10 + pix1];
+ *(pPixel++) = color_table[0x10 + pix1];
+ } else {
+ *(pPixel++) = color_table[0x00 + pix0];
+ *(pPixel++) = color_table[0x00 + pix0];
+ }
- if (x & 1)
- {
+ /*if (x & 1)
+ {*/
hpos0 = (hpos0 + 1) & 0xfff;
hpos1 = (hpos1 + 1) & 0xfff;
- }
+ /*}*/
}
break;
@@ -633,11 +647,12 @@ void HWRoad::render_foreground_hires(uint32_t* pixels)
if (data1 & 0x800)
continue;
hpos1 = (hpos1 - (s16_x + x_offset)) & 0xfff;
- for (x = 0; x < config.s16_width; x++)
+ for (x = 0; x < config.s16_width; x+=2)
{
int pix1 = (hpos1 < 0x200) ? src1[hpos1] : 3;
- pPixel[x] = color_table[0x10 + pix1];
- if (x & 1)
+ *(pPixel++) = color_table[0x10 + pix1];
+ *(pPixel++) = color_table[0x10 + pix1];
+ /*if (x & 1)*/
hpos1 = (hpos1 + 1) & 0xfff;
}
break;
diff --git a/src/main/hwvideo/hwroad.hpp b/src/main/hwvideo/hwroad.hpp
old mode 100644
new mode 100755
index 115bee1..85e778d
--- a/src/main/hwvideo/hwroad.hpp
+++ b/src/main/hwvideo/hwroad.hpp
@@ -9,11 +9,23 @@ public:
~HWRoad();
void init(const uint8_t*, const bool hires);
- void write16(uint32_t adr, const uint16_t data);
- void write16(uint32_t* adr, const uint16_t data);
- void write32(uint32_t* adr, const uint32_t data);
+ inline void write16(uint32_t adr, const uint16_t data)
+ {
+ ram[(adr >> 1) & 0x7FF] = data;
+ }
+ inline void write16(uint32_t* adr, const uint16_t data)
+ {
+ ram[((*adr) >> 1) & 0x7FF] = data; *adr+=2;
+ }
+ inline void write32(uint32_t* adr, const uint32_t data)
+ {
+ ram[((*adr) >> 1) & 0x7FF] = data >> 16; ram[(((*adr) >> 1) + 1) & 0x7FF] = data & 0xFFFF;*adr += 4;
+ }
uint16_t read_road_control();
- void write_road_control(const uint8_t);
+ inline void write_road_control(const uint8_t rc)
+ {
+ this->road_control = rc;
+ }
void (HWRoad::*render_background)(uint32_t*);
void (HWRoad::*render_foreground)(uint32_t*);
diff --git a/src/main/hwvideo/hwsprites.cpp b/src/main/hwvideo/hwsprites.cpp
index 233ecd3..7879363 100644
--- a/src/main/hwvideo/hwsprites.cpp
+++ b/src/main/hwvideo/hwsprites.cpp
@@ -225,15 +225,25 @@ void hwsprites::render(const uint8_t priority)
uint32_t pixels = sprites[spritedata + ++ramBuff[data+7]]; // Add to base sprite data the vzoom value
// draw four pixels
- pix = (pixels >> 28) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
- pix = (pixels >> 24) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
- pix = (pixels >> 20) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
- pix = (pixels >> 16) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
- pix = (pixels >> 12) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
- pix = (pixels >> 8) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
- pix = (pixels >> 4) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
- pix = (pixels >> 0) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
-
+ if (shadow) {
+ pix = (pixels >> 28) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 24) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 20) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 16) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 12) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 8) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 4) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 0) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ } else {
+ pix = (pixels >> 28) & 0xf; while (xacc < 0x200) { if (x >= x1 && x < x2 && pix != 0 && pix != 15) *(pPixel+x) = (pix | color | COLOR_BASE) & 0xfff; x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 24) & 0xf; while (xacc < 0x200) { if (x >= x1 && x < x2 && pix != 0 && pix != 15) *(pPixel+x) = (pix | color | COLOR_BASE) & 0xfff; x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 20) & 0xf; while (xacc < 0x200) { if (x >= x1 && x < x2 && pix != 0 && pix != 15) *(pPixel+x) = (pix | color | COLOR_BASE) & 0xfff; x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 16) & 0xf; while (xacc < 0x200) { if (x >= x1 && x < x2 && pix != 0 && pix != 15) *(pPixel+x) = (pix | color | COLOR_BASE) & 0xfff; x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 12) & 0xf; while (xacc < 0x200) { if (x >= x1 && x < x2 && pix != 0 && pix != 15) *(pPixel+x) = (pix | color | COLOR_BASE) & 0xfff; x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 8) & 0xf; while (xacc < 0x200) { if (x >= x1 && x < x2 && pix != 0 && pix != 15) *(pPixel+x) = (pix | color | COLOR_BASE) & 0xfff; x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 4) & 0xf; while (xacc < 0x200) { if (x >= x1 && x < x2 && pix != 0 && pix != 15) *(pPixel+x) = (pix | color | COLOR_BASE) & 0xfff; x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 0) & 0xf; while (xacc < 0x200) { if (x >= x1 && x < x2 && pix != 0 && pix != 15) *(pPixel+x) = (pix | color | COLOR_BASE) & 0xfff; x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ }
// stop if the second-to-last pixel in the group was 0xf
if ((pixels & 0x000000f0) == 0x000000f0)
break;
@@ -250,15 +260,25 @@ void hwsprites::render(const uint8_t priority)
uint32_t pixels = sprites[spritedata + --ramBuff[data+7]];
// draw four pixels
- pix = (pixels >> 0) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
- pix = (pixels >> 4) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
- pix = (pixels >> 8) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
- pix = (pixels >> 12) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
- pix = (pixels >> 16) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
- pix = (pixels >> 20) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
- pix = (pixels >> 24) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
- pix = (pixels >> 28) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
-
+ if (shadow) {
+ pix = (pixels >> 0) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 4) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 8) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 12) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 16) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 20) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 24) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 28) & 0xf; while (xacc < 0x200) { draw_pixel(x, pix, color, shadow, pPixel+x); x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ } else {
+ pix = (pixels >> 0) & 0xf; while (xacc < 0x200) { if (x >= x1 && x < x2 && pix != 0 && pix != 15) *(pPixel+x) = (pix | color | COLOR_BASE) & 0xfff; x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 4) & 0xf; while (xacc < 0x200) { if (x >= x1 && x < x2 && pix != 0 && pix != 15) *(pPixel+x) = (pix | color | COLOR_BASE) & 0xfff; x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 8) & 0xf; while (xacc < 0x200) { if (x >= x1 && x < x2 && pix != 0 && pix != 15) *(pPixel+x) = (pix | color | COLOR_BASE) & 0xfff; x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 12) & 0xf; while (xacc < 0x200) { if (x >= x1 && x < x2 && pix != 0 && pix != 15) *(pPixel+x) = (pix | color | COLOR_BASE) & 0xfff; x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 16) & 0xf; while (xacc < 0x200) { if (x >= x1 && x < x2 && pix != 0 && pix != 15) *(pPixel+x) = (pix | color | COLOR_BASE) & 0xfff; x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 20) & 0xf; while (xacc < 0x200) { if (x >= x1 && x < x2 && pix != 0 && pix != 15) *(pPixel+x) = (pix | color | COLOR_BASE) & 0xfff; x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 24) & 0xf; while (xacc < 0x200) { if (x >= x1 && x < x2 && pix != 0 && pix != 15) *(pPixel+x) = (pix | color | COLOR_BASE) & 0xfff;x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ pix = (pixels >> 28) & 0xf; while (xacc < 0x200) { if (x >= x1 && x < x2 && pix != 0 && pix != 15) *(pPixel+x) = (pix | color | COLOR_BASE) & 0xfff; x += xdelta; xacc += hzoom; } xacc -= 0x200;
+ }
// stop if the second-to-last pixel in the group was 0xf
if ((pixels & 0x0f000000) == 0x0f000000)
break;