|
|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
#include <SDL2/SDL.h> |
|
|
|
|
#include <stdio.h> |
|
|
|
|
|
|
|
|
|
#define HOR 24 |
|
|
|
|
#define HOR 32 |
|
|
|
|
#define VER 16 |
|
|
|
|
#define PAD 32 |
|
|
|
|
#define ZOOM 4 |
|
|
|
|
@ -11,6 +11,8 @@
|
|
|
|
|
#define color4 0x444444 |
|
|
|
|
#define color0 0x111111 |
|
|
|
|
|
|
|
|
|
#define SZ HOR* VER * 16 |
|
|
|
|
|
|
|
|
|
typedef struct Point { |
|
|
|
|
int x; |
|
|
|
|
int y; |
|
|
|
|
@ -36,7 +38,7 @@ char* modes[] = {
|
|
|
|
|
"ver", |
|
|
|
|
"cross"}; |
|
|
|
|
|
|
|
|
|
unsigned char buffer[4096]; |
|
|
|
|
unsigned char buffer[SZ]; |
|
|
|
|
int colors[] = {color1, color2, color3, color4, color0}; |
|
|
|
|
int WIDTH = 8 * HOR * ZOOM + PAD * 2; |
|
|
|
|
int HEIGHT = 8 * VER * ZOOM + PAD * 2; |
|
|
|
|
@ -84,7 +86,7 @@ void
|
|
|
|
|
draw(uint32_t* dst, int id, int color) |
|
|
|
|
{ |
|
|
|
|
int ti = id / 64; |
|
|
|
|
int px = (ti / 256) * (8 * HOR); |
|
|
|
|
int px = (ti / (HOR * VER)) * (8 * HOR); |
|
|
|
|
int tx = (ti % HOR) * 8; |
|
|
|
|
int ty = ((ti / HOR) * 8) % 128; |
|
|
|
|
int odd = (ti + (ti / HOR + 2)) % 2 == 0; |
|
|
|
|
@ -98,7 +100,7 @@ void
|
|
|
|
|
redraw(uint32_t* dst) |
|
|
|
|
{ |
|
|
|
|
int b, i, j, id = 0, ch1, ch2, color; |
|
|
|
|
for(b = 0; b < 4096; b += 16) |
|
|
|
|
for(b = 0; b < SZ; b += 16) |
|
|
|
|
for(i = 0; i < 8; i++) |
|
|
|
|
for(j = 7; j >= 0; j--) { |
|
|
|
|
ch1 = buffer[b + i]; |
|
|
|
|
@ -120,7 +122,7 @@ write(int tx, int ty, int px, int py, int color)
|
|
|
|
|
{ |
|
|
|
|
int id = tx + ty * HOR; |
|
|
|
|
int row = py + id * VER; |
|
|
|
|
if(id > 255) |
|
|
|
|
if(id > HOR * VER) |
|
|
|
|
return; |
|
|
|
|
if(color == 0) { |
|
|
|
|
buffer[row] &= ~(1UL << (7 - px)); |
|
|
|
|
@ -229,7 +231,7 @@ void
|
|
|
|
|
update(Brush* b) |
|
|
|
|
{ |
|
|
|
|
char title[512]; |
|
|
|
|
snprintf(title, 512, "chr6 | c%d %d:%d^%d%c", b->color, HOR, VER, ZOOM, b->edit ? '*' : ' '); |
|
|
|
|
snprintf(title, 512, "chr6 %d | c%d %d:%d^%d%c", b->size, b->color, HOR, VER, ZOOM, b->edit ? '*' : ' '); |
|
|
|
|
SDL_SetWindowTitle(gWindow, title); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -244,7 +246,7 @@ void
|
|
|
|
|
create(void) |
|
|
|
|
{ |
|
|
|
|
int i; |
|
|
|
|
for(i = 0; i < 4096; ++i) |
|
|
|
|
for(i = 0; i < SZ; ++i) |
|
|
|
|
buffer[i] = 0x00; |
|
|
|
|
redraw(pixels); |
|
|
|
|
} |
|
|
|
|
@ -257,7 +259,6 @@ save(Brush* b)
|
|
|
|
|
error("Save", "Invalid output file"); |
|
|
|
|
fclose(f); |
|
|
|
|
b->edit = 0; |
|
|
|
|
update(b); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
@ -348,7 +349,6 @@ dokey(SDL_Event* event, Brush* b)
|
|
|
|
|
break; |
|
|
|
|
case SDLK_TAB: |
|
|
|
|
b->color = b->color > 2 ? 0 : b->color + 1; |
|
|
|
|
update(b); |
|
|
|
|
break; |
|
|
|
|
case SDLK_h: |
|
|
|
|
GUIDES = !GUIDES; |
|
|
|
|
@ -373,7 +373,7 @@ dokey(SDL_Event* event, Brush* b)
|
|
|
|
|
b->size += 1; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
printf("%d\n", b->mode); |
|
|
|
|
update(b); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int |
|
|
|
|
|