123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375 |
- /* Catacomb Armageddon Source Code
- * Copyright (C) 1993-2014 Flat Rock Software
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
- // ID_VW.H
- #ifndef __TYPES__
- #include "ID_TYPES.H"
- #endif
- #ifndef __ID_MM__
- #include "ID_MM.H"
- #endif
- #ifndef __ID_GLOB__
- #include "ID_GLOB.H"
- #endif
- #define __ID_VW__
- //===========================================================================
- #define G_P_SHIFT 4 // global >> ?? = pixels
- #if GRMODE == EGAGR
- #define SCREENWIDTH 40
- #define CHARWIDTH 1
- #define TILEWIDTH 2
- #define GRPLANES 4
- #define BYTEPIXELS 8
- #endif
- #if GRMODE == CGAGR
- #define SCREENWIDTH 128
- #define CHARWIDTH 2
- #define TILEWIDTH 4
- #define GRPLANES 1
- #define BYTEPIXELS 4
- #endif
- #define VIRTUALHEIGHT 300
- #define VIRTUALWIDTH 512
- #if GRMODE == CGAGR
- #define MAXSHIFTS 1
- #define WHITE 3 // graphics mode independant colors
- #define BLACK 0
- #define FIRSTCOLOR 1
- #define SECONDCOLOR 2
- #define F_WHITE 0 // for XOR font drawing
- #define F_BLACK 3
- #define F_FIRSTCOLOR 2
- #define F_SECONDCOLOR 1
- #endif
- #if GRMODE == EGAGR
- #define MAXSHIFTS 4
- #define WHITE 15 // graphics mode independant colors
- #define BLACK 0
- #define LT_GREY 7
- #define FIRSTCOLOR 1
- #define SECONDCOLOR 12
- #define F_WHITE 0 // for XOR font drawing
- #define F_BLACK 15
- #define F_FIRSTCOLOR 14
- #define F_SECONDCOLOR 3
- #endif
- #if GRMODE == EGAGR
- #define SCREENXMASK (~7)
- #define SCREENXPLUS (7)
- #define SCREENXDIV (8)
- #endif
- #if GRMODE == CGAGR
- #define SCREENXMASK (~3)
- #define SCREENXDIV (4)
- #endif
- //===========================================================================
- #define SC_INDEX 0x3C4
- #define SC_RESET 0
- #define SC_CLOCK 1
- #define SC_MAPMASK 2
- #define SC_CHARMAP 3
- #define SC_MEMMODE 4
- #define CRTC_INDEX 0x3D4
- #define CRTC_H_TOTAL 0
- #define CRTC_H_DISPEND 1
- #define CRTC_H_BLANK 2
- #define CRTC_H_ENDBLANK 3
- #define CRTC_H_RETRACE 4
- #define CRTC_H_ENDRETRACE 5
- #define CRTC_V_TOTAL 6
- #define CRTC_OVERFLOW 7
- #define CRTC_ROWSCAN 8
- #define CRTC_MAXSCANLINE 9
- #define CRTC_CURSORSTART 10
- #define CRTC_CURSOREND 11
- #define CRTC_STARTHIGH 12
- #define CRTC_STARTLOW 13
- #define CRTC_CURSORHIGH 14
- #define CRTC_CURSORLOW 15
- #define CRTC_V_RETRACE 16
- #define CRTC_V_ENDRETRACE 17
- #define CRTC_V_DISPEND 18
- #define CRTC_OFFSET 19
- #define CRTC_UNDERLINE 20
- #define CRTC_V_BLANK 21
- #define CRTC_V_ENDBLANK 22
- #define CRTC_MODE 23
- #define CRTC_LINECOMPARE 24
- #define GC_INDEX 0x3CE
- #define GC_SETRESET 0
- #define GC_ENABLESETRESET 1
- #define GC_COLORCOMPARE 2
- #define GC_DATAROTATE 3
- #define GC_READMAP 4
- #define GC_MODE 5
- #define GC_MISCELLANEOUS 6
- #define GC_COLORDONTCARE 7
- #define GC_BITMASK 8
- #define ATR_INDEX 0x3c0
- #define ATR_MODE 16
- #define ATR_OVERSCAN 17
- #define ATR_COLORPLANEENABLE 18
- #define ATR_PELPAN 19
- #define ATR_COLORSELECT 20
- #define STATUS_REGISTER_1 0x3da
- //===========================================================================
- typedef enum {NOcard,MDAcard,CGAcard,EGAcard,MCGAcard,VGAcard,
- HGCcard=0x80,HGCPcard,HICcard} cardtype;
- typedef struct
- {
- int width,
- height,
- orgx,orgy,
- xl,yl,xh,yh,
- shifts;
- } spritetabletype;
- typedef struct
- {
- unsigned sourceoffset[MAXSHIFTS];
- unsigned planesize[MAXSHIFTS];
- unsigned width[MAXSHIFTS];
- byte data[];
- } spritetype; // the memptr for each sprite points to this
- typedef struct
- {
- int width,height;
- } pictabletype;
- typedef struct
- {
- int height;
- int location[256];
- char width[256];
- } fontstruct;
- typedef enum {CGAgr,EGAgr,VGAgr} grtype;
- //===========================================================================
- extern cardtype videocard; // set by VW_Startup
- extern grtype grmode; // CGAgr, EGAgr, VGAgr
- extern unsigned bufferofs; // hidden port to draw to before displaying
- extern unsigned displayofs; // origin of port on visable screen
- extern unsigned panx,pany; // panning adjustments inside port in pixels
- extern unsigned pansx,pansy;
- extern unsigned panadjust; // panx/pany adjusted by screen resolution
- extern unsigned screenseg; // normally 0xa000 or buffer segment
- extern unsigned linewidth;
- extern unsigned ylookup[VIRTUALHEIGHT];
- extern boolean screenfaded;
- extern char colors[7][17]; // pallets for fades
- extern pictabletype _seg *pictable;
- extern pictabletype _seg *picmtable;
- extern spritetabletype _seg *spritetable;
- extern unsigned fontnumber; // 0 based font number for drawing
- extern int px,py;
- extern byte pdrawmode,fontcolor;
- extern int bordercolor;
- //
- // asm globals
- //
- extern unsigned *shifttabletable[8];
- extern unsigned bufferwidth,bufferheight,screenspot; // used by font drawing stuff
- //===========================================================================
- void VW_Startup (void);
- void VW_Shutdown (void);
- cardtype VW_VideoID (void);
- //
- // EGA hardware routines
- //
- #define EGAWRITEMODE(x) asm{cli;mov dx,GC_INDEX;mov ax,GC_MODE+256*x;out dx,ax;sti;}
- #define EGABITMASK(x) asm{cli;mov dx,GC_INDEX;mov ax,GC_BITMASK+256*x;out dx,ax;sti;}
- #define EGAMAPMASK(x) asm{cli;mov dx,SC_INDEX;mov ax,SC_MAPMASK+x*256;out dx,ax;sti;}
- #define EGAREADMAP(x) asm{cli;mov dx,GC_INDEX;mov ax,GC_READMAP+x*256;out dx,ax;sti;}
- void VW_SetLineWidth(int width);
- void VW_SetSplitScreen(int width);
- void VW_SetScreen (unsigned CRTC, unsigned pelpan);
- void VW_SetScreenMode (int grmode);
- void VW_ClearVideo (int color);
- void VW_WaitVBL (int number);
- void VW_ColorBorder (int color);
- void VW_SetPalette(byte *palette);
- void VW_SetDefaultColors(void);
- void VW_FadeOut(void);
- void VW_FadeIn(void);
- void VW_FadeUp(void);
- void VW_FadeDown(void);
- void VW_SetAtrReg (int reg, int value);
- //
- // block primitives
- //
- void VW_MaskBlock(memptr segm,unsigned ofs,unsigned dest,
- unsigned wide,unsigned height,unsigned planesize);
- void VW_MemToScreen(memptr source,unsigned dest,unsigned width,unsigned height);
- void VW_MemToScreen2x(memptr source,unsigned dest,unsigned width,unsigned height);
- void VW_ScreenToMem(unsigned source,memptr dest,unsigned width,unsigned height);
- void VW_ScreenToScreen(unsigned source,unsigned dest,unsigned width,unsigned height);
- //
- // block addressable routines
- //
- void VW_DrawTile8(unsigned x, unsigned y, unsigned tile);
- #if GRMODE == EGAGR
- #define VW_DrawTile8M(x,y,t) \
- VW_MaskBlock(grsegs[STARTTILE8M],(t)*40,bufferofs+ylookup[y]+(x),1,8,8)
- #define VW_DrawTile16(x,y,t) \
- VW_MemToScreen(grsegs[STARTTILE16+t],bufferofs+ylookup[y]+(x),2,16)
- #define VW_DrawTile16M(x,y,t) \
- VW_MaskBlock(grsegs[STARTTILE16M],(t)*160,bufferofs+ylookup[y]+(x),2,16,32)
- #endif
- #if GRMODE == CGAGR
- #define VW_DrawTile8M(x,y,t) \
- VW_MaskBlock(grsegs[STARTTILE8M],(t)*32,bufferofs+ylookup[y]+(x),2,8,16)
- #define VW_DrawTile16(x,y,t) \
- VW_MemToScreen(grsegs[STARTTILE16+t],bufferofs+ylookup[y]+(x),4,16)
- #define VW_DrawTile16M(x,y,t) \
- VW_MaskBlock(grsegs[STARTTILE16M],(t)*128,bufferofs+ylookup[y]+(x),4,16,64)
- #endif
- void VW_DrawPic(unsigned x, unsigned y, unsigned chunknum);
- void VW_DrawPic2x(unsigned x, unsigned y, unsigned chunknum);
- void VW_DrawMPic(unsigned x, unsigned y, unsigned chunknum);
- void VW_ClipDrawMPic(unsigned x, int y, unsigned chunknum);
- //
- // pixel addressable routines
- //
- void VW_MeasurePropString (char far *string, word *width, word *height);
- void VW_MeasureMPropString (char far *string, word *width, word *height);
- void VW_DrawPropString (char far *string);
- void VW_DrawMPropString (char far *string);
- void VW_DrawSprite(int x, int y, unsigned sprite);
- void VW_Plot(unsigned x, unsigned y, unsigned color);
- void VW_Hlin(unsigned xl, unsigned xh, unsigned y, unsigned color);
- void VW_Vlin(unsigned yl, unsigned yh, unsigned x, unsigned color);
- void VW_Bar (unsigned x, unsigned y, unsigned width, unsigned height,
- unsigned color);
- //===========================================================================
- //
- // Double buffer management routines
- //
- void VW_InitDoubleBuffer (void);
- void VW_FixRefreshBuffer (void);
- int VW_MarkUpdateBlock (int x1, int y1, int x2, int y2);
- void VW_UpdateScreen (void);
- void VW_CGAFullUpdate (void);
- //
- // cursor
- //
- void VW_ShowCursor (void);
- void VW_HideCursor (void);
- void VW_MoveCursor (int x, int y);
- void VW_SetCursor (int spritenum);
- void VW_FreeCursor (void);
- //
- // mode independant routines
- // coordinates in pixels, rounded to best screen res
- // regions marked in double buffer
- //
- void VWB_DrawTile8 (int x, int y, int tile);
- void VWB_DrawTile8M (int x, int y, int tile);
- void VWB_DrawTile16 (int x, int y, int tile);
- void VWB_DrawTile16M (int x, int y, int tile);
- void VWB_DrawPic (int x, int y, int chunknum);
- void VWB_DrawMPic(int x, int y, int chunknum);
- void VWB_Bar (int x, int y, int width, int height, int color);
- void VWB_DrawPropString (char far *string);
- void VWB_DrawMPropString (char far *string);
- void VWB_DrawSprite (int x, int y, int chunknum);
- void VWB_Plot (int x, int y, int color);
- void VWB_Hlin (int x1, int x2, int y, int color);
- void VWB_Vlin (int y1, int y2, int x, int color);
- void VWL_MeasureString (char far *string, word *width, word *height, fontstruct _seg *font);
- //===========================================================================
|