added transparency to all mode + working dialogs on all plateforms and for all colorsets (thanks Lephe)

This commit is contained in:
SlyVTT 2023-07-13 22:23:31 +02:00
parent 5f55b46bad
commit 04f0a75472
8 changed files with 109 additions and 17 deletions

View file

@ -12,7 +12,7 @@ find_package(Gint 2.9 REQUIRED)
find_package(LibProf 2.4 REQUIRED) find_package(LibProf 2.4 REQUIRED)
#set the color mode either to 1b or 2b #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 the color mode either to 2b or EGA64
set(COLORMODE_cg EGA64) set(COLORMODE_cg EGA64)

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

View file

@ -1,6 +1,11 @@
#ifndef CONFIG_H #ifndef CONFIG_H
#define CONFIG_H #define CONFIG_H
#if !defined(FXCG50) && defined(COLOR2BIT)
#define GRAYMODEOK
#endif
#define USB_FEATURE 1 #define USB_FEATURE 1
#endif #endif

View file

@ -3,20 +3,57 @@
#include <gint/keyboard.h> #include <gint/keyboard.h>
#include <gint/cpu.h> #include <gint/cpu.h>
#include <string.h>
#include "config.h"
#define BOX_HEIGHT (F_HEIGHT/PXSIZE+8) #define BOX_HEIGHT (F_HEIGHT/PXSIZE+8)
extern font_t fontRPG; extern font_t fontRPG;
#define FONT_USED fontRPG
#ifdef GRAYMODEOK
#include <gint/gray.h>
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) { 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;i<BOX_HEIGHT;i++){ for(i=0;i<BOX_HEIGHT;i++){
draw(game); draw(game);
drect(0, 0, DWIDTH, i*PXSIZE, C_WHITE); drect(0, 0, DWIDTH, i*PXSIZE, C_WHITE);
drect(0, i*PXSIZE, DWIDTH, (i+1)*PXSIZE, C_BLACK); drect(0, i*PXSIZE, DWIDTH, (i+1)*PXSIZE, C_BLACK);
dsubimage(4*PXSIZE, 2*PXSIZE, face, 0, 0, F_WIDTH, (i-8)*PXSIZE, dsubimage(4*PXSIZE, 2*PXSIZE, face, 0, 0, F_WIDTH, (i-8)*PXSIZE,
DIMAGE_NONE); DIMAGE_NONE);
dupdate();
blit();
while(game->frame_duration < 20) sleep(); while(game->frame_duration < 20) sleep();
game->frame_duration = 0; game->frame_duration = 0;
} }
@ -24,23 +61,77 @@ void showtext(Game *game, bopti_image_t *face, char *text) {
* drawing on the face. */ * drawing on the face. */
/* Show a little message that showing text in dialogs is not implemented /* Show a little message that showing text in dialogs is not implemented
* yet. */ * 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++){ for(i=0;i<strlen(text);i++){
/**/ /* Get how many chars we can draw on screen with a padding on the left
* 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(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(l<max_lines_amount-1){
/* If we have not filled everthing with text at the end. */
/* Make a little animation :). */
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 ...");
while(getkey().key != KEY_EXE) sleep();
}
/* Run another little fancy animation. */
for(i=40;i>0;i--){ for(i=40;i>0;i--){
draw(game); draw(game);
drect(0, 0, DWIDTH, i*PXSIZE, C_WHITE); drect(0, 0, DWIDTH, i*PXSIZE, C_WHITE);
drect(0, i*PXSIZE, DWIDTH, (i+1)*PXSIZE, C_BLACK); drect(0, i*PXSIZE, DWIDTH, (i+1)*PXSIZE, C_BLACK);
dsubimage(4*PXSIZE, 2*PXSIZE, face, 0, 0, F_WIDTH, (i-8)*PXSIZE, dsubimage(4*PXSIZE, 2*PXSIZE, face, 0, 0, F_WIDTH, (i-8)*PXSIZE,
DIMAGE_NONE); DIMAGE_NONE);
dupdate();
blit();
while(game->frame_duration < 20) sleep(); while(game->frame_duration < 20) sleep();
game->frame_duration = 0; game->frame_duration = 0;
} }
} }

View file

@ -12,10 +12,6 @@
#endif //USB_FEATURE #endif //USB_FEATURE
#if !defined(FXCG50) && defined(COLOR2BIT)
#define GRAYMODEOK
#endif
#ifdef GRAYMODEOK #ifdef GRAYMODEOK
#include <gint/gray.h> #include <gint/gray.h>
#endif //GRAYMODEOK #endif //GRAYMODEOK
@ -103,7 +99,7 @@ int main(void) {
dgray(DGRAY_ON); dgray(DGRAY_ON);
#endif #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{ do{
/* clear screen */ /* clear screen */
dclear(C_WHITE); dclear(C_WHITE);