]> 4ch.mooo.com Git - 16.git/blob - src/lib/modex16.h
major changes to entire project for tweaking it amd making it cleaner!! OK PNGWEN...
[16.git] / src / lib / modex16.h
1 /* Project 16 Source Code~
2  * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669
3  *
4  * This file is part of Project 16.
5  *
6  * Project 16 is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Project 16 is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or
18  * write to the Free Software Foundation, Inc., 51 Franklin Street,
19  * Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  */
22 /*
23  * Functions for handling modex and doing other basic graphics stuff.
24  */
25 #ifndef MODEX16_H
26 #define MODEX16_H
27 //#include <conio.h>
28
29 #include "src/lib/types.h"
30 #include "src/lib/bitmap.h"
31 #include "src/lib/planar.h"
32 #include "src/lib/lib_head.h"
33
34 /* -========================== Types & Macros ==========================- */
35 #define PAGE_OFFSET(x,y) (((y)<<6)+((y)<<4)+((x)>>2))
36 #define PLANE(x) (1<< (x&3))
37 #define SELECT_ALL_PLANES() outpw(0x03c4, 0xff02)
38
39 typedef struct {
40         word id;        /* the Identification number of the page~ For layering~ */
41     byte far* data;     /* the data for the page */
42     word dx;            /* col we are viewing on the virtual screen */
43     word dy;            /* row we are viewing on the virtual screen */
44     word width;         /* virtual width of the page */
45     word height;        /* virtual height of the page */
46 } page_t;
47
48 typedef union
49 {
50         byte red;
51         byte green;
52         byte blue;
53 } rgb_t;
54
55 /* -============================ Functions =============================- */
56 /* mode switching, page, and plane functions */
57 void modexEnter();
58 void modexLeave();
59 page_t modexDefaultPage();
60 page_t modexNextPage(page_t *p);
61 page_t modexNextPage0(page_t *p, word x, word y);
62 void modexShowPage(page_t *page);
63 void modexPanPage(page_t *page, int dx, int dy);
64 void modexSelectPlane(byte plane);
65 void modexClearRegion(page_t *page, int x, int y, int w, int h, byte color);
66 void oldDrawBmp(byte far* page, int x, int y, bitmap_t *bmp, byte sprite);
67 void modexDrawBmp(page_t *page, int x, int y, bitmap_t *bmp);
68 void modexDrawBmpRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, bitmap_t *bmp);
69 void modexDrawPlanarBuf(page_t *page, int x, int y, planar_buf_t *bmp);
70 void modexDrawSprite(page_t *page, int x, int y, bitmap_t *bmp);
71 void modexDrawSpriteRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, bitmap_t *bmp);
72 void modexCopyPageRegion(page_t *dest, page_t *src, word sx, word sy, word dx, word dy, word width, word height);
73
74 /* Palette fade and flash effects */
75 void modexFadeOn(word fade, byte *palette);
76 void modexFadeOff(word fade, byte *palette);
77 void modexFlashOn(word fade, byte *palette);
78 void modexFlashOff(word fade, byte *palette);
79
80 /* palette loading and saving */
81 void modexPalSave(byte *palette);
82 byte *modexNewPal();
83 void modexLoadPalFile(char *filename, byte **palette);
84 void modexSavePalFile(char *filename, byte *palette);
85
86 /* fixed palette functions */
87 void modexPalBlack();
88 void modexPalWhite();
89
90 /* utility functions */
91 void modexPalUpdate(bitmap_t *bmp, word *i, word qp, word aqoffset);
92 void modexPalUpdate1(byte *p);
93 void modexPalUpdate0(byte *p);
94 void chkcolor(bitmap_t *bmp, word *q, word *a, word *aa, word *z, word *i/*, word *offset*/);
95 void modexWaitBorder();
96 byte far *bios_8x8_font(void);
97 void bputs(page_t *pee, int x, int y, const byte far *s);
98
99 /* -======================= Constants & Vars ==========================- */
100 extern byte far*  VGA;  /* The VGA Memory */
101 //extern word text_mask[16];
102 #define SCREEN_SEG              0xa000
103 #define VIDEO_INT               0x10
104 #define SET_MODE                0x00
105 #define VGA_256_COLOR_MODE      0x13
106 #define TEXT_MODE               0x03
107 #define SCREEN_WIDTH            320
108 #define SCREEN_HEIGHT           240
109 #define PAGE_SIZE               (word)(SCREEN_WIDTH/4 * SCREEN_HEIGHT)
110
111 #define AC_INDEX                0x03c0
112 #define SC_INDEX                0x03c4
113 #define SC_DATA                 0x03c5
114 #define CRTC_INDEX              0x03d4
115 #define CRTC_DATA               0x03d5
116 #define GC_INDEX                0x03ce
117 #define MISC_OUTPUT             0x03c2
118 #define HIGH_ADDRESS            0x0C
119 #define LOW_ADDRESS             0x0D
120 #define VRETRACE                0x08
121 #define INPUT_STATUS_1          0x03da
122 #define DISPLAY_ENABLE          0x01
123 #define MAP_MASK                0x02
124 #define PAL_READ_REG            0x03C7   /* Color register, read address */
125 #define PAL_WRITE_REG           0x03C8   /* Color register, write address */
126 #define PAL_DATA_REG            0x03C9   /* Color register, data port */
127 #define PAL_SIZE                (256 * 3)
128 #endif