~rabbits/nasu

efa7edd8758fbd91b2f7b4482fdac7c71cf3b9e2 — neauoire 2 years ago 3ae7524
Added drawing modes to UI
1 files changed, 35 insertions(+), 12 deletions(-)

M nasu.c
M nasu.c => nasu.c +35 -12
@@ 41,6 41,13 @@ Brush brush;

unsigned char icon0[] = {0x38, 0x7c, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x00};
unsigned char icon1[] = {0x38, 0x44, 0x82, 0x82, 0x82, 0x44, 0x38, 0x00};
unsigned char icon2[] = {0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x00};
unsigned char icon3[] = {0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00};
unsigned char icon4[] = {0xaa, 0x54, 0xaa, 0x54, 0xaa, 0x54, 0xaa, 0x00};
unsigned char icon5[] = {0x38, 0x7c, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x00};
unsigned char icon6[] = {0xfe, 0x00, 0xfe, 0x00, 0xfe, 0x00, 0xfe, 0x00};
unsigned char icon7[] = {0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x00};
unsigned char icon8[] = {0x92, 0x54, 0x00, 0xc6, 0x00, 0x54, 0x92, 0x00};

/* helpers */



@@ 95,6 102,14 @@ getclr(int r, int g, int b)

/* chr */

void
newchr(void)
{
	int i;
	for(i = 0; i < SZ; ++i)
		chrbuf[i] = 0x00;
}

int
rowchr(int x, int y)
{


@@ 120,15 135,17 @@ void
putchr(int x, int y, int color)
{
	int r = rowchr(x, y), px = x % 8;
	if(r < 0 || r > SZ - 8)
	if(x < 0 || x > HOR * 8)
		return;
	if(y < 0 || y > VER * 8)
		return;
	if(!color) {
		chrbuf[r] &= ~(1UL << (7 - px));
		chrbuf[r + 8] &= ~(1UL << (7 - px));
	} else if(color == 2) {
	} else if(color == 1) {
		chrbuf[r] |= 1UL << (7 - px);
		chrbuf[r + 8] &= ~(1UL << (7 - px));
	} else if(color == 1) {
	} else if(color == 2) {
		chrbuf[r] &= ~(1UL << (7 - px));
		chrbuf[r + 8] |= 1UL << (7 - px);
	} else if(color == 3) {


@@ 137,14 154,6 @@ putchr(int x, int y, int color)
	}
}

void
newchr(void)
{
	int i;
	for(i = 0; i < SZ; ++i)
		chrbuf[i] = 0x00;
}

int
jagg(int x, int y)
{


@@ 268,6 277,13 @@ drawui(Uint32 *dst)
	drawicon(dst, 0, bottom, brush.color == 1 ? icon1 : icon0, theme[1]);
	drawicon(dst, 8, bottom, brush.color == 2 ? icon1 : icon0, theme[2]);
	drawicon(dst, 16, bottom, brush.color == 3 ? icon1 : icon0, theme[3]);
	drawicon(dst, 4 * 8, bottom, icon2, theme[brush.mode == 0 ? 2 : 3]);
	drawicon(dst, 5 * 8, bottom, icon3, theme[brush.mode == 1 ? 2 : 3]);
	drawicon(dst, 6 * 8, bottom, icon4, theme[brush.mode == 2 ? 2 : 3]);
	drawicon(dst, 7 * 8, bottom, icon5, theme[brush.mode == 3 ? 2 : 3]);
	drawicon(dst, 8 * 8, bottom, icon6, theme[brush.mode == 4 ? 2 : 3]);
	drawicon(dst, 9 * 8, bottom, icon7, theme[brush.mode == 5 ? 2 : 3]);
	drawicon(dst, 10 * 8, bottom, icon8, theme[brush.mode == 7 ? 2 : 3]);
}

void


@@ 297,7 313,7 @@ error(char *msg, const char *err)
void
modzoom(int mod)
{
	if((mod > 0 && ZOOM < 4) || (mod < 0 && ZOOM > 1)) {
	if((mod > 0 && ZOOM < 5) || (mod < 0 && ZOOM > 1)) {
		ZOOM += mod;
		SDL_SetWindowSize(gWindow, WIDTH * ZOOM, HEIGHT * ZOOM);
	}


@@ 427,6 443,13 @@ selectoption(int option)
	case 0: setcolor(&brush, 1); break;
	case 1: setcolor(&brush, 2); break;
	case 2: setcolor(&brush, 3); break;
	case 4: setmode(&brush, 0); break;
	case 5: setmode(&brush, 1); break;
	case 6: setmode(&brush, 2); break;
	case 7: setmode(&brush, 3); break;
	case 8: setmode(&brush, 4); break;
	case 9: setmode(&brush, 5); break;
	case 10: setmode(&brush, 7); break;
	}
}