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