diff --git a/CMakeLists.txt b/CMakeLists.txt index d36cab6..75b29b7 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 2b) +set(COLORMODE_fx 1b) #set the color mode either to 2b or EGA64 set(COLORMODE_cg EGA64) diff --git a/fxlink-image-2023.07.10-20h57-1.png b/fxlink-image-2023.07.10-20h57-1.png new file mode 100644 index 0000000..eacb860 Binary files /dev/null and b/fxlink-image-2023.07.10-20h57-1.png differ diff --git a/fxlink-image-2023.07.10-20h57-2.png b/fxlink-image-2023.07.10-20h57-2.png new file mode 100644 index 0000000..55567eb Binary files /dev/null and b/fxlink-image-2023.07.10-20h57-2.png differ diff --git a/fxlink-image-2023.07.10-20h57-3.png b/fxlink-image-2023.07.10-20h57-3.png new file mode 100644 index 0000000..55567eb Binary files /dev/null and b/fxlink-image-2023.07.10-20h57-3.png differ diff --git a/fxlink-image-2023.07.10-20h57-4.png b/fxlink-image-2023.07.10-20h57-4.png new file mode 100644 index 0000000..cc40522 Binary files /dev/null and b/fxlink-image-2023.07.10-20h57-4.png differ diff --git a/src/config.h b/src/config.h index 87cd453..54bb80c 100644 --- a/src/config.h +++ b/src/config.h @@ -1,6 +1,11 @@ #ifndef CONFIG_H #define CONFIG_H + +#if !defined(FXCG50) && defined(COLOR2BIT) + #define GRAYMODEOK +#endif + #define USB_FEATURE 1 #endif diff --git a/src/dialogs.c b/src/dialogs.c index b4cb299..ed176de 100644 --- a/src/dialogs.c +++ b/src/dialogs.c @@ -3,20 +3,57 @@ #include #include +#include + +#include "config.h" + + #define BOX_HEIGHT (F_HEIGHT/PXSIZE+8) extern font_t fontRPG; +#define FONT_USED fontRPG + +#ifdef GRAYMODEOK + #include + uint32_t *lightVRAMnext, *darkVRAMnext; + uint32_t *lightVRAMcurrent, *darkVRAMcurrent; +#endif //GRAYMODEOK + + +void blit() +{ + dupdate(); + + #ifdef GRAYMODEOK + dgray_getvram( &lightVRAMnext, &darkVRAMnext ); + dgray_getscreen( &lightVRAMcurrent, &darkVRAMcurrent ); + + memcpy( lightVRAMnext, lightVRAMcurrent, 256*sizeof( uint32_t) ); + memcpy( darkVRAMnext, darkVRAMcurrent, 256*sizeof( uint32_t) ); + #endif +} + void showtext(Game *game, bopti_image_t *face, char *text) { - dfont(&fontRPG); - unsigned int i; + + + dfont(&FONT_USED); + unsigned int i, n, y = PXSIZE, l = 0; + int line_max_chars; + 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;iframe_duration < 20) sleep(); game->frame_duration = 0; } @@ -24,23 +61,77 @@ 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;i0; 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(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+PXSIZE; + 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 :). */ + 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 :). */ + blit(); + + 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-1, + C_WHITE); + /* Reset y and l. */ + y = PXSIZE; + l = 0; + } + else{ + while(game->frame_duration < 1000) sleep(); + game->frame_duration = 0; + } } + if(lframe_duration < 1000) 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); drect(0, i*PXSIZE, DWIDTH, (i+1)*PXSIZE, C_BLACK); dsubimage(4*PXSIZE, 2*PXSIZE, face, 0, 0, F_WIDTH, (i-8)*PXSIZE, DIMAGE_NONE); - dupdate(); + + blit(); + while(game->frame_duration < 20) sleep(); game->frame_duration = 0; } } - - diff --git a/src/main.c b/src/main.c index f48a53e..bfb9a74 100644 --- a/src/main.c +++ b/src/main.c @@ -12,10 +12,6 @@ #endif //USB_FEATURE -#if !defined(FXCG50) && defined(COLOR2BIT) - #define GRAYMODEOK -#endif - #ifdef GRAYMODEOK #include #endif //GRAYMODEOK @@ -103,7 +99,7 @@ int main(void) { dgray(DGRAY_ON); #endif - showtext(&game, &player_face_img, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula massa, varius a, semper congue, euismod non, mi. Proin porttitor, orci nec nonummy molestie, enim est eleifend mi, non fermentum diam nisl sit amet erat. Duis semper. Duis arcu massa, scelerisque vitae, consequat in, pretium a, enim. Pellentesque congue. Ut in risus volutpat libero pharetra tempor. Cras vestibulum bibendum augue. Praesent egestas leo in pede. Praesent blandit odio eu enim. Pellentesque sed dui ut augue blandit sodales. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam nibh. Mauris ac mauris sed pede pellentesque fermentum. Maecenas adipiscing ante non diam sodales hendrerit. Ut velit mauris, egestas sed, gravida nec, ornare ut, mi. Aenean ut orci vel massa suscipit pulvinar. Nulla sollicitudin. Fusce varius, ligula non tempus aliquam, nunc turpis ullamcorper nibh, in tempus sapien eros vitae ligula. Pellentesque rhoncus nunc et augue. Integer id felis. Curabitur aliquet pellentesque diam. Integer quis metus vitae elit lobortis egestas. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi vel erat non mauris convallis vehicula. Nulla et sapien. Integer tortor tellus, aliquam faucibus, convallis id, congue eu, quam. Mauris ullamcorper felis vitae erat. Proin feugiat, augue non elementum posuere, metus purus iaculis lectus, et tristique ligula justo vitae magna. Aliquam convallis sollicitudin purus. Praesent aliquam, enim at fermentum mollis, ligula massa adipiscing nisl, ac euismod nibh nisl eu lectus. Fusce vulputate sem at sapien. Vivamus leo. Aliquam euismod libero eu enim. Nulla nec felis sed leo placerat imperdiet. Aenean suscipit nulla in justo. Suspendisse cursus rutrum augue. Nulla tincidunt tincidunt mi. Curabitur iaculis, lorem vel rhoncus faucibus, felis magna fermentum augue, et ultricies lacus lorem varius purus. Curabitur eu amet."); + showtext(&game, &player_face_img, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet."); do{ /* clear screen */ dclear(C_WHITE);