Removed the SDL dependency from Draw.h

Should make compiling with VC++ 2003 simpler
This commit is contained in:
Clownacy 2019-02-18 20:40:07 +00:00
parent 132d3c5110
commit e5caff593c
16 changed files with 81 additions and 34 deletions

View file

@ -1,12 +1,15 @@
#include "Back.h"
#include <stdio.h>
#include "WindowsWrapper.h" #include "WindowsWrapper.h"
#include "Tags.h" #include "Tags.h"
#include "Back.h"
#include "Frame.h" #include "Frame.h"
#include "Game.h" #include "Game.h"
#include "Draw.h" #include "Draw.h"
#include "Stage.h" #include "Stage.h"
#include "Map.h" #include "Map.h"
#include "File.h"
BACK gBack; BACK gBack;
int gWaterY; int gWaterY;
@ -16,21 +19,48 @@ bool InitBack(char *fName, int type)
//Get width and height //Get width and height
char path[PATH_LENGTH]; char path[PATH_LENGTH];
sprintf(path, "%s/%s.pbm", gDataPath, fName); sprintf(path, "%s/%s.pbm", gDataPath, fName);
SDL_Surface *temp = SDL_LoadBMP(path); FILE *fp = fopen(path, "rb");
if (!temp) if (fp == NULL)
{ {
sprintf(path, "%s/%s.bmp", gDataPath, fName); sprintf(path, "%s/%s.bmp", gDataPath, fName);
temp = SDL_LoadBMP(path); fp = fopen(path, "rb");
if (!temp) if (fp == NULL)
return false; return false;
} }
gBack.partsW = temp->w; #ifdef FIX_BUGS // TODO: Maybe we need a 'BETTER_PORTABILITY' flag
gBack.partsH = temp->h; if (fgetc(fp) != 'B' || fgetc(fp) != 'M')
{
SDL_FreeSurface(temp); fclose(fp);
return false;
}
fseek(fp, 18, SEEK_SET);
gBack.partsW = File_ReadLE32(fp);
gBack.partsH = File_ReadLE32(fp);
fclose(fp);
#else
// This is ridiculously platform-dependant:
// It should break on big-endian CPUs, and platforms
// where short isn't 16-bit and long isn't 32-bit.
short bmp_header_buffer[7];
long bmp_header_buffer2[10];
fread(bmp_header_buffer, 14, 1, fp);
// Check if this is a valid bitmap file
if (bmp_header_buffer[0] != 0x4D42) // 'MB' (we use hex to prevent a compiler warning)
return false; // The original game forgets to close fp
fread(bmp_header_buffer2, 40, 1, fp);
fclose(fp);
gBack.partsW = bmp_header_buffer2[1];
gBack.partsH = bmp_header_buffer2[2];
#endif
//Set background stuff and load texture //Set background stuff and load texture
gBack.flag = 1; gBack.flag = 1;
if (!ReloadBitmap_File(fName, SURFACE_ID_LEVEL_BACKGROUND)) if (!ReloadBitmap_File(fName, SURFACE_ID_LEVEL_BACKGROUND))

View file

@ -1,4 +1,7 @@
#include "Bullet.h" #include "Bullet.h"
#include <string.h>
#include "Draw.h" #include "Draw.h"
#include "Caret.h" #include "Caret.h"
#include "NpChar.h" #include "NpChar.h"

View file

@ -1,8 +1,9 @@
#include <string> #include "Caret.h"
#include <string.h>
#include "WindowsWrapper.h" #include "WindowsWrapper.h"
#include "Caret.h"
#include "Draw.h" #include "Draw.h"
#include "Triangle.h" #include "Triangle.h"
#include "Game.h" #include "Game.h"

View file

@ -27,6 +27,17 @@
#include "Tags.h" #include "Tags.h"
#include "Resource.h" #include "Resource.h"
struct SURFACE
{
bool in_use;
bool needs_updating;
SDL_Surface *surface;
SDL_Texture *texture;
};
SDL_Window *gWindow;
SDL_Renderer *gRenderer;
RECT grcGame = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT}; RECT grcGame = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
RECT grcFull = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT}; RECT grcFull = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};

View file

@ -1,10 +1,6 @@
#pragma once #pragma once
#include <stdint.h> #include <stdint.h>
#include "WindowsWrapper.h" #include "WindowsWrapper.h"
#include <SDL_render.h>
extern SDL_Window *gWindow;
extern SDL_Renderer *gRenderer;
extern RECT grcGame; extern RECT grcGame;
extern RECT grcFull; extern RECT grcFull;
@ -48,13 +44,7 @@ typedef enum Surface_Ids
SURFACE_ID_MAX = 40, SURFACE_ID_MAX = 40,
} Surface_Ids; } Surface_Ids;
struct SURFACE struct SURFACE;
{
bool in_use;
bool needs_updating;
SDL_Surface *surface;
SDL_Texture *texture;
};
extern SURFACE surf[SURFACE_ID_MAX]; extern SURFACE surf[SURFACE_ID_MAX];

View file

@ -1,11 +1,14 @@
#include "Ending.h"
#include <stdint.h> #include <stdint.h>
#include <string> #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "WindowsWrapper.h" #include "WindowsWrapper.h"
#include "Tags.h" #include "Tags.h"
#include "Generic.h" #include "Generic.h"
#include "Ending.h"
#include "Flags.h" #include "Flags.h"
#include "KeyControl.h" #include "KeyControl.h"
#include "Escape.h" #include "Escape.h"

View file

@ -1,4 +1,4 @@
#include <string> #include <string.h>
#include "WindowsWrapper.h" #include "WindowsWrapper.h"

View file

@ -21,14 +21,15 @@
#include "Triangle.h" #include "Triangle.h"
#include "Resource.h" #include "Resource.h"
// These two are defined in Draw.cpp. This is a bit of a hack.
extern SDL_Window *gWindow;
extern SDL_Renderer *gRenderer;
char gModulePath[PATH_LENGTH]; char gModulePath[PATH_LENGTH];
char gDataPath[PATH_LENGTH]; char gDataPath[PATH_LENGTH];
int gJoystickButtonTable[8]; int gJoystickButtonTable[8];
SDL_Window *gWindow;
SDL_Renderer *gRenderer;
bool gbUseJoystick = false; bool gbUseJoystick = false;
bool bFps = false; bool bFps = false;

View file

@ -1,6 +1,7 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <string> #include <stdlib.h>
#include <string.h>
#include "WindowsWrapper.h" #include "WindowsWrapper.h"

View file

@ -1,5 +1,5 @@
#include <stdint.h> #include <stdint.h>
#include <string> #include <string.h>
#include "CommonDefines.h" #include "CommonDefines.h"
#include "MapName.h" #include "MapName.h"

View file

@ -1,4 +1,5 @@
#include <stdint.h> #include <stdint.h>
#include <string.h>
#include "WindowsWrapper.h" #include "WindowsWrapper.h"

View file

@ -1,5 +1,5 @@
#include <string>
#include <stdint.h> #include <stdint.h>
#include <string.h>
#include "WindowsWrapper.h" #include "WindowsWrapper.h"

View file

@ -1,3 +1,5 @@
#include "SDL.h"
#include "Sound.h" #include "Sound.h"
#include "MyChar.h" #include "MyChar.h"
#include "MycParam.h" #include "MycParam.h"

View file

@ -1,6 +1,7 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include "WindowsWrapper.h" #include "WindowsWrapper.h"

View file

@ -1,4 +1,5 @@
#include <stdint.h> #include <stdint.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include "WindowsWrapper.h" #include "WindowsWrapper.h"

View file

@ -1,5 +1,7 @@
#include <stdint.h> #include <stdint.h>
#include <string> #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "WindowsWrapper.h" #include "WindowsWrapper.h"