2 * Functions for handling modex and doing other basic graphics stuff.
8 #include "src/lib/types.h"
9 #include "src/lib/bitmap.h"
10 #include "src/lib/planar.h"
11 #include "src/lib/lib_head.h"
13 /* -========================== Types & Macros ==========================- */
14 #define PAGE_OFFSET(x,y) (((y)<<6)+((y)<<4)+((x)>>2))
15 #define PLANE(x) (1<< (x&3))
16 #define SELECT_ALL_PLANES() outpw(0x03c4, 0xff02)
19 byte far* data; /* the data for the page */
20 word dx; /* col we are viewing on the virtual screen */
21 word dy; /* row we are viewing on the virtual screen */
22 word width; /* virtual width of the page */
23 word height; /* virtual height of the page */
33 /* -============================ Functions =============================- */
34 /* mode switching, page, and plane functions */
37 page_t modexDefaultPage();
38 page_t modexNextPage(page_t *p);
39 page_t modexNextPage0(page_t *p, word x, word y);
40 void modexShowPage(page_t *page);
41 void modexPanPage(page_t *page, int dx, int dy);
42 void modexSelectPlane(byte plane);
43 void modexClearRegion(page_t *page, int x, int y, int w, int h, byte color);
44 void oldDrawBmp(byte far* page, int x, int y, bitmap_t *bmp, byte sprite);
45 void modexDrawBmp(page_t *page, int x, int y, bitmap_t *bmp);
46 void modexDrawBmpRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, bitmap_t *bmp);
47 void modexDrawPlanarBuf(page_t *page, int x, int y, planar_buf_t *bmp);
48 void modexDrawSprite(page_t *page, int x, int y, bitmap_t *bmp);
49 void modexDrawSpriteRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, bitmap_t *bmp);
50 void modexCopyPageRegion(page_t *dest, page_t *src, word sx, word sy, word dx, word dy, word width, word height);
52 /* Palette fade and flash effects */
53 void modexFadeOn(word fade, byte *palette);
54 void modexFadeOff(word fade, byte *palette);
55 void modexFlashOn(word fade, byte *palette);
56 void modexFlashOff(word fade, byte *palette);
58 /* palette loading and saving */
59 void modexPalSave(byte *palette);
61 void modexLoadPalFile(char *filename, byte **palette);
62 void modexSavePalFile(char *filename, byte *palette);
64 /* fixed palette functions */
68 /* utility functions */
69 void modexPalUpdate(bitmap_t *bmp, word *i, word qp, word aqoffset);
70 void modexPalUpdate1(byte *p);
71 void modexPalUpdate0(byte *p);
72 void chkcolor(bitmap_t *bmp, word *q, word *a, word *aa, word *z, word *i/*, word *offset*/);
73 void modexWaitBorder();
74 byte far *bios_8x8_font(void);
75 void bputs(page_t *pee, int x, int y, const byte far *s);
77 /* -======================= Constants & Vars ==========================- */
78 extern byte far* VGA; /* The VGA Memory */
79 //extern word text_mask[16];
80 #define SCREEN_SEG 0xa000
81 #define VIDEO_INT 0x10
83 #define VGA_256_COLOR_MODE 0x13
84 #define TEXT_MODE 0x03
85 #define SCREEN_WIDTH 320
86 #define SCREEN_HEIGHT 240
87 #define PAGE_SIZE (word)(SCREEN_WIDTH/4 * SCREEN_HEIGHT)
89 #define AC_INDEX 0x03c0
90 #define SC_INDEX 0x03c4
91 #define SC_DATA 0x03c5
92 #define CRTC_INDEX 0x03d4
93 #define CRTC_DATA 0x03d5
94 #define GC_INDEX 0x03ce
95 #define MISC_OUTPUT 0x03c2
96 #define HIGH_ADDRESS 0x0C
97 #define LOW_ADDRESS 0x0D
99 #define INPUT_STATUS_1 0x03da
100 #define DISPLAY_ENABLE 0x01
101 #define MAP_MASK 0x02
102 #define PAL_READ_REG 0x03C7 /* Color register, read address */
103 #define PAL_WRITE_REG 0x03C8 /* Color register, write address */
104 #define PAL_DATA_REG 0x03C9 /* Color register, data port */
105 #define PAL_SIZE (256 * 3)