OSDN Git Service

color palette updater dose not operate the way i want it to....
[proj16/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 /* -============================ Functions =============================- */
25 /* mode switching, page, and plane functions */
26 void modexEnter();
27 void modexLeave();
28 page_t modexDefaultPage();
29 page_t modexNextPage(page_t *p);
30 void modexShowPage(page_t *page);
31 void modexPanPage(page_t *page, int dx, int dy);
32 void modexSelectPlane(byte plane);
33 void modexClearRegion(page_t *page, int x, int y, int w, int h, byte color);
34 void modexDrawBmp(page_t *page, int x, int y, bitmap_t *bmp);
35 void modexDrawBmpRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, bitmap_t *bmp);
36 void modexDrawPlanarBuf(page_t *page, int x, int y, planar_buf_t *bmp);
37 void modexDrawSprite(page_t *page, int x, int y, bitmap_t *bmp);
38 void modexDrawSpriteRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, bitmap_t *bmp);
39 void modexCopyPageRegion(page_t *dest, page_t *src, word sx, word sy, word dx, word dy, word width, word height);
40
41 /* Palette fade and flash effects */
42 void modexFadeOn(word fade, byte *palette);
43 void modexFadeOff(word fade, byte *palette);
44 void modexFlashOn(word fade, byte *palette);
45 void modexFlashOff(word fade, byte *palette);
46
47 /* palette loading and saving */
48 void modexPalSave(byte *palette);
49 byte *modexNewPal();
50 void modexLoadPalFile(char *filename, byte **palette);
51 void modexSavePalFile(char *filename, byte *palette);
52
53 /* fixed palette functions */
54 void modexPalBlack();
55 void modexPalWhite();
56
57 /* utility functions */
58 void modexPalUpdate(bitmap_t *bmp, word *i, word qp, word qr);
59 void modexPalUpdate2(byte *p);
60 void chkcolor(bitmap_t *bmp, word *q, word *a, word *aa, word *z);
61 void modexWaitBorder();
62
63 /* -======================= Constants & Vars ==========================- */
64 extern byte far*  VGA;  /* The VGA Memory */
65 #define SCREEN_SEG              0xa000
66 #define VIDEO_INT               0x10
67 #define SET_MODE                0x00
68 #define VGA_256_COLOR_MODE      0x13
69 #define TEXT_MODE               0x03
70 #define SCREEN_WIDTH            320
71 #define SCREEN_HEIGHT           240
72 #define PAGE_SIZE               (word)(SCREEN_WIDTH/4 * SCREEN_HEIGHT)
73
74 #define AC_INDEX                0x03c0
75 #define SC_INDEX                0x03c4
76 #define SC_DATA                 0x03c5
77 #define CRTC_INDEX              0x03d4
78 #define CRTC_DATA               0x03d5
79 #define GC_INDEX                0x03ce
80 #define MISC_OUTPUT             0x03c2
81 #define HIGH_ADDRESS            0x0C
82 #define LOW_ADDRESS             0x0D
83 #define VRETRACE                0x08
84 #define INPUT_STATUS_1          0x03da
85 #define DISPLAY_ENABLE          0x01
86 #define MAP_MASK                0x02
87 #define PAL_READ_REG            0x03C7   /* Color register, read address */
88 #define PAL_WRITE_REG           0x03C8   /* Color register, write address */
89 #define PAL_DATA_REG            0x03C9   /* Color register, data port */
90 #define PAL_SIZE                (256 * 3)
91 #endif