Skip to content

Commit

Permalink
[MY] Fix Xcode2 builds
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFakeMontyOnTheRun committed Jun 13, 2024
1 parent 78a70f9 commit dec659f
Showing 1 changed file with 56 additions and 55 deletions.
111 changes: 56 additions & 55 deletions my_frontend/Xcode2/OSXRenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -197,57 +197,76 @@ void clearScreen(void) {
fillRect(0, 0, 255, 192, 0, 0);
}

void writeStrWithLimit(uint8_t _x, uint8_t y, const char *text, uint8_t limitX, uint8_t fg, uint8_t bg) {
uint8_t len = strlen(text);
char *ptr = text;
uint8_t c = 0;
uint8_t x = _x;
int d;

for (; c < len && y < 64; ++c) {

char cha = *ptr;

if (x == limitX) {
++y;
x = _x;
} else if (cha == '\n') {
++y;
x = _x;
++ptr;
void drawTextAtWithMarginWithFiltering(const int x, const int y, int margin, const char *text, const uint8_t fg,
char charToReplaceHifenWith) {

size_t len = strlen(text);
int32_t dstX = x * 8;
int32_t dstY = y * 8;

size_t c;
size_t d;
uint8_t lastSpacePos = 0xFF;

for (c = 0; c < len; ++c) {

char currentChar = text[c];

if (currentChar == '-') {
currentChar = charToReplaceHifenWith;
}

if (currentChar == '\n' || dstX >= (margin)) {
dstX = x * 8;
dstY += 8;
continue;
}

if (cha >= 'a') {
if (cha <= 'z') {
cha = (cha - 'a') + 'A';

if (dstY >= YRES_FRAMEBUFFER) {
return;
}

if (currentChar == ' ') {
lastSpacePos = c;
} else {
if ((c - 1) == lastSpacePos) {
d = c;
while (d < len && text[d] != ' ') ++d;

if ((dstX + ((d - c ) * 8)) >= margin ) {
dstX = x * 8;
dstY += 8;
}
}
}


if (currentChar >= 'a') {
if (currentChar <= 'z') {
currentChar = (currentChar - 'a') + 'A';
} else {
cha -= ('z' - 'a');
currentChar -= ('z' - 'a');
}
}

uint8_t *fontTop = &font[((cha - 32) << 3)];


for (d = 0; d < 8; ++d) {

uint8_t *fontTop = &font[((currentChar - 32) << 3)];

for (int f = 0; f < 8; ++f) {
int e;
uint8_t chunk = *fontTop;

for (e = 0; e < 8; ++e) {
if (chunk & 1) {
realPut(8 * x + (7 - e), 8 * y + (d), 1, NULL);
realPut(dstX + (7 - e), dstY + (f), 1, NULL);
} else {
realPut(8 * x + (7 - e), 8 * y + (d), 0, NULL);
realPut(dstX + (7 - e), dstY + (f), 0, NULL);
}
chunk = chunk >> 1;
}



fontTop++;
}

++x;
++ptr;
dstX += 8;
}
}

Expand All @@ -267,25 +286,7 @@ void flipRenderer(void) {
}
}

void graphicsFlush(void) {
if (updateDirection) {
updateDirection = 0;
switch (getPlayerDirection()) {
case 0:
writeStrWithLimit(12, 17, "N", 31, 2, 0);
break;
case 1:
writeStrWithLimit(12, 17, "E", 31, 2, 0);
break;
case 2:
writeStrWithLimit(12, 17, "S", 31, 2, 0);
break;
case 3:
writeStrWithLimit(12, 17, "W", 31, 2, 0);
break;
}
}

void graphicsFlush(void) {
if (needsToRedrawVisibleMeshes) {
flipRenderer();
clearGraphics();
Expand Down

0 comments on commit dec659f

Please sign in to comment.