set_mode, SDL en la graphics, y tal y cual
This commit is contained in:
parent
eb98f06c3c
commit
5411ad1508
|
@ -12,9 +12,10 @@
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include <export.h>
|
#include "export.h"
|
||||||
#include "graphics.h"
|
#include "graphics.h"
|
||||||
#include "SDL_rotozoom.h"
|
#include "SDL_rotozoom.h"
|
||||||
|
#include "default_palette.h"
|
||||||
|
|
||||||
#define ERR_FILENOTFOUND 105
|
#define ERR_FILENOTFOUND 105
|
||||||
#define ERR_INVALIDFPGHEADER 106
|
#define ERR_INVALIDFPGHEADER 106
|
||||||
|
@ -22,6 +23,7 @@
|
||||||
|
|
||||||
#define Miedzy(x,a,b) (((x) >= (a)) && ((x) <= (b)))
|
#define Miedzy(x,a,b) (((x) >= (a)) && ((x) <= (b)))
|
||||||
|
|
||||||
|
#define PaletteCopy(dst,src) SDL_SetPalette(dst,SDL_LOGPAL|SDL_PHYSPAL,src->format->palette->colors,0,256);
|
||||||
|
|
||||||
#define MAX_DRAWS 1024
|
#define MAX_DRAWS 1024
|
||||||
|
|
||||||
|
@ -29,7 +31,7 @@
|
||||||
struct _files files[ 0xFF ] ;
|
struct _files files[ 0xFF ] ;
|
||||||
|
|
||||||
SDL_Surface *Mapa[0xFFF] ;
|
SDL_Surface *Mapa[0xFFF] ;
|
||||||
SDL_Surface *fondo ;
|
|
||||||
struct _file file0[0xFFF] ;
|
struct _file file0[0xFFF] ;
|
||||||
int last_map[0xFF] ;
|
int last_map[0xFF] ;
|
||||||
int color_transparente ;
|
int color_transparente ;
|
||||||
|
@ -64,17 +66,7 @@ typedef struct _FPGMAPINFO{
|
||||||
int number_of_points;
|
int number_of_points;
|
||||||
}FPGMAPINFO;
|
}FPGMAPINFO;
|
||||||
|
|
||||||
typedef struct _MODOVIDEO {
|
//char *graphic; /* wide*height */
|
||||||
int ancho;
|
|
||||||
int alto;
|
|
||||||
int bpp;
|
|
||||||
int flags;
|
|
||||||
BOOL cambiado;
|
|
||||||
} MODOVIDEO;
|
|
||||||
|
|
||||||
MODOVIDEO modovideo;
|
|
||||||
|
|
||||||
char *graphic; /* wide*height */
|
|
||||||
|
|
||||||
|
|
||||||
struct{
|
struct{
|
||||||
|
@ -124,6 +116,8 @@ int ExportaFuncs(EXPORTAFUNCS_PARAMS)
|
||||||
CONST("m1600x1200",16001200);
|
CONST("m1600x1200",16001200);
|
||||||
CONST("m1900x1600",19001600);
|
CONST("m1900x1600",19001600);
|
||||||
|
|
||||||
|
CONST("_fullscreen",GR_FULLSCREEN);
|
||||||
|
|
||||||
CONST("partial_dump",0);
|
CONST("partial_dump",0);
|
||||||
CONST("complete_dump",1);
|
CONST("complete_dump",1);
|
||||||
|
|
||||||
|
@ -391,7 +385,8 @@ int eDIV_RGB(FUNCTION_PARAMS)
|
||||||
g = getparm() ;
|
g = getparm() ;
|
||||||
r = getparm() ;
|
r = getparm() ;
|
||||||
|
|
||||||
return ( b + g*256 + r*65536 ) ;
|
//return ( b + g*256 + r*65536 ) ;
|
||||||
|
return SDL_MapRGB(screen->format,r,g,b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************/
|
/*****************************************************************/
|
||||||
|
@ -413,7 +408,7 @@ int eDIV_GET_RGB(FUNCTION_PARAMS)
|
||||||
goff=getparm();
|
goff=getparm();
|
||||||
roff=getparm();
|
roff=getparm();
|
||||||
color=getparm();
|
color=getparm();
|
||||||
SDL_GetRGB(color,fp->screen->format,&r,&g,&b);
|
SDL_GetRGB(color,screen->format,&r,&g,&b);
|
||||||
if(roff) fp->mem[roff]=(int)r;
|
if(roff) fp->mem[roff]=(int)r;
|
||||||
if(goff) fp->mem[goff]=(int)g;
|
if(goff) fp->mem[goff]=(int)g;
|
||||||
if(boff) fp->mem[boff]=(int)b;
|
if(boff) fp->mem[boff]=(int)b;
|
||||||
|
@ -1039,6 +1034,7 @@ int eDIV_LOAD_FPG(FUNCTION_PARAMS)
|
||||||
int tamano;
|
int tamano;
|
||||||
int cont=0,num,i;
|
int cont=0,num,i;
|
||||||
int bpp;
|
int bpp;
|
||||||
|
char* graphic;
|
||||||
|
|
||||||
SDL_Color p[256];
|
SDL_Color p[256];
|
||||||
|
|
||||||
|
@ -1208,6 +1204,32 @@ int eDIV_FADE(FUNCTION_PARAMS)
|
||||||
FILE * fichero ;
|
FILE * fichero ;
|
||||||
FILE * memo ;
|
FILE * memo ;
|
||||||
|
|
||||||
|
void guarda_pantallazo(char* nombre_program)
|
||||||
|
{
|
||||||
|
char capturef[256], num[5];
|
||||||
|
int c,i;
|
||||||
|
FILE* f;
|
||||||
|
|
||||||
|
strcpy(capturef,nombre_program);
|
||||||
|
i=strlen(capturef)+3;
|
||||||
|
strcat(capturef,"0000");
|
||||||
|
strcat(capturef,".bmp");
|
||||||
|
while(f=fopen(capturef,"rb")) {
|
||||||
|
fclose(f);
|
||||||
|
c=i;
|
||||||
|
while(1) {
|
||||||
|
capturef[c]++;
|
||||||
|
if(capturef[c]>'9') {
|
||||||
|
capturef[c]='0';
|
||||||
|
c--;
|
||||||
|
if(c<i-3) break;
|
||||||
|
}
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SDL_SaveBMP(screen,capturef);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Función para usar con qsort() para ordenar los blits por su Z
|
* Función para usar con qsort() para ordenar los blits por su Z
|
||||||
*/
|
*/
|
||||||
|
@ -1224,8 +1246,16 @@ void frame(FUNCTION_PARAMS)
|
||||||
int i , id , f , g , r , z , trans,angle,size,resolution;
|
int i , id , f , g , r , z , trans,angle,size,resolution;
|
||||||
SDL_Rect dstrect , srcrect ;
|
SDL_Rect dstrect , srcrect ;
|
||||||
Uint32 rmask , gmask , bmask , amask ;
|
Uint32 rmask , gmask , bmask , amask ;
|
||||||
|
SDL_Surface* temp;
|
||||||
|
int noevent;
|
||||||
|
SDL_Event event;
|
||||||
|
byte* teclas;
|
||||||
|
|
||||||
//assert(0);
|
/* rmask = 0x00ff0000;
|
||||||
|
gmask = 0x0000ff00;
|
||||||
|
bmask = 0x000000ff;
|
||||||
|
amask = 0x00000000;
|
||||||
|
*/
|
||||||
|
|
||||||
if(primer_frame) {
|
if(primer_frame) {
|
||||||
primer_frame=FALSE;
|
primer_frame=FALSE;
|
||||||
|
@ -1238,47 +1268,64 @@ void frame(FUNCTION_PARAMS)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
screen = SDL_SetVideoMode(modovideo.ancho, modovideo.alto, modovideo.bpp, SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_HWACCEL);
|
temp = SDL_SetVideoMode(fp->graphics->ancho,fp->graphics->alto,fp->graphics->bpp,SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_HWACCEL|((fp->graphics->flags&GR_FULLSCREEN)?SDL_FULLSCREEN:0)|((fp->graphics->bpp==8)?SDL_HWPALETTE:0));
|
||||||
|
if(fp->graphics->bpp==8)
|
||||||
|
PaletteCopy(temp,screen);
|
||||||
|
|
||||||
|
if(fp->graphics->resflags&GR_CHANGED) {
|
||||||
|
SDL_FreeSurface(screen);
|
||||||
|
SDL_FreeSurface(fondo);
|
||||||
|
screen=temp;
|
||||||
|
fp->graphics->buffer=screen->pixels;
|
||||||
|
fondo=SDL_CreateRGBSurface(SDL_HWSURFACE,fp->graphics->ancho,fp->graphics->alto,fp->graphics->bpp,0,0,0,0);
|
||||||
|
if(fp->graphics->bpp==8)
|
||||||
|
PaletteCopy(fondo,screen);
|
||||||
|
fp->graphics->background=fondo->pixels;
|
||||||
|
fp->graphics->resflags^=GR_CHANGED;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SDL_BlitSurface(screen,NULL,temp,NULL);
|
||||||
|
SDL_FreeSurface(screen);
|
||||||
|
screen=temp;
|
||||||
|
fp->graphics->buffer=screen->pixels;
|
||||||
|
}
|
||||||
|
|
||||||
rmask = 0x00ff0000;
|
if ( screen == NULL || fondo==NULL) {
|
||||||
gmask = 0x0000ff00;
|
|
||||||
bmask = 0x000000ff;
|
|
||||||
amask = 0x00000000;
|
|
||||||
|
|
||||||
if ( screen == NULL ) {
|
|
||||||
fp->Critical_Error(7); /* No se pudo inicializar SDL */
|
fp->Critical_Error(7); /* No se pudo inicializar SDL */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fondo = SDL_CreateRGBSurface( SDL_HWSURFACE , modovideo.ancho , modovideo.alto , modovideo.bpp , rmask , gmask , bmask , amask ) ;
|
|
||||||
|
|
||||||
SDL_WM_SetCaption(fp->nombre_program, NULL);
|
SDL_WM_SetCaption(fp->nombre_program, NULL);
|
||||||
SDL_ShowCursor(0);
|
SDL_ShowCursor(0);
|
||||||
}
|
}
|
||||||
else if(modovideo.cambiado) {
|
else {
|
||||||
|
if(fp->graphics->resflags&GR_CHANGED)
|
||||||
/* TODO: Avisar a las DLLs */
|
fp->graphics->resflags^=GR_CHANGED;
|
||||||
|
|
||||||
SDL_FreeSurface(fondo);
|
|
||||||
SDL_FreeSurface(screen);
|
|
||||||
|
|
||||||
screen = SDL_SetVideoMode(modovideo.ancho, modovideo.alto, modovideo.bpp, SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_HWACCEL);
|
|
||||||
|
|
||||||
rmask = 0x00ff0000;
|
|
||||||
gmask = 0x0000ff00;
|
|
||||||
bmask = 0x000000ff;
|
|
||||||
amask = 0x00000000;
|
|
||||||
|
|
||||||
if ( screen == NULL ) {
|
|
||||||
fp->Critical_Error(7); /* No se pudo inicializar SDL */
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fondo = SDL_CreateRGBSurface( SDL_HWSURFACE , modovideo.ancho , modovideo.alto , modovideo.bpp , rmask , gmask , bmask , amask ) ;
|
|
||||||
|
|
||||||
modovideo.cambiado=FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* si no gestionamos un poco los eventos la cosa se cuelga :p */
|
||||||
|
|
||||||
|
noevent=0;
|
||||||
|
while ( SDL_PollEvent(&event) && !noevent )
|
||||||
|
{
|
||||||
|
switch( event.type )
|
||||||
|
{
|
||||||
|
case SDL_QUIT:
|
||||||
|
//assert(0);
|
||||||
|
fp->Stub_Quit(0);
|
||||||
|
break ;
|
||||||
|
case SDL_NOEVENT:
|
||||||
|
noevent=1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
teclas=SDL_GetKeyState(NULL);
|
||||||
|
if(teclas[SDLK_x] && (teclas[SDLK_RALT] || teclas[SDLK_LALT]))
|
||||||
|
fp->Stub_Quit(0);
|
||||||
|
if(teclas[SDLK_p] && (teclas[SDLK_RALT] || teclas[SDLK_LALT]))
|
||||||
|
guarda_pantallazo(fp->nombre_program);
|
||||||
|
|
||||||
fichero = fopen( "draw.txt" , "w" ) ;
|
fichero = fopen( "draw.txt" , "w" ) ;
|
||||||
|
|
||||||
if ( define_region == 1)
|
if ( define_region == 1)
|
||||||
|
@ -1299,6 +1346,7 @@ void frame(FUNCTION_PARAMS)
|
||||||
/*
|
/*
|
||||||
* Draws
|
* Draws
|
||||||
*/
|
*/
|
||||||
|
|
||||||
z = global("draw_z");
|
z = global("draw_z");
|
||||||
smooth = global("smooth");
|
smooth = global("smooth");
|
||||||
for ( i = 0 ; i <= last_draw ; i++ )
|
for ( i = 0 ; i <= last_draw ; i++ )
|
||||||
|
@ -1430,7 +1478,7 @@ void frame(FUNCTION_PARAMS)
|
||||||
last_blit = -1 ;
|
last_blit = -1 ;
|
||||||
|
|
||||||
SDL_Flip(screen) ;
|
SDL_Flip(screen) ;
|
||||||
fp->screen=screen;
|
fp->graphics->buffer=screen->pixels;
|
||||||
fclose(fichero);
|
fclose(fichero);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1438,6 +1486,7 @@ void frame(FUNCTION_PARAMS)
|
||||||
void first_load(FUNCTION_PARAMS)
|
void first_load(FUNCTION_PARAMS)
|
||||||
{
|
{
|
||||||
int i ;
|
int i ;
|
||||||
|
Uint32 rmask , gmask , bmask , amask ;
|
||||||
|
|
||||||
fp->Dibuja = Dibuja ;
|
fp->Dibuja = Dibuja ;
|
||||||
fp->files = files ;
|
fp->files = files ;
|
||||||
|
@ -1470,11 +1519,27 @@ void first_load(FUNCTION_PARAMS)
|
||||||
|
|
||||||
define_region = 1 ;
|
define_region = 1 ;
|
||||||
|
|
||||||
modovideo.ancho=320;
|
fp->graphics->ancho=320;
|
||||||
modovideo.alto=200;
|
fp->graphics->alto=200;
|
||||||
modovideo.bpp=8;
|
fp->graphics->bpp=8;
|
||||||
modovideo.flags=0;
|
fp->graphics->flags=0;
|
||||||
modovideo.cambiado=FALSE;
|
fp->graphics->resflags=GR_ACTIVE;
|
||||||
|
|
||||||
|
rmask = 0;
|
||||||
|
gmask = 0;
|
||||||
|
bmask = 0;
|
||||||
|
amask = 0;
|
||||||
|
|
||||||
|
screen=SDL_CreateRGBSurface(SDL_HWSURFACE,fp->graphics->ancho,fp->graphics->alto,fp->graphics->bpp,rmask,gmask,bmask,amask);
|
||||||
|
if(screen==NULL)
|
||||||
|
fp->Custom_Error(_critical_error,"graphics: Error al crear buffer");
|
||||||
|
|
||||||
|
fondo=SDL_CreateRGBSurface(SDL_HWSURFACE,fp->graphics->ancho,fp->graphics->alto,fp->graphics->bpp,rmask,gmask,bmask,amask);
|
||||||
|
if(fondo==NULL)
|
||||||
|
fp->Custom_Error(_critical_error,"graphics: Error al crear buffer");
|
||||||
|
|
||||||
|
fp->graphics->buffer=screen->pixels;
|
||||||
|
fp->graphics->background=fondo->pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1561,25 +1626,48 @@ int eDIV_SET_MODE(FUNCTION_PARAMS)
|
||||||
|
|
||||||
switch(fp->num_params) {
|
switch(fp->num_params) {
|
||||||
case 4:
|
case 4:
|
||||||
modovideo.flags=getparm();
|
fp->graphics->flags=getparm();
|
||||||
case 3:
|
case 3:
|
||||||
modovideo.bpp=getparm();
|
fp->graphics->bpp=getparm();
|
||||||
modovideo.alto=getparm();
|
fp->graphics->alto=getparm();
|
||||||
modovideo.ancho=getparm();
|
fp->graphics->ancho=getparm();
|
||||||
modovideo.cambiado=TRUE;
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
modo=getparm();
|
modo=getparm();
|
||||||
if(modo>1280960) {
|
if(modo>1280960) {
|
||||||
modovideo.ancho=modo/10000;
|
fp->graphics->ancho=modo/10000;
|
||||||
modovideo.alto=modo%10000;
|
fp->graphics->alto=modo%10000;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
modovideo.ancho=modo/1000;
|
fp->graphics->ancho=modo/1000;
|
||||||
modovideo.alto=modo%1000;
|
fp->graphics->alto=modo%1000;
|
||||||
}
|
}
|
||||||
modovideo.bpp=8;
|
fp->graphics->bpp=8;
|
||||||
modovideo.cambiado=TRUE;
|
fp->graphics->flags=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Esto avisa a las DLLs */
|
||||||
|
fp->graphics->resflags|=GR_CHANGED;
|
||||||
|
|
||||||
|
SDL_FreeSurface(fondo);
|
||||||
|
SDL_FreeSurface(screen);
|
||||||
|
|
||||||
|
screen=SDL_SetVideoMode(fp->graphics->ancho,fp->graphics->alto,fp->graphics->bpp,SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_HWACCEL|((fp->graphics->flags&GR_FULLSCREEN)?SDL_FULLSCREEN:0)|((fp->graphics->bpp==8)?SDL_HWPALETTE:0));
|
||||||
|
fp->graphics->buffer=screen->pixels;
|
||||||
|
|
||||||
|
if(fp->graphics->bpp==8)
|
||||||
|
SDL_SetPalette(screen,SDL_LOGPAL|SDL_PHYSPAL,(SDL_Color*)default_palette,0,256);
|
||||||
|
|
||||||
|
if ( screen == NULL ) {
|
||||||
|
fp->Critical_Error(7); /* No se pudo inicializar SDL */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
fondo=SDL_CreateRGBSurface(SDL_HWSURFACE,fp->graphics->ancho,fp->graphics->alto,fp->graphics->bpp,0,0,0,0);
|
||||||
|
fp->graphics->background=fondo->pixels;
|
||||||
|
|
||||||
|
if(fp->graphics->bpp==8)
|
||||||
|
PaletteCopy(fondo,screen);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#define PIOVER180 0.017453292519943295769236907684886
|
#define PIOVER180 0.017453292519943295769236907684886
|
||||||
|
|
||||||
SDL_Surface *screen;
|
SDL_Surface *screen;
|
||||||
SDL_Surface *prueba;
|
SDL_Surface *fondo;
|
||||||
|
|
||||||
int eDIV_LOAD_BMP(FUNCTION_PARAMS);
|
int eDIV_LOAD_BMP(FUNCTION_PARAMS);
|
||||||
int eDIV_COLLISION(FUNCTION_PARAMS);
|
int eDIV_COLLISION(FUNCTION_PARAMS);
|
||||||
|
|
|
@ -21,11 +21,13 @@
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories="../../include"
|
AdditionalIncludeDirectories="../../include"
|
||||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;GRAPHICS_EXPORTS"
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;GRAPHICS_EXPORTS"
|
||||||
|
GeneratePreprocessedFile="0"
|
||||||
MinimalRebuild="TRUE"
|
MinimalRebuild="TRUE"
|
||||||
ExceptionHandling="FALSE"
|
ExceptionHandling="FALSE"
|
||||||
BasicRuntimeChecks="3"
|
BasicRuntimeChecks="3"
|
||||||
RuntimeLibrary="1"
|
RuntimeLibrary="3"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
|
BrowseInformation="1"
|
||||||
WarningLevel="3"
|
WarningLevel="3"
|
||||||
Detect64BitPortabilityProblems="TRUE"
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
DebugInformationFormat="4"
|
DebugInformationFormat="4"
|
||||||
|
@ -40,13 +42,17 @@
|
||||||
ModuleDefinitionFile="../graphics.def"
|
ModuleDefinitionFile="../graphics.def"
|
||||||
GenerateDebugInformation="TRUE"
|
GenerateDebugInformation="TRUE"
|
||||||
ProgramDatabaseFile="$(OutDir)/graphics.pdb"
|
ProgramDatabaseFile="$(OutDir)/graphics.pdb"
|
||||||
|
GenerateMapFile="TRUE"
|
||||||
|
MapExports="TRUE"
|
||||||
|
MapLines="TRUE"
|
||||||
SubSystem="2"
|
SubSystem="2"
|
||||||
ImportLibrary=""
|
ImportLibrary=""
|
||||||
TargetMachine="1"/>
|
TargetMachine="1"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCMIDLTool"/>
|
Name="VCMIDLTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"/>
|
Name="VCPostBuildEventTool"
|
||||||
|
CommandLine="copy ..\..\..\bin\graphics.dll ..\..\..\..\ediv\bin\dll"/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPreBuildEventTool"/>
|
Name="VCPreBuildEventTool"/>
|
||||||
<Tool
|
<Tool
|
||||||
|
@ -127,6 +133,9 @@
|
||||||
<File
|
<File
|
||||||
RelativePath="..\SDL_rotozoom.h">
|
RelativePath="..\SDL_rotozoom.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\default_palette.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\graphics.h">
|
RelativePath="..\graphics.h">
|
||||||
</File>
|
</File>
|
||||||
|
|
|
@ -45,7 +45,6 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* VARINDEX */
|
/* VARINDEX */
|
||||||
typedef enum { v_global, v_reserved, v_local } tipo_t;
|
typedef enum { v_global, v_reserved, v_local } tipo_t;
|
||||||
|
|
||||||
|
@ -206,7 +205,9 @@ struct _existe {
|
||||||
} ;
|
} ;
|
||||||
struct _file
|
struct _file
|
||||||
{
|
{
|
||||||
SDL_Surface *Surface ;
|
SDL_Surface *Surface;
|
||||||
|
int w,h;
|
||||||
|
int bpp;
|
||||||
int existe ;
|
int existe ;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
@ -221,6 +222,16 @@ struct _files
|
||||||
struct _file *mapa ;
|
struct _file *mapa ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int ancho;
|
||||||
|
int alto;
|
||||||
|
int bpp;
|
||||||
|
int flags;
|
||||||
|
int resflags;
|
||||||
|
byte* buffer;
|
||||||
|
byte* background;
|
||||||
|
} _graphics;
|
||||||
|
|
||||||
struct _fun_params{
|
struct _fun_params{
|
||||||
int *pila ;
|
int *pila ;
|
||||||
int *sp ;
|
int *sp ;
|
||||||
|
@ -245,9 +256,15 @@ struct _fun_params{
|
||||||
int imem_max;
|
int imem_max;
|
||||||
int* nullstring;
|
int* nullstring;
|
||||||
int* nstring;
|
int* nstring;
|
||||||
SDL_Surface *screen;
|
_graphics* graphics;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Flags para graphics */
|
||||||
|
#define GR_FULLSCREEN 0x01
|
||||||
|
/* Flags reservados */
|
||||||
|
#define GR_ACTIVE 0x01
|
||||||
|
#define GR_CHANGED 0x02
|
||||||
|
|
||||||
|
|
||||||
/* Se usa igual que el getparm() de DIV */
|
/* Se usa igual que el getparm() de DIV */
|
||||||
#define getparm() fp->pila[(*fp->sp)--]
|
#define getparm() fp->pila[(*fp->sp)--]
|
||||||
|
|
|
@ -1,8 +1,15 @@
|
||||||
#include "export.h"
|
|
||||||
|
|
||||||
#include "qgraphics.h"
|
#include "qgraphics.h"
|
||||||
|
|
||||||
int ExportaFuncs(EXPORTAFUNCS_PARAMS)
|
int ExportaFuncs(EXPORTAFUNCS_PARAMS)
|
||||||
{
|
{
|
||||||
|
ENTRYPOINT(first_load);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void first_load(FUNCTION_PARAMS)
|
||||||
|
{
|
||||||
|
gr_Init()
|
||||||
|
}
|
||||||
|
|
||||||
|
void frame(FUNCTION_PARAMS)
|
|
@ -1,4 +1,21 @@
|
||||||
#ifndef __EDIV_QGRAPHICS_H_
|
#ifndef __EDIV_QGRAPHICS_H_
|
||||||
#define __EDIV_QGRAPHICS_H_
|
#define __EDIV_QGRAPHICS_H_
|
||||||
|
|
||||||
|
#include "export.h"
|
||||||
|
|
||||||
|
/* Flags de modos de video */
|
||||||
|
#define _FULLSCREEN 0x01
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
byte* buffer; // invisible buffer
|
||||||
|
byte* colormap; // 256 * VID_GRADES size
|
||||||
|
byte* alphamap; // 256 * 256 translucency map
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
int bpp;
|
||||||
|
int flags;
|
||||||
|
} viddef_t;
|
||||||
|
|
||||||
|
viddef_t vid;
|
||||||
|
|
||||||
#endif /* __EDIV_QGRAPHICS_H_ */
|
#endif /* __EDIV_QGRAPHICS_H_ */
|
|
@ -112,6 +112,9 @@
|
||||||
<Filter
|
<Filter
|
||||||
Name="Source Files"
|
Name="Source Files"
|
||||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
|
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
|
||||||
|
<File
|
||||||
|
RelativePath="win32\dib.c">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="qgraphics.c">
|
RelativePath="qgraphics.c">
|
||||||
</File>
|
</File>
|
||||||
|
@ -129,6 +132,9 @@
|
||||||
<Filter
|
<Filter
|
||||||
Name="Header Files"
|
Name="Header Files"
|
||||||
Filter="h;hpp;hxx;hm;inl;inc">
|
Filter="h;hpp;hxx;hm;inl;inc">
|
||||||
|
<File
|
||||||
|
RelativePath="win32\dib.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="win32\gr_win32.h">
|
RelativePath="win32\gr_win32.h">
|
||||||
</File>
|
</File>
|
||||||
|
|
|
@ -4,9 +4,13 @@
|
||||||
* funciones:
|
* funciones:
|
||||||
*
|
*
|
||||||
* gr_Init
|
* gr_Init
|
||||||
|
* gr_InitVideoMode
|
||||||
|
* gr_Shutdown
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "qgraphics.h"
|
||||||
#include "gr_win32.h"
|
#include "gr_win32.h"
|
||||||
|
#include "dib.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Inicializa cosillas de la libreria
|
* Inicializa cosillas de la libreria
|
||||||
|
@ -20,7 +24,7 @@ int gr_Init( void *hInstance, void *wndProc )
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** SWimp_InitGraphics
|
** gr_InitVideoMode
|
||||||
**
|
**
|
||||||
** This initializes the software refresh's implementation specific
|
** This initializes the software refresh's implementation specific
|
||||||
** graphics subsystem. In the case of Windows it creates DIB or
|
** graphics subsystem. In the case of Windows it creates DIB or
|
||||||
|
@ -29,35 +33,107 @@ int gr_Init( void *hInstance, void *wndProc )
|
||||||
** The necessary width and height parameters are grabbed from
|
** The necessary width and height parameters are grabbed from
|
||||||
** vid.width and vid.height.
|
** vid.width and vid.height.
|
||||||
*/
|
*/
|
||||||
static bool SWimp_InitGraphics( int vid_width, int vid_height, bool fullscreen )
|
static bool gr_InitVideoMode( int vid_width, int vid_height, int bpp, int flags )
|
||||||
{
|
{
|
||||||
// free resources in use
|
// free resources in use
|
||||||
gr_Shutdown ();
|
gr_Shutdown ();
|
||||||
|
|
||||||
|
vid.width=vid_width;
|
||||||
|
vid.height=vid_height;
|
||||||
|
vid.bpp=bpp;
|
||||||
|
vid.flags=flags;
|
||||||
|
|
||||||
// create a new window
|
// create a new window
|
||||||
VID_CreateWindow (vid_width, vid_height, WINDOW_STYLE);
|
Win32_CreateWindow (vid_width, vid_height, WINDOW_STYLE);
|
||||||
|
|
||||||
// initialize the appropriate subsystem
|
// initialize the appropriate subsystem
|
||||||
if ( !fullscreen )
|
if ( !(flags & _FULLSCREEN) )
|
||||||
{
|
{
|
||||||
if ( !DIB_Init( &vid.buffer, &vid.rowbytes ) )
|
if ( !DIB_Init( &vid.buffer ) )
|
||||||
|
{
|
||||||
|
vid.buffer = 0;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* de momento, solo DIB (sin fullscreen) */
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
/*if ( !DDRAW_Init( &vid.buffer, &vid.rowbytes ) )
|
||||||
{
|
{
|
||||||
vid.buffer = 0;
|
vid.buffer = 0;
|
||||||
vid.rowbytes = 0;
|
vid.rowbytes = 0;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}*/
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( !DDRAW_Init( &vid.buffer, &vid.rowbytes ) )
|
|
||||||
{
|
|
||||||
vid.buffer = 0;
|
|
||||||
vid.rowbytes = 0;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Win32_CreateWindow
|
||||||
|
*/
|
||||||
|
void Win32_CreateWindow( int width, int height, int stylebits )
|
||||||
|
{
|
||||||
|
WNDCLASS wc;
|
||||||
|
RECT r;
|
||||||
|
int x, y, w, h;
|
||||||
|
int exstyle;
|
||||||
|
|
||||||
|
if ( vid.flags & _FULLSCREEN )
|
||||||
|
exstyle = WS_EX_TOPMOST;
|
||||||
|
else
|
||||||
|
exstyle = 0;
|
||||||
|
|
||||||
|
/* Register the frame class */
|
||||||
|
wc.style = 0;
|
||||||
|
wc.lpfnWndProc = (WNDPROC)sww_state.wndproc;
|
||||||
|
wc.cbClsExtra = 0;
|
||||||
|
wc.cbWndExtra = 0;
|
||||||
|
wc.hInstance = sww_state.hInstance;
|
||||||
|
wc.hIcon = 0;
|
||||||
|
wc.hCursor = LoadCursor (NULL,IDC_ARROW);
|
||||||
|
wc.hbrBackground = (void *)COLOR_GRAYTEXT;
|
||||||
|
wc.lpszMenuName = 0;
|
||||||
|
wc.lpszClassName = WINDOW_CLASS_NAME;
|
||||||
|
|
||||||
|
if (!RegisterClass (&wc) )
|
||||||
|
fp->CustomError(_critical_error,"qgraphics: No puedo registrar clase de ventana");
|
||||||
|
|
||||||
|
r.left = 0;
|
||||||
|
r.top = 0;
|
||||||
|
r.right = width;
|
||||||
|
r.bottom = height;
|
||||||
|
|
||||||
|
AdjustWindowRect (&r, stylebits, FALSE);
|
||||||
|
|
||||||
|
w = r.right - r.left;
|
||||||
|
h = r.bottom - r.top;
|
||||||
|
x = 0;
|
||||||
|
y = 0;
|
||||||
|
|
||||||
|
sww_state.hWnd = CreateWindowEx (
|
||||||
|
exstyle,
|
||||||
|
WINDOW_CLASS_NAME,
|
||||||
|
"qgraphics",
|
||||||
|
stylebits,
|
||||||
|
x, y, w, h,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
sww_state.hInstance,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (!sww_state.hWnd)
|
||||||
|
fp->CustomError(_critical_error."qgraphics: No puedo crear ventana");
|
||||||
|
|
||||||
|
ShowWindow( sww_state.hWnd, SW_SHOWNORMAL );
|
||||||
|
UpdateWindow( sww_state.hWnd );
|
||||||
|
SetForegroundWindow( sww_state.hWnd );
|
||||||
|
SetFocus( sww_state.hWnd );
|
||||||
|
|
||||||
|
// let the sound and input subsystems know about the new window
|
||||||
|
//ri.Vid_NewWindow (width, height);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "export.h"
|
#include "export.h"
|
||||||
|
|
||||||
#define WINDOW_STYLE (WS_OVERLAPPED|WS_BORDER|WS_CAPTION|WS_VISIBLE)
|
#define WINDOW_STYLE (WS_OVERLAPPED|WS_BORDER|WS_CAPTION|WS_VISIBLE)
|
||||||
|
#define WINDOW_CLASS_NAME "qgraphics"
|
||||||
|
|
||||||
extern HINSTANCE global_hInstance;
|
extern HINSTANCE global_hInstance;
|
||||||
|
|
||||||
|
@ -52,13 +53,6 @@ typedef struct
|
||||||
|
|
||||||
extern swwstate_t sww_state;
|
extern swwstate_t sww_state;
|
||||||
|
|
||||||
/*
|
|
||||||
** DIB
|
|
||||||
*/
|
|
||||||
bool DIB_Init( unsigned char **ppbuffer, int *ppitch );
|
|
||||||
void DIB_Shutdown( void );
|
|
||||||
void DIB_SetPalette( const unsigned char *palette );
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** DirectDraw
|
** DirectDraw
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -5,8 +5,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "edivstd", "..\edivstd\win32
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "file", "..\file\win32\file.vcproj", "{EA869297-5AC6-4603-BB86-9962207DB25F}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "file", "..\file\win32\file.vcproj", "{EA869297-5AC6-4603-BB86-9962207DB25F}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "graphics", "..\graphics\win32\graphics.vcproj", "{20CF9907-2F82-4A8C-A5FB-074F5F1BCB32}"
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "input", "..\input\win32\input.vcproj", "{92E50294-4312-49E4-848B-5C9FF43AB27D}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "input", "..\input\win32\input.vcproj", "{92E50294-4312-49E4-848B-5C9FF43AB27D}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "math", "..\math\win32\math.vcproj", "{56A4746D-5A73-4CA5-BD0C-959F14B503E7}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "math", "..\math\win32\math.vcproj", "{56A4746D-5A73-4CA5-BD0C-959F14B503E7}"
|
||||||
|
@ -15,6 +13,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "strings", "..\strings\win32
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "text", "..\text\win32\text.vcproj", "{71D05C32-B49A-4690-AA4D-1385D4257CDF}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "text", "..\text\win32\text.vcproj", "{71D05C32-B49A-4690-AA4D-1385D4257CDF}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "graphics", "..\graphics\win32\graphics.vcproj", "{20CF9907-2F82-4A8C-A5FB-074F5F1BCB32}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfiguration) = preSolution
|
GlobalSection(SolutionConfiguration) = preSolution
|
||||||
ConfigName.0 = Debug
|
ConfigName.0 = Debug
|
||||||
|
@ -35,10 +35,6 @@ Global
|
||||||
{EA869297-5AC6-4603-BB86-9962207DB25F}.Debug.Build.0 = Debug|Win32
|
{EA869297-5AC6-4603-BB86-9962207DB25F}.Debug.Build.0 = Debug|Win32
|
||||||
{EA869297-5AC6-4603-BB86-9962207DB25F}.Release.ActiveCfg = Release|Win32
|
{EA869297-5AC6-4603-BB86-9962207DB25F}.Release.ActiveCfg = Release|Win32
|
||||||
{EA869297-5AC6-4603-BB86-9962207DB25F}.Release.Build.0 = Release|Win32
|
{EA869297-5AC6-4603-BB86-9962207DB25F}.Release.Build.0 = Release|Win32
|
||||||
{20CF9907-2F82-4A8C-A5FB-074F5F1BCB32}.Debug.ActiveCfg = Debug|Win32
|
|
||||||
{20CF9907-2F82-4A8C-A5FB-074F5F1BCB32}.Debug.Build.0 = Debug|Win32
|
|
||||||
{20CF9907-2F82-4A8C-A5FB-074F5F1BCB32}.Release.ActiveCfg = Release|Win32
|
|
||||||
{20CF9907-2F82-4A8C-A5FB-074F5F1BCB32}.Release.Build.0 = Release|Win32
|
|
||||||
{92E50294-4312-49E4-848B-5C9FF43AB27D}.Debug.ActiveCfg = Debug|Win32
|
{92E50294-4312-49E4-848B-5C9FF43AB27D}.Debug.ActiveCfg = Debug|Win32
|
||||||
{92E50294-4312-49E4-848B-5C9FF43AB27D}.Debug.Build.0 = Debug|Win32
|
{92E50294-4312-49E4-848B-5C9FF43AB27D}.Debug.Build.0 = Debug|Win32
|
||||||
{92E50294-4312-49E4-848B-5C9FF43AB27D}.Release.ActiveCfg = Release|Win32
|
{92E50294-4312-49E4-848B-5C9FF43AB27D}.Release.ActiveCfg = Release|Win32
|
||||||
|
@ -55,6 +51,10 @@ Global
|
||||||
{71D05C32-B49A-4690-AA4D-1385D4257CDF}.Debug.Build.0 = Debug|Win32
|
{71D05C32-B49A-4690-AA4D-1385D4257CDF}.Debug.Build.0 = Debug|Win32
|
||||||
{71D05C32-B49A-4690-AA4D-1385D4257CDF}.Release.ActiveCfg = Release|Win32
|
{71D05C32-B49A-4690-AA4D-1385D4257CDF}.Release.ActiveCfg = Release|Win32
|
||||||
{71D05C32-B49A-4690-AA4D-1385D4257CDF}.Release.Build.0 = Release|Win32
|
{71D05C32-B49A-4690-AA4D-1385D4257CDF}.Release.Build.0 = Release|Win32
|
||||||
|
{20CF9907-2F82-4A8C-A5FB-074F5F1BCB32}.Debug.ActiveCfg = Debug|Win32
|
||||||
|
{20CF9907-2F82-4A8C-A5FB-074F5F1BCB32}.Debug.Build.0 = Debug|Win32
|
||||||
|
{20CF9907-2F82-4A8C-A5FB-074F5F1BCB32}.Release.ActiveCfg = Release|Win32
|
||||||
|
{20CF9907-2F82-4A8C-A5FB-074F5F1BCB32}.Release.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
|
Loading…
Reference in a new issue