Skip to content

Commit

Permalink
OutText
Browse files Browse the repository at this point in the history
  • Loading branch information
javiergutierrezchamorro committed May 14, 2024
1 parent d2cafdd commit 26ce8be
Show file tree
Hide file tree
Showing 15 changed files with 2,069 additions and 97 deletions.
2 changes: 2 additions & 0 deletions Source/data.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@


11 changes: 10 additions & 1 deletion Source/data.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#pragma once
#ifndef _DATA_H
#define _DATA_H

#ifdef __cplusplus
extern "C" {
#endif


#ifdef __cplusplus
}
#endif


#endif
139 changes: 90 additions & 49 deletions Source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@

unsigned char *VGA256_Video;

void DemoPorsche(void);
void DemoDraw(void);



/*------------------------------------------------------------------------------------------------------- */
void main( int argc, char *argv[] )
{
short iMode;
unsigned int i, j, k;
unsigned char *b, *c, *p;
clock_t start_time, end_time;

unsigned int i;

VBE_Init();
iMode = VBE_FindMode(VGA256_WIDTH, VGA256_HEIGHT, 8);
Expand All @@ -32,56 +33,107 @@ void main( int argc, char *argv[] )
return;
}


VGA256FadeOut();
VBE_SetMode (iMode, 1, 1);

VBE_SetMode(iMode, 1, 1);
VGA256_Video = VBE_GetVideoPtr(iMode);

//DemoPorsche();
//VGA256GetCh();

//DemoDraw();
//VGA256GetCh();


b = malloc(640 * 1071);
c = malloc(250 * 151);
p = malloc(768);
VGA256LoadPCX("911.pcx", b, p);
VGA256LoadPCX("logo.pcx", c, NULL);
VGA256SetPalette(p);
/*
for (i = 0; i < 1071 - 480; i++)
for (i = 0; i < VGA256_HEIGHT; i += 16)
{
VGA256PutScreen(VGA256_Video, b + (i * 640));
//VGA256MemCpyMMX(VGA256_Video, b + (i * 640), VGA256_WIDTH * VGA256_HEIGHT);
VGA256PutSprite(VGA256_Video, c, 0, 0, 250, 151);
VGA256WaitVRetrace();
}
for (i = 1071 - 480; i > 0; i--)
{
VGA256PutScreen(VGA256_Video, b + (i * 640));
//VGA256MemCpyMMX(VGA256_Video, b + (i * 640), VGA256_WIDTH * VGA256_HEIGHT);
VGA256PutSprite(VGA256_Video, c, 0, 0, 250, 151);
VGA256WaitVRetrace();
VGA256OutText2x(VGA256_Video, "VGA256 Watcom/OpenWatcom Library", 60, i, 40, (unsigned char*)VGA256Font);
}
*/
free(c);
c = malloc(287 * 480);
VGA256ScaleImage(c, b, 287, 480, 640, 1171);
VGA256PutImage(VGA256_Video, c, 287, 480, 640, 1171);
VGA256OutText(VGA256_Video, "Hola", 160, 150, 40, (unsigned char*)VGA256Font);

VGA256GetCh();

free(p);
free(b);
//Test rotate

VGA256FadeOut();

VGA256ClearScreen(VGA256_Video, 50);
VGA256GetCh();



VBE_SetMode (3, 0, 1);
VBE_Done();
}


/*------------------------------------------------------------------------------------------------------- */
void DemoDraw(void)
{
VGA256OutText(VGA256_Video, "Test de prueba en VESA", 20, 20, 10, (unsigned char *) VGA256Font);

VGA256OutText(VGA256_Video, "Test de prueba en VESA", 20, 20, 10);
VGA256PutPixel(VGA256_Video, VGA256_WIDTH / 2, VGA256_HEIGHT / 2, 50);

VGA256LineH(VGA256_Video, 0, VGA256_HEIGHT/2, VGA256_WIDTH, 50);

VGA256LineH(VGA256_Video, 0, VGA256_HEIGHT / 2, VGA256_WIDTH, 50);

VGA256LineV(VGA256_Video, 320, 0, VGA256_WIDTH, 100);

VGA256DrawBox(VGA256_Video, 10, 10, VGA256_WIDTH - 20, VGA256_HEIGHT - 20, 200);

VGA256FillBox(VGA256_Video, 20, 20, VGA256_WIDTH - 40, VGA256_HEIGHT - 40, 240);

VGA256Circle(VGA256_Video, VGA256_WIDTH / 2, VGA256_HEIGHT / 2, 200, 40);

VGA256FloodFill(VGA256_Video, VGA256_WIDTH / 2, VGA256_HEIGHT / 2, 10, 40);

VGA256Line(VGA256_Video, 0, 0, VGA256_WIDTH, VGA256_HEIGHT, 40);
VGA256GetCh();
}


/*------------------------------------------------------------------------------------------------------- */
void DemoPorsche(void)
{
unsigned int i;
unsigned char *porsche, *logo, *pal, *smallporsche;

porsche = malloc(640 * 1071);
logo = malloc(250 * 151);
pal = malloc(768);
VGA256LoadPCX("911.pcx", porsche, pal);
VGA256LoadPCX("logo.pcx", logo, NULL);
VGA256FadeIn(pal);
free(pal);

for (i = 0; i < 1071 - 480; i++)
{
VGA256PutScreen(VGA256_Video, porsche + (i * 640));
//VGA256MemCpyMMX(VGA256_Video, b + (i * 640), VGA256_WIDTH * VGA256_HEIGHT);
VGA256PutSprite(VGA256_Video, logo, 0, 0, 250, 151);
VGA256WaitVRetrace();
}

for (i = 1071 - 480; i > 0; i--)
{
VGA256PutScreen(VGA256_Video, porsche + (i * 640));
//VGA256MemCpyMMX(VGA256_Video, b + (i * 640), VGA256_WIDTH * VGA256_HEIGHT);
VGA256PutSprite(VGA256_Video, logo, 0, 0, 250, 151);
VGA256WaitVRetrace();
}
free(logo);

smallporsche = malloc(287 * 480);
VGA256ScaleImage(smallporsche, porsche, 287, 480, 640, 1171);
VGA256PutImage(VGA256_Video, smallporsche, 287, 480, 640, 1171);
free(smallporsche);
}


/*------------------------------------------------------------------------------------------------------- */
void Demo(void)
{
unsigned int i, j, k;
unsigned char* b, * c, * p;
clock_t start_time, end_time;

c = malloc(320 * 200);
VGA256LoadPCX("perin.pcx", c, NULL);
Expand All @@ -91,7 +143,7 @@ void main( int argc, char *argv[] )

VGA256ClearScreen(VGA256_Video, 0);
b = malloc(VGA256_WIDTH * VGA256_HEIGHT);


start_time = clock();
VGA256ScaleImage(b, c, 640, 480, 320, 200);
Expand All @@ -118,16 +170,5 @@ void main( int argc, char *argv[] )
free(c);
VGA256GetCh();

VGA256FadeOut();

VGA256ClearScreen(VGA256_Video, 50);
VGA256GetCh();



VBE_SetMode (3, 0, 1);
VBE_Done();

printf("Execution time was %ld clocks\n", (end_time - start_time));

//printf("Execution time was %ld clocks\n", (end_time - start_time));
}
Loading

0 comments on commit 26ce8be

Please sign in to comment.