This commit was generated by cvs2svn to compensate for changes in r2,
authorBradley Bell <btb@icculus.org>
Fri, 19 Jan 2001 03:30:16 +0000 (03:30 +0000)
committerBradley Bell <btb@icculus.org>
Fri, 19 Jan 2001 03:30:16 +0000 (03:30 +0000)
which included commits to RCS files with non-trunk default branches.

697 files changed:
2d/2dsline.c [new file with mode: 0644]
2d/Makefile.am [new file with mode: 0644]
2d/Makefile.in [new file with mode: 0644]
2d/bitblt.c [new file with mode: 0644]
2d/bitmap.c [new file with mode: 0644]
2d/bitmap.h [new file with mode: 0644]
2d/box.c [new file with mode: 0644]
2d/canvas.c [new file with mode: 0644]
2d/circle.c [new file with mode: 0644]
2d/clip.h [new file with mode: 0644]
2d/diff [new file with mode: 0644]
2d/disc.c [new file with mode: 0644]
2d/font.c [new file with mode: 0644]
2d/gpixel.c [new file with mode: 0644]
2d/ibitblt.c [new file with mode: 0644]
2d/line.c [new file with mode: 0644]
2d/linear.asm [new file with mode: 0644]
2d/linear.h [new file with mode: 0644]
2d/palette.c [new file with mode: 0644]
2d/pcx.c [new file with mode: 0644]
2d/pixel.c [new file with mode: 0644]
2d/poly.c [new file with mode: 0644]
2d/rect.c [new file with mode: 0644]
2d/rle.c [new file with mode: 0644]
2d/scale.c [new file with mode: 0644]
2d/scalea.asm [new file with mode: 0644]
2d/scalea.h [new file with mode: 0644]
2d/scalec.c [new file with mode: 0644]
2d/tmerge.c [new file with mode: 0644]
2d/tmerge_a.asm [new file with mode: 0644]
3d/Makefile.am [new file with mode: 0644]
3d/Makefile.in [new file with mode: 0644]
3d/clipper.c [new file with mode: 0644]
3d/clipper.h [new file with mode: 0644]
3d/draw.c [new file with mode: 0644]
3d/globvars.c [new file with mode: 0644]
3d/globvars.h [new file with mode: 0644]
3d/instance.c [new file with mode: 0644]
3d/interp.asm [new file with mode: 0644]
3d/interp.c [new file with mode: 0644]
3d/matrix.c [new file with mode: 0644]
3d/points.c [new file with mode: 0644]
3d/rod.c [new file with mode: 0644]
3d/setup.c [new file with mode: 0644]
AUTHORS [new file with mode: 0644]
COPYING [new file with mode: 0644]
ChangeLog [new file with mode: 0644]
INSTALL [new file with mode: 0644]
Makefile.am [new file with mode: 0644]
Makefile.in [new file with mode: 0644]
NEWS [new file with mode: 0644]
README [new file with mode: 0644]
aclocal.m4 [new file with mode: 0644]
arch/Makefile.am [new file with mode: 0644]
arch/Makefile.in [new file with mode: 0644]
arch/dos/allg_snd/allg_snd.c [new file with mode: 0644]
arch/dos/allg_snd/internal.h [new file with mode: 0644]
arch/dos/allg_snd/sound/allegro.h [new file with mode: 0644]
arch/dos/allg_snd/sound/config.c [new file with mode: 0644]
arch/dos/allg_snd/sound/digmid.c [new file with mode: 0644]
arch/dos/allg_snd/sound/drv/adlib.c [new file with mode: 0644]
arch/dos/allg_snd/sound/drv/awedata.c [new file with mode: 0644]
arch/dos/allg_snd/sound/drv/dma.c [new file with mode: 0644]
arch/dos/allg_snd/sound/drv/emu8k.c [new file with mode: 0644]
arch/dos/allg_snd/sound/drv/emu8k.h [new file with mode: 0644]
arch/dos/allg_snd/sound/drv/emu8kmid.c [new file with mode: 0644]
arch/dos/allg_snd/sound/drv/fm_instr.h [new file with mode: 0644]
arch/dos/allg_snd/sound/drv/gus.c [new file with mode: 0644]
arch/dos/allg_snd/sound/drv/mpu.c [new file with mode: 0644]
arch/dos/allg_snd/sound/drv/sb.c [new file with mode: 0644]
arch/dos/allg_snd/sound/interndj.h [new file with mode: 0644]
arch/dos/allg_snd/sound/midi.c [new file with mode: 0644]
arch/dos/allg_snd/sound/mixer.c [new file with mode: 0644]
arch/dos/allg_snd/sound/readme.d1 [new file with mode: 0644]
arch/dos/allg_snd/sound/readme.txt [new file with mode: 0644]
arch/dos/allg_snd/sound/snddrv.c [new file with mode: 0644]
arch/dos/allg_snd/sound/sound.c [new file with mode: 0644]
arch/dos/bak/ipx.c [new file with mode: 0644]
arch/dos/bcd.c [new file with mode: 0644]
arch/dos/comm/commlib.c [new file with mode: 0644]
arch/dos/comm/dzcomm.c [new file with mode: 0644]
arch/dos/comm/dzqueue.c [new file with mode: 0644]
arch/dos/comm/include/allegro.h [new file with mode: 0644]
arch/dos/comm/include/asmdef.inc [new file with mode: 0644]
arch/dos/comm/include/asmdefs.inc [new file with mode: 0644]
arch/dos/comm/include/commlib.h [new file with mode: 0644]
arch/dos/comm/include/internal.h [new file with mode: 0644]
arch/dos/comm/irq.c [new file with mode: 0644]
arch/dos/comm/irqwrap.S [new file with mode: 0644]
arch/dos/digiallg.c [new file with mode: 0644]
arch/dos/digimm.c [new file with mode: 0644]
arch/dos/disk.c [new file with mode: 0644]
arch/dos/dosgr.c [new file with mode: 0644]
arch/dos/dpmi.c [new file with mode: 0644]
arch/dos/include/commlib.h [new file with mode: 0644]
arch/dos/include/disk.h [new file with mode: 0644]
arch/dos/include/dzcomm.h [new file with mode: 0644]
arch/dos/include/joy.h [new file with mode: 0644]
arch/dos/include/key.h [new file with mode: 0644]
arch/dos/include/midiallg.h [new file with mode: 0644]
arch/dos/include/mouse.h [new file with mode: 0644]
arch/dos/include/serial.h [new file with mode: 0644]
arch/dos/init.c [new file with mode: 0644]
arch/dos/ipx.c [new file with mode: 0644]
arch/dos/ipx.h [new file with mode: 0644]
arch/dos/joy2.asm [new file with mode: 0644]
arch/dos/joyc.c [new file with mode: 0644]
arch/dos/joydefs.c [new file with mode: 0644]
arch/dos/key.c [new file with mode: 0644]
arch/dos/midiallg.c [new file with mode: 0644]
arch/dos/mm_snd/drv_sb.c [new file with mode: 0644]
arch/dos/mm_snd/include/mdma.h [new file with mode: 0644]
arch/dos/mm_snd/include/mikmod.h [new file with mode: 0644]
arch/dos/mm_snd/include/mirq.h [new file with mode: 0644]
arch/dos/mm_snd/include/mm_drv.h [new file with mode: 0644]
arch/dos/mm_snd/include/mmio.h [new file with mode: 0644]
arch/dos/mm_snd/include/mtypes.h [new file with mode: 0644]
arch/dos/mm_snd/mdma.c [new file with mode: 0644]
arch/dos/mm_snd/mirq.c [new file with mode: 0644]
arch/dos/mm_snd/readme.txt [new file with mode: 0644]
arch/dos/modex.asm [new file with mode: 0644]
arch/dos/mono.c [new file with mode: 0644]
arch/dos/mono.h [new file with mode: 0644]
arch/dos/mouse.c [new file with mode: 0644]
arch/dos/serial.c [new file with mode: 0644]
arch/dos/sgrep.out [new file with mode: 0644]
arch/dos/timer.asm [new file with mode: 0644]
arch/dos/tweak.inc [new file with mode: 0644]
arch/dos/vesa.c [new file with mode: 0644]
arch/dos/vgaregs.inc [new file with mode: 0644]
arch/linux/Makefile.am [new file with mode: 0644]
arch/linux/Makefile.in [new file with mode: 0644]
arch/linux/alsadigi.c [new file with mode: 0644]
arch/linux/findfile.c [new file with mode: 0644]
arch/linux/hmiplay.c [new file with mode: 0644]
arch/linux/hmistub.c [new file with mode: 0644]
arch/linux/include/ipx_bsd.h [new file with mode: 0644]
arch/linux/include/ipx_drv.h [new file with mode: 0644]
arch/linux/include/ipx_hlpr.h [new file with mode: 0644]
arch/linux/include/ipx_kali.h [new file with mode: 0644]
arch/linux/include/ipx_ld.h [new file with mode: 0644]
arch/linux/include/ipx_lin.h [new file with mode: 0644]
arch/linux/include/ipx_udp.h [new file with mode: 0644]
arch/linux/include/music.h [new file with mode: 0644]
arch/linux/include/serial.h [new file with mode: 0644]
arch/linux/include/ukali.h [new file with mode: 0644]
arch/linux/init.c [new file with mode: 0644]
arch/linux/ipx_bsd.c [new file with mode: 0644]
arch/linux/ipx_kali.c [new file with mode: 0644]
arch/linux/ipx_lin.c [new file with mode: 0644]
arch/linux/ipx_udp.c [new file with mode: 0644]
arch/linux/linuxnet.c [new file with mode: 0644]
arch/linux/mono.c [new file with mode: 0644]
arch/linux/serial.c [new file with mode: 0644]
arch/linux/stHqFIq1 [new file with mode: 0644]
arch/linux/svgalib/event.c [new file with mode: 0644]
arch/linux/svgalib/gr.c [new file with mode: 0644]
arch/linux/svgalib/include/event.h [new file with mode: 0644]
arch/linux/svgalib/include/key.h [new file with mode: 0644]
arch/linux/svgalib/include/mouse.h [new file with mode: 0644]
arch/linux/svgalib/init.c [new file with mode: 0644]
arch/linux/svgalib/key.c [new file with mode: 0644]
arch/linux/svgalib/mouse.c [new file with mode: 0644]
arch/linux/timer.c [new file with mode: 0644]
arch/linux/ukali.c [new file with mode: 0644]
arch/ogl/include/loadgl.h [new file with mode: 0644]
arch/ogl/include/ogl_init.h [new file with mode: 0644]
arch/sdl/Makefile.am [new file with mode: 0644]
arch/sdl/Makefile.in [new file with mode: 0644]
arch/sdl/init.c [new file with mode: 0644]
arch/sdl/timer.c [new file with mode: 0644]
arch/win32/d1x.ico [new file with mode: 0644]
arch/win32/d1x.rc [new file with mode: 0644]
arch/win32/d3d.ico [new file with mode: 0644]
arch/win32/d3dframe/d3denum.cpp [new file with mode: 0644]
arch/win32/d3dframe/d3denum.h [new file with mode: 0644]
arch/win32/d3dframe/d3dframe.cpp [new file with mode: 0644]
arch/win32/d3dframe/d3dframe.h [new file with mode: 0644]
arch/win32/d3dframe/d3dmath.cpp [new file with mode: 0644]
arch/win32/d3dframe/d3dmath.h [new file with mode: 0644]
arch/win32/d3dframe/d3dtextr.cpp [new file with mode: 0644]
arch/win32/d3dframe/d3dtextr.h [new file with mode: 0644]
arch/win32/d3dframe/d3dutil.cpp [new file with mode: 0644]
arch/win32/d3dframe/d3dutil.h [new file with mode: 0644]
arch/win32/d3dframe/ddenum.cpp [new file with mode: 0644]
arch/win32/d3dframe/ddmm.h [new file with mode: 0644]
arch/win32/d3dframe/ddutil.h [new file with mode: 0644]
arch/win32/d3dframe/ddutil2.h [new file with mode: 0644]
arch/win32/d3dframe/dsutil.h [new file with mode: 0644]
arch/win32/d3dframe/lbprintf.h [new file with mode: 0644]
arch/win32/d3dframe/resource.h [new file with mode: 0644]
arch/win32/d3dframe/userdlg.cpp [new file with mode: 0644]
arch/win32/debug.cpp [new file with mode: 0644]
arch/win32/descent.ico [new file with mode: 0644]
arch/win32/digi.c [new file with mode: 0644]
arch/win32/glinit.c [new file with mode: 0644]
arch/win32/gr.c [new file with mode: 0644]
arch/win32/hmpfile.c [new file with mode: 0644]
arch/win32/include/d3dhelp.h [new file with mode: 0644]
arch/win32/include/debug.h [new file with mode: 0644]
arch/win32/include/hmpfile.h [new file with mode: 0644]
arch/win32/include/joy.h [new file with mode: 0644]
arch/win32/include/key.h [new file with mode: 0644]
arch/win32/include/mouse.h [new file with mode: 0644]
arch/win32/include/pch.h [new file with mode: 0644]
arch/win32/include/resource.h [new file with mode: 0644]
arch/win32/include/scene.h [new file with mode: 0644]
arch/win32/include/serial.h [new file with mode: 0644]
arch/win32/include/texture.h [new file with mode: 0644]
arch/win32/include/winmain.h [new file with mode: 0644]
arch/win32/include/wsipx.h [new file with mode: 0644]
arch/win32/init.c [new file with mode: 0644]
arch/win32/ipx_drv.h [new file with mode: 0644]
arch/win32/ipx_win.c [new file with mode: 0644]
arch/win32/joydefs.c [new file with mode: 0644]
arch/win32/joyhh.c [new file with mode: 0644]
arch/win32/key.c [new file with mode: 0644]
arch/win32/mono.c [new file with mode: 0644]
arch/win32/mouse.c [new file with mode: 0644]
arch/win32/palw32.c [new file with mode: 0644]
arch/win32/pch.cpp [new file with mode: 0644]
arch/win32/scene.cpp [new file with mode: 0644]
arch/win32/serial.c [new file with mode: 0644]
arch/win32/texture.cpp [new file with mode: 0644]
arch/win32/timer.c [new file with mode: 0644]
arch/win32/win32.c [new file with mode: 0644]
arch/win32/winmain.cpp [new file with mode: 0644]
arch/win32/winnet.c [new file with mode: 0644]
autogen.sh [new file with mode: 0644]
cfile/Makefile.am [new file with mode: 0644]
cfile/Makefile.in [new file with mode: 0644]
cfile/cfile.c [new file with mode: 0644]
cfile/nocfile.h [new file with mode: 0644]
conf.h.in [new file with mode: 0644]
config.guess [new file with mode: 0644]
config.sub [new file with mode: 0644]
configure [new file with mode: 0644]
configure.in [new file with mode: 0644]
iff/Makefile.am [new file with mode: 0644]
iff/Makefile.in [new file with mode: 0644]
iff/archive/iff15bpp.c [new file with mode: 0644]
iff/archive/iff8bpp.c [new file with mode: 0644]
iff/archive/iffmike.c [new file with mode: 0644]
iff/archive/ifftest.c [new file with mode: 0644]
iff/archive/ifftestv.c [new file with mode: 0644]
iff/iff.c [new file with mode: 0644]
include/3d.h [new file with mode: 0644]
include/args.h [new file with mode: 0644]
include/byteswap.h [new file with mode: 0644]
include/cfile.h [new file with mode: 0644]
include/checker.h [new file with mode: 0644]
include/cmd.h [new file with mode: 0644]
include/console.h [new file with mode: 0644]
include/d.bat [new file with mode: 0644]
include/d_delay.h [new file with mode: 0644]
include/d_io.h [new file with mode: 0644]
include/dtypes.h [new file with mode: 0644]
include/dtypes.inc [new file with mode: 0644]
include/error.h [new file with mode: 0644]
include/findfile.h [new file with mode: 0644]
include/fix.h [new file with mode: 0644]
include/gr.h [new file with mode: 0644]
include/grdef.h [new file with mode: 0644]
include/hash.h [new file with mode: 0644]
include/ibitblt.h [new file with mode: 0644]
include/iff.h [new file with mode: 0644]
include/ipx.h [new file with mode: 0644]
include/loadgl.h [new file with mode: 0644]
include/lst.bat [new file with mode: 0644]
include/m.bat [new file with mode: 0644]
include/maths.h [new file with mode: 0644]
include/modex.h [new file with mode: 0644]
include/mono.h [new file with mode: 0644]
include/ogl_init.h [new file with mode: 0644]
include/pa_enabl.h [new file with mode: 0644]
include/palette.h [new file with mode: 0644]
include/pcx.h [new file with mode: 0644]
include/psmacros.inc [new file with mode: 0644]
include/pstypes.h [new file with mode: 0644]
include/pstypes.inc [new file with mode: 0644]
include/rle.h [new file with mode: 0644]
include/strio.h [new file with mode: 0644]
include/strutil.h [new file with mode: 0644]
include/test.c [new file with mode: 0644]
include/test.lnk [new file with mode: 0644]
include/texmap.h [new file with mode: 0644]
include/timer.h [new file with mode: 0644]
include/u_dpmi.h [new file with mode: 0644]
include/u_mem.h [new file with mode: 0644]
include/vecmat.h [new file with mode: 0644]
include/vesa.h [new file with mode: 0644]
input/Makefile.am [new file with mode: 0644]
input/Makefile.in [new file with mode: 0644]
input/ggi/Makefile.am [new file with mode: 0644]
input/ggi/Makefile.in [new file with mode: 0644]
input/ggi/event.c [new file with mode: 0644]
input/ggi/include/event.h [new file with mode: 0644]
input/ggi/include/key.h [new file with mode: 0644]
input/ggi/include/mouse.h [new file with mode: 0644]
input/ggi/init.c [new file with mode: 0644]
input/ggi/key.c [new file with mode: 0644]
input/ggi/mouse.c [new file with mode: 0644]
input/linux/Makefile.am [new file with mode: 0644]
input/linux/Makefile.in [new file with mode: 0644]
input/linux/include/joy.h [new file with mode: 0644]
input/linux/include/joystick.h [new file with mode: 0644]
input/linux/joydefs.c [new file with mode: 0644]
input/linux/joystick.c [new file with mode: 0644]
input/sdl/Makefile.am [new file with mode: 0644]
input/sdl/Makefile.in [new file with mode: 0644]
input/sdl/event.c [new file with mode: 0644]
input/sdl/include/event.h [new file with mode: 0644]
input/sdl/include/key.h [new file with mode: 0644]
input/sdl/include/mouse.h [new file with mode: 0644]
input/sdl/key.c [new file with mode: 0644]
input/sdl/mouse.c [new file with mode: 0644]
install-sh [new file with mode: 0644]
libtool [new file with mode: 0644]
ltconfig [new file with mode: 0644]
ltmain.sh [new file with mode: 0644]
main/Makefile.am [new file with mode: 0644]
main/Makefile.in [new file with mode: 0644]
main/ai.c [new file with mode: 0644]
main/ai.h [new file with mode: 0644]
main/ai2.c [new file with mode: 0644]
main/aipath.c [new file with mode: 0644]
main/aistruct.h [new file with mode: 0644]
main/automap.c [new file with mode: 0644]
main/automap.h [new file with mode: 0644]
main/bm.c [new file with mode: 0644]
main/bm.h [new file with mode: 0644]
main/bmread.c [new file with mode: 0644]
main/bmread.h [new file with mode: 0644]
main/cdrom.h [new file with mode: 0644]
main/cmd.c [new file with mode: 0644]
main/cntrlcen.c [new file with mode: 0644]
main/cntrlcen.h [new file with mode: 0644]
main/collide.c [new file with mode: 0644]
main/collide.h [new file with mode: 0644]
main/compbit.h [new file with mode: 0644]
main/config.c [new file with mode: 0644]
main/config.h [new file with mode: 0644]
main/console.c [new file with mode: 0644]
main/controls.c [new file with mode: 0644]
main/controls.h [new file with mode: 0644]
main/credits.c [new file with mode: 0644]
main/credits.h [new file with mode: 0644]
main/crypt.c [new file with mode: 0644]
main/desc_id.h [new file with mode: 0644]
main/descent.cfg [new file with mode: 0644]
main/desw.h [new file with mode: 0644]
main/digi.h [new file with mode: 0644]
main/dumpmine.c [new file with mode: 0644]
main/editor/editor.h [new file with mode: 0644]
main/editor/kdefs.h [new file with mode: 0644]
main/editor/texpage.h [new file with mode: 0644]
main/effects.c [new file with mode: 0644]
main/effects.h [new file with mode: 0644]
main/endlevel.c [new file with mode: 0644]
main/endlevel.h [new file with mode: 0644]
main/escort.c [new file with mode: 0644]
main/fireball.c [new file with mode: 0644]
main/fireball.h [new file with mode: 0644]
main/fuelcen.c [new file with mode: 0644]
main/fuelcen.h [new file with mode: 0644]
main/fvi.c [new file with mode: 0644]
main/fvi.h [new file with mode: 0644]
main/fvi_a.h [new file with mode: 0644]
main/game.c [new file with mode: 0644]
main/game.h [new file with mode: 0644]
main/gamecntl.c [new file with mode: 0644]
main/gamefont.c [new file with mode: 0644]
main/gamefont.h [new file with mode: 0644]
main/gamemine.c [new file with mode: 0644]
main/gamemine.h [new file with mode: 0644]
main/gamepal.c [new file with mode: 0644]
main/gamepal.h [new file with mode: 0644]
main/gamerend.c [new file with mode: 0644]
main/gamesave.c [new file with mode: 0644]
main/gamesave.h [new file with mode: 0644]
main/gameseg.c [new file with mode: 0644]
main/gameseg.h [new file with mode: 0644]
main/gameseq.c [new file with mode: 0644]
main/gameseq.h [new file with mode: 0644]
main/gamestat.h [new file with mode: 0644]
main/gauges.c [new file with mode: 0644]
main/gauges.h [new file with mode: 0644]
main/hostage.c [new file with mode: 0644]
main/hostage.h [new file with mode: 0644]
main/hud.c [new file with mode: 0644]
main/inferno.c [new file with mode: 0644]
main/inferno.h [new file with mode: 0644]
main/inferno.ini [new file with mode: 0644]
main/joydefs.h [new file with mode: 0644]
main/kconfig.c [new file with mode: 0644]
main/kconfig.h [new file with mode: 0644]
main/kludge.c [new file with mode: 0644]
main/kmatrix.c [new file with mode: 0644]
main/kmatrix.h [new file with mode: 0644]
main/laser.c [new file with mode: 0644]
main/laser.h [new file with mode: 0644]
main/lighting.c [new file with mode: 0644]
main/lighting.h [new file with mode: 0644]
main/menu.c [new file with mode: 0644]
main/menu.h [new file with mode: 0644]
main/mglobal.c [new file with mode: 0644]
main/mission.c [new file with mode: 0644]
main/mission.h [new file with mode: 0644]
main/modem.h [new file with mode: 0644]
main/morph.c [new file with mode: 0644]
main/morph.h [new file with mode: 0644]
main/movie.h [new file with mode: 0644]
main/multi.c [new file with mode: 0644]
main/multi.h [new file with mode: 0644]
main/multibot.c [new file with mode: 0644]
main/multibot.h [new file with mode: 0644]
main/netmisc.c [new file with mode: 0644]
main/netmisc.h [new file with mode: 0644]
main/network.c [new file with mode: 0644]
main/network.h [new file with mode: 0644]
main/newdemo.c [new file with mode: 0644]
main/newdemo.h [new file with mode: 0644]
main/newmenu.c [new file with mode: 0644]
main/newmenu.h [new file with mode: 0644]
main/object.c [new file with mode: 0644]
main/object.h [new file with mode: 0644]
main/old/3dfx.c [new file with mode: 0644]
main/old/3dfx_des.h [new file with mode: 0644]
main/old/arcade.h [new file with mode: 0644]
main/old/cdmix32.c [new file with mode: 0644]
main/old/cdrom.c [new file with mode: 0644]
main/old/coindev.c [new file with mode: 0644]
main/old/coindev.h [new file with mode: 0644]
main/old/descentw.c [new file with mode: 0644]
main/old/digiobj.c [new file with mode: 0644]
main/old/files.h [new file with mode: 0644]
main/old/iglasses.c [new file with mode: 0644]
main/old/iglasses.h [new file with mode: 0644]
main/old/joydefs.c [new file with mode: 0644]
main/old/joydefsw.c [new file with mode: 0644]
main/old/modem.c [new file with mode: 0644]
main/old/movie.c [new file with mode: 0644]
main/old/newmodel.c [new file with mode: 0644]
main/old/rbtest.c [new file with mode: 0644]
main/old/settings.h [new file with mode: 0644]
main/old/terrain.c [new file with mode: 0644]
main/old/windigi.c [new file with mode: 0644]
main/old/winferno.c [new file with mode: 0644]
main/old/winmodem.c [new file with mode: 0644]
main/old/winvideo.c [new file with mode: 0644]
main/paging.c [new file with mode: 0644]
main/paging.h [new file with mode: 0644]
main/physics.c [new file with mode: 0644]
main/physics.h [new file with mode: 0644]
main/piggy.c [new file with mode: 0644]
main/piggy.h [new file with mode: 0644]
main/player.h [new file with mode: 0644]
main/playsave.c [new file with mode: 0644]
main/playsave.h [new file with mode: 0644]
main/polyobj.c [new file with mode: 0644]
main/polyobj.h [new file with mode: 0644]
main/powerup.c [new file with mode: 0644]
main/powerup.h [new file with mode: 0644]
main/render.c [new file with mode: 0644]
main/render.h [new file with mode: 0644]
main/robot.c [new file with mode: 0644]
main/robot.h [new file with mode: 0644]
main/scores.c [new file with mode: 0644]
main/scores.h [new file with mode: 0644]
main/screens.h [new file with mode: 0644]
main/segment.h [new file with mode: 0644]
main/segpoint.h [new file with mode: 0644]
main/slew.c [new file with mode: 0644]
main/slew.h [new file with mode: 0644]
main/songs.c [new file with mode: 0644]
main/songs.h [new file with mode: 0644]
main/sounds.h [new file with mode: 0644]
main/state.c [new file with mode: 0644]
main/state.h [new file with mode: 0644]
main/switch.c [new file with mode: 0644]
main/switch.h [new file with mode: 0644]
main/terrain.h [new file with mode: 0644]
main/test.txt [new file with mode: 0644]
main/texmerge.c [new file with mode: 0644]
main/texmerge.h [new file with mode: 0644]
main/text.c [new file with mode: 0644]
main/text.h [new file with mode: 0644]
main/textures.h [new file with mode: 0644]
main/titles.c [new file with mode: 0644]
main/titles.h [new file with mode: 0644]
main/vclip.c [new file with mode: 0644]
main/vclip.h [new file with mode: 0644]
main/vers_id.h [new file with mode: 0644]
main/wall.c [new file with mode: 0644]
main/wall.h [new file with mode: 0644]
main/weapon.c [new file with mode: 0644]
main/weapon.h [new file with mode: 0644]
maths/Makefile.am [new file with mode: 0644]
maths/Makefile.in [new file with mode: 0644]
maths/fix.asm [new file with mode: 0644]
maths/fixc.c [new file with mode: 0644]
maths/rand.c [new file with mode: 0644]
maths/tables.c [new file with mode: 0644]
maths/vecmat.c [new file with mode: 0644]
maths/vecmata.asm [new file with mode: 0644]
mem/Makefile.am [new file with mode: 0644]
mem/Makefile.in [new file with mode: 0644]
mem/mem.c [new file with mode: 0644]
misc/Makefile.am [new file with mode: 0644]
misc/Makefile.in [new file with mode: 0644]
misc/args.c [new file with mode: 0644]
misc/byteswap.c [new file with mode: 0644]
misc/byteswap.h [new file with mode: 0644]
misc/d_delay.c [new file with mode: 0644]
misc/d_glob.c [new file with mode: 0644]
misc/d_io.c [new file with mode: 0644]
misc/error.c [new file with mode: 0644]
misc/errtest.c [new file with mode: 0644]
misc/fileutil.c [new file with mode: 0644]
misc/fileutil.h [new file with mode: 0644]
misc/hash.c [new file with mode: 0644]
misc/parsarg.c [new file with mode: 0644]
misc/parsarg.h [new file with mode: 0644]
misc/parstest.c [new file with mode: 0644]
misc/strio.c [new file with mode: 0644]
misc/strutil.c [new file with mode: 0644]
missing [new file with mode: 0644]
mkinstalldirs [new file with mode: 0644]
readme.txt [new file with mode: 0644]
sound/Makefile.am [new file with mode: 0644]
sound/Makefile.in [new file with mode: 0644]
sound/sdl_cdrom.c [new file with mode: 0644]
sound/sdl_digi.c [new file with mode: 0644]
stamp-h.in [new file with mode: 0644]
texmap/Makefile.am [new file with mode: 0644]
texmap/Makefile.in [new file with mode: 0644]
texmap/ntmap.c [new file with mode: 0644]
texmap/scanline.c [new file with mode: 0644]
texmap/scanline.h [new file with mode: 0644]
texmap/texmapl.h [new file with mode: 0644]
texmap/tmap_flt.asm [new file with mode: 0644]
texmap/tmap_inc.asm [new file with mode: 0644]
texmap/tmap_lin.asm [new file with mode: 0644]
texmap/tmap_ll.asm [new file with mode: 0644]
texmap/tmap_per.asm [new file with mode: 0644]
texmap/tmapfade.asm [new file with mode: 0644]
texmap/tmapflat.c [new file with mode: 0644]
texmap/tmappent.S [new file with mode: 0644]
texmap/tmapppro.S [new file with mode: 0644]
thinking.txt [new file with mode: 0644]
unused/bios/d.bat [new file with mode: 0644]
unused/bios/dd.bat [new file with mode: 0644]
unused/bios/dpmi.c [new file with mode: 0644]
unused/bios/dpmi.h [new file with mode: 0644]
unused/bios/error.c [new file with mode: 0644]
unused/bios/error.h [new file with mode: 0644]
unused/bios/findfile.c [new file with mode: 0644]
unused/bios/findfile.h [new file with mode: 0644]
unused/bios/ipx.c [new file with mode: 0644]
unused/bios/ipx.h [new file with mode: 0644]
unused/bios/joy.asm [new file with mode: 0644]
unused/bios/joy.h [new file with mode: 0644]
unused/bios/joyc.c [new file with mode: 0644]
unused/bios/key.asm [new file with mode: 0644]
unused/bios/key.c [new file with mode: 0644]
unused/bios/key.h [new file with mode: 0644]
unused/bios/keys.inc [new file with mode: 0644]
unused/bios/make0000.bat [new file with mode: 0644]
unused/bios/make0001.bat [new file with mode: 0644]
unused/bios/make0100.bat [new file with mode: 0644]
unused/bios/mono.c [new file with mode: 0644]
unused/bios/mouse.asm [new file with mode: 0644]
unused/bios/mouse.c [new file with mode: 0644]
unused/bios/mouse.h [new file with mode: 0644]
unused/bios/oldkey.asm [new file with mode: 0644]
unused/bios/rbaudio.c [new file with mode: 0644]
unused/bios/rbaudio.h [new file with mode: 0644]
unused/bios/rbaudio.new [new file with mode: 0644]
unused/bios/speaker.c [new file with mode: 0644]
unused/bios/swiftcfg.h [new file with mode: 0644]
unused/bios/testj.c [new file with mode: 0644]
unused/bios/testk.c [new file with mode: 0644]
unused/bios/testk.lnk [new file with mode: 0644]
unused/bios/testm.c [new file with mode: 0644]
unused/bios/testm.lnk [new file with mode: 0644]
unused/bios/testms.c [new file with mode: 0644]
unused/bios/testt.c [new file with mode: 0644]
unused/bios/timer.asm [new file with mode: 0644]
unused/bios/timer.h [new file with mode: 0644]
unused/bios/timerp.c [new file with mode: 0644]
unused/bios/x [new file with mode: 0644]
unused/bios/x.bat [new file with mode: 0644]
unused/bios/x.c [new file with mode: 0644]
unused/bios/y.bat [new file with mode: 0644]
unused/lib/fix.h [new file with mode: 0644]
unused/lib/rbaudio.h [new file with mode: 0644]
unused/novga/files.rc [new file with mode: 0644]
unused/novga/novesa.c [new file with mode: 0644]
unused/pa_null/pa_enabl.h [new file with mode: 0644]
unused/pa_null/poly_acc.c [new file with mode: 0644]
unused/pa_null/poly_acc.h [new file with mode: 0644]
unused/readme.txt [new file with mode: 0644]
unused/ui/barbox.c [new file with mode: 0644]
unused/ui/button.c [new file with mode: 0644]
unused/ui/checkbox.c [new file with mode: 0644]
unused/ui/file.c [new file with mode: 0644]
unused/ui/func.c [new file with mode: 0644]
unused/ui/func.h [new file with mode: 0644]
unused/ui/gadget.c [new file with mode: 0644]
unused/ui/harderr.c [new file with mode: 0644]
unused/ui/icon.c [new file with mode: 0644]
unused/ui/inputbox.c [new file with mode: 0644]
unused/ui/keypad.c [new file with mode: 0644]
unused/ui/keypress.c [new file with mode: 0644]
unused/ui/keytrap.c [new file with mode: 0644]
unused/ui/listbox.c [new file with mode: 0644]
unused/ui/medfunc.c [new file with mode: 0644]
unused/ui/menu.c [new file with mode: 0644]
unused/ui/menubar.c [new file with mode: 0644]
unused/ui/message.c [new file with mode: 0644]
unused/ui/mouse.c [new file with mode: 0644]
unused/ui/number.c [new file with mode: 0644]
unused/ui/popup.c [new file with mode: 0644]
unused/ui/radio.c [new file with mode: 0644]
unused/ui/scroll.c [new file with mode: 0644]
unused/ui/ui.c [new file with mode: 0644]
unused/ui/ui.h [new file with mode: 0644]
unused/ui/uidraw.c [new file with mode: 0644]
unused/ui/userbox.c [new file with mode: 0644]
unused/ui/window.c [new file with mode: 0644]
unused/vga/dd.bat [new file with mode: 0644]
unused/vga/framebuf.c [new file with mode: 0644]
unused/vga/framebuf.jas [new file with mode: 0644]
unused/vga/fxdpmi.h [new file with mode: 0644]
unused/vga/fxvesa.h [new file with mode: 0644]
unused/vga/grx.h [new file with mode: 0644]
unused/vga/modex.asm [new file with mode: 0644]
unused/vga/new/palette.c [new file with mode: 0644]
unused/vga/new/vga.c [new file with mode: 0644]
unused/vga/palette.c [new file with mode: 0644]
unused/vga/tweak.inc [new file with mode: 0644]
unused/vga/vesa.asm [new file with mode: 0644]
unused/vga/vga.c [new file with mode: 0644]
unused/vga/vga.h [new file with mode: 0644]
unused/vga/vga.jas [new file with mode: 0644]
unused/vga/vgaregs.inc [new file with mode: 0644]
unused/vga/xyz.bat [new file with mode: 0644]
unused/win95/comm.c [new file with mode: 0644]
unused/win95/comm.h [new file with mode: 0644]
unused/win95/dd.bat [new file with mode: 0644]
unused/win95/dd.c [new file with mode: 0644]
unused/win95/dd.h [new file with mode: 0644]
unused/win95/ddgfx.c [new file with mode: 0644]
unused/win95/ddgr.c [new file with mode: 0644]
unused/win95/ddraw.c [new file with mode: 0644]
unused/win95/direct3d.c [new file with mode: 0644]
unused/win95/direct3d.h [new file with mode: 0644]
unused/win95/ds.c [new file with mode: 0644]
unused/win95/ds.h [new file with mode: 0644]
unused/win95/error.c [new file with mode: 0644]
unused/win95/error.h [new file with mode: 0644]
unused/win95/findfile.c [new file with mode: 0644]
unused/win95/gfx.c [new file with mode: 0644]
unused/win95/global.h [new file with mode: 0644]
unused/win95/iforce.c [new file with mode: 0644]
unused/win95/iforce.h [new file with mode: 0644]
unused/win95/ipx.c [new file with mode: 0644]
unused/win95/joyc.c [new file with mode: 0644]
unused/win95/key.c [new file with mode: 0644]
unused/win95/midifile.h [new file with mode: 0644]
unused/win95/midiseq.h [new file with mode: 0644]
unused/win95/mono.c [new file with mode: 0644]
unused/win95/mouse.c [new file with mode: 0644]
unused/win95/palette.c [new file with mode: 0644]
unused/win95/rbaudio.c [new file with mode: 0644]
unused/win95/swift.c [new file with mode: 0644]
unused/win95/tactile.c [new file with mode: 0644]
unused/win95/tactile.h [new file with mode: 0644]
unused/win95/timer.c [new file with mode: 0644]
unused/win95/winapp.c [new file with mode: 0644]
unused/win95/winapp.h [new file with mode: 0644]
unused/win95/winckpit.asm [new file with mode: 0644]
unused/win95/winmidi.c [new file with mode: 0644]
unused/win95/winmidi.h [new file with mode: 0644]
unused/win95/winmono.c [new file with mode: 0644]
unused/win95/winregs.c [new file with mode: 0644]
unused/win95/winregs.h [new file with mode: 0644]
unused/win95/xtapi.c [new file with mode: 0644]
unused/win95/xtapi.h [new file with mode: 0644]
video/Makefile.am [new file with mode: 0644]
video/Makefile.in [new file with mode: 0644]
video/ggi_gr.c [new file with mode: 0644]
video/ogl.c [new file with mode: 0644]
video/ogl_glx.c [new file with mode: 0644]
video/ogl_gr.c [new file with mode: 0644]
video/ogl_wgl.c [new file with mode: 0644]
video/sdl_gr.c [new file with mode: 0644]

diff --git a/2d/2dsline.c b/2d/2dsline.c
new file mode 100644 (file)
index 0000000..6e28cfd
--- /dev/null
@@ -0,0 +1,184 @@
+/*
+THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
+SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
+END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
+ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
+IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
+SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
+FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
+CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
+AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
+COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
+*/
+
+#include <conf.h>
+#include <string.h>
+
+#include "u_mem.h"
+
+#include "gr.h"
+#include "grdef.h"
+
+#ifdef __MSDOS__
+#include "modex.h"
+#include "vesa.h"
+#endif
+
+int Gr_scanline_darkening_level = GR_FADE_LEVELS;
+
+#ifndef NO_ASM
+# ifdef __WATCOMC__
+void gr_linear_darken( ubyte * dest, int darkening_level, int count, ubyte * fade_table );
+#  pragma aux gr_linear_darken parm [edi] [eax] [ecx] [edx] modify exact [eax ebx ecx edx edi] = \
+"                                      xor     ebx, ebx                                        "       \
+"                                      mov     bh, al                                  "  \
+"gld_loop:             mov     bl, [edi]                               "       \
+"                                      mov     al, [ebx+edx]                   "       \
+"                                      mov     [edi], al                               "       \
+"                                      inc     edi                                             "       \
+"                                      dec     ecx                                             "       \
+"                   jnz gld_loop                    "
+
+# elif defined __GNUC__
+static inline void gr_linear_darken( ubyte * dest, int darkening_level, int count, ubyte * fade_table ) {
+   int dummy[4];
+   __asm__ __volatile__ (
+"               xorl %%ebx, %%ebx;"
+"               movb %%al, %%bh;"
+"0:             movb (%%edi), %%bl;"
+"               movb (%%ebx, %%edx), %%al;"
+"               movb %%al, (%%edi);"
+"               incl %%edi;"
+"               decl %%ecx;"
+"               jnz 0b"
+   : "=D" (dummy[0]), "=a" (dummy[1]), "=c" (dummy[2]), "=d" (dummy[3])
+   : "0" (dest), "1" (darkening_level), "2" (count), "3" (fade_table)
+   : "%ebx");
+}
+# elif defined _MSC_VER
+__inline void gr_linear_darken( ubyte * dest, int darkening_level, int count, ubyte * fade_table )
+{
+  __asm {
+    mov edi,[dest]
+       mov eax,[darkening_level]
+       mov ecx,[count]
+       mov edx,[fade_table]
+       xor ebx, ebx
+       mov bh, al
+gld_loop:
+       mov bl,[edi]
+       mov al,[ebx+edx]
+       mov [edi],al
+       inc edi
+       dec ecx
+       jnz gld_loop
+  }
+}
+# else
+// Unknown compiler. So we use C rather than inline assembler.
+#  define USE_C_GR_LINEAR_DARKEN 1
+# endif
+
+#else // No Assembler. So we use C.
+# define USE_C_GR_LINEAR_DARKEN 1
+void gr_linear_stosd( ubyte * dest, unsigned char color, unsigned int nbytes) {
+       memset(dest,color,nbytes);
+}
+#endif
+
+#ifdef USE_C_GR_LINEAR_DARKEN
+void gr_linear_darken(ubyte * dest, int darkening_level, int count, ubyte * fade_table) {
+       register int i;
+
+       for (i=0;i<count;i++)
+               *dest=fade_table[(*dest++)+(darkening_level*256)];
+}
+#endif
+
+void gr_uscanline( int x1, int x2, int y )
+{
+       if (Gr_scanline_darkening_level >= GR_FADE_LEVELS )     {
+#ifdef __MSDOS__
+               switch(TYPE)
+               {
+               case BM_LINEAR:
+#endif
+                       gr_linear_stosd( DATA + ROWSIZE*y + x1, (unsigned char)COLOR, x2-x1+1);
+#ifdef __MSDOS__
+                        break;
+               case BM_MODEX:
+                       gr_modex_uscanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR );
+                       break;
+               case BM_SVGA:
+                       gr_vesa_scanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR );
+                       break;
+               }
+#endif
+       } else {
+#ifdef __MSDOS__
+               switch(TYPE)
+               {
+               case BM_LINEAR:
+#endif
+                       gr_linear_darken( DATA + ROWSIZE*y + x1, Gr_scanline_darkening_level, x2-x1+1, gr_fade_table);
+#ifdef __MSDOS__
+                       break;
+               case BM_MODEX:
+                       gr_modex_uscanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR );
+                       break;
+               case BM_SVGA:
+                       gr_vesa_scanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR );
+                       break;
+               }
+#endif
+       }
+}
+
+void gr_scanline( int x1, int x2, int y )
+{
+       if ((y<0)||(y>MAXY)) return;
+
+       if (x2 < x1 ) x2 ^= x1 ^= x2;
+
+       if (x1 > MAXX) return;
+       if (x2 < MINX) return;
+
+       if (x1 < MINX) x1 = MINX;
+       if (x2 > MAXX) x2 = MAXX;
+
+       if (Gr_scanline_darkening_level >= GR_FADE_LEVELS )     {
+#ifdef __MSDOS__
+               switch(TYPE)
+               {
+               case BM_LINEAR:
+#endif
+                       gr_linear_stosd( DATA + ROWSIZE*y + x1, (unsigned char)COLOR, x2-x1+1);
+#ifdef __MSDOS__
+                       break;
+               case BM_MODEX:
+                       gr_modex_uscanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR );
+                       break;
+               case BM_SVGA:
+                       gr_vesa_scanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR );
+                       break;
+               }
+#endif
+       } else {
+#ifdef __MSDOS__
+               switch(TYPE)
+               {
+               case BM_LINEAR:
+#endif
+                       gr_linear_darken( DATA + ROWSIZE*y + x1, Gr_scanline_darkening_level, x2-x1+1, gr_fade_table);
+#ifdef __MSDOS__
+                       break;
+               case BM_MODEX:
+                       gr_modex_uscanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR );
+                       break;
+               case BM_SVGA:
+                       gr_vesa_scanline( x1+XOFFSET, x2+XOFFSET, y+YOFFSET, COLOR );
+                       break;
+               }
+#endif
+       }
+}
diff --git a/2d/Makefile.am b/2d/Makefile.am
new file mode 100644 (file)
index 0000000..3629b8f
--- /dev/null
@@ -0,0 +1,18 @@
+noinst_LIBRARIES = lib2d.a
+INCLUDES = -I $(top_srcdir)/includes
+
+lib2d_a_SOURCES = \
+2dsline.c  box.c     disc.c    ibitblt.c  pcx.c    rect.c   scalec.c \
+bitblt.c   canvas.c  font.c    line.c    pixel.c  rle.c    tmerge.c \
+bitmap.c   circle.c  gpixel.c  palette.c  poly.c 
+
+if USE_ASM
+  SUFFIXES = .asm
+  %.o: %.asm
+       $(NASM) $(NASMFLAGS) $< -o $@
+       
+  lib2d_a_SOURCES += linear.asm tmerge_a.asm
+  lib2d_a_LIBADD += linear.o tmerge_a.o
+  2dsline.c: linear.o tmerge_a.o
+endif
+
diff --git a/2d/Makefile.in b/2d/Makefile.in
new file mode 100644 (file)
index 0000000..e3502c2
--- /dev/null
@@ -0,0 +1,313 @@
+# Makefile.in generated automatically by automake 1.4 from Makefile.am
+
+# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+
+top_builddir = ..
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+CC = @CC@
+CFLAGS = @CFLAGS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+NASM = @NASM@
+NASMFLAGS = @NASMFLAGS@
+PACKAGE = @PACKAGE@
+RANLIB = @RANLIB@
+SDL_LIBS = @SDL_LIBS@
+VERSION = @VERSION@
+
+noinst_LIBRARIES = lib2d.a
+INCLUDES = -I $(top_srcdir)/includes
+
+lib2d_a_SOURCES =  2dsline.c  box.c     disc.c    ibitblt.c  pcx.c    rect.c   scalec.c bitblt.c   canvas.c  font.c    line.c    pixel.c  rle.c    tmerge.c bitmap.c   circle.c  gpixel.c  palette.c  poly.c 
+
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = ../conf.h
+CONFIG_CLEAN_FILES = 
+LIBRARIES =  $(noinst_LIBRARIES)
+
+
+DEFS = @DEFS@ -I. -I$(srcdir) -I..
+CPPFLAGS = @CPPFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+lib2d_a_LIBADD = 
+lib2d_a_OBJECTS =  2dsline.o box.o disc.o ibitblt.o pcx.o rect.o \
+scalec.o bitblt.o canvas.o font.o line.o pixel.o rle.o tmerge.o \
+bitmap.o circle.o gpixel.o palette.o poly.o
+AR = ar
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
+DIST_COMMON =  Makefile.am Makefile.in
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = tar
+GZIP_ENV = --best
+DEP_FILES =  .deps/2dsline.P .deps/bitblt.P .deps/bitmap.P .deps/box.P \
+.deps/canvas.P .deps/circle.P .deps/disc.P .deps/font.P .deps/gpixel.P \
+.deps/ibitblt.P .deps/line.P .deps/palette.P .deps/pcx.P .deps/pixel.P \
+.deps/poly.P .deps/rect.P .deps/rle.P .deps/scalec.P .deps/tmerge.P
+SOURCES = $(lib2d_a_SOURCES)
+OBJECTS = $(lib2d_a_OBJECTS)
+
+all: all-redirect
+.SUFFIXES:
+.SUFFIXES: .S .c .o .s
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
+       cd $(top_srcdir) && $(AUTOMAKE) --gnu 2d/Makefile
+
+Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status $(BUILT_SOURCES)
+       cd $(top_builddir) \
+         && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+
+mostlyclean-noinstLIBRARIES:
+
+clean-noinstLIBRARIES:
+       -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+
+distclean-noinstLIBRARIES:
+
+maintainer-clean-noinstLIBRARIES:
+
+.s.o:
+       $(COMPILE) -c $<
+
+.S.o:
+       $(COMPILE) -c $<
+
+mostlyclean-compile:
+       -rm -f *.o core *.core
+
+clean-compile:
+
+distclean-compile:
+       -rm -f *.tab.c
+
+maintainer-clean-compile:
+
+lib2d.a: $(lib2d_a_OBJECTS) $(lib2d_a_DEPENDENCIES)
+       -rm -f lib2d.a
+       $(AR) cru lib2d.a $(lib2d_a_OBJECTS) $(lib2d_a_LIBADD)
+       $(RANLIB) lib2d.a
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP)
+       list='$(SOURCES) $(HEADERS)'; \
+       unique=`for i in $$list; do echo $$i; done | \
+         awk '    { files[$$0] = 1; } \
+              END { for (i in files) print i; }'`; \
+       here=`pwd` && cd $(srcdir) \
+         && mkid -f$$here/ID $$unique $(LISP)
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) $(LISP)
+       tags=; \
+       here=`pwd`; \
+       list='$(SOURCES) $(HEADERS)'; \
+       unique=`for i in $$list; do echo $$i; done | \
+         awk '    { files[$$0] = 1; } \
+              END { for (i in files) print i; }'`; \
+       test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
+         || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags  $$unique $(LISP) -o $$here/TAGS)
+
+mostlyclean-tags:
+
+clean-tags:
+
+distclean-tags:
+       -rm -f TAGS ID
+
+maintainer-clean-tags:
+
+distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
+
+subdir = 2d
+
+distdir: $(DISTFILES)
+       here=`cd $(top_builddir) && pwd`; \
+       top_distdir=`cd $(top_distdir) && pwd`; \
+       distdir=`cd $(distdir) && pwd`; \
+       cd $(top_srcdir) \
+         && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu 2d/Makefile
+       @for file in $(DISTFILES); do \
+         d=$(srcdir); \
+         if test -d $$d/$$file; then \
+           cp -pr $$d/$$file $(distdir)/$$file; \
+         else \
+           test -f $(distdir)/$$file \
+           || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+           || cp -p $$d/$$file $(distdir)/$$file || :; \
+         fi; \
+       done
+
+DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
+
+-include $(DEP_FILES)
+
+mostlyclean-depend:
+
+clean-depend:
+
+distclean-depend:
+       -rm -rf .deps
+
+maintainer-clean-depend:
+
+%.o: %.c
+       @echo '$(COMPILE) -c $<'; \
+       $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
+       @-cp .deps/$(*F).pp .deps/$(*F).P; \
+       tr ' ' '\012' < .deps/$(*F).pp \
+         | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
+           >> .deps/$(*F).P; \
+       rm .deps/$(*F).pp
+
+%.lo: %.c
+       @echo '$(LTCOMPILE) -c $<'; \
+       $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
+       @-sed -e 's/^\([^:]*\)\.o[      ]*:/\1.lo \1.o :/' \
+         < .deps/$(*F).pp > .deps/$(*F).P; \
+       tr ' ' '\012' < .deps/$(*F).pp \
+         | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
+           >> .deps/$(*F).P; \
+       rm -f .deps/$(*F).pp
+info-am:
+info: info-am
+dvi-am:
+dvi: dvi-am
+check-am: all-am
+check: check-am
+installcheck-am:
+installcheck: installcheck-am
+install-exec-am:
+install-exec: install-exec-am
+
+install-data-am:
+install-data: install-data-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+install: install-am
+uninstall-am:
+uninstall: uninstall-am
+all-am: Makefile $(LIBRARIES)
+all-redirect: all-am
+install-strip:
+       $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
+installdirs:
+
+
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -rm -f Makefile $(CONFIG_CLEAN_FILES)
+       -rm -f config.cache config.log stamp-h stamp-h[0-9]*
+
+maintainer-clean-generic:
+mostlyclean-am:  mostlyclean-noinstLIBRARIES mostlyclean-compile \
+               mostlyclean-tags mostlyclean-depend mostlyclean-generic
+
+mostlyclean: mostlyclean-am
+
+clean-am:  clean-noinstLIBRARIES clean-compile clean-tags clean-depend \
+               clean-generic mostlyclean-am
+
+clean: clean-am
+
+distclean-am:  distclean-noinstLIBRARIES distclean-compile \
+               distclean-tags distclean-depend distclean-generic \
+               clean-am
+
+distclean: distclean-am
+
+maintainer-clean-am:  maintainer-clean-noinstLIBRARIES \
+               maintainer-clean-compile maintainer-clean-tags \
+               maintainer-clean-depend maintainer-clean-generic \
+               distclean-am
+       @echo "This command is intended for maintainers to use;"
+       @echo "it deletes files that may require special tools to rebuild."
+
+maintainer-clean: maintainer-clean-am
+
+.PHONY: mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \
+clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \
+mostlyclean-compile distclean-compile clean-compile \
+maintainer-clean-compile tags mostlyclean-tags distclean-tags \
+clean-tags maintainer-clean-tags distdir mostlyclean-depend \
+distclean-depend clean-depend maintainer-clean-depend info-am info \
+dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
+install-exec install-data-am install-data install-am install \
+uninstall-am uninstall all-redirect all-am all installdirs \
+mostlyclean-generic distclean-generic clean-generic \
+maintainer-clean-generic clean mostlyclean distclean maintainer-clean
+
+
+@USE_ASM_TRUE@  SUFFIXES = .asm
+@USE_ASM_TRUE@  %.o: %.asm
+@USE_ASM_TRUE@ $(NASM) $(NASMFLAGS) $< -o $@
+
+@USE_ASM_TRUE@  lib2d_a_SOURCES += linear.asm tmerge_a.asm
+@USE_ASM_TRUE@  lib2d_a_LIBADD += linear.o tmerge_a.o
+@USE_ASM_TRUE@  2dsline.c: linear.o tmerge_a.o
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/2d/bitblt.c b/2d/bitblt.c
new file mode 100644 (file)
index 0000000..40177b0
--- /dev/null
@@ -0,0 +1,954 @@
+/*
+THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
+SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
+END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
+ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
+IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
+SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
+FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
+CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
+AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
+COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
+*/
+
+#include <conf.h>
+#include <string.h>
+#include "u_mem.h"
+#include "gr.h"
+#include "grdef.h"
+#include "rle.h"
+#include "error.h"
+
+#ifdef OGL
+#include "ogl_init.h"
+#endif
+
+int gr_bitblt_dest_step_shift = 0;
+int gr_bitblt_double = 0;
+ubyte *gr_bitblt_fade_table=NULL;
+
+void gr_bm_ubitblt00_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
+void gr_bm_ubitblt00m_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
+void gr_bm_ubitblt0x_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest, int masked);
+
+void gr_bm_ubitblt01(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
+void gr_bm_ubitblt02(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
+
+#include "linear.h"
+#include "modex.h"
+#include "vesa.h"
+
+#ifdef NO_ASM
+void gr_linear_movsd( ubyte * source, ubyte * dest, unsigned int nbytes) {
+       memcpy(dest,source,nbytes);
+}
+
+void gr_linear_rep_movsdm(ubyte *src, ubyte *dest, int num_pixels) {
+       register ubyte c;
+       while (num_pixels--)
+               if ((c=*src++)!=255)
+                       *dest++=c;
+               else    dest++;
+}
+
+void gr_linear_rep_movsdm_faded(ubyte * src, ubyte * dest, int num_pixels, ubyte fade_value ) {
+       register ubyte c;
+       while (num_pixels--)
+               if ((c=*src++)!=255)
+                       *dest++=gr_fade_table[((int)fade_value<<8)|(int)c];
+               else    dest++;
+}
+void gr_linear_rep_movsd_2x(ubyte * source, ubyte * dest, uint nbytes ) {
+       register ubyte c;
+       while (nbytes--) {
+               if (nbytes&1)
+                       *dest++=*source++;
+               else {
+                       c=*source++;
+                       *((unsigned short *)dest)++=((short)c<<8)|(short)c;
+               }
+       }
+}
+#endif
+#ifdef D1XD3D
+#include "d3dhelp.h"
+#endif
+
+void gr_ubitmap00( int x, int y, grs_bitmap *bm )
+{
+       register int y1;
+       int dest_rowsize;
+
+       unsigned char * dest;
+       unsigned char * src;
+
+       dest_rowsize=grd_curcanv->cv_bitmap.bm_rowsize << gr_bitblt_dest_step_shift;
+       dest = &(grd_curcanv->cv_bitmap.bm_data[ dest_rowsize*y+x ]);
+
+       src = bm->bm_data;
+
+       for (y1=0; y1 < bm->bm_h; y1++ )    {
+               if (gr_bitblt_double)
+                       gr_linear_rep_movsd_2x( src, dest, bm->bm_w );
+               else
+                       gr_linear_movsd( src, dest, bm->bm_w );
+               src += bm->bm_rowsize;
+               dest+= (int)(dest_rowsize);
+       }
+}
+
+void gr_ubitmap00m( int x, int y, grs_bitmap *bm )
+{
+       register int y1;
+       int dest_rowsize;
+
+       unsigned char * dest;
+       unsigned char * src;
+
+       dest_rowsize=grd_curcanv->cv_bitmap.bm_rowsize << gr_bitblt_dest_step_shift;
+       dest = &(grd_curcanv->cv_bitmap.bm_data[ dest_rowsize*y+x ]);
+
+       src = bm->bm_data;
+
+       if (gr_bitblt_fade_table==NULL) {
+               for (y1=0; y1 < bm->bm_h; y1++ )    {
+                       gr_linear_rep_movsdm( src, dest, bm->bm_w );
+                       src += bm->bm_rowsize;
+                       dest+= (int)(dest_rowsize);
+               }
+       } else {
+               for (y1=0; y1 < bm->bm_h; y1++ )    {
+                       gr_linear_rep_movsdm_faded( src, dest, bm->bm_w, gr_bitblt_fade_table[y1+y] );
+                       src += bm->bm_rowsize;
+                       dest+= (int)(dest_rowsize);
+               }
+       }
+}
+
+//"             jmp     aligned4                                "       
+//"             mov     eax, edi                                "       
+//"             and     eax, 11b                                "       
+//"             jz              aligned4                        "       
+//"             mov     ebx, 4                                  "       
+//"             sub     ebx, eax                                "       
+//"             sub     ecx, ebx                                "       
+//"alignstart:                                                  "       
+//"             mov     al, [esi]                               "       
+//"             add     esi, 4                                  "       
+//"             mov     [edi], al                               "       
+//"             inc     edi                                     "       
+//"             dec     ebx                                     "       
+//"             jne     alignstart                              "       
+//"aligned4:                                                    "       
+
+#ifdef __MSDOS__
+// From Linear to ModeX
+void gr_bm_ubitblt01(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest)
+{
+       ubyte * dbits;
+       ubyte * sbits;
+       int sstep,dstep;
+       int y,plane;
+       int w1;
+
+       if ( w < 4 ) return;
+
+       sstep = src->bm_rowsize;
+       dstep = dest->bm_rowsize << gr_bitblt_dest_step_shift;
+
+       if (!gr_bitblt_double)  {
+               for (plane=0; plane<4; plane++ )        {
+                       gr_modex_setplane( (plane+dx)&3 );
+                       sbits = src->bm_data + (src->bm_rowsize * sy) + sx + plane;
+                       dbits = &gr_video_memory[(dest->bm_rowsize * dy) + ((plane+dx)/4) ];
+                       w1 = w >> 2;
+                       if ( (w&3) > plane ) w1++;
+                       for (y=dy; y < dy+h; y++ )              {
+                               modex_copy_scanline( sbits, dbits, w1 );                
+                               dbits += dstep;
+                               sbits += sstep;
+                       }
+               }
+       } else {
+               for (plane=0; plane<4; plane++ )        {
+                       gr_modex_setplane( (plane+dx)&3 );
+                       sbits = src->bm_data + (src->bm_rowsize * sy) + sx + plane/2;
+                       dbits = &gr_video_memory[(dest->bm_rowsize * dy) + ((plane+dx)/4) ];
+                       w1 = w >> 2;
+                       if ( (w&3) > plane ) w1++;
+                       for (y=dy; y < dy+h; y++ )              {
+                               modex_copy_scanline_2x( sbits, dbits, w1 );             
+                               dbits += dstep;
+                               sbits += sstep;
+                       }
+               }
+       }
+}
+
+
+// From Linear to ModeX masked
+void gr_bm_ubitblt01m(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest)
+{
+       //ubyte * dbits1;
+       //ubyte * sbits1;
+       
+       ubyte * dbits;
+       ubyte * sbits;
+
+       int x;
+//     int y;
+
+       sbits =   src->bm_data  + (src->bm_rowsize * sy) + sx;
+       dbits =   &gr_video_memory[(dest->bm_rowsize * dy) + dx/4];
+
+       for (x=dx; x < dx+w; x++ )      {       
+               gr_modex_setplane( x&3 );
+
+               //sbits1 = sbits;
+               //dbits1 = dbits;
+               //for (y=0; y < h; y++ )    {
+               //      *dbits1 = *sbits1;
+               //      sbits1 += src_bm_rowsize;
+               //      dbits1 += dest_bm_rowsize;
+               //      }
+               modex_copy_column_m(sbits, dbits, h, src->bm_rowsize, dest->bm_rowsize << gr_bitblt_dest_step_shift );
+
+               sbits++;
+               if ( (x&3)==3 )
+                       dbits++;
+       }
+}
+
+#endif
+
+
+void gr_ubitmap012( int x, int y, grs_bitmap *bm )
+{
+       register int x1, y1;
+       unsigned char * src;
+
+       src = bm->bm_data;
+
+       for (y1=y; y1 < (y+bm->bm_h); y1++ )    {
+               for (x1=x; x1 < (x+bm->bm_w); x1++ )    {
+                       gr_setcolor( *src++ );
+                       gr_upixel( x1, y1 );
+               }
+       }
+}
+
+void gr_ubitmap012m( int x, int y, grs_bitmap *bm )
+{
+       register int x1, y1;
+       unsigned char * src;
+
+       src = bm->bm_data;
+
+       for (y1=y; y1 < (y+bm->bm_h); y1++ )    {
+               for (x1=x; x1 < (x+bm->bm_w); x1++ )    {
+                       if ( *src != 255 )      {
+                               gr_setcolor( *src );
+                               gr_upixel( x1, y1 );
+                       }
+                       src++;
+               }
+       }
+}
+
+
+void gr_ubitmapGENERIC(int x, int y, grs_bitmap * bm)
+{
+       register int x1, y1;
+
+       for (y1=0; y1 < bm->bm_h; y1++ )    {
+               for (x1=0; x1 < bm->bm_w; x1++ )    {
+                       gr_setcolor( gr_gpixel(bm,x1,y1) );
+                       gr_upixel( x+x1, y+y1 );
+               }
+       }
+}
+
+void gr_ubitmapGENERICm(int x, int y, grs_bitmap * bm)
+{
+       register int x1, y1;
+       ubyte c;
+
+       for (y1=0; y1 < bm->bm_h; y1++ )    {
+               for (x1=0; x1 < bm->bm_w; x1++ )    {
+                       c = gr_gpixel(bm,x1,y1);
+                       if ( c != 255 ) {
+                               gr_setcolor( c );
+                               gr_upixel( x+x1, y+y1 );
+                       }
+               }
+       }
+}
+
+void gr_ubitmap( int x, int y, grs_bitmap *bm )
+{   int source, dest;
+
+       source = bm->bm_type;
+       dest = TYPE;
+
+       if (source==BM_LINEAR) {
+               switch( dest )
+               {
+               case BM_LINEAR:
+                       if ( bm->bm_flags & BM_FLAG_RLE )
+                               gr_bm_ubitblt00_rle(bm->bm_w, bm->bm_h, x, y, 0, 0, bm, &grd_curcanv->cv_bitmap );
+                       else
+                               gr_ubitmap00( x, y, bm );
+                       return;
+#ifdef OGL
+               case BM_OGL:
+                       ogl_ubitmapm(x,y,bm);
+                       return;
+#endif
+#ifdef D1XD3D
+               case BM_DIRECTX:
+                       Assert ((int)grd_curcanv->cv_bitmap.bm_data == BM_D3D_RENDER || (int)grd_curcanv->cv_bitmap.bm_data == BM_D3D_DISPLAY);
+                       Win32_BlitLinearToDirectX_bm(bm, 0, 0, bm->bm_w, bm->bm_h, x, y, 0);
+                       return;
+#endif
+#ifdef __MSDOS__
+               case BM_SVGA:
+                       if ( bm->bm_flags & BM_FLAG_RLE )
+                               gr_bm_ubitblt0x_rle(bm->bm_w, bm->bm_h, x, y, 0, 0, bm, &grd_curcanv->cv_bitmap, 0 );
+                       else
+                               gr_bm_ubitblt02( bm->bm_w, bm->bm_h, x, y, 0, 0, bm, &grd_curcanv->cv_bitmap);
+                       return;
+               case BM_MODEX:
+                       gr_bm_ubitblt01(bm->bm_w, bm->bm_h, x+XOFFSET, y+YOFFSET, 0, 0, bm, &grd_curcanv->cv_bitmap);
+                       return;
+#endif
+               default:
+                       gr_ubitmap012( x, y, bm );
+                       return;
+               }
+       } else  {
+               gr_ubitmapGENERIC(x, y, bm);
+       }
+}
+
+void gr_ubitmapm( int x, int y, grs_bitmap *bm )
+{   int source, dest;
+
+
+       source = bm->bm_type;
+       dest = TYPE;
+
+       if (source==BM_LINEAR) {
+               switch( dest )
+               {
+               case BM_LINEAR:
+                       if ( bm->bm_flags & BM_FLAG_RLE )
+                               gr_bm_ubitblt00m_rle(bm->bm_w, bm->bm_h, x, y, 0, 0, bm, &grd_curcanv->cv_bitmap );
+                       else
+                               gr_ubitmap00m( x, y, bm );
+                       return;
+#ifdef OGL
+               case BM_OGL:
+                       ogl_ubitmapm(x,y,bm);
+                       return;
+#endif
+#ifdef D1XD3D
+               case BM_DIRECTX:
+                       if (bm->bm_w < 35 && bm->bm_h < 35) {
+                               // ugly hack needed for reticle
+                               if ( bm->bm_flags & BM_FLAG_RLE )
+                                       gr_bm_ubitblt0x_rle(bm->bm_w, bm->bm_h, x, y, 0, 0, bm, &grd_curcanv->cv_bitmap, 1 );
+                               else
+                                       gr_ubitmapGENERICm(x, y, bm);
+                               return;
+                       }
+                       Assert ((int)grd_curcanv->cv_bitmap.bm_data == BM_D3D_RENDER || (int)grd_curcanv->cv_bitmap.bm_data == BM_D3D_DISPLAY);
+                       Win32_BlitLinearToDirectX_bm(bm, 0, 0, bm->bm_w, bm->bm_h, x, y, 1);
+                       return;
+#endif
+#ifdef __MSDOS__
+               case BM_SVGA:
+                       gr_ubitmapGENERICm(x, y, bm);
+                       return;
+               case BM_MODEX:
+                       gr_bm_ubitblt01m(bm->bm_w, bm->bm_h, x+XOFFSET, y+YOFFSET, 0, 0, bm, &grd_curcanv->cv_bitmap);
+                       return;
+#endif
+               default:
+                       gr_ubitmap012m( x, y, bm );
+                       return;
+               }
+       } else  {
+               gr_ubitmapGENERICm(x, y, bm);
+       }
+}
+
+
+#ifdef __MSDOS__
+// From linear to SVGA
+void gr_bm_ubitblt02(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest)
+{
+       unsigned char * sbits;
+
+       unsigned int offset, EndingOffset, VideoLocation;
+
+       int sbpr, dbpr, y1, page, BytesToMove;
+
+       sbpr = src->bm_rowsize;
+
+       dbpr = dest->bm_rowsize << gr_bitblt_dest_step_shift;
+
+       VideoLocation = (unsigned int)dest->bm_data + (dest->bm_rowsize * dy) + dx;
+
+       sbits = src->bm_data + ( sbpr*sy ) + sx;
+
+       for (y1=0; y1 < h; y1++ )    {
+
+               page    = VideoLocation >> 16;
+               offset  = VideoLocation & 0xFFFF;
+
+               gr_vesa_setpage( page );
+
+               EndingOffset = offset+w-1;
+
+               if ( EndingOffset <= 0xFFFF )
+               {
+                       if ( gr_bitblt_double )
+                               gr_linear_rep_movsd_2x( (void *)sbits, (void *)(offset+gr_video_memory), w );
+                       else
+                               gr_linear_movsd( (void *)sbits, (void *)(offset+gr_video_memory), w );
+
+                       VideoLocation += dbpr;
+                       sbits += sbpr;
+               }
+               else
+               {
+                       BytesToMove = 0xFFFF-offset+1;
+
+                       if ( gr_bitblt_double )
+                               gr_linear_rep_movsd_2x( (void *)sbits, (void *)(offset+gr_video_memory), BytesToMove );
+                       else
+                               gr_linear_movsd( (void *)sbits, (void *)(offset+gr_video_memory), BytesToMove );
+
+                       page++;
+                       gr_vesa_setpage(page);
+
+                       if ( gr_bitblt_double )
+                               gr_linear_rep_movsd_2x( (void *)(sbits+BytesToMove/2), (void *)gr_video_memory, EndingOffset - 0xFFFF );
+                       else
+                               gr_linear_movsd( (void *)(sbits+BytesToMove), (void *)gr_video_memory, EndingOffset - 0xFFFF );
+
+                       VideoLocation += dbpr;
+                       sbits += sbpr;
+               }
+       }
+}
+
+// From SVGA to linear
+void gr_bm_ubitblt20(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest)
+{
+       unsigned char * dbits;
+
+       unsigned int offset, offset1, offset2;
+
+       int sbpr, dbpr, y1, page;
+
+       dbpr = dest->bm_rowsize;
+
+       sbpr = src->bm_rowsize;
+
+       for (y1=0; y1 < h; y1++ )    {
+
+               offset2 =   (unsigned int)src->bm_data  + (sbpr * (y1+sy)) + sx;
+               dbits   =   dest->bm_data + (dbpr * (y1+dy)) + dx;
+
+               page = offset2 >> 16;
+               offset = offset2 & 0xFFFF;
+               offset1 = offset+w-1;
+               gr_vesa_setpage( page );
+
+               if ( offset1 > 0xFFFF )  {
+                       // Overlaps two pages
+                       while( offset <= 0xFFFF )
+                               *dbits++ = gr_video_memory[offset++];
+                       offset1 -= (0xFFFF+1);
+                       offset = 0;
+                       page++;
+                       gr_vesa_setpage(page);
+               }
+               while( offset <= offset1 )
+                       *dbits++ = gr_video_memory[offset++];
+
+       }
+}
+#endif // __MSDOS__
+//@extern int Interlacing_on;
+
+// From Linear to Linear
+void gr_bm_ubitblt00(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest)
+{
+       unsigned char * dbits;
+       unsigned char * sbits;
+       //int   src_bm_rowsize_2, dest_bm_rowsize_2;
+       int dstep;
+
+       int i;
+
+       sbits =   src->bm_data  + (src->bm_rowsize * sy) + sx;
+       dbits =   dest->bm_data + (dest->bm_rowsize * dy) + dx;
+
+       dstep = dest->bm_rowsize << gr_bitblt_dest_step_shift;
+
+       // No interlacing, copy the whole buffer.
+       if (gr_bitblt_double)
+           for (i=0; i < h; i++ )    {
+               gr_linear_rep_movsd_2x( sbits, dbits, w );
+               sbits += src->bm_rowsize;
+               dbits += dstep;
+           }
+       else
+           for (i=0; i < h; i++ )    {
+               gr_linear_movsd( sbits, dbits, w );
+               //memcpy(dbits, sbits, w);
+               sbits += src->bm_rowsize;
+               dbits += dstep;
+           }
+}
+
+// From Linear to Linear Masked
+void gr_bm_ubitblt00m(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest)
+{
+       unsigned char * dbits;
+       unsigned char * sbits;
+       //int   src_bm_rowsize_2, dest_bm_rowsize_2;
+
+       int i;
+
+       sbits =   src->bm_data  + (src->bm_rowsize * sy) + sx;
+       dbits =   dest->bm_data + (dest->bm_rowsize * dy) + dx;
+
+       // No interlacing, copy the whole buffer.
+
+       if (gr_bitblt_fade_table==NULL) {
+               for (i=0; i < h; i++ )    {
+                       gr_linear_rep_movsdm( sbits, dbits, w );
+                       sbits += src->bm_rowsize;
+                       dbits += dest->bm_rowsize;
+               }
+       } else {
+               for (i=0; i < h; i++ )    {
+                       gr_linear_rep_movsdm_faded( sbits, dbits, w, gr_bitblt_fade_table[dy+i] );
+                       sbits += src->bm_rowsize;
+                       dbits += dest->bm_rowsize;
+               }
+       }
+}
+
+
+void gr_bm_bitblt(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest)
+{
+       int dx1=dx, dx2=dx+dest->bm_w-1;
+       int dy1=dy, dy2=dy+dest->bm_h-1;
+
+       int sx1=sx, sx2=sx+src->bm_w-1;
+       int sy1=sy, sy2=sy+src->bm_h-1;
+
+       if ((dx1 >= dest->bm_w ) || (dx2 < 0)) return;
+       if ((dy1 >= dest->bm_h ) || (dy2 < 0)) return;
+       if ( dx1 < 0 ) { sx1 += -dx1; dx1 = 0; }
+       if ( dy1 < 0 ) { sy1 += -dy1; dy1 = 0; }
+       if ( dx2 >= dest->bm_w )        { dx2 = dest->bm_w-1; }
+       if ( dy2 >= dest->bm_h )        { dy2 = dest->bm_h-1; }
+
+       if ((sx1 >= src->bm_w ) || (sx2 < 0)) return;
+       if ((sy1 >= src->bm_h ) || (sy2 < 0)) return;
+       if ( sx1 < 0 ) { dx1 += -sx1; sx1 = 0; }
+       if ( sy1 < 0 ) { dy1 += -sy1; sy1 = 0; }
+       if ( sx2 >= src->bm_w ) { sx2 = src->bm_w-1; }
+       if ( sy2 >= src->bm_h ) { sy2 = src->bm_h-1; }
+
+       // Draw bitmap bm[x,y] into (dx1,dy1)-(dx2,dy2)
+       if ( dx2-dx1+1 < w )
+               w = dx2-dx1+1;
+       if ( dy2-dy1+1 < h )
+               h = dy2-dy1+1;
+       if ( sx2-sx1+1 < w )
+               w = sx2-sx1+1;
+       if ( sy2-sy1+1 < h )
+               h = sy2-sy1+1;
+
+       gr_bm_ubitblt(w,h, dx1, dy1, sx1, sy1, src, dest );
+}
+
+void gr_bm_ubitblt(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest)
+{
+       register int x1, y1;
+
+       if ( (src->bm_type == BM_LINEAR) && (dest->bm_type == BM_LINEAR ))
+       {
+               if ( src->bm_flags & BM_FLAG_RLE )      
+                       gr_bm_ubitblt00_rle( w, h, dx, dy, sx, sy, src, dest );
+               else
+                       gr_bm_ubitblt00( w, h, dx, dy, sx, sy, src, dest );
+               return;
+       }
+
+#ifdef OGL
+       if ( (src->bm_type == BM_LINEAR) && (dest->bm_type == BM_OGL ))
+       {
+               ogl_ubitblt(w, h, dx, dy, sx, sy, src, dest);
+               return;
+       }
+       if ( (src->bm_type == BM_OGL) && (dest->bm_type == BM_LINEAR ))
+       {
+               ogl_ubitblt_tolinear(w, h, dx, dy, sx, sy, src, dest);
+               return;
+       }
+       if ( (src->bm_type == BM_OGL) && (dest->bm_type == BM_OGL ))
+       {
+               ogl_ubitblt_copy(w, h, dx, dy, sx, sy, src, dest);
+               return;
+       }
+#endif
+
+#ifdef D1XD3D
+       if ( (src->bm_type == BM_LINEAR) && (dest->bm_type == BM_DIRECTX ))
+       {
+               Assert ((int)dest->bm_data == BM_D3D_RENDER || (int)dest->bm_data == BM_D3D_DISPLAY);
+               Win32_BlitLinearToDirectX_bm (src, sx, sy, w, h, dx, dy, 0);
+               return;
+       }
+       if ( (src->bm_type == BM_DIRECTX) && (dest->bm_type == BM_LINEAR ))
+       {
+               return;
+       }
+       if ( (src->bm_type == BM_DIRECTX) && (dest->bm_type == BM_DIRECTX ))
+       {
+               return;
+       }
+#endif
+
+       if ( (src->bm_flags & BM_FLAG_RLE ) && (src->bm_type == BM_LINEAR) )    {
+               gr_bm_ubitblt0x_rle(w, h, dx, dy, sx, sy, src, dest, 0 );
+               return;
+       }
+#ifdef __MSDOS__
+       if ( (src->bm_type == BM_LINEAR) && (dest->bm_type == BM_SVGA ))
+       {
+               gr_bm_ubitblt02( w, h, dx, dy, sx, sy, src, dest );
+               return;
+       }
+
+       if ( (src->bm_type == BM_SVGA) && (dest->bm_type == BM_LINEAR ))
+       {
+               gr_bm_ubitblt20( w, h, dx, dy, sx, sy, src, dest );
+               return;
+       }
+
+       if ( (src->bm_type == BM_LINEAR) && (dest->bm_type == BM_MODEX ))
+       {
+               gr_bm_ubitblt01( w, h, dx+XOFFSET, dy+YOFFSET, sx, sy, src, dest );
+               return;
+       }
+#endif
+       for (y1=0; y1 < h; y1++ )    {
+               for (x1=0; x1 < w; x1++ )    {
+                       gr_bm_pixel( dest, dx+x1, dy+y1, gr_gpixel(src,sx+x1,sy+y1) );
+               }
+       }
+}
+
+// Clipped bitmap ... 
+
+void gr_bitmap( int x, int y, grs_bitmap *bm )
+{
+       int dx1=x, dx2=x+bm->bm_w-1;
+       int dy1=y, dy2=y+bm->bm_h-1;
+       int sx=0, sy=0;
+
+       if ((dx1 >= grd_curcanv->cv_bitmap.bm_w ) || (dx2 < 0)) return;
+       if ((dy1 >= grd_curcanv->cv_bitmap.bm_h) || (dy2 < 0)) return;
+       if ( dx1 < 0 ) { sx = -dx1; dx1 = 0; }
+       if ( dy1 < 0 ) { sy = -dy1; dy1 = 0; }
+       if ( dx2 >= grd_curcanv->cv_bitmap.bm_w )       { dx2 = grd_curcanv->cv_bitmap.bm_w-1; }
+       if ( dy2 >= grd_curcanv->cv_bitmap.bm_h )       { dy2 = grd_curcanv->cv_bitmap.bm_h-1; }
+               
+       // Draw bitmap bm[x,y] into (dx1,dy1)-(dx2,dy2)
+
+       gr_bm_ubitblt(dx2-dx1+1,dy2-dy1+1, dx1, dy1, sx, sy, bm, &grd_curcanv->cv_bitmap );
+
+}
+
+void gr_bitmapm( int x, int y, grs_bitmap *bm )
+{
+       int dx1=x, dx2=x+bm->bm_w-1;
+       int dy1=y, dy2=y+bm->bm_h-1;
+       int sx=0, sy=0;
+
+       if ((dx1 >= grd_curcanv->cv_bitmap.bm_w ) || (dx2 < 0)) return;
+       if ((dy1 >= grd_curcanv->cv_bitmap.bm_h) || (dy2 < 0)) return;
+       if ( dx1 < 0 ) { sx = -dx1; dx1 = 0; }
+       if ( dy1 < 0 ) { sy = -dy1; dy1 = 0; }
+       if ( dx2 >= grd_curcanv->cv_bitmap.bm_w )       { dx2 = grd_curcanv->cv_bitmap.bm_w-1; }
+       if ( dy2 >= grd_curcanv->cv_bitmap.bm_h )       { dy2 = grd_curcanv->cv_bitmap.bm_h-1; }
+               
+       // Draw bitmap bm[x,y] into (dx1,dy1)-(dx2,dy2)
+
+       if ( (bm->bm_type == BM_LINEAR) && (grd_curcanv->cv_bitmap.bm_type == BM_LINEAR ))
+       {
+               if ( bm->bm_flags & BM_FLAG_RLE )       
+                       gr_bm_ubitblt00m_rle(dx2-dx1+1,dy2-dy1+1, dx1, dy1, sx, sy, bm, &grd_curcanv->cv_bitmap );
+               else
+                       gr_bm_ubitblt00m(dx2-dx1+1,dy2-dy1+1, dx1, dy1, sx, sy, bm, &grd_curcanv->cv_bitmap );
+               return;
+       }
+
+       gr_bm_ubitbltm(dx2-dx1+1,dy2-dy1+1, dx1, dy1, sx, sy, bm, &grd_curcanv->cv_bitmap );
+
+}
+
+void gr_bm_ubitbltm(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest)
+{
+       register int x1, y1;
+       ubyte c;
+
+#ifdef OGL
+       if ( (src->bm_type == BM_LINEAR) && (dest->bm_type == BM_OGL ))
+       {
+               ogl_ubitblt(w, h, dx, dy, sx, sy, src, dest);
+               return;
+       }
+       if ( (src->bm_type == BM_OGL) && (dest->bm_type == BM_LINEAR ))
+       {
+               ogl_ubitblt_tolinear(w, h, dx, dy, sx, sy, src, dest);
+               return;
+       }
+       if ( (src->bm_type == BM_OGL) && (dest->bm_type == BM_OGL ))
+       {
+               ogl_ubitblt_copy(w, h, dx, dy, sx, sy, src, dest);
+               return;
+       }
+#endif
+#ifdef D1XD3D
+       if ( (src->bm_type == BM_LINEAR) && (dest->bm_type == BM_DIRECTX ))
+       {
+               Assert ((int)dest->bm_data == BM_D3D_RENDER || (int)dest->bm_data == BM_D3D_DISPLAY);
+               Win32_BlitLinearToDirectX_bm (src, sx, sy, w, h, dx, dy, 1);
+               return;
+       }
+       if ( (src->bm_type == BM_DIRECTX) && (dest->bm_type == BM_DIRECTX ))
+       {
+               Assert ((int)src->bm_data == BM_D3D_RENDER || (int)src->bm_data == BM_D3D_DISPLAY);
+//             Win32_BlitDirectXToDirectX (w, h, dx, dy, sx, sy, src->bm_data, dest->bm_data, 0);
+               return;
+       }
+#endif
+
+
+       for (y1=0; y1 < h; y1++ )    {
+               for (x1=0; x1 < w; x1++ )    {
+                       if ((c=gr_gpixel(src,sx+x1,sy+y1))!=255)
+                               gr_bm_pixel( dest, dx+x1, dy+y1,c  );
+               }
+       }
+
+}
+
+//-NOT-used // From linear to SVGA
+//-NOT-used void gr_bm_ubitblt02_2x(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest)
+//-NOT-used {
+//-NOT-used    unsigned char * sbits;
+//-NOT-used 
+//-NOT-used    unsigned int offset, EndingOffset, VideoLocation;
+//-NOT-used 
+//-NOT-used    int sbpr, dbpr, y1, page, BytesToMove;
+//-NOT-used 
+//-NOT-used    sbpr = src->bm_rowsize;
+//-NOT-used 
+//-NOT-used    dbpr = dest->bm_rowsize << gr_bitblt_dest_step_shift;
+//-NOT-used 
+//-NOT-used    VideoLocation = (unsigned int)dest->bm_data + (dest->bm_rowsize * dy) + dx;
+//-NOT-used 
+//-NOT-used    sbits = src->bm_data + ( sbpr*sy ) + sx;
+//-NOT-used 
+//-NOT-used    for (y1=0; y1 < h; y1++ )    {
+//-NOT-used 
+//-NOT-used            page    = VideoLocation >> 16;
+//-NOT-used            offset  = VideoLocation & 0xFFFF;
+//-NOT-used 
+//-NOT-used            gr_vesa_setpage( page );
+//-NOT-used 
+//-NOT-used            EndingOffset = offset+w-1;
+//-NOT-used 
+//-NOT-used            if ( EndingOffset <= 0xFFFF )
+//-NOT-used            {
+//-NOT-used                    gr_linear_rep_movsd_2x( (void *)sbits, (void *)(offset+gr_video_memory), w );
+//-NOT-used 
+//-NOT-used                    VideoLocation += dbpr;
+//-NOT-used                    sbits += sbpr;
+//-NOT-used            }
+//-NOT-used            else
+//-NOT-used            {
+//-NOT-used                    BytesToMove = 0xFFFF-offset+1;
+//-NOT-used 
+//-NOT-used                    gr_linear_rep_movsd_2x( (void *)sbits, (void *)(offset+gr_video_memory), BytesToMove );
+//-NOT-used 
+//-NOT-used                    page++;
+//-NOT-used                    gr_vesa_setpage(page);
+//-NOT-used 
+//-NOT-used                    gr_linear_rep_movsd_2x( (void *)(sbits+BytesToMove/2), (void *)gr_video_memory, EndingOffset - 0xFFFF );
+//-NOT-used 
+//-NOT-used                    VideoLocation += dbpr;
+//-NOT-used                    sbits += sbpr;
+//-NOT-used            }
+//-NOT-used 
+//-NOT-used 
+//-NOT-used    }
+//-NOT-used }
+
+
+//-NOT-used // From Linear to Linear
+//-NOT-used void gr_bm_ubitblt00_2x(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest)
+//-NOT-used {
+//-NOT-used    unsigned char * dbits;
+//-NOT-used    unsigned char * sbits;
+//-NOT-used    //int   src_bm_rowsize_2, dest_bm_rowsize_2;
+//-NOT-used 
+//-NOT-used    int i;
+//-NOT-used 
+//-NOT-used    sbits =   src->bm_data  + (src->bm_rowsize * sy) + sx;
+//-NOT-used    dbits =   dest->bm_data + (dest->bm_rowsize * dy) + dx;
+//-NOT-used 
+//-NOT-used    // No interlacing, copy the whole buffer.
+//-NOT-used    for (i=0; i < h; i++ )    {
+//-NOT-used            gr_linear_rep_movsd_2x( sbits, dbits, w );
+//-NOT-used 
+//-NOT-used            sbits += src->bm_rowsize;
+//-NOT-used            dbits += dest->bm_rowsize << gr_bitblt_dest_step_shift;
+//-NOT-used    }
+//-NOT-used }
+
+void gr_bm_ubitblt00_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest)
+{
+       unsigned char * dbits;
+       unsigned char * sbits;
+
+       int i;
+
+       sbits = &src->bm_data[4 + src->bm_h];
+       for (i=0; i<sy; i++ )
+               sbits += (int)src->bm_data[4+i];
+
+       dbits = dest->bm_data + (dest->bm_rowsize * dy) + dx;
+
+       // No interlacing, copy the whole buffer.
+       for (i=0; i < h; i++ )    {
+               gr_rle_expand_scanline( dbits, sbits, sx, sx+w-1 );
+               sbits += (int)src->bm_data[4+i+sy];
+               dbits += dest->bm_rowsize << gr_bitblt_dest_step_shift;
+       }
+}
+
+void gr_bm_ubitblt00m_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest)
+{
+       unsigned char * dbits;
+       unsigned char * sbits;
+
+       int i;
+
+       sbits = &src->bm_data[4 + src->bm_h];
+       for (i=0; i<sy; i++ )
+               sbits += (int)src->bm_data[4+i];
+
+       dbits = dest->bm_data + (dest->bm_rowsize * dy) + dx;
+
+       // No interlacing, copy the whole buffer.
+       for (i=0; i < h; i++ )    {
+               gr_rle_expand_scanline_masked( dbits, sbits, sx, sx+w-1 );
+               sbits += (int)src->bm_data[4+i+sy];
+               dbits += dest->bm_rowsize << gr_bitblt_dest_step_shift;
+       }
+}
+
+// in rle.c
+
+extern void gr_rle_expand_scanline_generic( grs_bitmap * dest, int dx, int dy, ubyte *src, 
+       int x1, int x2, int masked );
+
+
+void gr_bm_ubitblt0x_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, 
+       grs_bitmap * dest, int masked )
+{
+       int i;
+       register int y1;
+       unsigned char * sbits;
+
+       sbits = &src->bm_data[4 + src->bm_h];
+       for (i=0; i<sy; i++ )
+               sbits += (int)src->bm_data[4+i];
+
+       for (y1=0; y1 < h; y1++ )    {
+               gr_rle_expand_scanline_generic( dest, dx, dy+y1,  sbits, sx, sx+w-1, 
+                       masked );
+               sbits += (int)src->bm_data[4+y1+sy];
+       }
+}
+
+// rescalling bitmaps, 10/14/99 Jan Bobrowski jb@wizard.ae.krakow.pl
+
+inline void scale_line(byte *in, byte *out, int ilen, int olen)
+{
+       int a = olen/ilen, b = olen%ilen;
+       int c = 0, i;
+       byte *end = out + olen;
+       while(out<end) {
+               i = a;
+               c += b;
+               if(c >= ilen) {
+                       c -= ilen;
+                       goto inside;
+               }
+               while(--i>=0) {
+inside:
+                       *out++ = *in;
+               }
+               in++;
+       }
+}
+
+void gr_bitmap_scale_to(grs_bitmap *src, grs_bitmap *dst)
+{
+       byte *s = src->bm_data;
+       byte *d = dst->bm_data;
+       int h = src->bm_h;
+       int a = dst->bm_h/h, b = dst->bm_h%h;
+       int c = 0, i, y;
+
+       for(y=0; y<h; y++) {
+               i = a;
+               c += b;
+               if(c >= h) {
+                       c -= h;
+                       goto inside;
+               }
+               while(--i>=0) {
+inside:
+                       scale_line(s, d, src->bm_w, dst->bm_w);
+                       d += dst->bm_rowsize;
+               }
+               s += src->bm_rowsize;
+       }
+}
+
+void show_fullscr(grs_bitmap *bm)
+{
+       grs_bitmap * const scr = &grd_curcanv->cv_bitmap;
+
+       if(scr->bm_type != BM_LINEAR) {
+               grs_bitmap *tmp = gr_create_bitmap(scr->bm_w, scr->bm_h);
+               gr_bitmap_scale_to(bm, tmp);
+               gr_bitmap(0, 0, tmp);
+               gr_free_bitmap(tmp);
+               return;
+       }
+       gr_bitmap_scale_to(bm, scr);
+}
diff --git a/2d/bitmap.c b/2d/bitmap.c
new file mode 100644 (file)
index 0000000..740e485
--- /dev/null
@@ -0,0 +1,327 @@
+/*
+THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
+SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
+END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
+ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
+IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
+SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
+FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
+CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
+AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
+COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
+*/
+
+#include <conf.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "u_mem.h"
+
+
+#include "gr.h"
+#include "grdef.h"
+#include "u_dpmi.h"
+#include "bitmap.h"
+#include "error.h"
+
+#ifdef OGL
+#include "ogl_init.h"
+#endif
+
+void build_colormap_good( ubyte * palette, ubyte * colormap, int * freq );
+
+void gr_set_bitmap_data (grs_bitmap *bm, unsigned char *data)
+{
+#ifdef OGL
+//     if (bm->bm_data!=data)
+               ogl_freebmtexture(bm);
+#endif
+       bm->bm_data = data;
+#ifdef D1XD3D
+       Assert (bm->iMagic == BM_MAGIC_NUMBER);
+       Win32_SetTextureBits (bm, data, bm->bm_flags & BM_FLAG_RLE);
+#endif
+}
+
+void gr_init_bitmap( grs_bitmap *bm, int mode, int x, int y, int w, int h, int bytesperline, unsigned char * data ) // TODO: virtualize
+{
+#ifdef D1XD3D
+       Assert (bm->iMagic != BM_MAGIC_NUMBER || bm->pvSurface == NULL);
+#endif
+
+       bm->bm_x = x;
+       bm->bm_y = y;
+       bm->bm_w = w;
+       bm->bm_h = h;
+       bm->bm_flags = 0;
+       bm->bm_type = mode;
+       bm->bm_rowsize = bytesperline;
+
+       bm->bm_data = NULL;
+#ifdef D1XD3D
+       bm->iMagic = BM_MAGIC_NUMBER;
+       bm->pvSurface = NULL;
+#endif
+
+#ifdef D1XD3D
+       Win32_CreateTexture (bm);
+#endif
+#ifdef OGL
+       bm->bm_parent=NULL;bm->gltexture=NULL;
+#endif
+
+//     if (data != 0)
+               gr_set_bitmap_data (bm, data);
+/*
+       else
+               gr_set_bitmap_data (bm, d_malloc (w * h));
+*/
+
+#ifdef BITMAP_SELECTOR
+       bm->bm_selector = 0;
+#endif
+}
+
+void gr_init_bitmap_alloc( grs_bitmap *bm, int mode, int x, int y, int w, int h, int bytesperline)
+{
+       gr_init_bitmap(bm, mode, x, y, w, h, bytesperline, 0);
+       gr_set_bitmap_data(bm, d_malloc(w * h));
+}
+
+void gr_init_bitmap_data (grs_bitmap *bm) // TODO: virtulize
+{
+       bm->bm_data = NULL;
+#ifdef D1XD3D
+       Assert (bm->iMagic != BM_MAGIC_NUMBER);
+       bm->iMagic = BM_MAGIC_NUMBER;
+       bm->pvSurface = NULL;
+#endif
+#ifdef OGL
+//     ogl_freebmtexture(bm);//not what we want here.
+       bm->bm_parent=NULL;bm->gltexture=NULL;
+#endif
+}
+
+void gr_free_bitmap(grs_bitmap *bm )
+{
+       gr_free_bitmap_data (bm);
+       if (bm!=NULL)
+               d_free(bm);
+}
+
+void gr_free_bitmap_data (grs_bitmap *bm) // TODO: virtulize
+{
+#ifdef D1XD3D
+       Assert (bm->iMagic == BM_MAGIC_NUMBER);
+
+       Win32_FreeTexture (bm);
+       bm->iMagic = 0;
+       if (bm->bm_data == BM_D3D_RENDER)
+               bm->bm_data = NULL;
+#endif
+#ifdef OGL
+       ogl_freebmtexture(bm);
+#endif
+       if (bm->bm_data != NULL)
+               d_free (bm->bm_data);
+       bm->bm_data = NULL;
+}
+
+void gr_init_sub_bitmap (grs_bitmap *bm, grs_bitmap *bmParent, int x, int y, int w, int h )    // TODO: virtualize
+{
+       bm->bm_x = x + bmParent->bm_x;
+       bm->bm_y = y + bmParent->bm_y;
+       bm->bm_w = w;
+       bm->bm_h = h;
+       bm->bm_flags = bmParent->bm_flags;
+       bm->bm_type = bmParent->bm_type;
+       bm->bm_rowsize = bmParent->bm_rowsize;
+
+#ifdef OGL
+       bm->gltexture=bmParent->gltexture;
+       bm->bm_parent=bmParent;
+#endif
+#ifdef D1XD3D
+       Assert (bmParent->iMagic == BM_MAGIC_NUMBER);
+       bm->iMagic = BM_MAGIC_NUMBER;
+       bm->pvSurface = bmParent->pvSurface;
+       if (bm->bm_type == BM_DIRECTX)
+       {
+               bm->bm_data = bmParent->bm_data;
+       }
+       else
+#endif
+       {
+               bm->bm_data = bmParent->bm_data+(unsigned int)((y*bmParent->bm_rowsize)+x);
+       }
+
+}
+
+void gr_free_sub_bitmap(grs_bitmap *bm )
+{
+       if (bm!=NULL)
+       {
+#ifdef D1XD3D
+               bm->iMagic = 0;
+#endif
+               d_free(bm);
+       }
+}
+
+
+grs_bitmap *gr_create_bitmap(int w, int h )
+{
+       return gr_create_bitmap_raw (w, h, d_malloc(w * h));
+}
+
+grs_bitmap *gr_create_bitmap_raw(int w, int h, unsigned char * raw_data )
+{
+    grs_bitmap *new;
+
+    new = (grs_bitmap *)d_malloc( sizeof(grs_bitmap) );
+       gr_init_bitmap (new, 0, 0, 0, w, h, w, raw_data);
+
+    return new;
+}
+
+
+grs_bitmap *gr_create_sub_bitmap(grs_bitmap *bm, int x, int y, int w, int h )
+{
+    grs_bitmap *new;
+
+    new = (grs_bitmap *)d_malloc( sizeof(grs_bitmap) );
+       gr_init_sub_bitmap (new, bm, x, y, w, h);
+
+       return new;
+}
+
+void gr_set_bitmap_flags (grs_bitmap *pbm, int flags)
+{
+#ifdef D1XD3D
+       Assert (pbm->iMagic == BM_MAGIC_NUMBER);
+
+       if (pbm->pvSurface)
+       {
+               if ((flags & BM_FLAG_TRANSPARENT) != (pbm->bm_flags & BM_FLAG_TRANSPARENT))
+               {
+                       Win32_SetTransparent (pbm->pvSurface, flags & BM_FLAG_TRANSPARENT);
+               }
+       }
+#endif
+       pbm->bm_flags = flags;
+}
+
+void gr_set_transparent (grs_bitmap *pbm, int bTransparent)
+{
+       if (bTransparent)
+       {
+               gr_set_bitmap_flags (pbm, pbm->bm_flags | BM_FLAG_TRANSPARENT);
+       }
+       else
+       {
+               gr_set_bitmap_flags (pbm, pbm->bm_flags & ~BM_FLAG_TRANSPARENT);
+       }
+}
+
+void gr_set_super_transparent (grs_bitmap *pbm, int bTransparent)
+{
+       if (bTransparent)
+       {
+               gr_set_bitmap_flags (pbm, pbm->bm_flags & ~BM_FLAG_SUPER_TRANSPARENT);
+       }
+       else
+       {
+               gr_set_bitmap_flags (pbm, pbm->bm_flags | BM_FLAG_SUPER_TRANSPARENT);
+       }
+}
+
+void gr_remap_bitmap( grs_bitmap * bmp, ubyte * palette, int transparent_color, int super_transparent_color )
+{
+       ubyte colormap[256];
+       int freq[256];
+
+       // This should be build_colormap_asm, but we're not using invert table, so...
+       build_colormap_good( palette, colormap, freq );
+
+       if ( (super_transparent_color>=0) && (super_transparent_color<=255))
+               colormap[super_transparent_color] = 254;
+
+       if ( (transparent_color>=0) && (transparent_color<=255))
+               colormap[transparent_color] = 255;
+
+       decode_data_asm(bmp->bm_data, bmp->bm_w * bmp->bm_h, colormap, freq );
+
+       if ( (transparent_color>=0) && (transparent_color<=255) && (freq[transparent_color]>0) )
+               gr_set_transparent (bmp, 1);
+
+       if ( (super_transparent_color>=0) && (super_transparent_color<=255) && (freq[super_transparent_color]>0) )
+               gr_set_super_transparent (bmp, 0);
+}
+
+void build_colormap_good( ubyte * palette, ubyte * colormap, int * freq )
+{
+       int i, r, g, b;
+
+       for (i=0; i<256; i++ )  {
+               r = *palette++;         
+               g = *palette++;         
+               b = *palette++;         
+               *colormap++ = gr_find_closest_color( r, g, b );
+               *freq++ = 0;
+       }
+}
+
+
+void gr_remap_bitmap_good( grs_bitmap * bmp, ubyte * palette, int transparent_color, int super_transparent_color )
+{
+       ubyte colormap[256];
+       int freq[256];
+   
+       build_colormap_good( palette, colormap, freq );
+
+       if ( (super_transparent_color>=0) && (super_transparent_color<=255))
+               colormap[super_transparent_color] = 254;
+
+       if ( (transparent_color>=0) && (transparent_color<=255))
+               colormap[transparent_color] = 255;
+
+       decode_data_asm(bmp->bm_data, bmp->bm_w * bmp->bm_h, colormap, freq );
+
+       if ( (transparent_color>=0) && (transparent_color<=255) && (freq[transparent_color]>0) )
+               gr_set_transparent (bmp, 1);
+
+       if ( (super_transparent_color>=0) && (super_transparent_color<=255) && (freq[super_transparent_color]>0) )
+               gr_set_super_transparent (bmp, 1);
+}
+
+#ifdef BITMAP_SELECTOR
+int gr_bitmap_assign_selector( grs_bitmap * bmp )
+{
+       if (!dpmi_allocate_selector( bmp->bm_data, bmp->bm_w*bmp->bm_h, &bmp->bm_selector )) {
+               bmp->bm_selector = 0;
+               return 1;
+       }
+       return 0;
+}
+#endif
+
+void gr_bitmap_check_transparency( grs_bitmap * bmp )
+{
+       int x, y;
+       ubyte * data;
+
+       data = bmp->bm_data;
+       
+       for (y=0; y<bmp->bm_h; y++ )    {
+               for (x=0; x<bmp->bm_w; x++ )    {
+                       if (*data++ == 255 )    {
+                               gr_set_transparent (bmp, 1);
+                               return;
+                       }
+               }
+               data += bmp->bm_rowsize - bmp->bm_w;
+       }
+
+       bmp->bm_flags = 0;
+
+}
diff --git a/2d/bitmap.h b/2d/bitmap.h
new file mode 100644 (file)
index 0000000..1c4d1f0
--- /dev/null
@@ -0,0 +1,70 @@
+#ifndef _BITMAP_H
+#define _BITMAP_H
+
+#ifndef NO_ASM
+#ifdef __WATCOMC__
+void decode_data_asm(ubyte *data, int num_pixels, ubyte * colormap, int * count );
+#pragma aux decode_data_asm parm [esi] [ecx] [edi] [ebx] modify exact [esi edi eax ebx ecx] = \
+"again_ddn:"                            \
+    "xor    eax,eax"                \
+    "mov    al,[esi]"           \
+    "inc    dword ptr [ebx+eax*4]"      \
+    "mov    al,[edi+eax]"       \
+    "mov    [esi],al"           \
+    "inc    esi"                    \
+    "dec    ecx"                    \
+    "jne    again_ddn"
+#elif defined __GNUC__
+static inline void decode_data_asm(ubyte *data, int num_pixels, ubyte * colormap, int * count ) {
+       int dummy[4];
+   __asm__ __volatile__ (
+    "xorl   %%eax,%%eax;"
+"0:;"
+    "movb   (%%esi), %%al;"
+    "incl   (%%ebx, %%eax, 4);"
+    "movb   (%%edi, %%eax), %%al;"
+    "movb   %%al, (%%esi);"
+    "incl   %%esi;"
+    "decl   %%ecx;"
+    "jne    0b"
+    : "=S" (dummy[0]), "=c" (dummy[1]), "=D" (dummy[2]), "=b" (dummy[3])
+       : "0" (data), "1" (num_pixels), "2" (colormap), "3" (count)
+       : "%eax");
+}
+#elif defined _MSC_VER
+__inline void decode_data_asm(ubyte *data, int num_pixels, ubyte * colormap, int * count )
+{
+  __asm {
+       mov esi,[data]
+       mov ecx,[num_pixels]
+       mov edi,[colormap]
+       mov ebx,[count]
+again_ddn:
+       xor eax,eax
+       mov al,[esi]
+       inc dword ptr [ebx+eax*4]
+       mov al,[edi+eax]
+       mov [esi],al
+       inc esi
+       dec ecx
+       jne again_ddn
+  }
+}
+#else
+#define NO_ASM 1 // We really do want no assembler...
+#endif
+#endif
+
+#ifdef NO_ASM
+static void decode_data_asm(ubyte *data, int num_pixels, ubyte *colormap, int *count)
+{
+       int i;
+       
+       for (i = 0; i < num_pixels; i++) {
+               count[*data]++;
+               *data = colormap[*data];
+               data++;
+       }
+}
+#endif
+#endif
diff --git a/2d/box.c b/2d/box.c
new file mode 100644 (file)
index 0000000..54b4aae
--- /dev/null
+++ b/2d/box.c
@@ -0,0 +1,125 @@
+/*
+THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
+SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
+END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
+ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
+IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
+SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
+FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
+CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
+AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
+COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
+*/
+
+#include <conf.h>
+#include "u_mem.h"
+
+
+#include "gr.h"
+#include "grdef.h"
+
+void gr_ubox0(int left,int top,int right,int bot)
+{
+       int i, d;
+
+       unsigned char * ptr1;
+       unsigned char * ptr2;
+
+       ptr1 = DATA + ROWSIZE *top+left;
+
+       ptr2 = ptr1;
+       d = right - left;
+
+       for (i=top; i<=bot; i++ )
+       {
+               ptr2[0] = (unsigned char) COLOR;
+               ptr2[d] = (unsigned char) COLOR;
+               ptr2 += ROWSIZE;
+       }
+
+       ptr2 = ptr1;
+       d = (bot - top)*ROWSIZE;
+
+       for (i=1; i<(right-left); i++ )
+       {
+               ptr2[i+0] = (unsigned char) COLOR;
+               ptr2[i+d] = (unsigned char) COLOR;
+       }
+}
+
+void gr_box0(int left,int top,int right,int bot)
+{
+       if (top > MAXY ) return;
+    if (bot < MINY ) return;
+    if (left > MAXX ) return;
+    if (right < MINX ) return;
+    
+       if (top < MINY) top = MINY;
+    if (bot > MAXY ) bot = MAXY;
+       if (left < MINX) left = MINX;
+    if (right > MAXX ) right = MAXX;
+
+       gr_ubox0(left,top,right,bot);
+
+}
+
+
+void gr_ubox12(int left,int top,int right,int bot)
+{
+       int i;
+
+       for (i=top; i<=bot; i++ )
+       {
+               gr_upixel( left, i );
+               gr_upixel( right, i );
+       }
+
+       gr_uscanline( left, right, top );
+
+       gr_uscanline( left, right, bot );
+}
+
+void gr_box12(int left,int top,int right,int bot)
+{
+    if (top > MAXY ) return;
+    if (bot < MINY ) return;
+    if (left > MAXX ) return;
+    if (right < MINX ) return;
+    
+       if (top < MINY) top = MINY;
+    if (bot > MAXY ) bot = MAXY;
+       if (left < MINX) left = MINX;
+    if (right > MAXX ) right = MAXX;
+        
+       gr_ubox12(left, top, right, bot );
+    
+}
+
+void gr_ubox(int left,int top,int right,int bot)
+{
+       if (TYPE==BM_LINEAR)
+               gr_ubox0( left, top, right, bot );
+
+#ifdef __MSDOS__
+       else if ( TYPE == BM_MODEX )
+               gr_ubox12( left, top, right, bot );
+#endif
+
+    else
+               gr_ubox12( left, top, right, bot );
+}
+
+void gr_box(int left,int top,int right,int bot)
+{
+       if (TYPE==BM_LINEAR)
+               gr_box0( left, top, right, bot );
+
+#ifdef __MSDOS__
+       else if ( TYPE == BM_MODEX )
+               gr_box12( left, top, right, bot );
+#endif
+    
+       else
+               gr_ubox12( left, top, right, bot );
+}
+
diff --git a/2d/canvas.c b/2d/canvas.c
new file mode 100644 (file)
index 0000000..befb02c
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
+SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
+END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
+ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
+IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
+SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
+FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
+CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
+AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
+COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
+*/
+
+#include <conf.h>
+#include <stdlib.h>
+//#include <d_malloc.h>
+#include <stdio.h>
+
+#include "u_mem.h"
+
+
+#include "gr.h"
+#include "grdef.h"
+#ifdef __MSDOS__
+#include "modex.h"
+#include "vesa.h"
+#endif
+
+grs_canvas * grd_curcanv;    //active canvas
+grs_screen * grd_curscreen;  //active screen
+
+grs_canvas *gr_create_canvas(int w, int h)
+{
+       grs_canvas *new;
+       
+       new = (grs_canvas *)d_malloc( sizeof(grs_canvas) );
+       gr_init_bitmap_alloc (&new->cv_bitmap, BM_LINEAR, 0, 0, w, h, w);
+
+       new->cv_color = 0;
+       new->cv_drawmode = 0;
+       new->cv_font = NULL;
+       new->cv_font_fg_color = 0;
+       new->cv_font_bg_color = 0;
+       return new;
+}
+
+grs_canvas *gr_create_sub_canvas(grs_canvas *canv, int x, int y, int w, int h)
+{
+    grs_canvas *new;
+
+       new = (grs_canvas *)d_malloc( sizeof(grs_canvas) );
+       gr_init_sub_bitmap (&new->cv_bitmap, &canv->cv_bitmap, x, y, w, h);
+
+       new->cv_color = canv->cv_color;
+       new->cv_drawmode = canv->cv_drawmode;
+       new->cv_font = canv->cv_font;
+       new->cv_font_fg_color = canv->cv_font_fg_color;
+       new->cv_font_bg_color = canv->cv_font_bg_color;
+       return new;
+}
+
+void gr_init_canvas(grs_canvas *canv, unsigned char * pixdata, int pixtype, int w, int h)
+{
+       int wreal;
+    canv->cv_color = 0;
+    canv->cv_drawmode = 0;
+    canv->cv_font = NULL;
+       canv->cv_font_fg_color = 0;
+       canv->cv_font_bg_color = 0;
+
+
+#ifndef __MSDOS__
+       wreal = w;
+#else
+       wreal = (pixtype == BM_MODEX) ? w / 4 : w;
+#endif
+       gr_init_bitmap (&canv->cv_bitmap, pixtype, 0, 0, w, h, wreal, pixdata);
+}
+
+void gr_init_sub_canvas(grs_canvas *new, grs_canvas *src, int x, int y, int w, int h)
+{
+       new->cv_color = src->cv_color;
+       new->cv_drawmode = src->cv_drawmode;
+       new->cv_font = src->cv_font;
+       new->cv_font_fg_color = src->cv_font_fg_color;
+       new->cv_font_bg_color = src->cv_font_bg_color;
+
+       gr_init_sub_bitmap (&new->cv_bitmap, &src->cv_bitmap, x, y, w, h);
+}
+
+void gr_free_canvas(grs_canvas *canv)
+{
+       gr_free_bitmap_data(&canv->cv_bitmap);
+    d_free(canv);
+}
+
+void gr_free_sub_canvas(grs_canvas *canv)
+{
+    d_free(canv);
+}
+
+int gr_wait_for_retrace = 1;
+
+void gr_show_canvas( grs_canvas *canv )
+{
+#ifdef __MSDOS__
+       if (canv->cv_bitmap.bm_type == BM_MODEX )
+               gr_modex_setstart( canv->cv_bitmap.bm_x, canv->cv_bitmap.bm_y, gr_wait_for_retrace );
+
+       else if (canv->cv_bitmap.bm_type == BM_SVGA )
+               gr_vesa_setstart( canv->cv_bitmap.bm_x, canv->cv_bitmap.bm_y );
+#endif
+               //      else if (canv->cv_bitmap.bm_type == BM_LINEAR )
+               // Int3();              // Get JOHN!
+               //gr_linear_movsd( canv->cv_bitmap.bm_data, (void *)gr_video_memory, 320*200);
+}
+
+void gr_set_current_canvas( grs_canvas *canv )
+{
+       if (canv==NULL)
+               grd_curcanv = &(grd_curscreen->sc_canvas);
+       else
+               grd_curcanv = canv;
+#ifndef NO_ASM
+       if ( (grd_curcanv->cv_color >= 0) && (grd_curcanv->cv_color <= 255) )   {
+               gr_var_color = grd_curcanv->cv_color;
+       } else
+               gr_var_color  = 0;
+       gr_var_bitmap = grd_curcanv->cv_bitmap.bm_data;
+       gr_var_bwidth = grd_curcanv->cv_bitmap.bm_rowsize;
+#endif
+}
+
+void gr_clear_canvas(int color)
+{
+       gr_setcolor(color);
+       gr_rect(0,0,GWIDTH-1,GHEIGHT-1);
+}
+
+void gr_setcolor(int color)
+{
+       grd_curcanv->cv_color=color;
+#ifndef NO_ASM
+       gr_var_color = color;
+#endif
+}
+
diff --git a/2d/circle.c b/2d/circle.c
new file mode 100644 (file)
index 0000000..4d25a70
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
+SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
+END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
+ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
+IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
+SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
+FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
+CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
+AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
+COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
+*/
+
+#ifdef RCS
+static char rcsid[] = "$Id: circle.c,v 1.1.1.1 2001-01-19 03:29:57 bradleyb Exp $";
+#endif
+
+#include <conf.h>
+#include "u_mem.h"
+
+#include "gr.h"
+#include "grdef.h"
+
+#ifndef OGL
+
+int gr_circle(fix xc1,fix yc1,fix r1)
+{
+       int p,x, y, xc, yc, r;
+
+       r = f2i(r1);
+       xc = f2i(xc1);
+       yc = f2i(yc1);
+       p=3-(r*2);
+       x=0;
+       y=r;
+
+       // Big clip
+       if ( (xc+r) < 0 ) return 1;
+       if ( (xc-r) > GWIDTH ) return 1;
+       if ( (yc+r) < 0 ) return 1;
+       if ( (yc-r) > GHEIGHT ) return 1;
+
+       while(x<y)
+       {
+               // Draw the first octant
+               gr_pixel( xc-y, yc-x );
+               gr_pixel( xc+y, yc-x );
+               gr_pixel( xc-y, yc+x );
+               gr_pixel( xc+y, yc+x );
+
+               if (p<0) 
+                       p=p+(x<<2)+6;
+               else    {
+                       // Draw the second octant
+                       gr_pixel( xc-x, yc-y );
+                       gr_pixel( xc+x, yc-y );
+                       gr_pixel( xc-x, yc+y );
+                       gr_pixel( xc+x, yc+y );
+                       p=p+((x-y)<<2)+10;
+                       y--;
+               }
+               x++;
+       }
+       if(x==y)        {
+               gr_pixel( xc-x, yc-y );
+               gr_pixel( xc+x, yc-y );
+               gr_pixel( xc-x, yc+y );
+               gr_pixel( xc+x, yc+y );
+       }
+       return 0;
+}
+
+int gr_ucircle(fix xc1,fix yc1,fix r1)
+{
+       int p,x, y, xc, yc, r;
+
+       r = f2i(r1);
+       xc = f2i(xc1);
+       yc = f2i(yc1);
+       p=3-(r*2);
+       x=0;
+       y=r;
+
+       while(x<y)
+       {
+               // Draw the first octant
+               gr_upixel( xc-y, yc-x );
+               gr_upixel( xc+y, yc-x );
+               gr_upixel( xc-y, yc+x );
+               gr_upixel( xc+y, yc+x );
+
+               if (p<0) 
+                       p=p+(x<<2)+6;
+               else    {
+                       // Draw the second octant
+                       gr_upixel( xc-x, yc-y );
+                       gr_upixel( xc+x, yc-y );
+                       gr_upixel( xc-x, yc+y );
+                       gr_upixel( xc+x, yc+y );
+                       p=p+((x-y)<<2)+10;
+                       y--;
+               }
+               x++;
+       }
+       if(x==y)        {
+               gr_upixel( xc-x, yc-y );
+               gr_upixel( xc+x, yc-y );
+               gr_upixel( xc-x, yc+y );
+               gr_upixel( xc+x, yc+y );
+       }
+       return 0;
+}
+
+#endif //!OGL
diff --git a/2d/clip.h b/2d/clip.h
new file mode 100644 (file)
index 0000000..b4bd2f1
--- /dev/null
+++ b/2d/clip.h
@@ -0,0 +1,158 @@
+/*
+THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
+SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
+END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
+ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
+IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
+SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
+FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
+CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
+AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
+COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
+*/
+/*
+ * $Source: /cvs/cvsroot/d2x/2d/clip.h,v $
+ * $Revision: 1.1.1.1 $
+ * $Author: bradleyb $
+ * $Date: 2001-01-19 03:29:57 $
+ *
+ * Macros used for clipping
+ *
+ * $Log: not supported by cvs2svn $
+ * Revision 1.1.1.1  1999/06/14 21:57:39  donut
+ * Import of d1x 1.37 source.
+ *
+ * Revision 1.3  1993/10/15  16:22:28  john
+ * *** empty log message ***
+ * 
+ * Revision 1.2  1993/09/29  16:14:31  john
+ * made work with fix point
+ * 
+ * Revision 1.1  1993/09/08  11:40:53  john
+ * Initial revision
+ * 
+ *
+ */
+
+
+/*#define MIN(a,b)       (((a) < (b)) ? (a) : (b))
+#define MAX(a,b)        (((a) > (b)) ? (a) : (b))
+*/
+#define IABS(x)         (((x) < 0) ?  -(x) : (x))
+
+#define EXCHG(a,b) do {                                                 \
+    int __temp__ = (a);                                                 \
+    (a) = (b);                                                          \
+    (b) = __temp__;                                                     \
+} while(0)
+
+// sort two values
+#define SORT2(a,b) do {                                                 \
+    if((a) > (b)) EXCHG(a,b);                                           \
+} while(0)
+
+# define SCALE(var,arg,num,den)                                         \
+    ((var) = ((arg) * (num)) / (den))
+
+# define USCALE(var,arg,num,den)                                        \
+       ((var) = ((unsigned)(arg) * (unsigned)(num)) / (unsigned)(den))
+
+# define FSCALE(var,arg,num,den) ((var) = fixmuldiv((arg),(num),(den)))
+
+#define CLIPDOT(xx,yy,WHEN_OUTSIDE,WHEN_CLIPPED) {                      \
+    if((xx > XMAX) || (xx < XMIN)) { WHEN_OUTSIDE; }                    \
+    if((yy > YMAX) || (yy < YMIN)) { WHEN_OUTSIDE; }                    \
+}
+
+#define CLIPHLINE(x1,x2,yy,WHEN_OUTSIDE,WHEN_CLIPPED) {                 \
+    if(x1 > x2) EXCHG(x1,x2);                                           \
+    if((x1 > XMAX) || (x2 < XMIN)) { WHEN_OUTSIDE; }                    \
+    if((yy > YMAX) || (yy < YMIN)) { WHEN_OUTSIDE; }                    \
+    if(x1 < XMIN) { x1 = XMIN; WHEN_CLIPPED; }                          \
+    if(x2 > XMAX) { x2 = XMAX; WHEN_CLIPPED; }                          \
+}
+
+#define CLIPVLINE(xx,y1,y2,WHEN_OUTSIDE,WHEN_CLIPPED) {                 \
+    if(y1 > y2) EXCHG(y1,y2);                                           \
+    if((xx > XMAX) || (xx < XMIN)) { WHEN_OUTSIDE; }                    \
+    if((y1 > YMAX) || (y2 < YMIN)) { WHEN_OUTSIDE; }                    \
+    if(y1 < YMIN) { y1 = YMIN; WHEN_CLIPPED; }                          \
+    if(y2 > YMAX) { y2 = YMAX; WHEN_CLIPPED; }                          \
+}
+
+#define CLIPBOX(x1,y1,x2,y2,WHEN_OUTSIDE,WHEN_CLIPPED) {                \
+    if(x1 > x2) EXCHG(x1,x2);                                           \
+    if(y1 > y2) EXCHG(y1,y2);                                           \
+    if((x1 > XMAX) || (x2 < 0)) { WHEN_OUTSIDE; }                       \
+    if((y1 > YMAX) || (y2 < 0)) { WHEN_OUTSIDE; }                       \
+    if(x1 < 0) { x1 = 0; WHEN_CLIPPED; }                                \
+    if(y1 < 0) { y1 = 0; WHEN_CLIPPED; }                                \
+    if(x2 > XMAX) { x2 = XMAX; WHEN_CLIPPED; }                          \
+    if(y2 > YMAX) { y2 = YMAX; WHEN_CLIPPED; }                          \
+}
+    
+#define CLIPLINE(x1,y1,x2,y2,XMIN,YMIN,XMAX,YMAX,WHEN_OUTSIDE,WHEN_CLIPPED,MY_SCALE) do {       \
+    register int temp;                                                  \
+    if(y1 > y2)                                                         \
+        { EXCHG(y1,y2); EXCHG(x1,x2); }                                 \
+    if((y2 < YMIN) || (y1 > YMAX))                                      \
+        { WHEN_OUTSIDE; }                                               \
+    if(x1 < x2) {                                                       \
+        if((x2 < XMIN) || (x1 > XMAX)) {                                \
+            WHEN_OUTSIDE;                                               \
+        }                                                               \
+        if(x1 < XMIN) {                                                 \
+                       MY_SCALE(temp,(y2 - y1),(XMIN - x1),(x2 - x1)); \
+            if((y1 += temp) > YMAX) { WHEN_OUTSIDE; }                   \
+            x1 = XMIN;                                                  \
+            WHEN_CLIPPED;                                               \
+        }                                                               \
+        if(x2 > XMAX) {                                                 \
+                       MY_SCALE(temp,(y2 - y1),(x2 - XMAX),(x2 - x1)); \
+            if((y2 -= temp) < YMIN) { WHEN_OUTSIDE; }                   \
+            x2 = XMAX;                                                  \
+            WHEN_CLIPPED;                                               \
+        }                                                               \
+        if(y1 < YMIN) {                                                 \
+                       MY_SCALE(temp,(x2 - x1),(YMIN - y1),(y2 - y1)); \
+            x1 += temp;                                                 \
+            y1 = YMIN;                                                  \
+            WHEN_CLIPPED;                                               \
+        }                                                               \
+        if(y2 > YMAX) {                                                 \
+                       MY_SCALE(temp,(x2 - x1),(y2 - YMAX),(y2 - y1)); \
+            x2 -= temp;                                                 \
+            y2 = YMAX;                                                  \
+            WHEN_CLIPPED;                                               \
+        }                                                               \
+    }                                                                   \
+    else {                                                              \
+        if((x1 < XMIN) || (x2 > XMAX)) {                                \
+            WHEN_OUTSIDE;                                               \
+        }                                                               \
+        if(x1 > XMAX) {                                                 \
+                       MY_SCALE(temp,(y2 - y1),(x1 - XMAX),(x1 - x2)); \
+            if((y1 += temp) > YMAX) { WHEN_OUTSIDE; }                   \
+            x1 = XMAX;                                                  \
+            WHEN_CLIPPED;                                               \
+        }                                                               \
+        if(x2 < XMIN) {                                                 \
+                       MY_SCALE(temp,(y2 - y1),(XMIN - x2),(x1 - x2)); \
+            if((y2 -= temp) < YMIN) { WHEN_OUTSIDE; }                   \
+            x2 = XMIN;                                                  \
+            WHEN_CLIPPED;                                               \
+        }                                                               \
+        if(y1 < YMIN) {                                                 \
+                       MY_SCALE(temp,(x1 - x2),(YMIN - y1),(y2 - y1)); \
+            x1 -= temp;                                                 \
+            y1 = YMIN;                                                  \
+            WHEN_CLIPPED;                                               \
+        }                                                               \
+        if(y2 > YMAX) {                                                 \
+                       MY_SCALE(temp,(x1 - x2),(y2 - YMAX),(y2 - y1)); \
+            x2 += temp;                                                 \
+            y2 = YMAX;                                                  \
+            WHEN_CLIPPED;                                               \
+        }                                                               \
+    }                                                                   \
+} while(0)
diff --git a/2d/diff b/2d/diff
new file mode 100644 (file)
index 0000000..2dff4f7
--- /dev/null
+++ b/2d/diff
@@ -0,0 +1,354 @@
+13a14
+> #include <conf.h>\r
+23c24
+< #include "mem.h"\r
+---
+> #include "u_mem.h"\r
+31a33
+> #include "bitmap.h"\r
+133a136
+> \r
+135a139,156
+> //hack to allow color codes to be embedded in strings -MPM\r
+> //note we subtract one from color, since 255 is "transparent" so it'll never be used, and 0 would otherwise end the string.\r
+> //function must already have orig_color var set (or they could be passed as args...)\r
+> //perhaps some sort of recursive orig_color type thing would be better, but that would be way too much trouble for little gain\r
+> int gr_message_color_level=1;\r
+> #define CHECK_EMBEDDED_COLORS() if ((*text_ptr >= 0x01) && (*text_ptr <= 0x03)) { \\r
+>              text_ptr++; \\r
+>              if (*text_ptr){ \\r
+>                      if (gr_message_color_level >= *(text_ptr-1)) \\r
+>                              FG_COLOR = *text_ptr - 1; \\r
+>                      text_ptr++; \\r
+>              } \\r
+>      } \\r
+>      else if ((*text_ptr >= 0x04) && (*text_ptr <= 0x06)){ \\r
+>              if (gr_message_color_level >= *text_ptr - 3) \\r
+>                      FG_COLOR=orig_color; \\r
+>              text_ptr++; \\r
+>      }\r
+359c380
+< \r
+---
+> #ifdef __ENV_MSDOS__ \r
+749a771
+> #endif\r
+975a998
+> #ifndef OGL\r
+1049a1073,1336
+> #else // OGL\r
+> \r
+> #include "../main/inferno.h"\r
+> #include "ogl_init.h"\r
+> #include "args.h"\r
+> //font handling routines for OpenGL - Added 9/25/99 Matthew Mueller - they are here instead of in arch/ogl because they use all these defines\r
+> \r
+> int pow2ize(int x);//from ogl.c\r
+> \r
+> int get_font_total_width(grs_font * font){\r
+>      if (font->ft_flags & FT_PROPORTIONAL){\r
+>              int i,w=0,c=font->ft_minchar;\r
+>              for (i=0;c<=font->ft_maxchar;i++,c++){\r
+>                      if (font->ft_widths[i]<0)\r
+>                              Error("heh?\n");\r
+>                      w+=font->ft_widths[i];\r
+>              }\r
+>              return w;\r
+>      }else{\r
+>              return font->ft_w*(font->ft_maxchar-font->ft_minchar+1);\r
+>      }\r
+> }\r
+> void ogl_font_choose_size(grs_font * font,int gap,int *rw,int *rh){\r
+>      int     nchars = font->ft_maxchar-font->ft_minchar+1;\r
+>      int r,x,y,nc=0,smallest=999999,smallr=-1,tries;\r
+>      int smallprop=10000;\r
+>      int h,w;\r
+>      for (h=32;h<=256;h*=2){\r
+> //           h=pow2ize(font->ft_h*rows+gap*(rows-1));\r
+>              if (font->ft_h>h)continue;\r
+>              r=(h/(font->ft_h+gap));\r
+>              w=pow2ize((get_font_total_width(font)+(nchars-r)*gap)/r);\r
+>              tries=0;\r
+>              do {\r
+>                      if (tries)\r
+>                              w=pow2ize(w+1);\r
+>                      if(tries>3){\r
+>                              mprintf((0,"failed to fit (%ix%i, %ic)\n",w,h,nc));\r
+>                              break;\r
+>                      }\r
+>                      nc=0;\r
+>                      y=0;\r
+>                      while(y+font->ft_h<=h){\r
+>                              x=0;\r
+>                              while (x<w){\r
+>                                      if (nc==nchars)\r
+>                                              break;\r
+>                                      if (font->ft_flags & FT_PROPORTIONAL){\r
+>                                              if (x+font->ft_widths[nc]+gap>w)break;\r
+>                                              x+=font->ft_widths[nc++]+gap;\r
+>                                      }else{\r
+>                                              if (x+font->ft_w+gap>w)break;\r
+>                                              x+=font->ft_w+gap;\r
+>                                              nc++;\r
+>                                      }\r
+>                              }\r
+>                              if (nc==nchars)\r
+>                                      break;\r
+>                              y+=font->ft_h+gap;\r
+>                      }\r
+>                      \r
+>                      tries++;\r
+>              }while(nc!=nchars);\r
+>              if (nc!=nchars)\r
+>                      continue;\r
+>              mprintf((0,"fit: %ix%i  %i tries\n",w,h,tries));\r
+> \r
+>              if (w*h==smallest){//this gives squarer sizes priority (ie, 128x128 would be better than 512*32)\r
+>                      if (w>=h){\r
+>                              if (w/h<smallprop){\r
+>                                      smallprop=w/h;\r
+>                                      smallest++;//hack\r
+>                              }\r
+>                      }else{\r
+>                              if (h/w<smallprop){\r
+>                                      smallprop=h/w;\r
+>                                      smallest++;//hack\r
+>                              }\r
+>                      }\r
+>              }\r
+>              if (w*h<smallest){\r
+>                      smallr=1;\r
+>                      smallest=w*h;\r
+>                      *rw=w;\r
+>                      *rh=h;\r
+>              }\r
+>      }\r
+>      if (smallr<=0)\r
+>              Error("couldn't fit font?\n");\r
+>      mprintf((0,"using %ix%i\n",*rw,*rh));\r
+>      printf("using %ix%i\n",*rw,*rh);\r
+>      \r
+> }\r
+> \r
+> void ogl_init_font(grs_font * font){\r
+>      int     nchars = font->ft_maxchar-font->ft_minchar+1;\r
+>      int i,w,h,tw,th,x,y,curx=0,cury=0;\r
+>      char *fp;\r
+>      //      char data[32*32*4];\r
+>      char *data;\r
+>      int gap=0;//having a gap just wastes ram, since we don't filter text textures at all.\r
+>      //      char s[2];\r
+>      ogl_font_choose_size(font,gap,&tw,&th);\r
+>      data=malloc(tw*th);\r
+>      gr_init_bitmap(&font->ft_parent_bitmap,BM_LINEAR,0,0,tw,th,tw,data);\r
+> \r
+>      font->ft_parent_bitmap.gltexture=ogl_get_free_texture();\r
+> \r
+>      font->ft_bitmaps=(grs_bitmap*)malloc( nchars * sizeof(grs_bitmap));\r
+>      mprintf((0,"ogl_init_font %s, %s, nchars=%i, (%ix%i tex)\n",(font->ft_flags & FT_PROPORTIONAL)?"proportional":"fixedwidth",(font->ft_flags & FT_COLOR)?"color":"mono",nchars,tw,th));\r
+>      //      s[1]=0;\r
+>      h=font->ft_h;\r
+>      //      sleep(5);\r
+> \r
+>      for(i=0;i<nchars;i++){\r
+>              //              s[0]=font->ft_minchar+i;\r
+>              //              gr_get_string_size(s,&w,&h,&aw);\r
+>              if (font->ft_flags & FT_PROPORTIONAL)\r
+>                      w=font->ft_widths[i];\r
+>              else\r
+>                      w=font->ft_w;\r
+> //           mprintf((0,"char %i(%ix%i): ",i,w,h));\r
+>              if (w<1 || w>256){\r
+>                      mprintf((0,"grr\n"));continue;\r
+>              }\r
+>              if (curx+w+gap>tw){\r
+>                      cury+=h+gap;\r
+>                      curx=0;\r
+>              }\r
+>              if (cury+h>th)\r
+>                      Error("font doesn't really fit (%i/%i)?\n",i,nchars);\r
+>              if (font->ft_flags & FT_COLOR) {\r
+>                      if (font->ft_flags & FT_PROPORTIONAL)\r
+>                              fp = font->ft_chars[i];\r
+>                      else\r
+>                              fp = font->ft_data + i * w*h;\r
+>                      for (y=0;y<h;y++)\r
+>                              for (x=0;x<w;x++){\r
+>                                      font->ft_parent_bitmap.bm_data[curx+x+(cury+y)*tw]=fp[x+y*w];\r
+>                              }\r
+> \r
+>                      //                      gr_init_bitmap(&font->ft_bitmaps[i],BM_LINEAR,0,0,w,h,w,font->);\r
+>              }else{\r
+>                      int BitMask,bits=0,white=gr_find_closest_color(63,63,63);\r
+>                      //                      if (w*h>sizeof(data))\r
+>                      //                              Error("ogl_init_font: toobig\n");\r
+>                      if (font->ft_flags & FT_PROPORTIONAL)\r
+>                              fp = font->ft_chars[i];\r
+>                      else\r
+>                              fp = font->ft_data + i * BITS_TO_BYTES(w)*h;\r
+>                      for (y=0;y<h;y++){\r
+>                              BitMask=0;\r
+>                              for (x=0; x< w; x++ )\r
+>                              {\r
+>                                      if (BitMask==0) {\r
+>                                              bits = *fp++;\r
+>                                              BitMask = 0x80;\r
+>                                      }\r
+> \r
+>                                      if (bits & BitMask)\r
+>                                              font->ft_parent_bitmap.bm_data[curx+x+(cury+y)*tw]=white;\r
+>                                      else\r
+>                                              font->ft_parent_bitmap.bm_data[curx+x+(cury+y)*tw]=255;\r
+>                                      BitMask >>= 1;\r
+>                              }\r
+>                      }\r
+>              }\r
+>              gr_init_sub_bitmap(&font->ft_bitmaps[i],&font->ft_parent_bitmap,curx,cury,w,h);\r
+> \r
+>              curx+=w+gap;\r
+>      }\r
+>      if (!(font->ft_flags & FT_COLOR)) {\r
+>              //use GL_INTENSITY instead of GL_RGB\r
+>              if (ogl_intensity4_ok){\r
+>                      font->ft_parent_bitmap.gltexture->internalformat=GL_INTENSITY4;\r
+>                      font->ft_parent_bitmap.gltexture->format=GL_LUMINANCE;\r
+>              }else if (ogl_luminance4_alpha4_ok){\r
+>                      font->ft_parent_bitmap.gltexture->internalformat=GL_LUMINANCE4_ALPHA4;\r
+>                      font->ft_parent_bitmap.gltexture->format=GL_LUMINANCE_ALPHA;\r
+>              }else if (ogl_rgba2_ok){\r
+>                      font->ft_parent_bitmap.gltexture->internalformat=GL_RGBA2;\r
+>                      font->ft_parent_bitmap.gltexture->format=GL_RGBA;\r
+>              }else{\r
+>                      font->ft_parent_bitmap.gltexture->internalformat=ogl_rgba_format;\r
+>                      font->ft_parent_bitmap.gltexture->format=GL_RGBA;\r
+>              }\r
+>      }\r
+>      ogl_loadbmtexture_m(&font->ft_parent_bitmap,0);\r
+> }\r
+> \r
+> int ogl_internal_string(int x, int y, char *s )\r
+> {\r
+>      ubyte * text_ptr, * next_row, * text_ptr1;\r
+>      int width, spacing,letter;\r
+>      int xx,yy;\r
+>      int orig_color=FG_COLOR;//to allow easy reseting to default string color with colored strings -MPM\r
+> \r
+>      next_row = s;\r
+> \r
+>      yy = y;\r
+> \r
+>      if (grd_curscreen->sc_canvas.cv_bitmap.bm_type != BM_OGL)\r
+>              Error("carp.\n");\r
+>      while (next_row != NULL)\r
+>      {\r
+>              text_ptr1 = next_row;\r
+>              next_row = NULL;\r
+> \r
+>              text_ptr = text_ptr1;\r
+> \r
+>              xx = x;\r
+> \r
+>              if (xx==0x8000)                 //centered\r
+>                      xx = get_centered_x(text_ptr);\r
+> \r
+>              while (*text_ptr)\r
+>              {\r
+>                      if (*text_ptr == '\n' )\r
+>                      {\r
+>                              next_row = &text_ptr[1];\r
+>                              yy += FHEIGHT;\r
+>                              break;\r
+>                      }\r
+> \r
+>                      letter = *text_ptr-FMINCHAR;\r
+> \r
+>                      get_char_width(text_ptr[0],text_ptr[1],&width,&spacing);\r
+> \r
+>                      if (!INFONT(letter) || *text_ptr<=0x06) {       //not in font, draw as space\r
+>                              CHECK_EMBEDDED_COLORS() else{\r
+>                                      xx += spacing;\r
+>                                      text_ptr++;\r
+>                              }\r
+>                              continue;\r
+>                      }\r
+>                      \r
+> //                   ogl_ubitblt(FONT->ft_bitmaps[letter].bm_w,FONT->ft_bitmaps[letter].bm_h,xx,yy,0,0,&FONT->ft_bitmaps[letter],NULL);\r
+> //                   if (*text_ptr>='0' && *text_ptr<='9'){\r
+>                      printf("%p\n",&FONT->ft_bitmaps[letter]);\r
+>                      if (FFLAGS&FT_COLOR)\r
+>                              gr_ubitmapm(xx,yy,&FONT->ft_bitmaps[letter]);\r
+>                      else{\r
+>                              if (grd_curcanv->cv_bitmap.bm_type==BM_OGL)\r
+>                                      ogl_ubitmapm_c(xx,yy,&FONT->ft_bitmaps[letter],FG_COLOR);\r
+>                              else\r
+>                                      Error("ogl_internal_string: non-color string to non-ogl dest\n");\r
+> //                                   gr_ubitmapm(xx,yy,&FONT->ft_bitmaps[letter]);//ignores color..\r
+>                      }\r
+>                      //}\r
+> \r
+>                      xx += spacing;\r
+> \r
+>                      text_ptr++;\r
+>              }\r
+> \r
+>      }\r
+>      return 0;\r
+> }\r
+> int gr_internal_color_string(int x, int y, char *s ){\r
+>      return ogl_internal_string(x,y,s);\r
+> }\r
+> \r
+> #endif // OGL\r
+> \r
+1118a1406
+> #ifdef __ENV_MSDOS__\r
+1123a1412
+> #endif\r
+1248a1538,1539
+> #define swapshort(a) (a)\r
+> #define swapint(a) (a)\r
+1251a1543
+>      old_grs_font *oldfont;\r
+1284c1576,1578
+<      font = (grs_font *) malloc(datasize);\r
+---
+>      oldfont = (old_grs_font *) malloc(datasize);\r
+>      font = (grs_font *) malloc(sizeof(grs_font));\r
+>      font->oldfont = oldfont;\r
+1288c1582,1590
+<      cfread(font,1,datasize,fontfile);\r
+---
+>      cfread(oldfont,1,datasize,fontfile);\r
+>         font->ft_flags=swapshort(oldfont->ft_flags);\r
+>         font->ft_w=swapshort(oldfont->ft_w);\r
+>         font->ft_h=swapshort(oldfont->ft_h);\r
+>         font->ft_baseline=swapshort(oldfont->ft_baseline);\r
+>         font->ft_maxchar=oldfont->ft_maxchar;\r
+>         font->ft_minchar=oldfont->ft_minchar;\r
+>         font->ft_bytewidth=swapshort(oldfont->ft_bytewidth);\r
+> \r
+1307c1609
+<              font->ft_widths = (short *) (((int) font->ft_widths) + ((ubyte *) font));\r
+---
+>              font->ft_widths = (short *) (((int) oldfont->ft_widths) + ((ubyte *) oldfont));\r
+1311c1613
+<                      font->ft_widths[i] = SWAPSHORT(font->ft_widths[i]);\r
+---
+>                      font->ft_widths[i] = swapshort(oldfont->ft_widths[i]);\r
+1314c1616
+<              font->ft_data = ((int) font->ft_data) + ((ubyte *) font);\r
+---
+>              font->ft_data = ((int) oldfont->ft_data) + ((ubyte *) oldfont);\r
+1330c1632
+<              font->ft_data = ((unsigned char *) font) + sizeof(*font);\r
+---
+>              font->ft_data = ((unsigned char *) oldfont) + sizeof(*oldfont);\r
+1339c1641
+<              font->ft_kerndata = ((int) font->ft_kerndata) + ((ubyte *) font);\r
+---
+>              font->ft_kerndata = swapint(((int) oldfont->ft_kerndata) + ((ubyte *) oldfont));\r
+1386a1689,1692
+> \r
+> #ifdef OGL\r
+>      ogl_init_font(font);\r
+> #endif\r
diff --git a/2d/disc.c b/2d/disc.c
new file mode 100644 (file)
index 0000000..9a280c0
--- /dev/null
+++ b/2d/disc.c
@@ -0,0 +1,95 @@
+/*
+THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
+SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
+END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
+ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
+IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
+SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
+FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
+CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
+AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
+COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
+*/
+
+#include <conf.h>
+#include "u_mem.h"
+
+#include "gr.h"
+#include "grdef.h"
+
+int gr_disk(fix xc1,fix yc1,fix r1)
+{
+       int p,x, y, xc, yc, r;
+
+       r = f2i(r1);
+       xc = f2i(xc1);
+       yc = f2i(yc1);
+       p=3-(r*2);
+       x=0;
+       y=r;
+
+       // Big clip
+       if ( (xc+r) < 0 ) return 1;
+       if ( (xc-r) > GWIDTH ) return 1;
+       if ( (yc+r) < 0 ) return 1;
+       if ( (yc-r) > GHEIGHT ) return 1;
+
+       while(x<y)
+       {
+               // Draw the first octant
+               gr_scanline( xc-y, xc+y, yc-x );
+               gr_scanline( xc-y, xc+y, yc+x );
+
+               if (p<0) 
+                       p=p+(x<<2)+6;
+               else    {
+                       // Draw the second octant
+                       gr_scanline( xc-x, xc+x, yc-y );
+                       gr_scanline( xc-x, xc+x, yc+y );
+                       p=p+((x-y)<<2)+10;
+                       y--;
+               }
+               x++;
+       }
+       if(x==y)        {
+               gr_scanline( xc-x, xc+x, yc-y );
+               gr_scanline( xc-x, xc+x, yc+y );
+       }
+       return 0;
+}
+
+int gr_udisk(fix xc1,fix yc1,fix r1)
+{
+       int p,x, y, xc, yc, r;
+
+       r = f2i(r1);
+       xc = f2i(xc1);
+       yc = f2i(yc1);
+       p=3-(r*2);
+       x=0;
+       y=r;
+
+       while(x<y)
+       {
+               // Draw the first octant
+               gr_uscanline( xc-y, xc+y, yc-x );
+               gr_uscanline( xc-y, xc+y, yc+x );
+
+               if (p<0) 
+                       p=p+(x<<2)+6;
+               else    {
+                       // Draw the second octant
+                       gr_uscanline( xc-x, xc+x, yc-y );
+                       gr_uscanline( xc-x, xc+x, yc+y );
+                       p=p+((x-y)<<2)+10;
+                       y--;
+               }
+               x++;
+       }
+       if(x==y)        {
+               gr_uscanline( xc-x, xc+x, yc-y );
+               gr_uscanline( xc-x, xc+x, yc+y );
+       }
+       return 0;
+}
+
diff --git a/2d/font.c b/2d/font.c
new file mode 100644 (file)
index 0000000..d0bf3cf
--- /dev/null
+++ b/2d/font.c
@@ -0,0 +1,1707 @@
+/*
+THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
+SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
+END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
+ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
+IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
+SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
+FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
+CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
+AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
+COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
+*/
+
+#include <conf.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "pa_enabl.h"                   //$$POLY_ACC
+#include "u_mem.h"
+
+#include "gr.h"
+#include "grdef.h"
+#include "error.h"
+
+#include "cfile.h"
+#include "mono.h"
+#include "byteswap.h"
+#include "bitmap.h"
+
+#if defined(POLY_ACC)
+#include "poly_acc.h"
+#endif
+
+#define MAX_OPEN_FONTS 50
+#define FILENAME_LEN           13
+
+typedef struct openfont {
+       char filename[FILENAME_LEN];
+       grs_font *ptr;
+} openfont;
+
+//list of open fonts, for use (for now) for palette remapping
+openfont open_font[MAX_OPEN_FONTS];
+
+#define FONT        grd_curcanv->cv_font
+#define FG_COLOR    grd_curcanv->cv_font_fg_color
+#define BG_COLOR    grd_curcanv->cv_font_bg_color
+#define FWIDTH       FONT->ft_w
+#define FHEIGHT      FONT->ft_h
+#define FBASELINE    FONT->ft_baseline
+#define FFLAGS       FONT->ft_flags
+#define FMINCHAR     FONT->ft_minchar
+#define FMAXCHAR     FONT->ft_maxchar
+#define FDATA        FONT->ft_data
+#define FCHARS       FONT->ft_chars
+#define FWIDTHS      FONT->ft_widths
+
+#define BITS_TO_BYTES(x)    (((x)+7)>>3)
+
+int gr_internal_string_clipped(int x, int y, char *s );
+int gr_internal_string_clipped_m(int x, int y, char *s );
+
+ubyte *find_kern_entry(grs_font *font,ubyte first,ubyte second)
+{
+       ubyte *p=font->ft_kerndata;
+
+       while (*p!=255)
+               if (p[0]==first && p[1]==second)
+                       return p;
+               else p+=3;
+
+       return NULL;
+
+}
+
+//takes the character AFTER being offset into font
+#define INFONT(_c) ((_c >= 0) && (_c <= FMAXCHAR-FMINCHAR))
+
+//takes the character BEFORE being offset into current font
+void get_char_width(ubyte c,ubyte c2,int *width,int *spacing)
+{
+       int letter;
+
+       letter = c-FMINCHAR;
+
+       if (!INFONT(letter)) {                          //not in font, draw as space
+               *width=0;
+               if (FFLAGS & FT_PROPORTIONAL)
+                       *spacing = FWIDTH/2;
+               else
+                       *spacing = FWIDTH;
+               return;
+       }
+
+       if (FFLAGS & FT_PROPORTIONAL)
+               *width = FWIDTHS[letter];
+       else
+               *width = FWIDTH;
+
+       *spacing = *width;
+
+       if (FFLAGS & FT_KERNED)  {
+               ubyte *p;
+
+               if (!(c2==0 || c2=='\n')) {
+                       int letter2;
+
+                       letter2 = c2-FMINCHAR;
+
+                       if (INFONT(letter2)) {
+
+                               p = find_kern_entry(FONT,letter,letter2);
+
+                               if (p)
+                                       *spacing = p[2];
+                       }
+               }
+       }
+}
+
+int get_centered_x(char *s)
+{
+       int w,w2,s2;
+
+       for (w=0;*s!=0 && *s!='\n';s++) {
+               get_char_width(s[0],s[1],&w2,&s2);
+               w += s2;
+       }
+
+       return ((grd_curcanv->cv_bitmap.bm_w - w) / 2);
+}
+
+
+int gr_internal_string0(int x, int y, char *s )
+{
+       unsigned char * fp;
+       ubyte * text_ptr, * next_row, * text_ptr1;
+       int r, BitMask, i, bits, width, spacing, letter, underline;
+       int     skip_lines = 0;
+
+       unsigned int VideoOffset, VideoOffset1;
+
+       VideoOffset1 = y * ROWSIZE + x;
+
+       next_row = s;
+
+       while (next_row != NULL )
+       {
+               text_ptr1 = next_row;
+               next_row = NULL;
+
+               if (x==0x8000) {                        //centered
+                       int xx = get_centered_x(text_ptr1);
+                       VideoOffset1 = y * ROWSIZE + xx;
+               }
+
+               for (r=0; r<FHEIGHT; r++)
+               {
+
+                       text_ptr = text_ptr1;
+
+                       VideoOffset = VideoOffset1;
+
+                       while (*text_ptr)
+                       {
+                               if (*text_ptr == '\n' )
+                               {
+                                       next_row = &text_ptr[1];
+                                       break;
+                               }
+
+                               if (*text_ptr == CC_COLOR) {
+                                       FG_COLOR = *(text_ptr+1);
+                                       text_ptr += 2;
+                                       continue;
+                               }
+
+                               if (*text_ptr == CC_LSPACING) {
+                                       skip_lines = *(text_ptr+1) - '0';
+                                       text_ptr += 2;
+                                       continue;
+                               }
+
+                               underline = 0;
+                               if (*text_ptr == CC_UNDERLINE )
+                               {
+                                       if ((r==FBASELINE+2) || (r==FBASELINE+3))
+                                               underline = 1;
+                                       text_ptr++;
+                               }
+
+                               get_char_width(text_ptr[0],text_ptr[1],&width,&spacing);
+
+                               letter = *text_ptr-FMINCHAR;
+
+                               if (!INFONT(letter)) {  //not in font, draw as space
+                                       VideoOffset += spacing;
+                                       text_ptr++;
+                                       continue;
+                               }
+
+                               if (FFLAGS & FT_PROPORTIONAL)
+                                       fp = FCHARS[letter];
+                               else
+                                       fp = FDATA + letter * BITS_TO_BYTES(width)*FHEIGHT;
+
+                               if (underline)
+                                       for (i=0; i< width; i++ )
+                                               DATA[VideoOffset++] = FG_COLOR;
+                               else
+                               {
+                                       fp += BITS_TO_BYTES(width)*r;
+
+                                       BitMask = 0;
+
+                                       for (i=0; i< width; i++ )
+                                       {
+                                               if (BitMask==0) {
+                                                       bits = *fp++;
+                                                       BitMask = 0x80;
+                                               }
+
+                                               if (bits & BitMask)
+                                                       DATA[VideoOffset++] = FG_COLOR;
+                                               else
+                                                       DATA[VideoOffset++] = BG_COLOR;
+                                               BitMask >>= 1;
+                                       }
+                               }
+
+                               VideoOffset += spacing-width;           //for kerning
+
+                               text_ptr++;
+                       }
+
+                       VideoOffset1 += ROWSIZE; y++;
+               }
+
+               y += skip_lines;
+               VideoOffset1 += ROWSIZE * skip_lines;
+               skip_lines = 0;
+       }
+       return 0;
+}
+
+int gr_internal_string0m(int x, int y, char *s )
+{
+       unsigned char * fp;
+       ubyte * text_ptr, * next_row, * text_ptr1;
+       int r, BitMask, i, bits, width, spacing, letter, underline;
+       int     skip_lines = 0;
+
+       unsigned int VideoOffset, VideoOffset1;
+
+       VideoOffset1 = y * ROWSIZE + x;
+
+       next_row = s;
+
+       while (next_row != NULL )
+       {
+               text_ptr1 = next_row;
+               next_row = NULL;
+
+               if (x==0x8000) {                        //centered
+                       int xx = get_centered_x(text_ptr1);
+                       VideoOffset1 = y * ROWSIZE + xx;
+               }
+
+               for (r=0; r<FHEIGHT; r++)
+               {
+
+                       text_ptr = text_ptr1;
+
+                       VideoOffset = VideoOffset1;
+
+                       while (*text_ptr)
+                       {
+                               if (*text_ptr == '\n' )
+                               {
+                                       next_row = &text_ptr[1];
+                                       break;
+                               }
+
+                               if (*text_ptr == CC_COLOR) {
+                                       FG_COLOR = *(text_ptr+1);
+                                       text_ptr += 2;
+                                       continue;
+                               }
+
+                               if (*text_ptr == CC_LSPACING) {
+                                       skip_lines = *(text_ptr+1) - '0';
+                                       text_ptr += 2;
+                                       continue;
+                               }
+
+                               underline = 0;
+                               if (*text_ptr == CC_UNDERLINE )
+                               {
+                                       if ((r==FBASELINE+2) || (r==FBASELINE+3))
+                                               underline = 1;
+                                       text_ptr++;
+                               }
+
+                               get_char_width(text_ptr[0],text_ptr[1],&width,&spacing);
+
+                               letter = *text_ptr-FMINCHAR;
+
+                               if (!INFONT(letter)) {  //not in font, draw as space
+                                       VideoOffset += spacing;
+                                       text_ptr++;
+                                       continue;
+                               }
+
+                               if (FFLAGS & FT_PROPORTIONAL)
+                                       fp = FCHARS[letter];
+                               else
+                                       fp = FDATA + letter * BITS_TO_BYTES(width)*FHEIGHT;
+
+                               if (underline)
+                                       for (i=0; i< width; i++ )
+                                               DATA[VideoOffset++] = FG_COLOR;
+                               else
+                               {
+                                       fp += BITS_TO_BYTES(width)*r;
+
+                                       BitMask = 0;
+
+                                       for (i=0; i< width; i++ )
+                                       {
+                                               if (BitMask==0) {
+                                                       bits = *fp++;
+                                                       BitMask = 0x80;
+                                               }
+
+                                               if (bits & BitMask)
+                                                       DATA[VideoOffset++] = FG_COLOR;
+                                               else
+                                                       VideoOffset++;
+                                               BitMask >>= 1;
+                                       }
+                               }
+                               text_ptr++;
+
+                               VideoOffset += spacing-width;
+                       }
+
+                       VideoOffset1 += ROWSIZE; y++;
+               }
+               y += skip_lines;
+               VideoOffset1 += ROWSIZE * skip_lines;
+               skip_lines = 0;
+       }
+       return 0;
+}
+
+#ifdef __ENV_MSDOS__
+int gr_internal_string2(int x, int y, char *s )
+{
+       unsigned char * fp;
+       char * text_ptr, * next_row, * text_ptr1;
+       int r, BitMask, i, bits, width, spacing, letter, underline;
+       int page_switched, skip_lines = 0;
+
+       unsigned int VideoOffset, VideoOffset1;
+
+       VideoOffset1 = (unsigned int)DATA + y * ROWSIZE + x;
+
+       gr_vesa_setpage(VideoOffset1 >> 16);
+
+       VideoOffset1 &= 0xFFFF;
+
+       next_row = s;
+
+       while (next_row != NULL )
+       {
+               text_ptr1 = next_row;
+               next_row = NULL;
+
+               if (x==0x8000) {                        //centered
+                       int xx = get_centered_x(text_ptr1);
+                       VideoOffset1 = y * ROWSIZE + xx;
+                       gr_vesa_setpage(VideoOffset1 >> 16);
+                       VideoOffset1 &= 0xFFFF;
+               }
+
+               for (r=0; r<FHEIGHT; r++)
+               {
+                       text_ptr = text_ptr1;
+
+                       VideoOffset = VideoOffset1;
+
+                       page_switched = 0;
+
+                       while (*text_ptr)
+                       {
+                               if (*text_ptr == '\n' )
+                               {
+                                       next_row = &text_ptr[1];
+                                       break;
+                               }
+
+                               if (*text_ptr == CC_COLOR) {
+                                       FG_COLOR = *(text_ptr+1);
+                                       text_ptr += 2;
+                                       continue;
+                               }
+
+                               if (*text_ptr == CC_LSPACING) {
+                                       skip_lines = *(text_ptr+1) - '0';
+                                       text_ptr += 2;
+                                       continue;
+                               }
+
+                               underline = 0;
+                               if (*text_ptr == CC_UNDERLINE )
+                               {
+                                       if ((r==FBASELINE+2) || (r==FBASELINE+3))
+                                               underline = 1;
+                                       text_ptr++;
+                               }
+
+                               get_char_width(text_ptr[0],text_ptr[1],&width,&spacing);
+
+                               Assert(width==spacing);         //no kerning support here
+
+                               letter = *text_ptr-FMINCHAR;
+
+                               if (!INFONT(letter)) {  //not in font, draw as space
+                                       VideoOffset += spacing;
+                                       text_ptr++;
+                                       continue;
+                               }
+
+                               if (FFLAGS & FT_PROPORTIONAL)
+                                       fp = FCHARS[letter];
+                               else
+                                       fp = FDATA + letter * BITS_TO_BYTES(width)*FHEIGHT;
+
+                               if (underline)
+                               {
+                                       if ( VideoOffset+width > 0xFFFF )
+                                       {
+                                               for (i=0; i< width; i++ )
+                                               {
+                                                       gr_video_memory[VideoOffset++] = FG_COLOR;
+
+                                                       if (VideoOffset > 0xFFFF )
+                                                       {
+                                                               VideoOffset -= 0xFFFF + 1;
+                                                               page_switched = 1;
+                                                               gr_vesa_incpage();
+                                                       }
+                                               }
+                                       }
+                                       else
+                                       {
+                                               for (i=0; i< width; i++ )
+                                                       gr_video_memory[VideoOffset++] = FG_COLOR;
+                                       }
+                               }
+                               else
+                               {
+                                       // fp -- dword
+                                       // VideoOffset
+                                       // width
+
+                                       fp += BITS_TO_BYTES(width)*r;
+
+                                       BitMask = 0;
+
+                                       if ( VideoOffset+width > 0xFFFF )
+                                       {
+                                               for (i=0; i< width; i++ )
+                                               {
+                                                       if (BitMask==0) {
+                                                               bits = *fp++;
+                                                               BitMask = 0x80;
+                                                       }
+
+                                                       if (bits & BitMask)
+                                                               gr_video_memory[VideoOffset++] = FG_COLOR;
+                                                       else
+                                                               gr_video_memory[VideoOffset++] = BG_COLOR;
+
+                                                       BitMask >>= 1;
+
+                                                       if (VideoOffset > 0xFFFF )
+                                                       {
+                                                               VideoOffset -= 0xFFFF + 1;
+                                                               page_switched = 1;
+                                                               gr_vesa_incpage();
+                                                       }
+
+                                               }
+                                       } else {
+
+                                               if (width == 8 )
+                                               {
+                                                       bits = *fp++;
+
+                                                       if (bits & 0x80) gr_video_memory[VideoOffset+0] = FG_COLOR;
+                                                       else gr_video_memory[VideoOffset+0] = BG_COLOR;
+
+                                                       if (bits & 0x40) gr_video_memory[VideoOffset+1] = FG_COLOR;
+                                                       else gr_video_memory[VideoOffset+1] = BG_COLOR;
+
+                                                       if (bits & 0x20) gr_video_memory[VideoOffset+2] = FG_COLOR;
+                                                       else gr_video_memory[VideoOffset+2] = BG_COLOR;
+
+                                                       if (bits & 0x10) gr_video_memory[VideoOffset+3] = FG_COLOR;
+                                                       else gr_video_memory[VideoOffset+3] = BG_COLOR;
+
+                                                       if (bits & 0x08) gr_video_memory[VideoOffset+4] = FG_COLOR;
+                                                       else gr_video_memory[VideoOffset+4] = BG_COLOR;
+
+                                                       if (bits & 0x04) gr_video_memory[VideoOffset+5] = FG_COLOR;
+                                                       else gr_video_memory[VideoOffset+5] = BG_COLOR;
+
+                                                       if (bits & 0x02) gr_video_memory[VideoOffset+6] = FG_COLOR;
+                                                       else gr_video_memory[VideoOffset+6] = BG_COLOR;
+
+                                                       if (bits & 0x01) gr_video_memory[VideoOffset+7] = FG_COLOR;
+                                                       else gr_video_memory[VideoOffset+7] = BG_COLOR;
+
+                                                       VideoOffset += 8;
+                                               } else {
+                                                       for (i=0; i< width/2 ; i++ )
+                                                       {
+                                                               if (BitMask==0) {
+                                                                       bits = *fp++;
+                                                                       BitMask = 0x80;
+                                                               }
+
+                                                               if (bits & BitMask)
+                                                                       gr_video_memory[VideoOffset++] = FG_COLOR;
+                                                               else
+                                                                       gr_video_memory[VideoOffset++] = BG_COLOR;
+                                                               BitMask >>= 1;
+
+
+                                                               // Unroll twice
+
+                                                               if (BitMask==0) {
+                                                                       bits = *fp++;
+                                                                       BitMask = 0x80;
+                                                               }
+
+                                                               if (bits & BitMask)
+                                                                       gr_video_memory[VideoOffset++] = FG_COLOR;
+                                                               else
+                                                                       gr_video_memory[VideoOffset++] = BG_COLOR;
+                                                               BitMask >>= 1;
+                                                       }
+                                               }
+                                       }
+                               }
+                               text_ptr++;
+                       }
+
+                       y ++;
+                       VideoOffset1 += ROWSIZE;
+
+                       if (VideoOffset1 > 0xFFFF ) {
+                               VideoOffset1 -= 0xFFFF + 1;
+                               if (!page_switched)
+                                       gr_vesa_incpage();
+                       }
+               }
+
+               y += skip_lines;
+               VideoOffset1 += ROWSIZE * skip_lines;
+               skip_lines = 0;
+       }
+       return 0;
+}
+
+int gr_internal_string2m(int x, int y, char *s )
+{
+       unsigned char * fp;
+       char * text_ptr, * next_row, * text_ptr1;
+       int r, BitMask, i, bits, width, spacing, letter, underline;
+       int page_switched, skip_lines = 0;
+
+       unsigned int VideoOffset, VideoOffset1;
+
+       VideoOffset1 = (unsigned int)DATA + y * ROWSIZE + x;
+
+       gr_vesa_setpage(VideoOffset1 >> 16);
+
+       VideoOffset1 &= 0xFFFF;
+
+       next_row = s;
+
+       while (next_row != NULL )
+       {
+               text_ptr1 = next_row;
+               next_row = NULL;
+
+               if (x==0x8000) {                        //centered
+                       int xx = get_centered_x(text_ptr1);
+                       VideoOffset1 = y * ROWSIZE + xx;
+                       gr_vesa_setpage(VideoOffset1 >> 16);
+                       VideoOffset1 &= 0xFFFF;
+               }
+
+               for (r=0; r<FHEIGHT; r++)
+               {
+                       text_ptr = text_ptr1;
+
+                       VideoOffset = VideoOffset1;
+
+                       page_switched = 0;
+
+                       while (*text_ptr)
+                       {
+                               if (*text_ptr == '\n' )
+                               {
+                                       next_row = &text_ptr[1];
+                                       break;
+                               }
+
+                               if (*text_ptr == CC_COLOR) {
+                                       FG_COLOR = *(text_ptr+1);
+                                       text_ptr += 2;
+                                       continue;
+                               }
+
+                               if (*text_ptr == CC_LSPACING) {
+                                       skip_lines = *(text_ptr+1) - '0';
+                                       text_ptr += 2;
+                                       continue;
+                               }
+
+                               underline = 0;
+                               if (*text_ptr == CC_UNDERLINE )
+                               {
+                                       if ((r==FBASELINE+2) || (r==FBASELINE+3))
+                                               underline = 1;
+                                       text_ptr++;
+                               }
+
+                               get_char_width(text_ptr[0],text_ptr[1],&width,&spacing);
+
+                               letter = *text_ptr-FMINCHAR;
+
+                               if (!INFONT(letter)) {  //not in font, draw as space
+                                       VideoOffset += width;
+                                       text_ptr++;
+                                       continue;
+                               }
+
+                               if (FFLAGS & FT_PROPORTIONAL)
+                                       fp = FCHARS[letter];
+                               else
+                                       fp = FDATA + letter * BITS_TO_BYTES(width)*FHEIGHT;
+
+                               if (underline)
+                               {
+                                       if ( VideoOffset+width > 0xFFFF )
+                                       {
+                                               for (i=0; i< width; i++ )
+                                               {
+                                                       gr_video_memory[VideoOffset++] = FG_COLOR;
+
+                                                       if (VideoOffset > 0xFFFF )
+                                                       {
+                                                               VideoOffset -= 0xFFFF + 1;
+                                                               page_switched = 1;
+                                                               gr_vesa_incpage();
+                                                       }
+                                               }
+                                       }
+                                       else
+                                       {
+                                               for (i=0; i< width; i++ )
+                                                       gr_video_memory[VideoOffset++] = FG_COLOR;
+                                       }
+                               }
+                               else
+                               {
+                                       fp += BITS_TO_BYTES(width)*r;
+
+                                       BitMask = 0;
+
+                                       if ( VideoOffset+width > 0xFFFF )
+                                       {
+                                               for (i=0; i< width; i++ )
+                                               {
+                                                       if (BitMask==0) {
+                                                               bits = *fp++;
+                                                               BitMask = 0x80;
+                                                       }
+
+                                                       if (bits & BitMask)
+                                                               gr_video_memory[VideoOffset++] = FG_COLOR;
+                                                       else
+                                                               VideoOffset++;
+
+                                                       BitMask >>= 1;
+
+                                                       if (VideoOffset > 0xFFFF )
+                                                       {
+                                                               VideoOffset -= 0xFFFF + 1;
+                                                               page_switched = 1;
+                                                               gr_vesa_incpage();
+                                                       }
+
+                                               }
+                                       } else {
+                                               for (i=0; i< width; i++ )
+                                               {
+                                                       if (BitMask==0) {
+                                                               bits = *fp++;
+                                                               BitMask = 0x80;
+                                                       }
+
+                                                       if (bits & BitMask)
+                                                               gr_video_memory[VideoOffset++] = FG_COLOR;
+                                                       else
+                                                               VideoOffset++;;
+                                                       BitMask >>= 1;
+                                               }
+                                       }
+                               }
+                               text_ptr++;
+
+                               VideoOffset += spacing-width;
+                       }
+
+                       y ++;
+                       VideoOffset1 += ROWSIZE;
+
+                       if (VideoOffset1 > 0xFFFF ) {
+                               VideoOffset1 -= 0xFFFF + 1;
+                               if (!page_switched)
+                                       gr_vesa_incpage();
+                       }
+               }
+
+               y += skip_lines;
+               VideoOffset1 += ROWSIZE * skip_lines;
+               skip_lines = 0;
+       }
+       return 0;
+}
+
+#endif // __ENV_MSDOS__
+
+#if defined(POLY_ACC)
+int gr_internal_string5(int x, int y, char *s )
+{
+       unsigned char * fp;
+       ubyte * text_ptr, * next_row, * text_ptr1;
+       int r, BitMask, i, bits, width, spacing, letter, underline;
+       int     skip_lines = 0;
+
+       unsigned int VideoOffset, VideoOffset1;
+
+    pa_flush();
+    VideoOffset1 = y * ROWSIZE + x * PA_BPP;
+
+       next_row = s;
+
+       while (next_row != NULL )
+       {
+               text_ptr1 = next_row;
+               next_row = NULL;
+
+               if (x==0x8000) {                        //centered
+                       int xx = get_centered_x(text_ptr1);
+            VideoOffset1 = y * ROWSIZE + xx * PA_BPP;
+               }
+
+               for (r=0; r<FHEIGHT; r++)
+               {
+
+                       text_ptr = text_ptr1;
+
+                       VideoOffset = VideoOffset1;
+
+                       while (*text_ptr)
+                       {
+                               if (*text_ptr == '\n' )
+                               {
+                                       next_row = &text_ptr[1];
+                                       break;
+                               }
+
+                               if (*text_ptr == CC_COLOR) {
+                                       FG_COLOR = *(text_ptr+1);
+                                       text_ptr += 2;
+                                       continue;
+                               }
+
+                               if (*text_ptr == CC_LSPACING) {
+                                       skip_lines = *(text_ptr+1) - '0';
+                                       text_ptr += 2;
+                                       continue;
+                               }
+
+                               underline = 0;
+                               if (*text_ptr == CC_UNDERLINE )
+                               {
+                                       if ((r==FBASELINE+2) || (r==FBASELINE+3))
+                                               underline = 1;
+                                       text_ptr++;
+                               }
+
+                               get_char_width(text_ptr[0],text_ptr[1],&width,&spacing);
+
+                               letter = *text_ptr-FMINCHAR;
+
+                               if (!INFONT(letter)) {  //not in font, draw as space
+                    VideoOffset += spacing * PA_BPP;
+                                       text_ptr++;
+                                       continue;
+                               }
+
+                               if (FFLAGS & FT_PROPORTIONAL)
+                                       fp = FCHARS[letter];
+                               else
+                                       fp = FDATA + letter * BITS_TO_BYTES(width)*FHEIGHT;
+
+                               if (underline)
+                                       for (i=0; i< width; i++ )
+                    {    *(short *)(DATA + VideoOffset) = pa_clut[FG_COLOR]; VideoOffset += PA_BPP; }
+                               else
+                               {
+                                       fp += BITS_TO_BYTES(width)*r;
+
+                                       BitMask = 0;
+
+                                       for (i=0; i< width; i++ )
+                                       {
+                                               if (BitMask==0) {
+                                                       bits = *fp++;
+                                                       BitMask = 0x80;
+                                               }
+
+                                               if (bits & BitMask)
+                        {    *(short *)(DATA + VideoOffset) = pa_clut[FG_COLOR]; VideoOffset += PA_BPP; }
+                        else
+                        {    *(short *)(DATA + VideoOffset) = pa_clut[BG_COLOR]; VideoOffset += PA_BPP; }
+                        BitMask >>= 1;
+                                       }
+                               }
+
+                VideoOffset += PA_BPP * (spacing-width);       //for kerning
+
+                               text_ptr++;
+                       }
+
+                       VideoOffset1 += ROWSIZE; y++;
+               }
+
+               y += skip_lines;
+               VideoOffset1 += ROWSIZE * skip_lines;
+               skip_lines = 0;
+       }
+       return 0;
+}
+
+int gr_internal_string5m(int x, int y, char *s )
+{
+       unsigned char * fp;
+       ubyte * text_ptr, * next_row, * text_ptr1;
+       int r, BitMask, i, bits, width, spacing, letter, underline;
+       int     skip_lines = 0;
+
+       unsigned int VideoOffset, VideoOffset1;
+
+    pa_flush();
+    VideoOffset1 = y * ROWSIZE + x * PA_BPP;
+
+       next_row = s;
+
+       while (next_row != NULL )
+       {
+               text_ptr1 = next_row;
+               next_row = NULL;
+
+               if (x==0x8000) {                        //centered
+                       int xx = get_centered_x(text_ptr1);
+            VideoOffset1 = y * ROWSIZE + xx * PA_BPP;
+               }
+
+               for (r=0; r<FHEIGHT; r++)
+               {
+
+                       text_ptr = text_ptr1;
+
+                       VideoOffset = VideoOffset1;
+
+                       while (*text_ptr)
+                       {
+                               if (*text_ptr == '\n' )
+                               {
+                                       next_row = &text_ptr[1];
+                                       break;
+                               }
+
+                               if (*text_ptr == CC_COLOR) {
+                                       FG_COLOR = *(text_ptr+1);
+                                       text_ptr += 2;
+                                       continue;
+                               }
+
+                               if (*text_ptr == CC_LSPACING) {
+                                       skip_lines = *(text_ptr+1) - '0';
+                                       text_ptr += 2;
+                                       continue;
+                               }
+
+                               underline = 0;
+                               if (*text_ptr == CC_UNDERLINE )
+                               {
+                                       if ((r==FBASELINE+2) || (r==FBASELINE+3))
+                                               underline = 1;
+                                       text_ptr++;
+                               }
+
+                               get_char_width(text_ptr[0],text_ptr[1],&width,&spacing);
+
+                               letter = *text_ptr-FMINCHAR;
+
+                               if (!INFONT(letter)) {  //not in font, draw as space
+                    VideoOffset += spacing * PA_BPP;
+                                       text_ptr++;
+                                       continue;
+                               }
+
+                               if (FFLAGS & FT_PROPORTIONAL)
+                                       fp = FCHARS[letter];
+                               else
+                                       fp = FDATA + letter * BITS_TO_BYTES(width)*FHEIGHT;
+
+                               if (underline)
+                                       for (i=0; i< width; i++ )
+                    {    *(short *)(DATA + VideoOffset) = pa_clut[FG_COLOR]; VideoOffset += PA_BPP; }
+                else
+                               {
+                                       fp += BITS_TO_BYTES(width)*r;
+
+                                       BitMask = 0;
+
+                                       for (i=0; i< width; i++ )
+                                       {
+                                               if (BitMask==0) {
+                                                       bits = *fp++;
+                                                       BitMask = 0x80;
+                                               }
+
+                                               if (bits & BitMask)
+                        {    *(short *)(DATA + VideoOffset) = pa_clut[FG_COLOR]; VideoOffset += PA_BPP; }
+                        else
+                            VideoOffset += PA_BPP;
+                                               BitMask >>= 1;
+                                       }
+                               }
+                               text_ptr++;
+
+                VideoOffset += PA_BPP * (spacing-width);
+                       }
+
+                       VideoOffset1 += ROWSIZE; y++;
+               }
+               y += skip_lines;
+               VideoOffset1 += ROWSIZE * skip_lines;
+               skip_lines = 0;
+       }
+       return 0;
+}
+#endif
+
+//a bitmap for the character
+grs_bitmap char_bm = {
+                               0,0,0,0,                                                //x,y,w,h
+                               BM_LINEAR,                                      //type
+                               BM_FLAG_TRANSPARENT,            //flags
+                               0,                                                              //rowsize
+                               NULL,                                                   //data
+                               0                                                               //selector
+};
+
+int gr_internal_color_string(int x, int y, char *s )
+{
+       unsigned char * fp;
+       ubyte * text_ptr, * next_row, * text_ptr1;
+       int width, spacing,letter;
+       int xx,yy;
+
+       char_bm.bm_h = FHEIGHT;         //set height for chars of this font
+
+       next_row = s;
+
+       yy = y;
+
+
+       while (next_row != NULL)
+       {
+               text_ptr1 = next_row;
+               next_row = NULL;
+
+               text_ptr = text_ptr1;
+
+               xx = x;
+
+               if (xx==0x8000)                 //centered
+                       xx = get_centered_x(text_ptr);
+
+               while (*text_ptr)
+               {
+                       if (*text_ptr == '\n' )
+                       {
+                               next_row = &text_ptr[1];
+                               yy += FHEIGHT;
+                               break;
+                       }
+
+                       letter = *text_ptr-FMINCHAR;
+
+                       get_char_width(text_ptr[0],text_ptr[1],&width,&spacing);
+
+                       if (!INFONT(letter)) {  //not in font, draw as space
+                               xx += spacing;
+                               text_ptr++;
+                               continue;
+                       }
+
+                       if (FFLAGS & FT_PROPORTIONAL)
+                               fp = FCHARS[letter];
+                       else
+                               fp = FDATA + letter * BITS_TO_BYTES(width)*FHEIGHT;
+
+                       char_bm.bm_w = char_bm.bm_rowsize = width;
+
+                       char_bm.bm_data = fp;
+                       gr_bitmapm(xx,yy,&char_bm);
+
+                       xx += spacing;
+
+                       text_ptr++;
+               }
+
+       }
+       return 0;
+}
+
+int gr_string(int x, int y, char *s )
+{
+       int w, h, aw;
+       int clipped=0;
+
+       Assert(FONT != NULL);
+
+       if ( x == 0x8000 )      {
+               if ( y<0 ) clipped |= 1;
+               gr_get_string_size(s, &w, &h, &aw );
+               // for x, since this will be centered, only look at
+               // width.
+               if ( w > grd_curcanv->cv_bitmap.bm_w ) clipped |= 1;
+               if ( (y+h) > grd_curcanv->cv_bitmap.bm_h ) clipped |= 1;
+
+               if ( (y+h) < 0 ) clipped |= 2;
+               if ( y > grd_curcanv->cv_bitmap.bm_h ) clipped |= 2;
+
+       } else {
+               if ( (x<0) || (y<0) ) clipped |= 1;
+               gr_get_string_size(s, &w, &h, &aw );
+               if ( (x+w) > grd_curcanv->cv_bitmap.bm_w ) clipped |= 1;
+               if ( (y+h) > grd_curcanv->cv_bitmap.bm_h ) clipped |= 1;
+               if ( (x+w) < 0 ) clipped |= 2;
+               if ( (y+h) < 0 ) clipped |= 2;
+               if ( x > grd_curcanv->cv_bitmap.bm_w ) clipped |= 2;
+               if ( y > grd_curcanv->cv_bitmap.bm_h ) clipped |= 2;
+       }
+
+       if ( !clipped )
+               return gr_ustring(x, y, s );
+
+       if ( clipped & 2 )      {
+               // Completely clipped...
+               mprintf( (1, "Text '%s' at (%d,%d) is off screen!\n", s, x, y ));
+               return 0;
+       }
+
+       if ( clipped & 1 )      {
+               // Partially clipped...
+               //mprintf( (0, "Text '%s' at (%d,%d) is getting clipped!\n", s, x, y ));
+       }
+
+       // Partially clipped...
+
+       if (FFLAGS & FT_COLOR)
+               return gr_internal_color_string( x, y, s);
+
+       if ( BG_COLOR == -1)
+               return gr_internal_string_clipped_m( x, y, s );
+
+       return gr_internal_string_clipped( x, y, s );
+}
+
+int gr_ustring(int x, int y, char *s )
+{
+       if (FFLAGS & FT_COLOR) {
+
+               return gr_internal_color_string(x,y,s);
+
+       }
+       else
+               switch( TYPE )
+               {
+               case BM_LINEAR:
+                       if ( BG_COLOR == -1)
+                               return gr_internal_string0m(x,y,s);
+                       else
+                               return gr_internal_string0(x,y,s);
+#ifdef __ENV_MSDOS__
+               case BM_SVGA:
+                       if ( BG_COLOR == -1)
+                               return gr_internal_string2m(x,y,s);
+                       else
+                               return gr_internal_string2(x,y,s);
+#endif // __ENV_MSDOS__
+#if defined(POLY_ACC)
+        case BM_LINEAR15:
+                       if ( BG_COLOR == -1)
+                return gr_internal_string5m(x,y,s);
+                       else
+                return gr_internal_string5(x,y,s);
+#endif
+        }
+
+       return 0;
+}
+
+
+void gr_get_string_size(char *s, int *string_width, int *string_height, int *average_width )
+{
+       int i = 0, longest_width = 0;
+       int width,spacing;
+
+       *string_height = FHEIGHT;
+       *string_width = 0;
+       *average_width = FWIDTH;
+
+       if (s != NULL )
+       {
+               *string_width = 0;
+               while (*s)
+               {
+//                     if (*s == CC_UNDERLINE)
+//                             s++;
+                       while (*s == '\n')
+                       {
+                               s++;
+                               *string_height += FHEIGHT;
+                               *string_width = 0;
+                       }
+
+                       if (*s == 0) break;
+
+                       //      1 = next byte specifies color, so skip the 1 and the color value
+                       if (*s == CC_COLOR)
+                               s += 2;
+                       else if (*s == CC_LSPACING) {
+                               *string_height += *(s+1)-'0';
+                               s += 2;
+                       } else {
+                               get_char_width(s[0],s[1],&width,&spacing);
+                               *string_width += spacing;
+                               if (*string_width > longest_width)
+                                       longest_width = *string_width;
+                               i++;
+                               s++;
+                       }
+               }
+       }
+       *string_width = longest_width;
+}
+
+
+int gr_uprintf( int x, int y, char * format, ... )
+{
+       char buffer[1000];
+       va_list args;
+
+       va_start(args, format );
+       vsprintf(buffer,format,args);
+       return gr_ustring( x, y, buffer );
+}
+
+int gr_printf( int x, int y, char * format, ... )
+{
+       char buffer[1000];
+       va_list args;
+
+       va_start(args, format );
+       vsprintf(buffer,format,args);
+       return gr_string( x, y, buffer );
+}
+
+void gr_close_font( grs_font * font )
+{
+       if (font)
+       {
+               int fontnum;
+
+               //find font in list
+               for (fontnum=0;fontnum<MAX_OPEN_FONTS && open_font[fontnum].ptr!=font;fontnum++);
+               Assert(fontnum<MAX_OPEN_FONTS); //did we find slot?
+
+               open_font[fontnum].ptr = NULL;
+
+               if ( font->ft_chars )
+                       d_free( font->ft_chars );
+               d_free( font );
+
+       }
+}
+
+//remap (by re-reading) all the color fonts
+void gr_remap_color_fonts()
+{
+       int fontnum;
+
+       for (fontnum=0;fontnum<MAX_OPEN_FONTS;fontnum++) {
+               grs_font *font;
+
+               font = open_font[fontnum].ptr;
+
+               if (font && (font->ft_flags & FT_COLOR))
+                       gr_remap_font(font,open_font[fontnum].filename);
+       }
+}
+
+void build_colormap_good( ubyte * palette, ubyte * colormap, int * freq );
+void decode_data_asm(ubyte *data, int num_pixels, ubyte * colormap, int * count );
+#ifdef __WATCOMC__
+#pragma aux decode_data_asm parm [esi] [ecx] [edi] [ebx] modify exact [esi edi eax ebx ecx] = \
+"again_ddn:"                                                   \
+       "xor    eax,eax"                                \
+       "mov    al,[esi]"                       \
+       "inc    dword ptr [ebx+eax*4]"          \
+       "mov    al,[edi+eax]"           \
+       "mov    [esi],al"                       \
+       "inc    esi"                                    \
+       "dec    ecx"                                    \
+       "jne    again_ddn"
+
+#endif
+
+grs_font * gr_init_font( char * fontname )
+{
+       static int first_time=1;
+       grs_font *font;
+       int i,fontnum;
+       unsigned char * ptr;
+       int nchars;
+       CFILE *fontfile;
+       char file_id[4];
+       int datasize;           //size up to (but not including) palette
+
+       if (first_time) {
+               int i;
+               for (i=0;i<MAX_OPEN_FONTS;i++)
+                       open_font[i].ptr = NULL;
+               first_time=0;
+       }
+
+       //find free font slot
+       for (fontnum=0;fontnum<MAX_OPEN_FONTS && open_font[fontnum].ptr!=NULL;fontnum++);
+       Assert(fontnum<MAX_OPEN_FONTS); //did we find one?
+
+       strncpy(open_font[fontnum].filename,fontname,FILENAME_LEN);
+
+       fontfile = cfopen(fontname, "rb");
+
+       if (!fontfile)
+               Error( "Can't open font file %s", fontname );
+
+       cfread( file_id, 1, 4, fontfile );
+       datasize = cfile_read_int(fontfile);
+       
+
+       if ((file_id[0] != 'P') ||
+           (file_id[1] != 'S') ||
+           (file_id[2] != 'F') ||
+           (file_id[3] != 'N'))
+               Error( "File %s is not a font file", fontname );
+
+       font = (grs_font *) d_malloc(datasize);
+
+       open_font[fontnum].ptr = font;
+
+       cfread(font,1,datasize,fontfile);
+
+#ifdef MACINTOSH
+// gotta translate those endian things
+
+       font->ft_w = SWAPSHORT(font->ft_w);
+       font->ft_h = SWAPSHORT(font->ft_h);
+       font->ft_flags = SWAPSHORT(font->ft_flags);
+       font->ft_bytewidth = SWAPSHORT(font->ft_bytewidth);
+       font->ft_data = (ubyte *)SWAPINT((int)(font->ft_data));
+       font->ft_chars = (ubyte **)SWAPINT((int)(font->ft_chars));
+       font->ft_widths = (short *)SWAPINT((int)(font->ft_widths));
+       font->ft_kerndata = (ubyte *)SWAPINT((int)(font->ft_kerndata));
+#endif
+
+       nchars = font->ft_maxchar-font->ft_minchar+1;
+
+       if (font->ft_flags & FT_PROPORTIONAL) {
+
+               font->ft_widths = (short *) (((int) font->ft_widths) + ((ubyte *) font));
+
+#ifdef MACINTOSH
+               for (i = 0; i < nchars; i++)
+                       font->ft_widths[i] = SWAPSHORT(font->ft_widths[i]);
+#endif
+
+               font->ft_data = ((int) font->ft_data) + ((ubyte *) font);
+
+               font->ft_chars = (unsigned char **)d_malloc( nchars * sizeof(unsigned char *));
+
+               ptr = font->ft_data;
+
+               for (i=0; i< nchars; i++ ) {
+                       font->ft_chars[i] = ptr;
+                       if (font->ft_flags & FT_COLOR)
+                               ptr += font->ft_widths[i] * font->ft_h;
+                       else
+                               ptr += BITS_TO_BYTES(font->ft_widths[i]) * font->ft_h;
+               }
+
+       } else  {
+
+               font->ft_data = ((unsigned char *) font) + sizeof(*font);
+
+               font->ft_chars  = NULL;
+               font->ft_widths = NULL;
+
+               ptr = font->ft_data + (nchars * font->ft_w * font->ft_h);
+       }
+
+       if (font->ft_flags & FT_KERNED)
+               font->ft_kerndata = ((int) font->ft_kerndata) + ((ubyte *) font);
+
+
+       if (font->ft_flags & FT_COLOR) {                //remap palette
+               ubyte palette[256*3];
+               ubyte colormap[256];
+               int freq[256];
+
+               cfread(palette,3,256,fontfile);         //read the palette
+
+#ifdef MACINTOSH                       // swap the first and last palette entries (black and white)
+               {
+                       int i;
+                       ubyte c;
+
+                       for (i = 0; i < 3; i++) {
+                               c = palette[i];
+                               palette[i] = palette[765+i];
+                               palette[765+i] = c;
+                       }
+
+//  we also need to swap the data entries as well.  black is white and white is black
+
+                       for (i = 0; i < ptr-font->ft_data; i++) {
+                               if (font->ft_data[i] == 0)
+                                       font->ft_data[i] = 255;
+                               else if (font->ft_data[i] == 255)
+                                       font->ft_data[i] = 0;
+                       }
+
+               }
+#endif
+
+               build_colormap_good( (ubyte *)&palette, colormap, freq );
+
+               colormap[TRANSPARENCY_COLOR] = TRANSPARENCY_COLOR;              // chaged from colormap[255] = 255 to this for macintosh
+
+               decode_data_asm(font->ft_data, ptr-font->ft_data, colormap, freq );
+
+       }
+
+       cfclose(fontfile);
+
+       //set curcanv vars
+
+       FONT        = font;
+       FG_COLOR    = 0;
+       BG_COLOR    = 0;
+
+       return font;
+
+}
+
+//remap a font by re-reading its data & palette
+void gr_remap_font( grs_font *font, char * fontname )
+{
+       int i;
+       int nchars;
+       CFILE *fontfile;
+       char file_id[4];
+       int datasize;           //size up to (but not including) palette
+       int data_ofs,data_len;
+
+       if (! (font->ft_flags & FT_COLOR))
+               return;
+
+       fontfile = cfopen(fontname, "rb");
+
+       if (!fontfile)
+               Error( "Can't open font file %s", fontname );
+
+       cfread( file_id, 1, 4, fontfile );
+       datasize = cfile_read_int(fontfile);
+       
+
+       if ((file_id[0] != 'P') ||
+           (file_id[1] != 'S') ||
+           (file_id[2] != 'F') ||
+           (file_id[3] != 'N'))
+               Error( "File %s is not a font file", fontname );
+
+       nchars = font->ft_maxchar-font->ft_minchar+1;
+
+       //compute data length
+       data_len = 0;
+       if (font->ft_flags & FT_PROPORTIONAL) {
+
+               for (i=0; i< nchars; i++ ) {
+                       if (font->ft_flags & FT_COLOR)
+                               data_len += font->ft_widths[i] * font->ft_h;
+                       else
+                               data_len += BITS_TO_BYTES(font->ft_widths[i]) * font->ft_h;
+               }
+
+       } else
+               data_len = nchars * font->ft_w * font->ft_h;
+
+       data_ofs = font->ft_data - ((ubyte *) font);
+
+       cfseek(fontfile,data_ofs,SEEK_CUR);
+       cfread(font->ft_data,1,data_len,fontfile);              //read raw data
+
+       if (font->ft_flags & FT_COLOR) {                //remap palette
+               ubyte palette[256*3];
+               ubyte colormap[256];
+               int freq[256];
+
+               cfseek(fontfile,-sizeof(palette),SEEK_END);
+
+               cfread(palette,3,256,fontfile);         //read the palette
+
+#ifdef MACINTOSH                       // swap the first and last palette entries (black and white)
+               {
+                       int i;
+                       ubyte c;
+
+                       for (i = 0; i < 3; i++) {
+                               c = palette[i];
+                               palette[i] = palette[765+i];
+                               palette[765+i] = c;
+                       }
+
+//  we also need to swap the data entries as well.  black is white and white is black
+
+                       for (i = 0; i < data_len; i++) {
+                               if (font->ft_data[i] == 0)
+                                       font->ft_data[i] = 255;
+                               else if (font->ft_data[i] == 255)
+                                       font->ft_data[i] = 0;
+                       }
+
+               }
+#endif
+
+               build_colormap_good( (ubyte *)&palette, colormap, freq );
+
+               colormap[TRANSPARENCY_COLOR] = TRANSPARENCY_COLOR;      // changed from         colormap[255] = 255;
+
+               decode_data_asm(font->ft_data, data_len, colormap, freq );
+
+
+       }
+
+       cfclose(fontfile);
+}
+
+
+void gr_set_fontcolor( int fg, int bg )
+{
+       FG_COLOR    = fg;
+       BG_COLOR    = bg;
+}
+
+void gr_set_curfont( grs_font * new )
+{
+       FONT = new;
+}
+
+
+int gr_internal_string_clipped(int x, int y, char *s )
+{
+       unsigned char * fp;
+       char * text_ptr, * next_row, * text_ptr1;
+       int r, BitMask, i, bits, width, spacing, letter, underline;
+       int x1 = x, last_x;
+
+       next_row = s;
+
+       while (next_row != NULL )
+       {
+               text_ptr1 = next_row;
+               next_row = NULL;
+
+               x = x1;
+               if (x==0x8000)                  //centered
+                       x = get_centered_x(text_ptr1);
+
+               last_x = x;
+
+               for (r=0; r<FHEIGHT; r++)       {
+                       text_ptr = text_ptr1;
+                       x = last_x;
+
+                       while (*text_ptr)       {
+                               if (*text_ptr == '\n' ) {
+                                       next_row = &text_ptr[1];
+                                       break;
+                               }
+
+                               if (*text_ptr == CC_COLOR) {
+                                       FG_COLOR = *(text_ptr+1);
+                                       text_ptr += 2;
+                                       continue;
+                               }
+
+                               if (*text_ptr == CC_LSPACING) {
+                                       Int3(); //      Warning: skip lines not supported for clipped strings.
+                                       text_ptr += 2;
+                                       continue;
+                               }
+
+                               underline = 0;
+                               if (*text_ptr == CC_UNDERLINE ) {
+                                       if ((r==FBASELINE+2) || (r==FBASELINE+3))
+                                               underline = 1;
+                                       text_ptr++;
+                               }
+
+                               get_char_width(text_ptr[0],text_ptr[1],&width,&spacing);
+
+                               letter = *text_ptr-FMINCHAR;
+
+                               if (!INFONT(letter)) {  //not in font, draw as space
+                                       x += spacing;
+                                       text_ptr++;
+                                       continue;
+                               }
+
+                               if (FFLAGS & FT_PROPORTIONAL)
+                                       fp = FCHARS[letter];
+                               else
+                                       fp = FDATA + letter * BITS_TO_BYTES(width)*FHEIGHT;
+
+                               if (underline)  {
+                                       for (i=0; i< width; i++ )       {
+                                               gr_setcolor(FG_COLOR);
+                                               gr_pixel( x++, y );
+                                       }
+                               } else {
+                                       fp += BITS_TO_BYTES(width)*r;
+
+                                       BitMask = 0;
+
+                                       for (i=0; i< width; i++ )       {
+                                               if (BitMask==0) {
+                                                       bits = *fp++;
+                                                       BitMask = 0x80;
+                                               }
+                                               if (bits & BitMask)
+                                                       gr_setcolor(FG_COLOR);
+                                               else
+                                                       gr_setcolor(BG_COLOR);
+                                               gr_pixel( x++, y );
+                                               BitMask >>= 1;
+                                       }
+                               }
+
+                               x += spacing-width;             //for kerning
+
+                               text_ptr++;
+                       }
+                       y++;
+               }
+       }
+       return 0;
+}
+
+int gr_internal_string_clipped_m(int x, int y, char *s )
+{
+       unsigned char * fp;
+       char * text_ptr, * next_row, * text_ptr1;
+       int r, BitMask, i, bits, width, spacing, letter, underline;
+       int x1 = x, last_x;
+
+       next_row = s;
+
+       while (next_row != NULL )
+       {
+               text_ptr1 = next_row;
+               next_row = NULL;
+
+               x = x1;
+               if (x==0x8000)                  //centered
+                       x = get_centered_x(text_ptr1);
+
+               last_x = x;
+
+               for (r=0; r<FHEIGHT; r++)       {
+                       x = last_x;
+
+                       text_ptr = text_ptr1;
+
+                       while (*text_ptr)       {
+                               if (*text_ptr == '\n' ) {
+                                       next_row = &text_ptr[1];
+                                       break;
+                               }
+
+                               if (*text_ptr == CC_COLOR) {
+                                       FG_COLOR = *(text_ptr+1);
+                                       text_ptr += 2;
+                                       continue;
+                               }
+
+                               if (*text_ptr == CC_LSPACING) {
+                                       Int3(); //      Warning: skip lines not supported for clipped strings.