From 813c23ad00082e81e58676ae52e26a4802442d86 Mon Sep 17 00:00:00 2001
From: mibi88 <mbcontact50@gmail.com>
Date: Tue, 11 Jul 2023 11:23:27 +0200
Subject: [PATCH 1/8] Dialogs management should work, had not the time to test
 it yet.

---
 src/dialogs.c | 70 ++++++++++++++++++++++++++++++++++++++++++++-------
 src/map.c     | 57 ++++++++++++++++++++---------------------
 src/map.h     |  4 +--
 3 files changed, 90 insertions(+), 41 deletions(-)

diff --git a/src/dialogs.c b/src/dialogs.c
index b4cb299..abc7ba3 100644
--- a/src/dialogs.c
+++ b/src/dialogs.c
@@ -6,10 +6,15 @@
 #define BOX_HEIGHT (F_HEIGHT/PXSIZE+8)
 
 extern font_t fontRPG;
+#define FONT_USED fontRPG
 
 void showtext(Game *game, bopti_image_t *face, char *text) {
-    dfont(&fontRPG);
-    unsigned int i;
+    dfont(&FONT_USED);
+    unsigned int i, n, y = 1, l = 0;
+    int line_max_chars;
+    unsigned int max_lines_amount = BOX_HEIGHT/(FONT_USED.line_height +
+                                    FONT_USED.char_spacing);
+    /* Run a little fancy animation. */
     for(i=0;i<BOX_HEIGHT;i++){
         draw(game);
         drect(0, 0, DWIDTH, i*PXSIZE, C_WHITE);
@@ -24,13 +29,62 @@ void showtext(Game *game, bopti_image_t *face, char *text) {
      * drawing on the face. */
     /* Show a little message that showing text in dialogs is not implemented
      * yet. */
-    dtext(BOX_HEIGHT*PXSIZE, 1, C_BLACK, "Dialogs not implemented");
-    dtext(BOX_HEIGHT*PXSIZE, 8*PXSIZE, C_BLACK, "Press any key");
-    dupdate();
-    getkey();
     for(i=0;i<strlen(text);i++){
-        /**/
+        /* Get how many chars we can draw on screen with a padding on the left
+         * and on the right of 1 px. */
+        drsize(text+i, &FONT_USED, DWIDTH-2, &line_max_chars);
+        /* TODO: Handle lines that are longer than what I can draw. */
+        /* Loop from the end to the start for word wrap. */
+        for(n=line_max_chars; n>0; n--) {
+            /* If we found a space, we can draw this line and do the same for
+             * the next line. */
+            if(text[i+n] == ' '){
+                dtext_opt(1, y, C_BLACK, C_NONE, DTEXT_TOP, DTEXT_LEFT, text+i,
+                          n); /* Draw everything. */
+                /* Increment y by the line height plus the space between them.
+                 */
+                y += FONT_USED.line_height+FONT_USED.char_spacing;
+                i += n; /* We drew everything to i+n */
+                l++; /* We drew one more line. */
+                break;
+            }
+        }
+        if(l>=max_lines_amount-1){
+            /* We drew one entire screen, reset everything to draw the next one.
+             */
+            /* Make a little animation :). */
+            dupdate();
+            while(game->frame_duration < 20) sleep();
+            game->frame_duration = 0;
+            /* Ask the user to press EXE to continue. */
+            dtext(1, y, C_BLACK, "[EXE] To continue ...");
+            /* Reset y and l. */
+            y = 1;
+            l = 0;
+            /* Clear the screen. */
+            drect(0, i*PXSIZE, DWIDTH, (i+1)*PXSIZE, C_BLACK);
+        }
+        /* Make a little animation :). */
+        dupdate();
+        if(l>=max_lines_amount-1){
+            while(getkey().key != KEY_EXE) sleep();
+        }
+        else{
+            while(game->frame_duration < 20) sleep();
+        }
+        game->frame_duration = 0;
     }
+    if(l<max_lines_amount-1){
+        /* If we have not filled everthing with text at the end. */
+        /* Make a little animation :). */
+        dupdate();
+        while(game->frame_duration < 20) sleep();
+        game->frame_duration = 0;
+        /* Ask the user to press EXE to continue. */
+        dtext(1, y, C_BLACK, "[EXE] To continue ...");
+        while(getkey().key != KEY_EXE) sleep();
+    }
+    /* Run another little fancy animation. */
     for(i=40;i>0;i--){
         draw(game);
         drect(0, 0, DWIDTH, i*PXSIZE, C_WHITE);
@@ -42,5 +96,3 @@ void showtext(Game *game, bopti_image_t *face, char *text) {
         game->frame_duration = 0;
     }
 }
-
-
diff --git a/src/map.c b/src/map.c
index e80fe10..361e592 100644
--- a/src/map.c
+++ b/src/map.c
@@ -26,6 +26,8 @@ void render_map(Player *player, Map *map_level) {
     unsigned short int xtile, ytile;
     /* The layer we're drawing */
     unsigned char l;
+    /* The index of the current tile we're drawing in the layer. */
+    int current_index;
     /* Fix sx. */
     if(player->x<DWIDTH/2){
         /* If I can't center the player because I'm near the left border of
@@ -62,7 +64,6 @@ void render_map(Player *player, Map *map_level) {
     ty = sy/T_HEIGHT;
     mx = sx-tx*T_WIDTH;
     my = sy-ty*T_HEIGHT;
-
     for (l = 0; l < map_level->nblayers-1; l++){
         /* Draw a layer of the map on screen. */
         for(y=0;y<dh;y++){
@@ -72,10 +73,10 @@ void render_map(Player *player, Map *map_level) {
                 if(tx+x>=0 && tx+x < map_level->w &&
                    ty+y>=0 && ty+y < map_level->h){
                     /* index of the current tile */
-                    int currentIndex = (y+ty) * map_level->w + tx+x;
+                    current_index = (y+ty) * map_level->w + tx+x;
                     /* we get the ID of the tile in the current drawable layers
                      */
-                    tile = map_level->layers[l][currentIndex];
+                    tile = map_level->layers[l][current_index];
                    
                     /* tile == -1 means nothing to be drawn */
                     if(tile >= 0){
@@ -115,8 +116,6 @@ void render_map_by_layer(Player *player, Map *map_level, int layer) {
     unsigned short int sx, sy;
     /* The position of the tile in the tileset. */
     unsigned short int xtile, ytile;
-    /* The layer we're drawing */
-    unsigned char l;
     /* Fix sx. */
     if(player->x<DWIDTH/2){
         /* If I can't center the player because I'm near the left border of
@@ -153,34 +152,32 @@ void render_map_by_layer(Player *player, Map *map_level, int layer) {
     ty = sy/T_HEIGHT;
     mx = sx-tx*T_WIDTH;
     my = sy-ty*T_HEIGHT;
-
-
-        /* Draw a layer of the map on screen. */
-        for(y=0;y<dh;y++){
-            for(x=0;x<dw;x++){
-                /* I get the tile number if his position is inside the map. Then
-                 * I draw it. */
-                if(tx+x>=0 && tx+x < map_level->w &&
-                   ty+y>=0 && ty+y < map_level->h){
-                    /* index of the current tile */
-                    int currentIndex = (y+ty) * map_level->w + tx+x;
-                    /* we get the ID of the tile in the current drawable layers
-                     */
-                    tile = map_level->layers[layer][currentIndex];
-                   
-                    /* tile == -1 means nothing to be drawn */
-                    if(tile >= 0){
-                        /* get x and y position in the tileset image */
-                        xtile = (tile % map_level->tileset_size) * T_WIDTH;
-                        ytile = (tile / map_level->tileset_size) * T_HEIGHT;
-                        /* render */
-                        dsubimage(x*T_WIDTH-mx, y*T_HEIGHT-my,
-                                  map_level->tileset, xtile, ytile, T_WIDTH,
-                                  T_HEIGHT, DIMAGE_NONE);
-                    }
+    /* Draw a layer of the map on screen. */
+    for(y=0;y<dh;y++){
+        for(x=0;x<dw;x++){
+            /* I get the tile number if his position is inside the map. Then
+                * I draw it. */
+            if(tx+x>=0 && tx+x < map_level->w &&
+                ty+y>=0 && ty+y < map_level->h){
+                /* index of the current tile */
+                int currentIndex = (y+ty) * map_level->w + tx+x;
+                /* we get the ID of the tile in the current drawable layers
+                    */
+                tile = map_level->layers[layer][currentIndex];
+                
+                /* tile == -1 means nothing to be drawn */
+                if(tile >= 0){
+                    /* get x and y position in the tileset image */
+                    xtile = (tile % map_level->tileset_size) * T_WIDTH;
+                    ytile = (tile / map_level->tileset_size) * T_HEIGHT;
+                    /* render */
+                    dsubimage(x*T_WIDTH-mx, y*T_HEIGHT-my,
+                                map_level->tileset, xtile, ytile, T_WIDTH,
+                                T_HEIGHT, DIMAGE_NONE);
                 }
             }
         }
+    }
 }
 
 
diff --git a/src/map.h b/src/map.h
index be18c01..37d3eef 100644
--- a/src/map.h
+++ b/src/map.h
@@ -28,7 +28,8 @@
 /* Draws the map map on the entire screen to be viewed by the player player. */
 void render_map(Player *player, Map *map_level);
 
-/* Draws the map layer on the entire screen to be viewed by the player player. */
+/* Draws the map layer on the entire screen to be viewed by the player player.
+ */
 void render_map_by_layer(Player *player, Map *map_level, int layer);
 
 /* Get the tile at (x, y) of the map map. If the tile is located outside of the
@@ -39,4 +40,3 @@ short int get_tile(Map *map_level, int x, int y, int l);
 short int get_walkable(Map *map_level, int x, int y);
 
 #endif
-

From dc2a0b1473fd097a31bb98aa5c2caf5c8c355b7a Mon Sep 17 00:00:00 2001
From: mibi88 <mbcontact50@gmail.com>
Date: Tue, 11 Jul 2023 13:29:48 +0200
Subject: [PATCH 2/8] Continued improving it.

---
 src/dialogs.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/src/dialogs.c b/src/dialogs.c
index abc7ba3..ced3569 100644
--- a/src/dialogs.c
+++ b/src/dialogs.c
@@ -12,8 +12,8 @@ void showtext(Game *game, bopti_image_t *face, char *text) {
     dfont(&FONT_USED);
     unsigned int i, n, y = 1, l = 0;
     int line_max_chars;
-    unsigned int max_lines_amount = BOX_HEIGHT/(FONT_USED.line_height +
-                                    FONT_USED.char_spacing);
+    unsigned int max_lines_amount = BOX_HEIGHT/FONT_USED.line_height;
+    const char *c;
     /* Run a little fancy animation. */
     for(i=0;i<BOX_HEIGHT;i++){
         draw(game);
@@ -31,19 +31,20 @@ void showtext(Game *game, bopti_image_t *face, char *text) {
      * yet. */
     for(i=0;i<strlen(text);i++){
         /* Get how many chars we can draw on screen with a padding on the left
-         * and on the right of 1 px. */
-        drsize(text+i, &FONT_USED, DWIDTH-2, &line_max_chars);
+         * of BOX_HEIGHT px and on the right of 1 px. */
+        c = drsize(text+i, &FONT_USED, DWIDTH-(BOX_HEIGHT*PXSIZE+PXSIZE), NULL);
+        /* c is a pointer to the last char that can be drawn. So: */
+        line_max_chars = c-(text+i);
         /* TODO: Handle lines that are longer than what I can draw. */
         /* Loop from the end to the start for word wrap. */
         for(n=line_max_chars; n>0; n--) {
             /* If we found a space, we can draw this line and do the same for
              * the next line. */
             if(text[i+n] == ' '){
-                dtext_opt(1, y, C_BLACK, C_NONE, DTEXT_TOP, DTEXT_LEFT, text+i,
-                          n); /* Draw everything. */
-                /* Increment y by the line height plus the space between them.
-                 */
-                y += FONT_USED.line_height+FONT_USED.char_spacing;
+                dtext_opt(BOX_HEIGHT, y, C_BLACK, C_NONE, DTEXT_TOP, DTEXT_LEFT,
+                          text+i, n); /* Draw everything. */
+                /* Increment y by the line height. */
+                y += FONT_USED.line_height;
                 i += n; /* We drew everything to i+n */
                 l++; /* We drew one more line. */
                 break;
@@ -57,17 +58,17 @@ void showtext(Game *game, bopti_image_t *face, char *text) {
             while(game->frame_duration < 20) sleep();
             game->frame_duration = 0;
             /* Ask the user to press EXE to continue. */
-            dtext(1, y, C_BLACK, "[EXE] To continue ...");
-            /* Reset y and l. */
-            y = 1;
-            l = 0;
+            dtext(BOX_HEIGHT, y, C_BLACK, "[EXE] to continue ...");
             /* Clear the screen. */
-            drect(0, i*PXSIZE, DWIDTH, (i+1)*PXSIZE, C_BLACK);
+            drect(0, 0, DWIDTH, BOX_HEIGHT*PXSIZE, C_WHITE);
         }
         /* Make a little animation :). */
         dupdate();
         if(l>=max_lines_amount-1){
             while(getkey().key != KEY_EXE) sleep();
+            /* Reset y and l. */
+            y = 1;
+            l = 0;
         }
         else{
             while(game->frame_duration < 20) sleep();

From 6fa6f03c1a253cce801c34817cb7097c2e8f35c2 Mon Sep 17 00:00:00 2001
From: mibi88 <mbcontact50@gmail.com>
Date: Tue, 11 Jul 2023 13:46:18 +0200
Subject: [PATCH 3/8] More improvements but something is still buggy :/

---
 src/dialogs.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/dialogs.c b/src/dialogs.c
index ced3569..055c341 100644
--- a/src/dialogs.c
+++ b/src/dialogs.c
@@ -55,23 +55,23 @@ void showtext(Game *game, bopti_image_t *face, char *text) {
              */
             /* Make a little animation :). */
             dupdate();
-            while(game->frame_duration < 20) sleep();
+            while(game->frame_duration < 100) sleep();
             game->frame_duration = 0;
             /* Ask the user to press EXE to continue. */
             dtext(BOX_HEIGHT, y, C_BLACK, "[EXE] to continue ...");
-            /* Clear the screen. */
-            drect(0, 0, DWIDTH, BOX_HEIGHT*PXSIZE, C_WHITE);
         }
         /* Make a little animation :). */
         dupdate();
         if(l>=max_lines_amount-1){
             while(getkey().key != KEY_EXE) sleep();
+            /* Clear the screen. */
+            drect(BOX_HEIGHT*PXSIZE, 0, DWIDTH, (BOX_HEIGHT-1)*PXSIZE, C_WHITE);
             /* Reset y and l. */
             y = 1;
             l = 0;
         }
         else{
-            while(game->frame_duration < 20) sleep();
+            while(game->frame_duration < 100) sleep();
         }
         game->frame_duration = 0;
     }
@@ -79,7 +79,7 @@ void showtext(Game *game, bopti_image_t *face, char *text) {
         /* If we have not filled everthing with text at the end. */
         /* Make a little animation :). */
         dupdate();
-        while(game->frame_duration < 20) sleep();
+        while(game->frame_duration < 100) sleep();
         game->frame_duration = 0;
         /* Ask the user to press EXE to continue. */
         dtext(1, y, C_BLACK, "[EXE] To continue ...");

From 4956d0de317e2b660c857bd769777dd4789580a2 Mon Sep 17 00:00:00 2001
From: mibi88 <mbcontact50@gmail.com>
Date: Tue, 11 Jul 2023 23:32:09 +0200
Subject: [PATCH 4/8] Fixed a displaying bug (thanks Slyvtt !)

---
 src/dialogs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/dialogs.c b/src/dialogs.c
index 055c341..fa93bdb 100644
--- a/src/dialogs.c
+++ b/src/dialogs.c
@@ -12,7 +12,7 @@ void showtext(Game *game, bopti_image_t *face, char *text) {
     dfont(&FONT_USED);
     unsigned int i, n, y = 1, l = 0;
     int line_max_chars;
-    unsigned int max_lines_amount = BOX_HEIGHT/FONT_USED.line_height;
+    unsigned int max_lines_amount = (BOX_HEIGHT-1)/FONT_USED.line_height;
     const char *c;
     /* Run a little fancy animation. */
     for(i=0;i<BOX_HEIGHT;i++){
@@ -41,7 +41,7 @@ void showtext(Game *game, bopti_image_t *face, char *text) {
             /* If we found a space, we can draw this line and do the same for
              * the next line. */
             if(text[i+n] == ' '){
-                dtext_opt(BOX_HEIGHT, y, C_BLACK, C_NONE, DTEXT_TOP, DTEXT_LEFT,
+                dtext_opt(BOX_HEIGHT, y, C_BLACK, C_NONE, DTEXT_LEFT, DTEXT_TOP,
                           text+i, n); /* Draw everything. */
                 /* Increment y by the line height. */
                 y += FONT_USED.line_height;

From ca69693c5cfb118ec8e289a1ace3cc47e0de7cdc Mon Sep 17 00:00:00 2001
From: mibi88 <mbcontact50@gmail.com>
Date: Wed, 12 Jul 2023 11:44:41 +0200
Subject: [PATCH 5/8] Fixed a little typo

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index ed58c27..311003c 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@ A ce stade, on a déjà implémenté :
 - [x] Personnage
 - [ ] Dialogues
 - [ ] Fontes de caractères
-- [ ] Interraction
+- [ ] Interaction
 - [ ] NPC
 - [ ] Changement de map
 

From 4e06ddce105a2588856ad5d9199b33bd6201bd7a Mon Sep 17 00:00:00 2001
From: mibi88 <mbcontact50@gmail.com>
Date: Wed, 12 Jul 2023 12:42:28 +0200
Subject: [PATCH 6/8] Dialogs displaying now works on cg!

---
 src/dialogs.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/dialogs.c b/src/dialogs.c
index fa93bdb..cb11bbc 100644
--- a/src/dialogs.c
+++ b/src/dialogs.c
@@ -10,9 +10,10 @@ extern font_t fontRPG;
 
 void showtext(Game *game, bopti_image_t *face, char *text) {
     dfont(&FONT_USED);
-    unsigned int i, n, y = 1, l = 0;
+    unsigned int i, n, y = PXSIZE, l = 0;
     int line_max_chars;
-    unsigned int max_lines_amount = (BOX_HEIGHT-1)/FONT_USED.line_height;
+    unsigned int max_lines_amount = (BOX_HEIGHT-2)*PXSIZE/
+                                    (FONT_USED.line_height+PXSIZE);
     const char *c;
     /* Run a little fancy animation. */
     for(i=0;i<BOX_HEIGHT;i++){
@@ -41,10 +42,10 @@ void showtext(Game *game, bopti_image_t *face, char *text) {
             /* If we found a space, we can draw this line and do the same for
              * the next line. */
             if(text[i+n] == ' '){
-                dtext_opt(BOX_HEIGHT, y, C_BLACK, C_NONE, DTEXT_LEFT, DTEXT_TOP,
-                          text+i, n); /* Draw everything. */
+                dtext_opt(BOX_HEIGHT*PXSIZE, y, C_BLACK, C_NONE, DTEXT_LEFT,
+                          DTEXT_TOP, text+i, n); /* Draw everything. */
                 /* Increment y by the line height. */
-                y += FONT_USED.line_height;
+                y += FONT_USED.line_height+PXSIZE;
                 i += n; /* We drew everything to i+n */
                 l++; /* We drew one more line. */
                 break;
@@ -55,31 +56,32 @@ void showtext(Game *game, bopti_image_t *face, char *text) {
              */
             /* Make a little animation :). */
             dupdate();
-            while(game->frame_duration < 100) sleep();
+            while(game->frame_duration < 1000) sleep();
             game->frame_duration = 0;
             /* Ask the user to press EXE to continue. */
-            dtext(BOX_HEIGHT, y, C_BLACK, "[EXE] to continue ...");
+            dtext(BOX_HEIGHT*PXSIZE, y, C_BLACK, "[EXE] to continue ...");
         }
         /* Make a little animation :). */
         dupdate();
         if(l>=max_lines_amount-1){
             while(getkey().key != KEY_EXE) sleep();
             /* Clear the screen. */
-            drect(BOX_HEIGHT*PXSIZE, 0, DWIDTH, (BOX_HEIGHT-1)*PXSIZE, C_WHITE);
+            drect(BOX_HEIGHT*PXSIZE, 0, DWIDTH, (BOX_HEIGHT-1)*PXSIZE-1,
+                  C_WHITE);
             /* Reset y and l. */
-            y = 1;
+            y = PXSIZE;
             l = 0;
         }
         else{
-            while(game->frame_duration < 100) sleep();
+            while(game->frame_duration < 1000) sleep();
+            game->frame_duration = 0;
         }
-        game->frame_duration = 0;
     }
     if(l<max_lines_amount-1){
         /* If we have not filled everthing with text at the end. */
         /* Make a little animation :). */
         dupdate();
-        while(game->frame_duration < 100) sleep();
+        while(game->frame_duration < 1000) sleep();
         game->frame_duration = 0;
         /* Ask the user to press EXE to continue. */
         dtext(1, y, C_BLACK, "[EXE] To continue ...");

From f71c185a8dec63831edd690f8e87959d0e34dbcb Mon Sep 17 00:00:00 2001
From: mibi88 <mbcontact50@gmail.com>
Date: Thu, 13 Jul 2023 12:06:48 +0200
Subject: [PATCH 7/8] Start of the interactive dialogs code

---
 src/dialogs.c | 29 +++++++++++++++++++++++++++--
 src/dialogs.h |  9 +++++++++
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/src/dialogs.c b/src/dialogs.c
index cb11bbc..bc97b7c 100644
--- a/src/dialogs.c
+++ b/src/dialogs.c
@@ -8,10 +8,11 @@
 extern font_t fontRPG;
 #define FONT_USED fontRPG
 
-void showtext(Game *game, bopti_image_t *face, char *text) {
+int showtext_opt(Game *game, bopti_image_t *face, char *text,
+                 int call_before_end(void), bool start_anim, bool end_anim) {
     dfont(&FONT_USED);
     unsigned int i, n, y = PXSIZE, l = 0;
-    int line_max_chars;
+    int line_max_chars, return_int = 0;
     unsigned int max_lines_amount = (BOX_HEIGHT-2)*PXSIZE/
                                     (FONT_USED.line_height+PXSIZE);
     const char *c;
@@ -87,6 +88,7 @@ void showtext(Game *game, bopti_image_t *face, char *text) {
         dtext(1, y, C_BLACK, "[EXE] To continue ...");
         while(getkey().key != KEY_EXE) sleep();
     }
+    if(call_before_end) return_int = call_before_end();
     /* Run another little fancy animation. */
     for(i=40;i>0;i--){
         draw(game);
@@ -98,4 +100,27 @@ void showtext(Game *game, bopti_image_t *face, char *text) {
         while(game->frame_duration < 20) sleep();
         game->frame_duration = 0;
     }
+    return return_int;
+}
+
+void showtext(Game *game, bopti_image_t *face, char *text) {
+    showtext_opt(game, face, text, NULL, true, true);
+}
+
+void showtext_dialog_start(Game *game, bopti_image_t *face, char *text) {
+    showtext_opt(game, face, text, NULL, true, false);
+}
+
+void showtext_dialog_mid(Game *game, bopti_image_t *face, char *text) {
+    showtext_opt(game, face, text, NULL, false, false);
+}
+
+void showtext_dialog_end(Game *game, bopti_image_t *face, char *text) {
+    showtext_opt(game, face, text, NULL, false, true);
+}
+
+char **choices;
+
+void _choice_call_before_end(void) {
+    //
 }
diff --git a/src/dialogs.h b/src/dialogs.h
index 92cc96c..62c9a6e 100644
--- a/src/dialogs.h
+++ b/src/dialogs.h
@@ -9,6 +9,15 @@
 #define F_WIDTH (32*PXSIZE)
 #define F_HEIGHT (32*PXSIZE)
 
+int showtext_opt(Game *game, bopti_image_t *face, char *text,
+                 int call_before_end(void), bool start_anim, bool end_anim);
+
 void showtext(Game *game, bopti_image_t *face, char *text);
 
+void showtext_dialog_start(Game *game, bopti_image_t *face, char *text);
+
+void showtext_dialog_mid(Game *game, bopti_image_t *face, char *text);
+
+void showtext_dialog_end(Game *game, bopti_image_t *face, char *text);
+
 #endif

From 6ccd93843df1e294cd74542e32ec5a7751047a15 Mon Sep 17 00:00:00 2001
From: mibi88 <mbcontact50@gmail.com>
Date: Thu, 13 Jul 2023 23:49:07 +0200
Subject: [PATCH 8/8] Fixed the code to work with Sly's changes

---
 CMakeLists.txt |  2 +-
 src/dialogs.c  | 11 ++++++-----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 75b29b7..d36cab6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,7 +12,7 @@ find_package(Gint 2.9 REQUIRED)
 find_package(LibProf 2.4 REQUIRED)
 
 #set the color mode either to 1b or 2b
-set(COLORMODE_fx 1b)
+set(COLORMODE_fx 2b)
 #set the color mode either to 2b or EGA64
 set(COLORMODE_cg EGA64)
 
diff --git a/src/dialogs.c b/src/dialogs.c
index 281d9bd..bb2a3e1 100644
--- a/src/dialogs.c
+++ b/src/dialogs.c
@@ -51,7 +51,7 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text,
         dsubimage(4*PXSIZE, 2*PXSIZE, face, 0, 0, F_WIDTH, (i-8)*PXSIZE,
               DIMAGE_NONE);
 
-        blit();
+        dupdate();
 
         while(game->frame_duration < 20) sleep();
         game->frame_duration = 0;
@@ -85,14 +85,14 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text,
             /* We drew one entire screen, reset everything to draw the next one.
              */
             /* Make a little animation :). */
-            dupdate();
+            blit();
             while(game->frame_duration < 1000) sleep();
             game->frame_duration = 0;
             /* Ask the user to press EXE to continue. */
             dtext(BOX_HEIGHT*PXSIZE, y, C_BLACK, "[EXE] to continue ...");
         }
         /* Make a little animation :). */
-        dupdate();
+        blit();
         if(l>=max_lines_amount-1){
             while(getkey().key != KEY_EXE) sleep();
             /* Clear the screen. */
@@ -110,11 +110,12 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text,
     if(l<max_lines_amount-1){
         /* If we have not filled everthing with text at the end. */
         /* Make a little animation :). */
-        dupdate();
+        blit();
         while(game->frame_duration < 1000) sleep();
         game->frame_duration = 0;
         /* Ask the user to press EXE to continue. */
         dtext(1, y, C_BLACK, "[EXE] To continue ...");
+        blit();
         while(getkey().key != KEY_EXE) sleep();
     }
     if(call_before_end) return_int = call_before_end();
@@ -126,7 +127,7 @@ int showtext_opt(Game *game, bopti_image_t *face, char *text,
         dsubimage(4*PXSIZE, 2*PXSIZE, face, 0, 0, F_WIDTH, (i-8)*PXSIZE,
               DIMAGE_NONE);
 
-        blit();
+        dupdate();
 
         while(game->frame_duration < 20) sleep();
         game->frame_duration = 0;