1 /*
2  * Triplane Classic - a side-scrolling dogfighting game.
3  * Copyright (C) 1996,1997,2009  Dodekaedron Software Creations Oy
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  *
18  * tjt@users.sourceforge.net
19  */
20 
21 #include <string.h>
22 #include <assert.h>
23 #include "gfx/gfx.h"
24 #include "io/video.h"
25 
26 static void do_isa_clear(void);
27 
28 Bitmap *standard_background = NULL;
29 
putpix(int x,int y,unsigned char c,int x1,int y1,int x2,int y2)30 void putpix(int x, int y, unsigned char c, int x1, int y1, int x2, int y2) {
31     if (x < x1)
32         return;
33     if (x > x2)
34         return;
35     if (y < y1)
36         return;
37     if (y > y2)
38         return;
39     if (update_vircr_mode) {
40         if (current_mode == VGA_MODE) {
41             vircr[x + (y << 8) + (y << 6)] = c;
42         } else {
43             vircr[x + y * 800] = c;
44         }
45     }
46 
47     if (!draw_with_vircr_mode)
48         fillrect(x, y, 1, 1, c);
49 }
50 
draw_line(int x1,int y1,int x2,int y2,unsigned char vari)51 void draw_line(int x1, int y1, int x2, int y2, unsigned char vari) {
52     int omalask;
53 
54     if (x1 == x2) {
55         if (y1 > y2) {
56             omalask = y1;
57             y1 = y2;
58             y2 = omalask;
59         }
60         fill_vircr(x1, y1, x2, y2, vari);
61     } else if (y1 == y2) {
62         if (x1 > x2) {
63             omalask = x1;
64             x1 = x2;
65             x2 = omalask;
66         }
67         fill_vircr(x1, y1, x2, y2, vari);
68     }
69 
70 
71 }
72 
boxi(int x1,int y1,int x2,int y2,unsigned char vari)73 void boxi(int x1, int y1, int x2, int y2, unsigned char vari) {
74     draw_line(x1, y1, x2, y1, vari);
75     draw_line(x1, y1, x1, y2, vari);
76     draw_line(x2, y2, x2, y1, vari);
77     draw_line(x2, y2, x1, y2, vari);
78 }
79 
fill_vircr(int x1,int y1,int x2,int y2,unsigned char vari)80 void fill_vircr(int x1, int y1, int x2, int y2, unsigned char vari) {
81     int lasky;
82 
83     if (update_vircr_mode) {
84         for (lasky = y1; lasky <= y2; lasky++)
85             memset(&vircr[x1 + lasky * 320], vari, x2 - x1 + 1);
86     }
87 
88     if (!draw_with_vircr_mode)
89         fillrect(x1, y1, x2 - x1 + 1, y2 - y1 + 1, vari);
90 }
91 
tyhjaa_vircr(void)92 void tyhjaa_vircr(void) {
93     if (standard_background == NULL) {
94         if (current_mode == VGA_MODE) {
95             fill_vircr(0, 0, 319, 199, 0);
96         } else {
97             assert(current_mode == SVGA_MODE);
98             fill_vircr(0, 0, 799, 599, 0);
99         }
100 
101         do_isa_clear();
102     }
103 }
104 
do_isa_clear(void)105 static void do_isa_clear(void) {
106     if (!standard_background) {
107         return;
108     }
109 
110     if (current_mode == VGA_MODE) {
111         standard_background->blit_fullscreen();
112     } else {
113         standard_background->blit(0, 0, 0, 0, 799, 599);
114     }
115 
116 }
117 
do_all_clear(int do_retrace)118 void do_all_clear(int do_retrace) {
119     do_all();
120     do_isa_clear();
121 }
122