dos3d

changeset 23:f2c2e45e8edd

reverted the mistaken push from the deepstone branch
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 21 Sep 2013 18:22:11 +0300
parents 1f26cc6c6204
children 698c4d07702d
files .hgignore Makefile.bcc Makefile.wac dos4gw.exe src/dpmi.c src/dpmi.h src/inttypes.h src/mglgen.c src/mingl.c src/mouse.c src/test.c src/timer.c src/vga.c src/vga.h src/vmath.h src/wvga.c src/wvga.h
diffstat 17 files changed, 209 insertions(+), 272 deletions(-) [+]
line diff
     1.1 --- a/.hgignore	Sat Sep 21 18:18:31 2013 +0300
     1.2 +++ b/.hgignore	Sat Sep 21 18:22:11 2013 +0300
     1.3 @@ -1,9 +1,5 @@
     1.4  \.o$
     1.5  \.obj$
     1.6 -\.OBJ$
     1.7  \.d$
     1.8  \.swp$
     1.9  ^test$
    1.10 -\.exe$
    1.11 -\.EXE$
    1.12 -^OBJECTS.LNK$
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/Makefile.bcc	Sat Sep 21 18:22:11 2013 +0300
     2.3 @@ -0,0 +1,26 @@
     2.4 +.AUTODEPEND
     2.5 +
     2.6 +obj = src\test.obj src\vga.obj src\timer.obj src\mouse.obj \
     2.7 +	  src\mingl.obj src\mglrast.obj src\mglgen.obj \
     2.8 +	  src\texture.obj src\palman.obj
     2.9 +bin = dos3d.exe
    2.10 +
    2.11 +CC = bcc
    2.12 +
    2.13 +# 386 instructions, x87 fpu code, large memory model, optimize for speed
    2.14 +CFLAGS = -3 -f287 -ml -O2 -G -Isrc
    2.15 +
    2.16 +$(bin): $(obj)
    2.17 +	$(CC) @&&|
    2.18 +$(CFLAGS) -e$@
    2.19 +$(obj)
    2.20 +|
    2.21 +
    2.22 +.SUFFIXES: .c .obj
    2.23 +
    2.24 +.c.obj:
    2.25 +	$(CC) $(CFLAGS) -o$@ -c $<
    2.26 +
    2.27 +clean:
    2.28 +	del src\*.obj
    2.29 +	del $(bin)
     3.1 --- a/Makefile.wac	Sat Sep 21 18:18:31 2013 +0300
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,21 +0,0 @@
     3.4 -obj = test.obj wvga.obj dpmi.obj timer.obj mouse.obj &
     3.5 -	  mingl.obj mglrast.obj mglgen.obj &
     3.6 -	  texture.obj palman.obj
     3.7 -bin = deepston.exe
     3.8 -
     3.9 -CC = wcc386
    3.10 -CFLAGS = -5 -fp5 -otexan -zq -bt=dos
    3.11 -LD = wlink
    3.12 -
    3.13 -$(bin): $(obj)
    3.14 -	%write objects.lnk file { $(obj) }
    3.15 -	$(LD) name $@ @objects $(LDFLAGS)
    3.16 -
    3.17 -.c: src\
    3.18 -
    3.19 -.c.obj: .autodepend
    3.20 -	$(CC) $(CFLAGS) $[*
    3.21 -
    3.22 -clean: .symbolic
    3.23 -	del *.obj
    3.24 -	del $(bin)
     4.1 Binary file dos4gw.exe has changed
     5.1 --- a/src/dpmi.c	Sat Sep 21 18:18:31 2013 +0300
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,55 +0,0 @@
     5.4 -#include "dpmi.h"
     5.5 -
     5.6 -void dpmi_real_int(int inum, struct dpmi_real_regs *regs)
     5.7 -{
     5.8 -	unsigned char int_num = (unsigned char)inum;
     5.9 -	__asm {
    5.10 -		mov eax, 0x300
    5.11 -		mov edi, regs
    5.12 -		mov bl, int_num
    5.13 -		mov bh, 0
    5.14 -		xor ecx, ecx
    5.15 -		int 0x31
    5.16 -	}
    5.17 -}
    5.18 -
    5.19 -void *dpmi_mmap(uint32_t phys_addr, unsigned int size)
    5.20 -{
    5.21 -	uint16_t mem_high, mem_low;
    5.22 -	uint16_t phys_high = phys_addr >> 16;
    5.23 -	uint16_t phys_low = phys_addr & 0xffff;
    5.24 -	uint16_t size_high = size >> 16;
    5.25 -	uint16_t size_low = size & 0xffff;
    5.26 -	unsigned int err, res = 0;
    5.27 -
    5.28 -	__asm {
    5.29 -		mov eax, 0x800
    5.30 -		mov bx, phys_high
    5.31 -		mov cx, phys_low
    5.32 -		mov si, size_high
    5.33 -		mov di, size_low
    5.34 -		int 0x31
    5.35 -		add res, 1
    5.36 -		mov err, eax
    5.37 -		mov mem_high, bx
    5.38 -		mov mem_low, cx
    5.39 -	}
    5.40 -
    5.41 -	if(res == 2) {
    5.42 -		return 0;
    5.43 -	}
    5.44 -	return (void*)(((uint32_t)mem_high << 16) | ((uint32_t)mem_low));
    5.45 -}
    5.46 -
    5.47 -void dpmi_munmap(void *addr)
    5.48 -{
    5.49 -	uint16_t mem_high = (uint32_t)addr >> 16;
    5.50 -	uint16_t mem_low = (uint16_t)addr;
    5.51 -
    5.52 -	__asm {
    5.53 -		mov eax, 0x801
    5.54 -		mov bx, mem_high
    5.55 -		mov cx, mem_low
    5.56 -		int 0x31
    5.57 -	}
    5.58 -}
     6.1 --- a/src/dpmi.h	Sat Sep 21 18:18:31 2013 +0300
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,26 +0,0 @@
     6.4 -#ifndef DPMI_H_
     6.5 -#define DPMI_H_
     6.6 -
     6.7 -#include "inttypes.h"
     6.8 -
     6.9 -struct dpmi_real_regs {
    6.10 -	uint32_t edi, esi, ebp;
    6.11 -	uint32_t reserved;
    6.12 -	uint32_t ebx, edx, ecx, eax;
    6.13 -	uint16_t flags;
    6.14 -	uint16_t es, ds, fs, gs;
    6.15 -	uint16_t ip, cs, sp, ss;
    6.16 -};
    6.17 -
    6.18 -unsigned short dpmi_alloc(unsigned int par);
    6.19 -#pragma aux dpmi_alloc = \
    6.20 -		"mov eax, 0x100" \
    6.21 -		"int 0x31" \
    6.22 -		value[ax] parm[ebx];
    6.23 -
    6.24 -void dpmi_real_int(int inum, struct dpmi_real_regs *regs);
    6.25 -
    6.26 -void *dpmi_mmap(uint32_t phys_addr, unsigned int size);
    6.27 -void dpmi_munmap(void *addr);
    6.28 -
    6.29 -#endif	/* DPMI_H_ */
     7.1 --- a/src/inttypes.h	Sat Sep 21 18:18:31 2013 +0300
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,12 +0,0 @@
     7.4 -#ifndef INT_TYPES_H_
     7.5 -#define INT_TYPES_H_
     7.6 -
     7.7 -typedef char int8_t;
     7.8 -typedef short int16_t;
     7.9 -typedef long int32_t;
    7.10 -
    7.11 -typedef unsigned char uint8_t;
    7.12 -typedef unsigned short uint16_t;
    7.13 -typedef unsigned long uint32_t;
    7.14 -
    7.15 -#endif	/* INT_TYPES_H_ */
     8.1 --- a/src/mglgen.c	Sat Sep 21 18:18:31 2013 +0300
     8.2 +++ b/src/mglgen.c	Sat Sep 21 18:22:11 2013 +0300
     8.3 @@ -1,7 +1,23 @@
     8.4 +/*
     8.5 +256-color 3D graphics hack for real-mode DOS.
     8.6 +Copyright (C) 2011  John Tsiombikas <nuclear@member.fsf.org>
     8.7 +
     8.8 +This program is free software: you can redistribute it and/or modify
     8.9 +it under the terms of the GNU General Public License as published by
    8.10 +the Free Software Foundation, either version 3 of the License, or
    8.11 +(at your option) any later version.
    8.12 +
    8.13 +This program is distributed in the hope that it will be useful,
    8.14 +but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.15 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    8.16 +GNU General Public License for more details.
    8.17 +
    8.18 +You should have received a copy of the GNU General Public License
    8.19 +along with this program.  If not, see <http://www.gnu.org/licenses/>.
    8.20 +*/
    8.21  #include <math.h>
    8.22  #include <assert.h>
    8.23  #include "mingl.h"
    8.24 -#include "vmath.h"
    8.25  
    8.26  
    8.27  void mgl_cube(float sz)
     9.1 --- a/src/mingl.c	Sat Sep 21 18:18:31 2013 +0300
     9.2 +++ b/src/mingl.c	Sat Sep 21 18:22:11 2013 +0300
     9.3 @@ -1,10 +1,26 @@
     9.4 +/*
     9.5 +256-color 3D graphics hack for real-mode DOS.
     9.6 +Copyright (C) 2011  John Tsiombikas <nuclear@member.fsf.org>
     9.7 +
     9.8 +This program is free software: you can redistribute it and/or modify
     9.9 +it under the terms of the GNU General Public License as published by
    9.10 +the Free Software Foundation, either version 3 of the License, or
    9.11 +(at your option) any later version.
    9.12 +
    9.13 +This program is distributed in the hope that it will be useful,
    9.14 +but WITHOUT ANY WARRANTY; without even the implied warranty of
    9.15 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    9.16 +GNU General Public License for more details.
    9.17 +
    9.18 +You should have received a copy of the GNU General Public License
    9.19 +along with this program.  If not, see <http://www.gnu.org/licenses/>.
    9.20 +*/
    9.21  #include <stdio.h>
    9.22  #include <stdlib.h>
    9.23  #include <string.h>
    9.24  #include <math.h>
    9.25  #include <limits.h>
    9.26  #include <assert.h>
    9.27 -#include "vmath.h"
    9.28  #include "mingl.h"
    9.29  #include "mglimpl.h"
    9.30  
    10.1 --- a/src/mouse.c	Sat Sep 21 18:18:31 2013 +0300
    10.2 +++ b/src/mouse.c	Sat Sep 21 18:22:11 2013 +0300
    10.3 @@ -1,5 +1,4 @@
    10.4  #include "mouse.h"
    10.5 -#include "inttypes.h"
    10.6  
    10.7  #define INTR	0x33
    10.8  
    10.9 @@ -14,8 +13,8 @@
   10.10  
   10.11  int have_mouse(void)
   10.12  {
   10.13 -	int16_t res;
   10.14 -	__asm {
   10.15 +	int res;
   10.16 +	asm {
   10.17  		mov ax, QUERY
   10.18  		int INTR
   10.19  		mov res, ax
   10.20 @@ -25,8 +24,8 @@
   10.21  
   10.22  void show_mouse(int show)
   10.23  {
   10.24 -	int16_t cmd = show ? SHOW : HIDE;
   10.25 -	__asm {
   10.26 +	int cmd = show ? SHOW : HIDE;
   10.27 +	asm {
   10.28  		mov ax, cmd
   10.29  		int INTR
   10.30  	}
   10.31 @@ -34,9 +33,9 @@
   10.32  
   10.33  int read_mouse(int *xp, int *yp)
   10.34  {
   10.35 -	int16_t x, y, bn;
   10.36 +	int x, y, bn;
   10.37  
   10.38 -	__asm {
   10.39 +	asm {
   10.40  		mov ax, READ
   10.41  		int INTR
   10.42  		mov bn, bx
   10.43 @@ -52,24 +51,24 @@
   10.44  
   10.45  void set_mouse(int x, int y)
   10.46  {
   10.47 -	__asm {
   10.48 +	asm {
   10.49  		mov ax, WRITE
   10.50 -		mov ecx, x
   10.51 -		mov edx, y
   10.52 +		mov cx, x
   10.53 +		mov dx, y
   10.54  		int INTR
   10.55  	}
   10.56  }
   10.57  
   10.58  void set_mouse_limits(int xmin, int ymin, int xmax, int ymax)
   10.59  {
   10.60 -	__asm {
   10.61 +	asm {
   10.62  		mov ax, XLIM
   10.63 -		mov ecx, xmin
   10.64 -		mov edx, xmax
   10.65 +		mov cx, xmin
   10.66 +		mov dx, xmax
   10.67  		int INTR
   10.68  		mov ax, YLIM
   10.69 -		mov ecx, ymin
   10.70 -		mov edx, ymax
   10.71 +		mov cx, ymin
   10.72 +		mov dx, ymax
   10.73  		int INTR
   10.74  	}
   10.75  }
    11.1 --- a/src/test.c	Sat Sep 21 18:18:31 2013 +0300
    11.2 +++ b/src/test.c	Sat Sep 21 18:22:11 2013 +0300
    11.3 @@ -1,9 +1,26 @@
    11.4 +/*
    11.5 +256-color 3D graphics hack for real-mode DOS.
    11.6 +Copyright (C) 2011  John Tsiombikas <nuclear@member.fsf.org>
    11.7 +
    11.8 +This program is free software: you can redistribute it and/or modify
    11.9 +it under the terms of the GNU General Public License as published by
   11.10 +the Free Software Foundation, either version 3 of the License, or
   11.11 +(at your option) any later version.
   11.12 +
   11.13 +This program is distributed in the hope that it will be useful,
   11.14 +but WITHOUT ANY WARRANTY; without even the implied warranty of
   11.15 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   11.16 +GNU General Public License for more details.
   11.17 +
   11.18 +You should have received a copy of the GNU General Public License
   11.19 +along with this program.  If not, see <http://www.gnu.org/licenses/>.
   11.20 +*/
   11.21  #include <stdio.h>
   11.22  #include <stdlib.h>
   11.23  #include <string.h>
   11.24  #include <signal.h>
   11.25  #include <conio.h>
   11.26 -#include "wvga.h"
   11.27 +#include "vga.h"
   11.28  #include "mingl.h"
   11.29  #include "timer.h"
   11.30  #include "mouse.h"
   11.31 @@ -135,7 +152,7 @@
   11.32  
   11.33  	pal = palm_palette();
   11.34  	for(i=0; i<palm_palette_size(); i++) {
   11.35 -		set_pal_entry(i, pal[i].r, pal[i].g, pal[i].b);
   11.36 +		set_palette(i, pal[i].r, pal[i].g, pal[i].b);
   11.37  	}
   11.38  
   11.39  	mgl_enable(MGL_CULL_FACE);
    12.1 --- a/src/timer.c	Sat Sep 21 18:18:31 2013 +0300
    12.2 +++ b/src/timer.c	Sat Sep 21 18:22:11 2013 +0300
    12.3 @@ -17,9 +17,7 @@
    12.4  */
    12.5  #include <stdio.h>
    12.6  #include <stdlib.h>
    12.7 -#include <conio.h>
    12.8  #include <dos.h>
    12.9 -#include <i86.h>
   12.10  #include "pit8254.h"
   12.11  
   12.12  #define PIT_TIMER_INTR	8
   12.13 @@ -31,10 +29,9 @@
   12.14  
   12.15  static void set_timer_reload(int reload_val);
   12.16  static void cleanup(void);
   12.17 -static void __interrupt __far timer_irq();
   12.18 -static void __interrupt __far dos_timer_intr();
   12.19 -
   12.20 -static void (__interrupt __far *prev_timer_intr)();
   12.21 +static void interrupt dos_timer_intr();
   12.22 +static void interrupt timer_irq();
   12.23 +static void interrupt (*prev_timer_intr)();
   12.24  
   12.25  static unsigned long ticks;
   12.26  static unsigned long tick_interval, ticks_per_dos_intr;
   12.27 @@ -42,8 +39,8 @@
   12.28  
   12.29  void init_timer(int res_hz)
   12.30  {
   12.31 -	_disable();
   12.32  
   12.33 +	disable();
   12.34  	if(res_hz > 0) {
   12.35  		int reload_val = DIV_ROUND(OSC_FREQ_HZ, res_hz);
   12.36  		set_timer_reload(reload_val);
   12.37 @@ -52,16 +49,16 @@
   12.38  		ticks_per_dos_intr = DIV_ROUND(65535L, reload_val);
   12.39  
   12.40  		inum = PIT_TIMER_INTR;
   12.41 -		prev_timer_intr = _dos_getvect(inum);
   12.42 -		_dos_setvect(inum, timer_irq);
   12.43 +		prev_timer_intr = getvect(inum);
   12.44 +		setvect(inum, timer_irq);
   12.45  	} else {
   12.46  		tick_interval = 55;
   12.47  
   12.48  		inum = DOS_TIMER_INTR;
   12.49 -		prev_timer_intr = _dos_getvect(inum);
   12.50 -		_dos_setvect(inum, dos_timer_intr);
   12.51 +		prev_timer_intr = getvect(inum);
   12.52 +		setvect(inum, dos_timer_intr);
   12.53  	}
   12.54 -	_enable();
   12.55 +	enable();
   12.56  
   12.57  	atexit(cleanup);
   12.58  }
   12.59 @@ -72,15 +69,15 @@
   12.60  		return; /* init hasn't ran, there's nothing to cleanup */
   12.61  	}
   12.62  
   12.63 -	_disable();
   12.64 +	disable();
   12.65  	if(inum == PIT_TIMER_INTR) {
   12.66  		/* restore the original timer frequency */
   12.67  		set_timer_reload(65535);
   12.68  	}
   12.69  
   12.70  	/* restore the original interrupt handler */
   12.71 -	_dos_setvect(inum, prev_timer_intr);
   12.72 -	_enable();
   12.73 +	setvect(inum, prev_timer_intr);
   12.74 +	enable();
   12.75  }
   12.76  
   12.77  void reset_timer(void)
   12.78 @@ -95,15 +92,15 @@
   12.79  
   12.80  static void set_timer_reload(int reload_val)
   12.81  {
   12.82 -	outp(PORT_CMD, CMD_CHAN0 | CMD_ACCESS_BOTH | CMD_OP_SQWAVE);
   12.83 -	outp(PORT_DATA0, reload_val & 0xff);
   12.84 -	outp(PORT_DATA0, (reload_val >> 8) & 0xff);
   12.85 +	outportb(PORT_CMD, CMD_CHAN0 | CMD_ACCESS_BOTH | CMD_OP_SQWAVE);
   12.86 +	outportb(PORT_DATA0, reload_val & 0xff);
   12.87 +	outportb(PORT_DATA0, (reload_val >> 8) & 0xff);
   12.88  }
   12.89  
   12.90 -static void __interrupt __far dos_timer_intr()
   12.91 +static void interrupt dos_timer_intr()
   12.92  {
   12.93  	ticks++;
   12.94 -	_chain_intr(prev_timer_intr);	/* DOES NOT RETURN */
   12.95 +	prev_timer_intr();
   12.96  }
   12.97  
   12.98  /* first PIC command port */
   12.99 @@ -111,7 +108,7 @@
  12.100  /* end of interrupt control word */
  12.101  #define OCW2_EOI	(1 << 5)
  12.102  
  12.103 -static void __interrupt __far timer_irq()
  12.104 +static void interrupt timer_irq()
  12.105  {
  12.106  	static unsigned long dos_ticks;
  12.107  
  12.108 @@ -121,11 +118,10 @@
  12.109  		/* I suppose the dos irq handler does the EOI so I shouldn't
  12.110  		 * do it if I am to call the previous function
  12.111  		 */
  12.112 +		prev_timer_intr();
  12.113  		dos_ticks = 0;
  12.114 -		_chain_intr(prev_timer_intr);	/* XXX DOES NOT RETURN */
  12.115 -		return;	/* just for clarity */
  12.116 +	} else {
  12.117 +		/* send EOI to the PIC */
  12.118 +		outportb(PIC1_CMD, OCW2_EOI);
  12.119  	}
  12.120 -
  12.121 -	/* send EOI to the PIC */
  12.122 -	outp(PIC1_CMD, OCW2_EOI);
  12.123  }
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/src/vga.c	Sat Sep 21 18:22:11 2013 +0300
    13.3 @@ -0,0 +1,68 @@
    13.4 +/*
    13.5 +256-color 3D graphics hack for real-mode DOS.
    13.6 +Copyright (C) 2011  John Tsiombikas <nuclear@member.fsf.org>
    13.7 +
    13.8 +This program is free software: you can redistribute it and/or modify
    13.9 +it under the terms of the GNU General Public License as published by
   13.10 +the Free Software Foundation, either version 3 of the License, or
   13.11 +(at your option) any later version.
   13.12 +
   13.13 +This program is distributed in the hope that it will be useful,
   13.14 +but WITHOUT ANY WARRANTY; without even the implied warranty of
   13.15 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13.16 +GNU General Public License for more details.
   13.17 +
   13.18 +You should have received a copy of the GNU General Public License
   13.19 +along with this program.  If not, see <http://www.gnu.org/licenses/>.
   13.20 +*/
   13.21 +#include <dos.h>
   13.22 +#include <string.h>
   13.23 +
   13.24 +void set_video_mode(int mode)
   13.25 +{
   13.26 +	asm {
   13.27 +		mov ax, mode
   13.28 +		int 0x10
   13.29 +	}
   13.30 +}
   13.31 +
   13.32 +void set_palette(unsigned char c, unsigned char r, unsigned char g, unsigned char b)
   13.33 +{
   13.34 +	asm {
   13.35 +		mov dx, 0x3c8
   13.36 +		mov al, c
   13.37 +		out dx, al
   13.38 +		inc dx
   13.39 +		mov al, r
   13.40 +		shr al, 2
   13.41 +		out dx, al
   13.42 +		mov al, g
   13.43 +		shr al, 2
   13.44 +		out dx, al
   13.45 +		mov al, b
   13.46 +		shr al, 2
   13.47 +		out dx, al
   13.48 +	}
   13.49 +}
   13.50 +
   13.51 +void copy_frame(unsigned char *frame)
   13.52 +{
   13.53 +	_fmemcpy(MK_FP(0xa000, 0), frame, 64000);
   13.54 +}
   13.55 +
   13.56 +void wait_vsync(void)
   13.57 +{
   13.58 +	asm mov dx, 0x3da
   13.59 +l1:
   13.60 +	asm {
   13.61 +		in al, dx
   13.62 +		and al, 0x8
   13.63 +		jnz l1
   13.64 +	}
   13.65 +l2:
   13.66 +	asm {
   13.67 +		in al, dx
   13.68 +		and al, 0x8
   13.69 +		jz l2
   13.70 +	}
   13.71 +}
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/src/vga.h	Sat Sep 21 18:22:11 2013 +0300
    14.3 @@ -0,0 +1,26 @@
    14.4 +/*
    14.5 +256-color 3D graphics hack for real-mode DOS.
    14.6 +Copyright (C) 2011  John Tsiombikas <nuclear@member.fsf.org>
    14.7 +
    14.8 +This program is free software: you can redistribute it and/or modify
    14.9 +it under the terms of the GNU General Public License as published by
   14.10 +the Free Software Foundation, either version 3 of the License, or
   14.11 +(at your option) any later version.
   14.12 +
   14.13 +This program is distributed in the hope that it will be useful,
   14.14 +but WITHOUT ANY WARRANTY; without even the implied warranty of
   14.15 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14.16 +GNU General Public License for more details.
   14.17 +
   14.18 +You should have received a copy of the GNU General Public License
   14.19 +along with this program.  If not, see <http://www.gnu.org/licenses/>.
   14.20 +*/
   14.21 +#ifndef VGA_H_
   14.22 +#define VGA_H_
   14.23 +
   14.24 +void set_video_mode(int mode);
   14.25 +void set_palette(unsigned char c, unsigned char r, unsigned char g, unsigned char b);
   14.26 +void copy_frame(unsigned char *frame);
   14.27 +void wait_vsync(void);
   14.28 +
   14.29 +#endif /* VGA_H_ */
    15.1 --- a/src/vmath.h	Sat Sep 21 18:18:31 2013 +0300
    15.2 +++ b/src/vmath.h	Sat Sep 21 18:22:11 2013 +0300
    15.3 @@ -1,12 +1,6 @@
    15.4  #ifndef VMATH_H_
    15.5  #define VMATH_H_
    15.6  
    15.7 -#include <math.h>
    15.8 -
    15.9 -#ifndef M_PI
   15.10 -#define M_PI	3.1415926536
   15.11 -#endif
   15.12 -
   15.13  typedef struct {
   15.14  	float x, y, z, w;
   15.15  } vec4_t;
    16.1 --- a/src/wvga.c	Sat Sep 21 18:18:31 2013 +0300
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,91 +0,0 @@
    16.4 -#include <stdio.h>
    16.5 -#include <stdlib.h>
    16.6 -#include <string.h>
    16.7 -#include "wvga.h"
    16.8 -#include "dpmi.h"
    16.9 -
   16.10 -/* VGA DAC registers used for palette setting in 8bpp modes */
   16.11 -#define VGA_DAC_STATE		0x3c7
   16.12 -#define VGA_DAC_ADDR_RD		0x3c7
   16.13 -#define VGA_DAC_ADDR_WR		0x3c8
   16.14 -#define VGA_DAC_DATA		0x3c9
   16.15 -
   16.16 -static void *framebuffer;
   16.17 -
   16.18 -int set_video_mode(int mode)
   16.19 -{
   16.20 -	struct dpmi_real_regs regs;
   16.21 -
   16.22 -	memset(&regs, 0, sizeof regs);
   16.23 -	regs.eax = mode;
   16.24 -	dpmi_real_int(0x10, &regs);
   16.25 -
   16.26 -	if(regs.eax == 0x100) {
   16.27 -		return -1;
   16.28 -	}
   16.29 -
   16.30 -	if(mode != 3) {
   16.31 -		framebuffer = dpmi_mmap(0xa0000, 64000);
   16.32 -	} else {
   16.33 -		dpmi_munmap((void*)0xa0000);
   16.34 -	}
   16.35 -	return 0;
   16.36 -}
   16.37 -
   16.38 -void set_palette(int idx, int *col, int count)
   16.39 -{
   16.40 -	int i;
   16.41 -
   16.42 -	__asm {
   16.43 -		mov dx, VGA_DAC_ADDR_WR
   16.44 -		mov eax, idx
   16.45 -		out dx, al
   16.46 -	}
   16.47 -
   16.48 -	for(i=0; i<count; i++) {
   16.49 -		unsigned char r = *col++ >> 2;
   16.50 -		unsigned char g = *col++ >> 2;
   16.51 -		unsigned char b = *col++ >> 2;
   16.52 -
   16.53 -		__asm {
   16.54 -			mov dx, VGA_DAC_DATA
   16.55 -			mov al, r
   16.56 -			out dx, al
   16.57 -			mov al, g
   16.58 -			out dx, al
   16.59 -			mov al, b
   16.60 -			out dx, al
   16.61 -		}
   16.62 -	}
   16.63 -}
   16.64 -
   16.65 -void set_pal_entry(int idx, int r, int g, int b)
   16.66 -{
   16.67 -	int color[3];
   16.68 -	color[0] = r;
   16.69 -	color[1] = g;
   16.70 -	color[2] = b;
   16.71 -
   16.72 -	set_palette(idx, color, 1);
   16.73 -}
   16.74 -
   16.75 -void copy_frame(void *pixels)
   16.76 -{
   16.77 -	memcpy(framebuffer, pixels, 64000);
   16.78 -}
   16.79 -
   16.80 -
   16.81 -void wait_vsync(void)
   16.82 -{
   16.83 -	__asm {
   16.84 -		mov dx, 0x3da
   16.85 -	l1:
   16.86 -		in al, dx
   16.87 -		and al, 0x8
   16.88 -		jnz l1
   16.89 -	l2:
   16.90 -		in al, dx
   16.91 -		and al, 0x8
   16.92 -		jz l2
   16.93 -	}
   16.94 -}
    17.1 --- a/src/wvga.h	Sat Sep 21 18:18:31 2013 +0300
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,12 +0,0 @@
    17.4 -#ifndef WVGA_H_
    17.5 -#define WVGA_H_
    17.6 -
    17.7 -
    17.8 -int set_video_mode(int mode);
    17.9 -void set_palette(int idx, int *col, int count);
   17.10 -void set_pal_entry(int idx, int r, int g, int b);
   17.11 -void copy_frame(void *pixels);
   17.12 -
   17.13 -void wait_vsync(void);
   17.14 -
   17.15 -#endif	/* WVGA_H_ */