dos3d
view src/vga.c @ 14:be61704c4cc8
added initial firstp
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 29 Nov 2011 07:22:49 +0200 |
parents | |
children |
line source
1 /*
2 256-color 3D graphics hack for real-mode DOS.
3 Copyright (C) 2011 John Tsiombikas <nuclear@member.fsf.org>
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.
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.
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 #include <dos.h>
19 #include <string.h>
21 void set_video_mode(int mode)
22 {
23 asm {
24 mov ax, mode
25 int 0x10
26 }
27 }
29 void set_palette(unsigned char c, unsigned char r, unsigned char g, unsigned char b)
30 {
31 asm {
32 mov dx, 0x3c8
33 mov al, c
34 out dx, al
35 inc dx
36 mov al, r
37 shr al, 2
38 out dx, al
39 mov al, g
40 shr al, 2
41 out dx, al
42 mov al, b
43 shr al, 2
44 out dx, al
45 }
46 }
48 void copy_frame(unsigned char *frame)
49 {
50 _fmemcpy(MK_FP(0xa000, 0), frame, 64000);
51 }
53 void wait_vsync(void)
54 {
55 asm mov dx, 0x3da
56 l1:
57 asm {
58 in al, dx
59 and al, 0x8
60 jnz l1
61 }
62 l2:
63 asm {
64 in al, dx
65 and al, 0x8
66 jz l2
67 }
68 }