]> 4ch.mooo.com Git - 16.git/blob - src/lib/modex16.h
fa9e54e05799e564cf4c00c98a453486804a8399
[16.git] / src / lib / modex16.h
1 /*
2  * Functions for handling modex and doing other basic graphics stuff.
3  */
4 #ifndef MODEX16_H
5 #define MODEX16_H
6 #include <conio.h>
7 #include "src/lib/types.h"
8 #include "src/lib/bitmap.h"
9 #include "src/lib/planar.h"
10
11 /* -========================== Types & Macros ==========================- */
12 #define PAGE_OFFSET(x,y) (((y)<<6)+((y)<<4)+((x)>>2))
13 #define PLANE(x) (1<< (x&3))
14 #define SELECT_ALL_PLANES() outpw(0x03c4, 0xff02)
15
16 typedef struct {
17     byte far* data;     /* the data for the page */
18     word dx;            /* col we are viewing on the virtual screen */
19     word dy;            /* row we are viewing on the virtual screen */
20     word width;         /* virtual width of the page */
21     word height;        /* virtual height of the page */
22 } page_t;
23
24 typedef union
25 {
26         byte red;
27         byte green;
28         byte blue;
29 } rgb_t;
30
31 /* -============================ Functions =============================- */
32 /* mode switching, page, and plane functions */
33 void modexEnter();
34 void modexLeave();
35 page_t modexDefaultPage();
36 page_t modexNextPage(page_t *p);
37 void modexShowPage(page_t *page);
38 void modexPanPage(page_t *page, int dx, int dy);
39 void modexSelectPlane(byte plane);
40 void modexClearRegion(page_t *page, int x, int y, int w, int h, byte color);
41 void modexDrawBmp(page_t *page, int x, int y, bitmap_t *bmp);
42 void modexDrawBmpRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, bitmap_t *bmp);
43 void modexDrawPlanarBuf(page_t *page, int x, int y, planar_buf_t *bmp);
44 void modexDrawSprite(page_t *page, int x, int y, bitmap_t *bmp);
45 void modexDrawSpriteRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, bitmap_t *bmp);
46 void modexCopyPageRegion(page_t *dest, page_t *src, word sx, word sy, word dx, word dy, word width, word height);
47
48 /* Palette fade and flash effects */
49 void modexFadeOn(word fade, byte *palette);
50 void modexFadeOff(word fade, byte *palette);
51 void modexFlashOn(word fade, byte *palette);
52 void modexFlashOff(word fade, byte *palette);
53
54 /* palette loading and saving */
55 void modexPalSave(byte *palette);
56 byte *modexNewPal();
57 void modexLoadPalFile(char *filename, byte **palette);
58 void modexSavePalFile(char *filename, byte *palette);
59
60 /* fixed palette functions */
61 void modexPalBlack();
62 void modexPalWhite();
63
64 /* utility functions */
65 void modexPalUpdate(bitmap_t *bmp, word *i, word qp, word aqoffset);
66 void modexPalUpdate1(byte *p);
67 void modexPalUpdate0(byte *p);
68 void chkcolor(bitmap_t *bmp, word *q, word *a, word *aa, word *z, word *i/*, word *offset*/);
69 void modexWaitBorder();
70
71 /* -======================= Constants & Vars ==========================- */
72 extern byte far*  VGA;  /* The VGA Memory */
73 #define SCREEN_SEG              0xa000
74 #define VIDEO_INT               0x10
75 #define SET_MODE                0x00
76 #define VGA_256_COLOR_MODE      0x13
77 #define TEXT_MODE               0x03
78 #define SCREEN_WIDTH            320
79 #define SCREEN_HEIGHT           240
80 #define PAGE_SIZE               (word)(SCREEN_WIDTH/4 * SCREEN_HEIGHT)
81
82 #define AC_INDEX                0x03c0
83 #define SC_INDEX                0x03c4
84 #define SC_DATA                 0x03c5
85 #define CRTC_INDEX              0x03d4
86 #define CRTC_DATA               0x03d5
87 #define GC_INDEX                0x03ce
88 #define MISC_OUTPUT             0x03c2
89 #define HIGH_ADDRESS            0x0C
90 #define LOW_ADDRESS             0x0D
91 #define VRETRACE                0x08
92 #define INPUT_STATUS_1          0x03da
93 #define DISPLAY_ENABLE          0x01
94 #define MAP_MASK                0x02
95 #define PAL_READ_REG            0x03C7   /* Color register, read address */
96 #define PAL_WRITE_REG           0x03C8   /* Color register, write address */
97 #define PAL_DATA_REG            0x03C9   /* Color register, data port */
98 #define PAL_SIZE                (256 * 3)
99 #endif