diff --git a/src/vga.c b/src/vga.c
index f2e5b44079941a7db71016564543efc4f664f44c..8347b3ae55c0400becdbd67cb796e6d6b8ad60fe 100644 (file)
--- a/src/vga.c
+++ b/src/vga.c
#include "view.h"
#include "memory.h"
#include "misc.h"
#include "view.h"
#include "memory.h"
#include "misc.h"
+#include "files.h"
#include <assert.h>
// адрес экранного буфера
#include <assert.h>
// адрес экранного буфера
-unsigned char *scra;
+//unsigned char *scra;
// виртуальный экран
// виртуальный экран
-unsigned char scrbuf[64000];
-
+//unsigned char scrbuf[64000];
int SCRW = 800;
int SCRH = 600;
int SCRW = 800;
int SCRH = 600;
+char fullscreen = OFF;
-SDL_Surface* screen = NULL;
-
-int cx1,cx2,cy1,cy2;
+byte bright[256];
+byte mixmap[256][256];
+byte clrmap[256*12];
-char fullscreen = OFF;
+static SDL_Surface* screen = NULL;
+static int cx1,cx2,cy1,cy2;
+static byte flametab[16] = {
+ 0xBC,0xBA,0xB8,0xB6,0xB4,0xB2,0xB0,0xD5,0xD6,0xD7,0xA1,0xA0,0xE3,0xE2,0xE1,0xE0
+};
+static int offx = 0;
+static int offy = 0;
#define HQ 2
#define HQ 2
return V_getvgaimg(F_getresid(name));
}
return V_getvgaimg(F_getresid(name));
}
-short V_init(void)
-{
+short V_init (void) {
Uint32 flags = SDL_SWSURFACE|SDL_DOUBLEBUF|SDL_HWPALETTE;
if (fullscreen) flags = flags | SDL_FULLSCREEN;
screen = SDL_SetVideoMode(SCRW, SCRH, 8, flags);
Uint32 flags = SDL_SWSURFACE|SDL_DOUBLEBUF|SDL_HWPALETTE;
if (fullscreen) flags = flags | SDL_FULLSCREEN;
screen = SDL_SetVideoMode(SCRW, SCRH, 8, flags);
}
// переключение в текстовый режим
}
// переключение в текстовый режим
-void V_done(void)
-{
+void V_done (void) {
SDL_Quit();
}
SDL_Quit();
}
-void draw_rect (int x, int y, int w, int h, int c)
-{
+static void draw_rect (int x, int y, int w, int h, int c) {
SDL_Rect dstrect;
dstrect.x = x*HQ;
dstrect.y = y*HQ;
SDL_Rect dstrect;
dstrect.x = x*HQ;
dstrect.y = y*HQ;
}
// установить область вывода
}
// установить область вывода
-void V_setrect(short x,short w,short y,short h)
-{
+void V_setrect (short x,short w,short y,short h) {
SDL_Rect r;
r.x=x*HQ;
r.y=y*HQ;
SDL_Rect r;
r.x=x*HQ;
r.y=y*HQ;
if (cy2>=SCRH) cy2=SCRH-1;
}
if (cy2>=SCRH) cy2=SCRH-1;
}
-void putpixel(int x, int y, Uint8 color)
-{
+static void putpixel (int x, int y, Uint8 color) {
if(x>=cx1 && x<=cx2 && y>=cy1 && y<=cy2) {
x*=HQ;
y*=HQ;
if(x>=cx1 && x<=cx2 && y>=cy1 && y<=cy2) {
x*=HQ;
y*=HQ;
}
}
}
}
-byte getpixel(int x, int y)
-{
+static byte getpixel (int x, int y) {
if(x>=cx1 && x<=cx2 && y>=cy1 && y<=cy2) {
x*=HQ;
y*=HQ;
if(x>=cx1 && x<=cx2 && y>=cy1 && y<=cy2) {
x*=HQ;
y*=HQ;
return 0;
}
return 0;
}
-void mappixel(int x,int y,byte* cmap)
-{
+static void mappixel (int x, int y, byte* cmap) {
byte c = getpixel(x,y);
putpixel(x,y,cmap[c]);
}
byte c = getpixel(x,y);
putpixel(x,y,cmap[c]);
}
-int offx = 0;
-int offy = 0;
-
-void V_center(int f)
-{
+void V_center (int f) {
if (f) V_offset(SCRW/2-320/2, SCRH/2-200/2);
else V_offset(0, 0);
}
if (f) V_offset(SCRW/2-320/2, SCRH/2-200/2);
else V_offset(0, 0);
}
-void V_offset(int ox, int oy)
-{
+void V_offset (int ox, int oy) {
offx=ox;
offy=oy;
}
offx=ox;
offy=oy;
}
-void draw_spr(short x,short y,vgaimg *i, int d, int c)
-{
+static void draw_spr (short x, short y, vgaimg *i, int d, int c) {
if (i==NULL) return;
x += offx;
y += offy;
if (i==NULL) return;
x += offx;
y += offy;
}
}
}
}
-void V_rotspr (int x, int y, vgaimg* i, int d)
-{
+void V_rotspr (int x, int y, vgaimg* i, int d) {
x+=i->w*((d&1)?1:0);
y+=i->h*((d&2)?1:0);
draw_spr(x,y,i,d,0);
}
x+=i->w*((d&1)?1:0);
y+=i->h*((d&2)?1:0);
draw_spr(x,y,i,d,0);
}
-void V_pic(short x,short y,vgaimg *i)
-{
- draw_spr(x,y,i, 0, 0);
+void V_pic (short x, short y, vgaimg *i) {
+ draw_spr(x, y, i, 0, 0);
}
}
-void V_manspr(int x,int y,void *p, unsigned char c)
-{
- draw_spr(x,y,p, 0, c);
+void V_manspr (int x, int y, void *p, unsigned char c) {
+ draw_spr(x, y, p, 0, c);
}
}
-void V_manspr2(int x,int y,void *p, unsigned char c)
-{
- draw_spr(x,y,p, 1, c);
+void V_manspr2(int x,int y,void *p, unsigned char c) {
+ draw_spr(x, y, p, 1, c);
}
// вывести точку цвета c в координатах (x,y)
}
// вывести точку цвета c в координатах (x,y)
-void V_dot(short x,short y, unsigned char c)
-{
+void V_dot (short x,short y, unsigned char c) {
putpixel(x,y,c);
}
putpixel(x,y,c);
}
-
-extern byte bright[256];
-extern byte flametab[16];
-extern byte mixmap[256][256];
-
-void smoke_sprf(int x, int y, byte c)
-{
+void smoke_sprf (int x, int y, byte c) {
byte t = getpixel(x,y);
c = c + bright[t];
c += 0x60;
byte t = getpixel(x,y);
c = c + bright[t];
c += 0x60;
putpixel(x,y,mixmap[c][t]);
}
putpixel(x,y,mixmap[c][t]);
}
-void flame_sprf(int x, int y, byte c)
-{
+void flame_sprf (int x, int y, byte c) {
byte t = getpixel(x,y);
c = c + bright[t];
putpixel(x,y,flametab[c]);
}
byte t = getpixel(x,y);
c = c + bright[t];
putpixel(x,y,flametab[c]);
}
-void V_sprf(short x,short y,vgaimg *i,spr_f *f)
-{
+void V_sprf (short x,short y,vgaimg *i,spr_f *f) {
if (i==NULL) return;
x-=i->sx;
y-=i->sy;
if (i==NULL) return;
x-=i->sx;
y-=i->sy;
}
}
}
}
-void V_spr(short x,short y,vgaimg *i)
-{
- draw_spr(x,y,i,0, 0);
+void V_spr (short x, short y, vgaimg *i) {
+ draw_spr(x, y, i, 0, 0);
}
}
-void V_spr2(short x,short y,vgaimg *i)
-{
+void V_spr2 (short x, short y, vgaimg *i) {
draw_spr(x,y,i,1,0);
}
draw_spr(x,y,i,1,0);
}
-void V_clr(short x,short w,short y,short h,unsigned char c)
-{
- draw_rect(x,y,w,h, c);
-}
-
-// установить палитру из массива p
-void VP_setall(void *p)
-{
- VP_set(p, 0, 256);
+void V_clr (short x, short w, short y, short h, unsigned char c) {
+ draw_rect(x, y, w, h, c);
}
// установить n цветов, начиная с f, из массива p
}
// установить n цветов, начиная с f, из массива p
-void VP_set(void *p,short f,short n)
-{
+static void VP_set (void *p, short f, short n) {
byte *ptr = (byte*)p;
SDL_Color colors[256];
int i;
byte *ptr = (byte*)p;
SDL_Color colors[256];
int i;
SDL_SetPalette(screen, SDL_LOGPAL|SDL_PHYSPAL, colors, f, n);
}
SDL_SetPalette(screen, SDL_LOGPAL|SDL_PHYSPAL, colors, f, n);
}
+// установить палитру из массива p
+void VP_setall (void *p) {
+ VP_set(p, 0, 256);
+}
+
// установить адрес экранного буфера
// NULL - реальный экран
// установить адрес экранного буфера
// NULL - реальный экран
-void V_setscr(void *p)
-{
+void V_setscr (void *p) {
if (screen) SDL_Flip(screen);
}
// скопировать прямоугольник на экран
if (screen) SDL_Flip(screen);
}
// скопировать прямоугольник на экран
-void V_copytoscr(short x,short w,short y,short h)
-{
+void V_copytoscr (short x, short w, short y, short h) {
x*=HQ; y*=HQ; w*=HQ; h*=HQ;
SDL_UpdateRect(screen, x, y, w, h);
}
x*=HQ; y*=HQ; w*=HQ; h*=HQ;
SDL_UpdateRect(screen, x, y, w, h);
}
-void V_maptoscr(int x,int w,int y,int h,void *cmap)
-{
+void V_maptoscr (int x, int w, int y, int h, void *cmap) {
int cx,cy;
for (cx=x; cx<x+w; cx++)
for (cy=y; cy<y+h; cy++)
int cx,cy;
for (cx=x; cx<x+w; cx++)
for (cy=y; cy<y+h; cy++)
V_copytoscr(x,w,y,h);
}
V_copytoscr(x,w,y,h);
}
-void V_remap_rect(int x,int y,int w,int h,byte *cmap)
-{
+void V_remap_rect (int x, int y, int w, int h, byte *cmap) {
int cx,cy;
for (cx=x; cx<x+w; cx++)
for (cy=y; cy<y+h; cy++)
mappixel(cx,cy,cmap);
}
int cx,cy;
for (cx=x; cx<x+w; cx++)
for (cy=y; cy<y+h; cy++)
mappixel(cx,cy,cmap);
}
-extern void *walp[256];
-extern byte clrmap[256*12];
-
-void Z_drawfld(byte *fld, int bg)
-{
- byte *p = fld;
- int x,y;
- for (y=0; y<FLDH; y++)
- {
- for (x=0; x<FLDW; x++)
- {
- int sx = x*CELW-w_x+WD/2;
- int sy = y*CELH-w_y+HT/2+1+w_o;
-
-
- if (*p) {
- vgaimg *pic = walp[*p];
- if ((int)pic <= 3) {
- if (!bg) {
- byte *cmap = clrmap + ((int)pic+7)*256;
- V_remap_rect(sx, sy, CELW, CELH, cmap);
- }
- }
- else {
- V_pic(sx, sy, pic);
- }
- }
-
- p++;
- }
- }
-}
-
-void V_toggle()
-{
+void V_toggle (void) {
if (!SDL_WM_ToggleFullScreen(screen)) {
int ncolors = screen->format->palette->ncolors;
SDL_Color colors[256];
if (!SDL_WM_ToggleFullScreen(screen)) {
int ncolors = screen->format->palette->ncolors;
SDL_Color colors[256];