Browse Source

Reorder automap.cpp

pull/910/head
Anders Jenbo 5 years ago
parent
commit
30e61ed9a0
  1. 220
      Source/automap.cpp
  2. 17
      Source/automap.h

220
Source/automap.cpp

@ -214,102 +214,10 @@ void AutomapZoomOut()
}
}
/**
* @brief Renders the automap on screen.
*/
void DrawAutomap()
{
int cells;
int sx, sy;
int i, j;
int mapx, mapy;
if (leveltype == DTYPE_TOWN) {
DrawAutomapText();
return;
}
gpBufEnd = &gpBuffer[BUFFER_WIDTH * (SCREEN_Y + VIEWPORT_HEIGHT)];
AutoMapX = (ViewX - 16) >> 1;
while (AutoMapX + AutoMapXOfs < 0)
AutoMapXOfs++;
while (AutoMapX + AutoMapXOfs >= DMAXX)
AutoMapXOfs--;
AutoMapX += AutoMapXOfs;
AutoMapY = (ViewY - 16) >> 1;
while (AutoMapY + AutoMapYOfs < 0)
AutoMapYOfs++;
while (AutoMapY + AutoMapYOfs >= DMAXY)
AutoMapYOfs--;
AutoMapY += AutoMapYOfs;
cells = AmShiftTab[(AutoMapScale - 50) / 5];
if (ScrollInfo._sxoff + ScrollInfo._syoff)
cells++;
mapx = AutoMapX - cells;
mapy = AutoMapY - 1;
if (cells & 1) {
sx = SCREEN_WIDTH / 2 + SCREEN_X - AmLine64 * ((cells - 1) >> 1);
sy = (SCREEN_HEIGHT - PANEL_HEIGHT) / 2 + SCREEN_Y - AmLine32 * ((cells + 1) >> 1);
} else {
sx = SCREEN_WIDTH / 2 + SCREEN_X - AmLine64 * (cells >> 1) + AmLine32;
sy = (SCREEN_HEIGHT - PANEL_HEIGHT) / 2 + SCREEN_Y - AmLine32 * (cells >> 1) - AmLine16;
}
if (ViewX & 1) {
sx -= AmLine16;
sy -= AmLine8;
}
if (ViewY & 1) {
sx += AmLine16;
sy -= AmLine8;
}
sx += AutoMapScale * ScrollInfo._sxoff / 100 >> 1;
sy += AutoMapScale * ScrollInfo._syoff / 100 >> 1;
if (invflag || sbookflag) {
sx -= SCREEN_WIDTH / 4;
}
if (chrflag || questlog) {
sx += SCREEN_WIDTH / 4;
}
for (i = 0; i <= cells + 1; i++) {
int x = sx;
int y;
for (j = 0; j < cells; j++) {
WORD maptype = GetAutomapType(mapx + j, mapy - j, TRUE);
if (maptype != 0)
DrawAutomapTile(x, sy, maptype);
x += AmLine64;
}
mapy++;
x = sx - AmLine32;
y = sy + AmLine16;
for (j = 0; j <= cells; j++) {
WORD maptype = GetAutomapType(mapx + j, mapy - j, TRUE);
if (maptype != 0)
DrawAutomapTile(x, y, maptype);
x += AmLine64;
}
mapx++;
sy += AmLine32;
}
DrawAutomapPlr();
#ifdef HELLFIRE
if (AutoMapShowItems)
SearchAutomapItem();
#endif
DrawAutomapText();
}
/**
* @brief Renders the given automap shape at the specified screen coordinates.
*/
void DrawAutomapTile(int sx, int sy, WORD automap_type)
static void DrawAutomapTile(int sx, int sy, WORD automap_type)
{
BOOL do_vert;
BOOL do_horz;
@ -493,7 +401,21 @@ void DrawAutomapTile(int sx, int sy, WORD automap_type)
DrawLine(sx, sy + AmLine16, sx + AmLine32, sy, COLOR_DIM);
}
}
#ifdef HELLFIRE
static void DrawAutomapItem(int x, int y, BYTE color)
{
int x1, y1, x2, y2;
x1 = x - AmLine32 / 2;
y1 = y - AmLine16 / 2;
x2 = x1 + AmLine64 / 2;
y2 = y1 + AmLine32 / 2;
DrawLine(x, y1, x1, y, color);
DrawLine(x, y1, x2, y, color);
DrawLine(x, y2, x1, y, color);
DrawLine(x, y2, x2, y, color);
}
void SearchAutomapItem()
{
@ -557,26 +479,12 @@ void SearchAutomapItem()
}
}
}
void DrawAutomapItem(int x, int y, BYTE color)
{
int x1, y1, x2, y2;
x1 = x - AmLine32 / 2;
y1 = y - AmLine16 / 2;
x2 = x1 + AmLine64 / 2;
y2 = y1 + AmLine32 / 2;
DrawLine(x, y1, x1, y, color);
DrawLine(x, y1, x2, y, color);
DrawLine(x, y2, x1, y, color);
DrawLine(x, y2, x2, y, color);
}
#endif
/**
* @brief Renders an arrow on the automap, centered on and facing the direction of the player.
*/
void DrawAutomapPlr()
static void DrawAutomapPlr()
{
int px, py;
int x, y;
@ -651,7 +559,7 @@ void DrawAutomapPlr()
/**
* @brief Returns the automap shape at the given coordinate.
*/
WORD GetAutomapType(int x, int y, BOOL view)
static WORD GetAutomapType(int x, int y, BOOL view)
{
WORD rv;
@ -700,7 +608,7 @@ WORD GetAutomapType(int x, int y, BOOL view)
/**
* @brief Renders game info, such as the name of the current level, and in multi player the name of the game and the game password.
*/
void DrawAutomapText()
static void DrawAutomapText()
{
char desc[256];
int nextline = 20;
@ -734,6 +642,98 @@ void DrawAutomapText()
}
}
/**
* @brief Renders the automap on screen.
*/
void DrawAutomap()
{
int cells;
int sx, sy;
int i, j;
int mapx, mapy;
if (leveltype == DTYPE_TOWN) {
DrawAutomapText();
return;
}
gpBufEnd = &gpBuffer[BUFFER_WIDTH * (SCREEN_Y + VIEWPORT_HEIGHT)];
AutoMapX = (ViewX - 16) >> 1;
while (AutoMapX + AutoMapXOfs < 0)
AutoMapXOfs++;
while (AutoMapX + AutoMapXOfs >= DMAXX)
AutoMapXOfs--;
AutoMapX += AutoMapXOfs;
AutoMapY = (ViewY - 16) >> 1;
while (AutoMapY + AutoMapYOfs < 0)
AutoMapYOfs++;
while (AutoMapY + AutoMapYOfs >= DMAXY)
AutoMapYOfs--;
AutoMapY += AutoMapYOfs;
cells = AmShiftTab[(AutoMapScale - 50) / 5];
if (ScrollInfo._sxoff + ScrollInfo._syoff)
cells++;
mapx = AutoMapX - cells;
mapy = AutoMapY - 1;
if (cells & 1) {
sx = SCREEN_WIDTH / 2 + SCREEN_X - AmLine64 * ((cells - 1) >> 1);
sy = (SCREEN_HEIGHT - PANEL_HEIGHT) / 2 + SCREEN_Y - AmLine32 * ((cells + 1) >> 1);
} else {
sx = SCREEN_WIDTH / 2 + SCREEN_X - AmLine64 * (cells >> 1) + AmLine32;
sy = (SCREEN_HEIGHT - PANEL_HEIGHT) / 2 + SCREEN_Y - AmLine32 * (cells >> 1) - AmLine16;
}
if (ViewX & 1) {
sx -= AmLine16;
sy -= AmLine8;
}
if (ViewY & 1) {
sx += AmLine16;
sy -= AmLine8;
}
sx += AutoMapScale * ScrollInfo._sxoff / 100 >> 1;
sy += AutoMapScale * ScrollInfo._syoff / 100 >> 1;
if (invflag || sbookflag) {
sx -= SCREEN_WIDTH / 4;
}
if (chrflag || questlog) {
sx += SCREEN_WIDTH / 4;
}
for (i = 0; i <= cells + 1; i++) {
int x = sx;
int y;
for (j = 0; j < cells; j++) {
WORD maptype = GetAutomapType(mapx + j, mapy - j, TRUE);
if (maptype != 0)
DrawAutomapTile(x, sy, maptype);
x += AmLine64;
}
mapy++;
x = sx - AmLine32;
y = sy + AmLine16;
for (j = 0; j <= cells; j++) {
WORD maptype = GetAutomapType(mapx + j, mapy - j, TRUE);
if (maptype != 0)
DrawAutomapTile(x, y, maptype);
x += AmLine64;
}
mapx++;
sy += AmLine32;
}
DrawAutomapPlr();
#ifdef HELLFIRE
if (AutoMapShowItems)
SearchAutomapItem();
#endif
DrawAutomapText();
}
/**
* @brief Marks the given coordinate as within view on the automap.
*/

17
Source/automap.h

@ -6,18 +6,9 @@
#ifndef __AUTOMAP_H__
#define __AUTOMAP_H__
extern WORD automaptype[512];
extern BOOL automapflag;
extern char AmShiftTab[32];
extern BOOLEAN automapview[DMAXX][DMAXY];
extern int AutoMapScale;
extern int AutoMapXOfs;
extern int AutoMapYOfs;
extern int AmLine64;
extern int AmLine32;
extern int AmLine16;
extern int AmLine8;
extern int AmLine4;
void InitAutomapOnce();
void InitAutomap();
@ -29,14 +20,6 @@ void AutomapRight();
void AutomapZoomIn();
void AutomapZoomOut();
void DrawAutomap();
void DrawAutomapTile(int screen_x, int screen_y, WORD automap_type);
#ifdef HELLFIRE
void SearchAutomapItem();
void DrawAutomapItem(int x, int y, BYTE color);
#endif
void DrawAutomapPlr();
WORD GetAutomapType(int x, int y, BOOL view);
void DrawAutomapText();
void SetAutomapView(int x, int y);
void AutomapZoomReset();

Loading…
Cancel
Save