ScummVM API documentation
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
25namespace 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(40, 72)
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
62extern byte SCREENBUFFER[0xFA00];
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 SCREENBUFFER
70extern byte backbuffer[0xFA00];
71
72extern byte sprit_load_buffer[8192];
73
74extern byte cga_pixel_flip[256];
75
76extern byte char_draw_coords_x;
77extern byte char_draw_coords_y;
78extern byte *char_xlat_table;
79extern byte string_ended;
80extern byte char_draw_max_width;
81extern byte char_draw_max_height;
82
83void switchToTextMode(void);
84
85void waitVBlank(void);
86
87
88uint16 HGA_CalcXY(uint16 x, uint16 y);
89uint16 HGA_CalcXY_p(uint16 x, uint16 y);
90uint16 cga_CalcXY_p(uint16 x, uint16 y);
91
92byte *cga_BackupImageReal(uint16 ofs, uint16 w, uint16 h);
93
94void drawSpriteN(byte index, uint16 x, uint16 y, byte *target);
95void drawSpriteNFlip(byte index, uint16 x, uint16 y, byte *target);
96
97byte *loadSprite(byte index, byte *bank, byte *buffer, byte header_only);
98
99} // End of namespace Chamber
100
101#endif