]> 4ch.mooo.com Git - 16.git/blob - src/lib/modex16.h
bakapi.exe has tile support switch wwww
[16.git] / src / lib / modex16.h
1 /* Project 16 Source Code~
2  * Copyright (C) 2012-2016 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
28 #include "src/lib/16_head.h"
29 #include "src/lib/bitmap.h"
30 #include "src/lib/planar.h"
31 #include "src/lib/modex16/16planar.h"
32 #include "src/lib/16text.h"
33 #include "src/lib/modex16/16render.h"
34 #include "src/lib/modex16/320x240.h"
35 #include "src/lib/modex16/320x200.h"
36 #include "src/lib/modex16/256x192.h"
37 #include "src/lib/modex16/192x144_.h"
38 #include "src/lib/modex16/160x120.h"
39 extern byte gfxtest;
40
41 static struct pcxHeader {
42         byte id;
43         byte version;
44         byte encoding;
45         byte bpp;
46         word xmin;
47         word ymin;
48         word xmax;
49         word ymax;
50         word hres;
51         word vres;
52         byte pal16[48];
53         byte res1;
54         word bpplane;
55         word palType;
56         word hScreenSize;
57         word vScreenSize;
58         byte padding[54];
59 } head;
60
61 //320x240 = 20x15
62 //192x144 = 12x9
63
64 //temp defines
65 #define TILEWH 16
66 #define QUADWH                  TILEWH/2
67
68 /* -========================== Types & Macros ==========================- */
69 #define PAGE_OFFSET(x,y) (((y)<<6)+((y)<<4)+((x)>>2))
70 #define PLANE(x) (1<< (x&3))
71 #define SELECT_ALL_PLANES() outpw(0x03c4, 0xff02)
72 #define     PALSIZE            768
73
74 typedef union
75 {
76         byte red;
77         byte green;
78         byte blue;
79 } rgb_t;
80
81 /* -============================ Functions =============================- */
82 /* mode switching, page, and plane functions */
83 void VGAmodeX(sword vq, global_game_variables_t *gv);
84 void modexEnter(sword vq, global_game_variables_t *gv);
85 long vgaGetMode();
86 void modexLeave();
87 void modexsetBaseXMode(page_t *page);
88 page_t modexDefaultPage(page_t *p);
89 page_t modexNextPage(page_t *p);
90 page_t modexNextPageFlexibleSize(page_t *p, word x, word y);
91 void modexShowPage(page_t *page);
92 void modexPanPage(page_t *page, int dx, int dy);
93 void modexSelectPlane(byte plane);
94 void modexClearRegion(page_t *page, int x, int y, int w, int h, byte color);
95 /* moved to src/lib/modex16/16render.c */
96 void modexCopyPageRegion(page_t *dest, page_t *src, word sx, word sy, word dx, word dy, word width, word height);
97
98 /* Palette fade and flash effects */
99 void modexFadeOn(word fade, byte *palette);
100 void modexFadeOff(word fade, byte *palette);
101 void modexFlashOn(word fade, byte *palette);
102 void modexFlashOff(word fade, byte *palette);
103
104 /* palette loading and saving */
105 void modexPalSave(byte *palette);
106 byte *modexNewPal();
107 void modexLoadPalFile(char *filename, byte **palette);
108 void modexSavePalFile(char *filename, byte *palette);
109
110 /* fixed palette functions */
111 void modexPalBlack();
112 void modexPalWhite();
113
114 /* utility functions */
115 void modexPalUpdate(bitmap_t *bmp, word *i, word qp, word aqoffset);
116 void modexPalUpdate1(byte *p);
117 void modexPalUpdate0(byte *p);
118 void modexPalOverscan(byte *p, word col);
119 void chkcolor(bitmap_t *bmp, word *q, word *a, word *aa, word *z, word *i/*, word *offset*/);
120 void modexputPixel(page_t *page, int x, int y, byte color);
121 byte modexgetPixel(page_t *page, int x, int y);
122 void modexhlin(page_t *page, word xl, word xh, word y, word color);
123 void modexprint(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str, boolean q);
124 void modexprintbig(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str);
125 void pdump(page_t *pee);
126 void cls(page_t *page, byte color, byte *Where);
127 void modexWaitBorder();
128
129 /* -======================= Constants & Vars ==========================- */
130 extern byte far*  VGA;  /* The VGA Memory */
131 //extern int old_mode;
132 #define SCREEN_SEG              0xa000
133 #define VIDEO_INT               0x10
134 #define SET_MODE                0x00
135 #define VGA_256_COLOR_MODE      0x13
136 #define TEXT_MODE               0x03
137
138 #define AC_INDEX                0x03c0
139 #define SC_INDEX                0x03c4
140 #define SC_DATA                 0x03c5
141 #define CRTC_INDEX              0x03d4
142 #define CRTC_DATA               0x03d5
143 #define GC_INDEX                0x03ce
144 #define MISC_OUTPUT             0x03c2
145 #define HIGH_ADDRESS            0x0C
146 #define LOW_ADDRESS             0x0D
147 #define VRETRACE                0x08
148 //#define INPUT_STATUS_1                0x03da  defined in 16_head
149 #define DISPLAY_ENABLE          0x01
150 #define MAP_MASK                0x02
151 #define PAL_READ_REG                    0x03C7   /* Color register, read address */
152 #define PAL_WRITE_REG              0x03C8   /* Color register, write address */
153 #define PAL_DATA_REG                    0x03C9   /* Color register, data port */
154 #define PAL_SIZE                                (256 * 3)
155 #endif