INSTALLATION TIPS FOR COMPILATION UNDER M$-DOG
----------------------------------------------

Zoltan Kovacs <kovzol@math.u-szeged.hu>

Last modification information:
$Header: /cvsroot/xaos/XaoS/doc/README2.dos,v 1.3 2003/01/28 11:49:46 kovzol Exp $


I had many problems compiling XaoS under DOS and I'd like to help you
if you are planning to create an executable on your own. To do this
all from scratch, you probably need a whole day or so if you never
did such a thing before. Note that altogether you have to download >20
megabytes of software and this may also take a while if you don't
have a reasonably fast internet connection. Please feel free to
share your experiences with me. Thank you in advance.

1. If you haven't done yet, install all the neccessary packages for
   compilation. Search the web for all packages. I used:
	 
   * MS-DOS 6.0. However other DOS versions should also work,
     I tested XaoS only on this platform.

   * DJGPP 2.7.2.1 (download it from http://www.delorie.com and
     read the file README.1ST carefully). You need only the
     basic packages.

   * Allegro 2.2 (newer versions also exist but I haven't tried
     any of them yet). Its new web page is http://allegro.cc.

   * Doslibs (download it from the web site of CrystalSpace,
     http://crystal.sf.net/dlsrc.html). Two packages are needed:
     libpng 1.0.2 and zlib 1.1.3.

   * Libvga and libtext (without version numbers, download them
     from the web site of Aalib, http://aa-project.sf.net/aalib).

   * Aalib 1.2. It may be probably found only in .tar.gz format.
     If you don't have a GNU unzip under DOS, you should first
     unzip it e.g. under Linux, then zip it with 
		 
     $ zip -r aalib12.zip *
		 
     Now unzip it. I used DOS Navigator to do this part of
     preparation.

   * For internationalization (i18n) you need gettext and libiconv.
     Both may be downloaded from Simtel mirrors. Many FTP and
     HTTP servers mirror the Simtel repository. Search for
     the gnu/djgpp/v2gnu directory and get gtxt040b.zip and
     licv17b.zip.
		 
   You can compile XaoS without i18n support as well. Read
   below for further information about this.
		 
   Note that other versions should also work, however you may
   fine tune some things to do the all the job.
		 
2. Compile the packages. Doslibs, libvga and libtext should be
   automatically made. Aalib probably have to be changed a bit:
   the file CONFIG.DOS should be copied (or moved) onto CONFIG.H.

   For compiling gettext, first you have to install libiconv
   (licv17b.zip). This should be also done automatically.
	 
3. Install the packages. A general rule that all *.H files must
   be copied (or moved) into DJGPP/INCLUDE and all *.A files into
   DJGPP/LIB.
	 
   For installing gettext you have to relink the GNU C Library
   (libc). Please read the README file in the gettext binary
   package to learn about the way of doing this.
	   
4. Make sure that you copy all the files onto your DOS partition
   properly from your XaoS source (if it is in .zip format, it
   is quite simple, if not, convert it first into .zip).
   Long file names must be truncated without any special characters
   and directory structure must be also done correctly
   (do this also with DOS Navigator). At the BeoS files
   there may be questions about overwriting already existing files.
   You can answer "yes" to all.
	 
5. The XaoS source needs some modifications. Here I attach 4 modified
   files. Snip them and copy all of them to their appropriate place.
   Use such a text editor which does not break the lines (else
   you will get lots of errors during the compilation process).
   You can turn off internationalization support if you don't have
   gettext on your computer installed (choose the appropriate
   files below).
	 
   After modifications, run BUILD.BAT and go to the BIN/ directory to
   run XAOS.EXE or XAOS-XX.BAT for internationalized version of XaoS. (I
   had different experiences with Windows 95, 98, NT and 2000. Most of
   them detects localization very poor. Using native DOS may result more
   success.)
   
   Good luck! :-)

 
SRC/DOS.MAK (with i18n)
-------------------------------------------------------------------------------
CFLAGS1= -D__OPTIMIZE__ -Wall -fstrength-reduce -ffast-math -fomit-frame-pointer -L.  -D DOG_DRIVER  -Wall -D AA_DRIVER -malign-double -D HAVE_GETTEXT
LIBS = -lalleg -L ../../vga -L ../../text -L ../../aalib-1.2 -laa -ltext -lvga -lpng -lz -lm
 -lintl -liconv
LFLAGS = -s

SRC/DOS.MAK (without i18n)
-------------------------------------------------------------------------------
CFLAGS1= -D__OPTIMIZE__ -Wall -fstrength-reduce -ffast-math -fomit-frame-pointer -L.  -D DOG_DRIVER  -Wall -D AA_DRIVER -malign-double
LIBS = -lalleg -L ../../vga -L ../../text -L ../../aalib-1.2 -laa -ltext -lvga -lpng -lz -lm
LFLAGS = -s

SRC/DOS1.MAK (with i18n)
-------------------------------------------------------------------------------
CFLAGS1= -D__OPTIMIZE__ -Wall -fstrength-reduce -ffast-math -O6 -funroll-loops -L. -D DOG_DRIVER  -Wall -D AA_DRIVER -malign-double
 -D HAVE_GETTEXT
LIBS = -lalleg -L ../../vga -L ../../text -L ../../aalib-1.2 -laa -ltext -lvga -lpng -lz -lm
 -lintl -liconv
LFLAGS = -s

SRC/DOS1.MAK (without i18n)
-------------------------------------------------------------------------------
CFLAGS1= -D__OPTIMIZE__ -Wall -fstrength-reduce -ffast-math -O6 -funroll-loops -L. -D DOG_DRIVER  -Wall -D AA_DRIVER -malign-double
LIBS = -lalleg -L ../../vga -L ../../text -L ../../aalib-1.2 -laa -ltext -lvga -lpng -lz -lm
LFLAGS = -s

SRC/MAKEFILE.DOS (only needed to modify if you don't want i18n)
-------------------------------------------------------------------------------
include dos.mak
CFLAGS=$(CFLAGS1)

TLIBS= \
       lib/libui.a \
       lib/libui-hlp.a \
       lib/libengine.a \
       lib/libutil.a \
       lib/libfilter.a \
       lib/libuidos.a \
       lib/libuiaa.a

DIRS= \
       engine \
       filter \
       ui \
       ui-hlp \
       util \
       ui/ui-drv/dos \
       ui/ui-drv/aa

PROG= ../bin/xaos
OBJS = $(SRCS:.c=.o)

include dos.mak

all default:    $(PROG)

../bin:
	mkdir $@

lib:
	mkdir $@
libs:
	$(MAKE) -f Makefile.dos -C ui all
	$(MAKE) -f Makefile.dos -C ui-hlp all
	$(MAKE) -f Makefile.dos -C engine all
	$(MAKE) -f Makefile.dos -C filter all
	$(MAKE) -f Makefile.dos -C util all
	$(MAKE) -f Makefile.dos -C ui/ui-drv/dos all
	$(MAKE) -f Makefile.dos -C ui/ui-drv/aa all

$(PROG): lib ../bin include/config.h include/aconfig.h libs
	$(CC) $(CFLAGS) $(LFLAGS) -o $@ $(TLIBS) $(LIBS)

include/config.h:
	copy include\config\config.dos include\config.h

include/aconfig.h:
	copy include\config\aconfig.std include\aconfig.h

clean:
	$(MAKE) -f Makefile.dos -C ui clean
	$(MAKE) -f Makefile.dos -C ui-hlp clean
	$(MAKE) -f Makefile.dos -C engine clean
	$(MAKE) -f Makefile.dos -C util clean
	$(MAKE) -f Makefile.dos -C ui/ui-drv/dos clean
	$(MAKE) -f Makefile.dos -C ui/ui-drv/aa clean
	rm -f include/config.h
	rm -f include/aconfig.h
	rm -f $(PROG)

distclean:clean

SRC/UI/UI-DRC/DOS/UI_DOS.C
-------------------------------------------------------------------------------
/*
 *     XaoS, a fast portable realtime fractal zoomer
 *                  Copyright (C) 1996,1997 by
 *
 *      Jan Hubicka          (hubicka@paru.cas.cz)
 *      Thomas Marsh         (tmarsh@austin.ibm.com)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
#include "aconfig.h"
#ifdef DOG_DRIVER
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <allegro.h>
#include <string.h>
#include <config.h>
#include <xio.h>
#include <ui.h>
#include <timers.h>
static int width = 320, height = 200, depth = 8;
struct ui_driver dog_driver;
static int currentbuff = 0;
static BITMAP *buffers[2], *mouseb;
static int white;
static PALETTE palette;
static BITMAP *mouse_pointer;
static int mouse;
static int bill;
static unsigned char mouse_pointer_data[256] =
{
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 1, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 2, 1, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 1, 0,
  0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1,
  0, 0, 0, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1,
  1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1,
  1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0,
  1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1,
  0, 0, 0, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1,
  0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1,
  0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 1, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 2, 1, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 1, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0,
};
void
mkwaitsprite (void)
{
  int i, col;
  mouse_pointer = create_bitmap (16, 16);
  for (i = 0; i < 256; i++)
    {
      if (/*bitmap_color_depth (mouse_pointer)*/8 == 8)
        {
          switch (mouse_pointer_data[i])
            {
            case 1:
              mouse_pointer->line[i / 16][i & 15] = 3;
              break;
            case 2:
              mouse_pointer->line[i / 16][i & 15] = 1;
              break;
            default:
              mouse_pointer->line[i / 16][i & 15] = 0;
              break;
            }
        }
      else
        {
          switch (mouse_pointer_data[i])
            {
            case 1:
              col = makecol (255, 255, 255);
              break;
            case 2:
              col = makecol (0, 0, 0);
              break;
            default:
//              col = mouse_pointer->vtable->mask_color;
              break;
            }
          putpixel (mouse_pointer, i & 15, i / 16, col);
        }
    }
}
/*make startup faster and executable size smaller */
int _stklen = 81920;
/*int _crt0_startup_flags = _CRT0_FLAG_LOCK_MEMORY; */
void
__crt0_load_environment_file (char *_app_name)
{
  return;
}
/*
   void __crt0_setup_arguments(void)
   {
   return;
   } */
char **
__crt0_glob_function (char *_arg)
{
  return 0;
}
static void
dog_print (int x, int y, CONST char *text)
{
  if (mouse)
    show_mouse (NULL);
  text_mode(0);
  textout (screen, font, text, x, y, white);
  if (mouse)
    show_mouse (mouseb);
}
static void
dog_display ()
{
  if (mouse)
    show_mouse (NULL);
  blit (buffers[currentbuff], screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
  if (mouse)
    show_mouse (mouseb);
}
void
set_gui_colors ()
{
  static RGB black =
  {0, 0, 0};
  static RGB grey =
  {48, 48, 48};
  static RGB white =
  {63, 63, 63};
  set_color (0, &black);
  set_color (16, &black);
  set_color (1, &grey);
  set_color (255, &white);
  gui_fg_color = 0;
  gui_bg_color = 1;
}
static void
dog_set_color (ui_palette c, int start, int end)
{
  int i;
  for (i = start; i < end; i++)
    {
      palette[i].r = c[i - start][0] / 4;
      palette[i].g = c[i - start][1] / 4;
      palette[i].b = c[i - start][2] / 4;
    }
  set_palette (palette);
}
static void
fix_palette ()
{
  int i;
  for (i = 0; i < 2; i++)
    {
      palette[i].r = 0;
      palette[i].g = 0;
      palette[i].b = 0;
      set_color (i, &palette[i]);
    }
  palette[255].r = 63;
  palette[255].g = 63;
  palette[255].b = 63;
  set_color (255, &palette[255]);
  set_palette (palette);
}
static void
dog_flip_buffers ()
{
  currentbuff ^= 1;
}
static void
dog_get_size (int *wi, int *he)
{
  static int w = 320, c = GFX_VGA, h = 200;
  int vh;
  if (mouse)
    show_mouse (NULL);
again:
  set_color_depth (8);
  set_gfx_mode (c, w, h, 0, 0);
  if ((!keypressed ()) && (!joy_b1) && (!joy_b2))
    {
      rest (500);
    }
  clear (screen);
  set_gui_colors ();
  if (!gfx_mode_select (&c, &w, &h))
    {
      goto again;
    }
  vh = h;
  set_color_depth (depth);
  if (set_gfx_mode (c, w, h, 0, 0) != 0)
    {
      goto again;
    }
  width = SCREEN_W;
  height = SCREEN_H;
  switch (depth)
    {
    case 8:
      dog_driver.imagetype = UI_C256, white = 255;
      white=1;
      break;
    case 15:
      dog_driver.imagetype = UI_TRUECOLOR16, white = 0xffff;
      dog_driver.rmask = 31 * 32 * 32;
      dog_driver.gmask = 31 * 32;
      dog_driver.bmask = 31;
      break;
    case 16:
      dog_driver.imagetype = UI_TRUECOLOR16, white = 0xffff;
      dog_driver.rmask = 31 * 64 * 32;
      dog_driver.gmask = 63 * 32;
      dog_driver.bmask = 31;
      break;
    case 24:
      dog_driver.imagetype = UI_TRUECOLOR24, white = 0xffffff;
      dog_driver.rmask = 0xff0000;
      dog_driver.gmask = 0x00ff00;
      dog_driver.bmask = 0x0000ff;
      break;
    case 32:
      dog_driver.imagetype = UI_TRUECOLOR, white = 0xffffff;
      dog_driver.rmask = 0xff0000;
      dog_driver.gmask = 0x00ff00;
      dog_driver.bmask = 0x0000ff;
      break;
    }
  clear (screen);
  if (mouse)
    {
      mkwaitsprite ();
      show_mouse (screen);
    }
  if (depth == 8)
    fix_palette ();
  *wi = w;
  *he = h;
}
static void
dog_uninitialise ()
{
  text_mode (0);
  tl_allegromode (0);
  allegro_exit ();
  install_keyboard ();
  allegro_exit ();
}
void
dog_free (char *b1, char *b2)
{
  destroy_bitmap (buffers[0]);
  destroy_bitmap (buffers[1]);
}
int
dog_alloc (char **b1, char **b2)
{
  buffers[0] = create_bitmap (SCREEN_W, SCREEN_H);
  if(buffers[0]==NULL) return 0;
  buffers[1] = create_bitmap (SCREEN_W, SCREEN_H);
  if(buffers[1]==NULL) return 0;
  currentbuff = 0;
  *b1 = buffers[0]->line[0];
  *b2 = buffers[1]->line[0];
  return width * ((depth + 1) / 8);
}
static void
dog_processevents (int wait, int *x, int *y, int *b, int *k)
{
  *x = mouse_x;
  *y = mouse_y;
  *b = 0;
  while (keypressed ())
    {
      unsigned int c=readkey();
      switch(c>>8) {
      case KEY_UP:c=ui_key(UIKEY_UP);break;
      case KEY_DOWN:c=ui_key(UIKEY_DOWN);break;
      case KEY_LEFT:c=ui_key(UIKEY_LEFT);break;
      case KEY_RIGHT:c=ui_key(UIKEY_RIGHT);break;
      case KEY_ESC:c=ui_key(UIKEY_ESC);break;
      case KEY_BACKSPACE:c=ui_key(UIKEY_BACKSPACE);break;
      case KEY_HOME:c=ui_key(UIKEY_HOME);break;
      case KEY_END:c=ui_key(UIKEY_END);break;
      case KEY_PGUP:c=ui_key(UIKEY_PGUP);break;
      case KEY_PGDN:c=ui_key(UIKEY_PGDOWN);break;
      default:
      c=ui_key((unsigned char)c);
      }
      if (c == 2)
        return;
    }
  if (mouse_b & 1)
    *b |= BUTTON1;
  if (mouse_b & 2)
    *b |= BUTTON3;
  if (mouse_b & 4)
    *b |= BUTTON2;
  *k = (key[KEY_LEFT] != 0) + 2 * (key[KEY_RIGHT] != 0) + 4 * (key[KEY_UP] != 0) + 8 * (key[KEY_DOWN] != 0);
}
static void
dog_getmouse (int *x, int *y, int *b)
{
  *x = mouse_x;
  *y = mouse_y;
  *b = 0;
  if (mouse_b == 1)
    *b |= BUTTON1;
  if (mouse_b == 2)
    *b |= BUTTON3;
  if (mouse_b & 4)
    *b |= BUTTON2;
}
int
dog_init ()
{
  if (bill)
    i_love_bill = 1;
  i_love_bill = 1;
  allegro_init ();
  tl_allegromode (1);
  install_keyboard ();
  mouse = (install_mouse () != -1);
  if (bill)
    i_love_bill = 1;
  install_timer ();
  mouseb = screen;
  set_gfx_mode (GFX_VGA, 320, 200, 0, 0);
  signal (SIGFPE, SIG_IGN);
  fix_palette ();
  return (1);
}
static CONST struct params params[] =
{
  {"", P_HELP, NULL,"DOS driver options:"},
  {"-i_love_bill", P_SWITCH, &bill, "Enable windows friendly mode"},
  {NULL, 0, NULL, NULL}
};
void
dog_setmouse (int mode)
{
  if (mouse)
    {
      show_mouse (NULL);
      if (mode == WAITMOUSE)
        set_mouse_sprite (mouse_pointer), set_mouse_sprite_focus (4, 6);
      else
        set_mouse_sprite (NULL), set_mouse_sprite_focus (0, 0);
      if (mode == REPLAYMOUSE)
        mouseb = NULL;
      else
        mouseb = screen;
      show_mouse (mouseb);
    }
}
struct ui_driver dog_driver =
{
  "MS-DOG",
  dog_init,
  dog_get_size,
  dog_processevents,
  dog_getmouse,
  dog_uninitialise,
  NULL,
  dog_set_color,
  dog_print,
  dog_display,
  dog_alloc,
  dog_free,
  dog_flip_buffers,
  dog_setmouse,
  NULL,
  8,
  8,
  params,
  FULLSCREEN | UPDATE_AFTER_RESIZE | PALETTE_ROTATION | ROTATE_INSIDE_CALCULATION | RESIZE_COMMAND,
  0.0, 0.0,
  0, 0,
  UI_C256,
  0, 256, 255
};
#endif

SRC/ENGINE/FORMULAS.C
-------------------------------------------------------------------------------
Bailout is an interesting feature, but, unfortunately it slows down the
DJGPP compiled code on my system. Maybe this can also happen for you. If
yes, i.e. after starting XaoS Mandelbrot fractal comes up incredibly
slow, then you should change "cfractalc.bailout" string to "4" all places
in this file. As you can realize, binary distribution (xaos316b.zip)
does not support bailout setting (you can set it but nothing happens) at
the moment. :-(
