--- /dev/null
+Building and running on DOS
+---------------------------
+Make sure you have Watcom or OpenWatcom installed, and the appropriate env-vars
+set (the watcom installer automatically adds them to autoexec.bat by default).
+
+Run wmake to build. Needs dos4gw.exe in current dir.
+
+The demo requires VESA Bios Extensions (VBE) 2.0. If your graphics card doesn't
+support VBE 2.0 or greater, then make sure to run the `univbe` TSR first, or
+the demo will fail to find a usable LFB video mode.
+
+
+Cross-compile on GNU/Linux
+--------------------------
+source owdev script with contents (change WATCOM var as necessary):
+
+ export WATCOM=$HOME/devel/ow
+ export PATH=$WATCOM/binl:$PATH
+ export INCLUDE=$WATCOM/h:$INCLUDE
+
+Run wmake to build. Needs dos4gw.exe and wstub.exe in current dir or PATH
+
+Simply running ./demo.exe might invoke magic of the ancients to start wine,
+which will in turn start dosbox, which will execute the DOS binary! If the gods
+are slumbering in valhalla, just typing `dosbox demo.exe` should do the trick.
+
+
+SDL backend
+-----------
+Run make to build (assuming make on your system is GNU make).
+
+The SDL backend will scale the framebuffer up, by the factor specified in the
+`FBSCALE` environment variable. So run the demo as: `FBSCALE=3 ./demo` for
+a 3x scale factor, or just export the `FBSCALE` env var in the shell you are
+going to use for running the demo. The default scale factor is 2x.
+++ /dev/null
-Cross-compile on GNU/Linux
---------------------------
-
-source owdev file with contents (change WATCOM var as necessary):
-
- export WATCOM=$HOME/devel/ow
- export PATH=$WATCOM/binl:$PATH
- export INCLUDE=$WATCOM/h:$INCLUDE
-
-Run wmake to build. Needs dos4gw.exe and wstub.exe in current dir or PATH
-
-Simply running ./demo.exe will invoke magic of the ancients to start wine,
-which will in turn start dosbox, which will execute the DOS binary!
int fb_width = 320;
int fb_height = 240;
int fb_bpp = 16;
-unsigned char *fb_pixels;
+void *fb_pixels;
unsigned long time_msec;
static unsigned long nframes;
#define DEMO_H_
extern int fb_width, fb_height, fb_bpp;
-extern unsigned char *fb_pixels;
+extern void *fb_pixels;
extern unsigned long time_msec;
int demo_init(int argc, char **argv);
#include <stdio.h>
#include <stdlib.h>
+#include <limits.h>
#include <SDL/SDL.h>
#include "demo.h"
static long start_time;
static SDL_Surface *fbsurf;
+static int fbscale = 2;
+static int xsz, ysz;
+
int main(int argc, char **argv)
{
+ int s, i, j;
+ char *env;
+ unsigned short *sptr, *dptr;
unsigned int sdl_flags = SDL_SWSURFACE;
+ if((env = getenv("FBSCALE")) && (s = atoi(env))) {
+ fbscale = s;
+ printf("Framebuffer scaling x%d\n", fbscale);
+ }
+
+ xsz = fb_width * fbscale;
+ ysz = fb_height * fbscale;
+
+ if(!(fb_pixels = malloc(fb_width * fb_height * fb_bpp / CHAR_BIT))) {
+ fprintf(stderr, "failed to allocate virtual framebuffer\n");
+ return 1;
+ }
+
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);
- if(!(fbsurf = SDL_SetVideoMode(fb_width, fb_height, fb_bpp, sdl_flags))) {
+ if(!(fbsurf = SDL_SetVideoMode(xsz, ysz, fb_bpp, sdl_flags))) {
fprintf(stderr, "failed to set video mode %dx%d %dbpp\n", fb_width, fb_height, fb_bpp);
+ free(fb_pixels);
+ SDL_Quit();
return 1;
}
- SDL_WM_SetCaption("dosdemo SDLemu", 0);
+ SDL_WM_SetCaption("dosdemo/SDL", 0);
time_msec = 0;
if(demo_init(argc, argv) == -1) {
+ free(fb_pixels);
+ SDL_Quit();
return 1;
}
start_time = SDL_GetTicks();
}
time_msec = SDL_GetTicks() - start_time;
+ demo_draw();
+
if(SDL_MUSTLOCK(fbsurf)) {
SDL_LockSurface(fbsurf);
}
- fb_pixels = fbsurf->pixels;
- demo_draw();
+ sptr = fb_pixels;
+ dptr = fbsurf->pixels;
+ for(i=0; i<fb_height; i++) {
+ for(j=0; j<fb_width; j++) {
+ int x, y;
+ unsigned short pixel = *sptr++;
+
+ for(y=0; y<fbscale; y++) {
+ for(x=0; x<fbscale; x++) {
+ dptr[y * xsz + x] = pixel;
+ }
+ }
+ dptr += fbscale;
+ }
+ dptr += xsz * (fbscale - 1);
+ }
if(SDL_MUSTLOCK(fbsurf)) {
SDL_UnlockSurface(fbsurf);