[BUG]only using last defined colors

[BUG]print(str,x,y) never reached 0
This commit is contained in:
2021-12-03 20:07:46 +01:00
parent a21b66f12a
commit 72412a01bd
2 changed files with 15 additions and 6 deletions

View File

@@ -106,8 +106,9 @@ int main(int argc,char*argv[]) {
for (int y=0; y<screen_height; ++y) { for (int y=0; y<screen_height; ++y) {
for (int x=0; x<screen_width; ++x) { for (int x=0; x<screen_width; ++x) {
const uint32_t ink_color = palette[current_color & 0x0f]; const uint8_t chr_color = COLSCR(x,y);
const uint32_t paper_color = palette[current_color >> 4]; const uint32_t ink_color = palette[chr_color & 0x0f];
const uint32_t paper_color = palette[chr_color >> 4];
const uint8_t chr = CHRSCR(x,y); const uint8_t chr = CHRSCR(x,y);
for (int l=0; l<8; ++l) { for (int l=0; l<8; ++l) {
const uint8_t line = font[chr*8+l]; const uint8_t line = font[chr*8+l];
@@ -156,8 +157,8 @@ void locate(uint8_t x, uint8_t y) {
} }
void print(const char *str, int x, int y) { void print(const char *str, int x, int y) {
if (x > 0) cursor_x = min(x, screen_width-1); if (x >= 0) cursor_x = min(x, screen_width-1);
if (y > 0) cursor_y = min(y, screen_height-1); if (y >= 0) cursor_y = min(y, screen_height-1);
int len = SDL_strlen(str); int len = SDL_strlen(str);
if ((cursor_x+len) > screen_width) len -= ((cursor_x+len) - screen_width); if ((cursor_x+len) > screen_width) len -= ((cursor_x+len) - screen_width);
for (int i=0; i < len; ++i) { for (int i=0; i < len; ++i) {

View File

@@ -5,6 +5,7 @@ function init()
end end
function update() function update()
paper(COLOR_BLACK)
cls() cls()
x = x + dx x = x + dx
y = y + dy y = y + dy
@@ -14,6 +15,13 @@ function update()
if y == 29 or y == 0 then if y == 29 or y == 0 then
dy = -dy dy = -dy
end end
locate(x, y) locate(2, 2)
print("\224") paper(COLOR_GREEN)
ink(COLOR_BLACK)
print("HOLA!")
--locate(x, y)
ink(COLOR_RED)
paper(COLOR_YELLOW)
print("\224", x, y)
end end