ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
cga.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef CHAMBER_cga_H
23 #define CHAMBER_cga_H
24 
25 namespace Chamber {
26 
27 // HGA Constants
28 #define HGA_WIDTH 720
29 #define HGA_HEIGHT 348
30 #define HGA_BASE_SEG 0xB000
31 #define HGA_PAGE2_SEG 0xB800
32 #define HGA_NEXT_LINES_OFS 0x2000
33 #define HGA_BITS_PER_PIXEL 1
34 #define HGA_PIXELS_PER_BYTE (8 / HGA_BITS_PER_PIXEL)
35 #define HGA_BYTES_PER_LINE (HGA_WIDTH / HGA_PIXELS_PER_BYTE)
36 #define HGA_CALCXY_RAW(x, y) ( ((y) % 4) * HGA_NEXT_LINES_OFS + ((y) / 4) * HGA_BYTES_PER_LINE + (x) / HGA_PIXELS_PER_BYTE )
37 #define HGA_CENTERED_BASE_OFS HGA_CALCXY_RAW(-76, 8)
38 #ifdef __386__
39 #define HGA_SCREENBUFFER ((byte*)(HGA_BASE_SEG * 16))
40 #define HGA_BACKBUFFER ((byte*)(HGA_PAGE2_SEG * 16))
41 #else
42 #if 0
43 #define HGA_SCREENBUFFER ((byte*)MK_FP(HGA_BASE_SEG, 0))
44 #define HGA_BACKBUFFER ((byte*)MK_FP(HGA_PAGE2_SEG, 0))
45 
46 
47 #define HGA_FONT_HEIGHT 6
48 #define frontbuffer HGA_SCREENBUFFER
49 #define backbuffer HGA_BACKBUFFER
50 #endif
51 #endif
52 
53 // CGA Constants
54 #define CGA_WIDTH 320
55 #define CGA_HEIGHT 200
56 #define CGA_BASE_SEG 0xB800
57 #define CGA_ODD_LINES_OFS 0x2000
58 #define CGA_BITS_PER_PIXEL 2
59 #define CGA_PIXELS_PER_BYTE (8 / CGA_BITS_PER_PIXEL)
60 #define CGA_BYTES_PER_LINE (CGA_WIDTH / CGA_PIXELS_PER_BYTE)
61 
62 extern byte CGA_SCREENBUFFER[0xB800];
63 
64 #define CGA_FONT_HEIGHT 6
65 
66 #define CGA_NEXT_LINE(offs) ((CGA_ODD_LINES_OFS ^ (offs)) + (((offs) & CGA_ODD_LINES_OFS) ? 0 : CGA_BYTES_PER_LINE))
67 #define CGA_PREV_LINE(offs) ((CGA_ODD_LINES_OFS ^ (offs)) - (((offs) & CGA_ODD_LINES_OFS) ? CGA_BYTES_PER_LINE : 0))
68 
69 #define frontbuffer CGA_SCREENBUFFER
70 extern byte backbuffer[0xB800];
71 
72 extern byte sprit_load_buffer[1290];
73 
74 extern byte cga_pixel_flip[256];
75 
76 extern byte char_draw_coords_x;
77 extern byte char_draw_coords_y;
78 extern byte *char_xlat_table;
79 extern byte string_ended;
80 extern byte char_draw_max_width;
81 extern byte char_draw_max_height;
82 
83 void switchToGraphicsMode(void);
84 void switchToTextMode(void);
85 
86 void waitVBlank(void);
87 void cga_blitToScreen(int16 dx, int16 dy, int16 w, int16 h);
88 void cga_blitToScreen(int16 ofs, int16 w, int16 h);
89 
90 void cga_ColorSelect(byte csel);
91 void cga_BackBufferToRealFull(void);
92 void cga_RealBufferToBackFull(void);
93 void cga_SwapRealBackBuffer(void);
94 
95 void cga_SwapScreenRect(byte *pixels, uint16 w, uint16 h, byte *screen, uint16 ofs);
96 
97 uint16 CalcXY(uint16 x, uint16 y);
98 uint16 CalcXY_p(uint16 x, uint16 y);
99 
100 uint16 HGA_CalcXY(uint16 x, uint16 y);
101 uint16 HGA_CalcXY_p(uint16 x, uint16 y);
102 uint16 cga_CalcXY(uint16 x, uint16 y);
103 uint16 cga_CalcXY_p(uint16 x, uint16 y);
104 
105 void cga_CopyScreenBlock(byte *source, uint16 w, uint16 h, byte *target, uint16 ofs);
106 
107 byte *cga_BackupImage(byte *source, uint16 ofs, uint16 w, uint16 h, byte *buffer);
108 byte *cga_BackupImageReal(uint16 ofs, uint16 w, uint16 h);
109 
110 void cga_RestoreImage(byte *buffer, byte *target);
111 void cga_RefreshImageData(byte *buffer);
112 void cga_RestoreBackupImage(byte *target);
113 
114 void cga_Blit(byte *pixels, uint16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs);
115 void cga_BlitAndWait(byte *pixels, uint16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs);
116 void cga_FillAndWait(byte pixel, uint16 w, uint16 h, byte *screen, uint16 ofs);
117 
118 void cga_DrawVLine(uint16 x, uint16 y, uint16 l, byte color, byte *target);
119 void cga_DrawHLine(uint16 x, uint16 y, uint16 l, byte color, byte *target);
120 uint16 cga_DrawHLineWithEnds(uint16 bmask, uint16 bpix, byte color, uint16 l, byte *target, uint16 ofs);
121 
122 void cga_PrintChar(byte c, byte *target);
123 
124 void cga_BlitScratchBackSprite(uint16 sprofs, uint16 w, uint16 h, byte *screen, uint16 ofs);
125 void cga_BlitFromBackBuffer(byte w, byte h, byte *screen, uint16 ofs);
126 
127 void cga_BlitSprite(byte *pixels, int16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs);
128 void cga_BlitSpriteFlip(byte *pixels, int16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs);
129 
130 void cga_BlitSpriteBak(byte *pixels, int16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs, byte *backup, byte mask);
131 
132 void drawSprite(byte *sprite, byte *screen, uint16 ofs);
133 void drawSpriteFlip(byte *sprite, byte *screen, uint16 ofs);
134 
135 void drawSpriteN(byte index, uint16 x, uint16 y, byte *target);
136 void drawSpriteNFlip(byte index, uint16 x, uint16 y, byte *target);
137 
138 void backupAndShowSprite(byte index, byte x, byte y);
139 
140 byte *loadSprite(byte index, byte *bank, byte *buffer, byte header_only);
141 
142 byte *loadSprit(byte index);
143 byte *loadPersSprit(byte index);
144 
145 void cga_AnimLiftToUp(byte *pixels, uint16 pw, uint16 w, uint16 h, byte *screen, uint16 x, uint16 y);
146 void cga_AnimLiftToDown(byte *pixels, uint16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs);
147 void cga_AnimLiftToLeft(uint16 n, byte *pixels, uint16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs);
148 void cga_AnimLiftToRight(uint16 n, byte *pixels, uint16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs);
149 
150 void cga_HideScreenBlockLiftToUp(uint16 n, byte *screen, byte *source, uint16 w, uint16 h, byte *target, uint16 ofs);
151 void cga_HideScreenBlockLiftToDown(uint16 n, byte *screen, byte *source, uint16 w, uint16 h, byte *target, uint16 ofs);
152 void cga_HideScreenBlockLiftToLeft(uint16 n, byte *screen, byte *source, uint16 w, uint16 h, byte *target, uint16 ofs);
153 void cga_HideScreenBlockLiftToRight(uint16 n, byte *screen, byte *source, uint16 w, uint16 h, byte *target, uint16 ofs);
154 
155 void cga_HideShatterFall(byte *screen, byte *source, uint16 w, uint16 h, byte *target, uint16 ofs);
156 
157 void cga_TraceLine(uint16 sx, uint16 ex, uint16 sy, uint16 ey, byte *source, byte *target);
158 
159 void cga_ZoomImage(byte *pixels, byte w, byte h, byte nw, byte nh, byte *target, uint16 ofs);
160 void cga_AnimZoomIn(byte *pixels, byte w, byte h, byte *target, uint16 ofs);
161 
162 void cga_ZoomInplaceXY(byte *pixels, byte w, byte h, byte nw, byte nh, uint16 x, uint16 y, byte *target);
163 
164 } // End of namespace Chamber
165 
166 #endif
Definition: anim.h:25