Made Back.cpp about as ASM-accurate as I can make it
...without removing the widescreen stuff, at least.
This commit is contained in:
parent
e1e49a4dcc
commit
fbaf46548f
4 changed files with 57 additions and 52 deletions
61
src/Back.cpp
61
src/Back.cpp
|
@ -15,7 +15,7 @@
|
||||||
BACK gBack;
|
BACK gBack;
|
||||||
int gWaterY;
|
int gWaterY;
|
||||||
|
|
||||||
bool InitBack(char *fName, int type)
|
BOOL InitBack(const char *fName, int type)
|
||||||
{
|
{
|
||||||
//Get width and height
|
//Get width and height
|
||||||
char path[PATH_LENGTH];
|
char path[PATH_LENGTH];
|
||||||
|
@ -27,14 +27,14 @@ bool InitBack(char *fName, int type)
|
||||||
sprintf(path, "%s/%s.bmp", gDataPath, fName);
|
sprintf(path, "%s/%s.bmp", gDataPath, fName);
|
||||||
fp = fopen(path, "rb");
|
fp = fopen(path, "rb");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
return false;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FIX_BUGS // TODO: Maybe we need a 'BETTER_PORTABILITY' flag
|
#ifdef FIX_BUGS // TODO: Maybe we need a 'BETTER_PORTABILITY' flag
|
||||||
if (fgetc(fp) != 'B' || fgetc(fp) != 'M')
|
if (fgetc(fp) != 'B' || fgetc(fp) != 'M')
|
||||||
{
|
{
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return false;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
fseek(fp, 18, SEEK_SET);
|
fseek(fp, 18, SEEK_SET);
|
||||||
|
@ -53,7 +53,7 @@ bool InitBack(char *fName, int type)
|
||||||
|
|
||||||
// Check if this is a valid bitmap file
|
// Check if this is a valid bitmap file
|
||||||
if (bmp_header_buffer[0] != 0x4D42) // 'MB' (we use hex to prevent a compiler warning)
|
if (bmp_header_buffer[0] != 0x4D42) // 'MB' (we use hex to prevent a compiler warning)
|
||||||
return false; // The original game forgets to close fp
|
return FALSE; // The original game forgets to close fp
|
||||||
|
|
||||||
fread(bmp_header_buffer2, 40, 1, fp);
|
fread(bmp_header_buffer2, 40, 1, fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
@ -65,22 +65,25 @@ bool InitBack(char *fName, int type)
|
||||||
//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))
|
||||||
return false;
|
return FALSE;
|
||||||
gBack.type = type;
|
gBack.type = type;
|
||||||
gWaterY = 0x1E0000;
|
gWaterY = 0x1E0000;
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActBack()
|
void ActBack()
|
||||||
{
|
{
|
||||||
if (gBack.type == 5)
|
switch (gBack.type)
|
||||||
{
|
{
|
||||||
gBack.fx += 0xC00;
|
case 5:
|
||||||
}
|
gBack.fx += 0xC00;
|
||||||
else if (gBack.type >= 5 && gBack.type <= 7)
|
break;
|
||||||
{
|
|
||||||
++gBack.fx;
|
case 6:
|
||||||
gBack.fx %= 640;
|
case 7:
|
||||||
|
++gBack.fx;
|
||||||
|
gBack.fx %= 640;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,35 +198,35 @@ void PutBack(int fx, int fy)
|
||||||
|
|
||||||
void PutFront(int fx, int fy)
|
void PutFront(int fx, int fy)
|
||||||
{
|
{
|
||||||
RECT rcWater[2];
|
RECT rcWater[2] = {{0, 0, 32, 16}, {0, 16, 32, 48}};
|
||||||
rcWater[0] = {0, 0, 32, 16};
|
|
||||||
rcWater[1] = {0, 16, 32, 48};
|
|
||||||
|
|
||||||
if (gBack.type == 3)
|
switch (gBack.type)
|
||||||
{
|
{
|
||||||
int x_1 = fx / 0x4000;
|
case 3:
|
||||||
int x_2 = x_1 + (((WINDOW_WIDTH + 31) >> 5) + 1);
|
int x_1 = fx / 0x4000;
|
||||||
int y_1 = 0;
|
int x_2 = x_1 + (((WINDOW_WIDTH + 31) >> 5) + 1);
|
||||||
int y_2 = y_1 + 32;
|
int y_1 = 0;
|
||||||
|
int y_2 = y_1 + 32;
|
||||||
for (int y = y_1; y < y_2; y++)
|
|
||||||
{
|
|
||||||
int ypos = (y << 14) / 0x200 - fy / 0x200 + gWaterY / 0x200;
|
|
||||||
|
|
||||||
if (ypos >= -32)
|
for (int y = y_1; y < y_2; y++)
|
||||||
{
|
{
|
||||||
|
int ypos = (y * 0x20 * 0x200) / 0x200 - fy / 0x200 + gWaterY / 0x200;
|
||||||
|
|
||||||
|
if (ypos < -32)
|
||||||
|
break;
|
||||||
|
|
||||||
if (ypos > WINDOW_HEIGHT)
|
if (ypos > WINDOW_HEIGHT)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
for (int x = x_1; x < x_2; x++)
|
for (int x = x_1; x < x_2; x++)
|
||||||
{
|
{
|
||||||
int xpos = (x << 14) / 0x200 - fx / 0x200;
|
int xpos = (x * 0x20 * 0x200) / 0x200 - fx / 0x200;
|
||||||
PutBitmap3(&grcGame, xpos, ypos, &rcWater[1], SURFACE_ID_LEVEL_BACKGROUND);
|
PutBitmap3(&grcGame, xpos, ypos, &rcWater[1], SURFACE_ID_LEVEL_BACKGROUND);
|
||||||
if (!y)
|
if (!y)
|
||||||
PutBitmap3(&grcGame, xpos, ypos, rcWater, SURFACE_ID_LEVEL_BACKGROUND);
|
PutBitmap3(&grcGame, xpos, ypos, rcWater, SURFACE_ID_LEVEL_BACKGROUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Draw black bars
|
//Draw black bars
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "WindowsWrapper.h"
|
||||||
|
|
||||||
struct BACK
|
struct BACK
|
||||||
{
|
{
|
||||||
int flag;
|
int flag;
|
||||||
|
@ -14,7 +16,7 @@ struct BACK
|
||||||
extern BACK gBack;
|
extern BACK gBack;
|
||||||
extern int gWaterY;
|
extern int gWaterY;
|
||||||
|
|
||||||
bool InitBack(char *fName, int type);
|
BOOL InitBack(const char *fName, int type);
|
||||||
void ActBack();
|
void ActBack();
|
||||||
void PutBack(int fx, int fy);
|
void PutBack(int fx, int fy);
|
||||||
void PutFront(int fx, int fy);
|
void PutFront(int fx, int fy);
|
||||||
|
|
32
src/Draw.cpp
32
src/Draw.cpp
|
@ -78,7 +78,7 @@ BOOL Flip_SystemTask()
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StartDirectDraw(int lMagnification, int lColourDepth)
|
BOOL StartDirectDraw(int lMagnification, int lColourDepth)
|
||||||
{
|
{
|
||||||
//Initialize rendering
|
//Initialize rendering
|
||||||
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
||||||
|
@ -107,7 +107,7 @@ bool StartDirectDraw(int lMagnification, int lColourDepth)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EndDirectDraw()
|
void EndDirectDraw()
|
||||||
|
@ -144,9 +144,9 @@ void ReleaseSurface(int s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MakeSurface_Generic(int bxsize, int bysize, Surface_Ids surf_no)
|
BOOL MakeSurface_Generic(int bxsize, int bysize, Surface_Ids surf_no)
|
||||||
{
|
{
|
||||||
bool success = false;
|
BOOL success = FALSE;
|
||||||
|
|
||||||
#ifdef FIX_BUGS
|
#ifdef FIX_BUGS
|
||||||
if (surf_no >= SURFACE_ID_MAX)
|
if (surf_no >= SURFACE_ID_MAX)
|
||||||
|
@ -184,7 +184,7 @@ bool MakeSurface_Generic(int bxsize, int bysize, Surface_Ids surf_no)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
surf[surf_no].in_use = true;
|
surf[surf_no].in_use = true;
|
||||||
success = true;
|
success = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -303,7 +303,7 @@ static bool LoadBitmap(SDL_RWops *fp, Surface_Ids surf_no, bool create_surface)
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool LoadBitmap_File(const char *name, Surface_Ids surf_no, bool create_surface)
|
static BOOL LoadBitmap_File(const char *name, Surface_Ids surf_no, bool create_surface)
|
||||||
{
|
{
|
||||||
char path[PATH_LENGTH];
|
char path[PATH_LENGTH];
|
||||||
SDL_RWops *fp;
|
SDL_RWops *fp;
|
||||||
|
@ -322,7 +322,7 @@ static bool LoadBitmap_File(const char *name, Surface_Ids surf_no, bool create_s
|
||||||
{
|
{
|
||||||
printf("Loading surface (as .pbm) from %s for surface id %d\n", path, surf_no);
|
printf("Loading surface (as .pbm) from %s for surface id %d\n", path, surf_no);
|
||||||
if (LoadBitmap(fp, surf_no, create_surface))
|
if (LoadBitmap(fp, surf_no, create_surface))
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,14 +333,14 @@ static bool LoadBitmap_File(const char *name, Surface_Ids surf_no, bool create_s
|
||||||
{
|
{
|
||||||
printf("Loading surface (as .bmp) from %s for surface id %d\n", path, surf_no);
|
printf("Loading surface (as .bmp) from %s for surface id %d\n", path, surf_no);
|
||||||
if (LoadBitmap(fp, surf_no, create_surface))
|
if (LoadBitmap(fp, surf_no, create_surface))
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Failed to open file %s\n", name);
|
printf("Failed to open file %s\n", name);
|
||||||
return false;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool LoadBitmap_Resource(const char *res, Surface_Ids surf_no, bool create_surface)
|
static BOOL LoadBitmap_Resource(const char *res, Surface_Ids surf_no, bool create_surface)
|
||||||
{
|
{
|
||||||
SDL_RWops *fp = FindResource(res);
|
SDL_RWops *fp = FindResource(res);
|
||||||
|
|
||||||
|
@ -348,29 +348,29 @@ static bool LoadBitmap_Resource(const char *res, Surface_Ids surf_no, bool creat
|
||||||
{
|
{
|
||||||
printf("Loading surface from resource %s for surface id %d\n", res, surf_no);
|
printf("Loading surface from resource %s for surface id %d\n", res, surf_no);
|
||||||
if (LoadBitmap(fp, surf_no, create_surface))
|
if (LoadBitmap(fp, surf_no, create_surface))
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Failed to open resource %s\n", res);
|
printf("Failed to open resource %s\n", res);
|
||||||
return false;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MakeSurface_File(const char *name, Surface_Ids surf_no)
|
BOOL MakeSurface_File(const char *name, Surface_Ids surf_no)
|
||||||
{
|
{
|
||||||
return LoadBitmap_File(name, surf_no, true);
|
return LoadBitmap_File(name, surf_no, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MakeSurface_Resource(const char *res, Surface_Ids surf_no)
|
BOOL MakeSurface_Resource(const char *res, Surface_Ids surf_no)
|
||||||
{
|
{
|
||||||
return LoadBitmap_Resource(res, surf_no, true);
|
return LoadBitmap_Resource(res, surf_no, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReloadBitmap_File(const char *name, Surface_Ids surf_no)
|
BOOL ReloadBitmap_File(const char *name, Surface_Ids surf_no)
|
||||||
{
|
{
|
||||||
return LoadBitmap_File(name, surf_no, false);
|
return LoadBitmap_File(name, surf_no, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReloadBitmap_Resource(const char *res, Surface_Ids surf_no)
|
BOOL ReloadBitmap_Resource(const char *res, Surface_Ids surf_no)
|
||||||
{
|
{
|
||||||
return LoadBitmap_Resource(res, surf_no, false);
|
return LoadBitmap_Resource(res, surf_no, false);
|
||||||
}
|
}
|
||||||
|
|
12
src/Draw.h
12
src/Draw.h
|
@ -51,14 +51,14 @@ struct SURFACE;
|
||||||
extern SURFACE surf[SURFACE_ID_MAX];
|
extern SURFACE surf[SURFACE_ID_MAX];
|
||||||
|
|
||||||
BOOL Flip_SystemTask();
|
BOOL Flip_SystemTask();
|
||||||
bool StartDirectDraw(int lMagnification, int lColourDepth);
|
BOOL StartDirectDraw(int lMagnification, int lColourDepth);
|
||||||
void EndDirectDraw();
|
void EndDirectDraw();
|
||||||
void ReleaseSurface(int s);
|
void ReleaseSurface(int s);
|
||||||
bool MakeSurface_File(const char *name, Surface_Ids surf_no);
|
BOOL MakeSurface_File(const char *name, Surface_Ids surf_no);
|
||||||
bool MakeSurface_Resource(const char *res, Surface_Ids surf_no);
|
BOOL MakeSurface_Resource(const char *res, Surface_Ids surf_no);
|
||||||
bool ReloadBitmap_File(const char *name, Surface_Ids surf_no);
|
BOOL ReloadBitmap_File(const char *name, Surface_Ids surf_no);
|
||||||
bool ReloadBitmap_Resource(const char *res, Surface_Ids surf_no);
|
BOOL ReloadBitmap_Resource(const char *res, Surface_Ids surf_no);
|
||||||
bool MakeSurface_Generic(int bxsize, int bysize, Surface_Ids surf_no);
|
BOOL MakeSurface_Generic(int bxsize, int bysize, Surface_Ids surf_no);
|
||||||
void BackupSurface(Surface_Ids surf_no, RECT *rect);
|
void BackupSurface(Surface_Ids surf_no, RECT *rect);
|
||||||
void PutBitmap3(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no);
|
void PutBitmap3(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no);
|
||||||
void PutBitmap4(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no);
|
void PutBitmap4(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no);
|
||||||
|
|
Loading…
Add table
Reference in a new issue