summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPixel <Pixel>2002-10-08 09:19:36 +0000
committerPixel <Pixel>2002-10-08 09:19:36 +0000
commitb90141c6a440f7fd85abec5e46be8a1cdf896191 (patch)
tree62c5ddd6f29a4fff8feb845b362a7dc5e22a299a
parent4117003f640503c666e620cf6d70e80f23261ae1 (diff)
Still working...
-rw-r--r--ffx-convert.cpp65
1 files changed, 61 insertions, 4 deletions
diff --git a/ffx-convert.cpp b/ffx-convert.cpp
index f310b92..fc1cf69 100644
--- a/ffx-convert.cpp
+++ b/ffx-convert.cpp
@@ -10,12 +10,54 @@ int IMG_SX = 128, IMG_SY = 128, BLOC_SX = 128, BLOC_SY = 128;
int do_swap = 0;
+Uint8 * pixels;
+
CODE_BEGINS
Color LookUp(char i) {
return Color(i << 4, i << 4, i << 4, 255);
}
+void countdown(int o_x, int o_y, int size, int * counter, int * a_x, int * a_y) {
+ if (*counter) {
+ if (size != 1) {
+ int hs = size >> 1;
+ countdown(o_x, o_y, hs, counter, a_x, a_y);
+ if (!*counter)
+ return;
+ countdown(o_x, o_y + hs, hs, counter, a_x, a_y);
+ if (!*counter)
+ return;
+ countdown(o_x + hs, o_y, hs, counter, a_x, a_y);
+ if (!*counter)
+ return;
+ countdown(o_x + hs, o_y + hs, hs, counter, a_x, a_y);
+ } else {
+ *counter = *counter - 1;
+ *a_x = o_x;
+ *a_y = o_y;
+ }
+ }
+}
+
+void putpixel(int x, int y, Color C) {
+ pixels[(y * IMG_SX * 2 + x) * 3 + 0] = C.R;
+ pixels[(y * IMG_SX * 2 + x) * 3 + 1] = C.G;
+ pixels[(y * IMG_SX * 2 + x) * 3 + 2] = C.B;
+}
+
+void drawhline(int y, Color C) {
+ for (int i = 0; i < (IMG_SX << 1); i++) {
+ putpixel(i, y, C);
+ }
+}
+
+void drawvline(int x, Color C) {
+ for (int i = 0; i < (IMG_SY << 1); i++) {
+ putpixel(x, i, C);
+ }
+}
+
int transform(int x, int y) {
int numero_bloc_x = x / BLOC_SX;
@@ -23,6 +65,13 @@ int transform(int x, int y) {
int numero_bloc = numero_bloc_y * (IMG_SX / BLOC_SX) + numero_bloc_x;
+ if (do_swap) {
+ if ((BLOC_SX == BLOC_SY) || ((BLOC_SX >> 1) == BLOC_SY)) {
+ countdown(0, 0, IMG_SY / BLOC_SY, &numero_bloc, &numero_bloc_x, &numero_bloc_y);
+ numero_bloc = numero_bloc_y * (IMG_SX / BLOC_SX) + numero_bloc_x;
+ }
+ }
+
int bx = x % BLOC_SX;
int by = y % BLOC_SY;
@@ -35,7 +84,7 @@ int transform(int x, int y) {
virtual int startup() throw (GeneralException) {
int c;
- if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) < 0) {
+ if (SDL_Init(SDL_INIT_VIDEO) < 0) {
printm(M_ERROR, "Couldn't initialise SDL: %s\n", SDL_GetError());
exit(-1);
}
@@ -89,14 +138,14 @@ virtual int startup() throw (GeneralException) {
exit(-1);
}
+ pixels = ((Uint8 *) screen->pixels);
SDL_Event event;
bool exitting = false;
while (!exitting) {
- Uint8 * pixels = ((Uint8 *) screen->pixels);
- for (int y = 0; y < IMG_SX; y++) {
- for (int x = 0; x < IMG_SY; x++) {
+ for (int y = 0; y < IMG_SY; y++) {
+ for (int x = 0; x < IMG_SX; x++) {
Color c = LookUp(buffer[transform(x, y)]);
pixels[((y * 2 + 0) * IMG_SX * 2 + (x * 2 + 0)) * 3 + 0] = c.R;
pixels[((y * 2 + 0) * IMG_SX * 2 + (x * 2 + 0)) * 3 + 1] = c.G;
@@ -117,6 +166,14 @@ virtual int startup() throw (GeneralException) {
}
}
+ for (int x = 0; x < IMG_SX; x += BLOC_SX) {
+ drawvline(x << 1, Color(255, 255, 0));
+ }
+
+ for (int y = 0; y < IMG_SY; y += BLOC_SY) {
+ drawhline(y << 1, Color(255, 255, 0));
+ }
+
SDL_Flip(screen);
SDL_WaitEvent(&event);