OSDN Git Service

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