projects
/
dosdemo
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
foo
[dosdemo]
/
src
/
dos
/
gfx.c
diff --git
a/src/dos/gfx.c
b/src/dos/gfx.c
index
570eaba
..
5252cbc
100644
(file)
--- a/
src/dos/gfx.c
+++ b/
src/dos/gfx.c
@@
-1,16
+1,10
@@
#include <stdio.h>
#include <stdio.h>
+#include <string.h>
#include "gfx.h"
#include "vbe.h"
#include "vga.h"
#include "cdpmi.h"
#include "gfx.h"
#include "vbe.h"
#include "vga.h"
#include "cdpmi.h"
-#ifdef __DJGPP__
-#include <sys/nearptr.h>
-#define REALPTR(s, o) (void*)(((uint32_t)(s) << 4) - __djgpp_base_address + ((uint32_t)(o)))
-#else
-#define REALPTR(s, o) (void*)(((uint32_t)(s) << 4) + ((uint32_t)(o)))
-#endif
-
#define SAME_BPP(a, b) \
((a) == (b) || ((a) == 16 && (b) == 15) || ((a) == 15 && (b) == 16) || \
((a) == 32 && (b) == 24) || ((a) == 24 && (b) == 32))
#define SAME_BPP(a, b) \
((a) == (b) || ((a) == 16 && (b) == 15) || ((a) == 15 && (b) == 16) || \
((a) == 32 && (b) == 24) || ((a) == 24 && (b) == 32))
@@
-22,6
+16,7
@@
static struct vbe_mode_info mode_info;
static void *vpgaddr[2];
static int fbidx;
static void *vpgaddr[2];
static int fbidx;
+static int pgcount;
static int init_vbe(void)
{
static int init_vbe(void)
{
@@
-50,7
+45,7
@@
static int init_vbe(void)
return 0;
}
return 0;
}
-void *set_video_mode(int xsz, int ysz, int bpp)
+void *set_video_mode(int xsz, int ysz, int bpp, int nbuf)
{
int i, nmodes;
int best_match_mode = -1;
{
int i, nmodes;
int best_match_mode = -1;
@@
-95,17
+90,22
@@
void *set_video_mode(int xsz, int ysz, int bpp)
printf("setting video mode %x: (%dx%d %d)\n", (unsigned int)mode, mode_info.xres,
mode_info.yres, mode_info.bpp);
printf("setting video mode %x: (%dx%d %d)\n", (unsigned int)mode, mode_info.xres,
mode_info.yres, mode_info.bpp);
- if(vbe_setmode(mode) == -1) {
+ if(vbe_setmode(mode | VBE_MODE_LFB) == -1) {
fprintf(stderr, "failed to set video mode\n");
return 0;
}
fprintf(stderr, "failed to set video mode\n");
return 0;
}
+ if(nbuf < 1) nbuf = 1;
+ if(nbuf > 2) nbuf = 2;
+ pgcount = nbuf > mode_info.num_img_pages ? mode_info.num_img_pages : nbuf;
+
pgsize = mode_info.xres * mode_info.yres * (bpp / 8);
pgsize = mode_info.xres * mode_info.yres * (bpp / 8);
- fbsize = mode_info.num_img_pages * pgsize;
+ fbsize = pgcount * pgsize;
vpgaddr[0] = (void*)dpmi_mmap(mode_info.fb_addr, fbsize);
vpgaddr[0] = (void*)dpmi_mmap(mode_info.fb_addr, fbsize);
+ memset(vpgaddr[0], 0xaa, fbsize);
- if(mode_info.num_img_pages > 1) {
+ if(pgcount > 1) {
vpgaddr[1] = (char*)vpgaddr[0] + pgsize;
fbidx = 1;
page_flip(FLIP_NOW); /* start with the second page visible */
vpgaddr[1] = (char*)vpgaddr[0] + pgsize;
fbidx = 1;
page_flip(FLIP_NOW); /* start with the second page visible */