* tools.c *
***********************************************************/
-#include <stdarg.h>
-
-#if defined(PLATFORM_FREEBSD)
-#include <machine/joystick.h>
-#endif
-
#include "libgame/libgame.h"
#include "tools.h"
#include "game.h"
#include "events.h"
-#include "joystick.h"
#include "cartoons.h"
#include "network.h"
#include "tape.h"
}
}
+void RedrawPlayfield(boolean force_redraw, int x, int y, int width, int height)
+{
+ if (game_status == PLAYING)
+ {
+ if (force_redraw)
+ {
+ x = gfx.sx - TILEX;
+ y = gfx.sy - TILEY;
+ width = gfx.sxsize + 2 * TILEX;
+ height = gfx.sysize + 2 * TILEY;
+ }
+
+ if (force_redraw || setup.direct_draw)
+ {
+ int xx, yy;
+ int x1 = (x - SX) / TILEX, y1 = (y - SY) / TILEY;
+ int x2 = (x - SX + width) / TILEX, y2 = (y - SY + height) / TILEY;
+
+ if (setup.direct_draw)
+ SetDrawtoField(DRAW_BACKBUFFER);
+
+ for(xx=BX1; xx<=BX2; xx++)
+ for(yy=BY1; yy<=BY2; yy++)
+ if (xx >= x1 && xx <= x2 && yy >= y1 && yy <= y2)
+ DrawScreenField(xx, yy);
+ DrawAllPlayers();
+
+ if (setup.direct_draw)
+ SetDrawtoField(DRAW_DIRECT);
+ }
+
+ if (setup.soft_scrolling)
+ {
+ int fx = FX, fy = FY;
+
+ fx += (ScreenMovDir & (MV_LEFT|MV_RIGHT) ? ScreenGfxPos : 0);
+ fy += (ScreenMovDir & (MV_UP|MV_DOWN) ? ScreenGfxPos : 0);
+
+ BlitBitmap(fieldbuffer, backbuffer, fx,fy, SXSIZE,SYSIZE, SX,SY);
+ }
+ }
+
+ BlitBitmap(drawto, window, x, y, width, height, x, y);
+}
+
void BackToFront()
{
int x,y;
if (redraw_mask & REDRAW_FIELD)
redraw_mask &= ~REDRAW_TILES;
- if (!redraw_mask)
+ if (redraw_mask == REDRAW_NONE)
return;
if (global.fps_slowdown && game_status == PLAYING)
for(y=0; y<MAX_BUF_YSIZE; y++)
redraw[x][y] = 0;
redraw_tiles = 0;
- redraw_mask = 0;
+ redraw_mask = REDRAW_NONE;
}
void FadeToFront()
return 0;
}
+#define MAX_REQUEST_LINES 13
+#define MAX_REQUEST_LINE_LEN 7
+
boolean Request(char *text, unsigned int req_state)
{
int mx, my, ty, result = -1;
ClearRectangle(drawto, DX, DY, DXSIZE, DYSIZE);
/* write text for request */
- for(ty=0; ty<13; ty++)
+ for(ty=0; ty < MAX_REQUEST_LINES; ty++)
{
+ char text_line[MAX_REQUEST_LINE_LEN + 1];
int tx, tl, tc;
- char txt[256];
if (!*text)
break;
- for(tl=0,tx=0; tx<7; tl++,tx++)
+ for(tl=0,tx=0; tx < MAX_REQUEST_LINE_LEN; tl++,tx++)
{
tc = *(text + tx);
- if (!tc || tc == 32)
+ if (!tc || tc == ' ')
break;
}
+
if (!tl)
{
text++;
ty--;
continue;
}
- sprintf(txt, text);
- txt[tl] = 0;
- DrawTextExt(drawto, DX + 51 - (tl * 14)/2, DY + 8 + ty * 16,
- txt, FS_SMALL, FC_YELLOW);
- text += tl + (tc == 32 ? 1 : 0);
+
+ strncpy(text_line, text, tl);
+ text_line[tl] = 0;
+
+ DrawTextExt(drawto, DX + 50 - (tl * 14)/2, DY + 8 + ty * 16,
+ text_line, FS_SMALL, FC_YELLOW);
+
+ text += tl + (tc == ' ' ? 1 : 0);
}
if (req_state & REQ_ASK)
break;
case EVENT_KEYRELEASE:
- key_joystick_mapping = 0;
+ ClearPlayerAction();
break;
default:
unsigned int GetDoorState()
{
- return(MoveDoor(DOOR_GET_STATE));
+ return MoveDoor(DOOR_GET_STATE);
+}
+
+unsigned int SetDoorState(unsigned int door_state)
+{
+ return MoveDoor(door_state | DOOR_SET_STATE);
}
unsigned int MoveDoor(unsigned int door_state)
if (door_state == DOOR_GET_STATE)
return(door1 | door2);
+ if (door_state & DOOR_SET_STATE)
+ {
+ if (door_state & DOOR_ACTION_1)
+ door1 = door_state & DOOR_ACTION_1;
+ if (door_state & DOOR_ACTION_2)
+ door2 = door_state & DOOR_ACTION_2;
+
+ return(door1 | door2);
+ }
+
if (door1 == DOOR_OPEN_1 && door_state & DOOR_OPEN_1)
door_state &= ~DOOR_OPEN_1;
else if (door1 == DOOR_CLOSE_1 && door_state & DOOR_CLOSE_1)
}
};
-#if 0
-static void DoNotDisplayInfoText(void *ptr)
-{
- return;
-}
-#endif
-
void CreateToolButtons()
{
int i;
GDI_DECORATION_SIZE, MINI_TILEX, MINI_TILEY,
GDI_DECORATION_SHIFTING, 1, 1,
GDI_EVENT_MASK, event_mask,
-
-#if 0
- GDI_CALLBACK_INFO, DoNotDisplayInfoText,
-#endif
-
GDI_CALLBACK_ACTION, HandleToolButtons,
GDI_END);