NoiseByNorthwest / term-mode7

SNES's mode7 like rendering in a terminal
MIT License
27 stars 1 forks source link

sixel mode ? #1

Open stuaxo opened 6 years ago

stuaxo commented 6 years ago

Any chance of supporting sixel ? It could look even more awesome that way.

e.g. http://saitoha.github.io/libsixel/

NoiseByNorthwest commented 6 years ago

Yes I agree :) But I dont know if I will make changes to this demo, and if so I probably will not break compatibility with common terminals.

saitoha commented 6 years ago

patch: https://gist.github.com/saitoha/6622d20a4e4e49fd7d2beaf2bfdb4930 demo: https://youtu.be/YyRxkPMIBXk

Requesting Primary DA(https://www.vt100.net/docs/vt510-rm/DA1) to the terminal is most common way for testing sixel mode availability.

stuaxo commented 6 years ago

Awesome, it looks better than I imagined :)

There seems to be some slight colour banding effect on the demo (watch the youtube video especially the line where these purple bits are) - are they meant to be there?

image

saitoha commented 6 years ago

try:

diff --git a/main.c b/main.c
index 12c7890..98010a9 100644
--- a/main.c
+++ b/main.c
@@ -169,7 +169,7 @@ int main()
     size_t current_map = 0;

     size_t color_count = maps[current_map].default_color_count;
-    size_t mipmap_count = 5;
+    size_t mipmap_count = 1;
     texture_t * texture = texture_create(
         maps[current_map].file_name,
         color_count,
saitoha commented 6 years ago

Sorry, additionary some stupid bugs are found.

diff --git a/main.c b/main.c
index 12c7890..7ffd3d2 100644
--- a/main.c
+++ b/main.c
@@ -16,6 +16,8 @@
 static const size_t pixbuf_width = 640;
 static const size_t pixbuf_height = 360;
 unsigned char pixbuf[pixbuf_width * pixbuf_height];
+static const size_t default_mipmap_count_sixel = 1;
+static const size_t default_mipmap_count_character = 5;
 #endif /* HAVE_SIXEL */

 static void terminate_ncurses(void);
@@ -125,9 +127,9 @@ output_sixel(uint8_t colors[][4])
     if (SIXEL_FAILED(status))
         goto end;
     for (i = 0; i < 256; ++i) {
-       palette[i * 3 + 0] = colors[i * 4][0];
-       palette[i * 3 + 1] = colors[i * 4][1];
-       palette[i * 3 + 2] = colors[i * 4][2];
+       palette[i * 3 + 0] = colors[i][0];
+       palette[i * 3 + 1] = colors[i][1];
+       palette[i * 3 + 2] = colors[i][2];
     }
     sixel_dither_set_palette(dither, (unsigned char *)palette);
     if (SIXEL_FAILED(status))
@@ -169,7 +171,11 @@ int main()
     size_t current_map = 0;

     size_t color_count = maps[current_map].default_color_count;
-    size_t mipmap_count = 5;
+#if HAVE_SIXEL
+    size_t mipmap_count = default_mipmap_count_sixel;
+#else
+    size_t mipmap_count = default_mipmap_count_character;
+#endif /* HAVE_SIXEL */
     texture_t * texture = texture_create(
         maps[current_map].file_name,
         color_count,
@@ -357,7 +363,12 @@ int main()
                     }

                     color_count = maps[current_map].default_color_count;
-                    mipmap_count = 5;
+                    mipmap_count = default_mipmap_count_character;
+#if HAVE_SIXEL
+                    if (current_renderer == 3) { /* sixel */
+                        mipmap_count = default_mipmap_count_sixel;
+                    }
+#endif /* HAVE_SIXEL */
                 }

                 texture_destroy(texture);
saitoha commented 6 years ago

updated. patch: https://gist.github.com/saitoha/6622d20a4e4e49fd7d2beaf2bfdb4930 demo: https://youtu.be/snHtdvcMK0s

NoiseByNorthwest commented 6 years ago

@saitoha thanks, I'm going to try it

NoiseByNorthwest commented 6 years ago

@saitoha I've added your patch on sixel_support branch (see #2 ) with small additional patches to fix the build. But what I get when I run it is a black screen... Until I switch to another renderer. What are the full requirements to make sixel working ?

stuaxo commented 6 years ago

@saitoha looks really good, those kind of bugs are all too easy in graphics.

saitoha commented 6 years ago

@NoiseByNorthwest I'm guessing your terminal doesn't support sixel or isn't enabled sixel feature. See: https://github.com/saitoha/libsixel#terminal-requirements