mirror of
https://github.com/JorjBauer/aiie.git
synced 2025-01-29 21:31:10 +00:00
convert primitive drawing routines to macros
This commit is contained in:
parent
368b385ccf
commit
691b2de8bb
@ -30,6 +30,35 @@
|
||||
} \
|
||||
}
|
||||
|
||||
#define drawPixel(c, x, y) { \
|
||||
uint16_t idx = ((y) * DISPLAYWIDTH + (x)) / 2; \
|
||||
if ((x) & 1) { \
|
||||
videoBuffer[idx] = (videoBuffer[idx] & 0xF0) | (c); \
|
||||
} else { \
|
||||
videoBuffer[idx] = (videoBuffer[idx] & 0x0F) | ((c) << 4); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define draw2Pixels(cAB, x, y) { \
|
||||
videoBuffer[((y) * DISPLAYWIDTH + (x)) /2] = cAB; \
|
||||
}
|
||||
|
||||
|
||||
#define DrawLoresPixelAt(c, x, y) { \
|
||||
uint8_t pixel = c & 0x0F; \
|
||||
for (uint8_t y2 = 0; y2<4; y2++) { \
|
||||
for (int8_t x2 = 6; x2>=0; x2--) { \
|
||||
drawPixel(pixel, x*7+x2, y*8+y2); \
|
||||
} \
|
||||
} \
|
||||
pixel = (c >> 4); \
|
||||
for (uint8_t y2 = 4; y2<8; y2++) { \
|
||||
for (int8_t x2 = 6; x2>=0; x2--) { \
|
||||
drawPixel(pixel, x*7+x2, y*8+y2); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
AppleDisplay::AppleDisplay(uint8_t *vb) : VMDisplay(vb)
|
||||
@ -490,7 +519,7 @@ void AppleDisplay::modeChange()
|
||||
|
||||
void AppleDisplay::Draw80LoresPixelAt(uint8_t c, uint8_t x, uint8_t y, uint8_t offset)
|
||||
{
|
||||
// Just like 80-column text, this has a minor problem; we're talimg
|
||||
// Just like 80-column text, this has a minor problem; we're taking
|
||||
// a 7-pixel-wide space and dividing it in half. Here I'm drawing
|
||||
// every other column 1 pixel narrower (the ">= offset" in the for
|
||||
// loop condition).
|
||||
@ -517,40 +546,6 @@ void AppleDisplay::Draw80LoresPixelAt(uint8_t c, uint8_t x, uint8_t y, uint8_t o
|
||||
}
|
||||
}
|
||||
|
||||
// col, row are still character-like positions, as in DrawCharacterAt.
|
||||
// Each holds two pixels (one on top of the other).
|
||||
void AppleDisplay::DrawLoresPixelAt(uint8_t c, uint8_t x, uint8_t y)
|
||||
{
|
||||
uint8_t pixel = c & 0x0F;
|
||||
for (uint8_t y2 = 0; y2<4; y2++) {
|
||||
for (int8_t x2 = 6; x2>=0; x2--) {
|
||||
drawPixel(pixel, x*7+x2, y*8+y2);
|
||||
}
|
||||
}
|
||||
|
||||
pixel = (c >> 4);
|
||||
for (uint8_t y2 = 4; y2<8; y2++) {
|
||||
for (int8_t x2 = 6; x2>=0; x2--) {
|
||||
drawPixel(pixel, x*7+x2, y*8+y2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AppleDisplay::draw2Pixels(uint16_t two4bitColors, uint16_t x, uint8_t y)
|
||||
{
|
||||
videoBuffer[(y * DISPLAYWIDTH + x) /2] = two4bitColors;
|
||||
}
|
||||
|
||||
inline void AppleDisplay::drawPixel(uint8_t color4bit, uint16_t x, uint8_t y)
|
||||
{
|
||||
uint16_t idx = (y * DISPLAYWIDTH + x) / 2;
|
||||
if (x & 1) {
|
||||
videoBuffer[idx] = (videoBuffer[idx] & 0xF0) | color4bit;
|
||||
} else {
|
||||
videoBuffer[idx] = (videoBuffer[idx] & 0x0F) | (color4bit << 4);
|
||||
}
|
||||
}
|
||||
|
||||
void AppleDisplay::setSwitches(uint16_t *switches)
|
||||
{
|
||||
dirty = true;
|
||||
|
@ -58,14 +58,9 @@ class AppleDisplay : public VMDisplay{
|
||||
bool deinterlaceAddress(uint16_t address, uint8_t *row, uint8_t *col);
|
||||
bool deinterlaceHiresAddress(uint16_t address, uint8_t *row, uint16_t *col);
|
||||
|
||||
void Draw80CharacterAt(uint8_t c, uint8_t x, uint8_t y, uint8_t offset);
|
||||
void DrawCharacterAt(uint8_t c, uint8_t x, uint8_t y);
|
||||
void Draw14DoubleHiresPixelsAt(uint16_t address);
|
||||
void Draw14DoubleHiresPixelsAt(uint16_t addr);
|
||||
void Draw14HiresPixelsAt(uint16_t addr);
|
||||
void Draw80LoresPixelAt(uint8_t c, uint8_t x, uint8_t y, uint8_t offset);
|
||||
void DrawLoresPixelAt(uint8_t c, uint8_t x, uint8_t y);
|
||||
void draw2Pixels(uint16_t two4bitColors, uint16_t x, uint8_t y);
|
||||
void drawPixel(uint8_t cidx, uint16_t x, uint8_t y);
|
||||
|
||||
const unsigned char *xlateChar(uint8_t c, bool *invert);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user